@xcrong/docx-editor-vue 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +116 -0
  3. package/dist/KeyboardShortcutsDialog-60tuBVsM.js +2799 -0
  4. package/dist/KeyboardShortcutsDialog-BcNYSl3S.cjs +1 -0
  5. package/dist/RenderedDomContext-CuV0wMPx.js +2 -0
  6. package/dist/TablePropertiesDialog-CG6Yj6KO.js +1145 -0
  7. package/dist/TablePropertiesDialog-CzY5A22W.cjs +1 -0
  8. package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
  9. package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
  10. package/dist/components/DocxEditor/types.d.ts +193 -0
  11. package/dist/components/EditorToolbarContext.d.ts +9 -0
  12. package/dist/components/Toolbar/presets.d.ts +20 -0
  13. package/dist/components/dialogs/index.d.ts +27 -0
  14. package/dist/components/imageContextMenuTypes.d.ts +30 -0
  15. package/dist/components/imageSelectionTypes.d.ts +14 -0
  16. package/dist/components/insertTableState.d.ts +9 -0
  17. package/dist/components/sidebar/cardStyles.d.ts +3 -0
  18. package/dist/components/sidebar/cardUtils.d.ts +1 -0
  19. package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
  20. package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
  21. package/dist/components/tableStylePresets.d.ts +53 -0
  22. package/dist/components/toolbarUtils.d.ts +1 -0
  23. package/dist/components/ui/Icons.d.ts +1 -0
  24. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  25. package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
  26. package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
  27. package/dist/composables/fileOpen.test.d.ts +1 -0
  28. package/dist/composables/imageOverlayRect.d.ts +44 -0
  29. package/dist/composables/imageOverlayRect.test.d.ts +1 -0
  30. package/dist/composables/index.d.ts +30 -0
  31. package/dist/composables/useAutoSave.d.ts +40 -0
  32. package/dist/composables/useClipboard.d.ts +22 -0
  33. package/dist/composables/useColorMode.d.ts +8 -0
  34. package/dist/composables/useCommentLifecycle.d.ts +62 -0
  35. package/dist/composables/useCommentManagement.d.ts +68 -0
  36. package/dist/composables/useCommentSidebarItems.d.ts +24 -0
  37. package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
  38. package/dist/composables/useContextMenus.cut.test.d.ts +1 -0
  39. package/dist/composables/useContextMenus.d.ts +39 -0
  40. package/dist/composables/useControllableBoolean.d.ts +16 -0
  41. package/dist/composables/useControllableBoolean.test.d.ts +1 -0
  42. package/dist/composables/useDocumentLifecycle.d.ts +11 -0
  43. package/dist/composables/useDocxEditor.d.ts +96 -0
  44. package/dist/composables/useDocxEditorRefApi.d.ts +53 -0
  45. package/dist/composables/useDragAutoScroll.d.ts +11 -0
  46. package/dist/composables/useFileIO.d.ts +41 -0
  47. package/dist/composables/useFindReplace.d.ts +34 -0
  48. package/dist/composables/useFixedDropdown.d.ts +14 -0
  49. package/dist/composables/useFontLifecycle.d.ts +12 -0
  50. package/dist/composables/useFormattingActions.d.ts +31 -0
  51. package/dist/composables/useHistory.d.ts +9 -0
  52. package/dist/composables/useHostCallbacks.d.ts +7 -0
  53. package/dist/composables/useHyperlinkManagement.d.ts +38 -0
  54. package/dist/composables/useImageActions.d.ts +24 -0
  55. package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
  56. package/dist/composables/useMenuActions.d.ts +26 -0
  57. package/dist/composables/useOutlineSidebar.d.ts +24 -0
  58. package/dist/composables/useOutlineSidebar.test.d.ts +1 -0
  59. package/dist/composables/usePageSetupControls.d.ts +22 -0
  60. package/dist/composables/usePagesPointer.d.ts +86 -0
  61. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  62. package/dist/composables/usePortalClass.d.ts +8 -0
  63. package/dist/composables/useSelectionHighlight.d.ts +19 -0
  64. package/dist/composables/useSelectionSync.d.ts +37 -0
  65. package/dist/composables/useTableResize.d.ts +7 -0
  66. package/dist/composables/useTableSelection.d.ts +10 -0
  67. package/dist/composables/useToolbarDropdowns.d.ts +15 -0
  68. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  69. package/dist/composables/useTrackedChanges.d.ts +12 -0
  70. package/dist/composables/useVisualLineNavigation.d.ts +11 -0
  71. package/dist/composables/useWatermarkControls.d.ts +15 -0
  72. package/dist/composables/useWheelZoom.d.ts +10 -0
  73. package/dist/composables/useZoom.d.ts +16 -0
  74. package/dist/composables.cjs +1 -0
  75. package/dist/composables.js +401 -0
  76. package/dist/dialogs.cjs +1 -0
  77. package/dist/dialogs.js +3 -0
  78. package/dist/docx-editor-vue.css +2 -0
  79. package/dist/i18n/LocaleContext.d.ts +1 -0
  80. package/dist/i18n/index.d.ts +26 -0
  81. package/dist/index.cjs +19 -0
  82. package/dist/index.d.ts +24 -0
  83. package/dist/index.js +4506 -0
  84. package/dist/lib/utils.d.ts +10 -0
  85. package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
  86. package/dist/plugin-api/index.d.ts +18 -0
  87. package/dist/plugin-api/types.d.ts +28 -0
  88. package/dist/plugin-api.cjs +1 -0
  89. package/dist/plugin-api.js +62 -0
  90. package/dist/renderAsync.d.ts +31 -0
  91. package/dist/styles/index.d.ts +12 -0
  92. package/dist/styles/zIndex.d.ts +24 -0
  93. package/dist/styles.cjs +1 -0
  94. package/dist/styles.js +5 -0
  95. package/dist/ui.cjs +18 -0
  96. package/dist/ui.d.ts +79 -0
  97. package/dist/ui.js +986 -0
  98. package/dist/useCommentSidebarItems-DBeGKNGA.cjs +1 -0
  99. package/dist/useCommentSidebarItems-DXbF857R.js +45 -0
  100. package/dist/useDragAutoScroll-BzP7c_lM.cjs +1 -0
  101. package/dist/useDragAutoScroll-DOXQJ0os.js +520 -0
  102. package/dist/usePortalClass-C91WJPlr.js +3534 -0
  103. package/dist/usePortalClass-Ciqvd8GU.cjs +4 -0
  104. package/dist/utils/domQueries.d.ts +46 -0
  105. package/dist/utils/domQueries.test.d.ts +1 -0
  106. package/dist/utils/imageClipboard.d.ts +9 -0
  107. package/dist/utils/refApiQueries.d.ts +10 -0
  108. package/dist/zIndex-CH0jZ7U7.cjs +1 -0
  109. package/dist/zIndex-CxELVe_L.js +12 -0
  110. package/package.json +119 -0
@@ -0,0 +1 @@
1
+ let e=require(`vue`);function t({comments:t,trackedChanges:n,showResolved:r,isAddingComment:i,addCommentYPosition:a}){return(0,e.computed)(()=>{let e=[];i?.value&&a?.value!=null&&e.push({id:`new-comment-input`,anchorPos:0,fixedY:a.value,priority:-1e3,isTemporary:!0,estimatedHeight:120,kind:`add-comment`});let o=new Map;for(let e of t.value)if(e.parentId!=null){let t=o.get(e.parentId);t?t.push(e):o.set(e.parentId,[e])}for(let n of t.value)n.parentId??(n.done&&!r?.value||e.push({id:`comment-${n.id}`,anchorPos:0,anchorKey:`comment-${n.id}`,priority:0,estimatedHeight:n.done?28:80,kind:`comment`,comment:n,replies:o.get(n.id)??[]}));return n.value.forEach((t,n)=>{e.push({id:`tc-${t.revisionId}-${n}`,anchorPos:t.from,anchorKey:`revision-${t.revisionId}`,priority:1,estimatedHeight:80,kind:`tracked-change`,change:t,replies:o.get(t.revisionId)??[]})}),e})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
@@ -0,0 +1,45 @@
1
+ import { computed as e } from "vue";
2
+ //#region src/composables/useCommentSidebarItems.ts
3
+ function t({ comments: t, trackedChanges: n, showResolved: r, isAddingComment: i, addCommentYPosition: a }) {
4
+ return e(() => {
5
+ let e = [];
6
+ i?.value && a?.value != null && e.push({
7
+ id: "new-comment-input",
8
+ anchorPos: 0,
9
+ fixedY: a.value,
10
+ priority: -1e3,
11
+ isTemporary: !0,
12
+ estimatedHeight: 120,
13
+ kind: "add-comment"
14
+ });
15
+ let o = /* @__PURE__ */ new Map();
16
+ for (let e of t.value) if (e.parentId != null) {
17
+ let t = o.get(e.parentId);
18
+ t ? t.push(e) : o.set(e.parentId, [e]);
19
+ }
20
+ for (let n of t.value) n.parentId ?? (n.done && !r?.value || e.push({
21
+ id: `comment-${n.id}`,
22
+ anchorPos: 0,
23
+ anchorKey: `comment-${n.id}`,
24
+ priority: 0,
25
+ estimatedHeight: n.done ? 28 : 80,
26
+ kind: "comment",
27
+ comment: n,
28
+ replies: o.get(n.id) ?? []
29
+ }));
30
+ return n.value.forEach((t, n) => {
31
+ e.push({
32
+ id: `tc-${t.revisionId}-${n}`,
33
+ anchorPos: t.from,
34
+ anchorKey: `revision-${t.revisionId}`,
35
+ priority: 1,
36
+ estimatedHeight: 80,
37
+ kind: "tracked-change",
38
+ change: t,
39
+ replies: o.get(t.revisionId) ?? []
40
+ });
41
+ }), e;
42
+ });
43
+ }
44
+ //#endregion
45
+ export { t };
@@ -0,0 +1 @@
1
+ let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@xcrong/docx-editor-core/layout-bridge`),r=require(`@xcrong/docx-editor-core/prosemirror`),i=require(`@xcrong/docx-editor-core/layout-engine`),a=require(`@xcrong/docx-editor-core/utils`),o=require(`@xcrong/docx-editor-core/layout-painter`),s=require(`@xcrong/docx-editor-core/prosemirror/conversion`),c=require(`prosemirror-view`),l=require(`@xcrong/docx-editor-core/docx/parser`),u=require(`@xcrong/docx-editor-core/prosemirror/conversion/fromProseDoc`),d=require(`@xcrong/docx-editor-core/prosemirror/schema`),f=require(`@xcrong/docx-editor-core/prosemirror/plugins`),p=require(`@xcrong/docx-editor-core/prosemirror/extensions`),m=require(`@xcrong/docx-editor-core/layout-bridge/measuring`),h=require(`@xcrong/docx-editor-core/editor`),g=require(`@xcrong/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@xcrong/docx-editor-core/prosemirror/editor.css`);let _=require(`@xcrong/docx-editor-core/prosemirror/tableResize`),v=require(`@xcrong/docx-editor-core/utils/findVerticalScrollParent`),y=require(`@xcrong/docx-editor-core/utils/autoScroll`);var b=24;function x(e,t,r,a){switch(e.kind){case`paragraph`:return(0,m.measureParagraph)(e,t,{floatingZones:r,paragraphYOffset:a??0});case`table`:return(0,n.measureTableBlock)(e,t,x);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??i.DEFAULT_TEXTBOX_MARGINS,r=(t.width??i.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,a=t.content.map(e=>(0,m.measureParagraph)(e,r)),o=a.reduce((e,t)=>e+t.totalHeight,0),s=t.height??o+n.top+n.bottom;return{kind:`textBox`,width:t.width??i.DEFAULT_TEXTBOX_WIDTH,height:s,innerMeasures:a}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,i.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function S(e,t,n){return(0,m.measureBlocksWithFloats)(e,t,x,n)}function C(i){let{hiddenContainer:m,pagesContainer:_,readOnly:v=!1,pageGap:y=b,onChange:x,onError:C,onSelectionUpdate:w,externalPlugins:T=[],syncCoordinator:E,editorMode:D,author:O}=i,k=(0,e.shallowRef)(null),A=(0,e.shallowRef)(null),j=(0,e.shallowRef)(null),M=(0,e.ref)(!1),N=(0,e.ref)(null),P=(0,e.ref)([]),F=(0,e.shallowRef)(null),I=d.singletonManager;function L(e){let t=_.value;if(!t||!k.value)return;let r=E?.getStateSeq()??0;E?.onLayoutStart();let i=k.value.package?.document,a=i?.sections?.[0]?.properties??i?.finalSectionProperties??null,s=i?.finalSectionProperties??a,c=(0,n.getPageSize)(a),l=(0,n.getMargins)(a),u=(0,n.getPageSize)(s),d=(0,n.getMargins)(s),f=(0,n.getColumns)(a),p=(0,n.getColumns)(s),m=c.w-l.left-l.right,v=k.value.package?.theme??null,b=k.value.package?.styles??null;try{let{header:r,footer:i,firstHeader:_,firstFooter:x}=(0,n.resolveHeaderFooter)(k.value,a),{blocks:C,measures:w,layout:T,headerContentForRender:E,footerContentForRender:D,firstPageHeaderForRender:O,firstPageFooterForRender:A,hasTitlePg:j,watermark:M,footnotesByPage:N}=(0,h.computeLayout)({state:e,document:k.value,pageSize:c,margins:l,columns:f,finalPageSize:u,finalMargins:d,finalColumns:p,pageGap:y,contentWidth:m,theme:v,styles:b,sectionProperties:a,finalSectionProperties:s,headerContent:r,footerContent:i,firstPageHeaderContent:_,firstPageFooterContent:x,measureBlocks:S,getHfPmDoc:e=>K(e)?.state.doc??null});F.value=T;let P=(0,o.buildBlockLookup)(C,w);(0,g.renderPages)(T.pages,t,{pageGap:y,showShadow:!0,pageBackground:`var(--doc-page-bg, #ffffff)`,blockLookup:P,theme:v,headerContent:E,footerContent:D,firstPageHeaderContent:O,firstPageFooterContent:A,titlePage:j,watermark:M,footnotesByPage:N}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,o.applySdtFocus)(t,(0,o.enclosingSdtGroupIds)(e.doc,e.selection.from,e.selection.to))}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),C?.(e instanceof Error?e:Error(String(e)))}finally{E?.onLayoutComplete(r)}}let R=(0,h.createLayoutScheduler)(L);function z(){let n=m.value;if(!n)return;let i=k.value?.package?.styles,a=k.value?(0,s.toProseDoc)(k.value,{styles:i??void 0}):(0,s.createEmptyDoc)(),l=(0,f.createSuggestionModePlugin)(!1),d=(0,f.createDocumentStylesPlugin)(i),p=(0,f.createDocumentContextPlugin)({theme:k.value?.package?.theme??null,defaultTableStyleId:k.value?.package?.settings?.defaultTableStyle??null}),g=[l,...T,...I.getPlugins()??[],d,p],y=(0,r.ensureParaIdsInState)(t.EditorState.create({doc:a,schema:I.getSchema(),plugins:g}));if(j.value=y,k.value)try{k.value=(0,u.fromProseDoc)(y.doc,k.value)}catch(e){console.error(`[useDocxEditor] paraId cache sync error:`,e)}let b=new c.EditorView(n,{state:y,editable:()=>!(0,e.unref)(v),dispatchTransaction(e){if(!b)return;(0,h.stripScrollFlag)(e,b.state.tr);let t=b.state.apply(e);if(b.updateState(t),j.value=t,e.docChanged){E?.incrementStateSeq(),R.schedule(t);try{if(k.value){let e=(0,u.fromProseDoc)(t.doc,k.value);k.value=e,x?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(E?.requestRender(),w?.(),!e.docChanged){let e=_.value;e&&(0,o.applySdtFocus)(e,(0,o.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});A.value=b,M.value=!0,L(y),E?.requestRender(),(0,e.unref)(v)||requestAnimationFrame(()=>{b.focus()})}function B(){R.cancel(),A.value&&=(A.value.destroy(),null),j.value=null,M.value=!1}let V={current:null},H=new Map,U=new Map;function W(){if(V.current&&V.current.isConnected)return V.current;let e=window.document.createElement(`div`);return e.dataset.hfHost=`true`,e.style.cssText=`position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;`,window.document.body.appendChild(e),V.current=e,e}function G(e){let t=k.value?.package;if(!t)return null;if(t.headers){for(let[n,r]of t.headers)if(r===e)return n}if(t.footers){for(let[n,r]of t.footers)if(r===e)return n}return null}function K(e){let t=G(e);return t?H.get(t)??null:null}function q(){let n=k.value?.package,i=W(),a=new Set;if(n?.headers)for(let e of n.headers.keys())a.add(e);if(n?.footers)for(let e of n.footers.keys())a.add(e);for(let[e,t]of H)a.has(e)||(t.destroy(),t.dom.parentElement?.remove(),U.get(e)?.destroy(),U.delete(e),H.delete(e));if(!n)return;let o=n.styles??null,l=n.theme??null,u=n.settings?.defaultTabStop??null,d=n.settings?.defaultTableStyle??null;for(let m of a){if(H.has(m))continue;let a=n.headers?.get(m)??n.footers?.get(m);if(!a)continue;let h=n.headers?.has(m)?`header`:`footer`,g=new p.ExtensionManager((0,p.createStarterKit)());g.buildSchema(),g.initializeRuntime(),U.set(m,g);let _=window.document.createElement(`div`);_.dataset.hfRId=m,_.dataset.hfKind=h,i.appendChild(_);let v=(0,s.headerFooterToProseDoc)(a.content,{styles:o??void 0,theme:l,defaultTabStopTwips:u}),y=(0,f.createDocumentStylesPlugin)(o),b=(0,f.createDocumentContextPlugin)({theme:l,defaultTableStyleId:d}),x=(0,f.createSuggestionModePlugin)((0,e.unref)(D)===`suggesting`,(0,e.unref)(O)),S=t.EditorState.create({doc:v,schema:r.schema,plugins:[x,...g.getPlugins(),y,b]}),C=h,w=new c.EditorView(_,{state:S,dispatchTransaction(e){let t=w.state.apply(e);if(w.updateState(t),e.docChanged){let e=k.value?.package,n=(C===`header`?e?.headers:e?.footers)?.get(m);n&&(n.content=(0,s.proseDocToBlocks)(t.doc),n.verbatimXml=void 0)}e.docChanged&&j.value&&L(j.value),Y.value?.(m,w,e.docChanged)}});H.set(m,w)}}function J(){for(let e of H.values())e.destroy(),e.dom.parentElement?.remove();H.clear();for(let e of U.values())e.destroy();U.clear(),V.current&&=(V.current.remove(),null)}(0,e.watch)([()=>(0,e.unref)(D),()=>(0,e.unref)(O),A],([e,t,n])=>{let r=e===`suggesting`;n&&(0,f.setSuggestionMode)(r,n.state,n.dispatch,t);for(let e of H.values())(0,f.setSuggestionMode)(r,e.state,e.dispatch,t)},{immediate:!0});let Y={value:null};function X(e){Y.value=e}async function Z(e){N.value=null,M.value=!1;try{let t;t=e instanceof Blob||e instanceof File?await e.arrayBuffer():e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e;let n=await(0,l.parseDocx)(t);k.value=n,Q(n),B(),J(),z(),q()}catch(e){let t=e instanceof Error?e:Error(String(e));N.value=t.message,C?.(t)}}function ee(e){N.value=null,k.value=e,Q(e),B(),J(),z(),q()}function Q(e){P.value=(0,a.getRenderableDocumentFonts)(e,{embeddedFamilies:(0,a.getEmbeddedFontFamilies)(e.package?.fontTable)})}async function te(){if(!A.value||!k.value)return null;let{repackDocx:e,createDocx:t}=await import(`@xcrong/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@xcrong/docx-editor-core/docx`),i=(0,u.fromProseDoc)(A.value.state.doc,k.value),a=i.package.document?.comments??[];i.package.document?.content&&a.length>0&&(n(i.package.document.content,a),r(i.package.document.content,a));let o;return o=i.originalBuffer?await e(i):await t(i),new Blob([o],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function ne(){A.value?.focus()}function $(){B(),J(),k.value=null}function re(){return k.value}(0,e.onBeforeUnmount)(()=>{$()});function ie(){return I.getCommands()}return{editorView:A,editorState:j,isReady:M,parseError:N,documentFonts:P,layout:F,loadBuffer:Z,loadDocument:ee,save:te,focus:ne,destroy:$,getDocument:re,getCommands:ie,reLayout(){A.value&&L(A.value.state)},getHfPmView:K,getHfPmViews(){return H},syncHfPMs:q,setHfTransactionListener:X,setDocument(e){k.value=e}}}var w=.5,T=2,E=.1,D=[.5,.75,1,1.25,1.5,2];function O(t=1){let n=(0,e.ref)(Math.max(w,Math.min(T,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=w),a=(0,e.computed)(()=>n.value>=T);function o(e){n.value=Math.max(w,Math.min(T,Math.round(e*100)/100))}function s(){o(n.value+E)}function c(){o(n.value-E)}function l(){o(1)}function u(e){(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?s():c())}function d(e){(e.ctrlKey||e.metaKey)&&(e.shiftKey||e.altKey||(e.key===`=`||e.key===`+`?(e.preventDefault(),s()):e.key===`-`?(e.preventDefault(),c()):e.key===`0`&&(e.preventDefault(),l())))}function f(){(0,e.onMounted)(()=>document.addEventListener(`keydown`,d)),(0,e.onBeforeUnmount)(()=>document.removeEventListener(`keydown`,d))}return{zoom:n,zoomPercent:r,isMinZoom:i,isMaxZoom:a,setZoom:o,zoomIn:s,zoomOut:c,resetZoom:l,handleWheel:u,handleKeyDown:d,installShortcuts:f,ZOOM_PRESETS:D}}function k(){let e={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidths:{left:0,right:0}},t={active:!1,startY:0,handle:null,rowIndex:0,isEdge:!1,tablePmStart:0,origHeight:0},n={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidth:0},r=null;function i(){return e.active||t.active||n.active}function a(i,a){let o=i.target;return o?.classList?o.classList.contains(`layout-table-resize-handle`)?(i.preventDefault(),i.stopPropagation(),r=a,e.active=!0,e.startX=i.clientX,e.handle=o,o.classList.add(`dragging`),e.columnIndex=parseInt(o.dataset.columnIndex??`0`,10),e.tablePmStart=parseInt(o.dataset.tablePmStart??`0`,10),A(a,e),!0):o.classList.contains(`layout-table-row-resize-handle`)||o.classList.contains(`layout-table-edge-handle-bottom`)?(i.preventDefault(),i.stopPropagation(),r=a,t.active=!0,t.startY=i.clientY,t.handle=o,t.isEdge=o.dataset.isEdge===`bottom`,o.classList.add(`dragging`),t.rowIndex=parseInt(o.dataset.rowIndex??`0`,10),t.tablePmStart=parseInt(o.dataset.tablePmStart??`0`,10),j(a,t,o),!0):o.classList.contains(`layout-table-edge-handle-right`)?(i.preventDefault(),i.stopPropagation(),r=a,n.active=!0,n.startX=i.clientX,n.handle=o,o.classList.add(`dragging`),n.columnIndex=parseInt(o.dataset.columnIndex??`0`,10),n.tablePmStart=parseInt(o.dataset.tablePmStart??`0`,10),M(a,n),!0):!1:!1}function o(r){if(e.active&&e.handle){r.preventDefault();let t=r.clientX-e.startX,n=parseFloat(e.handle.style.left);e.handle.style.left=`${n+t}px`,e.startX=r.clientX;let i=Math.round(t*_.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=_.MIN_CELL_WIDTH_TWIPS&&o>=_.MIN_CELL_WIDTH_TWIPS&&(e.origWidths={left:a,right:o});return}if(t.active&&t.handle){r.preventDefault();let e=r.clientY-t.startY,n=parseFloat(t.handle.style.top);t.handle.style.top=`${n+e}px`,t.startY=r.clientY;let i=Math.round(e*_.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=_.MIN_ROW_HEIGHT_TWIPS&&(t.origHeight=a);return}if(n.active&&n.handle){r.preventDefault();let e=r.clientX-n.startX,t=parseFloat(n.handle.style.left);n.handle.style.left=`${t+e}px`,n.startX=r.clientX;let i=Math.round(e*_.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=_.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,_.commitColumnResize)(r,{pmStart:e.tablePmStart,colIdx:e.columnIndex,newLeft:e.origWidths.left,newRight:e.origWidths.right}),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&(0,_.commitRowResize)(r,{pmStart:t.tablePmStart,rowIdx:t.rowIndex,newHeight:t.origHeight}),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&(0,_.commitRightEdgeResize)(r,{pmStart:n.tablePmStart,colIdx:n.columnIndex,newWidth:n.origWidth}),n.handle=null)}function c(){return document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s)}}return{tryStartResize:a,install:c,isResizing:i}}function A(e,t){let n=(0,_.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function j(e,t,n){let r=(0,_.readRowHeight)(e,t.tablePmStart,t.rowIndex);if(r!=null){t.origHeight=r;return}let i=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),a=i?i.getBoundingClientRect().height:30;t.origHeight=Math.round(a*_.TWIPS_PER_PIXEL)}function M(e,t){let n=(0,_.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function N({pagesContainer:t,onScrollExtendSelection:n}){let r=null,i=0,a=0,o=!1,s=null;function c(){if(s)return s;let e=t.value;return e?(s=(0,v.findVerticalScrollParent)(e),s):null}function l(){o=!1,r!==null&&(cancelAnimationFrame(r),r=null)}function u(){if(!o)return;let e=c();if(!e)return;let t=(0,y.computeAutoScrollDelta)(e.getBoundingClientRect(),a);t!==0&&(e.scrollTop+=t,n(i,a)),r=requestAnimationFrame(u)}function d(){o||(o=!0,r=requestAnimationFrame(u))}function f(e,t){if(i=e,a=t,!o){let e=c();if(!e)return;let n=e.getBoundingClientRect();(t<n.top+y.AUTO_SCROLL_EDGE_ZONE||t>n.bottom-y.AUTO_SCROLL_EDGE_ZONE)&&d()}}return(0,e.onBeforeUnmount)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return N}});
@@ -0,0 +1,520 @@
1
+ import { computed as e, onBeforeUnmount as t, onMounted as n, ref as r, shallowRef as i, unref as a, watch as o } from "vue";
2
+ import { EditorState as s } from "prosemirror-state";
3
+ import { getColumns as c, getMargins as l, getPageSize as u, measureTableBlock as d, resolveHeaderFooter as f } from "@xcrong/docx-editor-core/layout-bridge";
4
+ import { ensureParaIdsInState as p, schema as m } from "@xcrong/docx-editor-core/prosemirror";
5
+ import { DEFAULT_TEXTBOX_MARGINS as h, DEFAULT_TEXTBOX_WIDTH as g, assertExhaustiveFlowBlock as _ } from "@xcrong/docx-editor-core/layout-engine";
6
+ import { getEmbeddedFontFamilies as v, getRenderableDocumentFonts as y } from "@xcrong/docx-editor-core/utils";
7
+ import { applySdtFocus as b, buildBlockLookup as ee, enclosingSdtGroupIds as te } from "@xcrong/docx-editor-core/layout-painter";
8
+ import { createEmptyDoc as x, headerFooterToProseDoc as S, proseDocToBlocks as C, toProseDoc as ne } from "@xcrong/docx-editor-core/prosemirror/conversion";
9
+ import { EditorView as w } from "prosemirror-view";
10
+ import { parseDocx as re } from "@xcrong/docx-editor-core/docx/parser";
11
+ import { fromProseDoc as T } from "@xcrong/docx-editor-core/prosemirror/conversion/fromProseDoc";
12
+ import { singletonManager as ie } from "@xcrong/docx-editor-core/prosemirror/schema";
13
+ import { createDocumentContextPlugin as E, createDocumentStylesPlugin as D, createSuggestionModePlugin as O, setSuggestionMode as ae } from "@xcrong/docx-editor-core/prosemirror/plugins";
14
+ import { ExtensionManager as oe, createStarterKit as se } from "@xcrong/docx-editor-core/prosemirror/extensions";
15
+ import { measureBlocksWithFloats as k, measureParagraph as A } from "@xcrong/docx-editor-core/layout-bridge/measuring";
16
+ import { computeLayout as ce, createLayoutScheduler as le, stripScrollFlag as ue } from "@xcrong/docx-editor-core/editor";
17
+ import { renderPages as de } from "@xcrong/docx-editor-core/layout-painter/renderPage";
18
+ import "prosemirror-view/style/prosemirror.css";
19
+ import "@xcrong/docx-editor-core/prosemirror/editor.css";
20
+ import { MIN_CELL_WIDTH_TWIPS as j, MIN_ROW_HEIGHT_TWIPS as M, TWIPS_PER_PIXEL as N, commitColumnResize as P, commitRightEdgeResize as F, commitRowResize as I, readColumnWidthAt as L, readColumnWidths as R, readRowHeight as z } from "@xcrong/docx-editor-core/prosemirror/tableResize";
21
+ import { findVerticalScrollParent as B } from "@xcrong/docx-editor-core/utils/findVerticalScrollParent";
22
+ import { AUTO_SCROLL_EDGE_ZONE as V, computeAutoScrollDelta as H } from "@xcrong/docx-editor-core/utils/autoScroll";
23
+ //#region src/composables/useDocxEditor.ts
24
+ var fe = 24;
25
+ function U(e, t, n, r) {
26
+ switch (e.kind) {
27
+ case "paragraph": return A(e, t, {
28
+ floatingZones: n,
29
+ paragraphYOffset: r ?? 0
30
+ });
31
+ case "table": return d(e, t, U);
32
+ case "image": {
33
+ let t = e;
34
+ return {
35
+ kind: "image",
36
+ width: t.width ?? 100,
37
+ height: t.height ?? 100
38
+ };
39
+ }
40
+ case "textBox": {
41
+ let t = e, n = t.margins ?? h, r = (t.width ?? g) - n.left - n.right, i = t.content.map((e) => A(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
42
+ return {
43
+ kind: "textBox",
44
+ width: t.width ?? g,
45
+ height: o,
46
+ innerMeasures: i
47
+ };
48
+ }
49
+ case "pageBreak": return { kind: "pageBreak" };
50
+ case "columnBreak": return { kind: "columnBreak" };
51
+ case "sectionBreak": return { kind: "sectionBreak" };
52
+ default: _(e, "vue useDocxEditor measureBlock");
53
+ }
54
+ }
55
+ function pe(e, t, n) {
56
+ return k(e, t, U, n);
57
+ }
58
+ function W(e) {
59
+ let { hiddenContainer: n, pagesContainer: d, readOnly: h = !1, pageGap: g = fe, onChange: _, onError: k, onSelectionUpdate: A, externalPlugins: j = [], syncCoordinator: M, editorMode: N, author: P } = e, F = i(null), I = i(null), L = i(null), R = r(!1), z = r(null), B = r([]), V = i(null), H = ie;
60
+ function U(e) {
61
+ let t = d.value;
62
+ if (!t || !F.value) return;
63
+ let n = M?.getStateSeq() ?? 0;
64
+ M?.onLayoutStart();
65
+ let r = F.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = u(i), s = l(i), p = u(a), m = l(a), h = c(i), _ = c(a), v = o.w - s.left - s.right, y = F.value.package?.theme ?? null, x = F.value.package?.styles ?? null;
66
+ try {
67
+ let { header: n, footer: r, firstHeader: c, firstFooter: l } = f(F.value, i), { blocks: u, measures: d, layout: S, headerContentForRender: C, footerContentForRender: ne, firstPageHeaderForRender: w, firstPageFooterForRender: re, hasTitlePg: T, watermark: ie, footnotesByPage: E } = ce({
68
+ state: e,
69
+ document: F.value,
70
+ pageSize: o,
71
+ margins: s,
72
+ columns: h,
73
+ finalPageSize: p,
74
+ finalMargins: m,
75
+ finalColumns: _,
76
+ pageGap: g,
77
+ contentWidth: v,
78
+ theme: y,
79
+ styles: x,
80
+ sectionProperties: i,
81
+ finalSectionProperties: a,
82
+ headerContent: n,
83
+ footerContent: r,
84
+ firstPageHeaderContent: c,
85
+ firstPageFooterContent: l,
86
+ measureBlocks: pe,
87
+ getHfPmDoc: (e) => X(e)?.state.doc ?? null
88
+ });
89
+ V.value = S;
90
+ let D = ee(u, d);
91
+ de(S.pages, t, {
92
+ pageGap: g,
93
+ showShadow: !0,
94
+ pageBackground: "var(--doc-page-bg, #ffffff)",
95
+ blockLookup: D,
96
+ theme: y,
97
+ headerContent: C,
98
+ footerContent: ne,
99
+ firstPageHeaderContent: w,
100
+ firstPageFooterContent: re,
101
+ titlePage: T,
102
+ watermark: ie,
103
+ footnotesByPage: E
104
+ }), t.style.overflowY = "auto", t.style.minHeight = "0";
105
+ for (let e of Array.from(t.children)) e.style.flexShrink = "0";
106
+ b(t, te(e.doc, e.selection.from, e.selection.to));
107
+ } catch (e) {
108
+ console.error("[useDocxEditor] Layout pipeline error:", e), k?.(e instanceof Error ? e : Error(String(e)));
109
+ } finally {
110
+ M?.onLayoutComplete(n);
111
+ }
112
+ }
113
+ let W = le(U);
114
+ function G() {
115
+ let e = n.value;
116
+ if (!e) return;
117
+ let t = F.value?.package?.styles, r = F.value ? ne(F.value, { styles: t ?? void 0 }) : x(), i = O(!1), o = D(t), c = E({
118
+ theme: F.value?.package?.theme ?? null,
119
+ defaultTableStyleId: F.value?.package?.settings?.defaultTableStyle ?? null
120
+ }), l = [
121
+ i,
122
+ ...j,
123
+ ...H.getPlugins() ?? [],
124
+ o,
125
+ c
126
+ ], u = p(s.create({
127
+ doc: r,
128
+ schema: H.getSchema(),
129
+ plugins: l
130
+ }));
131
+ if (L.value = u, F.value) try {
132
+ F.value = T(u.doc, F.value);
133
+ } catch (e) {
134
+ console.error("[useDocxEditor] paraId cache sync error:", e);
135
+ }
136
+ let f = new w(e, {
137
+ state: u,
138
+ editable: () => !a(h),
139
+ dispatchTransaction(e) {
140
+ if (!f) return;
141
+ ue(e, f.state.tr);
142
+ let t = f.state.apply(e);
143
+ if (f.updateState(t), L.value = t, e.docChanged) {
144
+ M?.incrementStateSeq(), W.schedule(t);
145
+ try {
146
+ if (F.value) {
147
+ let e = T(t.doc, F.value);
148
+ F.value = e, _?.(e);
149
+ }
150
+ } catch (e) {
151
+ console.error("[useDocxEditor] fromProseDoc error:", e);
152
+ }
153
+ }
154
+ if (M?.requestRender(), A?.(), !e.docChanged) {
155
+ let e = d.value;
156
+ e && b(e, te(t.doc, t.selection.from, t.selection.to));
157
+ }
158
+ }
159
+ });
160
+ I.value = f, R.value = !0, U(u), M?.requestRender(), a(h) || requestAnimationFrame(() => {
161
+ f.focus();
162
+ });
163
+ }
164
+ function K() {
165
+ W.cancel(), I.value &&= (I.value.destroy(), null), L.value = null, R.value = !1;
166
+ }
167
+ let q = { current: null }, J = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
168
+ function me() {
169
+ if (q.current && q.current.isConnected) return q.current;
170
+ let e = window.document.createElement("div");
171
+ return e.dataset.hfHost = "true", e.style.cssText = "position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;", window.document.body.appendChild(e), q.current = e, e;
172
+ }
173
+ function he(e) {
174
+ let t = F.value?.package;
175
+ if (!t) return null;
176
+ if (t.headers) {
177
+ for (let [n, r] of t.headers) if (r === e) return n;
178
+ }
179
+ if (t.footers) {
180
+ for (let [n, r] of t.footers) if (r === e) return n;
181
+ }
182
+ return null;
183
+ }
184
+ function X(e) {
185
+ let t = he(e);
186
+ return t ? J.get(t) ?? null : null;
187
+ }
188
+ function Z() {
189
+ let e = F.value?.package, t = me(), n = /* @__PURE__ */ new Set();
190
+ if (e?.headers) for (let t of e.headers.keys()) n.add(t);
191
+ if (e?.footers) for (let t of e.footers.keys()) n.add(t);
192
+ for (let [e, t] of J) n.has(e) || (t.destroy(), t.dom.parentElement?.remove(), Y.get(e)?.destroy(), Y.delete(e), J.delete(e));
193
+ if (!e) return;
194
+ let r = e.styles ?? null, i = e.theme ?? null, o = e.settings?.defaultTabStop ?? null, c = e.settings?.defaultTableStyle ?? null;
195
+ for (let l of n) {
196
+ if (J.has(l)) continue;
197
+ let n = e.headers?.get(l) ?? e.footers?.get(l);
198
+ if (!n) continue;
199
+ let u = e.headers?.has(l) ? "header" : "footer", d = new oe(se());
200
+ d.buildSchema(), d.initializeRuntime(), Y.set(l, d);
201
+ let f = window.document.createElement("div");
202
+ f.dataset.hfRId = l, f.dataset.hfKind = u, t.appendChild(f);
203
+ let p = S(n.content, {
204
+ styles: r ?? void 0,
205
+ theme: i,
206
+ defaultTabStopTwips: o
207
+ }), h = D(r), g = E({
208
+ theme: i,
209
+ defaultTableStyleId: c
210
+ }), _ = O(a(N) === "suggesting", a(P)), v = s.create({
211
+ doc: p,
212
+ schema: m,
213
+ plugins: [
214
+ _,
215
+ ...d.getPlugins(),
216
+ h,
217
+ g
218
+ ]
219
+ }), y = u, b = new w(f, {
220
+ state: v,
221
+ dispatchTransaction(e) {
222
+ let t = b.state.apply(e);
223
+ if (b.updateState(t), e.docChanged) {
224
+ let e = F.value?.package, n = (y === "header" ? e?.headers : e?.footers)?.get(l);
225
+ n && (n.content = C(t.doc), n.verbatimXml = void 0);
226
+ }
227
+ e.docChanged && L.value && U(L.value), ge.value?.(l, b, e.docChanged);
228
+ }
229
+ });
230
+ J.set(l, b);
231
+ }
232
+ }
233
+ function Q() {
234
+ for (let e of J.values()) e.destroy(), e.dom.parentElement?.remove();
235
+ J.clear();
236
+ for (let e of Y.values()) e.destroy();
237
+ Y.clear(), q.current &&= (q.current.remove(), null);
238
+ }
239
+ o([
240
+ () => a(N),
241
+ () => a(P),
242
+ I
243
+ ], ([e, t, n]) => {
244
+ let r = e === "suggesting";
245
+ n && ae(r, n.state, n.dispatch, t);
246
+ for (let e of J.values()) ae(r, e.state, e.dispatch, t);
247
+ }, { immediate: !0 });
248
+ let ge = { value: null };
249
+ function _e(e) {
250
+ ge.value = e;
251
+ }
252
+ async function ve(e) {
253
+ z.value = null, R.value = !1;
254
+ try {
255
+ let t;
256
+ t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e;
257
+ let n = await re(t);
258
+ F.value = n, $(n), K(), Q(), G(), Z();
259
+ } catch (e) {
260
+ let t = e instanceof Error ? e : Error(String(e));
261
+ z.value = t.message, k?.(t);
262
+ }
263
+ }
264
+ function ye(e) {
265
+ z.value = null, F.value = e, $(e), K(), Q(), G(), Z();
266
+ }
267
+ function $(e) {
268
+ B.value = y(e, { embeddedFamilies: v(e.package?.fontTable) });
269
+ }
270
+ async function be() {
271
+ if (!I.value || !F.value) return null;
272
+ let { repackDocx: e, createDocx: t } = await import("@xcrong/docx-editor-core/docx/rezip"), { injectReplyRangeMarkers: n, injectTCReplyRangeMarkers: r } = await import("@xcrong/docx-editor-core/docx"), i = T(I.value.state.doc, F.value), a = i.package.document?.comments ?? [];
273
+ i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
274
+ let o;
275
+ return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
276
+ }
277
+ function xe() {
278
+ I.value?.focus();
279
+ }
280
+ function Se() {
281
+ K(), Q(), F.value = null;
282
+ }
283
+ function Ce() {
284
+ return F.value;
285
+ }
286
+ t(() => {
287
+ Se();
288
+ });
289
+ function we() {
290
+ return H.getCommands();
291
+ }
292
+ return {
293
+ editorView: I,
294
+ editorState: L,
295
+ isReady: R,
296
+ parseError: z,
297
+ documentFonts: B,
298
+ layout: V,
299
+ loadBuffer: ve,
300
+ loadDocument: ye,
301
+ save: be,
302
+ focus: xe,
303
+ destroy: Se,
304
+ getDocument: Ce,
305
+ getCommands: we,
306
+ reLayout() {
307
+ I.value && U(I.value.state);
308
+ },
309
+ getHfPmView: X,
310
+ getHfPmViews() {
311
+ return J;
312
+ },
313
+ syncHfPMs: Z,
314
+ setHfTransactionListener: _e,
315
+ setDocument(e) {
316
+ F.value = e;
317
+ }
318
+ };
319
+ }
320
+ //#endregion
321
+ //#region src/composables/useZoom.ts
322
+ var G = .5, K = 2, q = .1, J = [
323
+ .5,
324
+ .75,
325
+ 1,
326
+ 1.25,
327
+ 1.5,
328
+ 2
329
+ ];
330
+ function Y(i = 1) {
331
+ let a = r(Math.max(G, Math.min(K, i))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= G), c = e(() => a.value >= K);
332
+ function l(e) {
333
+ a.value = Math.max(G, Math.min(K, Math.round(e * 100) / 100));
334
+ }
335
+ function u() {
336
+ l(a.value + q);
337
+ }
338
+ function d() {
339
+ l(a.value - q);
340
+ }
341
+ function f() {
342
+ l(1);
343
+ }
344
+ function p(e) {
345
+ (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
346
+ }
347
+ function m(e) {
348
+ (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f())));
349
+ }
350
+ function h() {
351
+ n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
352
+ }
353
+ return {
354
+ zoom: a,
355
+ zoomPercent: o,
356
+ isMinZoom: s,
357
+ isMaxZoom: c,
358
+ setZoom: l,
359
+ zoomIn: u,
360
+ zoomOut: d,
361
+ resetZoom: f,
362
+ handleWheel: p,
363
+ handleKeyDown: m,
364
+ installShortcuts: h,
365
+ ZOOM_PRESETS: J
366
+ };
367
+ }
368
+ //#endregion
369
+ //#region src/composables/useTableResize.ts
370
+ function me() {
371
+ let e = {
372
+ active: !1,
373
+ startX: 0,
374
+ handle: null,
375
+ columnIndex: 0,
376
+ tablePmStart: 0,
377
+ origWidths: {
378
+ left: 0,
379
+ right: 0
380
+ }
381
+ }, t = {
382
+ active: !1,
383
+ startY: 0,
384
+ handle: null,
385
+ rowIndex: 0,
386
+ isEdge: !1,
387
+ tablePmStart: 0,
388
+ origHeight: 0
389
+ }, n = {
390
+ active: !1,
391
+ startX: 0,
392
+ handle: null,
393
+ columnIndex: 0,
394
+ tablePmStart: 0,
395
+ origWidth: 0
396
+ }, r = null;
397
+ function i() {
398
+ return e.active || t.active || n.active;
399
+ }
400
+ function a(i, a) {
401
+ let o = i.target;
402
+ return o?.classList ? o.classList.contains("layout-table-resize-handle") ? (i.preventDefault(), i.stopPropagation(), r = a, e.active = !0, e.startX = i.clientX, e.handle = o, o.classList.add("dragging"), e.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), e.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), he(a, e), !0) : o.classList.contains("layout-table-row-resize-handle") || o.classList.contains("layout-table-edge-handle-bottom") ? (i.preventDefault(), i.stopPropagation(), r = a, t.active = !0, t.startY = i.clientY, t.handle = o, t.isEdge = o.dataset.isEdge === "bottom", o.classList.add("dragging"), t.rowIndex = parseInt(o.dataset.rowIndex ?? "0", 10), t.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), X(a, t, o), !0) : o.classList.contains("layout-table-edge-handle-right") ? (i.preventDefault(), i.stopPropagation(), r = a, n.active = !0, n.startX = i.clientX, n.handle = o, o.classList.add("dragging"), n.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), n.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), Z(a, n), !0) : !1 : !1;
403
+ }
404
+ function o(r) {
405
+ if (e.active && e.handle) {
406
+ r.preventDefault();
407
+ let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
408
+ e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
409
+ let i = Math.round(t * N), a = e.origWidths.left + i, o = e.origWidths.right - i;
410
+ a >= j && o >= j && (e.origWidths = {
411
+ left: a,
412
+ right: o
413
+ });
414
+ return;
415
+ }
416
+ if (t.active && t.handle) {
417
+ r.preventDefault();
418
+ let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
419
+ t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
420
+ let i = Math.round(e * N), a = t.origHeight + i;
421
+ a >= M && (t.origHeight = a);
422
+ return;
423
+ }
424
+ if (n.active && n.handle) {
425
+ r.preventDefault();
426
+ let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
427
+ n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
428
+ let i = Math.round(e * N), a = n.origWidth + i;
429
+ a >= j && (n.origWidth = a);
430
+ }
431
+ }
432
+ function s(i) {
433
+ if (e.active) {
434
+ e.active = !1, e.handle?.classList.remove("dragging"), r && P(r, {
435
+ pmStart: e.tablePmStart,
436
+ colIdx: e.columnIndex,
437
+ newLeft: e.origWidths.left,
438
+ newRight: e.origWidths.right
439
+ }), e.handle = null;
440
+ return;
441
+ }
442
+ if (t.active) {
443
+ t.active = !1, t.handle?.classList.remove("dragging"), r && I(r, {
444
+ pmStart: t.tablePmStart,
445
+ rowIdx: t.rowIndex,
446
+ newHeight: t.origHeight
447
+ }), t.handle = null;
448
+ return;
449
+ }
450
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && F(r, {
451
+ pmStart: n.tablePmStart,
452
+ colIdx: n.columnIndex,
453
+ newWidth: n.origWidth
454
+ }), n.handle = null);
455
+ }
456
+ function c() {
457
+ return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
458
+ document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
459
+ };
460
+ }
461
+ return {
462
+ tryStartResize: a,
463
+ install: c,
464
+ isResizing: i
465
+ };
466
+ }
467
+ function he(e, t) {
468
+ let n = R(e, t.tablePmStart, t.columnIndex);
469
+ n && (t.origWidths = n);
470
+ }
471
+ function X(e, t, n) {
472
+ let r = z(e, t.tablePmStart, t.rowIndex);
473
+ if (r != null) {
474
+ t.origHeight = r;
475
+ return;
476
+ }
477
+ let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
478
+ t.origHeight = Math.round(a * N);
479
+ }
480
+ function Z(e, t) {
481
+ let n = L(e, t.tablePmStart, t.columnIndex);
482
+ n != null && (t.origWidth = n);
483
+ }
484
+ //#endregion
485
+ //#region src/composables/useDragAutoScroll.ts
486
+ function Q({ pagesContainer: e, onScrollExtendSelection: n }) {
487
+ let r = null, i = 0, a = 0, o = !1, s = null;
488
+ function c() {
489
+ if (s) return s;
490
+ let t = e.value;
491
+ return t ? (s = B(t), s) : null;
492
+ }
493
+ function l() {
494
+ o = !1, r !== null && (cancelAnimationFrame(r), r = null);
495
+ }
496
+ function u() {
497
+ if (!o) return;
498
+ let e = c();
499
+ if (!e) return;
500
+ let t = H(e.getBoundingClientRect(), a);
501
+ t !== 0 && (e.scrollTop += t, n(i, a)), r = requestAnimationFrame(u);
502
+ }
503
+ function d() {
504
+ o || (o = !0, r = requestAnimationFrame(u));
505
+ }
506
+ function f(e, t) {
507
+ if (i = e, a = t, !o) {
508
+ let e = c();
509
+ if (!e) return;
510
+ let n = e.getBoundingClientRect();
511
+ (t < n.top + V || t > n.bottom - V) && d();
512
+ }
513
+ }
514
+ return t(() => l()), {
515
+ updateMousePosition: f,
516
+ stopAutoScroll: l
517
+ };
518
+ }
519
+ //#endregion
520
+ export { W as i, me as n, Y as r, Q as t };