mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-09 17:52:32 +08:00
client: Hide ribbon for non text or read-only notes
This commit is contained in:
parent
787aa6f5a6
commit
b88f0e0109
@ -216,7 +216,7 @@ export default class RibbonContainer extends NoteContextAwareWidget {
|
|||||||
this.$tabContainer.empty();
|
this.$tabContainer.empty();
|
||||||
|
|
||||||
for (const ribbonWidget of this.ribbonWidgets) {
|
for (const ribbonWidget of this.ribbonWidgets) {
|
||||||
const ret = ribbonWidget.getTitle(note);
|
const ret = await ribbonWidget.getTitle(note);
|
||||||
|
|
||||||
if (!ret.show) {
|
if (!ret.show) {
|
||||||
continue;
|
continue;
|
||||||
@ -351,6 +351,16 @@ export default class RibbonContainer extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executed as soon as the user presses the "Edit" floating button in a read-only text note.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* We need to refresh the ribbon for cases such as the classic editor which relies on the read-only state.
|
||||||
|
*/
|
||||||
|
readOnlyTemporarilyDisabledEvent() {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
getActiveRibbonWidget() {
|
getActiveRibbonWidget() {
|
||||||
return this.ribbonWidgets.find(ch => ch.componentId === this.lastActiveComponentId)
|
return this.ribbonWidgets.find(ch => ch.componentId === this.lastActiveComponentId)
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,25 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
|
|||||||
this.contentSized();
|
this.contentSized();
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitle(note) {
|
async getTitle() {
|
||||||
return {
|
return {
|
||||||
show: true,
|
show: await this.#shouldDisplay(),
|
||||||
activate: true,
|
activate: true,
|
||||||
title: "Editor toolbar",
|
title: "Editor toolbar",
|
||||||
icon: "bx bx-edit-alt"
|
icon: "bx bx-edit-alt"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async #shouldDisplay() {
|
||||||
|
if (this.note.type !== "text") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await this.noteContext.isReadOnly()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user