@eigenpal/docx-editor-vue 1.4.0 → 1.5.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.
@@ -118,6 +118,24 @@ export type DocxEditorRef = EditorRefLike & {
118
118
  scrollToPage(pageNumber: number): void;
119
119
  /** Scroll to a raw ProseMirror document position. */
120
120
  scrollToPosition(pmPos: number): void;
121
+ /**
122
+ * Scroll the comment with the given id into view and select its anchored
123
+ * range so the selection overlay highlights it. False when the id no longer
124
+ * resolves (the comment was deleted or its anchored text removed).
125
+ */
126
+ scrollToCommentId(commentId: number): boolean;
127
+ /**
128
+ * Scroll the tracked change with the given revision id into view and select
129
+ * its range so the selection overlay highlights it. False when the id no
130
+ * longer resolves (the change was accepted/rejected/deleted).
131
+ */
132
+ scrollToChangeId(revisionId: number): boolean;
133
+ /**
134
+ * Select the position range `[from, to]` so the selection overlay highlights
135
+ * it, and scroll its start into view. No-op for a malformed range or a
136
+ * `from` past the document end; `to` is clamped to the document size.
137
+ */
138
+ highlightRange(from: number, to: number): void;
121
139
  /** Open print preview / browser print. */
122
140
  openPrintPreview(): void;
123
141
  /** Print the document. */
@@ -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 @@
1
+ export {};
@@ -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>;
@@ -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,9 +4,9 @@ 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>;
@@ -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-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,4 +1,4 @@
1
- import { t as e } from "./useCommentSidebarItems-BHomCzpj.js";
1
+ import { t as e } from "./useCommentSidebarItems-DXbF857R.js";
2
2
  import { i as t, n, r, t as i } from "./useDragAutoScroll-BNPB-6SM.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";
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-DyfvEiK5.cjs`),t=require(`./TablePropertiesDialog-BVlqA7s3.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-DtuQzPxi.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-D4xs_Xif.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 };