@stll/folio-vue 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { A as e, F as t, O as n, P as r, _ as i, d as a, f as o, g as s, j as c, k as l, m as u, p as d, u as f, y as p } from "./WatermarkDialog-r4wmldt4.js";
2
2
  import { D as m, E as h, d as g, f as _, i as v, n as y, r as b, t as x, v as ee, w as S, y as te } from "./ListButtons-DXqMvba3.js";
3
3
  import { t as ne } from "./zIndex-BY0qa8Au.js";
4
- import { a as re, i as ie, o as C, r as ae, t as oe } from "./useZoom-BxDANpqb.js";
4
+ import { a as re, i as ie, o as C, r as ae, t as oe } from "./useZoom-zJvuJlUd.js";
5
5
  import { FindReplaceDialog as w, FootnotePropertiesDialog as T, HyperlinkDialog as se, ImagePositionDialog as ce, ImagePropertiesDialog as le, InsertImageDialog as E, InsertSymbolDialog as D, InsertTableDialog as ue, PageSetupDialog as de, PasteSpecialDialog as fe, SplitCellDialog as O, TablePropertiesDialog as k, WatermarkDialog as A } from "./dialogs.js";
6
6
  import { Fragment as j, Teleport as M, computed as N, createApp as pe, createBlock as P, createCommentVNode as F, createElementBlock as I, createElementVNode as L, createSlots as me, createStaticVNode as he, createTextVNode as ge, createVNode as R, defineComponent as z, h as B, inject as _e, mergeProps as ve, nextTick as ye, normalizeClass as V, normalizeStyle as H, onBeforeUnmount as be, onMounted as xe, openBlock as U, provide as Se, ref as W, renderList as G, renderSlot as Ce, shallowRef as we, toDisplayString as K, unref as q, vModelText as Te, watch as J, withCtx as Ee, withDirectives as De, withKeys as Oe, withModifiers as Y } from "vue";
7
7
  import { createStyleResolver as ke, extractSelectionState as Ae, getSelectedText as je, insertImageFromFile as Me, insertImageFromFile as Ne, insertPageBreakInView as Pe, insertPageBreakInView as Fe, insertTableInView as X, insertTableInView as Ie, insertTableOfContentsInView as Le, insertTableOfContentsInView as Re } from "@stll/folio-core/prosemirror";
@@ -29,10 +29,10 @@ import { createComment as Dt } from "@stll/folio-core/prosemirror/commentOps";
29
29
  import { findChangeRange as Ot } from "@stll/folio-core/prosemirror/queries";
30
30
  import { acceptAIEditRevision as kt, acceptChange as At, findAIEditRevisionRange as jt, rejectAIEditRevision as Mt, rejectChange as Nt } from "@stll/folio-core/prosemirror/commands/comments";
31
31
  import { makeRevisionInfo as Pt } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
32
- import { setTemplatePreviewValues as Ft } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
33
- import { clearTemplateSlashMenu as It, consumeTemplateSlashQuery as Lt, getTemplateSlashMenu as Rt, resetTemplateSlashQuery as Q, templateSlashMenuKey as zt } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
34
- import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION as $, applyFolioAIEditOperations as Bt, applyFolioAIEditOperations as Vt, applyFolioDocumentOperations as Ht, assertSupportedFolioDocumentOperationVersion as Ut, createFolioAIEditSnapshot as Wt, createFolioAIEditSnapshot as Gt, diffWordSegments as Kt, getCommentAnchorsFromDoc as qt, getFolioDocumentOperationIssues as Jt, getTrackedChangesFromDoc as Yt, hashFolioAIBlockText as Xt, normalizeFolioAIBlockText as Zt } from "@stll/folio-core/ai-edits";
35
- import { findPageIndexContainingPmPos as Qt } from "@stll/folio-core/layout-engine";
32
+ import { findPageIndexContainingPmPos as Ft } from "@stll/folio-core/layout-engine";
33
+ import { setTemplatePreviewValues as It } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
34
+ import { clearTemplateSlashMenu as Lt, consumeTemplateSlashQuery as Rt, getTemplateSlashMenu as Q, resetTemplateSlashQuery as zt, templateSlashMenuKey as $ } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
35
+ import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION as Bt, applyFolioAIEditOperations as Vt, applyFolioAIEditOperations as Ht, applyFolioDocumentOperations as Ut, assertSupportedFolioDocumentOperationVersion as Wt, createFolioAIEditSnapshot as Gt, createFolioAIEditSnapshot as Kt, diffWordSegments as qt, getCommentAnchorsFromDoc as Jt, getFolioDocumentOperationIssues as Yt, getTrackedChangesFromDoc as Xt, hashFolioAIBlockText as Zt, normalizeFolioAIBlockText as Qt } from "@stll/folio-core/ai-edits";
36
36
  import { findParagraphFragmentsByParaId as $t, flashParagraphElements as en } from "@stll/folio-core/paged-layout/paragraphFlash";
37
37
  import { blockSdtAttrsToSdtProperties as tn, findBlockSdtMatch as nn, findBlockSdtMatches as rn, removeContentControlTr as an, setContentControlContentTr as on, setContentControlValueTr as sn } from "@stll/folio-core/prosemirror/commands/contentControls";
38
38
  import { setContentControlContentBlocksTr as cn } from "@stll/folio-core/prosemirror/commands/contentControlsBlockFill";
@@ -2112,7 +2112,7 @@ function Ji(e) {
2112
2112
  getPageNumberForPmPos: (t) => {
2113
2113
  let n = e.layout.value;
2114
2114
  if (!n) return null;
2115
- let r = Qt(n, t);
2115
+ let r = Ft(n, t);
2116
2116
  return r == null ? null : r + 1;
2117
2117
  }
2118
2118
  }, o;
@@ -2123,7 +2123,7 @@ function Ji(e) {
2123
2123
  function l() {
2124
2124
  let t = e.layout.value, n = e.editorView.value;
2125
2125
  if (!t || !n) return 0;
2126
- let r = Qt(t, n.state.selection.from);
2126
+ let r = Ft(t, n.state.selection.from);
2127
2127
  return r == null ? 0 : r + 1;
2128
2128
  }
2129
2129
  function u(t) {
@@ -2156,10 +2156,10 @@ function Ji(e) {
2156
2156
  ensureEditorView: () => e.editor.ensureView(),
2157
2157
  createAIEditSnapshot: () => {
2158
2158
  let t = e.editorView.value;
2159
- return t ? Gt(t.state.doc) : null;
2159
+ return t ? Kt(t.state.doc) : null;
2160
2160
  },
2161
2161
  applyDocumentOperations: ({ snapshot: n, batch: r, author: i = e.author() }) => {
2162
- Ut(r.version);
2162
+ Wt(r.version);
2163
2163
  let a = e.editorView.value;
2164
2164
  if (!a) {
2165
2165
  let e = "committed";
@@ -2169,11 +2169,11 @@ function Ji(e) {
2169
2169
  reason: "unsupportedBlock"
2170
2170
  }));
2171
2171
  return {
2172
- version: $,
2172
+ version: Bt,
2173
2173
  status: e,
2174
2174
  applied: [],
2175
2175
  skipped: t,
2176
- issues: Jt(r.operations, t),
2176
+ issues: Yt(r.operations, t),
2177
2177
  receipts: [],
2178
2178
  undoHandle: null
2179
2179
  };
@@ -2185,7 +2185,7 @@ function Ji(e) {
2185
2185
  dispatch: (e) => {
2186
2186
  a.dispatch(xt(e)), c.state = a.state;
2187
2187
  }
2188
- }, l = Ht({
2188
+ }, l = Ut({
2189
2189
  view: c,
2190
2190
  snapshot: n,
2191
2191
  batch: r,
@@ -2231,7 +2231,7 @@ function Ji(e) {
2231
2231
  },
2232
2232
  applyAIEditOperations: ({ snapshot: t, operations: n, mode: r = "tracked-changes", author: i = e.author() }) => {
2233
2233
  let a = e.editorView.value;
2234
- return a ? Vt({
2234
+ return a ? Ht({
2235
2235
  view: a,
2236
2236
  snapshot: t,
2237
2237
  operations: n,
@@ -2276,13 +2276,14 @@ function Ji(e) {
2276
2276
  let { from: a, to: o } = i, s = r.state.doc.resolve(a), c = r.state.doc.resolve(o);
2277
2277
  return r.dispatch(r.state.tr.setSelection(Z.between(s, c))), requestAnimationFrame(() => e.scrollVisiblePositionIntoView(a)), !0;
2278
2278
  },
2279
+ showInDocument: () => !1,
2279
2280
  getTrackedChanges: () => {
2280
2281
  let t = e.editorView.value;
2281
- return t ? Yt(t.state.doc) : [];
2282
+ return t ? Xt(t.state.doc) : [];
2282
2283
  },
2283
2284
  getCommentAnchors: () => {
2284
2285
  let t = e.editorView.value;
2285
- return t ? qt(t.state.doc) : [];
2286
+ return t ? Jt(t.state.doc) : [];
2286
2287
  },
2287
2288
  getSelectionText: () => {
2288
2289
  let t = e.editorView.value;
@@ -2292,6 +2293,7 @@ function Ji(e) {
2292
2293
  let n = e.editorView.value;
2293
2294
  return n ? dn(e.layout.value, n.state.doc, t) : null;
2294
2295
  },
2296
+ getTargetPage: () => null,
2295
2297
  getContentControls: (t = {}) => {
2296
2298
  let n = e.editorView.value;
2297
2299
  return n ? rn(n.state.doc, t).map((e) => ({
@@ -4293,4 +4295,4 @@ var Ma = ["aria-label"], Na = ["aria-label"], Pa = [
4293
4295
  });
4294
4296
  };
4295
4297
  //#endregion
4296
- export { In as DEFAULT_AI_SUGGESTION_PRESETS, Yn as DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, Aa as DocxEditor, w as FindReplaceDialog, s as FolioUIProvider, T as FootnotePropertiesDialog, Ba as FormattingBar, se as HyperlinkDialog, ce as ImagePositionDialog, le as ImagePropertiesDialog, E as InsertImageDialog, D as InsertSymbolDialog, ue as InsertTableDialog, de as PageSetupDialog, fe as PasteSpecialDialog, O as SplitCellDialog, k as TablePropertiesDialog, A as WatermarkDialog, Ha as ZoomControl, Xn as acceptAutocompleteSuggestion, Zn as acceptAutocompleteWord, Je as anonymizationDecorationsKey, Qn as appendAutocompleteToken, Bt as applyFolioAIEditOperations, Ln as applySuggestions, $n as autocompleteSuggestionKey, er as autocompleteSuggestionPlugin, Bn as buildPositionalText, tr as clearAutocompleteSuggestion, It as clearTemplateSlashMenu, Lt as consumeTemplateSlashQuery, Kn as createAICitationDecorationsPlugin, jn as createDocx, An as createEmptyDocument, Wt as createFolioAIEditSnapshot, n as defaultLocale, Mn as deriveBlockId, Kt as diffWordSegments, nr as finishAutocompleteSuggestion, or as fromMarkdown, Ye as getAnonymizationMatches, rr as getAutocompleteSuggestion, On as getDocumentWatermark, Wn as getFolioCaretViewportRect, Nn as getFolioParaIdFromBlockId, Gn as getFolioSelectionViewportRect, vt as getTemplateDirectives, Rt as getTemplateSlashMenu, Xt as hashFolioAIBlockText, l as i18nPlugin, Me as insertImageFromFile, Pe as insertPageBreakInView, X as insertTableInView, Le as insertTableOfContentsInView, Pn as isFolioBlockId, Fn as isSequentialFolioBlockId, Rn as isSuggestionStale, Zt as normalizeFolioAIBlockText, e as provideLocale, Ua as renderAsync, Q as resetTemplateSlashQuery, zn as resolveSuggestionAnchor, bt as scanDirectives, Un as scrollFolioPositionIntoView, qn as setAICitationsMeta, Vn as setAISuggestionsMeta, Jn as setActiveCitationMeta, Ze as setAnonymizationTermsMeta, kn as setDocumentWatermark, Hn as setFocusedSuggestionMeta, Ft as setTemplatePreviewValues, ir as shouldTriggerAutocomplete, ar as startAutocompleteSuggestion, zt as templateSlashMenuKey, sr as toMarkdown, cr as toMarkdownResult, c as useTranslation, oe as useWheelZoom };
4298
+ export { In as DEFAULT_AI_SUGGESTION_PRESETS, Yn as DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, Aa as DocxEditor, w as FindReplaceDialog, s as FolioUIProvider, T as FootnotePropertiesDialog, Ba as FormattingBar, se as HyperlinkDialog, ce as ImagePositionDialog, le as ImagePropertiesDialog, E as InsertImageDialog, D as InsertSymbolDialog, ue as InsertTableDialog, de as PageSetupDialog, fe as PasteSpecialDialog, O as SplitCellDialog, k as TablePropertiesDialog, A as WatermarkDialog, Ha as ZoomControl, Xn as acceptAutocompleteSuggestion, Zn as acceptAutocompleteWord, Je as anonymizationDecorationsKey, Qn as appendAutocompleteToken, Vt as applyFolioAIEditOperations, Ln as applySuggestions, $n as autocompleteSuggestionKey, er as autocompleteSuggestionPlugin, Bn as buildPositionalText, tr as clearAutocompleteSuggestion, Lt as clearTemplateSlashMenu, Rt as consumeTemplateSlashQuery, Kn as createAICitationDecorationsPlugin, jn as createDocx, An as createEmptyDocument, Gt as createFolioAIEditSnapshot, n as defaultLocale, Mn as deriveBlockId, qt as diffWordSegments, nr as finishAutocompleteSuggestion, or as fromMarkdown, Ye as getAnonymizationMatches, rr as getAutocompleteSuggestion, On as getDocumentWatermark, Wn as getFolioCaretViewportRect, Nn as getFolioParaIdFromBlockId, Gn as getFolioSelectionViewportRect, vt as getTemplateDirectives, Q as getTemplateSlashMenu, Zt as hashFolioAIBlockText, l as i18nPlugin, Me as insertImageFromFile, Pe as insertPageBreakInView, X as insertTableInView, Le as insertTableOfContentsInView, Pn as isFolioBlockId, Fn as isSequentialFolioBlockId, Rn as isSuggestionStale, Qt as normalizeFolioAIBlockText, e as provideLocale, Ua as renderAsync, zt as resetTemplateSlashQuery, zn as resolveSuggestionAnchor, bt as scanDirectives, Un as scrollFolioPositionIntoView, qn as setAICitationsMeta, Vn as setAISuggestionsMeta, Jn as setActiveCitationMeta, Ze as setAnonymizationTermsMeta, kn as setDocumentWatermark, Hn as setFocusedSuggestionMeta, It as setTemplatePreviewValues, ir as shouldTriggerAutocomplete, ar as startAutocompleteSuggestion, $ as templateSlashMenuKey, sr as toMarkdown, cr as toMarkdownResult, c as useTranslation, oe as useWheelZoom };
@@ -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/templateDirectives"),i=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),a=require("@stll/folio-core/controller/folioEditor"),o=require("@stll/folio-core/controller/folioEditorEvents"),s=require("@stll/folio-core/controller/hiddenEditorManager"),c=require("@stll/folio-core/controller/layoutPipeline"),l=require("@stll/folio-core/controller/layoutScheduler"),u=require("@stll/folio-core/controller/layoutSession"),d=require("@stll/folio-core/docx/parser"),f=require("@stll/folio-core/docx/footnoteParser"),p=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),m=require("@stll/folio-core/layout-engine"),h=require("@stll/folio-core/layout-painter"),g=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),_=require("@stll/folio-core/paged-layout/transactionDirtyRange"),v=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),y=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),b=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),ee=require("@stll/folio-core/prosemirror/extensions/StarterKit"),te=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ne=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),x=require("@stll/folio-core/utils/findVerticalScrollParent"),S=require("@stll/folio-core/prosemirror/tableResize"),C=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),w=require("@stll/folio-core/utils/zoom");var re=24,ie=32,ae=96,oe=250,se=[];function ce(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}var T={hf:null,rId:null};function le(e,t){let n=e?.package;if(!n||!t)return{header:T,footer:T,firstHeader:T,firstFooter:T};let r=n.headers,i=n.footers,a=e=>e?r?.get(e)??null:null,o=e=>e?i?.get(e)??null:null,s=null,c=null;for(let e of t.headerReferences??[])e.type==="default"?s=e.rId:e.type===`first`&&(c=e.rId);let l=null,u=null;for(let e of t.footerReferences??[])e.type==="default"?l=e.rId:e.type===`first`&&(u=e.rId);return{header:{hf:a(s),rId:s},footer:{hf:o(l),rId:l},firstHeader:{hf:a(c),rId:c},firstFooter:{hf:o(u),rId:u}}}function ue(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,p.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,p.convertHeaderFooterToContent)(e,r,i,o)}function de(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=ue(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function fe(e,t,n){let r=new Map;if(!n||!n.package.footnotes)return r;let i=new Map;for(let e of n.package.footnotes)e.noteType&&e.noteType!==`normal`||i.set(e.id,e);for(let[n,a]of e){let e=[];for(let n of a){let r=i.get(n);if(!r)continue;let a=t.get(n),o=a?.displayNumber??0;e.push({displayNumber:String(o),text:(0,f.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var E=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function pe(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!E.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 me(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function D(f){let{hiddenContainer:p,pagesContainer:x,readOnly:S=!1,pageGap:C=re,documentKey:w,password:T,editorMode:E,author:D,externalPlugins:he=[],onAnonymizationMatchesChange:ge,showTemplateDirectives:_e,onSlashMenuChange:ve,onSlashMenuKeyAction:ye,onChange:be,onError:O,onSelectionUpdate:k,onEditorViewReady:A,onReadOnlyEditAttempt:j,featureFlags:M,onSelectiveSaveTripwire:N}=f,P=(0,e.shallowRef)(null),F=(0,e.shallowRef)(null),I=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),R=(0,e.shallowRef)([]),z=(0,e.shallowRef)([]),B=(0,e.ref)(!1),V=(0,e.ref)(null),H=(0,e.ref)(!1),U=new y.ExtensionManager((0,ee.createStarterKit)());U.buildSchema(),U.initializeRuntime();let xe=(0,i.createSuggestionModePlugin)(!1),Se=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>ge?.(e)}),W=(0,r.createTemplateDirectivesPlugin)(),G=(0,ne.templateSlashMenuPlugin)({onChange:e=>ve?.(e),onKeyAction:e=>ye?.(e)??!1}),Ce=(0,te.createTemplatePreviewValuesPlugin)(),K=()=>(0,e.toValue)(_e)===!0;function we(){return[xe,...he,Se,...K()?[W,G]:[],Ce]}let q=(0,o.createFolioEditorEmitter)(),J=new g.LayoutSelectionGate,Te=(0,u.createLayoutSession)(),Ee=new h.LayoutPainter({pageGap:C,showShadow:!0});function De(e){e.layout&&(L.value=e.layout),e.blocks&&(R.value=e.blocks),e.measures&&(z.value=e.measures),e.blockLookup&&Ee.setBlockLookup(e.blockLookup),e.layout&&q.emit(`layoutComplete`,e.layout)}function Y(e,n={}){let r=x.value,i=r instanceof HTMLDivElement?r:null,a=P.value,o=a?.package.document,s=o?.sections?.[0]?.properties??o?.finalSectionProperties??null,l=(0,t.getPageSize)(s),u=(0,t.getMargins)(s),d=ce(s),f=l.w-u.left-u.right,p=a?.package.styles??null,h=a?.package.theme??null,g=a?.package.settings?.defaultTabStop,_=a?.package.settings,v=_!==void 0&&`mirrorMargins`in _&&_.mirrorMargins===!0,y=le(a,s);try{De((0,c.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:l,margins:u,pageGap:C,syncCoordinator:J,headerContent:y.header.hf,footerContent:y.footer.hf,firstPageHeaderContent:y.firstHeader.hf,firstPageFooterContent:y.firstFooter.hf,headerContentRId:y.header.rId,footerContentRId:y.footer.rId,firstPageHeaderContentRId:y.firstHeader.rId,firstPageFooterContentRId:y.firstFooter.rId,sectionHeaderFooterRefs:(0,m.resolveSectionHeaderFooterRefs)(a),theme:h,sectionProperties:s,document:a,defaultTabStop:g,mirrorMargins:v,styles:p,layout:L.value,hfPMs:null,painter:Ee,pagesContainer:i,session:Te,renderHfFromContentOrPm:ue,renderHeaderFooterContentByRId:de,documentFontsAreLoaded:me,buildFootnoteRenderItems:fe,describeInvalidHighlightMarks:pe,emptyTemplatePreviewEntries:se},e,n))}catch(e){let t=e instanceof Error?e:Error(String(e));O?.(t)}}let X=(0,l.createLayoutScheduler)({runLayout:(e,t)=>Y(e,t),debounceMs:ie,maxDelayMs:ae,clock:l.browserClock}),Z=null;function Oe(){Z!==null&&(window.clearTimeout(Z),Z=null);let e=F.value,t=P.value;if(!(!e||!t))try{let n=(0,v.fromProseDoc)(e.state.doc,t);P.value=n,be?.(n),q.emit(`docChange`,n)}catch(e){O?.(e instanceof Error?e:Error(String(e)))}}function ke(){Z!==null&&window.clearTimeout(Z),Z=window.setTimeout(()=>{Z=null,Oe()},oe)}let Q=(0,s.createHiddenEditorManager)({getHost:()=>p.value,getDocument:()=>P.value,getStyles:()=>P.value?.package.styles??null,getExtensionManager:()=>U,getExternalPlugins:we,getCollaboration:()=>void 0,getCollaborationModules:()=>null,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(S),getDocumentKey:()=>(0,e.toValue)(w),getDocumentContext:()=>P.value,onTransaction:Ae,onSelectionChange:e=>{I.value=e,k?.(e),q.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onReadOnlyEditAttempt:()=>j?.(),onEditorViewReady:je,onEditorViewDestroy:()=>{F.value=null,B.value=!1,A?.(null)},onRemoteSelectionsChange:()=>{}});function Ae(e,t){I.value=t,e.docChanged&&(H.value=!0,J.incrementStateSeq(),X.schedule(t,(0,_.getTransactionDirtyRange)(e)),ke()),J.requestRender()}function je(t){F.value=t,I.value=t.state,B.value=!0,Y(t.state,{reason:`initial`}),J.requestRender(),Ne(t),A?.(t),(0,e.toValue)(S)||requestAnimationFrame(()=>{F.value===t&&t.focus()})}let Me=(0,a.createFolioEditor)({getEditorApi:()=>Q.api,getLayout:()=>L.value,runLayout:(e,t)=>Y(e,t),emitter:q});function Ne(t){(0,i.setSuggestionMode)((0,e.toValue)(E)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(D))}(0,e.watch)([()=>(0,e.toValue)(E),()=>(0,e.toValue)(D)],()=>{let e=F.value;e&&Ne(e)}),(0,e.watch)(()=>(0,e.toValue)(S),()=>Q.syncEditable());function Pe(e){let t=K();if(t===e.state.plugins.includes(W))return;let n=e.state.plugins.filter(e=>e!==W&&e!==G);if(t){let e=n.indexOf(Ce),t=e===-1?n.length:e;n.splice(t,0,W,G)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>K(),()=>{let e=F.value;e&&Pe(e)});function Fe(){Q.ensureView()}function Ie(){H.value=!1,X.dispose(),Q.destroyView(),Q.ensureView(),Q.getView()||Le()}function Le(){let e=P.value;if(e)try{let t=(0,s.createHiddenEditorState)({document:e,styles:e.package.styles??null,manager:U,externalPlugins:we(),collaborationModules:null,reason:`mount`});I.value=t,Y(t,{reason:`initial`})}catch(e){O?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([p,x],()=>{p.value&&P.value&&!Q.getView()&&Fe()},{flush:`post`});async function Re(t){V.value=null,B.value=!1;try{let n=await(0,d.parseDocx)(t,{password:(0,e.toValue)(T)});P.value=n,Ie()}catch(e){let t=e instanceof Error?e:Error(String(e));V.value=t.message,O?.(t)}}function ze(e){V.value=null,P.value=e,Ie()}async function Be(t){let n=F.value,r=P.value;if(!n||!r)return null;let i=n.state,{resolveSelectiveSaveFlags:a}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),o=a((0,e.toValue)(M)),s=(0,v.fromProseDoc)(i.doc,r),c=s.originalBuffer??null,l=o.selectiveSave&&t?.selective!==!1,u=l||o.selectiveSaveTripwire,{repackDocx:d,createDocx:f}=await import(`@stll/folio-core/docx/rezip`),p=null;if(u&&c){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);p=await e(s,c,{changedParaIds:(0,b.getChangedParagraphIds)(i),structuralChange:(0,b.hasStructuralChanges)(i),hasUntrackedChanges:(0,b.hasUntrackedChanges)(i),maxBytes:o.selectiveSaveMaxBytes})}let m=l?p:null,h=null;if(!m)h=c?await d(s):await f(s),m=h;else if(o.selectiveSaveTripwire)try{h=await d(s)}catch{}if(o.selectiveSaveTripwire&&h&&N)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);N(await e(p,h))}catch{}return H.value=!1,new Blob([m],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Ve(){return P.value}function He(e){P.value=e}function Ue(){return U.getCommands()}function We(){F.value?.focus()}function Ge(){let e=F.value;e&&Y(e.state,{reason:`manual`})}function $(){X.dispose(),Z!==null&&(window.clearTimeout(Z),Z=null),Q.destroyView(),U.destroy(),I.value=null,L.value=null,P.value=null,B.value=!1}return(0,e.onScopeDispose)($),{editor:Me,editorView:F,editorState:I,isReady:B,isDirty:H,parseError:V,layout:L,blocks:R,measures:z,loadBuffer:Re,loadDocument:ze,save:Be,getDocument:Ve,setDocument:He,getCommands:Ue,focus:We,reLayout:Ge,destroy:$}}function he(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 ge({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,x.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=he(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),ve(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),ye(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*S.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=S.MIN_CELL_WIDTH_TWIPS&&o>=S.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*S.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=S.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*S.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=S.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,S.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,S.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,S.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 ve(e,t){let n=(0,S.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function ye(e,t,n){let r=(0,S.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*S.TWIPS_PER_PIXEL)}function be(e,t){let n=(0,S.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function O(t,n){return(0,e.computed)(()=>(n.value,(0,C.extractTrackedChanges)(t.value?.state??null)))}var k=w.ZOOM_MIN,A=w.ZOOM_MAX,j=[.5,.75,1,1.25,1.5,2];function M(t=1){let n=(0,e.ref)(Math.max(k,Math.min(A,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=k),a=(0,e.computed)(()=>n.value>=A);function o(e){n.value=Math.max(k,Math.min(A,Math.round(e*100)/100))}function s(){o(n.value+w.ZOOM_STEP)}function c(){o(n.value-w.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:j}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return M}});