@eigenpal/docx-editor-vue 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useCommentLifecycle.d.ts +3 -0
- package/dist/composables/useCommentManagement.d.ts +6 -0
- package/dist/composables/useFormattingActions.d.ts +2 -22
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +85 -129
- package/dist/docx-editor-vue.css +1 -1
- package/dist/index.cjs +9 -10
- package/dist/index.js +873 -1083
- package/dist/useDragAutoScroll-BT6oPYBj.cjs +1 -0
- package/dist/useDragAutoScroll-C56F_WS_.js +493 -0
- package/dist/utils/refApiQueries.d.ts +8 -44
- package/package.json +4 -4
- package/dist/useTableResize-DBpEiuGQ.cjs +0 -1
- package/dist/useTableResize-uq2ksRDf.js +0 -587
- package/dist/utils/commentFactories.d.ts +0 -7
- package/dist/utils/paraTextHelpers.d.ts +0 -29
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@eigenpal/docx-editor-core/layout-bridge`),r=require(`@eigenpal/docx-editor-core/layout-painter`),i=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),a=require(`@eigenpal/docx-editor-core/prosemirror`),o=require(`prosemirror-view`),s=require(`@eigenpal/docx-editor-core/docx/parser`),c=require(`@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc`),l=require(`@eigenpal/docx-editor-core/prosemirror/schema`),u=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),d=require(`@eigenpal/docx-editor-core/prosemirror/extensions`),f=require(`@eigenpal/docx-editor-core/layout-bridge/measuring`),p=require(`@eigenpal/docx-editor-core/editor`),m=require(`@eigenpal/docx-editor-core/layout-engine`),h=require(`@eigenpal/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@eigenpal/docx-editor-core/prosemirror/editor.css`);let g=require(`@eigenpal/docx-editor-core/prosemirror/tableResize`),_=require(`@eigenpal/docx-editor-core/utils/findVerticalScrollParent`),v=require(`@eigenpal/docx-editor-core/utils/autoScroll`);var y=24;function b(e,t,r,i){switch(e.kind){case`paragraph`:return(0,f.measureParagraph)(e,t,{floatingZones:r,paragraphYOffset:i??0});case`table`:return(0,n.measureTableBlock)(e,t,b);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??m.DEFAULT_TEXTBOX_MARGINS,r=(t.width??m.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,i=t.content.map(e=>(0,f.measureParagraph)(e,r)),a=i.reduce((e,t)=>e+t.totalHeight,0),o=t.height??a+n.top+n.bottom;return{kind:`textBox`,width:t.width??m.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,m.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function x(e,t,n){return(0,f.measureBlocksWithFloats)(e,t,b,n)}function S(f){let{hiddenContainer:m,pagesContainer:g,readOnly:_=!1,pageGap:v=y,onChange:b,onError:S,onSelectionUpdate:C,externalPlugins:w=[],syncCoordinator:T,editorMode:E,author:D}=f,O=(0,e.shallowRef)(null),k=(0,e.shallowRef)(null),A=(0,e.shallowRef)(null),j=(0,e.ref)(!1),M=(0,e.ref)(null),N=(0,e.shallowRef)(null),P=l.singletonManager;function F(e){let t=g.value;if(!t||!O.value)return;let i=T?.getStateSeq()??0;T?.onLayoutStart();let a=O.value.package?.document,o=a?.sections?.[0]?.properties??a?.finalSectionProperties??null,s=a?.finalSectionProperties??o,c=(0,n.getPageSize)(o),l=(0,n.getMargins)(o),u=(0,n.getPageSize)(s),d=(0,n.getMargins)(s),f=(0,n.getColumns)(o),m=(0,n.getColumns)(s),_=c.w-l.left-l.right,y=O.value.package?.theme??null,b=O.value.package?.styles??null;try{let{header:i,footer:a,firstHeader:g,firstFooter:S}=(0,n.resolveHeaderFooter)(O.value,o),{blocks:C,measures:w,layout:T,headerContentForRender:E,footerContentForRender:D,firstPageHeaderForRender:k,firstPageFooterForRender:A,hasTitlePg:j,watermark:M,footnotesByPage:P}=(0,p.computeLayout)({state:e,document:O.value,pageSize:c,margins:l,columns:f,finalPageSize:u,finalMargins:d,finalColumns:m,pageGap:v,contentWidth:_,theme:y,styles:b,sectionProperties:o,finalSectionProperties:s,headerContent:i,footerContent:a,firstPageHeaderContent:g,firstPageFooterContent:S,measureBlocks:x,getHfPmDoc:e=>W(e)?.state.doc??null});N.value=T;let F=(0,r.buildBlockLookup)(C,w);(0,h.renderPages)(T.pages,t,{pageGap:v,showShadow:!0,pageBackground:`#fff`,blockLookup:F,theme:y,headerContent:E,footerContent:D,firstPageHeaderContent:k,firstPageFooterContent:A,titlePage:j,watermark:M,footnotesByPage:P}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,r.applySdtFocus)(t,(0,r.enclosingSdtGroupIds)(e.doc,e.selection.from,e.selection.to))}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),S?.(e instanceof Error?e:Error(String(e)))}finally{T?.onLayoutComplete(i)}}let I=(0,p.createLayoutScheduler)(F);function L(){let n=m.value;if(!n)return;let a=O.value?.package?.styles,s=O.value?(0,i.toProseDoc)(O.value,{styles:a??void 0}):(0,i.createEmptyDoc)(),l=(0,u.createSuggestionModePlugin)(!1),d=(0,u.createDocumentStylesPlugin)(a),f=[l,...w,...P.getPlugins()??[],d],h=t.EditorState.create({doc:s,schema:P.getSchema(),plugins:f});A.value=h;let v=new o.EditorView(n,{state:h,editable:()=>!(0,e.unref)(_),dispatchTransaction(e){if(!v)return;(0,p.stripScrollFlag)(e,v.state.tr);let t=v.state.apply(e);if(v.updateState(t),A.value=t,e.docChanged){T?.incrementStateSeq(),I.schedule(t);try{if(O.value){let e=(0,c.fromProseDoc)(t.doc,O.value);O.value=e,b?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(T?.requestRender(),C?.(),!e.docChanged){let e=g.value;e&&(0,r.applySdtFocus)(e,(0,r.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});k.value=v,j.value=!0,F(h),T?.requestRender()}(0,e.watch)([()=>(0,e.unref)(E),()=>(0,e.unref)(D),k],([e,t,n])=>{n&&(0,u.setSuggestionMode)(e===`suggesting`,n.state,n.dispatch,t)},{immediate:!0});function R(){I.cancel(),k.value&&=(k.value.destroy(),null),A.value=null,j.value=!1}let z={current:null},B=new Map,V=new Map;function H(){if(z.current&&z.current.isConnected)return z.current;let e=window.document.createElement(`div`);return e.dataset.hfHost=`true`,e.style.cssText=`position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;`,window.document.body.appendChild(e),z.current=e,e}function U(e){let t=O.value?.package;if(!t)return null;if(t.headers){for(let[n,r]of t.headers)if(r===e)return n}if(t.footers){for(let[n,r]of t.footers)if(r===e)return n}return null}function W(e){let t=U(e);return t?B.get(t)??null:null}function G(){let e=O.value?.package,n=H(),r=new Set;if(e?.headers)for(let t of e.headers.keys())r.add(t);if(e?.footers)for(let t of e.footers.keys())r.add(t);for(let[e,t]of B)r.has(e)||(t.destroy(),t.dom.parentElement?.remove(),V.get(e)?.destroy(),V.delete(e),B.delete(e));if(!e)return;let s=e.styles??null,c=e.theme??null,l=e.settings?.defaultTabStop??null;for(let f of r){if(B.has(f))continue;let r=e.headers?.get(f)??e.footers?.get(f);if(!r)continue;let p=e.headers?.has(f)?`header`:`footer`,m=new d.ExtensionManager((0,d.createStarterKit)());m.buildSchema(),m.initializeRuntime(),V.set(f,m);let h=window.document.createElement(`div`);h.dataset.hfRId=f,h.dataset.hfKind=p,n.appendChild(h);let g=(0,i.headerFooterToProseDoc)(r.content,{styles:s??void 0,theme:c,defaultTabStopTwips:l}),_=(0,u.createDocumentStylesPlugin)(s),v=t.EditorState.create({doc:g,schema:a.schema,plugins:[...m.getPlugins(),_]}),y=p,b=new o.EditorView(h,{state:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged){let e=O.value?.package,n=(y===`header`?e?.headers:e?.footers)?.get(f);n&&(n.content=(0,i.proseDocToBlocks)(t.doc))}e.docChanged&&A.value&&F(A.value),q.value?.(f,b,e.docChanged)}});B.set(f,b)}}function K(){for(let e of B.values())e.destroy(),e.dom.parentElement?.remove();B.clear();for(let e of V.values())e.destroy();V.clear(),z.current&&=(z.current.remove(),null)}let q={value:null};function J(e){q.value=e}async function Y(e){M.value=null,j.value=!1;try{let t;t=e instanceof Blob||e instanceof File?await e.arrayBuffer():e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e,O.value=await(0,s.parseDocx)(t),R(),K(),L(),G()}catch(e){let t=e instanceof Error?e:Error(String(e));M.value=t.message,S?.(t)}}function X(e){M.value=null,O.value=e,R(),K(),L(),G()}async function Z(){if(!k.value||!O.value)return null;let{repackDocx:e,createDocx:t}=await import(`@eigenpal/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@eigenpal/docx-editor-core/docx`),i=(0,c.fromProseDoc)(k.value.state.doc,O.value),a=i.package.document?.comments??[];i.package.document?.content&&a.length>0&&(n(i.package.document.content,a),r(i.package.document.content,a));let o;return o=i.originalBuffer?await e(i):await t(i),new Blob([o],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Q(){k.value?.focus()}function $(){R(),K(),O.value=null}function ee(){return O.value}(0,e.onBeforeUnmount)(()=>{$()});function te(){return P.getCommands()}return{editorView:k,editorState:A,isReady:j,parseError:M,layout:N,loadBuffer:Y,loadDocument:X,save:Z,focus:Q,destroy:$,getDocument:ee,getCommands:te,reLayout(){k.value&&F(k.value.state)},getHfPmView:W,syncHfPMs:G,setHfTransactionListener:J,setDocument(e){O.value=e}}}var C=.25,w=4,T=.1,E=[.25,.5,.75,1,1.25,1.5,2,3,4];function D(t=1){let n=(0,e.ref)(Math.max(C,Math.min(w,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=C),a=(0,e.computed)(()=>n.value>=w);function o(e){n.value=Math.max(C,Math.min(w,Math.round(e*100)/100))}function s(){o(n.value+T)}function c(){o(n.value-T)}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:E}}function O(){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?.classList?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),k(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),A(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),j(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*g.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=g.MIN_CELL_WIDTH_TWIPS&&o>=g.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*g.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=g.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*g.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=g.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,g.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,g.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,g.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 k(e,t){let n=(0,g.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function A(e,t,n){let r=(0,g.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*g.TWIPS_PER_PIXEL)}function j(e,t){let n=(0,g.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function M({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,_.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=(0,v.computeAutoScrollDelta)(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+v.AUTO_SCROLL_EDGE_ZONE||t>n.bottom-v.AUTO_SCROLL_EDGE_ZONE)&&d()}}return(0,e.onBeforeUnmount)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return M}});
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { computed as e, onBeforeUnmount as t, onMounted as n, ref as r, shallowRef as i, unref as a, watch as o } from "vue";
|
|
2
|
+
import { EditorState as s } from "prosemirror-state";
|
|
3
|
+
import { getColumns as c, getMargins as l, getPageSize as u, measureTableBlock as d, resolveHeaderFooter as f } from "@eigenpal/docx-editor-core/layout-bridge";
|
|
4
|
+
import { applySdtFocus as p, buildBlockLookup as m, enclosingSdtGroupIds as h } from "@eigenpal/docx-editor-core/layout-painter";
|
|
5
|
+
import { createEmptyDoc as g, headerFooterToProseDoc as _, proseDocToBlocks as v, toProseDoc as y } from "@eigenpal/docx-editor-core/prosemirror/conversion";
|
|
6
|
+
import { schema as b } from "@eigenpal/docx-editor-core/prosemirror";
|
|
7
|
+
import { EditorView as x } from "prosemirror-view";
|
|
8
|
+
import { parseDocx as S } from "@eigenpal/docx-editor-core/docx/parser";
|
|
9
|
+
import { fromProseDoc as C } from "@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc";
|
|
10
|
+
import { singletonManager as w } from "@eigenpal/docx-editor-core/prosemirror/schema";
|
|
11
|
+
import { createDocumentStylesPlugin as T, createSuggestionModePlugin as E, setSuggestionMode as ee } from "@eigenpal/docx-editor-core/prosemirror/plugins";
|
|
12
|
+
import { ExtensionManager as te, createStarterKit as ne } from "@eigenpal/docx-editor-core/prosemirror/extensions";
|
|
13
|
+
import { measureBlocksWithFloats as D, measureParagraph as O } from "@eigenpal/docx-editor-core/layout-bridge/measuring";
|
|
14
|
+
import { computeLayout as re, createLayoutScheduler as k, stripScrollFlag as ie } from "@eigenpal/docx-editor-core/editor";
|
|
15
|
+
import { DEFAULT_TEXTBOX_MARGINS as A, DEFAULT_TEXTBOX_WIDTH as j, assertExhaustiveFlowBlock as M } from "@eigenpal/docx-editor-core/layout-engine";
|
|
16
|
+
import { renderPages as ae } from "@eigenpal/docx-editor-core/layout-painter/renderPage";
|
|
17
|
+
import "prosemirror-view/style/prosemirror.css";
|
|
18
|
+
import "@eigenpal/docx-editor-core/prosemirror/editor.css";
|
|
19
|
+
import { MIN_CELL_WIDTH_TWIPS as N, MIN_ROW_HEIGHT_TWIPS as P, TWIPS_PER_PIXEL as F, commitColumnResize as oe, commitRightEdgeResize as I, commitRowResize as L, readColumnWidthAt as R, readColumnWidths as z, readRowHeight as B } from "@eigenpal/docx-editor-core/prosemirror/tableResize";
|
|
20
|
+
import { findVerticalScrollParent as V } from "@eigenpal/docx-editor-core/utils/findVerticalScrollParent";
|
|
21
|
+
import { AUTO_SCROLL_EDGE_ZONE as H, computeAutoScrollDelta as U } from "@eigenpal/docx-editor-core/utils/autoScroll";
|
|
22
|
+
//#region src/composables/useDocxEditor.ts
|
|
23
|
+
var se = 24;
|
|
24
|
+
function W(e, t, n, r) {
|
|
25
|
+
switch (e.kind) {
|
|
26
|
+
case "paragraph": return O(e, t, {
|
|
27
|
+
floatingZones: n,
|
|
28
|
+
paragraphYOffset: r ?? 0
|
|
29
|
+
});
|
|
30
|
+
case "table": return d(e, t, W);
|
|
31
|
+
case "image": {
|
|
32
|
+
let t = e;
|
|
33
|
+
return {
|
|
34
|
+
kind: "image",
|
|
35
|
+
width: t.width ?? 100,
|
|
36
|
+
height: t.height ?? 100
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
case "textBox": {
|
|
40
|
+
let t = e, n = t.margins ?? A, r = (t.width ?? j) - n.left - n.right, i = t.content.map((e) => O(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
|
|
41
|
+
return {
|
|
42
|
+
kind: "textBox",
|
|
43
|
+
width: t.width ?? j,
|
|
44
|
+
height: o,
|
|
45
|
+
innerMeasures: i
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
case "pageBreak": return { kind: "pageBreak" };
|
|
49
|
+
case "columnBreak": return { kind: "columnBreak" };
|
|
50
|
+
case "sectionBreak": return { kind: "sectionBreak" };
|
|
51
|
+
default: M(e, "vue useDocxEditor measureBlock");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function ce(e, t, n) {
|
|
55
|
+
return D(e, t, W, n);
|
|
56
|
+
}
|
|
57
|
+
function G(e) {
|
|
58
|
+
let { hiddenContainer: n, pagesContainer: d, readOnly: D = !1, pageGap: O = se, onChange: A, onError: j, onSelectionUpdate: M, externalPlugins: N = [], syncCoordinator: P, editorMode: F, author: oe } = e, I = i(null), L = i(null), R = i(null), z = r(!1), B = r(null), V = i(null), H = w;
|
|
59
|
+
function U(e) {
|
|
60
|
+
let t = d.value;
|
|
61
|
+
if (!t || !I.value) return;
|
|
62
|
+
let n = P?.getStateSeq() ?? 0;
|
|
63
|
+
P?.onLayoutStart();
|
|
64
|
+
let r = I.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = u(i), s = l(i), g = u(a), _ = l(a), v = c(i), y = c(a), b = o.w - s.left - s.right, x = I.value.package?.theme ?? null, S = I.value.package?.styles ?? null;
|
|
65
|
+
try {
|
|
66
|
+
let { header: n, footer: r, firstHeader: c, firstFooter: l } = f(I.value, i), { blocks: u, measures: d, layout: C, headerContentForRender: w, footerContentForRender: T, firstPageHeaderForRender: E, firstPageFooterForRender: ee, hasTitlePg: te, watermark: ne, footnotesByPage: D } = re({
|
|
67
|
+
state: e,
|
|
68
|
+
document: I.value,
|
|
69
|
+
pageSize: o,
|
|
70
|
+
margins: s,
|
|
71
|
+
columns: v,
|
|
72
|
+
finalPageSize: g,
|
|
73
|
+
finalMargins: _,
|
|
74
|
+
finalColumns: y,
|
|
75
|
+
pageGap: O,
|
|
76
|
+
contentWidth: b,
|
|
77
|
+
theme: x,
|
|
78
|
+
styles: S,
|
|
79
|
+
sectionProperties: i,
|
|
80
|
+
finalSectionProperties: a,
|
|
81
|
+
headerContent: n,
|
|
82
|
+
footerContent: r,
|
|
83
|
+
firstPageHeaderContent: c,
|
|
84
|
+
firstPageFooterContent: l,
|
|
85
|
+
measureBlocks: ce,
|
|
86
|
+
getHfPmDoc: (e) => X(e)?.state.doc ?? null
|
|
87
|
+
});
|
|
88
|
+
V.value = C;
|
|
89
|
+
let k = m(u, d);
|
|
90
|
+
ae(C.pages, t, {
|
|
91
|
+
pageGap: O,
|
|
92
|
+
showShadow: !0,
|
|
93
|
+
pageBackground: "#fff",
|
|
94
|
+
blockLookup: k,
|
|
95
|
+
theme: x,
|
|
96
|
+
headerContent: w,
|
|
97
|
+
footerContent: T,
|
|
98
|
+
firstPageHeaderContent: E,
|
|
99
|
+
firstPageFooterContent: ee,
|
|
100
|
+
titlePage: te,
|
|
101
|
+
watermark: ne,
|
|
102
|
+
footnotesByPage: D
|
|
103
|
+
}), t.style.overflowY = "auto", t.style.minHeight = "0";
|
|
104
|
+
for (let e of Array.from(t.children)) e.style.flexShrink = "0";
|
|
105
|
+
p(t, h(e.doc, e.selection.from, e.selection.to));
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.error("[useDocxEditor] Layout pipeline error:", e), j?.(e instanceof Error ? e : Error(String(e)));
|
|
108
|
+
} finally {
|
|
109
|
+
P?.onLayoutComplete(n);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
let W = k(U);
|
|
113
|
+
function G() {
|
|
114
|
+
let e = n.value;
|
|
115
|
+
if (!e) return;
|
|
116
|
+
let t = I.value?.package?.styles, r = I.value ? y(I.value, { styles: t ?? void 0 }) : g(), i = E(!1), o = T(t), c = [
|
|
117
|
+
i,
|
|
118
|
+
...N,
|
|
119
|
+
...H.getPlugins() ?? [],
|
|
120
|
+
o
|
|
121
|
+
], l = s.create({
|
|
122
|
+
doc: r,
|
|
123
|
+
schema: H.getSchema(),
|
|
124
|
+
plugins: c
|
|
125
|
+
});
|
|
126
|
+
R.value = l;
|
|
127
|
+
let u = new x(e, {
|
|
128
|
+
state: l,
|
|
129
|
+
editable: () => !a(D),
|
|
130
|
+
dispatchTransaction(e) {
|
|
131
|
+
if (!u) return;
|
|
132
|
+
ie(e, u.state.tr);
|
|
133
|
+
let t = u.state.apply(e);
|
|
134
|
+
if (u.updateState(t), R.value = t, e.docChanged) {
|
|
135
|
+
P?.incrementStateSeq(), W.schedule(t);
|
|
136
|
+
try {
|
|
137
|
+
if (I.value) {
|
|
138
|
+
let e = C(t.doc, I.value);
|
|
139
|
+
I.value = e, A?.(e);
|
|
140
|
+
}
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.error("[useDocxEditor] fromProseDoc error:", e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (P?.requestRender(), M?.(), !e.docChanged) {
|
|
146
|
+
let e = d.value;
|
|
147
|
+
e && p(e, h(t.doc, t.selection.from, t.selection.to));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
L.value = u, z.value = !0, U(l), P?.requestRender();
|
|
152
|
+
}
|
|
153
|
+
o([
|
|
154
|
+
() => a(F),
|
|
155
|
+
() => a(oe),
|
|
156
|
+
L
|
|
157
|
+
], ([e, t, n]) => {
|
|
158
|
+
n && ee(e === "suggesting", n.state, n.dispatch, t);
|
|
159
|
+
}, { immediate: !0 });
|
|
160
|
+
function K() {
|
|
161
|
+
W.cancel(), L.value &&= (L.value.destroy(), null), R.value = null, z.value = !1;
|
|
162
|
+
}
|
|
163
|
+
let q = { current: null }, J = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
|
|
164
|
+
function le() {
|
|
165
|
+
if (q.current && q.current.isConnected) return q.current;
|
|
166
|
+
let e = window.document.createElement("div");
|
|
167
|
+
return e.dataset.hfHost = "true", e.style.cssText = "position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;", window.document.body.appendChild(e), q.current = e, e;
|
|
168
|
+
}
|
|
169
|
+
function ue(e) {
|
|
170
|
+
let t = I.value?.package;
|
|
171
|
+
if (!t) return null;
|
|
172
|
+
if (t.headers) {
|
|
173
|
+
for (let [n, r] of t.headers) if (r === e) return n;
|
|
174
|
+
}
|
|
175
|
+
if (t.footers) {
|
|
176
|
+
for (let [n, r] of t.footers) if (r === e) return n;
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
function X(e) {
|
|
181
|
+
let t = ue(e);
|
|
182
|
+
return t ? J.get(t) ?? null : null;
|
|
183
|
+
}
|
|
184
|
+
function Z() {
|
|
185
|
+
let e = I.value?.package, t = le(), n = /* @__PURE__ */ new Set();
|
|
186
|
+
if (e?.headers) for (let t of e.headers.keys()) n.add(t);
|
|
187
|
+
if (e?.footers) for (let t of e.footers.keys()) n.add(t);
|
|
188
|
+
for (let [e, t] of J) n.has(e) || (t.destroy(), t.dom.parentElement?.remove(), Y.get(e)?.destroy(), Y.delete(e), J.delete(e));
|
|
189
|
+
if (!e) return;
|
|
190
|
+
let r = e.styles ?? null, i = e.theme ?? null, a = e.settings?.defaultTabStop ?? null;
|
|
191
|
+
for (let o of n) {
|
|
192
|
+
if (J.has(o)) continue;
|
|
193
|
+
let n = e.headers?.get(o) ?? e.footers?.get(o);
|
|
194
|
+
if (!n) continue;
|
|
195
|
+
let c = e.headers?.has(o) ? "header" : "footer", l = new te(ne());
|
|
196
|
+
l.buildSchema(), l.initializeRuntime(), Y.set(o, l);
|
|
197
|
+
let u = window.document.createElement("div");
|
|
198
|
+
u.dataset.hfRId = o, u.dataset.hfKind = c, t.appendChild(u);
|
|
199
|
+
let d = _(n.content, {
|
|
200
|
+
styles: r ?? void 0,
|
|
201
|
+
theme: i,
|
|
202
|
+
defaultTabStopTwips: a
|
|
203
|
+
}), f = T(r), p = s.create({
|
|
204
|
+
doc: d,
|
|
205
|
+
schema: b,
|
|
206
|
+
plugins: [...l.getPlugins(), f]
|
|
207
|
+
}), m = c, h = new x(u, {
|
|
208
|
+
state: p,
|
|
209
|
+
dispatchTransaction(e) {
|
|
210
|
+
let t = h.state.apply(e);
|
|
211
|
+
if (h.updateState(t), e.docChanged) {
|
|
212
|
+
let e = I.value?.package, n = (m === "header" ? e?.headers : e?.footers)?.get(o);
|
|
213
|
+
n && (n.content = v(t.doc));
|
|
214
|
+
}
|
|
215
|
+
e.docChanged && R.value && U(R.value), $.value?.(o, h, e.docChanged);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
J.set(o, h);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function Q() {
|
|
222
|
+
for (let e of J.values()) e.destroy(), e.dom.parentElement?.remove();
|
|
223
|
+
J.clear();
|
|
224
|
+
for (let e of Y.values()) e.destroy();
|
|
225
|
+
Y.clear(), q.current &&= (q.current.remove(), null);
|
|
226
|
+
}
|
|
227
|
+
let $ = { value: null };
|
|
228
|
+
function de(e) {
|
|
229
|
+
$.value = e;
|
|
230
|
+
}
|
|
231
|
+
async function fe(e) {
|
|
232
|
+
B.value = null, z.value = !1;
|
|
233
|
+
try {
|
|
234
|
+
let t;
|
|
235
|
+
t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, I.value = await S(t), K(), Q(), G(), Z();
|
|
236
|
+
} catch (e) {
|
|
237
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
238
|
+
B.value = t.message, j?.(t);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function pe(e) {
|
|
242
|
+
B.value = null, I.value = e, K(), Q(), G(), Z();
|
|
243
|
+
}
|
|
244
|
+
async function me() {
|
|
245
|
+
if (!L.value || !I.value) return null;
|
|
246
|
+
let { repackDocx: e, createDocx: t } = await import("@eigenpal/docx-editor-core/docx/rezip"), { injectReplyRangeMarkers: n, injectTCReplyRangeMarkers: r } = await import("@eigenpal/docx-editor-core/docx"), i = C(L.value.state.doc, I.value), a = i.package.document?.comments ?? [];
|
|
247
|
+
i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
|
|
248
|
+
let o;
|
|
249
|
+
return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
250
|
+
}
|
|
251
|
+
function he() {
|
|
252
|
+
L.value?.focus();
|
|
253
|
+
}
|
|
254
|
+
function ge() {
|
|
255
|
+
K(), Q(), I.value = null;
|
|
256
|
+
}
|
|
257
|
+
function _e() {
|
|
258
|
+
return I.value;
|
|
259
|
+
}
|
|
260
|
+
t(() => {
|
|
261
|
+
ge();
|
|
262
|
+
});
|
|
263
|
+
function ve() {
|
|
264
|
+
return H.getCommands();
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
editorView: L,
|
|
268
|
+
editorState: R,
|
|
269
|
+
isReady: z,
|
|
270
|
+
parseError: B,
|
|
271
|
+
layout: V,
|
|
272
|
+
loadBuffer: fe,
|
|
273
|
+
loadDocument: pe,
|
|
274
|
+
save: me,
|
|
275
|
+
focus: he,
|
|
276
|
+
destroy: ge,
|
|
277
|
+
getDocument: _e,
|
|
278
|
+
getCommands: ve,
|
|
279
|
+
reLayout() {
|
|
280
|
+
L.value && U(L.value.state);
|
|
281
|
+
},
|
|
282
|
+
getHfPmView: X,
|
|
283
|
+
syncHfPMs: Z,
|
|
284
|
+
setHfTransactionListener: de,
|
|
285
|
+
setDocument(e) {
|
|
286
|
+
I.value = e;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/composables/useZoom.ts
|
|
292
|
+
var K = .25, q = 4, J = .1, Y = [
|
|
293
|
+
.25,
|
|
294
|
+
.5,
|
|
295
|
+
.75,
|
|
296
|
+
1,
|
|
297
|
+
1.25,
|
|
298
|
+
1.5,
|
|
299
|
+
2,
|
|
300
|
+
3,
|
|
301
|
+
4
|
|
302
|
+
];
|
|
303
|
+
function le(i = 1) {
|
|
304
|
+
let a = r(Math.max(K, Math.min(q, i))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= K), c = e(() => a.value >= q);
|
|
305
|
+
function l(e) {
|
|
306
|
+
a.value = Math.max(K, Math.min(q, Math.round(e * 100) / 100));
|
|
307
|
+
}
|
|
308
|
+
function u() {
|
|
309
|
+
l(a.value + J);
|
|
310
|
+
}
|
|
311
|
+
function d() {
|
|
312
|
+
l(a.value - J);
|
|
313
|
+
}
|
|
314
|
+
function f() {
|
|
315
|
+
l(1);
|
|
316
|
+
}
|
|
317
|
+
function p(e) {
|
|
318
|
+
(e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
|
|
319
|
+
}
|
|
320
|
+
function m(e) {
|
|
321
|
+
(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())));
|
|
322
|
+
}
|
|
323
|
+
function h() {
|
|
324
|
+
n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
zoom: a,
|
|
328
|
+
zoomPercent: o,
|
|
329
|
+
isMinZoom: s,
|
|
330
|
+
isMaxZoom: c,
|
|
331
|
+
setZoom: l,
|
|
332
|
+
zoomIn: u,
|
|
333
|
+
zoomOut: d,
|
|
334
|
+
resetZoom: f,
|
|
335
|
+
handleWheel: p,
|
|
336
|
+
handleKeyDown: m,
|
|
337
|
+
installShortcuts: h,
|
|
338
|
+
ZOOM_PRESETS: Y
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/composables/useTableResize.ts
|
|
343
|
+
function ue() {
|
|
344
|
+
let e = {
|
|
345
|
+
active: !1,
|
|
346
|
+
startX: 0,
|
|
347
|
+
handle: null,
|
|
348
|
+
columnIndex: 0,
|
|
349
|
+
tablePmStart: 0,
|
|
350
|
+
origWidths: {
|
|
351
|
+
left: 0,
|
|
352
|
+
right: 0
|
|
353
|
+
}
|
|
354
|
+
}, t = {
|
|
355
|
+
active: !1,
|
|
356
|
+
startY: 0,
|
|
357
|
+
handle: null,
|
|
358
|
+
rowIndex: 0,
|
|
359
|
+
isEdge: !1,
|
|
360
|
+
tablePmStart: 0,
|
|
361
|
+
origHeight: 0
|
|
362
|
+
}, n = {
|
|
363
|
+
active: !1,
|
|
364
|
+
startX: 0,
|
|
365
|
+
handle: null,
|
|
366
|
+
columnIndex: 0,
|
|
367
|
+
tablePmStart: 0,
|
|
368
|
+
origWidth: 0
|
|
369
|
+
}, r = null;
|
|
370
|
+
function i() {
|
|
371
|
+
return e.active || t.active || n.active;
|
|
372
|
+
}
|
|
373
|
+
function a(i, a) {
|
|
374
|
+
let o = i.target;
|
|
375
|
+
return o?.classList ? 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), X(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), Q(a, n), !0) : !1 : !1;
|
|
376
|
+
}
|
|
377
|
+
function o(r) {
|
|
378
|
+
if (e.active && e.handle) {
|
|
379
|
+
r.preventDefault();
|
|
380
|
+
let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
|
|
381
|
+
e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
|
|
382
|
+
let i = Math.round(t * F), a = e.origWidths.left + i, o = e.origWidths.right - i;
|
|
383
|
+
a >= N && o >= N && (e.origWidths = {
|
|
384
|
+
left: a,
|
|
385
|
+
right: o
|
|
386
|
+
});
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (t.active && t.handle) {
|
|
390
|
+
r.preventDefault();
|
|
391
|
+
let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
|
|
392
|
+
t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
|
|
393
|
+
let i = Math.round(e * F), a = t.origHeight + i;
|
|
394
|
+
a >= P && (t.origHeight = a);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (n.active && n.handle) {
|
|
398
|
+
r.preventDefault();
|
|
399
|
+
let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
|
|
400
|
+
n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
|
|
401
|
+
let i = Math.round(e * F), a = n.origWidth + i;
|
|
402
|
+
a >= N && (n.origWidth = a);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function s(i) {
|
|
406
|
+
if (e.active) {
|
|
407
|
+
e.active = !1, e.handle?.classList.remove("dragging"), r && oe(r, {
|
|
408
|
+
pmStart: e.tablePmStart,
|
|
409
|
+
colIdx: e.columnIndex,
|
|
410
|
+
newLeft: e.origWidths.left,
|
|
411
|
+
newRight: e.origWidths.right
|
|
412
|
+
}), e.handle = null;
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (t.active) {
|
|
416
|
+
t.active = !1, t.handle?.classList.remove("dragging"), r && L(r, {
|
|
417
|
+
pmStart: t.tablePmStart,
|
|
418
|
+
rowIdx: t.rowIndex,
|
|
419
|
+
newHeight: t.origHeight
|
|
420
|
+
}), t.handle = null;
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && I(r, {
|
|
424
|
+
pmStart: n.tablePmStart,
|
|
425
|
+
colIdx: n.columnIndex,
|
|
426
|
+
newWidth: n.origWidth
|
|
427
|
+
}), n.handle = null);
|
|
428
|
+
}
|
|
429
|
+
function c() {
|
|
430
|
+
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
|
|
431
|
+
document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
tryStartResize: a,
|
|
436
|
+
install: c,
|
|
437
|
+
isResizing: i
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function X(e, t) {
|
|
441
|
+
let n = z(e, t.tablePmStart, t.columnIndex);
|
|
442
|
+
n && (t.origWidths = n);
|
|
443
|
+
}
|
|
444
|
+
function Z(e, t, n) {
|
|
445
|
+
let r = B(e, t.tablePmStart, t.rowIndex);
|
|
446
|
+
if (r != null) {
|
|
447
|
+
t.origHeight = r;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
|
|
451
|
+
t.origHeight = Math.round(a * F);
|
|
452
|
+
}
|
|
453
|
+
function Q(e, t) {
|
|
454
|
+
let n = R(e, t.tablePmStart, t.columnIndex);
|
|
455
|
+
n != null && (t.origWidth = n);
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/composables/useDragAutoScroll.ts
|
|
459
|
+
function $({ pagesContainer: e, onScrollExtendSelection: n }) {
|
|
460
|
+
let r = null, i = 0, a = 0, o = !1, s = null;
|
|
461
|
+
function c() {
|
|
462
|
+
if (s) return s;
|
|
463
|
+
let t = e.value;
|
|
464
|
+
return t ? (s = V(t), s) : null;
|
|
465
|
+
}
|
|
466
|
+
function l() {
|
|
467
|
+
o = !1, r !== null && (cancelAnimationFrame(r), r = null);
|
|
468
|
+
}
|
|
469
|
+
function u() {
|
|
470
|
+
if (!o) return;
|
|
471
|
+
let e = c();
|
|
472
|
+
if (!e) return;
|
|
473
|
+
let t = U(e.getBoundingClientRect(), a);
|
|
474
|
+
t !== 0 && (e.scrollTop += t, n(i, a)), r = requestAnimationFrame(u);
|
|
475
|
+
}
|
|
476
|
+
function d() {
|
|
477
|
+
o || (o = !0, r = requestAnimationFrame(u));
|
|
478
|
+
}
|
|
479
|
+
function f(e, t) {
|
|
480
|
+
if (i = e, a = t, !o) {
|
|
481
|
+
let e = c();
|
|
482
|
+
if (!e) return;
|
|
483
|
+
let n = e.getBoundingClientRect();
|
|
484
|
+
(t < n.top + H || t > n.bottom - H) && d();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return t(() => l()), {
|
|
488
|
+
updateMousePosition: f,
|
|
489
|
+
stopAutoScroll: l
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
export { G as i, ue as n, le as r, $ as t };
|
|
@@ -1,46 +1,10 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Layout } from '@eigenpal/docx-editor-core/layout-engine';
|
|
3
|
-
export interface FindInDocumentMatch {
|
|
4
|
-
paraId: string;
|
|
5
|
-
match: string;
|
|
6
|
-
before: string;
|
|
7
|
-
after: string;
|
|
8
|
-
}
|
|
9
1
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
2
|
+
* Pure ref-API query helpers — read-only inspectors over the PM document
|
|
3
|
+
* and the paginated layout. Used by DocxEditor's `defineExpose` ref API
|
|
4
|
+
* (`findInDocument`, `getSelectionInfo`, `getPageContent`).
|
|
5
|
+
*
|
|
6
|
+
* Lifted to `@eigenpal/docx-editor-core/prosemirror/queries` and shared
|
|
7
|
+
* with the React adapter; re-exported here to keep existing import sites stable.
|
|
14
8
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
limit?: number;
|
|
18
|
-
}): FindInDocumentMatch[];
|
|
19
|
-
export interface SelectionInfo {
|
|
20
|
-
paraId: string | null;
|
|
21
|
-
selectedText: string;
|
|
22
|
-
paragraphText: string;
|
|
23
|
-
before: string;
|
|
24
|
-
after: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Describe the current selection in agent-readable form — paraId of the
|
|
28
|
-
* containing paragraph, the selected text, the full paragraph text, and
|
|
29
|
-
* the leading/trailing slices.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getSelectionInfo(view: EditorView | null): SelectionInfo | null;
|
|
32
|
-
export interface PageContent {
|
|
33
|
-
pageNumber: number;
|
|
34
|
-
text: string;
|
|
35
|
-
paragraphs: Array<{
|
|
36
|
-
paraId: string;
|
|
37
|
-
text: string;
|
|
38
|
-
styleId?: string;
|
|
39
|
-
}>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Collect paragraphs visible on `pageNumber` (1-indexed) from the
|
|
43
|
-
* paginated `layout`. Dedupes by paraId so paragraphs split across page
|
|
44
|
-
* boundaries are reported once.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getPageContent(view: EditorView | null, layout: Layout | null, pageNumber: number): PageContent | null;
|
|
9
|
+
export { findInDocument, getSelectionInfo, getPageContent, } from '@eigenpal/docx-editor-core/prosemirror/queries';
|
|
10
|
+
export type { FindInDocumentMatch, SelectionInfo, PageContent, } from '@eigenpal/docx-editor-core/prosemirror/queries';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eigenpal/docx-editor-vue",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Vue 3 DOCX editor adapter for @eigenpal/docx-editor-core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"vue": "^3.3.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@eigenpal/docx-editor-agents": "^1.3.
|
|
87
|
-
"@eigenpal/docx-editor-core": "^1.3.
|
|
88
|
-
"@eigenpal/docx-editor-i18n": "^1.3.
|
|
86
|
+
"@eigenpal/docx-editor-agents": "^1.3.1",
|
|
87
|
+
"@eigenpal/docx-editor-core": "^1.3.1",
|
|
88
|
+
"@eigenpal/docx-editor-i18n": "^1.3.1"
|
|
89
89
|
},
|
|
90
90
|
"keywords": [
|
|
91
91
|
"docx",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@eigenpal/docx-editor-core/layout-bridge`),r=require(`@eigenpal/docx-editor-core/layout-painter`),i=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),a=require(`@eigenpal/docx-editor-core/prosemirror`),o=require(`prosemirror-view`),s=require(`@eigenpal/docx-editor-core/docx/parser`),c=require(`@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc`),l=require(`@eigenpal/docx-editor-core/prosemirror/schema`),u=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),d=require(`@eigenpal/docx-editor-core/prosemirror/extensions`),f=require(`@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks`),p=require(`@eigenpal/docx-editor-core/layout-bridge/measuring`),m=require(`@eigenpal/docx-editor-core/layout-engine`),h=require(`@eigenpal/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@eigenpal/docx-editor-core/prosemirror/editor.css`);var g=24;function _(e,t,r,i){switch(e.kind){case`paragraph`:return(0,p.measureParagraph)(e,t,{floatingZones:r,paragraphYOffset:i??0});case`table`:return(0,n.measureTableBlock)(e,t,_);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??m.DEFAULT_TEXTBOX_MARGINS,r=(t.width??m.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,i=t.content.map(e=>(0,p.measureParagraph)(e,r)),a=i.reduce((e,t)=>e+t.totalHeight,0),o=t.height??a+n.top+n.bottom;return{kind:`textBox`,width:t.width??m.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,m.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function v(e,t,n){return(0,p.measureBlocksWithFloats)(e,t,_,n)}function y(p){let{hiddenContainer:_,pagesContainer:y,readOnly:b=!1,pageGap:x=g,onChange:S,onError:C,onSelectionUpdate:w,externalPlugins:T=[],syncCoordinator:E,editorMode:D,author:O}=p,k=(0,e.shallowRef)(null),A=(0,e.shallowRef)(null),j=(0,e.shallowRef)(null),M=(0,e.ref)(!1),N=(0,e.ref)(null),P=(0,e.shallowRef)(null),F=l.singletonManager;function I(e){let t=y.value;if(!t||!k.value)return;let i=E?.getStateSeq()??0;E?.onLayoutStart();let a=k.value.package?.document,o=a?.sections?.[0]?.properties??a?.finalSectionProperties??null,s=a?.finalSectionProperties??o,c=(0,n.getPageSize)(o),l=(0,n.getMargins)(o),u=(0,n.getPageSize)(s),d=(0,n.getMargins)(s),p=c.w-l.left-l.right,g=c.h-l.top-l.bottom,_=k.value.package?.theme??null,b=k.value.package?.styles??null;try{let i=(0,f.toFlowBlocks)(e.doc,{theme:_,pageContentHeight:g}),a=v(i,p,(0,r.pageGeometryFromPage)({size:c,margins:l})),{header:s,footer:y,firstHeader:S,firstFooter:C}=(0,n.resolveHeaderFooter)(k.value,o),w={section:`header`,pageSize:c,margins:l},T={section:`footer`,pageSize:c,margins:l},E=e.doc.attrs?.defaultTabStopTwips,D={styles:b,theme:_,measureBlocks:v,defaultTabStopTwips:E},O=(e,t)=>{if(!e)return;let r=ee(e);return r?(0,n.convertHeaderFooterPmDocToContent)(r.state.doc,p,t,D):(0,n.convertHeaderFooterToContent)(e,p,t,D)},A=O(s,w),j=O(y,T),M=o?.titlePg===!0,N=M?O(S,w):void 0,F=M?O(C,T):void 0,I=e.doc.attrs?.watermark??void 0,L=l.header??48,R=l.footer??48,z=l.top-L,B=l.bottom-R,V=e=>e?e.visualBottom??e.height:0,H=e=>e?Math.max((e.visualBottom??e.height)-(e.visualTop??0),e.height):0,U=Math.max(V(A),V(N)),W=Math.max(H(j),H(F)),G=U>z,K=W>B;if(G||K){let e=e=>{let t={...e};return G&&(t.top=Math.max(e.top,L+U)),K&&(t.bottom=Math.max(e.bottom,R+W)),t};l=e(l),d=e(d);for(let t of i){if(t.kind!==`sectionBreak`)continue;let n=t;n.margins&&=e(n.margins)}}let q={pageSize:c,margins:l,finalPageSize:u,finalMargins:d,pageGap:x},J=(0,n.collectFootnoteRefs)(i),Y=J.length>0&&!!k.value.package?.footnotes,X=(0,m.layoutDocument)(i,a,q),Z=new Map,Q=new Map;if(Y){Q=(0,n.buildFootnoteContentMap)(k.value.package.footnotes,J,p,{styles:b,theme:_,measureBlocks:v,defaultTabStopTwips:E});let e=(0,n.stabilizeFootnoteLayout)({blocks:i,measures:a,layoutOpts:q,footnoteRefs:J,footnoteContentMap:Q,initialLayout:X});X=e.layout,Z=e.pageFootnoteMap}P.value=X;let $=new Map;for(let e=0;e<i.length;e++){let t=i[e],n=a[e];t&&n&&$.set(String(t.id),{block:t,measure:n})}let te=Y?(0,n.buildFootnoteRenderItems)(Z,Q,k.value):void 0;(0,h.renderPages)(X.pages,t,{pageGap:x,showShadow:!0,pageBackground:`#fff`,blockLookup:$,theme:_,headerContent:A,footerContent:j,firstPageHeaderContent:N,firstPageFooterContent:F,titlePage:M,watermark:I,footnotesByPage:te}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,r.applySdtFocus)(t,(0,r.enclosingSdtGroupIds)(e.doc,e.selection.from,e.selection.to))}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),C?.(e instanceof Error?e:Error(String(e)))}finally{E?.onLayoutComplete(i)}}function L(){let n=_.value;if(!n)return;let a=k.value?.package?.styles,s=k.value?(0,i.toProseDoc)(k.value,{styles:a??void 0}):(0,i.createEmptyDoc)(),l=(0,u.createSuggestionModePlugin)(!1),d=(0,u.createDocumentStylesPlugin)(a),f=[l,...T,...F.getPlugins()??[],d],p=t.EditorState.create({doc:s,schema:F.getSchema(),plugins:f});j.value=p;let m=new o.EditorView(n,{state:p,editable:()=>!(0,e.unref)(b),dispatchTransaction(e){if(!m)return;let t=m.state.apply(e);if(m.updateState(t),j.value=t,e.docChanged){E?.incrementStateSeq(),I(t);try{if(k.value){let e=(0,c.fromProseDoc)(t.doc,k.value);k.value=e,S?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(E?.requestRender(),w?.(),!e.docChanged){let e=y.value;e&&(0,r.applySdtFocus)(e,(0,r.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});A.value=m,M.value=!0,I(p),E?.requestRender()}(0,e.watch)([()=>(0,e.unref)(D),()=>(0,e.unref)(O),A],([e,t,n])=>{n&&(0,u.setSuggestionMode)(e===`suggesting`,n.state,n.dispatch,t)},{immediate:!0});function R(){A.value&&=(A.value.destroy(),null),j.value=null,M.value=!1}let z={current:null},B=new Map,V=new Map;function H(){if(z.current&&z.current.isConnected)return z.current;let e=window.document.createElement(`div`);return e.dataset.hfHost=`true`,e.style.cssText=`position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;`,window.document.body.appendChild(e),z.current=e,e}function U(e){let t=k.value?.package;if(!t)return null;if(t.headers){for(let[n,r]of t.headers)if(r===e)return n}if(t.footers){for(let[n,r]of t.footers)if(r===e)return n}return null}function ee(e){let t=U(e);return t?B.get(t)??null:null}function W(){let e=k.value?.package,n=H(),r=new Set;if(e?.headers)for(let t of e.headers.keys())r.add(t);if(e?.footers)for(let t of e.footers.keys())r.add(t);for(let[e,t]of B)r.has(e)||(t.destroy(),t.dom.parentElement?.remove(),V.get(e)?.destroy(),V.delete(e),B.delete(e));if(!e)return;let s=e.styles??null,c=e.theme??null,l=e.settings?.defaultTabStop??null;for(let f of r){if(B.has(f))continue;let r=e.headers?.get(f)??e.footers?.get(f);if(!r)continue;let p=e.headers?.has(f)?`header`:`footer`,m=new d.ExtensionManager((0,d.createStarterKit)());m.buildSchema(),m.initializeRuntime(),V.set(f,m);let h=window.document.createElement(`div`);h.dataset.hfRId=f,h.dataset.hfKind=p,n.appendChild(h);let g=(0,i.headerFooterToProseDoc)(r.content,{styles:s??void 0,theme:c,defaultTabStopTwips:l}),_=(0,u.createDocumentStylesPlugin)(s),v=t.EditorState.create({doc:g,schema:a.schema,plugins:[...m.getPlugins(),_]}),y=p,b=new o.EditorView(h,{state:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged){let e=k.value?.package,n=(y===`header`?e?.headers:e?.footers)?.get(f);n&&(n.content=(0,i.proseDocToBlocks)(t.doc))}e.docChanged&&j.value&&I(j.value),K.value?.(f,b,e.docChanged)}});B.set(f,b)}}function G(){for(let e of B.values())e.destroy(),e.dom.parentElement?.remove();B.clear();for(let e of V.values())e.destroy();V.clear(),z.current&&=(z.current.remove(),null)}let K={value:null};function q(e){K.value=e}async function J(e){N.value=null,M.value=!1;try{let t;t=e instanceof Blob||e instanceof File?await e.arrayBuffer():e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e,k.value=await(0,s.parseDocx)(t),R(),G(),L(),W()}catch(e){let t=e instanceof Error?e:Error(String(e));N.value=t.message,C?.(t)}}function Y(e){N.value=null,k.value=e,R(),G(),L(),W()}async function X(){if(!A.value||!k.value)return null;let{repackDocx:e,createDocx:t}=await import(`@eigenpal/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@eigenpal/docx-editor-core/docx`),i=(0,c.fromProseDoc)(A.value.state.doc,k.value),a=i.package.document?.comments??[];i.package.document?.content&&a.length>0&&(n(i.package.document.content,a),r(i.package.document.content,a));let o;return o=i.originalBuffer?await e(i):await t(i),new Blob([o],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Z(){A.value?.focus()}function Q(){R(),G(),k.value=null}function $(){return k.value}(0,e.onBeforeUnmount)(()=>{Q()});function te(){return F.getCommands()}return{editorView:A,editorState:j,isReady:M,parseError:N,layout:P,loadBuffer:J,loadDocument:Y,save:X,focus:Z,destroy:Q,getDocument:$,getCommands:te,reLayout(){A.value&&I(A.value.state)},getHfPmView:ee,syncHfPMs:W,setHfTransactionListener:q,setDocument(e){k.value=e}}}var b=.25,x=4,S=.1,C=[.25,.5,.75,1,1.25,1.5,2,3,4];function w(t=1){let n=(0,e.ref)(Math.max(b,Math.min(x,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=b),a=(0,e.computed)(()=>n.value>=x);function o(e){n.value=Math.max(b,Math.min(x,Math.round(e*100)/100))}function s(){o(n.value+S)}function c(){o(n.value-S)}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:C}}var T=15,E=300,D=200,O=15;function k(){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?.classList?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),A(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),j(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),M(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*T),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=E&&o>=E&&(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*T),a=t.origHeight+i;a>=D&&(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*T),a=n.origWidth+i;a>=E&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&N(r,e),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&P(r,t),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&F(r,n),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 A(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let e=n.depth;e>=0;e--){let r=n.node(e);if(r.type.name===`table`){let e=r.attrs.columnWidths;e&&e[t.columnIndex]!==void 0&&e[t.columnIndex+1]!==void 0&&(t.origWidths={left:e[t.columnIndex],right:e[t.columnIndex+1]});return}}}function j(e,t,n){let r=e.state.doc.resolve(t.tablePmStart+1);for(let e=r.depth;e>=0;e--){let i=r.node(e);if(i.type.name===`table`){let e=null,r=0;if(i.forEach(n=>{r===t.rowIndex&&(e=n),r++}),e){let r=e.attrs.height;if(r)t.origHeight=r;else{let e=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),r=e?e.getBoundingClientRect().height:30;t.origHeight=Math.round(r*O)}}return}}}function M(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let e=n.depth;e>=0;e--){let r=n.node(e);if(r.type.name===`table`){let e=r.attrs.columnWidths;e&&e[t.columnIndex]!==void 0&&(t.origWidth=e[t.columnIndex]);return}}}function N(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=[...i.attrs.columnWidths||[]];s[t.columnIndex]=t.origWidths.left,s[t.columnIndex+1]=t.origWidths.right,o.setNodeMarkup(a,void 0,{...i.attrs,columnWidths:s});let c=a+1;i.forEach(e=>{let n=c+1,r=0;e.forEach(e=>{let i=e.attrs.colspan||1;if(r===t.columnIndex||r===t.columnIndex+1){let i=r===t.columnIndex?t.origWidths.left:t.origWidths.right;o.setNodeMarkup(o.mapping.map(n),void 0,{...e.attrs,width:i,widthType:`dxa`,colwidth:null})}n+=e.nodeSize,r+=i}),c+=e.nodeSize}),e.dispatch(o);return}}function P(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=a+1,c=0;i.forEach(e=>{c===t.rowIndex&&o.setNodeMarkup(o.mapping.map(s),void 0,{...e.attrs,height:t.origHeight,heightRule:`atLeast`}),s+=e.nodeSize,c++}),e.dispatch(o);return}}function F(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=[...i.attrs.columnWidths||[]];s[t.columnIndex]=t.origWidth,o.setNodeMarkup(a,void 0,{...i.attrs,columnWidths:s});let c=a+1;i.forEach(e=>{let n=c+1,r=0;e.forEach(e=>{let i=e.attrs.colspan||1;r===t.columnIndex&&o.setNodeMarkup(o.mapping.map(n),void 0,{...e.attrs,width:t.origWidth,widthType:`dxa`,colwidth:null}),n+=e.nodeSize,r+=i}),c+=e.nodeSize}),e.dispatch(o);return}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return k}});
|