@xlsx-editor.dev/core 0.0.0-placeholder.0 → 0.1.0-beta.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/LICENSE +217 -0
- package/README.md +254 -2
- package/THIRD_PARTY_NOTICES.md +78 -0
- package/dist/automation.d.ts +299 -0
- package/dist/automation.js +42 -0
- package/dist/builtins-nmHrq2Et.d.ts +37 -0
- package/dist/cascade.d.ts +196 -0
- package/dist/cascade.js +60 -0
- package/dist/cell-format-DW8yF-c-.d.ts +226 -0
- package/dist/chunk-2DLJYRJC.js +3171 -0
- package/dist/chunk-2ZU4337U.js +204 -0
- package/dist/chunk-44L37ENZ.js +8219 -0
- package/dist/chunk-77N55BLP.js +911 -0
- package/dist/chunk-7PV5HQPE.js +84 -0
- package/dist/chunk-E4VJJ556.js +756 -0
- package/dist/chunk-KG4IL4JI.js +436 -0
- package/dist/chunk-PLDK4XO6.js +9125 -0
- package/dist/chunk-PRHLYXHL.js +1699 -0
- package/dist/chunk-TE4FXG5T.js +3156 -0
- package/dist/contracts.d.ts +32 -0
- package/dist/contracts.js +0 -0
- package/dist/dist-C7NLNUMD.js +2850 -0
- package/dist/editor.d.ts +3167 -0
- package/dist/editor.js +309 -0
- package/dist/harfbuzz-measurer-CkKfsEyu.d.ts +128 -0
- package/dist/harfbuzz.wasm +0 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +309 -0
- package/dist/layout.d.ts +111 -0
- package/dist/layout.js +104 -0
- package/dist/merge-commands-DthcNpfw.d.ts +53 -0
- package/dist/node-module-shim-LQXGL47O.js +18 -0
- package/dist/ops-CfUCjyph.d.ts +629 -0
- package/dist/output.d.ts +177 -0
- package/dist/output.js +29 -0
- package/dist/sheet-index-P5vevMWX.d.ts +52 -0
- package/dist/sheet-layout-D9M_4EBn.d.ts +494 -0
- package/dist/sheet-protection-D8goxm58.d.ts +209 -0
- package/dist/store.d.ts +615 -0
- package/dist/store.js +272 -0
- package/dist/theme-BprDji6x.d.ts +16 -0
- package/dist/units-D6CD_A5I.d.ts +13 -0
- package/dist/workbook-index-DsbeR8Kb.d.ts +294 -0
- package/licenses/Emscripten-LICENSE.txt +102 -0
- package/licenses/HarfBuzz-COPYING.txt +42 -0
- package/licenses/HarfBuzz-USE-MIT.txt +21 -0
- package/licenses/HarfBuzz-source-notices.txt +4508 -0
- package/licenses/README.md +19 -0
- package/licenses/Unicode-LICENSE.txt +39 -0
- package/licenses/compiler-rt-LICENSE.txt +311 -0
- package/licenses/harfbuzz-manifest.json +84 -0
- package/licenses/musl-COPYRIGHT.txt +193 -0
- package/package.json +79 -6
- package/src/styles/editor.css +1933 -0
- package/src/styles/editor.css.d.ts +2 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cellKey
|
|
3
|
+
} from "./chunk-44L37ENZ.js";
|
|
4
|
+
import {
|
|
5
|
+
MAX_COLS,
|
|
6
|
+
MAX_ROWS,
|
|
7
|
+
attr,
|
|
8
|
+
child,
|
|
9
|
+
parseCellRef
|
|
10
|
+
} from "./chunk-2DLJYRJC.js";
|
|
11
|
+
|
|
12
|
+
// src/layout/panes.ts
|
|
13
|
+
var MAX_MERGES = 1e5;
|
|
14
|
+
function frozenPanes(worksheet) {
|
|
15
|
+
const view = child(child(worksheet, "x:sheetViews"), "x:sheetView");
|
|
16
|
+
const pane = child(view, "x:pane");
|
|
17
|
+
const state = attr(pane, "state");
|
|
18
|
+
if (!pane || state !== "frozen" && state !== "frozenSplit") return { rows: 0, cols: 0 };
|
|
19
|
+
const split = (name, max) => {
|
|
20
|
+
const n = Number(attr(pane, name) ?? "0");
|
|
21
|
+
return Number.isInteger(n) && n > 0 ? Math.min(n, max) : 0;
|
|
22
|
+
};
|
|
23
|
+
return { rows: split("ySplit", MAX_ROWS), cols: split("xSplit", MAX_COLS) };
|
|
24
|
+
}
|
|
25
|
+
function parseRange(ref) {
|
|
26
|
+
if (ref.length > 21) return void 0;
|
|
27
|
+
const colon = ref.indexOf(":");
|
|
28
|
+
const a = parseCellRef(colon < 0 ? ref : ref.slice(0, colon));
|
|
29
|
+
const b = colon < 0 ? a : parseCellRef(ref.slice(colon + 1));
|
|
30
|
+
if (!a || !b) return void 0;
|
|
31
|
+
return {
|
|
32
|
+
firstRow: Math.min(a.row, b.row),
|
|
33
|
+
firstCol: Math.min(a.col, b.col),
|
|
34
|
+
lastRow: Math.max(a.row, b.row),
|
|
35
|
+
lastCol: Math.max(a.col, b.col)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var mergeCache = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
function lastStartingBy(sorted, col) {
|
|
40
|
+
let lo = 0;
|
|
41
|
+
let hi = sorted.length;
|
|
42
|
+
while (lo < hi) {
|
|
43
|
+
const mid = lo + hi >> 1;
|
|
44
|
+
if (sorted[mid].firstCol <= col) lo = mid + 1;
|
|
45
|
+
else hi = mid;
|
|
46
|
+
}
|
|
47
|
+
return lo - 1;
|
|
48
|
+
}
|
|
49
|
+
function withoutOverlaps(sorted) {
|
|
50
|
+
const kept = [];
|
|
51
|
+
let active = [];
|
|
52
|
+
let minLast = Number.POSITIVE_INFINITY;
|
|
53
|
+
let skipped = 0;
|
|
54
|
+
for (const m of sorted) {
|
|
55
|
+
if (minLast < m.firstRow) {
|
|
56
|
+
active = active.filter((a) => a.lastRow >= m.firstRow);
|
|
57
|
+
minLast = Number.POSITIVE_INFINITY;
|
|
58
|
+
for (const a of active) minLast = Math.min(minLast, a.lastRow);
|
|
59
|
+
}
|
|
60
|
+
const at = lastStartingBy(active, m.firstCol);
|
|
61
|
+
if (at >= 0 && active[at].lastCol >= m.firstCol) {
|
|
62
|
+
skipped += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
kept.push(m);
|
|
66
|
+
active.splice(at + 1, 0, m);
|
|
67
|
+
minLast = Math.min(minLast, m.lastRow);
|
|
68
|
+
}
|
|
69
|
+
return { kept, skipped };
|
|
70
|
+
}
|
|
71
|
+
function mergedRanges(worksheet) {
|
|
72
|
+
const hit = mergeCache.get(worksheet);
|
|
73
|
+
if (hit) return hit;
|
|
74
|
+
const ranges = [];
|
|
75
|
+
let dropped = 0;
|
|
76
|
+
for (const node of child(worksheet, "x:mergeCells")?.children ?? []) {
|
|
77
|
+
if (node.type !== "element" || node.local !== "mergeCell") continue;
|
|
78
|
+
const range = ranges.length < MAX_MERGES ? parseRange(attr(node, "ref") ?? "") : void 0;
|
|
79
|
+
if (range && (range.lastRow > range.firstRow || range.lastCol > range.firstCol))
|
|
80
|
+
ranges.push(range);
|
|
81
|
+
else dropped += 1;
|
|
82
|
+
}
|
|
83
|
+
ranges.sort((a, b) => a.firstRow - b.firstRow || a.firstCol - b.firstCol);
|
|
84
|
+
const { kept, skipped } = withoutOverlaps(ranges);
|
|
85
|
+
const index = { ranges: kept, dropped, overlapping: skipped };
|
|
86
|
+
mergeCache.set(worksheet, index);
|
|
87
|
+
return index;
|
|
88
|
+
}
|
|
89
|
+
var anchorCache = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
function mergeAnchoredAt(index, row, col) {
|
|
91
|
+
let anchors = anchorCache.get(index);
|
|
92
|
+
if (!anchors) {
|
|
93
|
+
anchors = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const m of index.ranges) anchors.set(cellKey(m.firstRow, m.firstCol), m);
|
|
95
|
+
anchorCache.set(index, anchors);
|
|
96
|
+
}
|
|
97
|
+
return anchors.get(cellKey(row, col));
|
|
98
|
+
}
|
|
99
|
+
function startingBy(index, row) {
|
|
100
|
+
let lo = 0;
|
|
101
|
+
let hi = index.ranges.length;
|
|
102
|
+
while (lo < hi) {
|
|
103
|
+
const mid = lo + hi >> 1;
|
|
104
|
+
if (index.ranges[mid].firstRow <= row) lo = mid + 1;
|
|
105
|
+
else hi = mid;
|
|
106
|
+
}
|
|
107
|
+
return lo;
|
|
108
|
+
}
|
|
109
|
+
function mergesIn(index, area, work) {
|
|
110
|
+
const out = [];
|
|
111
|
+
const end = startingBy(index, area.lastRow);
|
|
112
|
+
if (work) work.mergesRead += end;
|
|
113
|
+
for (let i = 0; i < end; i += 1) {
|
|
114
|
+
const m = index.ranges[i];
|
|
115
|
+
if (m.lastRow >= area.firstRow && m.firstCol <= area.lastCol && m.lastCol >= area.firstCol)
|
|
116
|
+
out.push(m);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
function mergeAt(index, row, col) {
|
|
121
|
+
const end = startingBy(index, row);
|
|
122
|
+
for (let i = 0; i < end; i += 1) {
|
|
123
|
+
const m = index.ranges[i];
|
|
124
|
+
if (row <= m.lastRow && col >= m.firstCol && col <= m.lastCol) return m;
|
|
125
|
+
}
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
function mergeCoverage(merges) {
|
|
129
|
+
let next = 0;
|
|
130
|
+
let row = -1;
|
|
131
|
+
let active = [];
|
|
132
|
+
let reach = [];
|
|
133
|
+
let minLast = Number.POSITIVE_INFINITY;
|
|
134
|
+
const advance = (r) => {
|
|
135
|
+
if (r === row) return;
|
|
136
|
+
if (r < row) {
|
|
137
|
+
next = 0;
|
|
138
|
+
active = [];
|
|
139
|
+
minLast = Number.POSITIVE_INFINITY;
|
|
140
|
+
}
|
|
141
|
+
let entered = false;
|
|
142
|
+
while (next < merges.length && merges[next].firstRow <= r) {
|
|
143
|
+
active.push(merges[next]);
|
|
144
|
+
next += 1;
|
|
145
|
+
entered = true;
|
|
146
|
+
}
|
|
147
|
+
row = r;
|
|
148
|
+
if (!entered && r <= minLast) return;
|
|
149
|
+
active = active.filter((m) => m.lastRow >= r);
|
|
150
|
+
if (entered) active.sort((a, b) => a.firstCol - b.firstCol);
|
|
151
|
+
reach = [];
|
|
152
|
+
let max = -1;
|
|
153
|
+
minLast = Number.POSITIVE_INFINITY;
|
|
154
|
+
for (const m of active) {
|
|
155
|
+
reach.push(max = Math.max(max, m.lastCol));
|
|
156
|
+
minLast = Math.min(minLast, m.lastRow);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return (r, c) => {
|
|
160
|
+
advance(r);
|
|
161
|
+
const at = lastStartingBy(active, c);
|
|
162
|
+
return at >= 0 && reach[at] >= c;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function visibleSpan(axis, start, length) {
|
|
166
|
+
const first = axis.indexAt(start);
|
|
167
|
+
const last = axis.indexAt(start + Math.max(0, length) - 1e-6);
|
|
168
|
+
return { first, last: Math.max(first, last) };
|
|
169
|
+
}
|
|
170
|
+
function windowPanes(rows, columns, frozen, viewport) {
|
|
171
|
+
const frozenHeight = rows.offsetOf(frozen.rows);
|
|
172
|
+
const frozenWidth = columns.offsetOf(frozen.cols);
|
|
173
|
+
const bodyY = rows.offsetOf(frozen.rows) + Math.max(0, viewport.scrollY);
|
|
174
|
+
const bodyX = columns.offsetOf(frozen.cols) + Math.max(0, viewport.scrollX);
|
|
175
|
+
const bodyRows = visibleSpan(rows, bodyY, viewport.height - frozenHeight);
|
|
176
|
+
const bodyCols = visibleSpan(columns, bodyX, viewport.width - frozenWidth);
|
|
177
|
+
const panes = [];
|
|
178
|
+
const pane = (r, c, x, y) => panes.push({
|
|
179
|
+
range: { firstRow: r.first, firstCol: c.first, lastRow: r.last, lastCol: c.last },
|
|
180
|
+
x,
|
|
181
|
+
y
|
|
182
|
+
});
|
|
183
|
+
const topRows = { first: 0, last: frozen.rows - 1 };
|
|
184
|
+
const leftCols = { first: 0, last: frozen.cols - 1 };
|
|
185
|
+
const shiftX = frozenWidth - (bodyX - columns.offsetOf(bodyCols.first));
|
|
186
|
+
const shiftY = frozenHeight - (bodyY - rows.offsetOf(bodyRows.first));
|
|
187
|
+
if (frozen.rows > 0 && frozen.cols > 0) pane(topRows, leftCols, 0, 0);
|
|
188
|
+
if (frozen.rows > 0) pane(topRows, bodyCols, shiftX, 0);
|
|
189
|
+
if (frozen.cols > 0) pane(bodyRows, leftCols, 0, shiftY);
|
|
190
|
+
pane(bodyRows, bodyCols, shiftX, shiftY);
|
|
191
|
+
return panes;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export {
|
|
195
|
+
MAX_MERGES,
|
|
196
|
+
frozenPanes,
|
|
197
|
+
parseRange,
|
|
198
|
+
mergedRanges,
|
|
199
|
+
mergeAnchoredAt,
|
|
200
|
+
mergesIn,
|
|
201
|
+
mergeAt,
|
|
202
|
+
mergeCoverage,
|
|
203
|
+
windowPanes
|
|
204
|
+
};
|