@xcrong/docx-editor-vue 1.10.1

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 (110) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +116 -0
  3. package/dist/KeyboardShortcutsDialog-60tuBVsM.js +2799 -0
  4. package/dist/KeyboardShortcutsDialog-BcNYSl3S.cjs +1 -0
  5. package/dist/RenderedDomContext-CuV0wMPx.js +2 -0
  6. package/dist/TablePropertiesDialog-CG6Yj6KO.js +1145 -0
  7. package/dist/TablePropertiesDialog-CzY5A22W.cjs +1 -0
  8. package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
  9. package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
  10. package/dist/components/DocxEditor/types.d.ts +193 -0
  11. package/dist/components/EditorToolbarContext.d.ts +9 -0
  12. package/dist/components/Toolbar/presets.d.ts +20 -0
  13. package/dist/components/dialogs/index.d.ts +27 -0
  14. package/dist/components/imageContextMenuTypes.d.ts +30 -0
  15. package/dist/components/imageSelectionTypes.d.ts +14 -0
  16. package/dist/components/insertTableState.d.ts +9 -0
  17. package/dist/components/sidebar/cardStyles.d.ts +3 -0
  18. package/dist/components/sidebar/cardUtils.d.ts +1 -0
  19. package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
  20. package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
  21. package/dist/components/tableStylePresets.d.ts +53 -0
  22. package/dist/components/toolbarUtils.d.ts +1 -0
  23. package/dist/components/ui/Icons.d.ts +1 -0
  24. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  25. package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
  26. package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
  27. package/dist/composables/fileOpen.test.d.ts +1 -0
  28. package/dist/composables/imageOverlayRect.d.ts +44 -0
  29. package/dist/composables/imageOverlayRect.test.d.ts +1 -0
  30. package/dist/composables/index.d.ts +30 -0
  31. package/dist/composables/useAutoSave.d.ts +40 -0
  32. package/dist/composables/useClipboard.d.ts +22 -0
  33. package/dist/composables/useColorMode.d.ts +8 -0
  34. package/dist/composables/useCommentLifecycle.d.ts +62 -0
  35. package/dist/composables/useCommentManagement.d.ts +68 -0
  36. package/dist/composables/useCommentSidebarItems.d.ts +24 -0
  37. package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
  38. package/dist/composables/useContextMenus.cut.test.d.ts +1 -0
  39. package/dist/composables/useContextMenus.d.ts +39 -0
  40. package/dist/composables/useControllableBoolean.d.ts +16 -0
  41. package/dist/composables/useControllableBoolean.test.d.ts +1 -0
  42. package/dist/composables/useDocumentLifecycle.d.ts +11 -0
  43. package/dist/composables/useDocxEditor.d.ts +96 -0
  44. package/dist/composables/useDocxEditorRefApi.d.ts +53 -0
  45. package/dist/composables/useDragAutoScroll.d.ts +11 -0
  46. package/dist/composables/useFileIO.d.ts +41 -0
  47. package/dist/composables/useFindReplace.d.ts +34 -0
  48. package/dist/composables/useFixedDropdown.d.ts +14 -0
  49. package/dist/composables/useFontLifecycle.d.ts +12 -0
  50. package/dist/composables/useFormattingActions.d.ts +31 -0
  51. package/dist/composables/useHistory.d.ts +9 -0
  52. package/dist/composables/useHostCallbacks.d.ts +7 -0
  53. package/dist/composables/useHyperlinkManagement.d.ts +38 -0
  54. package/dist/composables/useImageActions.d.ts +24 -0
  55. package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
  56. package/dist/composables/useMenuActions.d.ts +26 -0
  57. package/dist/composables/useOutlineSidebar.d.ts +24 -0
  58. package/dist/composables/useOutlineSidebar.test.d.ts +1 -0
  59. package/dist/composables/usePageSetupControls.d.ts +22 -0
  60. package/dist/composables/usePagesPointer.d.ts +86 -0
  61. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  62. package/dist/composables/usePortalClass.d.ts +8 -0
  63. package/dist/composables/useSelectionHighlight.d.ts +19 -0
  64. package/dist/composables/useSelectionSync.d.ts +37 -0
  65. package/dist/composables/useTableResize.d.ts +7 -0
  66. package/dist/composables/useTableSelection.d.ts +10 -0
  67. package/dist/composables/useToolbarDropdowns.d.ts +15 -0
  68. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  69. package/dist/composables/useTrackedChanges.d.ts +12 -0
  70. package/dist/composables/useVisualLineNavigation.d.ts +11 -0
  71. package/dist/composables/useWatermarkControls.d.ts +15 -0
  72. package/dist/composables/useWheelZoom.d.ts +10 -0
  73. package/dist/composables/useZoom.d.ts +16 -0
  74. package/dist/composables.cjs +1 -0
  75. package/dist/composables.js +401 -0
  76. package/dist/dialogs.cjs +1 -0
  77. package/dist/dialogs.js +3 -0
  78. package/dist/docx-editor-vue.css +2 -0
  79. package/dist/i18n/LocaleContext.d.ts +1 -0
  80. package/dist/i18n/index.d.ts +26 -0
  81. package/dist/index.cjs +19 -0
  82. package/dist/index.d.ts +24 -0
  83. package/dist/index.js +4506 -0
  84. package/dist/lib/utils.d.ts +10 -0
  85. package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
  86. package/dist/plugin-api/index.d.ts +18 -0
  87. package/dist/plugin-api/types.d.ts +28 -0
  88. package/dist/plugin-api.cjs +1 -0
  89. package/dist/plugin-api.js +62 -0
  90. package/dist/renderAsync.d.ts +31 -0
  91. package/dist/styles/index.d.ts +12 -0
  92. package/dist/styles/zIndex.d.ts +24 -0
  93. package/dist/styles.cjs +1 -0
  94. package/dist/styles.js +5 -0
  95. package/dist/ui.cjs +18 -0
  96. package/dist/ui.d.ts +79 -0
  97. package/dist/ui.js +986 -0
  98. package/dist/useCommentSidebarItems-DBeGKNGA.cjs +1 -0
  99. package/dist/useCommentSidebarItems-DXbF857R.js +45 -0
  100. package/dist/useDragAutoScroll-BzP7c_lM.cjs +1 -0
  101. package/dist/useDragAutoScroll-DOXQJ0os.js +520 -0
  102. package/dist/usePortalClass-C91WJPlr.js +3534 -0
  103. package/dist/usePortalClass-Ciqvd8GU.cjs +4 -0
  104. package/dist/utils/domQueries.d.ts +46 -0
  105. package/dist/utils/domQueries.test.d.ts +1 -0
  106. package/dist/utils/imageClipboard.d.ts +9 -0
  107. package/dist/utils/refApiQueries.d.ts +10 -0
  108. package/dist/zIndex-CH0jZ7U7.cjs +1 -0
  109. package/dist/zIndex-CxELVe_L.js +12 -0
  110. package/package.json +119 -0
@@ -0,0 +1,38 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { HyperlinkPopupData } from '../components/ui/hyperlinkPopupTypes';
4
+ export type { HyperlinkPopupData };
5
+ type Commands = Record<string, (...args: unknown[]) => unknown>;
6
+ export interface UseHyperlinkManagementOptions {
7
+ editorView: Ref<EditorView | null>;
8
+ getCommands: () => Commands;
9
+ }
10
+ export declare function useHyperlinkManagement(opts: UseHyperlinkManagementOptions): {
11
+ hyperlinkPopupData: Ref<{
12
+ href: string;
13
+ displayText: string;
14
+ tooltip?: string | undefined;
15
+ position: {
16
+ top: number;
17
+ left: number;
18
+ };
19
+ } | null, HyperlinkPopupData | {
20
+ href: string;
21
+ displayText: string;
22
+ tooltip?: string | undefined;
23
+ position: {
24
+ top: number;
25
+ left: number;
26
+ };
27
+ } | null>;
28
+ handleHyperlinkSubmit: (data: {
29
+ url?: string;
30
+ bookmark?: string;
31
+ displayText: string;
32
+ tooltip: string;
33
+ }) => void;
34
+ handleHyperlinkRemove: () => void;
35
+ handleHyperlinkPopupNavigate: (href: string) => void;
36
+ handleHyperlinkPopupEdit: (displayText: string, href: string) => void;
37
+ handleHyperlinkPopupRemove: () => void;
38
+ };
@@ -0,0 +1,24 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { ImageSelectionInfo } from '../components/imageSelectionTypes';
4
+ type Commands = Record<string, ((...args: unknown[]) => unknown) | undefined>;
5
+ export interface UseImageActionsOptions {
6
+ editorView: Ref<EditorView | null>;
7
+ zoom: Ref<number>;
8
+ stateTick: Ref<number>;
9
+ getCommands: () => Commands;
10
+ }
11
+ export interface ImageToolbarContext {
12
+ wrapType: string;
13
+ displayMode: string;
14
+ cssFloat: string | null;
15
+ }
16
+ export interface UseImageActionsReturn {
17
+ selectedImage: import('vue').ShallowRef<ImageSelectionInfo | null>;
18
+ imageInteracting: import('vue').Ref<boolean>;
19
+ imageToolbarContext: import('vue').ComputedRef<ImageToolbarContext | null>;
20
+ handleToolbarImageWrap: (value: string) => void;
21
+ handleImageTransform: (action: 'rotateCW' | 'rotateCCW' | 'flipH' | 'flipV') => void;
22
+ }
23
+ export declare function useImageActions(opts: UseImageActionsOptions): UseImageActionsReturn;
24
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Ref } from 'vue';
2
+ export interface UseKeyboardShortcutsOptions {
3
+ showKeyboardShortcuts: Ref<boolean>;
4
+ showFindReplace: Ref<boolean>;
5
+ showHyperlink: Ref<boolean>;
6
+ /** From useZoom — handles Ctrl+= / Ctrl+- / Ctrl+0. */
7
+ handleZoomKeyDown: (e: KeyboardEvent) => void;
8
+ /**
9
+ * Host prop accessor — read freshly inside the handler so a host
10
+ * toggle at runtime is honored. (Capturing the prop value at setup
11
+ * time would freeze it.)
12
+ */
13
+ disableFindReplaceShortcuts?: () => boolean | undefined;
14
+ /**
15
+ * Whether `File > Open` / Cmd+O is enabled. Read freshly so a runtime host
16
+ * toggle is honored. When false (or `onOpenDocument` is absent), Cmd+O is
17
+ * left unhandled so the browser default stands.
18
+ */
19
+ showFileOpen?: () => boolean | undefined;
20
+ /** Opens the DOCX picker — wired to the same hidden input as File > Open. */
21
+ onOpenDocument?: () => void;
22
+ }
23
+ export declare function useKeyboardShortcuts(opts: UseKeyboardShortcutsOptions): {
24
+ handleKeyDown: (e: KeyboardEvent) => void;
25
+ };
@@ -0,0 +1,26 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ export interface UseMenuActionsOptions {
4
+ editorView: Ref<EditorView | null>;
5
+ getCommands: () => Record<string, (...args: any[]) => any>;
6
+ docxInputRef: Ref<HTMLInputElement | null>;
7
+ imageInputRef: Ref<HTMLInputElement | null>;
8
+ showPageSetup: Ref<boolean>;
9
+ showWatermark: Ref<boolean>;
10
+ showHyperlink: Ref<boolean>;
11
+ showInsertSymbol: Ref<boolean>;
12
+ showKeyboardShortcuts: Ref<boolean>;
13
+ handleClearFormatting: () => void;
14
+ handleInsertPageBreak: () => void;
15
+ handleInsertSectionBreakNextPage: () => void;
16
+ handleInsertSectionBreakContinuous: () => void;
17
+ handleToggleOutline: () => void;
18
+ handleToggleSidebar: () => void;
19
+ downloadCurrentDocument: () => Promise<void>;
20
+ emit: (event: string, ...args: unknown[]) => void;
21
+ }
22
+ export declare function useMenuActions(opts: UseMenuActionsOptions): {
23
+ handleMenuAction: (action: string) => void;
24
+ handleMenuTableInsert: (rows: number, cols: number) => void;
25
+ execSimpleCommand: (name: string) => void;
26
+ };
@@ -0,0 +1,24 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { HeadingInfo } from '@xcrong/docx-editor-core/utils/headingCollector';
4
+ export interface UseOutlineSidebarOptions {
5
+ editorView: Ref<EditorView | null>;
6
+ showOutline: Ref<boolean>;
7
+ showSidebar: Ref<boolean>;
8
+ outlineHeadings: Ref<HeadingInfo[]>;
9
+ activeSidebarItem: Ref<string | null>;
10
+ extractCommentsAndChanges: () => void;
11
+ /**
12
+ * Scroll the VISIBLE paged viewport to a PM position. The hidden PM
13
+ * (`left: -9999px`) is never what the user sees, so `tr.scrollIntoView()`
14
+ * on it does nothing; the outline must drive the painter viewport instead
15
+ * (mirrors React's `scrollToPosition`; #930).
16
+ */
17
+ scrollToVisiblePosition: (pmPos: number) => void;
18
+ }
19
+ export declare function useOutlineSidebar(opts: UseOutlineSidebarOptions): {
20
+ handleToggleOutline: () => void;
21
+ handleOutlineNavigate: (pmPos: number) => void;
22
+ handleToggleSidebar: () => void;
23
+ handleEditorScrollMouseDown: (event: MouseEvent) => void;
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { Document, SectionProperties } from '@xcrong/docx-editor-core/types/document';
4
+ export interface UsePageSetupControlsOptions {
5
+ editorView: Ref<EditorView | null>;
6
+ getDocument: () => Document | null;
7
+ readOnly: Ref<boolean>;
8
+ stateTick: Ref<number>;
9
+ reLayout: () => void;
10
+ emit: (event: string, ...args: unknown[]) => void;
11
+ }
12
+ export declare function usePageSetupControls(opts: UsePageSetupControlsOptions): {
13
+ handlePageSetupApply: (sp: Partial<SectionProperties>) => void;
14
+ handleLeftMarginChange: (twips: number) => void;
15
+ handleRightMarginChange: (twips: number) => void;
16
+ handleTopMarginChange: (twips: number) => void;
17
+ handleBottomMarginChange: (twips: number) => void;
18
+ handleIndentLeftChange: (twips: number) => void;
19
+ handleIndentRightChange: (twips: number) => void;
20
+ handleFirstLineIndentChange: (twips: number) => void;
21
+ handleTabStopRemove: (positionTwips: number) => void;
22
+ };
@@ -0,0 +1,86 @@
1
+ import { Ref, ShallowRef } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { HeaderFooter, BlockContent } from '@xcrong/docx-editor-core/types/content';
4
+ import { Document } from '@xcrong/docx-editor-core/types/document';
5
+ import { ImageSelectionInfo } from '../components/imageSelectionTypes';
6
+ import { Layout } from '@xcrong/docx-editor-core/layout-engine';
7
+ import { HyperlinkPopupData } from '../components/ui/hyperlinkPopupTypes';
8
+ type TableResizeApi = {
9
+ tryStartResize: (e: MouseEvent, view: EditorView) => boolean;
10
+ isResizing: Ref<boolean>;
11
+ };
12
+ type Commands = Record<string, ((...args: unknown[]) => unknown) | undefined>;
13
+ export interface TableInsertButton {
14
+ type: 'row' | 'column';
15
+ x: number;
16
+ y: number;
17
+ cellPmPos: number;
18
+ }
19
+ export interface HfEditState {
20
+ position: 'header' | 'footer';
21
+ rId: string | null;
22
+ headerFooter: HeaderFooter | null;
23
+ targetRect: {
24
+ top: number;
25
+ left: number;
26
+ width: number;
27
+ height: number;
28
+ } | null;
29
+ }
30
+ export interface ScrollPageInfo {
31
+ currentPage: number;
32
+ totalPages: number;
33
+ visible: boolean;
34
+ }
35
+ export interface UsePagesPointerOptions {
36
+ editorView: Ref<EditorView | null>;
37
+ pagesRef: Ref<HTMLElement | null>;
38
+ pagesViewportRef: Ref<HTMLElement | null>;
39
+ selectedImage: ShallowRef<ImageSelectionInfo | null>;
40
+ imageInteracting: Ref<boolean>;
41
+ hyperlinkPopupData: Ref<HyperlinkPopupData | null>;
42
+ readOnly: Ref<boolean>;
43
+ zoom: Ref<number>;
44
+ layout: Ref<Layout | null>;
45
+ tableResize: TableResizeApi;
46
+ getCommands: () => Commands;
47
+ getDocument: () => Document | null;
48
+ reLayout: () => void;
49
+ emit: (event: string, ...args: unknown[]) => void;
50
+ clearOverlay: () => void;
51
+ /**
52
+ * Vue parity for the HF editing unification (openspec/changes/unify-hf-editing).
53
+ * Re-mount HF EditorViews when `package.headers/footers` content
54
+ * changes — exposed by `useDocxEditor.syncHfPMs`. Called after every
55
+ * save so the persistent PM points at the new HeaderFooter object.
56
+ * Optional so existing consumers can no-op until they wire it through.
57
+ */
58
+ syncHfPMs?: () => void;
59
+ /** Resolve the persistent EditorView for an HF instance (for click routing). */
60
+ getHfPmView?: (hf: import('@xcrong/docx-editor-core/types/content').HeaderFooter) => import('prosemirror-view').EditorView | null;
61
+ /**
62
+ * Replace the loaded Document — used by HF materialisation to publish a
63
+ * fresh Document object instead of mutating in place. Optional; if absent,
64
+ * callers fall back to in-place mutation + `syncHfPMs()`.
65
+ */
66
+ setDocument?: (doc: Document) => void;
67
+ }
68
+ export interface UsePagesPointerReturn {
69
+ tableInsertButton: Ref<TableInsertButton | null>;
70
+ hfEdit: ShallowRef<HfEditState | null>;
71
+ scrollPageInfo: Ref<ScrollPageInfo>;
72
+ resolvePos: (clientX: number, clientY: number) => number | null;
73
+ setPmSelection: (anchor: number, head?: number) => void;
74
+ scrollVisiblePositionIntoView: (pmPos: number) => void;
75
+ navigateToBookmark: (bookmarkName: string) => void;
76
+ handlePagesMouseDown: (event: MouseEvent) => void;
77
+ handlePagesMouseMove: (event: MouseEvent) => void;
78
+ handlePagesClick: (event: MouseEvent) => void;
79
+ handlePagesDoubleClick: (event: MouseEvent) => void;
80
+ handleTableInsertClick: (event: MouseEvent) => void;
81
+ clearTableInsertTimer: () => void;
82
+ handleHfSave: (content: BlockContent[]) => void;
83
+ handleHfRemove: () => void;
84
+ }
85
+ export declare function usePagesPointer(opts: UsePagesPointerOptions): UsePagesPointerReturn;
86
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { StylePreviewProps } from '@xcrong/docx-editor-core/utils/stylePreview';
3
+ import { Style } from '@xcrong/docx-editor-core/types/document';
4
+ import { TranslationKey } from '@xcrong/docx-editor-i18n';
5
+ export interface ResolvedStyle {
6
+ id: string;
7
+ label: string;
8
+ previewStyle: StylePreviewProps;
9
+ }
10
+ export interface UseParagraphStyleOptionsReturn {
11
+ resolvedParagraphStyles: ComputedRef<ResolvedStyle[]>;
12
+ currentStyleLabel: ComputedRef<string>;
13
+ }
14
+ export declare function useParagraphStyleOptions(opts: {
15
+ documentStyles: () => Style[] | undefined;
16
+ currentStyleId: () => string;
17
+ t: (key: TranslationKey) => string;
18
+ }): UseParagraphStyleOptionsReturn;
@@ -0,0 +1,8 @@
1
+ import { ComputedRef, MaybeRef } from 'vue';
2
+ export declare function provideDocxPortalClass(isDark: MaybeRef<boolean>): void;
3
+ /**
4
+ * Class binding to apply to a teleported root so it inherits the editor's
5
+ * `--doc-*` tokens and theme. Falls back to a light `.ep-root` when used
6
+ * outside a provider (e.g. an isolated component test).
7
+ */
8
+ export declare function useDocxPortalClass(): ComputedRef<Record<string, boolean>>;
@@ -0,0 +1,19 @@
1
+ import { Ref, ComputedRef, CSSProperties } from 'vue';
2
+ import { HighlightRect, SelectionHighlightConfig } from '@xcrong/docx-editor-core/utils';
3
+ export interface UseSelectionHighlightOptions {
4
+ containerRef: Ref<HTMLElement | null>;
5
+ enabled?: boolean;
6
+ config?: SelectionHighlightConfig;
7
+ useOverlay?: boolean;
8
+ debounceMs?: number;
9
+ onSelectionChange?: (hasSelection: boolean, text: string) => void;
10
+ }
11
+ export interface UseSelectionHighlightReturn {
12
+ hasSelection: ComputedRef<boolean>;
13
+ selectedText: ComputedRef<string>;
14
+ highlightRects: ComputedRef<HighlightRect[]>;
15
+ isSelectionInContainer: ComputedRef<boolean>;
16
+ refresh: () => void;
17
+ getOverlayStyle: (rect: HighlightRect) => CSSProperties;
18
+ }
19
+ export declare function useSelectionHighlight(options: UseSelectionHighlightOptions): UseSelectionHighlightReturn;
@@ -0,0 +1,37 @@
1
+ import { Ref, ShallowRef } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { ImageSelectionInfo } from '../components/imageSelectionTypes';
4
+ export interface UseSelectionSyncOptions {
5
+ editorView: Ref<EditorView | null>;
6
+ hiddenContainer?: Ref<HTMLElement | null>;
7
+ pagesRef: Ref<HTMLElement | null>;
8
+ /**
9
+ * Current zoom factor. The caret + selection rects are painted into the
10
+ * `.docx-editor-vue__pages` container, which carries `transform: scale(zoom)`.
11
+ * `getBoundingClientRect` returns post-transform (viewport) coordinates, so
12
+ * the rects must be divided by zoom to land in the container's own
13
+ * coordinate space — otherwise the parent's scale multiplies them a second
14
+ * time and the highlight drifts off the text at any zoom ≠ 100%.
15
+ */
16
+ zoom: Ref<number>;
17
+ selectedImage: ShallowRef<ImageSelectionInfo | null>;
18
+ /**
19
+ * True while the user is editing a header/footer. When set, the body PM's
20
+ * caret + selection rects MUST stay hidden so the user doesn't see two
21
+ * carets blinking simultaneously (one in the painted header, one in the
22
+ * body). The HF view's own caret rect is drawn by DocxEditor.vue.
23
+ */
24
+ isHfEditing?: Ref<boolean>;
25
+ /**
26
+ * True while a resize / move / rotate gesture is in flight. Suppresses the
27
+ * post-transaction "clear the overlay" path so the handles don't vanish
28
+ * mid-drag when an intermediate state momentarily isn't an image
29
+ * NodeSelection. Mirrors React's `isImageInteractingRef`.
30
+ */
31
+ imageInteracting?: Ref<boolean>;
32
+ }
33
+ export interface UseSelectionSyncReturn {
34
+ clearOverlay: () => void;
35
+ updateSelectionOverlay: () => void;
36
+ }
37
+ export declare function useSelectionSync(opts: UseSelectionSyncOptions): UseSelectionSyncReturn;
@@ -0,0 +1,7 @@
1
+ import { EditorView } from 'prosemirror-view';
2
+ export interface UseTableResizeReturn {
3
+ tryStartResize: (e: MouseEvent, view: EditorView) => boolean;
4
+ install: () => () => void;
5
+ isResizing: () => boolean;
6
+ }
7
+ export declare function useTableResize(): UseTableResizeReturn;
@@ -0,0 +1,10 @@
1
+ import { Ref } from 'vue';
2
+ import { CellCoordinates } from '@xcrong/docx-editor-core/managers/types';
3
+ export interface UseTableSelectionReturn {
4
+ selectedCell: Ref<CellCoordinates | null>;
5
+ handleCellClick: (tableIndex: number, rowIndex: number, columnIndex: number) => void;
6
+ handleClickTarget: (target: EventTarget | null, container?: HTMLElement | null) => void;
7
+ clearSelection: () => void;
8
+ isCellSelected: (tableIndex: number, rowIndex: number, columnIndex: number) => boolean;
9
+ }
10
+ export declare function useTableSelection(): UseTableSelectionReturn;
@@ -0,0 +1,15 @@
1
+ import { Ref, CSSProperties } from 'vue';
2
+ export interface UseToolbarDropdownsOptions {
3
+ zoom: Ref<HTMLElement | null>;
4
+ style: Ref<HTMLElement | null>;
5
+ font: Ref<HTMLElement | null>;
6
+ size: Ref<HTMLElement | null>;
7
+ align: Ref<HTMLElement | null>;
8
+ spacing: Ref<HTMLElement | null>;
9
+ }
10
+ export declare function useToolbarDropdowns(refs: UseToolbarDropdownsOptions): {
11
+ openDropdown: Ref<string | null, string | null>;
12
+ dropdownMenuStyle: import('vue').ComputedRef<CSSProperties>;
13
+ toggleDropdown: (name: string) => void;
14
+ recomputeDropdownPos: (name: string) => void;
15
+ };
@@ -0,0 +1,15 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ export interface UseToolbarFontSizeReturn {
3
+ onSizeFocus: () => void;
4
+ onSizeInput: () => void;
5
+ commitFontSize: (e: Event) => void;
6
+ pickFontSize: (size: number) => void;
7
+ increaseFontSize: () => void;
8
+ decreaseFontSize: () => void;
9
+ }
10
+ export declare function useToolbarFontSize(opts: {
11
+ currentFontSize: ComputedRef<number>;
12
+ openDropdown: Ref<string | null>;
13
+ recomputeDropdownPos: (name: string) => void;
14
+ execCommand: (name: string, ...args: unknown[]) => void;
15
+ }): UseToolbarFontSizeReturn;
@@ -0,0 +1,12 @@
1
+ import { Ref } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { extractTrackedChanges, TrackedChangesResult } from '@xcrong/docx-editor-core/prosemirror/utils/extractTrackedChanges';
4
+ export type { TrackedChangesResult };
5
+ export { extractTrackedChanges };
6
+ export type { TrackedChangeEntry } from '@xcrong/docx-editor-core/utils/comments';
7
+ /**
8
+ * Pass the editor view ref + a stateTick that bumps on every PM
9
+ * transaction (the same tick the Toolbar listens to). The computed
10
+ * re-runs whenever the tick advances.
11
+ */
12
+ export declare function useTrackedChanges(view: Ref<EditorView | null>, stateTick: Ref<number>): import('vue').ComputedRef<TrackedChangesResult>;
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ import { createVisualLineState } from '@xcrong/docx-editor-core/prosemirror/utils/visualLineNavigation';
3
+ import { EditorView } from 'prosemirror-view';
4
+ export interface UseVisualLineNavigationReturn {
5
+ state: ReturnType<typeof createVisualLineState>;
6
+ getCaretClientX: (pmPos: number) => number | null;
7
+ findLineElementAtPosition: (pmPos: number) => HTMLElement | null;
8
+ findPositionOnLineAtClientX: (line: HTMLElement, clientX: number) => number | null;
9
+ handlePMKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
10
+ }
11
+ export declare function useVisualLineNavigation(pagesContainer: Ref<HTMLElement | null>): UseVisualLineNavigationReturn;
@@ -0,0 +1,15 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { Watermark } from '@xcrong/docx-editor-core/types/document';
4
+ export interface UseWatermarkControlsOptions {
5
+ editorView: Ref<EditorView | null>;
6
+ readOnly: Ref<boolean>;
7
+ /** Bumped on every edit/selection change; drives `currentWatermark` reactivity. */
8
+ stateTick: Ref<number>;
9
+ }
10
+ export interface UseWatermarkControlsReturn {
11
+ showWatermark: Ref<boolean>;
12
+ currentWatermark: ComputedRef<Watermark | undefined>;
13
+ handleWatermarkApply: (watermark: Watermark | null) => void;
14
+ }
15
+ export declare function useWatermarkControls(opts: UseWatermarkControlsOptions): UseWatermarkControlsReturn;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Alias for cross-adapter parity — the React adapter has
3
+ * `useWheelZoom.ts` (Ctrl+wheel zoom + Ctrl+= / Ctrl+- / Ctrl+0
4
+ * shortcuts). Vue rolls the same behaviour into `useZoom`, which
5
+ * already exposes `handleWheel` and `installShortcuts()`. This file
6
+ * re-exports under the React-style name so plugin code can call
7
+ * `useWheelZoom()` either way and get the same composable.
8
+ */
9
+ export { useZoom as useWheelZoom } from './useZoom';
10
+ export type {} from './useZoom';
@@ -0,0 +1,16 @@
1
+ import { Ref, ComputedRef } from 'vue';
2
+ export interface UseZoomReturn {
3
+ zoom: Ref<number>;
4
+ zoomPercent: ComputedRef<number>;
5
+ isMinZoom: ComputedRef<boolean>;
6
+ isMaxZoom: ComputedRef<boolean>;
7
+ setZoom: (level: number) => void;
8
+ zoomIn: () => void;
9
+ zoomOut: () => void;
10
+ resetZoom: () => void;
11
+ handleWheel: (e: WheelEvent) => void;
12
+ handleKeyDown: (e: KeyboardEvent) => void;
13
+ installShortcuts: () => void;
14
+ ZOOM_PRESETS: number[];
15
+ }
16
+ export declare function useZoom(initialZoom?: number): UseZoomReturn;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useCommentSidebarItems-DBeGKNGA.cjs`),t=require(`./useDragAutoScroll-BzP7c_lM.cjs`);let n=require(`vue`),r=require(`@xcrong/docx-editor-core/utils`),i=require(`prosemirror-history`),a=require(`@xcrong/docx-editor-core/prosemirror/utils/extractTrackedChanges`),o=require(`@xcrong/docx-editor-core`),s=require(`@xcrong/docx-editor-core/utils/findReplace`),c=require(`@xcrong/docx-editor-core/managers/TableSelectionManager`),l=require(`@xcrong/docx-editor-core/prosemirror/utils/visualLineNavigation`);function u(e,t={}){let r=(0,n.ref)(`idle`),i=(0,n.ref)(null),a=(0,n.ref)(!1),s=(0,n.ref)(!0),{storageKey:c,interval:l,enabled:u=!0,maxAge:d,onSave:f,onError:p,onRecoveryAvailable:m,saveOnChange:h,debounceDelay:g}=t;if(!(0,o.isAutoSaveSupported)())return{status:r,lastSaveTime:i,hasRecoveryData:a,isEnabled:s,save:async()=>!1,clearAutoSave:()=>{},getRecoveryData:()=>null,acceptRecovery:()=>null,dismissRecovery:()=>{},enable:()=>{},disable:()=>{}};let _=new o.AutoSaveManager({storageKey:c,interval:l,maxAge:d,saveOnChange:h,debounceDelay:g,onSave:f,onError:p,onRecoveryAvailable:m}),v=()=>{let e=_.getSnapshot();r.value=e.status,i.value=e.lastSaveTime,a.value=e.hasRecoveryData,s.value=e.isEnabled},y=_.subscribe(v);u?_.enable():_.disable(),v(),(0,n.watch)(()=>(0,n.unref)(e),e=>_.onDocumentChanged(e??null),{immediate:!0});function b(){return _.save()}function x(){_.clear()}function S(){return _.getRecoveryData()}function C(){return _.acceptRecovery()}function w(){_.dismissRecovery()}function T(){_.enable()}function E(){_.disable()}return(0,n.onBeforeUnmount)(()=>{y(),_.destroy()}),{status:r,lastSaveTime:i,hasRecoveryData:a,isEnabled:s,save:b,clearAutoSave:x,getRecoveryData:S,acceptRecovery:C,dismissRecovery:w,enable:T,disable:E}}function d(e={}){let{onCopy:t,onCut:i,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c,theme:l}=e,u=(0,n.ref)(!1),d=(0,n.ref)(null);async function f(e){if(u.value)return!1;u.value=!0;try{let n=await(0,r.copyRuns)(e.runs,{onError:c,theme:l});return n&&t?.(e),n}finally{u.value=!1}}async function p(e){if(u.value||!s)return!1;u.value=!0;try{let t=await(0,r.copyRuns)(e.runs,{onError:c,theme:l});return t&&i?.(e),t}finally{u.value=!1}}async function m(e=!1){if(u.value||!s)return null;u.value=!0;try{if(navigator.clipboard&&navigator.clipboard.read){let t=await navigator.clipboard.read(),n=``,i=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(i=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,r.parseClipboardHtml)(n,i,o);return d.value=s,a?.(s,e),s}return null}catch(e){return c?.(e instanceof Error?e:Error(String(e))),null}finally{u.value=!1}}return{copy:f,cut:p,paste:m,isProcessing:u,lastPastedContent:d}}function f(e={}){let t=(0,n.reactive)({isOpen:!1,searchText:``,replaceText:``,options:(0,s.createDefaultFindOptions)(),matches:[],currentIndex:0,replaceMode:e.initialReplaceMode??!1});function r(e){t.isOpen=!0,t.replaceMode=!1,e&&(t.searchText=e),t.matches=[],t.currentIndex=0}function i(e){t.isOpen=!0,t.replaceMode=!0,e&&(t.searchText=e),t.matches=[],t.currentIndex=0}function a(){t.isOpen=!1}function o(){t.isOpen=!t.isOpen}function c(e){t.searchText=e}function l(e){t.replaceText=e}function u(e){t.options={...t.options,...e}}function d(n,r=0){let i=Math.max(0,Math.min(r,n.length-1));t.matches=n,t.currentIndex=n.length>0?i:0,e.onMatchesChange?.(n),n.length>0?e.onCurrentMatchChange?.(n[i],i):e.onCurrentMatchChange?.(null,-1)}function f(){return t.matches.length===0?0:(t.currentIndex=(t.currentIndex+1)%t.matches.length,t.currentIndex)}function p(){return t.matches.length===0?0:(t.currentIndex=t.currentIndex===0?t.matches.length-1:t.currentIndex-1,t.currentIndex)}function m(e){t.matches.length===0||e<0||e>=t.matches.length||(t.currentIndex=e)}return{state:t,currentMatch:(0,n.computed)(()=>t.matches.length===0?null:t.matches[t.currentIndex]??null),hasMatches:(0,n.computed)(()=>t.matches.length>0),openFind:r,openReplace:i,close:a,toggle:o,setSearchText:c,setReplaceText:l,setOptions:u,setMatches:d,goToNextMatch:f,goToPreviousMatch:p,goToMatch:m}}function p({isOpen:e,onClose:t,align:r=`left`}){let i=(0,n.ref)(null),a=(0,n.ref)(null),o=(0,n.ref)({position:`fixed`,top:`0px`,left:`0px`,zIndex:1e4});function s(e,t){o.value={position:`fixed`,top:e+`px`,left:t+`px`,zIndex:1e4}}function c(e){let n=e.target;i.value&&!i.value.contains(n)&&a.value&&!a.value.contains(n)&&t()}function l(e){e.key===`Escape`&&t()}function u(e){let n=e.target;n&&a.value&&a.value.contains(n)||t()}function d(){document.addEventListener(`mousedown`,c),document.addEventListener(`keydown`,l),window.addEventListener(`scroll`,u,!0)}function f(){document.removeEventListener(`mousedown`,c),document.removeEventListener(`keydown`,l),window.removeEventListener(`scroll`,u,!0)}(0,n.watch)(e,e=>{if(!e){f();return}let t=i.value;if(!t)return;let n=t.getBoundingClientRect();r===`right`?requestAnimationFrame(()=>{let e=a.value;if(e){let t=e.getBoundingClientRect();s(n.bottom+4,n.right-t.width)}else s(n.bottom+4,n.left)}):s(n.bottom+4,n.left),d()}),(0,n.onBeforeUnmount)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function m(e,t){let r=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,i.undoDepth)(n.state)>0:!1}),a=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,i.redoDepth)(n.state)>0:!1});function o(){let t=e.value;return t?(0,i.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,i.redo)(t.state,t.dispatch):!1}return{canUndo:r,canRedo:a,undo:o,redo:s}}function h(e){let{containerRef:t,enabled:i=!0,config:a=r.DEFAULT_SELECTION_STYLE,useOverlay:o=!1,debounceMs:s=16,onSelectionChange:c}=e,l=(0,n.ref)(!1),u=(0,n.ref)(``),d=(0,n.ref)([]),f=(0,n.ref)(!1),p=null,m=0;function h(){let e=t.value,n=(0,r.hasActiveSelection)(),i=(0,r.getSelectedText)(),a=e?(0,r.isSelectionWithin)(e):!1;l.value=n,u.value=i,f.value=a,d.value=o&&a&&e?(0,r.getMergedSelectionRects)(e):[],c?.(n&&a,i)}function g(){h()}function _(){let e=performance.now();if(e-m<s){p&&clearTimeout(p),p=setTimeout(()=>{m=performance.now(),h(),p=null},s);return}m=e,h()}function v(e){return{position:`absolute`,left:e.left+`px`,top:e.top+`px`,width:e.width+`px`,height:e.height+`px`,backgroundColor:a.backgroundColor,borderRadius:a.borderRadius?a.borderRadius+`px`:void 0,border:a.borderColor?`1px solid ${a.borderColor}`:void 0,zIndex:a.zIndex??0,pointerEvents:`none`}}return(0,n.onMounted)(()=>{i&&((0,r.areSelectionStylesInjected)()||(0,r.injectSelectionStyles)(a),document.addEventListener(`selectionchange`,_))}),(0,n.onBeforeUnmount)(()=>{document.removeEventListener(`selectionchange`,_),p&&clearTimeout(p)}),(0,n.watch)(t,()=>h()),{hasSelection:(0,n.computed)(()=>l.value),selectedText:(0,n.computed)(()=>u.value),highlightRects:(0,n.computed)(()=>d.value),isSelectionInContainer:(0,n.computed)(()=>f.value),refresh:g,getOverlayStyle:v}}function g(){let e=new c.TableSelectionManager,t=(0,n.ref)(null),r=()=>{t.value=e.getSnapshot().selectedCell},i=e.subscribe(r);r(),(0,n.onBeforeUnmount)(()=>{i()});function a(t,n,r){e.selectCell({tableIndex:t,rowIndex:n,columnIndex:r})}function o(t,n){let r=(0,c.findTableFromClick)(t,n);r?e.selectCell(r):e.clearSelection()}function s(){e.clearSelection()}function l(t,n,r){return e.isCellSelected(t,n,r)}return{selectedCell:t,handleCellClick:a,handleClickTarget:o,clearSelection:s,isCellSelected:l}}function _(e,t){return(0,n.computed)(()=>(t.value,(0,a.extractTrackedChanges)(e.value?.state??null)))}function v(e){let t=(0,l.createVisualLineState)();function n(t){let n=e.value;return n?(0,l.getCaretClientX)(n,t):null}function r(t){let n=e.value;return n?(0,l.findLineElementAtPosition)(n,t):null}function i(e,t){return(0,l.findPositionOnLineAtClientX)(e,t)}function a(n,r){return(0,l.handleVisualLineKeyDown)(t,n,r,e.value)}return{state:t,getCaretClientX:n,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}exports.createSelectionFromDOM=o.createSelectionFromDOM,exports.extractTrackedChanges=a.extractTrackedChanges,exports.formatLastSaveTime=o.formatLastSaveTime,exports.formatStorageSize=o.formatStorageSize,exports.getAutoSaveStatusLabel=o.getAutoSaveStatusLabel,exports.getAutoSaveStorageSize=o.getAutoSaveStorageSize,exports.getSelectionRuns=o.getSelectionRuns,exports.isAutoSaveSupported=o.isAutoSaveSupported,exports.runsToClipboardContent=r.runsToClipboardContent,exports.useAutoSave=u,exports.useClipboard=d,exports.useCommentSidebarItems=e.t,exports.useDocxEditor=t.i,exports.useDragAutoScroll=t.t,exports.useFindReplace=f,exports.useFixedDropdown=p,exports.useHistory=m,exports.useSelectionHighlight=h,exports.useTableResize=t.n,exports.useTableSelection=g,exports.useTrackedChanges=_,exports.useVisualLineNavigation=v,exports.useWheelZoom=t.r,exports.useZoom=t.r;