@eigenpal/docx-editor-vue 1.5.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 (34) hide show
  1. package/dist/KeyboardShortcutsDialog-Dohz9D39.cjs +1 -0
  2. package/dist/{KeyboardShortcutsDialog-DtuQzPxi.js → KeyboardShortcutsDialog-OPAV0oVm.js} +9 -6
  3. package/dist/{MenuBar-DfQrRpyI.js → MenuBar-BLKoZqG3.js} +644 -540
  4. package/dist/MenuBar-BP-XM0MI.cjs +4 -0
  5. package/dist/{TablePropertiesDialog-BVlqA7s3.cjs → TablePropertiesDialog-B-FVOqkH.cjs} +1 -1
  6. package/dist/{TablePropertiesDialog-D4xs_Xif.js → TablePropertiesDialog-B3oZIIjw.js} +9 -9
  7. package/dist/components/DocxEditor/types.d.ts +8 -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/useColorMode.d.ts +8 -0
  12. package/dist/composables/useDocxEditorRefApi.d.ts +4 -0
  13. package/dist/composables/useFormattingActions.d.ts +5 -2
  14. package/dist/composables/useMenuActions.d.ts +2 -0
  15. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  16. package/dist/composables/useToolbarDropdowns.d.ts +1 -0
  17. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  18. package/dist/composables.cjs +1 -1
  19. package/dist/composables.js +4 -3
  20. package/dist/dialogs.cjs +1 -1
  21. package/dist/dialogs.js +2 -2
  22. package/dist/docx-editor-vue.css +1 -1
  23. package/dist/index.cjs +3 -3
  24. package/dist/index.js +952 -906
  25. package/dist/plugin-api.cjs +1 -1
  26. package/dist/plugin-api.js +1 -1
  27. package/dist/ui.cjs +2 -2
  28. package/dist/ui.js +220 -197
  29. package/dist/{useDragAutoScroll-BNPB-6SM.js → useDragAutoScroll-B21Ec-Zy.js} +6 -7
  30. package/dist/useDragAutoScroll-BPnc7LEO.cjs +1 -0
  31. package/package.json +4 -4
  32. package/dist/KeyboardShortcutsDialog-DyfvEiK5.cjs +0 -1
  33. package/dist/MenuBar-p9bqtbLg.cjs +0 -4
  34. package/dist/useDragAutoScroll-DCUotwOX.cjs +0 -1
@@ -1 +0,0 @@
1
- let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@eigenpal/docx-editor-core/layout-bridge`),r=require(`@eigenpal/docx-editor-core/prosemirror`),i=require(`@eigenpal/docx-editor-core/layout-painter`),a=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),o=require(`prosemirror-view`),s=require(`@eigenpal/docx-editor-core/docx/parser`),c=require(`@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc`),l=require(`@eigenpal/docx-editor-core/prosemirror/schema`),u=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),d=require(`@eigenpal/docx-editor-core/prosemirror/extensions`),f=require(`@eigenpal/docx-editor-core/layout-bridge/measuring`),p=require(`@eigenpal/docx-editor-core/editor`),m=require(`@eigenpal/docx-editor-core/layout-engine`),h=require(`@eigenpal/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@eigenpal/docx-editor-core/prosemirror/editor.css`);let g=require(`@eigenpal/docx-editor-core/prosemirror/tableResize`),_=require(`@eigenpal/docx-editor-core/utils/findVerticalScrollParent`),v=require(`@eigenpal/docx-editor-core/utils/autoScroll`);var y=24;function b(e,t,r,i){switch(e.kind){case`paragraph`:return(0,f.measureParagraph)(e,t,{floatingZones:r,paragraphYOffset:i??0});case`table`:return(0,n.measureTableBlock)(e,t,b);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??m.DEFAULT_TEXTBOX_MARGINS,r=(t.width??m.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,i=t.content.map(e=>(0,f.measureParagraph)(e,r)),a=i.reduce((e,t)=>e+t.totalHeight,0),o=t.height??a+n.top+n.bottom;return{kind:`textBox`,width:t.width??m.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,m.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function x(e,t,n){return(0,f.measureBlocksWithFloats)(e,t,b,n)}function S(f){let{hiddenContainer:m,pagesContainer:g,readOnly:_=!1,pageGap:v=y,onChange:b,onError:S,onSelectionUpdate:C,externalPlugins:w=[],syncCoordinator:T,editorMode:E,author:D}=f,O=(0,e.shallowRef)(null),k=(0,e.shallowRef)(null),A=(0,e.shallowRef)(null),j=(0,e.ref)(!1),M=(0,e.ref)(null),N=(0,e.shallowRef)(null),P=l.singletonManager;function F(e){let t=g.value;if(!t||!O.value)return;let r=T?.getStateSeq()??0;T?.onLayoutStart();let a=O.value.package?.document,o=a?.sections?.[0]?.properties??a?.finalSectionProperties??null,s=a?.finalSectionProperties??o,c=(0,n.getPageSize)(o),l=(0,n.getMargins)(o),u=(0,n.getPageSize)(s),d=(0,n.getMargins)(s),f=(0,n.getColumns)(o),m=(0,n.getColumns)(s),_=c.w-l.left-l.right,y=O.value.package?.theme??null,b=O.value.package?.styles??null;try{let{header:r,footer:a,firstHeader:g,firstFooter:S}=(0,n.resolveHeaderFooter)(O.value,o),{blocks:C,measures:w,layout:T,headerContentForRender:E,footerContentForRender:D,firstPageHeaderForRender:k,firstPageFooterForRender:A,hasTitlePg:j,watermark:M,footnotesByPage:P}=(0,p.computeLayout)({state:e,document:O.value,pageSize:c,margins:l,columns:f,finalPageSize:u,finalMargins:d,finalColumns:m,pageGap:v,contentWidth:_,theme:y,styles:b,sectionProperties:o,finalSectionProperties:s,headerContent:r,footerContent:a,firstPageHeaderContent:g,firstPageFooterContent:S,measureBlocks:x,getHfPmDoc:e=>W(e)?.state.doc??null});N.value=T;let F=(0,i.buildBlockLookup)(C,w);(0,h.renderPages)(T.pages,t,{pageGap:v,showShadow:!0,pageBackground:`#fff`,blockLookup:F,theme:y,headerContent:E,footerContent:D,firstPageHeaderContent:k,firstPageFooterContent:A,titlePage:j,watermark:M,footnotesByPage:P}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,i.applySdtFocus)(t,(0,i.enclosingSdtGroupIds)(e.doc,e.selection.from,e.selection.to))}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),S?.(e instanceof Error?e:Error(String(e)))}finally{T?.onLayoutComplete(r)}}let I=(0,p.createLayoutScheduler)(F);function L(){let n=m.value;if(!n)return;let s=O.value?.package?.styles,l=O.value?(0,a.toProseDoc)(O.value,{styles:s??void 0}):(0,a.createEmptyDoc)(),d=(0,u.createSuggestionModePlugin)(!1),f=(0,u.createDocumentStylesPlugin)(s),h=[d,...w,...P.getPlugins()??[],f],v=(0,r.ensureParaIdsInState)(t.EditorState.create({doc:l,schema:P.getSchema(),plugins:h}));if(A.value=v,O.value)try{O.value=(0,c.fromProseDoc)(v.doc,O.value)}catch(e){console.error(`[useDocxEditor] paraId cache sync error:`,e)}let y=new o.EditorView(n,{state:v,editable:()=>!(0,e.unref)(_),dispatchTransaction(e){if(!y)return;(0,p.stripScrollFlag)(e,y.state.tr);let t=y.state.apply(e);if(y.updateState(t),A.value=t,e.docChanged){T?.incrementStateSeq(),I.schedule(t);try{if(O.value){let e=(0,c.fromProseDoc)(t.doc,O.value);O.value=e,b?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(T?.requestRender(),C?.(),!e.docChanged){let e=g.value;e&&(0,i.applySdtFocus)(e,(0,i.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});k.value=y,j.value=!0,F(v),T?.requestRender()}(0,e.watch)([()=>(0,e.unref)(E),()=>(0,e.unref)(D),k],([e,t,n])=>{n&&(0,u.setSuggestionMode)(e===`suggesting`,n.state,n.dispatch,t)},{immediate:!0});function R(){I.cancel(),k.value&&=(k.value.destroy(),null),A.value=null,j.value=!1}let z={current:null},B=new Map,V=new Map;function H(){if(z.current&&z.current.isConnected)return z.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),z.current=e,e}function U(e){let t=O.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 W(e){let t=U(e);return t?B.get(t)??null:null}function G(){let e=O.value?.package,n=H(),i=new Set;if(e?.headers)for(let t of e.headers.keys())i.add(t);if(e?.footers)for(let t of e.footers.keys())i.add(t);for(let[e,t]of B)i.has(e)||(t.destroy(),t.dom.parentElement?.remove(),V.get(e)?.destroy(),V.delete(e),B.delete(e));if(!e)return;let s=e.styles??null,c=e.theme??null,l=e.settings?.defaultTabStop??null;for(let f of i){if(B.has(f))continue;let i=e.headers?.get(f)??e.footers?.get(f);if(!i)continue;let p=e.headers?.has(f)?`header`:`footer`,m=new d.ExtensionManager((0,d.createStarterKit)());m.buildSchema(),m.initializeRuntime(),V.set(f,m);let h=window.document.createElement(`div`);h.dataset.hfRId=f,h.dataset.hfKind=p,n.appendChild(h);let g=(0,a.headerFooterToProseDoc)(i.content,{styles:s??void 0,theme:c,defaultTabStopTwips:l}),_=(0,u.createDocumentStylesPlugin)(s),v=t.EditorState.create({doc:g,schema:r.schema,plugins:[...m.getPlugins(),_]}),y=p,b=new o.EditorView(h,{state:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged){let e=O.value?.package,n=(y===`header`?e?.headers:e?.footers)?.get(f);n&&(n.content=(0,a.proseDocToBlocks)(t.doc))}e.docChanged&&A.value&&F(A.value),q.value?.(f,b,e.docChanged)}});B.set(f,b)}}function K(){for(let e of B.values())e.destroy(),e.dom.parentElement?.remove();B.clear();for(let e of V.values())e.destroy();V.clear(),z.current&&=(z.current.remove(),null)}let q={value:null};function J(e){q.value=e}async function Y(e){M.value=null,j.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,O.value=await(0,s.parseDocx)(t),R(),K(),L(),G()}catch(e){let t=e instanceof Error?e:Error(String(e));M.value=t.message,S?.(t)}}function X(e){M.value=null,O.value=e,R(),K(),L(),G()}async function Z(){if(!k.value||!O.value)return null;let{repackDocx:e,createDocx:t}=await import(`@eigenpal/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@eigenpal/docx-editor-core/docx`),i=(0,c.fromProseDoc)(k.value.state.doc,O.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 Q(){k.value?.focus()}function $(){R(),K(),O.value=null}function ee(){return O.value}(0,e.onBeforeUnmount)(()=>{$()});function te(){return P.getCommands()}return{editorView:k,editorState:A,isReady:j,parseError:M,layout:N,loadBuffer:Y,loadDocument:X,save:Z,focus:Q,destroy:$,getDocument:ee,getCommands:te,reLayout(){k.value&&F(k.value.state)},getHfPmView:W,syncHfPMs:G,setHfTransactionListener:J,setDocument(e){O.value=e}}}var C=.25,w=4,T=.1,E=[.25,.5,.75,1,1.25,1.5,2,3,4];function D(t=1){let n=(0,e.ref)(Math.max(C,Math.min(w,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=C),a=(0,e.computed)(()=>n.value>=w);function o(e){n.value=Math.max(C,Math.min(w,Math.round(e*100)/100))}function s(){o(n.value+T)}function c(){o(n.value-T)}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:E}}function O(){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),k(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),A(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),j(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*g.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=g.MIN_CELL_WIDTH_TWIPS&&o>=g.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*g.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=g.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*g.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=g.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,g.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,g.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,g.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 k(e,t){let n=(0,g.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function A(e,t,n){let r=(0,g.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*g.TWIPS_PER_PIXEL)}function j(e,t){let n=(0,g.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function M({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,_.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,v.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+v.AUTO_SCROLL_EDGE_ZONE||t>n.bottom-v.AUTO_SCROLL_EDGE_ZONE)&&d()}}return(0,e.onBeforeUnmount)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return M}});