@stll/folio-vue 0.22.1 → 0.22.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-vue",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
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",
@@ -87,7 +87,7 @@
87
87
  "@fontsource/noto-sans-arabic": "^5.2.7",
88
88
  "@fontsource/source-sans-3": "^5.2.9",
89
89
  "@fontsource/tinos": "^5.2.7",
90
- "@stll/folio-core": "^0.56.0",
90
+ "@stll/folio-core": "^0.58.0",
91
91
  "better-result": "3.0.1",
92
92
  "use-intl": "^4.13.0",
93
93
  "yjs": "^13.6.31"
@@ -1 +0,0 @@
1
- let e=require("vue"),t=require("@stll/folio-core/types/canonicalCapabilities"),n=require("@stll/folio-core/controller/layoutScheduler"),r=require("@stll/folio-core/controller/hiddenEditorManager"),i=require("@stll/folio-core/docx/document-clone"),a=require("@stll/folio-core/paged-layout/sectionGeometry"),o=require("@stll/folio-core/paged-layout/editorScrollRoot"),s=require("@stll/folio-core/prosemirror/plugins/anonymizationDecorations"),c=require("@stll/folio-core/prosemirror/plugins/autocompleteSuggestion"),l=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),u=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),d=require("@stll/folio-core/docx/storyPlainText"),f=require("@stll/folio-core/controller/folioEditor"),ee=require("@stll/folio-core/controller/folioEditorEvents"),te=require("@stll/folio-core/docx/canonicalSessionInput"),ne=require("@stll/folio-core/docx/canonicalSave"),re=require("@stll/folio-core/controller/collaborationModules"),p=require("@stll/folio-core/controller/headerFooterEditorManager"),ie=require("@stll/folio-core/controller/noteEditorManager"),m=require("@stll/folio-core/controller/layoutPipeline"),ae=require("@stll/folio-core/controller/hyphenationReadiness"),h=require("@stll/folio-core/controller/fontReadiness"),oe=require("@stll/folio-core/controller/layoutSession"),se=require("@stll/folio-core/docx/parser"),ce=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),le=require("@stll/folio-core/layout-engine"),ue=require("@stll/folio-core/layout-painter"),de=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),fe=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),pe=require("@stll/folio-core/prosemirror/noteReferenceReview"),me=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),g=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),he=require("@stll/folio-core/prosemirror/extensions/StarterKit"),ge=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),_e=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),ve=require("@stll/folio-core/utils/headerFooter"),_=require("@stll/folio-core/prosemirror/tableResize"),ye=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),v=require("@stll/folio-core/utils/zoom");var y=`(prefers-color-scheme: dark)`;function be(){return typeof window<`u`&&typeof window.matchMedia==`function`}function xe(e,t){return e===`dark`||e===`system`&&t}function Se(e){if(!be())return()=>{};let t=window.matchMedia(y);e(t.matches);let n=t=>e(t.matches);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var b=`light`,x=Symbol(`folioColorMode`),Ce=(t=b)=>{(0,e.provide)(x,(0,e.computed)(()=>(0,e.toValue)(t)))},S={install(t,n=b){t.provide(x,(0,e.computed)(()=>(0,e.toValue)(n)))}};function C(){let t=(0,e.inject)(x,(0,e.computed)(()=>b)),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(Se(e=>{r.value=e}))}),(0,e.computed)(()=>xe(t.value,n.value&&r.value))}var we=24,Te=250,Ee=[],De=[];function Oe(e){let t=e?.columnCount??1;if(t<=1)return;let n={count:t,gap:(0,a.twipsToPixels)(e?.columnSpace??720),equalWidth:e?.equalWidth??!0};return e?.separator!==void 0&&(n.separator=e.separator),n}function ke(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,ce.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,ce.convertHeaderFooterToContent)(e,r,i,o)}function Ae(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=ke(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function je(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,d.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var Me=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function Ne(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!Me.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 Pe(o){let{hiddenContainer:d,hiddenHeaderFooterContainer:ce,noteEditorContainer:_,pagesContainer:ye,readOnly:v=!1,experimentalSession:y,pageGap:be=we,pageRenderer:xe,markupView:Se=`all-markup`,showMarginGuides:b,marginGuideColor:x,password:Ce,editorMode:S,author:C,externalPlugins:Me=[],historyShortcuts:Pe=`editor`,collaboration:w,onAnonymizationMatchesChange:Fe,showTemplateDirectives:Ie,onSlashMenuChange:Le,onSlashMenuKeyAction:Re,onChange:ze,onError:T,onSelectionUpdate:E,onEditorViewReady:D,onCopy:Be,onCut:Ve,onPaste:He,onReadOnlyEditAttempt:Ue,featureFlags:We,onSelectiveSaveTripwire:Ge}=o,Ke=ce??d,O=(0,e.shallowRef)(null),k=0,qe=!1,A=0,j=!1,M=(0,e.shallowRef)(null),N=(0,e.shallowRef)(null),P=(0,e.shallowRef)(null),F=(0,e.shallowRef)([]),Je=(0,e.shallowRef)(null),I=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),Ye=(0,e.shallowRef)([]),Xe=(0,e.shallowRef)([]),R=(0,e.ref)(!1),z=(0,e.ref)(null),B=(0,e.ref)(!1),V=()=>(0,t.usesCanonicalSession)((0,e.toValue)(y),t.CANONICAL_GAP.authorityRouting),H=e=>V()?(0,i.cloneDocumentWithParagraphPropertySources)(e):e,Ze=(e,n)=>{if(!V())return!1;let i=new r.CanonicalSessionRefusalError({gap:e,message:(0,t.canonicalRefusalMessage)(e,n)});return T?.(i),!0},U=new me.ExtensionManager((0,he.createStarterKit)({historyShortcuts:Pe}));U.buildSchema(),U.initializeRuntime();let Qe=(0,u.createSuggestionModePlugin)(!1),$e=[Qe],et=(0,c.autocompleteSuggestionPlugin)({keymap:!0}),tt=(0,s.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>Fe?.(e)}),W=(0,l.createTemplateDirectivesPlugin)(),nt=(0,_e.templateSlashMenuPlugin)({onChange:e=>Le?.(e),onKeyAction:e=>Re?.(e)??!1}),rt=(0,ge.createTemplatePreviewValuesPlugin)(),it=()=>(0,e.toValue)(Ie)===!0;function at(){return[et,Qe,...Me,...(0,e.toValue)(w)?.plugins??[],tt,...it()?[W,nt]:[],rt]}let G=(0,ee.createFolioEditorEmitter)(),K=new de.LayoutSelectionGate,ot=(0,oe.createLayoutSession)(),st=(0,ae.createHyphenationReadiness)({relayout:()=>{let e=M.value?.state??ot.lastEditorState;e&&X(e,{reason:`hyphenation-ready`})},onError:e=>T?.(e)});(0,e.onScopeDispose)(st.cancel),(0,e.onScopeDispose)((0,h.watchLayoutFontLoads)({measuredFontSet:()=>ot.lastMeasureInputs?.fontSet??null,relayout:()=>{if(j)return;let e=M.value?.state??ot.lastEditorState;e&&X(e,{reason:`font-ready`})}}));let ct=new ue.LayoutPainter({pageGap:be,showShadow:!0}),q=(0,p.createHeaderFooterEditorManager)({getHost:()=>Ke.value,getDocument:()=>$.api.getCanonicalDocument()??O.value,getCanonicalApi:()=>$.api,getExperimentalSession:()=>(0,e.toValue)(y),onSessionRefusal:(e,t)=>{z.value=e,T?.(new r.CanonicalSessionRefusalError({gap:t,message:e}))},getStyles:()=>O.value?.package.styles??null,getTheme:()=>O.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r&&(B.value=!0,Z.schedule()),r||i){let{from:r,to:i}=n.state.selection;Je.value={from:r,kind:t,rId:e,to:i},E?.(n.state),G.emit(`selectionChange`,{from:r,to:i})}K.requestRender()}}),lt={current:null},J=(0,ie.createNoteEditorManager)({getHost:()=>_?.value??null,getPlugins:()=>$e,getDocument:()=>$.api.getCanonicalDocument()??O.value,getCanonicalApi:()=>$.api,getExperimentalSession:()=>(0,e.toValue)(y),onSessionRefusal:(e,t)=>{z.value=e,T?.(new r.CanonicalSessionRefusalError({gap:t,message:e}))},getStyles:()=>O.value?.package.styles??null,getTheme:()=>O.value?.package.theme??null,onTransaction:({docChanged:e,selectionChanged:t,view:n})=>{if(e){B.value=!0;let e=O.value;if(e){let t=$.api.getCanonicalDocument()??lt.current?.snapshotDocument(e)??e;O.value=t,ze?.(H(t)),G.emit(`docChange`,H(t))}Z.schedule()}if(e||t){E?.(n.state);let{from:e,to:t}=n.state.selection;G.emit(`selectionChange`,{from:e,to:t})}}});lt.current=J;let Y=()=>{q.sync(),J.sync()};(0,e.watch)(()=>(0,e.toValue)(y),Y);function ut(e){e.layout&&(L.value=e.layout),e.blocks&&(Ye.value=e.blocks),e.measures&&(Xe.value=e.measures),e.blockLookup&&ct.setBlockLookup(e.blockLookup),e.layout&&G.emit(`layoutComplete`,e.layout)}function X(t,n={}){if(j)return;let r=ye.value,i=r instanceof HTMLDivElement?r:null,o=O.value,s=o?.package.document,c=s?.sections?.[0]?.properties??s?.finalSectionProperties??null,l=(0,a.getPageSize)(c),u=(0,a.getMargins)(c),d=Oe(c),f=l.w-u.left-u.right,ee=o?.package.styles??null,te=o?.package.theme??null,ne=o?.package.settings?.defaultTabStop,re=o?.package.settings?.mirrorMargins===!0,p=(0,ve.resolveHeaderFooterContent)(o?.package);try{ut((0,m.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:l,margins:u,pageGap:be,showMarginGuides:(0,e.toValue)(b)===!0,marginGuideColor:(0,e.toValue)(x),...(()=>{let t=(0,e.toValue)(xe);return t===void 0?{}:{pageRenderer:t}})(),syncCoordinator:K,headerContent:p.headerContent,footerContent:p.footerContent,firstPageHeaderContent:p.firstPageHeaderContent,firstPageFooterContent:p.firstPageFooterContent,headerContentRId:p.activeHeaderRId,footerContentRId:p.activeFooterRId,firstPageHeaderContentRId:p.activeFirstHeaderRId,firstPageFooterContentRId:p.activeFirstFooterRId,sectionHeaderFooterRefs:(0,le.resolveSectionHeaderFooterRefs)(o),theme:te,sectionProperties:c,document:o,defaultTabStop:ne,mirrorMargins:re,styles:ee,layout:L.value,hfPMs:q,painter:ct,pagesContainer:i,session:ot,renderHfFromContentOrPm:ke,renderHeaderFooterContentByRId:Ae,readFontSetSignature:h.readFontSetSignature,buildFootnoteRenderItems:je,describeInvalidHighlightMarks:Ne,emptyTemplatePreviewEntries:Ee,emptyTemplatePreviewHidden:De,hyphenationReadiness:st,markupView:(0,e.toValue)(Se)},t,n))}catch(e){let t=e instanceof Error?e:Error(String(e));T?.(t)}}let Z=(0,n.createLayoutScheduler)({readState:()=>M.value?.state??null,runLayout:(e,t)=>X(e,t),...n.TRANSACTION_LAYOUT_TIMING,clock:n.browserClock}),Q=null,dt=(0,pe.createNoteReferenceFollower)();function ft(){Q!==null&&(window.clearTimeout(Q),Q=null);let e=M.value,t=O.value;if(!(!e||!t))try{let n=$.api.getCanonicalDocument();if(!n&&V())return;let r=n??dt.reconcile((0,fe.fromProseDoc)(e.state.doc,t),e.state.doc);O.value=r,Y(),ze?.(H(r)),G.emit(`docChange`,H(r))}catch(e){T?.(e instanceof Error?e:Error(String(e)))}}function pt(){Q!==null&&window.clearTimeout(Q),Q=window.setTimeout(()=>{Q=null,ft()},Te)}let $=(0,r.createHiddenEditorManager)({getHost:()=>d.value,getDocument:()=>O.value,getStyles:()=>O.value?.package.styles??null,getExtensionManager:()=>U,getExternalPlugins:at,getCollaboration:()=>(0,e.toValue)(w),getCollaborationModules:()=>P.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(v),getExperimentalSession:()=>(0,e.toValue)(y),getEditingMode:()=>(0,e.toValue)(S)??`editing`,getSuggestionAuthor:()=>(0,e.toValue)(C)??`User`,onSessionRefusal:(e,t)=>{T?.(new r.CanonicalSessionRefusalError({gap:t,message:e}))},getDocumentIdentity:()=>String(k),getDocumentContext:()=>O.value,onTransaction:ht,onSelectionChange:e=>{N.value=e,E?.(e),G.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onCopy:()=>Be?.(),onCut:()=>Ve?.(),onPaste:()=>He?.(),onReadOnlyEditAttempt:()=>Ue?.(),onEditorViewReady:gt,onEditorViewDestroy:()=>{M.value=null,R.value=!1,D?.(null)},onRemoteSelectionsChange:e=>{F.value=e}}),mt=()=>{let t=(0,e.toValue)(w)?.awareness,n=P.value,i=$.getView();F.value=t&&n&&i?(0,r.collectRemoteSelections)(i.state,t,n):[]};(0,e.watch)(()=>(0,e.toValue)(w),(e,t,n)=>{if(F.value=[],!e){P.value=null,$.retryViewCreation(),$.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),P.value=null,(0,re.loadCollaborationModules)().then(e=>{r||(P.value=e,$.retryViewCreation(),$.syncExternalDocument(),mt())},e=>{r||(P.value=null,T?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(w)?.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`,mt),mt(),i(()=>{e.off(`change`,mt),F.value=[]})},{flush:`post`});function ht({newState:e,docChanged:t,transactions:n}){N.value=e;let r=n[0]?.before;if(t&&r&&dt.noteBase(r),t){let e=$.api.getCanonicalDocument();e&&(O.value=e,Y()),B.value=!0,K.incrementStateSeq(),Z.schedule(),pt()}K.requestRender()}function gt(t){M.value=t,N.value=t.state,R.value=!0;let n=O.value,r=k,i=++A;j=!0;let a=()=>{A===i&&(j=!1,!(qe||k!==r||$.getView()!==t)&&(X(t.state,{reason:`initial`}),K.requestRender()))};(0,h.waitForInitialLayoutFonts)(n,t.state.doc).then(a,a),yt(t),D?.(t),(0,e.toValue)(v)||requestAnimationFrame(()=>{M.value===t&&t.focus()})}let _t={getDocx:async e=>(await Et(e))?.buffer??null,loadDocument:Tt,loadDocx:wt},vt=(0,f.createFolioEditor)({getEditorApi:()=>$.api,getLayout:()=>L.value,runLayout:(e,t)=>X(e,t),getDocumentIO:()=>_t,emitter:G});function yt(t){(0,u.setSuggestionMode)((0,e.toValue)(S)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(C))}(0,e.watch)([()=>(0,e.toValue)(S),()=>(0,e.toValue)(C)],()=>{let e=M.value;e&&yt(e);for(let e of J.listStories()){let t=J.getView(e);t&&yt(t)}}),(0,e.watch)(()=>(0,e.toValue)(v),e=>{$.syncEditable(),e&&Nt()});function bt(e){let t=it();if(t===e.state.plugins.includes(W))return;let n=e.state.plugins.filter(e=>e!==W&&e!==nt);if(t){let e=n.indexOf(rt),t=e===-1?n.length:e;n.splice(t,0,W,nt)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>it(),()=>{let e=M.value;e&&bt(e)});function xt(){$.ensureView()}function St(){k+=1,B.value=!1,Je.value=null,I.value=null,J.activate(null),Z.dispose(),$.destroyView(),V()&&$.ensureView(),Y(),$.ensureView(),$.getView()||Ct()}function Ct(){let t=O.value;if(!(!t||(0,e.toValue)(w)))try{let e=(0,r.createHiddenEditorState)({document:t,styles:t.package.styles??null,manager:U,externalPlugins:at(),collaborationModules:null,reason:`mount`});N.value=e;let n=k,i=++A;j=!0;let a=()=>{A===i&&(j=!1,!(qe||k!==n||O.value!==t||$.getView())&&X(e,{reason:`initial`}))};(0,h.waitForInitialLayoutFonts)(t,e.doc).then(a,a)}catch(e){T?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([d,ye,Ke,..._?[_]:[]],()=>{d.value&&O.value&&!$.getView()&&xt(),Y()},{flush:`post`});async function wt(t){z.value=null,R.value=!1;try{let n=t;if(V()){let e=await(0,te.prepareCanonicalDocxInput)(t);if(e.isErr())throw e.error;n=e.value}let r=await(0,se.parseDocx)(n,{password:(0,e.toValue)(Ce)});O.value=r,St()}catch(e){let t=e instanceof Error?e:Error(String(e));z.value=t.message,T?.(t)}}function Tt(e){z.value=null,O.value=e,dt.reset(),St()}async function Et(n){let r=M.value,i=O.value;if(!r||!i)return null;try{let r=$.api.captureCanonicalSave();if(r){let i=await(0,ne.serializeCanonicalSave)({snapshot:r,options:n,featureFlags:(0,e.toValue)(We)});for(let e of i.diagnostics)n?.onDiagnostic||T?.(new ne.CanonicalSaveDiagnosticError({gap:t.CANONICAL_GAP.save,diagnostic:e,message:`Canonical save used a fidelity fallback: ${e.type} (${e.part}).`}));return i.tripwireResult&&Ge?.(i.tripwireResult),i}}catch(e){return T?.(e instanceof Error?e:Error(String(e))),null}if(V())return null;Q!==null&&ft();let a=J.snapshotDocument(q.snapshotDocument(i)),o=r.state,s=(0,pe.withoutUnreferencedNotes)((0,fe.fromProseDoc)(o.doc,a)),{resolveSelectiveSaveFlags:c}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),l=c((0,e.toValue)(We)),u=s.originalBuffer??null,d=l.selectiveSave&&n?.mode!==f.FOLIO_DOCX_SERIALIZATION_MODE.full,ee=d||l.selectiveSaveTripwire,{repackDocx:te,createDocx:re}=await import(`@stll/folio-core/docx/rezip`),p=null;if(ee&&u){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);p=await e(s,u,{changedParaIds:(0,g.getChangedParagraphIds)(o),structuralChange:(0,g.hasStructuralChanges)(o),hasUntrackedChanges:(0,g.hasUntrackedChanges)(o),maxBytes:l.selectiveSaveMaxBytes})}let ie=d?p:null,m=null,ae=()=>(0,g.repackWithEditorSectionRemovals)({state:o,document:s,repack:()=>te(s)});if(!ie)m=u?await ae():await re(s),ie=m;else if(l.selectiveSaveTripwire)try{m=await ae()}catch{}if(l.selectiveSaveTripwire&&m&&Ge)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);Ge(await e(p,m))}catch{}return{buffer:ie,document:s}}async function Dt(e){let t=M.value,n=t?.state,r=await Et({mode:e?.selective===!1?f.FOLIO_DOCX_SERIALIZATION_MODE.full:f.FOLIO_DOCX_SERIALIZATION_MODE.preferSelective});return r?(M.value===t&&t?.state.doc===n?.doc&&(r.version===void 0||$.api.isCanonicalSaveCurrent(r.version))&&(O.value=r.document,Y(),B.value=!1),new Blob([r.buffer],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})):null}function Ot(){let e=$.api.getCanonicalDocument();if(e)return e;if(V())return null;let t=O.value;return t?H(J.snapshotDocument(q.snapshotDocument(t))):null}function kt(e){Ze(t.CANONICAL_GAP.modelEdits,`Direct document model changes are unavailable in this session.`)||(O.value=e,Y(),I.value&&!J.getView(I.value)&&(I.value=null))}function At(e){return q.getView(e)}function jt(){Y()}function Mt(e){let t=J.activate(e);t&&(yt(t),I.value=e,requestAnimationFrame(()=>t.focus()))}function Nt(){J.activate(null),I.value=null}function Pt(){let e=I.value;return e?J.getView(e):null}function Ft(){return U.getCommands()}function It(){let e=Pt();e?e.focus():M.value?.focus()}function Lt(){let e=M.value;e&&X(e.state,{reason:`manual`})}(0,e.watch)([()=>(0,e.toValue)(b),()=>(0,e.toValue)(x),()=>(0,e.toValue)(xe),()=>(0,e.toValue)(Se)],()=>Lt());function Rt(){qe=!0,A+=1,j=!1,Z.dispose(),Q!==null&&(window.clearTimeout(Q),Q=null),$.destroyView(),F.value=[],q.destroy(),J.destroy(),U.destroy(),N.value=null,L.value=null,O.value=null,R.value=!1}return(0,e.onScopeDispose)(Rt),{editor:vt,editorView:M,editorState:N,remoteSelections:F,headerFooterSelection:Je,activeNoteStory:I,isReady:R,isDirty:B,parseError:z,layout:L,blocks:Ye,measures:Xe,syncCoordinator:K,loadBuffer:wt,loadDocument:Tt,save:Dt,getDocument:Ot,setDocument:kt,getHeaderFooterView:At,syncHeaderFooterViews:jt,openNoteStory:Mt,closeNoteStory:Nt,getActiveNoteView:Pt,getCommands:Ft,focus:It,reLayout:Lt,destroy:Rt}}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 Fe({pagesContainer:t,onScrollExtendSelection:n}){let r=null,i=0,a=0,s=!1;function c(){return(0,o.getEditorScrollRoot)(t.value)}function l(){s=!1,r!==null&&(cancelAnimationFrame(r),r=null)}function u(){if(!s)return;let e=c();if(!e)return;let t=w(e.getBoundingClientRect(),a);t!==0&&((0,o.scrollEditorBy)(e,t),n(i,a)),r=requestAnimationFrame(u)}function d(){s||(s=!0,r=requestAnimationFrame(u))}function f(e,t){if(i=e,a=t,!s){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 Ie(){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),Le(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),Re(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),ze(a,n),!0):!1:!1}function o(r){if(e.active&&e.handle){r.preventDefault();let t=r.clientX-e.startX,n=parseFloat(e.handle.style.left);e.handle.style.left=`${n+t}px`,e.startX=r.clientX;let i=Math.round(t*_.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=_.MIN_CELL_WIDTH_TWIPS&&o>=_.MIN_CELL_WIDTH_TWIPS&&(e.origWidths={left:a,right:o});return}if(t.active&&t.handle){r.preventDefault();let e=r.clientY-t.startY,n=parseFloat(t.handle.style.top);t.handle.style.top=`${n+e}px`,t.startY=r.clientY;let i=Math.round(e*_.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=_.MIN_ROW_HEIGHT_TWIPS&&(t.origHeight=a);return}if(n.active&&n.handle){r.preventDefault();let e=r.clientX-n.startX,t=parseFloat(n.handle.style.left);n.handle.style.left=`${t+e}px`,n.startX=r.clientX;let i=Math.round(e*_.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=_.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,_.commitColumnResize)(r,{pmStart:e.tablePmStart,colIdx:e.columnIndex,newLeft:e.origWidths.left,newRight:e.origWidths.right}),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&(0,_.commitRowResize)(r,{pmStart:t.tablePmStart,rowIdx:t.rowIndex,newHeight:t.origHeight}),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&(0,_.commitRightEdgeResize)(r,{pmStart:n.tablePmStart,colIdx:n.columnIndex,newWidth:n.origWidth}),n.handle=null)}function c(){return document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s)}}return{tryStartResize:a,install:c,isResizing:i}}function Le(e,t){let n=(0,_.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function Re(e,t,n){let r=(0,_.readRowHeight)(e,t.tablePmStart,t.rowIndex);if(r!=null){t.origHeight=r;return}let i=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),a=i?i.getBoundingClientRect().height:30;t.origHeight=Math.round(a*_.TWIPS_PER_PIXEL)}function ze(e,t){let n=(0,_.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function T(t,n){return(0,e.computed)(()=>(n.value,(0,ye.extractTrackedChanges)(t.value?.state??null)))}var E=v.ZOOM_MIN,D=v.ZOOM_MAX,Be=[.5,.75,1,1.25,1.5,2];function Ve(t=1){let n=(0,e.ref)(Math.max(E,Math.min(D,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=E),a=(0,e.computed)(()=>n.value>=D);function o(e){n.value=Math.max(E,Math.min(D,Math.round(e*100)/100))}function s(){o(n.value+v.ZOOM_STEP)}function c(){o(n.value-v.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:Be}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ve}});