@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,22 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { Document, SectionProperties } from '@heyirisai/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 '@heyirisai/docx-editor-core/types/content';
|
|
4
|
+
import { Document } from '@heyirisai/docx-editor-core/types/document';
|
|
5
|
+
import { ImageSelectionInfo } from '../components/imageSelectionTypes';
|
|
6
|
+
import { Layout } from '@heyirisai/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('@heyirisai/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 '@heyirisai/docx-editor-core/utils/stylePreview';
|
|
3
|
+
import { Style } from '@heyirisai/docx-editor-core/types/document';
|
|
4
|
+
import { TranslationKey } from '@heyirisai/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 '@heyirisai/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,36 @@
|
|
|
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
|
+
pagesRef: Ref<HTMLElement | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Current zoom factor. The caret + selection rects are painted into the
|
|
9
|
+
* `.docx-editor-vue__pages` container, which carries `transform: scale(zoom)`.
|
|
10
|
+
* `getBoundingClientRect` returns post-transform (viewport) coordinates, so
|
|
11
|
+
* the rects must be divided by zoom to land in the container's own
|
|
12
|
+
* coordinate space — otherwise the parent's scale multiplies them a second
|
|
13
|
+
* time and the highlight drifts off the text at any zoom ≠ 100%.
|
|
14
|
+
*/
|
|
15
|
+
zoom: Ref<number>;
|
|
16
|
+
selectedImage: ShallowRef<ImageSelectionInfo | null>;
|
|
17
|
+
/**
|
|
18
|
+
* True while the user is editing a header/footer. When set, the body PM's
|
|
19
|
+
* caret + selection rects MUST stay hidden so the user doesn't see two
|
|
20
|
+
* carets blinking simultaneously (one in the painted header, one in the
|
|
21
|
+
* body). The HF view's own caret rect is drawn by DocxEditor.vue.
|
|
22
|
+
*/
|
|
23
|
+
isHfEditing?: Ref<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* True while a resize / move / rotate gesture is in flight. Suppresses the
|
|
26
|
+
* post-transaction "clear the overlay" path so the handles don't vanish
|
|
27
|
+
* mid-drag when an intermediate state momentarily isn't an image
|
|
28
|
+
* NodeSelection. Mirrors React's `isImageInteractingRef`.
|
|
29
|
+
*/
|
|
30
|
+
imageInteracting?: Ref<boolean>;
|
|
31
|
+
}
|
|
32
|
+
export interface UseSelectionSyncReturn {
|
|
33
|
+
clearOverlay: () => void;
|
|
34
|
+
updateSelectionOverlay: () => void;
|
|
35
|
+
}
|
|
36
|
+
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 '@heyirisai/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 '@heyirisai/docx-editor-core/prosemirror/utils/extractTrackedChanges';
|
|
4
|
+
export type { TrackedChangesResult };
|
|
5
|
+
export { extractTrackedChanges };
|
|
6
|
+
export type { TrackedChangeEntry } from '@heyirisai/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 '@heyirisai/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 '@heyirisai/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-liP5PRvM.cjs`);let n=require(`vue`),r=require(`@heyirisai/docx-editor-core/utils`),i=require(`prosemirror-history`),a=require(`@heyirisai/docx-editor-core/prosemirror/utils/extractTrackedChanges`),o=require(`@heyirisai/docx-editor-core`),s=require(`@heyirisai/docx-editor-core/utils/findReplace`),c=require(`@heyirisai/docx-editor-core/managers/TableSelectionManager`),l=require(`@heyirisai/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;
|