@forevka/wordcanvas 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/builder.js +5 -5
- package/dist-lib/{editorApp-Ct42Dpp1.js → editorApp-CRXveGOd.js} +1093 -1088
- package/dist-lib/{engine-Co8wGzPh.js → engine-CDHZLDvx.js} +1 -1
- package/dist-lib/{equationEditor-ufes6INd.js → equationEditor-C8O4iQY0.js} +5 -5
- package/dist-lib/export.js +3 -3
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.js +2 -2
- package/dist-lib/{inlineExport-DmiMGSna.js → inlineExport-DufSrjh6.js} +1 -1
- package/dist-lib/{latex-Bw2eoY11.js → latex-BXHY96IY.js} +2 -2
- package/dist-lib/{parse-B7crTYAa.js → parse-BBIeOUPD.js} +3 -3
- package/dist-lib/{pipeline-CgTexI-5.js → pipeline-BR9aUw6T.js} +1 -1
- package/dist-lib/{pipeline-BxTfzdGp.js → pipeline-CsIYBlrl.js} +6 -6
- package/dist-lib/query.js +3 -3
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/{recalcToc-C0QoMNY9.js → recalcToc-4YmgOJlg.js} +2 -2
- package/dist-lib/{styleProps-Dw6DnP6p.js → styleProps-hQ-xcGCW.js} +1 -1
- package/dist-lib/{stylesheet-BZQ2DVSJ.js → stylesheet-oa_qg3op.js} +1 -1
- package/dist-lib/{symbolPicker-CC3eVi98.js → symbolPicker-BXTEUH3F.js} +1 -1
- package/dist-lib/{toc-BIVKqYZ1.js → toc-C4oeGLWP.js} +105 -94
- package/dist-lib/{webmcp-CnuYu6Wt.js → webmcp-CC54nQHq.js} +8 -8
- package/dist-lib/{wordcanvas-B4jNWfw7.js → wordcanvas-mL3V3lME.js} +3 -3
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-XHBY3PPO.js → chunk-2BASYQX6.js} +2 -2
- package/dist-node/{chunk-YOBNPVKS.js → chunk-Q2PZZE6W.js} +1 -1
- package/dist-node/chunk-Q2PZZE6W.js.map +7 -0
- package/dist-node/{chunk-RH7KMFDB.js → chunk-RLIU3RM7.js} +2 -2
- package/dist-node/{chunk-WSLT7ILY.js → chunk-VGI576RA.js} +2 -2
- package/dist-node/{engine-WTNLTPJA.js → engine-JO72FQWP.js} +3 -3
- package/dist-node/export.js +4 -4
- package/dist-node/generate-toc.js +4 -4
- package/dist-node/import.js +2 -2
- package/dist-node/recalc-docx.js +2 -2
- package/package.json +1 -1
- package/dist-node/chunk-YOBNPVKS.js.map +0 -7
- /package/dist-node/{chunk-XHBY3PPO.js.map → chunk-2BASYQX6.js.map} +0 -0
- /package/dist-node/{chunk-RH7KMFDB.js.map → chunk-RLIU3RM7.js.map} +0 -0
- /package/dist-node/{chunk-WSLT7ILY.js.map → chunk-VGI576RA.js.map} +0 -0
- /package/dist-node/{engine-WTNLTPJA.js.map → engine-JO72FQWP.js.map} +0 -0
|
@@ -13,10 +13,10 @@ const He = 14, S = [
|
|
|
13
13
|
for (const o of s.rows)
|
|
14
14
|
for (const i of o.cells) n.push(...L(i.blocks, e));
|
|
15
15
|
return n;
|
|
16
|
-
},
|
|
16
|
+
}, j = (t, e) => L(t.section[e] ?? [], !0), ae = (t) => L(t.blocks, !0), z = /* @__PURE__ */ new WeakMap(), ce = (t) => {
|
|
17
17
|
const e = [
|
|
18
18
|
...L(t.blocks, !0),
|
|
19
|
-
...S.flatMap((s) =>
|
|
19
|
+
...S.flatMap((s) => j(t, s)),
|
|
20
20
|
...Object.values(t.footnotes ?? {}).flat(),
|
|
21
21
|
...Object.values(t.endnotes ?? {}).flat()
|
|
22
22
|
], n = /* @__PURE__ */ new Map();
|
|
@@ -25,48 +25,48 @@ const He = 14, S = [
|
|
|
25
25
|
n.has(o) || n.set(o, s);
|
|
26
26
|
}
|
|
27
27
|
return { list: e, byId: n };
|
|
28
|
-
},
|
|
29
|
-
let e =
|
|
30
|
-
return e || (e =
|
|
31
|
-
},
|
|
32
|
-
const n =
|
|
28
|
+
}, _ = (t) => {
|
|
29
|
+
let e = z.get(t);
|
|
30
|
+
return e || (e = ce(t), z.set(t, e)), e;
|
|
31
|
+
}, de = (t) => _(t).list, fe = (t, e) => {
|
|
32
|
+
const n = _(t), s = n.byId.get(e);
|
|
33
33
|
return s === void 0 ? void 0 : n.list[s];
|
|
34
|
-
},
|
|
35
|
-
const n =
|
|
34
|
+
}, De = (t, e) => {
|
|
35
|
+
const n = _(t).byId.get(e);
|
|
36
36
|
return n === void 0 ? -1 : n;
|
|
37
|
-
},
|
|
38
|
-
let e =
|
|
37
|
+
}, U = /* @__PURE__ */ new WeakMap(), ue = (t) => {
|
|
38
|
+
let e = U.get(t);
|
|
39
39
|
if (!e) {
|
|
40
40
|
const n = /* @__PURE__ */ new Set();
|
|
41
|
-
for (const s of S) for (const o of
|
|
42
|
-
e = n,
|
|
41
|
+
for (const s of S) for (const o of j(t, s)) n.add(o.id);
|
|
42
|
+
e = n, U.set(t, e);
|
|
43
43
|
}
|
|
44
44
|
return e;
|
|
45
|
-
},
|
|
46
|
-
let e =
|
|
45
|
+
}, X = /* @__PURE__ */ new WeakMap(), We = (t) => {
|
|
46
|
+
let e = X.get(t);
|
|
47
47
|
if (!e) {
|
|
48
|
-
const n =
|
|
49
|
-
e =
|
|
48
|
+
const n = ue(t);
|
|
49
|
+
e = de(t).filter((s) => !n.has(s.id) && !ne(s)), X.set(t, e);
|
|
50
50
|
}
|
|
51
51
|
return e;
|
|
52
|
-
},
|
|
53
|
-
let n =
|
|
54
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
52
|
+
}, Y = /* @__PURE__ */ new WeakMap(), $e = (t, e) => {
|
|
53
|
+
let n = Y.get(t);
|
|
54
|
+
n || (n = /* @__PURE__ */ new Map(), Y.set(t, n));
|
|
55
55
|
let s = n.get(e);
|
|
56
|
-
return s || (s =
|
|
57
|
-
},
|
|
56
|
+
return s || (s = j(t, e).filter((o) => !ne(o)), n.set(e, s)), s;
|
|
57
|
+
}, $ = (t, e) => {
|
|
58
58
|
for (const n of t)
|
|
59
59
|
if (e.add(n.id), n.kind === "table")
|
|
60
|
-
for (const s of n.rows) for (const o of s.cells)
|
|
60
|
+
for (const s of n.rows) for (const o of s.cells) $(o.blocks, e);
|
|
61
61
|
}, qe = (t, e) => {
|
|
62
62
|
const n = /* @__PURE__ */ new Set();
|
|
63
|
-
|
|
64
|
-
for (const s of S)
|
|
63
|
+
$(t.blocks, n);
|
|
64
|
+
for (const s of S) $(t.section[s] ?? [], n);
|
|
65
65
|
for (const s of Object.values(t.footnotes ?? {})) for (const o of s) n.add(o.id);
|
|
66
66
|
for (const s of Object.values(t.endnotes ?? {})) for (const o of s) n.add(o.id);
|
|
67
67
|
return n.has(e);
|
|
68
|
-
}, se = (t, e) => e === "body" ? t.blocks : t.section[e] ?? [],
|
|
69
|
-
function
|
|
68
|
+
}, se = (t, e) => e === "body" ? t.blocks : t.section[e] ?? [], V = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
function he(t) {
|
|
70
70
|
const e = /* @__PURE__ */ new Map(), n = (o, i) => {
|
|
71
71
|
e.has(o) || e.set(o, i);
|
|
72
72
|
}, s = (o, i) => {
|
|
@@ -96,10 +96,10 @@ function ue(t) {
|
|
|
96
96
|
return e;
|
|
97
97
|
}
|
|
98
98
|
function A(t, e) {
|
|
99
|
-
let n =
|
|
100
|
-
return n || (n =
|
|
99
|
+
let n = V.get(t);
|
|
100
|
+
return n || (n = he(t), V.set(t, n)), n.get(e) ?? null;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function q(t, e) {
|
|
103
103
|
return e.kind === "top" ? t.blocks[e.bi] : e.kind === "band" ? t.section[e.band][e.bi] : e.kind === "footnote" ? t.footnotes[e.noteId][e.pi] : e.kind === "endnote" ? t.endnotes[e.noteId][e.pi] : se(t, e.where)[e.bi].rows[e.ri].cells[e.ci].blocks[e.pi];
|
|
104
104
|
}
|
|
105
105
|
function R(t, e, n) {
|
|
@@ -123,7 +123,7 @@ function R(t, e, n) {
|
|
|
123
123
|
return a.blocks[e.pi] = n, r.cells[e.ci] = a, i[e.ri] = r, s[e.bi] = { ...o, rows: i, revision: o.revision + 1 }, e.where === "body" ? { ...t, blocks: s } : { ...t, section: { ...t.section, [e.where]: s } };
|
|
124
124
|
}
|
|
125
125
|
const je = (t, e) => A(t, e)?.kind === "cell", C = (t) => t.map((e) => e.text).join(""), _e = (t, e) => {
|
|
126
|
-
const n =
|
|
126
|
+
const n = fe(t, e);
|
|
127
127
|
return n ? C(n.runs) : "";
|
|
128
128
|
};
|
|
129
129
|
function Ge(t, e) {
|
|
@@ -156,7 +156,7 @@ function Xe(t, e) {
|
|
|
156
156
|
}
|
|
157
157
|
return t.length;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function be(t, e) {
|
|
160
160
|
let n = 0;
|
|
161
161
|
for (const s of t) {
|
|
162
162
|
const o = n + s.text.length;
|
|
@@ -173,7 +173,7 @@ function Ye(t, e) {
|
|
|
173
173
|
n += s.text.length;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function ke(t = {}) {
|
|
177
177
|
return {
|
|
178
178
|
fontFamily: t.fontFamily ?? "Georgia, serif",
|
|
179
179
|
fontSizePx: t.fontSizePx ?? 16,
|
|
@@ -184,7 +184,7 @@ function be(t = {}) {
|
|
|
184
184
|
color: t.color ?? "#202124"
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function ge(t = {}) {
|
|
188
188
|
return {
|
|
189
189
|
align: "left",
|
|
190
190
|
lineHeight: t.lineHeight ?? 1.5,
|
|
@@ -194,7 +194,7 @@ function ke(t = {}) {
|
|
|
194
194
|
indentLeftPx: 0
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
const oe =
|
|
197
|
+
const oe = ke(), Ve = ge();
|
|
198
198
|
function Je(t) {
|
|
199
199
|
const e = t.sdtPath;
|
|
200
200
|
return e && e.length > 0 ? e[e.length - 1] : void 0;
|
|
@@ -203,7 +203,7 @@ function Qe(t, e) {
|
|
|
203
203
|
const n = t?.sdtPath ?? [], s = e.sdtPath ?? [];
|
|
204
204
|
return n.length === 0 ? s.slice() : n.concat(s);
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function me(t, e) {
|
|
207
207
|
const n = t?.length ?? 0, s = e?.length ?? 0;
|
|
208
208
|
if (n !== s) return !1;
|
|
209
209
|
for (let o = 0; o < n; o++) if (t[o] !== e[o]) return !1;
|
|
@@ -228,7 +228,7 @@ function nt(t, e) {
|
|
|
228
228
|
const n = t.indexOf(e);
|
|
229
229
|
return n < 0 ? void 0 : t.slice(0, n + 1);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Ie(t) {
|
|
232
232
|
const e = (r) => Number.isFinite(r) ? Math.min(0.999, Math.max(0, r)) : 0;
|
|
233
233
|
let { left: n, top: s, right: o, bottom: i } = { left: e(t.left), top: e(t.top), right: e(t.right), bottom: e(t.bottom) };
|
|
234
234
|
if (n + o >= 1) {
|
|
@@ -241,27 +241,27 @@ function me(t) {
|
|
|
241
241
|
}
|
|
242
242
|
return { left: n, top: s, right: o, bottom: i };
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ye(t, e) {
|
|
245
245
|
return !t || !e ? !t == !e : t.font === e.font && t.char === e.char;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function we(t, e) {
|
|
248
248
|
return t.fontFamily === e.fontFamily && t.fontFamilyComplexScript === e.fontFamilyComplexScript && t.fontFamilyEastAsia === e.fontFamilyEastAsia && t.fontSizePx === e.fontSizePx && t.bold === e.bold && t.italic === e.italic && t.underline === e.underline && t.underlineStyle === e.underlineStyle && t.underlineColor === e.underlineColor && t.strikethrough === e.strikethrough && t.color === e.color && !!t.hidden == !!e.hidden && // hidden runs must never merge with visible ones
|
|
249
249
|
(t.letterSpacingPx ?? 0) === (e.letterSpacingPx ?? 0) && t.highlightColor === e.highlightColor && t.verticalAlign === e.verticalAlign && !!t.caps == !!e.caps && // case transforms change the rendered glyphs — never merge across
|
|
250
250
|
!!t.smallCaps == !!e.smallCaps && t.link === e.link && t.footnoteRef === e.footnoteRef && // adjacent refs must never merge into one run
|
|
251
|
-
|
|
251
|
+
me(t.sdtPath, e.sdtPath) && // content-control boundaries (incl. nesting) survive normalization
|
|
252
252
|
t.fieldId === e.fieldId && // inline-field boundaries survive normalization
|
|
253
253
|
t.equation === e.equation && // inline equations are atomic — never merge (reference identity)
|
|
254
254
|
// Minor run typography & effects (w:rPr extras) — compared so styled runs never
|
|
255
255
|
// merge with plain ones (and a struck-through pair keeps its boundary).
|
|
256
256
|
!!t.doubleStrikethrough == !!e.doubleStrikethrough && (t.positionPx ?? 0) === (e.positionPx ?? 0) && (t.kerningMinPx ?? 0) === (e.kerningMinPx ?? 0) && (t.widthScalePct ?? 100) === (e.widthScalePct ?? 100) && t.emphasisMark === e.emphasisMark && !!t.outline == !!e.outline && !!t.shadow == !!e.shadow && !!t.emboss == !!e.emboss && !!t.imprint == !!e.imprint && // w:snapToGrid defaults ON, so compare with a true default — an explicit OFF
|
|
257
257
|
// run must not merge with a plain (default-on) neighbour (issue #161).
|
|
258
|
-
(t.snapToGrid ?? !0) === (e.snapToGrid ?? !0) && (t.fitTextPx ?? 0) === (e.fitTextPx ?? 0) &&
|
|
259
|
-
|
|
258
|
+
(t.snapToGrid ?? !0) === (e.snapToGrid ?? !0) && (t.fitTextPx ?? 0) === (e.fitTextPx ?? 0) && xe(t.lang, e.lang) && // proofing language (w:lang) — runs with different tags must not merge
|
|
259
|
+
pe(t.runBorder, e.runBorder) && ye(t.symbol, e.symbol);
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function xe(t, e) {
|
|
262
262
|
return t === e ? !0 : !t || !e ? !1 : t.val === e.val && t.eastAsia === e.eastAsia && t.bidi === e.bidi;
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function pe(t, e) {
|
|
265
265
|
return t === e ? !0 : !t || !e ? !1 : t.color === e.color && t.widthPx === e.widthPx && t.style === e.style;
|
|
266
266
|
}
|
|
267
267
|
function x(t, e) {
|
|
@@ -270,7 +270,7 @@ function x(t, e) {
|
|
|
270
270
|
const s = [{ ...n[0] }];
|
|
271
271
|
for (let o = 1; o < n.length; o++) {
|
|
272
272
|
const i = n[o], r = s[s.length - 1];
|
|
273
|
-
|
|
273
|
+
we(r.style, i.style) ? r.text += i.text : s.push({ ...i });
|
|
274
274
|
}
|
|
275
275
|
return s;
|
|
276
276
|
}
|
|
@@ -288,17 +288,17 @@ function re(t, e, n) {
|
|
|
288
288
|
return o;
|
|
289
289
|
}
|
|
290
290
|
function p(t, e) {
|
|
291
|
-
return
|
|
291
|
+
return be(t, e) ?? { ...oe };
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function Pe(t, e, n, s) {
|
|
294
294
|
const o = s ?? p(t, e), [i, r] = y(t, e);
|
|
295
295
|
return x([...i, { text: n, style: o }, ...r], o);
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function ve(t, e, n) {
|
|
298
298
|
const [s, o] = y(t, e);
|
|
299
299
|
return x([...s, ...n, ...o], p(t, e));
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function Se(t, e, n) {
|
|
302
302
|
const [s, o] = y(t, e), [, i] = y(o, n - e);
|
|
303
303
|
return x([...s, ...i], p(t, e));
|
|
304
304
|
}
|
|
@@ -319,7 +319,7 @@ const b = (t) => t;
|
|
|
319
319
|
function E(t, e) {
|
|
320
320
|
const n = A(t, e);
|
|
321
321
|
if (!n) throw new Error(`paragraph ${e} not found`);
|
|
322
|
-
return { loc: n, block:
|
|
322
|
+
return { loc: n, block: q(t, n) };
|
|
323
323
|
}
|
|
324
324
|
function k(t, e) {
|
|
325
325
|
return e === "body" ? t.blocks : t.section[e] ?? [];
|
|
@@ -352,7 +352,7 @@ function O(t) {
|
|
|
352
352
|
for (const n of e.cells)
|
|
353
353
|
for (const s of n.blocks) if (s.kind === "paragraph") return s;
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function Be(t, e) {
|
|
356
356
|
const n = H(t, e);
|
|
357
357
|
if (n) {
|
|
358
358
|
const s = k(t, n.where)[n.index];
|
|
@@ -374,7 +374,7 @@ function Se(t, e) {
|
|
|
374
374
|
}
|
|
375
375
|
return null;
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function ie(t, e, n) {
|
|
378
378
|
const s = H(t, e);
|
|
379
379
|
if (s) {
|
|
380
380
|
const o = k(t, s.where)[s.index];
|
|
@@ -400,10 +400,10 @@ function Be(t, e, n) {
|
|
|
400
400
|
}
|
|
401
401
|
return null;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return
|
|
403
|
+
function J(t, e) {
|
|
404
|
+
return ie(t, e, "equation");
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function D(t, e, n) {
|
|
407
407
|
if (e.kind === "top") {
|
|
408
408
|
const i = k(t, e.where).slice();
|
|
409
409
|
return i[e.index] = n, w(t, e.where, i);
|
|
@@ -437,7 +437,7 @@ function v(t, e) {
|
|
|
437
437
|
function rt(t, e) {
|
|
438
438
|
switch (e.type) {
|
|
439
439
|
case "insertText": {
|
|
440
|
-
const { loc: n, block: s } = E(t, e.at.blockId), o =
|
|
440
|
+
const { loc: n, block: s } = E(t, e.at.blockId), o = Pe(s.runs, e.at.offset, e.text, e.style), i = e.text.length;
|
|
441
441
|
return {
|
|
442
442
|
doc: R(t, n, v(s, o)),
|
|
443
443
|
inverse: { type: "deleteRange", blockId: s.id, start: e.at.offset, end: e.at.offset + i },
|
|
@@ -446,7 +446,7 @@ function rt(t, e) {
|
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
case "insertRuns": {
|
|
449
|
-
const { loc: n, block: s } = E(t, e.at.blockId), o = C(e.runs).length, i =
|
|
449
|
+
const { loc: n, block: s } = E(t, e.at.blockId), o = C(e.runs).length, i = ve(s.runs, e.at.offset, e.runs);
|
|
450
450
|
return {
|
|
451
451
|
doc: R(t, n, v(s, i)),
|
|
452
452
|
inverse: { type: "deleteRange", blockId: s.id, start: e.at.offset, end: e.at.offset + o },
|
|
@@ -455,7 +455,7 @@ function rt(t, e) {
|
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
457
|
case "deleteRange": {
|
|
458
|
-
const { loc: n, block: s } = E(t, e.blockId), o = re(s.runs, e.start, e.end), i =
|
|
458
|
+
const { loc: n, block: s } = E(t, e.blockId), o = re(s.runs, e.start, e.end), i = Se(s.runs, e.start, e.end), r = e.end - e.start;
|
|
459
459
|
return {
|
|
460
460
|
doc: R(t, n, v(s, i)),
|
|
461
461
|
inverse: { type: "insertRuns", at: { blockId: s.id, offset: e.start }, runs: o },
|
|
@@ -492,7 +492,7 @@ function rt(t, e) {
|
|
|
492
492
|
case "splitParagraph": {
|
|
493
493
|
const n = A(t, e.at.blockId);
|
|
494
494
|
if (!n) throw new Error(`paragraph ${e.at.blockId} not found`);
|
|
495
|
-
const s =
|
|
495
|
+
const s = q(t, n), [o, i] = y(s.runs, e.at.offset), r = p(s.runs, e.at.offset), a = v(s, x(o, r)), l = {
|
|
496
496
|
kind: "paragraph",
|
|
497
497
|
id: e.newBlockId,
|
|
498
498
|
revision: 0,
|
|
@@ -527,7 +527,7 @@ function rt(t, e) {
|
|
|
527
527
|
case "mergeParagraphs": {
|
|
528
528
|
const n = A(t, e.firstBlockId);
|
|
529
529
|
if (!n) throw new Error(`paragraph ${e.firstBlockId} not found`);
|
|
530
|
-
const s =
|
|
530
|
+
const s = q(t, n);
|
|
531
531
|
let o;
|
|
532
532
|
if (n.kind === "cell") {
|
|
533
533
|
const c = k(t, n.where)[n.bi].rows[n.ri].cells[n.ci].blocks[n.pi + 1];
|
|
@@ -603,12 +603,12 @@ function rt(t, e) {
|
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
case "setImageProps": {
|
|
606
|
-
const n =
|
|
606
|
+
const n = Be(t, e.blockId);
|
|
607
607
|
if (!n) throw new Error(`image ${e.blockId} not found`);
|
|
608
608
|
const s = n.image, o = {};
|
|
609
609
|
e.patch.widthPx !== void 0 && (o.widthPx = s.widthPx), e.patch.heightPx !== void 0 && (o.heightPx = s.heightPx), e.patch.align !== void 0 && (o.align = s.align), e.patch.wrap !== void 0 && (o.wrap = s.wrap ?? null), e.patch.anchor !== void 0 && (o.anchor = s.anchor ?? null), e.patch.crop !== void 0 && (o.crop = s.crop ?? null);
|
|
610
610
|
const i = { ...s, revision: s.revision + 1 };
|
|
611
|
-
e.patch.widthPx !== void 0 && (i.widthPx = e.patch.widthPx), e.patch.heightPx !== void 0 && (i.heightPx = e.patch.heightPx), e.patch.align !== void 0 && (i.align = e.patch.align), e.patch.wrap !== void 0 && (e.patch.wrap === null ? delete i.wrap : i.wrap = e.patch.wrap), e.patch.anchor !== void 0 && (e.patch.anchor === null ? delete i.anchor : i.anchor = e.patch.anchor), e.patch.crop !== void 0 && (e.patch.crop === null ? delete i.crop : i.crop =
|
|
611
|
+
e.patch.widthPx !== void 0 && (i.widthPx = e.patch.widthPx), e.patch.heightPx !== void 0 && (i.heightPx = e.patch.heightPx), e.patch.align !== void 0 && (i.align = e.patch.align), e.patch.wrap !== void 0 && (e.patch.wrap === null ? delete i.wrap : i.wrap = e.patch.wrap), e.patch.anchor !== void 0 && (e.patch.anchor === null ? delete i.anchor : i.anchor = e.patch.anchor), e.patch.crop !== void 0 && (e.patch.crop === null ? delete i.crop : i.crop = Ie(e.patch.crop));
|
|
612
612
|
let r;
|
|
613
613
|
if (n.kind === "top") {
|
|
614
614
|
const a = k(t, n.where).slice();
|
|
@@ -625,22 +625,33 @@ function rt(t, e) {
|
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
627
|
case "setEquation": {
|
|
628
|
-
const n =
|
|
628
|
+
const n = J(t, e.blockId);
|
|
629
629
|
if (!n) throw new Error(`equation ${e.blockId} not found`);
|
|
630
630
|
const s = n.block.equation, o = { ...n.block, revision: n.block.revision + 1, equation: e.equation };
|
|
631
631
|
return {
|
|
632
|
-
doc:
|
|
632
|
+
doc: D(t, n, o),
|
|
633
633
|
inverse: { type: "setEquation", blockId: e.blockId, equation: s },
|
|
634
634
|
mapPosition: b,
|
|
635
635
|
dirtyBlockIds: [e.blockId]
|
|
636
636
|
};
|
|
637
637
|
}
|
|
638
|
+
case "setCustomBlockData": {
|
|
639
|
+
const n = ie(t, e.blockId, "custom");
|
|
640
|
+
if (!n) throw new Error(`custom block ${e.blockId} not found`);
|
|
641
|
+
const s = n.block.data, o = { ...n.block, revision: n.block.revision + 1, data: e.data };
|
|
642
|
+
return {
|
|
643
|
+
doc: D(t, n, o),
|
|
644
|
+
inverse: { type: "setCustomBlockData", blockId: e.blockId, data: s },
|
|
645
|
+
mapPosition: b,
|
|
646
|
+
dirtyBlockIds: [e.blockId]
|
|
647
|
+
};
|
|
648
|
+
}
|
|
638
649
|
case "setEquationAlign": {
|
|
639
|
-
const n =
|
|
650
|
+
const n = J(t, e.blockId);
|
|
640
651
|
if (!n) throw new Error(`equation ${e.blockId} not found`);
|
|
641
652
|
const s = n.block.align ?? "center", o = { ...n.block, revision: n.block.revision + 1, align: e.align };
|
|
642
653
|
return {
|
|
643
|
-
doc:
|
|
654
|
+
doc: D(t, n, o),
|
|
644
655
|
inverse: { type: "setEquationAlign", blockId: e.blockId, align: s },
|
|
645
656
|
mapPosition: b,
|
|
646
657
|
dirtyBlockIds: [e.blockId]
|
|
@@ -971,7 +982,7 @@ function rt(t, e) {
|
|
|
971
982
|
}
|
|
972
983
|
}
|
|
973
984
|
}
|
|
974
|
-
function
|
|
985
|
+
function le(t, e = 0) {
|
|
975
986
|
let n = e;
|
|
976
987
|
return {
|
|
977
988
|
siteId: t,
|
|
@@ -979,15 +990,15 @@ function ie(t, e = 0) {
|
|
|
979
990
|
count: () => n
|
|
980
991
|
};
|
|
981
992
|
}
|
|
982
|
-
let
|
|
993
|
+
let G = le("local");
|
|
983
994
|
function it(t, e = 0) {
|
|
984
|
-
|
|
995
|
+
G = le(t, e);
|
|
985
996
|
}
|
|
986
997
|
function Q() {
|
|
987
|
-
return
|
|
998
|
+
return G.next();
|
|
988
999
|
}
|
|
989
1000
|
function lt() {
|
|
990
|
-
return
|
|
1001
|
+
return G.siteId;
|
|
991
1002
|
}
|
|
992
1003
|
const Re = {
|
|
993
1004
|
yellow: "#ffff00",
|
|
@@ -1071,7 +1082,7 @@ function Ce(t, e, n) {
|
|
|
1071
1082
|
}
|
|
1072
1083
|
function Fe(t, e, n = 3) {
|
|
1073
1084
|
const s = e?.outlineRange?.to ?? n, o = [];
|
|
1074
|
-
for (const i of
|
|
1085
|
+
for (const i of ae(t)) {
|
|
1075
1086
|
const r = Ce(i, t, e);
|
|
1076
1087
|
r === null || r < 1 || r > s || e?.outlineRange && (r < e.outlineRange.from || r > e.outlineRange.to) || o.push({ block: i, level: r });
|
|
1077
1088
|
}
|
|
@@ -1173,38 +1184,38 @@ function ut(t, e = {}) {
|
|
|
1173
1184
|
return i.splice(n, 1, ...s), { doc: { ...t, blocks: i }, generated: o, headings: o };
|
|
1174
1185
|
}
|
|
1175
1186
|
export {
|
|
1176
|
-
$,
|
|
1187
|
+
q as $,
|
|
1177
1188
|
He as A,
|
|
1178
1189
|
S as B,
|
|
1179
1190
|
k as C,
|
|
1180
1191
|
Ve as D,
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1192
|
+
ie as E,
|
|
1193
|
+
se as F,
|
|
1194
|
+
Je as G,
|
|
1195
|
+
Ze as H,
|
|
1196
|
+
je as I,
|
|
1197
|
+
Ge as J,
|
|
1198
|
+
_e as K,
|
|
1199
|
+
J as L,
|
|
1200
|
+
Be as M,
|
|
1201
|
+
et as N,
|
|
1202
|
+
ne as O,
|
|
1203
|
+
y as P,
|
|
1204
|
+
x as Q,
|
|
1194
1205
|
re as R,
|
|
1195
1206
|
ze as S,
|
|
1196
1207
|
Ye as T,
|
|
1197
1208
|
Le as U,
|
|
1198
|
-
|
|
1209
|
+
ae as V,
|
|
1199
1210
|
$e as W,
|
|
1200
|
-
|
|
1211
|
+
We as X,
|
|
1201
1212
|
Ue as Y,
|
|
1202
1213
|
Xe as Z,
|
|
1203
|
-
|
|
1214
|
+
j as _,
|
|
1204
1215
|
oe as a,
|
|
1205
1216
|
W as a0,
|
|
1206
1217
|
it as a1,
|
|
1207
|
-
|
|
1218
|
+
le as a2,
|
|
1208
1219
|
Re as a3,
|
|
1209
1220
|
ft as a4,
|
|
1210
1221
|
at as a5,
|
|
@@ -1221,16 +1232,16 @@ export {
|
|
|
1221
1232
|
dt as l,
|
|
1222
1233
|
Ne as m,
|
|
1223
1234
|
Ke as n,
|
|
1224
|
-
|
|
1235
|
+
de as o,
|
|
1225
1236
|
Ee as p,
|
|
1226
1237
|
qe as q,
|
|
1227
1238
|
tt as r,
|
|
1228
|
-
|
|
1239
|
+
fe as s,
|
|
1229
1240
|
C as t,
|
|
1230
|
-
|
|
1241
|
+
De as u,
|
|
1231
1242
|
lt as v,
|
|
1232
1243
|
ot as w,
|
|
1233
|
-
|
|
1244
|
+
be as x,
|
|
1234
1245
|
te as y,
|
|
1235
1246
|
A as z
|
|
1236
1247
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as C, s as j,
|
|
1
|
+
import { o as C, s as j, K as L, t as k, u as T, a as A } from "./toc-C4oeGLWP.js";
|
|
2
2
|
const c = (e) => Math.round(e * 100) / 100;
|
|
3
3
|
function B(e) {
|
|
4
4
|
const o = { font: e.fontFamily, sizePx: e.fontSizePx };
|
|
@@ -118,11 +118,11 @@ function q(e) {
|
|
|
118
118
|
const a = y(e.wholeWord);
|
|
119
119
|
return a !== void 0 && (o.wholeWord = a), o;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function N(e) {
|
|
122
122
|
return C(e).map((o) => k(o.runs)).join(`
|
|
123
123
|
`);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function z(e, o) {
|
|
126
126
|
const s = C(e);
|
|
127
127
|
let a = o.anchor, r = o.focus, p = T(e, a.blockId), m = T(e, r.blockId);
|
|
128
128
|
if ((p > m || p === m && a.offset > r.offset) && ([a, r] = [r, a], [p, m] = [m, p]), p < 0 || m < 0) {
|
|
@@ -139,12 +139,12 @@ function N(e, o) {
|
|
|
139
139
|
return d.push(k(s[m].runs).slice(0, r.offset)), d.join(`
|
|
140
140
|
`);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function J() {
|
|
143
143
|
const e = globalThis;
|
|
144
144
|
return e.document?.modelContext ?? e.navigator?.modelContext ?? null;
|
|
145
145
|
}
|
|
146
146
|
function U(e, o = {}, s = {}) {
|
|
147
|
-
const a = s.modelContext ??
|
|
147
|
+
const a = s.modelContext ?? J();
|
|
148
148
|
if (!a)
|
|
149
149
|
return console.warn("[wordcanvas] agentTools enabled but no navigator.modelContext is available; tools not registered."), () => {
|
|
150
150
|
};
|
|
@@ -168,7 +168,7 @@ function U(e, o = {}, s = {}) {
|
|
|
168
168
|
inputSchema: { type: "object", properties: { format: { type: "string", enum: ["text", "json"], description: "text (default) or json" } } },
|
|
169
169
|
execute: (t) => {
|
|
170
170
|
const n = e.getDocument();
|
|
171
|
-
return (u(t.format) ?? "text") === "json" ? x(n) : g(
|
|
171
|
+
return (u(t.format) ?? "text") === "json" ? x(n) : g(N(n));
|
|
172
172
|
}
|
|
173
173
|
}), d({
|
|
174
174
|
name: "get_selection",
|
|
@@ -176,7 +176,7 @@ function U(e, o = {}, s = {}) {
|
|
|
176
176
|
inputSchema: { type: "object", properties: {} },
|
|
177
177
|
execute: () => {
|
|
178
178
|
const t = e.getSelection();
|
|
179
|
-
return x(t ? { selection: t, text:
|
|
179
|
+
return x(t ? { selection: t, text: z(e.getDocument(), t) } : { selection: null });
|
|
180
180
|
}
|
|
181
181
|
}), d({
|
|
182
182
|
name: "search_document",
|
|
@@ -332,7 +332,7 @@ function U(e, o = {}, s = {}) {
|
|
|
332
332
|
if (i && e.search(i).total === 0)
|
|
333
333
|
return e.searchClear(), f(`text not found: ${i}`);
|
|
334
334
|
if (!e.getSelection()) return f("no selection (pass 'find' or select_range first)");
|
|
335
|
-
const { insertText: l } = await import("./editorApp-
|
|
335
|
+
const { insertText: l } = await import("./editorApp-CRXveGOd.js").then((h) => h.c);
|
|
336
336
|
return e.dispatch(l(n)), i && e.searchClear(), g("inserted");
|
|
337
337
|
}
|
|
338
338
|
}), d({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./toc-
|
|
2
|
-
import { m as h } from "./stylesheet-
|
|
1
|
+
import "./toc-C4oeGLWP.js";
|
|
2
|
+
import { m as h } from "./stylesheet-oa_qg3op.js";
|
|
3
3
|
import { H as u, A as w, C as m, a as y, I as v, T as k, F as z, b as S, c as E, E as L, D as O } from "./paintStyle-BldhHuSV.js";
|
|
4
4
|
import "./blockRegistry-CGgu7-f7.js";
|
|
5
5
|
const R = 1.1, C = 0.25, T = 5, A = 36, s = {
|
|
@@ -630,7 +630,7 @@ class Z {
|
|
|
630
630
|
},
|
|
631
631
|
onEvent: (r) => this.emit(r)
|
|
632
632
|
};
|
|
633
|
-
e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-
|
|
633
|
+
e.onLoadProgress?.({ phase: "bundle", percent: 0, loaded: 0, total: 0 }), import("./editorApp-CRXveGOd.js").then((r) => r.e).then((r) => (e.onLoadProgress?.({ phase: "bundle", percent: p, loaded: 0, total: 0 }), r.mountEditorApp(i)));
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
636
|
/** Subscribe to a collaboration event. Returns an unsubscribe function. */
|
package/dist-lib/wordcanvas.js
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
normalizeRuns,
|
|
36
36
|
parseFieldInstruction,
|
|
37
37
|
parseFieldSpec
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-Q2PZZE6W.js";
|
|
39
39
|
|
|
40
40
|
// src/import/docx/units.ts
|
|
41
41
|
var twipsToPx = (tw) => tw / 15;
|
|
@@ -3307,4 +3307,4 @@ function partNameByRelType(rels, kind) {
|
|
|
3307
3307
|
export {
|
|
3308
3308
|
runImport
|
|
3309
3309
|
};
|
|
3310
|
-
//# sourceMappingURL=chunk-
|
|
3310
|
+
//# sourceMappingURL=chunk-2BASYQX6.js.map
|