ooxml-excel-editor 1.2.0 → 1.3.0

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/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "ooxml-excel-editor",
3
- "version": "1.2.0",
4
- "description": "High-fidelity OOXML (.xlsx) preview & editor — canvas renderer, framework-agnostic core with Vue 3 and React shells. Read-only by default; opt-in editing with undo/redo, formula recalc, and export back to .xlsx/JSON/CSV.",
3
+ "version": "1.3.0",
4
+ "description": "High-fidelity OOXML (.xlsx) preview & editor — canvas renderer, framework-agnostic core with Vue 3, Vue 2 and React shells (1:1 UI across all shells). Read-only by default; opt-in editing with undo/redo, formula recalc, and export back to .xlsx/JSON/CSV.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "keywords": [
8
8
  "vue",
9
9
  "vue3",
10
+ "vue2",
10
11
  "react",
11
12
  "excel",
12
13
  "xlsx",
@@ -41,19 +42,27 @@
41
42
  "types": "./dist/react.d.ts",
42
43
  "import": "./dist/react.js"
43
44
  },
45
+ "./vue2": {
46
+ "import": "./dist/vue2.js"
47
+ },
44
48
  "./core": {
45
49
  "types": "./dist/core.d.ts",
46
50
  "import": "./dist/core.js"
47
51
  },
48
- "./style.css": "./dist/style.css"
52
+ "./style.css": "./dist/style.css",
53
+ "./vue2.css": "./dist/vue2.css"
49
54
  },
50
55
  "sideEffects": [
51
56
  "**/*.css"
52
57
  ],
53
58
  "scripts": {
54
59
  "dev": "vite",
55
- "build": "vue-tsc --noEmit && vite build",
60
+ "dev:vue3": "vite",
61
+ "dev:react": "vite --mode react",
62
+ "dev:vue2": "vite --mode vue2",
63
+ "build": "vue-tsc --noEmit && vite build && vite build --mode lib-vue2",
56
64
  "build:demo": "vite build --mode demo",
65
+ "build:vue2": "vite build --mode lib-vue2",
57
66
  "preview": "vite preview",
58
67
  "test": "vitest run",
59
68
  "test:watch": "vitest",
@@ -68,7 +77,7 @@
68
77
  "jspdf": "^2.5.0 || ^3.0.0 || ^4.0.0",
69
78
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
70
79
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
71
- "vue": "^3.4.0"
80
+ "vue": "^2.7.0 || ^3.4.0"
72
81
  },
73
82
  "peerDependenciesMeta": {
74
83
  "echarts": {
@@ -101,9 +110,11 @@
101
110
  "@types/react-dom": "^18.3.7",
102
111
  "@vitejs/plugin-react": "^4.7.0",
103
112
  "@vitejs/plugin-vue": "^5.2.1",
113
+ "@vitejs/plugin-vue2": "^2.3.4",
104
114
  "echarts": "^5.5.1",
105
115
  "exceljs": "^4.4.0",
106
116
  "hyperformula": "^3.3.0",
117
+ "jsdom": "^29.1.1",
107
118
  "jspdf": "^4.2.1",
108
119
  "react": "^18.3.1",
109
120
  "react-dom": "^18.3.1",
@@ -112,6 +123,7 @@
112
123
  "vite-plugin-dts": "^4.5.4",
113
124
  "vitest": "^2.1.8",
114
125
  "vue": "^3.5.13",
115
- "vue-tsc": "^2.2.0"
126
+ "vue-tsc": "^2.2.0",
127
+ "vue2": "npm:vue@^2.7.16"
116
128
  }
117
129
  }
@@ -1,190 +0,0 @@
1
- import { c as g, p as M } from "./plugin-overlay-BBrNby8v.js";
2
- const b = Array(17).fill("#000000");
3
- function x() {
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 k(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: [x()],
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 I(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 r = Number(t);
50
- if (Number.isFinite(r)) return { raw: r, 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 r = new Date(t);
55
- if (!isNaN(r.getTime())) return { raw: r, type: "date" };
56
- }
57
- return { raw: e, type: "string" };
58
- }
59
- function T(e, o) {
60
- return o.map((t) => e[t]);
61
- }
62
- function A(e, o, t = {}) {
63
- const r = t.startRow ?? 0, i = t.startCol ?? 0, c = t.autoInfer ?? !0;
64
- let a = 0, m = 0, u = !1;
65
- if (!o.length) return { lastRow: 0, lastCol: 0, wrote: !1 };
66
- const s = o[0], w = s !== null && typeof s == "object" && !Array.isArray(s), p = w ? t.columns ?? Object.keys(s) : [];
67
- let d = r;
68
- if (w && (t.headerRow ?? !0)) {
69
- for (let n = 0; n < p.length; n++) {
70
- const l = d, f = i + n;
71
- e.cells.set(g(l, f), { row: l, col: f, type: "string", raw: p[n], styleId: 0 }), a = Math.max(a, l), m = Math.max(m, f), u = !0;
72
- }
73
- d++;
74
- }
75
- for (let n = 0; n < o.length; n++) {
76
- const l = o[n], f = Array.isArray(l) ? l : T(l, p);
77
- for (let h = 0; h < f.length; h++) {
78
- const y = d + n - (w && (t.headerRow ?? !0), 0), C = i + h, R = I(f[h], c);
79
- R.type !== "empty" && (e.cells.set(g(y, C), { row: y, col: C, type: R.type, raw: R.raw, styleId: 0 }), a = Math.max(a, y), m = Math.max(m, C), u = !0);
80
- }
81
- }
82
- return { lastRow: a, lastCol: m, wrote: u };
83
- }
84
- function E(e, o = {}) {
85
- const t = o.themeColors && o.themeColors.length === 17 ? o.themeColors : b, r = 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((d, n) => {
88
- const l = k(d.name || `Sheet${n + 1}`, n), { lastRow: f, lastCol: h, wrote: y } = A(l, d.rows ?? [], { headerRow: i, autoInfer: r });
89
- return l.dimension = y ? { rows: f + 1, cols: h + 1 } : { rows: 0, cols: 0 }, l;
90
- }), activeSheet: 0, themeColors: t, date1904: !1 };
91
- const c = k(o.sheetName || "Sheet1", 0), a = e ?? [], { lastRow: m, lastCol: u, wrote: s } = A(c, a, { headerRow: i, autoInfer: r });
92
- return c.dimension = s ? { rows: m + 1, cols: u + 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], r = e.sheets[0];
99
- if (!t) return e;
100
- if (!r)
101
- return {
102
- sheets: [z(t, t.name)],
103
- activeSheet: 0,
104
- themeColors: o.themeColors,
105
- date1904: e.date1904,
106
- cellImages: e.cellImages
107
- };
108
- const i = {
109
- name: r.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((s) => ({ ...s })),
115
- merges: t.merges.map((s) => ({ ...s })),
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, a = 0;
132
- for (const s of r.cells.values()) {
133
- const w = t.cells.get(g(s.row, s.col));
134
- i.cells.set(g(s.row, s.col), {
135
- row: s.row,
136
- col: s.col,
137
- type: s.type,
138
- raw: s.raw,
139
- rich: s.rich,
140
- formula: s.formula,
141
- hyperlink: s.hyperlink,
142
- comment: s.comment,
143
- styleId: (w == null ? void 0 : w.styleId) ?? 0,
144
- dispImgId: s.dispImgId
145
- }), s.row > c && (c = s.row), s.col > a && (a = s.col);
146
- }
147
- const m = t.columns.size ? Math.max(...t.columns.keys()) + 1 : 0, u = t.rows.size ? Math.max(...t.rows.keys()) + 1 : 0;
148
- return i.dimension = {
149
- rows: Math.max(r.dimension.rows, c + 1, u),
150
- cols: Math.max(r.dimension.cols, a + 1, m)
151
- }, {
152
- sheets: [i],
153
- activeSheet: 0,
154
- themeColors: o.themeColors,
155
- date1904: e.date1904,
156
- cellImages: e.cellImages
157
- };
158
- }
159
- function z(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 G(e, o) {
183
- return M(e, o);
184
- }
185
- export {
186
- S as a,
187
- L as i,
188
- E as j,
189
- G as p
190
- };