mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Add toggle for mode indicator with set modeindicator true|false
This commit is contained in:
parent
47409e4fd2
commit
e9f6afeb9c
2 changed files with 32 additions and 26 deletions
|
@ -221,6 +221,7 @@ const DEFAULTS = o({
|
|||
cursorpos: "end",
|
||||
|
||||
theme: "default", // currently available: "default", "dark"
|
||||
modeindicator: "true",
|
||||
|
||||
// Default logging levels - 2 === WARNING
|
||||
logging: o({
|
||||
|
|
|
@ -69,32 +69,37 @@ if (
|
|||
}
|
||||
|
||||
// Really bad status indicator
|
||||
let statusIndicator = document.createElement("span")
|
||||
statusIndicator.className = "cleanslate TridactylStatusIndicator"
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
statusIndicator.textContent = state.mode || "normal"
|
||||
document.body.appendChild(statusIndicator)
|
||||
})
|
||||
config.getAsync("modeindicator").then(mode => {
|
||||
if (mode !== "true") return
|
||||
|
||||
browser.storage.onChanged.addListener((changes, areaname) => {
|
||||
if (areaname === "local" && "state" in changes) {
|
||||
let mode = changes.state.newValue.mode
|
||||
if (
|
||||
dom.isTextEditable(document.activeElement) &&
|
||||
!["input", "ignore"].includes(mode)
|
||||
) {
|
||||
statusIndicator.textContent = "insert"
|
||||
// this doesn't work; statusIndicator.style is full of empty string
|
||||
// statusIndicator.style.borderColor = "green !important"
|
||||
// need to fix loss of focus by click: doesn't do anything here.
|
||||
} else if (
|
||||
mode === "insert" &&
|
||||
!dom.isTextEditable(document.activeElement)
|
||||
) {
|
||||
statusIndicator.textContent = "normal"
|
||||
// statusIndicator.style.borderColor = "lightgray !important"
|
||||
} else {
|
||||
statusIndicator.textContent = mode
|
||||
let statusIndicator = document.createElement("span")
|
||||
statusIndicator.className = "cleanslate TridactylStatusIndicator"
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
statusIndicator.textContent = state.mode || "normal"
|
||||
document.body.appendChild(statusIndicator)
|
||||
})
|
||||
|
||||
browser.storage.onChanged.addListener((changes, areaname) => {
|
||||
if (areaname === "local" && "state" in changes) {
|
||||
let mode = changes.state.newValue.mode
|
||||
if (
|
||||
dom.isTextEditable(document.activeElement) &&
|
||||
!["input", "ignore"].includes(mode)
|
||||
) {
|
||||
statusIndicator.textContent = "insert"
|
||||
// this doesn't work; statusIndicator.style is full of empty string
|
||||
// statusIndicator.style.borderColor = "green !important"
|
||||
// need to fix loss of focus by click: doesn't do anything here.
|
||||
} else if (
|
||||
mode === "insert" &&
|
||||
!dom.isTextEditable(document.activeElement)
|
||||
) {
|
||||
statusIndicator.textContent = "normal"
|
||||
// statusIndicator.style.borderColor = "lightgray !important"
|
||||
} else {
|
||||
statusIndicator.textContent = mode
|
||||
}
|
||||
}
|
||||
}
|
||||
if (config.get("modeindicator") !== "true") statusIndicator.remove()
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue