ooxml-excel-editor 1.2.0 → 1.3.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/CHANGELOG.md +108 -0
- package/README.md +59 -14
- package/dist/assets/exceljs.min-DH9BABny.js +23046 -0
- package/dist/assets/parse.worker-DIaMHX0x.js +2646 -0
- package/dist/chunks/{plugin-overlay-BBrNby8v.js → plugin-overlay-DLb6sRhU.js} +1424 -1384
- package/dist/chunks/toolbar-icons-BcnMin5s.js +223 -0
- package/dist/components/ExcelViewer.vue.d.ts +2 -0
- package/dist/core/edit/editor-context.d.ts +18 -3
- package/dist/core/edit/editor-host.d.ts +6 -1
- package/dist/core.js +1 -1
- package/dist/index.js +722 -742
- package/dist/react/ExcelViewer.d.ts +9 -0
- package/dist/react.js +610 -444
- package/dist/style.css +1 -1
- package/dist/vue2.css +1 -0
- package/dist/vue2.js +10433 -0
- package/package.json +23 -6
- package/dist/chunks/worker-client.stub-CJlmpAgJ.js +0 -190
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { i as p, p as R } from "./plugin-overlay-DLb6sRhU.js";
|
|
2
|
+
const A = Array(17).fill("#000000");
|
|
3
|
+
function I() {
|
|
4
|
+
return {
|
|
5
|
+
font: { name: "Calibri", size: 11, bold: !1, italic: !1, underline: !1, strike: !1, color: "#000000" },
|
|
6
|
+
fill: { type: "none" },
|
|
7
|
+
borders: {},
|
|
8
|
+
hAlign: "general",
|
|
9
|
+
vAlign: "bottom",
|
|
10
|
+
wrapText: !1,
|
|
11
|
+
shrinkToFit: !1,
|
|
12
|
+
textRotation: 0,
|
|
13
|
+
indent: 0,
|
|
14
|
+
numFmt: "General"
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function M(e, o) {
|
|
18
|
+
return {
|
|
19
|
+
name: e,
|
|
20
|
+
index: o,
|
|
21
|
+
state: "visible",
|
|
22
|
+
dimension: { rows: 0, cols: 0 },
|
|
23
|
+
cells: /* @__PURE__ */ new Map(),
|
|
24
|
+
styles: [I()],
|
|
25
|
+
merges: [],
|
|
26
|
+
columns: /* @__PURE__ */ new Map(),
|
|
27
|
+
rows: /* @__PURE__ */ new Map(),
|
|
28
|
+
defaultColWidth: 64,
|
|
29
|
+
defaultRowHeight: 20,
|
|
30
|
+
freeze: { frozenRows: 0, frozenCols: 0 },
|
|
31
|
+
conditional: [],
|
|
32
|
+
dataValidations: [],
|
|
33
|
+
images: [],
|
|
34
|
+
charts: [],
|
|
35
|
+
shapes: [],
|
|
36
|
+
sparklines: [],
|
|
37
|
+
showGridLines: !0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function b(e, o) {
|
|
41
|
+
if (e == null || e === "") return { raw: null, type: "empty" };
|
|
42
|
+
if (typeof e == "number") return { raw: e, type: "number" };
|
|
43
|
+
if (typeof e == "boolean") return { raw: e, type: "boolean" };
|
|
44
|
+
if (e instanceof Date) return { raw: e, type: "date" };
|
|
45
|
+
if (typeof e != "string") return { raw: String(e), type: "string" };
|
|
46
|
+
if (!o) return { raw: e, type: "string" };
|
|
47
|
+
const t = e.trim();
|
|
48
|
+
if (/^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(t)) {
|
|
49
|
+
const s = Number(t);
|
|
50
|
+
if (Number.isFinite(s)) return { raw: s, type: "number" };
|
|
51
|
+
}
|
|
52
|
+
if (/^(TRUE|FALSE)$/i.test(t)) return { raw: /^TRUE$/i.test(t), type: "boolean" };
|
|
53
|
+
if (/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/.test(t)) {
|
|
54
|
+
const s = new Date(t);
|
|
55
|
+
if (!isNaN(s.getTime())) return { raw: s, type: "date" };
|
|
56
|
+
}
|
|
57
|
+
return { raw: e, type: "string" };
|
|
58
|
+
}
|
|
59
|
+
function z(e, o) {
|
|
60
|
+
return o.map((t) => e[t]);
|
|
61
|
+
}
|
|
62
|
+
function k(e, o, t = {}) {
|
|
63
|
+
const s = t.startRow ?? 0, i = t.startCol ?? 0, c = t.autoInfer ?? !0;
|
|
64
|
+
let l = 0, y = 0, d = !1;
|
|
65
|
+
if (!o.length) return { lastRow: 0, lastCol: 0, wrote: !1 };
|
|
66
|
+
const r = o[0], h = r !== null && typeof r == "object" && !Array.isArray(r), x = h ? t.columns ?? Object.keys(r) : [];
|
|
67
|
+
let f = s;
|
|
68
|
+
if (h && (t.headerRow ?? !0)) {
|
|
69
|
+
for (let n = 0; n < x.length; n++) {
|
|
70
|
+
const a = f, m = i + n;
|
|
71
|
+
e.cells.set(p(a, m), { row: a, col: m, type: "string", raw: x[n], styleId: 0 }), l = Math.max(l, a), y = Math.max(y, m), d = !0;
|
|
72
|
+
}
|
|
73
|
+
f++;
|
|
74
|
+
}
|
|
75
|
+
for (let n = 0; n < o.length; n++) {
|
|
76
|
+
const a = o[n], m = Array.isArray(a) ? a : z(a, x);
|
|
77
|
+
for (let w = 0; w < m.length; w++) {
|
|
78
|
+
const u = f + n - (h && (t.headerRow ?? !0), 0), g = i + w, C = b(m[w], c);
|
|
79
|
+
C.type !== "empty" && (e.cells.set(p(u, g), { row: u, col: g, type: C.type, raw: C.raw, styleId: 0 }), l = Math.max(l, u), y = Math.max(y, g), d = !0);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { lastRow: l, lastCol: y, wrote: d };
|
|
83
|
+
}
|
|
84
|
+
function V(e, o = {}) {
|
|
85
|
+
const t = o.themeColors && o.themeColors.length === 17 ? o.themeColors : A, s = o.autoInfer ?? !0, i = o.headerRow ?? !0;
|
|
86
|
+
if (e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.sheets))
|
|
87
|
+
return { sheets: e.sheets.map((f, n) => {
|
|
88
|
+
const a = M(f.name || `Sheet${n + 1}`, n), { lastRow: m, lastCol: w, wrote: u } = k(a, f.rows ?? [], { headerRow: i, autoInfer: s });
|
|
89
|
+
return a.dimension = u ? { rows: m + 1, cols: w + 1 } : { rows: 0, cols: 0 }, a;
|
|
90
|
+
}), activeSheet: 0, themeColors: t, date1904: !1 };
|
|
91
|
+
const c = M(o.sheetName || "Sheet1", 0), l = e ?? [], { lastRow: y, lastCol: d, wrote: r } = k(c, l, { headerRow: i, autoInfer: s });
|
|
92
|
+
return c.dimension = r ? { rows: y + 1, cols: d + 1 } : { rows: 0, cols: 0 }, { sheets: [c], activeSheet: 0, themeColors: t, date1904: !1 };
|
|
93
|
+
}
|
|
94
|
+
function L(e) {
|
|
95
|
+
return !!e && typeof e == "object" && Array.isArray(e.sheets) && typeof e.activeSheet == "number" && Array.isArray(e.themeColors);
|
|
96
|
+
}
|
|
97
|
+
function S(e, o) {
|
|
98
|
+
const t = o.sheets[0], s = e.sheets[0];
|
|
99
|
+
if (!t) return e;
|
|
100
|
+
if (!s)
|
|
101
|
+
return {
|
|
102
|
+
sheets: [T(t, t.name)],
|
|
103
|
+
activeSheet: 0,
|
|
104
|
+
themeColors: o.themeColors,
|
|
105
|
+
date1904: e.date1904,
|
|
106
|
+
cellImages: e.cellImages
|
|
107
|
+
};
|
|
108
|
+
const i = {
|
|
109
|
+
name: s.name || t.name,
|
|
110
|
+
index: 0,
|
|
111
|
+
state: "visible",
|
|
112
|
+
dimension: { rows: 0, cols: 0 },
|
|
113
|
+
cells: /* @__PURE__ */ new Map(),
|
|
114
|
+
styles: t.styles.map((r) => ({ ...r })),
|
|
115
|
+
merges: t.merges.map((r) => ({ ...r })),
|
|
116
|
+
columns: new Map(t.columns),
|
|
117
|
+
rows: new Map(t.rows),
|
|
118
|
+
defaultColWidth: t.defaultColWidth,
|
|
119
|
+
defaultRowHeight: t.defaultRowHeight,
|
|
120
|
+
freeze: { ...t.freeze },
|
|
121
|
+
// 条件格式 / 数据验证 不带过来 —— 数据可能不在模板的目标列上, 套规则会误命中
|
|
122
|
+
conditional: [],
|
|
123
|
+
dataValidations: [],
|
|
124
|
+
// 模板的图 / 图表 / 形状 全部不带 —— 模板是"样式骨架", 不是内容
|
|
125
|
+
images: [],
|
|
126
|
+
charts: [],
|
|
127
|
+
shapes: [],
|
|
128
|
+
sparklines: [],
|
|
129
|
+
showGridLines: t.showGridLines
|
|
130
|
+
};
|
|
131
|
+
let c = 0, l = 0;
|
|
132
|
+
for (const r of s.cells.values()) {
|
|
133
|
+
const h = t.cells.get(p(r.row, r.col));
|
|
134
|
+
i.cells.set(p(r.row, r.col), {
|
|
135
|
+
row: r.row,
|
|
136
|
+
col: r.col,
|
|
137
|
+
type: r.type,
|
|
138
|
+
raw: r.raw,
|
|
139
|
+
rich: r.rich,
|
|
140
|
+
formula: r.formula,
|
|
141
|
+
hyperlink: r.hyperlink,
|
|
142
|
+
comment: r.comment,
|
|
143
|
+
styleId: (h == null ? void 0 : h.styleId) ?? 0,
|
|
144
|
+
dispImgId: r.dispImgId
|
|
145
|
+
}), r.row > c && (c = r.row), r.col > l && (l = r.col);
|
|
146
|
+
}
|
|
147
|
+
const y = t.columns.size ? Math.max(...t.columns.keys()) + 1 : 0, d = t.rows.size ? Math.max(...t.rows.keys()) + 1 : 0;
|
|
148
|
+
return i.dimension = {
|
|
149
|
+
rows: Math.max(s.dimension.rows, c + 1, d),
|
|
150
|
+
cols: Math.max(s.dimension.cols, l + 1, y)
|
|
151
|
+
}, {
|
|
152
|
+
sheets: [i],
|
|
153
|
+
activeSheet: 0,
|
|
154
|
+
themeColors: o.themeColors,
|
|
155
|
+
date1904: e.date1904,
|
|
156
|
+
cellImages: e.cellImages
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function T(e, o) {
|
|
160
|
+
return {
|
|
161
|
+
name: o,
|
|
162
|
+
index: 0,
|
|
163
|
+
state: "visible",
|
|
164
|
+
dimension: { rows: 0, cols: 0 },
|
|
165
|
+
cells: /* @__PURE__ */ new Map(),
|
|
166
|
+
styles: e.styles.map((t) => ({ ...t })),
|
|
167
|
+
merges: e.merges.map((t) => ({ ...t })),
|
|
168
|
+
columns: new Map(e.columns),
|
|
169
|
+
rows: new Map(e.rows),
|
|
170
|
+
defaultColWidth: e.defaultColWidth,
|
|
171
|
+
defaultRowHeight: e.defaultRowHeight,
|
|
172
|
+
freeze: { ...e.freeze },
|
|
173
|
+
conditional: [],
|
|
174
|
+
dataValidations: [],
|
|
175
|
+
images: [],
|
|
176
|
+
charts: [],
|
|
177
|
+
shapes: [],
|
|
178
|
+
sparklines: [],
|
|
179
|
+
showGridLines: e.showGridLines
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function E(e, o) {
|
|
183
|
+
return R(e, o);
|
|
184
|
+
}
|
|
185
|
+
const H = {
|
|
186
|
+
// 放大镜
|
|
187
|
+
find: '<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>',
|
|
188
|
+
// 漏斗
|
|
189
|
+
filter: '<path d="M3 5h18l-7 8.5V20l-4-2.2V13.5z"/>',
|
|
190
|
+
// 漏斗 + 斜杠(清除筛选)
|
|
191
|
+
"clear-filter": '<path d="M3 5h18l-7 8.5V20l-4-2.2V13.5z"/><line x1="3" y1="3" x2="21" y2="21"/>',
|
|
192
|
+
// 上下箭头(排序)
|
|
193
|
+
sort: '<path d="M7 16l3 3 3-3"/><line x1="10" y1="19" x2="10" y2="5"/><path d="M17 8l-3-3-3 3"/><line x1="14" y1="5" x2="14" y2="19"/>',
|
|
194
|
+
// 下载(导出)
|
|
195
|
+
export: '<line x1="12" y1="3" x2="12" y2="15"/><path d="M8 11l4 4 4-4"/><path d="M4 19h16"/>',
|
|
196
|
+
// 放大镜带 +
|
|
197
|
+
zoom: '<circle cx="10" cy="10" r="6"/><line x1="20" y1="20" x2="14.5" y2="14.5"/><line x1="10" y1="7.5" x2="10" y2="12.5"/><line x1="7.5" y1="10" x2="12.5" y2="10"/>',
|
|
198
|
+
// 两个叠框(复制)
|
|
199
|
+
copy: '<rect x="9" y="9" width="11" height="11" rx="1.5"/><path d="M5 15H4V5a1 1 0 0 1 1-1h10v1"/>',
|
|
200
|
+
// 十字线(冻结行列)
|
|
201
|
+
freeze: '<line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="3" x2="9" y2="21"/>',
|
|
202
|
+
// 自动换行:两条文本线 + 折回箭头
|
|
203
|
+
"wrap-text": '<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="18" x2="10" y2="18"/><path d="M3 12h15a3 3 0 0 1 0 6h-3"/><polyline points="17 15 14 18 17 21"/>',
|
|
204
|
+
// 模板:文档 + 排版网格
|
|
205
|
+
template: '<rect x="4" y="3" width="16" height="18" rx="1.5"/><line x1="4" y1="8" x2="20" y2="8"/><line x1="8" y1="12" x2="16" y2="12"/><line x1="8" y1="16" x2="16" y2="16"/>',
|
|
206
|
+
// 图片工具:山+太阳的图片框 + 小齿轮(批量转换)
|
|
207
|
+
"image-tools": '<rect x="3" y="4" width="14" height="14" rx="1.5"/><circle cx="8" cy="9" r="1.5"/><polyline points="3 16 7 12 11 16 14 13 17 16"/><path d="M19 19l2 2M19 21l2-2"/>',
|
|
208
|
+
// 三点(更多)
|
|
209
|
+
more: '<circle cx="5" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.6" fill="currentColor" stroke="none"/>',
|
|
210
|
+
// 下拉小箭头
|
|
211
|
+
caret: '<path d="M6 9l6 6 6-6"/>'
|
|
212
|
+
};
|
|
213
|
+
function G(e) {
|
|
214
|
+
return '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' + e + "</svg>";
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
H as T,
|
|
218
|
+
S as a,
|
|
219
|
+
L as i,
|
|
220
|
+
V as j,
|
|
221
|
+
E as p,
|
|
222
|
+
G as s
|
|
223
|
+
};
|
|
@@ -183,6 +183,7 @@ declare function __VLS_template(): {
|
|
|
183
183
|
};
|
|
184
184
|
refs: {
|
|
185
185
|
rootEl: HTMLDivElement;
|
|
186
|
+
fbEl: HTMLTextAreaElement;
|
|
186
187
|
renderAreaEl: HTMLDivElement;
|
|
187
188
|
canvasEl: HTMLCanvasElement;
|
|
188
189
|
ovMain: HTMLDivElement;
|
|
@@ -413,6 +414,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
|
|
|
413
414
|
contextMenu: boolean | ContextMenuTransform;
|
|
414
415
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
415
416
|
rootEl: HTMLDivElement;
|
|
417
|
+
fbEl: HTMLTextAreaElement;
|
|
416
418
|
renderAreaEl: HTMLDivElement;
|
|
417
419
|
canvasEl: HTMLCanvasElement;
|
|
418
420
|
ovMain: HTMLDivElement;
|
|
@@ -27,12 +27,27 @@ export interface CellEditorContext {
|
|
|
27
27
|
commit(value: EditorCommitValue, move?: 'down' | 'right'): void;
|
|
28
28
|
/** 取消编辑(不改模型) */
|
|
29
29
|
cancel(): void;
|
|
30
|
+
/**
|
|
31
|
+
* 请求 host 重新 position 编辑器 (Phase 1 长文本撑高用, 2026-06-08).
|
|
32
|
+
* 编辑器在内容变化(input 事件)后调一次, host 会重新读 `getDesiredHeight()` 并撑高.
|
|
33
|
+
* 不实现 `getDesiredHeight` 的编辑器调它无效(仍按 cell rect 尺寸).
|
|
34
|
+
*/
|
|
35
|
+
reposition?(): void;
|
|
30
36
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
37
|
+
/**
|
|
38
|
+
* 编辑器工厂的返回类型:可以是裸 HTMLElement, 或带钩子的对象.
|
|
39
|
+
* - `destroy`: 卸载时清理(可选)
|
|
40
|
+
* - `getDesiredHeight`: Phase 1 长文本撑高用. host 在 position 时调, 传入当前列宽 (px),
|
|
41
|
+
* 编辑器返回内容期望的总高度 (px). host 取 max(原 cell h, desired) 作为最终高度.
|
|
42
|
+
* 不实现 = 高度锁定为单元格高度(老行为).
|
|
43
|
+
*/
|
|
44
|
+
export interface CellEditorReturn {
|
|
33
45
|
el: HTMLElement;
|
|
34
46
|
destroy?: () => void;
|
|
35
|
-
|
|
47
|
+
getDesiredHeight?(widthPx: number): number;
|
|
48
|
+
}
|
|
49
|
+
/** 编辑器工厂:返回 DOM 元素,或 { el, destroy?, getDesiredHeight? }(destroy 在卸载时清理) */
|
|
50
|
+
export type CellEditorFactory = (ctx: CellEditorContext) => HTMLElement | CellEditorReturn;
|
|
36
51
|
/** 编辑器解析器:按格决定用哪个工厂(无 → 该格无自定义编辑器) */
|
|
37
52
|
export type EditorResolver = (cell: CellModel | null, pos: {
|
|
38
53
|
row: number;
|
|
@@ -14,7 +14,12 @@ export declare class CellEditorHost {
|
|
|
14
14
|
* rectOverride 给定时用它定位(合并单元格 → 整片合并区),否则按单格 rectOf。
|
|
15
15
|
*/
|
|
16
16
|
mount(row: number, col: number, factory: CellEditorFactory, ctx: CellEditorContext, rectOverride?: () => Rect | null): boolean;
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* 按当前 rectOf 重定位活动编辑器(滚动/缩放后跟随).
|
|
19
|
+
* Phase 1 长文本撑高 (2026-06-08): 若编辑器实现了 `getDesiredHeight`,
|
|
20
|
+
* 最终高度 = max(单元格原高, 期望高度), 上限 viewport 一半防撑爆.
|
|
21
|
+
* 宽度仍 = 列宽 (跟 WPS 一致, 仅向下溢出).
|
|
22
|
+
*/
|
|
18
23
|
position(): void;
|
|
19
24
|
/** 卸载活动编辑器 */
|
|
20
25
|
unmount(): void;
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as r, w as t, D as l, E as n, G as i, O as m, P as d, V as g, W as c, x as u, y as C, z as k, j as b, k as y, A as f, B as v, m as S,
|
|
1
|
+
import { C as r, w as t, D as l, E as n, G as i, O as m, P as d, V as g, W as c, x as u, y as C, z as k, j as b, k as y, A as f, B as v, m as S, i as E, F as I, H as T, I as p, J as R, h, K as W, L as w, M as x, N as D, d as F, n as O, f as V, o as B, a as H, q as M, t as A, c as J, e as L, g as N, b as P, u as U, Q as z, R as G, S as K, T as X, U as _, X as j, l as q, Y as Q, v as Y, p as Z, Z as $, _ as ee, $ as ae, a0 as se, a1 as oe, a2 as re, r as te, a3 as le, a4 as ne, a5 as ie, a6 as me, a7 as de, a8 as ge, s as ce, a9 as ue, aa as Ce, ab as ke, ac as be } from "./chunks/plugin-overlay-DLb6sRhU.js";
|
|
2
2
|
function a(e) {
|
|
3
3
|
return e;
|
|
4
4
|
}
|