Replace pin icon with lock icon

Credit goes out to @kleinerpirat
This commit is contained in:
Henrik Giesel 2021-02-28 18:46:43 +01:00
parent ebf423bc9c
commit da0317cb85
3 changed files with 17 additions and 10 deletions

View File

@ -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)

View File

@ -143,8 +143,4 @@ button.highlighted {
.nightMode & {
color: var(--bs-light);
}
&.is-active {
color: var(--bs-danger);
}
}

View File

@ -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);
}
);
}
}