@rightkit/document-workspace 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +51 -2
- package/dist/app/App.d.ts +1 -0
- package/dist/app/App.js +6 -0
- package/dist/app/AppDialogs.d.ts +52 -0
- package/dist/app/AppDialogs.js +23 -0
- package/dist/app/AppDialogsHost.d.ts +31 -0
- package/dist/app/AppDialogsHost.js +30 -0
- package/dist/app/AppLifecycle.d.ts +19 -0
- package/dist/app/AppLifecycle.js +87 -0
- package/dist/app/AppProvider.d.ts +317 -0
- package/dist/app/AppProvider.js +217 -0
- package/dist/app/AppRoot.d.ts +8 -0
- package/dist/app/AppRoot.js +159 -0
- package/dist/app/AppShell.d.ts +2 -0
- package/dist/app/AppShell.js +81 -0
- package/dist/app/CommandPalette.d.ts +13 -0
- package/dist/app/CommandPalette.js +47 -0
- package/dist/app/DocActionBar.d.ts +36 -0
- package/dist/app/DocActionBar.js +300 -0
- package/dist/app/DocumentContextMenu.d.ts +29 -0
- package/dist/app/DocumentContextMenu.js +122 -0
- package/dist/app/DocumentPane.d.ts +52 -0
- package/dist/app/DocumentPane.js +30 -0
- package/dist/app/DocumentRouterTable.d.ts +58 -0
- package/dist/app/DocumentRouterTable.js +143 -0
- package/dist/app/ErrorBoundary.d.ts +12 -0
- package/dist/app/ErrorBoundary.js +16 -0
- package/dist/app/FindBar.d.ts +12 -0
- package/dist/app/FindBar.js +199 -0
- package/dist/app/LiveTitle.d.ts +14 -0
- package/dist/app/LiveTitle.js +14 -0
- package/dist/app/OpeningProgress.d.ts +13 -0
- package/dist/app/OpeningProgress.js +21 -0
- package/dist/app/PrintPreviewWindow.d.ts +2 -0
- package/dist/app/PrintPreviewWindow.js +57 -0
- package/dist/app/ShortcutHelp.d.ts +3 -0
- package/dist/app/ShortcutHelp.js +99 -0
- package/dist/app/Sidebar.d.ts +36 -0
- package/dist/app/Sidebar.js +121 -0
- package/dist/app/ToastViewport.d.ts +1 -0
- package/dist/app/ToastViewport.js +31 -0
- package/dist/app/Toolbar.d.ts +26 -0
- package/dist/app/Toolbar.js +63 -0
- package/dist/app/activeFormatSavers.d.ts +7 -0
- package/dist/app/activeFormatSavers.js +4 -0
- package/dist/app/clipboardPaths.d.ts +1 -0
- package/dist/app/clipboardPaths.js +31 -0
- package/dist/app/documentDrafts.d.ts +17 -0
- package/dist/app/documentDrafts.js +104 -0
- package/dist/app/draftResolution.d.ts +5 -0
- package/dist/app/draftResolution.js +25 -0
- package/dist/app/markdownPaletteActions.d.ts +8 -0
- package/dist/app/markdownPaletteActions.js +107 -0
- package/dist/app/resourceCensusDev.d.ts +41 -0
- package/dist/app/resourceCensusDev.js +518 -0
- package/dist/app/setupRecovery.d.ts +34 -0
- package/dist/app/setupRecovery.js +70 -0
- package/dist/app/shell/DocStatsPill.d.ts +18 -0
- package/dist/app/shell/DocStatsPill.js +32 -0
- package/dist/app/shell/DocumentTools.d.ts +9 -0
- package/dist/app/shell/DocumentTools.js +73 -0
- package/dist/app/shell/InfoInspector.d.ts +9 -0
- package/dist/app/shell/InfoInspector.js +67 -0
- package/dist/app/shell/StartPage.d.ts +9 -0
- package/dist/app/shell/StartPage.js +49 -0
- package/dist/app/shell/readEdit.d.ts +6 -0
- package/dist/app/shell/readEdit.js +6 -0
- package/dist/app/sidebar/SidebarDocumentMenu.d.ts +20 -0
- package/dist/app/sidebar/SidebarDocumentMenu.js +56 -0
- package/dist/app/sidebar/SidebarExpandedPanel.d.ts +9 -0
- package/dist/app/sidebar/SidebarExpandedPanel.js +78 -0
- package/dist/app/sidebar/SidebarIcons.d.ts +3 -0
- package/dist/app/sidebar/SidebarIcons.js +18 -0
- package/dist/app/sidebar/SidebarMenus.d.ts +19 -0
- package/dist/app/sidebar/SidebarMenus.js +64 -0
- package/dist/app/sidebar/SidebarPathUtils.d.ts +10 -0
- package/dist/app/sidebar/SidebarPathUtils.js +55 -0
- package/dist/app/sidebar/SidebarPrimitives.d.ts +12 -0
- package/dist/app/sidebar/SidebarPrimitives.js +45 -0
- package/dist/app/sidebar/SidebarRail.d.ts +5 -0
- package/dist/app/sidebar/SidebarRail.js +37 -0
- package/dist/app/sidebar/explorer/ExplorerRowMenu.d.ts +21 -0
- package/dist/app/sidebar/explorer/ExplorerRowMenu.js +37 -0
- package/dist/app/sidebar/explorer/ExplorerSections.d.ts +16 -0
- package/dist/app/sidebar/explorer/ExplorerSections.js +259 -0
- package/dist/app/sidebar/explorer/ExplorerTree.d.ts +46 -0
- package/dist/app/sidebar/explorer/ExplorerTree.js +387 -0
- package/dist/app/sidebar/explorer/explorerState.d.ts +37 -0
- package/dist/app/sidebar/explorer/explorerState.js +135 -0
- package/dist/app/tabMountPolicy.d.ts +45 -0
- package/dist/app/tabMountPolicy.js +104 -0
- package/dist/app/tabWarmOrder.d.ts +7 -0
- package/dist/app/tabWarmOrder.js +48 -0
- package/dist/app/tabs/TabFuseCurves.d.ts +3 -0
- package/dist/app/tabs/TabFuseCurves.js +15 -0
- package/dist/app/tabs/TabOverview.d.ts +24 -0
- package/dist/app/tabs/TabOverview.js +121 -0
- package/dist/app/tabs/TabStrip.d.ts +42 -0
- package/dist/app/tabs/TabStrip.js +380 -0
- package/dist/app/tabs/tabIds.d.ts +5 -0
- package/dist/app/tabs/tabIds.js +7 -0
- package/dist/app/tabs/useTabDirty.d.ts +3 -0
- package/dist/app/tabs/useTabDirty.js +11 -0
- package/dist/app/useAppChromeState.d.ts +21 -0
- package/dist/app/useAppChromeState.js +48 -0
- package/dist/app/useAppCommands.d.ts +66 -0
- package/dist/app/useAppCommands.js +71 -0
- package/dist/app/useAppDocumentCore.d.ts +210 -0
- package/dist/app/useAppDocumentCore.js +40 -0
- package/dist/app/useAppEffects.d.ts +18 -0
- package/dist/app/useAppEffects.js +52 -0
- package/dist/app/useAppPaneSearch.d.ts +37 -0
- package/dist/app/useAppPaneSearch.js +74 -0
- package/dist/app/useAppShellSetup.d.ts +40 -0
- package/dist/app/useAppShellSetup.js +52 -0
- package/dist/app/useAppSlots.d.ts +28 -0
- package/dist/app/useAppSlots.js +40 -0
- package/dist/app/useAppTabChrome.d.ts +51 -0
- package/dist/app/useAppTabChrome.js +66 -0
- package/dist/app/useAutoSave.d.ts +34 -0
- package/dist/app/useAutoSave.js +116 -0
- package/dist/app/useCloseAll.d.ts +52 -0
- package/dist/app/useCloseAll.js +295 -0
- package/dist/app/useClosedTabEviction.d.ts +10 -0
- package/dist/app/useClosedTabEviction.js +38 -0
- package/dist/app/useCommandPalette.d.ts +44 -0
- package/dist/app/useCommandPalette.js +254 -0
- package/dist/app/useCrossDocSearch.d.ts +7 -0
- package/dist/app/useCrossDocSearch.js +94 -0
- package/dist/app/useDistractionFree.d.ts +21 -0
- package/dist/app/useDistractionFree.js +73 -0
- package/dist/app/useDocumentCreation.d.ts +18 -0
- package/dist/app/useDocumentCreation.js +63 -0
- package/dist/app/useDocumentDirty.d.ts +31 -0
- package/dist/app/useDocumentDirty.js +46 -0
- package/dist/app/useDocumentLoader.d.ts +55 -0
- package/dist/app/useDocumentLoader.js +267 -0
- package/dist/app/useDocumentOutputActions.d.ts +6 -0
- package/dist/app/useDocumentOutputActions.js +45 -0
- package/dist/app/useDocumentRuntimeEffects.d.ts +36 -0
- package/dist/app/useDocumentRuntimeEffects.js +458 -0
- package/dist/app/useDocumentSaver.d.ts +58 -0
- package/dist/app/useDocumentSaver.js +511 -0
- package/dist/app/useDocumentTabs.d.ts +41 -0
- package/dist/app/useDocumentTabs.js +207 -0
- package/dist/app/useDocumentWatcher.d.ts +83 -0
- package/dist/app/useDocumentWatcher.js +393 -0
- package/dist/app/useDocumentZoom.d.ts +24 -0
- package/dist/app/useDocumentZoom.js +104 -0
- package/dist/app/useDocuments.d.ts +169 -0
- package/dist/app/useDocuments.js +455 -0
- package/dist/app/useDraftConfirmGate.d.ts +27 -0
- package/dist/app/useDraftConfirmGate.js +47 -0
- package/dist/app/useFileDragOverlay.d.ts +12 -0
- package/dist/app/useFileDragOverlay.js +49 -0
- package/dist/app/useFormatApis.d.ts +13 -0
- package/dist/app/useFormatApis.js +62 -0
- package/dist/app/useFormatDirtyState.d.ts +29 -0
- package/dist/app/useFormatDirtyState.js +81 -0
- package/dist/app/useGlobalShortcuts.d.ts +47 -0
- package/dist/app/useGlobalShortcuts.js +359 -0
- package/dist/app/useHtmlSession.d.ts +68 -0
- package/dist/app/useHtmlSession.js +463 -0
- package/dist/app/useHtmlSessionProps.d.ts +33 -0
- package/dist/app/useHtmlSessionProps.js +57 -0
- package/dist/app/useLibrary.d.ts +21 -0
- package/dist/app/useLibrary.js +81 -0
- package/dist/app/useOpenFromClipboard.d.ts +7 -0
- package/dist/app/useOpenFromClipboard.js +44 -0
- package/dist/app/usePaneLiveness.d.ts +29 -0
- package/dist/app/usePaneLiveness.js +199 -0
- package/dist/app/usePendingSavePaths.d.ts +19 -0
- package/dist/app/usePendingSavePaths.js +67 -0
- package/dist/app/useReadyShow.d.ts +12 -0
- package/dist/app/useReadyShow.js +142 -0
- package/dist/app/useSearchController.d.ts +22 -0
- package/dist/app/useSearchController.js +114 -0
- package/dist/app/useSetupRecovery.d.ts +41 -0
- package/dist/app/useSetupRecovery.js +153 -0
- package/dist/app/useTabChrome.d.ts +40 -0
- package/dist/app/useTabChrome.js +115 -0
- package/dist/app/useViewState.d.ts +27 -0
- package/dist/app/useViewState.js +160 -0
- package/dist/appName.d.ts +2 -0
- package/dist/appName.js +8 -0
- package/dist/documents/DocumentRouter.d.ts +102 -0
- package/dist/documents/DocumentRouter.js +153 -0
- package/dist/documents/FileTypeIcon.d.ts +6 -0
- package/dist/documents/FileTypeIcon.js +93 -0
- package/dist/documents/ImageDocument.d.ts +14 -0
- package/dist/documents/ImageDocument.js +61 -0
- package/dist/documents/capabilities.d.ts +17 -0
- package/dist/documents/capabilities.js +18 -0
- package/dist/documents/html/HtmlDocument.d.ts +15 -0
- package/dist/documents/html/HtmlDocument.js +584 -0
- package/dist/documents/html/HtmlDocumentLayout.d.ts +87 -0
- package/dist/documents/html/HtmlDocumentLayout.js +25 -0
- package/dist/documents/html/HtmlDocumentProps.d.ts +60 -0
- package/dist/documents/html/HtmlDocumentProps.js +1 -0
- package/dist/documents/html/HtmlDocumentSource.d.ts +34 -0
- package/dist/documents/html/HtmlDocumentSource.js +28 -0
- package/dist/documents/markdown/MarkdownSplitPane.d.ts +115 -0
- package/dist/documents/markdown/MarkdownSplitPane.js +352 -0
- package/dist/documents/mdx/MdxSplitPane.d.ts +32 -0
- package/dist/documents/mdx/MdxSplitPane.js +60 -0
- package/dist/documents/txt/LinkDialog.d.ts +8 -0
- package/dist/documents/txt/LinkDialog.js +34 -0
- package/dist/documents/txt/MarkdownSourceToolbar.d.ts +8 -0
- package/dist/documents/txt/MarkdownSourceToolbar.js +25 -0
- package/dist/documents/txt/SourceEditorToolbar.d.ts +12 -0
- package/dist/documents/txt/SourceEditorToolbar.js +4 -0
- package/dist/documents/txt/TxtEditor.d.ts +39 -0
- package/dist/documents/txt/TxtEditor.js +186 -0
- package/dist/documents/txt/sourceEditorTypes.d.ts +49 -0
- package/dist/documents/txt/sourceEditorTypes.js +1 -0
- package/dist/documents/txt/sourceExtensions.d.ts +38 -0
- package/dist/documents/txt/sourceExtensions.js +444 -0
- package/dist/documents/txt/sourceFormatting.d.ts +18 -0
- package/dist/documents/txt/sourceFormatting.js +183 -0
- package/dist/documents/txt/sourceTheme.d.ts +5 -0
- package/dist/documents/txt/sourceTheme.js +220 -0
- package/dist/documents/txt/useCodeMirrorSourceEditor.d.ts +69 -0
- package/dist/documents/txt/useCodeMirrorSourceEditor.js +546 -0
- package/dist/documents/txt/useSourceSearch.d.ts +39 -0
- package/dist/documents/txt/useSourceSearch.js +122 -0
- package/dist/documents/txt/useTextEditorCommands.d.ts +26 -0
- package/dist/documents/txt/useTextEditorCommands.js +151 -0
- package/dist/documents/web/LivePreviewPane.d.ts +11 -0
- package/dist/documents/web/LivePreviewPane.js +58 -0
- package/dist/env.d.ts +66 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +123 -0
- package/dist/settings/AppearanceMenu.d.ts +9 -0
- package/dist/settings/AppearanceMenu.js +54 -0
- package/dist/settings/SettingsPanel.d.ts +7 -0
- package/dist/settings/SettingsPanel.js +104 -0
- package/dist/settings/publishedSections.d.ts +22 -0
- package/dist/settings/publishedSections.js +79 -0
- package/dist/settings/sections/AboutSection.d.ts +1 -0
- package/dist/settings/sections/AboutSection.js +13 -0
- package/dist/settings/sections/DiagnosticsSection.d.ts +1 -0
- package/dist/settings/sections/DiagnosticsSection.js +42 -0
- package/dist/settings/sections/PrivacySection.d.ts +3 -0
- package/dist/settings/sections/PrivacySection.js +51 -0
- package/dist/settings/sections/UpdateLicenseBlock.d.ts +10 -0
- package/dist/settings/sections/UpdateLicenseBlock.js +158 -0
- package/dist/state/explorer.d.ts +32 -0
- package/dist/state/explorer.js +111 -0
- package/dist/state/legal.d.ts +51 -0
- package/dist/state/legal.js +130 -0
- package/dist/state/library.d.ts +33 -0
- package/dist/state/library.js +110 -0
- package/dist/state/updateLicense.d.ts +31 -0
- package/dist/state/updateLicense.js +340 -0
- package/dist/styles/explorer.css +219 -0
- package/dist/styles/index.css +1477 -0
- package/dist/styles/tabs.css +467 -0
- package/dist/styles.css +6 -0
- package/package.json +88 -3
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document core: shared tab/edit state, view state, the recents/pins library, and the open/save/dirty/close
|
|
3
|
+
* owner. Extracted verbatim from useAppState; these are the first hook calls of the app shell.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useAppDocumentCore(): {
|
|
6
|
+
blockDrafts: import("@rightkit/document-core/app/blockDrafts").BlockDraftRegistry;
|
|
7
|
+
tabs: {
|
|
8
|
+
openDocs: import("@rightkit/document-core/documents/types").LoadedDocument[];
|
|
9
|
+
setOpenDocs: import("react").Dispatch<import("react").SetStateAction<import("@rightkit/document-core/documents/types").LoadedDocument[]>>;
|
|
10
|
+
activePath: string | null;
|
|
11
|
+
setActivePath: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
12
|
+
editsRef: import("react").RefObject<Record<string, string>>;
|
|
13
|
+
writeEdits: (updater: (prev: Record<string, string>) => Record<string, string>) => void;
|
|
14
|
+
writeEditsLive: (path: string, text: string) => void;
|
|
15
|
+
subscribeEdits: (path: string, cb: () => void) => () => void;
|
|
16
|
+
getEditSnapshot: (path: string) => string;
|
|
17
|
+
getExternalSeq: (path: string) => number;
|
|
18
|
+
docxDirty: Set<string>;
|
|
19
|
+
docxDirtyRef: import("react").RefObject<Set<string>>;
|
|
20
|
+
setDocxDirty: (next: import("react").SetStateAction<Set<string>>) => void;
|
|
21
|
+
pdfDirty: Set<string>;
|
|
22
|
+
pdfDirtyRef: import("react").RefObject<Set<string>>;
|
|
23
|
+
setPdfDirty: (next: import("react").SetStateAction<Set<string>>) => void;
|
|
24
|
+
imageDirty: Set<string>;
|
|
25
|
+
imageDirtyRef: import("react").RefObject<Set<string>>;
|
|
26
|
+
setImageDirty: (next: import("react").SetStateAction<Set<string>>) => void;
|
|
27
|
+
htmlPages: import("@rightkit/html-editor/documents/html/sessionTypes").HtmlSessionPages;
|
|
28
|
+
htmlPagesRef: import("react").RefObject<import("@rightkit/html-editor/documents/html/sessionTypes").HtmlSessionPages>;
|
|
29
|
+
writeHtmlPages: (updater: (prev: import("@rightkit/html-editor/documents/html/sessionTypes").HtmlSessionPages) => import("@rightkit/html-editor/documents/html/sessionTypes").HtmlSessionPages, options?: {
|
|
30
|
+
immediate?: boolean;
|
|
31
|
+
}) => void;
|
|
32
|
+
htmlActivePage: Record<string, string>;
|
|
33
|
+
setHtmlActivePage: import("react").Dispatch<import("react").SetStateAction<Record<string, string>>>;
|
|
34
|
+
mdxGrantsRef: import("react").RefObject<Record<string, Set<string>>>;
|
|
35
|
+
trackMdxGrant: (entryPath: string, grantedPath: string) => void;
|
|
36
|
+
};
|
|
37
|
+
docBarSlot: HTMLElement | null;
|
|
38
|
+
setDocBarSlot: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
|
|
39
|
+
dirtyPaths: Set<string>;
|
|
40
|
+
subscribeDirty: (path: string, listener: () => void) => () => void;
|
|
41
|
+
viewState: {
|
|
42
|
+
views: Record<string, import("@rightkit/document-core/documents/types").ViewMode>;
|
|
43
|
+
setViews: import("react").Dispatch<import("react").SetStateAction<Record<string, import("@rightkit/document-core/documents/types").ViewMode>>>;
|
|
44
|
+
viewsRef: import("react").RefObject<Record<string, import("@rightkit/document-core/documents/types").ViewMode>>;
|
|
45
|
+
viewMetaRef: import("react").RefObject<Record<string, import("@rightkit/document-core/documents/types").ViewMeta>>;
|
|
46
|
+
persistViewMeta: (path: string) => void;
|
|
47
|
+
contentScrollRef: import("react").RefObject<HTMLDivElement | null>;
|
|
48
|
+
requestViewChange: (next: import("@rightkit/document-core/documents/types").ViewMode) => Promise<void>;
|
|
49
|
+
confirmViewChange: (decision: "done" | "discard" | "stay") => Promise<void>;
|
|
50
|
+
cancelViewChange: () => void;
|
|
51
|
+
pendingViewChange: {
|
|
52
|
+
next: import("@rightkit/document-core/documents/types").ViewMode;
|
|
53
|
+
drafts: ReturnType<import("@rightkit/document-core/app/blockDrafts").BlockDraftRegistry["snapshotModified"]>;
|
|
54
|
+
} | null;
|
|
55
|
+
onContentScroll: () => void;
|
|
56
|
+
onPdfViewState: (m: import("@rightkit/document-core/documents/types").ViewMeta) => void;
|
|
57
|
+
dropViewState: (path: string) => void;
|
|
58
|
+
};
|
|
59
|
+
library: {
|
|
60
|
+
onHistoryPurged: () => void;
|
|
61
|
+
recents: import("../index.js").FileEntry[];
|
|
62
|
+
pinnedPaths: Set<string>;
|
|
63
|
+
pinnedEntries: import("../index.js").PinEntry[];
|
|
64
|
+
refreshLibrary: () => Promise<void>;
|
|
65
|
+
syncPinned: (path: string) => Promise<void>;
|
|
66
|
+
onTogglePin: (path: string) => Promise<void>;
|
|
67
|
+
onTogglePinDir: (path: string, displayName: string) => Promise<void>;
|
|
68
|
+
onClearRecents: () => Promise<void>;
|
|
69
|
+
};
|
|
70
|
+
docs: {
|
|
71
|
+
ensureHtmlPage: (entryPath: string, pagePath: string) => Promise<void>;
|
|
72
|
+
setHtmlPageEdited: (entryPath: string, pagePath: string, edited: string) => void;
|
|
73
|
+
setHtmlActive: (entryPath: string, pagePath: string) => void;
|
|
74
|
+
discardHtmlPage: (entryPath: string, pagePath: string) => void;
|
|
75
|
+
saveHtmlPage: (entryPath: string, pagePath: string, options?: {
|
|
76
|
+
silent?: boolean;
|
|
77
|
+
}) => Promise<boolean>;
|
|
78
|
+
saveAllHtmlPages: (entryPath: string, options?: {
|
|
79
|
+
silent?: boolean;
|
|
80
|
+
}) => Promise<boolean>;
|
|
81
|
+
discardAllHtmlPages: (entryPath: string) => void;
|
|
82
|
+
onHtmlSaveShortcut: (entryPath: string) => void;
|
|
83
|
+
htmlDirtyPages: (entryPath: string) => {
|
|
84
|
+
path: string;
|
|
85
|
+
name: string;
|
|
86
|
+
isEntry: boolean;
|
|
87
|
+
}[];
|
|
88
|
+
htmlSaveCurrent: () => Promise<void>;
|
|
89
|
+
htmlSaveAll: () => Promise<void>;
|
|
90
|
+
htmlDiscardAll: () => void;
|
|
91
|
+
htmlConfirmCancel: () => void;
|
|
92
|
+
htmlConflictReload: () => Promise<void>;
|
|
93
|
+
htmlConflictKeep: () => Promise<void>;
|
|
94
|
+
reloadHtmlSubpage: (path: string) => void;
|
|
95
|
+
blockDrafts: import("@rightkit/document-core/app/blockDrafts").BlockDraftRegistry;
|
|
96
|
+
activate: (path: string) => Promise<void>;
|
|
97
|
+
open: (path: string, opts?: import("./useDocumentLoader.js").OpenDocumentOptions) => Promise<void>;
|
|
98
|
+
openLiveUrl: (input: string, opts?: {
|
|
99
|
+
background?: boolean;
|
|
100
|
+
}) => Promise<void>;
|
|
101
|
+
openRecent: (entry: import("../index.js").FileEntry) => Promise<void>;
|
|
102
|
+
onOpenDialog: () => Promise<void>;
|
|
103
|
+
newDocument: (format?: "txt" | "md" | "docx") => void;
|
|
104
|
+
duplicateAsDraft: (text: string, toastMsg?: string) => void;
|
|
105
|
+
requestClose: (path: string) => void;
|
|
106
|
+
closeAll: () => void;
|
|
107
|
+
closeMany: (paths: string[]) => void;
|
|
108
|
+
reopenLastClosed: () => void;
|
|
109
|
+
openImageSibling: (currentPath: string, targetPath: string) => Promise<void>;
|
|
110
|
+
onTxtChange: (path: string, content: string, text: string) => void;
|
|
111
|
+
onSave: (doc: import("@rightkit/document-core/documents/types").LoadedDocument, options?: {
|
|
112
|
+
silent?: boolean;
|
|
113
|
+
}) => Promise<string | null>;
|
|
114
|
+
onSaveAs: (doc: import("@rightkit/document-core/documents/types").LoadedDocument) => Promise<string | null>;
|
|
115
|
+
onDocxSaveAs: (doc: import("@rightkit/document-core/documents/types").LoadedDocument, buffer?: ArrayBuffer) => Promise<string | null>;
|
|
116
|
+
onPrint: (doc: import("@rightkit/document-core/documents/types").LoadedDocument | null) => void;
|
|
117
|
+
onDocxSave: (path: string, buffer: ArrayBuffer) => Promise<void>;
|
|
118
|
+
onDocxChange: (path: string) => void;
|
|
119
|
+
onPdfDirtyChange: (path: string, dirty: boolean) => void;
|
|
120
|
+
docxSaver: import("react").RefObject<(() => Promise<ArrayBuffer | null>) | null>;
|
|
121
|
+
docxSaversRef: import("react").RefObject<Map<string, () => Promise<ArrayBuffer | null>>>;
|
|
122
|
+
pdfSaversRef: import("react").RefObject<Map<string, import("@rightkit/document-core/documents/pdf/pdfEditor").PdfSaveFunction>>;
|
|
123
|
+
pdfSavePlansRef: import("react").RefObject<Map<string, () => Promise<import("@rightkit/document-core/documents/pdf/pdfEditModel").PdfSavePlan>>>;
|
|
124
|
+
onImageChange: (path: string) => void;
|
|
125
|
+
imageSaver: import("react").RefObject<import("@rightkit/media-ui").ImageSaveFunction | null>;
|
|
126
|
+
imageSaversRef: import("react").RefObject<Map<string, import("@rightkit/media-ui").ImageSaveFunction>>;
|
|
127
|
+
onEditImageExternal: (doc: import("@rightkit/document-core/documents/types").LoadedDocument | null) => void;
|
|
128
|
+
isDirty: (doc: import("@rightkit/document-core/documents/types").LoadedDocument) => boolean;
|
|
129
|
+
hasModifiedDraft: (path: string) => boolean;
|
|
130
|
+
snapshotModified: (path?: string) => Readonly<{
|
|
131
|
+
identity: import("@rightkit/document-core/app/blockDrafts").BlockDraftIdentity;
|
|
132
|
+
blockKind: string;
|
|
133
|
+
originalRevision: string | number;
|
|
134
|
+
sourceRange?: import("@rightkit/document-core/app/blockDrafts").BlockDraftSourceRange;
|
|
135
|
+
sourceChecksum?: string;
|
|
136
|
+
originalText: string;
|
|
137
|
+
currentText: string;
|
|
138
|
+
targetTag?: string;
|
|
139
|
+
selectionBookmark?: import("@rightkit/document-core/app/blockDrafts").BlockDraftSelectionBookmark;
|
|
140
|
+
status: import("@rightkit/document-core/app/blockDrafts").BlockDraftStatus;
|
|
141
|
+
reason?: string;
|
|
142
|
+
error?: string;
|
|
143
|
+
}>[];
|
|
144
|
+
snapshotAll: (path?: string) => Readonly<{
|
|
145
|
+
identity: import("@rightkit/document-core/app/blockDrafts").BlockDraftIdentity;
|
|
146
|
+
blockKind: string;
|
|
147
|
+
originalRevision: string | number;
|
|
148
|
+
sourceRange?: import("@rightkit/document-core/app/blockDrafts").BlockDraftSourceRange;
|
|
149
|
+
sourceChecksum?: string;
|
|
150
|
+
originalText: string;
|
|
151
|
+
currentText: string;
|
|
152
|
+
targetTag?: string;
|
|
153
|
+
selectionBookmark?: import("@rightkit/document-core/app/blockDrafts").BlockDraftSelectionBookmark;
|
|
154
|
+
status: import("@rightkit/document-core/app/blockDrafts").BlockDraftStatus;
|
|
155
|
+
reason?: string;
|
|
156
|
+
error?: string;
|
|
157
|
+
}>[];
|
|
158
|
+
pendingSavePaths: Set<string>;
|
|
159
|
+
titleFor: (doc: import("@rightkit/document-core/documents/types").LoadedDocument) => string;
|
|
160
|
+
error: string | null;
|
|
161
|
+
openingPath: string | null;
|
|
162
|
+
restoringSession: boolean;
|
|
163
|
+
setError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
164
|
+
confirmClose: string | null;
|
|
165
|
+
setConfirmClose: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
166
|
+
confirmCloseAll: {
|
|
167
|
+
orderedPaths: string[];
|
|
168
|
+
affectedPaths: string[];
|
|
169
|
+
} | null;
|
|
170
|
+
setConfirmCloseAll: import("react").Dispatch<import("react").SetStateAction<{
|
|
171
|
+
orderedPaths: string[];
|
|
172
|
+
affectedPaths: string[];
|
|
173
|
+
} | null>>;
|
|
174
|
+
confirmCloseAllSaveAll: () => Promise<void>;
|
|
175
|
+
confirmCloseAllDontSave: () => Promise<void>;
|
|
176
|
+
confirmCloseAllCancel: () => void;
|
|
177
|
+
confirmQuit: boolean;
|
|
178
|
+
setConfirmQuit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
179
|
+
conflict: string | null;
|
|
180
|
+
setConflict: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
181
|
+
keepConflict: (path: string) => Promise<void>;
|
|
182
|
+
reload: (path: string, options?: {
|
|
183
|
+
force?: boolean;
|
|
184
|
+
replayDeferred?: boolean;
|
|
185
|
+
}) => void;
|
|
186
|
+
confirmSave: () => Promise<void>;
|
|
187
|
+
confirmDontSave: () => Promise<void>;
|
|
188
|
+
applyReload: (path: string) => void;
|
|
189
|
+
quitNow: () => Promise<void>;
|
|
190
|
+
quitSaveAll: () => Promise<void>;
|
|
191
|
+
quitDiscardAll: () => Promise<void>;
|
|
192
|
+
draftConfirm: {
|
|
193
|
+
documentPath: string;
|
|
194
|
+
intent: import("@rightkit/document-core/app/blockDrafts").BlockDraftIntent;
|
|
195
|
+
onResolved: () => void;
|
|
196
|
+
} | null;
|
|
197
|
+
setDraftConfirm: import("react").Dispatch<import("react").SetStateAction<{
|
|
198
|
+
documentPath: string;
|
|
199
|
+
intent: import("@rightkit/document-core/app/blockDrafts").BlockDraftIntent;
|
|
200
|
+
onResolved: () => void;
|
|
201
|
+
} | null>>;
|
|
202
|
+
confirmDraftDone: () => Promise<void>;
|
|
203
|
+
confirmDraftDiscard: () => Promise<void>;
|
|
204
|
+
confirmDraftCancel: () => void;
|
|
205
|
+
requestDraftAwareViewChange: (path: string, proceed: () => void) => void;
|
|
206
|
+
htmlConfirm: import("./useHtmlSession.js").HtmlConfirmState;
|
|
207
|
+
htmlConflict: import("./useHtmlSession.js").HtmlConflictState;
|
|
208
|
+
trackMdxGrant: (entryPath: string, grantedPath: string) => void;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { createBlockDraftRegistry } from "@rightkit/document-core/app/blockDrafts";
|
|
3
|
+
import { useDocumentTabs } from "./useDocumentTabs.js";
|
|
4
|
+
import { useViewState } from "./useViewState.js";
|
|
5
|
+
import { useLibrary } from "./useLibrary.js";
|
|
6
|
+
import { useDocuments } from "./useDocuments.js";
|
|
7
|
+
/**
|
|
8
|
+
* Document core: shared tab/edit state, view state, the recents/pins library, and the open/save/dirty/close
|
|
9
|
+
* owner. Extracted verbatim from useAppState; these are the first hook calls of the app shell.
|
|
10
|
+
*/
|
|
11
|
+
export function useAppDocumentCore() {
|
|
12
|
+
const [blockDrafts] = useState(() => createBlockDraftRegistry());
|
|
13
|
+
const tabs = useDocumentTabs();
|
|
14
|
+
// App's docked-bar centre slot; formats portal their tool capsule into it (shell/docBar).
|
|
15
|
+
const [docBarSlot, setDocBarSlot] = useState(null);
|
|
16
|
+
const { openDocs, activePath, subscribeEdits } = tabs;
|
|
17
|
+
const dirtyPaths = useMemo(() => new Set([...tabs.docxDirty, ...tabs.pdfDirty, ...tabs.imageDirty]), [tabs.docxDirty, tabs.pdfDirty, tabs.imageDirty]);
|
|
18
|
+
const subscribeDirty = useCallback((path, listener) => {
|
|
19
|
+
const unsubscribeEdits = subscribeEdits(path, listener);
|
|
20
|
+
const unsubscribeDrafts = blockDrafts.subscribe(listener);
|
|
21
|
+
return () => {
|
|
22
|
+
unsubscribeEdits();
|
|
23
|
+
unsubscribeDrafts();
|
|
24
|
+
};
|
|
25
|
+
}, [blockDrafts, subscribeEdits]);
|
|
26
|
+
const viewState = useViewState(activePath, openDocs, blockDrafts);
|
|
27
|
+
const library = useLibrary(openDocs);
|
|
28
|
+
const docs = useDocuments({ tabs, viewState, library, blockDrafts });
|
|
29
|
+
return {
|
|
30
|
+
blockDrafts,
|
|
31
|
+
tabs,
|
|
32
|
+
docBarSlot,
|
|
33
|
+
setDocBarSlot,
|
|
34
|
+
dirtyPaths,
|
|
35
|
+
subscribeDirty,
|
|
36
|
+
viewState,
|
|
37
|
+
library,
|
|
38
|
+
docs,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { syncActiveFormatSavers } from "./activeFormatSavers.js";
|
|
2
|
+
type SyncArgs = Parameters<typeof syncActiveFormatSavers>;
|
|
3
|
+
/** Small self-contained App effects, extracted verbatim: diagnostics toggle, startup persistence
|
|
4
|
+
* warning, pane-active paint marker, active-format saver sync, and the native-menu Settings event. */
|
|
5
|
+
export declare function useAppEffects({ diagnosticsSetting, activePath, docxSaver, imageSaver, docxSaversRef, imageSaversRef, openSettings, }: {
|
|
6
|
+
diagnosticsSetting: boolean | undefined;
|
|
7
|
+
activePath: SyncArgs[0];
|
|
8
|
+
docxSaver: SyncArgs[1];
|
|
9
|
+
imageSaver: SyncArgs[2];
|
|
10
|
+
docxSaversRef: {
|
|
11
|
+
current: SyncArgs[3];
|
|
12
|
+
};
|
|
13
|
+
imageSaversRef: {
|
|
14
|
+
current: SyncArgs[4];
|
|
15
|
+
};
|
|
16
|
+
openSettings: () => void;
|
|
17
|
+
}): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
import { toast } from "@rightkit/platform-ui/headless";
|
|
3
|
+
import { logEvent, setDiagnosticsEnabled } from "@rightkit/document-core/state/diagnostics";
|
|
4
|
+
import { getPersistenceStatus } from "@rightkit/document-core/state/tauriBridge";
|
|
5
|
+
import { scheduleAfterPaint } from "@rightkit/document-core/app/deferredMount";
|
|
6
|
+
import { syncActiveFormatSavers } from "./activeFormatSavers.js";
|
|
7
|
+
import { hostAppName } from "../appName.js";
|
|
8
|
+
/** Small self-contained App effects, extracted verbatim: diagnostics toggle, startup persistence
|
|
9
|
+
* warning, pane-active paint marker, active-format saver sync, and the native-menu Settings event. */
|
|
10
|
+
export function useAppEffects({ diagnosticsSetting, activePath, docxSaver, imageSaver, docxSaversRef, imageSaversRef, openSettings, }) {
|
|
11
|
+
// diagnostics.ts caches the privacy toggle instead of re-parsing settings per event; keep it current.
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setDiagnosticsEnabled(diagnosticsSetting !== false);
|
|
14
|
+
}, [diagnosticsSetting]);
|
|
15
|
+
// Startup: warn persistently when the local database was unreadable and had to be replaced.
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
void (async () => {
|
|
18
|
+
try {
|
|
19
|
+
const status = await getPersistenceStatus();
|
|
20
|
+
if (status.degraded) {
|
|
21
|
+
toast(status.quarantinedTo
|
|
22
|
+
? `${hostAppName()} couldn't read its local database, so recent files, pins and tabs start empty. The original was kept at ${status.quarantinedTo}.`
|
|
23
|
+
: `${hostAppName()} couldn't open its local database; recent files, tabs and settings won't be saved this session.`, { kind: "warning", ttl: 0 });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Status probe is best-effort; a failed probe must not block startup.
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
}, []);
|
|
31
|
+
// Post-paint marker — independent of resource reconciliation. The marker effect's
|
|
32
|
+
// deps are [activePath] only so the cleanup-then-rerun pattern in the deferred-mount effect
|
|
33
|
+
// (which cancels its own rAFs when renderedPaths updates) does not also cancel this log.
|
|
34
|
+
// Fires for both cold & warm clicks as a "pane became active" latency marker.
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!activePath)
|
|
37
|
+
return;
|
|
38
|
+
return scheduleAfterPaint(() => {
|
|
39
|
+
logEvent("pane:active:paint");
|
|
40
|
+
});
|
|
41
|
+
}, [activePath]);
|
|
42
|
+
// Restore an already-mounted DOCX/image tab's registered saver before paint. Clearing both
|
|
43
|
+
// refs loses warm viewers because their registration effect correctly does not remount.
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
syncActiveFormatSavers(activePath, docxSaver, imageSaver, docxSaversRef.current, imageSaversRef.current);
|
|
46
|
+
}, [activePath, docxSaver, docxSaversRef, imageSaver, imageSaversRef]);
|
|
47
|
+
// macOS app menu: the host app › Settings… (⌘,) fires this from the native menu bridge.
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
window.addEventListener("viewright:open-settings", openSettings);
|
|
50
|
+
return () => window.removeEventListener("viewright:open-settings", openSettings);
|
|
51
|
+
}, [openSettings]);
|
|
52
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LoadedDocument, SearchProvider } from "@rightkit/document-core/documents/types";
|
|
2
|
+
import type { createBlockDraftRegistry } from "@rightkit/document-core/app/blockDrafts";
|
|
3
|
+
import type { useDocuments } from "./useDocuments.js";
|
|
4
|
+
import type { useDocumentTabs } from "./useDocumentTabs.js";
|
|
5
|
+
import type { useAppShellSetup } from "./useAppShellSetup.js";
|
|
6
|
+
type Docs = ReturnType<typeof useDocuments>;
|
|
7
|
+
type Tabs = ReturnType<typeof useDocumentTabs>;
|
|
8
|
+
type Setup = ReturnType<typeof useAppShellSetup>;
|
|
9
|
+
export interface AppPaneSearchInput {
|
|
10
|
+
docs: Docs;
|
|
11
|
+
tabs: Tabs;
|
|
12
|
+
openDocs: LoadedDocument[];
|
|
13
|
+
activePath: Tabs["activePath"];
|
|
14
|
+
active: LoadedDocument | null;
|
|
15
|
+
blockDrafts: ReturnType<typeof createBlockDraftRegistry>;
|
|
16
|
+
previewScrollStore: Setup["previewScrollStore"];
|
|
17
|
+
sourceViewStateRef: Setup["sourceViewStateRef"];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Warm-MRU pane liveness, search controller, stable per-path search registration, HTML session props,
|
|
21
|
+
* and closed-tab eviction. Extracted verbatim from useAppState; hook call order is unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useAppPaneSearch({ docs, tabs, openDocs, activePath, active, blockDrafts, previewScrollStore, sourceViewStateRef, }: AppPaneSearchInput): {
|
|
24
|
+
livePaths: Set<string>;
|
|
25
|
+
renderedPaths: Set<string>;
|
|
26
|
+
searchProvider: SearchProvider | null;
|
|
27
|
+
openFind: (replace: boolean) => void;
|
|
28
|
+
toggleFind: (replace: boolean) => void;
|
|
29
|
+
closeFind: () => void;
|
|
30
|
+
findBarEl: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
31
|
+
canOpenFind: boolean;
|
|
32
|
+
findOpen: boolean;
|
|
33
|
+
findMode: "find" | "replace" | undefined;
|
|
34
|
+
registerSearchProviderFor: (path: string) => (provider: SearchProvider | null) => void;
|
|
35
|
+
htmlPropsFor: (entryPath: string) => NonNullable<import("react").ComponentProps<typeof import("../index.js").DocumentRouter>["html"]>;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { usePaneLiveness } from "./usePaneLiveness.js";
|
|
3
|
+
import { useSearchController } from "./useSearchController.js";
|
|
4
|
+
import { useHtmlSessionProps } from "./useHtmlSessionProps.js";
|
|
5
|
+
import { useClosedTabEviction } from "./useClosedTabEviction.js";
|
|
6
|
+
/**
|
|
7
|
+
* Warm-MRU pane liveness, search controller, stable per-path search registration, HTML session props,
|
|
8
|
+
* and closed-tab eviction. Extracted verbatim from useAppState; hook call order is unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export function useAppPaneSearch({ docs, tabs, openDocs, activePath, active, blockDrafts, previewScrollStore, sourceViewStateRef, }) {
|
|
11
|
+
// Warm-MRU pane liveness (see usePaneLiveness); `pruneClosedPaths` drops a closed tab's markers.
|
|
12
|
+
const { livePaths, renderedPaths, pruneClosedPaths } = usePaneLiveness({
|
|
13
|
+
openDocs,
|
|
14
|
+
activePath,
|
|
15
|
+
isDirty: docs.isDirty,
|
|
16
|
+
pendingSavePaths: docs.pendingSavePaths,
|
|
17
|
+
restoringSession: docs.restoringSession,
|
|
18
|
+
blockDrafts,
|
|
19
|
+
});
|
|
20
|
+
const { searchProvider, registerSearchProvider, openFind, toggleFind, closeFind, findBarEl, canOpenFind, findOpen, findMode, } = useSearchController(activePath, active, openDocs, docs.activate);
|
|
21
|
+
// Per-path, STABLE binding of the controller's `registerSearchProvider`. Each doc pane is rendered
|
|
22
|
+
// inside a `.map`, so an inline `(p) => registerSearchProvider(doc.path, p)` would be a fresh
|
|
23
|
+
// function every render — and viewers (MarkdownView/MarkdownSplitPane, HTML, PDF) list their register
|
|
24
|
+
// callback in effect deps, so an unstable identity re-fires those effects every render, each minting a
|
|
25
|
+
// new provider object → setSearchProvider → re-render → infinite "Maximum update depth" loop. Caching
|
|
26
|
+
// one bound fn per path keeps the identity stable (the controller's registerSearchProvider already is).
|
|
27
|
+
const boundRegisterRef = useRef(new Map());
|
|
28
|
+
const registerSearchProviderFor = useCallback((path) => {
|
|
29
|
+
const cache = boundRegisterRef.current;
|
|
30
|
+
let fn = cache.get(path);
|
|
31
|
+
if (!fn) {
|
|
32
|
+
fn = (provider) => registerSearchProvider(path, provider);
|
|
33
|
+
cache.set(path, fn);
|
|
34
|
+
}
|
|
35
|
+
return fn;
|
|
36
|
+
}, [registerSearchProvider]);
|
|
37
|
+
// HTML site-session props for the router — extracted to useHtmlSessionProps. dropHtmlProps is
|
|
38
|
+
// what the shared closed-tab eviction effect below calls per closed path.
|
|
39
|
+
const { htmlPropsFor, dropHtmlProps } = useHtmlSessionProps({
|
|
40
|
+
htmlPages: tabs.htmlPages,
|
|
41
|
+
previewScrollStore,
|
|
42
|
+
ensureHtmlPage: docs.ensureHtmlPage,
|
|
43
|
+
setHtmlPageEdited: docs.setHtmlPageEdited,
|
|
44
|
+
setHtmlActive: docs.setHtmlActive,
|
|
45
|
+
saveHtmlPage: docs.saveHtmlPage,
|
|
46
|
+
discardHtmlPage: docs.discardHtmlPage,
|
|
47
|
+
htmlDirtyPages: docs.htmlDirtyPages,
|
|
48
|
+
reload: docs.reload,
|
|
49
|
+
});
|
|
50
|
+
const evictBoundRegister = useCallback((path) => {
|
|
51
|
+
boundRegisterRef.current.delete(path);
|
|
52
|
+
}, []);
|
|
53
|
+
useClosedTabEviction({
|
|
54
|
+
openDocs,
|
|
55
|
+
onEvictPath: evictBoundRegister,
|
|
56
|
+
dropHtmlProps,
|
|
57
|
+
sourceViewStateRef,
|
|
58
|
+
pruneClosedPaths,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
livePaths,
|
|
62
|
+
renderedPaths,
|
|
63
|
+
searchProvider,
|
|
64
|
+
openFind,
|
|
65
|
+
toggleFind,
|
|
66
|
+
closeFind,
|
|
67
|
+
findBarEl,
|
|
68
|
+
canOpenFind,
|
|
69
|
+
findOpen,
|
|
70
|
+
findMode,
|
|
71
|
+
registerSearchProviderFor,
|
|
72
|
+
htmlPropsFor,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
import type { useDocuments } from "./useDocuments.js";
|
|
3
|
+
import type { useDocumentTabs } from "./useDocumentTabs.js";
|
|
4
|
+
import type { SourceEditorViewState } from "../documents/txt/TxtEditor.js";
|
|
5
|
+
type Docs = ReturnType<typeof useDocuments>;
|
|
6
|
+
type Tabs = ReturnType<typeof useDocumentTabs>;
|
|
7
|
+
export interface AppShellSetupInput {
|
|
8
|
+
docs: Docs;
|
|
9
|
+
activePath: Tabs["activePath"];
|
|
10
|
+
setSettingsOpen: Dispatch<SetStateAction<boolean>>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Settings, drag/drop overlay, format APIs, the document context menu, app-level effects, and the
|
|
14
|
+
* per-app refs (auto-update guard, preview scroll store, source view state). Extracted verbatim from
|
|
15
|
+
* useAppState; hook call order is unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useAppShellSetup({ docs, activePath, setSettingsOpen }: AppShellSetupInput): {
|
|
18
|
+
settings: import("@rightkit/document-core/settings/settings").Settings;
|
|
19
|
+
update: (patch: Partial<import("@rightkit/document-core/settings/settings").Settings>) => void;
|
|
20
|
+
handleOpenSettings: () => void;
|
|
21
|
+
dragOver: boolean;
|
|
22
|
+
rootDragProps: {
|
|
23
|
+
onDragEnter: (e: import("react").DragEvent) => void;
|
|
24
|
+
onDragOver: (e: import("react").DragEvent) => void;
|
|
25
|
+
onDragLeave: (e: import("react").DragEvent) => void;
|
|
26
|
+
onDrop: () => void;
|
|
27
|
+
};
|
|
28
|
+
docxMenu: import("@rightkit/docx-editor/documents/docx/menuApi").DocxMenuApi | null;
|
|
29
|
+
setDocxMenu: Dispatch<SetStateAction<import("@rightkit/docx-editor/documents/docx/menuApi").DocxMenuApi | null>>;
|
|
30
|
+
markdownExport: import("@rightkit/markdown-editor/documents/markdown/export/markdownExportTypes").MarkdownExportApi | null;
|
|
31
|
+
registerPdfPrint: (fn: (() => Promise<boolean>) | null) => void;
|
|
32
|
+
registerMarkdownExport: (api: import("@rightkit/markdown-editor/documents/markdown/export/markdownExportTypes").MarkdownExportApi | null) => void;
|
|
33
|
+
handlePrint: (doc: import("@rightkit/document-core/documents/types").LoadedDocument | null) => void;
|
|
34
|
+
docContextMenu: import("./DocumentContextMenu.js").DocContextMenu | null;
|
|
35
|
+
closeDocContextMenu: () => void;
|
|
36
|
+
autoUpdateCheckRan: import("react").RefObject<boolean>;
|
|
37
|
+
previewScrollStore: import("react").RefObject<Map<string, number>>;
|
|
38
|
+
sourceViewStateRef: import("react").RefObject<Record<string, SourceEditorViewState>>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { useAppEffects } from "./useAppEffects.js";
|
|
3
|
+
import { useFileDragOverlay } from "./useFileDragOverlay.js";
|
|
4
|
+
import { useFormatApis } from "./useFormatApis.js";
|
|
5
|
+
import { useDocumentContextMenu } from "./DocumentContextMenu.js";
|
|
6
|
+
import { useSettings } from "@rightkit/document-core/settings/settings";
|
|
7
|
+
/**
|
|
8
|
+
* Settings, drag/drop overlay, format APIs, the document context menu, app-level effects, and the
|
|
9
|
+
* per-app refs (auto-update guard, preview scroll store, source view state). Extracted verbatim from
|
|
10
|
+
* useAppState; hook call order is unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export function useAppShellSetup({ docs, activePath, setSettingsOpen }) {
|
|
13
|
+
const { settings, update } = useSettings();
|
|
14
|
+
const handleOpenSettings = useCallback(() => setSettingsOpen(true), [setSettingsOpen]);
|
|
15
|
+
useAppEffects({
|
|
16
|
+
diagnosticsSetting: settings.diagnostics,
|
|
17
|
+
activePath,
|
|
18
|
+
docxSaver: docs.docxSaver,
|
|
19
|
+
imageSaver: docs.imageSaver,
|
|
20
|
+
docxSaversRef: docs.docxSaversRef,
|
|
21
|
+
imageSaversRef: docs.imageSaversRef,
|
|
22
|
+
openSettings: handleOpenSettings,
|
|
23
|
+
});
|
|
24
|
+
const { dragOver, rootDragProps } = useFileDragOverlay();
|
|
25
|
+
const { docxMenu, setDocxMenu, markdownExport, registerPdfPrint, registerMarkdownExport, handlePrint, } = useFormatApis(docs.onPrint);
|
|
26
|
+
const { menu: docContextMenu, close: closeDocContextMenu } = useDocumentContextMenu();
|
|
27
|
+
const autoUpdateCheckRan = useRef(false);
|
|
28
|
+
// Durable interactive-HTML preview scroll, keyed by the html tab's entry path. Lives here (not in
|
|
29
|
+
// HtmlDocument) so it survives the unmount on tab switch and is restored when you return.
|
|
30
|
+
const previewScrollStore = useRef(new Map());
|
|
31
|
+
// Source selection + scroll are view state, but must survive an eligible dirty-router eviction just
|
|
32
|
+
// like the source itself. One path-keyed owner covers TXT, Markdown's source drawer, and HTML pages.
|
|
33
|
+
const sourceViewStateRef = useRef({});
|
|
34
|
+
return {
|
|
35
|
+
settings,
|
|
36
|
+
update,
|
|
37
|
+
handleOpenSettings,
|
|
38
|
+
dragOver,
|
|
39
|
+
rootDragProps,
|
|
40
|
+
docxMenu,
|
|
41
|
+
setDocxMenu,
|
|
42
|
+
markdownExport,
|
|
43
|
+
registerPdfPrint,
|
|
44
|
+
registerMarkdownExport,
|
|
45
|
+
handlePrint,
|
|
46
|
+
docContextMenu,
|
|
47
|
+
closeDocContextMenu,
|
|
48
|
+
autoUpdateCheckRan,
|
|
49
|
+
previewScrollStore,
|
|
50
|
+
sourceViewStateRef,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DocumentMenus } from "./DocActionBar.js";
|
|
2
|
+
import type { LoadedDocument, ReadEditMode } from "@rightkit/document-core/documents/types";
|
|
3
|
+
import type { useDocuments } from "./useDocuments.js";
|
|
4
|
+
import type { useFormatApis } from "./useFormatApis.js";
|
|
5
|
+
import type { useViewState } from "./useViewState.js";
|
|
6
|
+
type Docs = ReturnType<typeof useDocuments>;
|
|
7
|
+
type Formats = ReturnType<typeof useFormatApis>;
|
|
8
|
+
export interface AppSlotsInput {
|
|
9
|
+
docs: Docs;
|
|
10
|
+
active: LoadedDocument | null;
|
|
11
|
+
view: Parameters<typeof DocumentMenus>[0]["view"];
|
|
12
|
+
onChangeView: ReturnType<typeof useViewState>["requestViewChange"];
|
|
13
|
+
handlePrint: Formats["handlePrint"];
|
|
14
|
+
docxMenu: Formats["docxMenu"];
|
|
15
|
+
activeReadEdit: ReadEditMode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Stable close/edit/open callbacks and the docked-bar menu + mode slots. Extracted verbatim from
|
|
19
|
+
* useAppState; hook call order is unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useAppSlots({ docs, active, view, onChangeView, handlePrint, docxMenu, activeReadEdit, }: AppSlotsInput): {
|
|
22
|
+
onOpenPathForRouter: (p: string, opts?: {
|
|
23
|
+
background?: boolean;
|
|
24
|
+
}) => void;
|
|
25
|
+
menuSlot: import("react").JSX.Element | null;
|
|
26
|
+
modeSlot: import("react").JSX.Element | null;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { DocumentMenus, DocumentModeControls } from "./DocActionBar.js";
|
|
4
|
+
import { capabilitiesFor } from "../documents/capabilities.js";
|
|
5
|
+
/**
|
|
6
|
+
* Stable close/edit/open callbacks and the docked-bar menu + mode slots. Extracted verbatim from
|
|
7
|
+
* useAppState; hook call order is unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export function useAppSlots({ docs, active, view, onChangeView, handlePrint, docxMenu, activeReadEdit, }) {
|
|
10
|
+
const { onSave, onSaveAs, requestClose, open } = docs;
|
|
11
|
+
// Stabilized chrome props so the memoized Sidebar/Toolbar/DocStatsPill skip the per-keystroke
|
|
12
|
+
// App re-render — slots are memoized on the data they actually read.
|
|
13
|
+
const closeActive = useCallback(() => {
|
|
14
|
+
if (active)
|
|
15
|
+
requestClose(active.path);
|
|
16
|
+
}, [active, requestClose]);
|
|
17
|
+
const editActiveImageExternal = useCallback(() => {
|
|
18
|
+
if (active)
|
|
19
|
+
docs.onEditImageExternal(active);
|
|
20
|
+
}, [active, docs]);
|
|
21
|
+
// T2-3: stable identity so the memoized DocumentRouterTable doesn't see a fresh function every render.
|
|
22
|
+
const onOpenPathForRouter = useCallback((p, opts) => {
|
|
23
|
+
void open(p, opts);
|
|
24
|
+
}, [open]);
|
|
25
|
+
const menuSlot = useMemo(() => active ? (_jsx(DocumentMenus, { doc: active, view: view, onSave: () => active.format === "html" ? docs.onHtmlSaveShortcut(active.path) : onSave(active), onSaveAs: () => onSaveAs(active), onPrint: () => handlePrint(active), onClose: closeActive, onEditImageExternal: editActiveImageExternal, onChangeView: onChangeView, docxMenu: active.format === "docx" ? docxMenu : null, readOnly: activeReadEdit === "read" })) : null, [
|
|
26
|
+
active,
|
|
27
|
+
view,
|
|
28
|
+
docxMenu,
|
|
29
|
+
onChangeView,
|
|
30
|
+
onSave,
|
|
31
|
+
onSaveAs,
|
|
32
|
+
handlePrint,
|
|
33
|
+
docs,
|
|
34
|
+
closeActive,
|
|
35
|
+
editActiveImageExternal,
|
|
36
|
+
activeReadEdit,
|
|
37
|
+
]);
|
|
38
|
+
const modeSlot = useMemo(() => active && capabilitiesFor(active.format).canSwitchView ? (_jsx(DocumentModeControls, { doc: active, view: view, onChangeView: onChangeView, readOnly: activeReadEdit === "read" })) : null, [active, view, onChangeView, activeReadEdit]);
|
|
39
|
+
return { onOpenPathForRouter, menuSlot, modeSlot };
|
|
40
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
import { useDocumentZoom } from "./useDocumentZoom.js";
|
|
3
|
+
import type { LoadedDocument } from "@rightkit/document-core/documents/types";
|
|
4
|
+
import type { useDocuments } from "./useDocuments.js";
|
|
5
|
+
import type { useDocumentTabs } from "./useDocumentTabs.js";
|
|
6
|
+
import type { useAppDocumentCore } from "./useAppDocumentCore.js";
|
|
7
|
+
import type { useAppShellSetup } from "./useAppShellSetup.js";
|
|
8
|
+
import type { useLibrary } from "./useLibrary.js";
|
|
9
|
+
type Docs = ReturnType<typeof useDocuments>;
|
|
10
|
+
type Tabs = ReturnType<typeof useDocumentTabs>;
|
|
11
|
+
type Core = ReturnType<typeof useAppDocumentCore>;
|
|
12
|
+
type Setup = ReturnType<typeof useAppShellSetup>;
|
|
13
|
+
type Library = ReturnType<typeof useLibrary>;
|
|
14
|
+
export interface AppTabChromeInput {
|
|
15
|
+
docs: Docs;
|
|
16
|
+
tabs: Tabs;
|
|
17
|
+
activePath: Tabs["activePath"];
|
|
18
|
+
sidebarCollapsed: boolean;
|
|
19
|
+
tabOverviewOpen: boolean;
|
|
20
|
+
setTabOverviewOpen: Dispatch<SetStateAction<boolean>>;
|
|
21
|
+
pinnedPaths: Library["pinnedPaths"];
|
|
22
|
+
onTogglePin: Library["onTogglePin"];
|
|
23
|
+
dirtyPaths: Core["dirtyPaths"];
|
|
24
|
+
subscribeDirty: Core["subscribeDirty"];
|
|
25
|
+
active: LoadedDocument | null;
|
|
26
|
+
view: Parameters<typeof useDocumentZoom>[0]["view"];
|
|
27
|
+
settings: Setup["settings"];
|
|
28
|
+
update: Setup["update"];
|
|
29
|
+
autoUpdateCheckRan: Setup["autoUpdateCheckRan"];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Titlebar title, tab strip, document zoom, the open-file watch set, the lifecycle effects, and the
|
|
33
|
+
* open-from-clipboard action. Extracted verbatim from useAppState; hook call order is unchanged.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useAppTabChrome({ docs, tabs, activePath, sidebarCollapsed, tabOverviewOpen, setTabOverviewOpen, pinnedPaths, onTogglePin, dirtyPaths, subscribeDirty, active, view, settings, update, autoUpdateCheckRan, }: AppTabChromeInput): {
|
|
36
|
+
titleBarTitleFor: (d: LoadedDocument) => string;
|
|
37
|
+
tabStripProps: import("./tabs/TabStrip.js").TabStripProps;
|
|
38
|
+
openPathsSet: Set<string>;
|
|
39
|
+
openExplorerPath: (path: string) => void;
|
|
40
|
+
cycleTab: (dir: 1 | -1) => void;
|
|
41
|
+
jumpToTab: (index: number) => void;
|
|
42
|
+
zoom: {
|
|
43
|
+
zoomHud: string | null;
|
|
44
|
+
zoomedAwayFromDefault: boolean;
|
|
45
|
+
zoomPercentLabel: string;
|
|
46
|
+
resetDocumentZoom: () => void;
|
|
47
|
+
onDocumentWheel: (e: import("react").WheelEvent<HTMLDivElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
openFromClipboard: () => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
export {};
|