Show highlighted text in the right pane

This commit is contained in:
SiriusXT
2023-06-01 20:17:00 +08:00
parent 92d5aeae41
commit ecfdde2f2a
3 changed files with 94 additions and 120 deletions

View File

@@ -80,6 +80,16 @@ export default class TocWidget extends RightPanelWidget {
}
async refreshWithNote(note) {
/*The reason for adding tocTemporarilyHiddenPrevious is to record whether the previous state of the toc is hidden or displayed,
* and then let it be displayed/hidden at the initial time. If there is no such value,
* when the right panel needs to display highlighttext but not toc, every time the note content is changed,
* toc will appear and then close immediately, because getToc(html) function will consume time*/
if (this.noteContext.viewScope.tocTemporarilyHiddenPrevious ==true){
this.toggleInt(true);
}else{
this.toggleInt(false);
}
const tocLabel = note.getLabel('toc');
if (tocLabel?.value === 'hide') {
@@ -96,10 +106,13 @@ export default class TocWidget extends RightPanelWidget {
}
this.$toc.html($toc);
this.toggleInt(
["", "show"].includes(tocLabel?.value)
|| headingCount >= options.getInt('minTocHeadings')
);
if (["", "show"].includes(tocLabel?.value) || headingCount >= options.getInt('minTocHeadings')){
this.toggleInt(true);
this.noteContext.viewScope.tocTemporarilyHiddenPrevious=true;
}else{
this.toggleInt(false);
this.noteContext.viewScope.tocTemporarilyHiddenPrevious=false;
}
this.triggerCommand("reEvaluateRightPaneVisibility");
}