@stll/folio-vue 0.9.0 → 0.10.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 (39) hide show
  1. package/dist/{ListButtons-C1rU_Y1e.cjs → ListButtons-BcB7qvzQ.cjs} +2 -2
  2. package/dist/{ListButtons-DMnOM2pN.js → ListButtons-rpVlLZJ8.js} +388 -384
  3. package/dist/SplitCellDialog-B_TOoiMw.cjs +15 -0
  4. package/dist/{WatermarkDialog-Cf9ISDvv.js → SplitCellDialog-DRQuZsA3.js} +907 -907
  5. package/dist/components/AutocompleteCaretOverlay.types.d.ts +18 -0
  6. package/dist/components/DocxEditor/pagedEditorRef.d.ts +14 -0
  7. package/dist/components/DocxEditor/types.d.ts +27 -0
  8. package/dist/composables/index.d.ts +1 -0
  9. package/dist/composables/useColorMode.d.ts +17 -4
  10. package/dist/composables/useContextMenus.d.ts +3 -0
  11. package/dist/composables/useDocxEditor.d.ts +21 -0
  12. package/dist/composables/useDocxEditorRefApi.d.ts +13 -0
  13. package/dist/composables/useFontLifecycle.d.ts +21 -0
  14. package/dist/composables/useKeyboardShortcuts.d.ts +0 -1
  15. package/dist/composables/usePagesPointer.d.ts +5 -0
  16. package/dist/composables.cjs +2 -2
  17. package/dist/composables.js +75 -75
  18. package/dist/dialogs.cjs +1 -1
  19. package/dist/dialogs.js +2 -2
  20. package/dist/folio-vue.css +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.js +1719 -1275
  24. package/dist/renderAsync.d.ts +4 -0
  25. package/dist/ui/folio-ui.d.ts +1 -1
  26. package/dist/ui.cjs +1 -1
  27. package/dist/ui.js +10 -10
  28. package/dist/useZoom-DBbzwfMG.cjs +1 -0
  29. package/dist/useZoom-DwDDS7hq.js +749 -0
  30. package/dist/utils/colorMode.d.ts +3 -4
  31. package/dist/utils/embeddedFonts.d.ts +7 -0
  32. package/dist/utils/fontFaces.d.ts +10 -0
  33. package/dist/utils/hostFonts.d.ts +1 -5
  34. package/package.json +1 -1
  35. package/dist/WatermarkDialog-ChJtT7Bs.cjs +0 -15
  36. package/dist/composables/useHostCallbacks.d.ts +0 -24
  37. package/dist/composables/useMenuActions.d.ts +0 -36
  38. package/dist/useZoom-BYEcnpS0.cjs +0 -1
  39. package/dist/useZoom-C0p0o54p.js +0 -656
@@ -1 +0,0 @@
1
- let e=require("vue"),t=require("@stll/folio-core/paged-layout/sectionGeometry"),n=require("@stll/folio-core/prosemirror/plugins/anonymizationDecorations"),r=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),i=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),a=require("@stll/folio-core/controller/folioEditor"),o=require("@stll/folio-core/controller/folioEditorEvents"),s=require("@stll/folio-core/controller/collaborationModules"),c=require("@stll/folio-core/controller/headerFooterEditorManager"),l=require("@stll/folio-core/controller/hiddenEditorManager"),u=require("@stll/folio-core/controller/layoutPipeline"),d=require("@stll/folio-core/controller/layoutScheduler"),f=require("@stll/folio-core/controller/layoutSession"),p=require("@stll/folio-core/docx/parser"),m=require("@stll/folio-core/docx/footnoteParser"),h=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),g=require("@stll/folio-core/layout-engine"),_=require("@stll/folio-core/layout-painter"),ee=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),v=require("@stll/folio-core/paged-layout/transactionDirtyRange"),y=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),te=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),b=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),ne=require("@stll/folio-core/prosemirror/extensions/StarterKit"),re=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ie=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),ae=require("@stll/folio-core/utils/headerFooter"),oe=require("@stll/folio-core/utils/findVerticalScrollParent"),x=require("@stll/folio-core/prosemirror/tableResize"),S=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),C=require("@stll/folio-core/utils/zoom");var se=24,ce=32,le=96,ue=250,de=[];function fe(e){let n=e?.columnCount??1;if(n<=1)return;let r={count:n,gap:(0,t.twipsToPixels)(e?.columnSpace??720),equalWidth:e?.equalWidth??!0};return e?.separator!==void 0&&(r.separator=e.separator),r}function pe(e,t,n,r,i,a){if(!e)return;let o=t?{...a,rId:t}:a,s=t?n?.getView(t):null;return s?(0,h.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,h.convertHeaderFooterToContent)(e,r,i,o)}function me(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=pe(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function he(e,t,n){let r=new Map;if(!n||!n.package.footnotes)return r;let i=new Map;for(let e of n.package.footnotes)e.noteType&&e.noteType!==`normal`||i.set(e.id,e);for(let[n,a]of e){let e=[];for(let n of a){let r=i.get(n);if(!r)continue;let a=t.get(n),o=a?.displayNumber??0;e.push({displayNumber:String(o),text:(0,m.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var ge=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function _e(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!ge.has(String(i.attrs.color))&&t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);e.forEach((e,t,i)=>{n(e,`${r}.content[${i}]`)})};return n(e,`doc`),t.join(`; `)}function ve(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function ye(m){let{hiddenContainer:h,hiddenHeaderFooterContainer:oe,pagesContainer:x,readOnly:S=!1,pageGap:C=se,documentKey:ge,password:ye,editorMode:w,author:T,externalPlugins:be=[],collaboration:E,onAnonymizationMatchesChange:xe,showTemplateDirectives:Se,onSlashMenuChange:Ce,onSlashMenuKeyAction:D,onChange:O,onError:k,onSelectionUpdate:A,onEditorViewReady:we,onReadOnlyEditAttempt:Te,featureFlags:Ee,onSelectiveSaveTripwire:De}=m,Oe=oe??h,j=(0,e.shallowRef)(null),M=(0,e.shallowRef)(null),N=(0,e.shallowRef)(null),P=(0,e.shallowRef)(null),F=(0,e.shallowRef)([]),I=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),ke=(0,e.shallowRef)([]),Ae=(0,e.shallowRef)([]),R=(0,e.ref)(!1),z=(0,e.ref)(null),B=(0,e.ref)(!1),V=new te.ExtensionManager((0,ne.createStarterKit)());V.buildSchema(),V.initializeRuntime();let je=(0,i.createSuggestionModePlugin)(!1),Me=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>xe?.(e)}),H=(0,r.createTemplateDirectivesPlugin)(),U=(0,ie.templateSlashMenuPlugin)({onChange:e=>Ce?.(e),onKeyAction:e=>D?.(e)??!1}),Ne=(0,re.createTemplatePreviewValuesPlugin)(),W=()=>(0,e.toValue)(Se)===!0;function Pe(){return[je,...be,...(0,e.toValue)(E)?.plugins??[],Me,...W()?[H,U]:[],Ne]}let G=(0,o.createFolioEditorEmitter)(),K=new ee.LayoutSelectionGate,Fe=(0,f.createLayoutSession)(),Ie=new _.LayoutPainter({pageGap:C,showShadow:!0}),q=(0,c.createHeaderFooterEditorManager)({getHost:()=>Oe.value,getDocument:()=>j.value,getStyles:()=>j.value?.package.styles??null,getTheme:()=>j.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r){B.value=!0;let e=M.value;e&&Y.schedule(e.state,null)}if(r||i){let{from:r,to:i}=n.state.selection;I.value={from:r,kind:t,rId:e,to:i},A?.(n.state),G.emit(`selectionChange`,{from:r,to:i})}K.requestRender()}});function Le(e){e.layout&&(L.value=e.layout),e.blocks&&(ke.value=e.blocks),e.measures&&(Ae.value=e.measures),e.blockLookup&&Ie.setBlockLookup(e.blockLookup),e.layout&&G.emit(`layoutComplete`,e.layout)}function J(e,n={}){let r=x.value,i=r instanceof HTMLDivElement?r:null,a=j.value,o=a?.package.document,s=o?.sections?.[0]?.properties??o?.finalSectionProperties??null,c=(0,t.getPageSize)(s),l=(0,t.getMargins)(s),d=fe(s),f=c.w-l.left-l.right,p=a?.package.styles??null,m=a?.package.theme??null,h=a?.package.settings?.defaultTabStop,_=a?.package.settings,ee=_!==void 0&&`mirrorMargins`in _&&_.mirrorMargins===!0,v=(0,ae.resolveHeaderFooterContent)(a?.package);try{Le((0,u.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:c,margins:l,pageGap:C,syncCoordinator:K,headerContent:v.headerContent,footerContent:v.footerContent,firstPageHeaderContent:v.firstPageHeaderContent,firstPageFooterContent:v.firstPageFooterContent,headerContentRId:v.activeHeaderRId,footerContentRId:v.activeFooterRId,firstPageHeaderContentRId:v.activeFirstHeaderRId,firstPageFooterContentRId:v.activeFirstFooterRId,sectionHeaderFooterRefs:(0,g.resolveSectionHeaderFooterRefs)(a),theme:m,sectionProperties:s,document:a,defaultTabStop:h,mirrorMargins:ee,styles:p,layout:L.value,hfPMs:q,painter:Ie,pagesContainer:i,session:Fe,renderHfFromContentOrPm:pe,renderHeaderFooterContentByRId:me,documentFontsAreLoaded:ve,buildFootnoteRenderItems:he,describeInvalidHighlightMarks:_e,emptyTemplatePreviewEntries:de},e,n))}catch(e){let t=e instanceof Error?e:Error(String(e));k?.(t)}}let Y=(0,d.createLayoutScheduler)({runLayout:(e,t)=>J(e,t),debounceMs:ce,maxDelayMs:le,clock:d.browserClock}),X=null;function Re(){X!==null&&(window.clearTimeout(X),X=null);let e=M.value,t=j.value;if(!(!e||!t))try{let n=(0,y.fromProseDoc)(e.state.doc,t);j.value=n,q.sync(),O?.(n),G.emit(`docChange`,n)}catch(e){k?.(e instanceof Error?e:Error(String(e)))}}function ze(){X!==null&&window.clearTimeout(X),X=window.setTimeout(()=>{X=null,Re()},ue)}let Z=(0,l.createHiddenEditorManager)({getHost:()=>h.value,getDocument:()=>j.value,getStyles:()=>j.value?.package.styles??null,getExtensionManager:()=>V,getExternalPlugins:Pe,getCollaboration:()=>(0,e.toValue)(E),getCollaborationModules:()=>P.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(S),getDocumentKey:()=>(0,e.toValue)(ge),getDocumentContext:()=>j.value,onTransaction:Be,onSelectionChange:e=>{N.value=e,A?.(e),G.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onReadOnlyEditAttempt:()=>Te?.(),onEditorViewReady:Ve,onEditorViewDestroy:()=>{M.value=null,R.value=!1,we?.(null)},onRemoteSelectionsChange:e=>{F.value=e}}),Q=()=>{let t=(0,e.toValue)(E)?.awareness,n=P.value,r=Z.getView();F.value=t&&n&&r?(0,l.collectRemoteSelections)(r.state,t,n):[]};(0,e.watch)(()=>(0,e.toValue)(E),(e,t,n)=>{if(F.value=[],!e){P.value=null,Z.retryViewCreation(),Z.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),P.value=null,(0,s.loadCollaborationModules)().then(e=>{r||(P.value=e,Z.retryViewCreation(),Z.syncExternalDocument(),Q())},e=>{r||(P.value=null,k?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(E)?.awareness,modules:P.value,view:M.value}),({awareness:e,modules:t,view:n},r,i)=>{if(!e||!t||!n){F.value=[];return}e.on(`change`,Q),Q(),i(()=>{e.off(`change`,Q),F.value=[]})},{flush:`post`});function Be(e,t){N.value=t,e.docChanged&&(B.value=!0,K.incrementStateSeq(),Y.schedule(t,(0,v.getTransactionDirtyRange)(e)),ze()),K.requestRender()}function Ve(t){M.value=t,N.value=t.state,R.value=!0,J(t.state,{reason:`initial`}),K.requestRender(),Ue(t),we?.(t),(0,e.toValue)(S)||requestAnimationFrame(()=>{M.value===t&&t.focus()})}let He=(0,a.createFolioEditor)({getEditorApi:()=>Z.api,getLayout:()=>L.value,runLayout:(e,t)=>J(e,t),emitter:G});function Ue(t){(0,i.setSuggestionMode)((0,e.toValue)(w)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(T))}(0,e.watch)([()=>(0,e.toValue)(w),()=>(0,e.toValue)(T)],()=>{let e=M.value;e&&Ue(e)}),(0,e.watch)(()=>(0,e.toValue)(S),()=>Z.syncEditable());function We(e){let t=W();if(t===e.state.plugins.includes(H))return;let n=e.state.plugins.filter(e=>e!==H&&e!==U);if(t){let e=n.indexOf(Ne),t=e===-1?n.length:e;n.splice(t,0,H,U)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>W(),()=>{let e=M.value;e&&We(e)});function Ge(){Z.ensureView()}function Ke(){B.value=!1,I.value=null,Y.dispose(),Z.destroyView(),q.sync(),Z.ensureView(),Z.getView()||qe()}function qe(){let t=j.value;if(!(!t||(0,e.toValue)(E)))try{let e=(0,l.createHiddenEditorState)({document:t,styles:t.package.styles??null,manager:V,externalPlugins:Pe(),collaborationModules:null,reason:`mount`});N.value=e,J(e,{reason:`initial`})}catch(e){k?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([h,x,Oe],()=>{h.value&&j.value&&!Z.getView()&&Ge(),q.sync()},{flush:`post`});async function Je(t){z.value=null,R.value=!1;try{let n=await(0,p.parseDocx)(t,{password:(0,e.toValue)(ye)});j.value=n,Ke()}catch(e){let t=e instanceof Error?e:Error(String(e));z.value=t.message,k?.(t)}}function Ye(e){z.value=null,j.value=e,Ke()}async function Xe(t){let n=M.value,r=j.value;if(!n||!r)return null;let i=q.snapshotDocument(r),a=n.state,{resolveSelectiveSaveFlags:o}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),s=o((0,e.toValue)(Ee)),c=(0,y.fromProseDoc)(a.doc,i),l=c.originalBuffer??null,u=s.selectiveSave&&t?.selective!==!1,d=u||s.selectiveSaveTripwire,{repackDocx:f,createDocx:p}=await import(`@stll/folio-core/docx/rezip`),m=null;if(d&&l){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);m=await e(c,l,{changedParaIds:(0,b.getChangedParagraphIds)(a),structuralChange:(0,b.hasStructuralChanges)(a),hasUntrackedChanges:(0,b.hasUntrackedChanges)(a),maxBytes:s.selectiveSaveMaxBytes})}let h=u?m:null,g=null;if(!h)g=l?await f(c):await p(c),h=g;else if(s.selectiveSaveTripwire)try{g=await f(c)}catch{}if(s.selectiveSaveTripwire&&g&&De)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);De(await e(m,g))}catch{}return j.value=c,q.sync(),B.value=!1,new Blob([h],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Ze(){let e=j.value;return e?q.snapshotDocument(e):null}function Qe(e){j.value=e,q.sync()}function $e(e){return q.getView(e)}function et(){q.sync()}function tt(){return V.getCommands()}function nt(){M.value?.focus()}function rt(){let e=M.value;e&&J(e.state,{reason:`manual`})}function $(){Y.dispose(),X!==null&&(window.clearTimeout(X),X=null),Z.destroyView(),F.value=[],q.destroy(),V.destroy(),N.value=null,L.value=null,j.value=null,R.value=!1}return(0,e.onScopeDispose)($),{editor:He,editorView:M,editorState:N,remoteSelections:F,headerFooterSelection:I,isReady:R,isDirty:B,parseError:z,layout:L,blocks:ke,measures:Ae,syncCoordinator:K,loadBuffer:Je,loadDocument:Ye,save:Xe,getDocument:Ze,setDocument:Qe,getHeaderFooterView:$e,syncHeaderFooterViews:et,getCommands:tt,focus:nt,reLayout:rt,destroy:$}}function w(e,t){if(t<e.top+40){let n=Math.max(0,e.top+40-t);return-Math.min(12,n/40*12)}if(t>e.bottom-40){let n=Math.max(0,t-(e.bottom-40));return Math.min(12,n/40*12)}return 0}function T({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,oe.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=w(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+40||t>n.bottom-40)&&d()}}return(0,e.onScopeDispose)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}function be(){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 instanceof HTMLElement?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),E(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),xe(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),Se(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*x.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=x.MIN_CELL_WIDTH_TWIPS&&o>=x.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*x.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=x.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*x.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=x.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,x.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,x.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,x.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 E(e,t){let n=(0,x.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function xe(e,t,n){let r=(0,x.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*x.TWIPS_PER_PIXEL)}function Se(e,t){let n=(0,x.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function Ce(t,n){return(0,e.computed)(()=>(n.value,(0,S.extractTrackedChanges)(t.value?.state??null)))}var D=C.ZOOM_MIN,O=C.ZOOM_MAX,k=[.5,.75,1,1.25,1.5,2];function A(t=1){let n=(0,e.ref)(Math.max(D,Math.min(O,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=D),a=(0,e.computed)(()=>n.value>=O);function o(e){n.value=Math.max(D,Math.min(O,Math.round(e*100)/100))}function s(){o(n.value+C.ZOOM_STEP)}function c(){o(n.value-C.ZOOM_STEP)}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:k}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}});
@@ -1,656 +0,0 @@
1
- import { computed as e, onBeforeUnmount as t, onMounted as n, onScopeDispose as r, ref as i, shallowRef as a, toValue as o, watch as s } from "vue";
2
- import { getMargins as c, getPageSize as l, twipsToPixels as u } from "@stll/folio-core/paged-layout/sectionGeometry";
3
- import { createAnonymizationDecorationsPlugin as d } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
4
- import { createTemplateDirectivesPlugin as f } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
5
- import { createSuggestionModePlugin as p, setSuggestionMode as m } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
6
- import { createFolioEditor as h } from "@stll/folio-core/controller/folioEditor";
7
- import { createFolioEditorEmitter as g } from "@stll/folio-core/controller/folioEditorEvents";
8
- import { loadCollaborationModules as _ } from "@stll/folio-core/controller/collaborationModules";
9
- import { createHeaderFooterEditorManager as ee } from "@stll/folio-core/controller/headerFooterEditorManager";
10
- import { collectRemoteSelections as v, createHiddenEditorManager as te, createHiddenEditorState as ne } from "@stll/folio-core/controller/hiddenEditorManager";
11
- import { runLayoutPipeline as re } from "@stll/folio-core/controller/layoutPipeline";
12
- import { browserClock as ie, createLayoutScheduler as ae } from "@stll/folio-core/controller/layoutScheduler";
13
- import { createLayoutSession as oe } from "@stll/folio-core/controller/layoutSession";
14
- import { parseDocx as se } from "@stll/folio-core/docx/parser";
15
- import { getFootnoteText as y } from "@stll/folio-core/docx/footnoteParser";
16
- import { convertHeaderFooterPmDocToContent as b, convertHeaderFooterToContent as ce } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
17
- import { resolveSectionHeaderFooterRefs as le } from "@stll/folio-core/layout-engine";
18
- import { LayoutPainter as ue } from "@stll/folio-core/layout-painter";
19
- import { LayoutSelectionGate as de } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
20
- import { getTransactionDirtyRange as fe } from "@stll/folio-core/paged-layout/transactionDirtyRange";
21
- import { fromProseDoc as pe } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
22
- import { ExtensionManager as me } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
23
- import { getChangedParagraphIds as he, hasStructuralChanges as ge, hasUntrackedChanges as _e } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
24
- import { createStarterKit as ve } from "@stll/folio-core/prosemirror/extensions/StarterKit";
25
- import { createTemplatePreviewValuesPlugin as ye } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
26
- import { templateSlashMenuPlugin as be } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
27
- import { resolveHeaderFooterContent as xe } from "@stll/folio-core/utils/headerFooter";
28
- import { findVerticalScrollParent as Se } from "@stll/folio-core/utils/findVerticalScrollParent";
29
- import { MIN_CELL_WIDTH_TWIPS as x, MIN_ROW_HEIGHT_TWIPS as S, TWIPS_PER_PIXEL as C, commitColumnResize as w, commitRightEdgeResize as Ce, commitRowResize as we, readColumnWidthAt as Te, readColumnWidths as Ee, readRowHeight as De } from "@stll/folio-core/prosemirror/tableResize";
30
- import { extractTrackedChanges as T } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
31
- import { ZOOM_MAX as E, ZOOM_MIN as D, ZOOM_STEP as Oe } from "@stll/folio-core/utils/zoom";
32
- //#region src/composables/useDocxEditor.ts
33
- var ke = 24, Ae = 32, je = 96, Me = 250, Ne = [];
34
- function Pe(e) {
35
- let t = e?.columnCount ?? 1;
36
- if (t <= 1) return;
37
- let n = {
38
- count: t,
39
- gap: u(e?.columnSpace ?? 720),
40
- equalWidth: e?.equalWidth ?? !0
41
- };
42
- return e?.separator !== void 0 && (n.separator = e.separator), n;
43
- }
44
- function Fe(e, t, n, r, i, a) {
45
- if (!e) return;
46
- let o = t ? {
47
- ...a,
48
- rId: t
49
- } : a, s = t ? n?.getView(t) : null;
50
- return s ? b(s.state.doc, r, i, o) : ce(e, r, i, o);
51
- }
52
- function Ie(e, t, n, r, i) {
53
- if (!e || e.size === 0) return;
54
- let a = /* @__PURE__ */ new Map();
55
- for (let [o, s] of e) {
56
- let e = Fe(s, o, t, n, r, i);
57
- e && a.set(o, e);
58
- }
59
- return a.size > 0 ? a : void 0;
60
- }
61
- function Le(e, t, n) {
62
- let r = /* @__PURE__ */ new Map();
63
- if (!n || !n.package.footnotes) return r;
64
- let i = /* @__PURE__ */ new Map();
65
- for (let e of n.package.footnotes) e.noteType && e.noteType !== "normal" || i.set(e.id, e);
66
- for (let [n, a] of e) {
67
- let e = [];
68
- for (let n of a) {
69
- let r = i.get(n);
70
- if (!r) continue;
71
- let a = t.get(n), o = a?.displayNumber ?? 0;
72
- e.push({
73
- displayNumber: String(o),
74
- text: y(r),
75
- ...a ? { content: {
76
- blocks: a.blocks,
77
- measures: a.measures,
78
- height: a.height
79
- } } : {}
80
- });
81
- }
82
- e.length > 0 && r.set(n, e);
83
- }
84
- return r;
85
- }
86
- var Re = /* @__PURE__ */ new Set([
87
- "black",
88
- "blue",
89
- "cyan",
90
- "darkBlue",
91
- "darkCyan",
92
- "darkGray",
93
- "darkGreen",
94
- "darkMagenta",
95
- "darkRed",
96
- "darkYellow",
97
- "green",
98
- "lightGray",
99
- "magenta",
100
- "none",
101
- "red",
102
- "white",
103
- "yellow"
104
- ]);
105
- function ze(e) {
106
- let t = [], n = (e, r) => {
107
- for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !Re.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
108
- e.forEach((e, t, i) => {
109
- n(e, `${r}.content[${i}]`);
110
- });
111
- };
112
- return n(e, "doc"), t.join("; ");
113
- }
114
- function Be() {
115
- return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded";
116
- }
117
- function O(e) {
118
- let { hiddenContainer: t, hiddenHeaderFooterContainer: n, pagesContainer: u, readOnly: y = !1, pageGap: b = ke, documentKey: ce, password: Se, editorMode: x, author: S, externalPlugins: C = [], collaboration: w, onAnonymizationMatchesChange: Ce, showTemplateDirectives: we, onSlashMenuChange: Te, onSlashMenuKeyAction: Ee, onChange: De, onError: T, onSelectionUpdate: E, onEditorViewReady: D, onReadOnlyEditAttempt: Oe, featureFlags: Re, onSelectiveSaveTripwire: O } = e, k = n ?? t, A = a(null), j = a(null), M = a(null), N = a(null), P = a([]), F = a(null), I = a(null), L = a([]), R = a([]), z = i(!1), B = i(null), V = i(!1), H = new me(ve());
119
- H.buildSchema(), H.initializeRuntime();
120
- let Ve = p(!1), He = d({ onMatchesChange: (e) => Ce?.(e) }), U = f(), W = be({
121
- onChange: (e) => Te?.(e),
122
- onKeyAction: (e) => Ee?.(e) ?? !1
123
- }), Ue = ye(), G = () => o(we) === !0;
124
- function We() {
125
- return [
126
- Ve,
127
- ...C,
128
- ...o(w)?.plugins ?? [],
129
- He,
130
- ...G() ? [U, W] : [],
131
- Ue
132
- ];
133
- }
134
- let K = g(), q = new de(), Ge = oe(), Ke = new ue({
135
- pageGap: b,
136
- showShadow: !0
137
- }), J = ee({
138
- getHost: () => k.value,
139
- getDocument: () => A.value,
140
- getStyles: () => A.value?.package.styles ?? null,
141
- getTheme: () => A.value?.package.theme ?? null,
142
- onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
143
- if (r) {
144
- V.value = !0;
145
- let e = j.value;
146
- e && X.schedule(e.state, null);
147
- }
148
- if (r || i) {
149
- let { from: r, to: i } = n.state.selection;
150
- F.value = {
151
- from: r,
152
- kind: t,
153
- rId: e,
154
- to: i
155
- }, E?.(n.state), K.emit("selectionChange", {
156
- from: r,
157
- to: i
158
- });
159
- }
160
- q.requestRender();
161
- }
162
- });
163
- function qe(e) {
164
- e.layout && (I.value = e.layout), e.blocks && (L.value = e.blocks), e.measures && (R.value = e.measures), e.blockLookup && Ke.setBlockLookup(e.blockLookup), e.layout && K.emit("layoutComplete", e.layout);
165
- }
166
- function Y(e, t = {}) {
167
- let n = u.value, r = n instanceof HTMLDivElement ? n : null, i = A.value, a = i?.package.document, o = a?.sections?.[0]?.properties ?? a?.finalSectionProperties ?? null, s = l(o), d = c(o), f = Pe(o), p = s.w - d.left - d.right, m = i?.package.styles ?? null, h = i?.package.theme ?? null, g = i?.package.settings?.defaultTabStop, _ = i?.package.settings, ee = _ !== void 0 && "mirrorMargins" in _ && _.mirrorMargins === !0, v = xe(i?.package);
168
- try {
169
- qe(re({
170
- contentWidth: p,
171
- columns: f,
172
- pageSize: s,
173
- margins: d,
174
- pageGap: b,
175
- syncCoordinator: q,
176
- headerContent: v.headerContent,
177
- footerContent: v.footerContent,
178
- firstPageHeaderContent: v.firstPageHeaderContent,
179
- firstPageFooterContent: v.firstPageFooterContent,
180
- headerContentRId: v.activeHeaderRId,
181
- footerContentRId: v.activeFooterRId,
182
- firstPageHeaderContentRId: v.activeFirstHeaderRId,
183
- firstPageFooterContentRId: v.activeFirstFooterRId,
184
- sectionHeaderFooterRefs: le(i),
185
- theme: h,
186
- sectionProperties: o,
187
- document: i,
188
- defaultTabStop: g,
189
- mirrorMargins: ee,
190
- styles: m,
191
- layout: I.value,
192
- hfPMs: J,
193
- painter: Ke,
194
- pagesContainer: r,
195
- session: Ge,
196
- renderHfFromContentOrPm: Fe,
197
- renderHeaderFooterContentByRId: Ie,
198
- documentFontsAreLoaded: Be,
199
- buildFootnoteRenderItems: Le,
200
- describeInvalidHighlightMarks: ze,
201
- emptyTemplatePreviewEntries: Ne
202
- }, e, t));
203
- } catch (e) {
204
- let t = e instanceof Error ? e : Error(String(e));
205
- T?.(t);
206
- }
207
- }
208
- let X = ae({
209
- runLayout: (e, t) => Y(e, t),
210
- debounceMs: Ae,
211
- maxDelayMs: je,
212
- clock: ie
213
- }), Z = null;
214
- function Je() {
215
- Z !== null && (window.clearTimeout(Z), Z = null);
216
- let e = j.value, t = A.value;
217
- if (!(!e || !t)) try {
218
- let n = pe(e.state.doc, t);
219
- A.value = n, J.sync(), De?.(n), K.emit("docChange", n);
220
- } catch (e) {
221
- T?.(e instanceof Error ? e : Error(String(e)));
222
- }
223
- }
224
- function Ye() {
225
- Z !== null && window.clearTimeout(Z), Z = window.setTimeout(() => {
226
- Z = null, Je();
227
- }, Me);
228
- }
229
- let Q = te({
230
- getHost: () => t.value,
231
- getDocument: () => A.value,
232
- getStyles: () => A.value?.package.styles ?? null,
233
- getExtensionManager: () => H,
234
- getExternalPlugins: We,
235
- getCollaboration: () => o(w),
236
- getCollaborationModules: () => N.value,
237
- getPrecomputedInitialState: () => null,
238
- getReadOnly: () => o(y),
239
- getDocumentKey: () => o(ce),
240
- getDocumentContext: () => A.value,
241
- onTransaction: Xe,
242
- onSelectionChange: (e) => {
243
- M.value = e, E?.(e), K.emit("selectionChange", {
244
- from: e.selection.from,
245
- to: e.selection.to
246
- });
247
- },
248
- onKeyDown: () => !1,
249
- onReadOnlyEditAttempt: () => Oe?.(),
250
- onEditorViewReady: Ze,
251
- onEditorViewDestroy: () => {
252
- j.value = null, z.value = !1, D?.(null);
253
- },
254
- onRemoteSelectionsChange: (e) => {
255
- P.value = e;
256
- }
257
- }), $ = () => {
258
- let e = o(w)?.awareness, t = N.value, n = Q.getView();
259
- P.value = e && t && n ? v(n.state, e, t) : [];
260
- };
261
- s(() => o(w), (e, t, n) => {
262
- if (P.value = [], !e) {
263
- N.value = null, Q.retryViewCreation(), Q.syncExternalDocument();
264
- return;
265
- }
266
- let r = !1;
267
- n(() => {
268
- r = !0;
269
- }), N.value = null, _().then((e) => {
270
- r || (N.value = e, Q.retryViewCreation(), Q.syncExternalDocument(), $());
271
- }, (e) => {
272
- r || (N.value = null, T?.(e instanceof Error ? e : Error(String(e))));
273
- });
274
- }, { immediate: !0 }), s(() => ({
275
- awareness: o(w)?.awareness,
276
- modules: N.value,
277
- view: j.value
278
- }), ({ awareness: e, modules: t, view: n }, r, i) => {
279
- if (!e || !t || !n) {
280
- P.value = [];
281
- return;
282
- }
283
- e.on("change", $), $(), i(() => {
284
- e.off("change", $), P.value = [];
285
- });
286
- }, { flush: "post" });
287
- function Xe(e, t) {
288
- M.value = t, e.docChanged && (V.value = !0, q.incrementStateSeq(), X.schedule(t, fe(e)), Ye()), q.requestRender();
289
- }
290
- function Ze(e) {
291
- j.value = e, M.value = e.state, z.value = !0, Y(e.state, { reason: "initial" }), q.requestRender(), $e(e), D?.(e), o(y) || requestAnimationFrame(() => {
292
- j.value === e && e.focus();
293
- });
294
- }
295
- let Qe = h({
296
- getEditorApi: () => Q.api,
297
- getLayout: () => I.value,
298
- runLayout: (e, t) => Y(e, t),
299
- emitter: K
300
- });
301
- function $e(e) {
302
- m(o(x) === "suggesting", e.state, e.dispatch, o(S));
303
- }
304
- s([() => o(x), () => o(S)], () => {
305
- let e = j.value;
306
- e && $e(e);
307
- }), s(() => o(y), () => Q.syncEditable());
308
- function et(e) {
309
- let t = G();
310
- if (t === e.state.plugins.includes(U)) return;
311
- let n = e.state.plugins.filter((e) => e !== U && e !== W);
312
- if (t) {
313
- let e = n.indexOf(Ue), t = e === -1 ? n.length : e;
314
- n.splice(t, 0, U, W);
315
- }
316
- e.updateState(e.state.reconfigure({ plugins: n }));
317
- }
318
- s(() => G(), () => {
319
- let e = j.value;
320
- e && et(e);
321
- });
322
- function tt() {
323
- Q.ensureView();
324
- }
325
- function nt() {
326
- V.value = !1, F.value = null, X.dispose(), Q.destroyView(), J.sync(), Q.ensureView(), Q.getView() || rt();
327
- }
328
- function rt() {
329
- let e = A.value;
330
- if (!(!e || o(w))) try {
331
- let t = ne({
332
- document: e,
333
- styles: e.package.styles ?? null,
334
- manager: H,
335
- externalPlugins: We(),
336
- collaborationModules: null,
337
- reason: "mount"
338
- });
339
- M.value = t, Y(t, { reason: "initial" });
340
- } catch (e) {
341
- T?.(e instanceof Error ? e : Error(String(e)));
342
- }
343
- }
344
- s([
345
- t,
346
- u,
347
- k
348
- ], () => {
349
- t.value && A.value && !Q.getView() && tt(), J.sync();
350
- }, { flush: "post" });
351
- async function it(e) {
352
- B.value = null, z.value = !1;
353
- try {
354
- let t = await se(e, { password: o(Se) });
355
- A.value = t, nt();
356
- } catch (e) {
357
- let t = e instanceof Error ? e : Error(String(e));
358
- B.value = t.message, T?.(t);
359
- }
360
- }
361
- function at(e) {
362
- B.value = null, A.value = e, nt();
363
- }
364
- async function ot(e) {
365
- let t = j.value, n = A.value;
366
- if (!t || !n) return null;
367
- let r = J.snapshotDocument(n), i = t.state, { resolveSelectiveSaveFlags: a } = await import("@stll/folio-core/docx/selectiveSaveFlags"), s = a(o(Re)), c = pe(i.doc, r), l = c.originalBuffer ?? null, u = s.selectiveSave && e?.selective !== !1, d = u || s.selectiveSaveTripwire, { repackDocx: f, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null;
368
- if (d && l) {
369
- let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
370
- m = await e(c, l, {
371
- changedParaIds: he(i),
372
- structuralChange: ge(i),
373
- hasUntrackedChanges: _e(i),
374
- maxBytes: s.selectiveSaveMaxBytes
375
- });
376
- }
377
- let h = u ? m : null, g = null;
378
- if (!h) g = l ? await f(c) : await p(c), h = g;
379
- else if (s.selectiveSaveTripwire) try {
380
- g = await f(c);
381
- } catch {}
382
- if (s.selectiveSaveTripwire && g && O) try {
383
- let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
384
- O(await e(m, g));
385
- } catch {}
386
- return A.value = c, J.sync(), V.value = !1, new Blob([h], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
387
- }
388
- function st() {
389
- let e = A.value;
390
- return e ? J.snapshotDocument(e) : null;
391
- }
392
- function ct(e) {
393
- A.value = e, J.sync();
394
- }
395
- function lt(e) {
396
- return J.getView(e);
397
- }
398
- function ut() {
399
- J.sync();
400
- }
401
- function dt() {
402
- return H.getCommands();
403
- }
404
- function ft() {
405
- j.value?.focus();
406
- }
407
- function pt() {
408
- let e = j.value;
409
- e && Y(e.state, { reason: "manual" });
410
- }
411
- function mt() {
412
- X.dispose(), Z !== null && (window.clearTimeout(Z), Z = null), Q.destroyView(), P.value = [], J.destroy(), H.destroy(), M.value = null, I.value = null, A.value = null, z.value = !1;
413
- }
414
- return r(mt), {
415
- editor: Qe,
416
- editorView: j,
417
- editorState: M,
418
- remoteSelections: P,
419
- headerFooterSelection: F,
420
- isReady: z,
421
- isDirty: V,
422
- parseError: B,
423
- layout: I,
424
- blocks: L,
425
- measures: R,
426
- syncCoordinator: q,
427
- loadBuffer: it,
428
- loadDocument: at,
429
- save: ot,
430
- getDocument: st,
431
- setDocument: ct,
432
- getHeaderFooterView: lt,
433
- syncHeaderFooterViews: ut,
434
- getCommands: dt,
435
- focus: ft,
436
- reLayout: pt,
437
- destroy: mt
438
- };
439
- }
440
- function k(e, t) {
441
- if (t < e.top + 40) {
442
- let n = Math.max(0, e.top + 40 - t);
443
- return -Math.min(12, n / 40 * 12);
444
- }
445
- if (t > e.bottom - 40) {
446
- let n = Math.max(0, t - (e.bottom - 40));
447
- return Math.min(12, n / 40 * 12);
448
- }
449
- return 0;
450
- }
451
- //#endregion
452
- //#region src/composables/useDragAutoScroll.ts
453
- function A({ pagesContainer: e, onScrollExtendSelection: t }) {
454
- let n = null, i = 0, a = 0, o = !1, s = null;
455
- function c() {
456
- if (s) return s;
457
- let t = e.value;
458
- return t ? (s = Se(t), s) : null;
459
- }
460
- function l() {
461
- o = !1, n !== null && (cancelAnimationFrame(n), n = null);
462
- }
463
- function u() {
464
- if (!o) return;
465
- let e = c();
466
- if (!e) return;
467
- let r = k(e.getBoundingClientRect(), a);
468
- r !== 0 && (e.scrollTop += r, t(i, a)), n = requestAnimationFrame(u);
469
- }
470
- function d() {
471
- o || (o = !0, n = requestAnimationFrame(u));
472
- }
473
- function f(e, t) {
474
- if (i = e, a = t, !o) {
475
- let e = c();
476
- if (!e) return;
477
- let n = e.getBoundingClientRect();
478
- (t < n.top + 40 || t > n.bottom - 40) && d();
479
- }
480
- }
481
- return r(() => l()), {
482
- updateMousePosition: f,
483
- stopAutoScroll: l
484
- };
485
- }
486
- //#endregion
487
- //#region src/composables/useTableResize.ts
488
- function j() {
489
- let e = {
490
- active: !1,
491
- startX: 0,
492
- handle: null,
493
- columnIndex: 0,
494
- tablePmStart: 0,
495
- origWidths: {
496
- left: 0,
497
- right: 0
498
- }
499
- }, t = {
500
- active: !1,
501
- startY: 0,
502
- handle: null,
503
- rowIndex: 0,
504
- isEdge: !1,
505
- tablePmStart: 0,
506
- origHeight: 0
507
- }, n = {
508
- active: !1,
509
- startX: 0,
510
- handle: null,
511
- columnIndex: 0,
512
- tablePmStart: 0,
513
- origWidth: 0
514
- }, r = null;
515
- function i() {
516
- return e.active || t.active || n.active;
517
- }
518
- function a(i, a) {
519
- let o = i.target;
520
- return o instanceof HTMLElement ? 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), M(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), N(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), P(a, n), !0) : !1 : !1;
521
- }
522
- function o(r) {
523
- if (e.active && e.handle) {
524
- r.preventDefault();
525
- let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
526
- e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
527
- let i = Math.round(t * C), a = e.origWidths.left + i, o = e.origWidths.right - i;
528
- a >= x && o >= x && (e.origWidths = {
529
- left: a,
530
- right: o
531
- });
532
- return;
533
- }
534
- if (t.active && t.handle) {
535
- r.preventDefault();
536
- let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
537
- t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
538
- let i = Math.round(e * C), a = t.origHeight + i;
539
- a >= S && (t.origHeight = a);
540
- return;
541
- }
542
- if (n.active && n.handle) {
543
- r.preventDefault();
544
- let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
545
- n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
546
- let i = Math.round(e * C), a = n.origWidth + i;
547
- a >= x && (n.origWidth = a);
548
- }
549
- }
550
- function s(i) {
551
- if (e.active) {
552
- e.active = !1, e.handle?.classList.remove("dragging"), r && w(r, {
553
- pmStart: e.tablePmStart,
554
- colIdx: e.columnIndex,
555
- newLeft: e.origWidths.left,
556
- newRight: e.origWidths.right
557
- }), e.handle = null;
558
- return;
559
- }
560
- if (t.active) {
561
- t.active = !1, t.handle?.classList.remove("dragging"), r && we(r, {
562
- pmStart: t.tablePmStart,
563
- rowIdx: t.rowIndex,
564
- newHeight: t.origHeight
565
- }), t.handle = null;
566
- return;
567
- }
568
- n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && Ce(r, {
569
- pmStart: n.tablePmStart,
570
- colIdx: n.columnIndex,
571
- newWidth: n.origWidth
572
- }), n.handle = null);
573
- }
574
- function c() {
575
- return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
576
- document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
577
- };
578
- }
579
- return {
580
- tryStartResize: a,
581
- install: c,
582
- isResizing: i
583
- };
584
- }
585
- function M(e, t) {
586
- let n = Ee(e, t.tablePmStart, t.columnIndex);
587
- n && (t.origWidths = n);
588
- }
589
- function N(e, t, n) {
590
- let r = De(e, t.tablePmStart, t.rowIndex);
591
- if (r != null) {
592
- t.origHeight = r;
593
- return;
594
- }
595
- let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
596
- t.origHeight = Math.round(a * C);
597
- }
598
- function P(e, t) {
599
- let n = Te(e, t.tablePmStart, t.columnIndex);
600
- n != null && (t.origWidth = n);
601
- }
602
- //#endregion
603
- //#region src/composables/useTrackedChanges.ts
604
- function F(t, n) {
605
- return e(() => (n.value, T(t.value?.state ?? null)));
606
- }
607
- //#endregion
608
- //#region src/composables/useZoom.ts
609
- var I = D, L = E, R = [
610
- .5,
611
- .75,
612
- 1,
613
- 1.25,
614
- 1.5,
615
- 2
616
- ];
617
- function z(r = 1) {
618
- let a = i(Math.max(I, Math.min(L, r))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= I), c = e(() => a.value >= L);
619
- function l(e) {
620
- a.value = Math.max(I, Math.min(L, Math.round(e * 100) / 100));
621
- }
622
- function u() {
623
- l(a.value + Oe);
624
- }
625
- function d() {
626
- l(a.value - Oe);
627
- }
628
- function f() {
629
- l(1);
630
- }
631
- function p(e) {
632
- (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
633
- }
634
- function m(e) {
635
- (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())));
636
- }
637
- function h() {
638
- n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
639
- }
640
- return {
641
- zoom: a,
642
- zoomPercent: o,
643
- isMinZoom: s,
644
- isMaxZoom: c,
645
- setZoom: l,
646
- zoomIn: u,
647
- zoomOut: d,
648
- resetZoom: f,
649
- handleWheel: p,
650
- handleKeyDown: m,
651
- installShortcuts: h,
652
- ZOOM_PRESETS: R
653
- };
654
- }
655
- //#endregion
656
- export { A as a, j as i, T as n, O as o, F as r, z as t };