ai-word-editor 0.0.1
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/README.md +75 -0
- package/dist/ai-word-editor.css +1 -0
- package/dist/index.js +7297 -0
- package/dist/vite.svg +1 -0
- package/dist/wordDocxExport.js +360 -0
- package/package.json +60 -0
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import R from "jszip";
|
|
2
|
+
import { saveAs as F } from "file-saver";
|
|
3
|
+
async function Y(t, r, e = "文档") {
|
|
4
|
+
const o = new DOMParser().parseFromString(t, "text/html"), n = /* @__PURE__ */ new Map(), l = [], i = new Map((r || []).map((p) => [p.id, p]));
|
|
5
|
+
o.body.querySelectorAll("span[data-comment-id]").forEach((p) => {
|
|
6
|
+
const c = p.getAttribute("data-comment-id");
|
|
7
|
+
if (c && i.has(c) && !n.has(c)) {
|
|
8
|
+
const d = l.length;
|
|
9
|
+
n.set(c, d), l.push({ ...i.get(c), ooxmlId: d });
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const a = k(o.body, n), u = l.length > 0, w = new R();
|
|
13
|
+
w.file("[Content_Types].xml", L(u)), w.file("_rels/.rels", U()), w.file("word/document.xml", X(a)), w.file("word/styles.xml", K()), w.file("word/_rels/document.xml.rels", W(u)), u && w.file("word/comments.xml", Z(l));
|
|
14
|
+
const m = await w.generateAsync({
|
|
15
|
+
type: "blob",
|
|
16
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
17
|
+
});
|
|
18
|
+
F(m, `${e}.docx`);
|
|
19
|
+
}
|
|
20
|
+
const O = /* @__PURE__ */ new Set(["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote", "pre"]), q = /* @__PURE__ */ new Set(["script", "style", "head"]), M = {
|
|
21
|
+
signle: { val: "single", sz: "6" },
|
|
22
|
+
"signle-bold": { val: "thick", sz: "12" },
|
|
23
|
+
double: { val: "double", sz: "6" },
|
|
24
|
+
dotted: { val: "dotted", sz: "6" },
|
|
25
|
+
dashed: { val: "dashed", sz: "6" },
|
|
26
|
+
"dashed-double": { val: "dashSmallGap", sz: "6" },
|
|
27
|
+
"double-bold-top": { val: "thinThickSmallGap", sz: "24" },
|
|
28
|
+
"double-bold-bottom": { val: "thickThinSmallGap", sz: "24" },
|
|
29
|
+
wavy: { val: "wave", sz: "6" }
|
|
30
|
+
};
|
|
31
|
+
function k(t, r) {
|
|
32
|
+
let e = "";
|
|
33
|
+
for (const s of t.childNodes)
|
|
34
|
+
e += P(s, r);
|
|
35
|
+
return e.includes("<w:p") || (e = "<w:p><w:r><w:t></w:t></w:r></w:p>"), e;
|
|
36
|
+
}
|
|
37
|
+
function P(t, r) {
|
|
38
|
+
if (t.nodeType === 3) {
|
|
39
|
+
const o = t.textContent;
|
|
40
|
+
return !o || !o.trim() ? "" : `<w:p><w:r><w:t xml:space="preserve">${y(o)}</w:t></w:r></w:p>`;
|
|
41
|
+
}
|
|
42
|
+
if (t.nodeType !== 1) return "";
|
|
43
|
+
const e = t.tagName.toLowerCase();
|
|
44
|
+
if (q.has(e)) return "";
|
|
45
|
+
if (O.has(e)) {
|
|
46
|
+
const o = B(e, t), n = f(t, r, {});
|
|
47
|
+
return e === "p" ? `<w:p>${o}${n || "<w:r><w:t></w:t></w:r>"}</w:p>` : n ? `<w:p>${o}${n}</w:p>` : "";
|
|
48
|
+
}
|
|
49
|
+
if (e === "table") {
|
|
50
|
+
const o = t.querySelector("colgroup[data-word-col-layout]"), n = t.querySelectorAll("tbody tr, tr"), l = n.length === 1, i = n[0] ? [...n[0].querySelectorAll("td, th")] : [];
|
|
51
|
+
return o || l && i.length >= 2 ? I(t, r) : H(t, r);
|
|
52
|
+
}
|
|
53
|
+
if (["ul", "ol", "tbody", "thead", "tfoot", "tr", "td", "th"].includes(e)) {
|
|
54
|
+
let o = "";
|
|
55
|
+
for (const n of t.childNodes)
|
|
56
|
+
o += P(n, r);
|
|
57
|
+
return o;
|
|
58
|
+
}
|
|
59
|
+
if (e === "hr") {
|
|
60
|
+
const o = t.getAttribute("data-type") || "signle", l = (t.getAttribute("data-color") || "#000000").replace(/^#/, ""), i = M[o] || { val: "single", sz: "6" };
|
|
61
|
+
return `<w:p><w:pPr><w:pBdr><w:bottom w:val="${i.val}" w:color="${l}" w:sz="${i.sz}" w:space="1"/></w:pBdr></w:pPr></w:p>`;
|
|
62
|
+
}
|
|
63
|
+
const s = f(t, r, {});
|
|
64
|
+
return s ? `<w:p>${s}</w:p>` : "";
|
|
65
|
+
}
|
|
66
|
+
function H(t, r) {
|
|
67
|
+
const e = t.querySelectorAll("tr");
|
|
68
|
+
if (!e.length) return "";
|
|
69
|
+
const s = t.querySelector("colgroup"), o = s ? [...s.querySelectorAll("col")] : [], n = e[0], l = n ? [...n.querySelectorAll("td, th")] : [], i = Math.max(o.length, l.length, 1), a = 8306, u = (d, h) => {
|
|
70
|
+
const g = (d && d.getAttribute("style") || "").match(/width\s*:\s*([\d.]+)%/);
|
|
71
|
+
return g ? parseFloat(g[1]) : 100 / h;
|
|
72
|
+
}, w = Array.from({ length: i }).map((d, h) => {
|
|
73
|
+
const b = o[h], g = u(b, i);
|
|
74
|
+
return Math.round(g / 100 * a);
|
|
75
|
+
}), m = w.map((d) => `<w:gridCol w:w="${d}"/>`).join(""), p = `
|
|
76
|
+
<w:tblPr>
|
|
77
|
+
<w:tblW w:w="11906" w:type="dxa"/>
|
|
78
|
+
<w:tblLayout w:type="fixed"/>
|
|
79
|
+
<w:tblBorders>
|
|
80
|
+
<w:top w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
81
|
+
<w:left w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
82
|
+
<w:bottom w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
83
|
+
<w:right w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
84
|
+
<w:insideH w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
85
|
+
<w:insideV w:val="single" w:sz="4" w:color="D0D0D0"/>
|
|
86
|
+
</w:tblBorders>
|
|
87
|
+
</w:tblPr>`;
|
|
88
|
+
let c = "";
|
|
89
|
+
return e.forEach((d) => {
|
|
90
|
+
const h = [...d.querySelectorAll("td, th")];
|
|
91
|
+
if (!h.length) return;
|
|
92
|
+
let b = "";
|
|
93
|
+
h.forEach((g, N) => {
|
|
94
|
+
const $ = parseInt(g.getAttribute("colspan"), 10), S = !Number.isNaN($) && $ > 1, D = S ? $ : 1;
|
|
95
|
+
let T = 0;
|
|
96
|
+
for (let x = 0; x < D; x++) {
|
|
97
|
+
const z = w[N + x];
|
|
98
|
+
T += Number.isFinite(z) ? z : Math.round(a / i);
|
|
99
|
+
}
|
|
100
|
+
const C = [];
|
|
101
|
+
S && C.push(`<w:gridSpan w:val="${D}"/>`), T > 0 && C.push(`<w:tcW w:w="${T}" w:type="dxa"/>`);
|
|
102
|
+
const A = `<w:tcPr>${C.join("")}</w:tcPr>`;
|
|
103
|
+
let v = "";
|
|
104
|
+
for (const x of g.childNodes)
|
|
105
|
+
v += P(x, r);
|
|
106
|
+
v || (v = "<w:p><w:r><w:t></w:t></w:r></w:p>"), b += `<w:tc>${A}${v}</w:tc>`;
|
|
107
|
+
}), c += `<w:tr>${b}</w:tr>`;
|
|
108
|
+
}), c ? `<w:tbl>${p}<w:tblGrid>${m}</w:tblGrid>${c}</w:tbl>` : "";
|
|
109
|
+
}
|
|
110
|
+
function I(t, r) {
|
|
111
|
+
const e = t.querySelector("colgroup"), s = e ? [...e.querySelectorAll("col")] : [], o = t.querySelectorAll("tbody tr, tr"), n = o[0] ? [...o[0].querySelectorAll("td, th")] : [], l = Math.max(s.length, n.length, 1), i = 8306, a = 720, u = (c) => {
|
|
112
|
+
const h = (c && c.getAttribute("style") || "").match(/width\s*:\s*([\d.]+)%/);
|
|
113
|
+
return h ? parseFloat(h[1]) : 100 / l;
|
|
114
|
+
}, w = s.length > 0 ? s.map((c) => Math.round(u(c) / 100 * i)) : Array.from({ length: l }, () => Math.round((i - a * (l - 1)) / l));
|
|
115
|
+
let m = "";
|
|
116
|
+
n.forEach((c, d) => {
|
|
117
|
+
for (const h of c.childNodes)
|
|
118
|
+
m += P(h, r);
|
|
119
|
+
d < n.length - 1 && (m += '<w:p><w:r><w:br w:type="column"/></w:r></w:p>');
|
|
120
|
+
});
|
|
121
|
+
const p = w.map((c) => `<w:col w:w="${c}" w:space="${a}"/>`).join("");
|
|
122
|
+
return m += `<w:p><w:pPr><w:sectPr>
|
|
123
|
+
<w:cols w:num="${l}" w:space="${a}" w:equalWidth="0">${p}</w:cols>
|
|
124
|
+
<w:pgSz w:w="11906" w:h="16838"/>
|
|
125
|
+
<w:pgMar w:top="1800" w:right="1800" w:bottom="1800" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/>
|
|
126
|
+
</w:sectPr></w:pPr></w:p>`, m;
|
|
127
|
+
}
|
|
128
|
+
function f(t, r, e) {
|
|
129
|
+
let s = "";
|
|
130
|
+
for (const o of t.childNodes)
|
|
131
|
+
s += _(o, r, e);
|
|
132
|
+
return s;
|
|
133
|
+
}
|
|
134
|
+
function _(t, r, e) {
|
|
135
|
+
if (t.nodeType === 3) {
|
|
136
|
+
const o = t.textContent;
|
|
137
|
+
return o ? j(o, e) : "";
|
|
138
|
+
}
|
|
139
|
+
if (t.nodeType !== 1) return "";
|
|
140
|
+
const s = t.tagName.toLowerCase();
|
|
141
|
+
if (s === "span" && t.hasAttribute("data-comment-id")) {
|
|
142
|
+
const o = t.getAttribute("data-comment-id"), n = r.get(o);
|
|
143
|
+
if (n !== void 0) {
|
|
144
|
+
const l = f(t, r, e);
|
|
145
|
+
return `<w:commentRangeStart w:id="${n}"/>` + l + `<w:commentRangeEnd w:id="${n}"/><w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${n}"/></w:r>`;
|
|
146
|
+
}
|
|
147
|
+
return f(t, r, e);
|
|
148
|
+
}
|
|
149
|
+
if (s === "span") {
|
|
150
|
+
const o = E(t, e);
|
|
151
|
+
return f(t, r, o);
|
|
152
|
+
}
|
|
153
|
+
return s === "strong" || s === "b" ? f(t, r, { ...e, bold: !0 }) : s === "em" || s === "i" ? f(t, r, { ...e, italic: !0 }) : s === "u" ? f(t, r, { ...e, underline: !0 }) : s === "s" || s === "del" || s === "strike" ? f(t, r, { ...e, strike: !0 }) : s === "br" ? "<w:r><w:br/></w:r>" : f(t, r, e);
|
|
154
|
+
}
|
|
155
|
+
function E(t, r) {
|
|
156
|
+
const e = t.getAttribute("style") || "";
|
|
157
|
+
t.className;
|
|
158
|
+
const s = e.match(/font-family\s*:\s*([^;]+)/i), o = s ? s[1].trim().replace(/["']/g, "") : null, n = e.match(/font-size\s*:\s*([\d.]+)(px|pt)/i);
|
|
159
|
+
let l = null;
|
|
160
|
+
if (n) {
|
|
161
|
+
const u = parseFloat(n[1]);
|
|
162
|
+
l = n[2].toLowerCase() === "pt" ? Math.round(u * 2) : Math.round(u * 1.5);
|
|
163
|
+
}
|
|
164
|
+
const i = e.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i), a = i ? G(i[1].trim()) : null;
|
|
165
|
+
return {
|
|
166
|
+
...r,
|
|
167
|
+
bold: r.bold || /font-weight\s*:\s*(bold|[789]\d\d)/i.test(e),
|
|
168
|
+
italic: r.italic || /font-style\s*:\s*italic/i.test(e),
|
|
169
|
+
underline: r.underline || /text-decoration[^;]*underline/i.test(e),
|
|
170
|
+
strike: r.strike || /text-decoration[^;]*line-through/i.test(e),
|
|
171
|
+
fontFamily: o || r.fontFamily,
|
|
172
|
+
fontSize: l ?? r.fontSize,
|
|
173
|
+
color: a || r.color
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function j(t, { bold: r, italic: e, underline: s, strike: o, fontFamily: n, fontSize: l, color: i } = {}) {
|
|
177
|
+
let a = "";
|
|
178
|
+
if (n) {
|
|
179
|
+
const w = y(n);
|
|
180
|
+
a += `<w:rFonts w:ascii="${w}" w:eastAsia="${w}" w:hAnsi="${w}" w:cs="${w}"/>`;
|
|
181
|
+
}
|
|
182
|
+
return l && (a += `<w:sz w:val="${l}"/><w:szCs w:val="${l}"/>`), i && (a += `<w:color w:val="${i}"/>`), r && (a += "<w:b/><w:bCs/>"), e && (a += "<w:i/><w:iCs/>"), s && (a += '<w:u w:val="single"/>'), o && (a += "<w:strike/>"), `<w:r>${a ? `<w:rPr>${a}</w:rPr>` : ""}<w:t xml:space="preserve">${y(t)}</w:t></w:r>`;
|
|
183
|
+
}
|
|
184
|
+
function B(t, r) {
|
|
185
|
+
let e = "";
|
|
186
|
+
const s = { h1: "Heading1", h2: "Heading2", h3: "Heading3", h4: "Heading4", h5: "Heading5", h6: "Heading6" };
|
|
187
|
+
s[t] && (e += `<w:pStyle w:val="${s[t]}"/>`), (t === "li" || t === "blockquote" || t === "pre") && (e = '<w:ind w:left="720"/>');
|
|
188
|
+
const o = r.getAttribute("style") || "", n = o.match(/text-align\s*:\s*(left|center|right|justify)/i);
|
|
189
|
+
n && (e += `<w:jc w:val="${{ left: "left", center: "center", right: "right", justify: "both" }[n[1].toLowerCase()]}"/>`);
|
|
190
|
+
let l = "";
|
|
191
|
+
const i = o.match(/line-height\s*:\s*([^;]+)/i), a = o.match(/margin-top\s*:\s*([\d.]+)px/i), u = o.match(/margin-bottom\s*:\s*([\d.]+)px/i);
|
|
192
|
+
let w = "";
|
|
193
|
+
if (i) {
|
|
194
|
+
const m = i[1].trim(), p = parseFloat(m);
|
|
195
|
+
if (!Number.isNaN(p) && p > 0.25 && p < 4) {
|
|
196
|
+
const c = Math.round(p * 240);
|
|
197
|
+
w += ` w:line="${c}" w:lineRule="auto"`;
|
|
198
|
+
} else {
|
|
199
|
+
const c = m.match(/([\d.]+)px/i);
|
|
200
|
+
if (c) {
|
|
201
|
+
const d = parseFloat(c[1]);
|
|
202
|
+
if (!Number.isNaN(d) && d > 0) {
|
|
203
|
+
const h = Math.round(d * 15);
|
|
204
|
+
w += ` w:line="${h}" w:lineRule="exact"`;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (a) {
|
|
210
|
+
const m = parseFloat(a[1]);
|
|
211
|
+
if (!Number.isNaN(m) && m > 0) {
|
|
212
|
+
const p = Math.round(m * 15);
|
|
213
|
+
w += ` w:before="${p}"`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (u) {
|
|
217
|
+
const m = parseFloat(u[1]);
|
|
218
|
+
if (!Number.isNaN(m) && m > 0) {
|
|
219
|
+
const p = Math.round(m * 15);
|
|
220
|
+
w += ` w:after="${p}"`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return w && (l = `<w:spacing${w}/>`, e += l), e ? `<w:pPr>${e}</w:pPr>` : "";
|
|
224
|
+
}
|
|
225
|
+
function y(t) {
|
|
226
|
+
return String(t).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
227
|
+
}
|
|
228
|
+
function G(t) {
|
|
229
|
+
if (!t || typeof t != "string") return null;
|
|
230
|
+
const r = t.trim();
|
|
231
|
+
if (/^#[0-9a-f]{3,6}$/i.test(r)) {
|
|
232
|
+
let s = r.slice(1);
|
|
233
|
+
return s.length === 3 && (s = s.split("").map((o) => o + o).join("")), s.toUpperCase();
|
|
234
|
+
}
|
|
235
|
+
const e = r.match(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
|
|
236
|
+
return e ? [e[1], e[2], e[3]].map((s) => (+s).toString(16).padStart(2, "0")).join("").toUpperCase() : null;
|
|
237
|
+
}
|
|
238
|
+
function L(t) {
|
|
239
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
240
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
241
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
242
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
243
|
+
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
244
|
+
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>${t ? `
|
|
245
|
+
<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/>` : ""}
|
|
246
|
+
</Types>`;
|
|
247
|
+
}
|
|
248
|
+
function U() {
|
|
249
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
250
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
251
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
|
|
252
|
+
</Relationships>`;
|
|
253
|
+
}
|
|
254
|
+
function W(t) {
|
|
255
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
256
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
257
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${t ? `
|
|
258
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" Target="comments.xml"/>` : ""}
|
|
259
|
+
</Relationships>`;
|
|
260
|
+
}
|
|
261
|
+
function X(t) {
|
|
262
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
263
|
+
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
|
|
264
|
+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
265
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
266
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
267
|
+
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
|
|
268
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
|
269
|
+
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
|
270
|
+
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
271
|
+
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
|
|
272
|
+
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
|
|
273
|
+
mc:Ignorable="w14 w15">
|
|
274
|
+
<w:body>
|
|
275
|
+
${t}
|
|
276
|
+
<w:sectPr>
|
|
277
|
+
<w:pgSz w:w="11906" w:h="16838"/>
|
|
278
|
+
<w:pgMar w:top="1800" w:right="1800" w:bottom="1800" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/>
|
|
279
|
+
</w:sectPr>
|
|
280
|
+
</w:body>
|
|
281
|
+
</w:document>`;
|
|
282
|
+
}
|
|
283
|
+
function Z(t) {
|
|
284
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
285
|
+
<w:comments xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
286
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
287
|
+
${t.map(({ ooxmlId: e, author: s, createdAt: o, note: n }) => {
|
|
288
|
+
const l = y(s || "作者"), i = y((s || "作").charAt(0)), a = o ? new Date(o).toISOString().slice(0, 19) + "Z" : (/* @__PURE__ */ new Date()).toISOString().slice(0, 19) + "Z", u = y(n || "");
|
|
289
|
+
return ` <w:comment w:id="${e}" w:author="${l}" w:date="${a}" w:initials="${i}">
|
|
290
|
+
<w:p>
|
|
291
|
+
<w:pPr><w:pStyle w:val="CommentText"/></w:pPr>
|
|
292
|
+
<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:annotationRef/></w:r>
|
|
293
|
+
<w:r><w:t>${u}</w:t></w:r>
|
|
294
|
+
</w:p>
|
|
295
|
+
</w:comment>`;
|
|
296
|
+
}).join(`
|
|
297
|
+
`)}
|
|
298
|
+
</w:comments>`;
|
|
299
|
+
}
|
|
300
|
+
function K() {
|
|
301
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
302
|
+
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
303
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
304
|
+
<w:docDefaults>
|
|
305
|
+
<w:rPrDefault>
|
|
306
|
+
<w:rPr>
|
|
307
|
+
<w:rFonts w:ascii="宋体" w:eastAsia="宋体" w:hAnsi="宋体" w:cs="宋体"/>
|
|
308
|
+
<w:sz w:val="24"/>
|
|
309
|
+
<w:szCs w:val="24"/>
|
|
310
|
+
</w:rPr>
|
|
311
|
+
</w:rPrDefault>
|
|
312
|
+
</w:docDefaults>
|
|
313
|
+
<w:style w:type="paragraph" w:default="1" w:styleId="Normal">
|
|
314
|
+
<w:name w:val="Normal"/>
|
|
315
|
+
<w:qFormat/>
|
|
316
|
+
</w:style>
|
|
317
|
+
<w:style w:type="paragraph" w:styleId="Heading1">
|
|
318
|
+
<w:name w:val="heading 1"/>
|
|
319
|
+
<w:basedOn w:val="Normal"/>
|
|
320
|
+
<w:rPr><w:b/><w:sz w:val="40"/></w:rPr>
|
|
321
|
+
</w:style>
|
|
322
|
+
<w:style w:type="paragraph" w:styleId="Heading2">
|
|
323
|
+
<w:name w:val="heading 2"/>
|
|
324
|
+
<w:basedOn w:val="Normal"/>
|
|
325
|
+
<w:rPr><w:b/><w:sz w:val="32"/></w:rPr>
|
|
326
|
+
</w:style>
|
|
327
|
+
<w:style w:type="paragraph" w:styleId="Heading3">
|
|
328
|
+
<w:name w:val="heading 3"/>
|
|
329
|
+
<w:basedOn w:val="Normal"/>
|
|
330
|
+
<w:rPr><w:b/><w:sz w:val="28"/></w:rPr>
|
|
331
|
+
</w:style>
|
|
332
|
+
<w:style w:type="paragraph" w:styleId="Heading4">
|
|
333
|
+
<w:name w:val="heading 4"/>
|
|
334
|
+
<w:basedOn w:val="Normal"/>
|
|
335
|
+
<w:rPr><w:b/><w:sz w:val="26"/></w:rPr>
|
|
336
|
+
</w:style>
|
|
337
|
+
<w:style w:type="paragraph" w:styleId="Heading5">
|
|
338
|
+
<w:name w:val="heading 5"/>
|
|
339
|
+
<w:basedOn w:val="Normal"/>
|
|
340
|
+
<w:rPr><w:b/><w:sz w:val="24"/></w:rPr>
|
|
341
|
+
</w:style>
|
|
342
|
+
<w:style w:type="paragraph" w:styleId="Heading6">
|
|
343
|
+
<w:name w:val="heading 6"/>
|
|
344
|
+
<w:basedOn w:val="Normal"/>
|
|
345
|
+
<w:rPr><w:sz w:val="24"/></w:rPr>
|
|
346
|
+
</w:style>
|
|
347
|
+
<w:style w:type="paragraph" w:styleId="CommentText">
|
|
348
|
+
<w:name w:val="annotation text"/>
|
|
349
|
+
<w:basedOn w:val="Normal"/>
|
|
350
|
+
<w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr>
|
|
351
|
+
</w:style>
|
|
352
|
+
<w:style w:type="character" w:styleId="CommentReference">
|
|
353
|
+
<w:name w:val="annotation reference"/>
|
|
354
|
+
<w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr>
|
|
355
|
+
</w:style>
|
|
356
|
+
</w:styles>`;
|
|
357
|
+
}
|
|
358
|
+
export {
|
|
359
|
+
Y as exportToDocx
|
|
360
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-word-editor",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./style.css": "./dist/index.css",
|
|
15
|
+
"./word-docx-export": {
|
|
16
|
+
"types": "./dist/types/utils/wordDocxExport.d.ts",
|
|
17
|
+
"import": "./dist/wordDocxExport.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite",
|
|
28
|
+
"build": "tsc && vite build",
|
|
29
|
+
"build:types": "tsc -p tsconfig.lib.json",
|
|
30
|
+
"build:lib": "npm run build:types && vite build -c vite.lib.config.js",
|
|
31
|
+
"prepare": "npm run build:lib",
|
|
32
|
+
"preview": "vite preview"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@umoteam/editor": "^9.0.1",
|
|
37
|
+
"file-saver": "^2.0.5",
|
|
38
|
+
"jszip": "^3.10.1",
|
|
39
|
+
"mammoth": "^1.11.0",
|
|
40
|
+
"vue": "^3.5.29"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"file-saver": {
|
|
44
|
+
"optional": true
|
|
45
|
+
},
|
|
46
|
+
"jszip": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@umoteam/editor": "^9.0.1",
|
|
52
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
53
|
+
"file-saver": "^2.0.5",
|
|
54
|
+
"jszip": "^3.10.1",
|
|
55
|
+
"mammoth": "^1.11.0",
|
|
56
|
+
"typescript": "~5.9.3",
|
|
57
|
+
"vite": "^7.3.1",
|
|
58
|
+
"vue": "^3.5.29"
|
|
59
|
+
}
|
|
60
|
+
}
|