diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.ts index 22391b430..8e7b3c9b8 100644 --- a/src/public/app/components/app_context.ts +++ b/src/public/app/components/app_context.ts @@ -77,6 +77,7 @@ export type CommandMappings = { searchString?: string; ancestorNoteId?: string | null; }; + closeTocCommand: CommandData; showLaunchBarSubtree: CommandData; showOptions: CommandData & { section: string; @@ -206,6 +207,8 @@ export type CommandMappings = { zoomFactor: string; } + reEvaluateRightPaneVisibility: CommandData; + // Geomap deleteFromMap: { noteId: string }, openGeoLocation: { noteId: string, event: JQuery.MouseDownEvent } @@ -266,6 +269,9 @@ type EventMappings = { reEvaluateHighlightsListWidgetVisibility: { noteId: string | undefined; }; + reEvaluateTocWidgetVisibility: { + noteId: string | undefined; + }; showHighlightsListWidget: { noteId: string; }; @@ -301,7 +307,10 @@ type EventMappings = { }; refreshNoteList: { noteId: string; - } + }; + showToc: { + noteId: string; + }; }; export type EventListener = { diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts index f80a3c10a..3279ed5cf 100644 --- a/src/public/app/services/link.ts +++ b/src/public/app/services/link.ts @@ -33,6 +33,14 @@ export interface ViewScope { readOnlyTemporarilyDisabled?: boolean; highlightsListPreviousVisible?: boolean; highlightsListTemporarilyHidden?: boolean; + tocTemporarilyHidden?: boolean; + /* + * The reason for adding tocPreviousVisible 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 + */ + tocPreviousVisible?: boolean; } interface CreateLinkOptions { diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index 2af1e098d..8c649fce8 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -239,6 +239,7 @@ declare global { }, getData(): string; setData(data: string): void; + sourceElement: HTMLElement; } interface MentionItem { diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.ts similarity index 81% rename from src/public/app/widgets/toc.js rename to src/public/app/widgets/toc.ts index ab221edd6..e65b807c1 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.ts @@ -18,8 +18,9 @@ import attributeService from "../services/attributes.js"; import RightPanelWidget from "./right_panel_widget.js"; import options from "../services/options.js"; import OnClickButtonWidget from "./buttons/onclick_button.js"; -import appContext from "../components/app_context.js"; +import appContext, { type EventData } from "../components/app_context.js"; import libraryLoader from "../services/library_loader.js"; +import type FNote from "../entities/fnote.js"; const TPL = `