@stll/folio-vue 0.16.2 → 0.16.4

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.
@@ -0,0 +1 @@
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/autocompleteSuggestion"),i=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),a=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),o=require("@stll/folio-core/controller/folioEditor"),s=require("@stll/folio-core/controller/folioEditorEvents"),c=require("@stll/folio-core/controller/collaborationModules"),l=require("@stll/folio-core/controller/headerFooterEditorManager"),u=require("@stll/folio-core/controller/noteEditorManager"),d=require("@stll/folio-core/controller/hiddenEditorManager"),f=require("@stll/folio-core/controller/layoutPipeline"),p=require("@stll/folio-core/controller/layoutScheduler"),m=require("@stll/folio-core/controller/layoutSession"),h=require("@stll/folio-core/docx/parser"),g=require("@stll/folio-core/docx/footnoteParser"),_=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),ee=require("@stll/folio-core/layout-engine"),v=require("@stll/folio-core/layout-painter"),te=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),ne=require("@stll/folio-core/paged-layout/transactionDirtyRange"),re=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),ie=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),ae=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),oe=require("@stll/folio-core/prosemirror/extensions/StarterKit"),se=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ce=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),le=require("@stll/folio-core/utils/headerFooter"),ue=require("@stll/folio-core/utils/findVerticalScrollParent"),y=require("@stll/folio-core/prosemirror/tableResize"),b=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),x=require("@stll/folio-core/utils/zoom");var de=`(prefers-color-scheme: dark)`;function fe(){return typeof window<`u`&&typeof window.matchMedia==`function`}function pe(e,t){return e===`dark`||e===`system`&&t}function me(e){if(!fe())return()=>{};let t=window.matchMedia(de);e(t.matches);let n=t=>e(t.matches);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var S=`light`,C=Symbol(`folioColorMode`),w=(t=S)=>{(0,e.provide)(C,(0,e.computed)(()=>(0,e.toValue)(t)))},he={install(t,n=S){t.provide(C,(0,e.computed)(()=>(0,e.toValue)(n)))}};function T(){let t=(0,e.inject)(C,(0,e.computed)(()=>S)),n=(0,e.ref)(!1),r=(0,e.ref)(!1);return(0,e.onMounted)(()=>{n.value=!0}),(0,e.watchEffect)(e=>{!n.value||t.value!==`system`||e(me(e=>{r.value=e}))}),(0,e.computed)(()=>pe(t.value,n.value&&r.value))}var ge=24,_e=32,ve=96,ye=250,be=[];function xe(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 Se(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,_.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,_.convertHeaderFooterToContent)(e,r,i,o)}function Ce(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=Se(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function we(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),noteId:n,text:(0,g.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var Te=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function Ee(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!Te.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 De(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function Oe(g){let{hiddenContainer:_,hiddenHeaderFooterContainer:ue,noteEditorContainer:y,pagesContainer:b,readOnly:x=!1,pageGap:de=ge,pageRenderer:fe,showMarginGuides:pe,marginGuideColor:me,password:S,editorMode:C,author:w,externalPlugins:he=[],collaboration:T,onAnonymizationMatchesChange:Te,showTemplateDirectives:Oe,onSlashMenuChange:ke,onSlashMenuKeyAction:Ae,onChange:E,onError:D,onSelectionUpdate:O,onEditorViewReady:k,onCopy:je,onCut:A,onPaste:j,onReadOnlyEditAttempt:Me,featureFlags:Ne,onSelectiveSaveTripwire:Pe}=g,Fe=ue??_,M=(0,e.shallowRef)(null),Ie=0,N=(0,e.shallowRef)(null),P=(0,e.shallowRef)(null),F=(0,e.shallowRef)(null),I=(0,e.shallowRef)([]),Le=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),R=(0,e.shallowRef)(null),Re=(0,e.shallowRef)([]),ze=(0,e.shallowRef)([]),z=(0,e.ref)(!1),B=(0,e.ref)(null),V=(0,e.ref)(!1),H=new ie.ExtensionManager((0,oe.createStarterKit)());H.buildSchema(),H.initializeRuntime();let Be=(0,a.createSuggestionModePlugin)(!1),Ve=[Be],He=(0,r.autocompleteSuggestionPlugin)({keymap:!0}),Ue=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>Te?.(e)}),U=(0,i.createTemplateDirectivesPlugin)(),We=(0,ce.templateSlashMenuPlugin)({onChange:e=>ke?.(e),onKeyAction:e=>Ae?.(e)??!1}),Ge=(0,se.createTemplatePreviewValuesPlugin)(),Ke=()=>(0,e.toValue)(Oe)===!0;function qe(){return[He,Be,...he,...(0,e.toValue)(T)?.plugins??[],Ue,...Ke()?[U,We]:[],Ge]}let W=(0,s.createFolioEditorEmitter)(),G=new te.LayoutSelectionGate,Je=(0,m.createLayoutSession)(),Ye=new v.LayoutPainter({pageGap:de,showShadow:!0}),K=(0,l.createHeaderFooterEditorManager)({getHost:()=>Fe.value,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getTheme:()=>M.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r){V.value=!0;let e=N.value;e&&Y.schedule(e.state,null)}if(r||i){let{from:r,to:i}=n.state.selection;Le.value={from:r,kind:t,rId:e,to:i},O?.(n.state),W.emit(`selectionChange`,{from:r,to:i})}G.requestRender()}}),Xe={current:null},q=(0,u.createNoteEditorManager)({getHost:()=>y?.value??null,getPlugins:()=>Ve,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getTheme:()=>M.value?.package.theme??null,onTransaction:({docChanged:e,selectionChanged:t,view:n})=>{if(e){V.value=!0;let e=M.value;if(e){let t=Xe.current?.snapshotDocument(e)??e;M.value=t,E?.(t),W.emit(`docChange`,t)}let t=N.value;t&&Y.schedule(t.state,null)}if(e||t){O?.(n.state);let{from:e,to:t}=n.state.selection;W.emit(`selectionChange`,{from:e,to:t})}}});Xe.current=q;function Ze(e){e.layout&&(R.value=e.layout),e.blocks&&(Re.value=e.blocks),e.measures&&(ze.value=e.measures),e.blockLookup&&Ye.setBlockLookup(e.blockLookup),e.layout&&W.emit(`layoutComplete`,e.layout)}function J(n,r={}){let i=b.value,a=i instanceof HTMLDivElement?i:null,o=M.value,s=o?.package.document,c=s?.sections?.[0]?.properties??s?.finalSectionProperties??null,l=(0,t.getPageSize)(c),u=(0,t.getMargins)(c),d=xe(c),p=l.w-u.left-u.right,m=o?.package.styles??null,h=o?.package.theme??null,g=o?.package.settings?.defaultTabStop,_=o?.package.settings?.mirrorMargins===!0,v=(0,le.resolveHeaderFooterContent)(o?.package);try{Ze((0,f.runLayoutPipeline)({contentWidth:p,columns:d,pageSize:l,margins:u,pageGap:de,showMarginGuides:(0,e.toValue)(pe)===!0,marginGuideColor:(0,e.toValue)(me),...(()=>{let t=(0,e.toValue)(fe);return t===void 0?{}:{pageRenderer:t}})(),syncCoordinator:G,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,ee.resolveSectionHeaderFooterRefs)(o),theme:h,sectionProperties:c,document:o,defaultTabStop:g,mirrorMargins:_,styles:m,layout:R.value,hfPMs:K,painter:Ye,pagesContainer:a,session:Je,renderHfFromContentOrPm:Se,renderHeaderFooterContentByRId:Ce,documentFontsAreLoaded:De,buildFootnoteRenderItems:we,describeInvalidHighlightMarks:Ee,emptyTemplatePreviewEntries:be},n,r))}catch(e){let t=e instanceof Error?e:Error(String(e));D?.(t)}}let Y=(0,p.createLayoutScheduler)({runLayout:(e,t)=>J(e,t),debounceMs:_e,maxDelayMs:ve,clock:p.browserClock}),X=null;function Qe(){X!==null&&(window.clearTimeout(X),X=null);let e=N.value,t=M.value;if(!(!e||!t))try{let n=(0,re.fromProseDoc)(e.state.doc,t);M.value=n,K.sync(),q.sync(),E?.(n),W.emit(`docChange`,n)}catch(e){D?.(e instanceof Error?e:Error(String(e)))}}function $e(){X!==null&&window.clearTimeout(X),X=window.setTimeout(()=>{X=null,Qe()},ye)}let Z=(0,d.createHiddenEditorManager)({getHost:()=>_.value,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getExtensionManager:()=>H,getExternalPlugins:qe,getCollaboration:()=>(0,e.toValue)(T),getCollaborationModules:()=>F.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(x),getDocumentIdentity:()=>String(Ie),getDocumentContext:()=>M.value,onTransaction:et,onSelectionChange:e=>{P.value=e,O?.(e),W.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onCopy:()=>je?.(),onCut:()=>A?.(),onPaste:()=>j?.(),onReadOnlyEditAttempt:()=>Me?.(),onEditorViewReady:tt,onEditorViewDestroy:()=>{N.value=null,z.value=!1,k?.(null)},onRemoteSelectionsChange:e=>{I.value=e}}),Q=()=>{let t=(0,e.toValue)(T)?.awareness,n=F.value,r=Z.getView();I.value=t&&n&&r?(0,d.collectRemoteSelections)(r.state,t,n):[]};(0,e.watch)(()=>(0,e.toValue)(T),(e,t,n)=>{if(I.value=[],!e){F.value=null,Z.retryViewCreation(),Z.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),F.value=null,(0,c.loadCollaborationModules)().then(e=>{r||(F.value=e,Z.retryViewCreation(),Z.syncExternalDocument(),Q())},e=>{r||(F.value=null,D?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(T)?.awareness,modules:F.value,view:N.value}),({awareness:e,modules:t,view:n},r,i)=>{if(!e||!t||!n){I.value=[];return}e.on(`change`,Q),Q(),i(()=>{e.off(`change`,Q),I.value=[]})},{flush:`post`});function et({transactions:e,newState:t,docChanged:n}){P.value=t,n&&(V.value=!0,G.incrementStateSeq(),Y.schedule(t,(0,ne.getTransactionsDirtyRange)(e)),$e()),G.requestRender()}function tt(t){N.value=t,P.value=t.state,z.value=!0,J(t.state,{reason:`initial`}),G.requestRender(),$(t),k?.(t),(0,e.toValue)(x)||requestAnimationFrame(()=>{N.value===t&&t.focus()})}let nt={getDocx:async e=>(await ut(e))?.buffer??null,loadDocument:lt,loadDocx:ct},rt=(0,o.createFolioEditor)({getEditorApi:()=>Z.api,getLayout:()=>R.value,runLayout:(e,t)=>J(e,t),getDocumentIO:()=>nt,emitter:W});function $(t){(0,a.setSuggestionMode)((0,e.toValue)(C)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(w))}(0,e.watch)([()=>(0,e.toValue)(C),()=>(0,e.toValue)(w)],()=>{let e=N.value;e&&$(e);for(let e of q.listStories()){let t=q.getView(e);t&&$(t)}}),(0,e.watch)(()=>(0,e.toValue)(x),e=>{Z.syncEditable(),e&&_t()});function it(e){let t=Ke();if(t===e.state.plugins.includes(U))return;let n=e.state.plugins.filter(e=>e!==U&&e!==We);if(t){let e=n.indexOf(Ge),t=e===-1?n.length:e;n.splice(t,0,U,We)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>Ke(),()=>{let e=N.value;e&&it(e)});function at(){Z.ensureView()}function ot(){Ie+=1,V.value=!1,Le.value=null,L.value=null,q.activate(null),Y.dispose(),Z.destroyView(),K.sync(),q.sync(),Z.ensureView(),Z.getView()||st()}function st(){let t=M.value;if(!(!t||(0,e.toValue)(T)))try{let e=(0,d.createHiddenEditorState)({document:t,styles:t.package.styles??null,manager:H,externalPlugins:qe(),collaborationModules:null,reason:`mount`});P.value=e,J(e,{reason:`initial`})}catch(e){D?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([_,b,Fe,...y?[y]:[]],()=>{_.value&&M.value&&!Z.getView()&&at(),K.sync(),q.sync()},{flush:`post`});async function ct(t){B.value=null,z.value=!1;try{let n=await(0,h.parseDocx)(t,{password:(0,e.toValue)(S)});M.value=n,ot()}catch(e){let t=e instanceof Error?e:Error(String(e));B.value=t.message,D?.(t)}}function lt(e){B.value=null,M.value=e,ot()}async function ut(t){let n=N.value,r=M.value;if(!n||!r)return null;let i=q.snapshotDocument(K.snapshotDocument(r)),a=n.state,{resolveSelectiveSaveFlags:s}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),c=s((0,e.toValue)(Ne)),l=(0,re.fromProseDoc)(a.doc,i),u=l.originalBuffer??null,d=c.selectiveSave&&t?.mode!==o.FOLIO_DOCX_SERIALIZATION_MODE.full,f=d||c.selectiveSaveTripwire,{repackDocx:p,createDocx:m}=await import(`@stll/folio-core/docx/rezip`),h=null;if(f&&u){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);h=await e(l,u,{changedParaIds:(0,ae.getChangedParagraphIds)(a),structuralChange:(0,ae.hasStructuralChanges)(a),hasUntrackedChanges:(0,ae.hasUntrackedChanges)(a),maxBytes:c.selectiveSaveMaxBytes})}let g=d?h:null,_=null;if(!g)_=u?await p(l):await m(l),g=_;else if(c.selectiveSaveTripwire)try{_=await p(l)}catch{}if(c.selectiveSaveTripwire&&_&&Pe)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);Pe(await e(h,_))}catch{}return{buffer:g,document:l}}async function dt(e){let t=await ut({mode:e?.selective===!1?o.FOLIO_DOCX_SERIALIZATION_MODE.full:o.FOLIO_DOCX_SERIALIZATION_MODE.preferSelective});return t?(M.value=t.document,K.sync(),q.sync(),V.value=!1,new Blob([t.buffer],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})):null}function ft(){let e=M.value;return e?q.snapshotDocument(K.snapshotDocument(e)):null}function pt(e){M.value=e,K.sync(),q.sync(),L.value&&!q.getView(L.value)&&(L.value=null)}function mt(e){return K.getView(e)}function ht(){K.sync()}function gt(e){let t=q.activate(e);t&&($(t),L.value=e,requestAnimationFrame(()=>t.focus()))}function _t(){q.activate(null),L.value=null}function vt(){let e=L.value;return e?q.getView(e):null}function yt(){return H.getCommands()}function bt(){let e=vt();e?e.focus():N.value?.focus()}function xt(){let e=N.value;e&&J(e.state,{reason:`manual`})}(0,e.watch)([()=>(0,e.toValue)(pe),()=>(0,e.toValue)(me),()=>(0,e.toValue)(fe)],()=>xt());function St(){Y.dispose(),X!==null&&(window.clearTimeout(X),X=null),Z.destroyView(),I.value=[],K.destroy(),q.destroy(),H.destroy(),P.value=null,R.value=null,M.value=null,z.value=!1}return(0,e.onScopeDispose)(St),{editor:rt,editorView:N,editorState:P,remoteSelections:I,headerFooterSelection:Le,activeNoteStory:L,isReady:z,isDirty:V,parseError:B,layout:R,blocks:Re,measures:ze,syncCoordinator:G,loadBuffer:ct,loadDocument:lt,save:dt,getDocument:ft,setDocument:pt,getHeaderFooterView:mt,syncHeaderFooterViews:ht,openNoteStory:gt,closeNoteStory:_t,getActiveNoteView:vt,getCommands:yt,focus:bt,reLayout:xt,destroy:St}}function ke(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 Ae({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,ue.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=ke(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 E(){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),D(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),O(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),k(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*y.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=y.MIN_CELL_WIDTH_TWIPS&&o>=y.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*y.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=y.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*y.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=y.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,y.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,y.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,y.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 D(e,t){let n=(0,y.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function O(e,t,n){let r=(0,y.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*y.TWIPS_PER_PIXEL)}function k(e,t){let n=(0,y.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function je(t,n){return(0,e.computed)(()=>(n.value,(0,b.extractTrackedChanges)(t.value?.state??null)))}var A=x.ZOOM_MIN,j=x.ZOOM_MAX,Me=[.5,.75,1,1.25,1.5,2];function Ne(t=1){let n=(0,e.ref)(Math.max(A,Math.min(j,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=A),a=(0,e.computed)(()=>n.value>=j);function o(e){n.value=Math.max(A,Math.min(j,Math.round(e*100)/100))}function s(){o(n.value+x.ZOOM_STEP)}function c(){o(n.value-x.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:Me}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ne}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-vue",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "Vue 3 editor for folio: a Word-document (.docx) editor for the browser, built on @stll/folio-core and ProseMirror.",
5
5
  "keywords": [
6
6
  "document-editor",
@@ -74,7 +74,7 @@
74
74
  "test": "bun test src"
75
75
  },
76
76
  "dependencies": {
77
- "@stll/folio-core": "^0.39.0",
77
+ "@stll/folio-core": "^0.40.0",
78
78
  "better-result": "3.0.1",
79
79
  "use-intl": "^4.13.0",
80
80
  "yjs": "^13.6.31"
@@ -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/autocompleteSuggestion"),i=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),a=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),o=require("@stll/folio-core/controller/folioEditor"),s=require("@stll/folio-core/controller/folioEditorEvents"),c=require("@stll/folio-core/controller/collaborationModules"),l=require("@stll/folio-core/controller/headerFooterEditorManager"),u=require("@stll/folio-core/controller/noteEditorManager"),d=require("@stll/folio-core/controller/hiddenEditorManager"),f=require("@stll/folio-core/controller/layoutPipeline"),p=require("@stll/folio-core/controller/layoutScheduler"),m=require("@stll/folio-core/controller/layoutSession"),h=require("@stll/folio-core/docx/parser"),g=require("@stll/folio-core/docx/footnoteParser"),_=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),ee=require("@stll/folio-core/layout-engine"),te=require("@stll/folio-core/layout-painter"),v=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),ne=require("@stll/folio-core/paged-layout/transactionDirtyRange"),re=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),ie=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),ae=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),oe=require("@stll/folio-core/prosemirror/extensions/StarterKit"),se=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ce=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),le=require("@stll/folio-core/utils/headerFooter"),ue=require("@stll/folio-core/utils/findVerticalScrollParent"),y=require("@stll/folio-core/prosemirror/tableResize"),b=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),x=require("@stll/folio-core/utils/zoom");var de=`(prefers-color-scheme: dark)`;function fe(){return typeof window<`u`&&typeof window.matchMedia==`function`}function pe(e,t){return e===`dark`||e===`system`&&t}function me(e){if(!fe())return()=>{};let t=window.matchMedia(de);e(t.matches);let n=t=>e(t.matches);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var S=`light`,C=Symbol(`folioColorMode`),w=(t=S)=>{(0,e.provide)(C,(0,e.computed)(()=>(0,e.toValue)(t)))},he={install(t,n=S){t.provide(C,(0,e.computed)(()=>(0,e.toValue)(n)))}};function T(){let t=(0,e.inject)(C,(0,e.computed)(()=>S)),n=(0,e.ref)(!1),r=(0,e.ref)(!1);return(0,e.onMounted)(()=>{n.value=!0}),(0,e.watchEffect)(e=>{!n.value||t.value!==`system`||e(me(e=>{r.value=e}))}),(0,e.computed)(()=>pe(t.value,n.value&&r.value))}var ge=24,_e=32,ve=96,ye=250,be=[];function xe(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 Se(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,_.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,_.convertHeaderFooterToContent)(e,r,i,o)}function Ce(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=Se(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function we(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),noteId:n,text:(0,g.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var Te=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function Ee(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!Te.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 De(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function Oe(g){let{hiddenContainer:_,hiddenHeaderFooterContainer:ue,noteEditorContainer:y,pagesContainer:b,readOnly:x=!1,pageGap:de=ge,pageRenderer:fe,showMarginGuides:pe,marginGuideColor:me,password:S,editorMode:C,author:w,externalPlugins:he=[],collaboration:T,onAnonymizationMatchesChange:Te,showTemplateDirectives:Oe,onSlashMenuChange:ke,onSlashMenuKeyAction:Ae,onChange:E,onError:D,onSelectionUpdate:O,onEditorViewReady:k,onCopy:je,onCut:A,onPaste:j,onReadOnlyEditAttempt:Me,featureFlags:Ne,onSelectiveSaveTripwire:Pe}=g,Fe=ue??_,M=(0,e.shallowRef)(null),Ie=0,N=(0,e.shallowRef)(null),P=(0,e.shallowRef)(null),F=(0,e.shallowRef)(null),I=(0,e.shallowRef)([]),Le=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),R=(0,e.shallowRef)(null),Re=(0,e.shallowRef)([]),ze=(0,e.shallowRef)([]),z=(0,e.ref)(!1),B=(0,e.ref)(null),V=(0,e.ref)(!1),H=new ie.ExtensionManager((0,oe.createStarterKit)());H.buildSchema(),H.initializeRuntime();let Be=(0,a.createSuggestionModePlugin)(!1),Ve=[Be],He=(0,r.autocompleteSuggestionPlugin)({keymap:!0}),Ue=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>Te?.(e)}),U=(0,i.createTemplateDirectivesPlugin)(),We=(0,ce.templateSlashMenuPlugin)({onChange:e=>ke?.(e),onKeyAction:e=>Ae?.(e)??!1}),Ge=(0,se.createTemplatePreviewValuesPlugin)(),Ke=()=>(0,e.toValue)(Oe)===!0;function qe(){return[He,Be,...he,...(0,e.toValue)(T)?.plugins??[],Ue,...Ke()?[U,We]:[],Ge]}let W=(0,s.createFolioEditorEmitter)(),G=new v.LayoutSelectionGate,Je=(0,m.createLayoutSession)(),Ye=new te.LayoutPainter({pageGap:de,showShadow:!0}),K=(0,l.createHeaderFooterEditorManager)({getHost:()=>Fe.value,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getTheme:()=>M.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r){V.value=!0;let e=N.value;e&&Y.schedule(e.state,null)}if(r||i){let{from:r,to:i}=n.state.selection;Le.value={from:r,kind:t,rId:e,to:i},O?.(n.state),W.emit(`selectionChange`,{from:r,to:i})}G.requestRender()}}),Xe={current:null},q=(0,u.createNoteEditorManager)({getHost:()=>y?.value??null,getPlugins:()=>Ve,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getTheme:()=>M.value?.package.theme??null,onTransaction:({docChanged:e,selectionChanged:t,view:n})=>{if(e){V.value=!0;let e=M.value;if(e){let t=Xe.current?.snapshotDocument(e)??e;M.value=t,E?.(t),W.emit(`docChange`,t)}let t=N.value;t&&Y.schedule(t.state,null)}if(e||t){O?.(n.state);let{from:e,to:t}=n.state.selection;W.emit(`selectionChange`,{from:e,to:t})}}});Xe.current=q;function Ze(e){e.layout&&(R.value=e.layout),e.blocks&&(Re.value=e.blocks),e.measures&&(ze.value=e.measures),e.blockLookup&&Ye.setBlockLookup(e.blockLookup),e.layout&&W.emit(`layoutComplete`,e.layout)}function J(n,r={}){let i=b.value,a=i instanceof HTMLDivElement?i:null,o=M.value,s=o?.package.document,c=s?.sections?.[0]?.properties??s?.finalSectionProperties??null,l=(0,t.getPageSize)(c),u=(0,t.getMargins)(c),d=xe(c),p=l.w-u.left-u.right,m=o?.package.styles??null,h=o?.package.theme??null,g=o?.package.settings?.defaultTabStop,_=o?.package.settings,te=_!==void 0&&`mirrorMargins`in _&&_.mirrorMargins===!0,v=(0,le.resolveHeaderFooterContent)(o?.package);try{Ze((0,f.runLayoutPipeline)({contentWidth:p,columns:d,pageSize:l,margins:u,pageGap:de,showMarginGuides:(0,e.toValue)(pe)===!0,marginGuideColor:(0,e.toValue)(me),...(()=>{let t=(0,e.toValue)(fe);return t===void 0?{}:{pageRenderer:t}})(),syncCoordinator:G,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,ee.resolveSectionHeaderFooterRefs)(o),theme:h,sectionProperties:c,document:o,defaultTabStop:g,mirrorMargins:te,styles:m,layout:R.value,hfPMs:K,painter:Ye,pagesContainer:a,session:Je,renderHfFromContentOrPm:Se,renderHeaderFooterContentByRId:Ce,documentFontsAreLoaded:De,buildFootnoteRenderItems:we,describeInvalidHighlightMarks:Ee,emptyTemplatePreviewEntries:be},n,r))}catch(e){let t=e instanceof Error?e:Error(String(e));D?.(t)}}let Y=(0,p.createLayoutScheduler)({runLayout:(e,t)=>J(e,t),debounceMs:_e,maxDelayMs:ve,clock:p.browserClock}),X=null;function Qe(){X!==null&&(window.clearTimeout(X),X=null);let e=N.value,t=M.value;if(!(!e||!t))try{let n=(0,re.fromProseDoc)(e.state.doc,t);M.value=n,K.sync(),q.sync(),E?.(n),W.emit(`docChange`,n)}catch(e){D?.(e instanceof Error?e:Error(String(e)))}}function $e(){X!==null&&window.clearTimeout(X),X=window.setTimeout(()=>{X=null,Qe()},ye)}let Z=(0,d.createHiddenEditorManager)({getHost:()=>_.value,getDocument:()=>M.value,getStyles:()=>M.value?.package.styles??null,getExtensionManager:()=>H,getExternalPlugins:qe,getCollaboration:()=>(0,e.toValue)(T),getCollaborationModules:()=>F.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(x),getDocumentIdentity:()=>String(Ie),getDocumentContext:()=>M.value,onTransaction:et,onSelectionChange:e=>{P.value=e,O?.(e),W.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onCopy:()=>je?.(),onCut:()=>A?.(),onPaste:()=>j?.(),onReadOnlyEditAttempt:()=>Me?.(),onEditorViewReady:tt,onEditorViewDestroy:()=>{N.value=null,z.value=!1,k?.(null)},onRemoteSelectionsChange:e=>{I.value=e}}),Q=()=>{let t=(0,e.toValue)(T)?.awareness,n=F.value,r=Z.getView();I.value=t&&n&&r?(0,d.collectRemoteSelections)(r.state,t,n):[]};(0,e.watch)(()=>(0,e.toValue)(T),(e,t,n)=>{if(I.value=[],!e){F.value=null,Z.retryViewCreation(),Z.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),F.value=null,(0,c.loadCollaborationModules)().then(e=>{r||(F.value=e,Z.retryViewCreation(),Z.syncExternalDocument(),Q())},e=>{r||(F.value=null,D?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(T)?.awareness,modules:F.value,view:N.value}),({awareness:e,modules:t,view:n},r,i)=>{if(!e||!t||!n){I.value=[];return}e.on(`change`,Q),Q(),i(()=>{e.off(`change`,Q),I.value=[]})},{flush:`post`});function et({transactions:e,newState:t,docChanged:n}){P.value=t,n&&(V.value=!0,G.incrementStateSeq(),Y.schedule(t,(0,ne.getTransactionsDirtyRange)(e)),$e()),G.requestRender()}function tt(t){N.value=t,P.value=t.state,z.value=!0,J(t.state,{reason:`initial`}),G.requestRender(),$(t),k?.(t),(0,e.toValue)(x)||requestAnimationFrame(()=>{N.value===t&&t.focus()})}let nt={getDocx:async e=>(await ut(e))?.buffer??null,loadDocument:lt,loadDocx:ct},rt=(0,o.createFolioEditor)({getEditorApi:()=>Z.api,getLayout:()=>R.value,runLayout:(e,t)=>J(e,t),getDocumentIO:()=>nt,emitter:W});function $(t){(0,a.setSuggestionMode)((0,e.toValue)(C)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(w))}(0,e.watch)([()=>(0,e.toValue)(C),()=>(0,e.toValue)(w)],()=>{let e=N.value;e&&$(e);for(let e of q.listStories()){let t=q.getView(e);t&&$(t)}}),(0,e.watch)(()=>(0,e.toValue)(x),e=>{Z.syncEditable(),e&&_t()});function it(e){let t=Ke();if(t===e.state.plugins.includes(U))return;let n=e.state.plugins.filter(e=>e!==U&&e!==We);if(t){let e=n.indexOf(Ge),t=e===-1?n.length:e;n.splice(t,0,U,We)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>Ke(),()=>{let e=N.value;e&&it(e)});function at(){Z.ensureView()}function ot(){Ie+=1,V.value=!1,Le.value=null,L.value=null,q.activate(null),Y.dispose(),Z.destroyView(),K.sync(),q.sync(),Z.ensureView(),Z.getView()||st()}function st(){let t=M.value;if(!(!t||(0,e.toValue)(T)))try{let e=(0,d.createHiddenEditorState)({document:t,styles:t.package.styles??null,manager:H,externalPlugins:qe(),collaborationModules:null,reason:`mount`});P.value=e,J(e,{reason:`initial`})}catch(e){D?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([_,b,Fe,...y?[y]:[]],()=>{_.value&&M.value&&!Z.getView()&&at(),K.sync(),q.sync()},{flush:`post`});async function ct(t){B.value=null,z.value=!1;try{let n=await(0,h.parseDocx)(t,{password:(0,e.toValue)(S)});M.value=n,ot()}catch(e){let t=e instanceof Error?e:Error(String(e));B.value=t.message,D?.(t)}}function lt(e){B.value=null,M.value=e,ot()}async function ut(t){let n=N.value,r=M.value;if(!n||!r)return null;let i=q.snapshotDocument(K.snapshotDocument(r)),a=n.state,{resolveSelectiveSaveFlags:s}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),c=s((0,e.toValue)(Ne)),l=(0,re.fromProseDoc)(a.doc,i),u=l.originalBuffer??null,d=c.selectiveSave&&t?.mode!==o.FOLIO_DOCX_SERIALIZATION_MODE.full,f=d||c.selectiveSaveTripwire,{repackDocx:p,createDocx:m}=await import(`@stll/folio-core/docx/rezip`),h=null;if(f&&u){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);h=await e(l,u,{changedParaIds:(0,ae.getChangedParagraphIds)(a),structuralChange:(0,ae.hasStructuralChanges)(a),hasUntrackedChanges:(0,ae.hasUntrackedChanges)(a),maxBytes:c.selectiveSaveMaxBytes})}let g=d?h:null,_=null;if(!g)_=u?await p(l):await m(l),g=_;else if(c.selectiveSaveTripwire)try{_=await p(l)}catch{}if(c.selectiveSaveTripwire&&_&&Pe)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);Pe(await e(h,_))}catch{}return{buffer:g,document:l}}async function dt(e){let t=await ut({mode:e?.selective===!1?o.FOLIO_DOCX_SERIALIZATION_MODE.full:o.FOLIO_DOCX_SERIALIZATION_MODE.preferSelective});return t?(M.value=t.document,K.sync(),q.sync(),V.value=!1,new Blob([t.buffer],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})):null}function ft(){let e=M.value;return e?q.snapshotDocument(K.snapshotDocument(e)):null}function pt(e){M.value=e,K.sync(),q.sync(),L.value&&!q.getView(L.value)&&(L.value=null)}function mt(e){return K.getView(e)}function ht(){K.sync()}function gt(e){let t=q.activate(e);t&&($(t),L.value=e,requestAnimationFrame(()=>t.focus()))}function _t(){q.activate(null),L.value=null}function vt(){let e=L.value;return e?q.getView(e):null}function yt(){return H.getCommands()}function bt(){let e=vt();e?e.focus():N.value?.focus()}function xt(){let e=N.value;e&&J(e.state,{reason:`manual`})}(0,e.watch)([()=>(0,e.toValue)(pe),()=>(0,e.toValue)(me),()=>(0,e.toValue)(fe)],()=>xt());function St(){Y.dispose(),X!==null&&(window.clearTimeout(X),X=null),Z.destroyView(),I.value=[],K.destroy(),q.destroy(),H.destroy(),P.value=null,R.value=null,M.value=null,z.value=!1}return(0,e.onScopeDispose)(St),{editor:rt,editorView:N,editorState:P,remoteSelections:I,headerFooterSelection:Le,activeNoteStory:L,isReady:z,isDirty:V,parseError:B,layout:R,blocks:Re,measures:ze,syncCoordinator:G,loadBuffer:ct,loadDocument:lt,save:dt,getDocument:ft,setDocument:pt,getHeaderFooterView:mt,syncHeaderFooterViews:ht,openNoteStory:gt,closeNoteStory:_t,getActiveNoteView:vt,getCommands:yt,focus:bt,reLayout:xt,destroy:St}}function ke(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 Ae({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,ue.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=ke(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 E(){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),D(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),O(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),k(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*y.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=y.MIN_CELL_WIDTH_TWIPS&&o>=y.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*y.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=y.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*y.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=y.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,y.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,y.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,y.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 D(e,t){let n=(0,y.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function O(e,t,n){let r=(0,y.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*y.TWIPS_PER_PIXEL)}function k(e,t){let n=(0,y.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function je(t,n){return(0,e.computed)(()=>(n.value,(0,b.extractTrackedChanges)(t.value?.state??null)))}var A=x.ZOOM_MIN,j=x.ZOOM_MAX,Me=[.5,.75,1,1.25,1.5,2];function Ne(t=1){let n=(0,e.ref)(Math.max(A,Math.min(j,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=A),a=(0,e.computed)(()=>n.value>=j);function o(e){n.value=Math.max(A,Math.min(j,Math.round(e*100)/100))}function s(){o(n.value+x.ZOOM_STEP)}function c(){o(n.value-x.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:Me}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ne}});