@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.
- package/LICENSE +201 -0
- package/README.md +116 -0
- package/dist/KeyboardShortcutsDialog-B0fEvXnH.js +2799 -0
- package/dist/KeyboardShortcutsDialog-Cmezq6eJ.cjs +1 -0
- package/dist/RenderedDomContext-CHc18N_2.js +2 -0
- package/dist/TablePropertiesDialog-B6ncvNnv.cjs +1 -0
- package/dist/TablePropertiesDialog-P_vyKNTn.js +1145 -0
- package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
- package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
- package/dist/components/DocxEditor/types.d.ts +193 -0
- package/dist/components/EditorToolbarContext.d.ts +9 -0
- package/dist/components/Toolbar/presets.d.ts +20 -0
- package/dist/components/dialogs/index.d.ts +27 -0
- package/dist/components/imageContextMenuTypes.d.ts +30 -0
- package/dist/components/imageSelectionTypes.d.ts +14 -0
- package/dist/components/insertTableState.d.ts +9 -0
- package/dist/components/sidebar/cardStyles.d.ts +3 -0
- package/dist/components/sidebar/cardUtils.d.ts +1 -0
- package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
- package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
- package/dist/components/tableStylePresets.d.ts +53 -0
- package/dist/components/toolbarUtils.d.ts +1 -0
- package/dist/components/ui/Icons.d.ts +1 -0
- package/dist/components/ui/fontPickerValue.d.ts +1 -0
- package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
- package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
- package/dist/composables/fileOpen.test.d.ts +1 -0
- package/dist/composables/imageOverlayRect.d.ts +44 -0
- package/dist/composables/imageOverlayRect.test.d.ts +1 -0
- package/dist/composables/index.d.ts +30 -0
- package/dist/composables/useAutoSave.d.ts +40 -0
- package/dist/composables/useClipboard.d.ts +22 -0
- package/dist/composables/useColorMode.d.ts +8 -0
- package/dist/composables/useCommentLifecycle.d.ts +62 -0
- package/dist/composables/useCommentManagement.d.ts +68 -0
- package/dist/composables/useCommentSidebarItems.d.ts +24 -0
- package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
- package/dist/composables/useContextMenus.cut.test.d.ts +1 -0
- package/dist/composables/useContextMenus.d.ts +39 -0
- package/dist/composables/useControllableBoolean.d.ts +16 -0
- package/dist/composables/useControllableBoolean.test.d.ts +1 -0
- package/dist/composables/useDocumentLifecycle.d.ts +11 -0
- package/dist/composables/useDocxEditor.d.ts +96 -0
- package/dist/composables/useDocxEditorRefApi.d.ts +53 -0
- package/dist/composables/useDragAutoScroll.d.ts +11 -0
- package/dist/composables/useFileIO.d.ts +41 -0
- package/dist/composables/useFindReplace.d.ts +34 -0
- package/dist/composables/useFixedDropdown.d.ts +14 -0
- package/dist/composables/useFontLifecycle.d.ts +12 -0
- package/dist/composables/useFormattingActions.d.ts +31 -0
- package/dist/composables/useHistory.d.ts +9 -0
- package/dist/composables/useHostCallbacks.d.ts +7 -0
- package/dist/composables/useHyperlinkManagement.d.ts +38 -0
- package/dist/composables/useImageActions.d.ts +24 -0
- package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
- package/dist/composables/useMenuActions.d.ts +26 -0
- package/dist/composables/useOutlineSidebar.d.ts +24 -0
- package/dist/composables/useOutlineSidebar.test.d.ts +1 -0
- package/dist/composables/usePageSetupControls.d.ts +22 -0
- package/dist/composables/usePagesPointer.d.ts +86 -0
- package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
- package/dist/composables/usePortalClass.d.ts +8 -0
- package/dist/composables/useSelectionHighlight.d.ts +19 -0
- package/dist/composables/useSelectionSync.d.ts +36 -0
- package/dist/composables/useTableResize.d.ts +7 -0
- package/dist/composables/useTableSelection.d.ts +10 -0
- package/dist/composables/useToolbarDropdowns.d.ts +15 -0
- package/dist/composables/useToolbarFontSize.d.ts +15 -0
- package/dist/composables/useTrackedChanges.d.ts +12 -0
- package/dist/composables/useVisualLineNavigation.d.ts +11 -0
- package/dist/composables/useWatermarkControls.d.ts +15 -0
- package/dist/composables/useWheelZoom.d.ts +10 -0
- package/dist/composables/useZoom.d.ts +16 -0
- package/dist/composables.cjs +1 -0
- package/dist/composables.js +401 -0
- package/dist/dialogs.cjs +1 -0
- package/dist/dialogs.js +3 -0
- package/dist/docx-editor-vue.css +2 -0
- package/dist/i18n/LocaleContext.d.ts +1 -0
- package/dist/i18n/index.d.ts +26 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +4449 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
- package/dist/plugin-api/index.d.ts +18 -0
- package/dist/plugin-api/types.d.ts +28 -0
- package/dist/plugin-api.cjs +1 -0
- package/dist/plugin-api.js +62 -0
- package/dist/renderAsync.d.ts +31 -0
- package/dist/styles/index.d.ts +12 -0
- package/dist/styles/zIndex.d.ts +24 -0
- package/dist/styles.cjs +1 -0
- package/dist/styles.js +5 -0
- package/dist/ui.cjs +18 -0
- package/dist/ui.d.ts +79 -0
- package/dist/ui.js +986 -0
- package/dist/useCommentSidebarItems-DBeGKNGA.cjs +1 -0
- package/dist/useCommentSidebarItems-DXbF857R.js +45 -0
- package/dist/useDragAutoScroll-CVltVfKK.js +520 -0
- package/dist/useDragAutoScroll-liP5PRvM.cjs +1 -0
- package/dist/usePortalClass-B9gFYxe0.cjs +4 -0
- package/dist/usePortalClass-HM-UHRlE.js +3534 -0
- package/dist/utils/domQueries.d.ts +39 -0
- package/dist/utils/imageClipboard.d.ts +9 -0
- package/dist/utils/refApiQueries.d.ts +10 -0
- package/dist/zIndex-CH0jZ7U7.cjs +1 -0
- package/dist/zIndex-CxELVe_L.js +12 -0
- package/package.json +119 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4449 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./KeyboardShortcutsDialog-B0fEvXnH.js";
|
|
2
|
+
import { C as f, _ as p, c as m, l as h, n as g, o as _, r as v, s as y, t as b, u as ee } from "./usePortalClass-HM-UHRlE.js";
|
|
3
|
+
import { t as x } from "./_plugin-vue_export-helper-B52Kst-M.js";
|
|
4
|
+
import { n as S } from "./RenderedDomContext-CHc18N_2.js";
|
|
5
|
+
import { t as C } from "./zIndex-CxELVe_L.js";
|
|
6
|
+
import { i as te, n as ne, r as w, t as re } from "./useDragAutoScroll-CVltVfKK.js";
|
|
7
|
+
import { Fragment as T, Teleport as E, computed as D, createApp as ie, createBlock as O, createCommentVNode as k, createElementBlock as A, createElementVNode as j, createSlots as ae, createStaticVNode as oe, createTextVNode as M, createVNode as N, defineComponent as P, h as se, isRef as ce, nextTick as le, normalizeClass as F, normalizeStyle as I, onBeforeUnmount as L, onMounted as R, openBlock as z, ref as B, renderList as V, renderSlot as ue, resolveDynamicComponent as de, shallowRef as fe, toDisplayString as H, unref as U, vModelCheckbox as W, vModelSelect as pe, vModelText as G, watch as K, watchEffect as me, withCtx as he, withDirectives as q, withKeys as J, withModifiers as Y } from "vue";
|
|
8
|
+
import { NodeSelection as ge, TextSelection as _e } from "prosemirror-state";
|
|
9
|
+
import { applyCellSelectionHighlight as ve, clickToPositionDom as X, computeHfCaretRectFromView as ye, computeHfSelectionRectsFromView as be, findBodyPmAnchor as xe, findBodyPmSpans as Se } from "@heyirisai/docx-editor-core/layout-bridge";
|
|
10
|
+
import { clampRangeToDoc as Ce, findChangeRange as we, findCommentRange as Te, findInDocument as Ee, getPageContent as De, getSelectionInfo as Oe } from "@heyirisai/docx-editor-core/prosemirror/queries";
|
|
11
|
+
import { LayoutSelectionGate as ke, addRepeatingSectionItemTr as Ae, extractSelectionState as je, findContentControlPos as Me, findContentControlsInPM as Ne, removeContentControlTr as Z, removeRepeatingSectionItemTr as Pe, schema as Fe, setContentControlContentTr as Ie, setContentControlValueAtPosTr as Le, setContentControlValueTr as Re } from "@heyirisai/docx-editor-core/prosemirror";
|
|
12
|
+
import { SIDEBAR_DOCUMENT_SHIFT as ze, findWordBoundaries as Be, flashParagraphFragmentsByParaId as Ve, loadFontDefinitions as He, onFontError as Ue, pixelsToEmu as Q, prefersColorSchemeDark as We, readDocxFileFromInput as Ge, resolveIsDark as Ke, subscribeSystemDark as qe, toArrayBuffer as Je } from "@heyirisai/docx-editor-core/utils";
|
|
13
|
+
import { extractSelectionContext as Ye } from "@heyirisai/docx-editor-core/prosemirror/plugins/selectionTracker";
|
|
14
|
+
import { clearFormatting as Xe, findHyperlinkRangeAt as Ze } from "@heyirisai/docx-editor-core/prosemirror/commands/formatting";
|
|
15
|
+
import { getTableContext as Qe } from "@heyirisai/docx-editor-core/prosemirror/extensions/nodes/TableExtension";
|
|
16
|
+
import { clickToPositionDom as $e, getCaretPositionFromDom as et, getSelectionRectsFromDom as tt } from "@heyirisai/docx-editor-core/layout-bridge/clickToPositionDom";
|
|
17
|
+
import { calculateResizedImageDimensions as nt, commitImageFloatMove as rt, commitImageInlineMove as it, commitImageResize as at, isFloatingImage as ot } from "@heyirisai/docx-editor-core/prosemirror/imageCommit";
|
|
18
|
+
import { IMAGE_LAYOUT_OPTIONS as st, captureInlinePositionEmu as ct, deriveLayoutChoice as lt, findImageElement as ut, isImageLayoutOptionEnabled as dt, renderAllPagesNow as ft, toolbarValueToLayoutTarget as pt } from "@heyirisai/docx-editor-core/layout-painter";
|
|
19
|
+
import { proseDocToBlocks as mt } from "@heyirisai/docx-editor-core/prosemirror/conversion";
|
|
20
|
+
import { twipsToPixels as ht } from "@heyirisai/docx-editor-core/utils/units";
|
|
21
|
+
import { DEFAULT_WATERMARK_PRESETS as gt, pictureWatermarkDisplayEmu as _t } from "@heyirisai/docx-editor-core/types/document";
|
|
22
|
+
import { makeRevisionInfo as vt } from "@heyirisai/docx-editor-core/prosemirror/plugins";
|
|
23
|
+
import { findPageIndexContainingPmPos as yt } from "@heyirisai/docx-editor-core/layout-engine";
|
|
24
|
+
import { acceptChange as bt, acceptChangeById as xt, getWatermarkFromState as St, insertImageFromFile as Ct, rejectChange as wt, rejectChangeById as Tt, setWatermark as Et } from "@heyirisai/docx-editor-core/prosemirror/commands";
|
|
25
|
+
import { applyStyle as Dt, removeTabStop as Ot, setIndentFirstLine as kt, setIndentLeft as At, setIndentRight as jt } from "@heyirisai/docx-editor-core/prosemirror/commands/paragraph";
|
|
26
|
+
import { createStyleResolver as Mt } from "@heyirisai/docx-editor-core/prosemirror/styles";
|
|
27
|
+
import { getCachedNumberingMap as Nt } from "@heyirisai/docx-editor-core/docx";
|
|
28
|
+
import { insertPageBreak as Pt } from "@heyirisai/docx-editor-core/prosemirror/commands/pageBreak";
|
|
29
|
+
import { insertSectionBreakContinuous as Ft, insertSectionBreakNextPage as It } from "@heyirisai/docx-editor-core/prosemirror/commands/sectionBreak";
|
|
30
|
+
import { applyFormatting as Lt, insertBreak as Rt, setParagraphStyle as zt } from "@heyirisai/docx-editor-core/prosemirror/applyFormatting";
|
|
31
|
+
import { collectHeadings as Bt } from "@heyirisai/docx-editor-core/utils/headingCollector";
|
|
32
|
+
import { extractTrackedChanges as Vt } from "@heyirisai/docx-editor-core/prosemirror/utils/extractTrackedChanges";
|
|
33
|
+
import { addCommentToRange as Ht, applyProposedChange as Ut, createComment as Wt } from "@heyirisai/docx-editor-core/prosemirror/commentOps";
|
|
34
|
+
import { PENDING_COMMENT_ID as Gt, createCommentIdAllocator as Kt, seedCommentAllocator as qt } from "@heyirisai/docx-editor-core/prosemirror/commentIdAllocator";
|
|
35
|
+
import { TABLE_INSERT_HIDE_DELAY_MS as Jt, detectTableInsertHover as Yt } from "@heyirisai/docx-editor-core/layout-bridge/tableInsertHover";
|
|
36
|
+
import { createCellDragTracker as Xt, findCellPosFromPmPos as Zt } from "@heyirisai/docx-editor-core/prosemirror/cellDragSelection";
|
|
37
|
+
import { openReportIssue as Qt } from "@heyirisai/docx-editor-core/utils/reportIssue";
|
|
38
|
+
import { ContentControlNotFoundError as $t } from "@heyirisai/docx-editor-core/agent";
|
|
39
|
+
import { findParaIdRange as en } from "@heyirisai/docx-editor-core/prosemirror/paraText";
|
|
40
|
+
import { createDocumentWithText as tn, createEmptyDocument as nn } from "@heyirisai/docx-editor-core";
|
|
41
|
+
//#region src/utils/domQueries.ts
|
|
42
|
+
function rn(e) {
|
|
43
|
+
let t = window.document.querySelectorAll(`.layout-page-${e}`);
|
|
44
|
+
if (t.length === 0) return null;
|
|
45
|
+
let n = window.innerHeight / 2, r = t[0], i = Infinity;
|
|
46
|
+
for (let e of Array.from(t)) {
|
|
47
|
+
let t = e.getBoundingClientRect(), a = Math.abs((t.top + t.bottom) / 2 - n);
|
|
48
|
+
a < i && (i = a, r = e);
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
}
|
|
52
|
+
function an(e, t, n) {
|
|
53
|
+
let r = n ? Array.from(e.querySelectorAll(`.layout-page-${n} span[data-pm-start][data-pm-end]`)) : Se(e);
|
|
54
|
+
for (let e of r) {
|
|
55
|
+
let n = Number(e.dataset.pmStart), r = Number(e.dataset.pmEnd);
|
|
56
|
+
if (!isNaN(n) && !isNaN(r) && t >= n && t <= r) return e;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function on(e, t, n) {
|
|
61
|
+
if (!e || !t) return;
|
|
62
|
+
let r = xe(e, n);
|
|
63
|
+
if (!r) for (let t of Se(e)) {
|
|
64
|
+
let e = Number(t.dataset.pmStart), i = Number(t.dataset.pmEnd);
|
|
65
|
+
if (Number.isFinite(e) && Number.isFinite(i) && n >= e && n <= i) {
|
|
66
|
+
r = t;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!r) return;
|
|
71
|
+
let i = t.getBoundingClientRect(), a = r.getBoundingClientRect();
|
|
72
|
+
t.scrollTo({
|
|
73
|
+
top: a.top - i.top + t.scrollTop - 48,
|
|
74
|
+
behavior: "smooth"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function sn(e, t, n, r) {
|
|
78
|
+
if (!e || !t) return null;
|
|
79
|
+
let i = X(e, n, r, 1);
|
|
80
|
+
return i === null || i < 0 ? null : Math.min(i, t.state.doc.content.size);
|
|
81
|
+
}
|
|
82
|
+
function cn(e, t, n, r) {
|
|
83
|
+
if (!e) return;
|
|
84
|
+
let i = an(e, t, r);
|
|
85
|
+
if (!i) return;
|
|
86
|
+
let a = i.textContent || "", o = Number(i.dataset.pmStart) || 0, [s, c] = Be(a, t - o), l = o + s, u = o + c;
|
|
87
|
+
l < u && n(l, u);
|
|
88
|
+
}
|
|
89
|
+
function ln(e, t, n, r) {
|
|
90
|
+
if (!e) return;
|
|
91
|
+
let i = an(e, t, r);
|
|
92
|
+
if (!i) return;
|
|
93
|
+
let a = i.closest(".layout-paragraph");
|
|
94
|
+
if (!a) return;
|
|
95
|
+
let o = Number(a.dataset.pmStart), s = Number(a.dataset.pmEnd);
|
|
96
|
+
!isNaN(o) && !isNaN(s) && o < s && n(o, s);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/components/DecorationLayer.vue
|
|
100
|
+
var un = /* @__PURE__ */ P({
|
|
101
|
+
__name: "DecorationLayer",
|
|
102
|
+
props: {
|
|
103
|
+
getView: { type: Function },
|
|
104
|
+
getPagesContainer: { type: Function },
|
|
105
|
+
zoom: {},
|
|
106
|
+
transactionVersion: {},
|
|
107
|
+
syncCoordinator: {}
|
|
108
|
+
},
|
|
109
|
+
setup(e) {
|
|
110
|
+
let t = e, n = B(null), r = B(0), i = null, a = null;
|
|
111
|
+
function o() {
|
|
112
|
+
i !== null && cancelAnimationFrame(i), i = requestAnimationFrame(() => {
|
|
113
|
+
i = null;
|
|
114
|
+
let e = t.getView(), r = t.getPagesContainer(), a = n.value;
|
|
115
|
+
!e || !r || !a || t.syncCoordinator.isSafeToRender() && s(e, r, a, t.zoom);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
R(() => {
|
|
119
|
+
a = t.syncCoordinator.onRender(() => {
|
|
120
|
+
r.value++;
|
|
121
|
+
}), o();
|
|
122
|
+
}), L(() => {
|
|
123
|
+
i !== null && (cancelAnimationFrame(i), i = null), a?.();
|
|
124
|
+
}), K(() => [
|
|
125
|
+
t.zoom,
|
|
126
|
+
t.transactionVersion,
|
|
127
|
+
r.value
|
|
128
|
+
], () => o());
|
|
129
|
+
function s(e, t, n, r) {
|
|
130
|
+
let i = c(e.state);
|
|
131
|
+
if (i.length === 0) {
|
|
132
|
+
n.firstChild && n.replaceChildren();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
let a = S(t, r), o = a.getContainerOffset(), s = document.createDocumentFragment();
|
|
136
|
+
for (let { decoration: t, from: n, to: r } of i) {
|
|
137
|
+
if (n === r) {
|
|
138
|
+
let r = l(t, e);
|
|
139
|
+
if (!r) continue;
|
|
140
|
+
let i = a.getCoordinatesForPosition(n);
|
|
141
|
+
if (!i) continue;
|
|
142
|
+
let c = document.createElement("div");
|
|
143
|
+
c.style.cssText = `position:absolute;left:${i.x + o.x}px;top:${i.y + o.y}px;height:${i.height}px;`, c.appendChild(r), s.appendChild(c);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let i = u(t);
|
|
147
|
+
if (!i) continue;
|
|
148
|
+
let c = a.getRectsForRange(n, r);
|
|
149
|
+
for (let e of c) {
|
|
150
|
+
let t = document.createElement("div");
|
|
151
|
+
for (let [e, n] of Object.entries(i)) e !== "nodeName" && t.setAttribute(e, n);
|
|
152
|
+
let n = `position:absolute;left:${e.x + o.x}px;top:${e.y + o.y}px;width:${e.width}px;height:${e.height}px;`;
|
|
153
|
+
t.style.cssText = n + (i.style ?? ""), s.appendChild(t);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
n.replaceChildren(s);
|
|
157
|
+
}
|
|
158
|
+
function c(e) {
|
|
159
|
+
let t = [];
|
|
160
|
+
for (let n of e.plugins) {
|
|
161
|
+
let r = n.props.decorations;
|
|
162
|
+
if (!r) continue;
|
|
163
|
+
let i = r.call(n, e);
|
|
164
|
+
i && i.forEachSet((e) => {
|
|
165
|
+
e.find().forEach((e) => {
|
|
166
|
+
e.spec?.noOverlay || t.push({
|
|
167
|
+
decoration: e,
|
|
168
|
+
from: e.from,
|
|
169
|
+
to: e.to
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return t;
|
|
175
|
+
}
|
|
176
|
+
function l(e, t) {
|
|
177
|
+
let n = e.type;
|
|
178
|
+
if (!n) return null;
|
|
179
|
+
let r = n.toDOM;
|
|
180
|
+
return typeof r == "function" ? r(t, () => e.from) : r instanceof HTMLElement ? r.cloneNode(!0) : null;
|
|
181
|
+
}
|
|
182
|
+
function u(e) {
|
|
183
|
+
return e.type?.attrs ?? null;
|
|
184
|
+
}
|
|
185
|
+
return (e, t) => (z(), A("div", {
|
|
186
|
+
ref_key: "overlayRef",
|
|
187
|
+
ref: n,
|
|
188
|
+
class: "paged-editor__decoration-overlay",
|
|
189
|
+
"aria-hidden": "true"
|
|
190
|
+
}, null, 512));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/composables/imageOverlayRect.ts
|
|
195
|
+
function dn(e) {
|
|
196
|
+
let t = Math.max(0, e.parentOffsetWidth - e.parentClientWidth) / 2, n = e.zoom || 1;
|
|
197
|
+
return {
|
|
198
|
+
left: (e.imageRect.left - e.parentRect.left - t + e.scrollLeft) / n,
|
|
199
|
+
top: (e.imageRect.top - e.parentRect.top + e.scrollTop) / n,
|
|
200
|
+
width: e.imageRect.width / n,
|
|
201
|
+
height: e.imageRect.height / n
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/components/ImageSelectionOverlay.vue?vue&type=script&setup=true&lang.ts
|
|
206
|
+
var fn = ["data-handle", "onMousedown"], pn = ["title"], mn = {
|
|
207
|
+
key: 0,
|
|
208
|
+
class: "image-overlay__dim"
|
|
209
|
+
}, hn = {
|
|
210
|
+
key: 1,
|
|
211
|
+
class: "image-overlay__dim image-overlay__dim--rotate"
|
|
212
|
+
}, gn = 4, _n = 15, vn = 250, yn = 700, bn = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
213
|
+
__name: "ImageSelectionOverlay",
|
|
214
|
+
props: {
|
|
215
|
+
imageInfo: {},
|
|
216
|
+
zoom: {},
|
|
217
|
+
view: {}
|
|
218
|
+
},
|
|
219
|
+
emits: [
|
|
220
|
+
"deselect",
|
|
221
|
+
"interact-start",
|
|
222
|
+
"interact-end",
|
|
223
|
+
"context-menu"
|
|
224
|
+
],
|
|
225
|
+
setup(e, { emit: t }) {
|
|
226
|
+
let { t: n } = d(), r = e, i = t, a = B(null), o = B(!1), s = B(!1), c = B(!1), l = B(0), u = B(0), f = B(0), p = B(null), m = "se", h = 0, g = 0, _ = 0, v = 0, y = null, b = null, ee = null, x = null;
|
|
227
|
+
function S(e, t) {
|
|
228
|
+
if (!e) return null;
|
|
229
|
+
try {
|
|
230
|
+
let n = e.state.doc.nodeAt(t);
|
|
231
|
+
return n && n.type.name === "image" ? n : null;
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function te() {
|
|
237
|
+
return a.value?.closest(".docx-editor-vue__pages-viewport")?.querySelector(".docx-editor-vue__pages") ?? null;
|
|
238
|
+
}
|
|
239
|
+
function ne() {
|
|
240
|
+
let e = r.imageInfo;
|
|
241
|
+
if (!e) return null;
|
|
242
|
+
if (e.element.isConnected) return e.element;
|
|
243
|
+
let t = te();
|
|
244
|
+
if (!t) return null;
|
|
245
|
+
let n = xe(t, e.pmPos);
|
|
246
|
+
return n ? ut(n) : null;
|
|
247
|
+
}
|
|
248
|
+
function w() {
|
|
249
|
+
let e = ne();
|
|
250
|
+
if (!e || !a.value) {
|
|
251
|
+
p.value = null;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
let t = a.value.offsetParent;
|
|
255
|
+
if (!t) {
|
|
256
|
+
p.value = null;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
let n = t.getBoundingClientRect();
|
|
260
|
+
p.value = dn({
|
|
261
|
+
imageRect: e.getBoundingClientRect(),
|
|
262
|
+
parentRect: n,
|
|
263
|
+
scrollLeft: t.scrollLeft,
|
|
264
|
+
scrollTop: t.scrollTop,
|
|
265
|
+
parentOffsetWidth: t.offsetWidth,
|
|
266
|
+
parentClientWidth: t.clientWidth,
|
|
267
|
+
zoom: r.zoom
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
let re = null;
|
|
271
|
+
function E() {
|
|
272
|
+
re?.();
|
|
273
|
+
let e = 0, t = "", n = 0, r = 0, i = (a) => {
|
|
274
|
+
r === 0 && (r = a);
|
|
275
|
+
let o = a - r;
|
|
276
|
+
w();
|
|
277
|
+
let s = p.value, c = s ? `${s.left}|${s.top}|${s.width}|${s.height}` : "";
|
|
278
|
+
n = c === t ? n + 1 : 0, t = c, !(o >= vn && n >= 2) && o < yn && (e = requestAnimationFrame(i));
|
|
279
|
+
};
|
|
280
|
+
e = requestAnimationFrame(i);
|
|
281
|
+
let a = setTimeout(w, vn);
|
|
282
|
+
re = () => {
|
|
283
|
+
cancelAnimationFrame(e), clearTimeout(a);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
K(() => r.imageInfo, (e, t, n) => {
|
|
287
|
+
if (!r.imageInfo) {
|
|
288
|
+
p.value = null;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
E(), n(() => re?.());
|
|
292
|
+
}, { immediate: !0 }), K(() => r.zoom, () => {
|
|
293
|
+
r.imageInfo && E();
|
|
294
|
+
}), K(() => r.imageInfo, (e, t, n) => {
|
|
295
|
+
if (!r.imageInfo) return;
|
|
296
|
+
let i = () => {
|
|
297
|
+
b && cancelAnimationFrame(b), b = requestAnimationFrame(w);
|
|
298
|
+
}, o = a.value?.closest(".docx-editor-vue__pages-viewport");
|
|
299
|
+
o?.addEventListener("scroll", i, { passive: !0 }), window.addEventListener("resize", i, { passive: !0 });
|
|
300
|
+
let s = null, c = !1;
|
|
301
|
+
le(() => {
|
|
302
|
+
if (c || !r.imageInfo) return;
|
|
303
|
+
let e = te();
|
|
304
|
+
e && (s = new MutationObserver(() => E()), s.observe(e, {
|
|
305
|
+
attributes: !0,
|
|
306
|
+
attributeFilter: ["style"]
|
|
307
|
+
}));
|
|
308
|
+
}), n(() => {
|
|
309
|
+
c = !0, o?.removeEventListener("scroll", i), window.removeEventListener("resize", i), s?.disconnect(), b && cancelAnimationFrame(b);
|
|
310
|
+
});
|
|
311
|
+
}, { immediate: !0 });
|
|
312
|
+
let ie = D(() => o.value ? l.value : p.value?.width || 0), O = D(() => o.value ? u.value : p.value?.height || 0), ae = D(() => {
|
|
313
|
+
let e = p.value;
|
|
314
|
+
if (!e) return {
|
|
315
|
+
position: "absolute",
|
|
316
|
+
top: "0px",
|
|
317
|
+
left: "0px",
|
|
318
|
+
visibility: "hidden",
|
|
319
|
+
pointerEvents: "none"
|
|
320
|
+
};
|
|
321
|
+
let t = o.value ? l.value : e.width, n = o.value ? u.value : e.height, i = r.zoom || 1;
|
|
322
|
+
return {
|
|
323
|
+
position: "absolute",
|
|
324
|
+
left: `${e.left * i}px`,
|
|
325
|
+
top: `${e.top * i}px`,
|
|
326
|
+
width: `${t}px`,
|
|
327
|
+
height: `${n}px`,
|
|
328
|
+
transform: i === 1 ? void 0 : `scale(${i})`,
|
|
329
|
+
transformOrigin: "top left",
|
|
330
|
+
zIndex: C.imageOverlay,
|
|
331
|
+
pointerEvents: "auto"
|
|
332
|
+
};
|
|
333
|
+
}), oe = D(() => {
|
|
334
|
+
let e = ie.value, t = O.value, n = `${e / 2 - 5}px`, r = `${t / 2 - 5}px`, i = `${e - 5}px`, a = `${t - 5}px`, o = "-5px";
|
|
335
|
+
return [
|
|
336
|
+
{
|
|
337
|
+
pos: "nw",
|
|
338
|
+
style: {
|
|
339
|
+
left: o,
|
|
340
|
+
top: o,
|
|
341
|
+
cursor: "nwse-resize"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
pos: "n",
|
|
346
|
+
style: {
|
|
347
|
+
left: n,
|
|
348
|
+
top: o,
|
|
349
|
+
cursor: "ns-resize"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
pos: "ne",
|
|
354
|
+
style: {
|
|
355
|
+
left: i,
|
|
356
|
+
top: o,
|
|
357
|
+
cursor: "nesw-resize"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
pos: "e",
|
|
362
|
+
style: {
|
|
363
|
+
left: i,
|
|
364
|
+
top: r,
|
|
365
|
+
cursor: "ew-resize"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
pos: "se",
|
|
370
|
+
style: {
|
|
371
|
+
left: i,
|
|
372
|
+
top: a,
|
|
373
|
+
cursor: "nwse-resize"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
pos: "s",
|
|
378
|
+
style: {
|
|
379
|
+
left: n,
|
|
380
|
+
top: a,
|
|
381
|
+
cursor: "ns-resize"
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
pos: "sw",
|
|
386
|
+
style: {
|
|
387
|
+
left: o,
|
|
388
|
+
top: a,
|
|
389
|
+
cursor: "nesw-resize"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
pos: "w",
|
|
394
|
+
style: {
|
|
395
|
+
left: o,
|
|
396
|
+
top: r,
|
|
397
|
+
cursor: "ew-resize"
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
];
|
|
401
|
+
});
|
|
402
|
+
function M(e, t) {
|
|
403
|
+
!r.imageInfo || !p.value || (m = t, h = e.clientX, g = e.clientY, _ = p.value.width, v = p.value.height, y = { ...p.value }, l.value = Math.round(_), u.value = Math.round(v), o.value = !0, i("interact-start"), document.addEventListener("mousemove", N), document.addEventListener("mouseup", P));
|
|
404
|
+
}
|
|
405
|
+
function N(e) {
|
|
406
|
+
let t = r.zoom, n = (e.clientX - h) / t, i = (e.clientY - g) / t, a = !e.shiftKey, o = nt(m, n, i, _, v, a);
|
|
407
|
+
l.value = Math.round(o.width), u.value = Math.round(o.height);
|
|
408
|
+
let s = y;
|
|
409
|
+
s && (p.value = {
|
|
410
|
+
left: m.includes("w") ? s.left + (s.width - o.width) : s.left,
|
|
411
|
+
top: m.includes("n") ? s.top + (s.height - o.height) : s.top,
|
|
412
|
+
width: s.width,
|
|
413
|
+
height: s.height
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function P() {
|
|
417
|
+
document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", P), o.value = !1, y = null, i("interact-end");
|
|
418
|
+
let e = r.view, t = r.imageInfo;
|
|
419
|
+
if (!e || !t) {
|
|
420
|
+
w();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
let n = at(e, t.pmPos, l.value, u.value);
|
|
424
|
+
n !== null && ve(n), le(() => w());
|
|
425
|
+
}
|
|
426
|
+
let se = 0, ce = 0, F = 0, R = 0, ue = null, de = null;
|
|
427
|
+
function fe(e) {
|
|
428
|
+
if (!e) return 0;
|
|
429
|
+
let t = e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);
|
|
430
|
+
return t ? parseFloat(t[1]) : 0;
|
|
431
|
+
}
|
|
432
|
+
function W(e, t) {
|
|
433
|
+
let n = /scaleX\(-1\)/.test(e || ""), r = /scaleY\(-1\)/.test(e || ""), i = [], a = (t % 360 + 360) % 360;
|
|
434
|
+
return a !== 0 && i.push(`rotate(${a}deg)`), n && i.push("scaleX(-1)"), r && i.push("scaleY(-1)"), i.length > 0 ? i.join(" ") : null;
|
|
435
|
+
}
|
|
436
|
+
function pe(e, t) {
|
|
437
|
+
return Math.atan2(e - se, -(t - ce)) * 180 / Math.PI;
|
|
438
|
+
}
|
|
439
|
+
function G(e) {
|
|
440
|
+
if (!r.imageInfo) return;
|
|
441
|
+
let t = r.imageInfo.element.getBoundingClientRect();
|
|
442
|
+
se = t.left + t.width / 2, ce = t.top + t.height / 2;
|
|
443
|
+
let n = S(r.view, r.imageInfo.pmPos);
|
|
444
|
+
ue = n && n.attrs.transform || null, R = fe(ue), de = r.imageInfo.element.querySelector("img"), F = pe(e.clientX, e.clientY), f.value = R, c.value = !0, i("interact-start"), document.addEventListener("mousemove", me), document.addEventListener("mouseup", he);
|
|
445
|
+
}
|
|
446
|
+
function me(e) {
|
|
447
|
+
let t = pe(e.clientX, e.clientY) - F, n = R + t;
|
|
448
|
+
e.shiftKey || (n = Math.round(n / _n) * _n), f.value = (n % 360 + 360) % 360, de && (de.style.transform = W(ue, f.value) || "");
|
|
449
|
+
}
|
|
450
|
+
function he() {
|
|
451
|
+
document.removeEventListener("mousemove", me), document.removeEventListener("mouseup", he), c.value = !1, i("interact-end");
|
|
452
|
+
let e = r.view, t = r.imageInfo;
|
|
453
|
+
try {
|
|
454
|
+
let n = e && t ? S(e, t.pmPos) : null;
|
|
455
|
+
e && t && n && (e.dispatch(e.state.tr.setNodeMarkup(t.pmPos, void 0, {
|
|
456
|
+
...n.attrs,
|
|
457
|
+
transform: W(n.attrs.transform, f.value)
|
|
458
|
+
})), ve(t.pmPos));
|
|
459
|
+
} catch {} finally {
|
|
460
|
+
de && (de.style.transform = ""), de = null, ue = null;
|
|
461
|
+
}
|
|
462
|
+
le(() => w());
|
|
463
|
+
}
|
|
464
|
+
let q = null;
|
|
465
|
+
function J(e) {
|
|
466
|
+
if (!r.imageInfo || !p.value) return;
|
|
467
|
+
let t = e.clientX, n = e.clientY, a = p.value, o = !1, c = (e) => {
|
|
468
|
+
let c = e.clientX - t, l = e.clientY - n;
|
|
469
|
+
if (!(!o && Math.sqrt(c * c + l * l) < gn)) {
|
|
470
|
+
if (!o) {
|
|
471
|
+
o = !0, s.value = !0, i("interact-start"), q = document.createElement("div"), q.style.cssText = "position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);";
|
|
472
|
+
let e = r.zoom;
|
|
473
|
+
q.style.width = `${a.width * e}px`, q.style.height = `${a.height * e}px`, document.body.appendChild(q);
|
|
474
|
+
}
|
|
475
|
+
if (q) {
|
|
476
|
+
let t = r.zoom;
|
|
477
|
+
q.style.left = `${e.clientX - a.width * t / 2}px`, q.style.top = `${e.clientY - a.height * t / 2}px`;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}, l = (e) => {
|
|
481
|
+
document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", l), ee = null, x = null, q &&= (q.remove(), null), s.value = !1, o && (i("interact-end"), _e(e.clientX, e.clientY));
|
|
482
|
+
};
|
|
483
|
+
ee = c, x = l, document.addEventListener("mousemove", c), document.addEventListener("mouseup", l);
|
|
484
|
+
}
|
|
485
|
+
function _e(e, t) {
|
|
486
|
+
let n = r.view, i = r.imageInfo;
|
|
487
|
+
if (!n || !i) return;
|
|
488
|
+
let o = S(n, i.pmPos);
|
|
489
|
+
if (o) {
|
|
490
|
+
if (ot(o)) {
|
|
491
|
+
let o = (a.value?.closest(".docx-editor-vue__pages-viewport"))?.querySelectorAll(".layout-page");
|
|
492
|
+
if (!o || o.length === 0) return;
|
|
493
|
+
let s = null;
|
|
494
|
+
for (let e of o) {
|
|
495
|
+
let n = e.getBoundingClientRect();
|
|
496
|
+
if (t >= n.top && t <= n.bottom) {
|
|
497
|
+
s = e.querySelector(".layout-page-content");
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (s ||= o[o.length - 1].querySelector(".layout-page-content"), !s) return;
|
|
502
|
+
let c = s.getBoundingClientRect(), l = r.zoom, u = Q((e - c.left) / l), d = Q((t - c.top) / l), f = rt(n, i.pmPos, u, d);
|
|
503
|
+
f !== null && ve(f);
|
|
504
|
+
} else {
|
|
505
|
+
let r = te();
|
|
506
|
+
if (!r) return;
|
|
507
|
+
let a = $e(r, e, t, 1);
|
|
508
|
+
if (a == null || a < 0) return;
|
|
509
|
+
let o = it(n, i.pmPos, a);
|
|
510
|
+
o !== null && ve(o);
|
|
511
|
+
}
|
|
512
|
+
le(() => w());
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function ve(e) {
|
|
516
|
+
let t = r.view;
|
|
517
|
+
if (t) try {
|
|
518
|
+
let n = ge.create(t.state.doc, e);
|
|
519
|
+
t.dispatch(t.state.tr.setSelection(n));
|
|
520
|
+
} catch {}
|
|
521
|
+
}
|
|
522
|
+
return L(() => {
|
|
523
|
+
document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", P), document.removeEventListener("mousemove", me), document.removeEventListener("mouseup", he), ee && document.removeEventListener("mousemove", ee), x && document.removeEventListener("mouseup", x), q &&= (q.remove(), null), b && cancelAnimationFrame(b), re?.();
|
|
524
|
+
}), (t, r) => e.imageInfo ? (z(), A("div", {
|
|
525
|
+
key: 0,
|
|
526
|
+
ref_key: "overlayRootRef",
|
|
527
|
+
ref: a,
|
|
528
|
+
class: "image-overlay",
|
|
529
|
+
style: I(ae.value),
|
|
530
|
+
onMousedown: r[3] ||= Y(() => {}, ["stop"])
|
|
531
|
+
}, [
|
|
532
|
+
r[4] ||= j("div", { class: "image-overlay__border" }, null, -1),
|
|
533
|
+
j("div", {
|
|
534
|
+
class: "image-overlay__body",
|
|
535
|
+
style: I({ cursor: s.value ? "grabbing" : "grab" }),
|
|
536
|
+
onMousedown: r[0] ||= Y((e) => J(e), ["prevent", "stop"]),
|
|
537
|
+
onContextmenu: r[1] ||= Y((e) => t.$emit("context-menu", e), ["prevent", "stop"])
|
|
538
|
+
}, null, 36),
|
|
539
|
+
(z(!0), A(T, null, V(oe.value, (e) => (z(), A("div", {
|
|
540
|
+
key: e.pos,
|
|
541
|
+
class: "image-overlay__handle",
|
|
542
|
+
style: I(e.style),
|
|
543
|
+
"data-handle": e.pos,
|
|
544
|
+
onMousedown: Y((t) => M(t, e.pos), ["prevent", "stop"])
|
|
545
|
+
}, null, 44, fn))), 128)),
|
|
546
|
+
r[5] ||= j("div", { class: "image-overlay__rotate-line" }, null, -1),
|
|
547
|
+
j("div", {
|
|
548
|
+
class: "image-overlay__rotate-handle",
|
|
549
|
+
style: I({ left: `${ie.value / 2 - 7}px` }),
|
|
550
|
+
title: U(n)("imageOverlay.rotate"),
|
|
551
|
+
onMousedown: r[2] ||= Y((e) => G(e), ["prevent", "stop"])
|
|
552
|
+
}, null, 44, pn),
|
|
553
|
+
o.value ? (z(), A("div", mn, H(Math.round(l.value)) + " × " + H(Math.round(u.value)), 1)) : k("", !0),
|
|
554
|
+
c.value ? (z(), A("div", hn, H(Math.round(f.value)) + "° ", 1)) : k("", !0)
|
|
555
|
+
], 36)) : k("", !0);
|
|
556
|
+
}
|
|
557
|
+
}), [["__scopeId", "data-v-a3e3aca1"]]), xn = { class: "doc-outline__header" }, Sn = { class: "doc-outline__body" }, Cn = {
|
|
558
|
+
key: 0,
|
|
559
|
+
class: "doc-outline__empty"
|
|
560
|
+
}, wn = ["onMousedown"], Tn = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
561
|
+
__name: "DocumentOutline",
|
|
562
|
+
props: {
|
|
563
|
+
isOpen: { type: Boolean },
|
|
564
|
+
headings: {},
|
|
565
|
+
leftOffset: { default: 12 },
|
|
566
|
+
topPx: { default: 24 }
|
|
567
|
+
},
|
|
568
|
+
emits: ["close", "navigate"],
|
|
569
|
+
setup(e) {
|
|
570
|
+
let t = e, n = D(() => t.headings.length ? Math.min(...t.headings.map((e) => e.level)) : 0);
|
|
571
|
+
return (t, i) => e.isOpen ? (z(), A("nav", {
|
|
572
|
+
key: 0,
|
|
573
|
+
class: "doc-outline",
|
|
574
|
+
style: I({
|
|
575
|
+
left: e.leftOffset + "px",
|
|
576
|
+
top: e.topPx + "px"
|
|
577
|
+
}),
|
|
578
|
+
role: "navigation",
|
|
579
|
+
"aria-label": "Document outline",
|
|
580
|
+
onMousedown: i[1] ||= Y(() => {}, ["stop"])
|
|
581
|
+
}, [j("div", xn, [j("button", {
|
|
582
|
+
class: "doc-outline__back",
|
|
583
|
+
title: "Close outline",
|
|
584
|
+
"aria-label": "Close outline",
|
|
585
|
+
onClick: i[0] ||= (e) => t.$emit("close")
|
|
586
|
+
}, [N(r, {
|
|
587
|
+
name: "arrow_back",
|
|
588
|
+
size: 20
|
|
589
|
+
})]), i[2] ||= j("span", { class: "doc-outline__title" }, "Document Outline", -1)]), j("div", Sn, [e.headings.length === 0 ? (z(), A("div", Cn, "No headings found")) : k("", !0), (z(!0), A(T, null, V(e.headings, (e, r) => (z(), A("button", {
|
|
590
|
+
key: r,
|
|
591
|
+
class: "doc-outline__item",
|
|
592
|
+
style: I({ paddingLeft: 8 + (e.level - n.value) * 16 + "px" }),
|
|
593
|
+
onMousedown: Y((n) => t.$emit("navigate", e.pmPos), ["prevent"])
|
|
594
|
+
}, H(e.text || "(untitled)"), 45, wn))), 128))])], 36)) : k("", !0);
|
|
595
|
+
}
|
|
596
|
+
}), [["__scopeId", "data-v-8820ac3e"]]), En = ["title", "aria-label"], Dn = /* @__PURE__ */ P({
|
|
597
|
+
__name: "OutlineToggleButton",
|
|
598
|
+
props: {
|
|
599
|
+
leftOffset: {},
|
|
600
|
+
topPx: { default: 24 }
|
|
601
|
+
},
|
|
602
|
+
emits: ["toggle"],
|
|
603
|
+
setup(e) {
|
|
604
|
+
let { t } = d();
|
|
605
|
+
return (n, i) => (z(), A("button", {
|
|
606
|
+
type: "button",
|
|
607
|
+
class: "docx-outline-toggle docx-editor-vue__outline-toggle",
|
|
608
|
+
style: I({
|
|
609
|
+
left: e.leftOffset + "px",
|
|
610
|
+
top: e.topPx + "px"
|
|
611
|
+
}),
|
|
612
|
+
title: U(t)("editor.showDocumentOutline"),
|
|
613
|
+
"aria-label": U(t)("editor.showDocumentOutline"),
|
|
614
|
+
onClick: i[0] ||= (e) => n.$emit("toggle"),
|
|
615
|
+
onMousedown: i[1] ||= Y(() => {}, ["stop"])
|
|
616
|
+
}, [N(r, {
|
|
617
|
+
name: "format_list_bulleted",
|
|
618
|
+
size: 20
|
|
619
|
+
})], 44, En));
|
|
620
|
+
}
|
|
621
|
+
}), On = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
622
|
+
__name: "PageIndicator",
|
|
623
|
+
props: {
|
|
624
|
+
currentPage: {},
|
|
625
|
+
totalPages: {},
|
|
626
|
+
visible: { type: Boolean }
|
|
627
|
+
},
|
|
628
|
+
setup(e) {
|
|
629
|
+
let { t } = d();
|
|
630
|
+
return (n, r) => (z(), A("div", {
|
|
631
|
+
class: "docx-editor-vue__page-indicator",
|
|
632
|
+
style: I({ opacity: +!!e.visible }),
|
|
633
|
+
"aria-live": "polite",
|
|
634
|
+
role: "status"
|
|
635
|
+
}, H(U(t)("viewer.pageIndicator", {
|
|
636
|
+
current: e.currentPage,
|
|
637
|
+
total: e.totalPages
|
|
638
|
+
})), 5));
|
|
639
|
+
}
|
|
640
|
+
}), [["__scopeId", "data-v-877b9ee2"]]), kn = { class: "hf-editor__label" }, An = {
|
|
641
|
+
class: "hf-editor__actions",
|
|
642
|
+
style: { position: "relative" }
|
|
643
|
+
}, jn = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
644
|
+
__name: "InlineHeaderFooterEditor",
|
|
645
|
+
props: {
|
|
646
|
+
isOpen: { type: Boolean },
|
|
647
|
+
position: {},
|
|
648
|
+
view: {},
|
|
649
|
+
targetRect: {}
|
|
650
|
+
},
|
|
651
|
+
emits: [
|
|
652
|
+
"save",
|
|
653
|
+
"close",
|
|
654
|
+
"remove"
|
|
655
|
+
],
|
|
656
|
+
setup(e, { emit: t }) {
|
|
657
|
+
let n = e, r = t, i = B({}), a = B(!1);
|
|
658
|
+
function o(e) {
|
|
659
|
+
let t = n.view;
|
|
660
|
+
if (!t) return;
|
|
661
|
+
let { $from: r, from: i } = t.state.selection, a = t.state.storedMarks || r.marks(), o = Fe.nodes.field.create({
|
|
662
|
+
fieldType: e,
|
|
663
|
+
instruction: ` ${e} \\* MERGEFORMAT `,
|
|
664
|
+
fieldKind: "simple",
|
|
665
|
+
dirty: !0
|
|
666
|
+
});
|
|
667
|
+
t.dispatch(t.state.tr.insert(i, o.mark(a))), t.focus();
|
|
668
|
+
}
|
|
669
|
+
function s() {
|
|
670
|
+
let e = n.targetRect;
|
|
671
|
+
e && (i.value = {
|
|
672
|
+
position: "absolute",
|
|
673
|
+
top: `${e.top}px`,
|
|
674
|
+
left: `${e.left}px`,
|
|
675
|
+
width: `${e.width}px`,
|
|
676
|
+
height: `${e.height}px`,
|
|
677
|
+
zIndex: "100",
|
|
678
|
+
pointerEvents: "none"
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
K(() => n.isOpen, (e) => {
|
|
682
|
+
e && (s(), n.view?.focus());
|
|
683
|
+
}), K(() => n.targetRect, () => {
|
|
684
|
+
n.isOpen && s();
|
|
685
|
+
}, { deep: !0 });
|
|
686
|
+
function c() {
|
|
687
|
+
n.view && (r("save", mt(n.view.state.doc)), r("close"));
|
|
688
|
+
}
|
|
689
|
+
return (t, n) => e.isOpen ? (z(), A("div", {
|
|
690
|
+
key: 0,
|
|
691
|
+
class: "hf-editor",
|
|
692
|
+
style: I(i.value)
|
|
693
|
+
}, [j("div", {
|
|
694
|
+
class: F(["hf-editor__toolbar", e.position === "footer" ? "hf-editor__toolbar--below" : "hf-editor__toolbar--above"]),
|
|
695
|
+
onMousedown: n[8] ||= Y(() => {}, ["stop"]),
|
|
696
|
+
onContextmenu: n[9] ||= Y(() => {}, ["stop"])
|
|
697
|
+
}, [j("span", kn, H(e.position === "header" ? "Header" : "Footer"), 1), j("div", An, [
|
|
698
|
+
j("button", {
|
|
699
|
+
class: "hf-editor__btn",
|
|
700
|
+
title: "Options",
|
|
701
|
+
onMousedown: n[0] ||= Y(() => {}, ["prevent"]),
|
|
702
|
+
onClick: n[1] ||= (e) => a.value = !a.value
|
|
703
|
+
}, " Options ▾ ", 32),
|
|
704
|
+
a.value ? (z(), A("div", {
|
|
705
|
+
key: 0,
|
|
706
|
+
class: "hf-editor__dropdown",
|
|
707
|
+
onMousedown: n[4] ||= Y(() => {}, ["stop"]),
|
|
708
|
+
onContextmenu: n[5] ||= Y(() => {}, ["stop"])
|
|
709
|
+
}, [j("button", {
|
|
710
|
+
type: "button",
|
|
711
|
+
class: "hf-editor__dropdown-item",
|
|
712
|
+
onClick: n[2] ||= (e) => {
|
|
713
|
+
a.value = !1, o("PAGE");
|
|
714
|
+
}
|
|
715
|
+
}, " Insert current page number "), j("button", {
|
|
716
|
+
type: "button",
|
|
717
|
+
class: "hf-editor__dropdown-item",
|
|
718
|
+
onClick: n[3] ||= (e) => {
|
|
719
|
+
a.value = !1, o("NUMPAGES");
|
|
720
|
+
}
|
|
721
|
+
}, " Insert total page count ")], 32)) : k("", !0),
|
|
722
|
+
j("button", {
|
|
723
|
+
class: "hf-editor__btn",
|
|
724
|
+
title: "Remove",
|
|
725
|
+
onMousedown: n[6] ||= Y((e) => t.$emit("remove"), ["prevent"])
|
|
726
|
+
}, " Remove ", 32),
|
|
727
|
+
j("button", {
|
|
728
|
+
class: "hf-editor__btn hf-editor__btn--primary",
|
|
729
|
+
title: "Save",
|
|
730
|
+
onMousedown: Y(c, ["prevent"])
|
|
731
|
+
}, " Save ", 32),
|
|
732
|
+
j("button", {
|
|
733
|
+
class: "hf-editor__btn",
|
|
734
|
+
title: "Cancel",
|
|
735
|
+
onMousedown: n[7] ||= Y((e) => t.$emit("close"), ["prevent"])
|
|
736
|
+
}, " Cancel ", 32)
|
|
737
|
+
])], 34)], 4)) : k("", !0);
|
|
738
|
+
}
|
|
739
|
+
}), [["__scopeId", "data-v-81468575"]]), Mn = ["role"], Nn = {
|
|
740
|
+
key: 0,
|
|
741
|
+
class: "layout-sdt-widget-empty"
|
|
742
|
+
}, Pn = ["aria-selected", "onClick"], Fn = ["value"], In = ".layout-sdt-widget, .layout-inline-sdt-widget", Ln = /* @__PURE__ */ P({
|
|
743
|
+
__name: "ContentControlWidgets",
|
|
744
|
+
props: {
|
|
745
|
+
container: {},
|
|
746
|
+
view: {}
|
|
747
|
+
},
|
|
748
|
+
setup(e) {
|
|
749
|
+
function t(e) {
|
|
750
|
+
let t = /^sdt@(\d+)$/.exec(e ?? "");
|
|
751
|
+
return t ? Number(t[1]) : null;
|
|
752
|
+
}
|
|
753
|
+
function n(e) {
|
|
754
|
+
if (e == null || e === "") return null;
|
|
755
|
+
let t = Number(e);
|
|
756
|
+
return Number.isFinite(t) ? t : null;
|
|
757
|
+
}
|
|
758
|
+
function r(e) {
|
|
759
|
+
let r = t(e.dataset.sdtGroupId) ?? n(e.dataset.sdtPos), i = e.dataset.sdtTag;
|
|
760
|
+
return r == null ? i ? { tag: i } : null : i ? {
|
|
761
|
+
pos: r,
|
|
762
|
+
tag: i
|
|
763
|
+
} : { pos: r };
|
|
764
|
+
}
|
|
765
|
+
let i = e, a = B(null), o = B(null);
|
|
766
|
+
function s(e, t) {
|
|
767
|
+
let n = i.view;
|
|
768
|
+
if (n) try {
|
|
769
|
+
let r = e.pos == null ? e.tag ? Re(n.state, { tag: e.tag }, t) : null : Le(n.state, e.pos, t);
|
|
770
|
+
if (!r) return;
|
|
771
|
+
n.dispatch(r), n.focus();
|
|
772
|
+
} catch {}
|
|
773
|
+
a.value = null;
|
|
774
|
+
}
|
|
775
|
+
function c(e) {
|
|
776
|
+
let n = i.view, r = t(e.dataset.sdtGroupId);
|
|
777
|
+
if (!(!n || r == null)) try {
|
|
778
|
+
let t = e.dataset.sdtRepeat === "add" ? Ae(n.state, r) : Pe(n.state, r);
|
|
779
|
+
n.dispatch(t), n.focus();
|
|
780
|
+
} catch {}
|
|
781
|
+
}
|
|
782
|
+
function l(e) {
|
|
783
|
+
let t = e.target;
|
|
784
|
+
(t?.closest?.(In) || t?.closest?.(".layout-sdt-repeat-btn")) && e.preventDefault();
|
|
785
|
+
}
|
|
786
|
+
function u(e) {
|
|
787
|
+
let t = i.view, n = e.dataset.sdtWidget, o = r(e);
|
|
788
|
+
if (!t || !n || !o) return;
|
|
789
|
+
let c = o.pos == null ? o.tag ? Ne(t.state.doc, { tag: o.tag })[0] : void 0 : Ne(t.state.doc).find((e) => e.pos === o.pos), l = e.getBoundingClientRect();
|
|
790
|
+
n === "checkbox" ? s(o, {
|
|
791
|
+
kind: "checkbox",
|
|
792
|
+
checked: !c?.checked
|
|
793
|
+
}) : n === "dropdown" ? a.value = {
|
|
794
|
+
kind: "dropdown",
|
|
795
|
+
target: o,
|
|
796
|
+
items: c?.listItems ?? [],
|
|
797
|
+
current: c?.text ?? "",
|
|
798
|
+
x: l.left,
|
|
799
|
+
y: l.bottom + 2
|
|
800
|
+
} : n === "date" && (a.value = {
|
|
801
|
+
kind: "date",
|
|
802
|
+
target: o,
|
|
803
|
+
current: c?.dateValue ?? "",
|
|
804
|
+
x: l.left,
|
|
805
|
+
y: l.bottom + 2
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
function d(e) {
|
|
809
|
+
let t = e.target?.closest?.(".layout-sdt-repeat-btn");
|
|
810
|
+
if (t) {
|
|
811
|
+
e.preventDefault(), e.stopPropagation(), c(t);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
let n = e.target?.closest?.(In);
|
|
815
|
+
n && (e.preventDefault(), e.stopPropagation(), u(n));
|
|
816
|
+
}
|
|
817
|
+
function f(e) {
|
|
818
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
819
|
+
let t = e.target?.closest?.(In);
|
|
820
|
+
t && (e.preventDefault(), u(t));
|
|
821
|
+
}
|
|
822
|
+
function p(e) {
|
|
823
|
+
a.value && !o.value?.contains(e.target) && (a.value = null);
|
|
824
|
+
}
|
|
825
|
+
function m(e) {
|
|
826
|
+
e.key === "Escape" && (a.value = null);
|
|
827
|
+
}
|
|
828
|
+
let h = null;
|
|
829
|
+
K(() => i.container, (e) => {
|
|
830
|
+
h && (h.removeEventListener("mousedown", l), h.removeEventListener("click", d), h.removeEventListener("keydown", f)), h = e ?? null, h && (h.addEventListener("mousedown", l), h.addEventListener("click", d), h.addEventListener("keydown", f));
|
|
831
|
+
}, { immediate: !0 }), K(a, (e) => {
|
|
832
|
+
e ? (document.addEventListener("mousedown", p), document.addEventListener("keydown", m), e.kind === "dropdown" && le(() => {
|
|
833
|
+
let e = o.value?.querySelectorAll(".layout-sdt-widget-option");
|
|
834
|
+
e?.length && ([...e].find((e) => e.getAttribute("aria-selected") === "true") ?? e[0]).focus();
|
|
835
|
+
})) : (document.removeEventListener("mousedown", p), document.removeEventListener("keydown", m));
|
|
836
|
+
});
|
|
837
|
+
function g(e) {
|
|
838
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
839
|
+
let t = [...o.value?.querySelectorAll(".layout-sdt-widget-option") ?? []];
|
|
840
|
+
if (!t.length) return;
|
|
841
|
+
e.preventDefault();
|
|
842
|
+
let n = t.indexOf(document.activeElement);
|
|
843
|
+
t[e.key === "ArrowDown" ? (n + 1) % t.length : (n - 1 + t.length) % t.length].focus();
|
|
844
|
+
}
|
|
845
|
+
L(() => {
|
|
846
|
+
h && (h.removeEventListener("mousedown", l), h.removeEventListener("click", d), h.removeEventListener("keydown", f)), document.removeEventListener("mousedown", p), document.removeEventListener("keydown", m);
|
|
847
|
+
});
|
|
848
|
+
function _(e) {
|
|
849
|
+
let t = e.target.value;
|
|
850
|
+
t && a.value && s(a.value.target, {
|
|
851
|
+
kind: "date",
|
|
852
|
+
date: t
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
return (e, t) => a.value ? (z(), A("div", {
|
|
856
|
+
key: 0,
|
|
857
|
+
ref_key: "popupEl",
|
|
858
|
+
ref: o,
|
|
859
|
+
class: "layout-sdt-widget-popup",
|
|
860
|
+
role: a.value.kind === "dropdown" ? "listbox" : void 0,
|
|
861
|
+
style: I({
|
|
862
|
+
position: "fixed",
|
|
863
|
+
top: a.value.y + "px",
|
|
864
|
+
left: a.value.x + "px",
|
|
865
|
+
zIndex: 1e3
|
|
866
|
+
}),
|
|
867
|
+
onKeydown: g,
|
|
868
|
+
onMousedown: t[0] ||= Y(() => {}, ["prevent"])
|
|
869
|
+
}, [a.value.kind === "dropdown" ? (z(), A(T, { key: 0 }, [a.value.items.length === 0 ? (z(), A("div", Nn, "No options")) : k("", !0), (z(!0), A(T, null, V(a.value.items, (e) => (z(), A("button", {
|
|
870
|
+
key: e.value,
|
|
871
|
+
type: "button",
|
|
872
|
+
role: "option",
|
|
873
|
+
"aria-selected": e.displayText === a.value.current,
|
|
874
|
+
class: F(["layout-sdt-widget-option", { "is-selected": e.displayText === a.value.current }]),
|
|
875
|
+
onClick: (t) => s(a.value.target, {
|
|
876
|
+
kind: "dropdown",
|
|
877
|
+
value: e.value
|
|
878
|
+
})
|
|
879
|
+
}, H(e.displayText), 11, Pn))), 128))], 64)) : (z(), A("input", {
|
|
880
|
+
key: 1,
|
|
881
|
+
type: "date",
|
|
882
|
+
class: "layout-sdt-widget-date",
|
|
883
|
+
value: a.value.current,
|
|
884
|
+
onChange: _
|
|
885
|
+
}, null, 40, Fn))], 44, Mn)) : k("", !0);
|
|
886
|
+
}
|
|
887
|
+
}), Rn = {
|
|
888
|
+
key: 0,
|
|
889
|
+
class: "docx-editor-vue__title-bar"
|
|
890
|
+
}, zn = { class: "docx-editor-vue__title-bar-left" }, Bn = { class: "docx-editor-vue__title-bar-center" }, Vn = { class: "docx-editor-vue__title-bar-right" }, Hn = /* @__PURE__ */ P({
|
|
891
|
+
__name: "DocxEditorMenuBar",
|
|
892
|
+
props: {
|
|
893
|
+
showMenuBar: { type: Boolean },
|
|
894
|
+
documentName: {},
|
|
895
|
+
documentNameEditable: {
|
|
896
|
+
type: Boolean,
|
|
897
|
+
default: !0
|
|
898
|
+
},
|
|
899
|
+
showFileOpen: {
|
|
900
|
+
type: Boolean,
|
|
901
|
+
default: !0
|
|
902
|
+
},
|
|
903
|
+
showHelpMenu: {
|
|
904
|
+
type: Boolean,
|
|
905
|
+
default: !0
|
|
906
|
+
},
|
|
907
|
+
renderLogo: {},
|
|
908
|
+
renderTitleBarRight: {}
|
|
909
|
+
},
|
|
910
|
+
emits: [
|
|
911
|
+
"rename",
|
|
912
|
+
"menu-action",
|
|
913
|
+
"insert-table"
|
|
914
|
+
],
|
|
915
|
+
setup(e, { emit: t }) {
|
|
916
|
+
let n = t;
|
|
917
|
+
return (t, r) => e.showMenuBar ? (z(), A("div", Rn, [
|
|
918
|
+
j("div", zn, [e.renderLogo ? (z(), O(de(e.renderLogo), { key: 0 })) : k("", !0), ue(t.$slots, "title-bar-left")]),
|
|
919
|
+
j("div", Bn, [N(_, {
|
|
920
|
+
"model-value": e.documentName,
|
|
921
|
+
editable: e.documentNameEditable,
|
|
922
|
+
"onUpdate:modelValue": r[0] ||= (e) => n("rename", e)
|
|
923
|
+
}, null, 8, ["model-value", "editable"]), N(v, {
|
|
924
|
+
"show-file-open": e.showFileOpen,
|
|
925
|
+
"show-help-menu": e.showHelpMenu,
|
|
926
|
+
onAction: r[1] ||= (e) => n("menu-action", e),
|
|
927
|
+
onInsertTable: r[2] ||= (e, t) => n("insert-table", e, t)
|
|
928
|
+
}, null, 8, ["show-file-open", "show-help-menu"])]),
|
|
929
|
+
j("div", Vn, [ue(t.$slots, "title-bar-right"), e.renderTitleBarRight ? (z(), O(de(e.renderTitleBarRight), { key: 0 })) : k("", !0)])
|
|
930
|
+
])) : k("", !0);
|
|
931
|
+
}
|
|
932
|
+
}), Un = ["aria-label"], $ = { class: "wm-header" }, Wn = { class: "wm-body" }, Gn = { class: "wm-radio-row" }, Kn = ["checked"], qn = {
|
|
933
|
+
for: "wm-none",
|
|
934
|
+
class: "wm-inline-label"
|
|
935
|
+
}, Jn = { class: "wm-radio-row" }, Yn = ["checked"], Xn = {
|
|
936
|
+
for: "wm-picture",
|
|
937
|
+
class: "wm-inline-label"
|
|
938
|
+
}, Zn = {
|
|
939
|
+
key: 0,
|
|
940
|
+
class: "wm-subform"
|
|
941
|
+
}, Qn = { class: "wm-row" }, $n = {
|
|
942
|
+
key: 0,
|
|
943
|
+
class: "wm-row"
|
|
944
|
+
}, er = ["src"], tr = { class: "wm-row" }, nr = { class: "wm-label" }, rr = { class: "wm-inline-label" }, ir = { class: "wm-radio-row" }, ar = ["checked"], or = {
|
|
945
|
+
for: "wm-text",
|
|
946
|
+
class: "wm-inline-label"
|
|
947
|
+
}, sr = {
|
|
948
|
+
key: 1,
|
|
949
|
+
class: "wm-subform"
|
|
950
|
+
}, cr = {
|
|
951
|
+
key: 0,
|
|
952
|
+
class: "wm-row"
|
|
953
|
+
}, lr = { class: "wm-label" }, ur = ["value"], dr = ["value"], fr = { class: "wm-row" }, pr = { class: "wm-label" }, mr = { class: "wm-row" }, hr = { class: "wm-label" }, gr = ["value"], _r = { class: "wm-row" }, vr = { class: "wm-label" }, yr = { class: "wm-inline-label" }, br = { class: "wm-row" }, xr = { class: "wm-label" }, Sr = { class: "wm-row" }, Cr = { class: "wm-label" }, wr = { class: "wm-inline-label" }, Tr = ["checked"], Er = { class: "wm-inline-label" }, Dr = ["checked"], Or = { class: "wm-inline-label" }, kr = { class: "wm-footer" }, Ar = ["disabled"], jr = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
954
|
+
__name: "WatermarkDialog",
|
|
955
|
+
props: {
|
|
956
|
+
isOpen: { type: Boolean },
|
|
957
|
+
current: {},
|
|
958
|
+
presets: { default: () => gt }
|
|
959
|
+
},
|
|
960
|
+
emits: ["close", "apply"],
|
|
961
|
+
setup(e, { emit: t }) {
|
|
962
|
+
let n = [
|
|
963
|
+
"Calibri",
|
|
964
|
+
"Arial",
|
|
965
|
+
"Times New Roman",
|
|
966
|
+
"Georgia",
|
|
967
|
+
"Verdana",
|
|
968
|
+
"Courier New"
|
|
969
|
+
], { t: r } = d(), i = e, a = D(() => i.presets), o = t, s = B("none"), c = B(i.presets[0] ?? "CONFIDENTIAL"), l = B("Calibri"), u = B(!0), f = B(54), p = B("#C0C0C0"), m = B("diagonal"), h = B(!0), g = B(void 0), _ = B(void 0), v = B(100), y = B(!0);
|
|
970
|
+
K(() => i.isOpen, (e) => {
|
|
971
|
+
if (!e) return;
|
|
972
|
+
let t = i.current;
|
|
973
|
+
t?.kind === "text" ? (s.value = "text", c.value = t.text, l.value = t.font || "Calibri", u.value = t.fontSize === void 0, t.fontSize !== void 0 && (f.value = t.fontSize), p.value = t.color || "#C0C0C0", m.value = t.layout, h.value = t.semitransparent) : t?.kind === "picture" ? (s.value = "picture", g.value = t.dataUrl, _.value = t.widthEmu !== void 0 && t.heightEmu !== void 0 ? {
|
|
974
|
+
widthEmu: t.widthEmu,
|
|
975
|
+
heightEmu: t.heightEmu
|
|
976
|
+
} : void 0, v.value = Math.round((t.scale || 1) * 100), y.value = t.washout) : s.value = "none";
|
|
977
|
+
}, { immediate: !0 });
|
|
978
|
+
let b = D(() => s.value === "picture" && !g.value);
|
|
979
|
+
function ee(e) {
|
|
980
|
+
let t = e.target.value;
|
|
981
|
+
t && (c.value = t);
|
|
982
|
+
}
|
|
983
|
+
function x(e) {
|
|
984
|
+
let t = e.target.files?.[0];
|
|
985
|
+
if (!t) return;
|
|
986
|
+
let n = new FileReader();
|
|
987
|
+
n.onload = () => {
|
|
988
|
+
let e = typeof n.result == "string" ? n.result : void 0;
|
|
989
|
+
if (g.value = e, _.value = void 0, !e) return;
|
|
990
|
+
let t = new Image();
|
|
991
|
+
t.onload = () => {
|
|
992
|
+
_.value = _t(t.naturalWidth, t.naturalHeight);
|
|
993
|
+
}, t.src = e;
|
|
994
|
+
}, n.readAsDataURL(t);
|
|
995
|
+
}
|
|
996
|
+
function S() {
|
|
997
|
+
o("close");
|
|
998
|
+
}
|
|
999
|
+
function C() {
|
|
1000
|
+
if (s.value === "none") o("apply", null);
|
|
1001
|
+
else if (s.value === "text") o("apply", {
|
|
1002
|
+
kind: "text",
|
|
1003
|
+
text: c.value,
|
|
1004
|
+
font: l.value,
|
|
1005
|
+
color: p.value,
|
|
1006
|
+
semitransparent: h.value,
|
|
1007
|
+
layout: m.value,
|
|
1008
|
+
fontSize: u.value ? void 0 : f.value
|
|
1009
|
+
});
|
|
1010
|
+
else {
|
|
1011
|
+
if (!g.value) return;
|
|
1012
|
+
o("apply", {
|
|
1013
|
+
kind: "picture",
|
|
1014
|
+
dataUrl: g.value,
|
|
1015
|
+
scale: v.value / 100,
|
|
1016
|
+
washout: y.value,
|
|
1017
|
+
..._.value ?? {}
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
S();
|
|
1021
|
+
}
|
|
1022
|
+
function te(e) {
|
|
1023
|
+
e.key === "Escape" && S();
|
|
1024
|
+
}
|
|
1025
|
+
return (t, i) => e.isOpen ? (z(), A("div", {
|
|
1026
|
+
key: 0,
|
|
1027
|
+
class: "wm-overlay",
|
|
1028
|
+
onMousedown: Y(S, ["self"]),
|
|
1029
|
+
onKeydown: te
|
|
1030
|
+
}, [j("div", {
|
|
1031
|
+
class: "wm-dialog",
|
|
1032
|
+
role: "dialog",
|
|
1033
|
+
"aria-label": U(r)("dialogs.watermark.title"),
|
|
1034
|
+
onMousedown: i[13] ||= Y(() => {}, ["stop"])
|
|
1035
|
+
}, [
|
|
1036
|
+
j("div", $, H(U(r)("dialogs.watermark.title")), 1),
|
|
1037
|
+
j("div", Wn, [
|
|
1038
|
+
j("div", Gn, [j("input", {
|
|
1039
|
+
id: "wm-none",
|
|
1040
|
+
type: "radio",
|
|
1041
|
+
checked: s.value === "none",
|
|
1042
|
+
onChange: i[0] ||= (e) => s.value = "none"
|
|
1043
|
+
}, null, 40, Kn), j("label", qn, H(U(r)("dialogs.watermark.noWatermark")), 1)]),
|
|
1044
|
+
j("div", Jn, [j("input", {
|
|
1045
|
+
id: "wm-picture",
|
|
1046
|
+
type: "radio",
|
|
1047
|
+
checked: s.value === "picture",
|
|
1048
|
+
onChange: i[1] ||= (e) => s.value = "picture"
|
|
1049
|
+
}, null, 40, Yn), j("label", Xn, H(U(r)("dialogs.watermark.picture")), 1)]),
|
|
1050
|
+
s.value === "picture" ? (z(), A("div", Zn, [
|
|
1051
|
+
j("div", Qn, [j("input", {
|
|
1052
|
+
type: "file",
|
|
1053
|
+
accept: "image/*",
|
|
1054
|
+
onChange: x
|
|
1055
|
+
}, null, 32)]),
|
|
1056
|
+
g.value ? (z(), A("div", $n, [j("img", {
|
|
1057
|
+
src: g.value,
|
|
1058
|
+
alt: "",
|
|
1059
|
+
class: "wm-preview"
|
|
1060
|
+
}, null, 8, er)])) : k("", !0),
|
|
1061
|
+
j("div", tr, [
|
|
1062
|
+
j("span", nr, H(U(r)("dialogs.watermark.scale")), 1),
|
|
1063
|
+
q(j("input", {
|
|
1064
|
+
class: "wm-input wm-input--narrow",
|
|
1065
|
+
type: "number",
|
|
1066
|
+
min: "10",
|
|
1067
|
+
max: "500",
|
|
1068
|
+
"onUpdate:modelValue": i[2] ||= (e) => v.value = e
|
|
1069
|
+
}, null, 512), [[
|
|
1070
|
+
G,
|
|
1071
|
+
v.value,
|
|
1072
|
+
void 0,
|
|
1073
|
+
{ number: !0 }
|
|
1074
|
+
]]),
|
|
1075
|
+
i[14] ||= j("span", { class: "wm-unit" }, "%", -1)
|
|
1076
|
+
]),
|
|
1077
|
+
j("label", rr, [q(j("input", {
|
|
1078
|
+
type: "checkbox",
|
|
1079
|
+
"onUpdate:modelValue": i[3] ||= (e) => y.value = e
|
|
1080
|
+
}, null, 512), [[W, y.value]]), M(" " + H(U(r)("dialogs.watermark.washout")), 1)])
|
|
1081
|
+
])) : k("", !0),
|
|
1082
|
+
j("div", ir, [j("input", {
|
|
1083
|
+
id: "wm-text",
|
|
1084
|
+
type: "radio",
|
|
1085
|
+
checked: s.value === "text",
|
|
1086
|
+
onChange: i[4] ||= (e) => s.value = "text"
|
|
1087
|
+
}, null, 40, ar), j("label", or, H(U(r)("dialogs.watermark.text")), 1)]),
|
|
1088
|
+
s.value === "text" ? (z(), A("div", sr, [
|
|
1089
|
+
a.value.length > 0 ? (z(), A("div", cr, [j("span", lr, H(U(r)("dialogs.watermark.presetLabel")), 1), j("select", {
|
|
1090
|
+
class: "wm-input",
|
|
1091
|
+
value: a.value.includes(c.value) ? c.value : "",
|
|
1092
|
+
onChange: ee
|
|
1093
|
+
}, [i[15] ||= j("option", { value: "" }, "—", -1), (z(!0), A(T, null, V(a.value, (e) => (z(), A("option", {
|
|
1094
|
+
key: e,
|
|
1095
|
+
value: e
|
|
1096
|
+
}, H(e), 9, dr))), 128))], 40, ur)])) : k("", !0),
|
|
1097
|
+
j("div", fr, [j("span", pr, H(U(r)("dialogs.watermark.textLabel")), 1), q(j("input", {
|
|
1098
|
+
class: "wm-input",
|
|
1099
|
+
"onUpdate:modelValue": i[5] ||= (e) => c.value = e
|
|
1100
|
+
}, null, 512), [[G, c.value]])]),
|
|
1101
|
+
j("div", mr, [j("span", hr, H(U(r)("dialogs.watermark.fontLabel")), 1), q(j("select", {
|
|
1102
|
+
class: "wm-input",
|
|
1103
|
+
"onUpdate:modelValue": i[6] ||= (e) => l.value = e
|
|
1104
|
+
}, [(z(), A(T, null, V(n, (e) => j("option", {
|
|
1105
|
+
key: e,
|
|
1106
|
+
value: e
|
|
1107
|
+
}, H(e), 9, gr)), 64))], 512), [[pe, l.value]])]),
|
|
1108
|
+
j("div", _r, [
|
|
1109
|
+
j("span", vr, H(U(r)("dialogs.watermark.sizeLabel")), 1),
|
|
1110
|
+
j("label", yr, [q(j("input", {
|
|
1111
|
+
type: "checkbox",
|
|
1112
|
+
"onUpdate:modelValue": i[7] ||= (e) => u.value = e
|
|
1113
|
+
}, null, 512), [[W, u.value]]), M(" " + H(U(r)("dialogs.watermark.sizeAuto")), 1)]),
|
|
1114
|
+
u.value ? k("", !0) : q((z(), A("input", {
|
|
1115
|
+
key: 0,
|
|
1116
|
+
class: "wm-input wm-input--narrow",
|
|
1117
|
+
type: "number",
|
|
1118
|
+
min: "8",
|
|
1119
|
+
max: "200",
|
|
1120
|
+
"onUpdate:modelValue": i[8] ||= (e) => f.value = e
|
|
1121
|
+
}, null, 512)), [[
|
|
1122
|
+
G,
|
|
1123
|
+
f.value,
|
|
1124
|
+
void 0,
|
|
1125
|
+
{ number: !0 }
|
|
1126
|
+
]])
|
|
1127
|
+
]),
|
|
1128
|
+
j("div", br, [j("span", xr, H(U(r)("dialogs.watermark.colorLabel")), 1), q(j("input", {
|
|
1129
|
+
type: "color",
|
|
1130
|
+
"onUpdate:modelValue": i[9] ||= (e) => p.value = e
|
|
1131
|
+
}, null, 512), [[G, p.value]])]),
|
|
1132
|
+
j("div", Sr, [
|
|
1133
|
+
j("span", Cr, H(U(r)("dialogs.watermark.layoutLabel")), 1),
|
|
1134
|
+
j("label", wr, [j("input", {
|
|
1135
|
+
type: "radio",
|
|
1136
|
+
name: "wm-layout",
|
|
1137
|
+
checked: m.value === "diagonal",
|
|
1138
|
+
onChange: i[10] ||= (e) => m.value = "diagonal"
|
|
1139
|
+
}, null, 40, Tr), M(" " + H(U(r)("dialogs.watermark.diagonal")), 1)]),
|
|
1140
|
+
j("label", Er, [j("input", {
|
|
1141
|
+
type: "radio",
|
|
1142
|
+
name: "wm-layout",
|
|
1143
|
+
checked: m.value === "horizontal",
|
|
1144
|
+
onChange: i[11] ||= (e) => m.value = "horizontal"
|
|
1145
|
+
}, null, 40, Dr), M(" " + H(U(r)("dialogs.watermark.horizontal")), 1)])
|
|
1146
|
+
]),
|
|
1147
|
+
j("label", Or, [q(j("input", {
|
|
1148
|
+
type: "checkbox",
|
|
1149
|
+
"onUpdate:modelValue": i[12] ||= (e) => h.value = e
|
|
1150
|
+
}, null, 512), [[W, h.value]]), M(" " + H(U(r)("dialogs.watermark.semitransparent")), 1)])
|
|
1151
|
+
])) : k("", !0)
|
|
1152
|
+
]),
|
|
1153
|
+
j("div", kr, [j("button", {
|
|
1154
|
+
type: "button",
|
|
1155
|
+
class: "wm-btn",
|
|
1156
|
+
onClick: S
|
|
1157
|
+
}, H(U(r)("dialogs.watermark.cancelButton")), 1), j("button", {
|
|
1158
|
+
type: "button",
|
|
1159
|
+
class: F(["wm-btn wm-btn--primary", { "wm-btn--disabled": b.value }]),
|
|
1160
|
+
disabled: b.value,
|
|
1161
|
+
onClick: C
|
|
1162
|
+
}, H(U(r)("dialogs.watermark.applyButton")), 11, Ar)])
|
|
1163
|
+
], 40, Un)], 32)) : k("", !0);
|
|
1164
|
+
}
|
|
1165
|
+
}), [["__scopeId", "data-v-cf7e36c1"]]), Mr = /* @__PURE__ */ P({
|
|
1166
|
+
__name: "DocxEditorDialogs",
|
|
1167
|
+
props: {
|
|
1168
|
+
view: {},
|
|
1169
|
+
bookmarks: {},
|
|
1170
|
+
selectedImagePmPos: {},
|
|
1171
|
+
sectionProperties: {},
|
|
1172
|
+
scrollVisiblePositionIntoView: { type: Function },
|
|
1173
|
+
showFindReplace: { type: Boolean },
|
|
1174
|
+
showHyperlink: { type: Boolean },
|
|
1175
|
+
showInsertSymbol: { type: Boolean },
|
|
1176
|
+
showImageProperties: { type: Boolean },
|
|
1177
|
+
showPageSetup: { type: Boolean },
|
|
1178
|
+
showWatermark: { type: Boolean },
|
|
1179
|
+
currentWatermark: {},
|
|
1180
|
+
watermarkPresets: {},
|
|
1181
|
+
showKeyboardShortcuts: { type: Boolean }
|
|
1182
|
+
},
|
|
1183
|
+
emits: [
|
|
1184
|
+
"update:showFindReplace",
|
|
1185
|
+
"update:showHyperlink",
|
|
1186
|
+
"update:showInsertSymbol",
|
|
1187
|
+
"update:showImageProperties",
|
|
1188
|
+
"update:showPageSetup",
|
|
1189
|
+
"update:showWatermark",
|
|
1190
|
+
"update:showKeyboardShortcuts",
|
|
1191
|
+
"insert-symbol",
|
|
1192
|
+
"hyperlink-submit",
|
|
1193
|
+
"hyperlink-remove",
|
|
1194
|
+
"page-setup-apply",
|
|
1195
|
+
"watermark-apply"
|
|
1196
|
+
],
|
|
1197
|
+
setup(t, { emit: n }) {
|
|
1198
|
+
let r = n;
|
|
1199
|
+
return (n, a) => (z(), A(T, null, [
|
|
1200
|
+
N(s, {
|
|
1201
|
+
"is-open": t.showFindReplace,
|
|
1202
|
+
view: t.view,
|
|
1203
|
+
"scroll-visible-position-into-view": t.scrollVisiblePositionIntoView,
|
|
1204
|
+
onClose: a[0] ||= (e) => r("update:showFindReplace", !1)
|
|
1205
|
+
}, null, 8, [
|
|
1206
|
+
"is-open",
|
|
1207
|
+
"view",
|
|
1208
|
+
"scroll-visible-position-into-view"
|
|
1209
|
+
]),
|
|
1210
|
+
N(e, {
|
|
1211
|
+
"is-open": t.showHyperlink,
|
|
1212
|
+
view: t.view,
|
|
1213
|
+
bookmarks: t.bookmarks,
|
|
1214
|
+
onClose: a[1] ||= (e) => r("update:showHyperlink", !1),
|
|
1215
|
+
onSubmit: a[2] ||= (e) => r("hyperlink-submit", e),
|
|
1216
|
+
onRemove: a[3] ||= (e) => r("hyperlink-remove")
|
|
1217
|
+
}, null, 8, [
|
|
1218
|
+
"is-open",
|
|
1219
|
+
"view",
|
|
1220
|
+
"bookmarks"
|
|
1221
|
+
]),
|
|
1222
|
+
N(i, {
|
|
1223
|
+
"is-open": t.showInsertSymbol,
|
|
1224
|
+
onClose: a[4] ||= (e) => r("update:showInsertSymbol", !1),
|
|
1225
|
+
onInsert: a[5] ||= (e) => r("insert-symbol", e)
|
|
1226
|
+
}, null, 8, ["is-open"]),
|
|
1227
|
+
N(c, {
|
|
1228
|
+
"is-open": t.showImageProperties,
|
|
1229
|
+
view: t.view,
|
|
1230
|
+
"pm-pos": t.selectedImagePmPos,
|
|
1231
|
+
onClose: a[6] ||= (e) => r("update:showImageProperties", !1)
|
|
1232
|
+
}, null, 8, [
|
|
1233
|
+
"is-open",
|
|
1234
|
+
"view",
|
|
1235
|
+
"pm-pos"
|
|
1236
|
+
]),
|
|
1237
|
+
N(o, {
|
|
1238
|
+
"is-open": t.showPageSetup,
|
|
1239
|
+
"section-properties": t.sectionProperties,
|
|
1240
|
+
onClose: a[7] ||= (e) => r("update:showPageSetup", !1),
|
|
1241
|
+
onApply: a[8] ||= (e) => r("page-setup-apply", e)
|
|
1242
|
+
}, null, 8, ["is-open", "section-properties"]),
|
|
1243
|
+
N(jr, {
|
|
1244
|
+
"is-open": t.showWatermark,
|
|
1245
|
+
current: t.currentWatermark,
|
|
1246
|
+
presets: t.watermarkPresets,
|
|
1247
|
+
onClose: a[9] ||= (e) => r("update:showWatermark", !1),
|
|
1248
|
+
onApply: a[10] ||= (e) => r("watermark-apply", e)
|
|
1249
|
+
}, null, 8, [
|
|
1250
|
+
"is-open",
|
|
1251
|
+
"current",
|
|
1252
|
+
"presets"
|
|
1253
|
+
]),
|
|
1254
|
+
N(u, {
|
|
1255
|
+
"is-open": t.showKeyboardShortcuts,
|
|
1256
|
+
onClose: a[11] ||= (e) => r("update:showKeyboardShortcuts", !1)
|
|
1257
|
+
}, null, 8, ["is-open"])
|
|
1258
|
+
], 64));
|
|
1259
|
+
}
|
|
1260
|
+
}), Nr = ["disabled", "onMousedown"], Pr = { class: "ctx-menu__label" }, Fr = {
|
|
1261
|
+
key: 0,
|
|
1262
|
+
class: "ctx-menu__shortcut"
|
|
1263
|
+
}, Ir = 220, Lr = 32, Rr = 10, zr = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
1264
|
+
__name: "TextContextMenu",
|
|
1265
|
+
props: {
|
|
1266
|
+
isOpen: { type: Boolean },
|
|
1267
|
+
position: {},
|
|
1268
|
+
hasSelection: { type: Boolean },
|
|
1269
|
+
isEditable: { type: Boolean },
|
|
1270
|
+
inTable: { type: Boolean },
|
|
1271
|
+
onImage: { type: Boolean },
|
|
1272
|
+
canMergeCells: { type: Boolean },
|
|
1273
|
+
canSplitCell: { type: Boolean }
|
|
1274
|
+
},
|
|
1275
|
+
emits: ["close", "action"],
|
|
1276
|
+
setup(e, { emit: t }) {
|
|
1277
|
+
let n = e, r = t, { t: i } = d(), a = g(), o = B(null), s = D(() => {
|
|
1278
|
+
let e = [
|
|
1279
|
+
{
|
|
1280
|
+
id: "cut",
|
|
1281
|
+
label: i("contextMenu.cut"),
|
|
1282
|
+
action: "cut",
|
|
1283
|
+
shortcut: i("contextMenu.cutShortcut"),
|
|
1284
|
+
disabled: !n.hasSelection || !n.isEditable
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
id: "copy",
|
|
1288
|
+
label: i("contextMenu.copy"),
|
|
1289
|
+
action: "copy",
|
|
1290
|
+
shortcut: i("contextMenu.copyShortcut"),
|
|
1291
|
+
disabled: !n.hasSelection
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
id: "paste",
|
|
1295
|
+
label: i("contextMenu.paste"),
|
|
1296
|
+
action: "paste",
|
|
1297
|
+
shortcut: i("contextMenu.pasteShortcut"),
|
|
1298
|
+
disabled: !n.isEditable
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
id: "pasteAsPlainText",
|
|
1302
|
+
label: i("contextMenu.pastePlainText"),
|
|
1303
|
+
action: "pasteAsPlainText",
|
|
1304
|
+
shortcut: i("contextMenu.pastePlainTextShortcut"),
|
|
1305
|
+
disabled: !n.isEditable
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
id: "div1",
|
|
1309
|
+
label: "",
|
|
1310
|
+
action: "",
|
|
1311
|
+
divider: !0
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
id: "delete",
|
|
1315
|
+
label: i("contextMenu.delete"),
|
|
1316
|
+
action: "delete",
|
|
1317
|
+
shortcut: i("contextMenu.deleteShortcut"),
|
|
1318
|
+
disabled: !n.hasSelection || !n.isEditable
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
id: "selectAll",
|
|
1322
|
+
label: i("contextMenu.selectAll"),
|
|
1323
|
+
action: "selectAll",
|
|
1324
|
+
shortcut: i("contextMenu.selectAllShortcut")
|
|
1325
|
+
}
|
|
1326
|
+
];
|
|
1327
|
+
return n.onImage && n.isEditable && e.push({
|
|
1328
|
+
id: "div-img",
|
|
1329
|
+
label: "",
|
|
1330
|
+
action: "",
|
|
1331
|
+
divider: !0
|
|
1332
|
+
}, {
|
|
1333
|
+
id: "replaceImage",
|
|
1334
|
+
label: i("imageOverlay.replaceImage"),
|
|
1335
|
+
action: "replaceImage"
|
|
1336
|
+
}, {
|
|
1337
|
+
id: "imageProperties",
|
|
1338
|
+
label: i("imageWrap.menu.imageProperties"),
|
|
1339
|
+
action: "imageProperties"
|
|
1340
|
+
}, {
|
|
1341
|
+
id: "deleteImage",
|
|
1342
|
+
label: i("imageOverlay.deleteImage"),
|
|
1343
|
+
action: "deleteImage",
|
|
1344
|
+
shortcut: i("contextMenu.deleteShortcut")
|
|
1345
|
+
}), n.inTable && n.isEditable && e.push({
|
|
1346
|
+
id: "div2",
|
|
1347
|
+
label: "",
|
|
1348
|
+
action: "",
|
|
1349
|
+
divider: !0
|
|
1350
|
+
}, {
|
|
1351
|
+
id: "addRowAbove",
|
|
1352
|
+
label: i("table.insertRowAbove"),
|
|
1353
|
+
action: "addRowAbove"
|
|
1354
|
+
}, {
|
|
1355
|
+
id: "addRowBelow",
|
|
1356
|
+
label: i("table.insertRowBelow"),
|
|
1357
|
+
action: "addRowBelow"
|
|
1358
|
+
}, {
|
|
1359
|
+
id: "deleteRow",
|
|
1360
|
+
label: i("table.deleteRow"),
|
|
1361
|
+
action: "deleteRow"
|
|
1362
|
+
}, {
|
|
1363
|
+
id: "div3",
|
|
1364
|
+
label: "",
|
|
1365
|
+
action: "",
|
|
1366
|
+
divider: !0
|
|
1367
|
+
}, {
|
|
1368
|
+
id: "addColLeft",
|
|
1369
|
+
label: i("table.insertColumnLeft"),
|
|
1370
|
+
action: "addColumnLeft"
|
|
1371
|
+
}, {
|
|
1372
|
+
id: "addColRight",
|
|
1373
|
+
label: i("table.insertColumnRight"),
|
|
1374
|
+
action: "addColumnRight"
|
|
1375
|
+
}, {
|
|
1376
|
+
id: "deleteCol",
|
|
1377
|
+
label: i("table.deleteColumn"),
|
|
1378
|
+
action: "deleteColumn"
|
|
1379
|
+
}, {
|
|
1380
|
+
id: "div4",
|
|
1381
|
+
label: "",
|
|
1382
|
+
action: "",
|
|
1383
|
+
divider: !0
|
|
1384
|
+
}, {
|
|
1385
|
+
id: "mergeCells",
|
|
1386
|
+
label: i("table.mergeCells"),
|
|
1387
|
+
action: "mergeCells",
|
|
1388
|
+
disabled: !n.canMergeCells
|
|
1389
|
+
}, {
|
|
1390
|
+
id: "splitCell",
|
|
1391
|
+
label: i("table.splitCell"),
|
|
1392
|
+
action: "splitCell",
|
|
1393
|
+
disabled: !n.canSplitCell
|
|
1394
|
+
}, {
|
|
1395
|
+
id: "div5",
|
|
1396
|
+
label: "",
|
|
1397
|
+
action: "",
|
|
1398
|
+
divider: !0
|
|
1399
|
+
}, {
|
|
1400
|
+
id: "selectTable",
|
|
1401
|
+
label: i("table.selectTable"),
|
|
1402
|
+
action: "selectTable"
|
|
1403
|
+
}, {
|
|
1404
|
+
id: "deleteTable",
|
|
1405
|
+
label: i("table.deleteTable"),
|
|
1406
|
+
action: "deleteTable"
|
|
1407
|
+
}), e;
|
|
1408
|
+
}), c = D(() => {
|
|
1409
|
+
let e = n.position.x, t = n.position.y, r = s.value.filter((e) => !e.divider).length, i = s.value.filter((e) => e.divider).length, a = r * Lr + i * 9;
|
|
1410
|
+
return typeof window < "u" && (e + Ir + Rr > window.innerWidth && (e = window.innerWidth - Ir - Rr), t + a + Rr > window.innerHeight && (t = window.innerHeight - a - Rr)), {
|
|
1411
|
+
position: "fixed",
|
|
1412
|
+
left: `${e}px`,
|
|
1413
|
+
top: `${t}px`,
|
|
1414
|
+
zIndex: 400
|
|
1415
|
+
};
|
|
1416
|
+
});
|
|
1417
|
+
function l(e) {
|
|
1418
|
+
e && (r("action", e), r("close"));
|
|
1419
|
+
}
|
|
1420
|
+
function u(e) {
|
|
1421
|
+
e.key === "Escape" && r("close");
|
|
1422
|
+
}
|
|
1423
|
+
return K(() => n.isOpen, (e) => {
|
|
1424
|
+
e && le(() => o.value?.focus());
|
|
1425
|
+
}), (t, n) => (z(), O(E, { to: "body" }, [e.isOpen ? (z(), A("div", {
|
|
1426
|
+
key: 0,
|
|
1427
|
+
class: "ctx-menu-backdrop",
|
|
1428
|
+
onMousedown: n[0] ||= (e) => t.$emit("close"),
|
|
1429
|
+
onContextmenu: n[1] ||= Y((e) => t.$emit("close"), ["prevent"])
|
|
1430
|
+
}, null, 32)) : k("", !0), e.isOpen ? (z(), A("div", {
|
|
1431
|
+
key: 1,
|
|
1432
|
+
ref_key: "menuRef",
|
|
1433
|
+
ref: o,
|
|
1434
|
+
class: F(["ctx-menu", U(a)]),
|
|
1435
|
+
style: I(c.value),
|
|
1436
|
+
onContextmenu: n[2] ||= Y(() => {}, ["prevent"]),
|
|
1437
|
+
onKeydown: u
|
|
1438
|
+
}, [(z(!0), A(T, null, V(s.value, (e, t) => (z(), A("button", {
|
|
1439
|
+
key: e.id || t,
|
|
1440
|
+
class: F(["ctx-menu__item", {
|
|
1441
|
+
"ctx-menu__item--disabled": e.disabled,
|
|
1442
|
+
"ctx-menu__item--divider": e.divider
|
|
1443
|
+
}]),
|
|
1444
|
+
disabled: e.disabled,
|
|
1445
|
+
onMousedown: Y((t) => l(e.action), ["prevent"])
|
|
1446
|
+
}, [j("span", Pr, H(e.label), 1), e.shortcut ? (z(), A("span", Fr, H(e.shortcut), 1)) : k("", !0)], 42, Nr))), 128))], 38)) : k("", !0)]));
|
|
1447
|
+
}
|
|
1448
|
+
}), [["__scopeId", "data-v-6d4a567b"]]), Br = ["aria-label"], Vr = { class: "image-ctx-menu__icon" }, Hr = { class: "image-ctx-menu__label" }, Ur = {
|
|
1449
|
+
key: 1,
|
|
1450
|
+
class: "image-ctx-menu__divider",
|
|
1451
|
+
role: "separator"
|
|
1452
|
+
}, Wr = [
|
|
1453
|
+
"data-wrap-type",
|
|
1454
|
+
"data-current",
|
|
1455
|
+
"data-disabled",
|
|
1456
|
+
"disabled",
|
|
1457
|
+
"title",
|
|
1458
|
+
"onClick"
|
|
1459
|
+
], Gr = { class: "image-ctx-menu__icon" }, Kr = { class: "image-ctx-menu__label" }, qr = ["aria-label"], Jr = ["disabled", "onClick"], Yr = { class: "image-ctx-menu__label" }, Xr = {
|
|
1460
|
+
key: 0,
|
|
1461
|
+
class: "image-ctx-menu__shortcut"
|
|
1462
|
+
}, Zr = {
|
|
1463
|
+
key: 0,
|
|
1464
|
+
class: "image-ctx-menu__divider",
|
|
1465
|
+
role: "separator"
|
|
1466
|
+
}, Qr = 18, $r = 260, ei = 10, ti = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
1467
|
+
__name: "ImageContextMenu",
|
|
1468
|
+
props: {
|
|
1469
|
+
state: {},
|
|
1470
|
+
textActions: {},
|
|
1471
|
+
canOpenProperties: {
|
|
1472
|
+
type: Boolean,
|
|
1473
|
+
default: !1
|
|
1474
|
+
}
|
|
1475
|
+
},
|
|
1476
|
+
emits: [
|
|
1477
|
+
"close",
|
|
1478
|
+
"select",
|
|
1479
|
+
"text-action",
|
|
1480
|
+
"open-properties"
|
|
1481
|
+
],
|
|
1482
|
+
setup(e, { emit: t }) {
|
|
1483
|
+
let n = e, i = t;
|
|
1484
|
+
function a() {
|
|
1485
|
+
i("open-properties"), i("close");
|
|
1486
|
+
}
|
|
1487
|
+
let { t: o } = d(), s = g(), c = B(null), l = st, u = D(() => n.state ? lt(n.state.currentWrapType, n.state.currentCssFloat ?? null) : null), f = {
|
|
1488
|
+
inline: "wrap_text",
|
|
1489
|
+
squareLeft: "format_image_left",
|
|
1490
|
+
squareRight: "format_image_right",
|
|
1491
|
+
behind: "flip_to_back",
|
|
1492
|
+
inFront: "flip_to_front"
|
|
1493
|
+
};
|
|
1494
|
+
function p(e) {
|
|
1495
|
+
return f[e];
|
|
1496
|
+
}
|
|
1497
|
+
let m = D(() => {
|
|
1498
|
+
if (!n.state) return {};
|
|
1499
|
+
let e = st.length * 36 + 16, t = n.state.position.x, r = n.state.position.y;
|
|
1500
|
+
return typeof window < "u" && (t + $r > window.innerWidth && (t = window.innerWidth - $r - ei), r + e > window.innerHeight && (r = window.innerHeight - e - ei), t < ei && (t = ei), r < ei && (r = ei)), {
|
|
1501
|
+
position: "fixed",
|
|
1502
|
+
left: `${t}px`,
|
|
1503
|
+
top: `${r}px`,
|
|
1504
|
+
minWidth: `${$r}px`,
|
|
1505
|
+
zIndex: 400
|
|
1506
|
+
};
|
|
1507
|
+
});
|
|
1508
|
+
function h(e) {
|
|
1509
|
+
return n.state ? dt(e, n.state.currentWrapType) : !1;
|
|
1510
|
+
}
|
|
1511
|
+
function _(e) {
|
|
1512
|
+
h(e) && (i("select", e.choice), i("close"));
|
|
1513
|
+
}
|
|
1514
|
+
function v(e) {
|
|
1515
|
+
e.disabled || (i("text-action", e.action), i("close"));
|
|
1516
|
+
}
|
|
1517
|
+
function y(e) {
|
|
1518
|
+
e.preventDefault(), i("close");
|
|
1519
|
+
}
|
|
1520
|
+
function b(e) {
|
|
1521
|
+
e.key === "Escape" && (e.preventDefault(), i("close"));
|
|
1522
|
+
}
|
|
1523
|
+
return (t, n) => (z(), O(E, { to: "body" }, [e.state && e.state.open ? (z(), A("div", {
|
|
1524
|
+
key: 0,
|
|
1525
|
+
class: "image-ctx-menu-backdrop",
|
|
1526
|
+
onMousedown: y,
|
|
1527
|
+
onContextmenu: n[0] ||= Y((e) => t.$emit("close"), ["prevent"])
|
|
1528
|
+
}, null, 32)) : k("", !0), e.state && e.state.open ? (z(), A("div", {
|
|
1529
|
+
key: 1,
|
|
1530
|
+
ref_key: "menuRef",
|
|
1531
|
+
ref: c,
|
|
1532
|
+
class: F(["image-ctx-menu", U(s)]),
|
|
1533
|
+
role: "menu",
|
|
1534
|
+
"aria-label": U(o)("imageWrap.menu.ariaLabel"),
|
|
1535
|
+
"data-testid": "image-context-menu",
|
|
1536
|
+
style: I(m.value),
|
|
1537
|
+
onContextmenu: n[4] ||= Y(() => {}, ["prevent"]),
|
|
1538
|
+
onKeydown: b
|
|
1539
|
+
}, [
|
|
1540
|
+
e.canOpenProperties ? (z(), A("button", {
|
|
1541
|
+
key: 0,
|
|
1542
|
+
type: "button",
|
|
1543
|
+
role: "menuitem",
|
|
1544
|
+
class: "image-ctx-menu__item",
|
|
1545
|
+
"data-action": "open-properties",
|
|
1546
|
+
onMousedown: n[1] ||= Y(() => {}, ["prevent"]),
|
|
1547
|
+
onClick: a
|
|
1548
|
+
}, [j("span", Vr, [N(r, {
|
|
1549
|
+
name: "settings",
|
|
1550
|
+
size: Qr
|
|
1551
|
+
})]), j("span", Hr, H(U(o)("imageWrap.menu.imageProperties")), 1)], 32)) : k("", !0),
|
|
1552
|
+
e.canOpenProperties ? (z(), A("div", Ur)) : k("", !0),
|
|
1553
|
+
(z(!0), A(T, null, V(U(l), (e) => (z(), A("button", {
|
|
1554
|
+
key: e.choice,
|
|
1555
|
+
type: "button",
|
|
1556
|
+
role: "menuitem",
|
|
1557
|
+
class: F(["image-ctx-menu__item", { "image-ctx-menu__item--current": e.choice === u.value }]),
|
|
1558
|
+
"data-wrap-type": e.choice,
|
|
1559
|
+
"data-current": e.choice === u.value ? "true" : "false",
|
|
1560
|
+
"data-disabled": h(e) ? "false" : "true",
|
|
1561
|
+
disabled: !h(e),
|
|
1562
|
+
title: U(o)(`imageWrap.menuDesc.${e.i18nDescKey}`),
|
|
1563
|
+
onMousedown: n[2] ||= Y(() => {}, ["prevent"]),
|
|
1564
|
+
onClick: (t) => _(e)
|
|
1565
|
+
}, [
|
|
1566
|
+
j("span", Gr, [N(r, {
|
|
1567
|
+
name: p(e.iconHint),
|
|
1568
|
+
size: Qr
|
|
1569
|
+
}, null, 8, ["name"])]),
|
|
1570
|
+
j("span", Kr, H(U(o)(`imageWrap.menu.${e.i18nLabelKey}`)), 1),
|
|
1571
|
+
e.choice === u.value ? (z(), A("span", {
|
|
1572
|
+
key: 0,
|
|
1573
|
+
class: "image-ctx-menu__current-dot",
|
|
1574
|
+
"aria-label": U(o)("imageWrap.menu.ariaLabel")
|
|
1575
|
+
}, "●", 8, qr)) : k("", !0)
|
|
1576
|
+
], 42, Wr))), 128)),
|
|
1577
|
+
e.textActions && e.textActions.length > 0 ? (z(), A(T, { key: 2 }, [n[5] ||= j("div", {
|
|
1578
|
+
class: "image-ctx-menu__divider",
|
|
1579
|
+
role: "separator"
|
|
1580
|
+
}, null, -1), (z(!0), A(T, null, V(e.textActions, (e, t) => (z(), A(T, { key: `${e.action}-${t}` }, [j("button", {
|
|
1581
|
+
type: "button",
|
|
1582
|
+
role: "menuitem",
|
|
1583
|
+
class: "image-ctx-menu__item image-ctx-menu__item--text",
|
|
1584
|
+
disabled: e.disabled,
|
|
1585
|
+
onMousedown: n[3] ||= Y(() => {}, ["prevent"]),
|
|
1586
|
+
onClick: (t) => v(e)
|
|
1587
|
+
}, [j("span", Yr, H(e.label), 1), e.shortcut ? (z(), A("span", Xr, H(e.shortcut), 1)) : k("", !0)], 40, Jr), e.dividerAfter ? (z(), A("div", Zr)) : k("", !0)], 64))), 128))], 64)) : k("", !0)
|
|
1588
|
+
], 46, Br)) : k("", !0)]));
|
|
1589
|
+
}
|
|
1590
|
+
}), [["__scopeId", "data-v-a4798e95"]]), ni = /* @__PURE__ */ P({
|
|
1591
|
+
__name: "DocxEditorOverlays",
|
|
1592
|
+
props: {
|
|
1593
|
+
readOnly: { type: Boolean },
|
|
1594
|
+
contextMenu: {},
|
|
1595
|
+
imageContextMenu: {},
|
|
1596
|
+
imageContextMenuTextActions: {},
|
|
1597
|
+
canOpenImageProperties: { type: Boolean }
|
|
1598
|
+
},
|
|
1599
|
+
emits: [
|
|
1600
|
+
"context-menu-action",
|
|
1601
|
+
"close-context-menu",
|
|
1602
|
+
"image-wrap-select",
|
|
1603
|
+
"close-image-context-menu",
|
|
1604
|
+
"open-image-properties"
|
|
1605
|
+
],
|
|
1606
|
+
setup(e, { emit: t }) {
|
|
1607
|
+
let n = t;
|
|
1608
|
+
return (t, r) => (z(), A(T, null, [N(zr, {
|
|
1609
|
+
"is-open": e.contextMenu.isOpen,
|
|
1610
|
+
position: e.contextMenu.position,
|
|
1611
|
+
"has-selection": e.contextMenu.hasSelection,
|
|
1612
|
+
"is-editable": !e.readOnly,
|
|
1613
|
+
"in-table": e.contextMenu.inTable,
|
|
1614
|
+
"on-image": e.contextMenu.onImage,
|
|
1615
|
+
"can-merge-cells": e.contextMenu.canMergeCells,
|
|
1616
|
+
"can-split-cell": e.contextMenu.canSplitCell,
|
|
1617
|
+
onAction: r[0] ||= (e) => n("context-menu-action", e),
|
|
1618
|
+
onClose: r[1] ||= (e) => n("close-context-menu")
|
|
1619
|
+
}, null, 8, [
|
|
1620
|
+
"is-open",
|
|
1621
|
+
"position",
|
|
1622
|
+
"has-selection",
|
|
1623
|
+
"is-editable",
|
|
1624
|
+
"in-table",
|
|
1625
|
+
"on-image",
|
|
1626
|
+
"can-merge-cells",
|
|
1627
|
+
"can-split-cell"
|
|
1628
|
+
]), N(ti, {
|
|
1629
|
+
state: e.imageContextMenu,
|
|
1630
|
+
"text-actions": e.imageContextMenuTextActions,
|
|
1631
|
+
"can-open-properties": e.canOpenImageProperties,
|
|
1632
|
+
onClose: r[2] ||= (e) => n("close-image-context-menu"),
|
|
1633
|
+
onSelect: r[3] ||= (e) => n("image-wrap-select", e),
|
|
1634
|
+
onTextAction: r[4] ||= (e) => n("context-menu-action", e),
|
|
1635
|
+
onOpenProperties: r[5] ||= (e) => n("open-image-properties")
|
|
1636
|
+
}, null, 8, [
|
|
1637
|
+
"state",
|
|
1638
|
+
"text-actions",
|
|
1639
|
+
"can-open-properties"
|
|
1640
|
+
])], 64));
|
|
1641
|
+
}
|
|
1642
|
+
}), ri = ["href", "title"], ii = ["title"], ai = ["title"], oi = ["title"], si = { class: "docx-hyperlink-popup__edit-row" }, ci = ["placeholder", "onKeydown"], li = { class: "docx-hyperlink-popup__edit-row" }, ui = ["onKeydown"], di = ["disabled"], fi = /* @__PURE__ */ x(/* @__PURE__ */ P({
|
|
1643
|
+
__name: "HyperlinkPopup",
|
|
1644
|
+
props: {
|
|
1645
|
+
data: {},
|
|
1646
|
+
readOnly: { type: Boolean }
|
|
1647
|
+
},
|
|
1648
|
+
emits: [
|
|
1649
|
+
"navigate",
|
|
1650
|
+
"copy",
|
|
1651
|
+
"edit",
|
|
1652
|
+
"remove",
|
|
1653
|
+
"close"
|
|
1654
|
+
],
|
|
1655
|
+
setup(e, { emit: t }) {
|
|
1656
|
+
let { t: n } = d(), r = e, i = t, a = B(!1), o = B(""), s = B(""), c = B(null), l = D(() => ({
|
|
1657
|
+
left: (r.data?.position.left ?? 0) + "px",
|
|
1658
|
+
top: (r.data?.position.top ?? 0) + "px"
|
|
1659
|
+
}));
|
|
1660
|
+
K(() => r.data?.href, () => {
|
|
1661
|
+
a.value = !1;
|
|
1662
|
+
});
|
|
1663
|
+
let u = null, f = null;
|
|
1664
|
+
function p() {
|
|
1665
|
+
f &&= (clearTimeout(f), null), u &&= (document.removeEventListener("mousedown", u), null);
|
|
1666
|
+
}
|
|
1667
|
+
K(() => r.data, (e) => {
|
|
1668
|
+
p(), e && (u = (e) => {
|
|
1669
|
+
let t = c.value;
|
|
1670
|
+
t && !t.contains(e.target) && i("close");
|
|
1671
|
+
}, f = setTimeout(() => {
|
|
1672
|
+
u && document.addEventListener("mousedown", u);
|
|
1673
|
+
}, 0));
|
|
1674
|
+
}, { immediate: !0 }), L(p);
|
|
1675
|
+
function m() {
|
|
1676
|
+
r.data && (o.value = r.data.displayText, s.value = r.data.href, a.value = !0);
|
|
1677
|
+
}
|
|
1678
|
+
function h() {
|
|
1679
|
+
s.value.trim() && (i("edit", o.value, s.value), a.value = !1);
|
|
1680
|
+
}
|
|
1681
|
+
function g() {
|
|
1682
|
+
r.data && (i("copy", r.data.href), typeof navigator < "u" && navigator.clipboard && navigator.clipboard.writeText(r.data.href).catch(() => {}));
|
|
1683
|
+
}
|
|
1684
|
+
return (t, r) => e.data ? (z(), A("div", {
|
|
1685
|
+
key: 0,
|
|
1686
|
+
ref_key: "popupRef",
|
|
1687
|
+
ref: c,
|
|
1688
|
+
class: F(["docx-hyperlink-popup", { "docx-hyperlink-popup--edit": a.value }]),
|
|
1689
|
+
style: I(l.value),
|
|
1690
|
+
onMousedown: r[6] ||= Y(() => {}, ["stop"])
|
|
1691
|
+
}, [a.value ? (z(), A(T, { key: 1 }, [j("div", si, [q(j("input", {
|
|
1692
|
+
class: "docx-hyperlink-popup__input",
|
|
1693
|
+
placeholder: U(n)("hyperlinkPopup.displayTextPlaceholder"),
|
|
1694
|
+
"onUpdate:modelValue": r[2] ||= (e) => o.value = e,
|
|
1695
|
+
onKeydown: [J(Y(h, ["prevent"]), ["enter"]), r[3] ||= J((e) => t.$emit("close"), ["esc"])]
|
|
1696
|
+
}, null, 40, ci), [[G, o.value]])]), j("div", li, [q(j("input", {
|
|
1697
|
+
class: "docx-hyperlink-popup__input",
|
|
1698
|
+
placeholder: "https://...",
|
|
1699
|
+
"onUpdate:modelValue": r[4] ||= (e) => s.value = e,
|
|
1700
|
+
onKeydown: [J(Y(h, ["prevent"]), ["enter"]), r[5] ||= J((e) => t.$emit("close"), ["esc"])]
|
|
1701
|
+
}, null, 40, ui), [[G, s.value]]), j("button", {
|
|
1702
|
+
class: "docx-hyperlink-popup__apply",
|
|
1703
|
+
disabled: !s.value.trim(),
|
|
1704
|
+
onClick: Y(h, ["prevent"])
|
|
1705
|
+
}, H(U(n)("common.apply")), 9, di)])], 64)) : (z(), A(T, { key: 0 }, [
|
|
1706
|
+
r[10] ||= oe("<span class=\"docx-hyperlink-popup__icon\" aria-hidden data-v-084b4288><svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-084b4288><circle cx=\"12\" cy=\"12\" r=\"10\" data-v-084b4288></circle><path d=\"M2 12h20\" data-v-084b4288></path><path d=\"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z\" data-v-084b4288></path></svg></span>", 1),
|
|
1707
|
+
j("a", {
|
|
1708
|
+
class: "docx-hyperlink-popup__url",
|
|
1709
|
+
href: e.data.href,
|
|
1710
|
+
title: e.data.href,
|
|
1711
|
+
onClick: r[0] ||= Y((n) => t.$emit("navigate", e.data.href), ["prevent"])
|
|
1712
|
+
}, H(e.data.href), 9, ri),
|
|
1713
|
+
r[11] ||= j("span", { class: "docx-hyperlink-popup__sep" }, null, -1),
|
|
1714
|
+
j("button", {
|
|
1715
|
+
class: "docx-hyperlink-popup__btn",
|
|
1716
|
+
title: U(n)("hyperlinkPopup.copyLink"),
|
|
1717
|
+
onClick: Y(g, ["prevent"])
|
|
1718
|
+
}, [...r[7] ||= [j("svg", {
|
|
1719
|
+
width: "18",
|
|
1720
|
+
height: "18",
|
|
1721
|
+
viewBox: "0 0 24 24",
|
|
1722
|
+
fill: "none",
|
|
1723
|
+
stroke: "currentColor",
|
|
1724
|
+
"stroke-width": "2",
|
|
1725
|
+
"stroke-linecap": "round",
|
|
1726
|
+
"stroke-linejoin": "round"
|
|
1727
|
+
}, [j("rect", {
|
|
1728
|
+
x: "9",
|
|
1729
|
+
y: "9",
|
|
1730
|
+
width: "13",
|
|
1731
|
+
height: "13",
|
|
1732
|
+
rx: "2",
|
|
1733
|
+
ry: "2"
|
|
1734
|
+
}), j("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })], -1)]], 8, ii),
|
|
1735
|
+
e.readOnly ? k("", !0) : (z(), A("button", {
|
|
1736
|
+
key: 0,
|
|
1737
|
+
class: "docx-hyperlink-popup__btn",
|
|
1738
|
+
title: U(n)("hyperlinkPopup.editLink"),
|
|
1739
|
+
onClick: Y(m, ["prevent"])
|
|
1740
|
+
}, [...r[8] ||= [j("svg", {
|
|
1741
|
+
width: "18",
|
|
1742
|
+
height: "18",
|
|
1743
|
+
viewBox: "0 0 24 24",
|
|
1744
|
+
fill: "none",
|
|
1745
|
+
stroke: "currentColor",
|
|
1746
|
+
"stroke-width": "2",
|
|
1747
|
+
"stroke-linecap": "round",
|
|
1748
|
+
"stroke-linejoin": "round"
|
|
1749
|
+
}, [j("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), j("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })], -1)]], 8, ai)),
|
|
1750
|
+
e.readOnly ? k("", !0) : (z(), A("button", {
|
|
1751
|
+
key: 1,
|
|
1752
|
+
class: "docx-hyperlink-popup__btn",
|
|
1753
|
+
title: U(n)("hyperlinkPopup.removeLink"),
|
|
1754
|
+
onClick: r[1] ||= Y((e) => t.$emit("remove"), ["prevent"])
|
|
1755
|
+
}, [...r[9] ||= [oe("<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-084b4288><path d=\"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71\" data-v-084b4288></path><path d=\"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71\" data-v-084b4288></path><line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"5\" data-v-084b4288></line><line x1=\"2\" y1=\"8\" x2=\"5\" y2=\"8\" data-v-084b4288></line><line x1=\"16\" y1=\"19\" x2=\"16\" y2=\"22\" data-v-084b4288></line><line x1=\"19\" y1=\"16\" x2=\"22\" y2=\"16\" data-v-084b4288></line></svg>", 1)]], 8, oi))
|
|
1756
|
+
], 64))], 38)) : k("", !0);
|
|
1757
|
+
}
|
|
1758
|
+
}), [["__scopeId", "data-v-084b4288"]]);
|
|
1759
|
+
//#endregion
|
|
1760
|
+
//#region src/composables/useFileIO.ts
|
|
1761
|
+
function pi(e) {
|
|
1762
|
+
let t = B(null), n = B(null);
|
|
1763
|
+
function r(t) {
|
|
1764
|
+
let n = t.target, r = n.files?.[0], i = e.getActiveView();
|
|
1765
|
+
r && i && Ct(i, r, { onError: (t) => e.emit("error", t instanceof Error ? t : /* @__PURE__ */ Error("Failed to insert image")) }), n.value = "";
|
|
1766
|
+
}
|
|
1767
|
+
async function i() {
|
|
1768
|
+
await e.nextTick(), e.extractCommentsAndChanges(), e.emit("ready");
|
|
1769
|
+
}
|
|
1770
|
+
async function a(t) {
|
|
1771
|
+
if (e.onOpen) {
|
|
1772
|
+
let n = t.target, r = n.files?.[0];
|
|
1773
|
+
if (n.value = "", !r) return;
|
|
1774
|
+
try {
|
|
1775
|
+
await e.onOpen(r);
|
|
1776
|
+
} catch (t) {
|
|
1777
|
+
e.emit("error", t instanceof Error ? t : /* @__PURE__ */ Error("Failed to open document"));
|
|
1778
|
+
}
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
try {
|
|
1782
|
+
let n = await Ge(t);
|
|
1783
|
+
if (!n) return;
|
|
1784
|
+
await e.loadBuffer(n.buffer), e.emit("update:document", e.getDocument()), e.emit("rename", n.name), await i();
|
|
1785
|
+
} catch (t) {
|
|
1786
|
+
e.emit("error", t instanceof Error ? t : /* @__PURE__ */ Error("Failed to open document"));
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
function o(t) {
|
|
1790
|
+
e.onDocumentNameChange?.(t), e.emit("rename", t);
|
|
1791
|
+
}
|
|
1792
|
+
async function s() {
|
|
1793
|
+
let t = await e.saveBlob();
|
|
1794
|
+
if (!t) return;
|
|
1795
|
+
let n = (e.documentName() ?? "").trim() || "document", r = URL.createObjectURL(t), i = window.document.createElement("a");
|
|
1796
|
+
i.href = r, i.download = `${n.replace(/\.docx$/i, "")}.docx`, i.click(), setTimeout(() => URL.revokeObjectURL(r), 0);
|
|
1797
|
+
}
|
|
1798
|
+
async function c(t) {
|
|
1799
|
+
await e.loadBuffer(t), e.emit("update:document", e.getDocument()), await i();
|
|
1800
|
+
}
|
|
1801
|
+
function l(t) {
|
|
1802
|
+
e.loadParsedDocument(t), e.emit("update:document", t), i();
|
|
1803
|
+
}
|
|
1804
|
+
async function u() {
|
|
1805
|
+
let t = await e.saveBlob();
|
|
1806
|
+
return t ? t.arrayBuffer() : null;
|
|
1807
|
+
}
|
|
1808
|
+
return {
|
|
1809
|
+
docxInputRef: t,
|
|
1810
|
+
imageInputRef: n,
|
|
1811
|
+
handleImageFileChange: r,
|
|
1812
|
+
handleDocxFileChange: a,
|
|
1813
|
+
handleDocumentNameChange: o,
|
|
1814
|
+
downloadCurrentDocument: s,
|
|
1815
|
+
emitReadyAfterSidebarStateRefresh: i,
|
|
1816
|
+
loadDocumentBuffer: c,
|
|
1817
|
+
loadDocument: l,
|
|
1818
|
+
save: u
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
//#endregion
|
|
1822
|
+
//#region src/composables/useHyperlinkManagement.ts
|
|
1823
|
+
function mi(e) {
|
|
1824
|
+
let t = B(null);
|
|
1825
|
+
function n(t) {
|
|
1826
|
+
let n = e.editorView.value;
|
|
1827
|
+
if (!n) return;
|
|
1828
|
+
let r = e.getCommands(), { empty: i } = n.state.selection, a = t.bookmark ? `#${t.bookmark}` : t.url;
|
|
1829
|
+
if (a) {
|
|
1830
|
+
if (i && t.displayText) {
|
|
1831
|
+
let e = r.insertHyperlink;
|
|
1832
|
+
e && e(t.displayText, a, t.tooltip || void 0)(n.state, (e) => n.dispatch(e), n);
|
|
1833
|
+
} else {
|
|
1834
|
+
let e = r.setHyperlink;
|
|
1835
|
+
e && e(a, t.tooltip || void 0)(n.state, (e) => n.dispatch(e), n);
|
|
1836
|
+
}
|
|
1837
|
+
n.focus();
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
function r() {
|
|
1841
|
+
let t = e.editorView.value;
|
|
1842
|
+
if (!t) return;
|
|
1843
|
+
let n = e.getCommands().removeHyperlink;
|
|
1844
|
+
n && n()(t.state, (e) => t.dispatch(e), t), t.focus();
|
|
1845
|
+
}
|
|
1846
|
+
function i(e) {
|
|
1847
|
+
window.open(e, "_blank", "noopener,noreferrer"), t.value = null;
|
|
1848
|
+
}
|
|
1849
|
+
function a(n, r) {
|
|
1850
|
+
let i = e.editorView.value;
|
|
1851
|
+
if (!i) return;
|
|
1852
|
+
let a = Ze(i.state);
|
|
1853
|
+
if (!a) {
|
|
1854
|
+
t.value = null;
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
let o = i.state.schema.marks.hyperlink, { $from: s } = i.state.selection, c = o.create({
|
|
1858
|
+
href: r,
|
|
1859
|
+
tooltip: a.mark.attrs.tooltip
|
|
1860
|
+
}), l = s.marks().filter((e) => e.type !== o), u = i.state.schema.text(n, [...l, c]), d = i.state.tr.replaceWith(a.start, a.end, u);
|
|
1861
|
+
i.dispatch(d.scrollIntoView()), t.value = null, i.focus();
|
|
1862
|
+
}
|
|
1863
|
+
function o() {
|
|
1864
|
+
let n = e.editorView.value;
|
|
1865
|
+
if (!n) return;
|
|
1866
|
+
let r = Ze(n.state, t.value?.href);
|
|
1867
|
+
if (!r) {
|
|
1868
|
+
t.value = null;
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
let i = n.state.schema.marks.hyperlink, a = n.state.tr.removeMark(r.start, r.end, i);
|
|
1872
|
+
n.dispatch(a.scrollIntoView()), t.value = null, n.focus();
|
|
1873
|
+
}
|
|
1874
|
+
return {
|
|
1875
|
+
hyperlinkPopupData: t,
|
|
1876
|
+
handleHyperlinkSubmit: n,
|
|
1877
|
+
handleHyperlinkRemove: r,
|
|
1878
|
+
handleHyperlinkPopupNavigate: i,
|
|
1879
|
+
handleHyperlinkPopupEdit: a,
|
|
1880
|
+
handleHyperlinkPopupRemove: o
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
//#endregion
|
|
1884
|
+
//#region src/composables/useFormattingActions.ts
|
|
1885
|
+
function hi(e) {
|
|
1886
|
+
let t = () => e.activeView?.value ?? e.editorView.value;
|
|
1887
|
+
function n() {
|
|
1888
|
+
let e = t();
|
|
1889
|
+
e && (Xe(e.state, e.dispatch, e), e.focus());
|
|
1890
|
+
}
|
|
1891
|
+
function r(n) {
|
|
1892
|
+
let r = t();
|
|
1893
|
+
if (!r) return;
|
|
1894
|
+
let i = e.getDocument(), a = i?.package?.styles;
|
|
1895
|
+
if (a) {
|
|
1896
|
+
let e = Mt(a).resolveParagraphStyle(n);
|
|
1897
|
+
Dt(n, {
|
|
1898
|
+
paragraphFormatting: e.paragraphFormatting,
|
|
1899
|
+
runFormatting: e.runFormatting,
|
|
1900
|
+
numbering: i?.package?.numbering ? Nt(i.package.numbering) : null
|
|
1901
|
+
})(r.state, (e) => r.dispatch(e));
|
|
1902
|
+
} else Dt(n)(r.state, (e) => r.dispatch(e));
|
|
1903
|
+
r.focus();
|
|
1904
|
+
}
|
|
1905
|
+
function i() {
|
|
1906
|
+
let t = e.editorView.value;
|
|
1907
|
+
t && (Pt(t.state, (e) => t.dispatch(e), t), t.focus());
|
|
1908
|
+
}
|
|
1909
|
+
function a() {
|
|
1910
|
+
let t = e.editorView.value;
|
|
1911
|
+
t && (It(t.state, (e) => t.dispatch(e), t), t.focus());
|
|
1912
|
+
}
|
|
1913
|
+
function o() {
|
|
1914
|
+
let t = e.editorView.value;
|
|
1915
|
+
t && (Ft(t.state, (e) => t.dispatch(e), t), t.focus());
|
|
1916
|
+
}
|
|
1917
|
+
function s(e) {
|
|
1918
|
+
let n = t();
|
|
1919
|
+
if (!n) return;
|
|
1920
|
+
let { from: r } = n.state.selection, i = n.state.tr.insertText(e, r);
|
|
1921
|
+
n.dispatch(i.scrollIntoView()), n.focus();
|
|
1922
|
+
}
|
|
1923
|
+
function c(t) {
|
|
1924
|
+
let n = e.editorView.value;
|
|
1925
|
+
return n ? Lt(n, t) : !1;
|
|
1926
|
+
}
|
|
1927
|
+
function l(t) {
|
|
1928
|
+
let n = e.editorView.value;
|
|
1929
|
+
if (!n) return !1;
|
|
1930
|
+
let r = e.getDocument();
|
|
1931
|
+
return zt(n, t, {
|
|
1932
|
+
styleResolver: r?.package?.styles ? Mt(r.package.styles) : null,
|
|
1933
|
+
numbering: r?.package?.numbering ? Nt(r.package.numbering) : null
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
function u(t) {
|
|
1937
|
+
let n = e.editorView.value;
|
|
1938
|
+
return n ? Rt(n, t) : !1;
|
|
1939
|
+
}
|
|
1940
|
+
return {
|
|
1941
|
+
handleClearFormatting: n,
|
|
1942
|
+
handleApplyStyle: r,
|
|
1943
|
+
handleInsertPageBreak: i,
|
|
1944
|
+
handleInsertSectionBreakNextPage: a,
|
|
1945
|
+
handleInsertSectionBreakContinuous: o,
|
|
1946
|
+
handleInsertSymbol: s,
|
|
1947
|
+
applyFormatting: c,
|
|
1948
|
+
setParagraphStyle: l,
|
|
1949
|
+
insertBreak: u
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region src/composables/usePageSetupControls.ts
|
|
1954
|
+
function gi(e) {
|
|
1955
|
+
function t(t) {
|
|
1956
|
+
let n = e.getDocument();
|
|
1957
|
+
if (!n?.package?.document) return;
|
|
1958
|
+
let r = n.package.document.finalSectionProperties ?? {};
|
|
1959
|
+
n.package.document.finalSectionProperties = {
|
|
1960
|
+
...r,
|
|
1961
|
+
...t
|
|
1962
|
+
}, e.stateTick.value++, e.reLayout(), e.emit("change", n);
|
|
1963
|
+
}
|
|
1964
|
+
function n(n, r) {
|
|
1965
|
+
e.readOnly.value || t({ [n]: r });
|
|
1966
|
+
}
|
|
1967
|
+
function r(e) {
|
|
1968
|
+
n("marginLeft", e);
|
|
1969
|
+
}
|
|
1970
|
+
function i(e) {
|
|
1971
|
+
n("marginRight", e);
|
|
1972
|
+
}
|
|
1973
|
+
function a(e) {
|
|
1974
|
+
n("marginTop", e);
|
|
1975
|
+
}
|
|
1976
|
+
function o(e) {
|
|
1977
|
+
n("marginBottom", e);
|
|
1978
|
+
}
|
|
1979
|
+
function s(t) {
|
|
1980
|
+
let n = e.editorView.value;
|
|
1981
|
+
n && At(t)(n.state, n.dispatch);
|
|
1982
|
+
}
|
|
1983
|
+
function c(t) {
|
|
1984
|
+
let n = e.editorView.value;
|
|
1985
|
+
n && jt(t)(n.state, n.dispatch);
|
|
1986
|
+
}
|
|
1987
|
+
function l(t) {
|
|
1988
|
+
let n = e.editorView.value;
|
|
1989
|
+
n && (t < 0 ? kt(-t, !0)(n.state, n.dispatch) : kt(t, !1)(n.state, n.dispatch));
|
|
1990
|
+
}
|
|
1991
|
+
function u(t) {
|
|
1992
|
+
let n = e.editorView.value;
|
|
1993
|
+
n && Ot(t)(n.state, n.dispatch);
|
|
1994
|
+
}
|
|
1995
|
+
return {
|
|
1996
|
+
handlePageSetupApply: t,
|
|
1997
|
+
handleLeftMarginChange: r,
|
|
1998
|
+
handleRightMarginChange: i,
|
|
1999
|
+
handleTopMarginChange: a,
|
|
2000
|
+
handleBottomMarginChange: o,
|
|
2001
|
+
handleIndentLeftChange: s,
|
|
2002
|
+
handleIndentRightChange: c,
|
|
2003
|
+
handleFirstLineIndentChange: l,
|
|
2004
|
+
handleTabStopRemove: u
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/composables/useWatermarkControls.ts
|
|
2009
|
+
function _i(e) {
|
|
2010
|
+
let t = B(!1), n = D(() => {
|
|
2011
|
+
e.stateTick.value;
|
|
2012
|
+
let t = e.editorView.value;
|
|
2013
|
+
return t ? St(t.state) ?? void 0 : void 0;
|
|
2014
|
+
});
|
|
2015
|
+
function r(t) {
|
|
2016
|
+
if (e.readOnly.value) return;
|
|
2017
|
+
let n = e.editorView.value;
|
|
2018
|
+
n && (Et(t)(n.state, n.dispatch), e.stateTick.value++, n.focus());
|
|
2019
|
+
}
|
|
2020
|
+
return {
|
|
2021
|
+
showWatermark: t,
|
|
2022
|
+
currentWatermark: n,
|
|
2023
|
+
handleWatermarkApply: r
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
//#endregion
|
|
2027
|
+
//#region src/composables/useOutlineSidebar.ts
|
|
2028
|
+
function vi(e) {
|
|
2029
|
+
function t() {
|
|
2030
|
+
if (!e.showOutline.value) {
|
|
2031
|
+
let t = e.editorView.value;
|
|
2032
|
+
t && (e.outlineHeadings.value = Bt(t.state.doc));
|
|
2033
|
+
}
|
|
2034
|
+
e.showOutline.value = !e.showOutline.value;
|
|
2035
|
+
}
|
|
2036
|
+
function n(t) {
|
|
2037
|
+
let n = e.editorView.value;
|
|
2038
|
+
if (!n) return;
|
|
2039
|
+
let r = n.state.doc.resolve(Math.min(t + 1, n.state.doc.content.size)), i = _e.near(r);
|
|
2040
|
+
n.dispatch(n.state.tr.setSelection(i)), e.scrollToVisiblePosition(t), n.focus();
|
|
2041
|
+
}
|
|
2042
|
+
function r() {
|
|
2043
|
+
e.showSidebar.value || e.extractCommentsAndChanges(), e.showSidebar.value = !e.showSidebar.value;
|
|
2044
|
+
}
|
|
2045
|
+
function i(t) {
|
|
2046
|
+
let n = t.target;
|
|
2047
|
+
n && (n.closest(".paged-editor__pages") || n.closest(".unified-sidebar") || n.closest(".docx-comment-margin-markers") || (e.activeSidebarItem.value = null));
|
|
2048
|
+
}
|
|
2049
|
+
return {
|
|
2050
|
+
handleToggleOutline: t,
|
|
2051
|
+
handleOutlineNavigate: n,
|
|
2052
|
+
handleToggleSidebar: r,
|
|
2053
|
+
handleEditorScrollMouseDown: i
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
//#endregion
|
|
2057
|
+
//#region src/composables/useKeyboardShortcuts.ts
|
|
2058
|
+
function yi(e) {
|
|
2059
|
+
function t(t) {
|
|
2060
|
+
if (t.key === "F1") {
|
|
2061
|
+
t.preventDefault(), e.showKeyboardShortcuts.value = !0;
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
if (e.handleZoomKeyDown(t), t.ctrlKey || t.metaKey) {
|
|
2065
|
+
if (t.key === "o") {
|
|
2066
|
+
if (!e.showFileOpen?.() || !e.onOpenDocument) return;
|
|
2067
|
+
t.preventDefault(), e.onOpenDocument();
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
e.disableFindReplaceShortcuts?.() && (t.key === "f" || t.key === "h") || (t.key === "f" || t.key === "h" ? (t.preventDefault(), e.showFindReplace.value = !0) : t.key === "k" ? (t.preventDefault(), e.showHyperlink.value = !0) : t.key === "/" && (t.preventDefault(), e.showKeyboardShortcuts.value = !e.showKeyboardShortcuts.value));
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
return R(() => window.addEventListener("keydown", t)), L(() => window.removeEventListener("keydown", t)), { handleKeyDown: t };
|
|
2074
|
+
}
|
|
2075
|
+
//#endregion
|
|
2076
|
+
//#region src/composables/useCommentManagement.ts
|
|
2077
|
+
function bi(e) {
|
|
2078
|
+
let t = () => U(e.author) ?? "User";
|
|
2079
|
+
function n(t) {
|
|
2080
|
+
e.comments.value = t, e.commentCallbacks?.onCommentsChange?.(t);
|
|
2081
|
+
}
|
|
2082
|
+
function r() {
|
|
2083
|
+
qt(e.commentIdAllocator, e.getDocument()?.package?.document?.comments, e.editorView.value);
|
|
2084
|
+
}
|
|
2085
|
+
function i(t, n, i) {
|
|
2086
|
+
return r(), Wt(e.commentIdAllocator, t, n, i);
|
|
2087
|
+
}
|
|
2088
|
+
function a(t) {
|
|
2089
|
+
let i = e.getDocument(), a = e.editorView.value;
|
|
2090
|
+
if (!i?.package?.document || !a) return null;
|
|
2091
|
+
i.package.document.comments || (i.package.document.comments = []), r();
|
|
2092
|
+
let o = Ht(a, t, e.commentIdAllocator);
|
|
2093
|
+
return o ? (i.package.document.comments.push(o), n([...i.package.document.comments]), e.showSidebar.value = !0, e.emit("change", i), e.contentChangeSubscribers.forEach((e) => e(i)), o.id) : null;
|
|
2094
|
+
}
|
|
2095
|
+
function o(t, r, a) {
|
|
2096
|
+
let o = e.getDocument();
|
|
2097
|
+
if (!o?.package?.document?.comments || !o.package.document.comments.some((e) => e.id === t)) return null;
|
|
2098
|
+
let s = i(r, a, t);
|
|
2099
|
+
return o.package.document.comments.push(s), n([...o.package.document.comments]), e.emit("change", o), e.contentChangeSubscribers.forEach((e) => e(o)), s.id;
|
|
2100
|
+
}
|
|
2101
|
+
function s(t) {
|
|
2102
|
+
let r = e.getDocument();
|
|
2103
|
+
if (!r?.package?.document?.comments) return;
|
|
2104
|
+
let i = r.package.document.comments.find((e) => e.id === t);
|
|
2105
|
+
i && (i.done = !0, n([...r.package.document.comments]), e.emit("change", r), e.contentChangeSubscribers.forEach((e) => e(r)));
|
|
2106
|
+
}
|
|
2107
|
+
function c(t) {
|
|
2108
|
+
let n = e.editorView.value;
|
|
2109
|
+
if (!n) return !1;
|
|
2110
|
+
r();
|
|
2111
|
+
let i = Ut(n, t, e.commentIdAllocator);
|
|
2112
|
+
return i && (e.extractCommentsAndChanges(), e.showSidebar.value = !0), i;
|
|
2113
|
+
}
|
|
2114
|
+
function l(n, r) {
|
|
2115
|
+
let i = e.getDocument(), a = i?.package?.document?.comments?.find((e) => e.id === n), s = o(n, r, t());
|
|
2116
|
+
if (s == null || !a) return;
|
|
2117
|
+
let c = i?.package?.document?.comments?.find((e) => e.id === s);
|
|
2118
|
+
c && e.commentCallbacks?.onCommentReply?.(c, a);
|
|
2119
|
+
}
|
|
2120
|
+
function u(t) {
|
|
2121
|
+
let n = e.getDocument()?.package?.document?.comments?.find((e) => e.id === t);
|
|
2122
|
+
s(t), n && e.commentCallbacks?.onCommentResolve?.({ ...n });
|
|
2123
|
+
}
|
|
2124
|
+
function d(t) {
|
|
2125
|
+
let r = e.getDocument();
|
|
2126
|
+
if (!r?.package?.document?.comments) return;
|
|
2127
|
+
let i = r.package.document.comments.find((e) => e.id === t);
|
|
2128
|
+
i && (i.done = !1), n([...r.package.document.comments]), e.emit("change", r);
|
|
2129
|
+
}
|
|
2130
|
+
function f(t) {
|
|
2131
|
+
let r = e.getDocument();
|
|
2132
|
+
if (!r?.package?.document?.comments) return;
|
|
2133
|
+
let i = r.package.document.comments.find((e) => e.id === t);
|
|
2134
|
+
r.package.document.comments = r.package.document.comments.filter((e) => e.id !== t && e.parentId !== t), n([...r.package.document.comments]), i && e.commentCallbacks?.onCommentDelete?.(i), e.emit("change", r);
|
|
2135
|
+
}
|
|
2136
|
+
function p(t, n) {
|
|
2137
|
+
let r = e.editorView.value;
|
|
2138
|
+
r && (bt(t, n)(r.state, r.dispatch), e.extractCommentsAndChanges(), r.focus());
|
|
2139
|
+
}
|
|
2140
|
+
function m(t, n) {
|
|
2141
|
+
let r = e.editorView.value;
|
|
2142
|
+
r && (wt(t, n)(r.state, r.dispatch), e.extractCommentsAndChanges(), r.focus());
|
|
2143
|
+
}
|
|
2144
|
+
function h(t) {
|
|
2145
|
+
let n = e.getHfPmViews?.(), r = null;
|
|
2146
|
+
if (n) for (let e of n.values()) {
|
|
2147
|
+
let { entries: n } = Vt(e.state);
|
|
2148
|
+
if (n.some((e) => e.revisionId === t || e.insertionRevisionId === t || e.coalescedRevisionIds?.includes(t))) {
|
|
2149
|
+
r = e;
|
|
2150
|
+
break;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
let i = r || e.editorView.value;
|
|
2154
|
+
i && (xt(t)(i.state, i.dispatch), e.extractCommentsAndChanges(), i.focus());
|
|
2155
|
+
}
|
|
2156
|
+
function g(t) {
|
|
2157
|
+
let n = e.getHfPmViews?.(), r = null;
|
|
2158
|
+
if (n) for (let e of n.values()) {
|
|
2159
|
+
let { entries: n } = Vt(e.state);
|
|
2160
|
+
if (n.some((e) => e.revisionId === t || e.insertionRevisionId === t || e.coalescedRevisionIds?.includes(t))) {
|
|
2161
|
+
r = e;
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
let i = r || e.editorView.value;
|
|
2166
|
+
i && (Tt(t)(i.state, i.dispatch), e.extractCommentsAndChanges(), i.focus());
|
|
2167
|
+
}
|
|
2168
|
+
function _(r, a) {
|
|
2169
|
+
let o = e.getDocument();
|
|
2170
|
+
if (!o?.package?.document) return;
|
|
2171
|
+
o.package.document.comments || (o.package.document.comments = []);
|
|
2172
|
+
let s = i(a, t(), r);
|
|
2173
|
+
o.package.document.comments.push(s), n([...o.package.document.comments]), e.emit("change", o);
|
|
2174
|
+
}
|
|
2175
|
+
return {
|
|
2176
|
+
addComment: a,
|
|
2177
|
+
replyToComment: o,
|
|
2178
|
+
resolveComment: s,
|
|
2179
|
+
proposeChange: c,
|
|
2180
|
+
handleCommentReply: l,
|
|
2181
|
+
handleCommentResolve: u,
|
|
2182
|
+
handleCommentUnresolve: d,
|
|
2183
|
+
handleCommentDelete: f,
|
|
2184
|
+
handleAcceptChange: p,
|
|
2185
|
+
handleRejectChange: m,
|
|
2186
|
+
handleAcceptChangeById: h,
|
|
2187
|
+
handleRejectChangeById: g,
|
|
2188
|
+
handleTrackedChangeReply: _
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
//#endregion
|
|
2192
|
+
//#region src/composables/useHostCallbacks.ts
|
|
2193
|
+
function xi(e, t) {
|
|
2194
|
+
return K(t, (t) => t && e.onEditorViewReady?.(t), { immediate: !0 }), { commentCallbacks: {
|
|
2195
|
+
onCommentAdd: (t) => e.onCommentAdd?.(t),
|
|
2196
|
+
onCommentResolve: (t) => e.onCommentResolve?.(t),
|
|
2197
|
+
onCommentDelete: (t) => e.onCommentDelete?.(t),
|
|
2198
|
+
onCommentReply: (t, n) => e.onCommentReply?.(t, n),
|
|
2199
|
+
onCommentsChange: (t) => e.onCommentsChange?.(t)
|
|
2200
|
+
} };
|
|
2201
|
+
}
|
|
2202
|
+
//#endregion
|
|
2203
|
+
//#region src/composables/useCommentLifecycle.ts
|
|
2204
|
+
function Si(e) {
|
|
2205
|
+
let t = B(null), n = B(null), r = B(null), i = B(!1);
|
|
2206
|
+
function a() {
|
|
2207
|
+
let t = e.getDocument(), n = e.editorView.value;
|
|
2208
|
+
if (!t || !n) return;
|
|
2209
|
+
e.comments.value = [...t.package?.document?.comments ?? []];
|
|
2210
|
+
let r = [...Vt(n.state).entries];
|
|
2211
|
+
if (e.getHfPmViews) {
|
|
2212
|
+
let t = e.getHfPmViews();
|
|
2213
|
+
for (let [e, n] of t.entries()) {
|
|
2214
|
+
let t = Vt(n.state);
|
|
2215
|
+
for (let n of t.entries) n.hfRid = e, r.push(n);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
e.trackedChanges.value = r, !i.value && (e.comments.value.length > 0 || e.trackedChanges.value.length > 0) && (e.showSidebar.value = !0, i.value = !0);
|
|
2219
|
+
}
|
|
2220
|
+
function o() {
|
|
2221
|
+
e.stateTick.value;
|
|
2222
|
+
let n = e.editorView.value;
|
|
2223
|
+
if (!n || e.isAddingComment.value || e.readOnly.value) {
|
|
2224
|
+
t.value = null;
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
let { from: r, to: i } = n.state.selection;
|
|
2228
|
+
if (r === i) {
|
|
2229
|
+
t.value = null;
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
let a = e.pagesRef.value, o = e.pagesViewportRef.value;
|
|
2233
|
+
if (!a || !o) {
|
|
2234
|
+
t.value = null;
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2237
|
+
let s = o.getBoundingClientRect(), c = an(a, r);
|
|
2238
|
+
if (!c) {
|
|
2239
|
+
t.value = null;
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
let l = c.getBoundingClientRect().top - s.top + o.scrollTop, u = a.querySelector(".layout-page");
|
|
2243
|
+
if (!u) {
|
|
2244
|
+
t.value = null;
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2247
|
+
t.value = {
|
|
2248
|
+
top: l,
|
|
2249
|
+
left: u.getBoundingClientRect().right - s.left + 8
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
function s() {
|
|
2253
|
+
e.stateTick.value;
|
|
2254
|
+
let t = e.editorView.value;
|
|
2255
|
+
if (!t) return;
|
|
2256
|
+
let n = t.state.selection.$from, r = [
|
|
2257
|
+
...t.state.storedMarks ?? [],
|
|
2258
|
+
...n.nodeAfter?.marks ?? [],
|
|
2259
|
+
...n.nodeBefore?.marks ?? [],
|
|
2260
|
+
...n.marks()
|
|
2261
|
+
], i = null;
|
|
2262
|
+
for (let t of r) {
|
|
2263
|
+
if (t.type.name === "comment" && t.attrs.commentId != null) {
|
|
2264
|
+
let n = t.attrs.commentId;
|
|
2265
|
+
if (n === Gt || e.resolvedCommentIds.value.has(n)) continue;
|
|
2266
|
+
i = `comment-${n}`;
|
|
2267
|
+
break;
|
|
2268
|
+
}
|
|
2269
|
+
if ((t.type.name === "insertion" || t.type.name === "deletion") && t.attrs.revisionId != null) {
|
|
2270
|
+
let n = String(t.attrs.revisionId), r = e.trackedChanges.value.findIndex((e) => String(e.revisionId) === n || String(e.insertionRevisionId ?? "") === n);
|
|
2271
|
+
if (r >= 0) {
|
|
2272
|
+
i = `tc-${e.trackedChanges.value[r].revisionId}-${r}`;
|
|
2273
|
+
break;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
i && (e.showSidebar.value = !0), e.activeSidebarItem.value = i;
|
|
2278
|
+
}
|
|
2279
|
+
function c() {
|
|
2280
|
+
let i = e.editorView.value;
|
|
2281
|
+
if (!i) return;
|
|
2282
|
+
let { from: a, to: o } = i.state.selection;
|
|
2283
|
+
if (a === o) return;
|
|
2284
|
+
n.value = {
|
|
2285
|
+
from: a,
|
|
2286
|
+
to: o
|
|
2287
|
+
}, r.value = t.value?.top ?? null;
|
|
2288
|
+
let s = i.state.schema.marks.comment;
|
|
2289
|
+
if (s) {
|
|
2290
|
+
let e = i.state.tr.addMark(a, o, s.create({ commentId: Gt }));
|
|
2291
|
+
i.dispatch(e);
|
|
2292
|
+
}
|
|
2293
|
+
e.showSidebar.value = !0, e.isAddingComment.value = !0, t.value = null;
|
|
2294
|
+
}
|
|
2295
|
+
function l(t) {
|
|
2296
|
+
let i = e.getDocument(), a = e.editorView.value;
|
|
2297
|
+
if (!i?.package) return;
|
|
2298
|
+
i.package.document.comments || (i.package.document.comments = []), qt(e.commentIdAllocator, i.package.document.comments, a);
|
|
2299
|
+
let o = Wt(e.commentIdAllocator, t, U(e.author) ?? "User");
|
|
2300
|
+
i.package.document.comments.push(o), e.comments.value = [...i.package.document.comments], e.commentCallbacks?.onCommentsChange?.(e.comments.value), e.commentCallbacks?.onCommentAdd?.(o);
|
|
2301
|
+
let s = n.value;
|
|
2302
|
+
if (a && s && s.from !== s.to) {
|
|
2303
|
+
let e = a.state.schema.marks.comment;
|
|
2304
|
+
if (e) {
|
|
2305
|
+
let t = a.state.tr.removeMark(s.from, s.to, e);
|
|
2306
|
+
t = t.addMark(s.from, s.to, e.create({ commentId: o.id })), a.dispatch(t);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
n.value = null, r.value = null, e.isAddingComment.value = !1, e.emit("change", i);
|
|
2310
|
+
}
|
|
2311
|
+
function u() {
|
|
2312
|
+
let t = e.editorView.value, i = n.value;
|
|
2313
|
+
if (t && i && i.from !== i.to) {
|
|
2314
|
+
let e = t.state.schema.marks.comment;
|
|
2315
|
+
e && t.dispatch(t.state.tr.removeMark(i.from, i.to, e));
|
|
2316
|
+
}
|
|
2317
|
+
n.value = null, r.value = null, e.isAddingComment.value = !1;
|
|
2318
|
+
}
|
|
2319
|
+
function d(t) {
|
|
2320
|
+
e.showSidebar.value = !0;
|
|
2321
|
+
}
|
|
2322
|
+
K([
|
|
2323
|
+
e.stateTick,
|
|
2324
|
+
e.isAddingComment,
|
|
2325
|
+
e.zoom
|
|
2326
|
+
], () => o()), K(e.stateTick, () => s()), K(e.stateTick, () => a());
|
|
2327
|
+
let f = null;
|
|
2328
|
+
return R(() => {
|
|
2329
|
+
f = new ResizeObserver(() => o()), e.pagesRef.value && f.observe(e.pagesRef.value), window.addEventListener("resize", o);
|
|
2330
|
+
}), L(() => {
|
|
2331
|
+
f?.disconnect(), window.removeEventListener("resize", o);
|
|
2332
|
+
}), {
|
|
2333
|
+
floatingCommentBtn: t,
|
|
2334
|
+
pendingCommentRange: n,
|
|
2335
|
+
addCommentYPosition: r,
|
|
2336
|
+
sidebarAutoOpenedRef: i,
|
|
2337
|
+
extractCommentsAndChanges: a,
|
|
2338
|
+
handleAddComment: l,
|
|
2339
|
+
handleCancelAddComment: u,
|
|
2340
|
+
handleStartAddComment: c,
|
|
2341
|
+
handleMarkerClick: d,
|
|
2342
|
+
recomputeFloatingCommentBtn: o,
|
|
2343
|
+
recomputeActiveSidebarItem: s
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
//#endregion
|
|
2347
|
+
//#region src/composables/useImageActions.ts
|
|
2348
|
+
function Ci(e) {
|
|
2349
|
+
let t = fe(null), n = B(!1), r = D(() => {
|
|
2350
|
+
e.stateTick.value;
|
|
2351
|
+
let n = e.editorView.value, r = t.value;
|
|
2352
|
+
if (!n || !r) return null;
|
|
2353
|
+
let i = n.state.doc.nodeAt(r.pmPos);
|
|
2354
|
+
return !i || i.type.name !== "image" ? null : {
|
|
2355
|
+
wrapType: i.attrs.wrapType ?? "inline",
|
|
2356
|
+
displayMode: i.attrs.displayMode ?? "inline",
|
|
2357
|
+
cssFloat: i.attrs.cssFloat ?? null
|
|
2358
|
+
};
|
|
2359
|
+
});
|
|
2360
|
+
function i(n) {
|
|
2361
|
+
let r = e.editorView.value, i = t.value;
|
|
2362
|
+
if (!r || !i) return;
|
|
2363
|
+
let a = pt(n);
|
|
2364
|
+
if (!a) return;
|
|
2365
|
+
let o = r.state.doc.nodeAt(i.pmPos), s = e.getCommands(), c = o?.attrs.wrapType === "inline" && a !== "inline" ? { initialPositionEmu: ct(i.element, e.zoom.value) } : void 0, l = s.setImageWrapType?.(i.pmPos, a, c);
|
|
2366
|
+
l && (l(r.state, (e) => r.dispatch(e), r), r.focus());
|
|
2367
|
+
}
|
|
2368
|
+
function a(n) {
|
|
2369
|
+
let r = e.editorView.value, i = t.value;
|
|
2370
|
+
if (!r || !i) return;
|
|
2371
|
+
let a = r.state.doc.nodeAt(i.pmPos);
|
|
2372
|
+
if (!a || a.type.name !== "image") return;
|
|
2373
|
+
let o = a.attrs.transform || "", s = o.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/), c = s ? parseFloat(s[1]) : 0, l = /scaleX\(-1\)/.test(o), u = /scaleY\(-1\)/.test(o);
|
|
2374
|
+
n === "rotateCW" ? c = (c + 90) % 360 : n === "rotateCCW" ? c = (c - 90 + 360) % 360 : n === "flipH" ? l = !l : n === "flipV" && (u = !u);
|
|
2375
|
+
let d = [];
|
|
2376
|
+
c !== 0 && d.push(`rotate(${c}deg)`), l && d.push("scaleX(-1)"), u && d.push("scaleY(-1)");
|
|
2377
|
+
let f = d.length > 0 ? d.join(" ") : null, p = r.state.tr.setNodeMarkup(i.pmPos, void 0, {
|
|
2378
|
+
...a.attrs,
|
|
2379
|
+
transform: f
|
|
2380
|
+
});
|
|
2381
|
+
r.dispatch(p.scrollIntoView()), r.focus();
|
|
2382
|
+
}
|
|
2383
|
+
return {
|
|
2384
|
+
selectedImage: t,
|
|
2385
|
+
imageInteracting: n,
|
|
2386
|
+
imageToolbarContext: r,
|
|
2387
|
+
handleToolbarImageWrap: i,
|
|
2388
|
+
handleImageTransform: a
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
//#endregion
|
|
2392
|
+
//#region src/utils/imageClipboard.ts
|
|
2393
|
+
function wi(e, t, n) {
|
|
2394
|
+
let r = vt(e.state), i = e.state.schema.marks.insertion;
|
|
2395
|
+
if (!r || !i) return;
|
|
2396
|
+
let a = t.selection.from, o = a - n.nodeSize;
|
|
2397
|
+
o < 0 || t.addMark(o, a, i.create({
|
|
2398
|
+
revisionId: r.revisionId,
|
|
2399
|
+
author: r.author,
|
|
2400
|
+
date: r.date
|
|
2401
|
+
}));
|
|
2402
|
+
}
|
|
2403
|
+
function Ti(e, t) {
|
|
2404
|
+
return e.getBlob(t);
|
|
2405
|
+
}
|
|
2406
|
+
function Ei(e, t) {
|
|
2407
|
+
let n = e.state.doc.nodeAt(t);
|
|
2408
|
+
if (!n || n.type.name !== "image") return;
|
|
2409
|
+
let r = `<img src="${n.attrs.src}" data-pm-image="true" data-width="${n.attrs.width ?? ""}" data-height="${n.attrs.height ?? ""}" data-wrap-type="${n.attrs.wrapType ?? ""}" data-display-mode="${n.attrs.displayMode ?? ""}" data-rid="${n.attrs.rId ?? ""}" />`, i = new ClipboardItem({
|
|
2410
|
+
"text/html": new Blob([r], { type: "text/html" }),
|
|
2411
|
+
"text/plain": new Blob(["[image]"], { type: "text/plain" })
|
|
2412
|
+
});
|
|
2413
|
+
navigator.clipboard.write([i]).catch(() => {
|
|
2414
|
+
let e = document.createElement("textarea");
|
|
2415
|
+
e.value = r, document.body.appendChild(e), e.select(), document.execCommand("copy"), document.body.removeChild(e);
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
function Di(e) {
|
|
2419
|
+
return new Promise((t, n) => {
|
|
2420
|
+
let r = new FileReader();
|
|
2421
|
+
r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2424
|
+
function Oi(e) {
|
|
2425
|
+
return new Promise((t) => {
|
|
2426
|
+
let n = new Image();
|
|
2427
|
+
n.onload = () => t({
|
|
2428
|
+
width: n.naturalWidth,
|
|
2429
|
+
height: n.naturalHeight
|
|
2430
|
+
}), n.onerror = () => t({
|
|
2431
|
+
width: 200,
|
|
2432
|
+
height: 200
|
|
2433
|
+
}), n.src = e;
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
async function ki(e) {
|
|
2437
|
+
try {
|
|
2438
|
+
let t = await navigator.clipboard.read();
|
|
2439
|
+
for (let n of t) {
|
|
2440
|
+
let t = n.types.find((e) => e.startsWith("image/"));
|
|
2441
|
+
if (t) {
|
|
2442
|
+
let r = await Di(await Ti(n, t)), i = await Oi(r), a = i.width, o = i.height;
|
|
2443
|
+
a > 612 && (o = Math.round(612 / a * o), a = 612);
|
|
2444
|
+
let s = e.state.schema.nodes.image.create({
|
|
2445
|
+
src: r,
|
|
2446
|
+
width: a,
|
|
2447
|
+
height: o,
|
|
2448
|
+
rId: `rId_img_${Date.now()}`,
|
|
2449
|
+
wrapType: "inline",
|
|
2450
|
+
displayMode: "inline"
|
|
2451
|
+
}), c = e.state.tr.replaceSelectionWith(s);
|
|
2452
|
+
wi(e, c, s), e.dispatch(c);
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2455
|
+
if (n.types.includes("text/html")) {
|
|
2456
|
+
let t = await (await Ti(n, "text/html")).text(), r = t.match(/<img[^>]+src="([^"]+)"[^>]*>/i);
|
|
2457
|
+
if (r && r[1]) {
|
|
2458
|
+
let n = r[1], i = t.match(/data-width="(\d+)"/), a = t.match(/data-height="(\d+)"/), o = i ? Number(i[1]) : 200, s = a ? Number(a[1]) : 200, c = e.state.schema.nodes.image.create({
|
|
2459
|
+
src: n,
|
|
2460
|
+
width: o || 200,
|
|
2461
|
+
height: s || 200,
|
|
2462
|
+
rId: `rId_img_${Date.now()}`,
|
|
2463
|
+
wrapType: "inline",
|
|
2464
|
+
displayMode: "inline"
|
|
2465
|
+
}), l = e.state.tr.replaceSelectionWith(c);
|
|
2466
|
+
wi(e, l, c), e.dispatch(l);
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
if (n.types.includes("text/plain")) {
|
|
2471
|
+
let t = await (await Ti(n, "text/plain")).text();
|
|
2472
|
+
if (t && t !== "[image]") {
|
|
2473
|
+
let { from: n } = e.state.selection;
|
|
2474
|
+
e.dispatch(e.state.tr.insertText(t, n));
|
|
2475
|
+
}
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
} catch {
|
|
2480
|
+
let t = await navigator.clipboard?.readText();
|
|
2481
|
+
if (t) {
|
|
2482
|
+
let { from: n } = e.state.selection;
|
|
2483
|
+
e.dispatch(e.state.tr.insertText(t, n));
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
function Ai(e, t) {
|
|
2488
|
+
let n = e.state.doc.nodeAt(t);
|
|
2489
|
+
if (!n || n.type.name !== "image") return;
|
|
2490
|
+
let r = document.createElement("input");
|
|
2491
|
+
r.type = "file", r.accept = "image/*", r.onchange = async () => {
|
|
2492
|
+
let i = r.files?.[0];
|
|
2493
|
+
if (!i) return;
|
|
2494
|
+
let a = await Di(i), o = await Oi(a), s = n.attrs.width || o.width, c = n.attrs.height || o.height, l = Math.min(s / o.width, c / o.height), u = Math.round(o.width * l), d = Math.round(o.height * l);
|
|
2495
|
+
try {
|
|
2496
|
+
let r = e.state.tr.setNodeMarkup(t, void 0, {
|
|
2497
|
+
...n.attrs,
|
|
2498
|
+
src: a,
|
|
2499
|
+
width: u,
|
|
2500
|
+
height: d,
|
|
2501
|
+
rId: `rId_img_${Date.now()}`
|
|
2502
|
+
});
|
|
2503
|
+
e.dispatch(r);
|
|
2504
|
+
} catch {}
|
|
2505
|
+
}, r.click();
|
|
2506
|
+
}
|
|
2507
|
+
//#endregion
|
|
2508
|
+
//#region src/composables/useContextMenus.ts
|
|
2509
|
+
function ji(e) {
|
|
2510
|
+
let { t } = d(), n = B({
|
|
2511
|
+
isOpen: !1,
|
|
2512
|
+
position: {
|
|
2513
|
+
x: 0,
|
|
2514
|
+
y: 0
|
|
2515
|
+
},
|
|
2516
|
+
hasSelection: !1,
|
|
2517
|
+
inTable: !1,
|
|
2518
|
+
onImage: !1,
|
|
2519
|
+
canMergeCells: !1,
|
|
2520
|
+
canSplitCell: !1
|
|
2521
|
+
}), r = B(null), i = D(() => [
|
|
2522
|
+
{
|
|
2523
|
+
action: "cut",
|
|
2524
|
+
label: t("contextMenu.cut"),
|
|
2525
|
+
shortcut: t("contextMenu.cutShortcut")
|
|
2526
|
+
},
|
|
2527
|
+
{
|
|
2528
|
+
action: "copy",
|
|
2529
|
+
label: t("contextMenu.copy"),
|
|
2530
|
+
shortcut: t("contextMenu.copyShortcut")
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
action: "paste",
|
|
2534
|
+
label: t("contextMenu.paste"),
|
|
2535
|
+
shortcut: t("contextMenu.pasteShortcut"),
|
|
2536
|
+
dividerAfter: !0
|
|
2537
|
+
},
|
|
2538
|
+
{
|
|
2539
|
+
action: "delete",
|
|
2540
|
+
label: t("contextMenu.delete"),
|
|
2541
|
+
shortcut: t("contextMenu.deleteShortcut")
|
|
2542
|
+
}
|
|
2543
|
+
]);
|
|
2544
|
+
function a(t) {
|
|
2545
|
+
let i = e.editorView.value;
|
|
2546
|
+
if (!i) return;
|
|
2547
|
+
let a = t.target, o = ut(a);
|
|
2548
|
+
if (o) {
|
|
2549
|
+
let a = Number(o.dataset.pmStart);
|
|
2550
|
+
if (!isNaN(a)) {
|
|
2551
|
+
try {
|
|
2552
|
+
let e = ge.create(i.state.doc, a);
|
|
2553
|
+
i.dispatch(i.state.tr.setSelection(e));
|
|
2554
|
+
} catch {}
|
|
2555
|
+
e.selectedImage.value = {
|
|
2556
|
+
element: o,
|
|
2557
|
+
pmPos: a,
|
|
2558
|
+
width: o.offsetWidth,
|
|
2559
|
+
height: o.offsetHeight
|
|
2560
|
+
}, e.clearOverlay();
|
|
2561
|
+
let s = i.state.doc.nodeAt(a);
|
|
2562
|
+
if (s && s.type.name === "image") {
|
|
2563
|
+
let i = s.attrs.wrapType ?? "inline", c = s.attrs.cssFloat;
|
|
2564
|
+
r.value = {
|
|
2565
|
+
open: !0,
|
|
2566
|
+
position: {
|
|
2567
|
+
x: t.clientX,
|
|
2568
|
+
y: t.clientY
|
|
2569
|
+
},
|
|
2570
|
+
pmPos: a,
|
|
2571
|
+
currentWrapType: i,
|
|
2572
|
+
currentCssFloat: c ?? null,
|
|
2573
|
+
inlinePositionEmu: i === "inline" ? ct(o, e.zoom.value) : void 0
|
|
2574
|
+
}, n.value.isOpen = !1;
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
{
|
|
2580
|
+
let { from: n, to: r } = i.state.selection, a = e.resolvePos(t.clientX, t.clientY);
|
|
2581
|
+
if (a !== null && (a < n || a > r)) try {
|
|
2582
|
+
e.setPmSelection(a);
|
|
2583
|
+
} catch {}
|
|
2584
|
+
}
|
|
2585
|
+
let s = Qe(i.state), { empty: c } = i.state.selection;
|
|
2586
|
+
r.value &&= null, n.value = {
|
|
2587
|
+
isOpen: !0,
|
|
2588
|
+
position: {
|
|
2589
|
+
x: t.clientX,
|
|
2590
|
+
y: t.clientY
|
|
2591
|
+
},
|
|
2592
|
+
hasSelection: !c,
|
|
2593
|
+
inTable: s.isInTable,
|
|
2594
|
+
onImage: !!o,
|
|
2595
|
+
canMergeCells: !!s.hasMultiCellSelection,
|
|
2596
|
+
canSplitCell: !!s.canSplitCell
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function o(t) {
|
|
2600
|
+
let i = e.editorView.value, a = e.selectedImage.value;
|
|
2601
|
+
if (!i || !a) return;
|
|
2602
|
+
let o = i.state.doc.nodeAt(a.pmPos);
|
|
2603
|
+
if (!o || o.type.name !== "image") return;
|
|
2604
|
+
let s = o.attrs.wrapType ?? "inline", c = o.attrs.cssFloat;
|
|
2605
|
+
r.value = {
|
|
2606
|
+
open: !0,
|
|
2607
|
+
position: {
|
|
2608
|
+
x: t.clientX,
|
|
2609
|
+
y: t.clientY
|
|
2610
|
+
},
|
|
2611
|
+
pmPos: a.pmPos,
|
|
2612
|
+
currentWrapType: s,
|
|
2613
|
+
currentCssFloat: c ?? null,
|
|
2614
|
+
inlinePositionEmu: s === "inline" ? ct(a.element, e.zoom.value) : void 0
|
|
2615
|
+
}, n.value.isOpen = !1;
|
|
2616
|
+
}
|
|
2617
|
+
function s(t) {
|
|
2618
|
+
let n = e.editorView.value, i = r.value;
|
|
2619
|
+
if (!n || !i) return;
|
|
2620
|
+
let a = e.getCommands(), o = i.inlinePositionEmu && t !== "inline" ? { initialPositionEmu: i.inlinePositionEmu } : void 0, s = a.setImageWrapType?.(i.pmPos, t, o);
|
|
2621
|
+
s && (s(n.state, (e) => n.dispatch(e), n), n.focus());
|
|
2622
|
+
}
|
|
2623
|
+
function c(t) {
|
|
2624
|
+
let n = e.editorView.value;
|
|
2625
|
+
if (!n) return;
|
|
2626
|
+
let r = e.getCommands();
|
|
2627
|
+
switch (t) {
|
|
2628
|
+
case "cut":
|
|
2629
|
+
if (e.selectedImage.value) {
|
|
2630
|
+
Ei(n, e.selectedImage.value.pmPos);
|
|
2631
|
+
let t = e.selectedImage.value.pmPos, r = n.state.doc.nodeAt(t);
|
|
2632
|
+
r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
|
|
2633
|
+
} else n.focus(), document.execCommand("cut");
|
|
2634
|
+
break;
|
|
2635
|
+
case "copy":
|
|
2636
|
+
e.selectedImage.value ? Ei(n, e.selectedImage.value.pmPos) : (n.focus(), document.execCommand("copy"));
|
|
2637
|
+
break;
|
|
2638
|
+
case "paste":
|
|
2639
|
+
ki(n);
|
|
2640
|
+
break;
|
|
2641
|
+
case "pasteAsPlainText":
|
|
2642
|
+
navigator.clipboard.readText().then((e) => {
|
|
2643
|
+
e && n.dispatch(n.state.tr.insertText(e).scrollIntoView());
|
|
2644
|
+
}).catch(() => {});
|
|
2645
|
+
break;
|
|
2646
|
+
case "delete": {
|
|
2647
|
+
let { from: e, to: t } = n.state.selection;
|
|
2648
|
+
e !== t && n.dispatch(n.state.tr.delete(e, t));
|
|
2649
|
+
break;
|
|
2650
|
+
}
|
|
2651
|
+
case "selectAll": {
|
|
2652
|
+
let e = _e.create(n.state.doc, 0, n.state.doc.content.size);
|
|
2653
|
+
n.dispatch(n.state.tr.setSelection(e));
|
|
2654
|
+
break;
|
|
2655
|
+
}
|
|
2656
|
+
case "imageProperties":
|
|
2657
|
+
e.selectedImage.value && (e.showImageProperties.value = !0);
|
|
2658
|
+
break;
|
|
2659
|
+
case "replaceImage":
|
|
2660
|
+
e.selectedImage.value && Ai(n, e.selectedImage.value.pmPos);
|
|
2661
|
+
break;
|
|
2662
|
+
case "deleteImage":
|
|
2663
|
+
if (e.selectedImage.value) {
|
|
2664
|
+
let t = e.selectedImage.value.pmPos, r = n.state.doc.nodeAt(t);
|
|
2665
|
+
r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
|
|
2666
|
+
}
|
|
2667
|
+
break;
|
|
2668
|
+
case "addRowAbove":
|
|
2669
|
+
case "addRowBelow":
|
|
2670
|
+
case "deleteRow":
|
|
2671
|
+
case "addColumnLeft":
|
|
2672
|
+
case "addColumnRight":
|
|
2673
|
+
case "deleteColumn":
|
|
2674
|
+
case "mergeCells":
|
|
2675
|
+
case "splitCell":
|
|
2676
|
+
case "selectTable":
|
|
2677
|
+
case "deleteTable": {
|
|
2678
|
+
let e = r[t];
|
|
2679
|
+
e && e()(n.state, (e) => n.dispatch(e), n);
|
|
2680
|
+
break;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
n.focus();
|
|
2684
|
+
}
|
|
2685
|
+
return {
|
|
2686
|
+
contextMenu: n,
|
|
2687
|
+
imageContextMenu: r,
|
|
2688
|
+
imageContextMenuTextActions: i,
|
|
2689
|
+
handleContextMenu: a,
|
|
2690
|
+
handleSelectedImageContextMenu: o,
|
|
2691
|
+
handleImageWrapSelect: s,
|
|
2692
|
+
handleContextMenuAction: c
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
//#endregion
|
|
2696
|
+
//#region src/composables/usePagesPointer.ts
|
|
2697
|
+
var Mi = 500;
|
|
2698
|
+
function Ni(e) {
|
|
2699
|
+
let t = B(null), n = null;
|
|
2700
|
+
function r() {
|
|
2701
|
+
n !== null && (clearTimeout(n), n = null);
|
|
2702
|
+
}
|
|
2703
|
+
let i = fe(null), a = 0, o = null, s = 0, c = !1, l = null, u = Xt(), d = re({
|
|
2704
|
+
pagesContainer: e.pagesRef,
|
|
2705
|
+
onScrollExtendSelection: (e, t) => {
|
|
2706
|
+
if (!c || l === null) return;
|
|
2707
|
+
let n = m(e, t);
|
|
2708
|
+
n !== null && n !== l && g(l, n);
|
|
2709
|
+
}
|
|
2710
|
+
}), f = B({
|
|
2711
|
+
currentPage: 1,
|
|
2712
|
+
totalPages: 1,
|
|
2713
|
+
visible: !1
|
|
2714
|
+
}), p = null;
|
|
2715
|
+
function m(t, n) {
|
|
2716
|
+
return sn(e.pagesRef.value, e.editorView.value, t, n);
|
|
2717
|
+
}
|
|
2718
|
+
function h() {
|
|
2719
|
+
let t = i.value;
|
|
2720
|
+
if (t?.headerFooter && e.getHfPmView) {
|
|
2721
|
+
let n = e.getHfPmView(t.headerFooter);
|
|
2722
|
+
if (n) return n;
|
|
2723
|
+
}
|
|
2724
|
+
return e.editorView.value;
|
|
2725
|
+
}
|
|
2726
|
+
function g(e, t) {
|
|
2727
|
+
let n = h();
|
|
2728
|
+
if (n) try {
|
|
2729
|
+
let r = n.state.doc.resolve(e), i = t === void 0 ? r : n.state.doc.resolve(t), a = _e.between(r, i);
|
|
2730
|
+
n.dispatch(n.state.tr.setSelection(a));
|
|
2731
|
+
} catch {}
|
|
2732
|
+
}
|
|
2733
|
+
function _(t) {
|
|
2734
|
+
on(e.pagesRef.value, e.pagesViewportRef.value, t);
|
|
2735
|
+
}
|
|
2736
|
+
function v(t) {
|
|
2737
|
+
cn(e.pagesRef.value, t, g, i.value?.position);
|
|
2738
|
+
}
|
|
2739
|
+
function y(t) {
|
|
2740
|
+
ln(e.pagesRef.value, t, g, i.value?.position);
|
|
2741
|
+
}
|
|
2742
|
+
function b(t) {
|
|
2743
|
+
let n = e.editorView.value;
|
|
2744
|
+
if (!n) return;
|
|
2745
|
+
let r = null;
|
|
2746
|
+
if (n.state.doc.descendants((e, n) => r === null ? (e.attrs?.bookmarks)?.some((e) => e.name === t) ? (r = n, !1) : !0 : !1), r !== null) {
|
|
2747
|
+
_(r);
|
|
2748
|
+
try {
|
|
2749
|
+
g(Math.min(r + 1, n.state.doc.content.size));
|
|
2750
|
+
} catch {
|
|
2751
|
+
g(r);
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
function ee(a) {
|
|
2756
|
+
if (e.readOnly.value || c) return;
|
|
2757
|
+
let o = e.pagesRef.value;
|
|
2758
|
+
if (!o) return;
|
|
2759
|
+
let s = e.pagesViewportRef.value;
|
|
2760
|
+
if (!s) return;
|
|
2761
|
+
let l = Yt({
|
|
2762
|
+
mouseX: a.clientX,
|
|
2763
|
+
mouseY: a.clientY,
|
|
2764
|
+
pagesContainer: o,
|
|
2765
|
+
target: a.target,
|
|
2766
|
+
hfEditMode: i.value?.position ?? null
|
|
2767
|
+
});
|
|
2768
|
+
if (!l) {
|
|
2769
|
+
n === null && (n = setTimeout(() => {
|
|
2770
|
+
t.value = null, n = null;
|
|
2771
|
+
}, Jt));
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
let u = e.zoom.value || 1, d = s.getBoundingClientRect();
|
|
2775
|
+
t.value = {
|
|
2776
|
+
type: l.type,
|
|
2777
|
+
x: (l.clientX - d.left) / u,
|
|
2778
|
+
y: (l.clientY - d.top) / u,
|
|
2779
|
+
cellPmPos: l.cellPmPos
|
|
2780
|
+
}, r();
|
|
2781
|
+
}
|
|
2782
|
+
function x(n) {
|
|
2783
|
+
n.preventDefault(), n.stopPropagation();
|
|
2784
|
+
let r = t.value, i = e.editorView.value;
|
|
2785
|
+
if (!r || !i) return;
|
|
2786
|
+
let a = i.state.tr.setSelection(_e.create(i.state.doc, r.cellPmPos + 1));
|
|
2787
|
+
i.dispatch(a);
|
|
2788
|
+
let o = e.getCommands(), s = r.type === "row" ? o.addRowBelow?.() : o.addColumnRight?.();
|
|
2789
|
+
s && (s(i.state, (e) => i.dispatch(e), i), t.value = null, i.focus());
|
|
2790
|
+
}
|
|
2791
|
+
function S(t) {
|
|
2792
|
+
let n = t.target?.closest("a[href]");
|
|
2793
|
+
if (!n) return;
|
|
2794
|
+
t.preventDefault();
|
|
2795
|
+
let r = n.getAttribute("href") || "";
|
|
2796
|
+
if (r.startsWith("#")) {
|
|
2797
|
+
let e = r.slice(1);
|
|
2798
|
+
e && b(e);
|
|
2799
|
+
return;
|
|
2800
|
+
}
|
|
2801
|
+
let i = h();
|
|
2802
|
+
if (i && i.state.selection.from !== i.state.selection.to) return;
|
|
2803
|
+
let a = e.pagesViewportRef.value;
|
|
2804
|
+
if (!a) return;
|
|
2805
|
+
let o = a.getBoundingClientRect(), s = n.getBoundingClientRect();
|
|
2806
|
+
e.hyperlinkPopupData.value = {
|
|
2807
|
+
href: r,
|
|
2808
|
+
displayText: n.textContent || "",
|
|
2809
|
+
tooltip: n.getAttribute("title") || void 0,
|
|
2810
|
+
position: {
|
|
2811
|
+
top: s.bottom - o.top + a.scrollTop + 4,
|
|
2812
|
+
left: s.left - o.left + a.scrollLeft
|
|
2813
|
+
}
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
function C(t) {
|
|
2817
|
+
let n = t.target, r = n.closest(".layout-page-header"), a = n.closest(".layout-page-footer"), o = r ?? a;
|
|
2818
|
+
if (!o) return;
|
|
2819
|
+
let s = r ? "header" : "footer", c = e.getDocument();
|
|
2820
|
+
if (!c?.package) return;
|
|
2821
|
+
let l = c.package.document?.sections?.[0]?.properties ?? c.package.document?.finalSectionProperties ?? null, u = s === "header" ? l?.headerReferences : l?.footerReferences, d = s === "header" ? c.package.headers : c.package.footers, f = (u?.find((e) => e.type === "default") ?? u?.find((e) => e.type === "first") ?? null)?.rId ?? null, p = f ? d?.get(f) ?? null : null;
|
|
2822
|
+
if (!p) {
|
|
2823
|
+
if (!l) return;
|
|
2824
|
+
let t = "default", n = `rId_new_${s}_${t}`, r = {
|
|
2825
|
+
type: s,
|
|
2826
|
+
hdrFtrType: t,
|
|
2827
|
+
content: [{
|
|
2828
|
+
type: "paragraph",
|
|
2829
|
+
content: []
|
|
2830
|
+
}]
|
|
2831
|
+
}, i = s === "header" ? "headers" : "footers", a = s === "header" ? "headerReferences" : "footerReferences", o = new Map(c.package[i] ?? []);
|
|
2832
|
+
o.set(n, r);
|
|
2833
|
+
let u = c.package.relationships, d = /* @__PURE__ */ new Set();
|
|
2834
|
+
for (let e of u?.values() ?? []) e.target && d.add(e.target);
|
|
2835
|
+
let m = 1;
|
|
2836
|
+
for (; d.has(`${s}${m}.xml`);) m++;
|
|
2837
|
+
let h = s === "header" ? "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", g = new Map(u);
|
|
2838
|
+
g.set(n, {
|
|
2839
|
+
id: n,
|
|
2840
|
+
type: h,
|
|
2841
|
+
target: `${s}${m}.xml`
|
|
2842
|
+
});
|
|
2843
|
+
let _ = {
|
|
2844
|
+
type: t,
|
|
2845
|
+
rId: n
|
|
2846
|
+
}, v = l && {
|
|
2847
|
+
...l,
|
|
2848
|
+
[a]: [...l[a] ?? [], _]
|
|
2849
|
+
}, y = {
|
|
2850
|
+
...c,
|
|
2851
|
+
package: {
|
|
2852
|
+
...c.package,
|
|
2853
|
+
[i]: o,
|
|
2854
|
+
relationships: g,
|
|
2855
|
+
document: c.package.document ? {
|
|
2856
|
+
...c.package.document,
|
|
2857
|
+
sections: c.package.document.sections?.map((e, t) => t === 0 ? {
|
|
2858
|
+
...e,
|
|
2859
|
+
properties: v ?? e.properties
|
|
2860
|
+
} : e),
|
|
2861
|
+
finalSectionProperties: c.package.document.finalSectionProperties === l ? v : c.package.document.finalSectionProperties
|
|
2862
|
+
} : c.package.document
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
f = n, p = r, e.setDocument?.(y), e.syncHfPMs?.(), e.reLayout(), e.emit("change", y);
|
|
2866
|
+
}
|
|
2867
|
+
let m = e.pagesViewportRef.value;
|
|
2868
|
+
if (!m) return;
|
|
2869
|
+
let h = o.getBoundingClientRect(), g = m.getBoundingClientRect(), _ = e.zoom.value || 1;
|
|
2870
|
+
i.value = {
|
|
2871
|
+
position: s,
|
|
2872
|
+
rId: f,
|
|
2873
|
+
headerFooter: p,
|
|
2874
|
+
targetRect: {
|
|
2875
|
+
top: (h.top - g.top + m.scrollTop) / _,
|
|
2876
|
+
left: (h.left - g.left + m.scrollLeft) / _,
|
|
2877
|
+
width: h.width / _,
|
|
2878
|
+
height: h.height / _
|
|
2879
|
+
}
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
function te(t) {
|
|
2883
|
+
let n = e.getDocument(), r = i.value;
|
|
2884
|
+
if (!n?.package || !r) return;
|
|
2885
|
+
let a = r.position === "header" ? n.package.headers : n.package.footers;
|
|
2886
|
+
if (!a || !r.rId) return;
|
|
2887
|
+
let o = a.get(r.rId);
|
|
2888
|
+
o && (o.content = t), e.syncHfPMs?.(), e.reLayout(), e.emit("change", n);
|
|
2889
|
+
}
|
|
2890
|
+
function ne() {
|
|
2891
|
+
let t = e.getDocument(), n = i.value;
|
|
2892
|
+
if (!t?.package || !n || !n.rId) {
|
|
2893
|
+
i.value = null;
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
2896
|
+
let r = n.position === "header" ? "headers" : "footers", a = n.position === "header" ? "headerReferences" : "footerReferences", o = n.rId, s = new Map(t.package[r] ?? []);
|
|
2897
|
+
s.delete(o);
|
|
2898
|
+
let c = (e) => ({
|
|
2899
|
+
...e,
|
|
2900
|
+
[a]: (e[a] ?? []).filter((e) => e.rId !== o)
|
|
2901
|
+
}), l = (e) => "sectionProperties" in e && e.sectionProperties ? {
|
|
2902
|
+
...e,
|
|
2903
|
+
sectionProperties: c(e.sectionProperties)
|
|
2904
|
+
} : e, u = t.package.document, d = {
|
|
2905
|
+
...t,
|
|
2906
|
+
package: {
|
|
2907
|
+
...t.package,
|
|
2908
|
+
[r]: s,
|
|
2909
|
+
document: u && {
|
|
2910
|
+
...u,
|
|
2911
|
+
content: u.content.map(l),
|
|
2912
|
+
sections: u.sections?.map((e) => ({
|
|
2913
|
+
...e,
|
|
2914
|
+
properties: c(e.properties)
|
|
2915
|
+
})),
|
|
2916
|
+
finalSectionProperties: u.finalSectionProperties ? c(u.finalSectionProperties) : u.finalSectionProperties
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
i.value = null, e.setDocument?.(d), e.syncHfPMs?.(), e.reLayout(), e.emit("change", d);
|
|
2921
|
+
}
|
|
2922
|
+
function w(t) {
|
|
2923
|
+
if (t.button !== 0 || e.imageInteracting.value) return;
|
|
2924
|
+
let n = e.editorView.value;
|
|
2925
|
+
if (!n) return;
|
|
2926
|
+
let r = t.target;
|
|
2927
|
+
i.value && (r.closest(".layout-page-header") || r.closest(".layout-page-footer") || r.closest(".hf-editor") || (i.value = null, n.focus()));
|
|
2928
|
+
let d = h() ?? n;
|
|
2929
|
+
if (!e.readOnly.value && e.tableResize.tryStartResize(t, d)) return;
|
|
2930
|
+
let f = ut(r);
|
|
2931
|
+
if (f) {
|
|
2932
|
+
t.preventDefault(), t.stopPropagation();
|
|
2933
|
+
let n = Number(f.dataset.pmStart);
|
|
2934
|
+
if (!isNaN(n)) {
|
|
2935
|
+
try {
|
|
2936
|
+
d.dispatch(d.state.tr.setSelection(ge.create(d.state.doc, n)));
|
|
2937
|
+
} catch {}
|
|
2938
|
+
e.selectedImage.value = {
|
|
2939
|
+
element: f,
|
|
2940
|
+
pmPos: n,
|
|
2941
|
+
width: f.offsetWidth,
|
|
2942
|
+
height: f.offsetHeight
|
|
2943
|
+
}, e.clearOverlay();
|
|
2944
|
+
}
|
|
2945
|
+
d.focus();
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
2948
|
+
e.selectedImage.value = null, t.preventDefault();
|
|
2949
|
+
let p = m(t.clientX, t.clientY);
|
|
2950
|
+
if (p === null) {
|
|
2951
|
+
d.focus();
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
let _ = Date.now();
|
|
2955
|
+
if (_ - a < Mi && o === p ? s++ : s = 1, a = _, o = p, s === 2) v(p);
|
|
2956
|
+
else if (s >= 3) y(p), s = 0;
|
|
2957
|
+
else {
|
|
2958
|
+
if (t.shiftKey) {
|
|
2959
|
+
let { from: e } = d.state.selection;
|
|
2960
|
+
g(e, p);
|
|
2961
|
+
} else g(p);
|
|
2962
|
+
l = p, c = !0, u.begin(Zt(d, p));
|
|
2963
|
+
}
|
|
2964
|
+
d.focus();
|
|
2965
|
+
}
|
|
2966
|
+
function T(e) {
|
|
2967
|
+
if (!c || l === null) return;
|
|
2968
|
+
let t = m(e.clientX, e.clientY);
|
|
2969
|
+
if (t !== null) {
|
|
2970
|
+
let n = h();
|
|
2971
|
+
if (n && u.update(n, t, e.clientX)) {
|
|
2972
|
+
d.updateMousePosition(e.clientX, e.clientY);
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
t !== l && g(l, t);
|
|
2976
|
+
}
|
|
2977
|
+
d.updateMousePosition(e.clientX, e.clientY);
|
|
2978
|
+
}
|
|
2979
|
+
function E() {
|
|
2980
|
+
c = !1, u.end(), d.stopAutoScroll();
|
|
2981
|
+
}
|
|
2982
|
+
function D() {
|
|
2983
|
+
let t = e.pagesViewportRef.value, n = e.layout.value;
|
|
2984
|
+
if (!t || !n || n.pages.length === 0) return;
|
|
2985
|
+
let r = t.scrollTop, i = n.pages.length, a = r + t.clientHeight / 2, o = 24, s = 1;
|
|
2986
|
+
for (let e = 0; e < n.pages.length; e++) {
|
|
2987
|
+
let t = n.pages[e].size.h, r = o + t;
|
|
2988
|
+
if (a < r) {
|
|
2989
|
+
s = e + 1;
|
|
2990
|
+
break;
|
|
2991
|
+
}
|
|
2992
|
+
o = r + 24, s = e + 2;
|
|
2993
|
+
}
|
|
2994
|
+
s = Math.min(s, i), f.value = {
|
|
2995
|
+
currentPage: s,
|
|
2996
|
+
totalPages: i,
|
|
2997
|
+
visible: !0
|
|
2998
|
+
}, p && clearTimeout(p), p = setTimeout(() => {
|
|
2999
|
+
f.value = {
|
|
3000
|
+
...f.value,
|
|
3001
|
+
visible: !1
|
|
3002
|
+
};
|
|
3003
|
+
}, 600);
|
|
3004
|
+
}
|
|
3005
|
+
return R(() => {
|
|
3006
|
+
window.addEventListener("mousemove", T), window.addEventListener("mouseup", E), e.pagesViewportRef.value?.addEventListener("scroll", D, { passive: !0 });
|
|
3007
|
+
}), L(() => {
|
|
3008
|
+
r(), window.removeEventListener("mousemove", T), window.removeEventListener("mouseup", E), e.pagesViewportRef.value?.removeEventListener("scroll", D), p && clearTimeout(p);
|
|
3009
|
+
}), {
|
|
3010
|
+
tableInsertButton: t,
|
|
3011
|
+
hfEdit: i,
|
|
3012
|
+
scrollPageInfo: f,
|
|
3013
|
+
resolvePos: m,
|
|
3014
|
+
setPmSelection: g,
|
|
3015
|
+
scrollVisiblePositionIntoView: _,
|
|
3016
|
+
navigateToBookmark: b,
|
|
3017
|
+
handlePagesMouseDown: w,
|
|
3018
|
+
handlePagesMouseMove: ee,
|
|
3019
|
+
handlePagesClick: S,
|
|
3020
|
+
handlePagesDoubleClick: C,
|
|
3021
|
+
handleTableInsertClick: x,
|
|
3022
|
+
clearTableInsertTimer: r,
|
|
3023
|
+
handleHfSave: te,
|
|
3024
|
+
handleHfRemove: ne
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region src/composables/useSelectionSync.ts
|
|
3029
|
+
function Pi(e) {
|
|
3030
|
+
let t = null, n = null, r = null;
|
|
3031
|
+
function i() {
|
|
3032
|
+
let r = e.pagesRef.value;
|
|
3033
|
+
r && (r.querySelectorAll(".vue-sel-rect, .vue-caret").forEach((e) => e.remove()), t !== null && (clearInterval(t), t = null), n = null);
|
|
3034
|
+
}
|
|
3035
|
+
function a() {
|
|
3036
|
+
r !== null && cancelAnimationFrame(r), r = requestAnimationFrame(() => {
|
|
3037
|
+
r = null;
|
|
3038
|
+
let t = e.pagesRef.value, n = e.editorView.value;
|
|
3039
|
+
if (!t || !n || e.isHfEditing?.value) return;
|
|
3040
|
+
let i = n.state.selection;
|
|
3041
|
+
if (i instanceof ge && i.node.type.name === "image") {
|
|
3042
|
+
let n = xe(t, i.from), r = n ? ut(n) : null;
|
|
3043
|
+
if (r) {
|
|
3044
|
+
let t = e.selectedImage.value;
|
|
3045
|
+
(!t || t.element !== r || t.pmPos !== i.from || t.width !== r.offsetWidth || t.height !== r.offsetHeight) && (e.selectedImage.value = {
|
|
3046
|
+
element: r,
|
|
3047
|
+
pmPos: i.from,
|
|
3048
|
+
width: r.offsetWidth,
|
|
3049
|
+
height: r.offsetHeight
|
|
3050
|
+
});
|
|
3051
|
+
return;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
e.imageInteracting?.value || (e.selectedImage.value = null);
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
function o() {
|
|
3058
|
+
let r = e.pagesRef.value, o = e.editorView.value;
|
|
3059
|
+
if (!r || !o || (i(), e.isHfEditing?.value)) return;
|
|
3060
|
+
a(), ve(r, o.state);
|
|
3061
|
+
let s = o.state.selection;
|
|
3062
|
+
if (s instanceof ge && s.node.type.name === "image") return;
|
|
3063
|
+
let { from: c, to: l, empty: u } = s, d = r.scrollTop, f = r.scrollLeft, p = e.zoom.value || 1;
|
|
3064
|
+
if (u) {
|
|
3065
|
+
let e = et(r, c, r.getBoundingClientRect(), p);
|
|
3066
|
+
if (e) {
|
|
3067
|
+
let i = document.createElement("div");
|
|
3068
|
+
i.className = "vue-caret", i.style.cssText = `
|
|
3069
|
+
position: absolute;
|
|
3070
|
+
left: ${e.x / p + f}px;
|
|
3071
|
+
top: ${e.y / p + d}px;
|
|
3072
|
+
width: 2px;
|
|
3073
|
+
height: ${e.height}px;
|
|
3074
|
+
background: var(--doc-caret, #000);
|
|
3075
|
+
pointer-events: none;
|
|
3076
|
+
z-index: ${C.selectionOverlay};
|
|
3077
|
+
`, r.appendChild(i), n = i;
|
|
3078
|
+
let a = !0;
|
|
3079
|
+
t = setInterval(() => {
|
|
3080
|
+
a = !a, n && (n.style.opacity = a ? "1" : "0");
|
|
3081
|
+
}, 530);
|
|
3082
|
+
}
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
let m = tt(r, c, l, r.getBoundingClientRect());
|
|
3086
|
+
for (let e of m) {
|
|
3087
|
+
let t = document.createElement("div");
|
|
3088
|
+
t.className = "vue-sel-rect", t.style.cssText = `
|
|
3089
|
+
position: absolute;
|
|
3090
|
+
left: ${e.x / p + f}px;
|
|
3091
|
+
top: ${e.y / p + d}px;
|
|
3092
|
+
width: ${e.width / p}px;
|
|
3093
|
+
height: ${e.height / p}px;
|
|
3094
|
+
background: rgba(66, 133, 244, 0.3);
|
|
3095
|
+
pointer-events: none;
|
|
3096
|
+
z-index: ${C.selectionOverlay};
|
|
3097
|
+
`, r.appendChild(t);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
return L(() => {
|
|
3101
|
+
r !== null && cancelAnimationFrame(r), i();
|
|
3102
|
+
}), {
|
|
3103
|
+
clearOverlay: i,
|
|
3104
|
+
updateSelectionOverlay: o
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
//#endregion
|
|
3108
|
+
//#region src/composables/useMenuActions.ts
|
|
3109
|
+
function Fi(e) {
|
|
3110
|
+
function t(t) {
|
|
3111
|
+
let n = e.editorView.value;
|
|
3112
|
+
if (!n) return;
|
|
3113
|
+
let r = e.getCommands()[t];
|
|
3114
|
+
r && (r()(n.state, (e) => n.dispatch(e), n), n.focus());
|
|
3115
|
+
}
|
|
3116
|
+
function n(t, n) {
|
|
3117
|
+
let r = e.editorView.value;
|
|
3118
|
+
if (!r) return;
|
|
3119
|
+
let i = e.getCommands().insertTable;
|
|
3120
|
+
i && (i(t, n)(r.state, (e) => r.dispatch(e), r), r.focus());
|
|
3121
|
+
}
|
|
3122
|
+
function r(n) {
|
|
3123
|
+
switch (n) {
|
|
3124
|
+
case "open":
|
|
3125
|
+
e.docxInputRef.value?.click(), e.emit("menu-action", "open");
|
|
3126
|
+
break;
|
|
3127
|
+
case "save":
|
|
3128
|
+
e.emit("menu-action", "save"), e.downloadCurrentDocument();
|
|
3129
|
+
break;
|
|
3130
|
+
case "pageSetup":
|
|
3131
|
+
e.showPageSetup.value = !0;
|
|
3132
|
+
break;
|
|
3133
|
+
case "watermark":
|
|
3134
|
+
e.showWatermark.value = !0;
|
|
3135
|
+
break;
|
|
3136
|
+
case "clearFormatting":
|
|
3137
|
+
e.handleClearFormatting();
|
|
3138
|
+
break;
|
|
3139
|
+
case "insertImage":
|
|
3140
|
+
e.imageInputRef.value?.click();
|
|
3141
|
+
break;
|
|
3142
|
+
case "insertLink":
|
|
3143
|
+
e.showHyperlink.value = !0;
|
|
3144
|
+
break;
|
|
3145
|
+
case "insertSymbol":
|
|
3146
|
+
e.showInsertSymbol.value = !0;
|
|
3147
|
+
break;
|
|
3148
|
+
case "insertPageBreak":
|
|
3149
|
+
e.handleInsertPageBreak();
|
|
3150
|
+
break;
|
|
3151
|
+
case "insertSectionBreakNextPage":
|
|
3152
|
+
e.handleInsertSectionBreakNextPage();
|
|
3153
|
+
break;
|
|
3154
|
+
case "insertSectionBreakContinuous":
|
|
3155
|
+
e.handleInsertSectionBreakContinuous();
|
|
3156
|
+
break;
|
|
3157
|
+
case "insertTOC":
|
|
3158
|
+
t("generateTOC");
|
|
3159
|
+
break;
|
|
3160
|
+
case "outline":
|
|
3161
|
+
e.handleToggleOutline();
|
|
3162
|
+
break;
|
|
3163
|
+
case "sidebar":
|
|
3164
|
+
e.handleToggleSidebar();
|
|
3165
|
+
break;
|
|
3166
|
+
case "shortcuts":
|
|
3167
|
+
e.showKeyboardShortcuts.value = !0;
|
|
3168
|
+
break;
|
|
3169
|
+
case "reportIssue":
|
|
3170
|
+
Qt();
|
|
3171
|
+
break;
|
|
3172
|
+
case "dirLTR":
|
|
3173
|
+
t("setLtr");
|
|
3174
|
+
break;
|
|
3175
|
+
case "dirRTL":
|
|
3176
|
+
t("setRtl");
|
|
3177
|
+
break;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
return {
|
|
3181
|
+
handleMenuAction: r,
|
|
3182
|
+
handleMenuTableInsert: n,
|
|
3183
|
+
execSimpleCommand: t
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
//#endregion
|
|
3187
|
+
//#region src/composables/useDocumentLifecycle.ts
|
|
3188
|
+
function Ii(e) {
|
|
3189
|
+
async function t(t) {
|
|
3190
|
+
e.sidebarAutoOpenedRef.value = !1, await e.loadDocumentBuffer(t);
|
|
3191
|
+
}
|
|
3192
|
+
function n(t) {
|
|
3193
|
+
e.sidebarAutoOpenedRef.value = !1, e.loadDocument(t);
|
|
3194
|
+
}
|
|
3195
|
+
K(e.documentBuffer, (e) => {
|
|
3196
|
+
e && t(e);
|
|
3197
|
+
}), K(e.document, (e) => {
|
|
3198
|
+
e && n(e);
|
|
3199
|
+
}), R(async () => {
|
|
3200
|
+
await le();
|
|
3201
|
+
let r = e.documentBuffer(), i = e.document();
|
|
3202
|
+
r ? await t(r) : i && n(i);
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
//#endregion
|
|
3206
|
+
//#region src/composables/useDocxEditorRefApi.ts
|
|
3207
|
+
function Li(e) {
|
|
3208
|
+
function t() {
|
|
3209
|
+
let t = e.pagesRef.value;
|
|
3210
|
+
t && ft(t), e.onPrint?.(), window.print();
|
|
3211
|
+
}
|
|
3212
|
+
function n() {
|
|
3213
|
+
t();
|
|
3214
|
+
}
|
|
3215
|
+
function r() {
|
|
3216
|
+
return e.zoom.value;
|
|
3217
|
+
}
|
|
3218
|
+
function i(t) {
|
|
3219
|
+
if (!Number.isInteger(t) || t < 1) return;
|
|
3220
|
+
let n = e.pagesViewportRef.value, r = e.pagesRef.value?.querySelector(`[data-page-number="${t}"]`);
|
|
3221
|
+
if (!n || !r) return;
|
|
3222
|
+
let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
|
|
3223
|
+
n.scrollTo({
|
|
3224
|
+
top: a.top - i.top + n.scrollTop - 24,
|
|
3225
|
+
behavior: "smooth"
|
|
3226
|
+
});
|
|
3227
|
+
}
|
|
3228
|
+
function a(t) {
|
|
3229
|
+
Number.isFinite(t) && e.scrollVisiblePositionIntoView(t);
|
|
3230
|
+
}
|
|
3231
|
+
function o() {
|
|
3232
|
+
return e.editorView.value ? {
|
|
3233
|
+
getDocument: e.getDocument,
|
|
3234
|
+
getView: () => e.editorView.value,
|
|
3235
|
+
getState: () => e.editorView.value?.state ?? null
|
|
3236
|
+
} : null;
|
|
3237
|
+
}
|
|
3238
|
+
function s() {
|
|
3239
|
+
return e.layout.value?.pages.length ?? 0;
|
|
3240
|
+
}
|
|
3241
|
+
function c() {
|
|
3242
|
+
let t = e.layout.value, n = e.editorView.value;
|
|
3243
|
+
if (!t || !n) return 0;
|
|
3244
|
+
let r = yt(t, n.state.selection.from);
|
|
3245
|
+
return r == null ? 0 : r + 1;
|
|
3246
|
+
}
|
|
3247
|
+
function l(t, n) {
|
|
3248
|
+
let r = e.editorView.value;
|
|
3249
|
+
if (!r) return !1;
|
|
3250
|
+
let i = en(r.state.doc, t);
|
|
3251
|
+
if (!i) return !1;
|
|
3252
|
+
if (e.scrollVisiblePositionIntoView(i.from + 1), n?.highlight) {
|
|
3253
|
+
let r = () => {
|
|
3254
|
+
let r = e.pagesRef.value;
|
|
3255
|
+
r && Ve(r, t, n.highlight);
|
|
3256
|
+
};
|
|
3257
|
+
r(), requestAnimationFrame(() => requestAnimationFrame(r));
|
|
3258
|
+
}
|
|
3259
|
+
return !0;
|
|
3260
|
+
}
|
|
3261
|
+
function u(t, n) {
|
|
3262
|
+
return Ee(e.editorView.value, t, n);
|
|
3263
|
+
}
|
|
3264
|
+
function d() {
|
|
3265
|
+
return Oe(e.editorView.value);
|
|
3266
|
+
}
|
|
3267
|
+
function f() {
|
|
3268
|
+
return e.comments.value;
|
|
3269
|
+
}
|
|
3270
|
+
function p(t) {
|
|
3271
|
+
let n = e.editorView.value;
|
|
3272
|
+
return n ? Ne(n.state.doc, t ?? {}) : [];
|
|
3273
|
+
}
|
|
3274
|
+
function m(t) {
|
|
3275
|
+
let n = e.editorView.value;
|
|
3276
|
+
if (!n) return !1;
|
|
3277
|
+
let r = Me(n.state.doc, t);
|
|
3278
|
+
return r == null ? !1 : (a(r), !0);
|
|
3279
|
+
}
|
|
3280
|
+
function h(t, n, r) {
|
|
3281
|
+
let i = _e.between(t.state.doc.resolve(n), t.state.doc.resolve(r));
|
|
3282
|
+
t.dispatch(t.state.tr.setSelection(i)), e.scrollVisiblePositionIntoView(n);
|
|
3283
|
+
}
|
|
3284
|
+
function g(t, n) {
|
|
3285
|
+
let r = e.editorView.value;
|
|
3286
|
+
if (!r) return;
|
|
3287
|
+
let i = Ce(r.state.doc, t, n);
|
|
3288
|
+
i && h(r, i.from, i.to);
|
|
3289
|
+
}
|
|
3290
|
+
function _(t) {
|
|
3291
|
+
let n = e.editorView.value;
|
|
3292
|
+
if (!n) return !1;
|
|
3293
|
+
let r = Te(n, t);
|
|
3294
|
+
return r ? (h(n, r.from, r.to), !0) : !1;
|
|
3295
|
+
}
|
|
3296
|
+
function v(t) {
|
|
3297
|
+
let n = e.editorView.value;
|
|
3298
|
+
if (!n) return !1;
|
|
3299
|
+
let r = we(n, t);
|
|
3300
|
+
return r ? (h(n, r.from, r.to), !0) : !1;
|
|
3301
|
+
}
|
|
3302
|
+
function y(t, n, r) {
|
|
3303
|
+
let i = e.editorView.value;
|
|
3304
|
+
if (!i) return !1;
|
|
3305
|
+
try {
|
|
3306
|
+
return i.dispatch(Ie(i.state, t, n, r)), !0;
|
|
3307
|
+
} catch (e) {
|
|
3308
|
+
if (e instanceof $t) return !1;
|
|
3309
|
+
throw e;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
function b(t, n) {
|
|
3313
|
+
let r = e.editorView.value;
|
|
3314
|
+
if (!r) return !1;
|
|
3315
|
+
try {
|
|
3316
|
+
return r.dispatch(Z(r.state, t, n)), !0;
|
|
3317
|
+
} catch (e) {
|
|
3318
|
+
if (e instanceof $t) return !1;
|
|
3319
|
+
throw e;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
function ee(t, n, r) {
|
|
3323
|
+
let i = e.editorView.value;
|
|
3324
|
+
if (!i) return !1;
|
|
3325
|
+
try {
|
|
3326
|
+
return i.dispatch(Re(i.state, t, n, r)), !0;
|
|
3327
|
+
} catch (e) {
|
|
3328
|
+
if (e instanceof $t) return !1;
|
|
3329
|
+
throw e;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
function x(t) {
|
|
3333
|
+
return De(e.editorView.value, e.layout.value, t);
|
|
3334
|
+
}
|
|
3335
|
+
function S(t) {
|
|
3336
|
+
return e.contentChangeSubscribers.add(t), () => e.contentChangeSubscribers.delete(t);
|
|
3337
|
+
}
|
|
3338
|
+
function C(t) {
|
|
3339
|
+
return e.selectionChangeSubscribers.add(t), () => e.selectionChangeSubscribers.delete(t);
|
|
3340
|
+
}
|
|
3341
|
+
return { exposed: {
|
|
3342
|
+
getAgent: () => null,
|
|
3343
|
+
save: e.save,
|
|
3344
|
+
setZoom: e.setZoom,
|
|
3345
|
+
getZoom: r,
|
|
3346
|
+
focus: e.focus,
|
|
3347
|
+
scrollToPage: i,
|
|
3348
|
+
scrollToPosition: a,
|
|
3349
|
+
openPrintPreview: n,
|
|
3350
|
+
print: t,
|
|
3351
|
+
loadDocument: e.loadDocument,
|
|
3352
|
+
loadDocumentBuffer: e.loadDocumentBuffer,
|
|
3353
|
+
destroy: e.destroy,
|
|
3354
|
+
getDocument: e.getDocument,
|
|
3355
|
+
getEditorRef: o,
|
|
3356
|
+
addComment: e.addComment,
|
|
3357
|
+
replyToComment: e.replyToComment,
|
|
3358
|
+
resolveComment: e.resolveComment,
|
|
3359
|
+
proposeChange: e.proposeChange,
|
|
3360
|
+
scrollToParaId: l,
|
|
3361
|
+
scrollToCommentId: _,
|
|
3362
|
+
scrollToChangeId: v,
|
|
3363
|
+
highlightRange: g,
|
|
3364
|
+
findInDocument: u,
|
|
3365
|
+
getSelectionInfo: d,
|
|
3366
|
+
getComments: f,
|
|
3367
|
+
getContentControls: p,
|
|
3368
|
+
scrollToContentControl: m,
|
|
3369
|
+
setContentControlContent: y,
|
|
3370
|
+
removeContentControl: b,
|
|
3371
|
+
setContentControlValue: ee,
|
|
3372
|
+
applyFormatting: e.applyFormatting,
|
|
3373
|
+
setParagraphStyle: e.setParagraphStyle,
|
|
3374
|
+
insertBreak: e.insertBreak,
|
|
3375
|
+
getPageContent: x,
|
|
3376
|
+
getTotalPages: s,
|
|
3377
|
+
getCurrentPage: c,
|
|
3378
|
+
onContentChange: S,
|
|
3379
|
+
onSelectionChange: C
|
|
3380
|
+
} };
|
|
3381
|
+
}
|
|
3382
|
+
//#endregion
|
|
3383
|
+
//#region src/composables/useControllableBoolean.ts
|
|
3384
|
+
function Ri(e, t, n = !1) {
|
|
3385
|
+
let r = B(n);
|
|
3386
|
+
return D({
|
|
3387
|
+
get() {
|
|
3388
|
+
let t = e();
|
|
3389
|
+
return t === void 0 ? r.value : t;
|
|
3390
|
+
},
|
|
3391
|
+
set(n) {
|
|
3392
|
+
let i = e();
|
|
3393
|
+
n !== (i === void 0 ? r.value : i) && (i === void 0 && (r.value = n), t?.(n));
|
|
3394
|
+
}
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
//#endregion
|
|
3398
|
+
//#region src/composables/useColorMode.ts
|
|
3399
|
+
function zi(e) {
|
|
3400
|
+
let t = B(We());
|
|
3401
|
+
return me((n) => {
|
|
3402
|
+
e() === "system" && n(qe((e) => {
|
|
3403
|
+
t.value = e;
|
|
3404
|
+
}));
|
|
3405
|
+
}), D(() => Ke(e(), t.value));
|
|
3406
|
+
}
|
|
3407
|
+
//#endregion
|
|
3408
|
+
//#region src/composables/useFontLifecycle.ts
|
|
3409
|
+
function Bi(e, t) {
|
|
3410
|
+
K(e, (e) => {
|
|
3411
|
+
He(e);
|
|
3412
|
+
}, { immediate: !0 });
|
|
3413
|
+
let n = Ue(t);
|
|
3414
|
+
L(() => n());
|
|
3415
|
+
}
|
|
3416
|
+
//#endregion
|
|
3417
|
+
//#region src/components/DocxEditor.vue?vue&type=script&setup=true&lang.ts
|
|
3418
|
+
var Vi = { class: "docx-editor-vue__toolbar-shell" }, Hi = {
|
|
3419
|
+
key: 0,
|
|
3420
|
+
class: "docx-editor-vue__error"
|
|
3421
|
+
}, Ui = {
|
|
3422
|
+
key: 1,
|
|
3423
|
+
class: "docx-editor-vue__loading"
|
|
3424
|
+
}, Wi = { class: "docx-editor-vue__editor-area" }, Gi = {
|
|
3425
|
+
key: 0,
|
|
3426
|
+
class: "docx-editor-vue__vertical-ruler"
|
|
3427
|
+
}, Ki = ["title"], qi = ["title", "aria-label"], Ji = 268, Yi = 64, Xi = 20, Zi = 816, Qi = /* @__PURE__ */ P({
|
|
3428
|
+
__name: "DocxEditor",
|
|
3429
|
+
props: {
|
|
3430
|
+
documentBuffer: { default: null },
|
|
3431
|
+
document: { default: null },
|
|
3432
|
+
showToolbar: {
|
|
3433
|
+
type: Boolean,
|
|
3434
|
+
default: !0
|
|
3435
|
+
},
|
|
3436
|
+
showFileOpen: {
|
|
3437
|
+
type: Boolean,
|
|
3438
|
+
default: !0
|
|
3439
|
+
},
|
|
3440
|
+
showHelpMenu: {
|
|
3441
|
+
type: Boolean,
|
|
3442
|
+
default: !0
|
|
3443
|
+
},
|
|
3444
|
+
showMenuBar: {
|
|
3445
|
+
type: Boolean,
|
|
3446
|
+
default: !0
|
|
3447
|
+
},
|
|
3448
|
+
showRuler: {
|
|
3449
|
+
type: Boolean,
|
|
3450
|
+
default: !0
|
|
3451
|
+
},
|
|
3452
|
+
documentName: { default: "" },
|
|
3453
|
+
readOnly: {
|
|
3454
|
+
type: Boolean,
|
|
3455
|
+
default: !1
|
|
3456
|
+
},
|
|
3457
|
+
author: { default: "User" },
|
|
3458
|
+
mode: { default: "editing" },
|
|
3459
|
+
onModeChange: {},
|
|
3460
|
+
commentsSidebarOpen: {
|
|
3461
|
+
type: Boolean,
|
|
3462
|
+
default: void 0
|
|
3463
|
+
},
|
|
3464
|
+
onCommentsSidebarOpenChange: {},
|
|
3465
|
+
i18n: { default: void 0 },
|
|
3466
|
+
theme: { default: null },
|
|
3467
|
+
colorMode: { default: "light" },
|
|
3468
|
+
externalPlugins: { default: () => [] },
|
|
3469
|
+
showZoomControl: {
|
|
3470
|
+
type: Boolean,
|
|
3471
|
+
default: !0
|
|
3472
|
+
},
|
|
3473
|
+
initialZoom: { default: 1 },
|
|
3474
|
+
toolbarExtra: {
|
|
3475
|
+
type: Function,
|
|
3476
|
+
default: void 0
|
|
3477
|
+
},
|
|
3478
|
+
className: { default: "" },
|
|
3479
|
+
style: {
|
|
3480
|
+
type: [
|
|
3481
|
+
Boolean,
|
|
3482
|
+
null,
|
|
3483
|
+
String,
|
|
3484
|
+
Object,
|
|
3485
|
+
Array
|
|
3486
|
+
],
|
|
3487
|
+
default: void 0
|
|
3488
|
+
},
|
|
3489
|
+
showOutline: {
|
|
3490
|
+
type: Boolean,
|
|
3491
|
+
default: !1
|
|
3492
|
+
},
|
|
3493
|
+
showOutlineButton: {
|
|
3494
|
+
type: Boolean,
|
|
3495
|
+
default: !0
|
|
3496
|
+
},
|
|
3497
|
+
fontFamilies: { default: void 0 },
|
|
3498
|
+
fonts: {},
|
|
3499
|
+
watermarkPresets: { default: void 0 },
|
|
3500
|
+
onPrint: {
|
|
3501
|
+
type: Function,
|
|
3502
|
+
default: void 0
|
|
3503
|
+
},
|
|
3504
|
+
onOpen: {
|
|
3505
|
+
type: Function,
|
|
3506
|
+
default: void 0
|
|
3507
|
+
},
|
|
3508
|
+
disableFindReplaceShortcuts: {
|
|
3509
|
+
type: Boolean,
|
|
3510
|
+
default: !1
|
|
3511
|
+
},
|
|
3512
|
+
renderLogo: {
|
|
3513
|
+
type: Function,
|
|
3514
|
+
default: void 0
|
|
3515
|
+
},
|
|
3516
|
+
onDocumentNameChange: {
|
|
3517
|
+
type: Function,
|
|
3518
|
+
default: void 0
|
|
3519
|
+
},
|
|
3520
|
+
documentNameEditable: {
|
|
3521
|
+
type: Boolean,
|
|
3522
|
+
default: !0
|
|
3523
|
+
},
|
|
3524
|
+
renderTitleBarRight: {
|
|
3525
|
+
type: Function,
|
|
3526
|
+
default: void 0
|
|
3527
|
+
},
|
|
3528
|
+
onChange: {},
|
|
3529
|
+
onError: {},
|
|
3530
|
+
onSelectionChange: {},
|
|
3531
|
+
onEditorViewReady: {},
|
|
3532
|
+
onCommentAdd: {},
|
|
3533
|
+
onCommentResolve: {},
|
|
3534
|
+
onCommentDelete: {},
|
|
3535
|
+
onCommentReply: {},
|
|
3536
|
+
onCommentsChange: {}
|
|
3537
|
+
},
|
|
3538
|
+
emits: [
|
|
3539
|
+
"change",
|
|
3540
|
+
"update:document",
|
|
3541
|
+
"error",
|
|
3542
|
+
"ready",
|
|
3543
|
+
"rename",
|
|
3544
|
+
"menu-action",
|
|
3545
|
+
"mode-change",
|
|
3546
|
+
"comments-sidebar-open-change"
|
|
3547
|
+
],
|
|
3548
|
+
setup(e, { expose: t, emit: n }) {
|
|
3549
|
+
let i = e, o = n, s = zi(() => i.colorMode), c = B(i.mode), u = D(() => i.readOnly || c.value === "viewing"), d = D(() => i.author);
|
|
3550
|
+
a(D(() => i.i18n));
|
|
3551
|
+
let { t: g } = l(D(() => i.i18n));
|
|
3552
|
+
b(s);
|
|
3553
|
+
let _ = B(null), v = B(null), x = B(null), S = B(0), C = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set(), E = new ke(), ie = B(!1), oe = B(!1), M = B(!1), P = B(!1), se = B(!1), W = B(i.showOutline), pe = B(!1), G = Ri(() => i.commentsSidebarOpen, (e) => o("comments-sidebar-open-change", e)), me = B(!1), q = B(null), J = fe([]), ge = fe([]), ve = fe([]), { zoom: X, zoomPercent: xe, isMinZoom: Se, isMaxZoom: Ce, setZoom: we, zoomIn: Te, zoomOut: Ee, handleWheel: De, handleKeyDown: Ae, installShortcuts: Me, ZOOM_PRESETS: Ne } = w(i.initialZoom);
|
|
3554
|
+
Me();
|
|
3555
|
+
let { editorView: Z, isReady: Pe, parseError: Fe, documentFonts: Ie, layout: Le, loadBuffer: Re, loadDocument: Be, save: Ve, focus: He, destroy: Ue, getDocument: Q, getCommands: We, reLayout: Ge, getHfPmView: Ke, getHfPmViews: qe, syncHfPMs: Je, setHfTransactionListener: Xe, setDocument: Ze } = te({
|
|
3556
|
+
hiddenContainer: _,
|
|
3557
|
+
pagesContainer: v,
|
|
3558
|
+
readOnly: u,
|
|
3559
|
+
externalPlugins: i.externalPlugins,
|
|
3560
|
+
syncCoordinator: E,
|
|
3561
|
+
editorMode: c,
|
|
3562
|
+
author: d,
|
|
3563
|
+
onChange: (e) => {
|
|
3564
|
+
o("change", e), o("update:document", e), i.onChange?.(e), C.forEach((t) => t(e));
|
|
3565
|
+
},
|
|
3566
|
+
onError: (e) => {
|
|
3567
|
+
o("error", e), i.onError?.(e);
|
|
3568
|
+
},
|
|
3569
|
+
onSelectionUpdate: () => {
|
|
3570
|
+
S.value++;
|
|
3571
|
+
let e = Z.value;
|
|
3572
|
+
i.onSelectionChange?.(e ? je(e.state) : null);
|
|
3573
|
+
let t = Oe(e);
|
|
3574
|
+
re.forEach((e) => e(t));
|
|
3575
|
+
}
|
|
3576
|
+
}), { commentCallbacks: Qe } = xi(i, Z), $e = D(() => {
|
|
3577
|
+
S.value;
|
|
3578
|
+
let e = Q();
|
|
3579
|
+
if (!e?.package?.document) return null;
|
|
3580
|
+
let t = e.package.document;
|
|
3581
|
+
return t.finalSectionProperties ?? t.sections?.[0]?.properties ?? null;
|
|
3582
|
+
}), et = D(() => {
|
|
3583
|
+
S.value;
|
|
3584
|
+
let e = Z.value, t = e ? Ye(e.state).paragraphFormatting : {};
|
|
3585
|
+
return {
|
|
3586
|
+
indentLeft: t.indentLeft ?? 0,
|
|
3587
|
+
indentRight: t.indentRight ?? 0,
|
|
3588
|
+
firstLineIndent: t.indentFirstLine ?? 0,
|
|
3589
|
+
hangingIndent: t.hangingIndent ?? !1,
|
|
3590
|
+
tabStops: t.tabs ?? null
|
|
3591
|
+
};
|
|
3592
|
+
}), tt = D(() => (S.value, Q()?.package?.theme ?? i.theme ?? null)), nt = D(() => (S.value, Q()?.package?.styles?.styles ?? void 0)), rt = B(null), it = B([]);
|
|
3593
|
+
function at(e, t) {
|
|
3594
|
+
rt.value = ye(e, t), it.value = be(e, t);
|
|
3595
|
+
}
|
|
3596
|
+
function ot() {
|
|
3597
|
+
rt.value = null, it.value = [];
|
|
3598
|
+
}
|
|
3599
|
+
Bi(() => i.fonts, (e) => {
|
|
3600
|
+
o("error", e), i.onError?.(e);
|
|
3601
|
+
});
|
|
3602
|
+
let st = D(() => $.value?.headerFooter ? Ke($.value.headerFooter) ?? null : null), ct = D(() => st.value ?? Z.value);
|
|
3603
|
+
R(() => {
|
|
3604
|
+
Xe((e, t) => {
|
|
3605
|
+
S.value++, requestAnimationFrame(() => {
|
|
3606
|
+
let e = $.value;
|
|
3607
|
+
if (!e) return;
|
|
3608
|
+
at(t, e.position);
|
|
3609
|
+
let n = rn(e.position), r = x.value;
|
|
3610
|
+
if (!n || !r) return;
|
|
3611
|
+
let i = n.getBoundingClientRect(), a = r.getBoundingClientRect(), o = X.value || 1;
|
|
3612
|
+
$.value = {
|
|
3613
|
+
...e,
|
|
3614
|
+
targetRect: {
|
|
3615
|
+
top: (i.top - a.top + r.scrollTop) / o,
|
|
3616
|
+
left: (i.left - a.left + r.scrollLeft) / o,
|
|
3617
|
+
width: i.width / o,
|
|
3618
|
+
height: i.height / o
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
});
|
|
3622
|
+
}), K(() => $.value, (e) => {
|
|
3623
|
+
if (!e) {
|
|
3624
|
+
ot();
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
let t = Z.value;
|
|
3628
|
+
if (t) {
|
|
3629
|
+
try {
|
|
3630
|
+
let e = t.state.tr.setSelection(_e.create(t.state.doc, 0));
|
|
3631
|
+
t.dispatch(e);
|
|
3632
|
+
} catch {}
|
|
3633
|
+
t.dom.blur?.();
|
|
3634
|
+
}
|
|
3635
|
+
gr.updateSelectionOverlay();
|
|
3636
|
+
});
|
|
3637
|
+
let e = 0;
|
|
3638
|
+
function t() {
|
|
3639
|
+
!$.value || e || (e = requestAnimationFrame(() => {
|
|
3640
|
+
e = 0;
|
|
3641
|
+
let t = $.value;
|
|
3642
|
+
if (!t?.headerFooter) return;
|
|
3643
|
+
let n = Ke(t.headerFooter);
|
|
3644
|
+
n && at(n, t.position);
|
|
3645
|
+
}));
|
|
3646
|
+
}
|
|
3647
|
+
window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), L(() => {
|
|
3648
|
+
e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
|
|
3649
|
+
});
|
|
3650
|
+
});
|
|
3651
|
+
let lt = D(() => {
|
|
3652
|
+
S.value;
|
|
3653
|
+
let e = (W.value ? Ji : i.showOutlineButton ? Yi : 20) + (i.showRuler && (W.value || i.showOutlineButton) ? Xi : 0), t = Q()?.package?.document, n = [t?.finalSectionProperties?.pageWidth, ...t?.sections?.map((e) => e.properties?.pageWidth) ?? []].filter((e) => typeof e == "number" && e > 0), r = n.length ? Math.round(Math.max(...n) / 15) : Zi;
|
|
3654
|
+
return 2 * e + r + (G.value ? ze * 2 : 0);
|
|
3655
|
+
}), ut = D(() => {
|
|
3656
|
+
let e = [];
|
|
3657
|
+
return G.value && e.push(`translateX(-${ze}px)`), X.value !== 1 && e.push(`scale(${X.value})`), {
|
|
3658
|
+
transform: e.length > 0 ? e.join(" ") : void 0,
|
|
3659
|
+
transformOrigin: "top center",
|
|
3660
|
+
transition: "transform 0.2s ease"
|
|
3661
|
+
};
|
|
3662
|
+
}), dt = D(() => ({
|
|
3663
|
+
paddingLeft: "20px",
|
|
3664
|
+
paddingRight: 20 + (G.value ? ze * 2 : 0) + "px",
|
|
3665
|
+
transition: "padding 0.2s ease",
|
|
3666
|
+
minWidth: lt.value + "px"
|
|
3667
|
+
})), ft = D(() => {
|
|
3668
|
+
let e = $e.value;
|
|
3669
|
+
return ht(e?.pageWidth ?? 12240) * X.value;
|
|
3670
|
+
}), pt = D(() => new Set(J.value.filter((e) => e.parentId == null && e.done).map((e) => e.id))), mt = D(() => {
|
|
3671
|
+
S.value;
|
|
3672
|
+
let e = Z.value;
|
|
3673
|
+
if (!e) return [];
|
|
3674
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
3675
|
+
return e.state.doc.descendants((e) => {
|
|
3676
|
+
let r = e.attrs?.bookmarks;
|
|
3677
|
+
if (!r) return !0;
|
|
3678
|
+
for (let e of r) {
|
|
3679
|
+
let r = e.name;
|
|
3680
|
+
!r || r.startsWith("_") || t.has(r) || (t.add(r), n.push({
|
|
3681
|
+
name: r,
|
|
3682
|
+
label: r
|
|
3683
|
+
}));
|
|
3684
|
+
}
|
|
3685
|
+
return !0;
|
|
3686
|
+
}), n.sort((e, t) => e.name.localeCompare(t.name));
|
|
3687
|
+
}), gt = Kt(), { floatingCommentBtn: _t, pendingCommentRange: vt, addCommentYPosition: yt, sidebarAutoOpenedRef: bt, extractCommentsAndChanges: xt, handleAddComment: St, handleCancelAddComment: Ct, handleStartAddComment: wt, handleMarkerClick: Tt } = Si({
|
|
3688
|
+
editorView: Z,
|
|
3689
|
+
getDocument: Q,
|
|
3690
|
+
comments: J,
|
|
3691
|
+
trackedChanges: ge,
|
|
3692
|
+
resolvedCommentIds: pt,
|
|
3693
|
+
activeSidebarItem: q,
|
|
3694
|
+
showSidebar: G,
|
|
3695
|
+
isAddingComment: me,
|
|
3696
|
+
readOnly: u,
|
|
3697
|
+
zoom: X,
|
|
3698
|
+
stateTick: S,
|
|
3699
|
+
pagesRef: v,
|
|
3700
|
+
pagesViewportRef: x,
|
|
3701
|
+
emit: o,
|
|
3702
|
+
commentIdAllocator: gt,
|
|
3703
|
+
author: d,
|
|
3704
|
+
commentCallbacks: Qe,
|
|
3705
|
+
getHfPmViews: qe
|
|
3706
|
+
}), { docxInputRef: Et, imageInputRef: Dt, handleImageFileChange: Ot, handleDocxFileChange: kt, handleDocumentNameChange: At, downloadCurrentDocument: jt, loadDocumentBuffer: Mt, loadDocument: Nt, save: Pt } = pi({
|
|
3707
|
+
loadBuffer: Re,
|
|
3708
|
+
onOpen: i.onOpen,
|
|
3709
|
+
loadParsedDocument: Be,
|
|
3710
|
+
getDocument: Q,
|
|
3711
|
+
saveBlob: Ve,
|
|
3712
|
+
extractCommentsAndChanges: xt,
|
|
3713
|
+
emit: o,
|
|
3714
|
+
documentName: () => i.documentName,
|
|
3715
|
+
onDocumentNameChange: i.onDocumentNameChange,
|
|
3716
|
+
getActiveView: () => ct.value,
|
|
3717
|
+
nextTick: le
|
|
3718
|
+
}), { hyperlinkPopupData: Ft, handleHyperlinkSubmit: It, handleHyperlinkRemove: Lt, handleHyperlinkPopupNavigate: Rt, handleHyperlinkPopupEdit: zt, handleHyperlinkPopupRemove: Bt } = mi({
|
|
3719
|
+
editorView: Z,
|
|
3720
|
+
getCommands: We
|
|
3721
|
+
}), { handleClearFormatting: Vt, handleApplyStyle: Ht, handleInsertPageBreak: Ut, handleInsertSectionBreakNextPage: Wt, handleInsertSectionBreakContinuous: Gt, handleInsertSymbol: qt, applyFormatting: Jt, setParagraphStyle: Yt, insertBreak: Xt } = hi({
|
|
3722
|
+
editorView: Z,
|
|
3723
|
+
activeView: ct,
|
|
3724
|
+
getDocument: Q
|
|
3725
|
+
}), { handlePageSetupApply: Zt, handleLeftMarginChange: Qt, handleRightMarginChange: $t, handleTopMarginChange: en, handleBottomMarginChange: tn, handleIndentLeftChange: nn, handleIndentRightChange: an, handleFirstLineIndentChange: on, handleTabStopRemove: sn } = gi({
|
|
3726
|
+
editorView: Z,
|
|
3727
|
+
getDocument: Q,
|
|
3728
|
+
readOnly: u,
|
|
3729
|
+
stateTick: S,
|
|
3730
|
+
reLayout: Ge,
|
|
3731
|
+
emit: o
|
|
3732
|
+
}), { showWatermark: cn, currentWatermark: ln, handleWatermarkApply: dn } = _i({
|
|
3733
|
+
editorView: Z,
|
|
3734
|
+
readOnly: u,
|
|
3735
|
+
stateTick: S
|
|
3736
|
+
}), { handleToggleOutline: fn, handleOutlineNavigate: pn, handleToggleSidebar: mn, handleEditorScrollMouseDown: hn } = vi({
|
|
3737
|
+
editorView: Z,
|
|
3738
|
+
showOutline: W,
|
|
3739
|
+
showSidebar: G,
|
|
3740
|
+
outlineHeadings: ve,
|
|
3741
|
+
activeSidebarItem: q,
|
|
3742
|
+
extractCommentsAndChanges: xt,
|
|
3743
|
+
scrollToVisiblePosition: (e) => qn(e)
|
|
3744
|
+
});
|
|
3745
|
+
yi({
|
|
3746
|
+
showKeyboardShortcuts: pe,
|
|
3747
|
+
showFindReplace: ie,
|
|
3748
|
+
showHyperlink: oe,
|
|
3749
|
+
handleZoomKeyDown: Ae,
|
|
3750
|
+
disableFindReplaceShortcuts: () => i.disableFindReplaceShortcuts,
|
|
3751
|
+
showFileOpen: () => i.showFileOpen,
|
|
3752
|
+
onOpenDocument: () => Et.value?.click()
|
|
3753
|
+
});
|
|
3754
|
+
let { addComment: gn, replyToComment: _n, resolveComment: vn, proposeChange: yn, handleCommentReply: xn, handleCommentResolve: Sn, handleCommentUnresolve: Cn, handleCommentDelete: wn, handleAcceptChange: En, handleRejectChange: kn, handleAcceptChangeById: An, handleRejectChangeById: Mn, handleTrackedChangeReply: Nn } = bi({
|
|
3755
|
+
editorView: Z,
|
|
3756
|
+
getDocument: Q,
|
|
3757
|
+
comments: J,
|
|
3758
|
+
trackedChanges: ge,
|
|
3759
|
+
showSidebar: G,
|
|
3760
|
+
isAddingComment: me,
|
|
3761
|
+
pendingCommentRange: vt,
|
|
3762
|
+
contentChangeSubscribers: C,
|
|
3763
|
+
extractCommentsAndChanges: xt,
|
|
3764
|
+
emit: o,
|
|
3765
|
+
commentIdAllocator: gt,
|
|
3766
|
+
author: d,
|
|
3767
|
+
commentCallbacks: Qe,
|
|
3768
|
+
getHfPmViews: qe
|
|
3769
|
+
}), { selectedImage: Pn, imageInteracting: Fn, imageToolbarContext: In, handleToolbarImageWrap: Rn, handleImageTransform: zn } = Ci({
|
|
3770
|
+
editorView: Z,
|
|
3771
|
+
zoom: X,
|
|
3772
|
+
stateTick: S,
|
|
3773
|
+
getCommands: We
|
|
3774
|
+
}), Bn = ne(), Vn = null, { tableInsertButton: Un, hfEdit: $, scrollPageInfo: Wn, resolvePos: Gn, setPmSelection: Kn, scrollVisiblePositionIntoView: qn, handlePagesMouseDown: Jn, handlePagesMouseMove: Yn, handlePagesClick: Xn, handlePagesDoubleClick: Zn, handleTableInsertClick: Qn, clearTableInsertTimer: $n, handleHfSave: er, handleHfRemove: tr } = Ni({
|
|
3775
|
+
editorView: Z,
|
|
3776
|
+
pagesRef: v,
|
|
3777
|
+
pagesViewportRef: x,
|
|
3778
|
+
selectedImage: Pn,
|
|
3779
|
+
imageInteracting: Fn,
|
|
3780
|
+
hyperlinkPopupData: Ft,
|
|
3781
|
+
readOnly: u,
|
|
3782
|
+
zoom: X,
|
|
3783
|
+
layout: Le,
|
|
3784
|
+
tableResize: Bn,
|
|
3785
|
+
getCommands: We,
|
|
3786
|
+
getDocument: Q,
|
|
3787
|
+
reLayout: Ge,
|
|
3788
|
+
emit: o,
|
|
3789
|
+
clearOverlay: mr,
|
|
3790
|
+
syncHfPMs: Je,
|
|
3791
|
+
getHfPmView: Ke,
|
|
3792
|
+
setDocument: Ze
|
|
3793
|
+
}), { contextMenu: nr, imageContextMenu: rr, imageContextMenuTextActions: ir, handleContextMenu: ar, handleSelectedImageContextMenu: or, handleImageWrapSelect: sr, handleContextMenuAction: cr } = ji({
|
|
3794
|
+
editorView: Z,
|
|
3795
|
+
selectedImage: Pn,
|
|
3796
|
+
zoom: X,
|
|
3797
|
+
showImageProperties: P,
|
|
3798
|
+
getCommands: We,
|
|
3799
|
+
clearOverlay: mr,
|
|
3800
|
+
setPmSelection: Kn,
|
|
3801
|
+
resolvePos: Gn
|
|
3802
|
+
}), { handleMenuAction: lr, handleMenuTableInsert: ur } = Fi({
|
|
3803
|
+
editorView: Z,
|
|
3804
|
+
getCommands: We,
|
|
3805
|
+
docxInputRef: Et,
|
|
3806
|
+
imageInputRef: Dt,
|
|
3807
|
+
showPageSetup: se,
|
|
3808
|
+
showWatermark: cn,
|
|
3809
|
+
showHyperlink: oe,
|
|
3810
|
+
showInsertSymbol: M,
|
|
3811
|
+
showKeyboardShortcuts: pe,
|
|
3812
|
+
handleClearFormatting: Vt,
|
|
3813
|
+
handleInsertPageBreak: Ut,
|
|
3814
|
+
handleInsertSectionBreakNextPage: Wt,
|
|
3815
|
+
handleInsertSectionBreakContinuous: Gt,
|
|
3816
|
+
handleToggleOutline: fn,
|
|
3817
|
+
handleToggleSidebar: mn,
|
|
3818
|
+
downloadCurrentDocument: jt,
|
|
3819
|
+
emit: o
|
|
3820
|
+
});
|
|
3821
|
+
Ii({
|
|
3822
|
+
documentBuffer: () => i.documentBuffer,
|
|
3823
|
+
document: () => i.document,
|
|
3824
|
+
loadDocumentBuffer: Mt,
|
|
3825
|
+
loadDocument: Nt,
|
|
3826
|
+
sidebarAutoOpenedRef: bt
|
|
3827
|
+
});
|
|
3828
|
+
let dr = () => Z.value, fr = () => v.value;
|
|
3829
|
+
K(() => i.mode, (e) => {
|
|
3830
|
+
e && e !== c.value && (c.value = e);
|
|
3831
|
+
}), K(() => i.showOutline, (e) => {
|
|
3832
|
+
W.value = !!e;
|
|
3833
|
+
});
|
|
3834
|
+
function pr(e) {
|
|
3835
|
+
c.value !== e && (c.value = e, o("mode-change", e));
|
|
3836
|
+
}
|
|
3837
|
+
R(() => {
|
|
3838
|
+
Vn = Bn.install();
|
|
3839
|
+
}), L(() => {
|
|
3840
|
+
Vn?.();
|
|
3841
|
+
});
|
|
3842
|
+
function mr() {
|
|
3843
|
+
gr.clearOverlay();
|
|
3844
|
+
}
|
|
3845
|
+
function hr() {
|
|
3846
|
+
gr.updateSelectionOverlay();
|
|
3847
|
+
}
|
|
3848
|
+
let gr = Pi({
|
|
3849
|
+
editorView: Z,
|
|
3850
|
+
pagesRef: v,
|
|
3851
|
+
zoom: X,
|
|
3852
|
+
selectedImage: Pn,
|
|
3853
|
+
isHfEditing: D(() => $.value !== null),
|
|
3854
|
+
imageInteracting: Fn
|
|
3855
|
+
}), _r = E.onRender(() => hr());
|
|
3856
|
+
hr(), L(() => {
|
|
3857
|
+
_r(), mr();
|
|
3858
|
+
});
|
|
3859
|
+
let { exposed: vr } = Li({
|
|
3860
|
+
editorView: Z,
|
|
3861
|
+
layout: Le,
|
|
3862
|
+
pagesRef: v,
|
|
3863
|
+
pagesViewportRef: x,
|
|
3864
|
+
zoom: X,
|
|
3865
|
+
comments: J,
|
|
3866
|
+
focus: He,
|
|
3867
|
+
destroy: Ue,
|
|
3868
|
+
getDocument: Q,
|
|
3869
|
+
setZoom: we,
|
|
3870
|
+
save: Pt,
|
|
3871
|
+
loadDocument: Nt,
|
|
3872
|
+
loadDocumentBuffer: Mt,
|
|
3873
|
+
addComment: gn,
|
|
3874
|
+
replyToComment: _n,
|
|
3875
|
+
resolveComment: vn,
|
|
3876
|
+
proposeChange: yn,
|
|
3877
|
+
applyFormatting: Jt,
|
|
3878
|
+
setParagraphStyle: Yt,
|
|
3879
|
+
insertBreak: Xt,
|
|
3880
|
+
scrollVisiblePositionIntoView: qn,
|
|
3881
|
+
contentChangeSubscribers: C,
|
|
3882
|
+
selectionChangeSubscribers: re,
|
|
3883
|
+
onPrint: i.onPrint
|
|
3884
|
+
});
|
|
3885
|
+
return t(vr), (t, n) => (z(), A("div", {
|
|
3886
|
+
class: F([
|
|
3887
|
+
"docx-editor-vue ep-root paged-editor",
|
|
3888
|
+
U(s) ? "dark" : "",
|
|
3889
|
+
e.className,
|
|
3890
|
+
{
|
|
3891
|
+
"paged-editor--readonly": u.value,
|
|
3892
|
+
"paged-editor--hf-editing": U($) !== null,
|
|
3893
|
+
"paged-editor--editing-header": U($)?.position === "header",
|
|
3894
|
+
"paged-editor--editing-footer": U($)?.position === "footer"
|
|
3895
|
+
}
|
|
3896
|
+
]),
|
|
3897
|
+
style: I(e.style)
|
|
3898
|
+
}, [
|
|
3899
|
+
j("div", Vi, [N(Hn, {
|
|
3900
|
+
"show-menu-bar": e.showMenuBar,
|
|
3901
|
+
"document-name": e.documentName,
|
|
3902
|
+
"document-name-editable": e.documentNameEditable,
|
|
3903
|
+
"show-file-open": e.showFileOpen,
|
|
3904
|
+
"show-help-menu": e.showHelpMenu,
|
|
3905
|
+
"render-logo": e.renderLogo,
|
|
3906
|
+
"render-title-bar-right": e.renderTitleBarRight,
|
|
3907
|
+
onRename: U(At),
|
|
3908
|
+
onMenuAction: U(lr),
|
|
3909
|
+
onInsertTable: U(ur)
|
|
3910
|
+
}, {
|
|
3911
|
+
"title-bar-left": he(() => [ue(t.$slots, "title-bar-left")]),
|
|
3912
|
+
"title-bar-right": he(() => [ue(t.$slots, "title-bar-right")]),
|
|
3913
|
+
_: 3
|
|
3914
|
+
}, 8, [
|
|
3915
|
+
"show-menu-bar",
|
|
3916
|
+
"document-name",
|
|
3917
|
+
"document-name-editable",
|
|
3918
|
+
"show-file-open",
|
|
3919
|
+
"show-help-menu",
|
|
3920
|
+
"render-logo",
|
|
3921
|
+
"render-title-bar-right",
|
|
3922
|
+
"onRename",
|
|
3923
|
+
"onMenuAction",
|
|
3924
|
+
"onInsertTable"
|
|
3925
|
+
]), e.showToolbar ? (z(), O(f, {
|
|
3926
|
+
key: 0,
|
|
3927
|
+
view: ct.value,
|
|
3928
|
+
"get-commands": U(We),
|
|
3929
|
+
"state-tick": S.value,
|
|
3930
|
+
"zoom-percent": U(xe),
|
|
3931
|
+
"is-min-zoom": U(Se),
|
|
3932
|
+
"is-max-zoom": U(Ce),
|
|
3933
|
+
"zoom-presets": U(Ne),
|
|
3934
|
+
"show-zoom-control": e.showZoomControl,
|
|
3935
|
+
"editor-mode": c.value,
|
|
3936
|
+
"comments-sidebar-open": U(G),
|
|
3937
|
+
"image-context": U(In),
|
|
3938
|
+
theme: tt.value,
|
|
3939
|
+
"font-families": e.fontFamilies,
|
|
3940
|
+
"document-fonts": U(Ie),
|
|
3941
|
+
"document-styles": nt.value,
|
|
3942
|
+
onInsertLink: n[0] ||= (e) => oe.value = !0,
|
|
3943
|
+
onApplyStyle: U(Ht),
|
|
3944
|
+
onZoomIn: U(Te),
|
|
3945
|
+
onZoomOut: U(Ee),
|
|
3946
|
+
onZoomSet: U(we),
|
|
3947
|
+
onToggleSidebar: U(mn),
|
|
3948
|
+
onModeChange: pr,
|
|
3949
|
+
onImageWrapType: U(Rn),
|
|
3950
|
+
onImageProperties: n[1] ||= (e) => P.value = !0,
|
|
3951
|
+
onImageTransform: U(zn)
|
|
3952
|
+
}, ae({
|
|
3953
|
+
"table-context": he(() => [N(p, {
|
|
3954
|
+
view: ct.value,
|
|
3955
|
+
"get-commands": U(We),
|
|
3956
|
+
"state-tick": S.value,
|
|
3957
|
+
theme: tt.value
|
|
3958
|
+
}, null, 8, [
|
|
3959
|
+
"view",
|
|
3960
|
+
"get-commands",
|
|
3961
|
+
"state-tick",
|
|
3962
|
+
"theme"
|
|
3963
|
+
])]),
|
|
3964
|
+
_: 2
|
|
3965
|
+
}, [e.toolbarExtra ? {
|
|
3966
|
+
name: "toolbar-extra",
|
|
3967
|
+
fn: he(() => [(z(), O(de(e.toolbarExtra)))]),
|
|
3968
|
+
key: "0"
|
|
3969
|
+
} : {
|
|
3970
|
+
name: "toolbar-extra",
|
|
3971
|
+
fn: he(() => [ue(t.$slots, "toolbar-extra")]),
|
|
3972
|
+
key: "1"
|
|
3973
|
+
}]), 1032, [
|
|
3974
|
+
"view",
|
|
3975
|
+
"get-commands",
|
|
3976
|
+
"state-tick",
|
|
3977
|
+
"zoom-percent",
|
|
3978
|
+
"is-min-zoom",
|
|
3979
|
+
"is-max-zoom",
|
|
3980
|
+
"zoom-presets",
|
|
3981
|
+
"show-zoom-control",
|
|
3982
|
+
"editor-mode",
|
|
3983
|
+
"comments-sidebar-open",
|
|
3984
|
+
"image-context",
|
|
3985
|
+
"theme",
|
|
3986
|
+
"font-families",
|
|
3987
|
+
"document-fonts",
|
|
3988
|
+
"document-styles",
|
|
3989
|
+
"onApplyStyle",
|
|
3990
|
+
"onZoomIn",
|
|
3991
|
+
"onZoomOut",
|
|
3992
|
+
"onZoomSet",
|
|
3993
|
+
"onToggleSidebar",
|
|
3994
|
+
"onImageWrapType",
|
|
3995
|
+
"onImageTransform"
|
|
3996
|
+
])) : k("", !0)]),
|
|
3997
|
+
N(Mr, {
|
|
3998
|
+
"show-find-replace": ie.value,
|
|
3999
|
+
"onUpdate:showFindReplace": n[2] ||= (e) => ie.value = e,
|
|
4000
|
+
"show-hyperlink": oe.value,
|
|
4001
|
+
"onUpdate:showHyperlink": n[3] ||= (e) => oe.value = e,
|
|
4002
|
+
"show-insert-symbol": M.value,
|
|
4003
|
+
"onUpdate:showInsertSymbol": n[4] ||= (e) => M.value = e,
|
|
4004
|
+
"show-image-properties": P.value,
|
|
4005
|
+
"onUpdate:showImageProperties": n[5] ||= (e) => P.value = e,
|
|
4006
|
+
"show-page-setup": se.value,
|
|
4007
|
+
"onUpdate:showPageSetup": n[6] ||= (e) => se.value = e,
|
|
4008
|
+
"show-watermark": U(cn),
|
|
4009
|
+
"onUpdate:showWatermark": n[7] ||= (e) => ce(cn) ? cn.value = e : null,
|
|
4010
|
+
"show-keyboard-shortcuts": pe.value,
|
|
4011
|
+
"onUpdate:showKeyboardShortcuts": n[8] ||= (e) => pe.value = e,
|
|
4012
|
+
view: U(Z),
|
|
4013
|
+
bookmarks: mt.value,
|
|
4014
|
+
"selected-image-pm-pos": U(Pn)?.pmPos ?? null,
|
|
4015
|
+
"section-properties": $e.value,
|
|
4016
|
+
"current-watermark": U(ln),
|
|
4017
|
+
"watermark-presets": e.watermarkPresets,
|
|
4018
|
+
"scroll-visible-position-into-view": U(qn),
|
|
4019
|
+
onInsertSymbol: U(qt),
|
|
4020
|
+
onHyperlinkSubmit: U(It),
|
|
4021
|
+
onHyperlinkRemove: U(Lt),
|
|
4022
|
+
onPageSetupApply: U(Zt),
|
|
4023
|
+
onWatermarkApply: U(dn)
|
|
4024
|
+
}, null, 8, [
|
|
4025
|
+
"show-find-replace",
|
|
4026
|
+
"show-hyperlink",
|
|
4027
|
+
"show-insert-symbol",
|
|
4028
|
+
"show-image-properties",
|
|
4029
|
+
"show-page-setup",
|
|
4030
|
+
"show-watermark",
|
|
4031
|
+
"show-keyboard-shortcuts",
|
|
4032
|
+
"view",
|
|
4033
|
+
"bookmarks",
|
|
4034
|
+
"selected-image-pm-pos",
|
|
4035
|
+
"section-properties",
|
|
4036
|
+
"current-watermark",
|
|
4037
|
+
"watermark-presets",
|
|
4038
|
+
"scroll-visible-position-into-view",
|
|
4039
|
+
"onInsertSymbol",
|
|
4040
|
+
"onHyperlinkSubmit",
|
|
4041
|
+
"onHyperlinkRemove",
|
|
4042
|
+
"onPageSetupApply",
|
|
4043
|
+
"onWatermarkApply"
|
|
4044
|
+
]),
|
|
4045
|
+
U(Fe) ? (z(), A("div", Hi, H(U(Fe)), 1)) : k("", !0),
|
|
4046
|
+
!U(Pe) && !U(Fe) ? (z(), A("div", Ui, "Loading...")) : k("", !0),
|
|
4047
|
+
j("div", {
|
|
4048
|
+
ref_key: "hiddenPmRef",
|
|
4049
|
+
ref: _,
|
|
4050
|
+
class: "docx-editor-vue__hidden-pm paged-editor__hidden-pm"
|
|
4051
|
+
}, null, 512),
|
|
4052
|
+
j("div", {
|
|
4053
|
+
class: "docx-editor-vue__editor-scroll",
|
|
4054
|
+
onMousedown: n[29] ||= (...e) => U(hn) && U(hn)(...e)
|
|
4055
|
+
}, [j("div", Wi, [
|
|
4056
|
+
j("div", {
|
|
4057
|
+
ref_key: "pagesViewportRef",
|
|
4058
|
+
ref: x,
|
|
4059
|
+
class: "docx-editor-vue__pages-viewport",
|
|
4060
|
+
onMousedown: n[22] ||= (...e) => U(Jn) && U(Jn)(...e),
|
|
4061
|
+
onMousemove: n[23] ||= (...e) => U(Yn) && U(Yn)(...e),
|
|
4062
|
+
onClick: n[24] ||= (...e) => U(Xn) && U(Xn)(...e),
|
|
4063
|
+
onDblclick: n[25] ||= (...e) => U(Zn) && U(Zn)(...e),
|
|
4064
|
+
onContextmenu: n[26] ||= Y((...e) => U(ar) && U(ar)(...e), ["prevent"]),
|
|
4065
|
+
onWheel: n[27] ||= (...e) => U(De) && U(De)(...e)
|
|
4066
|
+
}, [
|
|
4067
|
+
e.showRuler && $e.value ? (z(), A("div", {
|
|
4068
|
+
key: 0,
|
|
4069
|
+
class: "docx-editor-vue__ruler-row",
|
|
4070
|
+
style: I(dt.value)
|
|
4071
|
+
}, [N(m, {
|
|
4072
|
+
"section-props": $e.value,
|
|
4073
|
+
zoom: U(X),
|
|
4074
|
+
editable: !u.value,
|
|
4075
|
+
"indent-left": et.value.indentLeft,
|
|
4076
|
+
"indent-right": et.value.indentRight,
|
|
4077
|
+
"first-line-indent": et.value.firstLineIndent,
|
|
4078
|
+
"hanging-indent": et.value.hangingIndent,
|
|
4079
|
+
"tab-stops": et.value.tabStops,
|
|
4080
|
+
onLeftMarginChange: U(Qt),
|
|
4081
|
+
onRightMarginChange: U($t),
|
|
4082
|
+
onIndentLeftChange: U(nn),
|
|
4083
|
+
onIndentRightChange: U(an),
|
|
4084
|
+
onFirstLineIndentChange: U(on),
|
|
4085
|
+
onTabStopRemove: U(sn)
|
|
4086
|
+
}, null, 8, [
|
|
4087
|
+
"section-props",
|
|
4088
|
+
"zoom",
|
|
4089
|
+
"editable",
|
|
4090
|
+
"indent-left",
|
|
4091
|
+
"indent-right",
|
|
4092
|
+
"first-line-indent",
|
|
4093
|
+
"hanging-indent",
|
|
4094
|
+
"tab-stops",
|
|
4095
|
+
"onLeftMarginChange",
|
|
4096
|
+
"onRightMarginChange",
|
|
4097
|
+
"onIndentLeftChange",
|
|
4098
|
+
"onIndentRightChange",
|
|
4099
|
+
"onFirstLineIndentChange",
|
|
4100
|
+
"onTabStopRemove"
|
|
4101
|
+
])], 4)) : k("", !0),
|
|
4102
|
+
j("div", {
|
|
4103
|
+
class: "docx-editor-vue__editor-content-wrapper",
|
|
4104
|
+
style: I({
|
|
4105
|
+
position: "relative",
|
|
4106
|
+
display: "flex",
|
|
4107
|
+
flex: "1 0 auto",
|
|
4108
|
+
flexDirection: "column",
|
|
4109
|
+
minHeight: "100%",
|
|
4110
|
+
minWidth: lt.value + "px"
|
|
4111
|
+
})
|
|
4112
|
+
}, [e.showRuler && $e.value ? (z(), A("div", Gi, [N(y, {
|
|
4113
|
+
"section-props": $e.value,
|
|
4114
|
+
zoom: U(X),
|
|
4115
|
+
editable: !u.value,
|
|
4116
|
+
onTopMarginChange: U(en),
|
|
4117
|
+
onBottomMarginChange: U(tn)
|
|
4118
|
+
}, null, 8, [
|
|
4119
|
+
"section-props",
|
|
4120
|
+
"zoom",
|
|
4121
|
+
"editable",
|
|
4122
|
+
"onTopMarginChange",
|
|
4123
|
+
"onBottomMarginChange"
|
|
4124
|
+
])])) : k("", !0), j("div", {
|
|
4125
|
+
ref_key: "pagesRef",
|
|
4126
|
+
ref: v,
|
|
4127
|
+
class: "docx-editor-vue__pages paged-editor__pages",
|
|
4128
|
+
style: I(ut.value)
|
|
4129
|
+
}, null, 4)], 4),
|
|
4130
|
+
u.value ? k("", !0) : (z(), O(Ln, {
|
|
4131
|
+
key: 1,
|
|
4132
|
+
container: v.value,
|
|
4133
|
+
view: U(Z)
|
|
4134
|
+
}, null, 8, ["container", "view"])),
|
|
4135
|
+
N(jn, {
|
|
4136
|
+
"is-open": U($) !== null,
|
|
4137
|
+
position: U($)?.position ?? "header",
|
|
4138
|
+
view: st.value,
|
|
4139
|
+
"target-rect": U($)?.targetRect ?? null,
|
|
4140
|
+
onSave: U(er),
|
|
4141
|
+
onClose: n[9] ||= (e) => $.value = null,
|
|
4142
|
+
onRemove: U(tr)
|
|
4143
|
+
}, null, 8, [
|
|
4144
|
+
"is-open",
|
|
4145
|
+
"position",
|
|
4146
|
+
"view",
|
|
4147
|
+
"target-rect",
|
|
4148
|
+
"onSave",
|
|
4149
|
+
"onRemove"
|
|
4150
|
+
]),
|
|
4151
|
+
(z(!0), A(T, null, V(U($) ? it.value : [], (e, t) => (z(), A("div", {
|
|
4152
|
+
key: `hf-sel-${t}-${e.top}-${e.left}`,
|
|
4153
|
+
class: "vue-hf-sel-rect",
|
|
4154
|
+
"aria-hidden": "true",
|
|
4155
|
+
style: I({
|
|
4156
|
+
position: "fixed",
|
|
4157
|
+
top: `${e.top}px`,
|
|
4158
|
+
left: `${e.left}px`,
|
|
4159
|
+
width: `${e.width}px`,
|
|
4160
|
+
height: `${e.height}px`,
|
|
4161
|
+
background: "var(--doc-selection)",
|
|
4162
|
+
pointerEvents: "none",
|
|
4163
|
+
zIndex: 9998
|
|
4164
|
+
})
|
|
4165
|
+
}, null, 4))), 128)),
|
|
4166
|
+
U($) && rt.value ? (z(), A("div", {
|
|
4167
|
+
key: 2,
|
|
4168
|
+
"aria-hidden": "true",
|
|
4169
|
+
style: I({
|
|
4170
|
+
position: "fixed",
|
|
4171
|
+
top: `${rt.value.top}px`,
|
|
4172
|
+
left: `${rt.value.left}px`,
|
|
4173
|
+
width: "2px",
|
|
4174
|
+
height: `${rt.value.height}px`,
|
|
4175
|
+
background: "#4285f4",
|
|
4176
|
+
pointerEvents: "none",
|
|
4177
|
+
zIndex: 9999,
|
|
4178
|
+
animation: "hf-caret-blink 1.06s steps(1) infinite"
|
|
4179
|
+
})
|
|
4180
|
+
}, null, 4)) : k("", !0),
|
|
4181
|
+
N(bn, {
|
|
4182
|
+
"image-info": U(Pn),
|
|
4183
|
+
zoom: U(X),
|
|
4184
|
+
view: U(Z),
|
|
4185
|
+
onOpenProperties: n[10] ||= (e) => P.value = !0,
|
|
4186
|
+
onDeselect: n[11] ||= (e) => Pn.value = null,
|
|
4187
|
+
onInteractStart: n[12] ||= (e) => Fn.value = !0,
|
|
4188
|
+
onInteractEnd: n[13] ||= (e) => Fn.value = !1,
|
|
4189
|
+
onContextMenu: U(or)
|
|
4190
|
+
}, null, 8, [
|
|
4191
|
+
"image-info",
|
|
4192
|
+
"zoom",
|
|
4193
|
+
"view",
|
|
4194
|
+
"onContextMenu"
|
|
4195
|
+
]),
|
|
4196
|
+
N(un, {
|
|
4197
|
+
"get-view": dr,
|
|
4198
|
+
"get-pages-container": fr,
|
|
4199
|
+
zoom: U(X),
|
|
4200
|
+
"transaction-version": S.value,
|
|
4201
|
+
"sync-coordinator": U(E)
|
|
4202
|
+
}, null, 8, [
|
|
4203
|
+
"zoom",
|
|
4204
|
+
"transaction-version",
|
|
4205
|
+
"sync-coordinator"
|
|
4206
|
+
]),
|
|
4207
|
+
U(_t) && !me.value && !u.value ? (z(), A("button", {
|
|
4208
|
+
key: 3,
|
|
4209
|
+
type: "button",
|
|
4210
|
+
class: "docx-editor-vue__floating-comment",
|
|
4211
|
+
style: I({
|
|
4212
|
+
top: U(_t).top + "px",
|
|
4213
|
+
left: U(_t).left + "px"
|
|
4214
|
+
}),
|
|
4215
|
+
title: U(g)("comments.addComment"),
|
|
4216
|
+
onMousedown: n[14] ||= Y((...e) => U(wt) && U(wt)(...e), ["prevent", "stop"])
|
|
4217
|
+
}, [N(r, {
|
|
4218
|
+
name: "add_comment",
|
|
4219
|
+
size: 16
|
|
4220
|
+
})], 44, Ki)) : k("", !0),
|
|
4221
|
+
U(Un) && !u.value ? (z(), A("button", {
|
|
4222
|
+
key: 4,
|
|
4223
|
+
type: "button",
|
|
4224
|
+
class: "docx-editor-vue__table-insert-btn",
|
|
4225
|
+
style: I({
|
|
4226
|
+
left: U(Un).x + "px",
|
|
4227
|
+
top: U(Un).y + "px"
|
|
4228
|
+
}),
|
|
4229
|
+
title: U(Un).type === "row" ? "Insert row below" : "Insert column to the right",
|
|
4230
|
+
"aria-label": U(Un).type === "row" ? "Insert row below" : "Insert column to the right",
|
|
4231
|
+
onMousedown: n[15] ||= (...e) => U(Qn) && U(Qn)(...e),
|
|
4232
|
+
onMouseenter: n[16] ||= (...e) => U($n) && U($n)(...e),
|
|
4233
|
+
onMouseleave: n[17] ||= (e) => Un.value = null
|
|
4234
|
+
}, [...n[35] ||= [j("svg", {
|
|
4235
|
+
width: "12",
|
|
4236
|
+
height: "12",
|
|
4237
|
+
viewBox: "0 0 12 12",
|
|
4238
|
+
fill: "none"
|
|
4239
|
+
}, [j("path", {
|
|
4240
|
+
d: "M6 1v10M1 6h10",
|
|
4241
|
+
stroke: "currentColor",
|
|
4242
|
+
"stroke-width": "1.5",
|
|
4243
|
+
"stroke-linecap": "round"
|
|
4244
|
+
})], -1)]], 44, qi)) : k("", !0),
|
|
4245
|
+
N(h, {
|
|
4246
|
+
comments: J.value,
|
|
4247
|
+
"pages-container": v.value,
|
|
4248
|
+
zoom: U(X),
|
|
4249
|
+
"page-width-px": ft.value,
|
|
4250
|
+
"sidebar-open": U(G),
|
|
4251
|
+
"resolved-comment-ids": pt.value,
|
|
4252
|
+
onMarkerClick: U(Tt)
|
|
4253
|
+
}, null, 8, [
|
|
4254
|
+
"comments",
|
|
4255
|
+
"pages-container",
|
|
4256
|
+
"zoom",
|
|
4257
|
+
"page-width-px",
|
|
4258
|
+
"sidebar-open",
|
|
4259
|
+
"resolved-comment-ids",
|
|
4260
|
+
"onMarkerClick"
|
|
4261
|
+
]),
|
|
4262
|
+
N(ee, {
|
|
4263
|
+
"is-open": U(G),
|
|
4264
|
+
comments: J.value,
|
|
4265
|
+
"tracked-changes": ge.value,
|
|
4266
|
+
"is-adding-comment": me.value,
|
|
4267
|
+
"add-comment-y-position": U(yt),
|
|
4268
|
+
"show-resolved": !0,
|
|
4269
|
+
"pages-container": v.value,
|
|
4270
|
+
"page-width-px": ft.value,
|
|
4271
|
+
zoom: U(X),
|
|
4272
|
+
"active-item-id": q.value,
|
|
4273
|
+
onClose: n[18] ||= (e) => G.value = !1,
|
|
4274
|
+
onAddComment: U(St),
|
|
4275
|
+
onCancelAddComment: U(Ct),
|
|
4276
|
+
onCommentReply: U(xn),
|
|
4277
|
+
onCommentResolve: U(Sn),
|
|
4278
|
+
onCommentUnresolve: U(Cn),
|
|
4279
|
+
onCommentDelete: U(wn),
|
|
4280
|
+
onAcceptChange: U(En),
|
|
4281
|
+
onRejectChange: U(kn),
|
|
4282
|
+
onAcceptChangeById: U(An),
|
|
4283
|
+
onRejectChangeById: U(Mn),
|
|
4284
|
+
onTrackedChangeReply: U(Nn),
|
|
4285
|
+
"onUpdate:activeItemId": n[19] ||= (e) => q.value = e
|
|
4286
|
+
}, null, 8, [
|
|
4287
|
+
"is-open",
|
|
4288
|
+
"comments",
|
|
4289
|
+
"tracked-changes",
|
|
4290
|
+
"is-adding-comment",
|
|
4291
|
+
"add-comment-y-position",
|
|
4292
|
+
"pages-container",
|
|
4293
|
+
"page-width-px",
|
|
4294
|
+
"zoom",
|
|
4295
|
+
"active-item-id",
|
|
4296
|
+
"onAddComment",
|
|
4297
|
+
"onCancelAddComment",
|
|
4298
|
+
"onCommentReply",
|
|
4299
|
+
"onCommentResolve",
|
|
4300
|
+
"onCommentUnresolve",
|
|
4301
|
+
"onCommentDelete",
|
|
4302
|
+
"onAcceptChange",
|
|
4303
|
+
"onRejectChange",
|
|
4304
|
+
"onAcceptChangeById",
|
|
4305
|
+
"onRejectChangeById",
|
|
4306
|
+
"onTrackedChangeReply"
|
|
4307
|
+
]),
|
|
4308
|
+
N(fi, {
|
|
4309
|
+
data: U(Ft),
|
|
4310
|
+
"read-only": u.value,
|
|
4311
|
+
onNavigate: U(Rt),
|
|
4312
|
+
onCopy: n[20] ||= (e) => Ft.value = null,
|
|
4313
|
+
onEdit: U(zt),
|
|
4314
|
+
onRemove: U(Bt),
|
|
4315
|
+
onClose: n[21] ||= (e) => Ft.value = null
|
|
4316
|
+
}, null, 8, [
|
|
4317
|
+
"data",
|
|
4318
|
+
"read-only",
|
|
4319
|
+
"onNavigate",
|
|
4320
|
+
"onEdit",
|
|
4321
|
+
"onRemove"
|
|
4322
|
+
])
|
|
4323
|
+
], 544),
|
|
4324
|
+
!W.value && e.showOutlineButton ? (z(), O(Dn, {
|
|
4325
|
+
key: 0,
|
|
4326
|
+
"left-offset": e.showRuler ? 32 : 12,
|
|
4327
|
+
"top-px": e.showRuler ? 54 : 24,
|
|
4328
|
+
onToggle: U(fn)
|
|
4329
|
+
}, null, 8, [
|
|
4330
|
+
"left-offset",
|
|
4331
|
+
"top-px",
|
|
4332
|
+
"onToggle"
|
|
4333
|
+
])) : k("", !0),
|
|
4334
|
+
U(Wn).totalPages > 1 ? (z(), O(On, {
|
|
4335
|
+
key: 1,
|
|
4336
|
+
"current-page": U(Wn).currentPage,
|
|
4337
|
+
"total-pages": U(Wn).totalPages,
|
|
4338
|
+
visible: U(Wn).visible
|
|
4339
|
+
}, null, 8, [
|
|
4340
|
+
"current-page",
|
|
4341
|
+
"total-pages",
|
|
4342
|
+
"visible"
|
|
4343
|
+
])) : k("", !0),
|
|
4344
|
+
N(Tn, {
|
|
4345
|
+
"is-open": W.value,
|
|
4346
|
+
headings: ve.value,
|
|
4347
|
+
"left-offset": e.showRuler ? 32 : 12,
|
|
4348
|
+
"top-px": e.showRuler ? 54 : 24,
|
|
4349
|
+
onClose: n[28] ||= (e) => W.value = !1,
|
|
4350
|
+
onNavigate: U(pn)
|
|
4351
|
+
}, null, 8, [
|
|
4352
|
+
"is-open",
|
|
4353
|
+
"headings",
|
|
4354
|
+
"left-offset",
|
|
4355
|
+
"top-px",
|
|
4356
|
+
"onNavigate"
|
|
4357
|
+
])
|
|
4358
|
+
])], 32),
|
|
4359
|
+
j("input", {
|
|
4360
|
+
ref_key: "docxInputRef",
|
|
4361
|
+
ref: Et,
|
|
4362
|
+
type: "file",
|
|
4363
|
+
accept: ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
4364
|
+
style: { display: "none" },
|
|
4365
|
+
onChange: n[30] ||= (...e) => U(kt) && U(kt)(...e)
|
|
4366
|
+
}, null, 544),
|
|
4367
|
+
j("input", {
|
|
4368
|
+
ref_key: "imageInputRef",
|
|
4369
|
+
ref: Dt,
|
|
4370
|
+
type: "file",
|
|
4371
|
+
accept: "image/*",
|
|
4372
|
+
style: { display: "none" },
|
|
4373
|
+
onChange: n[31] ||= (...e) => U(Ot) && U(Ot)(...e)
|
|
4374
|
+
}, null, 544),
|
|
4375
|
+
N(ni, {
|
|
4376
|
+
"read-only": u.value,
|
|
4377
|
+
"context-menu": U(nr),
|
|
4378
|
+
"image-context-menu": U(rr),
|
|
4379
|
+
"image-context-menu-text-actions": U(ir),
|
|
4380
|
+
"can-open-image-properties": !!U(Pn),
|
|
4381
|
+
onContextMenuAction: U(cr),
|
|
4382
|
+
onCloseContextMenu: n[32] ||= (e) => U(nr).isOpen = !1,
|
|
4383
|
+
onImageWrapSelect: U(sr),
|
|
4384
|
+
onCloseImageContextMenu: n[33] ||= (e) => rr.value = null,
|
|
4385
|
+
onOpenImageProperties: n[34] ||= (e) => P.value = !0
|
|
4386
|
+
}, null, 8, [
|
|
4387
|
+
"read-only",
|
|
4388
|
+
"context-menu",
|
|
4389
|
+
"image-context-menu",
|
|
4390
|
+
"image-context-menu-text-actions",
|
|
4391
|
+
"can-open-image-properties",
|
|
4392
|
+
"onContextMenuAction",
|
|
4393
|
+
"onImageWrapSelect"
|
|
4394
|
+
])
|
|
4395
|
+
], 6));
|
|
4396
|
+
}
|
|
4397
|
+
});
|
|
4398
|
+
//#endregion
|
|
4399
|
+
//#region src/renderAsync.ts
|
|
4400
|
+
async function $i(e, t, n = {}) {
|
|
4401
|
+
let r = e instanceof ArrayBuffer ? e : await Je(e), i = null, a = null, o = !1, s = {
|
|
4402
|
+
save: async () => {
|
|
4403
|
+
let e = await (i?.save() ?? Promise.resolve(null));
|
|
4404
|
+
return e ? new Blob([e], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }) : null;
|
|
4405
|
+
},
|
|
4406
|
+
getDocument: () => i?.getDocument() ?? null,
|
|
4407
|
+
focus: () => {
|
|
4408
|
+
i?.focus();
|
|
4409
|
+
},
|
|
4410
|
+
setZoom: (e) => {
|
|
4411
|
+
i?.setZoom(e);
|
|
4412
|
+
},
|
|
4413
|
+
scrollToParaId: (e, t) => i?.scrollToParaId(e, t) ?? !1,
|
|
4414
|
+
scrollToPosition: (e) => {
|
|
4415
|
+
i?.scrollToPosition(e);
|
|
4416
|
+
},
|
|
4417
|
+
destroy: () => {
|
|
4418
|
+
i?.destroy(), a?.unmount(), a = null;
|
|
4419
|
+
}
|
|
4420
|
+
};
|
|
4421
|
+
return new Promise((e, c) => {
|
|
4422
|
+
a = ie({ setup() {
|
|
4423
|
+
return () => se(Qi, {
|
|
4424
|
+
...n,
|
|
4425
|
+
documentBuffer: r,
|
|
4426
|
+
showToolbar: n.showToolbar ?? !0,
|
|
4427
|
+
readOnly: n.readOnly ?? !1,
|
|
4428
|
+
ref: (e) => {
|
|
4429
|
+
i = e ?? null;
|
|
4430
|
+
},
|
|
4431
|
+
onReady: () => {
|
|
4432
|
+
n.onReady?.(), o || (o = !0, e(s));
|
|
4433
|
+
},
|
|
4434
|
+
onError: (e) => {
|
|
4435
|
+
n.onError?.(e), o || (o = !0, c(e));
|
|
4436
|
+
},
|
|
4437
|
+
onChange: n.onChange,
|
|
4438
|
+
onRename: n.onRename,
|
|
4439
|
+
onMenuAction: n.onMenuAction,
|
|
4440
|
+
onModeChange: n.onModeChange
|
|
4441
|
+
});
|
|
4442
|
+
} }), a.mount(t);
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
//#endregion
|
|
4446
|
+
//#region src/index.ts
|
|
4447
|
+
var ea = "0.0.2";
|
|
4448
|
+
//#endregion
|
|
4449
|
+
export { Qi as DocxEditor, ea as VERSION, tn as createDocumentWithText, nn as createEmptyDocument, n as defaultLocale, t as i18nPlugin, a as provideLocale, $i as renderAsync, d as useTranslation };
|