@fileverse-dev/ddoc 6.0.1 → 7.0.0-drop-in.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.
Files changed (40) hide show
  1. package/README.md +89 -18
  2. package/dist/data-BCRDUrcS.mjs +59842 -0
  3. package/dist/{ddoc-persistence-C2ay3lLb.mjs → ddoc-persistence-DLdSviUr.mjs} +14 -13
  4. package/dist/headless-editor-utils.es.js +1 -1
  5. package/dist/index-C2HUe78M.mjs +14053 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.es.js +11197 -21742
  8. package/dist/markdown-source-pane-BJbpMXo2.mjs +143 -0
  9. package/dist/package/components/editor-navbar.d.ts +12 -0
  10. package/dist/package/components/editor-toolbar.d.ts +2 -1
  11. package/dist/package/components/fullscreen-toolbar.d.ts +2 -2
  12. package/dist/package/components/mobile-toolbar.d.ts +2 -1
  13. package/dist/package/components/tabs/document-mobile-tab-panel.d.ts +3 -1
  14. package/dist/package/components/tabs/document-tabs-sidebar.d.ts +2 -1
  15. package/dist/package/components/toc/document-outline.d.ts +1 -1
  16. package/dist/package/components/toc/toc.d.ts +1 -1
  17. package/dist/package/components/toc/types.d.ts +7 -0
  18. package/dist/package/extensions/emoji/components/emoji-utils.d.ts +2 -2
  19. package/dist/package/hooks/use-canvas-metrics.d.ts +16 -0
  20. package/dist/package/hooks/use-controllable-state.d.ts +3 -0
  21. package/dist/package/hooks/use-editor-media-query.d.ts +4 -0
  22. package/dist/package/hooks/use-focus-mode.d.ts +1 -3
  23. package/dist/package/hooks/use-tab-editor.d.ts +4 -1
  24. package/dist/package/types.d.ts +41 -5
  25. package/dist/package/use-ddoc-editor.d.ts +3 -1
  26. package/dist/package/utils/container-query-support.d.ts +1 -0
  27. package/dist/package/utils/editor-width-store.d.ts +6 -0
  28. package/dist/package/utils/responsive.d.ts +3 -1
  29. package/dist/package/utils/stats-publisher.d.ts +8 -0
  30. package/dist/persistence.es.js +1 -1
  31. package/dist/{split-view-toolbar-DrK-Wp2F.mjs → split-view-toolbar-6aBSjsO2.mjs} +47 -46
  32. package/dist/style.css +1 -1
  33. package/dist/tab-utils-BNFvrUAj.mjs +284 -0
  34. package/dist/use-headless-editor-Cipcv5df.mjs +44491 -0
  35. package/package.json +5 -2
  36. package/tailwind.preset.cjs +42 -0
  37. package/dist/index-By29BevC.mjs +0 -13126
  38. package/dist/markdown-source-pane-CYcEKMfr.mjs +0 -6069
  39. package/dist/tab-utils-CAcIp-Dt.mjs +0 -313
  40. package/dist/use-headless-editor-BIcZNvlS.mjs +0 -162510
@@ -0,0 +1,143 @@
1
+ var k = Object.defineProperty;
2
+ var v = (t, o, r) => o in t ? k(t, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[o] = r;
3
+ var d = (t, o, r) => v(t, typeof o != "symbol" ? o + "" : o, r);
4
+ import { jsx as C } from "react/jsx-runtime";
5
+ import { useRef as m, useEffect as f } from "react";
6
+ import { EditorState as b, Annotation as L, Transaction as S, RangeSetBuilder as y } from "@codemirror/state";
7
+ import { EditorView as u, lineNumbers as D, highlightActiveLine as E, highlightActiveLineGutter as w, keymap as H, ViewPlugin as P, placeholder as N, Decoration as A } from "@codemirror/view";
8
+ import { history as M, defaultKeymap as T, historyKeymap as W } from "@codemirror/commands";
9
+ import { markdown as $ } from "@codemirror/lang-markdown";
10
+ import { syntaxHighlighting as G, defaultHighlightStyle as K, syntaxTree as F } from "@codemirror/language";
11
+ const I = "Write your ideas. Watch them grow. 🌱", h = L.define(), O = /^https?:\/\/\S+$/i, R = u.domEventHandlers({
12
+ paste(t, o) {
13
+ var c, a;
14
+ const r = (a = (c = t.clipboardData) == null ? void 0 : c.getData("text/plain")) == null ? void 0 : a.trim();
15
+ if (!r || !O.test(r)) return !1;
16
+ const { from: s, to: e } = o.state.selection.main, l = o.state.sliceDoc(s, e), n = l ? `[${l}](${r})` : `<${r}>`;
17
+ return t.preventDefault(), o.dispatch({
18
+ changes: { from: s, to: e, insert: n },
19
+ selection: { anchor: s + n.length }
20
+ }), !0;
21
+ }
22
+ }), U = A.mark({ class: "cm-md-link" }), _ = /* @__PURE__ */ new Set(["Link", "Autolink"]), p = (t) => {
23
+ const o = new y();
24
+ for (const { from: r, to: s } of t.visibleRanges)
25
+ F(t.state).iterate({
26
+ from: r,
27
+ to: s,
28
+ enter: (e) => {
29
+ _.has(e.name) && e.to > e.from && o.add(e.from, e.to, U);
30
+ }
31
+ });
32
+ return o.finish();
33
+ }, j = P.fromClass(
34
+ class {
35
+ constructor(t) {
36
+ d(this, "decorations");
37
+ this.decorations = p(t);
38
+ }
39
+ update(t) {
40
+ (t.docChanged || t.viewportChanged) && (this.decorations = p(t.view));
41
+ }
42
+ },
43
+ { decorations: (t) => t.decorations }
44
+ ), z = u.theme({
45
+ "&": {
46
+ height: "100%",
47
+ fontSize: "14px",
48
+ backgroundColor: "transparent",
49
+ color: "hsl(var(--color-text-default))"
50
+ },
51
+ ".cm-scroller": {
52
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
53
+ lineHeight: "1.7",
54
+ padding: "12px 16px 12px 8px"
55
+ },
56
+ ".cm-content": { caretColor: "hsl(var(--color-text-default))", padding: "0" },
57
+ "&.cm-focused": { outline: "none" },
58
+ ".cm-gutters": {
59
+ backgroundColor: "transparent",
60
+ border: "none",
61
+ color: "hsl(var(--color-text-secondary))"
62
+ },
63
+ ".cm-lineNumbers .cm-gutterElement": {
64
+ minWidth: "26px",
65
+ padding: "0 8px 0 4px"
66
+ },
67
+ ".cm-activeLine": { backgroundColor: "hsl(var(--color-bg-secondary))" },
68
+ ".cm-activeLineGutter": { backgroundColor: "transparent" },
69
+ ".cm-cursor, .cm-dropCursor": {
70
+ borderLeftColor: "hsl(var(--color-text-default))"
71
+ },
72
+ // Markdown links use the editor's text-link token (override the default
73
+ // syntax color, incl. the inner highlight spans).
74
+ ".cm-md-link, .cm-md-link span": {
75
+ color: "hsla(var(--color-text-link)) !important"
76
+ }
77
+ });
78
+ function tt({
79
+ value: t,
80
+ onChange: o,
81
+ onViewReady: r
82
+ }) {
83
+ const s = m(null), e = m(null), l = m(o);
84
+ l.current = o;
85
+ const n = m(r);
86
+ return n.current = r, f(() => {
87
+ var a;
88
+ if (!s.current) return;
89
+ const c = new u({
90
+ parent: s.current,
91
+ state: b.create({
92
+ doc: t,
93
+ extensions: [
94
+ D(),
95
+ E(),
96
+ w(),
97
+ M(),
98
+ // Swallow Ctrl/Cmd+S so it doesn't open the browser "Save page"
99
+ // dialog — there's no manual save in Split View (changes are live).
100
+ H.of([
101
+ { key: "Mod-s", run: () => !0, preventDefault: !0 },
102
+ ...T,
103
+ ...W
104
+ ]),
105
+ $(),
106
+ G(K),
107
+ j,
108
+ R,
109
+ N(I),
110
+ u.lineWrapping,
111
+ z,
112
+ u.updateListener.of((i) => {
113
+ const g = i.transactions.some(
114
+ (x) => x.annotation(h)
115
+ );
116
+ i.docChanged && !g && l.current(i.state.doc.toString());
117
+ })
118
+ ]
119
+ })
120
+ });
121
+ return e.current = c, (a = n.current) == null || a.call(n, c), () => {
122
+ var i;
123
+ (i = n.current) == null || i.call(n, null), c.destroy(), e.current = null;
124
+ };
125
+ }, []), f(() => {
126
+ const c = e.current;
127
+ if (!c) return;
128
+ const a = c.state.doc.toString();
129
+ t !== a && c.dispatch({
130
+ changes: { from: 0, to: a.length, insert: t },
131
+ // Keep the seed out of the undo history: its base state is the empty
132
+ // mount-time doc, so an undo would revert the pane to empty and the
133
+ // change listener would replace the whole document with nothing.
134
+ annotations: [
135
+ h.of(!0),
136
+ S.addToHistory.of(!1)
137
+ ]
138
+ });
139
+ }, [t]), /* @__PURE__ */ C("div", { ref: s, className: "w-full h-full overflow-auto" });
140
+ }
141
+ export {
142
+ tt as default
143
+ };
@@ -0,0 +1,12 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { DdocProps } from '../types';
3
+
4
+ type EditorNavbarProps = {
5
+ editor: Editor | null;
6
+ renderNavbar?: DdocProps['renderNavbar'];
7
+ /** undefined: in flow. null: host element not attached yet, render nothing. */
8
+ container?: HTMLElement | null;
9
+ isHidden: boolean;
10
+ };
11
+ export declare const EditorNavbar: ({ editor, renderNavbar, container, isHidden, }: EditorNavbarProps) => import("react/jsx-runtime").JSX.Element | null;
12
+ export {};
@@ -4,7 +4,7 @@ import { FontDescriptor, IpfsImageFetchPayload, IpfsImageUploadResponse } from '
4
4
  import { Tab } from './tabs/utils/tab-utils';
5
5
 
6
6
  import * as Y from 'yjs';
7
- declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, isSplitView, onToggleSplitView, fonts: consumerFonts, renderToolbarLeading, }: {
7
+ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onError, isPresentationMode, setIsPresentationMode, enableCollaboration, zoomLevel, setZoomLevel, isNavbarVisible, setIsNavbarVisible, showNavbarToggle, ipfsImageUploadFn, onMarkdownExport, onMarkdownImport, onPdfExport, onHtmlExport, onTxtExport, onOdtExport, onDocxImport, ipfsImageFetchFn, fetchV1ImageFn, isConnected, tabs, ydoc, onRegisterExportTrigger, toggleFocusMode, isSplitView, onToggleSplitView, fonts: consumerFonts, renderToolbarLeading, }: {
8
8
  editor: Editor | null;
9
9
  onError?: (errorString: string) => void;
10
10
  isPresentationMode?: boolean;
@@ -14,6 +14,7 @@ declare const MemoizedTiptapToolBar: React.MemoExoticComponent<({ editor, onErro
14
14
  setZoomLevel: (zoom: string) => void;
15
15
  isNavbarVisible: boolean;
16
16
  setIsNavbarVisible: React.Dispatch<React.SetStateAction<boolean>>;
17
+ showNavbarToggle?: boolean;
17
18
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
18
19
  onMarkdownExport?: () => void;
19
20
  onMarkdownImport?: () => void;
@@ -4,8 +4,8 @@ import { DdocProps } from '../types';
4
4
  type FullScreenToolbarProps = {
5
5
  dropdownOpen: boolean;
6
6
  setDropdownOpen: Dispatch<SetStateAction<boolean>>;
7
- zoomLevel: DdocProps['zoomLevel'];
8
- setZoomLevel: DdocProps['setZoomLevel'];
7
+ zoomLevel: string;
8
+ setZoomLevel: Dispatch<SetStateAction<string>>;
9
9
  showTOC: DdocProps['showTOC'];
10
10
  setShowTOC: DdocProps['setShowTOC'];
11
11
  toggleFocusMode: () => Promise<void>;
@@ -2,12 +2,13 @@ import { default as React } from 'react';
2
2
  import { Editor } from '@tiptap/react';
3
3
  import { FontDescriptor, IpfsImageFetchPayload, IpfsImageUploadResponse } from '../types';
4
4
 
5
- declare const MemoizedMobileToolbar: React.MemoExoticComponent<({ editor, onError, isKeyboardVisible, isNavbarVisible, setIsNavbarVisible, ipfsImageUploadFn, ipfsImageFetchFn, fetchV1ImageFn, fonts, }: {
5
+ declare const MemoizedMobileToolbar: React.MemoExoticComponent<({ editor, onError, isKeyboardVisible, isNavbarVisible, setIsNavbarVisible, showNavbarToggle, ipfsImageUploadFn, ipfsImageFetchFn, fetchV1ImageFn, fonts, }: {
6
6
  editor: Editor | null;
7
7
  onError?: (errorString: string) => void;
8
8
  isKeyboardVisible: boolean;
9
9
  isNavbarVisible: boolean;
10
10
  setIsNavbarVisible: React.Dispatch<React.SetStateAction<boolean>>;
11
+ showNavbarToggle?: boolean;
11
12
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
12
13
  ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
13
14
  url: string;
@@ -25,5 +25,7 @@ export interface DocumentMobileTabPanelProps {
25
25
  isVersionHistoryMode: boolean;
26
26
  isConnected?: boolean;
27
27
  isFocusMode?: boolean;
28
+ layout?: DocumentOutlineProps['layout'];
29
+ tabPanelSlot?: HTMLElement | null;
28
30
  }
29
- export declare const DocumentMobileTabPanel: ({ tabs, activeTabId, setActiveTabId, editor, items, setItems, orientation, renameTab, createTab, duplicateTab, orderTab, deleteTab, tabCommentCounts, isPreviewMode, tabConfig, isVersionHistoryMode, isConnected, isFocusMode, }: DocumentMobileTabPanelProps) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const DocumentMobileTabPanel: ({ tabs, activeTabId, setActiveTabId, editor, items, setItems, orientation, renameTab, createTab, duplicateTab, orderTab, deleteTab, tabCommentCounts, isPreviewMode, tabConfig, isVersionHistoryMode, isConnected, isFocusMode, layout, tabPanelSlot, }: DocumentMobileTabPanelProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -32,9 +32,10 @@ export interface DocumentTabsSidebarProps {
32
32
  deleteTab?: (tabId: string) => void;
33
33
  isConnected?: boolean;
34
34
  isFocusMode?: boolean;
35
+ layout?: DocumentOutlineProps['layout'];
35
36
  }
36
37
  export declare const DocumentTabsSidebar: ({ tabSectionContainer, ...rest }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element | null;
37
- export declare const TabSidebar: ({ tabs, activeTabId, setActiveTabId, showTOC, setShowTOC, hasToC, isPreviewMode, editor, items, setItems, orientation, createTab, renameTab, duplicateTab, orderTab, tabCommentCounts, isVersionHistoryMode, tabConfig, deleteTab, isConnected, isFocusMode, }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element;
38
+ export declare const TabSidebar: ({ tabs, activeTabId, setActiveTabId, showTOC, setShowTOC, hasToC, isPreviewMode, editor, items, setItems, orientation, createTab, renameTab, duplicateTab, orderTab, tabCommentCounts, isVersionHistoryMode, tabConfig, deleteTab, isConnected, isFocusMode, layout, }: DocumentTabsSidebarProps) => import("react/jsx-runtime").JSX.Element;
38
39
  export declare const DdocTab: ({ tab, tabIndex, tabCount, handleEmojiChange, handleNameChange, onClick, editor, tocItem, setTocItems, orientation, activeTabId, duplicateTab, commentCount, moveTabUp, moveTabDown, isPreviewMode, isVersionHistoryMode, tabConfig, onDelete, showOutline, onShowOutlineChange, isConnected, }: {
39
40
  tab: Tab;
40
41
  tabIndex: number;
@@ -1,3 +1,3 @@
1
1
  import { DocumentOutlineProps } from './types';
2
2
 
3
- export declare const DocumentOutline: ({ editor, hasToC, items, setItems, showTOC, setShowTOC, isPreviewMode, orientation, tabs, setTabs, activeTabId, setActiveTabId, createTab, renameTab, duplicateTab, orderTab, ydoc, tabCommentCounts, tabSectionContainer, isVersionHistoryMode, tabConfig, deleteTab, isConnected, isFocusMode, }: DocumentOutlineProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const DocumentOutline: ({ editor, hasToC, items, setItems, showTOC, setShowTOC, isPreviewMode, orientation, tabs, setTabs, activeTabId, setActiveTabId, createTab, renameTab, duplicateTab, orderTab, ydoc, tabCommentCounts, tabSectionContainer, isVersionHistoryMode, tabConfig, deleteTab, isConnected, isFocusMode, layout, tabPanelSlot, }: DocumentOutlineProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { ToCProps, ToCItemProps } from './types';
2
2
 
3
- export declare const ToCItem: import('react').MemoExoticComponent<({ item, onItemClick, index, orientation, }: ToCItemProps) => import("react/jsx-runtime").JSX.Element>;
3
+ export declare const ToCItem: import('react').MemoExoticComponent<({ item, onItemClick, index, orientation, isMobile, isWide, }: ToCItemProps) => import("react/jsx-runtime").JSX.Element>;
4
4
  export declare const ToCEmptyState: import('react').MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
5
5
  export declare const ToC: import('react').MemoExoticComponent<({ items, editor, setItems, orientation }: ToCProps) => import("react/jsx-runtime").JSX.Element>;
@@ -22,6 +22,10 @@ export type ToCItemProps = {
22
22
  onItemRemove: (e: React.MouseEvent, id: string) => void;
23
23
  index: number;
24
24
  orientation?: 'portrait' | 'landscape';
25
+ /** At or below 1280px: the item is in the mobile list. */
26
+ isMobile?: boolean;
27
+ /** At or above 1280px: the item takes the rail's width caps. */
28
+ isWide?: boolean;
25
29
  };
26
30
  export interface DocumentOutlineProps {
27
31
  editor: Editor;
@@ -54,4 +58,7 @@ export interface DocumentOutlineProps {
54
58
  deleteTab?: (tabId: string) => void;
55
59
  isConnected?: boolean;
56
60
  isFocusMode?: boolean;
61
+ /** 'contained': sized from the editor canvas. Only DdocEditor passes it. */
62
+ layout?: 'viewport' | 'contained';
63
+ tabPanelSlot?: HTMLElement | null;
57
64
  }
@@ -1,4 +1,4 @@
1
- export declare function emojiSearch(query: string): {
1
+ export declare function emojiSearch(query: string): Promise<{
2
2
  name: string;
3
3
  emoji: string;
4
- }[];
4
+ }[]>;
@@ -0,0 +1,16 @@
1
+ import { RefObject } from 'react';
2
+ import { EditorWidthStore } from '../utils/editor-width-store';
3
+
4
+ export declare const computeWidthDecisions: (width: number, scaledWidth: number, leftWidth: number) => {
5
+ shouldHideRight: boolean;
6
+ shouldScroll: boolean;
7
+ };
8
+ type WidthDecisions = ReturnType<typeof computeWidthDecisions>;
9
+ export declare const useCanvasMetrics: ({ canvasRef, rootRef, scaledWidth, leftWidth, widthStore, }: {
10
+ canvasRef: RefObject<HTMLElement | null>;
11
+ rootRef: RefObject<HTMLElement | null>;
12
+ scaledWidth: number;
13
+ leftWidth: number;
14
+ widthStore?: EditorWidthStore;
15
+ }) => WidthDecisions;
16
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+
3
+ export declare const useControllableState: <T>(value: T | undefined, defaultValue: T, onChange?: (next: T) => void, legacySetter?: (next: T) => void) => [T, Dispatch<SetStateAction<T>>];
@@ -0,0 +1,4 @@
1
+ import { EditorWidthStore } from '../utils/editor-width-store';
2
+
3
+ export declare const EditorWidthContext: import('react').Context<EditorWidthStore | null>;
4
+ export declare const useEditorMediaQuery: (query: string, store?: EditorWidthStore) => boolean;
@@ -1,9 +1,7 @@
1
1
  type UseFocusModeOptions = {
2
- /** Notify callback — fires on every toggle in both modes (existing API). */
2
+ /** @deprecated Use onFocusModeChange. Still fires on every change. */
3
3
  onFocusMode?: (isFocusMode: boolean) => void;
4
- /** Controlled value (D6). Omit for the legacy internal-state behavior. */
5
4
  isFocusMode?: boolean;
6
- /** Controlled setter — receives the next value instead of internal mutation. */
7
5
  onFocusModeChange?: (isFocusMode: boolean) => void;
8
6
  };
9
7
  export declare const useFocusMode: ({ onFocusMode, isFocusMode: controlledValue, onFocusModeChange, }?: UseFocusModeOptions) => {
@@ -4,12 +4,14 @@ import { AnyExtension, Editor } from '@tiptap/react';
4
4
  import { CommentAnchor } from '../extensions/comment/comment-decoration-plugin';
5
5
  import { DBlockRuntimeStateRef } from '../extensions/d-block/dblock-runtime';
6
6
  import { ToCItemType } from '../components/toc/types';
7
+ import { EditorWidthStore } from '../utils/editor-width-store';
7
8
  import { CollabConnectionConfig, CollaborationProps } from '../sync-local/types';
8
9
 
9
10
  import * as Y from 'yjs';
10
11
  export declare const TAB_EDITOR_ATTRIBUTES: Record<string, string>;
11
12
  interface UseTabEditorArgs {
12
13
  ydoc: Y.Doc;
14
+ editorWidthStore?: EditorWidthStore;
13
15
  isVersionMode?: boolean;
14
16
  hasTabState?: boolean;
15
17
  versionId?: string;
@@ -36,6 +38,7 @@ interface UseTabEditorArgs {
36
38
  setWordCount?: DdocProps['setWordCount'];
37
39
  setSelectedWordCount?: DdocProps['setSelectedWordCount'];
38
40
  setPageCount?: DdocProps['setPageCount'];
41
+ onStatsChange?: DdocProps['onStatsChange'];
39
42
  setIsContentLoading: Dispatch<SetStateAction<boolean>>;
40
43
  setIsCollabContentLoading: Dispatch<SetStateAction<boolean>>;
41
44
  unFocused?: boolean;
@@ -58,7 +61,7 @@ interface UseTabEditorArgs {
58
61
  dBlockRuntimeStateRef?: DBlockRuntimeStateRef;
59
62
  docSchemaVersion?: number;
60
63
  }
61
- export declare const useTabEditor: ({ ydoc, isVersionMode, hasTabState, versionId, isPreviewMode, viewerMode, initialContent, collaboration, isReady, awareness, disableInlineComment, isFocusMode, onCommentInteraction, onError, ipfsImageUploadFn, metadataProxyUrl, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, setCharacterCount, setWordCount, setSelectedWordCount, setPageCount, setIsContentLoading, setIsCollabContentLoading, unFocused, zoomLevel, isPresentationMode, onInvalidContentError, ignoreCorruptedData, onConnect, onDisconnect, isIndexeddbSynced, hasCollabContentInitialised, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, tabIds, theme, editorRef, initialCommentAnchors, dBlockRuntimeStateRef, docSchemaVersion, }: UseTabEditorArgs) => {
64
+ export declare const useTabEditor: ({ ydoc, editorWidthStore, isVersionMode, hasTabState, versionId, isPreviewMode, viewerMode, initialContent, collaboration, isReady, awareness, disableInlineComment, isFocusMode, onCommentInteraction, onError, ipfsImageUploadFn, metadataProxyUrl, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, setCharacterCount, setWordCount, setSelectedWordCount, setPageCount, onStatsChange, setIsContentLoading, setIsCollabContentLoading, unFocused, zoomLevel, isPresentationMode, onInvalidContentError, ignoreCorruptedData, onConnect, onDisconnect, isIndexeddbSynced, hasCollabContentInitialised, initialiseYjsIndexedDbProvider, externalExtensions, isContentLoading, activeTabId, tabIds, theme, editorRef, initialCommentAnchors, dBlockRuntimeStateRef, docSchemaVersion, }: UseTabEditorArgs) => {
62
65
  editor: Editor | null;
63
66
  cachedEditorEntries: import('./use-tab-editor-cache').CachedTabEditorRenderEntry[];
64
67
  ref: import('react').RefObject<HTMLDivElement>;
@@ -126,6 +126,13 @@ export interface DocumentStyling {
126
126
  */
127
127
  customCSS?: string;
128
128
  }
129
+ export type DdocStats = {
130
+ words: number;
131
+ characters: number;
132
+ selectedWords: number;
133
+ /** null until the active tab has been measured. */
134
+ pages: number | null;
135
+ };
129
136
  export interface DdocProps extends CommentAccountProps {
130
137
  /**
131
138
  * Optional catalog of fonts available to the editor in addition to the
@@ -162,6 +169,8 @@ export interface DdocProps extends CommentAccountProps {
162
169
  fetchV1ImageFn?: (url: string) => Promise<ArrayBuffer | undefined>;
163
170
  disableInlineComment?: boolean;
164
171
  commentDrawerOpen?: boolean;
172
+ onCommentDrawerOpenChange?: (open: boolean) => void;
173
+ /** @deprecated Use onCommentDrawerOpenChange. */
165
174
  setCommentDrawerOpen?: React.Dispatch<SetStateAction<boolean>>;
166
175
  initialComments?: IComment[];
167
176
  initialCommentAnchors?: SerializedCommentAnchor[];
@@ -175,6 +184,8 @@ export interface DdocProps extends CommentAccountProps {
175
184
  onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
176
185
  onDeleteReply?: (activeCommentId: string, replyId: string) => void;
177
186
  showTOC?: boolean;
187
+ onShowTOCChange?: (show: boolean) => void;
188
+ /** @deprecated Use onShowTOCChange. */
178
189
  setShowTOC?: React.Dispatch<SetStateAction<boolean>>;
179
190
  extensions?: Record<string, Extension | any>;
180
191
  selectedTags?: TagType[];
@@ -184,13 +195,19 @@ export interface DdocProps extends CommentAccountProps {
184
195
  inlineCommentData?: InlineCommentData;
185
196
  setInlineCommentData?: React.Dispatch<React.SetStateAction<InlineCommentData>>;
186
197
  theme?: ThemeKey;
187
- zoomLevel: string;
188
- setZoomLevel: React.Dispatch<SetStateAction<string>>;
189
- isNavbarVisible: boolean;
190
- setIsNavbarVisible: React.Dispatch<SetStateAction<boolean>>;
198
+ /** Defaults to '1' when omitted. */
199
+ zoomLevel?: string;
200
+ onZoomLevelChange?: (zoomLevel: string) => void;
201
+ /** @deprecated Use onZoomLevelChange. */
202
+ setZoomLevel?: React.Dispatch<SetStateAction<string>>;
203
+ /** Defaults to true when omitted. */
204
+ isNavbarVisible?: boolean;
205
+ onNavbarVisibleChange?: (visible: boolean) => void;
206
+ /** @deprecated Use onNavbarVisibleChange. */
207
+ setIsNavbarVisible?: React.Dispatch<SetStateAction<boolean>>;
191
208
  editorCanvasClassNames?: string;
192
209
  isCommentSectionOpen?: boolean;
193
- isPreviewMode: boolean;
210
+ isPreviewMode?: boolean;
194
211
  viewerMode?: 'suggest' | 'view-only';
195
212
  ensResolutionUrl?: string;
196
213
  /**
@@ -215,6 +232,13 @@ export interface DdocProps extends CommentAccountProps {
215
232
  walletAddress?: string | null;
216
233
  username?: string | null;
217
234
  setUsername?: React.Dispatch<SetStateAction<string>>;
235
+ /**
236
+ * Host element to render the navbar into. Omit to render it as the editor's
237
+ * first row. Pass null while the element is not attached yet.
238
+ */
239
+ navbarContainer?: HTMLElement | null;
240
+ /** Show the toolbar's navbar collapse chevron. Default true. */
241
+ showNavbarToggle?: boolean;
218
242
  renderNavbar?: ({ editor, liveEditor, }: {
219
243
  /** JSON snapshot — legacy field, unchanged. */
220
244
  editor: JSONContent;
@@ -252,9 +276,15 @@ export interface DdocProps extends CommentAccountProps {
252
276
  */
253
277
  enableFanficTemplate?: boolean;
254
278
  onError?: (error: string) => void;
279
+ /** Active-tab stats. Fires with all four fields whenever one changes. */
280
+ onStatsChange?: (stats: DdocStats) => void;
281
+ /** @deprecated Use onStatsChange. */
255
282
  setCharacterCount?: React.Dispatch<SetStateAction<number>>;
283
+ /** @deprecated Use onStatsChange. */
256
284
  setWordCount?: React.Dispatch<SetStateAction<number>>;
285
+ /** @deprecated Use onStatsChange. */
257
286
  setSelectedWordCount?: React.Dispatch<SetStateAction<number>>;
287
+ /** @deprecated Use onStatsChange. */
258
288
  setPageCount?: React.Dispatch<SetStateAction<number>>;
259
289
  tags?: Array<{
260
290
  name: string;
@@ -263,12 +293,17 @@ export interface DdocProps extends CommentAccountProps {
263
293
  className?: string;
264
294
  unFocused?: boolean;
265
295
  isPresentationMode?: boolean;
296
+ onPresentationModeChange?: (active: boolean) => void;
297
+ /** @deprecated Use onPresentationModeChange. */
266
298
  setIsPresentationMode?: React.Dispatch<SetStateAction<boolean>>;
267
299
  /** Split View: edit markdown on the left, see the read-only ddoc render on the right. */
268
300
  isSplitView?: boolean;
301
+ onSplitViewChange?: (active: boolean) => void;
302
+ /** @deprecated Use onSplitViewChange. */
269
303
  setIsSplitView?: React.Dispatch<SetStateAction<boolean>>;
270
304
  onComment?: () => void;
271
305
  onInlineComment?: () => void;
306
+ /** @deprecated Use onFocusModeChange. Still fires on every change. */
272
307
  onFocusMode?: (isFocusMode: boolean) => void;
273
308
  /** Controlled focus mode (D6). Omit for the legacy internal-state behavior. */
274
309
  isFocusMode?: boolean;
@@ -294,6 +329,7 @@ export interface DdocProps extends CommentAccountProps {
294
329
  renderToolbarLeading?: () => React.ReactNode;
295
330
  metadataProxyUrl?: string;
296
331
  onCopyHeadingLink?: (link: string) => void;
332
+ /** @deprecated No effect. The host footer sits outside the editor. */
297
333
  footerHeight?: string;
298
334
  activeModel?: CustomModel;
299
335
  maxTokens?: number;
@@ -1,10 +1,12 @@
1
1
  import { DdocProps } from './types';
2
2
  import { Editor } from '@tiptap/react';
3
3
  import { DBlockRuntimeState } from './extensions/d-block/dblock-runtime';
4
+ import { EditorWidthStore } from './utils/editor-width-store';
4
5
 
5
- export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent, versionHistoryState, collaboration, onChange, onLocalChange, isNewDocument, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setSelectedWordCount, setPageCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, isPreviewEditor, fonts, preferredSchemaVersion, onSchemaStampGuard, ...rest }: Partial<DdocProps> & {
6
+ export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent, versionHistoryState, collaboration, onChange, onLocalChange, isNewDocument, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, setSelectedWordCount, setPageCount, onStatsChange, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, isFocusMode, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, initialCommentAnchors, isPreviewEditor, fonts, preferredSchemaVersion, editorWidthStore, onSchemaStampGuard, ...rest }: Partial<DdocProps> & {
6
7
  isFocusMode?: boolean;
7
8
  isPreviewEditor?: boolean;
9
+ editorWidthStore?: EditorWidthStore;
8
10
  }) => {
9
11
  ydoc: import('yjs').Doc;
10
12
  awareness: import('y-protocols/awareness.js').Awareness | null;
@@ -0,0 +1 @@
1
+ export declare const canUseEditorContainerQueries: () => boolean;
@@ -0,0 +1,6 @@
1
+ export type EditorWidthStore = {
2
+ get(): number | null;
3
+ set(width: number): void;
4
+ subscribe(listener: () => void): () => void;
5
+ };
6
+ export declare const createEditorWidthStore: () => EditorWidthStore;
@@ -1,4 +1,6 @@
1
- export declare const useResponsive: () => {
1
+ import { EditorWidthStore } from './editor-width-store';
2
+
3
+ export declare const useResponsive: (store?: EditorWidthStore) => {
2
4
  isBelow1024px: boolean;
3
5
  isBelow1280px: boolean;
4
6
  isMobileScreen: boolean;
@@ -0,0 +1,8 @@
1
+ import { DdocStats } from '../types';
2
+
3
+ export declare const createStatsPublisher: (emit: (stats: DdocStats) => void) => {
4
+ beginTab(pages: number | null): void;
5
+ publish(patch: Partial<DdocStats>, options?: {
6
+ tick?: boolean;
7
+ }): void;
8
+ };
@@ -1,4 +1,4 @@
1
- import { D as n, a as o, d as D, g as a, m as r, r as d, b as C } from "./ddoc-persistence-C2ay3lLb.mjs";
1
+ import { D as n, a as o, d as D, g as a, m as r, r as d, b as C } from "./ddoc-persistence-DLdSviUr.mjs";
2
2
  export {
3
3
  n as DDOC_STORE_REPAIRED,
4
4
  o as DEFAULT_DDOC_PERSISTENCE_TIMEOUT_MS,