ai-word-editor 0.0.18 → 0.0.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"wordDocxExport.d.ts","sourceRoot":"","sources":["../../../src/utils/wordDocxExport.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC,YAAY;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAuBD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,EAAE,EACvB,QAAQ,SAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxF"}
1
+ {"version":3,"file":"wordDocxExport.d.ts","sourceRoot":"","sources":["../../../src/utils/wordDocxExport.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC,YAAY;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAuBD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,EAAE,EACvB,QAAQ,SAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxF"}
@@ -1,6 +1,7 @@
1
- import j from "jszip";
2
- import { saveAs as J } from "file-saver";
3
- async function K(e, o, t = "文档") {
1
+ import * as j from "jszip";
2
+ import { saveAs as K } from "file-saver";
3
+ const L = j.default || j;
4
+ async function V(e, o, t = "文档") {
4
5
  const s = new DOMParser().parseFromString(e, "text/html"), n = /* @__PURE__ */ new Map(), l = [], w = new Map((o || []).map((v) => [v.id, v]));
5
6
  s.body.querySelectorAll("span[data-comment-id]").forEach((v) => {
6
7
  const a = v.getAttribute("data-comment-id");
@@ -9,25 +10,25 @@ async function K(e, o, t = "文档") {
9
10
  n.set(a, u), l.push({ ...w.get(a), ooxmlId: u });
10
11
  }
11
12
  });
12
- const i = L(s.body, n), m = l.length > 0, d = new j();
13
- d.file("[Content_Types].xml", W(m)), d.file("_rels/.rels", E()), d.file("word/document.xml", U(i)), d.file("word/styles.xml", X()), d.file("word/_rels/document.xml.rels", G(m)), m && d.file("word/comments.xml", at(l));
13
+ const i = W(s.body, n), m = l.length > 0, d = new L();
14
+ d.file("[Content_Types].xml", E(m)), d.file("_rels/.rels", G()), d.file("word/document.xml", X(i)), d.file("word/styles.xml", Z()), d.file("word/_rels/document.xml.rels", U(m)), m && d.file("word/comments.xml", wt(l));
14
15
  const c = await d.generateAsync({
15
16
  type: "blob",
16
17
  mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
17
18
  });
18
- J(c, `${t}.docx`);
19
+ K(c, `${t}.docx`);
19
20
  }
20
21
  async function ct(e, o = "文档") {
21
- return K(e, [], o);
22
+ return V(e, [], o);
22
23
  }
23
24
  async function mt(e, o = "文档") {
24
- const r = new DOMParser().parseFromString(e, "text/html"), s = L(r.body, /* @__PURE__ */ new Map()), n = new j();
25
- return n.file("[Content_Types].xml", W(!1)), n.file("_rels/.rels", E()), n.file("word/document.xml", U(s)), n.file("word/styles.xml", X()), n.file("word/_rels/document.xml.rels", G(!1)), n.generateAsync({
25
+ const r = new DOMParser().parseFromString(e, "text/html"), s = W(r.body, /* @__PURE__ */ new Map()), n = new L();
26
+ return n.file("[Content_Types].xml", E(!1)), n.file("_rels/.rels", G()), n.file("word/document.xml", X(s)), n.file("word/styles.xml", Z()), n.file("word/_rels/document.xml.rels", U(!1)), n.generateAsync({
26
27
  type: "blob",
27
28
  mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
28
29
  });
29
30
  }
30
- const V = /* @__PURE__ */ new Set(["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote", "pre"]), Y = /* @__PURE__ */ new Set(["script", "style", "head"]), Q = {
31
+ const Y = /* @__PURE__ */ new Set(["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote", "pre"]), Q = /* @__PURE__ */ new Set(["script", "style", "head"]), tt = {
31
32
  signle: { val: "single", sz: "6" },
32
33
  "signle-bold": { val: "thick", sz: "12" },
33
34
  double: { val: "double", sz: "6" },
@@ -38,7 +39,7 @@ const V = /* @__PURE__ */ new Set(["p", "div", "h1", "h2", "h3", "h4", "h5", "h6
38
39
  "double-bold-bottom": { val: "thickThinSmallGap", sz: "24" },
39
40
  wavy: { val: "wave", sz: "6" }
40
41
  };
41
- function L(e, o) {
42
+ function W(e, o) {
42
43
  let t = "";
43
44
  for (const r of e.childNodes)
44
45
  t += q(r, o);
@@ -51,14 +52,14 @@ function q(e, o) {
51
52
  }
52
53
  if (e.nodeType !== 1) return "";
53
54
  const t = e, r = t.tagName.toLowerCase();
54
- if (Y.has(r)) return "";
55
- if (V.has(r)) {
56
- const n = st(r, t), l = T(t, o, {});
55
+ if (Q.has(r)) return "";
56
+ if (Y.has(r)) {
57
+ const n = lt(r, t), l = S(t, o, {});
57
58
  return r === "p" ? `<w:p>${n}${l || "<w:r><w:t></w:t></w:r>"}</w:p>` : l ? `<w:p>${n}${l}</w:p>` : "";
58
59
  }
59
60
  if (r === "table") {
60
61
  const n = t.querySelector("colgroup[data-word-col-layout]"), l = t.querySelectorAll("tbody tr, tr"), w = l.length === 1, i = l[0] ? [...l[0].querySelectorAll("td, th")] : [];
61
- return n || w && i.length >= 2 ? et(t, o) : tt(t, o);
62
+ return n || w && i.length >= 2 ? ot(t, o) : et(t, o);
62
63
  }
63
64
  if (["ul", "ol", "tbody", "thead", "tfoot", "tr", "td", "th"].includes(r)) {
64
65
  let n = "";
@@ -67,34 +68,34 @@ function q(e, o) {
67
68
  return n;
68
69
  }
69
70
  if (r === "hr") {
70
- const n = t.getAttribute("data-type") || "signle", w = (t.getAttribute("data-color") || "#000000").replace(/^#/, ""), i = Q[n] || { val: "single", sz: "6" };
71
+ const n = t.getAttribute("data-type") || "signle", w = (t.getAttribute("data-color") || "#000000").replace(/^#/, ""), i = tt[n] || { val: "single", sz: "6" };
71
72
  return `<w:p><w:pPr><w:pBdr><w:bottom w:val="${i.val}" w:color="${w}" w:sz="${i.sz}" w:space="1"/></w:pBdr></w:pPr></w:p>`;
72
73
  }
73
- const s = T(t, o, {});
74
+ const s = S(t, o, {});
74
75
  return s ? `<w:p>${s}</w:p>` : "";
75
76
  }
76
- function tt(e, o) {
77
+ function et(e, o) {
77
78
  const t = e.querySelectorAll("tr");
78
79
  if (!t.length) return "";
79
- const r = e.querySelector("colgroup"), s = r ? [...r.querySelectorAll("col")] : [], n = t[0], l = n ? [...n.querySelectorAll("td, th")] : [], w = Math.max(s.length, l.length, 1), i = 8306, m = (f, b) => {
80
- const h = (f && f.getAttribute("style") || "").match(/width\s*:\s*([\d.]+)%/);
81
- return h ? parseFloat(h[1]) : 100 / b;
82
- }, d = Array.from({ length: w }).map((f, b) => {
83
- const $ = s[b], h = m($, w);
84
- return Math.round(h / 100 * i);
85
- }), c = d.map((f) => `<w:gridCol w:w="${f}"/>`).join(""), v = e.getAttribute("data-word-tbl-borders");
80
+ const r = e.querySelector("colgroup"), s = r ? [...r.querySelectorAll("col")] : [], n = t[0], l = n ? [...n.querySelectorAll("td, th")] : [], w = Math.max(s.length, l.length, 1), i = 8306, m = (h, b) => {
81
+ const f = (h && h.getAttribute("style") || "").match(/width\s*:\s*([\d.]+)%/);
82
+ return f ? parseFloat(f[1]) : 100 / b;
83
+ }, d = Array.from({ length: w }).map((h, b) => {
84
+ const $ = s[b], f = m($, w);
85
+ return Math.round(f / 100 * i);
86
+ }), c = d.map((h) => `<w:gridCol w:w="${h}"/>`).join(""), v = e.getAttribute("data-word-tbl-borders");
86
87
  let a = null;
87
88
  if (v)
88
89
  try {
89
- const f = JSON.parse(v), b = f.val || "single", $ = f.sz || "4", h = f.color || "auto", C = f.space || "0";
90
+ const h = JSON.parse(v), b = h.val || "single", $ = h.sz || "4", f = h.color || "auto", C = h.space || "0";
90
91
  a = `
91
92
  <w:tblBorders>
92
- <w:top w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
93
- <w:left w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
94
- <w:bottom w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
95
- <w:right w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
96
- <w:insideH w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
97
- <w:insideV w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${h}"/>
93
+ <w:top w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
94
+ <w:left w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
95
+ <w:bottom w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
96
+ <w:right w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
97
+ <w:insideH w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
98
+ <w:insideV w:val="${b}" w:sz="${$}" w:space="${C}" w:color="${f}"/>
98
99
  </w:tblBorders>`;
99
100
  } catch {
100
101
  a = null;
@@ -114,21 +115,21 @@ function tt(e, o) {
114
115
  <w:tblLayout w:type="fixed"/>${a}
115
116
  </w:tblPr>`, p = Array(w).fill(0);
116
117
  let z = "";
117
- return t.forEach((f) => {
118
- const b = [...f.querySelectorAll("td, th")];
118
+ return t.forEach((h) => {
119
+ const b = [...h.querySelectorAll("td, th")];
119
120
  if (!b.length) return;
120
121
  const $ = [];
121
- let h = 0;
122
+ let f = 0;
122
123
  b.forEach((A) => {
123
- for (; h < w && p[h] > 0; )
124
- h++;
124
+ for (; f < w && p[f] > 0; )
125
+ f++;
125
126
  const g = parseInt(A.getAttribute("colspan") ?? "", 10), y = !Number.isNaN(g) && g > 1 ? g : 1, x = parseInt(A.getAttribute("rowspan") ?? "", 10), R = !Number.isNaN(x) && x > 1 ? x : 1;
126
127
  $.push({
127
- startCol: h,
128
+ startCol: f,
128
129
  colspan: y,
129
130
  rowspan: R,
130
131
  el: A
131
- }), h += y;
132
+ }), f += y;
132
133
  });
133
134
  let C = "", P = 0;
134
135
  for (; P < w; ) {
@@ -136,22 +137,22 @@ function tt(e, o) {
136
137
  if (A) {
137
138
  const { el: g, colspan: y, rowspan: x } = A, R = y > 1, F = x > 1, D = (g.getAttribute("style") || "").match(/vertical-align\s*:\s*(top|middle|bottom)/i), I = D ? D[1].toLowerCase() : "middle", k = { top: "top", middle: "center", bottom: "bottom" };
138
139
  let _ = 0;
139
- for (let S = 0; S < y; S++) {
140
- const B = d[P + S];
140
+ for (let T = 0; T < y; T++) {
141
+ const B = d[P + T];
141
142
  _ += Number.isFinite(B) ? B : Math.round(i / w);
142
143
  }
143
144
  const M = [];
144
145
  if (R && M.push(`<w:gridSpan w:val="${y}"/>`), I && k[I] && M.push(`<w:vAlign w:val="${k[I]}"/>`), F) {
145
146
  M.push('<w:vMerge w:val="restart"/>');
146
- for (let S = 0; S < y; S++)
147
- p[P + S] = x;
147
+ for (let T = 0; T < y; T++)
148
+ p[P + T] = x;
148
149
  }
149
150
  _ > 0 && M.push(`<w:tcW w:w="${_}" w:type="dxa"/>`);
150
- const Z = `<w:tcPr>${M.join("")}</w:tcPr>`;
151
+ const J = `<w:tcPr>${M.join("")}</w:tcPr>`;
151
152
  let H = "";
152
- for (const S of g.childNodes)
153
- H += q(S, o);
154
- H || (H = "<w:p><w:r><w:t></w:t></w:r></w:p>"), C += `<w:tc>${Z}${H}</w:tc>`, P += y;
153
+ for (const T of g.childNodes)
154
+ H += q(T, o);
155
+ H || (H = "<w:p><w:r><w:t></w:t></w:r></w:p>"), C += `<w:tc>${J}${H}</w:tc>`, P += y;
155
156
  } else if (p[P] > 0) {
156
157
  let g = 0;
157
158
  for (; P + g < w && p[P + g] > 0; )
@@ -181,7 +182,7 @@ function tt(e, o) {
181
182
  z += `<w:tr>${C}</w:tr>`;
182
183
  }), z ? `<w:tbl>${u}<w:tblGrid>${c}</w:tblGrid>${z}</w:tbl>` : "";
183
184
  }
184
- function et(e, o) {
185
+ function ot(e, o) {
185
186
  const t = e.querySelector("colgroup"), r = t ? [...t.querySelectorAll("col")] : [], s = e.querySelectorAll("tbody tr, tr"), n = s[0] ? [...s[0].querySelectorAll("td, th")] : [], l = Math.max(r.length, n.length, 1), w = 8306, i = 720, m = (a) => {
186
187
  const p = (a && a.getAttribute("style") || "").match(/width\s*:\s*([\d.]+)%/);
187
188
  return p ? parseFloat(p[1]) : 100 / l;
@@ -199,41 +200,41 @@ function et(e, o) {
199
200
  <w:pgMar w:top="1800" w:right="1800" w:bottom="1800" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/>
200
201
  </w:sectPr></w:pPr></w:p>`, c;
201
202
  }
202
- function T(e, o, t) {
203
+ function S(e, o, t) {
203
204
  let r = "";
204
205
  for (const s of e.childNodes)
205
- r += ot(s, o, t);
206
+ r += rt(s, o, t);
206
207
  return r;
207
208
  }
208
- function ot(e, o, t) {
209
+ function rt(e, o, t) {
209
210
  if (e.nodeType === 3) {
210
211
  const n = e.textContent;
211
- return n ? nt(n, t) : "";
212
+ return n ? st(n, t) : "";
212
213
  }
213
214
  if (e.nodeType !== 1) return "";
214
215
  const r = e, s = r.tagName.toLowerCase();
215
216
  if (s === "span" && r.hasAttribute("data-comment-id")) {
216
217
  const n = r.getAttribute("data-comment-id"), l = n !== null ? o.get(n) : void 0;
217
218
  if (l !== void 0) {
218
- const w = T(r, o, t);
219
+ const w = S(r, o, t);
219
220
  return `<w:commentRangeStart w:id="${l}"/>` + w + `<w:commentRangeEnd w:id="${l}"/><w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${l}"/></w:r>`;
220
221
  }
221
- return T(r, o, t);
222
+ return S(r, o, t);
222
223
  }
223
224
  if (s === "span") {
224
- const n = rt(r, t);
225
- return T(r, o, n);
225
+ const n = nt(r, t);
226
+ return S(r, o, n);
226
227
  }
227
- return s === "strong" || s === "b" ? T(r, o, { ...t, bold: !0 }) : s === "em" || s === "i" ? T(r, o, { ...t, italic: !0 }) : s === "u" ? T(r, o, { ...t, underline: !0 }) : s === "s" || s === "del" || s === "strike" ? T(r, o, { ...t, strike: !0 }) : s === "br" ? "<w:r><w:br/></w:r>" : T(r, o, t);
228
+ return s === "strong" || s === "b" ? S(r, o, { ...t, bold: !0 }) : s === "em" || s === "i" ? S(r, o, { ...t, italic: !0 }) : s === "u" ? S(r, o, { ...t, underline: !0 }) : s === "s" || s === "del" || s === "strike" ? S(r, o, { ...t, strike: !0 }) : s === "br" ? "<w:r><w:br/></w:r>" : S(r, o, t);
228
229
  }
229
- function rt(e, o) {
230
+ function nt(e, o) {
230
231
  const t = e.getAttribute("style") || "", r = t.match(/font-family\s*:\s*([^;]+)/i), s = r ? r[1].trim().replace(/["']/g, "") : null, n = t.match(/font-size\s*:\s*([\d.]+)(px|pt)/i);
231
232
  let l = null;
232
233
  if (n) {
233
234
  const m = parseFloat(n[1]);
234
235
  l = n[2].toLowerCase() === "pt" ? Math.round(m * 2) : Math.round(m * 1.5);
235
236
  }
236
- const w = t.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i), i = w ? lt(w[1].trim()) : null;
237
+ const w = t.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i), i = w ? at(w[1].trim()) : null;
237
238
  return {
238
239
  ...o,
239
240
  bold: o.bold || /font-weight\s*:\s*(bold|[789]\d\d)/i.test(t),
@@ -250,7 +251,7 @@ function rt(e, o) {
250
251
  noProof: e.hasAttribute("data-word-no-proof") ? e.getAttribute("data-word-no-proof") !== "0" && e.getAttribute("data-word-no-proof") !== "false" : o.noProof
251
252
  };
252
253
  }
253
- function nt(e, { bold: o, italic: t, underline: r, strike: s, fontFamily: n, fontSize: l, color: w, lang: i, langEastAsia: m, noProof: d } = {}) {
254
+ function st(e, { bold: o, italic: t, underline: r, strike: s, fontFamily: n, fontSize: l, color: w, lang: i, langEastAsia: m, noProof: d } = {}) {
254
255
  let c = "";
255
256
  if (n) {
256
257
  const a = N(n);
@@ -262,7 +263,7 @@ function nt(e, { bold: o, italic: t, underline: r, strike: s, fontFamily: n, fon
262
263
  }
263
264
  return d && (c += "<w:noProof/>"), `<w:r>${c ? `<w:rPr>${c}</w:rPr>` : ""}<w:t xml:space="preserve">${N(e)}</w:t></w:r>`;
264
265
  }
265
- function st(e, o) {
266
+ function lt(e, o) {
266
267
  let t = "";
267
268
  const r = { h1: "Heading1", h2: "Heading2", h3: "Heading3", h4: "Heading4", h5: "Heading5", h6: "Heading6" };
268
269
  r[e] && (t += `<w:pStyle w:val="${r[e]}"/>`), (e === "li" || e === "blockquote" || e === "pre") && (t = '<w:ind w:left="720"/>');
@@ -278,9 +279,9 @@ function st(e, o) {
278
279
  } else {
279
280
  const z = u.match(/([\d.]+)px/i);
280
281
  if (z) {
281
- const f = parseFloat(z[1]);
282
- if (!Number.isNaN(f) && f > 0) {
283
- const b = Math.round(f * 15);
282
+ const h = parseFloat(z[1]);
283
+ if (!Number.isNaN(h) && h > 0) {
284
+ const b = Math.round(h * 15);
284
285
  a += ` w:line="${b}" w:lineRule="exact"`;
285
286
  }
286
287
  }
@@ -305,7 +306,7 @@ function st(e, o) {
305
306
  function N(e) {
306
307
  return String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
307
308
  }
308
- function lt(e) {
309
+ function at(e) {
309
310
  if (!e || typeof e != "string") return null;
310
311
  const o = e.trim();
311
312
  if (/^#[0-9a-f]{3,6}$/i.test(o)) {
@@ -315,7 +316,7 @@ function lt(e) {
315
316
  const t = o.match(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
316
317
  return t ? [t[1], t[2], t[3]].map((r) => (+r).toString(16).padStart(2, "0")).join("").toUpperCase() : null;
317
318
  }
318
- function W(e) {
319
+ function E(e) {
319
320
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
320
321
  <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
321
322
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
@@ -325,20 +326,20 @@ function W(e) {
325
326
  <Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/>` : ""}
326
327
  </Types>`;
327
328
  }
328
- function E() {
329
+ function G() {
329
330
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
330
331
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
331
332
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
332
333
  </Relationships>`;
333
334
  }
334
- function G(e) {
335
+ function U(e) {
335
336
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
336
337
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
337
338
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${e ? `
338
339
  <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" Target="comments.xml"/>` : ""}
339
340
  </Relationships>`;
340
341
  }
341
- function U(e) {
342
+ function X(e) {
342
343
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
343
344
  <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
344
345
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -360,7 +361,7 @@ ${e}
360
361
  </w:body>
361
362
  </w:document>`;
362
363
  }
363
- function at(e) {
364
+ function wt(e) {
364
365
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
365
366
  <w:comments xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
366
367
  xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
@@ -377,7 +378,7 @@ ${e.map(({ ooxmlId: t, author: r, createdAt: s, note: n }) => {
377
378
  `)}
378
379
  </w:comments>`;
379
380
  }
380
- function X() {
381
+ function Z() {
381
382
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
382
383
  <w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
383
384
  xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
@@ -439,5 +440,5 @@ function X() {
439
440
  export {
440
441
  ct as exportHtmlToDocx,
441
442
  mt as exportHtmlToDocxBlob,
442
- K as exportToDocx
443
+ V as exportToDocx
443
444
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-word-editor",
3
3
  "private": false,
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "type": "module",
6
6
  "main": "./src/lib/index.ts",
7
7
  "module": "./src/lib/index.ts",
@@ -9,9 +9,12 @@
9
9
  * word/styles.xml ← 基础样式(含 CommentText / CommentReference)
10
10
  * word/_rels/document.xml.rels
11
11
  */
12
- import JSZip from 'jszip'
12
+ import * as JSZipNS from 'jszip'
13
13
  import { saveAs } from 'file-saver'
14
14
 
15
+ // jszip 在不同打包方式下可能没有 default 导出,这里做一层兼容
16
+ const JSZip = (JSZipNS as any).default || (JSZipNS as any)
17
+
15
18
  // ─── 公开类型 ─────────────────────────────────────────────────
16
19
 
17
20
  export interface WordComment {