@heyirisai/docx-editor-vue 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +116 -0
  3. package/dist/KeyboardShortcutsDialog-B0fEvXnH.js +2799 -0
  4. package/dist/KeyboardShortcutsDialog-Cmezq6eJ.cjs +1 -0
  5. package/dist/RenderedDomContext-CHc18N_2.js +2 -0
  6. package/dist/TablePropertiesDialog-B6ncvNnv.cjs +1 -0
  7. package/dist/TablePropertiesDialog-P_vyKNTn.js +1145 -0
  8. package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
  9. package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
  10. package/dist/components/DocxEditor/types.d.ts +193 -0
  11. package/dist/components/EditorToolbarContext.d.ts +9 -0
  12. package/dist/components/Toolbar/presets.d.ts +20 -0
  13. package/dist/components/dialogs/index.d.ts +27 -0
  14. package/dist/components/imageContextMenuTypes.d.ts +30 -0
  15. package/dist/components/imageSelectionTypes.d.ts +14 -0
  16. package/dist/components/insertTableState.d.ts +9 -0
  17. package/dist/components/sidebar/cardStyles.d.ts +3 -0
  18. package/dist/components/sidebar/cardUtils.d.ts +1 -0
  19. package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
  20. package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
  21. package/dist/components/tableStylePresets.d.ts +53 -0
  22. package/dist/components/toolbarUtils.d.ts +1 -0
  23. package/dist/components/ui/Icons.d.ts +1 -0
  24. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  25. package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
  26. package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
  27. package/dist/composables/fileOpen.test.d.ts +1 -0
  28. package/dist/composables/imageOverlayRect.d.ts +44 -0
  29. package/dist/composables/imageOverlayRect.test.d.ts +1 -0
  30. package/dist/composables/index.d.ts +30 -0
  31. package/dist/composables/useAutoSave.d.ts +40 -0
  32. package/dist/composables/useClipboard.d.ts +22 -0
  33. package/dist/composables/useColorMode.d.ts +8 -0
  34. package/dist/composables/useCommentLifecycle.d.ts +62 -0
  35. package/dist/composables/useCommentManagement.d.ts +68 -0
  36. package/dist/composables/useCommentSidebarItems.d.ts +24 -0
  37. package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
  38. package/dist/composables/useContextMenus.cut.test.d.ts +1 -0
  39. package/dist/composables/useContextMenus.d.ts +39 -0
  40. package/dist/composables/useControllableBoolean.d.ts +16 -0
  41. package/dist/composables/useControllableBoolean.test.d.ts +1 -0
  42. package/dist/composables/useDocumentLifecycle.d.ts +11 -0
  43. package/dist/composables/useDocxEditor.d.ts +96 -0
  44. package/dist/composables/useDocxEditorRefApi.d.ts +53 -0
  45. package/dist/composables/useDragAutoScroll.d.ts +11 -0
  46. package/dist/composables/useFileIO.d.ts +41 -0
  47. package/dist/composables/useFindReplace.d.ts +34 -0
  48. package/dist/composables/useFixedDropdown.d.ts +14 -0
  49. package/dist/composables/useFontLifecycle.d.ts +12 -0
  50. package/dist/composables/useFormattingActions.d.ts +31 -0
  51. package/dist/composables/useHistory.d.ts +9 -0
  52. package/dist/composables/useHostCallbacks.d.ts +7 -0
  53. package/dist/composables/useHyperlinkManagement.d.ts +38 -0
  54. package/dist/composables/useImageActions.d.ts +24 -0
  55. package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
  56. package/dist/composables/useMenuActions.d.ts +26 -0
  57. package/dist/composables/useOutlineSidebar.d.ts +24 -0
  58. package/dist/composables/useOutlineSidebar.test.d.ts +1 -0
  59. package/dist/composables/usePageSetupControls.d.ts +22 -0
  60. package/dist/composables/usePagesPointer.d.ts +86 -0
  61. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  62. package/dist/composables/usePortalClass.d.ts +8 -0
  63. package/dist/composables/useSelectionHighlight.d.ts +19 -0
  64. package/dist/composables/useSelectionSync.d.ts +36 -0
  65. package/dist/composables/useTableResize.d.ts +7 -0
  66. package/dist/composables/useTableSelection.d.ts +10 -0
  67. package/dist/composables/useToolbarDropdowns.d.ts +15 -0
  68. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  69. package/dist/composables/useTrackedChanges.d.ts +12 -0
  70. package/dist/composables/useVisualLineNavigation.d.ts +11 -0
  71. package/dist/composables/useWatermarkControls.d.ts +15 -0
  72. package/dist/composables/useWheelZoom.d.ts +10 -0
  73. package/dist/composables/useZoom.d.ts +16 -0
  74. package/dist/composables.cjs +1 -0
  75. package/dist/composables.js +401 -0
  76. package/dist/dialogs.cjs +1 -0
  77. package/dist/dialogs.js +3 -0
  78. package/dist/docx-editor-vue.css +2 -0
  79. package/dist/i18n/LocaleContext.d.ts +1 -0
  80. package/dist/i18n/index.d.ts +26 -0
  81. package/dist/index.cjs +19 -0
  82. package/dist/index.d.ts +24 -0
  83. package/dist/index.js +4449 -0
  84. package/dist/lib/utils.d.ts +10 -0
  85. package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
  86. package/dist/plugin-api/index.d.ts +18 -0
  87. package/dist/plugin-api/types.d.ts +28 -0
  88. package/dist/plugin-api.cjs +1 -0
  89. package/dist/plugin-api.js +62 -0
  90. package/dist/renderAsync.d.ts +31 -0
  91. package/dist/styles/index.d.ts +12 -0
  92. package/dist/styles/zIndex.d.ts +24 -0
  93. package/dist/styles.cjs +1 -0
  94. package/dist/styles.js +5 -0
  95. package/dist/ui.cjs +18 -0
  96. package/dist/ui.d.ts +79 -0
  97. package/dist/ui.js +986 -0
  98. package/dist/useCommentSidebarItems-DBeGKNGA.cjs +1 -0
  99. package/dist/useCommentSidebarItems-DXbF857R.js +45 -0
  100. package/dist/useDragAutoScroll-CVltVfKK.js +520 -0
  101. package/dist/useDragAutoScroll-liP5PRvM.cjs +1 -0
  102. package/dist/usePortalClass-B9gFYxe0.cjs +4 -0
  103. package/dist/usePortalClass-HM-UHRlE.js +3534 -0
  104. package/dist/utils/domQueries.d.ts +39 -0
  105. package/dist/utils/imageClipboard.d.ts +9 -0
  106. package/dist/utils/refApiQueries.d.ts +10 -0
  107. package/dist/zIndex-CH0jZ7U7.cjs +1 -0
  108. package/dist/zIndex-CxELVe_L.js +12 -0
  109. package/package.json +119 -0
@@ -0,0 +1 @@
1
+ let e=require(`vue`);function t({comments:t,trackedChanges:n,showResolved:r,isAddingComment:i,addCommentYPosition:a}){return(0,e.computed)(()=>{let e=[];i?.value&&a?.value!=null&&e.push({id:`new-comment-input`,anchorPos:0,fixedY:a.value,priority:-1e3,isTemporary:!0,estimatedHeight:120,kind:`add-comment`});let o=new Map;for(let e of t.value)if(e.parentId!=null){let t=o.get(e.parentId);t?t.push(e):o.set(e.parentId,[e])}for(let n of t.value)n.parentId??(n.done&&!r?.value||e.push({id:`comment-${n.id}`,anchorPos:0,anchorKey:`comment-${n.id}`,priority:0,estimatedHeight:n.done?28:80,kind:`comment`,comment:n,replies:o.get(n.id)??[]}));return n.value.forEach((t,n)=>{e.push({id:`tc-${t.revisionId}-${n}`,anchorPos:t.from,anchorKey:`revision-${t.revisionId}`,priority:1,estimatedHeight:80,kind:`tracked-change`,change:t,replies:o.get(t.revisionId)??[]})}),e})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
@@ -0,0 +1,45 @@
1
+ import { computed as e } from "vue";
2
+ //#region src/composables/useCommentSidebarItems.ts
3
+ function t({ comments: t, trackedChanges: n, showResolved: r, isAddingComment: i, addCommentYPosition: a }) {
4
+ return e(() => {
5
+ let e = [];
6
+ i?.value && a?.value != null && e.push({
7
+ id: "new-comment-input",
8
+ anchorPos: 0,
9
+ fixedY: a.value,
10
+ priority: -1e3,
11
+ isTemporary: !0,
12
+ estimatedHeight: 120,
13
+ kind: "add-comment"
14
+ });
15
+ let o = /* @__PURE__ */ new Map();
16
+ for (let e of t.value) if (e.parentId != null) {
17
+ let t = o.get(e.parentId);
18
+ t ? t.push(e) : o.set(e.parentId, [e]);
19
+ }
20
+ for (let n of t.value) n.parentId ?? (n.done && !r?.value || e.push({
21
+ id: `comment-${n.id}`,
22
+ anchorPos: 0,
23
+ anchorKey: `comment-${n.id}`,
24
+ priority: 0,
25
+ estimatedHeight: n.done ? 28 : 80,
26
+ kind: "comment",
27
+ comment: n,
28
+ replies: o.get(n.id) ?? []
29
+ }));
30
+ return n.value.forEach((t, n) => {
31
+ e.push({
32
+ id: `tc-${t.revisionId}-${n}`,
33
+ anchorPos: t.from,
34
+ anchorKey: `revision-${t.revisionId}`,
35
+ priority: 1,
36
+ estimatedHeight: 80,
37
+ kind: "tracked-change",
38
+ change: t,
39
+ replies: o.get(t.revisionId) ?? []
40
+ });
41
+ }), e;
42
+ });
43
+ }
44
+ //#endregion
45
+ export { t };
@@ -0,0 +1,520 @@
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 "@heyirisai/docx-editor-core/layout-bridge";
4
+ import { ensureParaIdsInState as p, schema as m } from "@heyirisai/docx-editor-core/prosemirror";
5
+ import { getEmbeddedFontFamilies as h, getRenderableDocumentFonts as g } from "@heyirisai/docx-editor-core/utils";
6
+ import { applySdtFocus as _, buildBlockLookup as ee, enclosingSdtGroupIds as v } from "@heyirisai/docx-editor-core/layout-painter";
7
+ import { createEmptyDoc as y, headerFooterToProseDoc as b, proseDocToBlocks as x, toProseDoc as S } from "@heyirisai/docx-editor-core/prosemirror/conversion";
8
+ import { EditorView as C } from "prosemirror-view";
9
+ import { parseDocx as te } from "@heyirisai/docx-editor-core/docx/parser";
10
+ import { fromProseDoc as w } from "@heyirisai/docx-editor-core/prosemirror/conversion/fromProseDoc";
11
+ import { singletonManager as ne } from "@heyirisai/docx-editor-core/prosemirror/schema";
12
+ import { createDocumentContextPlugin as T, createDocumentStylesPlugin as E, createSuggestionModePlugin as D, setSuggestionMode as O } from "@heyirisai/docx-editor-core/prosemirror/plugins";
13
+ import { ExtensionManager as re, createStarterKit as ie } from "@heyirisai/docx-editor-core/prosemirror/extensions";
14
+ import { measureBlocksWithFloats as k, measureParagraph as A } from "@heyirisai/docx-editor-core/layout-bridge/measuring";
15
+ import { computeLayout as ae, createLayoutScheduler as oe, stripScrollFlag as se } from "@heyirisai/docx-editor-core/editor";
16
+ import { DEFAULT_TEXTBOX_MARGINS as ce, DEFAULT_TEXTBOX_WIDTH as j, assertExhaustiveFlowBlock as le } from "@heyirisai/docx-editor-core/layout-engine";
17
+ import { renderPages as ue } from "@heyirisai/docx-editor-core/layout-painter/renderPage";
18
+ import "prosemirror-view/style/prosemirror.css";
19
+ import "@heyirisai/docx-editor-core/prosemirror/editor.css";
20
+ import { MIN_CELL_WIDTH_TWIPS as M, MIN_ROW_HEIGHT_TWIPS as N, TWIPS_PER_PIXEL as P, commitColumnResize as F, commitRightEdgeResize as I, commitRowResize as L, readColumnWidthAt as R, readColumnWidths as z, readRowHeight as B } from "@heyirisai/docx-editor-core/prosemirror/tableResize";
21
+ import { findVerticalScrollParent as V } from "@heyirisai/docx-editor-core/utils/findVerticalScrollParent";
22
+ import { AUTO_SCROLL_EDGE_ZONE as H, computeAutoScrollDelta as U } from "@heyirisai/docx-editor-core/utils/autoScroll";
23
+ //#region src/composables/useDocxEditor.ts
24
+ var de = 24;
25
+ function W(e, t, n, r) {
26
+ switch (e.kind) {
27
+ case "paragraph": return A(e, t, {
28
+ floatingZones: n,
29
+ paragraphYOffset: r ?? 0
30
+ });
31
+ case "table": return d(e, t, W);
32
+ case "image": {
33
+ let t = e;
34
+ return {
35
+ kind: "image",
36
+ width: t.width ?? 100,
37
+ height: t.height ?? 100
38
+ };
39
+ }
40
+ case "textBox": {
41
+ let t = e, n = t.margins ?? ce, r = (t.width ?? j) - n.left - n.right, i = t.content.map((e) => A(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
42
+ return {
43
+ kind: "textBox",
44
+ width: t.width ?? j,
45
+ height: o,
46
+ innerMeasures: i
47
+ };
48
+ }
49
+ case "pageBreak": return { kind: "pageBreak" };
50
+ case "columnBreak": return { kind: "columnBreak" };
51
+ case "sectionBreak": return { kind: "sectionBreak" };
52
+ default: le(e, "vue useDocxEditor measureBlock");
53
+ }
54
+ }
55
+ function fe(e, t, n) {
56
+ return k(e, t, W, n);
57
+ }
58
+ function G(e) {
59
+ let { hiddenContainer: n, pagesContainer: d, readOnly: k = !1, pageGap: A = de, onChange: ce, onError: j, onSelectionUpdate: le, externalPlugins: M = [], syncCoordinator: N, editorMode: P, author: F } = e, I = i(null), L = i(null), R = i(null), z = r(!1), B = r(null), V = r([]), H = i(null), U = ne;
60
+ function W(e) {
61
+ let t = d.value;
62
+ if (!t || !I.value) return;
63
+ let n = N?.getStateSeq() ?? 0;
64
+ N?.onLayoutStart();
65
+ let r = I.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = u(i), s = l(i), p = u(a), m = l(a), h = c(i), g = c(a), y = o.w - s.left - s.right, b = I.value.package?.theme ?? null, x = I.value.package?.styles ?? null;
66
+ try {
67
+ let { header: n, footer: r, firstHeader: c, firstFooter: l } = f(I.value, i), { blocks: u, measures: d, layout: S, headerContentForRender: C, footerContentForRender: te, firstPageHeaderForRender: w, firstPageFooterForRender: ne, hasTitlePg: T, watermark: E, footnotesByPage: D } = ae({
68
+ state: e,
69
+ document: I.value,
70
+ pageSize: o,
71
+ margins: s,
72
+ columns: h,
73
+ finalPageSize: p,
74
+ finalMargins: m,
75
+ finalColumns: g,
76
+ pageGap: A,
77
+ contentWidth: y,
78
+ theme: b,
79
+ styles: x,
80
+ sectionProperties: i,
81
+ finalSectionProperties: a,
82
+ headerContent: n,
83
+ footerContent: r,
84
+ firstPageHeaderContent: c,
85
+ firstPageFooterContent: l,
86
+ measureBlocks: fe,
87
+ getHfPmDoc: (e) => Z(e)?.state.doc ?? null
88
+ });
89
+ H.value = S;
90
+ let O = ee(u, d);
91
+ ue(S.pages, t, {
92
+ pageGap: A,
93
+ showShadow: !0,
94
+ pageBackground: "var(--doc-page-bg, #ffffff)",
95
+ blockLookup: O,
96
+ theme: b,
97
+ headerContent: C,
98
+ footerContent: te,
99
+ firstPageHeaderContent: w,
100
+ firstPageFooterContent: ne,
101
+ titlePage: T,
102
+ watermark: E,
103
+ footnotesByPage: D
104
+ }), t.style.overflowY = "auto", t.style.minHeight = "0";
105
+ for (let e of Array.from(t.children)) e.style.flexShrink = "0";
106
+ _(t, v(e.doc, e.selection.from, e.selection.to));
107
+ } catch (e) {
108
+ console.error("[useDocxEditor] Layout pipeline error:", e), j?.(e instanceof Error ? e : Error(String(e)));
109
+ } finally {
110
+ N?.onLayoutComplete(n);
111
+ }
112
+ }
113
+ let G = oe(W);
114
+ function K() {
115
+ let e = n.value;
116
+ if (!e) return;
117
+ let t = I.value?.package?.styles, r = I.value ? S(I.value, { styles: t ?? void 0 }) : y(), i = D(!1), o = E(t), c = T({
118
+ theme: I.value?.package?.theme ?? null,
119
+ defaultTableStyleId: I.value?.package?.settings?.defaultTableStyle ?? null
120
+ }), l = [
121
+ i,
122
+ ...M,
123
+ ...U.getPlugins() ?? [],
124
+ o,
125
+ c
126
+ ], u = p(s.create({
127
+ doc: r,
128
+ schema: U.getSchema(),
129
+ plugins: l
130
+ }));
131
+ if (R.value = u, I.value) try {
132
+ I.value = w(u.doc, I.value);
133
+ } catch (e) {
134
+ console.error("[useDocxEditor] paraId cache sync error:", e);
135
+ }
136
+ let f = new C(e, {
137
+ state: u,
138
+ editable: () => !a(k),
139
+ dispatchTransaction(e) {
140
+ if (!f) return;
141
+ se(e, f.state.tr);
142
+ let t = f.state.apply(e);
143
+ if (f.updateState(t), R.value = t, e.docChanged) {
144
+ N?.incrementStateSeq(), G.schedule(t);
145
+ try {
146
+ if (I.value) {
147
+ let e = w(t.doc, I.value);
148
+ I.value = e, ce?.(e);
149
+ }
150
+ } catch (e) {
151
+ console.error("[useDocxEditor] fromProseDoc error:", e);
152
+ }
153
+ }
154
+ if (N?.requestRender(), le?.(), !e.docChanged) {
155
+ let e = d.value;
156
+ e && _(e, v(t.doc, t.selection.from, t.selection.to));
157
+ }
158
+ }
159
+ });
160
+ L.value = f, z.value = !0, W(u), N?.requestRender(), a(k) || requestAnimationFrame(() => {
161
+ f.focus();
162
+ });
163
+ }
164
+ function q() {
165
+ G.cancel(), L.value &&= (L.value.destroy(), null), R.value = null, z.value = !1;
166
+ }
167
+ let J = { current: null }, Y = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map();
168
+ function pe() {
169
+ if (J.current && J.current.isConnected) return J.current;
170
+ let e = window.document.createElement("div");
171
+ 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), J.current = e, e;
172
+ }
173
+ function me(e) {
174
+ let t = I.value?.package;
175
+ if (!t) return null;
176
+ if (t.headers) {
177
+ for (let [n, r] of t.headers) if (r === e) return n;
178
+ }
179
+ if (t.footers) {
180
+ for (let [n, r] of t.footers) if (r === e) return n;
181
+ }
182
+ return null;
183
+ }
184
+ function Z(e) {
185
+ let t = me(e);
186
+ return t ? Y.get(t) ?? null : null;
187
+ }
188
+ function Q() {
189
+ let e = I.value?.package, t = pe(), n = /* @__PURE__ */ new Set();
190
+ if (e?.headers) for (let t of e.headers.keys()) n.add(t);
191
+ if (e?.footers) for (let t of e.footers.keys()) n.add(t);
192
+ for (let [e, t] of Y) n.has(e) || (t.destroy(), t.dom.parentElement?.remove(), X.get(e)?.destroy(), X.delete(e), Y.delete(e));
193
+ if (!e) return;
194
+ let r = e.styles ?? null, i = e.theme ?? null, o = e.settings?.defaultTabStop ?? null, c = e.settings?.defaultTableStyle ?? null;
195
+ for (let l of n) {
196
+ if (Y.has(l)) continue;
197
+ let n = e.headers?.get(l) ?? e.footers?.get(l);
198
+ if (!n) continue;
199
+ let u = e.headers?.has(l) ? "header" : "footer", d = new re(ie());
200
+ d.buildSchema(), d.initializeRuntime(), X.set(l, d);
201
+ let f = window.document.createElement("div");
202
+ f.dataset.hfRId = l, f.dataset.hfKind = u, t.appendChild(f);
203
+ let p = b(n.content, {
204
+ styles: r ?? void 0,
205
+ theme: i,
206
+ defaultTabStopTwips: o
207
+ }), h = E(r), g = T({
208
+ theme: i,
209
+ defaultTableStyleId: c
210
+ }), _ = D(a(P) === "suggesting", a(F)), ee = s.create({
211
+ doc: p,
212
+ schema: m,
213
+ plugins: [
214
+ _,
215
+ ...d.getPlugins(),
216
+ h,
217
+ g
218
+ ]
219
+ }), v = u, y = new C(f, {
220
+ state: ee,
221
+ dispatchTransaction(e) {
222
+ let t = y.state.apply(e);
223
+ if (y.updateState(t), e.docChanged) {
224
+ let e = I.value?.package, n = (v === "header" ? e?.headers : e?.footers)?.get(l);
225
+ n && (n.content = x(t.doc));
226
+ }
227
+ e.docChanged && R.value && W(R.value), he.value?.(l, y, e.docChanged);
228
+ }
229
+ });
230
+ Y.set(l, y);
231
+ }
232
+ }
233
+ function $() {
234
+ for (let e of Y.values()) e.destroy(), e.dom.parentElement?.remove();
235
+ Y.clear();
236
+ for (let e of X.values()) e.destroy();
237
+ X.clear(), J.current &&= (J.current.remove(), null);
238
+ }
239
+ o([
240
+ () => a(P),
241
+ () => a(F),
242
+ L
243
+ ], ([e, t, n]) => {
244
+ let r = e === "suggesting";
245
+ n && O(r, n.state, n.dispatch, t);
246
+ for (let e of Y.values()) O(r, e.state, e.dispatch, t);
247
+ }, { immediate: !0 });
248
+ let he = { value: null };
249
+ function ge(e) {
250
+ he.value = e;
251
+ }
252
+ async function _e(e) {
253
+ B.value = null, z.value = !1;
254
+ try {
255
+ let t;
256
+ t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e;
257
+ let n = await te(t);
258
+ I.value = n, ye(n), q(), $(), K(), Q();
259
+ } catch (e) {
260
+ let t = e instanceof Error ? e : Error(String(e));
261
+ B.value = t.message, j?.(t);
262
+ }
263
+ }
264
+ function ve(e) {
265
+ B.value = null, I.value = e, ye(e), q(), $(), K(), Q();
266
+ }
267
+ function ye(e) {
268
+ V.value = g(e, { embeddedFamilies: h(e.package?.fontTable) });
269
+ }
270
+ async function be() {
271
+ if (!L.value || !I.value) return null;
272
+ let { repackDocx: e, createDocx: t } = await import("@heyirisai/docx-editor-core/docx/rezip"), { injectReplyRangeMarkers: n, injectTCReplyRangeMarkers: r } = await import("@heyirisai/docx-editor-core/docx"), i = w(L.value.state.doc, I.value), a = i.package.document?.comments ?? [];
273
+ i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
274
+ let o;
275
+ return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
276
+ }
277
+ function xe() {
278
+ L.value?.focus();
279
+ }
280
+ function Se() {
281
+ q(), $(), I.value = null;
282
+ }
283
+ function Ce() {
284
+ return I.value;
285
+ }
286
+ t(() => {
287
+ Se();
288
+ });
289
+ function we() {
290
+ return U.getCommands();
291
+ }
292
+ return {
293
+ editorView: L,
294
+ editorState: R,
295
+ isReady: z,
296
+ parseError: B,
297
+ documentFonts: V,
298
+ layout: H,
299
+ loadBuffer: _e,
300
+ loadDocument: ve,
301
+ save: be,
302
+ focus: xe,
303
+ destroy: Se,
304
+ getDocument: Ce,
305
+ getCommands: we,
306
+ reLayout() {
307
+ L.value && W(L.value.state);
308
+ },
309
+ getHfPmView: Z,
310
+ getHfPmViews() {
311
+ return Y;
312
+ },
313
+ syncHfPMs: Q,
314
+ setHfTransactionListener: ge,
315
+ setDocument(e) {
316
+ I.value = e;
317
+ }
318
+ };
319
+ }
320
+ //#endregion
321
+ //#region src/composables/useZoom.ts
322
+ var K = .5, q = 2, J = .1, Y = [
323
+ .5,
324
+ .75,
325
+ 1,
326
+ 1.25,
327
+ 1.5,
328
+ 2
329
+ ];
330
+ function X(i = 1) {
331
+ 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);
332
+ function l(e) {
333
+ a.value = Math.max(K, Math.min(q, Math.round(e * 100) / 100));
334
+ }
335
+ function u() {
336
+ l(a.value + J);
337
+ }
338
+ function d() {
339
+ l(a.value - J);
340
+ }
341
+ function f() {
342
+ l(1);
343
+ }
344
+ function p(e) {
345
+ (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
346
+ }
347
+ function m(e) {
348
+ (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())));
349
+ }
350
+ function h() {
351
+ n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
352
+ }
353
+ return {
354
+ zoom: a,
355
+ zoomPercent: o,
356
+ isMinZoom: s,
357
+ isMaxZoom: c,
358
+ setZoom: l,
359
+ zoomIn: u,
360
+ zoomOut: d,
361
+ resetZoom: f,
362
+ handleWheel: p,
363
+ handleKeyDown: m,
364
+ installShortcuts: h,
365
+ ZOOM_PRESETS: Y
366
+ };
367
+ }
368
+ //#endregion
369
+ //#region src/composables/useTableResize.ts
370
+ function pe() {
371
+ let e = {
372
+ active: !1,
373
+ startX: 0,
374
+ handle: null,
375
+ columnIndex: 0,
376
+ tablePmStart: 0,
377
+ origWidths: {
378
+ left: 0,
379
+ right: 0
380
+ }
381
+ }, t = {
382
+ active: !1,
383
+ startY: 0,
384
+ handle: null,
385
+ rowIndex: 0,
386
+ isEdge: !1,
387
+ tablePmStart: 0,
388
+ origHeight: 0
389
+ }, n = {
390
+ active: !1,
391
+ startX: 0,
392
+ handle: null,
393
+ columnIndex: 0,
394
+ tablePmStart: 0,
395
+ origWidth: 0
396
+ }, r = null;
397
+ function i() {
398
+ return e.active || t.active || n.active;
399
+ }
400
+ function a(i, a) {
401
+ let o = i.target;
402
+ 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), me(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;
403
+ }
404
+ function o(r) {
405
+ if (e.active && e.handle) {
406
+ r.preventDefault();
407
+ let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
408
+ e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
409
+ let i = Math.round(t * P), a = e.origWidths.left + i, o = e.origWidths.right - i;
410
+ a >= M && o >= M && (e.origWidths = {
411
+ left: a,
412
+ right: o
413
+ });
414
+ return;
415
+ }
416
+ if (t.active && t.handle) {
417
+ r.preventDefault();
418
+ let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
419
+ t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
420
+ let i = Math.round(e * P), a = t.origHeight + i;
421
+ a >= N && (t.origHeight = a);
422
+ return;
423
+ }
424
+ if (n.active && n.handle) {
425
+ r.preventDefault();
426
+ let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
427
+ n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
428
+ let i = Math.round(e * P), a = n.origWidth + i;
429
+ a >= M && (n.origWidth = a);
430
+ }
431
+ }
432
+ function s(i) {
433
+ if (e.active) {
434
+ e.active = !1, e.handle?.classList.remove("dragging"), r && F(r, {
435
+ pmStart: e.tablePmStart,
436
+ colIdx: e.columnIndex,
437
+ newLeft: e.origWidths.left,
438
+ newRight: e.origWidths.right
439
+ }), e.handle = null;
440
+ return;
441
+ }
442
+ if (t.active) {
443
+ t.active = !1, t.handle?.classList.remove("dragging"), r && L(r, {
444
+ pmStart: t.tablePmStart,
445
+ rowIdx: t.rowIndex,
446
+ newHeight: t.origHeight
447
+ }), t.handle = null;
448
+ return;
449
+ }
450
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && I(r, {
451
+ pmStart: n.tablePmStart,
452
+ colIdx: n.columnIndex,
453
+ newWidth: n.origWidth
454
+ }), n.handle = null);
455
+ }
456
+ function c() {
457
+ return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
458
+ document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
459
+ };
460
+ }
461
+ return {
462
+ tryStartResize: a,
463
+ install: c,
464
+ isResizing: i
465
+ };
466
+ }
467
+ function me(e, t) {
468
+ let n = z(e, t.tablePmStart, t.columnIndex);
469
+ n && (t.origWidths = n);
470
+ }
471
+ function Z(e, t, n) {
472
+ let r = B(e, t.tablePmStart, t.rowIndex);
473
+ if (r != null) {
474
+ t.origHeight = r;
475
+ return;
476
+ }
477
+ let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
478
+ t.origHeight = Math.round(a * P);
479
+ }
480
+ function Q(e, t) {
481
+ let n = R(e, t.tablePmStart, t.columnIndex);
482
+ n != null && (t.origWidth = n);
483
+ }
484
+ //#endregion
485
+ //#region src/composables/useDragAutoScroll.ts
486
+ function $({ pagesContainer: e, onScrollExtendSelection: n }) {
487
+ let r = null, i = 0, a = 0, o = !1, s = null;
488
+ function c() {
489
+ if (s) return s;
490
+ let t = e.value;
491
+ return t ? (s = V(t), s) : null;
492
+ }
493
+ function l() {
494
+ o = !1, r !== null && (cancelAnimationFrame(r), r = null);
495
+ }
496
+ function u() {
497
+ if (!o) return;
498
+ let e = c();
499
+ if (!e) return;
500
+ let t = U(e.getBoundingClientRect(), a);
501
+ t !== 0 && (e.scrollTop += t, n(i, a)), r = requestAnimationFrame(u);
502
+ }
503
+ function d() {
504
+ o || (o = !0, r = requestAnimationFrame(u));
505
+ }
506
+ function f(e, t) {
507
+ if (i = e, a = t, !o) {
508
+ let e = c();
509
+ if (!e) return;
510
+ let n = e.getBoundingClientRect();
511
+ (t < n.top + H || t > n.bottom - H) && d();
512
+ }
513
+ }
514
+ return t(() => l()), {
515
+ updateMousePosition: f,
516
+ stopAutoScroll: l
517
+ };
518
+ }
519
+ //#endregion
520
+ export { G as i, pe as n, X as r, $ as t };
@@ -0,0 +1 @@
1
+ let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@heyirisai/docx-editor-core/layout-bridge`),r=require(`@heyirisai/docx-editor-core/prosemirror`),i=require(`@heyirisai/docx-editor-core/utils`),a=require(`@heyirisai/docx-editor-core/layout-painter`),o=require(`@heyirisai/docx-editor-core/prosemirror/conversion`),s=require(`prosemirror-view`),c=require(`@heyirisai/docx-editor-core/docx/parser`),l=require(`@heyirisai/docx-editor-core/prosemirror/conversion/fromProseDoc`),u=require(`@heyirisai/docx-editor-core/prosemirror/schema`),d=require(`@heyirisai/docx-editor-core/prosemirror/plugins`),f=require(`@heyirisai/docx-editor-core/prosemirror/extensions`),p=require(`@heyirisai/docx-editor-core/layout-bridge/measuring`),m=require(`@heyirisai/docx-editor-core/editor`),h=require(`@heyirisai/docx-editor-core/layout-engine`),g=require(`@heyirisai/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@heyirisai/docx-editor-core/prosemirror/editor.css`);let _=require(`@heyirisai/docx-editor-core/prosemirror/tableResize`),v=require(`@heyirisai/docx-editor-core/utils/findVerticalScrollParent`),y=require(`@heyirisai/docx-editor-core/utils/autoScroll`);var b=24;function x(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,x);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??h.DEFAULT_TEXTBOX_MARGINS,r=(t.width??h.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??h.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,h.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function S(e,t,n){return(0,p.measureBlocksWithFloats)(e,t,x,n)}function C(p){let{hiddenContainer:h,pagesContainer:_,readOnly:v=!1,pageGap:y=b,onChange:x,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.ref)([]),F=(0,e.shallowRef)(null),I=u.singletonManager;function L(e){let t=_.value;if(!t||!k.value)return;let r=E?.getStateSeq()??0;E?.onLayoutStart();let i=k.value.package?.document,o=i?.sections?.[0]?.properties??i?.finalSectionProperties??null,s=i?.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),p=(0,n.getColumns)(s),h=c.w-l.left-l.right,v=k.value.package?.theme??null,b=k.value.package?.styles??null;try{let{header:r,footer:i,firstHeader:_,firstFooter:x}=(0,n.resolveHeaderFooter)(k.value,o),{blocks:C,measures:w,layout:T,headerContentForRender:E,footerContentForRender:D,firstPageHeaderForRender:O,firstPageFooterForRender:A,hasTitlePg:j,watermark:M,footnotesByPage:N}=(0,m.computeLayout)({state:e,document:k.value,pageSize:c,margins:l,columns:f,finalPageSize:u,finalMargins:d,finalColumns:p,pageGap:y,contentWidth:h,theme:v,styles:b,sectionProperties:o,finalSectionProperties:s,headerContent:r,footerContent:i,firstPageHeaderContent:_,firstPageFooterContent:x,measureBlocks:S,getHfPmDoc:e=>K(e)?.state.doc??null});F.value=T;let P=(0,a.buildBlockLookup)(C,w);(0,g.renderPages)(T.pages,t,{pageGap:y,showShadow:!0,pageBackground:`var(--doc-page-bg, #ffffff)`,blockLookup:P,theme:v,headerContent:E,footerContent:D,firstPageHeaderContent:O,firstPageFooterContent:A,titlePage:j,watermark:M,footnotesByPage:N}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,a.applySdtFocus)(t,(0,a.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(r)}}let R=(0,m.createLayoutScheduler)(L);function z(){let n=h.value;if(!n)return;let i=k.value?.package?.styles,c=k.value?(0,o.toProseDoc)(k.value,{styles:i??void 0}):(0,o.createEmptyDoc)(),u=(0,d.createSuggestionModePlugin)(!1),f=(0,d.createDocumentStylesPlugin)(i),p=(0,d.createDocumentContextPlugin)({theme:k.value?.package?.theme??null,defaultTableStyleId:k.value?.package?.settings?.defaultTableStyle??null}),g=[u,...T,...I.getPlugins()??[],f,p],y=(0,r.ensureParaIdsInState)(t.EditorState.create({doc:c,schema:I.getSchema(),plugins:g}));if(j.value=y,k.value)try{k.value=(0,l.fromProseDoc)(y.doc,k.value)}catch(e){console.error(`[useDocxEditor] paraId cache sync error:`,e)}let b=new s.EditorView(n,{state:y,editable:()=>!(0,e.unref)(v),dispatchTransaction(e){if(!b)return;(0,m.stripScrollFlag)(e,b.state.tr);let t=b.state.apply(e);if(b.updateState(t),j.value=t,e.docChanged){E?.incrementStateSeq(),R.schedule(t);try{if(k.value){let e=(0,l.fromProseDoc)(t.doc,k.value);k.value=e,x?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(E?.requestRender(),w?.(),!e.docChanged){let e=_.value;e&&(0,a.applySdtFocus)(e,(0,a.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});A.value=b,M.value=!0,L(y),E?.requestRender(),(0,e.unref)(v)||requestAnimationFrame(()=>{b.focus()})}function B(){R.cancel(),A.value&&=(A.value.destroy(),null),j.value=null,M.value=!1}let V={current:null},H=new Map,U=new Map;function W(){if(V.current&&V.current.isConnected)return V.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),V.current=e,e}function G(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 K(e){let t=G(e);return t?H.get(t)??null:null}function q(){let n=k.value?.package,i=W(),a=new Set;if(n?.headers)for(let e of n.headers.keys())a.add(e);if(n?.footers)for(let e of n.footers.keys())a.add(e);for(let[e,t]of H)a.has(e)||(t.destroy(),t.dom.parentElement?.remove(),U.get(e)?.destroy(),U.delete(e),H.delete(e));if(!n)return;let c=n.styles??null,l=n.theme??null,u=n.settings?.defaultTabStop??null,p=n.settings?.defaultTableStyle??null;for(let m of a){if(H.has(m))continue;let a=n.headers?.get(m)??n.footers?.get(m);if(!a)continue;let h=n.headers?.has(m)?`header`:`footer`,g=new f.ExtensionManager((0,f.createStarterKit)());g.buildSchema(),g.initializeRuntime(),U.set(m,g);let _=window.document.createElement(`div`);_.dataset.hfRId=m,_.dataset.hfKind=h,i.appendChild(_);let v=(0,o.headerFooterToProseDoc)(a.content,{styles:c??void 0,theme:l,defaultTabStopTwips:u}),y=(0,d.createDocumentStylesPlugin)(c),b=(0,d.createDocumentContextPlugin)({theme:l,defaultTableStyleId:p}),x=(0,d.createSuggestionModePlugin)((0,e.unref)(D)===`suggesting`,(0,e.unref)(O)),S=t.EditorState.create({doc:v,schema:r.schema,plugins:[x,...g.getPlugins(),y,b]}),C=h,w=new s.EditorView(_,{state:S,dispatchTransaction(e){let t=w.state.apply(e);if(w.updateState(t),e.docChanged){let e=k.value?.package,n=(C===`header`?e?.headers:e?.footers)?.get(m);n&&(n.content=(0,o.proseDocToBlocks)(t.doc))}e.docChanged&&j.value&&L(j.value),Y.value?.(m,w,e.docChanged)}});H.set(m,w)}}function J(){for(let e of H.values())e.destroy(),e.dom.parentElement?.remove();H.clear();for(let e of U.values())e.destroy();U.clear(),V.current&&=(V.current.remove(),null)}(0,e.watch)([()=>(0,e.unref)(D),()=>(0,e.unref)(O),A],([e,t,n])=>{let r=e===`suggesting`;n&&(0,d.setSuggestionMode)(r,n.state,n.dispatch,t);for(let e of H.values())(0,d.setSuggestionMode)(r,e.state,e.dispatch,t)},{immediate:!0});let Y={value:null};function X(e){Y.value=e}async function Z(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;let n=await(0,c.parseDocx)(t);k.value=n,Q(n),B(),J(),z(),q()}catch(e){let t=e instanceof Error?e:Error(String(e));N.value=t.message,C?.(t)}}function ee(e){N.value=null,k.value=e,Q(e),B(),J(),z(),q()}function Q(e){P.value=(0,i.getRenderableDocumentFonts)(e,{embeddedFamilies:(0,i.getEmbeddedFontFamilies)(e.package?.fontTable)})}async function te(){if(!A.value||!k.value)return null;let{repackDocx:e,createDocx:t}=await import(`@heyirisai/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@heyirisai/docx-editor-core/docx`),i=(0,l.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 ne(){A.value?.focus()}function $(){B(),J(),k.value=null}function re(){return k.value}(0,e.onBeforeUnmount)(()=>{$()});function ie(){return I.getCommands()}return{editorView:A,editorState:j,isReady:M,parseError:N,documentFonts:P,layout:F,loadBuffer:Z,loadDocument:ee,save:te,focus:ne,destroy:$,getDocument:re,getCommands:ie,reLayout(){A.value&&L(A.value.state)},getHfPmView:K,getHfPmViews(){return H},syncHfPMs:q,setHfTransactionListener:X,setDocument(e){k.value=e}}}var w=.5,T=2,E=.1,D=[.5,.75,1,1.25,1.5,2];function O(t=1){let n=(0,e.ref)(Math.max(w,Math.min(T,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=w),a=(0,e.computed)(()=>n.value>=T);function o(e){n.value=Math.max(w,Math.min(T,Math.round(e*100)/100))}function s(){o(n.value+E)}function c(){o(n.value-E)}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:D}}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*_.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=_.MIN_CELL_WIDTH_TWIPS&&o>=_.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*_.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=_.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*_.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=_.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,_.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,_.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,_.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 A(e,t){let n=(0,_.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function j(e,t,n){let r=(0,_.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*_.TWIPS_PER_PIXEL)}function M(e,t){let n=(0,_.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function N({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,v.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,y.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+y.AUTO_SCROLL_EDGE_ZONE||t>n.bottom-y.AUTO_SCROLL_EDGE_ZONE)&&d()}}return(0,e.onBeforeUnmount)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return N}});