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