@heyirisai/docx-editor-vue 1.9.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/LICENSE +201 -0
- package/README.md +116 -0
- package/dist/KeyboardShortcutsDialog-B0fEvXnH.js +2799 -0
- package/dist/KeyboardShortcutsDialog-Cmezq6eJ.cjs +1 -0
- package/dist/RenderedDomContext-CHc18N_2.js +2 -0
- package/dist/TablePropertiesDialog-B6ncvNnv.cjs +1 -0
- package/dist/TablePropertiesDialog-P_vyKNTn.js +1145 -0
- package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
- package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
- package/dist/components/DocxEditor/types.d.ts +193 -0
- package/dist/components/EditorToolbarContext.d.ts +9 -0
- package/dist/components/Toolbar/presets.d.ts +20 -0
- package/dist/components/dialogs/index.d.ts +27 -0
- package/dist/components/imageContextMenuTypes.d.ts +30 -0
- package/dist/components/imageSelectionTypes.d.ts +14 -0
- package/dist/components/insertTableState.d.ts +9 -0
- package/dist/components/sidebar/cardStyles.d.ts +3 -0
- package/dist/components/sidebar/cardUtils.d.ts +1 -0
- package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
- package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
- package/dist/components/tableStylePresets.d.ts +53 -0
- package/dist/components/toolbarUtils.d.ts +1 -0
- package/dist/components/ui/Icons.d.ts +1 -0
- package/dist/components/ui/fontPickerValue.d.ts +1 -0
- package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
- package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
- package/dist/composables/fileOpen.test.d.ts +1 -0
- package/dist/composables/imageOverlayRect.d.ts +44 -0
- package/dist/composables/imageOverlayRect.test.d.ts +1 -0
- package/dist/composables/index.d.ts +30 -0
- package/dist/composables/useAutoSave.d.ts +40 -0
- package/dist/composables/useClipboard.d.ts +22 -0
- package/dist/composables/useColorMode.d.ts +8 -0
- package/dist/composables/useCommentLifecycle.d.ts +62 -0
- package/dist/composables/useCommentManagement.d.ts +68 -0
- package/dist/composables/useCommentSidebarItems.d.ts +24 -0
- package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
- package/dist/composables/useContextMenus.cut.test.d.ts +1 -0
- package/dist/composables/useContextMenus.d.ts +39 -0
- package/dist/composables/useControllableBoolean.d.ts +16 -0
- package/dist/composables/useControllableBoolean.test.d.ts +1 -0
- package/dist/composables/useDocumentLifecycle.d.ts +11 -0
- package/dist/composables/useDocxEditor.d.ts +96 -0
- package/dist/composables/useDocxEditorRefApi.d.ts +53 -0
- package/dist/composables/useDragAutoScroll.d.ts +11 -0
- package/dist/composables/useFileIO.d.ts +41 -0
- package/dist/composables/useFindReplace.d.ts +34 -0
- package/dist/composables/useFixedDropdown.d.ts +14 -0
- package/dist/composables/useFontLifecycle.d.ts +12 -0
- package/dist/composables/useFormattingActions.d.ts +31 -0
- package/dist/composables/useHistory.d.ts +9 -0
- package/dist/composables/useHostCallbacks.d.ts +7 -0
- package/dist/composables/useHyperlinkManagement.d.ts +38 -0
- package/dist/composables/useImageActions.d.ts +24 -0
- package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
- package/dist/composables/useMenuActions.d.ts +26 -0
- package/dist/composables/useOutlineSidebar.d.ts +24 -0
- package/dist/composables/useOutlineSidebar.test.d.ts +1 -0
- package/dist/composables/usePageSetupControls.d.ts +22 -0
- package/dist/composables/usePagesPointer.d.ts +86 -0
- package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
- package/dist/composables/usePortalClass.d.ts +8 -0
- package/dist/composables/useSelectionHighlight.d.ts +19 -0
- package/dist/composables/useSelectionSync.d.ts +36 -0
- package/dist/composables/useTableResize.d.ts +7 -0
- package/dist/composables/useTableSelection.d.ts +10 -0
- package/dist/composables/useToolbarDropdowns.d.ts +15 -0
- package/dist/composables/useToolbarFontSize.d.ts +15 -0
- package/dist/composables/useTrackedChanges.d.ts +12 -0
- package/dist/composables/useVisualLineNavigation.d.ts +11 -0
- package/dist/composables/useWatermarkControls.d.ts +15 -0
- package/dist/composables/useWheelZoom.d.ts +10 -0
- package/dist/composables/useZoom.d.ts +16 -0
- package/dist/composables.cjs +1 -0
- package/dist/composables.js +401 -0
- package/dist/dialogs.cjs +1 -0
- package/dist/dialogs.js +3 -0
- package/dist/docx-editor-vue.css +2 -0
- package/dist/i18n/LocaleContext.d.ts +1 -0
- package/dist/i18n/index.d.ts +26 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +4449 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
- package/dist/plugin-api/index.d.ts +18 -0
- package/dist/plugin-api/types.d.ts +28 -0
- package/dist/plugin-api.cjs +1 -0
- package/dist/plugin-api.js +62 -0
- package/dist/renderAsync.d.ts +31 -0
- package/dist/styles/index.d.ts +12 -0
- package/dist/styles/zIndex.d.ts +24 -0
- package/dist/styles.cjs +1 -0
- package/dist/styles.js +5 -0
- package/dist/ui.cjs +18 -0
- package/dist/ui.d.ts +79 -0
- package/dist/ui.js +986 -0
- package/dist/useCommentSidebarItems-DBeGKNGA.cjs +1 -0
- package/dist/useCommentSidebarItems-DXbF857R.js +45 -0
- package/dist/useDragAutoScroll-CVltVfKK.js +520 -0
- package/dist/useDragAutoScroll-liP5PRvM.cjs +1 -0
- package/dist/usePortalClass-B9gFYxe0.cjs +4 -0
- package/dist/usePortalClass-HM-UHRlE.js +3534 -0
- package/dist/utils/domQueries.d.ts +39 -0
- package/dist/utils/imageClipboard.d.ts +9 -0
- package/dist/utils/refApiQueries.d.ts +10 -0
- package/dist/zIndex-CH0jZ7U7.cjs +1 -0
- package/dist/zIndex-CxELVe_L.js +12 -0
- package/package.json +119 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MaybeRef, Ref } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Comment, Document } from '@heyirisai/docx-editor-core/types/document';
|
|
4
|
+
import { CommentIdAllocator } from '@heyirisai/docx-editor-core/prosemirror/commentIdAllocator';
|
|
5
|
+
import { TrackedChangeEntry } from '../components/sidebar/sidebarUtils';
|
|
6
|
+
/**
|
|
7
|
+
* Host-facing comment lifecycle callbacks (the `onComment*` props). Shared with
|
|
8
|
+
* `useCommentLifecycle`. The granular callbacks fire on the matching UI action;
|
|
9
|
+
* `onCommentsChange` fires with the full array on every comment mutation.
|
|
10
|
+
*/
|
|
11
|
+
export interface CommentCallbacks {
|
|
12
|
+
onCommentAdd?: (comment: Comment) => void;
|
|
13
|
+
onCommentResolve?: (comment: Comment) => void;
|
|
14
|
+
onCommentDelete?: (comment: Comment) => void;
|
|
15
|
+
onCommentReply?: (reply: Comment, parent: Comment) => void;
|
|
16
|
+
onCommentsChange?: (comments: Comment[]) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface UseCommentManagementOptions {
|
|
19
|
+
editorView: Ref<EditorView | null>;
|
|
20
|
+
getDocument: () => Document | null;
|
|
21
|
+
comments: Ref<Comment[]>;
|
|
22
|
+
trackedChanges: Ref<TrackedChangeEntry[]>;
|
|
23
|
+
showSidebar: Ref<boolean>;
|
|
24
|
+
isAddingComment: Ref<boolean>;
|
|
25
|
+
pendingCommentRange: Ref<{
|
|
26
|
+
from: number;
|
|
27
|
+
to: number;
|
|
28
|
+
} | null>;
|
|
29
|
+
contentChangeSubscribers: Set<(document: unknown) => void>;
|
|
30
|
+
extractCommentsAndChanges: () => void;
|
|
31
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Per-editor-instance monotonic ID allocator, shared with
|
|
34
|
+
* `useCommentLifecycle` so comment and tracked-change IDs never collide.
|
|
35
|
+
*/
|
|
36
|
+
commentIdAllocator: CommentIdAllocator;
|
|
37
|
+
/** Author name for UI-created replies/changes (the `author` prop). */
|
|
38
|
+
author?: MaybeRef<string>;
|
|
39
|
+
/** Host-facing comment lifecycle callbacks (the `onComment*` props). */
|
|
40
|
+
commentCallbacks?: CommentCallbacks;
|
|
41
|
+
/** Get all active header/footer ProseMirror EditorViews. */
|
|
42
|
+
getHfPmViews?: () => Map<string, EditorView>;
|
|
43
|
+
}
|
|
44
|
+
export declare function useCommentManagement(opts: UseCommentManagementOptions): {
|
|
45
|
+
addComment: (options: {
|
|
46
|
+
paraId: string;
|
|
47
|
+
text: string;
|
|
48
|
+
author: string;
|
|
49
|
+
search?: string;
|
|
50
|
+
}) => number | null;
|
|
51
|
+
replyToComment: (commentId: number, text: string, author: string) => number | null;
|
|
52
|
+
resolveComment: (commentId: number) => void;
|
|
53
|
+
proposeChange: (options: {
|
|
54
|
+
paraId: string;
|
|
55
|
+
search: string;
|
|
56
|
+
replaceWith: string;
|
|
57
|
+
author: string;
|
|
58
|
+
}) => boolean;
|
|
59
|
+
handleCommentReply: (commentId: number, text: string) => void;
|
|
60
|
+
handleCommentResolve: (commentId: number) => void;
|
|
61
|
+
handleCommentUnresolve: (commentId: number) => void;
|
|
62
|
+
handleCommentDelete: (commentId: number) => void;
|
|
63
|
+
handleAcceptChange: (from: number, to: number) => void;
|
|
64
|
+
handleRejectChange: (from: number, to: number) => void;
|
|
65
|
+
handleAcceptChangeById: (revisionId: number) => void;
|
|
66
|
+
handleRejectChangeById: (revisionId: number) => void;
|
|
67
|
+
handleTrackedChangeReply: (revisionId: number, text: string) => void;
|
|
68
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { Comment } from '@heyirisai/docx-editor-core/types/content';
|
|
3
|
+
import { TrackedChangeEntry } from './useTrackedChanges';
|
|
4
|
+
export interface CommentSidebarItem {
|
|
5
|
+
id: string;
|
|
6
|
+
anchorPos: number;
|
|
7
|
+
anchorKey?: string;
|
|
8
|
+
priority?: number;
|
|
9
|
+
isTemporary?: boolean;
|
|
10
|
+
fixedY?: number;
|
|
11
|
+
estimatedHeight?: number;
|
|
12
|
+
kind: 'add-comment' | 'comment' | 'tracked-change';
|
|
13
|
+
comment?: Comment;
|
|
14
|
+
replies?: Comment[];
|
|
15
|
+
change?: TrackedChangeEntry;
|
|
16
|
+
}
|
|
17
|
+
export interface UseCommentSidebarItemsOptions {
|
|
18
|
+
comments: Ref<Comment[]>;
|
|
19
|
+
trackedChanges: Ref<TrackedChangeEntry[]>;
|
|
20
|
+
showResolved?: Ref<boolean>;
|
|
21
|
+
isAddingComment?: Ref<boolean>;
|
|
22
|
+
addCommentYPosition?: Ref<number | null>;
|
|
23
|
+
}
|
|
24
|
+
export declare function useCommentSidebarItems({ comments, trackedChanges, showResolved, isAddingComment, addCommentYPosition, }: UseCommentSidebarItemsOptions): import('vue').ComputedRef<CommentSidebarItem[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComputedRef, Ref, ShallowRef } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { ImageLayoutTarget } from '@heyirisai/docx-editor-core/prosemirror/commands';
|
|
4
|
+
import { ImageSelectionInfo } from '../components/imageSelectionTypes';
|
|
5
|
+
import { ImageContextMenuState, ImageContextMenuTextAction } from '../components/imageContextMenuTypes';
|
|
6
|
+
type Commands = Record<string, ((...args: unknown[]) => unknown) | undefined>;
|
|
7
|
+
export interface TextContextMenuState {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
position: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
hasSelection: boolean;
|
|
14
|
+
inTable: boolean;
|
|
15
|
+
onImage: boolean;
|
|
16
|
+
canMergeCells: boolean;
|
|
17
|
+
canSplitCell: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface UseContextMenusOptions {
|
|
20
|
+
editorView: Ref<EditorView | null>;
|
|
21
|
+
selectedImage: ShallowRef<ImageSelectionInfo | null>;
|
|
22
|
+
zoom: Ref<number>;
|
|
23
|
+
showImageProperties: Ref<boolean>;
|
|
24
|
+
getCommands: () => Commands;
|
|
25
|
+
clearOverlay: () => void;
|
|
26
|
+
setPmSelection: (anchor: number, head?: number) => void;
|
|
27
|
+
resolvePos: (clientX: number, clientY: number) => number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface UseContextMenusReturn {
|
|
30
|
+
contextMenu: Ref<TextContextMenuState>;
|
|
31
|
+
imageContextMenu: Ref<ImageContextMenuState | null>;
|
|
32
|
+
imageContextMenuTextActions: ComputedRef<ImageContextMenuTextAction[]>;
|
|
33
|
+
handleContextMenu: (event: MouseEvent) => void;
|
|
34
|
+
handleSelectedImageContextMenu: (event: MouseEvent) => void;
|
|
35
|
+
handleImageWrapSelect: (target: ImageLayoutTarget) => void;
|
|
36
|
+
handleContextMenuAction: (action: string) => void;
|
|
37
|
+
}
|
|
38
|
+
export declare function useContextMenus(opts: UseContextMenusOptions): UseContextMenusReturn;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WritableComputedRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* A boolean that can run either controlled or uncontrolled, exposed as a
|
|
4
|
+
* writable ref so existing call sites can keep mutating `.value` directly.
|
|
5
|
+
*
|
|
6
|
+
* - Controlled (`controlled()` returns a boolean): the prop is the source of
|
|
7
|
+
* truth. Internal state is bypassed; writes only call `onChange` (if provided)
|
|
8
|
+
* and the consumer decides whether to honor them.
|
|
9
|
+
* - Uncontrolled (`controlled()` returns `undefined`): the composable owns the
|
|
10
|
+
* value, and writes update internal state and call `onChange` so consumers can
|
|
11
|
+
* observe without owning state.
|
|
12
|
+
*
|
|
13
|
+
* `onChange` is optional and does not fire when the value would be unchanged.
|
|
14
|
+
* Mirrors the React adapter's `useControllableBoolean` hook.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useControllableBoolean(controlled: () => boolean | undefined, onChange?: (value: boolean) => void, defaultValue?: boolean): WritableComputedRef<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
3
|
+
import { DocxInput } from '@heyirisai/docx-editor-core/utils';
|
|
4
|
+
export interface UseDocumentLifecycleOptions {
|
|
5
|
+
documentBuffer: () => DocxInput | null;
|
|
6
|
+
document: () => Document | null;
|
|
7
|
+
loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
|
|
8
|
+
loadDocument: (doc: Document) => void;
|
|
9
|
+
sidebarAutoOpenedRef: Ref<boolean>;
|
|
10
|
+
}
|
|
11
|
+
export declare function useDocumentLifecycle(opts: UseDocumentLifecycleOptions): void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { MaybeRef, Ref, ShallowRef } from 'vue';
|
|
2
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { FontOption } from '@heyirisai/docx-editor-core/utils/fontOptions';
|
|
5
|
+
import { CommandMap } from '@heyirisai/docx-editor-core/prosemirror/extensions/types';
|
|
6
|
+
import { Layout } from '@heyirisai/docx-editor-core/layout-engine/types';
|
|
7
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
8
|
+
import { LayoutSelectionGate } from '@heyirisai/docx-editor-core/prosemirror';
|
|
9
|
+
export interface UseDocxEditorOptions {
|
|
10
|
+
/** Container element for the hidden ProseMirror editor */
|
|
11
|
+
hiddenContainer: Ref<HTMLElement | null>;
|
|
12
|
+
/** Container element for the visible pages */
|
|
13
|
+
pagesContainer: Ref<HTMLElement | null>;
|
|
14
|
+
/** Whether the editor is read-only */
|
|
15
|
+
readOnly?: MaybeRef<boolean>;
|
|
16
|
+
/** Page gap in pixels */
|
|
17
|
+
pageGap?: number;
|
|
18
|
+
/** Callback on document change */
|
|
19
|
+
onChange?: (doc: Document) => void;
|
|
20
|
+
/** Callback on error */
|
|
21
|
+
onError?: (error: Error) => void;
|
|
22
|
+
/** Callback on selection change */
|
|
23
|
+
onSelectionUpdate?: () => void;
|
|
24
|
+
/** External ProseMirror plugins supplied by the host app. */
|
|
25
|
+
externalPlugins?: Plugin[];
|
|
26
|
+
/** Coordinates layout updates with visible selection/decoration overlays. */
|
|
27
|
+
syncCoordinator?: LayoutSelectionGate;
|
|
28
|
+
/**
|
|
29
|
+
* Editor mode. When set to `'suggesting'`, the composable toggles the
|
|
30
|
+
* mounted suggestion-mode plugin's active state so typed text becomes
|
|
31
|
+
* tracked changes. Reactive — flip at runtime to switch modes.
|
|
32
|
+
* Mirrors React's `editingMode` prop wiring.
|
|
33
|
+
*/
|
|
34
|
+
editorMode?: MaybeRef<'editing' | 'suggesting' | 'viewing'>;
|
|
35
|
+
/** Author name attached to tracked changes minted in suggesting mode. */
|
|
36
|
+
author?: MaybeRef<string>;
|
|
37
|
+
}
|
|
38
|
+
export interface UseDocxEditorReturn {
|
|
39
|
+
/** ProseMirror editor view (hidden). */
|
|
40
|
+
editorView: ShallowRef<EditorView | null>;
|
|
41
|
+
/** Latest editor state. Updated on each transaction. */
|
|
42
|
+
editorState: ShallowRef<EditorState | null>;
|
|
43
|
+
/** True once the editor view has mounted and a document is loaded. */
|
|
44
|
+
isReady: Ref<boolean>;
|
|
45
|
+
/** Last parse error message, or null if the most recent load succeeded. */
|
|
46
|
+
parseError: Ref<string | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Fonts the loaded document references that the browser can render (embedded
|
|
49
|
+
* faces + system-resolved), for the picker's "Document fonts" group.
|
|
50
|
+
*/
|
|
51
|
+
documentFonts: Ref<FontOption[]>;
|
|
52
|
+
/** Computed page layout. */
|
|
53
|
+
layout: ShallowRef<Layout | null>;
|
|
54
|
+
/** Load a DOCX from a binary buffer. */
|
|
55
|
+
loadBuffer: (buffer: ArrayBuffer | Uint8Array | Blob | File) => Promise<void>;
|
|
56
|
+
/** Load a parsed `Document` directly. */
|
|
57
|
+
loadDocument: (doc: Document) => void;
|
|
58
|
+
/** Serialize the current document to a DOCX blob. */
|
|
59
|
+
save: () => Promise<Blob | null>;
|
|
60
|
+
/** Focus the hidden ProseMirror view. */
|
|
61
|
+
focus: () => void;
|
|
62
|
+
/** Destroy the editor view and clean up listeners. */
|
|
63
|
+
destroy: () => void;
|
|
64
|
+
/** Snapshot the current document model. */
|
|
65
|
+
getDocument: () => Document | null;
|
|
66
|
+
/** Access the extension command map for invoking marks/nodes/features. */
|
|
67
|
+
getCommands: () => CommandMap;
|
|
68
|
+
/** Force a re-layout without a doc change (e.g. after page-setup changes). */
|
|
69
|
+
reLayout: () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Look up the persistent hidden HF EditorView for a HeaderFooter
|
|
72
|
+
* instance. The inline overlay and the click router use this to
|
|
73
|
+
* dispatch selection / focus on the same EditorView the painter reads.
|
|
74
|
+
* Returns null if the document is unloaded or no PM is mounted for
|
|
75
|
+
* the HF's `rId` (cold boot, or just-removed slot).
|
|
76
|
+
*/
|
|
77
|
+
getHfPmView: (hf: import('@heyirisai/docx-editor-core/types/document').HeaderFooter) => EditorView | null;
|
|
78
|
+
/** Get all active header/footer EditorViews mapped by rId. */
|
|
79
|
+
getHfPmViews: () => Map<string, EditorView>;
|
|
80
|
+
/**
|
|
81
|
+
* Re-mount / tear down HF EditorViews to match the current document's
|
|
82
|
+
* `package.headers/footers`. Call this after the inline overlay saves
|
|
83
|
+
* back into `Document.package.headers` (the swap produces new HeaderFooter
|
|
84
|
+
* objects; new EditorViews need to point at the new objects).
|
|
85
|
+
*/
|
|
86
|
+
syncHfPMs: () => void;
|
|
87
|
+
/**
|
|
88
|
+
* Subscribe to every HF transaction. `cb(rId, view)` fires after the
|
|
89
|
+
* EditorView's state has been updated. Used by the painted-HF caret
|
|
90
|
+
* overlay and HF UI chrome (toolbar selection sync).
|
|
91
|
+
*/
|
|
92
|
+
setHfTransactionListener: (cb: ((rId: string, view: EditorView, docChanged: boolean) => void) | null) => void;
|
|
93
|
+
/** Publish a fresh Document object (used by HF materialisation). */
|
|
94
|
+
setDocument: (doc: Document) => void;
|
|
95
|
+
}
|
|
96
|
+
export declare function useDocxEditor(options: UseDocxEditorOptions): UseDocxEditorReturn;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
4
|
+
import { Comment } from '@heyirisai/docx-editor-core/types/content';
|
|
5
|
+
import { DocxInput } from '@heyirisai/docx-editor-core/utils';
|
|
6
|
+
import { Layout } from '@heyirisai/docx-editor-core/layout-engine';
|
|
7
|
+
import { DocxEditorRef } from '../components/DocxEditor/types';
|
|
8
|
+
import { ApplyFormattingOptions } from './useFormattingActions';
|
|
9
|
+
export interface UseDocxEditorRefApiOptions {
|
|
10
|
+
editorView: Ref<EditorView | null>;
|
|
11
|
+
layout: Ref<Layout | null>;
|
|
12
|
+
pagesRef: Ref<HTMLElement | null>;
|
|
13
|
+
pagesViewportRef: Ref<HTMLElement | null>;
|
|
14
|
+
zoom: Ref<number>;
|
|
15
|
+
comments: ShallowRef<Comment[]>;
|
|
16
|
+
focus: () => void;
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
getDocument: () => Document | null;
|
|
19
|
+
setZoom: (zoom: number) => void;
|
|
20
|
+
save: () => Promise<ArrayBuffer | null>;
|
|
21
|
+
loadDocument: (doc: Document) => void;
|
|
22
|
+
loadDocumentBuffer: (buffer: DocxInput) => Promise<void>;
|
|
23
|
+
addComment: (options: {
|
|
24
|
+
paraId: string;
|
|
25
|
+
text: string;
|
|
26
|
+
author: string;
|
|
27
|
+
search?: string;
|
|
28
|
+
}) => number | null;
|
|
29
|
+
replyToComment: (commentId: number, text: string, author: string) => number | null;
|
|
30
|
+
resolveComment: (commentId: number) => void;
|
|
31
|
+
proposeChange: (options: {
|
|
32
|
+
paraId: string;
|
|
33
|
+
search: string;
|
|
34
|
+
replaceWith: string;
|
|
35
|
+
author: string;
|
|
36
|
+
}) => boolean;
|
|
37
|
+
applyFormatting: (options: ApplyFormattingOptions) => boolean;
|
|
38
|
+
setParagraphStyle: (options: {
|
|
39
|
+
paraId: string;
|
|
40
|
+
styleId: string;
|
|
41
|
+
}) => boolean;
|
|
42
|
+
insertBreak: (options: {
|
|
43
|
+
paraId: string;
|
|
44
|
+
type: 'page' | 'sectionNextPage' | 'sectionContinuous';
|
|
45
|
+
}) => boolean;
|
|
46
|
+
scrollVisiblePositionIntoView: (pmPos: number) => void;
|
|
47
|
+
contentChangeSubscribers: Set<(document: unknown) => void>;
|
|
48
|
+
selectionChangeSubscribers: Set<(selection: unknown) => void>;
|
|
49
|
+
onPrint?: () => void;
|
|
50
|
+
}
|
|
51
|
+
export declare function useDocxEditorRefApi(opts: UseDocxEditorRefApiOptions): {
|
|
52
|
+
exposed: DocxEditorRef;
|
|
53
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export interface DragAutoScrollOptions {
|
|
3
|
+
pagesContainer: Ref<HTMLElement | null>;
|
|
4
|
+
/** Called during auto-scroll to extend the selection at the current mouse position. */
|
|
5
|
+
onScrollExtendSelection: (clientX: number, clientY: number) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface UseDragAutoScrollReturn {
|
|
8
|
+
updateMousePosition: (clientX: number, clientY: number) => void;
|
|
9
|
+
stopAutoScroll: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useDragAutoScroll({ pagesContainer, onScrollExtendSelection, }: DragAutoScrollOptions): UseDragAutoScrollReturn;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
3
|
+
export interface UseFileIOOptions {
|
|
4
|
+
/** From useDocxEditor — loads a .docx buffer into the editor. */
|
|
5
|
+
loadBuffer: (buffer: ArrayBuffer | Uint8Array | Blob | File) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Host override for File > Open / Cmd+O. When provided, the picked file is
|
|
8
|
+
* passed here instead of running the built-in local load — lets consumers
|
|
9
|
+
* route Open through their own import pipeline (e.g. a CRDT backend).
|
|
10
|
+
*/
|
|
11
|
+
onOpen?: (file: File) => void | Promise<void>;
|
|
12
|
+
/** From useDocxEditor — loads an already-parsed Document model. */
|
|
13
|
+
loadParsedDocument: (doc: Document) => void;
|
|
14
|
+
/** From useDocxEditor — returns the current Document, or null. */
|
|
15
|
+
getDocument: () => Document | null;
|
|
16
|
+
/** From useDocxEditor — serializes the current state to a .docx Blob. */
|
|
17
|
+
saveBlob: () => Promise<Blob | null>;
|
|
18
|
+
/** Fired after load+extract so the next tick sees comments/tracked-changes. */
|
|
19
|
+
extractCommentsAndChanges: () => void;
|
|
20
|
+
/** SFC's emit function — re-emits ready / rename / update:document / error. */
|
|
21
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
22
|
+
/** Accessor — read freshly inside the handler so prop updates are honored. */
|
|
23
|
+
documentName: () => string | undefined;
|
|
24
|
+
onDocumentNameChange?: (name: string) => void;
|
|
25
|
+
/** Active editor view to insert images into — the header/footer being edited, else the body. */
|
|
26
|
+
getActiveView: () => EditorView | null;
|
|
27
|
+
/** Vue's `nextTick` — passed in so the composable doesn't require its own import wiring. */
|
|
28
|
+
nextTick: () => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function useFileIO(opts: UseFileIOOptions): {
|
|
31
|
+
docxInputRef: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
32
|
+
imageInputRef: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
33
|
+
handleImageFileChange: (event: Event) => void;
|
|
34
|
+
handleDocxFileChange: (event: Event) => Promise<void>;
|
|
35
|
+
handleDocumentNameChange: (name: string) => void;
|
|
36
|
+
downloadCurrentDocument: () => Promise<void>;
|
|
37
|
+
emitReadyAfterSidebarStateRefresh: () => Promise<void>;
|
|
38
|
+
loadDocumentBuffer: (buffer: Parameters<typeof opts.loadBuffer>[0]) => Promise<void>;
|
|
39
|
+
loadDocument: (doc: Document) => void;
|
|
40
|
+
save: () => Promise<ArrayBuffer | null>;
|
|
41
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { FindMatch, FindOptions } from '@heyirisai/docx-editor-core/utils/findReplace';
|
|
3
|
+
export type { FindMatch, FindOptions };
|
|
4
|
+
export interface FindReplaceOptions {
|
|
5
|
+
initialReplaceMode?: boolean;
|
|
6
|
+
onMatchesChange?: (matches: FindMatch[]) => void;
|
|
7
|
+
onCurrentMatchChange?: (match: FindMatch | null, index: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface FindReplaceState {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
searchText: string;
|
|
12
|
+
replaceText: string;
|
|
13
|
+
options: FindOptions;
|
|
14
|
+
matches: FindMatch[];
|
|
15
|
+
currentIndex: number;
|
|
16
|
+
replaceMode: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface UseFindReplaceReturn {
|
|
19
|
+
state: FindReplaceState;
|
|
20
|
+
currentMatch: ComputedRef<FindMatch | null>;
|
|
21
|
+
hasMatches: ComputedRef<boolean>;
|
|
22
|
+
openFind: (selectedText?: string) => void;
|
|
23
|
+
openReplace: (selectedText?: string) => void;
|
|
24
|
+
close: () => void;
|
|
25
|
+
toggle: () => void;
|
|
26
|
+
setSearchText: (text: string) => void;
|
|
27
|
+
setReplaceText: (text: string) => void;
|
|
28
|
+
setOptions: (opts: Partial<FindOptions>) => void;
|
|
29
|
+
setMatches: (matches: FindMatch[], currentIndex?: number) => void;
|
|
30
|
+
goToNextMatch: () => number;
|
|
31
|
+
goToPreviousMatch: () => number;
|
|
32
|
+
goToMatch: (index: number) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function useFindReplace(hookOptions?: FindReplaceOptions): UseFindReplaceReturn;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ref, CSSProperties } from 'vue';
|
|
2
|
+
export interface UseFixedDropdownOptions {
|
|
3
|
+
isOpen: Ref<boolean>;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
/** 'left' aligns dropdown left edge to trigger, 'right' aligns right edge. */
|
|
6
|
+
align?: 'left' | 'right';
|
|
7
|
+
}
|
|
8
|
+
export interface UseFixedDropdownReturn {
|
|
9
|
+
containerRef: Ref<HTMLElement | null>;
|
|
10
|
+
dropdownRef: Ref<HTMLElement | null>;
|
|
11
|
+
dropdownStyle: Ref<CSSProperties>;
|
|
12
|
+
handleMouseDown: (e: MouseEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useFixedDropdown({ isOpen, onClose, align, }: UseFixedDropdownOptions): UseFixedDropdownReturn;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FontDefinition } from '@heyirisai/docx-editor-core/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Vue counterpart to React's `useFontLifecycle`.
|
|
4
|
+
*
|
|
5
|
+
* - Re-registers custom faces from the `fonts` prop on identity change.
|
|
6
|
+
* The loader dedupes by `family|weight`, so re-runs are cheap.
|
|
7
|
+
* - Forwards font-load failures to the supplied error handler. `<DocxEditor>`
|
|
8
|
+
* passes `(err) => emit('error', err)`; `emit` is stable per `<script setup>`
|
|
9
|
+
* instance, so the subscription stays on a single listener for the
|
|
10
|
+
* component's lifetime.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useFontLifecycle(fontsGetter: () => ReadonlyArray<FontDefinition> | undefined, onError: (error: Error) => void): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
4
|
+
import { ApplyFormattingOptions, InsertBreakOptions } from '@heyirisai/docx-editor-core/prosemirror/applyFormatting';
|
|
5
|
+
export interface UseFormattingActionsOptions {
|
|
6
|
+
editorView: Ref<EditorView | null>;
|
|
7
|
+
/**
|
|
8
|
+
* The view interactive toolbar formatting should target. While a header or
|
|
9
|
+
* footer is being edited this is its EditorView, so toolbar actions land in
|
|
10
|
+
* the HF and not the body (#749). Falls back to the body `editorView`. The
|
|
11
|
+
* agent ref-API (`applyFormatting`/`setParagraphStyle`, which resolve a
|
|
12
|
+
* paraId in the body) deliberately keeps using `editorView`.
|
|
13
|
+
*/
|
|
14
|
+
activeView?: Ref<EditorView | null>;
|
|
15
|
+
getDocument: () => Document | null;
|
|
16
|
+
}
|
|
17
|
+
export type { ApplyFormattingOptions, InsertBreakOptions };
|
|
18
|
+
export declare function useFormattingActions(opts: UseFormattingActionsOptions): {
|
|
19
|
+
handleClearFormatting: () => void;
|
|
20
|
+
handleApplyStyle: (styleId: string) => void;
|
|
21
|
+
handleInsertPageBreak: () => void;
|
|
22
|
+
handleInsertSectionBreakNextPage: () => void;
|
|
23
|
+
handleInsertSectionBreakContinuous: () => void;
|
|
24
|
+
handleInsertSymbol: (symbol: string) => void;
|
|
25
|
+
applyFormatting: (options: ApplyFormattingOptions) => boolean;
|
|
26
|
+
setParagraphStyle: (options: {
|
|
27
|
+
paraId: string;
|
|
28
|
+
styleId: string;
|
|
29
|
+
}) => boolean;
|
|
30
|
+
insertBreak: (options: InsertBreakOptions) => boolean;
|
|
31
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
export interface UseHistoryReturn {
|
|
4
|
+
canUndo: ComputedRef<boolean>;
|
|
5
|
+
canRedo: ComputedRef<boolean>;
|
|
6
|
+
undo: () => boolean;
|
|
7
|
+
redo: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useHistory(view: Ref<EditorView | null>, stateTick: Ref<number>): UseHistoryReturn;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { DocxEditorProps } from '../components/DocxEditor/types';
|
|
4
|
+
import { CommentCallbacks } from './useCommentManagement';
|
|
5
|
+
export declare function useHostCallbacks(props: DocxEditorProps, editorView: Ref<EditorView | null>): {
|
|
6
|
+
commentCallbacks: CommentCallbacks;
|
|
7
|
+
};
|
|
@@ -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 '@heyirisai/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 {};
|