@eigenpal/docx-editor-vue 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/KeyboardShortcutsDialog-Dohz9D39.cjs +1 -0
  2. package/dist/{KeyboardShortcutsDialog-BbuDgglK.js → KeyboardShortcutsDialog-OPAV0oVm.js} +351 -506
  3. package/dist/{MenuBar-CbONA9-a.js → MenuBar-BLKoZqG3.js} +813 -692
  4. package/dist/MenuBar-BP-XM0MI.cjs +4 -0
  5. package/dist/{TablePropertiesDialog-JWT68zEO.cjs → TablePropertiesDialog-B-FVOqkH.cjs} +1 -1
  6. package/dist/TablePropertiesDialog-B3oZIIjw.js +1145 -0
  7. package/dist/components/DocxEditor/types.d.ts +26 -0
  8. package/dist/components/Toolbar/presets.d.ts +0 -1
  9. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  10. package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
  11. package/dist/composables/imageOverlayRect.d.ts +44 -0
  12. package/dist/composables/imageOverlayRect.test.d.ts +1 -0
  13. package/dist/composables/useColorMode.d.ts +8 -0
  14. package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
  15. package/dist/composables/useDocxEditorRefApi.d.ts +4 -0
  16. package/dist/composables/useFileIO.d.ts +5 -0
  17. package/dist/composables/useFormattingActions.d.ts +5 -2
  18. package/dist/composables/useImageActions.d.ts +0 -6
  19. package/dist/composables/useMenuActions.d.ts +3 -1
  20. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  21. package/dist/composables/useToolbarDropdowns.d.ts +1 -0
  22. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  23. package/dist/composables.cjs +1 -1
  24. package/dist/composables.js +5 -4
  25. package/dist/dialogs.cjs +1 -1
  26. package/dist/dialogs.js +3 -3
  27. package/dist/docx-editor-vue.css +1 -1
  28. package/dist/index.cjs +4 -4
  29. package/dist/index.js +1375 -1258
  30. package/dist/plugin-api.cjs +1 -1
  31. package/dist/plugin-api.js +1 -1
  32. package/dist/ui.cjs +2 -2
  33. package/dist/ui.js +253 -230
  34. package/dist/{useCommentSidebarItems-CbNvNCd3.cjs → useCommentSidebarItems-DBeGKNGA.cjs} +1 -1
  35. package/dist/{useCommentSidebarItems-BHomCzpj.js → useCommentSidebarItems-DXbF857R.js} +2 -1
  36. package/dist/{useDragAutoScroll-BNPB-6SM.js → useDragAutoScroll-B21Ec-Zy.js} +6 -7
  37. package/dist/useDragAutoScroll-BPnc7LEO.cjs +1 -0
  38. package/package.json +4 -4
  39. package/dist/KeyboardShortcutsDialog-Bct8AJ0i.cjs +0 -1
  40. package/dist/MenuBar-m0JEaF1X.cjs +0 -4
  41. package/dist/TablePropertiesDialog-D5MIF3cj.js +0 -987
  42. package/dist/useDragAutoScroll-DCUotwOX.cjs +0 -1
@@ -38,6 +38,8 @@ export interface DocxEditorProps {
38
38
  i18n?: Translations;
39
39
  /** Theme override used for toolbar color palettes when the document has no theme. */
40
40
  theme?: Theme | null;
41
+ /** Color theme mode for UI styling. `'system'` follows the OS preference. */
42
+ colorMode?: 'light' | 'dark' | 'system';
41
43
  /** External ProseMirror plugins supplied by the host app. */
42
44
  externalPlugins?: Plugin[];
43
45
  /** Whether to show the zoom controls in the toolbar. */
@@ -63,6 +65,12 @@ export interface DocxEditorProps {
63
65
  * entries can share `family` to register different weights/styles.
64
66
  */
65
67
  fonts?: ReadonlyArray<FontDefinition>;
68
+ /**
69
+ * Text-watermark presets shown in the watermark dialog's preset dropdown.
70
+ * Omit to use the built-in MS Word phrases (`DEFAULT_WATERMARK_PRESETS`).
71
+ * Pass an empty array to hide the preset dropdown.
72
+ */
73
+ watermarkPresets?: readonly string[];
66
74
  /**
67
75
  * Callback fired when the print action is triggered. Pass it to enable the
68
76
  * `File > Print` menu entry; omit to hide. The `editor.print()` ref method
@@ -118,6 +126,24 @@ export type DocxEditorRef = EditorRefLike & {
118
126
  scrollToPage(pageNumber: number): void;
119
127
  /** Scroll to a raw ProseMirror document position. */
120
128
  scrollToPosition(pmPos: number): void;
129
+ /**
130
+ * Scroll the comment with the given id into view and select its anchored
131
+ * range so the selection overlay highlights it. False when the id no longer
132
+ * resolves (the comment was deleted or its anchored text removed).
133
+ */
134
+ scrollToCommentId(commentId: number): boolean;
135
+ /**
136
+ * Scroll the tracked change with the given revision id into view and select
137
+ * its range so the selection overlay highlights it. False when the id no
138
+ * longer resolves (the change was accepted/rejected/deleted).
139
+ */
140
+ scrollToChangeId(revisionId: number): boolean;
141
+ /**
142
+ * Select the position range `[from, to]` so the selection overlay highlights
143
+ * it, and scroll its start into view. No-op for a malformed range or a
144
+ * `from` past the document end; `to` is clamped to the document size.
145
+ */
146
+ highlightRange(from: number, to: number): void;
121
147
  /** Open print preview / browser print. */
122
148
  openPrintPreview(): void;
123
149
  /** Print the document. */
@@ -7,7 +7,6 @@ export interface ParagraphStylePreset {
7
7
  /** Fallback label used if the i18n key resolves to nothing. */
8
8
  label: string;
9
9
  nameKey: TranslationKey;
10
- previewStyle: Record<string, string>;
11
10
  }
12
11
  export declare const paragraphStyles: ParagraphStylePreset[];
13
12
  export interface LineSpacingPreset {
@@ -0,0 +1 @@
1
+ export declare function getPrimaryFontFamily(fontFamily: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Pure geometry for the Vue image-selection overlay. Kept separate from the
3
+ * component so the scrollbar-gutter handling can be unit-tested without a DOM.
4
+ */
5
+ export interface OverlayRectInputs {
6
+ /** `image.getBoundingClientRect()` (viewport coords). */
7
+ imageRect: {
8
+ left: number;
9
+ top: number;
10
+ width: number;
11
+ height: number;
12
+ };
13
+ /** `offsetParent.getBoundingClientRect()` (the scroll container, viewport coords). */
14
+ parentRect: {
15
+ left: number;
16
+ top: number;
17
+ };
18
+ scrollLeft: number;
19
+ scrollTop: number;
20
+ /** `offsetParent.offsetWidth` / `.clientWidth` — used to derive the gutter. */
21
+ parentOffsetWidth: number;
22
+ parentClientWidth: number;
23
+ zoom: number;
24
+ }
25
+ export interface OverlayRect {
26
+ left: number;
27
+ top: number;
28
+ width: number;
29
+ height: number;
30
+ }
31
+ /**
32
+ * Position the overlay (absolute, inside the scroll container) over the image.
33
+ *
34
+ * The scroll container uses `scrollbar-gutter: stable both-edges`, which
35
+ * reserves an inline-start gutter that sits OUTSIDE the absolute-positioning
36
+ * origin. `getBoundingClientRect().left` is the border-box left (before the
37
+ * gutter), so `imageRect.left - parentRect.left` over-counts the left gutter
38
+ * and the frame lands shifted right by that width (issue #764). With
39
+ * `both-edges` the two gutters are equal, so the left gutter is half of the
40
+ * total reserved inline space (`offsetWidth - clientWidth`, no borders here).
41
+ * On overlay-scrollbar platforms (e.g. macOS) the reserved space is 0, so the
42
+ * correction is a no-op and behavior is unchanged.
43
+ */
44
+ export declare function computeImageOverlayRect(i: OverlayRectInputs): OverlayRect;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { ColorMode } from '@eigenpal/docx-editor-core/utils';
3
+ /**
4
+ * Resolve the effective dark flag from a reactive `colorMode`. `'system'`
5
+ * follows the OS via `subscribeSystemDark` (SSR-safe; re-syncs on entry).
6
+ * Mirrors the React adapter's inline colorMode logic via the shared core helpers.
7
+ */
8
+ export declare function useColorMode(colorMode: () => ColorMode): ComputedRef<boolean>;
@@ -0,0 +1 @@
1
+ export {};
@@ -39,6 +39,10 @@ export interface UseDocxEditorRefApiOptions {
39
39
  paraId: string;
40
40
  styleId: string;
41
41
  }) => boolean;
42
+ insertBreak: (options: {
43
+ paraId: string;
44
+ type: 'page' | 'sectionNextPage' | 'sectionContinuous';
45
+ }) => boolean;
42
46
  scrollVisiblePositionIntoView: (pmPos: number) => void;
43
47
  contentChangeSubscribers: Set<(document: unknown) => void>;
44
48
  selectionChangeSubscribers: Set<(selection: unknown) => void>;
@@ -1,3 +1,4 @@
1
+ import { EditorView } from 'prosemirror-view';
1
2
  import { Document } from '@eigenpal/docx-editor-core/types/document';
2
3
  export interface UseFileIOOptions {
3
4
  /** From useDocxEditor — loads a .docx buffer into the editor. */
@@ -15,11 +16,15 @@ export interface UseFileIOOptions {
15
16
  /** Accessor — read freshly inside the handler so prop updates are honored. */
16
17
  documentName: () => string | undefined;
17
18
  onDocumentNameChange?: (name: string) => void;
19
+ /** Active editor view to insert images into — the header/footer being edited, else the body. */
20
+ getActiveView: () => EditorView | null;
18
21
  /** Vue's `nextTick` — passed in so the composable doesn't require its own import wiring. */
19
22
  nextTick: () => Promise<void>;
20
23
  }
21
24
  export declare function useFileIO(opts: UseFileIOOptions): {
22
25
  docxInputRef: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
26
+ imageInputRef: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
27
+ handleImageFileChange: (event: Event) => void;
23
28
  handleDocxFileChange: (event: Event) => Promise<void>;
24
29
  handleDocumentNameChange: (name: string) => void;
25
30
  downloadCurrentDocument: () => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { Ref } from 'vue';
2
2
  import { EditorView } from 'prosemirror-view';
3
3
  import { Document } from '@eigenpal/docx-editor-core/types/document';
4
- import { ApplyFormattingOptions } from '@eigenpal/docx-editor-core/prosemirror/applyFormatting';
4
+ import { ApplyFormattingOptions, InsertBreakOptions } from '@eigenpal/docx-editor-core/prosemirror/applyFormatting';
5
5
  export interface UseFormattingActionsOptions {
6
6
  editorView: Ref<EditorView | null>;
7
7
  /**
@@ -14,15 +14,18 @@ export interface UseFormattingActionsOptions {
14
14
  activeView?: Ref<EditorView | null>;
15
15
  getDocument: () => Document | null;
16
16
  }
17
- export type { ApplyFormattingOptions };
17
+ export type { ApplyFormattingOptions, InsertBreakOptions };
18
18
  export declare function useFormattingActions(opts: UseFormattingActionsOptions): {
19
19
  handleClearFormatting: () => void;
20
20
  handleApplyStyle: (styleId: string) => void;
21
21
  handleInsertPageBreak: () => void;
22
+ handleInsertSectionBreakNextPage: () => void;
23
+ handleInsertSectionBreakContinuous: () => void;
22
24
  handleInsertSymbol: (symbol: string) => void;
23
25
  applyFormatting: (options: ApplyFormattingOptions) => boolean;
24
26
  setParagraphStyle: (options: {
25
27
  paraId: string;
26
28
  styleId: string;
27
29
  }) => boolean;
30
+ insertBreak: (options: InsertBreakOptions) => boolean;
28
31
  };
@@ -17,12 +17,6 @@ export interface UseImageActionsReturn {
17
17
  selectedImage: import('vue').ShallowRef<ImageSelectionInfo | null>;
18
18
  imageInteracting: import('vue').Ref<boolean>;
19
19
  imageToolbarContext: import('vue').ComputedRef<ImageToolbarContext | null>;
20
- handleInsertImage: (data: {
21
- src: string;
22
- width: number;
23
- height: number;
24
- alt: string;
25
- }) => void;
26
20
  handleToolbarImageWrap: (value: string) => void;
27
21
  handleImageTransform: (action: 'rotateCW' | 'rotateCCW' | 'flipH' | 'flipV') => void;
28
22
  }
@@ -4,14 +4,16 @@ export interface UseMenuActionsOptions {
4
4
  editorView: Ref<EditorView | null>;
5
5
  getCommands: () => Record<string, (...args: any[]) => any>;
6
6
  docxInputRef: Ref<HTMLInputElement | null>;
7
+ imageInputRef: Ref<HTMLInputElement | null>;
7
8
  showPageSetup: Ref<boolean>;
8
9
  showWatermark: Ref<boolean>;
9
- showInsertImage: Ref<boolean>;
10
10
  showHyperlink: Ref<boolean>;
11
11
  showInsertSymbol: Ref<boolean>;
12
12
  showKeyboardShortcuts: Ref<boolean>;
13
13
  handleClearFormatting: () => void;
14
14
  handleInsertPageBreak: () => void;
15
+ handleInsertSectionBreakNextPage: () => void;
16
+ handleInsertSectionBreakContinuous: () => void;
15
17
  handleToggleOutline: () => void;
16
18
  handleToggleSidebar: () => void;
17
19
  downloadCurrentDocument: () => Promise<void>;
@@ -0,0 +1,18 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { StylePreviewProps } from '@eigenpal/docx-editor-core/utils/stylePreview';
3
+ import { Style } from '@eigenpal/docx-editor-core/types/document';
4
+ import { TranslationKey } from '@eigenpal/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;
@@ -11,4 +11,5 @@ export declare function useToolbarDropdowns(refs: UseToolbarDropdownsOptions): {
11
11
  openDropdown: Ref<string | null, string | null>;
12
12
  dropdownMenuStyle: import('vue').ComputedRef<CSSProperties>;
13
13
  toggleDropdown: (name: string) => void;
14
+ recomputeDropdownPos: (name: string) => void;
14
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;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useCommentSidebarItems-CbNvNCd3.cjs`),t=require(`./useDragAutoScroll-DCUotwOX.cjs`);let n=require(`vue`),r=require(`@eigenpal/docx-editor-core/utils`),i=require(`prosemirror-history`),a=require(`@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges`),o=require(`@eigenpal/docx-editor-core`),s=require(`@eigenpal/docx-editor-core/utils/findReplace`),c=require(`@eigenpal/docx-editor-core/managers/TableSelectionManager`),l=require(`@eigenpal/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(){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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useCommentSidebarItems-DBeGKNGA.cjs`),t=require(`./useDragAutoScroll-BPnc7LEO.cjs`);let n=require(`vue`),r=require(`@eigenpal/docx-editor-core/utils`),i=require(`prosemirror-history`),a=require(`@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges`),o=require(`@eigenpal/docx-editor-core`),s=require(`@eigenpal/docx-editor-core/utils/findReplace`),c=require(`@eigenpal/docx-editor-core/managers/TableSelectionManager`),l=require(`@eigenpal/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;
@@ -1,5 +1,5 @@
1
- import { t as e } from "./useCommentSidebarItems-BHomCzpj.js";
2
- import { i as t, n, r, t as i } from "./useDragAutoScroll-BNPB-6SM.js";
1
+ import { t as e } from "./useCommentSidebarItems-DXbF857R.js";
2
+ import { i as t, n, r, t as i } from "./useDragAutoScroll-B21Ec-Zy.js";
3
3
  import { computed as a, onBeforeUnmount as o, onMounted as s, reactive as c, ref as l, unref as u, watch as d } from "vue";
4
4
  import { DEFAULT_SELECTION_STYLE as f, areSelectionStylesInjected as p, copyRuns as m, getMergedSelectionRects as h, getSelectedText as g, hasActiveSelection as _, injectSelectionStyles as v, isSelectionWithin as y, parseClipboardHtml as b, runsToClipboardContent as x } from "@eigenpal/docx-editor-core/utils";
5
5
  import { redo as S, redoDepth as C, undo as w, undoDepth as T } from "prosemirror-history";
@@ -221,8 +221,9 @@ function K({ isOpen: e, onClose: t, align: n = "left" }) {
221
221
  function u(e) {
222
222
  e.key === "Escape" && t();
223
223
  }
224
- function f() {
225
- t();
224
+ function f(e) {
225
+ let n = e.target;
226
+ n && i.value && i.value.contains(n) || t();
226
227
  }
227
228
  function p() {
228
229
  document.addEventListener("mousedown", c), document.addEventListener("keydown", u), window.addEventListener("scroll", f, !0);
package/dist/dialogs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./KeyboardShortcutsDialog-Bct8AJ0i.cjs`),t=require(`./TablePropertiesDialog-JWT68zEO.cjs`);exports.FindReplaceDialog=e.s,exports.FootnotePropertiesDialog=t.o,exports.HyperlinkDialog=e.a,exports.ImagePositionDialog=t.a,exports.ImagePropertiesDialog=e.r,exports.InsertImageDialog=e.o,exports.InsertSymbolDialog=e.i,exports.InsertTableDialog=t.i,exports.KeyboardShortcutsDialog=e.t,exports.PageSetupDialog=e.n,exports.PasteSpecialDialog=t.r,exports.SplitCellDialog=t.n,exports.TablePropertiesDialog=t.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./KeyboardShortcutsDialog-Dohz9D39.cjs`),t=require(`./TablePropertiesDialog-B-FVOqkH.cjs`);exports.FindReplaceDialog=e.o,exports.FootnotePropertiesDialog=t.s,exports.HyperlinkDialog=e.a,exports.ImagePositionDialog=t.o,exports.ImagePropertiesDialog=e.r,exports.InsertImageDialog=t.a,exports.InsertSymbolDialog=e.i,exports.InsertTableDialog=t.i,exports.KeyboardShortcutsDialog=e.t,exports.PageSetupDialog=e.n,exports.PasteSpecialDialog=t.r,exports.SplitCellDialog=t.n,exports.TablePropertiesDialog=t.t;
package/dist/dialogs.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./KeyboardShortcutsDialog-BbuDgglK.js";
2
- import { a as s, i as c, n as l, o as u, r as d, t as f } from "./TablePropertiesDialog-D5MIF3cj.js";
3
- export { a as FindReplaceDialog, u as FootnotePropertiesDialog, e as HyperlinkDialog, s as ImagePositionDialog, i as ImagePropertiesDialog, r as InsertImageDialog, t as InsertSymbolDialog, c as InsertTableDialog, o as KeyboardShortcutsDialog, n as PageSetupDialog, d as PasteSpecialDialog, l as SplitCellDialog, f as TablePropertiesDialog };
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./KeyboardShortcutsDialog-OPAV0oVm.js";
2
+ import { a as o, i as s, n as c, o as l, r as u, s as d, t as f } from "./TablePropertiesDialog-B3oZIIjw.js";
3
+ export { r as FindReplaceDialog, d as FootnotePropertiesDialog, e as HyperlinkDialog, l as ImagePositionDialog, i as ImagePropertiesDialog, o as InsertImageDialog, t as InsertSymbolDialog, s as InsertTableDialog, a as KeyboardShortcutsDialog, n as PageSetupDialog, u as PasteSpecialDialog, c as SplitCellDialog, f as TablePropertiesDialog };