diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 2723796d7..89c0a69b8 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -477,7 +477,10 @@ class Editor: ord = int(num) fld = self.note.model()["flds"][ord] - fld["sticky"] = not fld["sticky"] + new_state = not fld["sticky"] + fld["sticky"] = new_state + + return new_state def mungeHTML(self, txt: str) -> str: return gui_hooks.editor_will_munge_html(txt, self) diff --git a/ts/editor/editor.scss b/ts/editor/editor.scss index f7c151420..0f9a93454 100644 --- a/ts/editor/editor.scss +++ b/ts/editor/editor.scss @@ -143,8 +143,4 @@ button.highlighted { .nightMode & { color: var(--bs-light); } - - &.is-active { - color: var(--bs-danger); - } } diff --git a/ts/editor/labelContainer.ts b/ts/editor/labelContainer.ts index 3d622ed69..40e6046a5 100644 --- a/ts/editor/labelContainer.ts +++ b/ts/editor/labelContainer.ts @@ -9,7 +9,7 @@ export class LabelContainer extends HTMLDivElement { this.className = "d-flex"; this.sticky = document.createElement("span"); - this.sticky.className = "bi bi-pin-angle-fill me-1 sticky-icon"; + this.sticky.className = "bi me-1 sticky-icon"; this.sticky.hidden = true; this.appendChild(this.sticky); @@ -32,14 +32,22 @@ export class LabelContainer extends HTMLDivElement { this.label.innerText = labelName; } + setSticky(state: boolean): void { + this.sticky.classList.toggle("bi-lock-fill", state); + this.sticky.classList.toggle("bi-unlock-fill", !state); + } + activateSticky(initialState: boolean): void { - this.sticky.classList.toggle("is-active", initialState); + this.setSticky(initialState); this.sticky.hidden = false; } toggleSticky(): void { - bridgeCommand(`toggleSticky:${this.getAttribute("ord")}`, () => { - this.sticky.classList.toggle("is-active"); - }); + bridgeCommand( + `toggleSticky:${this.getAttribute("ord")}`, + (newState: boolean): void => { + this.setSticky(newState); + } + ); } }