@stll/folio-vue
Advanced tools
| import { Ref } from 'vue'; | ||
| import { HiddenProseMirrorRemoteSelection } from '@stll/folio-core/controller/hiddenEditorManager'; | ||
| import { LayoutSelectionGate } from '@stll/folio-core/paged-layout/LayoutSelectionGate'; | ||
| export type UseRemoteSelectionSyncOptions = { | ||
| pagesRef: Ref<HTMLElement | null>; | ||
| remoteSelections: Ref<HiddenProseMirrorRemoteSelection[]>; | ||
| syncCoordinator: LayoutSelectionGate; | ||
| zoom: Ref<number>; | ||
| }; | ||
| export declare const useRemoteSelectionSync: (options: UseRemoteSelectionSyncOptions) => void; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { computed as e, reactive as t, ref as n, shallowRef as r } from "vue"; | ||
| import { TextSelection as i } from "prosemirror-state"; | ||
| import { FindReplaceManager as a } from "@stll/folio-core/managers/FindReplaceManager"; | ||
| import { findInProseMirrorDocument as o } from "@stll/folio-core/prosemirror/findReplaceSelection"; | ||
| import { createDefaultFindOptions as s } from "@stll/folio-core/utils/findReplace"; | ||
| //#region src/composables/useFindReplace.ts | ||
| function c({ editorView: i, scrollVisiblePositionIntoView: c }) { | ||
| let u = new a(), d = n(""), f = n(""), p = t(s()), m = r([]), h = n(-1), g = e(() => m.value.at(h.value) ?? null), _ = () => { | ||
| u.clear(), m.value = [], h.value = -1; | ||
| }, v = (e, t) => { | ||
| let n = i.value; | ||
| return !n || e.to > n.state.doc.content.size ? !1 : (h.value = t, n.dispatch(n.state.tr.setSelection(l(n, e))), c?.(e.from), !0); | ||
| }, y = () => { | ||
| let e = i.value; | ||
| if (!e || !d.value.trim()) return _(), []; | ||
| let t = o(e.state.doc, d.value, p); | ||
| u.setMatches(t), m.value = t, h.value = t.length > 0 ? 0 : -1; | ||
| let n = t.at(0); | ||
| return n && v(n, 0), t; | ||
| }, b = (e) => { | ||
| let t = u.goTo(e); | ||
| return t ? v(t.match, t.index) : !1; | ||
| }, x = (e) => { | ||
| let t = u.navigate(e); | ||
| return !t || !v(t.match, t.index) ? null : t.match; | ||
| }; | ||
| return { | ||
| searchText: d, | ||
| replaceText: f, | ||
| options: p, | ||
| matches: m, | ||
| currentIndex: h, | ||
| currentMatch: g, | ||
| performSearch: y, | ||
| goToMatch: b, | ||
| findNext: () => x("next"), | ||
| findPrevious: () => x("previous"), | ||
| replaceCurrent: () => { | ||
| let e = i.value, t = g.value; | ||
| return !e || !t || t.to > e.state.doc.content.size ? !1 : (e.dispatch(e.state.tr.insertText(f.value, t.from, t.to)), y(), !0); | ||
| }, | ||
| replaceAll: () => { | ||
| let e = i.value; | ||
| if (!e || m.value.length === 0) return 0; | ||
| let t = e.state.tr, n = [...m.value].toSorted((e, t) => t.from - e.from); | ||
| for (let e of n) t = t.insertText(f.value, e.from, e.to); | ||
| e.dispatch(t); | ||
| let r = n.length; | ||
| return y(), r; | ||
| }, | ||
| clear: _ | ||
| }; | ||
| } | ||
| var l = (e, t) => { | ||
| let n = e.state.doc.resolve(t.from), r = e.state.doc.resolve(t.to); | ||
| return i.between(n, r); | ||
| }; | ||
| //#endregion | ||
| export { c as t }; |
| let e=require("vue"),t=require("prosemirror-state"),n=require("@stll/folio-core/managers/FindReplaceManager"),r=require("@stll/folio-core/prosemirror/findReplaceSelection"),i=require("@stll/folio-core/utils/findReplace");function a({editorView:t,scrollVisiblePositionIntoView:a}){let s=new n.FindReplaceManager,c=(0,e.ref)(``),l=(0,e.ref)(``),u=(0,e.reactive)((0,i.createDefaultFindOptions)()),d=(0,e.shallowRef)([]),f=(0,e.ref)(-1),p=(0,e.computed)(()=>d.value.at(f.value)??null),m=()=>{s.clear(),d.value=[],f.value=-1},h=(e,n)=>{let r=t.value;return!r||e.to>r.state.doc.content.size?!1:(f.value=n,r.dispatch(r.state.tr.setSelection(o(r,e))),a?.(e.from),!0)},g=()=>{let e=t.value;if(!e||!c.value.trim())return m(),[];let n=(0,r.findInProseMirrorDocument)(e.state.doc,c.value,u);s.setMatches(n),d.value=n,f.value=n.length>0?0:-1;let i=n.at(0);return i&&h(i,0),n},_=e=>{let t=s.goTo(e);return t?h(t.match,t.index):!1},v=e=>{let t=s.navigate(e);return!t||!h(t.match,t.index)?null:t.match};return{searchText:c,replaceText:l,options:u,matches:d,currentIndex:f,currentMatch:p,performSearch:g,goToMatch:_,findNext:()=>v(`next`),findPrevious:()=>v(`previous`),replaceCurrent:()=>{let e=t.value,n=p.value;return!e||!n||n.to>e.state.doc.content.size?!1:(e.dispatch(e.state.tr.insertText(l.value,n.from,n.to)),g(),!0)},replaceAll:()=>{let e=t.value;if(!e||d.value.length===0)return 0;let n=e.state.tr,r=[...d.value].toSorted((e,t)=>t.from-e.from);for(let e of r)n=n.insertText(l.value,e.from,e.to);e.dispatch(n);let i=r.length;return g(),i},clear:m}}var o=(e,n)=>{let r=e.state.doc.resolve(n.from),i=e.state.doc.resolve(n.to);return t.TextSelection.between(r,i)};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}}); |
| 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/collaborationModules"),c=require("@stll/folio-core/controller/headerFooterEditorManager"),l=require("@stll/folio-core/controller/hiddenEditorManager"),u=require("@stll/folio-core/controller/layoutPipeline"),d=require("@stll/folio-core/controller/layoutScheduler"),f=require("@stll/folio-core/controller/layoutSession"),p=require("@stll/folio-core/docx/parser"),m=require("@stll/folio-core/docx/footnoteParser"),h=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),g=require("@stll/folio-core/layout-engine"),_=require("@stll/folio-core/layout-painter"),ee=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),v=require("@stll/folio-core/paged-layout/transactionDirtyRange"),y=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),te=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),b=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),ne=require("@stll/folio-core/prosemirror/extensions/StarterKit"),re=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ie=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),ae=require("@stll/folio-core/utils/headerFooter"),oe=require("@stll/folio-core/utils/findVerticalScrollParent"),x=require("@stll/folio-core/prosemirror/tableResize"),S=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),C=require("@stll/folio-core/utils/zoom");var se=24,ce=32,le=96,ue=250,de=[];function fe(e){let n=e?.columnCount??1;if(n<=1)return;let r={count:n,gap:(0,t.twipsToPixels)(e?.columnSpace??720),equalWidth:e?.equalWidth??!0};return e?.separator!==void 0&&(r.separator=e.separator),r}function pe(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,h.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,h.convertHeaderFooterToContent)(e,r,i,o)}function me(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=pe(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function he(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,m.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var ge=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function _e(e){let t=[],n=(e,r)=>{for(let[n,i]of e.marks.entries())i.type.name===`highlight`&&!ge.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 ve(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function ye(m){let{hiddenContainer:h,hiddenHeaderFooterContainer:oe,pagesContainer:x,readOnly:S=!1,pageGap:C=se,documentKey:ge,password:ye,editorMode:w,author:T,externalPlugins:be=[],collaboration:E,onAnonymizationMatchesChange:xe,showTemplateDirectives:Se,onSlashMenuChange:Ce,onSlashMenuKeyAction:D,onChange:O,onError:k,onSelectionUpdate:A,onEditorViewReady:we,onReadOnlyEditAttempt:Te,featureFlags:Ee,onSelectiveSaveTripwire:De}=m,Oe=oe??h,j=(0,e.shallowRef)(null),M=(0,e.shallowRef)(null),N=(0,e.shallowRef)(null),P=(0,e.shallowRef)(null),F=(0,e.shallowRef)([]),I=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),ke=(0,e.shallowRef)([]),Ae=(0,e.shallowRef)([]),R=(0,e.ref)(!1),z=(0,e.ref)(null),B=(0,e.ref)(!1),V=new te.ExtensionManager((0,ne.createStarterKit)());V.buildSchema(),V.initializeRuntime();let je=(0,i.createSuggestionModePlugin)(!1),Me=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>xe?.(e)}),H=(0,r.createTemplateDirectivesPlugin)(),U=(0,ie.templateSlashMenuPlugin)({onChange:e=>Ce?.(e),onKeyAction:e=>D?.(e)??!1}),Ne=(0,re.createTemplatePreviewValuesPlugin)(),W=()=>(0,e.toValue)(Se)===!0;function Pe(){return[je,...be,...(0,e.toValue)(E)?.plugins??[],Me,...W()?[H,U]:[],Ne]}let G=(0,o.createFolioEditorEmitter)(),K=new ee.LayoutSelectionGate,Fe=(0,f.createLayoutSession)(),Ie=new _.LayoutPainter({pageGap:C,showShadow:!0}),q=(0,c.createHeaderFooterEditorManager)({getHost:()=>Oe.value,getDocument:()=>j.value,getStyles:()=>j.value?.package.styles??null,getTheme:()=>j.value?.package.theme??null,onTransaction:({rId:e,kind:t,view:n,docChanged:r,selectionChanged:i})=>{if(r){B.value=!0;let e=M.value;e&&Y.schedule(e.state,null)}if(r||i){let{from:r,to:i}=n.state.selection;I.value={from:r,kind:t,rId:e,to:i},A?.(n.state),G.emit(`selectionChange`,{from:r,to:i})}K.requestRender()}});function Le(e){e.layout&&(L.value=e.layout),e.blocks&&(ke.value=e.blocks),e.measures&&(Ae.value=e.measures),e.blockLookup&&Ie.setBlockLookup(e.blockLookup),e.layout&&G.emit(`layoutComplete`,e.layout)}function J(e,n={}){let r=x.value,i=r instanceof HTMLDivElement?r:null,a=j.value,o=a?.package.document,s=o?.sections?.[0]?.properties??o?.finalSectionProperties??null,c=(0,t.getPageSize)(s),l=(0,t.getMargins)(s),d=fe(s),f=c.w-l.left-l.right,p=a?.package.styles??null,m=a?.package.theme??null,h=a?.package.settings?.defaultTabStop,_=a?.package.settings,ee=_!==void 0&&`mirrorMargins`in _&&_.mirrorMargins===!0,v=(0,ae.resolveHeaderFooterContent)(a?.package);try{Le((0,u.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:c,margins:l,pageGap:C,syncCoordinator:K,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,g.resolveSectionHeaderFooterRefs)(a),theme:m,sectionProperties:s,document:a,defaultTabStop:h,mirrorMargins:ee,styles:p,layout:L.value,hfPMs:q,painter:Ie,pagesContainer:i,session:Fe,renderHfFromContentOrPm:pe,renderHeaderFooterContentByRId:me,documentFontsAreLoaded:ve,buildFootnoteRenderItems:he,describeInvalidHighlightMarks:_e,emptyTemplatePreviewEntries:de},e,n))}catch(e){let t=e instanceof Error?e:Error(String(e));k?.(t)}}let Y=(0,d.createLayoutScheduler)({runLayout:(e,t)=>J(e,t),debounceMs:ce,maxDelayMs:le,clock:d.browserClock}),X=null;function Re(){X!==null&&(window.clearTimeout(X),X=null);let e=M.value,t=j.value;if(!(!e||!t))try{let n=(0,y.fromProseDoc)(e.state.doc,t);j.value=n,q.sync(),O?.(n),G.emit(`docChange`,n)}catch(e){k?.(e instanceof Error?e:Error(String(e)))}}function ze(){X!==null&&window.clearTimeout(X),X=window.setTimeout(()=>{X=null,Re()},ue)}let Z=(0,l.createHiddenEditorManager)({getHost:()=>h.value,getDocument:()=>j.value,getStyles:()=>j.value?.package.styles??null,getExtensionManager:()=>V,getExternalPlugins:Pe,getCollaboration:()=>(0,e.toValue)(E),getCollaborationModules:()=>P.value,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(S),getDocumentKey:()=>(0,e.toValue)(ge),getDocumentContext:()=>j.value,onTransaction:Be,onSelectionChange:e=>{N.value=e,A?.(e),G.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onReadOnlyEditAttempt:()=>Te?.(),onEditorViewReady:Ve,onEditorViewDestroy:()=>{M.value=null,R.value=!1,we?.(null)},onRemoteSelectionsChange:e=>{F.value=e}}),Q=()=>{let t=(0,e.toValue)(E)?.awareness,n=P.value,r=Z.getView();F.value=t&&n&&r?(0,l.collectRemoteSelections)(r.state,t,n):[]};(0,e.watch)(()=>(0,e.toValue)(E),(e,t,n)=>{if(F.value=[],!e){P.value=null,Z.retryViewCreation(),Z.syncExternalDocument();return}let r=!1;n(()=>{r=!0}),P.value=null,(0,s.loadCollaborationModules)().then(e=>{r||(P.value=e,Z.retryViewCreation(),Z.syncExternalDocument(),Q())},e=>{r||(P.value=null,k?.(e instanceof Error?e:Error(String(e))))})},{immediate:!0}),(0,e.watch)(()=>({awareness:(0,e.toValue)(E)?.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`,Q),Q(),i(()=>{e.off(`change`,Q),F.value=[]})},{flush:`post`});function Be(e,t){N.value=t,e.docChanged&&(B.value=!0,K.incrementStateSeq(),Y.schedule(t,(0,v.getTransactionDirtyRange)(e)),ze()),K.requestRender()}function Ve(t){M.value=t,N.value=t.state,R.value=!0,J(t.state,{reason:`initial`}),K.requestRender(),Ue(t),we?.(t),(0,e.toValue)(S)||requestAnimationFrame(()=>{M.value===t&&t.focus()})}let He=(0,a.createFolioEditor)({getEditorApi:()=>Z.api,getLayout:()=>L.value,runLayout:(e,t)=>J(e,t),emitter:G});function Ue(t){(0,i.setSuggestionMode)((0,e.toValue)(w)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(T))}(0,e.watch)([()=>(0,e.toValue)(w),()=>(0,e.toValue)(T)],()=>{let e=M.value;e&&Ue(e)}),(0,e.watch)(()=>(0,e.toValue)(S),()=>Z.syncEditable());function We(e){let t=W();if(t===e.state.plugins.includes(H))return;let n=e.state.plugins.filter(e=>e!==H&&e!==U);if(t){let e=n.indexOf(Ne),t=e===-1?n.length:e;n.splice(t,0,H,U)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>W(),()=>{let e=M.value;e&&We(e)});function Ge(){Z.ensureView()}function Ke(){B.value=!1,I.value=null,Y.dispose(),Z.destroyView(),q.sync(),Z.ensureView(),Z.getView()||qe()}function qe(){let t=j.value;if(!(!t||(0,e.toValue)(E)))try{let e=(0,l.createHiddenEditorState)({document:t,styles:t.package.styles??null,manager:V,externalPlugins:Pe(),collaborationModules:null,reason:`mount`});N.value=e,J(e,{reason:`initial`})}catch(e){k?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([h,x,Oe],()=>{h.value&&j.value&&!Z.getView()&&Ge(),q.sync()},{flush:`post`});async function Je(t){z.value=null,R.value=!1;try{let n=await(0,p.parseDocx)(t,{password:(0,e.toValue)(ye)});j.value=n,Ke()}catch(e){let t=e instanceof Error?e:Error(String(e));z.value=t.message,k?.(t)}}function Ye(e){z.value=null,j.value=e,Ke()}async function Xe(t){let n=M.value,r=j.value;if(!n||!r)return null;let i=q.snapshotDocument(r),a=n.state,{resolveSelectiveSaveFlags:o}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),s=o((0,e.toValue)(Ee)),c=(0,y.fromProseDoc)(a.doc,i),l=c.originalBuffer??null,u=s.selectiveSave&&t?.selective!==!1,d=u||s.selectiveSaveTripwire,{repackDocx:f,createDocx:p}=await import(`@stll/folio-core/docx/rezip`),m=null;if(d&&l){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);m=await e(c,l,{changedParaIds:(0,b.getChangedParagraphIds)(a),structuralChange:(0,b.hasStructuralChanges)(a),hasUntrackedChanges:(0,b.hasUntrackedChanges)(a),maxBytes:s.selectiveSaveMaxBytes})}let h=u?m:null,g=null;if(!h)g=l?await f(c):await p(c),h=g;else if(s.selectiveSaveTripwire)try{g=await f(c)}catch{}if(s.selectiveSaveTripwire&&g&&De)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);De(await e(m,g))}catch{}return j.value=c,q.sync(),B.value=!1,new Blob([h],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Ze(){let e=j.value;return e?q.snapshotDocument(e):null}function Qe(e){j.value=e,q.sync()}function $e(e){return q.getView(e)}function et(){q.sync()}function tt(){return V.getCommands()}function nt(){M.value?.focus()}function rt(){let e=M.value;e&&J(e.state,{reason:`manual`})}function $(){Y.dispose(),X!==null&&(window.clearTimeout(X),X=null),Z.destroyView(),F.value=[],q.destroy(),V.destroy(),N.value=null,L.value=null,j.value=null,R.value=!1}return(0,e.onScopeDispose)($),{editor:He,editorView:M,editorState:N,remoteSelections:F,headerFooterSelection:I,isReady:R,isDirty:B,parseError:z,layout:L,blocks:ke,measures:Ae,syncCoordinator:K,loadBuffer:Je,loadDocument:Ye,save:Xe,getDocument:Ze,setDocument:Qe,getHeaderFooterView:$e,syncHeaderFooterViews:et,getCommands:tt,focus:nt,reLayout:rt,destroy:$}}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 T({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,oe.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=w(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 be(){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),E(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),xe(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),Se(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*x.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=x.MIN_CELL_WIDTH_TWIPS&&o>=x.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*x.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=x.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*x.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=x.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,x.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,x.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,x.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 E(e,t){let n=(0,x.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function xe(e,t,n){let r=(0,x.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*x.TWIPS_PER_PIXEL)}function Se(e,t){let n=(0,x.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function Ce(t,n){return(0,e.computed)(()=>(n.value,(0,S.extractTrackedChanges)(t.value?.state??null)))}var D=C.ZOOM_MIN,O=C.ZOOM_MAX,k=[.5,.75,1,1.25,1.5,2];function A(t=1){let n=(0,e.ref)(Math.max(D,Math.min(O,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=D),a=(0,e.computed)(()=>n.value>=O);function o(e){n.value=Math.max(D,Math.min(O,Math.round(e*100)/100))}function s(){o(n.value+C.ZOOM_STEP)}function c(){o(n.value-C.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:k}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}}); |
| import { computed as e, onBeforeUnmount as t, onMounted as n, onScopeDispose as r, ref as i, shallowRef as a, toValue as o, watch as s } from "vue"; | ||
| import { getMargins as c, getPageSize as l, twipsToPixels as u } from "@stll/folio-core/paged-layout/sectionGeometry"; | ||
| import { createAnonymizationDecorationsPlugin as d } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations"; | ||
| import { createTemplateDirectivesPlugin as f } from "@stll/folio-core/prosemirror/plugins/templateDirectives"; | ||
| import { createSuggestionModePlugin as p, setSuggestionMode as m } from "@stll/folio-core/prosemirror/plugins/suggestionMode"; | ||
| import { createFolioEditor as h } from "@stll/folio-core/controller/folioEditor"; | ||
| import { createFolioEditorEmitter as g } from "@stll/folio-core/controller/folioEditorEvents"; | ||
| import { loadCollaborationModules as _ } from "@stll/folio-core/controller/collaborationModules"; | ||
| import { createHeaderFooterEditorManager as ee } from "@stll/folio-core/controller/headerFooterEditorManager"; | ||
| import { collectRemoteSelections as v, createHiddenEditorManager as te, createHiddenEditorState as ne } from "@stll/folio-core/controller/hiddenEditorManager"; | ||
| import { runLayoutPipeline as re } from "@stll/folio-core/controller/layoutPipeline"; | ||
| import { browserClock as ie, createLayoutScheduler as ae } from "@stll/folio-core/controller/layoutScheduler"; | ||
| import { createLayoutSession as oe } from "@stll/folio-core/controller/layoutSession"; | ||
| import { parseDocx as se } from "@stll/folio-core/docx/parser"; | ||
| import { getFootnoteText as y } from "@stll/folio-core/docx/footnoteParser"; | ||
| import { convertHeaderFooterPmDocToContent as b, convertHeaderFooterToContent as ce } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout"; | ||
| import { resolveSectionHeaderFooterRefs as le } from "@stll/folio-core/layout-engine"; | ||
| import { LayoutPainter as ue } from "@stll/folio-core/layout-painter"; | ||
| import { LayoutSelectionGate as de } from "@stll/folio-core/paged-layout/LayoutSelectionGate"; | ||
| import { getTransactionDirtyRange as fe } from "@stll/folio-core/paged-layout/transactionDirtyRange"; | ||
| import { fromProseDoc as pe } from "@stll/folio-core/prosemirror/conversion/fromProseDoc"; | ||
| import { ExtensionManager as me } from "@stll/folio-core/prosemirror/extensions/ExtensionManager"; | ||
| import { getChangedParagraphIds as he, hasStructuralChanges as ge, hasUntrackedChanges as _e } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"; | ||
| import { createStarterKit as ve } from "@stll/folio-core/prosemirror/extensions/StarterKit"; | ||
| import { createTemplatePreviewValuesPlugin as ye } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues"; | ||
| import { templateSlashMenuPlugin as be } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu"; | ||
| import { resolveHeaderFooterContent as xe } from "@stll/folio-core/utils/headerFooter"; | ||
| import { findVerticalScrollParent as Se } from "@stll/folio-core/utils/findVerticalScrollParent"; | ||
| import { MIN_CELL_WIDTH_TWIPS as x, MIN_ROW_HEIGHT_TWIPS as S, TWIPS_PER_PIXEL as C, commitColumnResize as w, commitRightEdgeResize as Ce, commitRowResize as we, readColumnWidthAt as Te, readColumnWidths as Ee, readRowHeight as De } from "@stll/folio-core/prosemirror/tableResize"; | ||
| import { extractTrackedChanges as T } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges"; | ||
| import { ZOOM_MAX as E, ZOOM_MIN as D, ZOOM_STEP as Oe } from "@stll/folio-core/utils/zoom"; | ||
| //#region src/composables/useDocxEditor.ts | ||
| var ke = 24, Ae = 32, je = 96, Me = 250, Ne = []; | ||
| function Pe(e) { | ||
| let t = e?.columnCount ?? 1; | ||
| if (t <= 1) return; | ||
| let n = { | ||
| count: t, | ||
| gap: u(e?.columnSpace ?? 720), | ||
| equalWidth: e?.equalWidth ?? !0 | ||
| }; | ||
| return e?.separator !== void 0 && (n.separator = e.separator), n; | ||
| } | ||
| function Fe(e, t, n, r, i, a) { | ||
| if (!e) return; | ||
| let o = t ? { | ||
| ...a, | ||
| rId: t | ||
| } : a, s = t ? n?.getView(t) : null; | ||
| return s ? b(s.state.doc, r, i, o) : ce(e, r, i, o); | ||
| } | ||
| function Ie(e, t, n, r, i) { | ||
| if (!e || e.size === 0) return; | ||
| let a = /* @__PURE__ */ new Map(); | ||
| for (let [o, s] of e) { | ||
| let e = Fe(s, o, t, n, r, i); | ||
| e && a.set(o, e); | ||
| } | ||
| return a.size > 0 ? a : void 0; | ||
| } | ||
| function Le(e, t, n) { | ||
| let r = /* @__PURE__ */ new Map(); | ||
| if (!n || !n.package.footnotes) return r; | ||
| let i = /* @__PURE__ */ 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: y(r), | ||
| ...a ? { content: { | ||
| blocks: a.blocks, | ||
| measures: a.measures, | ||
| height: a.height | ||
| } } : {} | ||
| }); | ||
| } | ||
| e.length > 0 && r.set(n, e); | ||
| } | ||
| return r; | ||
| } | ||
| var Re = /* @__PURE__ */ new Set([ | ||
| "black", | ||
| "blue", | ||
| "cyan", | ||
| "darkBlue", | ||
| "darkCyan", | ||
| "darkGray", | ||
| "darkGreen", | ||
| "darkMagenta", | ||
| "darkRed", | ||
| "darkYellow", | ||
| "green", | ||
| "lightGray", | ||
| "magenta", | ||
| "none", | ||
| "red", | ||
| "white", | ||
| "yellow" | ||
| ]); | ||
| function ze(e) { | ||
| let t = [], n = (e, r) => { | ||
| for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !Re.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 Be() { | ||
| return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded"; | ||
| } | ||
| function O(e) { | ||
| let { hiddenContainer: t, hiddenHeaderFooterContainer: n, pagesContainer: u, readOnly: y = !1, pageGap: b = ke, documentKey: ce, password: Se, editorMode: x, author: S, externalPlugins: C = [], collaboration: w, onAnonymizationMatchesChange: Ce, showTemplateDirectives: we, onSlashMenuChange: Te, onSlashMenuKeyAction: Ee, onChange: De, onError: T, onSelectionUpdate: E, onEditorViewReady: D, onReadOnlyEditAttempt: Oe, featureFlags: Re, onSelectiveSaveTripwire: O } = e, k = n ?? t, A = a(null), j = a(null), M = a(null), N = a(null), P = a([]), F = a(null), I = a(null), L = a([]), R = a([]), z = i(!1), B = i(null), V = i(!1), H = new me(ve()); | ||
| H.buildSchema(), H.initializeRuntime(); | ||
| let Ve = p(!1), He = d({ onMatchesChange: (e) => Ce?.(e) }), U = f(), W = be({ | ||
| onChange: (e) => Te?.(e), | ||
| onKeyAction: (e) => Ee?.(e) ?? !1 | ||
| }), Ue = ye(), G = () => o(we) === !0; | ||
| function We() { | ||
| return [ | ||
| Ve, | ||
| ...C, | ||
| ...o(w)?.plugins ?? [], | ||
| He, | ||
| ...G() ? [U, W] : [], | ||
| Ue | ||
| ]; | ||
| } | ||
| let K = g(), q = new de(), Ge = oe(), Ke = new ue({ | ||
| pageGap: b, | ||
| showShadow: !0 | ||
| }), J = ee({ | ||
| getHost: () => k.value, | ||
| getDocument: () => A.value, | ||
| getStyles: () => A.value?.package.styles ?? null, | ||
| getTheme: () => A.value?.package.theme ?? null, | ||
| onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => { | ||
| if (r) { | ||
| V.value = !0; | ||
| let e = j.value; | ||
| e && X.schedule(e.state, null); | ||
| } | ||
| if (r || i) { | ||
| let { from: r, to: i } = n.state.selection; | ||
| F.value = { | ||
| from: r, | ||
| kind: t, | ||
| rId: e, | ||
| to: i | ||
| }, E?.(n.state), K.emit("selectionChange", { | ||
| from: r, | ||
| to: i | ||
| }); | ||
| } | ||
| q.requestRender(); | ||
| } | ||
| }); | ||
| function qe(e) { | ||
| e.layout && (I.value = e.layout), e.blocks && (L.value = e.blocks), e.measures && (R.value = e.measures), e.blockLookup && Ke.setBlockLookup(e.blockLookup), e.layout && K.emit("layoutComplete", e.layout); | ||
| } | ||
| function Y(e, t = {}) { | ||
| let n = u.value, r = n instanceof HTMLDivElement ? n : null, i = A.value, a = i?.package.document, o = a?.sections?.[0]?.properties ?? a?.finalSectionProperties ?? null, s = l(o), d = c(o), f = Pe(o), p = s.w - d.left - d.right, m = i?.package.styles ?? null, h = i?.package.theme ?? null, g = i?.package.settings?.defaultTabStop, _ = i?.package.settings, ee = _ !== void 0 && "mirrorMargins" in _ && _.mirrorMargins === !0, v = xe(i?.package); | ||
| try { | ||
| qe(re({ | ||
| contentWidth: p, | ||
| columns: f, | ||
| pageSize: s, | ||
| margins: d, | ||
| pageGap: b, | ||
| 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: le(i), | ||
| theme: h, | ||
| sectionProperties: o, | ||
| document: i, | ||
| defaultTabStop: g, | ||
| mirrorMargins: ee, | ||
| styles: m, | ||
| layout: I.value, | ||
| hfPMs: J, | ||
| painter: Ke, | ||
| pagesContainer: r, | ||
| session: Ge, | ||
| renderHfFromContentOrPm: Fe, | ||
| renderHeaderFooterContentByRId: Ie, | ||
| documentFontsAreLoaded: Be, | ||
| buildFootnoteRenderItems: Le, | ||
| describeInvalidHighlightMarks: ze, | ||
| emptyTemplatePreviewEntries: Ne | ||
| }, e, t)); | ||
| } catch (e) { | ||
| let t = e instanceof Error ? e : Error(String(e)); | ||
| T?.(t); | ||
| } | ||
| } | ||
| let X = ae({ | ||
| runLayout: (e, t) => Y(e, t), | ||
| debounceMs: Ae, | ||
| maxDelayMs: je, | ||
| clock: ie | ||
| }), Z = null; | ||
| function Je() { | ||
| Z !== null && (window.clearTimeout(Z), Z = null); | ||
| let e = j.value, t = A.value; | ||
| if (!(!e || !t)) try { | ||
| let n = pe(e.state.doc, t); | ||
| A.value = n, J.sync(), De?.(n), K.emit("docChange", n); | ||
| } catch (e) { | ||
| T?.(e instanceof Error ? e : Error(String(e))); | ||
| } | ||
| } | ||
| function Ye() { | ||
| Z !== null && window.clearTimeout(Z), Z = window.setTimeout(() => { | ||
| Z = null, Je(); | ||
| }, Me); | ||
| } | ||
| let Q = te({ | ||
| getHost: () => t.value, | ||
| getDocument: () => A.value, | ||
| getStyles: () => A.value?.package.styles ?? null, | ||
| getExtensionManager: () => H, | ||
| getExternalPlugins: We, | ||
| getCollaboration: () => o(w), | ||
| getCollaborationModules: () => N.value, | ||
| getPrecomputedInitialState: () => null, | ||
| getReadOnly: () => o(y), | ||
| getDocumentKey: () => o(ce), | ||
| getDocumentContext: () => A.value, | ||
| onTransaction: Xe, | ||
| onSelectionChange: (e) => { | ||
| M.value = e, E?.(e), K.emit("selectionChange", { | ||
| from: e.selection.from, | ||
| to: e.selection.to | ||
| }); | ||
| }, | ||
| onKeyDown: () => !1, | ||
| onReadOnlyEditAttempt: () => Oe?.(), | ||
| onEditorViewReady: Ze, | ||
| onEditorViewDestroy: () => { | ||
| j.value = null, z.value = !1, D?.(null); | ||
| }, | ||
| onRemoteSelectionsChange: (e) => { | ||
| P.value = e; | ||
| } | ||
| }), $ = () => { | ||
| let e = o(w)?.awareness, t = N.value, n = Q.getView(); | ||
| P.value = e && t && n ? v(n.state, e, t) : []; | ||
| }; | ||
| s(() => o(w), (e, t, n) => { | ||
| if (P.value = [], !e) { | ||
| N.value = null, Q.retryViewCreation(), Q.syncExternalDocument(); | ||
| return; | ||
| } | ||
| let r = !1; | ||
| n(() => { | ||
| r = !0; | ||
| }), N.value = null, _().then((e) => { | ||
| r || (N.value = e, Q.retryViewCreation(), Q.syncExternalDocument(), $()); | ||
| }, (e) => { | ||
| r || (N.value = null, T?.(e instanceof Error ? e : Error(String(e)))); | ||
| }); | ||
| }, { immediate: !0 }), s(() => ({ | ||
| awareness: o(w)?.awareness, | ||
| modules: N.value, | ||
| view: j.value | ||
| }), ({ awareness: e, modules: t, view: n }, r, i) => { | ||
| if (!e || !t || !n) { | ||
| P.value = []; | ||
| return; | ||
| } | ||
| e.on("change", $), $(), i(() => { | ||
| e.off("change", $), P.value = []; | ||
| }); | ||
| }, { flush: "post" }); | ||
| function Xe(e, t) { | ||
| M.value = t, e.docChanged && (V.value = !0, q.incrementStateSeq(), X.schedule(t, fe(e)), Ye()), q.requestRender(); | ||
| } | ||
| function Ze(e) { | ||
| j.value = e, M.value = e.state, z.value = !0, Y(e.state, { reason: "initial" }), q.requestRender(), $e(e), D?.(e), o(y) || requestAnimationFrame(() => { | ||
| j.value === e && e.focus(); | ||
| }); | ||
| } | ||
| let Qe = h({ | ||
| getEditorApi: () => Q.api, | ||
| getLayout: () => I.value, | ||
| runLayout: (e, t) => Y(e, t), | ||
| emitter: K | ||
| }); | ||
| function $e(e) { | ||
| m(o(x) === "suggesting", e.state, e.dispatch, o(S)); | ||
| } | ||
| s([() => o(x), () => o(S)], () => { | ||
| let e = j.value; | ||
| e && $e(e); | ||
| }), s(() => o(y), () => Q.syncEditable()); | ||
| function et(e) { | ||
| let t = G(); | ||
| if (t === e.state.plugins.includes(U)) return; | ||
| let n = e.state.plugins.filter((e) => e !== U && e !== W); | ||
| if (t) { | ||
| let e = n.indexOf(Ue), t = e === -1 ? n.length : e; | ||
| n.splice(t, 0, U, W); | ||
| } | ||
| e.updateState(e.state.reconfigure({ plugins: n })); | ||
| } | ||
| s(() => G(), () => { | ||
| let e = j.value; | ||
| e && et(e); | ||
| }); | ||
| function tt() { | ||
| Q.ensureView(); | ||
| } | ||
| function nt() { | ||
| V.value = !1, F.value = null, X.dispose(), Q.destroyView(), J.sync(), Q.ensureView(), Q.getView() || rt(); | ||
| } | ||
| function rt() { | ||
| let e = A.value; | ||
| if (!(!e || o(w))) try { | ||
| let t = ne({ | ||
| document: e, | ||
| styles: e.package.styles ?? null, | ||
| manager: H, | ||
| externalPlugins: We(), | ||
| collaborationModules: null, | ||
| reason: "mount" | ||
| }); | ||
| M.value = t, Y(t, { reason: "initial" }); | ||
| } catch (e) { | ||
| T?.(e instanceof Error ? e : Error(String(e))); | ||
| } | ||
| } | ||
| s([ | ||
| t, | ||
| u, | ||
| k | ||
| ], () => { | ||
| t.value && A.value && !Q.getView() && tt(), J.sync(); | ||
| }, { flush: "post" }); | ||
| async function it(e) { | ||
| B.value = null, z.value = !1; | ||
| try { | ||
| let t = await se(e, { password: o(Se) }); | ||
| A.value = t, nt(); | ||
| } catch (e) { | ||
| let t = e instanceof Error ? e : Error(String(e)); | ||
| B.value = t.message, T?.(t); | ||
| } | ||
| } | ||
| function at(e) { | ||
| B.value = null, A.value = e, nt(); | ||
| } | ||
| async function ot(e) { | ||
| let t = j.value, n = A.value; | ||
| if (!t || !n) return null; | ||
| let r = J.snapshotDocument(n), i = t.state, { resolveSelectiveSaveFlags: a } = await import("@stll/folio-core/docx/selectiveSaveFlags"), s = a(o(Re)), c = pe(i.doc, r), l = c.originalBuffer ?? null, u = s.selectiveSave && e?.selective !== !1, d = u || s.selectiveSaveTripwire, { repackDocx: f, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null; | ||
| if (d && l) { | ||
| let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave"); | ||
| m = await e(c, l, { | ||
| changedParaIds: he(i), | ||
| structuralChange: ge(i), | ||
| hasUntrackedChanges: _e(i), | ||
| maxBytes: s.selectiveSaveMaxBytes | ||
| }); | ||
| } | ||
| let h = u ? m : null, g = null; | ||
| if (!h) g = l ? await f(c) : await p(c), h = g; | ||
| else if (s.selectiveSaveTripwire) try { | ||
| g = await f(c); | ||
| } catch {} | ||
| if (s.selectiveSaveTripwire && g && O) try { | ||
| let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire"); | ||
| O(await e(m, g)); | ||
| } catch {} | ||
| return A.value = c, J.sync(), V.value = !1, new Blob([h], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }); | ||
| } | ||
| function st() { | ||
| let e = A.value; | ||
| return e ? J.snapshotDocument(e) : null; | ||
| } | ||
| function ct(e) { | ||
| A.value = e, J.sync(); | ||
| } | ||
| function lt(e) { | ||
| return J.getView(e); | ||
| } | ||
| function ut() { | ||
| J.sync(); | ||
| } | ||
| function dt() { | ||
| return H.getCommands(); | ||
| } | ||
| function ft() { | ||
| j.value?.focus(); | ||
| } | ||
| function pt() { | ||
| let e = j.value; | ||
| e && Y(e.state, { reason: "manual" }); | ||
| } | ||
| function mt() { | ||
| X.dispose(), Z !== null && (window.clearTimeout(Z), Z = null), Q.destroyView(), P.value = [], J.destroy(), H.destroy(), M.value = null, I.value = null, A.value = null, z.value = !1; | ||
| } | ||
| return r(mt), { | ||
| editor: Qe, | ||
| editorView: j, | ||
| editorState: M, | ||
| remoteSelections: P, | ||
| headerFooterSelection: F, | ||
| isReady: z, | ||
| isDirty: V, | ||
| parseError: B, | ||
| layout: I, | ||
| blocks: L, | ||
| measures: R, | ||
| syncCoordinator: q, | ||
| loadBuffer: it, | ||
| loadDocument: at, | ||
| save: ot, | ||
| getDocument: st, | ||
| setDocument: ct, | ||
| getHeaderFooterView: lt, | ||
| syncHeaderFooterViews: ut, | ||
| getCommands: dt, | ||
| focus: ft, | ||
| reLayout: pt, | ||
| destroy: mt | ||
| }; | ||
| } | ||
| function k(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; | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useDragAutoScroll.ts | ||
| function A({ pagesContainer: e, onScrollExtendSelection: t }) { | ||
| let n = null, i = 0, a = 0, o = !1, s = null; | ||
| function c() { | ||
| if (s) return s; | ||
| let t = e.value; | ||
| return t ? (s = Se(t), s) : null; | ||
| } | ||
| function l() { | ||
| o = !1, n !== null && (cancelAnimationFrame(n), n = null); | ||
| } | ||
| function u() { | ||
| if (!o) return; | ||
| let e = c(); | ||
| if (!e) return; | ||
| let r = k(e.getBoundingClientRect(), a); | ||
| r !== 0 && (e.scrollTop += r, t(i, a)), n = requestAnimationFrame(u); | ||
| } | ||
| function d() { | ||
| o || (o = !0, n = 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 r(() => l()), { | ||
| updateMousePosition: f, | ||
| stopAutoScroll: l | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useTableResize.ts | ||
| function j() { | ||
| 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), M(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), N(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), P(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 * C), a = e.origWidths.left + i, o = e.origWidths.right - i; | ||
| a >= x && o >= x && (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 * C), a = t.origHeight + i; | ||
| a >= S && (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 * C), a = n.origWidth + i; | ||
| a >= x && (n.origWidth = a); | ||
| } | ||
| } | ||
| function s(i) { | ||
| if (e.active) { | ||
| e.active = !1, e.handle?.classList.remove("dragging"), r && w(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 && we(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 && Ce(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 M(e, t) { | ||
| let n = Ee(e, t.tablePmStart, t.columnIndex); | ||
| n && (t.origWidths = n); | ||
| } | ||
| function N(e, t, n) { | ||
| let r = De(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 * C); | ||
| } | ||
| function P(e, t) { | ||
| let n = Te(e, t.tablePmStart, t.columnIndex); | ||
| n != null && (t.origWidth = n); | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useTrackedChanges.ts | ||
| function F(t, n) { | ||
| return e(() => (n.value, T(t.value?.state ?? null))); | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useZoom.ts | ||
| var I = D, L = E, R = [ | ||
| .5, | ||
| .75, | ||
| 1, | ||
| 1.25, | ||
| 1.5, | ||
| 2 | ||
| ]; | ||
| function z(r = 1) { | ||
| let a = i(Math.max(I, Math.min(L, r))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= I), c = e(() => a.value >= L); | ||
| function l(e) { | ||
| a.value = Math.max(I, Math.min(L, Math.round(e * 100) / 100)); | ||
| } | ||
| function u() { | ||
| l(a.value + Oe); | ||
| } | ||
| function d() { | ||
| l(a.value - Oe); | ||
| } | ||
| function f() { | ||
| l(1); | ||
| } | ||
| function p(e) { | ||
| (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d()); | ||
| } | ||
| function m(e) { | ||
| (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f()))); | ||
| } | ||
| function h() { | ||
| n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m)); | ||
| } | ||
| return { | ||
| zoom: a, | ||
| zoomPercent: o, | ||
| isMinZoom: s, | ||
| isMaxZoom: c, | ||
| setZoom: l, | ||
| zoomIn: u, | ||
| zoomOut: d, | ||
| resetZoom: f, | ||
| handleWheel: p, | ||
| handleKeyDown: m, | ||
| installShortcuts: h, | ||
| ZOOM_PRESETS: R | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { A as a, j as i, T as n, O as o, F as r, z as t }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| var e={selectionOverlay:10,decorationLayer:11,remoteSelection:12,imageOverlay:15,hfInlineEditor:10,ruler:30,dropdown:100,contextMenu:1e4};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}}); |
| //#region src/styles/zIndex.ts | ||
| var e = { | ||
| selectionOverlay: 10, | ||
| decorationLayer: 11, | ||
| remoteSelection: 12, | ||
| imageOverlay: 15, | ||
| hfInlineEditor: 10, | ||
| ruler: 30, | ||
| dropdown: 100, | ||
| contextMenu: 1e4 | ||
| }; | ||
| //#endregion | ||
| export { e as t }; |
@@ -16,5 +16,4 @@ import { EditorState, Transaction } from 'prosemirror-state'; | ||
| * the pages-scroll helpers) rather than tearing a component ref off a | ||
| * component that does not exist. `getHfView` is the one method with no | ||
| * backing implementation yet (no persistent hidden header/footer PM view in | ||
| * Vue) and stays a documented no-op; see its call site for the exact reason. | ||
| * component that does not exist. `getHfView` delegates to the shared | ||
| * persistent header/footer editor manager. | ||
| * | ||
@@ -21,0 +20,0 @@ * TODO(vue): re-home to the Vue PagedEditor component when it lands. |
@@ -1,2 +0,2 @@ | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useZoom-C7jhL696.cjs");let t=require("vue"),n=require("prosemirror-history"),r=require("@stll/folio-core/utils/clipboard"),i=require("@stll/folio-core/managers/ClipboardManager"),a=require("@stll/folio-core/managers/TableSelectionManager"),o=require("@stll/folio-core/prosemirror/utils/visualLineNavigation"),s=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges");function c(e={}){let{onCopy:n,onCut:i,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c}=e,l=(0,t.ref)(!1),u=(0,t.ref)(null),d=c?{onError:c}:{};async function f(e){if(l.value)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&n?.(e),t}finally{l.value=!1}}async function p(e){if(l.value||!s)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&i?.(e),t}finally{l.value=!1}}async function m(e=!1){if(l.value||!s)return null;l.value=!0;try{if(navigator.clipboard&&navigator.clipboard.read){let t=await navigator.clipboard.read(),n=``,i=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(i=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,r.parseClipboardHtml)(n,i,o);return u.value=s,a?.(s,e),s}return null}catch(e){return c?.(e instanceof Error?e:Error(String(e))),null}finally{l.value=!1}}return{copy:f,cut:p,paste:m,isProcessing:l,lastPastedContent:u}}function l({isOpen:e,onClose:n,align:r=`left`}){let i=(0,t.ref)(null),a=(0,t.ref)(null),o=(0,t.ref)({position:`fixed`,top:`0px`,left:`0px`,zIndex:1e4});function s(e,t){o.value={position:`fixed`,top:e+`px`,left:t+`px`,zIndex:1e4}}function c(e){let t=e.target;t instanceof Node&&i.value&&!i.value.contains(t)&&a.value&&!a.value.contains(t)&&n()}function l(e){e.key===`Escape`&&n()}function u(e){let t=e.target;t instanceof Node&&a.value&&a.value.contains(t)||n()}function d(){document.addEventListener(`mousedown`,c),document.addEventListener(`keydown`,l),window.addEventListener(`scroll`,u,!0)}function f(){document.removeEventListener(`mousedown`,c),document.removeEventListener(`keydown`,l),window.removeEventListener(`scroll`,u,!0)}(0,t.watch)(e,e=>{if(!e){f();return}let t=i.value;if(!t)return;let n=t.getBoundingClientRect();r===`right`?requestAnimationFrame(()=>{let e=a.value;if(e){let t=e.getBoundingClientRect();s(n.bottom+4,n.right-t.width)}else s(n.bottom+4,n.left)}):s(n.bottom+4,n.left),d()}),(0,t.onScopeDispose)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function u(e,r){let i=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.undoDepth)(t.state)>0:!1}),a=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.redoDepth)(t.state)>0:!1});function o(){let t=e.value;return t?(0,n.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,n.redo)(t.state,t.dispatch):!1}return{canUndo:i,canRedo:a,undo:o,redo:s}}var d={backgroundColor:`rgba(26, 115, 232, 0.3)`,borderRadius:0,zIndex:0,opacity:1,mixBlendMode:`multiply`};function f(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return[];let n=t.getRangeAt(0);if(e&&!e.contains(n.commonAncestorContainer))return[];let r=0,i=0;if(e){let t=e.getBoundingClientRect();r=t.left+e.scrollLeft,i=t.top+e.scrollTop}let a=[];for(let e of n.getClientRects())e.width===0&&e.height===0||a.push({left:e.left-r,top:e.top-i,width:e.width,height:e.height});return a}function p(e,t=2){if(e.length<=1)return e;let n=[...e].sort((e,n)=>Math.abs(e.top-n.top)<t?e.left-n.left:e.top-n.top),r=n[0];if(!r)return e;let i=[],a={...r};for(let e=1;e<n.length;e++){let r=n[e];if(!r)continue;let o=Math.abs(r.top-a.top)<t,s=r.left<=a.left+a.width+t;if(o&&s){let e=Math.max(a.left+a.width,r.left+r.width);a.width=e-a.left,a.height=Math.max(a.height,r.height)}else i.push(a),a={...r}}return i.push(a),i}function m(e){return p(f(e))}function h(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function g(e){let t=window.getSelection();return!t||t.rangeCount===0?!1:e.contains(t.getRangeAt(0).commonAncestorContainer)}var _=`docx-selection-styles`,v=null;function y(){v&&=(v.remove(),null),document.getElementById(_)?.remove()}function b(e=d){y();let t=` | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useFindReplace-ZCrdvwEk.cjs"),t=require("./useZoom-BYEcnpS0.cjs");let n=require("vue"),r=require("prosemirror-history"),i=require("@stll/folio-core/utils/clipboard"),a=require("@stll/folio-core/managers/ClipboardManager"),o=require("@stll/folio-core/managers/TableSelectionManager"),s=require("@stll/folio-core/prosemirror/utils/visualLineNavigation"),c=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges");function l(e={}){let{onCopy:t,onCut:r,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c}=e,l=(0,n.ref)(!1),u=(0,n.ref)(null),d=c?{onError:c}:{};async function f(e){if(l.value)return!1;l.value=!0;try{let n=await(0,i.copyRuns)(e.runs,d);return n&&t?.(e),n}finally{l.value=!1}}async function p(e){if(l.value||!s)return!1;l.value=!0;try{let t=await(0,i.copyRuns)(e.runs,d);return t&&r?.(e),t}finally{l.value=!1}}async function m(e=!1){if(l.value||!s)return null;l.value=!0;try{if(navigator.clipboard&&navigator.clipboard.read){let t=await navigator.clipboard.read(),n=``,r=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(r=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,i.parseClipboardHtml)(n,r,o);return u.value=s,a?.(s,e),s}return null}catch(e){return c?.(e instanceof Error?e:Error(String(e))),null}finally{l.value=!1}}return{copy:f,cut:p,paste:m,isProcessing:l,lastPastedContent:u}}function u({isOpen:e,onClose:t,align:r=`left`}){let i=(0,n.ref)(null),a=(0,n.ref)(null),o=(0,n.ref)({position:`fixed`,top:`0px`,left:`0px`,zIndex:1e4});function s(e,t){o.value={position:`fixed`,top:e+`px`,left:t+`px`,zIndex:1e4}}function c(e){let n=e.target;n instanceof Node&&i.value&&!i.value.contains(n)&&a.value&&!a.value.contains(n)&&t()}function l(e){e.key===`Escape`&&t()}function u(e){let n=e.target;n instanceof Node&&a.value&&a.value.contains(n)||t()}function d(){document.addEventListener(`mousedown`,c),document.addEventListener(`keydown`,l),window.addEventListener(`scroll`,u,!0)}function f(){document.removeEventListener(`mousedown`,c),document.removeEventListener(`keydown`,l),window.removeEventListener(`scroll`,u,!0)}(0,n.watch)(e,e=>{if(!e){f();return}let t=i.value;if(!t)return;let n=t.getBoundingClientRect();r===`right`?requestAnimationFrame(()=>{let e=a.value;if(e){let t=e.getBoundingClientRect();s(n.bottom+4,n.right-t.width)}else s(n.bottom+4,n.left)}):s(n.bottom+4,n.left),d()}),(0,n.onScopeDispose)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function d(e,t){let i=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,r.undoDepth)(n.state)>0:!1}),a=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,r.redoDepth)(n.state)>0:!1});function o(){let t=e.value;return t?(0,r.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,r.redo)(t.state,t.dispatch):!1}return{canUndo:i,canRedo:a,undo:o,redo:s}}var f={backgroundColor:`rgba(26, 115, 232, 0.3)`,borderRadius:0,zIndex:0,opacity:1,mixBlendMode:`multiply`};function p(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return[];let n=t.getRangeAt(0);if(e&&!e.contains(n.commonAncestorContainer))return[];let r=0,i=0;if(e){let t=e.getBoundingClientRect();r=t.left+e.scrollLeft,i=t.top+e.scrollTop}let a=[];for(let e of n.getClientRects())e.width===0&&e.height===0||a.push({left:e.left-r,top:e.top-i,width:e.width,height:e.height});return a}function m(e,t=2){if(e.length<=1)return e;let n=[...e].sort((e,n)=>Math.abs(e.top-n.top)<t?e.left-n.left:e.top-n.top),r=n[0];if(!r)return e;let i=[],a={...r};for(let e=1;e<n.length;e++){let r=n[e];if(!r)continue;let o=Math.abs(r.top-a.top)<t,s=r.left<=a.left+a.width+t;if(o&&s){let e=Math.max(a.left+a.width,r.left+r.width);a.width=e-a.left,a.height=Math.max(a.height,r.height)}else i.push(a),a={...r}}return i.push(a),i}function h(e){return m(p(e))}function g(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function _(e){let t=window.getSelection();return!t||t.rangeCount===0?!1:e.contains(t.getRangeAt(0).commonAncestorContainer)}var v=`docx-selection-styles`,y=null;function b(){y&&=(y.remove(),null),document.getElementById(v)?.remove()}function x(e=f){b();let t=` | ||
| /* DOCX Editor Selection Highlighting */ | ||
@@ -61,2 +61,2 @@ | ||
| } | ||
| `;v=document.createElement(`style`),v.id=_,v.textContent=t,document.head.appendChild(v)}function x(){return v!==null||document.getElementById(_)!==null}function S(){return window.getSelection()?.toString()??``}function C(e){let{containerRef:n,enabled:r=!0,config:i=d,useOverlay:a=!1,debounceMs:o=16,onSelectionChange:s}=e,c=(0,t.ref)(!1),l=(0,t.ref)(``),u=(0,t.ref)([]),f=(0,t.ref)(!1),p=null,_=0;function v(){let e=n.value,t=h(),r=S(),i=e?g(e):!1;c.value=t,l.value=r,f.value=i,u.value=a&&i&&e?m(e):[],s?.(t&&i,r)}function y(){v()}function C(){let e=performance.now();if(e-_<o){p&&clearTimeout(p),p=setTimeout(()=>{_=performance.now(),v(),p=null},o);return}_=e,v()}function w(e){let t={position:`absolute`,left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:i.backgroundColor,zIndex:i.zIndex??0,pointerEvents:`none`};return i.borderRadius&&(t.borderRadius=`${i.borderRadius}px`),i.borderColor&&(t.border=`1px solid ${i.borderColor}`),t}return(0,t.onMounted)(()=>{r&&(x()||b(i),document.addEventListener(`selectionchange`,C))}),(0,t.onBeforeUnmount)(()=>{document.removeEventListener(`selectionchange`,C),p&&clearTimeout(p)}),(0,t.watch)(n,()=>v()),{hasSelection:(0,t.computed)(()=>c.value),selectedText:(0,t.computed)(()=>l.value),highlightRects:(0,t.computed)(()=>u.value),isSelectionInContainer:(0,t.computed)(()=>f.value),refresh:y,getOverlayStyle:w}}function w(){let e=new a.TableSelectionManager,n=(0,t.ref)(null),r=()=>{let t=e.getSnapshot();n.value=t.tableIndex!==null&&t.rowIndex!==null&&t.columnIndex!==null?{tableIndex:t.tableIndex,rowIndex:t.rowIndex,columnIndex:t.columnIndex}:null},i=e.subscribe(r);r(),(0,t.onScopeDispose)(i);function o(e,t,n){}function s(t,n){(0,a.findTableFromClick)(t,n)||e.clearSelection()}function c(){e.clearSelection()}function l(t,n,r){return e.isCellSelected(t,n,r)}return{selectedCell:n,handleCellClick:o,handleClickTarget:s,clearSelection:c,isCellSelected:l}}function T(e){let t=(0,o.createVisualLineState)();function n(t){let n=e.value;return n?(0,o.getCaretClientX)(n,t):null}function r(t){let n=e.value;return n?(0,o.findLineElementAtPosition)(n,t):null}function i(e,t){return(0,o.findPositionOnLineAtClientX)(e,t)}function a(n,r){return(0,o.handleVisualLineKeyDown)(t,n,r,e.value)}return{state:t,getCaretClientX:n,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}exports.createSelectionFromDOM=i.createSelectionFromDOM,exports.extractTrackedChanges=s.extractTrackedChanges,exports.getSelectionRuns=i.getSelectionRuns,exports.runsToClipboardContent=r.runsToClipboardContent,exports.useClipboard=c,exports.useDocxEditor=e.a,exports.useDragAutoScroll=e.i,exports.useFixedDropdown=l,exports.useHistory=u,exports.useSelectionHighlight=C,exports.useTableResize=e.r,exports.useTableSelection=w,exports.useTrackedChanges=e.n,exports.useVisualLineNavigation=T,exports.useWheelZoom=e.t,exports.useZoom=e.t; | ||
| `;y=document.createElement(`style`),y.id=v,y.textContent=t,document.head.appendChild(y)}function S(){return y!==null||document.getElementById(v)!==null}function C(){return window.getSelection()?.toString()??``}function w(e){let{containerRef:t,enabled:r=!0,config:i=f,useOverlay:a=!1,debounceMs:o=16,onSelectionChange:s}=e,c=(0,n.ref)(!1),l=(0,n.ref)(``),u=(0,n.ref)([]),d=(0,n.ref)(!1),p=null,m=0;function v(){let e=t.value,n=g(),r=C(),i=e?_(e):!1;c.value=n,l.value=r,d.value=i,u.value=a&&i&&e?h(e):[],s?.(n&&i,r)}function y(){v()}function b(){let e=performance.now();if(e-m<o){p&&clearTimeout(p),p=setTimeout(()=>{m=performance.now(),v(),p=null},o);return}m=e,v()}function w(e){let t={position:`absolute`,left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:i.backgroundColor,zIndex:i.zIndex??0,pointerEvents:`none`};return i.borderRadius&&(t.borderRadius=`${i.borderRadius}px`),i.borderColor&&(t.border=`1px solid ${i.borderColor}`),t}return(0,n.onMounted)(()=>{r&&(S()||x(i),document.addEventListener(`selectionchange`,b))}),(0,n.onBeforeUnmount)(()=>{document.removeEventListener(`selectionchange`,b),p&&clearTimeout(p)}),(0,n.watch)(t,()=>v()),{hasSelection:(0,n.computed)(()=>c.value),selectedText:(0,n.computed)(()=>l.value),highlightRects:(0,n.computed)(()=>u.value),isSelectionInContainer:(0,n.computed)(()=>d.value),refresh:y,getOverlayStyle:w}}function T(){let e=new o.TableSelectionManager,t=(0,n.ref)(null),r=()=>{let n=e.getSnapshot();t.value=n.tableIndex!==null&&n.rowIndex!==null&&n.columnIndex!==null?{tableIndex:n.tableIndex,rowIndex:n.rowIndex,columnIndex:n.columnIndex}:null},i=e.subscribe(r);r(),(0,n.onScopeDispose)(i);function a(t,n,r){e.selectCellCoordinates({tableIndex:t,rowIndex:n,columnIndex:r})}function s(t,n){let r=(0,o.findTableFromClick)(t,n);if(!r){e.clearSelection();return}e.selectCellCoordinates(r)}function c(){e.clearSelection()}function l(t,n,r){return e.isCellSelected(t,n,r)}return{selectedCell:t,handleCellClick:a,handleClickTarget:s,clearSelection:c,isCellSelected:l}}function E(e){let t=(0,s.createVisualLineState)();function n(t){let n=e.value;return n?(0,s.getCaretClientX)(n,t):null}function r(t){let n=e.value;return n?(0,s.findLineElementAtPosition)(n,t):null}function i(e,t){return(0,s.findPositionOnLineAtClientX)(e,t)}function a(n,r){return(0,s.handleVisualLineKeyDown)(t,n,r,e.value)}return{state:t,getCaretClientX:n,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}exports.createSelectionFromDOM=a.createSelectionFromDOM,exports.extractTrackedChanges=c.extractTrackedChanges,exports.getSelectionRuns=a.getSelectionRuns,exports.runsToClipboardContent=i.runsToClipboardContent,exports.useClipboard=l,exports.useDocxEditor=t.a,exports.useDragAutoScroll=t.i,exports.useFindReplace=e.t,exports.useFixedDropdown=u,exports.useHistory=d,exports.useSelectionHighlight=w,exports.useTableResize=t.r,exports.useTableSelection=T,exports.useTrackedChanges=t.n,exports.useVisualLineNavigation=E,exports.useWheelZoom=t.t,exports.useZoom=t.t; |
+80
-68
@@ -1,16 +0,17 @@ | ||
| import { a as e, i as t, n, o as r, r as i, t as a } from "./useZoom-zJvuJlUd.js"; | ||
| import { computed as o, onBeforeUnmount as s, onMounted as c, onScopeDispose as l, ref as u, watch as d } from "vue"; | ||
| import { redo as f, redoDepth as p, undo as m, undoDepth as h } from "prosemirror-history"; | ||
| import { copyRuns as g, parseClipboardHtml as _, runsToClipboardContent as v } from "@stll/folio-core/utils/clipboard"; | ||
| import { createSelectionFromDOM as y, getSelectionRuns as b } from "@stll/folio-core/managers/ClipboardManager"; | ||
| import { TableSelectionManager as x, findTableFromClick as S } from "@stll/folio-core/managers/TableSelectionManager"; | ||
| import { createVisualLineState as C, findLineElementAtPosition as w, findPositionOnLineAtClientX as T, getCaretClientX as E, handleVisualLineKeyDown as D } from "@stll/folio-core/prosemirror/utils/visualLineNavigation"; | ||
| import { t as e } from "./useFindReplace-CL8Rbc3y.js"; | ||
| import { a as t, i as n, n as r, o as i, r as a, t as o } from "./useZoom-C0p0o54p.js"; | ||
| import { computed as s, onBeforeUnmount as c, onMounted as l, onScopeDispose as u, ref as d, watch as f } from "vue"; | ||
| import { redo as p, redoDepth as m, undo as h, undoDepth as g } from "prosemirror-history"; | ||
| import { copyRuns as _, parseClipboardHtml as v, runsToClipboardContent as y } from "@stll/folio-core/utils/clipboard"; | ||
| import { createSelectionFromDOM as b, getSelectionRuns as x } from "@stll/folio-core/managers/ClipboardManager"; | ||
| import { TableSelectionManager as S, findTableFromClick as C } from "@stll/folio-core/managers/TableSelectionManager"; | ||
| import { createVisualLineState as w, findLineElementAtPosition as T, findPositionOnLineAtClientX as E, getCaretClientX as D, handleVisualLineKeyDown as O } from "@stll/folio-core/prosemirror/utils/visualLineNavigation"; | ||
| //#region src/composables/useClipboard.ts | ||
| function O(e = {}) { | ||
| let { onCopy: t, onCut: n, onPaste: r, cleanWordFormatting: i = !0, editable: a = !0, onError: o } = e, s = u(!1), c = u(null), l = o ? { onError: o } : {}; | ||
| async function d(e) { | ||
| function k(e = {}) { | ||
| let { onCopy: t, onCut: n, onPaste: r, cleanWordFormatting: i = !0, editable: a = !0, onError: o } = e, s = d(!1), c = d(null), l = o ? { onError: o } : {}; | ||
| async function u(e) { | ||
| if (s.value) return !1; | ||
| s.value = !0; | ||
| try { | ||
| let n = await g(e.runs, l); | ||
| let n = await _(e.runs, l); | ||
| return n && t?.(e), n; | ||
@@ -25,3 +26,3 @@ } finally { | ||
| try { | ||
| let t = await g(e.runs, l); | ||
| let t = await _(e.runs, l); | ||
| return t && n?.(e), t; | ||
@@ -40,3 +41,3 @@ } finally { | ||
| e && (n = ""); | ||
| let o = _(n, a, i); | ||
| let o = v(n, a, i); | ||
| return c.value = o, r?.(o, e), o; | ||
@@ -52,3 +53,3 @@ } | ||
| return { | ||
| copy: d, | ||
| copy: u, | ||
| cut: f, | ||
@@ -62,4 +63,4 @@ paste: p, | ||
| //#region src/composables/useFixedDropdown.ts | ||
| function k({ isOpen: e, onClose: t, align: n = "left" }) { | ||
| let r = u(null), i = u(null), a = u({ | ||
| function A({ isOpen: e, onClose: t, align: n = "left" }) { | ||
| let r = d(null), i = d(null), a = d({ | ||
| position: "fixed", | ||
@@ -85,3 +86,3 @@ top: "0px", | ||
| } | ||
| function f(e) { | ||
| function l(e) { | ||
| let n = e.target; | ||
@@ -91,8 +92,8 @@ n instanceof Node && i.value && i.value.contains(n) || t(); | ||
| function p() { | ||
| document.addEventListener("mousedown", s), document.addEventListener("keydown", c), window.addEventListener("scroll", f, !0); | ||
| document.addEventListener("mousedown", s), document.addEventListener("keydown", c), window.addEventListener("scroll", l, !0); | ||
| } | ||
| function m() { | ||
| document.removeEventListener("mousedown", s), document.removeEventListener("keydown", c), window.removeEventListener("scroll", f, !0); | ||
| document.removeEventListener("mousedown", s), document.removeEventListener("keydown", c), window.removeEventListener("scroll", l, !0); | ||
| } | ||
| d(e, (e) => { | ||
| f(e, (e) => { | ||
| if (!e) { | ||
@@ -112,3 +113,3 @@ m(); | ||
| }) : o(a.bottom + 4, a.left), p(); | ||
| }), l(m); | ||
| }), u(m); | ||
| function h(e) { | ||
@@ -126,19 +127,19 @@ e.preventDefault(), e.stopPropagation(); | ||
| //#region src/composables/useHistory.ts | ||
| function A(e, t) { | ||
| let n = o(() => { | ||
| function j(e, t) { | ||
| let n = s(() => { | ||
| t.value; | ||
| let n = e.value; | ||
| return n ? h(n.state) > 0 : !1; | ||
| }), r = o(() => { | ||
| return n ? g(n.state) > 0 : !1; | ||
| }), r = s(() => { | ||
| t.value; | ||
| let n = e.value; | ||
| return n ? p(n.state) > 0 : !1; | ||
| return n ? m(n.state) > 0 : !1; | ||
| }); | ||
| function i() { | ||
| let t = e.value; | ||
| return t ? m(t.state, t.dispatch) : !1; | ||
| return t ? h(t.state, t.dispatch) : !1; | ||
| } | ||
| function a() { | ||
| let t = e.value; | ||
| return t ? f(t.state, t.dispatch) : !1; | ||
| return t ? p(t.state, t.dispatch) : !1; | ||
| } | ||
@@ -154,3 +155,3 @@ return { | ||
| //#region src/utils/selectionHighlight.ts | ||
| var j = { | ||
| var M = { | ||
| backgroundColor: "rgba(26, 115, 232, 0.3)", | ||
@@ -162,3 +163,3 @@ borderRadius: 0, | ||
| }; | ||
| function M(e) { | ||
| function N(e) { | ||
| let t = window.getSelection(); | ||
@@ -182,3 +183,3 @@ if (!t || t.rangeCount === 0 || t.isCollapsed) return []; | ||
| } | ||
| function N(e, t = 2) { | ||
| function P(e, t = 2) { | ||
| if (e.length <= 1) return e; | ||
@@ -199,19 +200,19 @@ let n = [...e].sort((e, n) => Math.abs(e.top - n.top) < t ? e.left - n.left : e.top - n.top), r = n[0]; | ||
| } | ||
| function P(e) { | ||
| return N(M(e)); | ||
| function F(e) { | ||
| return P(N(e)); | ||
| } | ||
| function F() { | ||
| function I() { | ||
| let e = window.getSelection(); | ||
| return e !== null && !e.isCollapsed && e.rangeCount > 0; | ||
| } | ||
| function I(e) { | ||
| function L(e) { | ||
| let t = window.getSelection(); | ||
| return !t || t.rangeCount === 0 ? !1 : e.contains(t.getRangeAt(0).commonAncestorContainer); | ||
| } | ||
| var L = "docx-selection-styles", R = null; | ||
| function z() { | ||
| R &&= (R.remove(), null), document.getElementById(L)?.remove(); | ||
| var R = "docx-selection-styles", z = null; | ||
| function B() { | ||
| z &&= (z.remove(), null), document.getElementById(R)?.remove(); | ||
| } | ||
| function B(e = j) { | ||
| z(); | ||
| function V(e = M) { | ||
| B(); | ||
| let t = ` | ||
@@ -278,17 +279,17 @@ /* DOCX Editor Selection Highlighting */ | ||
| `; | ||
| R = document.createElement("style"), R.id = L, R.textContent = t, document.head.appendChild(R); | ||
| z = document.createElement("style"), z.id = R, z.textContent = t, document.head.appendChild(z); | ||
| } | ||
| function V() { | ||
| return R !== null || document.getElementById(L) !== null; | ||
| function H() { | ||
| return z !== null || document.getElementById(R) !== null; | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useSelectionHighlight.ts | ||
| function H() { | ||
| function U() { | ||
| return window.getSelection()?.toString() ?? ""; | ||
| } | ||
| function U(e) { | ||
| let { containerRef: t, enabled: n = !0, config: r = j, useOverlay: i = !1, debounceMs: a = 16, onSelectionChange: l } = e, f = u(!1), p = u(""), m = u([]), h = u(!1), g = null, _ = 0; | ||
| function W(e) { | ||
| let { containerRef: t, enabled: n = !0, config: r = M, useOverlay: i = !1, debounceMs: a = 16, onSelectionChange: o } = e, u = d(!1), p = d(""), m = d([]), h = d(!1), g = null, _ = 0; | ||
| function v() { | ||
| let e = t.value, n = F(), r = H(), a = e ? I(e) : !1; | ||
| f.value = n, p.value = r, h.value = a, m.value = i && a && e ? P(e) : [], l?.(n && a, r); | ||
| let e = t.value, n = I(), r = U(), a = e ? L(e) : !1; | ||
| u.value = n, p.value = r, h.value = a, m.value = i && a && e ? F(e) : [], o?.(n && a, r); | ||
| } | ||
@@ -321,11 +322,11 @@ function y() { | ||
| } | ||
| return c(() => { | ||
| n && (V() || B(r), document.addEventListener("selectionchange", b)); | ||
| }), s(() => { | ||
| return l(() => { | ||
| n && (H() || V(r), document.addEventListener("selectionchange", b)); | ||
| }), c(() => { | ||
| document.removeEventListener("selectionchange", b), g && clearTimeout(g); | ||
| }), d(t, () => v()), { | ||
| hasSelection: o(() => f.value), | ||
| selectedText: o(() => p.value), | ||
| highlightRects: o(() => m.value), | ||
| isSelectionInContainer: o(() => h.value), | ||
| }), f(t, () => v()), { | ||
| hasSelection: s(() => u.value), | ||
| selectedText: s(() => p.value), | ||
| highlightRects: s(() => m.value), | ||
| isSelectionInContainer: s(() => h.value), | ||
| refresh: y, | ||
@@ -337,4 +338,4 @@ getOverlayStyle: x | ||
| //#region src/composables/useTableSelection.ts | ||
| function W() { | ||
| let e = new x(), t = u(null), n = () => { | ||
| function G() { | ||
| let e = new S(), t = d(null), n = () => { | ||
| let n = e.getSnapshot(); | ||
@@ -347,6 +348,17 @@ t.value = n.tableIndex !== null && n.rowIndex !== null && n.columnIndex !== null ? { | ||
| }, r = e.subscribe(n); | ||
| n(), l(r); | ||
| function i(e, t, n) {} | ||
| n(), u(r); | ||
| function i(t, n, r) { | ||
| e.selectCellCoordinates({ | ||
| tableIndex: t, | ||
| rowIndex: n, | ||
| columnIndex: r | ||
| }); | ||
| } | ||
| function a(t, n) { | ||
| S(t, n) || e.clearSelection(); | ||
| let r = C(t, n); | ||
| if (!r) { | ||
| e.clearSelection(); | ||
| return; | ||
| } | ||
| e.selectCellCoordinates(r); | ||
| } | ||
@@ -369,17 +381,17 @@ function o() { | ||
| //#region src/composables/useVisualLineNavigation.ts | ||
| function G(e) { | ||
| let t = C(); | ||
| function K(e) { | ||
| let t = w(); | ||
| function n(t) { | ||
| let n = e.value; | ||
| return n ? E(n, t) : null; | ||
| return n ? D(n, t) : null; | ||
| } | ||
| function r(t) { | ||
| let n = e.value; | ||
| return n ? w(n, t) : null; | ||
| return n ? T(n, t) : null; | ||
| } | ||
| function i(e, t) { | ||
| return T(e, t); | ||
| return E(e, t); | ||
| } | ||
| function a(n, r) { | ||
| return D(t, n, r, e.value); | ||
| return O(t, n, r, e.value); | ||
| } | ||
@@ -395,2 +407,2 @@ return { | ||
| //#endregion | ||
| export { y as createSelectionFromDOM, n as extractTrackedChanges, b as getSelectionRuns, v as runsToClipboardContent, O as useClipboard, r as useDocxEditor, e as useDragAutoScroll, k as useFixedDropdown, A as useHistory, U as useSelectionHighlight, t as useTableResize, W as useTableSelection, i as useTrackedChanges, G as useVisualLineNavigation, a as useWheelZoom, a as useZoom }; | ||
| export { b as createSelectionFromDOM, r as extractTrackedChanges, x as getSelectionRuns, y as runsToClipboardContent, k as useClipboard, i as useDocxEditor, t as useDragAutoScroll, e as useFindReplace, A as useFixedDropdown, j as useHistory, W as useSelectionHighlight, n as useTableResize, G as useTableSelection, a as useTrackedChanges, K as useVisualLineNavigation, o as useWheelZoom, o as useZoom }; |
@@ -7,4 +7,3 @@ /** | ||
| * navigation, and the high-level `useDocxEditor` host composable. Only the | ||
| * composables the fork has ported are re-exported (React's `useAutoSave` and | ||
| * `useCommentSidebarItems` have no Vue equivalent yet). | ||
| * composables the fork has ported are re-exported. | ||
| * | ||
@@ -11,0 +10,0 @@ * @example |
@@ -5,5 +5,8 @@ import { MaybeRefOrGetter, Ref } from 'vue'; | ||
| import { FolioEditor } from '@stll/folio-core/controller/folioEditor'; | ||
| import { HeaderFooterPartKind } from '@stll/folio-core/controller/headerFooterEditorManager'; | ||
| import { HiddenProseMirrorCollaboration, HiddenProseMirrorRemoteSelection } from '@stll/folio-core/controller/hiddenEditorManager'; | ||
| import { FolioSelectiveSaveFlags } from '@stll/folio-core/docx/selectiveSaveFlags'; | ||
| import { TripwireResult } from '@stll/folio-core/docx/selectiveSaveTripwire'; | ||
| import { FlowBlock, Layout, Measure } from '@stll/folio-core/layout-engine/types'; | ||
| import { LayoutSelectionGate } from '@stll/folio-core/paged-layout/LayoutSelectionGate'; | ||
| import { CommandMap } from '@stll/folio-core/prosemirror/extensions/types'; | ||
@@ -17,2 +20,4 @@ import { AnonymizationMatch } from '@stll/folio-core/prosemirror/plugins/anonymizationDecorations'; | ||
| hiddenContainer: Ref<HTMLElement | null>; | ||
| /** Optional separate host for persistent header/footer ProseMirror views. */ | ||
| hiddenHeaderFooterContainer?: Ref<HTMLElement | null>; | ||
| /** Container element the paginated pages are painted into. */ | ||
@@ -41,2 +46,4 @@ pagesContainer: Ref<HTMLElement | null>; | ||
| externalPlugins?: Plugin[]; | ||
| /** Reactive Yjs collaboration owner and the ProseMirror binding plugins. */ | ||
| collaboration?: MaybeRefOrGetter<UseDocxEditorCollaboration | undefined>; | ||
| /** | ||
@@ -83,2 +90,11 @@ * Fires with the anonymization decoration plugin's current match list on | ||
| }; | ||
| export type UseDocxEditorCollaboration = HiddenProseMirrorCollaboration & { | ||
| plugins?: Plugin[] | undefined; | ||
| }; | ||
| export type HeaderFooterSelectionState = { | ||
| from: number; | ||
| kind: HeaderFooterPartKind; | ||
| rId: string; | ||
| to: number; | ||
| }; | ||
| export type UseDocxEditorReturn = { | ||
@@ -91,2 +107,6 @@ /** The headless controller (imperative API + layout access + events). */ | ||
| editorState: Ref<EditorState | null>; | ||
| /** Remote collaborative cursors decoded into body ProseMirror positions. */ | ||
| remoteSelections: Ref<HiddenProseMirrorRemoteSelection[]>; | ||
| /** Selection in the currently active persistent header/footer view. */ | ||
| headerFooterSelection: Ref<HeaderFooterSelectionState | null>; | ||
| /** True once the hidden view is mounted and a document is loaded. */ | ||
@@ -109,2 +129,4 @@ isReady: Ref<boolean>; | ||
| measures: Ref<Measure[]>; | ||
| /** Gate that schedules overlay work only after the matching layout paint. */ | ||
| syncCoordinator: LayoutSelectionGate; | ||
| /** Load a DOCX from a binary buffer / Blob / File. */ | ||
@@ -122,2 +144,6 @@ loadBuffer: (buffer: DocxInput) => Promise<void>; | ||
| setDocument: (doc: Document) => void; | ||
| /** Resolve a persistent header/footer EditorView by relationship id. */ | ||
| getHeaderFooterView: (rId: string) => EditorView | null; | ||
| /** Synchronize persistent header/footer views after a document-model change. */ | ||
| syncHeaderFooterViews: () => void; | ||
| /** Access the extension command map for invoking marks / nodes / features. */ | ||
@@ -124,0 +150,0 @@ getCommands: () => CommandMap; |
@@ -58,2 +58,3 @@ import { Ref } from 'vue'; | ||
| getDocument: () => Document | null; | ||
| getHeaderFooterView: (rId: string) => EditorView | null; | ||
| setZoom: (zoom: number) => void; | ||
@@ -60,0 +61,0 @@ /** useDocxEditor.save returns a Blob; the ref surface exposes an ArrayBuffer. */ |
@@ -1,22 +0,24 @@ | ||
| /** | ||
| * Vue port of the find/replace UI-state container. | ||
| * | ||
| * PORT-BLOCKED (missing `utils/findReplace` UI-util): upstream builds this | ||
| * composable's entire state on three symbols from | ||
| * `@eigenpal/docx-editor-core/utils/findReplace` — the `FindMatch` and | ||
| * `FindOptions` data contracts and the `createDefaultFindOptions()` factory. | ||
| * That util is absent from our fork: it is neither in `@stll/folio-core` | ||
| * (whose search surface is the lower-level `prosemirror/findReplaceSelection` | ||
| * `FindMatchPosition` + `managers/FindReplaceManager`, a different shape) nor | ||
| * in our ported Vue `../utils/*`. Every field of the reactive state | ||
| * (`options: createDefaultFindOptions()`, `matches: FindMatch[]`, the | ||
| * `currentMatch`/`setMatches`/`goToMatch` surface) depends on those types, so | ||
| * there is no working subset to port without fabricating the data contract. | ||
| * | ||
| * Unblock: port upstream `packages/core/src/utils/findReplace.ts` (pure, no | ||
| * runtime deps) into the Vue package as `../utils/findReplace.ts`, reconciling | ||
| * its `FindMatch`/`FindOptions` with core's `FindMatchPosition` / | ||
| * `FindReplaceManager`, then restore the full composable — its body is a direct | ||
| * `reactive()` translation of the React hook with no other blockers. | ||
| */ | ||
| export {}; | ||
| import { ComputedRef, Ref, ShallowRef } from 'vue'; | ||
| import { EditorView } from 'prosemirror-view'; | ||
| import { ProseMirrorFindMatch } from '@stll/folio-core/prosemirror/findReplaceSelection'; | ||
| import { FindOptions } from '@stll/folio-core/utils/findReplace'; | ||
| export type UseFindReplaceOptions = { | ||
| editorView: Readonly<Ref<EditorView | null>>; | ||
| scrollVisiblePositionIntoView?: (pmPos: number) => void; | ||
| }; | ||
| export type UseFindReplaceReturn = { | ||
| searchText: Ref<string>; | ||
| replaceText: Ref<string>; | ||
| options: FindOptions; | ||
| matches: ShallowRef<ProseMirrorFindMatch[]>; | ||
| currentIndex: Ref<number>; | ||
| currentMatch: ComputedRef<ProseMirrorFindMatch | null>; | ||
| performSearch: () => ProseMirrorFindMatch[]; | ||
| goToMatch: (index: number) => boolean; | ||
| findNext: () => ProseMirrorFindMatch | null; | ||
| findPrevious: () => ProseMirrorFindMatch | null; | ||
| replaceCurrent: () => boolean; | ||
| replaceAll: () => number; | ||
| clear: () => void; | ||
| }; | ||
| export declare function useFindReplace({ editorView, scrollVisiblePositionIntoView, }: UseFindReplaceOptions): UseFindReplaceReturn; |
| import { Ref, ShallowRef } from 'vue'; | ||
| import { Command } from 'prosemirror-state'; | ||
| import { EditorView } from 'prosemirror-view'; | ||
| import { HeaderFooter, BlockContent } from '@stll/folio-core/types/content'; | ||
| import { Document } from '@stll/folio-core/types/document'; | ||
@@ -22,5 +21,6 @@ import { Layout } from '@stll/folio-core/layout-engine'; | ||
| export type HfEditState = { | ||
| isFirstPage: boolean; | ||
| pageNumber: number; | ||
| position: "header" | "footer"; | ||
| rId: string | null; | ||
| headerFooter: HeaderFooter | null; | ||
| targetRect: { | ||
@@ -46,2 +46,3 @@ top: number; | ||
| readOnly: Ref<boolean>; | ||
| showHeaderFooterEditing: Ref<boolean>; | ||
| zoom: Ref<number>; | ||
@@ -53,13 +54,8 @@ layout: Ref<Layout | null>; | ||
| reLayout: () => void; | ||
| emit: (event: string, ...args: unknown[]) => void; | ||
| onDocumentChange: (document: Document) => void; | ||
| clearOverlay: () => void; | ||
| /** | ||
| * Re-mount HF EditorViews when `package.headers/footers` content changes — | ||
| * exposed by `useDocxEditor.syncHfPMs`. Called after every save so the | ||
| * persistent PM points at the new HeaderFooter object. Optional so existing | ||
| * consumers can no-op until they wire it through. | ||
| */ | ||
| syncHfPMs?: () => void; | ||
| /** Synchronize persistent header/footer views after document-model changes. */ | ||
| syncHfPMs: () => void; | ||
| /** Resolve the persistent EditorView for an HF instance (for click routing). */ | ||
| getHfPmView?: (hf: HeaderFooter) => EditorView | null; | ||
| getHfPmView: (rId: string) => EditorView | null; | ||
| /** | ||
@@ -70,3 +66,3 @@ * Replace the loaded Document — used by HF materialisation to publish a | ||
| */ | ||
| setDocument?: (doc: Document) => void; | ||
| setDocument: (doc: Document) => void; | ||
| }; | ||
@@ -87,3 +83,3 @@ export type UsePagesPointerReturn = { | ||
| clearTableInsertTimer: () => void; | ||
| handleHfSave: (content: BlockContent[]) => void; | ||
| handleHfSave: () => void; | ||
| handleHfRemove: () => void; | ||
@@ -90,0 +86,0 @@ }; |
@@ -1,30 +0,17 @@ | ||
| /** | ||
| * Selection-overlay composable — owns the text-caret blink + selection-rect | ||
| * painter, the cell-selection highlight, and the image-selection sync that | ||
| * re-derives `selectedImage` from the live PM NodeSelection. | ||
| * | ||
| * PORT-BLOCKED (multiple absent dependencies): | ||
| * - `applyCellSelectionHighlight` — absent from our core. Upstream ships it in | ||
| * `layout-bridge/cellSelectionHighlight.ts`; our `layout-bridge` barrel does | ||
| * not expose it (see CORE-API-MAP Table 4, PORT). The multi-cell highlight | ||
| * branch cannot run without it. | ||
| * - `findImageElement` — absent from our core `layout-painter` barrel (which | ||
| * exposes only `renderPages`/`LayoutPainter`/registry); it is a PORT item. | ||
| * The image-overlay sync (`syncSelectedImageToSelection`) depends on it. | ||
| * - `../components/imageSelectionTypes` (`ImageSelectionInfo`) — the Vue-package | ||
| * image-selection type module has not been ported. | ||
| * - `../styles/zIndex` (`Z_INDEX`) — the Vue-package z-index token module does | ||
| * not exist in our fork (there is no `styles/` dir). | ||
| * | ||
| * The DOM primitives it also uses DO resolve, but at drifted paths | ||
| * (`getSelectionRectsFromDom`/`getCaretPositionFromDom` → | ||
| * `@stll/folio-core/layout-bridge/dom/clickToPositionDom`; `findBodyPmAnchor` → | ||
| * `@stll/folio-core/layout-bridge/dom/findBodyPmSpans`). With the four blockers | ||
| * above there is no coherent working subset, so the whole composable is blocked. | ||
| * | ||
| * Unblock: PORT `applyCellSelectionHighlight` and `findImageElement` into core | ||
| * (or a core barrel), then port the `imageSelectionTypes` + `styles/zIndex` | ||
| * Vue-package modules, and re-point the DOM-primitive imports to the drifted | ||
| * paths above. | ||
| */ | ||
| export {}; | ||
| import { Ref, ShallowRef } from 'vue'; | ||
| import { EditorView } from 'prosemirror-view'; | ||
| import { LayoutSelectionGate } from '@stll/folio-core/paged-layout/LayoutSelectionGate'; | ||
| import { ImageSelectionInfo } from '../components/imageSelectionTypes'; | ||
| export type UseSelectionSyncOptions = { | ||
| editorView: Ref<EditorView | null>; | ||
| pagesRef: Ref<HTMLElement | null>; | ||
| zoom: Ref<number>; | ||
| selectedImage: ShallowRef<ImageSelectionInfo | null>; | ||
| syncCoordinator: LayoutSelectionGate; | ||
| imageInteracting?: Ref<boolean>; | ||
| }; | ||
| export type UseSelectionSyncReturn = { | ||
| clearOverlay: () => void; | ||
| updateSelectionOverlay: () => void; | ||
| }; | ||
| export declare const useSelectionSync: (opts: UseSelectionSyncOptions) => UseSelectionSyncReturn; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WatermarkDialog-DHfk8jrg.cjs");var t=e.m,n=e.l,r=e.p,i=e.c,a=e.f,o=e.s,s=e.d,c=e.a,l=e.u,u=e.i,d=e.r,f=e.n,p=e.t;exports.FindReplaceDialog=t,exports.FootnotePropertiesDialog=n,exports.HyperlinkDialog=r,exports.ImagePositionDialog=i,exports.ImagePropertiesDialog=a,exports.InsertImageDialog=o,exports.InsertSymbolDialog=s,exports.InsertTableDialog=c,exports.PageSetupDialog=l,exports.PasteSpecialDialog=u,exports.SplitCellDialog=d,exports.TablePropertiesDialog=f,exports.WatermarkDialog=p; | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WatermarkDialog-ChJtT7Bs.cjs");var t=e.m,n=e.l,r=e.p,i=e.c,a=e.f,o=e.s,s=e.d,c=e.a,l=e.u,u=e.i,d=e.r,f=e.n,p=e.t;exports.FindReplaceDialog=t,exports.FootnotePropertiesDialog=n,exports.HyperlinkDialog=r,exports.ImagePositionDialog=i,exports.ImagePropertiesDialog=a,exports.InsertImageDialog=o,exports.InsertSymbolDialog=s,exports.InsertTableDialog=c,exports.PageSetupDialog=l,exports.PasteSpecialDialog=u,exports.SplitCellDialog=d,exports.TablePropertiesDialog=f,exports.WatermarkDialog=p; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, p as c, r as l, s as u, t as d, u as f } from "./WatermarkDialog-r4wmldt4.js"; | ||
| import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, p as c, r as l, s as u, t as d, u as f } from "./WatermarkDialog-Cf9ISDvv.js"; | ||
| //#region src/components/dialogs/index.ts | ||
@@ -3,0 +3,0 @@ var p = o, m = a, h = c, g = t, _ = r, v = u, y = n, b = e, x = f, S = i, C = l, w = s, T = d; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./zIndex-dFsQbASx.cjs");var t=`@stll/folio-vue/editor.css`;exports.EDITOR_CSS_PATH=t,exports.Z_INDEX=e.t; | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./zIndex-CYoLNG_N.cjs");var t=`@stll/folio-vue/editor.css`;exports.EDITOR_CSS_PATH=t,exports.Z_INDEX=e.t; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { t as e } from "./zIndex-BY0qa8Au.js"; | ||
| import { t as e } from "./zIndex-Ei9BbHSW.js"; | ||
| //#region src/styles/index.ts | ||
@@ -3,0 +3,0 @@ var t = "@stll/folio-vue/editor.css"; |
@@ -13,2 +13,3 @@ /** | ||
| readonly decorationLayer: 11; | ||
| readonly remoteSelection: 12; | ||
| readonly imageOverlay: 15; | ||
@@ -15,0 +16,0 @@ readonly hfInlineEditor: 10; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WatermarkDialog-DHfk8jrg.cjs"),t=require("./ListButtons-BvsV1yti.cjs");let n=require("vue");require("@stll/folio-core/utils/units");var r={class:`docx-editor-toolbar`},i={class:`docx-editor-toolbar__title-row`},a={class:`docx-editor-toolbar__title-left`},o={class:`docx-editor-toolbar__title-center`},s={class:`docx-editor-toolbar__title-right`},c=(0,n.defineComponent)({inheritAttrs:!1,__name:`EditorToolbar`,props:{showMenuBar:{type:Boolean,default:!0}},emits:[`menu-action`],setup(e){return(c,l)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[(0,n.renderSlot)(c.$slots,`title-bar`,{},()=>[(0,n.createElementVNode)(`div`,i,[(0,n.createElementVNode)(`div`,a,[(0,n.renderSlot)(c.$slots,`title-bar-left`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,o,[(0,n.renderSlot)(c.$slots,`document-name`,{},void 0,!0),e.showMenuBar?((0,n.openBlock)(),(0,n.createBlock)(t.w,{key:0,onAction:l[0]||=e=>c.$emit(`menu-action`,e)})):(0,n.createCommentVNode)(``,!0)]),(0,n.createElementVNode)(`div`,s,[(0,n.renderSlot)(c.$slots,`title-bar-right`,{},void 0,!0)])])],!0),(0,n.renderSlot)(c.$slots,`toolbar`,{},()=>[(0,n.createVNode)(t.y,(0,n.normalizeProps)((0,n.guardReactiveProps)(c.$attrs)),null,16)],!0)]))}}),l=e.F(c,[[`__scopeId`,`data-v-79d81064`]]),u={},d={class:`docx-title-bar`},f={class:`docx-title-bar__left`},p={class:`docx-title-bar__center`},m={class:`docx-title-bar__right`};function h(e,t){return(0,n.openBlock)(),(0,n.createElementBlock)(`div`,d,[(0,n.createElementVNode)(`div`,f,[(0,n.renderSlot)(e.$slots,`left`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,p,[(0,n.renderSlot)(e.$slots,`default`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,m,[(0,n.renderSlot)(e.$slots,`right`,{},void 0,!0)])])}var g=e.F(u,[[`render`,h],[`__scopeId`,`data-v-44b23810`]]);function _(e){let t=e.trim();if(!t)return``;let n=null,r=``;for(let e of t){if((e===`"`||e===`'`)&&n===null){n=e,r+=e;continue}if(e===n){n=null,r+=e;continue}if(e===`,`&&n===null)break;r+=e}return r.trim().replace(/^['"]|['"]$/g,``)}var v=[`value`,`disabled`],y={key:0,label:`Sans-serif`},b=[`value`],x={key:1,label:`Serif`},S=[`value`],C={key:2,label:`Monospace`},w=[`value`],T={key:3,label:`Other`},E=[`value`],D=(0,n.defineComponent)({__name:`FontPicker`,props:{value:{},fonts:{},disabled:{type:Boolean,default:!1},className:{},placeholder:{default:`Font`},showPreview:{type:Boolean,default:!0}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[{name:`Arial`,fontFamily:`Arial, Helvetica, sans-serif`,category:`sans-serif`},{name:`Calibri`,fontFamily:`"Calibri", Arial, sans-serif`,category:`sans-serif`},{name:`Helvetica`,fontFamily:`Helvetica, Arial, sans-serif`,category:`sans-serif`},{name:`Verdana`,fontFamily:`Verdana, Geneva, sans-serif`,category:`sans-serif`},{name:`Open Sans`,fontFamily:`"Open Sans", sans-serif`,category:`sans-serif`},{name:`Roboto`,fontFamily:`Roboto, sans-serif`,category:`sans-serif`},{name:`Times New Roman`,fontFamily:`"Times New Roman", Times, serif`,category:`serif`},{name:`Georgia`,fontFamily:`Georgia, serif`,category:`serif`},{name:`Cambria`,fontFamily:`Cambria, Georgia, serif`,category:`serif`},{name:`Garamond`,fontFamily:`Garamond, serif`,category:`serif`},{name:`Courier New`,fontFamily:`"Courier New", monospace`,category:`monospace`},{name:`Consolas`,fontFamily:`Consolas, monospace`,category:`monospace`}],o=(0,n.computed)(()=>r.fonts??a),s=(0,n.computed)(()=>{let e={"sans-serif":[],serif:[],monospace:[],other:[]};for(let t of o.value)e[t.category??`other`].push(t);return e}),c=(0,n.computed)(()=>{let e=r.value;if(!e)return r.placeholder;let t=e.toLowerCase();return o.value.find(n=>n.fontFamily===e||n.name.toLowerCase()===t||_(n.fontFamily).toLowerCase()===t)?.name??e});function l(e){if(!(e.target instanceof HTMLSelectElement))return;let t=e.target.value,n=o.value.find(e=>e.name===t);i(`change`,n?_(n.fontFamily)||n.name:t)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`select`,{class:(0,n.normalizeClass)([`docx-font-picker`,e.className]),value:c.value,disabled:e.disabled,"aria-label":`Font family`,onChange:l},[s.value[`sans-serif`].length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,y,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value[`sans-serif`],t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,b))),128))])):(0,n.createCommentVNode)(``,!0),s.value.serif.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,x,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.serif,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,S))),128))])):(0,n.createCommentVNode)(``,!0),s.value.monospace.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,C,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.monospace,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,w))),128))])):(0,n.createCommentVNode)(``,!0),s.value.other.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,T,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.other,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,E))),128))])):(0,n.createCommentVNode)(``,!0)],42,v))}}),O=e.F(D,[[`__scopeId`,`data-v-a6d7700f`]]),k={class:`docx-font-size`},A=[`disabled`],j=[`value`,`disabled`,`placeholder`],M=[`disabled`],N=(0,n.defineComponent)({__name:`FontSizePicker`,props:{value:{},sizes:{},disabled:{type:Boolean,default:!1},minSize:{default:1},maxSize:{default:1638},placeholder:{default:`11`}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],o=(0,n.computed)(()=>r.sizes??a),s=(0,n.computed)(()=>r.value??parseInt(r.placeholder,10)??11),c=(0,n.computed)(()=>r.value===void 0?r.placeholder:String(r.value));function l(e){return o.value.find(t=>t>e)??Math.min(e+1,r.maxSize)}function u(e){return[...o.value].reverse().find(t=>t<e)??Math.max(e-1,r.minSize)}function d(){r.disabled||i(`change`,u(s.value))}function f(){r.disabled||i(`change`,l(s.value))}function p(e){if(!(e.target instanceof HTMLInputElement))return;let t=parseFloat(e.target.value);!isNaN(t)&&t>=r.minSize&&t<=r.maxSize&&i(`change`,Math.round(t*2)/2)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,k,[(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-font-size__btn`,disabled:e.disabled||s.value<=e.minSize,title:`Decrease font size`,onClick:(0,n.withModifiers)(d,[`prevent`])},` − `,8,A),(0,n.createElementVNode)(`input`,{class:`docx-font-size__input`,type:`text`,value:c.value,disabled:e.disabled,placeholder:e.placeholder,onKeydown:[r[0]||=(0,n.withKeys)((0,n.withModifiers)(e=>{d(),e.stopPropagation()},[`prevent`]),[`up`]),r[1]||=(0,n.withKeys)((0,n.withModifiers)(e=>{f(),e.stopPropagation()},[`prevent`]),[`down`]),r[2]||=(0,n.withKeys)((0,n.withModifiers)(e=>p(e),[`prevent`]),[`enter`])],onBlur:r[3]||=e=>p(e)},null,40,j),(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-font-size__btn`,disabled:e.disabled||s.value>=e.maxSize,title:`Increase font size`,onClick:(0,n.withModifiers)(f,[`prevent`])},` + `,8,M)]))}}),P=e.F(N,[[`__scopeId`,`data-v-dbc73bbe`]]),F=[`value`,`disabled`],I=[`value`],L=(0,n.defineComponent)({__name:`LineSpacingPicker`,props:{value:{},options:{},disabled:{type:Boolean,default:!1},className:{}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[{label:`Single`,value:1,twipsValue:240},{label:`1.15`,value:1.15,twipsValue:276},{label:`1.5`,value:1.5,twipsValue:360},{label:`Double`,value:2,twipsValue:480}],o=(0,n.computed)(()=>r.options??a),s=(0,n.computed)(()=>r.value??o.value[0]?.twipsValue??240);function c(e){if(!(e.target instanceof HTMLSelectElement))return;let t=parseInt(e.target.value,10);isNaN(t)||i(`change`,t)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`select`,{class:(0,n.normalizeClass)([`docx-line-spacing`,e.className]),value:String(s.value),disabled:e.disabled,"aria-label":`Line spacing`,onChange:c},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(o.value,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:e.twipsValue,value:String(e.twipsValue)},(0,n.toDisplayString)(e.label),9,I))),128))],42,F))}}),R=e.F(L,[[`__scopeId`,`data-v-c262ff91`]]),z=[`disabled`,`aria-expanded`,`title`,`onClick`],B={class:`docx-table-grid__panel`},V={class:`docx-table-grid__label`},H=[`onMouseenter`,`onClick`],U=(0,n.defineComponent)({__name:`TableGridPicker`,props:{disabled:{type:Boolean,default:!1},gridRows:{default:5},gridColumns:{default:5},tooltip:{default:`Insert table`}},emits:[`insert`],setup(t,{emit:r}){let{Popover:i}=e.y(),a=t,o=r,s=(0,n.ref)(!1),c=(0,n.ref)({rows:1,cols:1}),l=(0,n.computed)(()=>{let e=[];for(let t=1;t<=a.gridRows;t++)for(let n=1;n<=a.gridColumns;n++)e.push({r:t,c:n});return e});function u(e,t){o(`insert`,e,t),s.value=!1}function d(){s.value=!1,c.value={rows:1,cols:1}}return(r,a)=>((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(i),{open:s.value,"onUpdate:open":a[0]||=e=>s.value=e,onClose:d},{trigger:(0,n.withCtx)(({toggle:r})=>[(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-table-grid__btn`,disabled:t.disabled,"aria-expanded":s.value,"aria-haspopup":`grid`,title:t.tooltip,onClick:(0,n.withModifiers)(r,[`prevent`])},[(0,n.createVNode)(e.P,{name:`grid_on`,size:20})],8,z)]),panel:(0,n.withCtx)(()=>[(0,n.createElementVNode)(`div`,B,[(0,n.createElementVNode)(`div`,V,(0,n.toDisplayString)(c.value.rows)+` × `+(0,n.toDisplayString)(c.value.cols),1),(0,n.createElementVNode)(`div`,{class:`docx-table-grid__grid`,style:(0,n.normalizeStyle)({gridTemplateColumns:`repeat(${t.gridColumns}, 18px)`})},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(l.value,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:`${e.r}-${e.c}`,class:(0,n.normalizeClass)([`docx-table-grid__cell`,{"docx-table-grid__cell--active":e.r<=c.value.rows&&e.c<=c.value.cols}]),onMouseenter:t=>c.value={rows:e.r,cols:e.c},onClick:(0,n.withModifiers)(t=>u(e.r,e.c),[`prevent`])},null,42,H))),128))],4)])]),_:1},8,[`open`]))}}),W=e.F(U,[[`__scopeId`,`data-v-2f56c54d`]]),G=[`disabled`,`title`],K={key:0,class:`print-btn__icon`},q=(0,n.defineComponent)({__name:`PrintButton`,props:{disabled:{type:Boolean,default:!1},label:{default:`Print`},compact:{type:Boolean,default:!1}},emits:[`print`],setup(e,{emit:t}){let r=e,i=t;function a(){r.disabled||(i(`print`),window.print())}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{class:`print-btn`,disabled:e.disabled,title:e.label,onMousedown:(0,n.withModifiers)(a,[`prevent`])},[(0,n.createTextVNode)((0,n.toDisplayString)(e.compact?``:e.label)+` `,1),e.compact?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,K,`🖨`)):(0,n.createCommentVNode)(``,!0)],40,G))}}),J=e.F(q,[[`__scopeId`,`data-v-2f2ba140`]]),Y={padding:`8px 10px`,borderRadius:8,backgroundColor:`var(--doc-card)`,cursor:`pointer`,boxShadow:`var(--doc-card-shadow)`},X={padding:`10px 12px`,borderRadius:8,backgroundColor:`var(--doc-surface)`,cursor:`pointer`,boxShadow:`var(--doc-card-shadow-strong)`};exports.AddCommentCard=t.a,exports.AlignmentButtons=t.n,exports.Button=e.N,exports.CARD_STYLE_COLLAPSED=Y,exports.CARD_STYLE_EXPANDED=X,exports.Checkbox=e.M,exports.ColorPicker=e.D,exports.CommentCard=t.c,exports.CommentMarginMarkers=t.D,exports.DEFAULT_COMPONENTS=e.h,exports.DatePickerPopover=e.E,exports.Dialog=e.T,exports.DocumentName=t.E,exports.EditingModeDropdown=t.b,exports.EditorToolbar=l,exports.FindReplaceDialog=e.m,exports.FontPicker=O,exports.FontSizePicker=P,exports.FootnotePropertiesDialog=e.l,exports.HorizontalRuler=t.v,exports.HyperlinkDialog=e.p,exports.IconGridDropdown=t.C,exports.ImagePositionDialog=e.c,exports.ImagePropertiesDialog=e.f,exports.ImageTransformDropdown=t.x,exports.ImageWrapDropdown=t.S,exports.Input=e.w,exports.InsertImageDialog=e.s,exports.InsertSymbolDialog=e.d,exports.InsertTableDialog=e.a,exports.LineSpacingPicker=R,exports.ListButtons=t.t,exports.MenuBar=t.w,exports.MenuDropdown=e.S,exports.OutlineRail=e.x,exports.PageSetupDialog=e.u,exports.PasteSpecialDialog=e.i,exports.Popover=e.C,exports.PrintButton=J,exports.ReplyInput=t.l,exports.ReplyThread=t.u,exports.ResolvedCommentMarker=t.s,exports.Select=e.b,exports.SplitCellDialog=e.r,exports.StylePicker=t.r,exports.TableBorderColorPicker=t.g,exports.TableBorderPicker=t._,exports.TableBorderWidthPicker=t.h,exports.TableCellFillPicker=t.m,exports.TableGridInline=t.T,exports.TableGridPicker=W,exports.TableMoreDropdown=t.p,exports.TablePropertiesDialog=e.n,exports.TableStyleGallery=e.o,exports.TableToolbar=t.f,exports.TitleBar=g,exports.Toolbar=t.y,exports.TrackedChangeCard=t.o,exports.UnifiedSidebar=t.i,exports.VerticalRuler=t.d,exports.WatermarkDialog=e.t,exports.provideFolioUI=e._,exports.resolveFolioComponents=e.v,exports.useFolioUI=e.y; | ||
| Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WatermarkDialog-ChJtT7Bs.cjs"),t=require("./ListButtons-C1rU_Y1e.cjs");let n=require("vue");require("@stll/folio-core/utils/units");var r={class:`docx-editor-toolbar`},i={class:`docx-editor-toolbar__title-row`},a={class:`docx-editor-toolbar__title-left`},o={class:`docx-editor-toolbar__title-center`},s={class:`docx-editor-toolbar__title-right`},c=(0,n.defineComponent)({inheritAttrs:!1,__name:`EditorToolbar`,props:{showMenuBar:{type:Boolean,default:!0}},emits:[`menu-action`],setup(e){return(c,l)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[(0,n.renderSlot)(c.$slots,`title-bar`,{},()=>[(0,n.createElementVNode)(`div`,i,[(0,n.createElementVNode)(`div`,a,[(0,n.renderSlot)(c.$slots,`title-bar-left`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,o,[(0,n.renderSlot)(c.$slots,`document-name`,{},void 0,!0),e.showMenuBar?((0,n.openBlock)(),(0,n.createBlock)(t.w,{key:0,onAction:l[0]||=e=>c.$emit(`menu-action`,e)})):(0,n.createCommentVNode)(``,!0)]),(0,n.createElementVNode)(`div`,s,[(0,n.renderSlot)(c.$slots,`title-bar-right`,{},void 0,!0)])])],!0),(0,n.renderSlot)(c.$slots,`toolbar`,{},()=>[(0,n.createVNode)(t.y,(0,n.normalizeProps)((0,n.guardReactiveProps)(c.$attrs)),null,16)],!0)]))}}),l=e.F(c,[[`__scopeId`,`data-v-79d81064`]]),u={},d={class:`docx-title-bar`},f={class:`docx-title-bar__left`},p={class:`docx-title-bar__center`},m={class:`docx-title-bar__right`};function h(e,t){return(0,n.openBlock)(),(0,n.createElementBlock)(`div`,d,[(0,n.createElementVNode)(`div`,f,[(0,n.renderSlot)(e.$slots,`left`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,p,[(0,n.renderSlot)(e.$slots,`default`,{},void 0,!0)]),(0,n.createElementVNode)(`div`,m,[(0,n.renderSlot)(e.$slots,`right`,{},void 0,!0)])])}var g=e.F(u,[[`render`,h],[`__scopeId`,`data-v-44b23810`]]);function _(e){let t=e.trim();if(!t)return``;let n=null,r=``;for(let e of t){if((e===`"`||e===`'`)&&n===null){n=e,r+=e;continue}if(e===n){n=null,r+=e;continue}if(e===`,`&&n===null)break;r+=e}return r.trim().replace(/^['"]|['"]$/g,``)}var v=[`value`,`disabled`],y={key:0,label:`Sans-serif`},b=[`value`],x={key:1,label:`Serif`},S=[`value`],C={key:2,label:`Monospace`},w=[`value`],T={key:3,label:`Other`},E=[`value`],D=(0,n.defineComponent)({__name:`FontPicker`,props:{value:{},fonts:{},disabled:{type:Boolean,default:!1},className:{},placeholder:{default:`Font`},showPreview:{type:Boolean,default:!0}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[{name:`Arial`,fontFamily:`Arial, Helvetica, sans-serif`,category:`sans-serif`},{name:`Calibri`,fontFamily:`"Calibri", Arial, sans-serif`,category:`sans-serif`},{name:`Helvetica`,fontFamily:`Helvetica, Arial, sans-serif`,category:`sans-serif`},{name:`Verdana`,fontFamily:`Verdana, Geneva, sans-serif`,category:`sans-serif`},{name:`Open Sans`,fontFamily:`"Open Sans", sans-serif`,category:`sans-serif`},{name:`Roboto`,fontFamily:`Roboto, sans-serif`,category:`sans-serif`},{name:`Times New Roman`,fontFamily:`"Times New Roman", Times, serif`,category:`serif`},{name:`Georgia`,fontFamily:`Georgia, serif`,category:`serif`},{name:`Cambria`,fontFamily:`Cambria, Georgia, serif`,category:`serif`},{name:`Garamond`,fontFamily:`Garamond, serif`,category:`serif`},{name:`Courier New`,fontFamily:`"Courier New", monospace`,category:`monospace`},{name:`Consolas`,fontFamily:`Consolas, monospace`,category:`monospace`}],o=(0,n.computed)(()=>r.fonts??a),s=(0,n.computed)(()=>{let e={"sans-serif":[],serif:[],monospace:[],other:[]};for(let t of o.value)e[t.category??`other`].push(t);return e}),c=(0,n.computed)(()=>{let e=r.value;if(!e)return r.placeholder;let t=e.toLowerCase();return o.value.find(n=>n.fontFamily===e||n.name.toLowerCase()===t||_(n.fontFamily).toLowerCase()===t)?.name??e});function l(e){if(!(e.target instanceof HTMLSelectElement))return;let t=e.target.value,n=o.value.find(e=>e.name===t);i(`change`,n?_(n.fontFamily)||n.name:t)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`select`,{class:(0,n.normalizeClass)([`docx-font-picker`,e.className]),value:c.value,disabled:e.disabled,"aria-label":`Font family`,onChange:l},[s.value[`sans-serif`].length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,y,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value[`sans-serif`],t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,b))),128))])):(0,n.createCommentVNode)(``,!0),s.value.serif.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,x,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.serif,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,S))),128))])):(0,n.createCommentVNode)(``,!0),s.value.monospace.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,C,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.monospace,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,w))),128))])):(0,n.createCommentVNode)(``,!0),s.value.other.length?((0,n.openBlock)(),(0,n.createElementBlock)(`optgroup`,T,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(s.value.other,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:t.name,value:t.name,style:(0,n.normalizeStyle)(e.showPreview?{fontFamily:t.fontFamily}:void 0)},(0,n.toDisplayString)(t.name),13,E))),128))])):(0,n.createCommentVNode)(``,!0)],42,v))}}),O=e.F(D,[[`__scopeId`,`data-v-a6d7700f`]]),k={class:`docx-font-size`},A=[`disabled`],j=[`value`,`disabled`,`placeholder`],M=[`disabled`],N=(0,n.defineComponent)({__name:`FontSizePicker`,props:{value:{},sizes:{},disabled:{type:Boolean,default:!1},minSize:{default:1},maxSize:{default:1638},placeholder:{default:`11`}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],o=(0,n.computed)(()=>r.sizes??a),s=(0,n.computed)(()=>r.value??parseInt(r.placeholder,10)??11),c=(0,n.computed)(()=>r.value===void 0?r.placeholder:String(r.value));function l(e){return o.value.find(t=>t>e)??Math.min(e+1,r.maxSize)}function u(e){return[...o.value].reverse().find(t=>t<e)??Math.max(e-1,r.minSize)}function d(){r.disabled||i(`change`,u(s.value))}function f(){r.disabled||i(`change`,l(s.value))}function p(e){if(!(e.target instanceof HTMLInputElement))return;let t=parseFloat(e.target.value);!isNaN(t)&&t>=r.minSize&&t<=r.maxSize&&i(`change`,Math.round(t*2)/2)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,k,[(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-font-size__btn`,disabled:e.disabled||s.value<=e.minSize,title:`Decrease font size`,onClick:(0,n.withModifiers)(d,[`prevent`])},` − `,8,A),(0,n.createElementVNode)(`input`,{class:`docx-font-size__input`,type:`text`,value:c.value,disabled:e.disabled,placeholder:e.placeholder,onKeydown:[r[0]||=(0,n.withKeys)((0,n.withModifiers)(e=>{d(),e.stopPropagation()},[`prevent`]),[`up`]),r[1]||=(0,n.withKeys)((0,n.withModifiers)(e=>{f(),e.stopPropagation()},[`prevent`]),[`down`]),r[2]||=(0,n.withKeys)((0,n.withModifiers)(e=>p(e),[`prevent`]),[`enter`])],onBlur:r[3]||=e=>p(e)},null,40,j),(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-font-size__btn`,disabled:e.disabled||s.value>=e.maxSize,title:`Increase font size`,onClick:(0,n.withModifiers)(f,[`prevent`])},` + `,8,M)]))}}),P=e.F(N,[[`__scopeId`,`data-v-dbc73bbe`]]),F=[`value`,`disabled`],I=[`value`],L=(0,n.defineComponent)({__name:`LineSpacingPicker`,props:{value:{},options:{},disabled:{type:Boolean,default:!1},className:{}},emits:[`change`],setup(e,{emit:t}){let r=e,i=t,a=[{label:`Single`,value:1,twipsValue:240},{label:`1.15`,value:1.15,twipsValue:276},{label:`1.5`,value:1.5,twipsValue:360},{label:`Double`,value:2,twipsValue:480}],o=(0,n.computed)(()=>r.options??a),s=(0,n.computed)(()=>r.value??o.value[0]?.twipsValue??240);function c(e){if(!(e.target instanceof HTMLSelectElement))return;let t=parseInt(e.target.value,10);isNaN(t)||i(`change`,t)}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`select`,{class:(0,n.normalizeClass)([`docx-line-spacing`,e.className]),value:String(s.value),disabled:e.disabled,"aria-label":`Line spacing`,onChange:c},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(o.value,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`option`,{key:e.twipsValue,value:String(e.twipsValue)},(0,n.toDisplayString)(e.label),9,I))),128))],42,F))}}),R=e.F(L,[[`__scopeId`,`data-v-c262ff91`]]),z=[`disabled`,`aria-expanded`,`title`,`onClick`],B={class:`docx-table-grid__panel`},V={class:`docx-table-grid__label`},H=[`onMouseenter`,`onClick`],U=(0,n.defineComponent)({__name:`TableGridPicker`,props:{disabled:{type:Boolean,default:!1},gridRows:{default:5},gridColumns:{default:5},tooltip:{default:`Insert table`}},emits:[`insert`],setup(t,{emit:r}){let{Popover:i}=e.y(),a=t,o=r,s=(0,n.ref)(!1),c=(0,n.ref)({rows:1,cols:1}),l=(0,n.computed)(()=>{let e=[];for(let t=1;t<=a.gridRows;t++)for(let n=1;n<=a.gridColumns;n++)e.push({r:t,c:n});return e});function u(e,t){o(`insert`,e,t),s.value=!1}function d(){s.value=!1,c.value={rows:1,cols:1}}return(r,a)=>((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(i),{open:s.value,"onUpdate:open":a[0]||=e=>s.value=e,onClose:d},{trigger:(0,n.withCtx)(({toggle:r})=>[(0,n.createElementVNode)(`button`,{type:`button`,class:`docx-table-grid__btn`,disabled:t.disabled,"aria-expanded":s.value,"aria-haspopup":`grid`,title:t.tooltip,onClick:(0,n.withModifiers)(r,[`prevent`])},[(0,n.createVNode)(e.P,{name:`grid_on`,size:20})],8,z)]),panel:(0,n.withCtx)(()=>[(0,n.createElementVNode)(`div`,B,[(0,n.createElementVNode)(`div`,V,(0,n.toDisplayString)(c.value.rows)+` × `+(0,n.toDisplayString)(c.value.cols),1),(0,n.createElementVNode)(`div`,{class:`docx-table-grid__grid`,style:(0,n.normalizeStyle)({gridTemplateColumns:`repeat(${t.gridColumns}, 18px)`})},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(l.value,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:`${e.r}-${e.c}`,class:(0,n.normalizeClass)([`docx-table-grid__cell`,{"docx-table-grid__cell--active":e.r<=c.value.rows&&e.c<=c.value.cols}]),onMouseenter:t=>c.value={rows:e.r,cols:e.c},onClick:(0,n.withModifiers)(t=>u(e.r,e.c),[`prevent`])},null,42,H))),128))],4)])]),_:1},8,[`open`]))}}),W=e.F(U,[[`__scopeId`,`data-v-2f56c54d`]]),G=[`disabled`,`title`],K={key:0,class:`print-btn__icon`},q=(0,n.defineComponent)({__name:`PrintButton`,props:{disabled:{type:Boolean,default:!1},label:{default:`Print`},compact:{type:Boolean,default:!1}},emits:[`print`],setup(e,{emit:t}){let r=e,i=t;function a(){r.disabled||(i(`print`),window.print())}return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{class:`print-btn`,disabled:e.disabled,title:e.label,onMousedown:(0,n.withModifiers)(a,[`prevent`])},[(0,n.createTextVNode)((0,n.toDisplayString)(e.compact?``:e.label)+` `,1),e.compact?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,K,`🖨`)):(0,n.createCommentVNode)(``,!0)],40,G))}}),J=e.F(q,[[`__scopeId`,`data-v-2f2ba140`]]),Y={padding:`8px 10px`,borderRadius:8,backgroundColor:`var(--doc-card)`,cursor:`pointer`,boxShadow:`var(--doc-card-shadow)`},X={padding:`10px 12px`,borderRadius:8,backgroundColor:`var(--doc-surface)`,cursor:`pointer`,boxShadow:`var(--doc-card-shadow-strong)`};exports.AddCommentCard=t.a,exports.AlignmentButtons=t.n,exports.Button=e.N,exports.CARD_STYLE_COLLAPSED=Y,exports.CARD_STYLE_EXPANDED=X,exports.Checkbox=e.M,exports.ColorPicker=e.D,exports.CommentCard=t.c,exports.CommentMarginMarkers=t.D,exports.DEFAULT_COMPONENTS=e.h,exports.DatePickerPopover=e.E,exports.Dialog=e.T,exports.DocumentName=t.E,exports.EditingModeDropdown=t.b,exports.EditorToolbar=l,exports.FindReplaceDialog=e.m,exports.FontPicker=O,exports.FontSizePicker=P,exports.FootnotePropertiesDialog=e.l,exports.HorizontalRuler=t.v,exports.HyperlinkDialog=e.p,exports.IconGridDropdown=t.C,exports.ImagePositionDialog=e.c,exports.ImagePropertiesDialog=e.f,exports.ImageTransformDropdown=t.x,exports.ImageWrapDropdown=t.S,exports.Input=e.w,exports.InsertImageDialog=e.s,exports.InsertSymbolDialog=e.d,exports.InsertTableDialog=e.a,exports.LineSpacingPicker=R,exports.ListButtons=t.t,exports.MenuBar=t.w,exports.MenuDropdown=e.S,exports.OutlineRail=e.x,exports.PageSetupDialog=e.u,exports.PasteSpecialDialog=e.i,exports.Popover=e.C,exports.PrintButton=J,exports.ReplyInput=t.l,exports.ReplyThread=t.u,exports.ResolvedCommentMarker=t.s,exports.Select=e.b,exports.SplitCellDialog=e.r,exports.StylePicker=t.r,exports.TableBorderColorPicker=t.g,exports.TableBorderPicker=t._,exports.TableBorderWidthPicker=t.h,exports.TableCellFillPicker=t.m,exports.TableGridInline=t.T,exports.TableGridPicker=W,exports.TableMoreDropdown=t.p,exports.TablePropertiesDialog=e.n,exports.TableStyleGallery=e.o,exports.TableToolbar=t.f,exports.TitleBar=g,exports.Toolbar=t.y,exports.TrackedChangeCard=t.o,exports.UnifiedSidebar=t.i,exports.VerticalRuler=t.d,exports.WatermarkDialog=e.t,exports.provideFolioUI=e._,exports.resolveFolioComponents=e.v,exports.useFolioUI=e.y; |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { C as e, D as t, E as n, F as r, M as i, N as a, P as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as ee, f as te, h as ne, i as re, l as ie, m as ae, n as oe, o as se, p as ce, r as p, s as le, t as ue, u as de, v as m, w as fe, x as pe, y as h } from "./WatermarkDialog-r4wmldt4.js"; | ||
| import { C as me, D as he, E as ge, S as _e, T as ve, _ as ye, a as be, b as g, c as _, d as v, f as y, g as b, h as x, i as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, u as j, v as M, w as N, x as xe, y as P } from "./ListButtons-DXqMvba3.js"; | ||
| import { C as e, D as t, E as n, F as r, M as i, N as a, P as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as ee, f as te, h as ne, i as re, l as ie, m as ae, n as oe, o as se, p as ce, r as p, s as le, t as ue, u as de, v as m, w as fe, x as pe, y as h } from "./WatermarkDialog-Cf9ISDvv.js"; | ||
| import { C as me, D as he, E as ge, S as _e, T as ve, _ as ye, a as be, b as g, c as _, d as v, f as y, g as b, h as x, i as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, u as j, v as M, w as N, x as xe, y as P } from "./ListButtons-DMnOM2pN.js"; | ||
| import { Fragment as F, computed as I, createBlock as L, createCommentVNode as R, createElementBlock as z, createElementVNode as B, createTextVNode as Se, createVNode as V, defineComponent as H, guardReactiveProps as Ce, normalizeClass as U, normalizeProps as we, normalizeStyle as W, openBlock as G, ref as K, renderList as q, renderSlot as J, toDisplayString as Y, unref as Te, withCtx as X, withKeys as Z, withModifiers as Q } from "vue"; | ||
@@ -4,0 +4,0 @@ import "@stll/folio-core/utils/units"; |
+1
-1
| { | ||
| "name": "@stll/folio-vue", | ||
| "version": "0.8.1", | ||
| "version": "0.9.0", | ||
| "description": "Vue 3 editor for folio: a Word-document (.docx) editor for the browser, built on @stll/folio-core and ProseMirror.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
| /** Minimal shape the layout pass needs from a sidebar item. */ | ||
| export type ResolvableSidebarItem = { | ||
| id: string; | ||
| anchorPos: number; | ||
| anchorKey?: string; | ||
| priority?: number; | ||
| fixedY?: number; | ||
| estimatedHeight?: number; | ||
| }; | ||
| export type ResolvedPosition<T extends ResolvableSidebarItem = ResolvableSidebarItem> = { | ||
| item: T; | ||
| y: number; | ||
| }; | ||
| /** | ||
| * Given a list of sidebar items plus their anchor sources, return resolved Y | ||
| * positions with collision avoidance applied. Items resolve their target Y from | ||
| * (1) an explicit `fixedY`, (2) an `anchorKey` lookup in `anchorPositions` | ||
| * (layout-engine coords scaled by `zoom`), or (3) the last-known cache so cards | ||
| * don't pop out during transient layout. Overlapping cards are then pushed down | ||
| * by their measured height + `MIN_CARD_GAP`. | ||
| */ | ||
| export declare function resolveItemPositions<T extends ResolvableSidebarItem>(items: T[], anchorPositions: Map<string, number>, zoom: number, cardHeights: Map<string, number>, lastKnown: Map<string, number>): ResolvedPosition<T>[]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 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}}); |
| import { computed as e, onBeforeUnmount as t, onMounted as n, onScopeDispose as r, ref as i, shallowRef as a, toValue as o, watch as s } from "vue"; | ||
| import { getMargins as c, getPageSize as l, twipsToPixels as u } from "@stll/folio-core/paged-layout/sectionGeometry"; | ||
| import { createAnonymizationDecorationsPlugin as d } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations"; | ||
| import { createTemplateDirectivesPlugin as f } from "@stll/folio-core/prosemirror/plugins/templateDirectives"; | ||
| import { createSuggestionModePlugin as p, setSuggestionMode as m } from "@stll/folio-core/prosemirror/plugins/suggestionMode"; | ||
| import { createFolioEditor as h } from "@stll/folio-core/controller/folioEditor"; | ||
| import { createFolioEditorEmitter as ee } from "@stll/folio-core/controller/folioEditorEvents"; | ||
| import { createHiddenEditorManager as g, createHiddenEditorState as _ } from "@stll/folio-core/controller/hiddenEditorManager"; | ||
| import { runLayoutPipeline as te } from "@stll/folio-core/controller/layoutPipeline"; | ||
| import { browserClock as v, createLayoutScheduler as ne } from "@stll/folio-core/controller/layoutScheduler"; | ||
| import { createLayoutSession as re } from "@stll/folio-core/controller/layoutSession"; | ||
| import { parseDocx as ie } from "@stll/folio-core/docx/parser"; | ||
| import { getFootnoteText as y } from "@stll/folio-core/docx/footnoteParser"; | ||
| import { convertHeaderFooterPmDocToContent as b, convertHeaderFooterToContent as x } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout"; | ||
| import { resolveSectionHeaderFooterRefs as ae } from "@stll/folio-core/layout-engine"; | ||
| import { LayoutPainter as oe } from "@stll/folio-core/layout-painter"; | ||
| import { LayoutSelectionGate as se } from "@stll/folio-core/paged-layout/LayoutSelectionGate"; | ||
| import { getTransactionDirtyRange as ce } from "@stll/folio-core/paged-layout/transactionDirtyRange"; | ||
| import { fromProseDoc as le } from "@stll/folio-core/prosemirror/conversion/fromProseDoc"; | ||
| import { ExtensionManager as ue } from "@stll/folio-core/prosemirror/extensions/ExtensionManager"; | ||
| import { getChangedParagraphIds as de, hasStructuralChanges as fe, hasUntrackedChanges as pe } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"; | ||
| import { createStarterKit as me } from "@stll/folio-core/prosemirror/extensions/StarterKit"; | ||
| import { createTemplatePreviewValuesPlugin as he } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues"; | ||
| import { templateSlashMenuPlugin as ge } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu"; | ||
| import { findVerticalScrollParent as S } from "@stll/folio-core/utils/findVerticalScrollParent"; | ||
| import { MIN_CELL_WIDTH_TWIPS as C, MIN_ROW_HEIGHT_TWIPS as _e, TWIPS_PER_PIXEL as w, commitColumnResize as T, commitRightEdgeResize as E, commitRowResize as D, readColumnWidthAt as ve, readColumnWidths as O, readRowHeight as ye } from "@stll/folio-core/prosemirror/tableResize"; | ||
| import { extractTrackedChanges as k } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges"; | ||
| import { ZOOM_MAX as be, ZOOM_MIN as xe, ZOOM_STEP as A } from "@stll/folio-core/utils/zoom"; | ||
| //#region src/composables/useDocxEditor.ts | ||
| var Se = 24, Ce = 32, we = 96, Te = 250, Ee = []; | ||
| function De(e) { | ||
| let t = e?.columnCount ?? 1; | ||
| if (t <= 1) return; | ||
| let n = { | ||
| count: t, | ||
| gap: u(e?.columnSpace ?? 720), | ||
| equalWidth: e?.equalWidth ?? !0 | ||
| }; | ||
| return e?.separator !== void 0 && (n.separator = e.separator), n; | ||
| } | ||
| var j = { | ||
| hf: null, | ||
| rId: null | ||
| }; | ||
| function Oe(e, t) { | ||
| let n = e?.package; | ||
| if (!n || !t) return { | ||
| header: j, | ||
| footer: j, | ||
| firstHeader: j, | ||
| firstFooter: j | ||
| }; | ||
| 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 M(e, t, n, r, i, a) { | ||
| if (!e) return; | ||
| let o = t ? { | ||
| ...a, | ||
| rId: t | ||
| } : a, s = t ? n?.getView(t) : null; | ||
| return s ? b(s.state.doc, r, i, o) : x(e, r, i, o); | ||
| } | ||
| function ke(e, t, n, r, i) { | ||
| if (!e || e.size === 0) return; | ||
| let a = /* @__PURE__ */ new Map(); | ||
| for (let [o, s] of e) { | ||
| let e = M(s, o, t, n, r, i); | ||
| e && a.set(o, e); | ||
| } | ||
| return a.size > 0 ? a : void 0; | ||
| } | ||
| function Ae(e, t, n) { | ||
| let r = /* @__PURE__ */ new Map(); | ||
| if (!n || !n.package.footnotes) return r; | ||
| let i = /* @__PURE__ */ 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: y(r), | ||
| ...a ? { content: { | ||
| blocks: a.blocks, | ||
| measures: a.measures, | ||
| height: a.height | ||
| } } : {} | ||
| }); | ||
| } | ||
| e.length > 0 && r.set(n, e); | ||
| } | ||
| return r; | ||
| } | ||
| var N = /* @__PURE__ */ new Set([ | ||
| "black", | ||
| "blue", | ||
| "cyan", | ||
| "darkBlue", | ||
| "darkCyan", | ||
| "darkGray", | ||
| "darkGreen", | ||
| "darkMagenta", | ||
| "darkRed", | ||
| "darkYellow", | ||
| "green", | ||
| "lightGray", | ||
| "magenta", | ||
| "none", | ||
| "red", | ||
| "white", | ||
| "yellow" | ||
| ]); | ||
| function je(e) { | ||
| let t = [], n = (e, r) => { | ||
| for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !N.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 P(e) { | ||
| let { hiddenContainer: t, pagesContainer: n, readOnly: u = !1, pageGap: y = Se, documentKey: b, password: x, editorMode: S, author: C, externalPlugins: _e = [], onAnonymizationMatchesChange: w, showTemplateDirectives: T, onSlashMenuChange: E, onSlashMenuKeyAction: D, onChange: ve, onError: O, onSelectionUpdate: ye, onEditorViewReady: k, onReadOnlyEditAttempt: be, featureFlags: xe, onSelectiveSaveTripwire: A } = e, j = a(null), N = a(null), P = a(null), F = a(null), I = a([]), L = a([]), R = i(!1), z = i(null), B = i(!1), V = new ue(me()); | ||
| V.buildSchema(), V.initializeRuntime(); | ||
| let H = p(!1), U = d({ onMatchesChange: (e) => w?.(e) }), W = f(), G = ge({ | ||
| onChange: (e) => E?.(e), | ||
| onKeyAction: (e) => D?.(e) ?? !1 | ||
| }), Ne = he(), K = () => o(T) === !0; | ||
| function Pe() { | ||
| return [ | ||
| H, | ||
| ..._e, | ||
| U, | ||
| ...K() ? [W, G] : [], | ||
| Ne | ||
| ]; | ||
| } | ||
| let q = ee(), J = new se(), Fe = re(), Y = new oe({ | ||
| pageGap: y, | ||
| showShadow: !0 | ||
| }); | ||
| function Ie(e) { | ||
| e.layout && (F.value = e.layout), e.blocks && (I.value = e.blocks), e.measures && (L.value = e.measures), e.blockLookup && Y.setBlockLookup(e.blockLookup), e.layout && q.emit("layoutComplete", e.layout); | ||
| } | ||
| function X(e, t = {}) { | ||
| let r = n.value, i = r instanceof HTMLDivElement ? r : null, a = j.value, o = a?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, u = l(s), d = c(s), f = De(s), p = u.w - d.left - d.right, m = a?.package.styles ?? null, h = a?.package.theme ?? null, ee = a?.package.settings?.defaultTabStop, g = a?.package.settings, _ = g !== void 0 && "mirrorMargins" in g && g.mirrorMargins === !0, v = Oe(a, s); | ||
| try { | ||
| Ie(te({ | ||
| contentWidth: p, | ||
| columns: f, | ||
| pageSize: u, | ||
| margins: d, | ||
| pageGap: y, | ||
| syncCoordinator: J, | ||
| headerContent: v.header.hf, | ||
| footerContent: v.footer.hf, | ||
| firstPageHeaderContent: v.firstHeader.hf, | ||
| firstPageFooterContent: v.firstFooter.hf, | ||
| headerContentRId: v.header.rId, | ||
| footerContentRId: v.footer.rId, | ||
| firstPageHeaderContentRId: v.firstHeader.rId, | ||
| firstPageFooterContentRId: v.firstFooter.rId, | ||
| sectionHeaderFooterRefs: ae(a), | ||
| theme: h, | ||
| sectionProperties: s, | ||
| document: a, | ||
| defaultTabStop: ee, | ||
| mirrorMargins: _, | ||
| styles: m, | ||
| layout: F.value, | ||
| hfPMs: null, | ||
| painter: Y, | ||
| pagesContainer: i, | ||
| session: Fe, | ||
| renderHfFromContentOrPm: M, | ||
| renderHeaderFooterContentByRId: ke, | ||
| documentFontsAreLoaded: Me, | ||
| buildFootnoteRenderItems: Ae, | ||
| describeInvalidHighlightMarks: je, | ||
| emptyTemplatePreviewEntries: Ee | ||
| }, e, t)); | ||
| } catch (e) { | ||
| let t = e instanceof Error ? e : Error(String(e)); | ||
| O?.(t); | ||
| } | ||
| } | ||
| let Z = ne({ | ||
| runLayout: (e, t) => X(e, t), | ||
| debounceMs: Ce, | ||
| maxDelayMs: we, | ||
| clock: v | ||
| }), Q = null; | ||
| function Le() { | ||
| Q !== null && (window.clearTimeout(Q), Q = null); | ||
| let e = N.value, t = j.value; | ||
| if (!(!e || !t)) try { | ||
| let n = le(e.state.doc, t); | ||
| j.value = n, ve?.(n), q.emit("docChange", n); | ||
| } catch (e) { | ||
| O?.(e instanceof Error ? e : Error(String(e))); | ||
| } | ||
| } | ||
| function Re() { | ||
| Q !== null && window.clearTimeout(Q), Q = window.setTimeout(() => { | ||
| Q = null, Le(); | ||
| }, Te); | ||
| } | ||
| let $ = g({ | ||
| getHost: () => t.value, | ||
| getDocument: () => j.value, | ||
| getStyles: () => j.value?.package.styles ?? null, | ||
| getExtensionManager: () => V, | ||
| getExternalPlugins: Pe, | ||
| getCollaboration: () => void 0, | ||
| getCollaborationModules: () => null, | ||
| getPrecomputedInitialState: () => null, | ||
| getReadOnly: () => o(u), | ||
| getDocumentKey: () => o(b), | ||
| getDocumentContext: () => j.value, | ||
| onTransaction: ze, | ||
| onSelectionChange: (e) => { | ||
| P.value = e, ye?.(e), q.emit("selectionChange", { | ||
| from: e.selection.from, | ||
| to: e.selection.to | ||
| }); | ||
| }, | ||
| onKeyDown: () => !1, | ||
| onReadOnlyEditAttempt: () => be?.(), | ||
| onEditorViewReady: Be, | ||
| onEditorViewDestroy: () => { | ||
| N.value = null, R.value = !1, k?.(null); | ||
| }, | ||
| onRemoteSelectionsChange: () => {} | ||
| }); | ||
| function ze(e, t) { | ||
| P.value = t, e.docChanged && (B.value = !0, J.incrementStateSeq(), Z.schedule(t, ce(e)), Re()), J.requestRender(); | ||
| } | ||
| function Be(e) { | ||
| N.value = e, P.value = e.state, R.value = !0, X(e.state, { reason: "initial" }), J.requestRender(), He(e), k?.(e), o(u) || requestAnimationFrame(() => { | ||
| N.value === e && e.focus(); | ||
| }); | ||
| } | ||
| let Ve = h({ | ||
| getEditorApi: () => $.api, | ||
| getLayout: () => F.value, | ||
| runLayout: (e, t) => X(e, t), | ||
| emitter: q | ||
| }); | ||
| function He(e) { | ||
| m(o(S) === "suggesting", e.state, e.dispatch, o(C)); | ||
| } | ||
| s([() => o(S), () => o(C)], () => { | ||
| let e = N.value; | ||
| e && He(e); | ||
| }), s(() => o(u), () => $.syncEditable()); | ||
| function Ue(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(Ne), t = e === -1 ? n.length : e; | ||
| n.splice(t, 0, W, G); | ||
| } | ||
| e.updateState(e.state.reconfigure({ plugins: n })); | ||
| } | ||
| s(() => K(), () => { | ||
| let e = N.value; | ||
| e && Ue(e); | ||
| }); | ||
| function We() { | ||
| $.ensureView(); | ||
| } | ||
| function Ge() { | ||
| B.value = !1, Z.dispose(), $.destroyView(), $.ensureView(), $.getView() || Ke(); | ||
| } | ||
| function Ke() { | ||
| let e = j.value; | ||
| if (e) try { | ||
| let t = _({ | ||
| document: e, | ||
| styles: e.package.styles ?? null, | ||
| manager: V, | ||
| externalPlugins: Pe(), | ||
| collaborationModules: null, | ||
| reason: "mount" | ||
| }); | ||
| P.value = t, X(t, { reason: "initial" }); | ||
| } catch (e) { | ||
| O?.(e instanceof Error ? e : Error(String(e))); | ||
| } | ||
| } | ||
| s([t, n], () => { | ||
| t.value && j.value && !$.getView() && We(); | ||
| }, { flush: "post" }); | ||
| async function qe(e) { | ||
| z.value = null, R.value = !1; | ||
| try { | ||
| let t = await ie(e, { password: o(x) }); | ||
| j.value = t, Ge(); | ||
| } catch (e) { | ||
| let t = e instanceof Error ? e : Error(String(e)); | ||
| z.value = t.message, O?.(t); | ||
| } | ||
| } | ||
| function Je(e) { | ||
| z.value = null, j.value = e, Ge(); | ||
| } | ||
| async function Ye(e) { | ||
| let t = N.value, n = j.value; | ||
| if (!t || !n) return null; | ||
| let r = t.state, { resolveSelectiveSaveFlags: i } = await import("@stll/folio-core/docx/selectiveSaveFlags"), a = i(o(xe)), s = le(r.doc, n), c = s.originalBuffer ?? null, l = a.selectiveSave && e?.selective !== !1, u = l || a.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: de(r), | ||
| structuralChange: fe(r), | ||
| hasUntrackedChanges: pe(r), | ||
| maxBytes: a.selectiveSaveMaxBytes | ||
| }); | ||
| } | ||
| let m = l ? p : null, h = null; | ||
| if (!m) h = c ? await d(s) : await f(s), m = h; | ||
| else if (a.selectiveSaveTripwire) try { | ||
| h = await d(s); | ||
| } catch {} | ||
| if (a.selectiveSaveTripwire && h && A) try { | ||
| let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire"); | ||
| A(await e(p, h)); | ||
| } catch {} | ||
| return B.value = !1, new Blob([m], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }); | ||
| } | ||
| function Xe() { | ||
| return j.value; | ||
| } | ||
| function Ze(e) { | ||
| j.value = e; | ||
| } | ||
| function Qe() { | ||
| return V.getCommands(); | ||
| } | ||
| function $e() { | ||
| N.value?.focus(); | ||
| } | ||
| function et() { | ||
| let e = N.value; | ||
| e && X(e.state, { reason: "manual" }); | ||
| } | ||
| function tt() { | ||
| Z.dispose(), Q !== null && (window.clearTimeout(Q), Q = null), $.destroyView(), V.destroy(), P.value = null, F.value = null, j.value = null, R.value = !1; | ||
| } | ||
| return r(tt), { | ||
| editor: Ve, | ||
| editorView: N, | ||
| editorState: P, | ||
| isReady: R, | ||
| isDirty: B, | ||
| parseError: z, | ||
| layout: F, | ||
| blocks: I, | ||
| measures: L, | ||
| loadBuffer: qe, | ||
| loadDocument: Je, | ||
| save: Ye, | ||
| getDocument: Xe, | ||
| setDocument: Ze, | ||
| getCommands: Qe, | ||
| focus: $e, | ||
| reLayout: et, | ||
| destroy: tt | ||
| }; | ||
| } | ||
| function F(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; | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useDragAutoScroll.ts | ||
| function I({ pagesContainer: e, onScrollExtendSelection: t }) { | ||
| let n = null, i = 0, a = 0, o = !1, s = null; | ||
| function c() { | ||
| if (s) return s; | ||
| let t = e.value; | ||
| return t ? (s = S(t), s) : null; | ||
| } | ||
| function l() { | ||
| o = !1, n !== null && (cancelAnimationFrame(n), n = null); | ||
| } | ||
| function u() { | ||
| if (!o) return; | ||
| let e = c(); | ||
| if (!e) return; | ||
| let r = F(e.getBoundingClientRect(), a); | ||
| r !== 0 && (e.scrollTop += r, t(i, a)), n = requestAnimationFrame(u); | ||
| } | ||
| function d() { | ||
| o || (o = !0, n = 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 r(() => l()), { | ||
| updateMousePosition: f, | ||
| stopAutoScroll: l | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useTableResize.ts | ||
| function L() { | ||
| 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), R(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), z(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), B(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 * w), a = e.origWidths.left + i, o = e.origWidths.right - i; | ||
| a >= C && o >= C && (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 * w), a = t.origHeight + i; | ||
| a >= _e && (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 * w), a = n.origWidth + i; | ||
| a >= C && (n.origWidth = a); | ||
| } | ||
| } | ||
| function s(i) { | ||
| if (e.active) { | ||
| e.active = !1, e.handle?.classList.remove("dragging"), r && T(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 && D(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 && E(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 R(e, t) { | ||
| let n = O(e, t.tablePmStart, t.columnIndex); | ||
| n && (t.origWidths = n); | ||
| } | ||
| function z(e, t, n) { | ||
| let r = ye(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 * w); | ||
| } | ||
| function B(e, t) { | ||
| let n = ve(e, t.tablePmStart, t.columnIndex); | ||
| n != null && (t.origWidth = n); | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useTrackedChanges.ts | ||
| function V(t, n) { | ||
| return e(() => (n.value, k(t.value?.state ?? null))); | ||
| } | ||
| //#endregion | ||
| //#region src/composables/useZoom.ts | ||
| var H = xe, U = be, W = [ | ||
| .5, | ||
| .75, | ||
| 1, | ||
| 1.25, | ||
| 1.5, | ||
| 2 | ||
| ]; | ||
| function G(r = 1) { | ||
| let a = i(Math.max(H, Math.min(U, r))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= H), c = e(() => a.value >= U); | ||
| function l(e) { | ||
| a.value = Math.max(H, Math.min(U, Math.round(e * 100) / 100)); | ||
| } | ||
| function u() { | ||
| l(a.value + A); | ||
| } | ||
| function d() { | ||
| l(a.value - A); | ||
| } | ||
| function f() { | ||
| l(1); | ||
| } | ||
| function p(e) { | ||
| (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d()); | ||
| } | ||
| function m(e) { | ||
| (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f()))); | ||
| } | ||
| function h() { | ||
| n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m)); | ||
| } | ||
| return { | ||
| zoom: a, | ||
| zoomPercent: o, | ||
| isMinZoom: s, | ||
| isMaxZoom: c, | ||
| setZoom: l, | ||
| zoomIn: u, | ||
| zoomOut: d, | ||
| resetZoom: f, | ||
| handleWheel: p, | ||
| handleKeyDown: m, | ||
| installShortcuts: h, | ||
| ZOOM_PRESETS: W | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { I as a, L as i, k as n, P as o, V as r, G as t }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| //#region src/styles/zIndex.ts | ||
| var e = { | ||
| selectionOverlay: 10, | ||
| decorationLayer: 11, | ||
| imageOverlay: 15, | ||
| hfInlineEditor: 10, | ||
| ruler: 30, | ||
| dropdown: 100, | ||
| contextMenu: 1e4 | ||
| }; | ||
| //#endregion | ||
| export { e as t }; |
| var e={selectionOverlay:10,decorationLayer:11,imageOverlay:15,hfInlineEditor:10,ruler:30,dropdown:100,contextMenu:1e4};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1217703
2.36%108
1.89%20517
2.13%14
7.69%1
Infinity%