forked from zadam/trilium
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from SiriusXT/highlightslits
Toc and Highlightslist improvement
- Loading branch information
Showing
6 changed files
with
273 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/public/app/widgets/buttons/show_highlights_list_widget_button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
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) { | ||
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
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) { | ||
this.toggleInt(this.noteContext.viewScope.tocTemporarilyHidden); | ||
} | ||
async reEvaluateTocWidgetVisibilityEvent({ 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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.