mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-01 04:32:26 +08:00
30 lines
799 B
JavaScript
30 lines
799 B
JavaScript
![]() |
import ButtonWidget from "./button_widget.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;
|
||
|
|
||
|
this.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);
|
||
|
}
|
||
|
}
|