mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Make toc/hightlightslist reopen after it's closed
This commit is contained in:
parent
98c9e25124
commit
31aa6feb0c
@ -38,6 +38,8 @@ import SimilarNotesWidget from "../widgets/ribbon_widgets/similar_notes.js";
|
|||||||
import RightPaneContainer from "../widgets/containers/right_pane_container.js";
|
import RightPaneContainer from "../widgets/containers/right_pane_container.js";
|
||||||
import EditButton from "../widgets/buttons/edit_button.js";
|
import EditButton from "../widgets/buttons/edit_button.js";
|
||||||
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
|
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
|
||||||
|
import ShowTocWidgetButton from "../widgets/buttons/show_toc_widget_button.js";
|
||||||
|
import ShowHighlightsListWidgetButton from "../widgets/buttons/show_highlights_list_widget_button.js";
|
||||||
import MermaidWidget from "../widgets/mermaid.js";
|
import MermaidWidget from "../widgets/mermaid.js";
|
||||||
import NoteWrapperWidget from "../widgets/note_wrapper.js";
|
import NoteWrapperWidget from "../widgets/note_wrapper.js";
|
||||||
import BacklinksWidget from "../widgets/floating_buttons/zpetne_odkazy.js";
|
import BacklinksWidget from "../widgets/floating_buttons/zpetne_odkazy.js";
|
||||||
@ -160,6 +162,8 @@ export default class DesktopLayout {
|
|||||||
.child(new WatchedFileUpdateStatusWidget())
|
.child(new WatchedFileUpdateStatusWidget())
|
||||||
.child(new FloatingButtons()
|
.child(new FloatingButtons()
|
||||||
.child(new EditButton())
|
.child(new EditButton())
|
||||||
|
.child(new ShowTocWidgetButton())
|
||||||
|
.child(new ShowHighlightsListWidgetButton())
|
||||||
.child(new CodeButtonsWidget())
|
.child(new CodeButtonsWidget())
|
||||||
.child(new RelationMapButtons())
|
.child(new RelationMapButtons())
|
||||||
.child(new CopyImageReferenceButton())
|
.child(new CopyImageReferenceButton())
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
import OnClickButtonWidget from "./onclick_button.js";
|
||||||
|
import appContext from "../../components/app_context.js";
|
||||||
|
import attributeService from "../../services/attributes.js";
|
||||||
|
import { t } from "../../services/i18n.js";
|
||||||
|
|
||||||
|
export default class ShowHighlightsListWidgetButton extends OnClickButtonWidget {
|
||||||
|
isEnabled() {
|
||||||
|
return super.isEnabled()
|
||||||
|
&& this.note
|
||||||
|
&& this.note.type === 'text'
|
||||||
|
&& this.noteContext.viewScope.viewMode === 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.icon("bx-highlight")
|
||||||
|
.title(t("show_highlights_list_widget_button.show_highlights_list"))
|
||||||
|
.titlePlacement("bottom")
|
||||||
|
.onClick(widget => {
|
||||||
|
this.noteContext.viewScope.highlightsListTemporarilyHidden = false;
|
||||||
|
appContext.triggerEvent("showHighlightsListWidget", { noteId: this.noteId });
|
||||||
|
this.toggleInt(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async refreshWithNote(note) {
|
||||||
|
console.log(222)
|
||||||
|
this.toggleInt(this.noteContext.viewScope.highlightsListTemporarilyHidden);
|
||||||
|
}
|
||||||
|
async reEvaluateHighlightsListWidgetVisibilityEvent({ noteId }) {
|
||||||
|
if (noteId === this.noteId) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async entitiesReloadedEvent({ loadResults }) {
|
||||||
|
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
||||||
|
await this.refresh();
|
||||||
|
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
||||||
|
&& (attr.name.toLowerCase().includes('readonly') || attr.name === 'hideHighlightWidget')
|
||||||
|
&& attributeService.isAffecting(attr, this.note))) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async noteTypeMimeChangedEvent({ noteId }) {
|
||||||
|
if (this.isNote(noteId)) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
src/public/app/widgets/buttons/show_toc_widget_button.js
Normal file
52
src/public/app/widgets/buttons/show_toc_widget_button.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import OnClickButtonWidget from "./onclick_button.js";
|
||||||
|
import appContext from "../../components/app_context.js";
|
||||||
|
import attributeService from "../../services/attributes.js";
|
||||||
|
import { t } from "../../services/i18n.js";
|
||||||
|
|
||||||
|
export default class ShowTocWidgetButton extends OnClickButtonWidget {
|
||||||
|
isEnabled() {
|
||||||
|
return super.isEnabled()
|
||||||
|
&& this.note
|
||||||
|
&& this.note.type === 'text'
|
||||||
|
&& this.noteContext.viewScope.viewMode === 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.icon("bx-objects-horizontal-left")
|
||||||
|
.title(t("show_toc_widget_button.show_toc"))
|
||||||
|
.titlePlacement("bottom")
|
||||||
|
.onClick(widget => {
|
||||||
|
this.noteContext.viewScope.tocTemporarilyHidden = false;
|
||||||
|
appContext.triggerEvent("showTocWidget", { noteId: this.noteId });
|
||||||
|
this.toggleInt(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async refreshWithNote(note) {
|
||||||
|
console.log(213)
|
||||||
|
this.toggleInt(this.noteContext.viewScope.tocTemporarilyHidden);
|
||||||
|
}
|
||||||
|
async reEvaluateTocWidgetVisibilityEvent({ noteId }) {
|
||||||
|
console.log("noteId", noteId)
|
||||||
|
if (noteId === this.noteId) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async entitiesReloadedEvent({ loadResults }) {
|
||||||
|
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
||||||
|
await this.refresh();
|
||||||
|
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
||||||
|
&& (attr.name.toLowerCase().includes('readonly') || attr.name === 'toc')
|
||||||
|
&& attributeService.isAffecting(attr, this.note))) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async noteTypeMimeChangedEvent({ noteId }) {
|
||||||
|
if (this.isNote(noteId)) {
|
||||||
|
await this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -318,6 +318,14 @@ export default class HighlightsListWidget extends RightPanelWidget {
|
|||||||
this.noteContext.viewScope.highlightsListTemporarilyHidden = true;
|
this.noteContext.viewScope.highlightsListTemporarilyHidden = true;
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.triggerCommand('reEvaluateRightPaneVisibility');
|
this.triggerCommand('reEvaluateRightPaneVisibility');
|
||||||
|
appContext.triggerEvent("reEvaluateHighlightsListWidgetVisibility", { noteId: this.noteId });
|
||||||
|
}
|
||||||
|
|
||||||
|
async showHighlightsListWidgetEvent({ noteId }) {
|
||||||
|
if (this.noteId === noteId) {
|
||||||
|
await this.refresh();
|
||||||
|
this.triggerCommand('reEvaluateRightPaneVisibility');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async entitiesReloadedEvent({ loadResults }) {
|
async entitiesReloadedEvent({ loadResults }) {
|
||||||
|
@ -275,9 +275,17 @@ export default class TocWidget extends RightPanelWidget {
|
|||||||
this.noteContext.viewScope.tocTemporarilyHidden = true;
|
this.noteContext.viewScope.tocTemporarilyHidden = true;
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.triggerCommand('reEvaluateRightPaneVisibility');
|
this.triggerCommand('reEvaluateRightPaneVisibility');
|
||||||
|
appContext.triggerEvent("reEvaluateTocWidgetVisibility", { noteId: this.noteId });
|
||||||
}
|
}
|
||||||
|
|
||||||
async entitiesReloadedEvent({loadResults}) {
|
async showTocWidgetEvent({ noteId }) {
|
||||||
|
if (this.noteId === noteId) {
|
||||||
|
await this.refresh();
|
||||||
|
this.triggerCommand('reEvaluateRightPaneVisibility');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async entitiesReloadedEvent({ loadResults }) {
|
||||||
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
if (loadResults.isNoteContentReloaded(this.noteId)) {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
} else if (loadResults.getAttributeRows().find(attr => attr.type === 'label'
|
||||||
|
@ -567,6 +567,12 @@
|
|||||||
"edit_button": {
|
"edit_button": {
|
||||||
"edit_this_note": "Edit this note"
|
"edit_this_note": "Edit this note"
|
||||||
},
|
},
|
||||||
|
"show_toc_widget_button": {
|
||||||
|
"show_toc": "Show Table of Contents"
|
||||||
|
},
|
||||||
|
"show_highlights_list_widget_button": {
|
||||||
|
"show_highlights_list": "Show Highlights List"
|
||||||
|
},
|
||||||
"global_menu": {
|
"global_menu": {
|
||||||
"menu": "Menu",
|
"menu": "Menu",
|
||||||
"options": "Options",
|
"options": "Options",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user