added "edit" button into ribbon button container

This commit is contained in:
zadam
2021-06-15 22:59:13 +02:00
parent 2220c4491b
commit 02da5b598c
7 changed files with 65 additions and 43 deletions

View File

@@ -0,0 +1,31 @@
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());
console.log("await this.noteContext.isReadOnly()", await this.noteContext.isReadOnly());
await super.refreshWithNote(note);
}
}