mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
31 lines
861 B
JavaScript
31 lines
861 B
JavaScript
import ButtonWidget from "./button_widget.js";
|
|
import appContext from "../../services/app_context.js";
|
|
|
|
export default class EditButton extends ButtonWidget {
|
|
isEnabled() {
|
|
return super.isEnabled() && this.noteContext;
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
|
|
this.icon("bx-edit-alt")
|
|
.title("Edit this note")
|
|
.titlePlacement("bottom")
|
|
.onClick(widget => {
|
|
this.noteContext.readOnlyTemporarilyDisabled = true;
|
|
|
|
appContext.triggerEvent('readOnlyTemporarilyDisabled', {noteContext: this.noteContext});
|
|
|
|
this.refresh();
|
|
});
|
|
}
|
|
|
|
async refreshWithNote(note) {
|
|
// can't do this in isEnabled() since isReadOnly is async
|
|
this.toggleInt(await this.noteContext.isReadOnly());
|
|
|
|
await super.refreshWithNote(note);
|
|
}
|
|
}
|