@stll/folio-vue 0.28.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/commentMarks.d.ts +5 -14
- package/dist/composables/useCommentLifecycle.d.ts +0 -2
- package/dist/composables/useDocxEditorRefApi.d.ts +10 -3
- package/dist/composables/useTableResize.d.ts +6 -1
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +1 -1
- package/dist/folio-vue.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1411 -1361
- package/dist/useZoom-B4Q-QRRT.cjs +1 -0
- package/dist/useZoom-DoMlCL_b.js +1021 -0
- package/package.json +3 -3
- package/dist/useZoom-CKHgvyHZ.js +0 -1014
- package/dist/useZoom-Db3Q3xP7.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("vue"),t=require("@stll/folio-core/controller/hiddenEditorManager"),n=require("@stll/folio-core/docx/document-clone"),r=require("@stll/folio-core/docx/hostCommentThreads"),i=require("@stll/folio-core/managers/EditorModeManager"),a=require("@stll/folio-core/paged-layout/editorScrollRoot"),o=require("@stll/folio-core/paged-layout/sectionGeometry"),s=require("@stll/folio-core/prosemirror/commentRecords"),c=require("@stll/folio-core/types/canonicalCapabilities"),l=require("@stll/folio-core/utils/paintedPositions"),u=require("@stll/folio-core/prosemirror/commands/comments"),d=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),f=require("@stll/folio-core/controller/collaborationModules"),p=require("@stll/folio-core/controller/folioEditor"),m=require("@stll/folio-core/controller/folioEditorEvents"),h=require("@stll/folio-core/controller/fontReadiness"),g=require("@stll/folio-core/controller/headerFooterEditorManager"),_=require("@stll/folio-core/controller/hyphenationReadiness"),ee=require("@stll/folio-core/controller/layoutPipeline"),v=require("@stll/folio-core/controller/layoutScheduler"),te=require("@stll/folio-core/controller/layoutSession"),y=require("@stll/folio-core/controller/noteEditorManager"),b=require("@stll/folio-core/docx/canonicalSave"),x=require("@stll/folio-core/docx/canonicalSessionInput"),S=require("@stll/folio-core/docx/parser"),C=require("@stll/folio-core/docx/storyPlainText"),w=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),ne=require("@stll/folio-core/layout-engine"),T=require("@stll/folio-core/layout-painter"),re=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),ie=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),ae=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),E=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),D=require("@stll/folio-core/prosemirror/extensions/StarterKit"),oe=require("@stll/folio-core/prosemirror/noteReferenceReview"),se=require("@stll/folio-core/prosemirror/plugins/anonymizationDecorations"),ce=require("@stll/folio-core/prosemirror/plugins/autocompleteSuggestion"),le=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),ue=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),de=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),fe=require("@stll/folio-core/utils/headerFooter"),pe=require("@stll/folio-core/managers/FindReplaceManager"),O=require("@stll/folio-core/prosemirror/findReplaceSelection"),me=require("@stll/folio-core/utils/findMatchView"),he=require("@stll/folio-core/utils/findReplace"),ge=require("@stll/folio-core/utils/findSearchKey"),k=require("@stll/folio-core/prosemirror/tableResize"),_e=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),A=require("@stll/folio-core/utils/zoom");var ve=`(prefers-color-scheme: dark)`;function ye(){return typeof window<`u`&&typeof window.matchMedia==`function`}function be(e,t){return e===`dark`||e===`system`&&t}function xe(e){if(!ye())return()=>{};let t=window.matchMedia(ve);e(t.matches);let n=t=>e(t.matches);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var Se=`light`,Ce=Symbol(`folioColorMode`),j=(t=Se)=>{(0,e.provide)(Ce,(0,e.computed)(()=>(0,e.toValue)(t)))},we={install(t,n=Se){t.provide(Ce,(0,e.computed)(()=>(0,e.toValue)(n)))}};function Te(){let t=(0,e.inject)(Ce,(0,e.computed)(()=>Se)),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(xe(e=>{r.value=e}))}),(0,e.computed)(()=>be(t.value,n.value&&r.value))}var Ee=24,De=`User`,Oe=250,ke=[],Ae=[];function je(e){let t=e?.columnCount??1;if(t<=1)return;let n={count:t,gap:(0,o.twipsToPixels)(e?.columnSpace??720),equalWidth:e?.equalWidth??!0};return e?.separator!==void 0&&(n.separator=e.separator),n}function Me(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,w.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,w.convertHeaderFooterToContent)(e,r,i,o)}function Ne(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=Me(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function Pe(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,C.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var Fe=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function Ie(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!Fe.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 Le(i){let{comments:a,hiddenContainer:l,hiddenHeaderFooterContainer:u,noteEditorContainer:C,pagesContainer:w,readOnly:pe=!1,experimentalSession:O,pageGap:me=Ee,pageRenderer:he,markupView:ge=`all-markup`,showCommentHighlights:k=!0,altChunkMarkerText:_e,showMarginGuides:A,marginGuideColor:ve,password:ye,editorMode:be,author:xe,externalPlugins:Se=[],historyShortcuts:Ce=`editor`,collaboration:j,onAnonymizationMatchesChange:we,showTemplateDirectives:Te,onSlashMenuChange:Fe,onSlashMenuKeyAction:Le,onChange:Re,onError:M,onSelectionUpdate:ze,onEditorViewReady:Be,onCopy:Ve,onCut:He,onPaste:Ue,onReadOnlyEditAttempt:We,featureFlags:Ge,onSelectiveSaveTripwire:N}=i,Ke=u??l,qe=()=>(0,e.toValue)(xe)??De,P=(0,e.shallowRef)(null),F=0,Je=!1,Ye=0,I=!1,L=(0,e.shallowRef)(null),R=(0,e.shallowRef)(null),z=(0,e.shallowRef)(null),B=(0,e.shallowRef)([]),Xe=(0,e.shallowRef)(null),V=(0,e.shallowRef)(null),Ze=(0,e.shallowRef)(null),Qe=(0,e.shallowRef)([]),$e=(0,e.shallowRef)([]),et=(0,e.ref)(!1),H=(0,e.ref)(null),U=(0,e.ref)(!1),W=()=>(0,c.usesCanonicalSession)((0,e.toValue)(O),c.CANONICAL_GAP.authorityRouting),tt=e=>W()?(0,n.cloneDocumentWithParagraphPropertySources)(e):e,nt=(e,t)=>{let r=t?(0,n.cloneDocumentWithParagraphPropertySources)(e):tt(e);Re?.(r),K.emit(`docChange`,r)},rt=(e,n)=>{if(!W())return!1;let r=new t.CanonicalSessionRefusalError({ground:{gap:e},message:(0,c.canonicalRefusalMessage)(e,n)});return M?.(r),!0},G=new ae.ExtensionManager((0,D.createStarterKit)({historyShortcuts:Ce}));G.buildSchema(),G.initializeRuntime();let it=(0,d.createSuggestionModePlugin)(!1),at=[it],ot=(0,ce.autocompleteSuggestionPlugin)({keymap:!0}),st=(0,se.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>we?.(e)}),ct=(0,le.createTemplateDirectivesPlugin)(),lt=(0,de.templateSlashMenuPlugin)({onChange:e=>Fe?.(e),onKeyAction:e=>Le?.(e)??!1}),ut=(0,ue.createTemplatePreviewValuesPlugin)(),dt=()=>(0,e.toValue)(Te)===!0;function ft(){return[ot,it,...Se,...(0,e.toValue)(j)?.plugins??[],st,...dt()?[ct,lt]:[],ut]}let K=(0,m.createFolioEditorEmitter)(),q=new re.LayoutSelectionGate,pt=(0,te.createLayoutSession)(),mt=(0,_.createHyphenationReadiness)({relayout:()=>{let e=L.value?.state??pt.lastEditorState;e&&Z(e,{reason:`hyphenation-ready`})},onError:e=>M?.(e)});(0,e.onScopeDispose)(mt.cancel),(0,e.onScopeDispose)((0,h.watchLayoutFontLoads)({measuredFontSet:()=>pt.lastMeasureInputs?.fontSet??null,relayout:()=>{if(I)return;let e=L.value?.state??pt.lastEditorState;e&&Z(e,{reason:`font-ready`})}}));let ht=new T.LayoutPainter({pageGap:me,showShadow:!0}),J=(0,g.createHeaderFooterEditorManager)({getHost:()=>Ke.value,getReadOnly:()=>(0,e.toValue)(pe),getDocument:()=>$.api.getCanonicalDocument()??P.value,getCanonicalApi:()=>$.api,readCanonicalDocument:()=>$.readCanonicalDocument(),getExperimentalSession:()=>(0,e.toValue)(O),onSessionRefusal:(e,n,r)=>{H.value=e,M?.(r??new t.CanonicalSessionRefusalError({ground:n,message:e}))},getStyles:()=>P.value?.package.styles??null,getTheme:()=>P.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r&&(U.value=!0,vt.schedule()),r||i){let{from:r,to:i}=n.state.selection;Xe.value={from:r,kind:t,rId:e,to:i},ze?.(n.state),K.emit(`selectionChange`,{from:r,to:i})}q.requestRender()}}),gt={current:null},Y=(0,y.createNoteEditorManager)({getHost:()=>C?.value??null,getPlugins:()=>at,getDocument:()=>$.api.getCanonicalDocument()??P.value,getCanonicalApi:()=>$.api,readCanonicalDocument:()=>$.readCanonicalDocument(),getExperimentalSession:()=>(0,e.toValue)(O),onSessionRefusal:(e,n,r)=>{H.value=e,M?.(r??new t.CanonicalSessionRefusalError({ground:n,message:e}))},getStyles:()=>P.value?.package.styles??null,getTheme:()=>P.value?.package.theme??null,onTransaction:({docChanged:e,selectionChanged:t,view:n})=>{if(e){U.value=!0;let e=P.value;if(e){let t=$.readCanonicalDocument(),n=t??gt.current?.snapshotDocument(e)??e;P.value=n,nt(n,t!==null)}vt.schedule()}if(e||t){ze?.(n.state);let{from:e,to:t}=n.state.selection;K.emit(`selectionChange`,{from:e,to:t})}}});gt.current=Y;let X=()=>{J.sync(),Y.sync()};(0,e.watch)(()=>(0,e.toValue)(O),X);function _t(e){e.layout&&(Ze.value=e.layout),e.blocks&&(Qe.value=e.blocks),e.measures&&($e.value=e.measures),e.blockLookup&&ht.setBlockLookup(e.blockLookup),e.layout&&K.emit(`layoutComplete`,e.layout)}function Z(t,n={}){if(I)return;let r=w.value,i=r instanceof HTMLDivElement?r:null,a=P.value,s=a?.package.document,c=s?.sections?.[0]?.properties??s?.finalSectionProperties??null,l=(0,o.getPageSize)(c),u=(0,o.getMargins)(c),d=je(c),f=l.w-u.left-u.right,p=a?.package.styles??null,m=a?.package.theme??null,g=a?.package.settings?.defaultTabStop,_=a?.package.settings?.mirrorMargins===!0,v=(0,fe.resolveHeaderFooterContent)(a?.package);try{_t((0,ee.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:l,margins:u,pageGap:me,showMarginGuides:(0,e.toValue)(A)===!0,marginGuideColor:(0,e.toValue)(ve),...(()=>{let t=(0,e.toValue)(he);return t===void 0?{}:{pageRenderer:t}})(),syncCoordinator:q,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,ne.resolveSectionHeaderFooterRefs)(a),theme:m,sectionProperties:c,document:a,defaultTabStop:g,mirrorMargins:_,styles:p,layout:Ze.value,hfPMs:J,painter:ht,pagesContainer:i,session:pt,renderHfFromContentOrPm:Me,renderHeaderFooterContentByRId:Ne,readFontSetSignature:h.readFontSetSignature,buildFootnoteRenderItems:Pe,describeInvalidHighlightMarks:Ie,emptyTemplatePreviewEntries:ke,emptyTemplatePreviewHidden:Ae,hyphenationReadiness:mt,markupView:(0,e.toValue)(ge),showCommentHighlights:(0,e.toValue)(k),..._e===void 0?{}:{altChunkMarkerText:(0,e.toValue)(_e)}},t,n))}catch(e){let t=e instanceof Error?e:Error(String(e));M?.(t)}}let vt=(0,v.createLayoutScheduler)({readState:()=>L.value?.state??null,runLayout:(e,t)=>Z(e,t),...v.TRANSACTION_LAYOUT_TIMING,clock:v.browserClock}),Q=null,yt=(0,oe.createNoteReferenceFollower)();function bt(){Q!==null&&(window.clearTimeout(Q),Q=null);let e=L.value,t=P.value;if(e&&t)try{let n=$.readCanonicalDocument();if(!n&&W())return;let r=n??yt.reconcile((0,ie.fromProseDoc)(e.state.doc,t,{stylesheetSource:{type:`package`}}),e.state.doc);P.value=r,X(),nt(r,n!==null)}catch(e){M?.(e instanceof Error?e:Error(String(e)))}}function xt(){Q!==null&&window.clearTimeout(Q),Q=window.setTimeout(()=>{Q=null,bt()},Oe)}let $=(0,t.createHiddenEditorManager)({getHost:()=>l.value,getDocument:()=>P.value,getStyles:()=>P.value?.package.styles??null,getExtensionManager:()=>G,getExternalPlugins:ft,getCollaboration:()=>(0,e.toValue)(j),getCollaborationModules:()=>z.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(pe),getExperimentalSession:()=>(0,e.toValue)(O),getEditingMode:()=>(0,e.toValue)(be)??`editing`,getSuggestionAuthor:qe,onSessionRefusal:(e,n,r)=>{M?.(r??new t.CanonicalSessionRefusalError({ground:n,message:e}))},getDocumentIdentity:()=>String(F),getDocumentContext:()=>P.value,onTransaction:Ct,onCanonicalCompositionEnd:()=>vt.schedule(),onSelectionChange:e=>{R.value=e,ze?.(e),K.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onCopy:()=>Ve?.(),onCut:()=>He?.(),onPaste:()=>Ue?.(),onReadOnlyEditAttempt:()=>We?.(),onEditorViewReady:wt,onEditorViewDestroy:()=>{L.value=null,et.value=!1,Be?.(null)},onRemoteSelectionsChange:e=>{B.value=e}}),St=()=>{let n=(0,e.toValue)(j)?.awareness,r=z.value,i=$.getView();B.value=n&&r&&i?(0,t.collectRemoteSelections)(i.state,n,r):[]};(0,e.watch)(()=>(0,e.toValue)(j),(e,t,n)=>{if(B.value=[],!e){z.value=null,$.retryViewCreation(),$.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),z.value=null,(0,f.loadCollaborationModules)().then(e=>{r||(z.value=e,$.retryViewCreation(),$.syncExternalDocument(),St())},e=>{r||(z.value=null,M?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(j)?.awareness,modules:z.value,view:L.value}),({awareness:e,modules:t,view:n},r,i)=>{!e||!t||!n?B.value=[]:(e.on(`change`,St),St(),i(()=>{e.off(`change`,St),B.value=[]}))},{flush:`post`});function Ct({newState:e,docChanged:t,transactions:n}){R.value=e;let r=n[0]?.before;if(t&&r&&yt.noteBase(r),t){let e=$.readCanonicalDocument();e&&(P.value=e,X()),U.value=!0,q.incrementStateSeq(),vt.schedule(),xt()}q.requestRender()}function wt(t){L.value=t,R.value=t.state,et.value=!0;let n=P.value,r=F,i=++Ye;I=!0;let a=()=>{Ye===i&&(I=!1,!(Je||F!==r||$.getView()!==t)&&(Z(t.state,{reason:`initial`}),q.requestRender()))};(0,h.waitForInitialLayoutFonts)(n,t.state.doc).then(a,a),Dt(t),Be?.(t),(0,e.toValue)(pe)||requestAnimationFrame(()=>{L.value===t&&t.focus()})}let Tt={getDocx:async e=>(await Pt(e))?.buffer??null,loadDocument:Nt,loadDocx:Mt},Et=(0,p.createFolioEditor)({getEditorApi:()=>$.api,getLayout:()=>Ze.value,runLayout:(e,t)=>Z(e,t),getDocumentIO:()=>Tt,emitter:K});function Dt(t){let n=(0,e.toValue)(be)===`suggesting`;(0,d.setSuggestionMode)(n,t.state,t.dispatch,qe())}(0,e.watch)([()=>(0,e.toValue)(be),qe],()=>{Et.setCanonicalMode((0,e.toValue)(be)===`suggesting`?{type:`suggesting`,author:qe()}:{type:`editing`});let t=L.value;t&&Dt(t);for(let e of Y.listStories()){let t=Y.getView(e);t&&Dt(t)}}),(0,e.watch)(()=>(0,e.toValue)(pe),e=>{$.syncEditable(),e&&Vt(),J.sync()});function Ot(e){let t=dt();if(t===e.state.plugins.includes(ct))return;let n=e.state.plugins.filter(e=>e!==ct&&e!==lt);if(t){let e=n.indexOf(ut),t=e===-1?n.length:e;n.splice(t,0,ct,lt)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>dt(),()=>{let e=L.value;e&&Ot(e)});function kt(){$.ensureView()}function At(){F+=1,U.value=!1,Xe.value=null,V.value=null,Y.activate(null),vt.dispose(),$.destroyView(),W()&&$.ensureView(),X(),$.ensureView(),$.getView()||jt()}function jt(){let n=P.value;if(n&&!(0,e.toValue)(j))try{let e=(0,t.createHiddenEditorState)({document:n,styles:n.package.styles??null,manager:G,externalPlugins:ft(),collaborationModules:null,reason:`mount`});R.value=e;let r=F,i=++Ye;I=!0;let a=()=>{Ye===i&&(I=!1,!(Je||F!==r||P.value!==n||$.getView())&&Z(e,{reason:`initial`}))};(0,h.waitForInitialLayoutFonts)(n,e.doc).then(a,a)}catch(e){M?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([l,w,Ke,...C?[C]:[]],()=>{l.value&&P.value&&!$.getView()&&kt(),X()},{flush:`post`});async function Mt(t){H.value=null,et.value=!1;try{let n=t;if(W()){let e=await(0,x.prepareCanonicalDocxInput)(t);if(e.isErr())throw e.error;n=e.value}let r=await(0,S.parseDocx)(n,{password:(0,e.toValue)(ye)});P.value=r,At()}catch(e){let t=e instanceof Error?e:Error(String(e));H.value=t.message,M?.(t)}}function Nt(e){H.value=null,P.value=e,yt.reset(),At()}async function Pt(t){let n=L.value,i=P.value;if(!n||!i)return null;try{let n=$.api.captureCanonicalSave();if(n){let r=await(0,b.serializeCanonicalSave)({snapshot:n,options:t,featureFlags:(0,e.toValue)(Ge)});for(let e of r.diagnostics)t?.onDiagnostic||M?.(new b.CanonicalSaveDiagnosticError({gap:c.CANONICAL_GAP.save,diagnostic:e,message:`Canonical save used a fidelity fallback: ${e.type} (${e.part}).`}));return r.tripwireResult&&N?.(r.tripwireResult),r}}catch(e){return M?.(e instanceof Error?e:Error(String(e))),null}if(W())return null;Q!==null&&bt();let o=Y.snapshotDocument(J.snapshotDocument(i)),l=n.state,u=(0,ie.fromProseDoc)(l.doc,o,{stylesheetSource:{type:`package`}}),d=(0,oe.withoutUnreferencedNotes)(a?(0,r.withHostCommentThreads)(u,a(),{anchoredInEditor:(0,s.commentIdsNamedIn)(l.doc)}):u),{resolveSelectiveSaveFlags:f}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),m=f((0,e.toValue)(Ge)),h=d.originalBuffer??null,g=m.selectiveSave&&t?.mode!==p.FOLIO_DOCX_SERIALIZATION_MODE.full,_=g||m.selectiveSaveTripwire,{repackDocx:ee,createDocx:v}=await import(`@stll/folio-core/docx/rezip`),te=null;if(_&&h){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);te=await e(d,h,{changedParaIds:(0,E.getChangedParagraphIds)(l),structuralChange:(0,E.hasStructuralChanges)(l),hasUntrackedChanges:(0,E.hasUntrackedChanges)(l),maxBytes:m.selectiveSaveMaxBytes})}let y=g?te:null,x=null,S=()=>(0,E.repackWithEditorSectionRemovals)({state:l,document:d,repack:()=>ee(d)});if(!y)x=h?await S():await v(d),y=x;else if(m.selectiveSaveTripwire)try{x=await S()}catch{}if(m.selectiveSaveTripwire&&x&&N)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);N(await e(te,x))}catch{}return{buffer:y,document:d}}async function Ft(e){let t=L.value,n=t?.state,r=await Pt({mode:e?.selective===!1?p.FOLIO_DOCX_SERIALIZATION_MODE.full:p.FOLIO_DOCX_SERIALIZATION_MODE.preferSelective});return r?(L.value===t&&t?.state.doc===n?.doc&&(r.version===void 0||$.api.isCanonicalSaveCurrent(r.version))&&(P.value=r.document,X(),U.value=!1),new Blob([r.buffer],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})):null}function It(){let e=$.api.getCanonicalDocument();if(e)return e;if(W())return null;let t=P.value;if(!t)return null;let n=$.api.getDocument()??t;return tt(Y.snapshotDocument(J.snapshotDocument(n)))}function Lt(e){rt(c.CANONICAL_GAP.modelEdits,`Direct document model changes are unavailable in this session.`)||(P.value=e,X(),V.value&&!Y.getView(V.value)&&(V.value=null))}function Rt(e){return J.getView(e)}function zt(){X()}function Bt(e){let t=Y.activate(e);t&&(Dt(t),V.value=e,requestAnimationFrame(()=>t.focus()))}function Vt(){Y.activate(null),V.value=null}function Ht(){let e=V.value;return e?Y.getView(e):null}function Ut(){return G.getCommands()}function Wt(){let e=Ht();e?e.focus():L.value?.focus()}function Gt(){let e=L.value;e&&Z(e.state,{reason:`manual`})}(0,e.watch)([()=>(0,e.toValue)(A),()=>(0,e.toValue)(ve),()=>(0,e.toValue)(he),()=>(0,e.toValue)(ge),()=>(0,e.toValue)(k),()=>(0,e.toValue)(_e)],()=>Gt());function Kt(){Je=!0,w.value&&(0,T.releaseDisplayPageResources)(w.value),Ye+=1,I=!1,vt.dispose(),Q!==null&&(window.clearTimeout(Q),Q=null),$.destroyView(),B.value=[],J.destroy(),Y.destroy(),G.destroy(),R.value=null,Ze.value=null,P.value=null,et.value=!1}return(0,e.onScopeDispose)(Kt),{setEmbeddedFontFamilies:e=>{e?pt.embeddedFontFamilyMap=new Map(e):delete pt.embeddedFontFamilyMap},editor:Et,editorView:L,editorState:R,remoteSelections:B,headerFooterSelection:Xe,activeNoteStory:V,isReady:et,isDirty:U,parseError:H,layout:Ze,blocks:Qe,measures:$e,syncCoordinator:q,loadBuffer:Mt,loadDocument:Nt,save:Ft,getDocument:It,setDocument:Lt,getHeaderFooterView:Rt,syncHeaderFooterViews:zt,openNoteStory:Bt,closeNoteStory:Vt,getActiveNoteView:Ht,getCommands:Ut,focus:Wt,reLayout:Gt,destroy:Kt}}function Re({editorView:t,pagesRef:n,getDocument:r,layout:a,commentRoot:o,revealComment:s,displayMode:c,readOnly:l,onReadonlyEditAttempt:u,onResultChange:d}){let f=new pe.FindReplaceManager,p=(0,e.ref)(``),m=(0,e.ref)(``),h=(0,e.reactive)((0,he.createDefaultFindOptions)()),g=(0,e.shallowRef)([]),_=(0,e.ref)(-1),ee=(0,e.computed)(()=>g.value.at(_.value)??null),v=()=>(0,i.getEditorReadOnlyReason)({editingMode:t.value?.editable===!1?`viewing`:`editing`,readOnlyProp:l.value,displayMode:c.value}),te=(0,e.computed)(v),y=(0,e.computed)(()=>{let e=ee.value;return v()===null&&!!t.value&&!!e&&w()&&(0,he.replaceEligibility)(e).status===`allowed`}),b=null,x,S=null,C=e=>{let n=t.value?.state.doc;return{query:p.value,options:{...h,displayMode:c.value,includeComments:!!o},document:e,...n?{bodyVersion:n}:{},context:{renderedStories:(0,me.getRenderedSearchStories)(a.value)}}},w=()=>{let e=r();return!!e&&(0,ge.sameFindSearchKey)(S,(0,ge.createFindSearchKey)(C(e)))},ne=()=>f.getResult(),T=()=>d(ne()),re=()=>{clearTimeout(x),x=void 0},ie=()=>{re(),f.clear(),b?.destroy(),b=null,g.value=[],S=null,_.value=-1},ae=()=>{ie(),p.value=``,T()},E=e=>(_.value=e,b?.navigate(e,s),T(),!0),D=(e=`query`)=>{re();let i=r(),s=n.value,c=t.value?.state.doc;if(!i||!p.value.trim())return ae(),[];let l=C(i),u=(0,O.findInDisplayedDocument)({document:l.document,state:t.value?.state??null,searchText:l.query,options:l.options,context:l.context});if(u===null)return ie(),T(),[];let d=(0,ge.createFindSearchKey)(l),m=e===`refresh`&&S?.query===d.query,h=f.setMatches(u,m?f.getResult()?.currentIndex??0:0);return S=d,g.value=u,_.value=u.length>0?h.currentIndex:-1,b?.destroy(),b=s?(0,me.createFindMatchView)({container:s,document:i,bodyDoc:c,matches:u,commentRoot:o?.value??void 0,layout:a.value}):null,b?.paint(_.value),u.at(0)&&!m?E(0):T(),u},oe=()=>{re(),x=setTimeout(()=>D(`refresh`),120)},se=(e,t)=>(p.value=e,Object.assign(h,(0,he.createDefaultFindOptions)(),t),D(),ne()),ce=e=>{let t=f.goTo(e);return t?E(t.index):!1},le=e=>{let t=f.navigate(e);return t?(E(t.index),t.match):null},ue=()=>!w()&&(D(`refresh`),!0),de=()=>{let e=v();return e!==null&&(u?.(e),!0)};return(0,e.watch)(c,()=>{p.value.trim()&&D()}),(0,e.onScopeDispose)(()=>{re(),b?.destroy()}),{searchText:p,replaceText:m,options:h,matches:g,currentIndex:_,currentMatch:ee,canReplaceCurrent:y,replacementRefusal:te,performSearch:D,scheduleSearch:oe,find:se,getFindResult:ne,goToMatch:ce,findNext:()=>le(`next`),findPrevious:()=>le(`previous`),replaceCurrent:()=>{let e=t.value;if(!e||de()||ue())return!1;let n=ee.value;if(!y.value||!e||!n)return!1;if(n.text===m.value)return!0;let r=(0,O.resolveFindMatchRange)(e.state.doc,n);return r?(e.dispatch(e.state.tr.insertText(m.value,r.from,r.to)),D(`refresh`),!0):!1},replaceAll:()=>{let e=t.value,n=g.value.length;if(!e||de()||ue())return{replacedCount:0,skippedCount:n};let r=g.value.filter(e=>(0,he.replaceEligibility)(e).status===`allowed`),i=r.filter(e=>e.text===m.value).length,a=r.filter(e=>e.text!==m.value).flatMap(t=>{let n=(0,O.resolveFindMatchRange)(e.state.doc,t);return n?[n]:[]}).toSorted((e,t)=>t.from-e.from),o=a.length+i,s={replacedCount:o,skippedCount:n-o};if(!a.length)return s;let c=e.state.tr;for(let e of a)c=c.insertText(m.value,e.from,e.to);return e.dispatch(c),D(),s},clear:ae}}function M(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 ze({pagesContainer:t,onScrollExtendSelection:n}){let r=null,i=0,o=0,s=!1;function c(){return(0,a.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=M(e.getBoundingClientRect(),o);t!==0&&((0,a.scrollEditorBy)(e,t),n(i,o)),r=requestAnimationFrame(u)}function d(){s||(s=!0,r=requestAnimationFrame(u))}function f(e,t){if(i=e,o=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 Be({runCommand:e}){let t={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidths:{left:0,right:0}},n={active:!1,startY:0,handle:null,rowIndex:0,isEdge:!1,tablePmStart:0,origHeight:0,minimumHeight:k.MIN_ROW_HEIGHT_TWIPS},r={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidth:0},i=null;function a(){return t.active||n.active||r.active}function o(e,a){let o=e.target;return o instanceof HTMLElement?o.classList.contains(`layout-table-resize-handle`)?(e.preventDefault(),e.stopPropagation(),i=a,t.active=!0,t.startX=e.clientX,t.handle=o,o.classList.add(`dragging`),t.columnIndex=parseInt(o.dataset.columnIndex??`0`,10),t.tablePmStart=(0,l.readPaintedTableStart)(o)??0,Ve(a,t),!0):o.classList.contains(`layout-table-row-resize-handle`)||o.classList.contains(`layout-table-edge-handle-bottom`)?(e.preventDefault(),e.stopPropagation(),i=a,n.active=!0,n.startY=e.clientY,n.handle=o,n.isEdge=o.dataset.isEdge===`bottom`,o.classList.add(`dragging`),n.rowIndex=parseInt(o.dataset.rowIndex??`0`,10),n.tablePmStart=(0,l.readPaintedTableStart)(o)??0,He(a,n,o),!0):o.classList.contains(`layout-table-edge-handle-right`)?(e.preventDefault(),e.stopPropagation(),i=a,r.active=!0,r.startX=e.clientX,r.handle=o,o.classList.add(`dragging`),r.columnIndex=parseInt(o.dataset.columnIndex??`0`,10),r.tablePmStart=(0,l.readPaintedTableStart)(o)??0,Ue(a,r),!0):!1:!1}function s(e){if(t.active&&t.handle){e.preventDefault();let n=e.clientX-t.startX,r=parseFloat(t.handle.style.left);t.handle.style.left=`${r+n}px`,t.startX=e.clientX;let i=Math.round(n*k.TWIPS_PER_PIXEL),a=t.origWidths.left+i,o=t.origWidths.right-i;a>=k.MIN_CELL_WIDTH_TWIPS&&o>=k.MIN_CELL_WIDTH_TWIPS&&(t.origWidths={left:a,right:o})}else if(n.active&&n.handle){e.preventDefault();let t=e.clientY-n.startY,r=parseFloat(n.handle.style.top);n.startY=e.clientY;let i=Math.round(t*k.TWIPS_PER_PIXEL),a=(0,k.clampRowResizeDelta)({currentHeight:n.origHeight,delta:i,minimumHeight:n.minimumHeight});n.handle.style.top=`${r+a/k.TWIPS_PER_PIXEL}px`,n.origHeight+=a}else if(r.active&&r.handle){e.preventDefault();let t=e.clientX-r.startX,n=parseFloat(r.handle.style.left);r.handle.style.left=`${n+t}px`,r.startX=e.clientX;let i=Math.round(t*k.TWIPS_PER_PIXEL),a=r.origWidth+i;a>=k.MIN_CELL_WIDTH_TWIPS&&(r.origWidth=a)}}function c(a){t.active?(t.active=!1,t.handle?.classList.remove(`dragging`),i&&e(i,(0,k.columnResizeCommand)({pmStart:t.tablePmStart,colIdx:t.columnIndex,newLeft:t.origWidths.left,newRight:t.origWidths.right})),t.handle=null):n.active?(n.active=!1,n.handle?.classList.remove(`dragging`),i&&e(i,(0,k.rowResizeCommand)({pmStart:n.tablePmStart,rowIdx:n.rowIndex,newHeight:n.origHeight})),n.handle=null):r.active&&(r.active=!1,r.handle?.classList.remove(`dragging`),i&&e(i,(0,k.rightEdgeResizeCommand)({pmStart:r.tablePmStart,colIdx:r.columnIndex,newWidth:r.origWidth})),r.handle=null)}function u(){return document.addEventListener(`mousemove`,s),document.addEventListener(`mouseup`,c),()=>{document.removeEventListener(`mousemove`,s),document.removeEventListener(`mouseup`,c)}}return{tryStartResize:o,install:u,isResizing:a}}function Ve(e,t){let n=(0,k.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function He(e,t,n){let r=(0,k.readRowHeight)(e,t.tablePmStart,t.rowIndex);if(r!=null)t.origHeight=r;else{let e=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),r=e?e.getBoundingClientRect().height:30;t.origHeight=Math.round(r*k.TWIPS_PER_PIXEL)}t.minimumHeight=Math.min(k.MIN_ROW_HEIGHT_TWIPS,t.origHeight)}function Ue(e,t){let n=(0,k.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function We(t,n){return(0,e.computed)(()=>{n.value;let e=t.value?.state??null,r=(0,_e.extractTrackedChanges)(e);if(e===null)return r;let i={accept:(0,u.lockHeldRevisions)(e,`accept`),reject:(0,u.lockHeldRevisions)(e,`reject`)};if(i.accept.size===0&&i.reject.size===0)return r;let a=r.entries;for(let e of a){let t=(0,u.trackedChangeEntryRevisionIds)(e);e.heldByLock={accept:t.some(e=>i.accept.has(e)),reject:t.some(e=>i.reject.has(e))}}return{...r,entries:a}})}var Ge=A.ZOOM_MIN,N=A.ZOOM_MAX,Ke=[.5,.75,1,1.25,1.5,2];function qe(t=1){let n=(0,e.ref)(Math.max(Ge,Math.min(N,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=Ge),a=(0,e.computed)(()=>n.value>=N);function o(e){n.value=Math.max(Ge,Math.min(N,Math.round(e*100)/100))}function s(){o(n.value+A.ZOOM_STEP)}function c(){o(n.value-A.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:Ke}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Te}});
|