@web-ppt/edit-core 0.6.0 → 0.8.0-beta.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/CHANGELOG.md +29 -0
- package/README.md +8 -0
- package/dist/agent/base64.d.ts +2 -0
- package/dist/agent/errors.d.ts +9 -0
- package/dist/agent/generated-schema.d.ts +6038 -0
- package/dist/agent/generated-validator.d.ts +6 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/query.d.ts +3 -0
- package/dist/agent/session.d.ts +33 -0
- package/dist/agent/targets.d.ts +5 -0
- package/dist/agent/tools.d.ts +2 -0
- package/dist/agent/types.d.ts +126 -0
- package/dist/agent/validation.d.ts +2 -0
- package/dist/agent.js +46364 -0
- package/dist/commands/types.d.ts +23 -23
- package/dist/fill/api.d.ts +29 -0
- package/dist/fill/chart-seed-chart.d.ts +7 -0
- package/dist/fill/chart-seed-workbook.d.ts +12 -0
- package/dist/fill/chart-seed-xml.d.ts +12 -0
- package/dist/fill/chart-seed.d.ts +17 -0
- package/dist/fill/content.d.ts +16 -0
- package/dist/fill/errors.d.ts +10 -0
- package/dist/fill/generated-schema.d.ts +291 -0
- package/dist/fill/generated-validator.d.ts +6 -0
- package/dist/fill/index.d.ts +10 -0
- package/dist/fill/layouts.d.ts +24 -0
- package/dist/fill/package.d.ts +2 -0
- package/dist/fill/repair.d.ts +32 -0
- package/dist/fill/text-validation.d.ts +3 -0
- package/dist/fill/types.d.ts +60 -0
- package/dist/fill/validation.d.ts +10 -0
- package/dist/fill.js +12 -0
- package/dist/generate.js +53 -53
- package/dist/index-2ti1e4_F.js +411 -0
- package/dist/index-BbsPmmoy.js +4046 -0
- package/dist/save/notes-master.d.ts +12 -0
- package/dist/save.js +650 -484
- package/dist/{slide-parts-D0o_DDhi.js → slide-parts-zyOP9lia.js} +5 -5
- package/dist/types.d.ts +4 -4
- package/package.json +13 -3
- package/schemas/agent-tools.schema.json +7999 -0
- package/schemas/template-fill.schema.json +371 -0
package/dist/save.js
CHANGED
|
@@ -1,581 +1,747 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { p as
|
|
3
|
-
import { p as
|
|
4
|
-
import { p as
|
|
5
|
-
import { PLACEHOLDER_DIRECT_BITS as
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
return (
|
|
9
|
-
},
|
|
10
|
-
function
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
var
|
|
17
|
-
const
|
|
18
|
-
return !
|
|
19
|
-
var
|
|
20
|
-
return ((
|
|
21
|
-
}).map((
|
|
22
|
-
}), f = [...
|
|
23
|
-
if (!
|
|
24
|
-
const
|
|
25
|
-
var
|
|
26
|
-
return (
|
|
27
|
-
}),
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
for (const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
for (const
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
for (const
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
1
|
+
import { r as T, a as se, b as Ne, m as rt, c as st, d as Ge, e as nt, n as ne, l as at, o as fe, f as ot, g as it, h as ct, v as lt, i as Qe, j as pt, t as ft, k as ut, p as mt, q as Te, s as Me, u as dt, w as Ze, x as ht, y as gt, z as Pt, A as et, B as yt, C as wt, D as vt, E as St, F as kt, G as Et, H as xt, I as Ot, J as Tt, K as Mt, L as Nt, M as bt, N as $t, O as Rt, P as It, Q as Ct, R as Ut } from "./model-invariants-BM19JVxy.js";
|
|
2
|
+
import { p as I, r as Ce, s as W, f as At, a as H, i as oe, c as Ue, b as Ae, x as D, D as re, d as ve, e as jt, g as ae, P as L, O as ue } from "./index-C2r7c6G6.js";
|
|
3
|
+
import { p as Lt } from "./patch-BwhfBbYE.js";
|
|
4
|
+
import { p as be, a as Xt, m as _t, c as zt, t as Dt, b as Ht, e as Ft, r as Bt, d as Gt, f as Wt, g as Vt, h as We, i as qt, j as Yt, k as Kt, l as Jt, n as Qt, o as Zt, q as er, s as tr, u as rr, v as sr, w as nr } from "./slide-parts-zyOP9lia.js";
|
|
5
|
+
import { PLACEHOLDER_DIRECT_BITS as ee, findPlaceholderByIdentity as ar } from "@web-ppt/core";
|
|
6
|
+
const x = (e, s) => {
|
|
7
|
+
var r;
|
|
8
|
+
return (r = Ae(e, { localName: s, namespaceUri: null })) == null ? void 0 : r.value;
|
|
9
|
+
}, G = (e, s) => D(e, { localName: s, namespaceUri: e.namespaceUri }), Ve = (e) => G(I(e).root, "Relationship");
|
|
10
|
+
function or(e, s, r, n, a) {
|
|
11
|
+
var U, S, q;
|
|
12
|
+
const i = (c) => {
|
|
13
|
+
var y;
|
|
14
|
+
return r[c] ?? ((y = e.package) == null ? void 0 : y.parts[c]);
|
|
15
|
+
}, p = s.flatMap((c) => {
|
|
16
|
+
var k, b;
|
|
17
|
+
const y = (k = c.creation) == null ? void 0 : k.duplicateSourcePart, E = (b = c.origin) == null ? void 0 : b.part, C = y && i(T(y));
|
|
18
|
+
return !C || !E ? [] : Ve(C).filter(($) => {
|
|
19
|
+
var F;
|
|
20
|
+
return ((F = x($, "Type")) == null ? void 0 : F.endsWith("/comments")) && x($, "TargetMode") !== "External";
|
|
21
|
+
}).map(($) => ({ slide: E, id: x($, "Id"), source: se(y, x($, "Target")) }));
|
|
22
|
+
}), f = [...n].filter((c) => /^ppt\/comments\/(?:_rels\/)?web-ppt-(?!edit-)/.test(c));
|
|
23
|
+
if (!p.length && !f.length) return;
|
|
24
|
+
const u = "ppt/presentation.xml", h = Ve(i(T(u))).find((c) => {
|
|
25
|
+
var y;
|
|
26
|
+
return (y = x(c, "Type")) == null ? void 0 : y.endsWith("/commentAuthors");
|
|
27
|
+
}), P = h && se(u, x(h, "Target")), g = P && i(P);
|
|
28
|
+
P && g && (r[P] ?? (r[P] = g.slice()));
|
|
29
|
+
const A = g ? I(g) : void 0, X = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const c of A ? G(A.root, "cmAuthor") : [])
|
|
31
|
+
X.set(x(c, "id"), Number(x(c, "lastIdx")) || 0), l.set(x(c, "id"), /* @__PURE__ */ new Set());
|
|
32
|
+
const w = "[Content_Types].xml", M = I(a[w] ?? i(w));
|
|
33
|
+
for (const c of G(M.root, "Override")) {
|
|
34
|
+
const y = (U = x(c, "PartName")) == null ? void 0 : U.slice(1);
|
|
35
|
+
if (!y || n.has(y) || !((S = x(c, "ContentType")) != null && S.endsWith(".comments+xml"))) continue;
|
|
36
|
+
const E = i(y);
|
|
37
|
+
if (!E) throw new Error(`批注来源部件缺失:${y}`);
|
|
38
|
+
for (const C of G(I(E).root, "cm")) {
|
|
39
|
+
const k = x(C, "authorId"), b = Number(x(C, "idx"));
|
|
40
|
+
if (l.has(k) || l.set(k, /* @__PURE__ */ new Set()), !Number.isInteger(b) || b < 0 || b > 4294967295) throw new Error("批注作者或索引无效");
|
|
41
|
+
l.get(k).add(b), X.set(k, Math.max(X.get(k) ?? 0, b));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
for (const
|
|
45
|
-
f.includes(((
|
|
44
|
+
for (const c of [...G(M.root, "Override")])
|
|
45
|
+
f.includes(((q = x(c, "PartName")) == null ? void 0 : q.slice(1)) ?? "") && Ce(M.root, c);
|
|
46
46
|
const j = /* @__PURE__ */ new Set();
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
const
|
|
51
|
-
let
|
|
52
|
-
const
|
|
53
|
-
for (const
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
let O =
|
|
57
|
-
for (;
|
|
47
|
+
for (const c of p) {
|
|
48
|
+
const y = i(c.source);
|
|
49
|
+
if (!y) throw new Error(`复制批注缺少来源部件:${c.source}`);
|
|
50
|
+
const E = I(y);
|
|
51
|
+
let C = 0;
|
|
52
|
+
const k = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const d of G(E.root, "cm").sort((N, O) => Number(x(N, "idx")) - Number(x(O, "idx")))) {
|
|
54
|
+
const N = x(d, "authorId");
|
|
55
|
+
if (!X.has(N)) throw new Error(`复制批注缺少作者:${N}`);
|
|
56
|
+
let O = C + 1;
|
|
57
|
+
for (; l.get(N).has(O); ) O++;
|
|
58
58
|
if (O > 4294967295) throw new Error("批注索引超出 OOXML 可表示范围");
|
|
59
|
-
|
|
59
|
+
l.get(N).add(O), X.set(N, Math.max(X.get(N), O)), C = O, k.set(`${N}:${x(d, "idx")}`, O), W(d, "idx", String(O));
|
|
60
60
|
}
|
|
61
|
-
for (const
|
|
62
|
-
const
|
|
63
|
-
|
|
61
|
+
for (const d of G(E.root, "cm")) {
|
|
62
|
+
const N = At(d, { localName: "parentCm", namespaceUri: "http://schemas.microsoft.com/office/powerpoint/2012/main" }), O = N && k.get(`${x(N, "authorId")}:${x(N, "idx")}`);
|
|
63
|
+
N && O !== void 0 && W(N, "idx", String(O));
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
let
|
|
67
|
-
for (;
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
for (const O of
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
const
|
|
79
|
-
|
|
65
|
+
const b = `ppt/comments/web-ppt-${c.slide.slice(c.slide.lastIndexOf("/") + 1).replace(/\.xml$/, "")}`;
|
|
66
|
+
let $ = `${b}.xml`, F = 1;
|
|
67
|
+
for (; i($) && !n.has($); ) $ = `${b}-${F++}.xml`;
|
|
68
|
+
a[$] = H(E), j.add($), n.add($);
|
|
69
|
+
const ce = T(c.slide), le = I(a[ce]), de = G(le.root, "Relationship").find((d) => x(d, "Id") === c.id);
|
|
70
|
+
if (!de) throw new Error("复制批注目标关系缺失");
|
|
71
|
+
W(de, "Target", Ne(c.slide, $)), a[ce] = H(le);
|
|
72
|
+
const Q = i(T(c.source));
|
|
73
|
+
if (Q) {
|
|
74
|
+
const d = T($), N = I(Q);
|
|
75
|
+
for (const O of G(N.root, "Relationship")) {
|
|
76
|
+
const Z = x(O, "Target");
|
|
77
|
+
if (!Z || x(O, "TargetMode") === "External") continue;
|
|
78
|
+
const xe = Z.includes("#") ? Z.slice(Z.indexOf("#")) : "";
|
|
79
|
+
W(O, "Target", Ne($, se(c.source, Z)) + xe);
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
a[d] = H(N), j.add(d), n.add(d);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
["PartName", `/${
|
|
83
|
+
oe(M.root, Ue("Override", { attributes: [
|
|
84
|
+
["PartName", `/${$}`],
|
|
85
85
|
["ContentType", "application/vnd.openxmlformats-officedocument.presentationml.comments+xml"]
|
|
86
86
|
] }));
|
|
87
87
|
}
|
|
88
|
-
for (const
|
|
89
|
-
for (const
|
|
90
|
-
|
|
88
|
+
for (const c of f) j.has(c) || (a[c] = null);
|
|
89
|
+
for (const c of A ? G(A.root, "cmAuthor") : []) W(c, "lastIdx", String(X.get(x(c, "id")) ?? 0));
|
|
90
|
+
A && P && (a[P] = H(A)), a[w] = H(M);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
var
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
return
|
|
92
|
+
function tt(e, s, r) {
|
|
93
|
+
var a;
|
|
94
|
+
const n = s[r] ?? ((a = e.package) == null ? void 0 : a.parts[r]);
|
|
95
|
+
if (!n) throw new Error(`页面副本缺少来源 OPC part:${r}`);
|
|
96
|
+
return n;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
var
|
|
100
|
-
const
|
|
101
|
-
return
|
|
98
|
+
function ir(e, s, r) {
|
|
99
|
+
var a;
|
|
100
|
+
const n = (a = s.creation) == null ? void 0 : a.duplicateSourcePart;
|
|
101
|
+
return n ? tt(e, r, n) : void 0;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
var
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
id: `${
|
|
113
|
-
parent:
|
|
114
|
-
meta: { editable: "full", origin: { part:
|
|
103
|
+
function Pe(e, s, r) {
|
|
104
|
+
var a;
|
|
105
|
+
const n = (a = s.creation) == null ? void 0 : a.duplicateSourcePart;
|
|
106
|
+
return n ? tt(e, r, T(n)) : void 0;
|
|
107
|
+
}
|
|
108
|
+
function cr(e) {
|
|
109
|
+
var r, n;
|
|
110
|
+
const s = (r = e.origin) == null ? void 0 : r.part;
|
|
111
|
+
return s ? (((n = e.creation) == null ? void 0 : n.duplicateRemovedSpids) ?? []).map((a) => ({
|
|
112
|
+
id: `${e.id}-baseline-${a}`,
|
|
113
|
+
parent: e.id,
|
|
114
|
+
meta: { editable: "full", origin: { part: s, spid: a } }
|
|
115
115
|
})) : [];
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
const { host:
|
|
119
|
-
if (!
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
function
|
|
123
|
-
if (!
|
|
124
|
-
const
|
|
125
|
-
for (const f of [...
|
|
126
|
-
f.namespaceUri ===
|
|
127
|
-
if (
|
|
128
|
-
|
|
117
|
+
function lr(e, s) {
|
|
118
|
+
const { host: r } = at(e, s), n = ae(r, { localName: "spPr", namespaceUri: L });
|
|
119
|
+
if (!n) throw new Error(`元素 ${s.id} 缺少 p:spPr`);
|
|
120
|
+
return n;
|
|
121
|
+
}
|
|
122
|
+
function pr(e, s, r, n) {
|
|
123
|
+
if (!r && !n) return;
|
|
124
|
+
const a = lr(e, s);
|
|
125
|
+
for (const f of [...D(a)])
|
|
126
|
+
f.namespaceUri === re && ["prstGeom", "custGeom"].includes(f.localName) && Ce(a, f);
|
|
127
|
+
if (n) {
|
|
128
|
+
ve(a, jt(n));
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
if (!
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
for (const f of Object.keys(
|
|
137
|
-
const
|
|
138
|
-
|
|
131
|
+
if (!r) return;
|
|
132
|
+
const i = ne(a, re, "prstGeom");
|
|
133
|
+
W(i, "prst", r.preset), ve(a, i);
|
|
134
|
+
const p = ne(i, re, "avLst");
|
|
135
|
+
oe(i, p);
|
|
136
|
+
for (const f of Object.keys(r.adj)) {
|
|
137
|
+
const u = r.adj[f], h = ne(p, re, "gd");
|
|
138
|
+
W(h, "name", f), W(h, "fmla", `val ${Math.round(u)}`), oe(p, h);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function fr(e, s, r, n, a) {
|
|
142
142
|
var f;
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
((f =
|
|
148
|
-
), !
|
|
149
|
-
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
152
|
-
localName:
|
|
153
|
-
...
|
|
143
|
+
const i = s.meta.placeholderDirect ?? 0, p = !!(i & ee.style);
|
|
144
|
+
i & ee.transform || rt(e, s, r), (s.src.kind === "shape" || s.src.kind === "image") && !(i & ee.geometry) && pr(e, s, n, a), s.src.kind === "shape" && r.kind === "shape" ? (!p && !(i & ee.fill) && st(
|
|
145
|
+
e,
|
|
146
|
+
s,
|
|
147
|
+
((f = r.fill) == null ? void 0 : f.type) === "image" ? { type: "none" } : r.fill
|
|
148
|
+
), !p && !(i & ee.stroke) && r.stroke && Ge(e, s, r.stroke)) : s.src.kind === "image" && r.kind === "image" && !p && !(i & ee.stroke) && r.stroke && Ge(e, s, r.stroke), (s.src.kind === "shape" || s.src.kind === "image" || s.src.kind === "group") && !p && !(i & ee.effects) && r.effects && nt(e, s, r.effects);
|
|
149
|
+
}
|
|
150
|
+
function te(e, s, r) {
|
|
151
|
+
return e && ae(e, {
|
|
152
|
+
localName: s,
|
|
153
|
+
...r ? { namespaceUri: r } : {}
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
var
|
|
158
|
-
return
|
|
156
|
+
function Se(e, s) {
|
|
157
|
+
var r;
|
|
158
|
+
return e ? ((r = Ae(e, { localName: s })) == null ? void 0 : r.value) ?? null : null;
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
160
|
+
function ur(e) {
|
|
161
|
+
const s = D(e).find((a) => [
|
|
162
162
|
"nvSpPr",
|
|
163
163
|
"nvPicPr",
|
|
164
164
|
"nvCxnSpPr",
|
|
165
165
|
"nvGraphicFramePr"
|
|
166
|
-
].includes(
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
169
|
-
return { type:
|
|
170
|
-
}
|
|
171
|
-
function
|
|
172
|
-
if (!
|
|
173
|
-
const
|
|
174
|
-
|
|
166
|
+
].includes(a.localName)) ?? null, r = te(te(s, "nvPr", L), "ph", L);
|
|
167
|
+
if (!r) return null;
|
|
168
|
+
const n = Se(r, "idx");
|
|
169
|
+
return { type: Se(r, "type") ?? "obj", ...n === null ? {} : { idx: n } };
|
|
170
|
+
}
|
|
171
|
+
function qe(e, s) {
|
|
172
|
+
if (!e) return;
|
|
173
|
+
const r = te(
|
|
174
|
+
te(e.root, "cSld", L),
|
|
175
175
|
"spTree",
|
|
176
|
-
|
|
176
|
+
L
|
|
177
177
|
);
|
|
178
|
-
if (!
|
|
179
|
-
const
|
|
180
|
-
|
|
178
|
+
if (!r) return;
|
|
179
|
+
const n = ar(
|
|
180
|
+
D(r).filter((i) => [
|
|
181
181
|
"sp",
|
|
182
182
|
"pic",
|
|
183
183
|
"cxnSp",
|
|
184
184
|
"graphicFrame"
|
|
185
|
-
].includes(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
),
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
function
|
|
192
|
-
const
|
|
193
|
-
var
|
|
194
|
-
if (!
|
|
195
|
-
const
|
|
196
|
-
|
|
185
|
+
].includes(i.localName)),
|
|
186
|
+
ur,
|
|
187
|
+
s
|
|
188
|
+
), a = n ? te(n, "spPr", L) : null;
|
|
189
|
+
return te(a, "custGeom", re) ?? te(a, "prstGeom", re) ?? void 0;
|
|
190
|
+
}
|
|
191
|
+
function mr(e) {
|
|
192
|
+
const s = /* @__PURE__ */ new Map(), r = (a) => {
|
|
193
|
+
var i;
|
|
194
|
+
if (!s.has(a)) {
|
|
195
|
+
const p = (i = e.package) == null ? void 0 : i.parts[a];
|
|
196
|
+
s.set(a, p ? I(p) : null);
|
|
197
197
|
}
|
|
198
|
-
return
|
|
199
|
-
},
|
|
200
|
-
const
|
|
201
|
-
var
|
|
202
|
-
return
|
|
203
|
-
}), f =
|
|
204
|
-
return f ?
|
|
198
|
+
return s.get(a) ?? null;
|
|
199
|
+
}, n = (a) => {
|
|
200
|
+
const i = r(T(a)), p = i && D(i.root).find((u) => {
|
|
201
|
+
var h;
|
|
202
|
+
return u.localName === "Relationship" && ((h = Se(u, "Type")) == null ? void 0 : h.endsWith("/slideMaster"));
|
|
203
|
+
}), f = p ? Se(p, "Target") : null;
|
|
204
|
+
return f ? se(a, f) : null;
|
|
205
205
|
};
|
|
206
|
-
return (
|
|
207
|
-
const
|
|
208
|
-
if (!(!
|
|
209
|
-
return
|
|
206
|
+
return (a, i) => {
|
|
207
|
+
const p = a.sourceLayoutId, f = i.meta.ph;
|
|
208
|
+
if (!(!p || !f))
|
|
209
|
+
return qe(r(p), f) ?? (n(p) ? qe(r(n(p)), f) : void 0);
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
const K = "ppt/presentation.xml", ke = T(K), Ee = "[Content_Types].xml", Ye = "http://schemas.openxmlformats.org/package/2006/relationships", $e = "http://schemas.openxmlformats.org/package/2006/content-types", Re = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml", Ke = `${ue}/notesMaster`, Ie = `${ue}/slide`, dr = /^ppt\/notesMasters\/[^/]+\.xml$/, hr = {
|
|
213
|
+
bg1: "lt1",
|
|
214
|
+
tx1: "dk1",
|
|
215
|
+
bg2: "lt2",
|
|
216
|
+
tx2: "dk2",
|
|
217
|
+
accent1: "accent1",
|
|
218
|
+
accent2: "accent2",
|
|
219
|
+
accent3: "accent3",
|
|
220
|
+
accent4: "accent4",
|
|
221
|
+
accent5: "accent5",
|
|
222
|
+
accent6: "accent6",
|
|
223
|
+
hlink: "hlink",
|
|
224
|
+
folHlink: "folHlink"
|
|
225
|
+
}, J = (e, s) => {
|
|
226
|
+
var r;
|
|
227
|
+
return (r = Ae(e, { localName: s, namespaceUri: null })) == null ? void 0 : r.value;
|
|
228
|
+
};
|
|
229
|
+
function me(e) {
|
|
230
|
+
if (!e) return [];
|
|
231
|
+
const s = I(e).root;
|
|
232
|
+
if (s.namespaceUri !== Ye || s.localName !== "Relationships") throw new Error("备注保存关系部件的根命名空间无效");
|
|
233
|
+
return D(s, { localName: "Relationship", namespaceUri: Ye }).flatMap((r) => {
|
|
234
|
+
const n = J(r, "Id"), a = J(r, "Type"), i = J(r, "Target");
|
|
235
|
+
return n && a && i ? [{ id: n, type: a, target: i, external: J(r, "TargetMode") === "External" }] : [];
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function we(e, s) {
|
|
239
|
+
const r = me(e).filter((n) => n.type.endsWith("/notesMaster"));
|
|
240
|
+
if (r.length > 1 || r.some((n) => n.external)) throw new Error(`备注母版关系不唯一或指向外部:${s}`);
|
|
241
|
+
return r[0] ? se(s, r[0].target) : void 0;
|
|
242
|
+
}
|
|
243
|
+
function Je(e, s, r, n) {
|
|
244
|
+
var i;
|
|
245
|
+
if (s[n] || r.has(n)) return;
|
|
246
|
+
const a = (i = e.package) == null ? void 0 : i.parts[n];
|
|
247
|
+
a ? s[n] = a.slice() : r.add(n);
|
|
248
|
+
}
|
|
249
|
+
function V(e, s, r) {
|
|
250
|
+
var n;
|
|
251
|
+
return s[r] ?? ((n = e.package) == null ? void 0 : n.parts[r]);
|
|
252
|
+
}
|
|
253
|
+
function gr(e, s, r) {
|
|
254
|
+
var q;
|
|
255
|
+
const n = e.slideOrder.map((c) => e.slides[c]).filter((c) => !!c.notes), a = n.filter((c) => fe(c.ovr, "notes") || r.has(c.notes.targetPart)), i = [...r].filter((c) => dr.test(c));
|
|
256
|
+
if (!a.length) return i.length ? { part: i[0], created: !0, linkPresentation: !0, slides: [] } : void 0;
|
|
257
|
+
const p = V(e, s, ke), f = we(p, K), u = new Set(n.flatMap((c) => {
|
|
258
|
+
const y = c.notes.sourcePart ?? c.notes.targetPart, E = we(V(e, s, T(y)), y);
|
|
259
|
+
return E ? [E] : [];
|
|
260
|
+
}));
|
|
261
|
+
if (u.size > 1 || f && [...u].some((c) => c !== f))
|
|
262
|
+
throw new Error("活动备注页引用了不同的备注母版,不能在保存时覆盖既有设计");
|
|
263
|
+
const h = V(e, s, Ee), P = h ? D(I(h).root, { localName: "Override", namespaceUri: $e }).filter((c) => J(c, "ContentType") === Re).flatMap((c) => {
|
|
264
|
+
var y;
|
|
265
|
+
return ((y = J(c, "PartName")) == null ? void 0 : y.replace(/^\//, "")) ?? [];
|
|
266
|
+
}) : [];
|
|
267
|
+
let g = f ?? [...u][0] ?? i[0];
|
|
268
|
+
if (!g && P.length === 1 && (g = P[0]), !g && P.length > 1) throw new Error("存在多个未绑定的备注母版,不能猜测应复用的设计");
|
|
269
|
+
const A = !g || i.includes(g);
|
|
270
|
+
if (!g) {
|
|
271
|
+
let c = 1;
|
|
272
|
+
do
|
|
273
|
+
g = `ppt/notesMasters/notesMaster${c++}.xml`;
|
|
274
|
+
while ((q = e.package) != null && q.parts[g] || r.has(g) || P.includes(g));
|
|
275
|
+
}
|
|
276
|
+
if (!A && !V(e, s, g)) throw new Error(`备注母版关系目标不存在:${g}`);
|
|
277
|
+
if (!A) {
|
|
278
|
+
const c = I(V(e, s, g)).root;
|
|
279
|
+
if (c.localName !== "notesMaster" || c.namespaceUri !== L) throw new Error(`备注母版目标不是标准 notesMaster:${g}`);
|
|
280
|
+
}
|
|
281
|
+
const X = V(e, s, K);
|
|
282
|
+
if (!X) throw new Error("备注保存缺少 ppt/presentation.xml");
|
|
283
|
+
const l = I(X).root, w = ae(l, { localName: "notesMasterIdLst", namespaceUri: l.namespaceUri }), M = w ? D(w, { localName: "notesMasterId", namespaceUri: l.namespaceUri }) : [], j = me(p);
|
|
284
|
+
if (M.length > 1 || M.some((c) => {
|
|
285
|
+
var C;
|
|
286
|
+
const y = (C = c.attributes.find((k) => {
|
|
287
|
+
var b;
|
|
288
|
+
return k.localName === "id" && ((b = k.namespaceUri) == null ? void 0 : b.endsWith("/relationships"));
|
|
289
|
+
})) == null ? void 0 : C.value, E = j.find((k) => k.id === y);
|
|
290
|
+
return !E || !E.type.endsWith("/notesMaster") || E.external || se(K, E.target) !== g;
|
|
291
|
+
})) throw new Error("presentation 的备注母版目录与关系目标不一致");
|
|
292
|
+
const U = A || !f || !M.length || !P.includes(g);
|
|
293
|
+
if (U) for (const c of [K, ke, Ee]) Je(e, s, r, c);
|
|
294
|
+
for (const c of a) {
|
|
295
|
+
const y = c.notes.targetPart, E = T(y), C = V(e, s, E);
|
|
296
|
+
(we(C, y) !== g || !me(C).some((k) => k.type === Ie && !k.external)) && Je(e, s, r, E);
|
|
297
|
+
}
|
|
298
|
+
let S;
|
|
299
|
+
if (A) {
|
|
300
|
+
r.add(g), r.add(T(g));
|
|
301
|
+
const c = a[0].layoutId ? e.layouts[a[0].layoutId] : void 0;
|
|
302
|
+
if (S = (c == null ? void 0 : c.themeId) ?? e.themeOrder[0], !S || !V(e, s, S)) throw new Error("新增备注母版缺少可读的主题来源");
|
|
303
|
+
}
|
|
304
|
+
return { part: g, created: A, linkPresentation: U, theme: S, slides: a };
|
|
305
|
+
}
|
|
306
|
+
function Pr() {
|
|
307
|
+
const e = I(`<p:notesMaster xmlns:p="${L}" xmlns:a="${re}" xmlns:r="${ue}"/>`), s = (i, p, f = {}) => {
|
|
308
|
+
const u = Ue(p, { attributes: Object.entries(f) });
|
|
309
|
+
return oe(i, u), u;
|
|
310
|
+
}, r = s(s(e.root, "p:cSld"), "p:spTree"), n = s(r, "p:nvGrpSpPr");
|
|
311
|
+
s(n, "p:cNvPr", { id: "1", name: "" }), s(n, "p:cNvGrpSpPr"), s(n, "p:nvPr");
|
|
312
|
+
const a = s(s(r, "p:grpSpPr"), "a:xfrm");
|
|
313
|
+
return s(a, "a:off", { x: "0", y: "0" }), s(a, "a:ext", { cx: "0", cy: "0" }), s(a, "a:chOff", { x: "0", y: "0" }), s(a, "a:chExt", { cx: "0", cy: "0" }), s(e.root, "p:clrMap", hr), s(e.root, "p:hf"), s(e.root, "p:notesStyle"), H(e);
|
|
214
314
|
}
|
|
215
|
-
function
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
315
|
+
function ye(e, s, r, n, a) {
|
|
316
|
+
const i = me(e), p = i.find((P) => P.type === r && !P.external && se(s, P.target) === n);
|
|
317
|
+
if (p) return { bytes: e, id: p.id };
|
|
318
|
+
const f = new Set(i.map((P) => P.id));
|
|
319
|
+
let u = a, h = 1;
|
|
320
|
+
for (; f.has(u); ) u = `${a}${h++}`;
|
|
321
|
+
return { id: u, bytes: be(e, [{
|
|
322
|
+
sourceId: u,
|
|
323
|
+
targetId: u,
|
|
324
|
+
type: r,
|
|
325
|
+
target: Ne(s, n)
|
|
326
|
+
}]) };
|
|
327
|
+
}
|
|
328
|
+
function yr(e, s) {
|
|
329
|
+
const r = I(e);
|
|
330
|
+
if (r.root.namespaceUri !== $e || r.root.localName !== "Types") throw new Error("备注保存缺少有效内容类型目录");
|
|
331
|
+
const n = D(r.root, { localName: "Override", namespaceUri: $e }).find((a) => J(a, "PartName") === `/${s}`);
|
|
332
|
+
if (n) {
|
|
333
|
+
if (J(n, "ContentType") !== Re) throw new Error(`备注母版 Content-Type 冲突:${s}`);
|
|
334
|
+
return e;
|
|
335
|
+
}
|
|
336
|
+
return oe(r.root, Ue("Override", { attributes: [
|
|
337
|
+
["PartName", `/${s}`],
|
|
338
|
+
["ContentType", Re]
|
|
339
|
+
] })), H(r);
|
|
340
|
+
}
|
|
341
|
+
function wr(e, s, r, n) {
|
|
342
|
+
if (!(s != null && s.slides.length)) return;
|
|
343
|
+
const a = (i) => n[i] instanceof Uint8Array ? n[i] : V(e, r, i);
|
|
344
|
+
if (s.created && (n[s.part] = Pr(), n[T(s.part)] = ye(
|
|
345
|
+
void 0,
|
|
346
|
+
s.part,
|
|
347
|
+
`${ue}/theme`,
|
|
348
|
+
s.theme,
|
|
349
|
+
"rIdTheme"
|
|
350
|
+
).bytes), s.linkPresentation) {
|
|
351
|
+
const i = ye(a(ke), K, Ke, s.part, "rIdNotesMaster");
|
|
352
|
+
n[ke] = i.bytes;
|
|
353
|
+
const p = I(a(K));
|
|
354
|
+
let f = ae(p.root, { localName: "notesMasterIdLst", namespaceUri: p.root.namespaceUri });
|
|
355
|
+
if (!f) {
|
|
356
|
+
f = ne(p.root, p.root.namespaceUri, "notesMasterIdLst");
|
|
357
|
+
const u = D(p.root).find((h) => h.namespaceUri === p.root.namespaceUri && h.localName !== "sldMasterIdLst");
|
|
358
|
+
oe(p.root, f, u ?? null);
|
|
359
|
+
}
|
|
360
|
+
if (!D(f, { localName: "notesMasterId", namespaceUri: p.root.namespaceUri }).length) {
|
|
361
|
+
const u = ne(f, p.root.namespaceUri, "notesMasterId");
|
|
362
|
+
W(u, "xmlns:r", ue), W(u, "r:id", i.id), oe(f, u);
|
|
363
|
+
}
|
|
364
|
+
n[K] = H(p), n[Ee] = yr(a(Ee), s.part);
|
|
365
|
+
}
|
|
366
|
+
for (const i of s.slides) {
|
|
367
|
+
const p = i.notes.targetPart, f = T(p), u = a(f), h = we(u, p);
|
|
368
|
+
if (h && h !== s.part) throw new Error(`备注页 ${p} 的母版与 presentation 不一致`);
|
|
369
|
+
let P = ye(u, p, Ke, s.part, "rIdNotesMaster").bytes;
|
|
370
|
+
if (!me(P).some((g) => g.type === Ie && !g.external)) {
|
|
371
|
+
if (!i.origin) throw new Error(`备注页 ${p} 缺少对应页面锚点`);
|
|
372
|
+
P = ye(P, p, Ie, i.origin.part, "rIdNotesSlide").bytes;
|
|
373
|
+
}
|
|
374
|
+
n[f] = P;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function vr(e) {
|
|
378
|
+
return fe(e.ovr, "background") || fe(e.ovr, "transition");
|
|
379
|
+
}
|
|
380
|
+
function Sr(e, s) {
|
|
381
|
+
if (fe(s.ovr, "transition") && Xt(e, s.ovr.transition, !0), !fe(s.ovr, "background")) return;
|
|
382
|
+
const r = s.ovr.background;
|
|
383
|
+
ot(r, `版式 ${s.id} 的背景覆盖`);
|
|
384
|
+
const n = ae(e.root, {
|
|
220
385
|
localName: "cSld",
|
|
221
|
-
namespaceUri:
|
|
386
|
+
namespaceUri: L
|
|
222
387
|
});
|
|
223
|
-
if (!
|
|
224
|
-
let
|
|
388
|
+
if (!n) throw new Error(`版式 ${s.id} 缺少 p:cSld`);
|
|
389
|
+
let a = ae(n, {
|
|
225
390
|
localName: "bg",
|
|
226
|
-
namespaceUri:
|
|
391
|
+
namespaceUri: L
|
|
227
392
|
});
|
|
228
|
-
|
|
229
|
-
for (const
|
|
230
|
-
|
|
231
|
-
let
|
|
393
|
+
a || (a = ne(n, L, "bg"), ve(n, a));
|
|
394
|
+
for (const p of [...D(a)])
|
|
395
|
+
p.namespaceUri === L && p.localName === "bgRef" && Ce(a, p);
|
|
396
|
+
let i = ae(a, {
|
|
232
397
|
localName: "bgPr",
|
|
233
|
-
namespaceUri:
|
|
398
|
+
namespaceUri: L
|
|
234
399
|
});
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
function
|
|
238
|
-
const
|
|
239
|
-
return
|
|
240
|
-
var
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
var
|
|
244
|
-
const
|
|
245
|
-
return ((
|
|
246
|
-
}) &&
|
|
247
|
-
}),
|
|
248
|
-
}
|
|
249
|
-
function
|
|
250
|
-
const
|
|
251
|
-
for (const
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
return
|
|
259
|
-
}
|
|
260
|
-
function
|
|
261
|
-
const
|
|
262
|
-
for (const
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
function
|
|
271
|
-
var
|
|
272
|
-
const
|
|
273
|
-
for (const
|
|
274
|
-
if (!
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
return
|
|
280
|
-
}
|
|
281
|
-
function
|
|
282
|
-
return new Map(
|
|
283
|
-
const
|
|
284
|
-
return
|
|
400
|
+
i || (i = ne(a, L, "bgPr"), ve(a, i)), it(i), ct(i, r);
|
|
401
|
+
}
|
|
402
|
+
function kr(e) {
|
|
403
|
+
const s = /* @__PURE__ */ new Map();
|
|
404
|
+
return e.slideOrder.forEach((r, n) => {
|
|
405
|
+
var p;
|
|
406
|
+
const a = e.slides[r], i = (p = a.origin) == null ? void 0 : p.part;
|
|
407
|
+
i && a.dynamicSlideNumbers.some((f) => {
|
|
408
|
+
var h;
|
|
409
|
+
const u = e.elements[f];
|
|
410
|
+
return ((h = u == null ? void 0 : u.meta.origin) == null ? void 0 : h.part) === i && Ct(Ze(e, f));
|
|
411
|
+
}) && s.set(i, n + 1);
|
|
412
|
+
}), s;
|
|
413
|
+
}
|
|
414
|
+
function Er(e) {
|
|
415
|
+
const s = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const r of Object.values(e.elements)) {
|
|
417
|
+
if (!wt(r) && !vt(r) && !St(r) && !kt(r) && !Et(r) && !xt(r) && !Ot(r) && !Tt(r) && !Mt(r) && !Nt(r) && !bt(r) && !$t(r) && !Qe(r) && !Rt(r) && r.meta.sourceParent === void 0 && !r.meta.insertion) continue;
|
|
418
|
+
const n = r.meta.origin;
|
|
419
|
+
if (!n) throw new Error(`元素 ${r.id} 缺少 OOXML 回写锚点`);
|
|
420
|
+
const a = s.get(n.part) ?? [];
|
|
421
|
+
a.push(r), s.set(n.part, a);
|
|
422
|
+
}
|
|
423
|
+
return s;
|
|
424
|
+
}
|
|
425
|
+
function xr(e) {
|
|
426
|
+
const s = /* @__PURE__ */ new Map();
|
|
427
|
+
for (const r of Object.values(e.removedElements)) {
|
|
428
|
+
const n = r.meta.origin;
|
|
429
|
+
if (!n) continue;
|
|
430
|
+
const a = s.get(n.part) ?? [];
|
|
431
|
+
a.push(r), s.set(n.part, a);
|
|
432
|
+
}
|
|
433
|
+
return s;
|
|
434
|
+
}
|
|
435
|
+
function Or(e) {
|
|
436
|
+
var r;
|
|
437
|
+
const s = /* @__PURE__ */ new Map();
|
|
438
|
+
for (const n of Object.values(e.slides)) {
|
|
439
|
+
if (!nr(n)) continue;
|
|
440
|
+
const a = (r = n.origin) == null ? void 0 : r.part;
|
|
441
|
+
if (!a) throw new Error(`幻灯片 ${n.id} 缺少 OOXML 回写锚点`);
|
|
442
|
+
s.set(a, n);
|
|
443
|
+
}
|
|
444
|
+
return s;
|
|
445
|
+
}
|
|
446
|
+
function Tr(e) {
|
|
447
|
+
return new Map(e.layoutOrder.flatMap((s) => {
|
|
448
|
+
const r = e.layouts[s];
|
|
449
|
+
return vr(r) ? [[r.origin.part, r]] : [];
|
|
285
450
|
}));
|
|
286
451
|
}
|
|
287
|
-
function
|
|
288
|
-
return new Map(
|
|
289
|
-
const
|
|
290
|
-
return
|
|
452
|
+
function Mr(e) {
|
|
453
|
+
return new Map(e.masterOrder.flatMap((s) => {
|
|
454
|
+
const r = e.masters[s];
|
|
455
|
+
return It(r) ? [[r.id, r]] : [];
|
|
291
456
|
}));
|
|
292
457
|
}
|
|
293
|
-
async function
|
|
294
|
-
var
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
for (const
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
for (const [f,
|
|
302
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
458
|
+
async function Nr(e) {
|
|
459
|
+
var a;
|
|
460
|
+
const s = et();
|
|
461
|
+
Ut(e);
|
|
462
|
+
const r = /* @__PURE__ */ Object.create(null), n = /* @__PURE__ */ Object.create(null);
|
|
463
|
+
for (const i of s.values()) {
|
|
464
|
+
const p = await ((a = i.beforeSave) == null ? void 0 : a.call(i, e));
|
|
465
|
+
if (p) {
|
|
466
|
+
for (const [f, u] of Object.entries(p.changes)) {
|
|
467
|
+
if (Object.prototype.hasOwnProperty.call(r, f))
|
|
303
468
|
throw new Error(`多个编辑扩展同时修改 OPC part:${f}`);
|
|
304
|
-
|
|
469
|
+
r[f] = u;
|
|
305
470
|
}
|
|
306
|
-
for (const [f,
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
471
|
+
for (const [f, u] of Object.entries(p.baselines)) {
|
|
472
|
+
const h = n[f];
|
|
473
|
+
if (h && (h.length !== u.length || !h.every((P, g) => P === u[g])))
|
|
309
474
|
throw new Error(`多个编辑扩展的保存基线冲突:${f}`);
|
|
310
|
-
|
|
475
|
+
n[f] = u;
|
|
311
476
|
}
|
|
312
477
|
}
|
|
313
478
|
}
|
|
314
|
-
return { changes:
|
|
479
|
+
return { changes: r, baselines: n };
|
|
315
480
|
}
|
|
316
|
-
async function
|
|
317
|
-
return
|
|
481
|
+
async function br(e) {
|
|
482
|
+
return $r(e, await Nr(e));
|
|
318
483
|
}
|
|
319
|
-
async function
|
|
320
|
-
return
|
|
484
|
+
async function jr(e) {
|
|
485
|
+
return e.meta.source === "pptx" && e.package && !e.package.disposed ? br(e) : (await import("./generate.js")).generateEditDoc(e);
|
|
321
486
|
}
|
|
322
|
-
function
|
|
323
|
-
var
|
|
324
|
-
if (
|
|
325
|
-
if (
|
|
487
|
+
function $r(e, s = { changes: {}, baselines: {} }) {
|
|
488
|
+
var Xe, _e, ze, De, He;
|
|
489
|
+
if (lt(e), e.meta.readonly) throw new Error("只读编辑文档不能保存");
|
|
490
|
+
if (e.meta.source !== "pptx" || !e.package)
|
|
326
491
|
throw new Error("当前版本尚未实现生成式 PPTX 保存");
|
|
327
|
-
const
|
|
328
|
-
const
|
|
329
|
-
return
|
|
330
|
-
})),
|
|
492
|
+
const r = Er(e), n = Or(e), a = Tr(e), i = Mr(e), p = new Set([...r].flatMap(([t, o]) => o.some(Qe) ? [t] : [])), f = xr(e), u = _t(e), h = zt(e), P = new Map(Object.values(e.slides).flatMap((t) => t.layoutId !== t.sourceLayoutId && t.origin ? [[t.origin.part, t]] : [])), g = new Map(Object.values(e.slides).flatMap((t) => {
|
|
493
|
+
const o = pt(e, t.id);
|
|
494
|
+
return t.origin && o.length ? [[t.origin.part, o]] : [];
|
|
495
|
+
})), A = new Map(Object.values(e.slides).flatMap((t) => t.origin ? [[t.origin.part, t]] : [])), X = mr(e), l = Object.assign(
|
|
331
496
|
/* @__PURE__ */ Object.create(null),
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
),
|
|
335
|
-
for (const
|
|
336
|
-
if (
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
if (
|
|
342
|
-
const
|
|
343
|
-
if (
|
|
497
|
+
e.saveState.baselines,
|
|
498
|
+
s.baselines
|
|
499
|
+
), w = new Set(e.saveState.createdParts), M = "[Content_Types].xml", j = "ppt/presentation.xml", U = "ppt/_rels/presentation.xml.rels", S = Dt(e), q = e.themeOrder.filter((t) => ft(e.themes[t]) || !!l[t]);
|
|
500
|
+
for (const t of q) {
|
|
501
|
+
if (l[t]) continue;
|
|
502
|
+
const o = e.package.parts[t];
|
|
503
|
+
if (!o) throw new Error(`找不到主题 OPC part:${t}`);
|
|
504
|
+
l[t] = o.slice();
|
|
505
|
+
}
|
|
506
|
+
if (S != null && S.definitions.length && !l[S.part]) {
|
|
507
|
+
const t = e.package.parts[S.part];
|
|
508
|
+
if (t) l[S.part] = t.slice();
|
|
344
509
|
else {
|
|
345
|
-
|
|
346
|
-
for (const
|
|
347
|
-
if (o
|
|
348
|
-
const
|
|
349
|
-
if (!
|
|
350
|
-
o
|
|
510
|
+
w.add(S.part);
|
|
511
|
+
for (const o of [M, U]) {
|
|
512
|
+
if (l[o]) continue;
|
|
513
|
+
const m = e.package.parts[o];
|
|
514
|
+
if (!m) throw new Error(`PPTX 缺少 ${o}`);
|
|
515
|
+
l[o] = m.slice();
|
|
351
516
|
}
|
|
352
517
|
}
|
|
353
518
|
}
|
|
354
|
-
const
|
|
355
|
-
var
|
|
356
|
-
return ((
|
|
357
|
-
}),
|
|
358
|
-
if (
|
|
359
|
-
for (const
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
362
|
-
const
|
|
363
|
-
|
|
519
|
+
const c = Ht(e, l, w), y = gr(e, l, w), E = h.length > 0 || [...w].some((t) => /^ppt\/slides\/slide\d+\.xml$/.test(t)), C = e.slideOrder.flatMap((t) => {
|
|
520
|
+
var o;
|
|
521
|
+
return ((o = e.slides[t].origin) == null ? void 0 : o.part) ?? [];
|
|
522
|
+
}), k = ut(e, w), b = k.slideParts.size > 0, $ = /* @__PURE__ */ new Set();
|
|
523
|
+
if (b)
|
|
524
|
+
for (const t of e.slideOrder) {
|
|
525
|
+
const o = e.slides[t], m = (Xe = o.origin) == null ? void 0 : Xe.part;
|
|
526
|
+
if (!m) continue;
|
|
527
|
+
const v = T(m), _ = l[v] ?? (o.creation ? Pe(e, o, l) : void 0) ?? e.package.parts[v];
|
|
528
|
+
mt(e, m, _) && $.add(m);
|
|
364
529
|
}
|
|
365
|
-
const
|
|
366
|
-
if ((
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
const
|
|
372
|
-
for (const
|
|
373
|
-
...
|
|
374
|
-
...i.keys(),
|
|
530
|
+
const F = /* @__PURE__ */ new Set([...p, ...$]), ce = C.length !== e.saveState.sourceSlideParts.length || C.some((t, o) => t !== e.saveState.sourceSlideParts[o]), le = e.meta.width !== e.meta.sourceWidth || e.meta.height !== e.meta.sourceHeight || e.sections.edited, de = E || b || ce || le || !!l[j];
|
|
531
|
+
if ((ce || le) && !l[j]) {
|
|
532
|
+
const t = e.package.parts[j];
|
|
533
|
+
if (!t) throw new Error("PPTX 缺少 ppt/presentation.xml");
|
|
534
|
+
l[j] = t.slice();
|
|
535
|
+
}
|
|
536
|
+
const Q = de ? kr(e) : /* @__PURE__ */ new Map();
|
|
537
|
+
for (const t of /* @__PURE__ */ new Set([
|
|
538
|
+
...r.keys(),
|
|
375
539
|
...n.keys(),
|
|
376
|
-
...
|
|
540
|
+
...a.keys(),
|
|
541
|
+
...i.keys(),
|
|
377
542
|
...f.keys(),
|
|
378
|
-
...
|
|
379
|
-
...
|
|
380
|
-
...
|
|
543
|
+
...Q.keys(),
|
|
544
|
+
...F,
|
|
545
|
+
...g.keys()
|
|
381
546
|
])) {
|
|
382
|
-
if (
|
|
383
|
-
var
|
|
384
|
-
return ((
|
|
547
|
+
if (l[t] || h.some((m) => {
|
|
548
|
+
var v;
|
|
549
|
+
return ((v = m.origin) == null ? void 0 : v.part) === t;
|
|
385
550
|
})) continue;
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
for (const
|
|
391
|
-
const
|
|
392
|
-
if (o
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
for (const
|
|
397
|
-
const
|
|
398
|
-
if (o
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
for (const [
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
for (const
|
|
410
|
-
if (
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
if ((
|
|
415
|
-
const
|
|
416
|
-
if (!
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
if (
|
|
420
|
-
for (const
|
|
421
|
-
if (
|
|
422
|
-
const
|
|
423
|
-
if (!
|
|
424
|
-
|
|
551
|
+
const o = e.package.parts[t];
|
|
552
|
+
if (!o) throw new Error(`找不到待写回的 OPC part:${t}`);
|
|
553
|
+
l[t] = o.slice();
|
|
554
|
+
}
|
|
555
|
+
for (const t of u.relationships.keys()) {
|
|
556
|
+
const o = T(t);
|
|
557
|
+
if (l[o] || w.has(o)) continue;
|
|
558
|
+
const m = e.package.parts[o];
|
|
559
|
+
m ? l[o] = m.slice() : w.add(o);
|
|
560
|
+
}
|
|
561
|
+
for (const t of F) {
|
|
562
|
+
const o = T(t);
|
|
563
|
+
if (l[o] || w.has(o)) continue;
|
|
564
|
+
const m = e.package.parts[o];
|
|
565
|
+
m ? l[o] = m.slice() : w.add(o);
|
|
566
|
+
}
|
|
567
|
+
for (const [t, o] of P) {
|
|
568
|
+
if (o.creation) continue;
|
|
569
|
+
const m = T(t);
|
|
570
|
+
if (l[m] || w.has(m)) continue;
|
|
571
|
+
const v = e.package.parts[m];
|
|
572
|
+
v ? l[m] = v.slice() : w.add(m);
|
|
573
|
+
}
|
|
574
|
+
for (const t of k.packageParts) {
|
|
575
|
+
if (w.has(t) || l[t]) continue;
|
|
576
|
+
const o = e.package.parts[t];
|
|
577
|
+
o && (l[t] = o.slice());
|
|
578
|
+
}
|
|
579
|
+
if ((u.resources.size || E || b || c.trackedParts.size) && !l[M]) {
|
|
580
|
+
const t = e.package.parts[M];
|
|
581
|
+
if (!t) throw new Error("PPTX 缺少 [Content_Types].xml");
|
|
582
|
+
l[M] = t.slice();
|
|
583
|
+
}
|
|
584
|
+
if (E || b)
|
|
585
|
+
for (const t of [j, U]) {
|
|
586
|
+
if (l[t]) continue;
|
|
587
|
+
const o = e.package.parts[t];
|
|
588
|
+
if (!o) throw new Error(`PPTX 缺少 ${t}`);
|
|
589
|
+
l[t] = o.slice();
|
|
425
590
|
}
|
|
426
|
-
for (const
|
|
427
|
-
const
|
|
428
|
-
|
|
591
|
+
for (const t of h) {
|
|
592
|
+
const o = t.origin.part;
|
|
593
|
+
w.add(o), w.add(T(o));
|
|
429
594
|
}
|
|
430
|
-
for (const
|
|
431
|
-
|
|
432
|
-
const
|
|
595
|
+
for (const t of u.resources.values())
|
|
596
|
+
t.created && w.add(t.targetPart);
|
|
597
|
+
const d = Object.assign(
|
|
433
598
|
/* @__PURE__ */ Object.create(null),
|
|
434
|
-
|
|
599
|
+
s.changes
|
|
435
600
|
);
|
|
436
|
-
for (const
|
|
437
|
-
for (const [
|
|
438
|
-
!
|
|
439
|
-
const
|
|
440
|
-
var
|
|
441
|
-
const
|
|
442
|
-
return
|
|
443
|
-
})),
|
|
444
|
-
for (const
|
|
445
|
-
const
|
|
446
|
-
var
|
|
447
|
-
return ((
|
|
448
|
-
}),
|
|
449
|
-
if (!
|
|
450
|
-
const
|
|
451
|
-
t,
|
|
601
|
+
for (const t of w) d[t] = null;
|
|
602
|
+
for (const [t, o] of Object.entries(l))
|
|
603
|
+
!e.package.parts[t] && !k.packageParts.has(t) && !w.has(t) && (d[t] = o);
|
|
604
|
+
const N = new Set(e.slideOrder.flatMap((t) => {
|
|
605
|
+
var v;
|
|
606
|
+
const o = e.slides[t], m = (v = o.origin) == null ? void 0 : v.part;
|
|
607
|
+
return m && (l[m] || o.creation || Q.has(m)) ? [m] : [];
|
|
608
|
+
})), O = /* @__PURE__ */ new Map();
|
|
609
|
+
for (const t of N) {
|
|
610
|
+
const o = h.find((Y) => {
|
|
611
|
+
var ie;
|
|
612
|
+
return ((ie = Y.origin) == null ? void 0 : ie.part) === t;
|
|
613
|
+
}), m = l[t] ?? (o ? ir(e, o, l) ?? Ft() : void 0);
|
|
614
|
+
if (!m) throw new Error(`找不到页面保存基线:${t}`);
|
|
615
|
+
const v = I(m), _ = r.get(t) ?? [], R = T(t), B = l[R] ?? (o ? Pe(e, o, l) : void 0), z = F.has(t) ? Te(
|
|
452
616
|
e,
|
|
453
|
-
|
|
454
|
-
|
|
617
|
+
t,
|
|
618
|
+
B,
|
|
619
|
+
u.relationships.get(t) ?? []
|
|
455
620
|
) : void 0;
|
|
456
|
-
z &&
|
|
457
|
-
const
|
|
458
|
-
...
|
|
459
|
-
...f.get(
|
|
621
|
+
z && O.set(t, z), z == null || z.removeDanglingHyperlinks(v);
|
|
622
|
+
const he = [
|
|
623
|
+
...o ? cr(o) : [],
|
|
624
|
+
...f.get(t) ?? []
|
|
460
625
|
];
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
for (const
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
626
|
+
Me(v, e, t, _, he, { links: z });
|
|
627
|
+
const ge = ((_e = o == null ? void 0 : o.creation) == null ? void 0 : _e.duplicateRemovedAnimationSpids) ?? ((ze = o == null ? void 0 : o.creation) == null ? void 0 : ze.duplicateRemovedSpids) ?? [], Oe = (f.get(t) ?? []).flatMap((Y) => Y.sourceSpids ?? (Y.meta.origin ? [Y.meta.origin.spid] : []));
|
|
628
|
+
Bt(v, [...ge, ...Oe]);
|
|
629
|
+
for (const Y of g.get(t) ?? []) {
|
|
630
|
+
const ie = e.elements[Y], Be = A.get(t);
|
|
631
|
+
fr(
|
|
632
|
+
v,
|
|
633
|
+
ie,
|
|
634
|
+
Ze(e, Y),
|
|
635
|
+
dt(ie),
|
|
636
|
+
Be ? X(Be, ie) : void 0
|
|
472
637
|
);
|
|
473
638
|
}
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
const
|
|
480
|
-
for (const
|
|
481
|
-
const
|
|
482
|
-
if (!
|
|
483
|
-
const
|
|
484
|
-
t,
|
|
639
|
+
const pe = n.get(t);
|
|
640
|
+
pe && Gt(v, e, pe);
|
|
641
|
+
const Fe = H(v);
|
|
642
|
+
d[t] = Q.has(t) ? Wt(Fe, Q.get(t)) : Fe;
|
|
643
|
+
}
|
|
644
|
+
const Z = new Set(e.layoutOrder.filter((t) => l[t] || r.has(t) || f.has(t) || a.has(t)));
|
|
645
|
+
for (const t of Z) {
|
|
646
|
+
const o = l[t];
|
|
647
|
+
if (!o) throw new Error(`找不到版式保存基线:${t}`);
|
|
648
|
+
const m = I(o), v = r.get(t) ?? [], _ = l[T(t)], R = F.has(t) ? Te(
|
|
485
649
|
e,
|
|
486
|
-
I,
|
|
487
|
-
d.relationships.get(e) ?? []
|
|
488
|
-
) : void 0;
|
|
489
|
-
b && y.set(e, b), b == null || b.removeDanglingHyperlinks(l), Pe(l, t, e, h, f.get(e) ?? [], { links: b });
|
|
490
|
-
const H = n.get(e);
|
|
491
|
-
H && Zt(l, H), m[e] = W(l);
|
|
492
|
-
}
|
|
493
|
-
const J = new Set(t.masterOrder.filter((e) => o[e] || s.has(e) || f.has(e) || c.has(e)));
|
|
494
|
-
for (const e of J) {
|
|
495
|
-
const r = o[e];
|
|
496
|
-
if (!r) throw new Error(`找不到母版保存基线:${e}`);
|
|
497
|
-
const l = D(r), h = s.get(e) ?? [], I = o[E(e)], b = S.has(e) ? ge(
|
|
498
650
|
t,
|
|
651
|
+
_,
|
|
652
|
+
u.relationships.get(t) ?? []
|
|
653
|
+
) : void 0;
|
|
654
|
+
R && O.set(t, R), R == null || R.removeDanglingHyperlinks(m), Me(m, e, t, v, f.get(t) ?? [], { links: R });
|
|
655
|
+
const B = a.get(t);
|
|
656
|
+
B && Sr(m, B), d[t] = H(m);
|
|
657
|
+
}
|
|
658
|
+
const xe = new Set(e.masterOrder.filter((t) => l[t] || r.has(t) || f.has(t) || i.has(t)));
|
|
659
|
+
for (const t of xe) {
|
|
660
|
+
const o = l[t];
|
|
661
|
+
if (!o) throw new Error(`找不到母版保存基线:${t}`);
|
|
662
|
+
const m = I(o), v = r.get(t) ?? [], _ = l[T(t)], R = F.has(t) ? Te(
|
|
499
663
|
e,
|
|
500
|
-
|
|
501
|
-
|
|
664
|
+
t,
|
|
665
|
+
_,
|
|
666
|
+
u.relationships.get(t) ?? []
|
|
502
667
|
) : void 0;
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
const
|
|
508
|
-
for (const
|
|
509
|
-
...
|
|
510
|
-
...
|
|
511
|
-
...
|
|
512
|
-
...
|
|
668
|
+
R && O.set(t, R), R == null || R.removeDanglingHyperlinks(m), Me(m, e, t, v, f.get(t) ?? [], { links: R });
|
|
669
|
+
const B = i.get(t);
|
|
670
|
+
B && ht(m, B), d[t] = H(m);
|
|
671
|
+
}
|
|
672
|
+
const je = /* @__PURE__ */ new Set();
|
|
673
|
+
for (const t of /* @__PURE__ */ new Set([
|
|
674
|
+
...u.relationships.keys(),
|
|
675
|
+
...O.keys(),
|
|
676
|
+
...P.keys(),
|
|
677
|
+
...c.relationshipSlides.keys()
|
|
513
678
|
])) {
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
var
|
|
518
|
-
return ((
|
|
519
|
-
}),
|
|
520
|
-
let z =
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
for (const [
|
|
527
|
-
|
|
528
|
-
for (const [
|
|
529
|
-
if (
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
[...
|
|
679
|
+
const o = u.relationships.get(t) ?? [], m = T(t);
|
|
680
|
+
je.add(m);
|
|
681
|
+
const v = h.find((Oe) => {
|
|
682
|
+
var pe;
|
|
683
|
+
return ((pe = Oe.origin) == null ? void 0 : pe.part) === t;
|
|
684
|
+
}), _ = l[m] ?? (v ? Pe(e, v, l) : void 0), R = O.get(t), B = d[t];
|
|
685
|
+
let z = R && B instanceof Uint8Array ? gt(_, o, R, B) : be(_, o);
|
|
686
|
+
const he = P.get(t);
|
|
687
|
+
he && (z = Vt(he, z));
|
|
688
|
+
const ge = c.relationshipSlides.get(t);
|
|
689
|
+
ge && (z = We(ge, z)), d[m] = z;
|
|
690
|
+
}
|
|
691
|
+
for (const [t, o] of Object.entries(l))
|
|
692
|
+
t.endsWith(".rels") && !je.has(t) && (d[t] = be(o, []));
|
|
693
|
+
for (const [t, o] of u.resources) d[t] = qt(o);
|
|
694
|
+
if (Yt(e, l, c, d), l[M]) {
|
|
695
|
+
const t = Kt(
|
|
696
|
+
l[M],
|
|
697
|
+
[...u.resources.values()]
|
|
533
698
|
);
|
|
534
|
-
|
|
535
|
-
e,
|
|
699
|
+
d[M] = Jt(
|
|
536
700
|
t,
|
|
537
|
-
|
|
701
|
+
e,
|
|
702
|
+
k.contentTypeParts
|
|
538
703
|
);
|
|
539
704
|
}
|
|
540
|
-
for (const
|
|
541
|
-
const
|
|
542
|
-
|
|
705
|
+
for (const t of h) {
|
|
706
|
+
const o = T(t.origin.part), m = d[o], v = m instanceof Uint8Array ? m : Pe(e, t, l), _ = (De = t.creation) != null && De.duplicateSourcePart ? v : Qt(t, v);
|
|
707
|
+
d[o] = We(t, _);
|
|
543
708
|
}
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
if (!
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
709
|
+
if (l[j]) {
|
|
710
|
+
const t = l[U] ?? e.package.parts[U];
|
|
711
|
+
if (!t) throw new Error("PPTX 缺少 ppt/_rels/presentation.xml.rels");
|
|
712
|
+
d[j] = Zt(
|
|
713
|
+
l[j],
|
|
714
|
+
t,
|
|
715
|
+
e
|
|
551
716
|
);
|
|
552
717
|
}
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
)),
|
|
557
|
-
const
|
|
558
|
-
if (!(
|
|
718
|
+
if (l[U] && (d[U] = er(
|
|
719
|
+
l[U],
|
|
720
|
+
e
|
|
721
|
+
)), S != null && S.definitions.length && w.has(S.part)) {
|
|
722
|
+
const t = d[M] ?? l[M], o = d[U] ?? l[U];
|
|
723
|
+
if (!(t instanceof Uint8Array) || !(o instanceof Uint8Array))
|
|
559
724
|
throw new Error("创建 tableStyles.xml 缺少 OPC 闭包基线");
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
725
|
+
d[M] = tr(t, S.part), d[U] = rr(
|
|
726
|
+
o,
|
|
727
|
+
S.part
|
|
563
728
|
);
|
|
564
729
|
}
|
|
565
|
-
for (const
|
|
566
|
-
if (
|
|
567
|
-
const
|
|
568
|
-
|
|
730
|
+
for (const t of k.packageParts) d[t] = null;
|
|
731
|
+
if (S) {
|
|
732
|
+
const t = l[S.part];
|
|
733
|
+
S.definitions.length ? d[S.part] = sr(t, S.definitions) : t && (d[S.part] = t);
|
|
569
734
|
}
|
|
570
|
-
for (const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
for (const
|
|
574
|
-
|
|
575
|
-
|
|
735
|
+
for (const t of q)
|
|
736
|
+
d[t] = Pt(l[t], e.themes[t]);
|
|
737
|
+
or(e, h, l, w, d);
|
|
738
|
+
for (const t of et().values()) (He = t.materializePackage) == null || He.call(t, e, l, w, d);
|
|
739
|
+
wr(e, y, l, d);
|
|
740
|
+
const Le = Lt(e.package, d);
|
|
741
|
+
return yt(e, Le.package, l, [...w].sort()), Le;
|
|
576
742
|
}
|
|
577
743
|
export {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
744
|
+
$r as saveEditDoc,
|
|
745
|
+
br as saveEditDocWithExtensions,
|
|
746
|
+
jr as serializeEditDoc
|
|
581
747
|
};
|