@w100n/documents 0.15.1 → 0.16.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/dist/Compare-M57FG4R3.js +96 -0
- package/dist/Compare-M57FG4R3.js.map +1 -0
- package/dist/{SheetView-RPQS43XY.js → SheetView-EFBSMY7K.js} +6 -4
- package/dist/{SheetView-RPQS43XY.js.map → SheetView-EFBSMY7K.js.map} +1 -1
- package/dist/{TextEditor-D6QH2B7O.js → TextEditor-MGCSGGGA.js} +128 -43
- package/dist/TextEditor-MGCSGGGA.js.map +1 -0
- package/dist/{chunk-BGH36LAR.js → chunk-2L3TK7UF.js} +87 -411
- package/dist/chunk-2L3TK7UF.js.map +1 -0
- package/dist/{chunk-XR42B3F5.js → chunk-3OLRFIHQ.js} +2 -2
- package/dist/chunk-EQLBYW42.js +458 -0
- package/dist/chunk-EQLBYW42.js.map +1 -0
- package/dist/chunk-RKV3N6OS.js +1011 -0
- package/dist/chunk-RKV3N6OS.js.map +1 -0
- package/dist/{chunk-CAPICJ6B.js → chunk-ZAVXCH7V.js} +51 -1032
- package/dist/chunk-ZAVXCH7V.js.map +1 -0
- package/dist/collab.cjs +346 -200
- package/dist/collab.cjs.map +1 -1
- package/dist/collab.js +4 -2
- package/dist/index.cjs +931 -600
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +135 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/TextEditor-D6QH2B7O.js.map +0 -1
- package/dist/chunk-BGH36LAR.js.map +0 -1
- package/dist/chunk-CAPICJ6B.js.map +0 -1
- /package/dist/{chunk-XR42B3F5.js.map → chunk-3OLRFIHQ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -37,11 +37,11 @@ function rove(e) {
|
|
|
37
37
|
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key) || e.altKey || e.metaKey || e.ctrlKey || target.closest('input, textarea, select, [contenteditable="true"]')) return;
|
|
38
38
|
const pop = target.closest(pops);
|
|
39
39
|
const list = [...(pop ?? e.currentTarget).querySelectorAll("button:not(:disabled)")].filter((el) => el.closest(pops) === pop);
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
40
|
+
const at2 = list.indexOf(target);
|
|
41
|
+
if (at2 < 0) return;
|
|
42
42
|
e.preventDefault();
|
|
43
43
|
e.stopPropagation();
|
|
44
|
-
list[e.key === "Home" ? 0 : e.key === "End" ? list.length - 1 : (
|
|
44
|
+
list[e.key === "Home" ? 0 : e.key === "End" ? list.length - 1 : (at2 + (e.key === "ArrowRight" ? 1 : -1) + list.length) % list.length].focus();
|
|
45
45
|
}
|
|
46
46
|
function useRestore(open) {
|
|
47
47
|
(0, import_react.useLayoutEffect)(() => {
|
|
@@ -98,8 +98,17 @@ var init_text = __esm({
|
|
|
98
98
|
retry: "Try again",
|
|
99
99
|
loading: "Loading",
|
|
100
100
|
unsupported: "This file cannot be shown yet",
|
|
101
|
+
printLayout: "Print layout",
|
|
102
|
+
cut: "Cut",
|
|
103
|
+
paste: "Paste",
|
|
104
|
+
spellCheck: "Spell check",
|
|
105
|
+
spellHint: "Spelling: right-click again",
|
|
101
106
|
restore: "Restore this version",
|
|
102
107
|
restoreFailed: "Could not restore",
|
|
108
|
+
showChanges: "What changed",
|
|
109
|
+
hideChanges: "Back to the version",
|
|
110
|
+
noChanges: "Same text as now",
|
|
111
|
+
changeCount: "Since this version, paragraphs: {added} added, {edited} changed, {removed} removed",
|
|
103
112
|
allProjects: "All projects",
|
|
104
113
|
closePanel: "Hide the panel",
|
|
105
114
|
openPanel: "Show the panel",
|
|
@@ -204,7 +213,6 @@ var init_text = __esm({
|
|
|
204
213
|
footnote: "Footnote",
|
|
205
214
|
footnoteText: "Footnote text",
|
|
206
215
|
formula: "Formula",
|
|
207
|
-
formulaHint: "Saved as a Word equation",
|
|
208
216
|
symbols: "Special characters",
|
|
209
217
|
symbolSearch: "Search, for example arrow",
|
|
210
218
|
update: "Update",
|
|
@@ -424,8 +432,17 @@ var init_text = __esm({
|
|
|
424
432
|
retry: "Spr\xF3buj ponownie",
|
|
425
433
|
loading: "Wczytywanie",
|
|
426
434
|
unsupported: "Tego pliku nie da si\u0119 jeszcze pokaza\u0107",
|
|
435
|
+
printLayout: "Uk\u0142ad wydruku",
|
|
436
|
+
cut: "Wytnij",
|
|
437
|
+
paste: "Wklej",
|
|
438
|
+
spellCheck: "Sprawdzanie pisowni",
|
|
439
|
+
spellHint: "Pisownia: kliknij prawym jeszcze raz",
|
|
427
440
|
restore: "Przywr\xF3\u0107 t\u0119 wersj\u0119",
|
|
428
441
|
restoreFailed: "Nie uda\u0142o si\u0119 przywr\xF3ci\u0107",
|
|
442
|
+
showChanges: "Co si\u0119 zmieni\u0142o",
|
|
443
|
+
hideChanges: "Wr\xF3\u0107 do wersji",
|
|
444
|
+
noChanges: "Tekst taki sam jak teraz",
|
|
445
|
+
changeCount: "Od tej wersji, akapity: {added} dodane, {edited} zmienione, {removed} usuni\u0119te",
|
|
429
446
|
allProjects: "Wszystkie projekty",
|
|
430
447
|
closePanel: "Ukryj panel",
|
|
431
448
|
openPanel: "Poka\u017C panel",
|
|
@@ -530,7 +547,6 @@ var init_text = __esm({
|
|
|
530
547
|
footnote: "Przypis",
|
|
531
548
|
footnoteText: "Tekst przypisu",
|
|
532
549
|
formula: "Wz\xF3r",
|
|
533
|
-
formulaHint: "Zapisany jako r\xF3wnanie Word",
|
|
534
550
|
symbols: "Znaki specjalne",
|
|
535
551
|
symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
|
|
536
552
|
update: "Zmie\u0144",
|
|
@@ -750,8 +766,17 @@ var init_text = __esm({
|
|
|
750
766
|
retry: "\u0421\u043F\u0440\u043E\u0431\u0443\u0432\u0430\u0442\u0438 \u0449\u0435",
|
|
751
767
|
loading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
|
|
752
768
|
unsupported: "\u0426\u0435\u0439 \u0444\u0430\u0439\u043B \u043F\u043E\u043A\u0438 \u043D\u0435 \u043C\u043E\u0436\u043D\u0430 \u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",
|
|
769
|
+
printLayout: "\u0420\u043E\u0437\u043C\u0456\u0442\u043A\u0430 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
|
|
770
|
+
cut: "\u0412\u0438\u0440\u0456\u0437\u0430\u0442\u0438",
|
|
771
|
+
paste: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
|
|
772
|
+
spellCheck: "\u041F\u0435\u0440\u0435\u0432\u0456\u0440\u043A\u0430 \u043F\u0440\u0430\u0432\u043E\u043F\u0438\u0441\u0443",
|
|
773
|
+
spellHint: "\u041F\u0440\u0430\u0432\u043E\u043F\u0438\u0441: \u043A\u043B\u0430\u0446\u043D\u0456\u0442\u044C \u043F\u0440\u0430\u0432\u043E\u044E \u0449\u0435 \u0440\u0430\u0437",
|
|
753
774
|
restore: "\u0412\u0456\u0434\u043D\u043E\u0432\u0438\u0442\u0438 \u0446\u044E \u0432\u0435\u0440\u0441\u0456\u044E",
|
|
754
775
|
restoreFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0432\u0456\u0434\u043D\u043E\u0432\u0438\u0442\u0438",
|
|
776
|
+
showChanges: "\u0429\u043E \u0437\u043C\u0456\u043D\u0438\u043B\u043E\u0441\u044C",
|
|
777
|
+
hideChanges: "\u041D\u0430\u0437\u0430\u0434 \u0434\u043E \u0432\u0435\u0440\u0441\u0456\u0457",
|
|
778
|
+
noChanges: "\u0422\u0435\u043A\u0441\u0442 \u0442\u0430\u043A\u0438\u0439 \u0441\u0430\u043C\u0438\u0439, \u044F\u043A \u0437\u0430\u0440\u0430\u0437",
|
|
779
|
+
changeCount: "\u0412\u0456\u0434\u0442\u043E\u0434\u0456 \u0430\u0431\u0437\u0430\u0446\u0456\u0432: {added} \u0434\u043E\u0434\u0430\u043D\u043E, {edited} \u0437\u043C\u0456\u043D\u0435\u043D\u043E, {removed} \u0432\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
|
|
755
780
|
allProjects: "\u0423\u0441\u0456 \u043F\u0440\u043E\u0454\u043A\u0442\u0438",
|
|
756
781
|
closePanel: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",
|
|
757
782
|
openPanel: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",
|
|
@@ -855,7 +880,6 @@ var init_text = __esm({
|
|
|
855
880
|
footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
|
|
856
881
|
footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
|
|
857
882
|
formula: "\u0424\u043E\u0440\u043C\u0443\u043B\u0430",
|
|
858
|
-
formulaHint: "\u0417\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044C\u0441\u044F \u044F\u043A \u0440\u0456\u0432\u043D\u044F\u043D\u043D\u044F Word",
|
|
859
883
|
symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
|
|
860
884
|
symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
|
|
861
885
|
update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
|
|
@@ -1296,35 +1320,35 @@ function unzip(buf) {
|
|
|
1296
1320
|
while (eocd >= 0 && view.getUint32(eocd, true) !== 101010256) eocd--;
|
|
1297
1321
|
if (eocd < 0) throw new Error("Not a DOCX file");
|
|
1298
1322
|
const count = view.getUint16(eocd + 10, true);
|
|
1299
|
-
let
|
|
1300
|
-
if (count === 65535 ||
|
|
1323
|
+
let at2 = view.getUint32(eocd + 16, true);
|
|
1324
|
+
if (count === 65535 || at2 === 4294967295) throw new Error("ZIP64 DOCX files are not supported");
|
|
1301
1325
|
const names2 = new TextDecoder();
|
|
1302
1326
|
const out = [];
|
|
1303
1327
|
for (let n = 0; n < count; n++) {
|
|
1304
|
-
if (view.getUint32(
|
|
1305
|
-
const length = view.getUint16(
|
|
1306
|
-
const extra = view.getUint16(
|
|
1307
|
-
const note = view.getUint16(
|
|
1308
|
-
const local2 = view.getUint32(
|
|
1309
|
-
const csize = view.getUint32(
|
|
1310
|
-
const path = buf.subarray(
|
|
1328
|
+
if (view.getUint32(at2, true) !== 33639248) throw new Error("Broken DOCX file");
|
|
1329
|
+
const length = view.getUint16(at2 + 28, true);
|
|
1330
|
+
const extra = view.getUint16(at2 + 30, true);
|
|
1331
|
+
const note = view.getUint16(at2 + 32, true);
|
|
1332
|
+
const local2 = view.getUint32(at2 + 42, true);
|
|
1333
|
+
const csize = view.getUint32(at2 + 20, true);
|
|
1334
|
+
const path = buf.subarray(at2 + 46, at2 + 46 + length);
|
|
1311
1335
|
const begin = local2 + 30 + view.getUint16(local2 + 26, true) + view.getUint16(local2 + 28, true);
|
|
1312
1336
|
out.push({
|
|
1313
1337
|
name: names2.decode(path),
|
|
1314
1338
|
path,
|
|
1315
|
-
made: view.getUint16(
|
|
1316
|
-
version: view.getUint16(
|
|
1317
|
-
flags: view.getUint16(
|
|
1318
|
-
method: view.getUint16(
|
|
1319
|
-
time: view.getUint16(
|
|
1320
|
-
date: view.getUint16(
|
|
1321
|
-
crc: view.getUint32(
|
|
1322
|
-
size: view.getUint32(
|
|
1323
|
-
inner: view.getUint16(
|
|
1324
|
-
outer: view.getUint32(
|
|
1339
|
+
made: view.getUint16(at2 + 4, true),
|
|
1340
|
+
version: view.getUint16(at2 + 6, true),
|
|
1341
|
+
flags: view.getUint16(at2 + 8, true),
|
|
1342
|
+
method: view.getUint16(at2 + 10, true),
|
|
1343
|
+
time: view.getUint16(at2 + 12, true),
|
|
1344
|
+
date: view.getUint16(at2 + 14, true),
|
|
1345
|
+
crc: view.getUint32(at2 + 16, true),
|
|
1346
|
+
size: view.getUint32(at2 + 24, true),
|
|
1347
|
+
inner: view.getUint16(at2 + 36, true),
|
|
1348
|
+
outer: view.getUint32(at2 + 38, true),
|
|
1325
1349
|
raw: buf.subarray(begin, begin + csize)
|
|
1326
1350
|
});
|
|
1327
|
-
|
|
1351
|
+
at2 += 46 + length + extra + note;
|
|
1328
1352
|
}
|
|
1329
1353
|
return out;
|
|
1330
1354
|
}
|
|
@@ -1348,49 +1372,49 @@ function zip(entries2) {
|
|
|
1348
1372
|
const buf = new Uint8Array(total);
|
|
1349
1373
|
const view = new DataView(buf.buffer);
|
|
1350
1374
|
const offsets = [];
|
|
1351
|
-
let
|
|
1375
|
+
let at2 = 0;
|
|
1352
1376
|
for (const e of entries2) {
|
|
1353
|
-
offsets.push(
|
|
1354
|
-
view.setUint32(
|
|
1355
|
-
view.setUint16(
|
|
1356
|
-
view.setUint16(
|
|
1357
|
-
view.setUint16(
|
|
1358
|
-
view.setUint16(
|
|
1359
|
-
view.setUint16(
|
|
1360
|
-
view.setUint32(
|
|
1361
|
-
view.setUint32(
|
|
1362
|
-
view.setUint32(
|
|
1363
|
-
view.setUint16(
|
|
1364
|
-
view.setUint16(
|
|
1365
|
-
buf.set(e.path,
|
|
1366
|
-
buf.set(e.raw,
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1369
|
-
const start =
|
|
1377
|
+
offsets.push(at2);
|
|
1378
|
+
view.setUint32(at2, 67324752, true);
|
|
1379
|
+
view.setUint16(at2 + 4, e.version, true);
|
|
1380
|
+
view.setUint16(at2 + 6, e.flags & ~8, true);
|
|
1381
|
+
view.setUint16(at2 + 8, e.method, true);
|
|
1382
|
+
view.setUint16(at2 + 10, e.time, true);
|
|
1383
|
+
view.setUint16(at2 + 12, e.date, true);
|
|
1384
|
+
view.setUint32(at2 + 14, e.crc, true);
|
|
1385
|
+
view.setUint32(at2 + 18, e.raw.length, true);
|
|
1386
|
+
view.setUint32(at2 + 22, e.size, true);
|
|
1387
|
+
view.setUint16(at2 + 26, e.path.length, true);
|
|
1388
|
+
view.setUint16(at2 + 28, 0, true);
|
|
1389
|
+
buf.set(e.path, at2 + 30);
|
|
1390
|
+
buf.set(e.raw, at2 + 30 + e.path.length);
|
|
1391
|
+
at2 += 30 + e.path.length + e.raw.length;
|
|
1392
|
+
}
|
|
1393
|
+
const start = at2;
|
|
1370
1394
|
entries2.forEach((e, n) => {
|
|
1371
|
-
view.setUint32(
|
|
1372
|
-
view.setUint16(
|
|
1373
|
-
view.setUint16(
|
|
1374
|
-
view.setUint16(
|
|
1375
|
-
view.setUint16(
|
|
1376
|
-
view.setUint16(
|
|
1377
|
-
view.setUint16(
|
|
1378
|
-
view.setUint32(
|
|
1379
|
-
view.setUint32(
|
|
1380
|
-
view.setUint32(
|
|
1381
|
-
view.setUint16(
|
|
1382
|
-
view.setUint16(
|
|
1383
|
-
view.setUint32(
|
|
1384
|
-
view.setUint32(
|
|
1385
|
-
buf.set(e.path,
|
|
1386
|
-
|
|
1395
|
+
view.setUint32(at2, 33639248, true);
|
|
1396
|
+
view.setUint16(at2 + 4, e.made, true);
|
|
1397
|
+
view.setUint16(at2 + 6, e.version, true);
|
|
1398
|
+
view.setUint16(at2 + 8, e.flags & ~8, true);
|
|
1399
|
+
view.setUint16(at2 + 10, e.method, true);
|
|
1400
|
+
view.setUint16(at2 + 12, e.time, true);
|
|
1401
|
+
view.setUint16(at2 + 14, e.date, true);
|
|
1402
|
+
view.setUint32(at2 + 16, e.crc, true);
|
|
1403
|
+
view.setUint32(at2 + 20, e.raw.length, true);
|
|
1404
|
+
view.setUint32(at2 + 24, e.size, true);
|
|
1405
|
+
view.setUint16(at2 + 28, e.path.length, true);
|
|
1406
|
+
view.setUint16(at2 + 36, e.inner, true);
|
|
1407
|
+
view.setUint32(at2 + 38, e.outer, true);
|
|
1408
|
+
view.setUint32(at2 + 42, offsets[n], true);
|
|
1409
|
+
buf.set(e.path, at2 + 46);
|
|
1410
|
+
at2 += 46 + e.path.length;
|
|
1387
1411
|
});
|
|
1388
|
-
view.setUint32(
|
|
1389
|
-
view.setUint16(
|
|
1390
|
-
view.setUint16(
|
|
1391
|
-
view.setUint32(
|
|
1392
|
-
view.setUint32(
|
|
1393
|
-
return buf.subarray(0,
|
|
1412
|
+
view.setUint32(at2, 101010256, true);
|
|
1413
|
+
view.setUint16(at2 + 8, entries2.length, true);
|
|
1414
|
+
view.setUint16(at2 + 10, entries2.length, true);
|
|
1415
|
+
view.setUint32(at2 + 12, at2 - start, true);
|
|
1416
|
+
view.setUint32(at2 + 16, start, true);
|
|
1417
|
+
return buf.subarray(0, at2 + 22);
|
|
1394
1418
|
}
|
|
1395
1419
|
var import_fflate, table;
|
|
1396
1420
|
var init_zip = __esm({
|
|
@@ -2432,21 +2456,21 @@ var init_read = __esm({
|
|
|
2432
2456
|
out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null, box: true });
|
|
2433
2457
|
} else {
|
|
2434
2458
|
const content = kid(k, "w:sdtContent");
|
|
2435
|
-
const
|
|
2436
|
-
if (content) this.walk(content.kids, ctx, content,
|
|
2437
|
-
this.span(s.slice(k.start, k.end),
|
|
2459
|
+
const inside2 = [];
|
|
2460
|
+
if (content) this.walk(content.kids, ctx, content, inside2, { lock: null, task: false, box: false });
|
|
2461
|
+
this.span(s.slice(k.start, k.end), inside2, out, ctx, null);
|
|
2438
2462
|
}
|
|
2439
2463
|
} else if (name === "w:fldSimple") {
|
|
2440
|
-
const
|
|
2441
|
-
this.walk(k.kids, ctx, k,
|
|
2442
|
-
this.span(s.slice(k.start, k.end),
|
|
2464
|
+
const inside2 = [];
|
|
2465
|
+
this.walk(k.kids, ctx, k, inside2, { lock: null, task: false, box: false });
|
|
2466
|
+
this.span(s.slice(k.start, k.end), inside2, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
|
|
2443
2467
|
} else if (name === "m:oMath") out.push({ text: "\uE000", raw: s.slice(k.start, k.end), run: null, ctx, span: null, math: latexOf(s.slice(k.start, k.end)) });
|
|
2444
2468
|
else if (name === "m:oMathPara") st.lock = "Equation";
|
|
2445
2469
|
else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
|
|
2446
2470
|
}
|
|
2447
2471
|
}
|
|
2448
|
-
span(xml,
|
|
2449
|
-
const shown =
|
|
2472
|
+
span(xml, inside2, out, ctx, link) {
|
|
2473
|
+
const shown = inside2.filter((p) => p.text !== null);
|
|
2450
2474
|
if (!shown.length) {
|
|
2451
2475
|
out.push({ text: null, raw: xml, run: null, ctx, span: null });
|
|
2452
2476
|
return;
|
|
@@ -2623,13 +2647,13 @@ var init_read = __esm({
|
|
|
2623
2647
|
let vm = vmEl ? vmVal === "restart" ? "restart" : "continue" : null;
|
|
2624
2648
|
if (vm === "continue" && !open[col]) vm = null;
|
|
2625
2649
|
const cref = this.ref();
|
|
2626
|
-
const
|
|
2627
|
-
const cell2 = { ref: cref, el: tc, lead: s.slice(last2, tc.start), col, span: span2, vm, blocks:
|
|
2650
|
+
const inside2 = this.blocks(tc);
|
|
2651
|
+
const cell2 = { ref: cref, el: tc, lead: s.slice(last2, tc.start), col, span: span2, vm, blocks: inside2.list, tail: s.slice(inside2.tail, tc.close), node: null };
|
|
2628
2652
|
last2 = tc.end;
|
|
2629
2653
|
this.refs.set(cref, cell2);
|
|
2630
2654
|
if (vm === "continue") open[col].attrs.rowspan++;
|
|
2631
2655
|
else {
|
|
2632
|
-
const content = assemble(
|
|
2656
|
+
const content = assemble(inside2.list);
|
|
2633
2657
|
const own = widths.slice(col, col + span2);
|
|
2634
2658
|
const shd = tcPr && kid(tcPr, "w:shd");
|
|
2635
2659
|
const fill3 = shd ? attr(s, shd, "w:fill") : null;
|
|
@@ -2681,10 +2705,10 @@ function diff(a, b) {
|
|
|
2681
2705
|
if (x >= n && y >= m) {
|
|
2682
2706
|
for (let e = d; e > 0; e--) {
|
|
2683
2707
|
const t = trace[e];
|
|
2684
|
-
const
|
|
2685
|
-
const down2 = k === -e || k !== e &&
|
|
2708
|
+
const at2 = (j) => t[j + e + 1];
|
|
2709
|
+
const down2 = k === -e || k !== e && at2(k - 1) < at2(k + 1);
|
|
2686
2710
|
const pk = down2 ? k + 1 : k - 1;
|
|
2687
|
-
const px2 =
|
|
2711
|
+
const px2 = at2(pk);
|
|
2688
2712
|
const py = px2 - pk;
|
|
2689
2713
|
while (x > px2 && y > py) map[p + --y] = p + --x;
|
|
2690
2714
|
x = px2;
|
|
@@ -2838,10 +2862,10 @@ function checked(xml, on2) {
|
|
|
2838
2862
|
const no = /w14:uncheckedState\b[^>]*w14:val="([0-9A-Fa-f]+)"/.exec(xml)?.[1] ?? "2610";
|
|
2839
2863
|
const [from, to] = on2 ? [no, yes] : [yes, no];
|
|
2840
2864
|
let out = /<w14:checked\b/.test(xml) ? xml.replace(/(<w14:checked\b[^>]*w14:val=")[^"]*"/, `$1${on2 ? 1 : 0}"`) : xml.replace(/(<w14:checkbox\b[^>]*>)/, `$1<w14:checked w14:val="${on2 ? 1 : 0}"/>`);
|
|
2841
|
-
const
|
|
2842
|
-
if (
|
|
2843
|
-
const tail = out.slice(
|
|
2844
|
-
out = out.slice(0,
|
|
2865
|
+
const at2 = out.indexOf("<w:sdtContent");
|
|
2866
|
+
if (at2 === -1) return out;
|
|
2867
|
+
const tail = out.slice(at2).replace(new RegExp(`w:char="${from}"`, "i"), `w:char="${to}"`).replace(`>${String.fromCharCode(parseInt(from, 16))}<`, `>${String.fromCharCode(parseInt(to, 16))}<`);
|
|
2868
|
+
out = out.slice(0, at2) + tail;
|
|
2845
2869
|
return out;
|
|
2846
2870
|
}
|
|
2847
2871
|
async function fetched(src) {
|
|
@@ -2952,9 +2976,9 @@ var init_write = __esm({
|
|
|
2952
2976
|
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"></w:numbering>`;
|
|
2953
2977
|
this.types.add(`<Override PartName="/${path}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>`);
|
|
2954
2978
|
}
|
|
2955
|
-
const
|
|
2979
|
+
const at2 = n.search(/<w:num\b[\s>]/);
|
|
2956
2980
|
const abs = this.numbering.abs.join("");
|
|
2957
|
-
n =
|
|
2981
|
+
n = at2 === -1 ? n.replace(/(<w:numIdMacAtCleanup\b|<\/w:numbering>)/, abs + "$1") : n.slice(0, at2) + abs + n.slice(at2);
|
|
2958
2982
|
n = n.replace(/(<w:numIdMacAtCleanup\b|<\/w:numbering>)/, this.numbering.nums.join("") + "$1");
|
|
2959
2983
|
changed2.set(path, n);
|
|
2960
2984
|
if (!rel) {
|
|
@@ -2967,8 +2991,8 @@ var init_write = __esm({
|
|
|
2967
2991
|
const settings = this.tocs && this.pkg.byType("/settings");
|
|
2968
2992
|
const listed2 = settings && this.pkg.text(settings.target);
|
|
2969
2993
|
if (settings && listed2 && !/<w:updateFields\b/.test(listed2)) {
|
|
2970
|
-
const
|
|
2971
|
-
changed2.set(settings.target, listed2.slice(0,
|
|
2994
|
+
const at2 = listed2.search(/<(?:w:hdrShapeDefaults|w:footnotePr|w:endnotePr|w:compat|w:docVars|w:rsids|m:mathPr|w:attachedSchema|w:themeFontLang|w:clrSchemeMapping|w:doNotIncludeSubdocsInStats|w:doNotAutoCompressPictures|w:forceUpgrade|w:captions|w:readModeInkLockDown|w:smartTagType|sl:schemaLibrary|w:shapeDefaults|w:doNotEmbedSmartTags|w:decimalSymbol|w:listSeparator)\b|<\/w:settings>/);
|
|
2995
|
+
changed2.set(settings.target, listed2.slice(0, at2) + '<w:updateFields w:val="true"/>' + listed2.slice(at2));
|
|
2972
2996
|
}
|
|
2973
2997
|
if (this.styleXml.length) {
|
|
2974
2998
|
const rel = this.pkg.byType("/styles");
|
|
@@ -3068,20 +3092,20 @@ var init_write = __esm({
|
|
|
3068
3092
|
return ++this.lastNote;
|
|
3069
3093
|
}
|
|
3070
3094
|
footnotes(doc, changed2) {
|
|
3071
|
-
const
|
|
3095
|
+
const notes3 = [];
|
|
3072
3096
|
const walk = (n) => {
|
|
3073
|
-
if (n.type === "footnote" && n.attrs?.id)
|
|
3097
|
+
if (n.type === "footnote" && n.attrs?.id) notes3.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
|
|
3074
3098
|
n.content?.forEach(walk);
|
|
3075
3099
|
};
|
|
3076
3100
|
walk(doc);
|
|
3077
3101
|
const rel = this.pkg.byType("/footnotes");
|
|
3078
3102
|
const old = rel ? this.pkg.text(rel.target) : null;
|
|
3079
|
-
if (!
|
|
3103
|
+
if (!notes3.length) return;
|
|
3080
3104
|
const path = rel ? rel.target : "word/footnotes.xml";
|
|
3081
3105
|
let xml = old ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3082
3106
|
<w:footnotes xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}"><w:footnote w:type="separator" w:id="-1"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote></w:footnotes>`;
|
|
3083
|
-
const fresh2 = (id,
|
|
3084
|
-
for (const n of
|
|
3107
|
+
const fresh2 = (id, words3) => `<w:footnote w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:footnoteRef/></w:r><w:r><w:rPr><w:sz w:val="20"/></w:rPr><w:t xml:space="preserve"> ${escape2(words3)}</w:t></w:r></w:p></w:footnote>`;
|
|
3108
|
+
for (const n of notes3) {
|
|
3085
3109
|
const found = new RegExp(`<w:footnote\\b[^>]*\\bw:id="${n.id}"[^>]*>([\\s\\S]*?)</w:footnote>`).exec(xml);
|
|
3086
3110
|
if (found && noteText(found[1]) === n.text) continue;
|
|
3087
3111
|
xml = found ? xml.replace(found[0], fresh2(n.id, n.text)) : xml.replace(/<\/w:footnotes>\s*$/, fresh2(n.id, n.text) + "</w:footnotes>");
|
|
@@ -3128,8 +3152,8 @@ var init_write = __esm({
|
|
|
3128
3152
|
sec = sec.replace(re, xml);
|
|
3129
3153
|
return;
|
|
3130
3154
|
}
|
|
3131
|
-
const
|
|
3132
|
-
const i =
|
|
3155
|
+
const at2 = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
|
|
3156
|
+
const i = at2.length ? Math.min(...at2) : sec.lastIndexOf("</w:sectPr>");
|
|
3133
3157
|
sec = sec.slice(0, i) + xml + sec.slice(i);
|
|
3134
3158
|
};
|
|
3135
3159
|
const tw = (px2) => Math.round(px2 * 15);
|
|
@@ -3155,11 +3179,11 @@ var init_write = __esm({
|
|
|
3155
3179
|
const open = sec.indexOf(">") + 1;
|
|
3156
3180
|
sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
|
|
3157
3181
|
};
|
|
3158
|
-
const line = (
|
|
3182
|
+
const line = (words3, page) => {
|
|
3159
3183
|
const field = '<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve"> PAGE </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:t>1</w:t></w:r><w:r><w:fldChar w:fldCharType="end"/></w:r>';
|
|
3160
|
-
const run3 =
|
|
3161
|
-
if (!
|
|
3162
|
-
return `<w:p><w:pPr>${page &&
|
|
3184
|
+
const run3 = words3 ? `<w:r><w:t xml:space="preserve">${escape2(words3)}</w:t></w:r>` : "";
|
|
3185
|
+
if (!words3 && !page) return "";
|
|
3186
|
+
return `<w:p><w:pPr>${page && words3 ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run3}${page && words3 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
|
|
3163
3187
|
};
|
|
3164
3188
|
if (setup.header !== void 0) part("header", line(setup.header, false));
|
|
3165
3189
|
if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
|
|
@@ -3394,11 +3418,11 @@ var init_write = __esm({
|
|
|
3394
3418
|
}
|
|
3395
3419
|
const slot = new Int32Array(A.length + 1);
|
|
3396
3420
|
for (let k = 1; k <= A.length; k++) slot[k] = back[k - 1] >= 0 ? back[k - 1] + 1 : slot[k - 1];
|
|
3397
|
-
const
|
|
3421
|
+
const at2 = Array.from({ length: B.length + 1 }, () => []);
|
|
3398
3422
|
let chars = 0;
|
|
3399
3423
|
for (const u of units) {
|
|
3400
3424
|
if (u.ch !== null) chars++;
|
|
3401
|
-
else if (!u.box || o.task !== null)
|
|
3425
|
+
else if (!u.box || o.task !== null) at2[slot[chars]].push(u);
|
|
3402
3426
|
}
|
|
3403
3427
|
const paraBase = b ? this.markRun(b) : this.firstRun(src);
|
|
3404
3428
|
const out = [];
|
|
@@ -3412,7 +3436,7 @@ var init_write = __esm({
|
|
|
3412
3436
|
const next = new Int32Array(B.length + 1).fill(-1);
|
|
3413
3437
|
for (let k = B.length - 1; k >= 0; k--) next[k] = map[k] >= 0 ? map[k] : next[k + 1];
|
|
3414
3438
|
for (let j = 0; j <= B.length; j++) {
|
|
3415
|
-
for (const u of
|
|
3439
|
+
for (const u of at2[j]) out.push({ ch: null, raw: u.box && !u.run && b && b.task !== o.task ? checked(u.raw, !!o.task) : u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
|
|
3416
3440
|
if (j === B.length) break;
|
|
3417
3441
|
const i = map[j];
|
|
3418
3442
|
const want = B[j];
|
|
@@ -3513,8 +3537,8 @@ var init_write = __esm({
|
|
|
3513
3537
|
wrap = { open: tag, close: "</w:hyperlink>", link, ins: false };
|
|
3514
3538
|
this.wraps.set(link, wrap);
|
|
3515
3539
|
}
|
|
3516
|
-
const
|
|
3517
|
-
return
|
|
3540
|
+
const at2 = out.findIndex((w) => w.ins);
|
|
3541
|
+
return at2 === -1 ? [...out, wrap] : [...out.slice(0, at2), wrap, ...out.slice(at2)];
|
|
3518
3542
|
}
|
|
3519
3543
|
revised(ctx, rev) {
|
|
3520
3544
|
const out = ctx.filter((w) => !w.rev || w.rev === rev);
|
|
@@ -3713,8 +3737,8 @@ var init_write = __esm({
|
|
|
3713
3737
|
head2 = opened(s, b.el) + s.slice(b.el.open, first ? first.el.start - first.lead.length : b.el.close);
|
|
3714
3738
|
if (last2) tail = s.slice(last2.el.end, b.el.close);
|
|
3715
3739
|
if (b.cols && cols !== b.cols) {
|
|
3716
|
-
head2 = head2.replace(/(<w:tblGrid\b[^>]*>)([\s\S]*?)(<\/w:tblGrid>)/, (_, open,
|
|
3717
|
-
const list = [...
|
|
3740
|
+
head2 = head2.replace(/(<w:tblGrid\b[^>]*>)([\s\S]*?)(<\/w:tblGrid>)/, (_, open, inside2, close) => {
|
|
3741
|
+
const list = [...inside2.match(/<w:gridCol\b[^>]*\/>/g) ?? []];
|
|
3718
3742
|
while (list.length < cols) list.push(list[list.length - 1] ?? "<w:gridCol/>");
|
|
3719
3743
|
return open + list.slice(0, cols).join("") + close;
|
|
3720
3744
|
});
|
|
@@ -3793,9 +3817,9 @@ var init_write = __esm({
|
|
|
3793
3817
|
continue;
|
|
3794
3818
|
}
|
|
3795
3819
|
const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
|
|
3796
|
-
let
|
|
3797
|
-
if (!this.last || this.last === "tbl")
|
|
3798
|
-
xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C, own(sl.col, sl.span), value("background", sl.cell.attrs?.background)) +
|
|
3820
|
+
let inside2 = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
|
|
3821
|
+
if (!this.last || this.last === "tbl") inside2 += "<w:p/>";
|
|
3822
|
+
xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C, own(sl.col, sl.span), value("background", sl.cell.attrs?.background)) + inside2 + (C ? C.tail : "") + "</w:tc>";
|
|
3799
3823
|
}
|
|
3800
3824
|
const lastCell = R2?.cells[R2.cells.length - 1];
|
|
3801
3825
|
xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
|
|
@@ -3835,14 +3859,14 @@ async function readDocx(bytes) {
|
|
|
3835
3859
|
const size2 = sect && kid(sect, "w:pgSz");
|
|
3836
3860
|
const mar = sect && kid(sect, "w:pgMar");
|
|
3837
3861
|
const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
|
|
3838
|
-
const
|
|
3862
|
+
const words3 = (kind) => {
|
|
3839
3863
|
const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
|
|
3840
3864
|
const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
|
|
3841
3865
|
const xml = part ? pkg.text(part.target) ?? "" : "";
|
|
3842
3866
|
return { text: [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").trim(), page: /\bPAGE\b/.test(xml) };
|
|
3843
3867
|
};
|
|
3844
|
-
const head2 =
|
|
3845
|
-
const foot =
|
|
3868
|
+
const head2 = words3("header");
|
|
3869
|
+
const foot = words3("footer");
|
|
3846
3870
|
return {
|
|
3847
3871
|
marginal: { header: head2.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
|
|
3848
3872
|
doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
|
|
@@ -3935,7 +3959,7 @@ function measure(view) {
|
|
|
3935
3959
|
const gaps = [];
|
|
3936
3960
|
const line = page.width - page.margins[1] - page.margins[3];
|
|
3937
3961
|
const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
|
|
3938
|
-
let
|
|
3962
|
+
let notes3 = [];
|
|
3939
3963
|
let count = 0;
|
|
3940
3964
|
let i = 0;
|
|
3941
3965
|
let shift = 0;
|
|
@@ -3955,20 +3979,20 @@ function measure(view) {
|
|
|
3955
3979
|
if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
|
|
3956
3980
|
});
|
|
3957
3981
|
if (node.type.name === "pageBreak") {
|
|
3958
|
-
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes:
|
|
3959
|
-
|
|
3982
|
+
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes3 });
|
|
3983
|
+
notes3 = [];
|
|
3960
3984
|
start = end;
|
|
3961
|
-
} else if (end > start + room - area([...
|
|
3962
|
-
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes:
|
|
3963
|
-
|
|
3985
|
+
} else if (end > start + room - area([...notes3, ...mine]) && y > start) {
|
|
3986
|
+
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes3 });
|
|
3987
|
+
notes3 = [];
|
|
3964
3988
|
start = y;
|
|
3965
3989
|
}
|
|
3966
|
-
|
|
3990
|
+
notes3.push(...mine);
|
|
3967
3991
|
count += mine.length;
|
|
3968
3992
|
while (end > start + room) start += room;
|
|
3969
3993
|
last2 = end;
|
|
3970
3994
|
});
|
|
3971
|
-
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true, notes:
|
|
3995
|
+
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true, notes: notes3 });
|
|
3972
3996
|
return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
|
|
3973
3997
|
}
|
|
3974
3998
|
var import_core, import_state, import_view, a4, letter, paging, skip2, Pager;
|
|
@@ -3987,10 +4011,10 @@ var init_pager = __esm({
|
|
|
3987
4011
|
addProseMirrorPlugins: () => [new import_state.Plugin({
|
|
3988
4012
|
key: paging,
|
|
3989
4013
|
state: {
|
|
3990
|
-
init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" } }),
|
|
4014
|
+
init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" }, flow: false }),
|
|
3991
4015
|
apply(tr, value3) {
|
|
3992
4016
|
const next = tr.getMeta(paging);
|
|
3993
|
-
return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks };
|
|
4017
|
+
return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks, flow: next?.flow ?? value3.flow };
|
|
3994
4018
|
}
|
|
3995
4019
|
},
|
|
3996
4020
|
props: { decorations: (state) => paging.getState(state).set },
|
|
@@ -3999,8 +4023,13 @@ var init_pager = __esm({
|
|
|
3999
4023
|
let sig2 = "";
|
|
4000
4024
|
const run3 = () => {
|
|
4001
4025
|
if (!view.dom.isConnected) return;
|
|
4026
|
+
const { marks: marks2, flow } = paging.getState(view.state);
|
|
4027
|
+
if (flow) {
|
|
4028
|
+
if (sig2 !== "flow") view.dispatch(view.state.tr.setMeta(paging, { set: import_view.DecorationSet.empty }).setMeta("addToHistory", false));
|
|
4029
|
+
sig2 = "flow";
|
|
4030
|
+
return;
|
|
4031
|
+
}
|
|
4002
4032
|
const gaps = measure(view);
|
|
4003
|
-
const { marks: marks2 } = paging.getState(view.state);
|
|
4004
4033
|
const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks2.header}|${marks2.footer}`;
|
|
4005
4034
|
if (next === sig2) return;
|
|
4006
4035
|
sig2 = next;
|
|
@@ -4051,7 +4080,8 @@ var init_pager = __esm({
|
|
|
4051
4080
|
later(0);
|
|
4052
4081
|
return {
|
|
4053
4082
|
update: (next, prev) => {
|
|
4054
|
-
|
|
4083
|
+
const now = paging.getState(next.state), was = paging.getState(prev);
|
|
4084
|
+
if (now.page !== was.page || now.marks !== was.marks || now.flow !== was.flow) later(0);
|
|
4055
4085
|
else if (next.state.doc !== prev.doc) later(400);
|
|
4056
4086
|
},
|
|
4057
4087
|
destroy: () => {
|
|
@@ -4120,7 +4150,10 @@ function kit(kind, t, live) {
|
|
|
4120
4150
|
Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
|
|
4121
4151
|
Note,
|
|
4122
4152
|
Notes,
|
|
4123
|
-
|
|
4153
|
+
Formula,
|
|
4154
|
+
Footnote,
|
|
4155
|
+
EndNotes,
|
|
4156
|
+
...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
|
|
4124
4157
|
...live ? [import_extension_collaboration.default.configure({ document: live.doc }), import_extension_collaboration_caret.default.configure({ provider: live.link, user: live.user })] : []
|
|
4125
4158
|
];
|
|
4126
4159
|
}
|
|
@@ -4143,8 +4176,8 @@ function locate(doc, list) {
|
|
|
4143
4176
|
if (line) doc.descendants((node, pos) => {
|
|
4144
4177
|
if (hit) return false;
|
|
4145
4178
|
if (!node.isTextblock) return true;
|
|
4146
|
-
const
|
|
4147
|
-
if (
|
|
4179
|
+
const at2 = node.textBetween(0, node.content.size, void 0, "\uFFFC").indexOf(line);
|
|
4180
|
+
if (at2 >= 0) hit = { from: pos + 1 + at2, to: pos + 1 + at2 + line.length };
|
|
4148
4181
|
return false;
|
|
4149
4182
|
});
|
|
4150
4183
|
return hit;
|
|
@@ -4163,7 +4196,7 @@ function locate(doc, list) {
|
|
|
4163
4196
|
return range ? [{ id: c.id, from: range.from, to: range.to }] : [];
|
|
4164
4197
|
});
|
|
4165
4198
|
}
|
|
4166
|
-
var import_core2, import_extension_collaboration, import_extension_collaboration_caret, import_extension_highlight, import_extension_image, import_extension_list, import_extension_table, import_extension_text_style, import_state2, import_transform, import_view2, import_starter_kit, import_y_tiptap, notes, blocks, changed, Cells, searching, lookup, Search2, replace, cleanPaste, Blocks, PageBreak, Formula, Footnote, headings, Toc, revision, seen, suggesting, Suggest, Note, locks, locked, scan, Locks, paint, remap, Notes, script, textblocks, align2, spacing, indent, clear;
|
|
4199
|
+
var import_core2, import_extension_collaboration, import_extension_collaboration_caret, import_extension_highlight, import_extension_image, import_extension_list, import_extension_table, import_extension_text_style, import_state2, import_transform, import_view2, import_starter_kit, import_y_tiptap, notes, blocks, changed, Cells, searching, lookup, Search2, replace, cleanPaste, Blocks, PageBreak, Formula, Footnote, EndNotes, headings, Toc, revision, seen, suggesting, Suggest, Note, locks, locked, scan, Locks, paint, remap, Notes, script, textblocks, align2, spacing, indent, clear;
|
|
4167
4200
|
var init_extensions = __esm({
|
|
4168
4201
|
"src/editor/extensions.ts"() {
|
|
4169
4202
|
"use strict";
|
|
@@ -4227,14 +4260,14 @@ var init_extensions = __esm({
|
|
|
4227
4260
|
doc.descendants((node, pos) => {
|
|
4228
4261
|
if (!node.isTextblock) return true;
|
|
4229
4262
|
let text = "";
|
|
4230
|
-
const
|
|
4263
|
+
const at2 = [];
|
|
4231
4264
|
node.forEach((child, offset) => {
|
|
4232
4265
|
const part = child.isText ? child.text : "\uFFFC";
|
|
4233
|
-
for (let i = 0; i < part.length; i++)
|
|
4266
|
+
for (let i = 0; i < part.length; i++) at2.push(pos + 1 + offset + i);
|
|
4234
4267
|
text += part;
|
|
4235
4268
|
});
|
|
4236
4269
|
const hay = matchCase ? text : text.toLowerCase();
|
|
4237
|
-
for (let i = hay.indexOf(needle); i >= 0; i = hay.indexOf(needle, i + needle.length)) hits.push({ from:
|
|
4270
|
+
for (let i = hay.indexOf(needle); i >= 0; i = hay.indexOf(needle, i + needle.length)) hits.push({ from: at2[i], to: at2[i + needle.length - 1] + 1 });
|
|
4238
4271
|
return false;
|
|
4239
4272
|
});
|
|
4240
4273
|
return hits;
|
|
@@ -4250,18 +4283,18 @@ var init_extensions = __esm({
|
|
|
4250
4283
|
if (!meta2 && !tr.docChanged) return value3;
|
|
4251
4284
|
const next = { ...value3, ...meta2 };
|
|
4252
4285
|
const hits = lookup(tr.doc, next.query, next.matchCase);
|
|
4253
|
-
const
|
|
4254
|
-
return { ...next, hits, at, set: import_view2.DecorationSet.create(tr.doc, hits.map((h, i) => import_view2.Decoration.inline(h.from, h.to, { class: i ===
|
|
4286
|
+
const at2 = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
|
|
4287
|
+
return { ...next, hits, at: at2, set: import_view2.DecorationSet.create(tr.doc, hits.map((h, i) => import_view2.Decoration.inline(h.from, h.to, { class: i === at2 ? "w100n-found is-current" : "w100n-found" }))) };
|
|
4255
4288
|
}
|
|
4256
4289
|
},
|
|
4257
4290
|
props: { decorations: (state) => searching.getState(state).set }
|
|
4258
4291
|
})]
|
|
4259
4292
|
});
|
|
4260
4293
|
replace = (editor, text, all) => {
|
|
4261
|
-
const { hits, at } = searching.getState(editor.state);
|
|
4294
|
+
const { hits, at: at2 } = searching.getState(editor.state);
|
|
4262
4295
|
if (!hits.length) return 0;
|
|
4263
4296
|
const tr = editor.state.tr;
|
|
4264
|
-
for (const hit of all ? [...hits].reverse() : [hits[
|
|
4297
|
+
for (const hit of all ? [...hits].reverse() : [hits[at2]]) tr.insertText(text, hit.from, hit.to);
|
|
4265
4298
|
editor.view.dispatch(tr);
|
|
4266
4299
|
return all ? hits.length : 1;
|
|
4267
4300
|
};
|
|
@@ -4308,12 +4341,12 @@ var init_extensions = __esm({
|
|
|
4308
4341
|
for (let i = start; i < end; i++) {
|
|
4309
4342
|
const top = state.doc.child(i);
|
|
4310
4343
|
visit(top, pos);
|
|
4311
|
-
top.descendants((node,
|
|
4344
|
+
top.descendants((node, at2) => visit(node, pos + 1 + at2));
|
|
4312
4345
|
pos += top.nodeSize;
|
|
4313
4346
|
}
|
|
4314
4347
|
if (!drop2.length) return null;
|
|
4315
4348
|
const tr = state.tr;
|
|
4316
|
-
for (const
|
|
4349
|
+
for (const at2 of drop2) tr.setNodeAttribute(at2, "ref", null);
|
|
4317
4350
|
return tr;
|
|
4318
4351
|
}
|
|
4319
4352
|
})]
|
|
@@ -4360,6 +4393,31 @@ var init_extensions = __esm({
|
|
|
4360
4393
|
parseHTML: () => [{ tag: "sup[data-footnote]" }],
|
|
4361
4394
|
renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
|
|
4362
4395
|
});
|
|
4396
|
+
EndNotes = import_core2.Extension.create({
|
|
4397
|
+
name: "endNotes",
|
|
4398
|
+
addProseMirrorPlugins: () => [new import_state2.Plugin({
|
|
4399
|
+
props: {
|
|
4400
|
+
decorations(state) {
|
|
4401
|
+
const notes3 = [];
|
|
4402
|
+
state.doc.descendants((n) => {
|
|
4403
|
+
if (n.type.name === "footnote") notes3.push(n.attrs.text);
|
|
4404
|
+
});
|
|
4405
|
+
if (!notes3.length) return null;
|
|
4406
|
+
return import_view2.DecorationSet.create(state.doc, [import_view2.Decoration.widget(state.doc.content.size, () => {
|
|
4407
|
+
const list = document.createElement("div");
|
|
4408
|
+
list.className = "w100n-text-endnotes";
|
|
4409
|
+
list.contentEditable = "false";
|
|
4410
|
+
notes3.forEach((text, i) => {
|
|
4411
|
+
const p = list.appendChild(document.createElement("p"));
|
|
4412
|
+
p.appendChild(document.createElement("sup")).textContent = String(i + 1);
|
|
4413
|
+
p.append(text);
|
|
4414
|
+
});
|
|
4415
|
+
return list;
|
|
4416
|
+
}, { key: notes3.join("\n"), side: 1, ignoreSelection: true })]);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
})]
|
|
4420
|
+
});
|
|
4363
4421
|
headings = (doc, after) => {
|
|
4364
4422
|
const found = [];
|
|
4365
4423
|
doc.descendants((node, pos) => {
|
|
@@ -4385,8 +4443,8 @@ var init_extensions = __esm({
|
|
|
4385
4443
|
dom.className = "w100n-text-toc";
|
|
4386
4444
|
dom.contentEditable = "false";
|
|
4387
4445
|
const paint2 = () => {
|
|
4388
|
-
const
|
|
4389
|
-
const list = entries(editor.state.doc, this.options.relative,
|
|
4446
|
+
const at2 = getPos() ?? 0;
|
|
4447
|
+
const list = entries(editor.state.doc, this.options.relative, at2);
|
|
4390
4448
|
const head2 = document.createElement("b");
|
|
4391
4449
|
head2.textContent = this.options.label;
|
|
4392
4450
|
const items = list.map(([level, text], i) => {
|
|
@@ -4421,13 +4479,13 @@ var init_extensions = __esm({
|
|
|
4421
4479
|
return [new import_state2.Plugin({
|
|
4422
4480
|
appendTransaction(trs, _old, state) {
|
|
4423
4481
|
if (!trs.some((tr2) => tr2.docChanged && !tr2.getMeta(import_y_tiptap.ySyncPluginKey))) return null;
|
|
4424
|
-
const
|
|
4482
|
+
const at2 = [];
|
|
4425
4483
|
state.doc.forEach((node, pos) => {
|
|
4426
|
-
if (node.type.name === "toc")
|
|
4484
|
+
if (node.type.name === "toc") at2.push(pos);
|
|
4427
4485
|
});
|
|
4428
|
-
if (!
|
|
4486
|
+
if (!at2.length) return null;
|
|
4429
4487
|
const tr = state.tr;
|
|
4430
|
-
for (const pos of
|
|
4488
|
+
for (const pos of at2) {
|
|
4431
4489
|
const fresh2 = JSON.stringify(entries(state.doc, relative2, pos));
|
|
4432
4490
|
if (state.doc.nodeAt(pos).attrs.entries !== fresh2) tr.setNodeAttribute(pos, "entries", fresh2);
|
|
4433
4491
|
}
|
|
@@ -4471,10 +4529,10 @@ var init_extensions = __esm({
|
|
|
4471
4529
|
const { state } = view;
|
|
4472
4530
|
const tr = state.tr;
|
|
4473
4531
|
if (to > from) strike(tr, state, from, to);
|
|
4474
|
-
const
|
|
4532
|
+
const at2 = tr.mapping.map(to);
|
|
4475
4533
|
const kept = (state.storedMarks ?? state.doc.resolve(from).marks()).filter((m) => m.type.name !== "insertion" && m.type.name !== "deletion");
|
|
4476
|
-
tr.insert(
|
|
4477
|
-
tr.setSelection(import_state2.TextSelection.create(tr.doc,
|
|
4534
|
+
tr.insert(at2, state.schema.text(text, [...kept, stamp(state, "insertion", from, to)]));
|
|
4535
|
+
tr.setSelection(import_state2.TextSelection.create(tr.doc, at2 + text.length));
|
|
4478
4536
|
view.dispatch(tr.scrollIntoView());
|
|
4479
4537
|
return true;
|
|
4480
4538
|
};
|
|
@@ -4498,16 +4556,16 @@ var init_extensions = __esm({
|
|
|
4498
4556
|
if (!suggesting.getState(state).on || event.key !== "Backspace" && event.key !== "Delete" || event.metaKey || event.ctrlKey || event.altKey) return false;
|
|
4499
4557
|
const { from, to, empty, $from } = state.selection;
|
|
4500
4558
|
const back = event.key === "Backspace";
|
|
4501
|
-
let
|
|
4559
|
+
let at2 = from;
|
|
4502
4560
|
if (empty) {
|
|
4503
4561
|
const skip3 = (pos) => state.doc.resolve(pos)[back ? "nodeBefore" : "nodeAfter"]?.marks.some((m) => m.type.name === "deletion");
|
|
4504
|
-
while (skip3(
|
|
4505
|
-
if (back ?
|
|
4562
|
+
while (skip3(at2)) at2 += back ? -1 : 1;
|
|
4563
|
+
if (back ? at2 <= $from.start() : at2 >= $from.end()) return false;
|
|
4506
4564
|
}
|
|
4507
4565
|
const tr = state.tr;
|
|
4508
|
-
if (empty) strike(tr, state, back ?
|
|
4566
|
+
if (empty) strike(tr, state, back ? at2 - 1 : at2, back ? at2 : at2 + 1);
|
|
4509
4567
|
else strike(tr, state, from, to);
|
|
4510
|
-
const caret = empty ? tr.mapping.map(back ?
|
|
4568
|
+
const caret = empty ? tr.mapping.map(back ? at2 - 1 : at2 + 1, back ? -1 : 1) : tr.mapping.map(back ? from : to);
|
|
4511
4569
|
tr.setSelection(import_state2.TextSelection.create(tr.doc, caret));
|
|
4512
4570
|
view.dispatch(tr.scrollIntoView());
|
|
4513
4571
|
return true;
|
|
@@ -4579,10 +4637,10 @@ var init_extensions = __esm({
|
|
|
4579
4637
|
const { $from, empty } = view.state.selection;
|
|
4580
4638
|
if (!back && event.key !== "Delete" || !empty || $from.depth < 1) return false;
|
|
4581
4639
|
if (back ? $from.parentOffset !== 0 : $from.parentOffset !== $from.parent.content.size) return false;
|
|
4582
|
-
const
|
|
4583
|
-
const node = back ? view.state.doc.resolve(
|
|
4640
|
+
const at2 = back ? $from.before() : $from.after();
|
|
4641
|
+
const node = back ? view.state.doc.resolve(at2).nodeBefore : view.state.doc.resolve(at2).nodeAfter;
|
|
4584
4642
|
if (!node || !locked(node)) return false;
|
|
4585
|
-
view.dispatch(view.state.tr.delete(back ?
|
|
4643
|
+
view.dispatch(view.state.tr.delete(back ? at2 - node.nodeSize : at2, back ? at2 : at2 + node.nodeSize));
|
|
4586
4644
|
return true;
|
|
4587
4645
|
}
|
|
4588
4646
|
}
|
|
@@ -4656,7 +4714,7 @@ var init_extensions = __esm({
|
|
|
4656
4714
|
var version;
|
|
4657
4715
|
var init_package = __esm({
|
|
4658
4716
|
"package.json"() {
|
|
4659
|
-
version = "0.
|
|
4717
|
+
version = "0.16.0";
|
|
4660
4718
|
}
|
|
4661
4719
|
});
|
|
4662
4720
|
|
|
@@ -4681,6 +4739,8 @@ function inline3(tokens = [], outer = []) {
|
|
|
4681
4739
|
else if (token2.type === "del") wrap(token2.tokens, { type: "strike" });
|
|
4682
4740
|
else if (token2.type === "codespan") text(token2.text, [{ type: "code" }]);
|
|
4683
4741
|
else if (token2.type === "br") out.push({ type: "hardBreak" });
|
|
4742
|
+
else if (token2.type === "math") out.push({ type: "math", attrs: { latex: token2.text } });
|
|
4743
|
+
else if (token2.type === "footnoteRef") out.push({ type: "footnote", attrs: { id: token2.id, text: notes2.get(token2.id) ?? "" } });
|
|
4684
4744
|
else if (token2.type === "link") wrap(token2.tokens, { type: "link", attrs: { href: token2.href } });
|
|
4685
4745
|
else if (token2.type === "image") out.push({ type: "image", attrs: { src: token2.href, alt: token2.text || null, title: token2.title || null }, ...marks2().length ? { marks: marks2() } : {} });
|
|
4686
4746
|
else if (token2.type === "html") {
|
|
@@ -4703,7 +4763,15 @@ function block(token2, hints) {
|
|
|
4703
4763
|
case "space":
|
|
4704
4764
|
case "def":
|
|
4705
4765
|
case "checkbox":
|
|
4766
|
+
case "footnoteDef":
|
|
4706
4767
|
return [];
|
|
4768
|
+
case "html": {
|
|
4769
|
+
const m = /^\s*<(p|h[1-6])\s+align="(center|right|justify)"\s*>([\s\S]*?)<\/\1>\s*$/i.exec(token2.raw);
|
|
4770
|
+
if (!m) return [{ type: "codeBlock", attrs: { language: "html" }, content: [{ type: "text", text: token2.raw.replace(/\n+$/, "") }] }];
|
|
4771
|
+
const content = inline3(marked.Lexer.lexInline(m[3].trim(), marked.defaults));
|
|
4772
|
+
const level = Number(m[1][1]);
|
|
4773
|
+
return [level ? { type: "heading", attrs: { level, align: m[2] }, content } : { type: "paragraph", attrs: { align: m[2] }, content }];
|
|
4774
|
+
}
|
|
4707
4775
|
case "heading":
|
|
4708
4776
|
return [{ type: "heading", attrs: { level: token2.depth }, content: inline3(token2.tokens) }];
|
|
4709
4777
|
case "paragraph":
|
|
@@ -4715,8 +4783,6 @@ function block(token2, hints) {
|
|
|
4715
4783
|
const fence = /^ {0,3}(`{3,}|~{3,})/.exec(token2.raw)?.[1][0];
|
|
4716
4784
|
return [{ type: "codeBlock", attrs: { language: token2.lang || null, ref: fence ? ref({ fence: fence.repeat(3) }) : null }, content: token2.text ? [{ type: "text", text: token2.text }] : [] }];
|
|
4717
4785
|
}
|
|
4718
|
-
case "html":
|
|
4719
|
-
return [{ type: "codeBlock", attrs: { language: "html" }, content: [{ type: "text", text: token2.raw.replace(/\n+$/, "") }] }];
|
|
4720
4786
|
case "hr":
|
|
4721
4787
|
return [{ type: "horizontalRule" }];
|
|
4722
4788
|
case "list": {
|
|
@@ -4746,6 +4812,21 @@ function block(token2, hints) {
|
|
|
4746
4812
|
return [{ type: "paragraph", content: inline3([{ type: "text", raw: token2.raw, text: token2.raw }]) }];
|
|
4747
4813
|
}
|
|
4748
4814
|
}
|
|
4815
|
+
function aligned(tokens, i, hints) {
|
|
4816
|
+
const m = tokens[i].type === "html" ? /^\s*<div\s+align="(center|right|justify)"\s*>\s*$/i.exec(tokens[i].raw) : null;
|
|
4817
|
+
if (!m) return null;
|
|
4818
|
+
let j = i + 1;
|
|
4819
|
+
const skip3 = () => {
|
|
4820
|
+
while (tokens[j]?.type === "space") j++;
|
|
4821
|
+
};
|
|
4822
|
+
skip3();
|
|
4823
|
+
const inner2 = tokens[j]?.type === "paragraph" || tokens[j]?.type === "heading" ? tokens[j++] : null;
|
|
4824
|
+
skip3();
|
|
4825
|
+
if (!inner2 || tokens[j]?.type !== "html" || !/^\s*<\/div>\s*$/i.test(tokens[j].raw)) return null;
|
|
4826
|
+
const made2 = block(inner2, hints);
|
|
4827
|
+
made2[0].attrs = { ...made2[0].attrs, align: m[1] };
|
|
4828
|
+
return { end: j, made: made2 };
|
|
4829
|
+
}
|
|
4749
4830
|
function contents2(tokens, i) {
|
|
4750
4831
|
if (tokens[i].type !== "html" || !opens.test(tokens[i].raw)) return null;
|
|
4751
4832
|
let j = i + 1;
|
|
@@ -4770,7 +4851,7 @@ function sniff(tokens) {
|
|
|
4770
4851
|
style[key2] = value3;
|
|
4771
4852
|
};
|
|
4772
4853
|
let loose = 0;
|
|
4773
|
-
|
|
4854
|
+
marked.walkTokens(tokens, (token2) => {
|
|
4774
4855
|
if (token2.type === "list") {
|
|
4775
4856
|
const marker = /^\s*(?:([-*+])|\d+([.)]))/.exec(token2.raw);
|
|
4776
4857
|
if (token2.ordered) note("delim", marker?.[2] ?? ".");
|
|
@@ -4787,7 +4868,11 @@ function sniff(tokens) {
|
|
|
4787
4868
|
function fromMarkdown(source) {
|
|
4788
4869
|
const bom = source.startsWith("\uFEFF");
|
|
4789
4870
|
const crlf = source.includes("\r\n");
|
|
4790
|
-
const tokens =
|
|
4871
|
+
const tokens = marked.lexer(source.slice(bom ? 1 : 0).replace(/\r\n?/g, "\n"));
|
|
4872
|
+
notes2 = /* @__PURE__ */ new Map();
|
|
4873
|
+
marked.walkTokens(tokens, (token2) => {
|
|
4874
|
+
if (token2.type === "footnoteDef") notes2.set(token2.id, token2.text);
|
|
4875
|
+
});
|
|
4791
4876
|
const hints = {};
|
|
4792
4877
|
const content = [];
|
|
4793
4878
|
const raws2 = [];
|
|
@@ -4795,8 +4880,8 @@ function fromMarkdown(source) {
|
|
|
4795
4880
|
let gap = "";
|
|
4796
4881
|
for (let i = 0; i < tokens.length; i++) {
|
|
4797
4882
|
const token2 = tokens[i];
|
|
4798
|
-
const toc = contents2(tokens, i);
|
|
4799
|
-
const made2 = toc ? [{ type: "toc", attrs: { entries: JSON.stringify(toc.entries) } }] : block(token2, hints);
|
|
4883
|
+
const toc = contents2(tokens, i) ?? aligned(tokens, i, hints);
|
|
4884
|
+
const made2 = toc ? "made" in toc ? toc.made : [{ type: "toc", attrs: { entries: JSON.stringify(toc.entries) } }] : block(token2, hints);
|
|
4800
4885
|
if (!made2.length) {
|
|
4801
4886
|
gap += token2.raw;
|
|
4802
4887
|
continue;
|
|
@@ -4835,17 +4920,36 @@ function serializer(style, hints, before, cell2 = false) {
|
|
|
4835
4920
|
const bullet = hint(node).bullet ?? (run3(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
|
|
4836
4921
|
tight(state, node, () => state.renderList(node, " ", () => `${bullet} `));
|
|
4837
4922
|
};
|
|
4923
|
+
const aligned2 = (state, node, render) => {
|
|
4924
|
+
const side2 = cell2 ? null : node.attrs.align;
|
|
4925
|
+
if (side2 && side2 !== "left") {
|
|
4926
|
+
state.write(`<div align="${side2}">`);
|
|
4927
|
+
state.closeBlock(node);
|
|
4928
|
+
}
|
|
4929
|
+
render();
|
|
4930
|
+
state.closeBlock(node);
|
|
4931
|
+
if (side2 && side2 !== "left") {
|
|
4932
|
+
state.write("</div>");
|
|
4933
|
+
state.closeBlock(node);
|
|
4934
|
+
}
|
|
4935
|
+
};
|
|
4838
4936
|
const blank6 = { open: "", close: "", mixable: true };
|
|
4839
4937
|
const wrap = (open, close = open) => ({ open, close, mixable: true, expelEnclosingWhitespace: true });
|
|
4840
4938
|
return new import_prosemirror_markdown.MarkdownSerializer({
|
|
4841
4939
|
paragraph(state, node) {
|
|
4842
|
-
state.renderInline(node);
|
|
4843
|
-
state.closeBlock(node);
|
|
4940
|
+
aligned2(state, node, () => state.renderInline(node));
|
|
4844
4941
|
},
|
|
4845
4942
|
heading(state, node) {
|
|
4846
|
-
state
|
|
4847
|
-
|
|
4848
|
-
|
|
4943
|
+
aligned2(state, node, () => {
|
|
4944
|
+
state.write(`${"#".repeat(node.attrs.level)} `);
|
|
4945
|
+
state.renderInline(node, false);
|
|
4946
|
+
});
|
|
4947
|
+
},
|
|
4948
|
+
math(state, node, parent) {
|
|
4949
|
+
state.write(parent.childCount === 1 ? `$$${node.attrs.latex}$$` : `$${node.attrs.latex}$`);
|
|
4950
|
+
},
|
|
4951
|
+
footnote(state, node) {
|
|
4952
|
+
state.write(`[^${node.attrs.id}]`);
|
|
4849
4953
|
},
|
|
4850
4954
|
blockquote(state, node) {
|
|
4851
4955
|
state.wrapBlock("> ", null, node, () => state.renderContent(node));
|
|
@@ -4965,31 +5069,66 @@ function toMarkdown(doc, base) {
|
|
|
4965
5069
|
nodes.push(node);
|
|
4966
5070
|
found.push(k);
|
|
4967
5071
|
});
|
|
4968
|
-
|
|
5072
|
+
const now = refs(nodes), was = refs(base.nodes);
|
|
5073
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
5074
|
+
const fix = (text2) => now.size || was.size ? text2.replace(defs, (all, id, note) => {
|
|
5075
|
+
if (!now.has(id)) return was.has(id) ? "" : all;
|
|
5076
|
+
seen2.add(id);
|
|
5077
|
+
return noteOf(note) === now.get(id) ? all : `[^${id}]: ${now.get(id).replace(/\n/g, "\n ")}
|
|
5078
|
+
`;
|
|
5079
|
+
}) : text2;
|
|
5080
|
+
const kept = new Set(found);
|
|
5081
|
+
const lost = base.raws.filter((_, m) => !kept.has(m)).flatMap((raw) => marked.lexer(raw).filter((t) => t.type === "def" || t.type === "footnoteDef").map((t) => t.raw.replace(/\n*$/, "\n"))).join("");
|
|
5082
|
+
let out = fix(base.head);
|
|
4969
5083
|
const starts = [];
|
|
4970
5084
|
nodes.forEach((node, i) => {
|
|
4971
5085
|
const k = found[i];
|
|
4972
5086
|
if (i && !(k >= 0 && found[i - 1] === k - 1)) out = out.replace(/\n*$/, "\n\n");
|
|
4973
5087
|
starts.push(out.length);
|
|
4974
|
-
out += k >= 0 ? base.raws[k] : one(node, i ? nodes[i - 1] : null, base);
|
|
5088
|
+
out += k >= 0 ? fix(base.raws[k]) : one(node, i ? nodes[i - 1] : null, base);
|
|
4975
5089
|
});
|
|
4976
5090
|
const last2 = found[found.length - 1];
|
|
4977
5091
|
const end = last2 >= 0 && last2 === base.nodes.length - 1;
|
|
4978
5092
|
if (!end) out = out.replace(/\n*$/, "\n");
|
|
4979
5093
|
const cut = out.length;
|
|
4980
|
-
out += end ? base.tail : base.tail.trim() ? `
|
|
4981
|
-
${base.tail.replace(/^\n+/, "")}` : "";
|
|
4982
|
-
const
|
|
4983
|
-
|
|
5094
|
+
out += fix(end ? base.tail : base.tail.trim() ? `
|
|
5095
|
+
${base.tail.replace(/^\n+/, "")}` : "");
|
|
5096
|
+
const extra = fix(lost) + [...now].filter(([id]) => !seen2.has(id)).map(([id, note]) => `[^${id}]: ${note.replace(/\n/g, "\n ")}
|
|
5097
|
+
`).join("");
|
|
5098
|
+
if (extra) out = `${out.replace(/\n*$/, "\n\n")}${extra}`;
|
|
5099
|
+
const at2 = starts.map((s) => Math.min(s, cut));
|
|
5100
|
+
const raws2 = at2.map((s, i) => out.slice(s, i + 1 < at2.length ? at2[i + 1] : cut));
|
|
4984
5101
|
const text = base.crlf ? out.replace(/\n/g, "\r\n") : out;
|
|
4985
5102
|
return { text: base.bom ? `\uFEFF${text}` : text, base: { ...base, nodes, raws: raws2, tail: out.slice(cut) } };
|
|
4986
5103
|
}
|
|
4987
|
-
var import_marked, import_prosemirror_markdown, tags, decode2, unique, fill, opens, shuts, row, slug, track, ticks, plain2, one;
|
|
5104
|
+
var import_marked, import_prosemirror_markdown, def, defs, noteOf, at, marked, notes2, tags, decode2, unique, fill, opens, shuts, row, slug, track, ticks, plain2, one, refs;
|
|
4988
5105
|
var init_markdown = __esm({
|
|
4989
5106
|
"src/editor/markdown.ts"() {
|
|
4990
5107
|
"use strict";
|
|
4991
5108
|
import_marked = require("marked");
|
|
4992
5109
|
import_prosemirror_markdown = require("prosemirror-markdown");
|
|
5110
|
+
def = /^\[\^([^\]\s]+)\]:[ \t]*([^\n]*(?:\n {4}[^\n]*)*)(?:\n|$)/;
|
|
5111
|
+
defs = new RegExp(def.source.slice(1), "gm");
|
|
5112
|
+
noteOf = (text) => text.replace(/\n {4}/g, "\n").trim();
|
|
5113
|
+
at = (src, find3) => {
|
|
5114
|
+
const i = src.search(find3);
|
|
5115
|
+
return i < 0 ? void 0 : i;
|
|
5116
|
+
};
|
|
5117
|
+
marked = new import_marked.Marked({ extensions: [
|
|
5118
|
+
{ name: "footnoteDef", level: "block", start: (src) => at(src, /^\[\^/m), tokenizer(src) {
|
|
5119
|
+
const m = def.exec(src);
|
|
5120
|
+
return m ? { type: "footnoteDef", raw: m[0], id: m[1], text: noteOf(m[2]) } : void 0;
|
|
5121
|
+
} },
|
|
5122
|
+
{ name: "footnoteRef", level: "inline", start: (src) => at(src, /\[\^/), tokenizer(src) {
|
|
5123
|
+
const m = /^\[\^([^\]\s]+)\]/.exec(src);
|
|
5124
|
+
return m ? { type: "footnoteRef", raw: m[0], id: m[1] } : void 0;
|
|
5125
|
+
} },
|
|
5126
|
+
{ name: "math", level: "inline", start: (src) => at(src, /\$/), tokenizer(src) {
|
|
5127
|
+
const m = /^\$\$([^$]+?)\$\$|^\$(?![\s$])((?:\\.|[^$\\\n])*?[^\s\\])\$(?!\d)/.exec(src);
|
|
5128
|
+
return m ? { type: "math", raw: m[0], text: (m[1] ?? m[2]).trim() } : void 0;
|
|
5129
|
+
} }
|
|
5130
|
+
] });
|
|
5131
|
+
notes2 = /* @__PURE__ */ new Map();
|
|
4993
5132
|
tags = { u: "underline", ins: "underline", mark: "highlight", s: "strike", del: "strike", b: "bold", strong: "bold", i: "italic", em: "italic" };
|
|
4994
5133
|
decode2 = (text) => text.includes("&") ? new DOMParser().parseFromString(`<p>${text.replace(/</g, "<")}</p>`, "text/html").body.textContent ?? text : text;
|
|
4995
5134
|
unique = (marks2) => [...new Map(marks2.map((m) => [m.type, m])).values()];
|
|
@@ -5025,12 +5164,19 @@ var init_markdown = __esm({
|
|
|
5025
5164
|
return /^[\s(*_~]?$/.test(left) && /^([\s)]|[.,:;!?]+(\s|$)|$)/.test(right) ? "bare" : text === href || href.startsWith("mailto:") ? "angle" : null;
|
|
5026
5165
|
};
|
|
5027
5166
|
one = (node, before, base) => serializer(base.style, base.hints, before).serialize(node.type.schema.topNodeType.create(null, node)).replace(/\n+$/, "");
|
|
5167
|
+
refs = (nodes) => {
|
|
5168
|
+
const found = /* @__PURE__ */ new Map();
|
|
5169
|
+
nodes.forEach((n) => n.descendants((d) => {
|
|
5170
|
+
if (d.type.name === "footnote" && d.attrs.id) found.set(d.attrs.id, d.attrs.text);
|
|
5171
|
+
}));
|
|
5172
|
+
return found;
|
|
5173
|
+
};
|
|
5028
5174
|
}
|
|
5029
5175
|
});
|
|
5030
5176
|
|
|
5031
5177
|
// src/sheets/model.ts
|
|
5032
|
-
function insert(list,
|
|
5033
|
-
list.splice(
|
|
5178
|
+
function insert(list, at2, count, prefix) {
|
|
5179
|
+
list.splice(at2, 0, ...Array.from({ length: count }, () => fresh(prefix)));
|
|
5034
5180
|
}
|
|
5035
5181
|
function move(list, from, count, to) {
|
|
5036
5182
|
const taken = list.splice(from, count);
|
|
@@ -5096,12 +5242,12 @@ function encode(text, encoding, bom) {
|
|
|
5096
5242
|
if (encoding === "utf-16le" || encoding === "utf-16be") {
|
|
5097
5243
|
const out2 = new Uint8Array(text.length * 2 + (bom ? 2 : 0));
|
|
5098
5244
|
const view = new DataView(out2.buffer);
|
|
5099
|
-
let
|
|
5245
|
+
let at2 = 0;
|
|
5100
5246
|
if (bom) {
|
|
5101
5247
|
view.setUint16(0, 65279, encoding === "utf-16le");
|
|
5102
|
-
|
|
5248
|
+
at2 = 2;
|
|
5103
5249
|
}
|
|
5104
|
-
for (let i = 0; i < text.length; i++) view.setUint16(
|
|
5250
|
+
for (let i = 0; i < text.length; i++) view.setUint16(at2 + i * 2, text.charCodeAt(i), encoding === "utf-16le");
|
|
5105
5251
|
return out2;
|
|
5106
5252
|
}
|
|
5107
5253
|
const table3 = /* @__PURE__ */ new Map();
|
|
@@ -5387,7 +5533,7 @@ function squeeze(b, rows, cols) {
|
|
|
5387
5533
|
const r = edge(b.startRow, b.endRow, rows, MAX_ROW), c = edge(b.startColumn, b.endColumn, cols, MAX_COL);
|
|
5388
5534
|
return r && c ? { startRow: r[0], endRow: r[1], startColumn: c[0], endColumn: c[1] } : null;
|
|
5389
5535
|
}
|
|
5390
|
-
function
|
|
5536
|
+
function refs2(formula, visit) {
|
|
5391
5537
|
let sheet2 = null;
|
|
5392
5538
|
let outside = false;
|
|
5393
5539
|
let last2 = 0;
|
|
@@ -5419,7 +5565,7 @@ function refs(formula, visit) {
|
|
|
5419
5565
|
return out + formula.slice(last2);
|
|
5420
5566
|
}
|
|
5421
5567
|
function shifted(formula, dr, dc) {
|
|
5422
|
-
return
|
|
5568
|
+
return refs2(formula, (p) => {
|
|
5423
5569
|
const ends = p.text.split(":").map(side);
|
|
5424
5570
|
if (ends.some((e) => !e)) return p.text;
|
|
5425
5571
|
for (const e of ends) {
|
|
@@ -5431,7 +5577,7 @@ function shifted(formula, dr, dc) {
|
|
|
5431
5577
|
});
|
|
5432
5578
|
}
|
|
5433
5579
|
function remapped(formula, mine, rows, cols) {
|
|
5434
|
-
return
|
|
5580
|
+
return refs2(formula, (p) => {
|
|
5435
5581
|
if (!mine(p.sheet)) return p.text;
|
|
5436
5582
|
const b = box(p.text);
|
|
5437
5583
|
const ends = p.text.split(":").map(side);
|
|
@@ -5833,8 +5979,8 @@ var init_styles = __esm({
|
|
|
5833
5979
|
return index;
|
|
5834
5980
|
}
|
|
5835
5981
|
add(list, xml) {
|
|
5836
|
-
const
|
|
5837
|
-
if (
|
|
5982
|
+
const at2 = this[list].indexOf(xml);
|
|
5983
|
+
if (at2 >= 0) return at2;
|
|
5838
5984
|
this[list].push(xml);
|
|
5839
5985
|
this.added = true;
|
|
5840
5986
|
return this[list].length - 1;
|
|
@@ -5913,8 +6059,8 @@ var init_styles = __esm({
|
|
|
5913
6059
|
edits2.push([el.start, el.end, `${open} count="${lists[name].length}">${lists[name].join("")}</${el.name}>`]);
|
|
5914
6060
|
} else {
|
|
5915
6061
|
const after = root.kids.find((k) => order2.indexOf(this.bare(k.name)) > order2.indexOf(name));
|
|
5916
|
-
const
|
|
5917
|
-
edits2.push([
|
|
6062
|
+
const at2 = after ? after.start : root.close;
|
|
6063
|
+
edits2.push([at2, at2, `<${p}${name} count="${lists[name].length}">${lists[name].join("")}</${p}${name}>`]);
|
|
5918
6064
|
}
|
|
5919
6065
|
}
|
|
5920
6066
|
edits2.sort((x, y) => y[0] - x[0]);
|
|
@@ -5976,7 +6122,7 @@ function load2(bytes) {
|
|
|
5976
6122
|
defaultStyle: styles2.looks[0]
|
|
5977
6123
|
};
|
|
5978
6124
|
if (date1904) book.dateSystem = "date1904";
|
|
5979
|
-
const
|
|
6125
|
+
const notes3 = {};
|
|
5980
6126
|
const validations = {};
|
|
5981
6127
|
const filters = {};
|
|
5982
6128
|
const model = { book, lines: {}, origin: { sheets: {}, lines: {} } };
|
|
@@ -6040,13 +6186,13 @@ function load2(bytes) {
|
|
|
6040
6186
|
let maxRow = -1, maxCol = -1;
|
|
6041
6187
|
if (open && open.close > open.open) {
|
|
6042
6188
|
const end = open.close;
|
|
6043
|
-
let
|
|
6044
|
-
while (
|
|
6045
|
-
const lt = sxml.indexOf("<",
|
|
6189
|
+
let at2 = open.open, row2 = -1, col = -1;
|
|
6190
|
+
while (at2 < end) {
|
|
6191
|
+
const lt = sxml.indexOf("<", at2);
|
|
6046
6192
|
if (lt < 0 || lt >= end) break;
|
|
6047
6193
|
const gt = sxml.indexOf(">", lt);
|
|
6048
6194
|
if (sxml.charCodeAt(lt + 1) === 47) {
|
|
6049
|
-
|
|
6195
|
+
at2 = gt + 1;
|
|
6050
6196
|
continue;
|
|
6051
6197
|
}
|
|
6052
6198
|
let j = lt + 1;
|
|
@@ -6074,11 +6220,11 @@ function load2(bytes) {
|
|
|
6074
6220
|
}
|
|
6075
6221
|
if (Object.keys(rd).length) rowData[row2] = rd;
|
|
6076
6222
|
if (rd.h !== void 0 || rd.hd || rd.s) maxRow = Math.max(maxRow, row2);
|
|
6077
|
-
|
|
6223
|
+
at2 = gt + 1;
|
|
6078
6224
|
continue;
|
|
6079
6225
|
}
|
|
6080
6226
|
if (name !== "c") {
|
|
6081
|
-
|
|
6227
|
+
at2 = gt + 1;
|
|
6082
6228
|
continue;
|
|
6083
6229
|
}
|
|
6084
6230
|
const ref = attr2(tag, "r");
|
|
@@ -6142,7 +6288,7 @@ function load2(bytes) {
|
|
|
6142
6288
|
}
|
|
6143
6289
|
}
|
|
6144
6290
|
cells.set(key(row2, col), { start: lt, end: stop, shared });
|
|
6145
|
-
|
|
6291
|
+
at2 = stop;
|
|
6146
6292
|
}
|
|
6147
6293
|
}
|
|
6148
6294
|
for (const [r, c, si] of children) {
|
|
@@ -6190,7 +6336,7 @@ function load2(bytes) {
|
|
|
6190
6336
|
sheetNotes.push(note);
|
|
6191
6337
|
const [r, c] = cell(ref);
|
|
6192
6338
|
if (r < 0) continue;
|
|
6193
|
-
((_b =
|
|
6339
|
+
((_b = notes3[sid] ?? (notes3[sid] = {}))[r] ?? (_b[r] = {}))[c] = { note: note.text, width: 160, height: 72, show: false, id: `n${sheetNotes.length - 1}`, row: r, col: c };
|
|
6194
6340
|
maxRow = Math.max(maxRow, r);
|
|
6195
6341
|
maxCol = Math.max(maxCol, c);
|
|
6196
6342
|
}
|
|
@@ -6247,7 +6393,7 @@ function load2(bytes) {
|
|
|
6247
6393
|
}
|
|
6248
6394
|
const resources = book.resources;
|
|
6249
6395
|
if (Object.keys(names2).length) resources.push({ name: "SHEET_DEFINED_NAME_PLUGIN", data: JSON.stringify(names2) });
|
|
6250
|
-
if (Object.keys(
|
|
6396
|
+
if (Object.keys(notes3).length) resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes3) });
|
|
6251
6397
|
if (Object.keys(validations).length) resources.push({ name: "SHEET_DATA_VALIDATION_PLUGIN", data: JSON.stringify(validations) });
|
|
6252
6398
|
if (Object.keys(filters).length) resources.push({ name: "SHEET_FILTER_PLUGIN", data: JSON.stringify(filters) });
|
|
6253
6399
|
const shown = entries2[active];
|
|
@@ -6375,14 +6521,14 @@ function place(xml, name, value3) {
|
|
|
6375
6521
|
if (found) return xml.slice(0, found.start) + (value3 ?? "") + xml.slice(found.end);
|
|
6376
6522
|
if (value3 === null) return xml;
|
|
6377
6523
|
const rank = order.indexOf(name);
|
|
6378
|
-
let
|
|
6524
|
+
let at2 = -1;
|
|
6379
6525
|
for (const later of order.slice(rank + 1)) {
|
|
6380
6526
|
const f = find2(xml, later);
|
|
6381
|
-
if (f && (
|
|
6527
|
+
if (f && (at2 < 0 || f.start < at2)) at2 = f.start;
|
|
6382
6528
|
}
|
|
6383
|
-
if (
|
|
6384
|
-
if (
|
|
6385
|
-
return xml.slice(0,
|
|
6529
|
+
if (at2 < 0) at2 = xml.search(/<\/(?:\w+:)?worksheet>\s*$/);
|
|
6530
|
+
if (at2 < 0) at2 = xml.length;
|
|
6531
|
+
return xml.slice(0, at2) + value3 + xml.slice(at2);
|
|
6386
6532
|
}
|
|
6387
6533
|
function remapZone(xml, mine, rows, cols) {
|
|
6388
6534
|
const ranges = (sqref) => boxes2(sqref).map((b) => squeeze(b, rows.map, cols.map)).filter((b) => b !== null).map(span).join(" ");
|
|
@@ -6633,12 +6779,12 @@ function writeXlsx(original, model) {
|
|
|
6633
6779
|
tail = place(tail, "autoFilter", filter?.ref ? filterXml(p, filter.ref, filter.filterColumns ?? []) : null);
|
|
6634
6780
|
filterNames.set(entry2.sheetId, filter?.ref ? `${quoted(sheet2.name)}!${span(filter.ref).split(":").map((s) => s.replace(/([A-Z]+)(\d+)/, "$$$1$$$2")).join(":")}` : null);
|
|
6635
6781
|
}
|
|
6636
|
-
const
|
|
6782
|
+
const notes3 = Object.values(curNotes?.[sid] ?? {}).flatMap((line) => Object.values(line ?? {})).filter((n) => n && !blank3(n.note));
|
|
6637
6783
|
const oldNotes = (rec?.notes ?? []).map((n) => ({ ref: n.ref, text: n.text }));
|
|
6638
|
-
const nowNotes =
|
|
6784
|
+
const nowNotes = notes3.map((n) => ({ ref: a1(n.row, n.col), text: n.note })).sort((a, b) => a.ref.localeCompare(b.ref));
|
|
6639
6785
|
if (curNotes && !same2(nowNotes, [...oldNotes].sort((a, b) => a.ref.localeCompare(b.ref)))) {
|
|
6640
6786
|
changed2 = true;
|
|
6641
|
-
tail = writeNotes(book, entry2, tail, p,
|
|
6787
|
+
tail = writeNotes(book, entry2, tail, p, notes3, rows, cols, types2, defaultsNeeded, fresh2);
|
|
6642
6788
|
}
|
|
6643
6789
|
const rename = (s) => names2.size ? s.replace(/<(xm:f|(?:\w+:)?formula\d?)>([\s\S]*?)<\/\1>/g, (_, n, f) => `<${n}>${escape2([...names2].reduce((g, [from, to]) => renamed(g, from, to), unescape(f)))}</${n}>`) : s;
|
|
6644
6790
|
if (!changed2) {
|
|
@@ -6728,9 +6874,9 @@ function writeXlsx(original, model) {
|
|
|
6728
6874
|
listed2.push({ xml: tag, sheetId: s.sheetId, oldIndex: s.rec ? indexOf.get(s.sheetId) : -1 });
|
|
6729
6875
|
}
|
|
6730
6876
|
for (const { e, i } of nonSheets) {
|
|
6731
|
-
let
|
|
6732
|
-
if (
|
|
6733
|
-
listed2.splice(
|
|
6877
|
+
let at2 = listed2.findIndex((x) => x.oldIndex > i);
|
|
6878
|
+
if (at2 < 0) at2 = listed2.length;
|
|
6879
|
+
listed2.splice(at2, 0, { xml: e.xml, sheetId: e.sheetId, oldIndex: i });
|
|
6734
6880
|
}
|
|
6735
6881
|
wb = wb.replace(/(<(?:\w+:)?sheets\b[^>]*>)[\s\S]*?(<\/(?:\w+:)?sheets>)/, (_, a, b) => a + listed2.map((x) => x.xml).join("") + b);
|
|
6736
6882
|
const newIndex = new Map(listed2.map((x, i) => [x.oldIndex, i]));
|
|
@@ -6758,8 +6904,8 @@ function writeXlsx(original, model) {
|
|
|
6758
6904
|
});
|
|
6759
6905
|
for (const [sheetId, f] of filterNames) {
|
|
6760
6906
|
if (!f) continue;
|
|
6761
|
-
const
|
|
6762
|
-
wb = /<(?:\w+:)?definedNames\b/.test(wb) ? wb.replace(/<\/(?:\w+:)?definedNames>/, (end) =>
|
|
6907
|
+
const def2 = `<${wp}definedName name="_xlnm._FilterDatabase" localSheetId="${sheetIndex.get(sheetId)}" hidden="1">${escape2(f)}</${wp}definedName>`;
|
|
6908
|
+
wb = /<(?:\w+:)?definedNames\b/.test(wb) ? wb.replace(/<\/(?:\w+:)?definedNames>/, (end) => def2 + end) : wb.replace(/<\/(?:\w+:)?sheets>/, (end) => `${end}<${wp}definedNames>${def2}</${wp}definedNames>`);
|
|
6763
6909
|
}
|
|
6764
6910
|
wb = wb.replace(/<((?:\w+:)?)definedNames>\s*<\/\1definedNames>/, "");
|
|
6765
6911
|
wb = wb.replace(/<(?:\w+:)?workbookView\b[^>]*>/g, (tag) => {
|
|
@@ -6947,7 +7093,7 @@ function filterXml(p, ref, columns2) {
|
|
|
6947
7093
|
}).join("");
|
|
6948
7094
|
return body ? `<${p}autoFilter ref="${span(ref)}">${body}</${p}autoFilter>` : `<${p}autoFilter ref="${span(ref)}"/>`;
|
|
6949
7095
|
}
|
|
6950
|
-
function writeNotes(book, entry2, tail, p,
|
|
7096
|
+
function writeNotes(book, entry2, tail, p, notes3, rows, cols, types2, defaults, fresh2) {
|
|
6951
7097
|
const { pack } = book;
|
|
6952
7098
|
const rec = entry2.rec;
|
|
6953
7099
|
const relsPart = relsOf(entry2.part);
|
|
@@ -6974,7 +7120,7 @@ function writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaults,
|
|
|
6974
7120
|
const [r, c] = cell(n.ref);
|
|
6975
7121
|
return [a1(rows.map(r), cols.map(c)), n];
|
|
6976
7122
|
}));
|
|
6977
|
-
const list = [...
|
|
7123
|
+
const list = [...notes3].sort((a, b) => a.row - b.row || a.col - b.col).map((n) => {
|
|
6978
7124
|
const ref = a1(n.row, n.col);
|
|
6979
7125
|
const was = byOld.get(ref);
|
|
6980
7126
|
if (was && was.text === n.note) return setAttr(was.xml.slice(0, was.xml.indexOf(">") + 1), "ref", ref) + was.xml.slice(was.xml.indexOf(">") + 1);
|
|
@@ -6995,7 +7141,7 @@ function writeNotes(book, entry2, tail, p, notes2, rows, cols, types2, defaults,
|
|
|
6995
7141
|
return "";
|
|
6996
7142
|
});
|
|
6997
7143
|
let id = Math.max(1024, ...[...vml2.matchAll(/_x0000_s(\d+)/g)].map((m) => Number(m[1])));
|
|
6998
|
-
const out =
|
|
7144
|
+
const out = notes3.map((n) => {
|
|
6999
7145
|
const ref = a1(n.row, n.col);
|
|
7000
7146
|
const was = shapes.get(ref);
|
|
7001
7147
|
if (was) return was.replace(/<x:Row>\d+<\/x:Row>/, `<x:Row>${n.row}</x:Row>`).replace(/<x:Column>\d+<\/x:Column>/, `<x:Column>${n.col}</x:Column>`).replace(/<x:Anchor>([^<]*)<\/x:Anchor>/, `<x:Anchor>${n.col + 1}, 15, ${n.row}, 2, ${n.col + 3}, 15, ${n.row + 4}, 16</x:Anchor>`);
|
|
@@ -7132,7 +7278,7 @@ function made(config, lines2) {
|
|
|
7132
7278
|
function fill2(doc, model) {
|
|
7133
7279
|
const { book: wb, lines: lines2 } = model;
|
|
7134
7280
|
const book = doc.getMap("book");
|
|
7135
|
-
const
|
|
7281
|
+
const notes3 = JSON.parse(wb.resources?.find((r) => r.name === "SHEET_NOTE_PLUGIN")?.data ?? "{}");
|
|
7136
7282
|
doc.transact(() => {
|
|
7137
7283
|
book.set("head", strip({ id: wb.id, name: wb.name, appVersion: wb.appVersion, locale: wb.locale, defaultStyle: wb.defaultStyle, dateSystem: wb.dateSystem }));
|
|
7138
7284
|
book.set("extras", (wb.resources ?? []).filter((r) => r.name !== "SHEET_NOTE_PLUGIN"));
|
|
@@ -7150,23 +7296,23 @@ function fill2(doc, model) {
|
|
|
7150
7296
|
const { cells, rowData, colData, merges, notes: kept } = pieces(sheets.get(sid));
|
|
7151
7297
|
for (const [r, line] of Object.entries(sheet2.cellData ?? {})) for (const [c, x] of Object.entries(line ?? {})) {
|
|
7152
7298
|
if (!x) continue;
|
|
7153
|
-
const
|
|
7299
|
+
const at2 = spot2(l.rows[+r], l.cols[+c]);
|
|
7154
7300
|
const out = {};
|
|
7155
7301
|
if (x.f) {
|
|
7156
7302
|
out.f = x.f;
|
|
7157
|
-
values.set(`${sid}:${
|
|
7303
|
+
values.set(`${sid}:${at2}`, { v: x.v ?? null, t: x.t ?? null });
|
|
7158
7304
|
} else {
|
|
7159
7305
|
if (x.v !== void 0 && x.v !== null) out.v = x.v;
|
|
7160
7306
|
if (x.t) out.t = x.t;
|
|
7161
7307
|
}
|
|
7162
7308
|
if (x.p) out.p = x.p;
|
|
7163
7309
|
if (typeof x.s === "string") out.s = x.s;
|
|
7164
|
-
cells.set(
|
|
7310
|
+
cells.set(at2, out);
|
|
7165
7311
|
}
|
|
7166
7312
|
for (const [r, rd] of Object.entries(sheet2.rowData ?? {})) if (rd) rowData.set(l.rows[+r], strip({ h: rd.h, hd: rd.hd, ia: rd.ia, s: typeof rd.s === "string" ? rd.s : void 0 }));
|
|
7167
7313
|
for (const [c, cd] of Object.entries(sheet2.columnData ?? {})) if (cd) colData.set(l.cols[+c], strip({ w: cd.w, hd: cd.hd, s: typeof cd.s === "string" ? cd.s : void 0 }));
|
|
7168
7314
|
for (const b of sheet2.mergeData ?? []) merges.set([l.rows[b.startRow], l.cols[b.startColumn], l.rows[b.endRow], l.cols[b.endColumn]].join(":"), 1);
|
|
7169
|
-
for (const [r, line] of Object.entries(
|
|
7315
|
+
for (const [r, line] of Object.entries(notes3[sid] ?? {})) for (const [c, n] of Object.entries(line)) kept.set(spot2(l.rows[+r], l.cols[+c]), { note: n.note, width: n.width, height: n.height });
|
|
7170
7316
|
}
|
|
7171
7317
|
});
|
|
7172
7318
|
}
|
|
@@ -7176,11 +7322,11 @@ function sheetOf(doc, sid, l) {
|
|
|
7176
7322
|
const { cells, rowData, colData, merges } = pieces(m);
|
|
7177
7323
|
const rows = new Map(l.rows.map((id, i) => [id, i])), cols = new Map(l.cols.map((id, i) => [id, i]));
|
|
7178
7324
|
const cellData = {};
|
|
7179
|
-
for (const [
|
|
7180
|
-
const [row2, col] =
|
|
7325
|
+
for (const [at2, x] of cells) {
|
|
7326
|
+
const [row2, col] = at2.split(":");
|
|
7181
7327
|
const r = rows.get(row2), c = cols.get(col);
|
|
7182
7328
|
if (r === void 0 || c === void 0) continue;
|
|
7183
|
-
const kept = x.f ? values.get(`${sid}:${
|
|
7329
|
+
const kept = x.f ? values.get(`${sid}:${at2}`) : void 0;
|
|
7184
7330
|
(cellData[r] ?? (cellData[r] = {}))[c] = kept ? { ...x, v: kept.v, t: kept.t } : { ...x };
|
|
7185
7331
|
}
|
|
7186
7332
|
const rowsOut = {}, colsOut = {};
|
|
@@ -7196,7 +7342,7 @@ function build(doc) {
|
|
|
7196
7342
|
const sheetOrder = [...new Set(order2.toArray())].filter((sid) => sheets.has(sid));
|
|
7197
7343
|
const wb = { ...book.get("head"), styles: styles2.toJSON(), sheetOrder, sheets: {}, resources: [] };
|
|
7198
7344
|
const model = { book: wb, lines: {}, origin: { sheets: {}, lines: {} } };
|
|
7199
|
-
const
|
|
7345
|
+
const notes3 = {};
|
|
7200
7346
|
for (const sid of sheetOrder) {
|
|
7201
7347
|
const { rows, cols } = pieces(sheets.get(sid));
|
|
7202
7348
|
const l = { rows: rows.toArray(), cols: cols.toArray() };
|
|
@@ -7204,14 +7350,14 @@ function build(doc) {
|
|
|
7204
7350
|
wb.sheets[sid] = sheetOf(doc, sid, l);
|
|
7205
7351
|
notesOf2(sheets.get(sid), l).forEach((n, i) => {
|
|
7206
7352
|
var _a, _b;
|
|
7207
|
-
((_a =
|
|
7353
|
+
((_a = notes3[sid] ?? (notes3[sid] = {}))[_b = n.row] ?? (_a[_b] = {}))[n.col] = { ...n, show: false, id: `n${i}` };
|
|
7208
7354
|
});
|
|
7209
7355
|
const o = origin.get(sid);
|
|
7210
7356
|
if (!o) continue;
|
|
7211
7357
|
model.origin.sheets[sid] = o.id;
|
|
7212
7358
|
model.origin.lines[sid] = { rows: typeof o.rows === "number" ? numbered("r", o.rows) : o.rows, cols: typeof o.cols === "number" ? numbered("c", o.cols) : o.cols };
|
|
7213
7359
|
}
|
|
7214
|
-
wb.resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(
|
|
7360
|
+
wb.resources.push({ name: "SHEET_NOTE_PLUGIN", data: JSON.stringify(notes3) });
|
|
7215
7361
|
const active = book.get("active");
|
|
7216
7362
|
if (active && sheetOrder.includes(active)) model.active = active;
|
|
7217
7363
|
return model;
|
|
@@ -7293,7 +7439,7 @@ var init_shared = __esm({
|
|
|
7293
7439
|
});
|
|
7294
7440
|
notesOf2 = (m, l) => {
|
|
7295
7441
|
const rows = new Map(l.rows.map((id, i) => [id, i])), cols = new Map(l.cols.map((id, i) => [id, i]));
|
|
7296
|
-
return [...pieces(m).notes].map(([
|
|
7442
|
+
return [...pieces(m).notes].map(([at2, n]) => ({ ...n, row: rows.get(at2.split(":")[0]), col: cols.get(at2.split(":")[1]) })).filter((n) => n.row !== void 0 && n.col !== void 0);
|
|
7297
7443
|
};
|
|
7298
7444
|
}
|
|
7299
7445
|
});
|
|
@@ -7573,13 +7719,13 @@ async function save(doc, kind, base, put, load3, note) {
|
|
|
7573
7719
|
const bytes = await write3(kind, base, node, load3, doc.getMap("setup").size ? doc.getMap("setup").toJSON() : void 0);
|
|
7574
7720
|
const changed2 = !same3(bytes, base);
|
|
7575
7721
|
const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
|
|
7576
|
-
const
|
|
7722
|
+
const refs3 = [];
|
|
7577
7723
|
if (changed2) schema.nodeFromJSON(await parse4(kind, bytes)).descendants((n) => {
|
|
7578
|
-
if (n.isBlock)
|
|
7724
|
+
if (n.isBlock) refs3.push([n.type.name, n.attrs.ref ?? null]);
|
|
7579
7725
|
});
|
|
7580
7726
|
doc.transact(() => {
|
|
7581
|
-
if (
|
|
7582
|
-
const ref =
|
|
7727
|
+
if (refs3.length === list.length && list.every((el, i) => el.nodeName === refs3[i][0])) list.forEach((el, i) => {
|
|
7728
|
+
const ref = refs3[i][1];
|
|
7583
7729
|
if ((el.getAttribute("ref") ?? null) === ref) return;
|
|
7584
7730
|
if (ref === null) el.removeAttribute("ref");
|
|
7585
7731
|
else el.setAttribute("ref", ref);
|
|
@@ -7875,12 +8021,17 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7875
8021
|
const scroller = (0, import_react10.useRef)(null);
|
|
7876
8022
|
const root = (0, import_react10.useRef)(null);
|
|
7877
8023
|
const [pop, setPop] = (0, import_react10.useState)(null);
|
|
8024
|
+
const [spot3, setSpot] = (0, import_react10.useState)({ x: 0, y: 0 });
|
|
8025
|
+
const touch = (0, import_react10.useRef)(false);
|
|
8026
|
+
const [spell, setSpell] = (0, import_react10.useState)(() => typeof localStorage === "undefined" || localStorage.getItem("w100n-docs-spell") !== "0");
|
|
7878
8027
|
const [dialog, setDialog] = (0, import_react10.useState)(null);
|
|
7879
8028
|
const field = (0, import_react10.useRef)(null);
|
|
7880
8029
|
const [more, setMore] = (0, import_react10.useState)(() => typeof localStorage !== "undefined" && localStorage.getItem("w100n-docs-more") === "1");
|
|
7881
8030
|
const [zoom, setZoom] = (0, import_react10.useState)(null);
|
|
7882
8031
|
const [layout2, setLayout] = (0, import_react10.useState)(null);
|
|
7883
8032
|
const [room, setRoom] = (0, import_react10.useState)(0);
|
|
8033
|
+
const [printed, setPrinted] = (0, import_react10.useState)(null);
|
|
8034
|
+
const flow = docx2 && !(printed ?? !(room > 0 && room < 640));
|
|
7884
8035
|
const [saving, setSaving] = (0, import_react10.useState)("idle");
|
|
7885
8036
|
const [href, setHref] = (0, import_react10.useState)("");
|
|
7886
8037
|
const [grid3, setGrid] = (0, import_react10.useState)({ rows: 0, cols: 0 });
|
|
@@ -7911,7 +8062,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7911
8062
|
editable: can.edit && (!live || !!shared),
|
|
7912
8063
|
immediatelyRender: true,
|
|
7913
8064
|
shouldRerenderOnTransaction: false,
|
|
7914
|
-
editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText }, transformPastedHTML: cleanPaste },
|
|
8065
|
+
editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText, spellcheck: String(spell), lang: language }, transformPastedHTML: cleanPaste },
|
|
7915
8066
|
onCreate: ({ editor: made2 }) => {
|
|
7916
8067
|
if (source.data && !live) baseline.current = { bytes, doc: made2.state.doc, base: source.data.md && track(source.data.md, made2.state.doc) };
|
|
7917
8068
|
}
|
|
@@ -7950,13 +8101,13 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7950
8101
|
redo: e.can().redo(),
|
|
7951
8102
|
empty,
|
|
7952
8103
|
toc: (() => {
|
|
7953
|
-
let
|
|
8104
|
+
let at2 = -1;
|
|
7954
8105
|
e.state.doc.forEach((node, pos) => {
|
|
7955
|
-
if (
|
|
8106
|
+
if (at2 < 0 && node.type.name === "toc") at2 = pos;
|
|
7956
8107
|
});
|
|
7957
|
-
return
|
|
8108
|
+
return at2;
|
|
7958
8109
|
})(),
|
|
7959
|
-
find: (({ at, hits }) => `${
|
|
8110
|
+
find: (({ at: at2, hits }) => `${at2}/${hits.length}`)(searching.getState(e.state)),
|
|
7960
8111
|
suggest: !!suggesting.getState(e.state)?.on,
|
|
7961
8112
|
revs: docx2 ? changes(e.state.doc) : [],
|
|
7962
8113
|
dirty: !!baseline.current && !e.state.doc.eq(baseline.current.doc)
|
|
@@ -7987,8 +8138,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
7987
8138
|
};
|
|
7988
8139
|
const marginal = marg ?? (source.data && "marginal" in source.data ? source.data.marginal : null) ?? { header: "", footer: "", numbers: false };
|
|
7989
8140
|
(0, import_react10.useEffect)(() => {
|
|
7990
|
-
if (editor && docx2 && source.data) editor.view.dispatch(editor.state.tr.setMeta(paging, { page, marks: { header: marginal.header, footer: marginal.footer } }));
|
|
7991
|
-
}, [editor, source.data, page, marginal.header, marginal.footer]);
|
|
8141
|
+
if (editor && docx2 && source.data) editor.view.dispatch(editor.state.tr.setMeta(paging, { page, marks: { header: marginal.header, footer: marginal.footer }, flow }));
|
|
8142
|
+
}, [editor, source.data, page, marginal.header, marginal.footer, flow]);
|
|
7992
8143
|
(0, import_react10.useEffect)(() => {
|
|
7993
8144
|
if (!shared || !docx2) return;
|
|
7994
8145
|
const map = shared.doc.getMap("setup");
|
|
@@ -8102,6 +8253,18 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8102
8253
|
watch.observe(el);
|
|
8103
8254
|
return () => watch.disconnect();
|
|
8104
8255
|
}, [editor, source.data]);
|
|
8256
|
+
(0, import_react10.useEffect)(() => {
|
|
8257
|
+
const view = window.visualViewport;
|
|
8258
|
+
const el = root.current;
|
|
8259
|
+
if (!view || !el) return;
|
|
8260
|
+
const lift = () => el.style.setProperty("--kb", `${Math.max(0, innerHeight - view.height - view.offsetTop)}px`);
|
|
8261
|
+
view.addEventListener("resize", lift);
|
|
8262
|
+
view.addEventListener("scroll", lift);
|
|
8263
|
+
return () => {
|
|
8264
|
+
view.removeEventListener("resize", lift);
|
|
8265
|
+
view.removeEventListener("scroll", lift);
|
|
8266
|
+
};
|
|
8267
|
+
}, [editor, source.data]);
|
|
8105
8268
|
(0, import_react10.useEffect)(() => {
|
|
8106
8269
|
const el = root.current;
|
|
8107
8270
|
if (!el) return;
|
|
@@ -8131,8 +8294,17 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8131
8294
|
const close = (e) => {
|
|
8132
8295
|
if (!e.target.closest(".w100n-text-pop, [data-pop]")) setPop(null);
|
|
8133
8296
|
};
|
|
8297
|
+
const off = (e) => {
|
|
8298
|
+
if (pop === "context" && (e.type === "scroll" || e.key === "Escape")) setPop(null);
|
|
8299
|
+
};
|
|
8134
8300
|
document.addEventListener("pointerdown", close);
|
|
8135
|
-
|
|
8301
|
+
window.addEventListener("keydown", off);
|
|
8302
|
+
window.addEventListener("scroll", off, true);
|
|
8303
|
+
return () => {
|
|
8304
|
+
document.removeEventListener("pointerdown", close);
|
|
8305
|
+
window.removeEventListener("keydown", off);
|
|
8306
|
+
window.removeEventListener("scroll", off, true);
|
|
8307
|
+
};
|
|
8136
8308
|
}, [pop]);
|
|
8137
8309
|
if (source.error) return docx2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DocxView, { bytes, onOutline, failed: t.failed }) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-empty", children: t.failed });
|
|
8138
8310
|
if (!source.data || !editor || !state || live && !live.ready && !live.late && !live.denied) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
|
|
@@ -8167,18 +8339,18 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8167
8339
|
}
|
|
8168
8340
|
};
|
|
8169
8341
|
const renew = (fresh2) => {
|
|
8170
|
-
const
|
|
8171
|
-
const
|
|
8342
|
+
const at2 = [];
|
|
8343
|
+
const refs3 = [];
|
|
8172
8344
|
editor.state.doc.descendants((node, pos) => {
|
|
8173
|
-
if (node.isBlock)
|
|
8345
|
+
if (node.isBlock) at2.push(pos);
|
|
8174
8346
|
});
|
|
8175
8347
|
editor.schema.nodeFromJSON(fresh2).descendants((node) => {
|
|
8176
|
-
if (node.isBlock)
|
|
8348
|
+
if (node.isBlock) refs3.push(node.type.name, node.attrs.ref);
|
|
8177
8349
|
});
|
|
8178
|
-
if (
|
|
8350
|
+
if (refs3.length !== at2.length * 2 || at2.some((pos, i) => editor.state.doc.nodeAt(pos).type.name !== refs3[i * 2])) return false;
|
|
8179
8351
|
const tr = editor.state.tr.setMeta("addToHistory", false);
|
|
8180
|
-
|
|
8181
|
-
if (tr.doc.nodeAt(pos).attrs.ref !==
|
|
8352
|
+
at2.forEach((pos, i) => {
|
|
8353
|
+
if (tr.doc.nodeAt(pos).attrs.ref !== refs3[i * 2 + 1]) tr.setNodeAttribute(pos, "ref", refs3[i * 2 + 1]);
|
|
8182
8354
|
});
|
|
8183
8355
|
editor.view.dispatch(tr);
|
|
8184
8356
|
return true;
|
|
@@ -8265,10 +8437,10 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8265
8437
|
const drops = (c) => mine(c) || c.author.id.startsWith("guest:") && !!rights?.edit;
|
|
8266
8438
|
const show = (c) => {
|
|
8267
8439
|
setActive(c.id);
|
|
8268
|
-
const
|
|
8269
|
-
if (!
|
|
8270
|
-
const
|
|
8271
|
-
(
|
|
8440
|
+
const spot4 = notes.getState(editor.state).spots.find((s) => s.id === c.id);
|
|
8441
|
+
if (!spot4) return;
|
|
8442
|
+
const at2 = editor.view.domAtPos(spot4.from).node;
|
|
8443
|
+
(at2 instanceof HTMLElement ? at2 : at2.parentElement)?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
8272
8444
|
};
|
|
8273
8445
|
const suggested = [...state.revs.reduce((all2, c) => {
|
|
8274
8446
|
const key2 = `${c.kind}:${c.id}`;
|
|
@@ -8276,11 +8448,11 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8276
8448
|
all2.set(key2, was ? { ...was, text: `${was.text} ${c.text}` } : c);
|
|
8277
8449
|
return all2;
|
|
8278
8450
|
}, /* @__PURE__ */ new Map()).values()];
|
|
8279
|
-
const jump = (
|
|
8280
|
-
const dom = editor.view.domAtPos(
|
|
8451
|
+
const jump = (at2) => {
|
|
8452
|
+
const dom = editor.view.domAtPos(at2).node;
|
|
8281
8453
|
(dom instanceof HTMLElement ? dom : dom.parentElement)?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
8282
8454
|
};
|
|
8283
|
-
const percent = zoom ?? (docx2 && room ? Math.max(10, Math.min(100, Math.floor((room - 24) / page.width * 100))) : 100);
|
|
8455
|
+
const percent = zoom ?? (docx2 && room && !flow ? Math.max(10, Math.min(100, Math.floor((room - 24) / page.width * 100))) : 100);
|
|
8284
8456
|
const zoomBy = (d) => setZoom(Math.min(200, Math.max(30, percent + d)));
|
|
8285
8457
|
const keys2 = (e) => {
|
|
8286
8458
|
if (e.defaultPrevented) return;
|
|
@@ -8306,7 +8478,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8306
8478
|
else if (key2 === "]" || key2 === "[") act(() => indent(editor, key2 === "]" ? 1 : -1));
|
|
8307
8479
|
else if (key2 === "\\") act(() => clear(editor));
|
|
8308
8480
|
else if (key2 === "enter" && docx2) act(() => editor.chain().focus().insertContent({ type: "pageBreak" }).run());
|
|
8309
|
-
else if (e.shiftKey &&
|
|
8481
|
+
else if (e.shiftKey && ["l", "e", "r", "j"].includes(key2)) act(() => align2(editor, { l: "left", e: "center", r: "right", j: "justify" }[key2]));
|
|
8310
8482
|
};
|
|
8311
8483
|
const tool = (icon, label, run3, pressed, disabled) => {
|
|
8312
8484
|
const Icon = icon;
|
|
@@ -8353,7 +8525,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8353
8525
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Trash2, { "aria-hidden": true }) })
|
|
8354
8526
|
] })
|
|
8355
8527
|
] });
|
|
8356
|
-
const
|
|
8528
|
+
const words3 = (c) => editing?.id === c.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply w100n-text-edit", onClick: (e) => e.stopPropagation(), children: [
|
|
8357
8529
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
8358
8530
|
"textarea",
|
|
8359
8531
|
{
|
|
@@ -8397,8 +8569,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8397
8569
|
const mod = /Mac|iPhone|iPad/.test(navigator.platform) ? "\u2318" : "Ctrl+";
|
|
8398
8570
|
const item = (label, run3, more2 = {}) => ({ label, run: run3, ...more2 });
|
|
8399
8571
|
const insertToc = () => {
|
|
8400
|
-
const
|
|
8401
|
-
editor.chain().focus().insertContentAt(
|
|
8572
|
+
const at2 = editor.state.selection.$from.before(1);
|
|
8573
|
+
editor.chain().focus().insertContentAt(at2, { type: "toc", attrs: { entries: JSON.stringify(entries(editor.state.doc, !docx2, at2 - 1)) } }).run();
|
|
8402
8574
|
};
|
|
8403
8575
|
const suggest = () => editor.view.dispatch(editor.state.tr.setMeta(suggesting, { on: !state.suggest, me: host?.me.name ?? "" }));
|
|
8404
8576
|
const aligns = [[import_lucide_react5.AlignLeft, t.alignLeft, "left"], [import_lucide_react5.AlignCenter, t.alignCenter, "center"], [import_lucide_react5.AlignRight, t.alignRight, "right"], [import_lucide_react5.AlignJustify, t.justify, "justify"]];
|
|
@@ -8424,9 +8596,13 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8424
8596
|
item(t.clearFormat, () => clear(editor), { keys: `${mod}\\` })
|
|
8425
8597
|
] : []],
|
|
8426
8598
|
["view", t.viewTab, [
|
|
8599
|
+
docx2 && item(t.printLayout, () => {
|
|
8600
|
+
setPrinted(flow);
|
|
8601
|
+
setZoom(null);
|
|
8602
|
+
}, { on: !flow }),
|
|
8427
8603
|
item(t.zoomIn, () => zoomBy(10)),
|
|
8428
8604
|
item(t.zoomOut, () => zoomBy(-10)),
|
|
8429
|
-
docx2 && item(t.fitWidth, () => setZoom(null), { on: zoom === null }),
|
|
8605
|
+
docx2 && !flow && item(t.fitWidth, () => setZoom(null), { on: zoom === null }),
|
|
8430
8606
|
item(t.fit, () => setZoom(100)),
|
|
8431
8607
|
"-",
|
|
8432
8608
|
item(t.outline, () => onPanel?.("outline")),
|
|
@@ -8448,8 +8624,8 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8448
8624
|
can.comment && item(t.addComment, begin, { off: state.empty, keys: `${mod}\u2325M` }),
|
|
8449
8625
|
"-",
|
|
8450
8626
|
item(t.symbols, () => setDialog({ kind: "symbol", query: "" })),
|
|
8451
|
-
|
|
8452
|
-
|
|
8627
|
+
item(t.formula, () => setDialog({ kind: "formula", latex: "", at: null })),
|
|
8628
|
+
item(t.footnote, () => setDialog({ kind: "note", text: "", at: null }))
|
|
8453
8629
|
] : []],
|
|
8454
8630
|
["format", t.menuFormat, can.edit ? [
|
|
8455
8631
|
...styles2.map(([key2, label, run3]) => item(label, run3, { on: state.style === key2 })),
|
|
@@ -8460,12 +8636,9 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8460
8636
|
item(t.strike, () => editor.chain().focus().toggleStrike().run(), { on: state.strike }),
|
|
8461
8637
|
docx2 && item(t.superscript, () => editor.chain().focus().toggleMark("superscript").run(), { on: state.sup, keys: `${mod}.` }),
|
|
8462
8638
|
docx2 && item(t.subscript, () => editor.chain().focus().toggleMark("subscript").run(), { on: state.sub, keys: `${mod},` }),
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
"-",
|
|
8467
|
-
...lines2.map(([v, label]) => item(`${t.lineSpacing}: ${label}`, () => spacing(editor, { line: v }), { on: state.line === v }))
|
|
8468
|
-
] : [],
|
|
8639
|
+
"-",
|
|
8640
|
+
...aligns.map(([, label, value3]) => item(label, () => align2(editor, value3), { on: state.align === value3 })),
|
|
8641
|
+
...docx2 ? ["-", ...lines2.map(([v, label]) => item(`${t.lineSpacing}: ${label}`, () => spacing(editor, { line: v }), { on: state.line === v }))] : [],
|
|
8469
8642
|
"-",
|
|
8470
8643
|
item(t.bullets, () => editor.chain().focus().toggleBulletList().run(), { on: state.bullets }),
|
|
8471
8644
|
item(t.numbers, () => editor.chain().focus().toggleOrderedList().run(), { on: state.numbers }),
|
|
@@ -8478,19 +8651,55 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8478
8651
|
docx2 && can.edit && item(t.suggest, suggest, { on: state.suggest }),
|
|
8479
8652
|
docx2 && can.edit && state.revs.length > 0 && item(t.acceptAll, () => decide(editor, true)),
|
|
8480
8653
|
docx2 && can.edit && state.revs.length > 0 && item(t.rejectAll, () => decide(editor, false)),
|
|
8481
|
-
!!host?.comments && (can.comment || open.length > 0) && item(t.comments, () => onPanel?.("comments"))
|
|
8654
|
+
!!host?.comments && (can.comment || open.length > 0) && item(t.comments, () => onPanel?.("comments")),
|
|
8655
|
+
can.edit && item(t.spellCheck, () => {
|
|
8656
|
+
editor.view.dom.spellcheck = !spell;
|
|
8657
|
+
localStorage.setItem("w100n-docs-spell", spell ? "0" : "1");
|
|
8658
|
+
setSpell(!spell);
|
|
8659
|
+
}, { on: spell })
|
|
8482
8660
|
]]
|
|
8483
8661
|
];
|
|
8662
|
+
const clip = (kind2) => {
|
|
8663
|
+
editor.view.focus();
|
|
8664
|
+
document.execCommand(kind2);
|
|
8665
|
+
};
|
|
8666
|
+
const paste = async () => {
|
|
8667
|
+
const found2 = await navigator.clipboard.read().catch(() => []);
|
|
8668
|
+
const html = found2.find((c) => c.types.includes("text/html"));
|
|
8669
|
+
if (html) return editor.view.pasteHTML(await (await html.getType("text/html")).text());
|
|
8670
|
+
const plain4 = found2.find((c) => c.types.includes("text/plain"));
|
|
8671
|
+
if (plain4) editor.view.pasteText(await (await plain4.getType("text/plain")).text());
|
|
8672
|
+
};
|
|
8673
|
+
const table3 = editor.isActive("table");
|
|
8674
|
+
const near = [
|
|
8675
|
+
can.edit && item(t.cut, () => clip("cut"), { off: state.empty, keys: `${mod}X` }),
|
|
8676
|
+
item(t.copy, () => clip("copy"), { off: state.empty, keys: `${mod}C` }),
|
|
8677
|
+
can.edit && !!navigator.clipboard?.read && item(t.paste, () => void paste(), { keys: `${mod}V` }),
|
|
8678
|
+
"-",
|
|
8679
|
+
can.comment && item(t.addComment, begin, { off: state.empty, keys: `${mod}\u2325M` }),
|
|
8680
|
+
can.edit && item(t.link, linkUp, { keys: `${mod}K` }),
|
|
8681
|
+
can.edit && item(t.clearFormat, () => clear(editor), { keys: `${mod}\\` }),
|
|
8682
|
+
...can.edit && table3 ? [
|
|
8683
|
+
"-",
|
|
8684
|
+
item(t.rowAbove, () => editor.chain().focus().addRowBefore().run()),
|
|
8685
|
+
item(t.rowBelow, () => editor.chain().focus().addRowAfter().run()),
|
|
8686
|
+
item(t.columnLeft, () => editor.chain().focus().addColumnBefore().run()),
|
|
8687
|
+
item(t.columnRight, () => editor.chain().focus().addColumnAfter().run()),
|
|
8688
|
+
item(t.deleteRow, () => editor.chain().focus().deleteRow().run()),
|
|
8689
|
+
item(t.deleteColumn, () => editor.chain().focus().deleteColumn().run())
|
|
8690
|
+
] : []
|
|
8691
|
+
];
|
|
8692
|
+
const rows = (list) => list.filter((x) => x !== false).filter((x, i, all2) => x !== "-" || i > 0 && all2[i - 1] !== "-" && i < all2.length - 1).map((x, i) => x === "-" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("hr", {}, i) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", role: x.on === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": x.on, disabled: x.off, onClick: () => {
|
|
8693
|
+
setPop(null);
|
|
8694
|
+
x.run();
|
|
8695
|
+
}, children: [
|
|
8696
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
8697
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: x.label }),
|
|
8698
|
+
x.keys && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: x.keys })
|
|
8699
|
+
] }, i));
|
|
8484
8700
|
const menu = ([key2, label, list]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8485
8701
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-text-menu-button", "data-pop": true, "aria-haspopup": "menu", "aria-expanded": pop === key2, onClick: () => pick(key2), children: label }),
|
|
8486
|
-
pop === key2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-menu", role: "menu", "aria-label": label, children: list
|
|
8487
|
-
setPop(null);
|
|
8488
|
-
x.run();
|
|
8489
|
-
}, children: [
|
|
8490
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
8491
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: x.label }),
|
|
8492
|
-
x.keys && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: x.keys })
|
|
8493
|
-
] }, i)) })
|
|
8702
|
+
pop === key2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-menu", role: "menu", "aria-label": label, children: rows(list) })
|
|
8494
8703
|
] }, key2);
|
|
8495
8704
|
const seek = (next) => {
|
|
8496
8705
|
editor.view.dispatch(editor.state.tr.setMeta(searching, next));
|
|
@@ -8697,7 +8906,7 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8697
8906
|
pop === "color" && swatches(inks, state.color, (c) => c ? editor.chain().focus().setColor(c).run() : editor.chain().focus().unsetColor().run(), t.automatic)
|
|
8698
8907
|
] }),
|
|
8699
8908
|
gap,
|
|
8700
|
-
|
|
8909
|
+
aligner,
|
|
8701
8910
|
tool(import_lucide_react5.List, t.bullets, () => editor.chain().focus().toggleBulletList().run(), state.bullets),
|
|
8702
8911
|
tool(import_lucide_react5.ListOrdered, t.numbers, () => editor.chain().focus().toggleOrderedList().run(), state.numbers),
|
|
8703
8912
|
!docx2 && tool(import_lucide_react5.ListChecks, t.tasks, () => editor.chain().focus().toggleTaskList().run(), state.tasks),
|
|
@@ -8774,17 +8983,17 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8774
8983
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "table", "aria-label": t.table, title: t.table, onClick: () => pick("table"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Table, { "aria-hidden": true }) }),
|
|
8775
8984
|
pop === "table" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-grid", role: "group", "aria-label": t.table, onPointerLeave: () => setGrid({ rows: 0, cols: 0 }), children: [
|
|
8776
8985
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: Array.from({ length: 48 }, (_, i) => {
|
|
8777
|
-
const
|
|
8986
|
+
const rows2 = Math.floor(i / 8) + 1;
|
|
8778
8987
|
const cols = i % 8 + 1;
|
|
8779
8988
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
8780
8989
|
"button",
|
|
8781
8990
|
{
|
|
8782
8991
|
type: "button",
|
|
8783
|
-
"aria-label": `${
|
|
8784
|
-
"data-on":
|
|
8785
|
-
onPointerEnter: () => setGrid({ rows, cols }),
|
|
8992
|
+
"aria-label": `${rows2} \xD7 ${cols}`,
|
|
8993
|
+
"data-on": rows2 <= grid3.rows && cols <= grid3.cols,
|
|
8994
|
+
onPointerEnter: () => setGrid({ rows: rows2, cols }),
|
|
8786
8995
|
onClick: () => {
|
|
8787
|
-
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
8996
|
+
editor.chain().focus().insertTable({ rows: rows2, cols, withHeaderRow: true }).run();
|
|
8788
8997
|
setPop(null);
|
|
8789
8998
|
}
|
|
8790
8999
|
},
|
|
@@ -8886,20 +9095,34 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8886
9095
|
menubar,
|
|
8887
9096
|
status
|
|
8888
9097
|
] }),
|
|
8889
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", "data-paint": !!paint2, onMouseUp: lay,
|
|
9098
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", "data-paint": !!paint2, onMouseUp: lay, onPointerDown: (e) => {
|
|
9099
|
+
touch.current = e.pointerType === "touch";
|
|
9100
|
+
}, onContextMenu: (e) => {
|
|
9101
|
+
if (touch.current || e.shiftKey || pop === "context" || !e.target.closest(".ProseMirror")) return setPop(null);
|
|
9102
|
+
e.preventDefault();
|
|
9103
|
+
const at2 = editor.view.posAtCoords({ left: e.clientX, top: e.clientY });
|
|
9104
|
+
const { from, to } = editor.state.selection;
|
|
9105
|
+
if (at2 && (at2.pos < from || at2.pos > to)) editor.commands.setTextSelection(at2.pos);
|
|
9106
|
+
setSpot({ x: Math.min(e.clientX, innerWidth - 260), y: Math.min(e.clientY, innerHeight - 360) });
|
|
9107
|
+
setPop("context");
|
|
9108
|
+
}, onClick: (e) => {
|
|
8890
9109
|
const atom = can.edit ? e.target.closest(".w100n-math, sup[data-footnote]") : null;
|
|
8891
9110
|
if (atom) {
|
|
8892
|
-
const
|
|
8893
|
-
const node = editor.state.doc.nodeAt(
|
|
8894
|
-
if (node?.type.name === "math") setDialog({ kind: "formula", latex: node.attrs.latex, at });
|
|
8895
|
-
if (node?.type.name === "footnote") setDialog({ kind: "note", text: node.attrs.text, at });
|
|
9111
|
+
const at2 = editor.view.posAtDOM(atom, 0);
|
|
9112
|
+
const node = editor.state.doc.nodeAt(at2);
|
|
9113
|
+
if (node?.type.name === "math") setDialog({ kind: "formula", latex: node.attrs.latex, at: at2 });
|
|
9114
|
+
if (node?.type.name === "footnote") setDialog({ kind: "note", text: node.attrs.text, at: at2 });
|
|
8896
9115
|
return;
|
|
8897
9116
|
}
|
|
8898
9117
|
const id = e.target.closest("[data-note]")?.getAttribute("data-note");
|
|
8899
9118
|
if (!id) return;
|
|
8900
9119
|
setActive(id);
|
|
8901
9120
|
onPanel?.("comments");
|
|
8902
|
-
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-zoomed", style: { zoom: percent / 100 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: docx2 ?
|
|
9121
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-zoomed", style: { zoom: percent / 100 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: docx2 ? `w100n-text-sheet${flow ? " is-flow" : ""}` : "w100n-docs-page w100n-text-column", style: sheet2, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.EditorContent, { editor }) }) }) }),
|
|
9122
|
+
pop === "context" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-menu w100n-text-context", role: "menu", "aria-label": t.textTools, style: { left: spot3.x, top: spot3.y }, onPointerDown: keep, children: [
|
|
9123
|
+
rows(near),
|
|
9124
|
+
spell && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { className: "w100n-text-hint", children: t.spellHint })
|
|
9125
|
+
] }),
|
|
8903
9126
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-ribbon w100n-text-corner", "data-side": "left", onPointerDown: keep, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-tools", role: "group", "aria-label": t.zoom, children: [
|
|
8904
9127
|
tool(import_lucide_react5.Minus, t.zoomOut, () => zoomBy(-10)),
|
|
8905
9128
|
zoomer,
|
|
@@ -8951,16 +9174,15 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8951
9174
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
8952
9175
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-new-tile", "data-tone": "blue", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Sigma, { "aria-hidden": true }) }),
|
|
8953
9176
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.formula }),
|
|
8954
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-badge", children: t.formulaHint }),
|
|
8955
9177
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => setDialog(null), "aria-label": t.close, title: t.close, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.X, { "aria-hidden": true }) })
|
|
8956
9178
|
] }),
|
|
8957
9179
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ref: field, autoFocus: true, className: "w100n-insert-latex", value: dialog.latex, "aria-label": t.formula, placeholder: "F = 900 + 12 \\\\cdot n", onChange: (e) => setDialog({ ...dialog, latex: e.target.value }) }),
|
|
8958
9180
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-insert-tools", role: "group", "aria-label": t.formula, children: helpers.map(([label, code]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", onClick: () => {
|
|
8959
9181
|
const el = field.current;
|
|
8960
|
-
const
|
|
8961
|
-
const latex = dialog.latex.slice(0,
|
|
9182
|
+
const at2 = el.selectionStart ?? dialog.latex.length;
|
|
9183
|
+
const latex = dialog.latex.slice(0, at2) + code + dialog.latex.slice(el.selectionEnd ?? at2);
|
|
8962
9184
|
setDialog({ ...dialog, latex });
|
|
8963
|
-
const caret =
|
|
9185
|
+
const caret = at2 + (code.indexOf("{}") >= 0 ? code.indexOf("{}") + 1 : code.length);
|
|
8964
9186
|
requestAnimationFrame(() => {
|
|
8965
9187
|
el.focus();
|
|
8966
9188
|
el.setSelectionRange(caret, caret);
|
|
@@ -8982,7 +9204,13 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
8982
9204
|
tr.setNodeAttribute(dialog.at, "text", text);
|
|
8983
9205
|
return true;
|
|
8984
9206
|
}).run();
|
|
8985
|
-
else
|
|
9207
|
+
else {
|
|
9208
|
+
let id = 0;
|
|
9209
|
+
editor.state.doc.descendants((n) => {
|
|
9210
|
+
if (n.type.name === "footnote") id = Math.max(id, Number(n.attrs.id) || 0);
|
|
9211
|
+
});
|
|
9212
|
+
editor.chain().focus().insertContent({ type: "footnote", attrs: { id: docx2 ? null : String(id + 1), text } }).run();
|
|
9213
|
+
}
|
|
8986
9214
|
setDialog(null);
|
|
8987
9215
|
}, children: [
|
|
8988
9216
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
@@ -9155,10 +9383,10 @@ img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt
|
|
|
9155
9383
|
threads.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { className: "w100n-text-card", "aria-current": active === c.id, "data-resolved": c.resolved, onClick: () => show(c), children: [
|
|
9156
9384
|
person(c),
|
|
9157
9385
|
c.quote && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("blockquote", { children: c.quote }),
|
|
9158
|
-
|
|
9386
|
+
words3(c),
|
|
9159
9387
|
all.filter((r) => r.replyTo === c.id).map((r) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", children: [
|
|
9160
9388
|
person(r),
|
|
9161
|
-
|
|
9389
|
+
words3(r)
|
|
9162
9390
|
] }, r.id)),
|
|
9163
9391
|
reply?.id === c.id && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", onClick: (e) => e.stopPropagation(), children: [
|
|
9164
9392
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -9355,8 +9583,8 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9355
9583
|
const commands = injector.get(import_core4.ICommandService);
|
|
9356
9584
|
const run3 = (id, params) => commands.hasCommand(id) && commands.syncExecuteCommand(id, { unitId: unit, ...params }, { fromCollab: true });
|
|
9357
9585
|
const ws = (sid) => wb.getSheetBySheetId(sid);
|
|
9358
|
-
const
|
|
9359
|
-
const index = (sid) =>
|
|
9586
|
+
const at2 = /* @__PURE__ */ new Map();
|
|
9587
|
+
const index = (sid) => at2.get(sid) ?? at2.set(sid, { rows: new Map(lines2[sid].rows.map((id, i) => [id, i])), cols: new Map(lines2[sid].cols.map((id, i) => [id, i])) }).get(sid);
|
|
9360
9588
|
const live = (sid) => !!sid && !!lines2[sid] && sheets.has(sid) && !!wb.getSheetBySheetId(sid);
|
|
9361
9589
|
const look = (s) => {
|
|
9362
9590
|
const style = typeof s === "string" ? looks.get(s) : s;
|
|
@@ -9416,7 +9644,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9416
9644
|
for (const k of [...kept.keys()]) if (!want.has(k)) kept.delete(k);
|
|
9417
9645
|
for (const k of want) if (!kept.has(k)) kept.set(k, 1);
|
|
9418
9646
|
};
|
|
9419
|
-
const
|
|
9647
|
+
const notes3 = (sid) => {
|
|
9420
9648
|
const l = lines2[sid];
|
|
9421
9649
|
const { notes: kept } = pieces(sheets.get(sid));
|
|
9422
9650
|
const want = new Map(api.getWorkbook(unit).getSheetBySheetId(sid).getNotes().map((n) => [spot2(l.rows[n.row], l.cols[n.col]), { note: n.note, width: n.width, height: n.height }]));
|
|
@@ -9448,7 +9676,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9448
9676
|
l.rows.forEach((_, r) => putRow(sid, r));
|
|
9449
9677
|
l.cols.forEach((_, c) => putCol(sid, c));
|
|
9450
9678
|
merges(sid);
|
|
9451
|
-
|
|
9679
|
+
notes3(sid);
|
|
9452
9680
|
props2.forEach((name) => prop(sid, name));
|
|
9453
9681
|
};
|
|
9454
9682
|
const write4 = (id, p) => {
|
|
@@ -9460,7 +9688,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9460
9688
|
return resync(added);
|
|
9461
9689
|
}
|
|
9462
9690
|
if (id === "sheet.mutation.remove-sheet" && sid) {
|
|
9463
|
-
|
|
9691
|
+
at2.delete(sid);
|
|
9464
9692
|
sheets.delete(sid);
|
|
9465
9693
|
const i = order2.toArray().indexOf(sid);
|
|
9466
9694
|
if (i >= 0) order2.delete(i, 1);
|
|
@@ -9484,7 +9712,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9484
9712
|
const ids = list.slice(from, from + n);
|
|
9485
9713
|
list.delete(from, n);
|
|
9486
9714
|
list.insert(to > from ? to - n : to, ids);
|
|
9487
|
-
|
|
9715
|
+
at2.delete(sid);
|
|
9488
9716
|
};
|
|
9489
9717
|
switch (id) {
|
|
9490
9718
|
case "sheet.mutation.set-range-values":
|
|
@@ -9494,29 +9722,29 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9494
9722
|
return;
|
|
9495
9723
|
case "sheet.mutation.insert-row":
|
|
9496
9724
|
rows.insert(p.range.startRow, l.rows.slice(p.range.startRow, p.range.endRow + 1));
|
|
9497
|
-
|
|
9725
|
+
at2.delete(sid);
|
|
9498
9726
|
for (let r = p.range.startRow; r <= p.range.endRow; r++) putRow(sid, r);
|
|
9499
9727
|
return;
|
|
9500
9728
|
case "sheet.mutation.insert-col":
|
|
9501
9729
|
cols.insert(p.range.startColumn, l.cols.slice(p.range.startColumn, p.range.endColumn + 1));
|
|
9502
|
-
|
|
9730
|
+
at2.delete(sid);
|
|
9503
9731
|
for (let c = p.range.startColumn; c <= p.range.endColumn; c++) putCol(sid, c);
|
|
9504
9732
|
return;
|
|
9505
9733
|
case "sheet.mutation.remove-rows":
|
|
9506
|
-
|
|
9734
|
+
at2.delete(sid);
|
|
9507
9735
|
return rows.delete(p.range.startRow, count(p.range, true));
|
|
9508
9736
|
case "sheet.mutation.remove-col":
|
|
9509
|
-
|
|
9737
|
+
at2.delete(sid);
|
|
9510
9738
|
return cols.delete(p.range.startColumn, count(p.range, false));
|
|
9511
9739
|
case "sheet.mutation.move-rows":
|
|
9512
9740
|
return shift(rows, p.sourceRange.startRow, count(p.sourceRange, true), p.targetRange.startRow);
|
|
9513
9741
|
case "sheet.mutation.move-columns":
|
|
9514
9742
|
return shift(cols, p.sourceRange.startColumn, count(p.sourceRange, false), p.targetRange.startColumn);
|
|
9515
9743
|
case "sheet.mutation.set-worksheet-row-count":
|
|
9516
|
-
|
|
9744
|
+
at2.delete(sid);
|
|
9517
9745
|
return fit(rows, l.rows);
|
|
9518
9746
|
case "sheet.mutation.set-worksheet-column-count":
|
|
9519
|
-
|
|
9747
|
+
at2.delete(sid);
|
|
9520
9748
|
return fit(cols, l.cols);
|
|
9521
9749
|
case "sheet.mutation.set-worksheet-row-height":
|
|
9522
9750
|
case "sheet.mutation.set-worksheet-row-is-auto-height":
|
|
@@ -9539,7 +9767,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9539
9767
|
case "sheet.mutation.update-note":
|
|
9540
9768
|
case "sheet.mutation.remove-note":
|
|
9541
9769
|
case "sheet.mutation.update-note-position":
|
|
9542
|
-
return
|
|
9770
|
+
return notes3(sid);
|
|
9543
9771
|
default: {
|
|
9544
9772
|
const setter = setters.find((x) => x[1] === id);
|
|
9545
9773
|
if (setter) prop(sid, setter[0]);
|
|
@@ -9645,7 +9873,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9645
9873
|
}
|
|
9646
9874
|
run3("sheet.mutation.remove-sheet", { subUnitId: sid });
|
|
9647
9875
|
delete lines2[sid];
|
|
9648
|
-
|
|
9876
|
+
at2.delete(sid);
|
|
9649
9877
|
}
|
|
9650
9878
|
want.forEach((sid, i) => {
|
|
9651
9879
|
if (wb.getSheetBySheetId(sid)) return;
|
|
@@ -9682,7 +9910,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
9682
9910
|
i += ids.length;
|
|
9683
9911
|
}
|
|
9684
9912
|
}
|
|
9685
|
-
|
|
9913
|
+
at2.delete(sid);
|
|
9686
9914
|
return added;
|
|
9687
9915
|
};
|
|
9688
9916
|
const remote = (events, tr) => {
|
|
@@ -9903,7 +10131,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
9903
10131
|
const [pop, setPop] = (0, import_react11.useState)(null);
|
|
9904
10132
|
const [look, setLook] = (0, import_react11.useState)(null);
|
|
9905
10133
|
const edit = rights.edit && !!onSaveRequest && (!room || !!shared && !room.readonly);
|
|
9906
|
-
const
|
|
10134
|
+
const notes3 = !edit && rights.comment && !!onSaveRequest && !room;
|
|
9907
10135
|
(0, import_react11.useEffect)(() => {
|
|
9908
10136
|
if (waiting2) return;
|
|
9909
10137
|
let gone = false;
|
|
@@ -9938,7 +10166,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
9938
10166
|
if (model.active) wb.setActiveSheet(model.active);
|
|
9939
10167
|
if (!edit) wb.setEditable(false);
|
|
9940
10168
|
const state = { api: api2, model, original: bytes, changes: 0 };
|
|
9941
|
-
const untrack = track2(api2, model, { view: true, comment:
|
|
10169
|
+
const untrack = track2(api2, model, { view: true, comment: notes3, edit }, () => {
|
|
9942
10170
|
state.changes++;
|
|
9943
10171
|
if (state.changes === 1 && !shared) {
|
|
9944
10172
|
setDirty(true);
|
|
@@ -10065,7 +10293,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
10065
10293
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "s") {
|
|
10066
10294
|
e.preventDefault();
|
|
10067
10295
|
e.stopPropagation();
|
|
10068
|
-
if (edit ||
|
|
10296
|
+
if (edit || notes3) void save2();
|
|
10069
10297
|
}
|
|
10070
10298
|
if (e.key === "Escape" && pop) {
|
|
10071
10299
|
e.stopPropagation();
|
|
@@ -10238,7 +10466,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
10238
10466
|
!room && tool(import_lucide_react6.Funnel, t.filter, () => run3("sheet.command.smart-toggle-filter")),
|
|
10239
10467
|
gap
|
|
10240
10468
|
] }),
|
|
10241
|
-
(edit ||
|
|
10469
|
+
(edit || notes3) && tool(import_lucide_react6.StickyNote, t.note, () => run3("sheet.operation.add-note-popup")),
|
|
10242
10470
|
tool(import_lucide_react6.Search, t.find, () => run3("ui.operation.open-find-dialog"))
|
|
10243
10471
|
] }),
|
|
10244
10472
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-sheet-end", children: [
|
|
@@ -10247,9 +10475,9 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
10247
10475
|
room.denied ? t.liveOff : t.offline
|
|
10248
10476
|
] }),
|
|
10249
10477
|
room && room.people.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-text-people", role: "group", "aria-label": t.people, children: room.people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-text-face", title: p.me ? `${p.name} (${t.you})` : p.name, style: { "--face": p.color }, children: p.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: p.avatarUrl, alt: "" }) : p.name.split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase() }, p.id)) }),
|
|
10250
|
-
!edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-docs-badge", children:
|
|
10478
|
+
!edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-docs-badge", children: notes3 ? t.notesOnly : t.viewOnly }),
|
|
10251
10479
|
saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-sheet-muted", role: "alert", children: refusal ? t.refused[refusal.code].replace("{sheet}", refusal.sheet) : t.saveFailed }),
|
|
10252
|
-
(edit ||
|
|
10480
|
+
(edit || notes3) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !pending2 || saving === "busy" || phase !== "ready" || !!room && !room.online, onClick: () => void save2(), children: [
|
|
10253
10481
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.Save, { "aria-hidden": true }),
|
|
10254
10482
|
saving === "busy" ? t.saving : !pending2 && saving === "done" ? t.saved : t.save
|
|
10255
10483
|
] })
|
|
@@ -10297,6 +10525,101 @@ var init_SheetView = __esm({
|
|
|
10297
10525
|
}
|
|
10298
10526
|
});
|
|
10299
10527
|
|
|
10528
|
+
// src/Compare.tsx
|
|
10529
|
+
var Compare_exports = {};
|
|
10530
|
+
__export(Compare_exports, {
|
|
10531
|
+
changes: () => changes2,
|
|
10532
|
+
default: () => Compare,
|
|
10533
|
+
textOf: () => textOf2
|
|
10534
|
+
});
|
|
10535
|
+
function blocks3(node, out = []) {
|
|
10536
|
+
if (node.type === "paragraph" || node.type === "heading") {
|
|
10537
|
+
const text = (node.content ?? []).map((n) => n.type === "text" ? n.text : n.type === "hardBreak" ? "\n" : n.type === "math" ? ` ${n.attrs?.latex} ` : "").join("").trim();
|
|
10538
|
+
if (text) out.push(text);
|
|
10539
|
+
} else node.content?.forEach((n) => blocks3(n, out));
|
|
10540
|
+
return out;
|
|
10541
|
+
}
|
|
10542
|
+
async function textOf2(kind, bytes) {
|
|
10543
|
+
return blocks3(kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc);
|
|
10544
|
+
}
|
|
10545
|
+
function inside(a, b) {
|
|
10546
|
+
const x = words2(a), y = words2(b);
|
|
10547
|
+
const map = diff(x, y);
|
|
10548
|
+
const out = [];
|
|
10549
|
+
const push = (text, op) => {
|
|
10550
|
+
const last2 = out[out.length - 1];
|
|
10551
|
+
if (last2?.op === op) last2.text += text;
|
|
10552
|
+
else out.push({ text, op });
|
|
10553
|
+
};
|
|
10554
|
+
let i = 0;
|
|
10555
|
+
map.forEach((from, j) => {
|
|
10556
|
+
if (from < 0) {
|
|
10557
|
+
const next = map.findIndex((n, at2) => at2 > j && n >= 0);
|
|
10558
|
+
while (i < (next < 0 ? x.length : map[next])) push(x[i++], "-");
|
|
10559
|
+
return push(y[j], "+");
|
|
10560
|
+
}
|
|
10561
|
+
while (i < from) push(x[i++], "-");
|
|
10562
|
+
push(y[j], "=");
|
|
10563
|
+
i = from + 1;
|
|
10564
|
+
});
|
|
10565
|
+
while (i < x.length) push(x[i++], "-");
|
|
10566
|
+
return out;
|
|
10567
|
+
}
|
|
10568
|
+
function changes2(before, after) {
|
|
10569
|
+
const map = diff(before, after);
|
|
10570
|
+
const rows = [];
|
|
10571
|
+
let gone = [];
|
|
10572
|
+
const drop2 = (n) => {
|
|
10573
|
+
gone.slice(0, n).forEach((text) => rows.push({ op: "-", parts: [{ text, op: "-" }] }));
|
|
10574
|
+
gone = gone.slice(n);
|
|
10575
|
+
};
|
|
10576
|
+
let i = 0;
|
|
10577
|
+
map.forEach((from, j) => {
|
|
10578
|
+
if (from >= 0) {
|
|
10579
|
+
while (i < from) gone.push(before[i++]);
|
|
10580
|
+
drop2(gone.length);
|
|
10581
|
+
rows.push({ op: "=", parts: [{ text: after[j], op: "=" }] });
|
|
10582
|
+
i = from + 1;
|
|
10583
|
+
return;
|
|
10584
|
+
}
|
|
10585
|
+
const next = map.findIndex((n, at2) => at2 > j && n >= 0);
|
|
10586
|
+
while (i < (next < 0 ? before.length : map[next])) gone.push(before[i++]);
|
|
10587
|
+
const k = gone.findIndex((old) => alike(old, after[j]) >= 0.4);
|
|
10588
|
+
if (k < 0) return rows.push({ op: "+", parts: [{ text: after[j], op: "+" }] });
|
|
10589
|
+
drop2(k);
|
|
10590
|
+
rows.push({ op: "~", parts: inside(gone.shift(), after[j]) });
|
|
10591
|
+
});
|
|
10592
|
+
while (i < before.length) gone.push(before[i++]);
|
|
10593
|
+
drop2(gone.length);
|
|
10594
|
+
return rows;
|
|
10595
|
+
}
|
|
10596
|
+
function Compare({ host, documentId, kind, older, t }) {
|
|
10597
|
+
const rows = useLoad(async (signal) => changes2(await textOf2(kind, older), await textOf2(kind, await host.content(documentId, null, { signal }))), [host, documentId, older]);
|
|
10598
|
+
if (rows.error) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.failed });
|
|
10599
|
+
if (!rows.data) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
|
|
10600
|
+
const added = rows.data.filter((r) => r.op === "+").length, removed = rows.data.filter((r) => r.op === "-").length, edited = rows.data.filter((r) => r.op === "~").length;
|
|
10601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-page w100n-compare", children: [
|
|
10602
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-compare-sum", children: added + removed + edited ? t.changeCount.replace("{added}", String(added)).replace("{edited}", String(edited)).replace("{removed}", String(removed)) : t.noChanges }),
|
|
10603
|
+
rows.data.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { "data-op": r.op, children: r.parts.map((p, k) => p.op === "=" ? p.text : p.op === "+" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ins", { children: p.text }, k) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("del", { children: p.text }, k)) }, i))
|
|
10604
|
+
] }) });
|
|
10605
|
+
}
|
|
10606
|
+
var import_jsx_runtime12, words2, alike;
|
|
10607
|
+
var init_Compare = __esm({
|
|
10608
|
+
"src/Compare.tsx"() {
|
|
10609
|
+
"use strict";
|
|
10610
|
+
init_docx();
|
|
10611
|
+
init_diff();
|
|
10612
|
+
init_markdown();
|
|
10613
|
+
init_useLoad();
|
|
10614
|
+
import_jsx_runtime12 = require("react/jsx-runtime");
|
|
10615
|
+
words2 = (text) => text.split(/(\s+)/).filter(Boolean);
|
|
10616
|
+
alike = (a, b) => {
|
|
10617
|
+
const x = a.split(/\s+/).filter(Boolean), y = b.split(/\s+/).filter(Boolean);
|
|
10618
|
+
return diff(x, y).filter((n) => n >= 0).length / Math.max(x.length, y.length, 1);
|
|
10619
|
+
};
|
|
10620
|
+
}
|
|
10621
|
+
});
|
|
10622
|
+
|
|
10300
10623
|
// src/index.ts
|
|
10301
10624
|
var index_exports = {};
|
|
10302
10625
|
__export(index_exports, {
|
|
@@ -10354,8 +10677,8 @@ function readable(name, mimeType) {
|
|
|
10354
10677
|
return kind !== "sheet" || /\.(xlsx|csv)$/i.test(name) || /spreadsheetml|text\/csv/.test(mimeType ?? "") ? kind : null;
|
|
10355
10678
|
}
|
|
10356
10679
|
function matches(doc, query, picked) {
|
|
10357
|
-
const
|
|
10358
|
-
return (!picked.length || picked.includes(doc.kind)) &&
|
|
10680
|
+
const words3 = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
10681
|
+
return (!picked.length || picked.includes(doc.kind)) && words3.every((word) => doc.name.toLocaleLowerCase().includes(word));
|
|
10359
10682
|
}
|
|
10360
10683
|
|
|
10361
10684
|
// src/slides/SlidesView.tsx
|
|
@@ -10447,8 +10770,8 @@ var tagName = /<([a-zA-Z][^\s/>]*)/y;
|
|
|
10447
10770
|
var endTag = /<\/([a-zA-Z][^\s/>]*)[^>]*>/y;
|
|
10448
10771
|
var attrName = /[^\s/>=]+/y;
|
|
10449
10772
|
var bare = /[^\s>]*/y;
|
|
10450
|
-
var sticky = (re, s,
|
|
10451
|
-
re.lastIndex =
|
|
10773
|
+
var sticky = (re, s, at2) => {
|
|
10774
|
+
re.lastIndex = at2;
|
|
10452
10775
|
return re.exec(s);
|
|
10453
10776
|
};
|
|
10454
10777
|
function parse(html) {
|
|
@@ -10460,9 +10783,9 @@ function parse(html) {
|
|
|
10460
10783
|
const text = (start, end) => {
|
|
10461
10784
|
if (end > start) top().children.push({ text: true, start, end });
|
|
10462
10785
|
};
|
|
10463
|
-
const shut = (k,
|
|
10464
|
-
for (let i2 = stack.length - 1; i2 > k; i2--) stack[i2].close = stack[i2].end =
|
|
10465
|
-
stack[k].close =
|
|
10786
|
+
const shut = (k, at2, end) => {
|
|
10787
|
+
for (let i2 = stack.length - 1; i2 > k; i2--) stack[i2].close = stack[i2].end = at2;
|
|
10788
|
+
stack[k].close = at2;
|
|
10466
10789
|
stack[k].end = end;
|
|
10467
10790
|
for (let i2 = stack.length - 1; i2 >= k; i2--) if (stack[i2].tag === "svg" || stack[i2].tag === "math") foreign--;
|
|
10468
10791
|
stack.length = k;
|
|
@@ -10529,24 +10852,24 @@ function parse(html) {
|
|
|
10529
10852
|
j += n[0].length;
|
|
10530
10853
|
while (j < len && /\s/.test(html[j])) j++;
|
|
10531
10854
|
let value3 = "";
|
|
10532
|
-
let
|
|
10855
|
+
let at2 = null;
|
|
10533
10856
|
if (html[j] === "=") {
|
|
10534
10857
|
j++;
|
|
10535
10858
|
while (j < len && /\s/.test(html[j])) j++;
|
|
10536
10859
|
const q = html[j];
|
|
10537
10860
|
if (q === '"' || q === "'") {
|
|
10538
10861
|
const e = html.indexOf(q, j + 1);
|
|
10539
|
-
|
|
10862
|
+
at2 = [j + 1, e < 0 ? len : e];
|
|
10540
10863
|
j = e < 0 ? len : e + 1;
|
|
10541
10864
|
} else {
|
|
10542
10865
|
const v = sticky(bare, html, j);
|
|
10543
|
-
|
|
10866
|
+
at2 = [j, j + v[0].length];
|
|
10544
10867
|
j += v[0].length;
|
|
10545
10868
|
}
|
|
10546
|
-
value3 = decode(html.slice(
|
|
10869
|
+
value3 = decode(html.slice(at2[0], at2[1]));
|
|
10547
10870
|
}
|
|
10548
10871
|
const key2 = n[0].toLowerCase();
|
|
10549
|
-
if (!attrs2.has(key2)) attrs2.set(key2, { value: value3, at });
|
|
10872
|
+
if (!attrs2.has(key2)) attrs2.set(key2, { value: value3, at: at2 });
|
|
10550
10873
|
}
|
|
10551
10874
|
if (breaks.has(tag)) {
|
|
10552
10875
|
const k = seek(["p"], fences);
|
|
@@ -10665,12 +10988,12 @@ var flat = (el, html) => {
|
|
|
10665
10988
|
});
|
|
10666
10989
|
return visit(el) && (text || boxes.has(el.tag));
|
|
10667
10990
|
};
|
|
10668
|
-
var blocksOf = (el, html,
|
|
10991
|
+
var blocksOf = (el, html, notes3) => {
|
|
10669
10992
|
if (flat(el, html)) return [el];
|
|
10670
10993
|
const out = [];
|
|
10671
10994
|
const walk = (e) => {
|
|
10672
10995
|
for (const part of e.children) {
|
|
10673
|
-
if (part.text || part ===
|
|
10996
|
+
if (part.text || part === notes3 || skip.has(part.tag) || part.attrs.get("contenteditable")?.value === "false") continue;
|
|
10674
10997
|
if (flat(part, html)) out.push(part);
|
|
10675
10998
|
else walk(part);
|
|
10676
10999
|
}
|
|
@@ -10687,8 +11010,8 @@ var notesHtml = (text) => escape(text).split("\n").join("<br>\n");
|
|
|
10687
11010
|
var sizeOf = (html, kind, scripts, styles2, marks2) => {
|
|
10688
11011
|
if (kind === "reveal") {
|
|
10689
11012
|
const code = scripts.map((s) => html.slice(s.open, s.close)).join("\n");
|
|
10690
|
-
const
|
|
10691
|
-
const init2 =
|
|
11013
|
+
const at2 = code.search(/Reveal\.initialize\s*\(/);
|
|
11014
|
+
const init2 = at2 < 0 ? "" : code.slice(at2, at2 + 4e3);
|
|
10692
11015
|
const width = Number(/\bwidth\s*:\s*['"]?(\d+)/.exec(init2)?.[1] ?? 960);
|
|
10693
11016
|
const height = Number(/\bheight\s*:\s*['"]?(\d+)/.exec(init2)?.[1] ?? 700);
|
|
10694
11017
|
return { width, height, center: !/\bcenter\s*:\s*false/.test(init2) };
|
|
@@ -10718,14 +11041,14 @@ function shape(html) {
|
|
|
10718
11041
|
const outer = all.find((el) => el.tag === "html");
|
|
10719
11042
|
const body = all.find((el) => el.tag === "body") ?? null;
|
|
10720
11043
|
const doctype = /^\s*<!doctype[^>]*>/i.exec(html);
|
|
10721
|
-
const
|
|
11044
|
+
const at2 = head2 ? head2.open : outer ? outer.open : doctype ? doctype[0].length : 0;
|
|
10722
11045
|
const reveal = all.find((el) => classes(el).includes("reveal")) ?? null;
|
|
10723
11046
|
const box2 = reveal && all.find((el) => classes(el).includes("slides") && under(el, (up) => up === reveal));
|
|
10724
11047
|
const spots = [];
|
|
10725
11048
|
const stacks = [];
|
|
10726
11049
|
const spot3 = (el, stack) => {
|
|
10727
|
-
const
|
|
10728
|
-
spots.push({ el, stack, notes:
|
|
11050
|
+
const notes3 = notesOf(el);
|
|
11051
|
+
spots.push({ el, stack, notes: notes3, attr: notes3 ? null : el.attrs.get("data-notes") ?? null, blocks: blocksOf(el, html, notes3) });
|
|
10729
11052
|
};
|
|
10730
11053
|
let kind;
|
|
10731
11054
|
let units;
|
|
@@ -10759,7 +11082,7 @@ function shape(html) {
|
|
|
10759
11082
|
for (const unit of units) spot3(unit, null);
|
|
10760
11083
|
}
|
|
10761
11084
|
const size2 = sizeOf(html, kind, scripts, styles2, [container, ...body ? [body] : [], ...outer ? [outer] : []]);
|
|
10762
|
-
return { kind, ...size2, root, box: container, units, stacks, spots, scripts, refresh, head:
|
|
11085
|
+
return { kind, ...size2, root, box: container, units, stacks, spots, scripts, refresh, head: at2, body };
|
|
10763
11086
|
}
|
|
10764
11087
|
var titleOf = (html, s) => {
|
|
10765
11088
|
const heading = elements(s.el).find((el2) => /^h[1-6]$/.test(el2.tag) && !(s.notes && under(el2, (up) => up === s.notes)));
|
|
@@ -10802,8 +11125,8 @@ function cuts(html, s, slide, stamp) {
|
|
|
10802
11125
|
const lead = /^\s*/.exec(inner2)[0];
|
|
10803
11126
|
const tail = /\s*$/.exec(inner2)[0];
|
|
10804
11127
|
const indent2 = lead.includes("\n") ? lead.slice(lead.lastIndexOf("\n")) : "";
|
|
10805
|
-
const
|
|
10806
|
-
out.push([
|
|
11128
|
+
const at2 = Math.max(s.el.open, s.el.close - tail.length);
|
|
11129
|
+
out.push([at2, at2, `${indent2}<aside class="notes">${notesHtml(slide.notes)}</aside>`]);
|
|
10807
11130
|
}
|
|
10808
11131
|
}
|
|
10809
11132
|
return out;
|
|
@@ -10811,13 +11134,13 @@ function cuts(html, s, slide, stamp) {
|
|
|
10811
11134
|
function apply(html, from, to, list) {
|
|
10812
11135
|
const sorted = [...list].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
10813
11136
|
const out = [];
|
|
10814
|
-
let
|
|
11137
|
+
let at2 = from;
|
|
10815
11138
|
for (const [start, end, put] of sorted) {
|
|
10816
|
-
if (start <
|
|
10817
|
-
out.push(html.slice(
|
|
10818
|
-
|
|
11139
|
+
if (start < at2 || end > to) continue;
|
|
11140
|
+
out.push(html.slice(at2, start), put);
|
|
11141
|
+
at2 = end;
|
|
10819
11142
|
}
|
|
10820
|
-
out.push(html.slice(
|
|
11143
|
+
out.push(html.slice(at2, to));
|
|
10821
11144
|
return out.join("");
|
|
10822
11145
|
}
|
|
10823
11146
|
var blank = (s) => !/\S/.test(s);
|
|
@@ -10862,15 +11185,15 @@ function writeDeck(original, deck, known) {
|
|
|
10862
11185
|
function moveSlide(deck, from, to) {
|
|
10863
11186
|
const slide = deck.slides[from];
|
|
10864
11187
|
const rest = deck.slides.filter((_, i) => i !== from);
|
|
10865
|
-
let
|
|
11188
|
+
let at2 = Math.max(0, Math.min(rest.length, to));
|
|
10866
11189
|
const run3 = rest.flatMap((other, i) => slide.stack !== null && other.stack === slide.stack ? [i] : []);
|
|
10867
|
-
if (run3.length)
|
|
10868
|
-
else if (
|
|
10869
|
-
let end =
|
|
10870
|
-
while (end < rest.length && rest[end].stack === rest[
|
|
10871
|
-
|
|
11190
|
+
if (run3.length) at2 = Math.max(run3[0], Math.min(run3[run3.length - 1] + 1, at2));
|
|
11191
|
+
else if (at2 > 0 && at2 < rest.length && rest[at2].stack !== null && rest[at2 - 1].stack === rest[at2].stack) {
|
|
11192
|
+
let end = at2;
|
|
11193
|
+
while (end < rest.length && rest[end].stack === rest[at2].stack) end++;
|
|
11194
|
+
at2 = to > from ? end : rest.findIndex((other) => other.stack === rest[at2].stack);
|
|
10872
11195
|
}
|
|
10873
|
-
return { ...deck, slides: [...rest.slice(0,
|
|
11196
|
+
return { ...deck, slides: [...rest.slice(0, at2), slide, ...rest.slice(at2)] };
|
|
10874
11197
|
}
|
|
10875
11198
|
var duplicateSlide = (deck, i, key2) => ({ ...deck, slides: [...deck.slides.slice(0, i + 1), { ...deck.slides[i], key: key2 }, ...deck.slides.slice(i + 1)] });
|
|
10876
11199
|
var deleteSlide = (deck, i) => ({ ...deck, slides: deck.slides.filter((_, k) => k !== i) });
|
|
@@ -11147,7 +11470,7 @@ function SlidesView({ html, name, rights, language = "en", theme = "light", base
|
|
|
11147
11470
|
const live = (0, import_react2.useRef)(state);
|
|
11148
11471
|
const [saved, setSaved] = (0, import_react2.useState)({ html, deck: source.deck });
|
|
11149
11472
|
const [prop, setProp] = (0, import_react2.useState)(html);
|
|
11150
|
-
const [
|
|
11473
|
+
const [at2, setAt] = (0, import_react2.useState)(0);
|
|
11151
11474
|
if (html !== prop) {
|
|
11152
11475
|
setProp(html);
|
|
11153
11476
|
if (html !== saved.html) {
|
|
@@ -11165,7 +11488,7 @@ function SlidesView({ html, name, rights, language = "en", theme = "light", base
|
|
|
11165
11488
|
};
|
|
11166
11489
|
const { deck, epoch } = state;
|
|
11167
11490
|
const count = deck.slides.length;
|
|
11168
|
-
const index = Math.min(
|
|
11491
|
+
const index = Math.min(at2, count - 1);
|
|
11169
11492
|
const slide = deck.slides[index];
|
|
11170
11493
|
const can = rights.edit && !!onSaveRequest;
|
|
11171
11494
|
const movable = can && deck.kind !== "page";
|
|
@@ -11706,7 +12029,7 @@ var same = (a, b) => !!b && a.page === b.page && a.start === b.start;
|
|
|
11706
12029
|
var spot = (b, size2) => ({ left: pct(b.x / size2.w), top: pct(b.y / size2.h), width: pct(b.w / size2.w), height: pct(b.h / size2.h) });
|
|
11707
12030
|
function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
11708
12031
|
const paint2 = (0, import_react5.useRef)(null);
|
|
11709
|
-
const
|
|
12032
|
+
const words3 = (0, import_react5.useRef)(null);
|
|
11710
12033
|
const forms = (0, import_react5.useRef)(null);
|
|
11711
12034
|
const focus = (0, import_react5.useRef)(null);
|
|
11712
12035
|
const rubbed = (0, import_react5.useRef)(null);
|
|
@@ -11718,7 +12041,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11718
12041
|
const hitKey = layers ? layers.hits.map((hit) => `${hit.start}:${hit.end}`).join() : "";
|
|
11719
12042
|
(0, import_react5.useEffect)(() => {
|
|
11720
12043
|
if (!live) return;
|
|
11721
|
-
const holders = [paint2,
|
|
12044
|
+
const holders = [paint2, words3, forms].flatMap((ref) => ref.current ? [ref.current] : []);
|
|
11722
12045
|
return () => {
|
|
11723
12046
|
for (const holder of holders) {
|
|
11724
12047
|
for (const canvas of holder.querySelectorAll("canvas")) {
|
|
@@ -11803,7 +12126,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11803
12126
|
const end = document.createElement("div");
|
|
11804
12127
|
end.className = "endOfContent";
|
|
11805
12128
|
layer.append(end);
|
|
11806
|
-
|
|
12129
|
+
words3.current.replaceChildren(layer);
|
|
11807
12130
|
const annotations = await page.getAnnotations();
|
|
11808
12131
|
for (const a of annotations) {
|
|
11809
12132
|
if (!a.fieldName || a.pushButton || !["Tx", "Btn", "Ch"].includes(a.fieldType)) continue;
|
|
@@ -11839,7 +12162,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11839
12162
|
};
|
|
11840
12163
|
}, [pdf, n, live, fill3]);
|
|
11841
12164
|
(0, import_react5.useLayoutEffect)(() => {
|
|
11842
|
-
const layer =
|
|
12165
|
+
const layer = words3.current?.firstElementChild;
|
|
11843
12166
|
if (!layers || !layer || !hitKey) {
|
|
11844
12167
|
setBoxes([]);
|
|
11845
12168
|
return;
|
|
@@ -11847,13 +12170,13 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11847
12170
|
const frame = layer.getBoundingClientRect();
|
|
11848
12171
|
const k = frame.width ? size2.w / frame.width : 1 / scale;
|
|
11849
12172
|
const parts2 = [];
|
|
11850
|
-
let
|
|
12173
|
+
let at3 = 0;
|
|
11851
12174
|
const walk = document.createTreeWalker(layer, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
|
|
11852
12175
|
for (let node = walk.nextNode(); node; node = walk.nextNode()) {
|
|
11853
12176
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
11854
|
-
parts2.push({ node, start:
|
|
11855
|
-
|
|
11856
|
-
} else if (node.nodeName === "BR")
|
|
12177
|
+
parts2.push({ node, start: at3 });
|
|
12178
|
+
at3 += node.length;
|
|
12179
|
+
} else if (node.nodeName === "BR") at3 += 1;
|
|
11857
12180
|
}
|
|
11858
12181
|
setBoxes(layers.hits.flatMap((hit) => parts2.flatMap(({ node, start }) => {
|
|
11859
12182
|
const from = Math.max(hit.start, start);
|
|
@@ -11877,13 +12200,13 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11877
12200
|
if (!layers) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w100n-pdf-page", "data-n": n, style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: paint2, className: "w100n-pdf-paint" }) });
|
|
11878
12201
|
const { tool, marks: marks2, act, t, open } = layers;
|
|
11879
12202
|
const first = boxes3.findIndex((b) => same(b.hit, layers.active));
|
|
11880
|
-
const
|
|
12203
|
+
const at2 = (e) => {
|
|
11881
12204
|
const r = e.currentTarget.closest(".w100n-pdf-page").getBoundingClientRect();
|
|
11882
12205
|
return { x: (e.clientX - r.left) / scale, y: (e.clientY - r.top) / scale };
|
|
11883
12206
|
};
|
|
11884
12207
|
const line = (points) => points.map((p, i) => `${i ? "L" : "M"}${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join(" ");
|
|
11885
12208
|
const down2 = (e) => {
|
|
11886
|
-
const p =
|
|
12209
|
+
const p = at2(e);
|
|
11887
12210
|
if (tool === "note" || tool === "place") {
|
|
11888
12211
|
e.preventDefault();
|
|
11889
12212
|
if (tool === "note") act.note(n, p);
|
|
@@ -11899,7 +12222,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11899
12222
|
};
|
|
11900
12223
|
const move2 = (e) => {
|
|
11901
12224
|
if (!e.buttons) return;
|
|
11902
|
-
const p =
|
|
12225
|
+
const p = at2(e);
|
|
11903
12226
|
if (stroke) {
|
|
11904
12227
|
const last2 = stroke[stroke.length - 1];
|
|
11905
12228
|
if (Math.hypot(p.x - last2.x, p.y - last2.y) > 0.8) setStroke([...stroke, p]);
|
|
@@ -11914,11 +12237,11 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11914
12237
|
e.stopPropagation();
|
|
11915
12238
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
11916
12239
|
act.open(mark.id);
|
|
11917
|
-
setDrag({ id: mark.id, from:
|
|
12240
|
+
setDrag({ id: mark.id, from: at2(e), start: mark.box, box: mark.box, resize: resize2 });
|
|
11918
12241
|
};
|
|
11919
12242
|
const pull = (e) => {
|
|
11920
12243
|
if (!drag) return;
|
|
11921
|
-
const p =
|
|
12244
|
+
const p = at2(e);
|
|
11922
12245
|
const dx = p.x - drag.from.x;
|
|
11923
12246
|
const { start } = drag;
|
|
11924
12247
|
if (drag.resize) {
|
|
@@ -11934,7 +12257,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
11934
12257
|
};
|
|
11935
12258
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "w100n-pdf-page", id, "data-n": n, style, children: [
|
|
11936
12259
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: paint2, className: "w100n-pdf-paint" }),
|
|
11937
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref:
|
|
12260
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: words3, className: "w100n-pdf-words" }),
|
|
11938
12261
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: forms, className: "w100n-pdf-forms" }),
|
|
11939
12262
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { className: "w100n-pdf-marks", viewBox: `0 0 ${size2.w} ${size2.h}`, preserveAspectRatio: "none", "aria-hidden": true, children: [
|
|
11940
12263
|
marks2.map((mark) => {
|
|
@@ -12034,11 +12357,11 @@ var dist = (p, a, b) => {
|
|
|
12034
12357
|
return Math.hypot(p.x - a.x - k * dx, p.y - a.y - k * dy);
|
|
12035
12358
|
};
|
|
12036
12359
|
var touches = (m, p) => {
|
|
12037
|
-
const
|
|
12038
|
-
if (m.kind === "note") return
|
|
12039
|
-
if (m.kind === "sign") return
|
|
12360
|
+
const inside2 = (b) => p.x >= b.x - 2 && p.x <= b.x + b.w + 2 && p.y >= b.y - 2 && p.y <= b.y + b.h + 2;
|
|
12361
|
+
if (m.kind === "note") return inside2({ ...m.spot, w: 20, h: 20 });
|
|
12362
|
+
if (m.kind === "sign") return inside2(m.box);
|
|
12040
12363
|
if (m.kind === "ink") return m.lines.some((line) => line.some((q, i) => dist(p, line[Math.max(0, i - 1)], q) < m.width / 2 + 4));
|
|
12041
|
-
return m.rects.some(
|
|
12364
|
+
return m.rects.some(inside2);
|
|
12042
12365
|
};
|
|
12043
12366
|
function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved, onOutline, guard }) {
|
|
12044
12367
|
const prefix = (0, import_react6.useId)();
|
|
@@ -12050,7 +12373,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12050
12373
|
const pad = (0, import_react6.useRef)(null);
|
|
12051
12374
|
const inked = (0, import_react6.useRef)(null);
|
|
12052
12375
|
const widgets = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
|
|
12053
|
-
const
|
|
12376
|
+
const words3 = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
|
|
12054
12377
|
const anchor = (0, import_react6.useRef)({ scale: 0, page: 0, frac: 0 });
|
|
12055
12378
|
const [pdf, setPdf] = (0, import_react6.useState)(null);
|
|
12056
12379
|
const [sizes2, setSizes] = (0, import_react6.useState)([]);
|
|
@@ -12064,7 +12387,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12064
12387
|
const [typed, setTyped] = (0, import_react6.useState)(null);
|
|
12065
12388
|
const [query, setQuery] = (0, import_react6.useState)(null);
|
|
12066
12389
|
const [hits, setHits] = (0, import_react6.useState)({ list: [], done: true });
|
|
12067
|
-
const [
|
|
12390
|
+
const [at2, setAt] = (0, import_react6.useState)(0);
|
|
12068
12391
|
const [tool, setTool] = (0, import_react6.useState)("select");
|
|
12069
12392
|
const [pen, setPen] = (0, import_react6.useState)({ highlight: "#facc15", line: "#dc2626", ink: "#2563eb", width: 2 });
|
|
12070
12393
|
const [palette2, setPalette] = (0, import_react6.useState)(false);
|
|
@@ -12092,7 +12415,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12092
12415
|
setFilled(false);
|
|
12093
12416
|
setOpen(null);
|
|
12094
12417
|
widgets.current = /* @__PURE__ */ new Map();
|
|
12095
|
-
|
|
12418
|
+
words3.current = /* @__PURE__ */ new Map();
|
|
12096
12419
|
(async () => {
|
|
12097
12420
|
var _a;
|
|
12098
12421
|
const pdfjs = await import("pdfjs-dist");
|
|
@@ -12217,11 +12540,11 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12217
12540
|
const timer = setTimeout(async () => {
|
|
12218
12541
|
const found = [];
|
|
12219
12542
|
for (let n = 1; n <= pdf.numPages && !stop; n++) {
|
|
12220
|
-
let text =
|
|
12543
|
+
let text = words3.current.get(n);
|
|
12221
12544
|
if (text === void 0) {
|
|
12222
12545
|
const content = await (await pdf.getPage(n)).getTextContent();
|
|
12223
12546
|
text = content.items.map((piece) => "str" in piece ? piece.str + (piece.hasEOL ? " " : "") : "").join("").toLowerCase();
|
|
12224
|
-
|
|
12547
|
+
words3.current.set(n, text);
|
|
12225
12548
|
}
|
|
12226
12549
|
for (let i = text.indexOf(needle); i >= 0; i = text.indexOf(needle, i + needle.length)) found.push({ page: n, start: i, end: i + needle.length });
|
|
12227
12550
|
if (!stop && (n % 20 === 0 || n === pdf.numPages)) setHits({ list: [...found], done: n === pdf.numPages });
|
|
@@ -12265,7 +12588,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12265
12588
|
};
|
|
12266
12589
|
const step = (d) => {
|
|
12267
12590
|
if (!hits.list.length) return;
|
|
12268
|
-
const next = (
|
|
12591
|
+
const next = (at2 + d + hits.list.length) % hits.list.length;
|
|
12269
12592
|
setAt(next);
|
|
12270
12593
|
const n = hits.list[next].page;
|
|
12271
12594
|
if (tops[n - 1] + sizes2[n - 1].h * scale < top || tops[n - 1] > top + box2.h) go(n);
|
|
@@ -12520,7 +12843,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12520
12843
|
{ key: "find", at: 0, Icon: import_lucide_react4.Search, label: t.find, run: () => setQuery(query === null ? "" : null), pressed: query !== null },
|
|
12521
12844
|
...can.mark ? [
|
|
12522
12845
|
{ key: "g3", at: 2, node: gap },
|
|
12523
|
-
...tools.filter(([, , , shown]) => shown).map(([key2, Icon, label, ,
|
|
12846
|
+
...tools.filter(([, , , shown]) => shown).map(([key2, Icon, label, , at3]) => ({ key: key2, at: at3, Icon, label, run: () => pick(key2), pressed: tool === key2 })),
|
|
12524
12847
|
...can.edit ? [{ key: "sign", at: 2, Icon: import_lucide_react4.Signature, label: t.sign, run: () => setSigning({ tab: "typed", name: me, image: null, drawn: false }), pressed: tool === "place" || signing !== null }] : [],
|
|
12525
12848
|
{ key: "colour", at: 0, node: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "w100n-pdf-palette", children: [
|
|
12526
12849
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-expanded": palette2, onClick: () => {
|
|
@@ -12607,7 +12930,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12607
12930
|
}
|
|
12608
12931
|
}
|
|
12609
12932
|
),
|
|
12610
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-live": "polite", children: hits.list.length ? `${Math.min(
|
|
12933
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-live": "polite", children: hits.list.length ? `${Math.min(at2 + 1, hits.list.length)} / ${hits.list.length}` : query.trim() ? hits.done ? t.noHits : t.searching : "" }),
|
|
12611
12934
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", disabled: !hits.list.length, onClick: () => step(-1), "aria-label": t.previous, title: t.previous, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.ChevronUp, { "aria-hidden": true }) }),
|
|
12612
12935
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", disabled: !hits.list.length, onClick: () => step(1), "aria-label": t.next, title: t.next, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.ChevronDown, { "aria-hidden": true }) }),
|
|
12613
12936
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => setQuery(null), "aria-label": t.close, title: t.close, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react4.X, { "aria-hidden": true }) })
|
|
@@ -12652,7 +12975,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
12652
12975
|
tool,
|
|
12653
12976
|
marks: byPage.get(i + 1) ?? [],
|
|
12654
12977
|
hits: hitsBy.get(i + 1) ?? [],
|
|
12655
|
-
active: hits.list[
|
|
12978
|
+
active: hits.list[at2],
|
|
12656
12979
|
open,
|
|
12657
12980
|
pen: { color: pen.ink, width: pen.width },
|
|
12658
12981
|
widgets: widgets.current,
|
|
@@ -12904,8 +13227,8 @@ var table2 = (rows) => {
|
|
|
12904
13227
|
return `<w:tbl><w:tblPr><w:tblW w:w="5000" w:type="pct"/><w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(border).join("")}</w:tblBorders></w:tblPr><w:tblGrid>${rows[0].map(() => `<w:gridCol w:w="${width}"/>`).join("")}</w:tblGrid>` + rows.map((row2, r) => `<w:tr>${row2.map((cell2) => `<w:tc><w:tcPr><w:tcW w:w="${width}" w:type="dxa"/></w:tcPr><w:p>${r === 0 ? `<w:r><w:rPr><w:b/></w:rPr><w:t xml:space="preserve">${escape2(cell2)}</w:t></w:r>` : run2(cell2)}</w:p></w:tc>`).join("")}</w:tr>`).join("") + "</w:tbl><w:p/>";
|
|
12905
13228
|
};
|
|
12906
13229
|
var styles = `${head}<w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:eastAsia="Arial" w:cs="Arial"/><w:sz w:val="22"/><w:szCs w:val="22"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="120" w:line="276" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:after="80"/></w:pPr><w:rPr><w:b/><w:sz w:val="48"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="heading 1"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="360" w:after="120"/><w:outlineLvl w:val="0"/></w:pPr><w:rPr><w:b/><w:sz w:val="32"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading2"><w:name w:val="heading 2"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="240" w:after="80"/><w:outlineLvl w:val="1"/></w:pPr><w:rPr><w:b/><w:sz w:val="26"/></w:rPr></w:style></w:styles>`;
|
|
12907
|
-
function docx(
|
|
12908
|
-
const body =
|
|
13230
|
+
function docx(blocks4) {
|
|
13231
|
+
const body = blocks4.map((block2) => typeof block2[0] === "string" || block2[0] === null ? para(block2) : table2(block2)).join("") || "<w:p/>";
|
|
12909
13232
|
return (0, import_fflate2.zipSync)({
|
|
12910
13233
|
"[Content_Types].xml": (0, import_fflate2.strToU8)(`${head}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/></Types>`),
|
|
12911
13234
|
"_rels/.rels": (0, import_fflate2.strToU8)(`${head}<Relationships xmlns="${PKG}"><Relationship Id="rId1" Type="${REL3}/officeDocument" Target="word/document.xml"/></Relationships>`),
|
|
@@ -12914,7 +13237,7 @@ function docx(blocks3) {
|
|
|
12914
13237
|
"word/document.xml": (0, import_fflate2.strToU8)(`${head}<w:document xmlns:w="${W}" xmlns:r="${REL3}"><w:body>${body}<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1417" w:right="1134" w:bottom="1417" w:left="1134" w:header="708" w:footer="708" w:gutter="0"/></w:sectPr></w:body></w:document>`)
|
|
12915
13238
|
});
|
|
12916
13239
|
}
|
|
12917
|
-
function markdown(
|
|
13240
|
+
function markdown(blocks4) {
|
|
12918
13241
|
const line = (block2) => {
|
|
12919
13242
|
if (typeof block2[0] === "string" || block2[0] === null) {
|
|
12920
13243
|
const [style, text] = block2;
|
|
@@ -12923,7 +13246,7 @@ function markdown(blocks3) {
|
|
|
12923
13246
|
const rows = block2;
|
|
12924
13247
|
return [rows[0], rows[0].map(() => "---"), ...rows.slice(1)].map((row2) => `| ${row2.join(" | ")} |`).join("\n");
|
|
12925
13248
|
};
|
|
12926
|
-
return (0, import_fflate2.strToU8)(
|
|
13249
|
+
return (0, import_fflate2.strToU8)(blocks4.map(line).join("\n\n").replace(/\n{3,}/g, "\n\n") + "\n");
|
|
12927
13250
|
}
|
|
12928
13251
|
var S = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
12929
13252
|
function sheet() {
|
|
@@ -12956,8 +13279,8 @@ var slides = (name) => (0, import_fflate2.strToU8)(`<!DOCTYPE html>
|
|
|
12956
13279
|
</html>
|
|
12957
13280
|
`);
|
|
12958
13281
|
function blank4(kind, name, template = "blank") {
|
|
12959
|
-
const
|
|
12960
|
-
const bytes = kind === "docx" ? docx(
|
|
13282
|
+
const blocks4 = template === "blank" ? [] : templates[template](name);
|
|
13283
|
+
const bytes = kind === "docx" ? docx(blocks4) : kind === "markdown" ? markdown(blocks4.length ? blocks4 : [["Title", name]]) : kind === "sheet" ? sheet() : slides(name);
|
|
12961
13284
|
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
12962
13285
|
}
|
|
12963
13286
|
|
|
@@ -13050,8 +13373,8 @@ init_useLoad();
|
|
|
13050
13373
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
13051
13374
|
var blank5 = { id: null, comment: false, download: false, askName: true, works: "30", day: "", password: false, secret: "", had: false };
|
|
13052
13375
|
var local = (iso) => {
|
|
13053
|
-
const
|
|
13054
|
-
return `${
|
|
13376
|
+
const at2 = new Date(iso);
|
|
13377
|
+
return `${at2.getFullYear()}-${String(at2.getMonth() + 1).padStart(2, "0")}-${String(at2.getDate()).padStart(2, "0")}`;
|
|
13055
13378
|
};
|
|
13056
13379
|
function Sharing({ host, doc, t, language, team }) {
|
|
13057
13380
|
const links = useLoad((signal) => host.links(doc.id, { signal }), [host, doc.id]);
|
|
@@ -13394,9 +13717,10 @@ function Thumb({ host, item, label }) {
|
|
|
13394
13717
|
|
|
13395
13718
|
// src/DocumentsWorkspace.tsx
|
|
13396
13719
|
init_useLoad();
|
|
13397
|
-
var
|
|
13720
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
13398
13721
|
var TextEditor3 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports)));
|
|
13399
13722
|
var SheetView3 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_SheetView(), SheetView_exports)));
|
|
13723
|
+
var Compare2 = (0, import_react16.lazy)(() => Promise.resolve().then(() => (init_Compare(), Compare_exports)));
|
|
13400
13724
|
var icons3 = { docx: import_lucide_react10.FileText, markdown: import_lucide_react10.FileType, pdf: import_lucide_react10.Files, sheet: import_lucide_react10.FileSpreadsheet, slides: import_lucide_react10.Presentation };
|
|
13401
13725
|
function DocumentsWorkspace({ host, language = "en", theme = "light", place: place2, onPlace, start, end, aside, actions }) {
|
|
13402
13726
|
const t = texts[language];
|
|
@@ -13473,6 +13797,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13473
13797
|
const [fold, setFold] = (0, import_react16.useState)({});
|
|
13474
13798
|
const [version2, setVersion] = (0, import_react16.useState)({ documentId: null, id: null });
|
|
13475
13799
|
const versionId = version2.documentId === here.documentId ? version2.id : null;
|
|
13800
|
+
const [comparing, setComparing] = (0, import_react16.useState)(false);
|
|
13476
13801
|
const [restoring, setRestoring] = (0, import_react16.useState)("idle");
|
|
13477
13802
|
const [exporting, setExporting] = (0, import_react16.useState)("idle");
|
|
13478
13803
|
const [copying, setCopying] = (0, import_react16.useState)("idle");
|
|
@@ -13530,9 +13855,9 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13530
13855
|
return new Intl.DateTimeFormat(language, { day: "numeric", month: "short", year: "numeric" }).format(new Date(iso));
|
|
13531
13856
|
};
|
|
13532
13857
|
const size2 = (bytes) => bytes < 1024 ? `${bytes} B` : bytes < 1048576 ? `${(bytes / 1024).toFixed(0)} KB` : `${(bytes / 1048576).toFixed(1)} MB`;
|
|
13533
|
-
const failed = (retry) => /* @__PURE__ */ (0,
|
|
13858
|
+
const failed = (retry) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-note", children: [
|
|
13534
13859
|
t.failed,
|
|
13535
|
-
/* @__PURE__ */ (0,
|
|
13860
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: retry, children: t.retry })
|
|
13536
13861
|
] });
|
|
13537
13862
|
const { ask, dialog } = useUnsaved(guard, t);
|
|
13538
13863
|
const side2 = (which, open2) => {
|
|
@@ -13569,6 +13894,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13569
13894
|
if (id === versionId) return;
|
|
13570
13895
|
ask(() => {
|
|
13571
13896
|
setRestoring("idle");
|
|
13897
|
+
setComparing(false);
|
|
13572
13898
|
setVersion({ documentId: here.documentId, id });
|
|
13573
13899
|
});
|
|
13574
13900
|
};
|
|
@@ -13650,8 +13976,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13650
13976
|
setSending("failed");
|
|
13651
13977
|
}
|
|
13652
13978
|
};
|
|
13653
|
-
let stage = /* @__PURE__ */ (0,
|
|
13654
|
-
/* @__PURE__ */ (0,
|
|
13979
|
+
let stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-empty", children: [
|
|
13980
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileText, { "aria-hidden": true }),
|
|
13655
13981
|
t.pick
|
|
13656
13982
|
] });
|
|
13657
13983
|
if (here.documentId) {
|
|
@@ -13659,8 +13985,9 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13659
13985
|
doc.retry();
|
|
13660
13986
|
content.retry();
|
|
13661
13987
|
});
|
|
13662
|
-
else if (!doc.data || !content.data) stage = /* @__PURE__ */ (0,
|
|
13663
|
-
else if (doc.data.kind === "markdown" || doc.data.kind === "docx") stage = /* @__PURE__ */ (0,
|
|
13988
|
+
else if (!doc.data || !content.data) stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading });
|
|
13989
|
+
else if (comparing && versionId && (doc.data.kind === "markdown" || doc.data.kind === "docx")) stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Compare2, { host, documentId: doc.data.id, kind: doc.data.kind, older: content.data, t }, versionId) });
|
|
13990
|
+
else if (doc.data.kind === "markdown" || doc.data.kind === "docx") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13664
13991
|
TextEditor3,
|
|
13665
13992
|
{
|
|
13666
13993
|
kind: doc.data.kind,
|
|
@@ -13695,7 +14022,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13695
14022
|
},
|
|
13696
14023
|
doc.data.id
|
|
13697
14024
|
) });
|
|
13698
|
-
else if (doc.data.kind === "pdf") stage = /* @__PURE__ */ (0,
|
|
14025
|
+
else if (doc.data.kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13699
14026
|
PdfView,
|
|
13700
14027
|
{
|
|
13701
14028
|
bytes: content.data,
|
|
@@ -13717,7 +14044,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13717
14044
|
},
|
|
13718
14045
|
`${doc.data.id}:${versionId ?? ""}`
|
|
13719
14046
|
);
|
|
13720
|
-
else if (doc.data.kind === "slides") stage = /* @__PURE__ */ (0,
|
|
14047
|
+
else if (doc.data.kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13721
14048
|
SlidesView,
|
|
13722
14049
|
{
|
|
13723
14050
|
html: new TextDecoder().decode(content.data),
|
|
@@ -13736,7 +14063,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13736
14063
|
},
|
|
13737
14064
|
doc.data.id
|
|
13738
14065
|
);
|
|
13739
|
-
else if (doc.data.kind === "sheet") stage = /* @__PURE__ */ (0,
|
|
14066
|
+
else if (doc.data.kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react16.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13740
14067
|
SheetView3,
|
|
13741
14068
|
{
|
|
13742
14069
|
bytes: content.data,
|
|
@@ -13763,7 +14090,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13763
14090
|
},
|
|
13764
14091
|
`${doc.data.id}:${versionId ?? ""}`
|
|
13765
14092
|
) });
|
|
13766
|
-
else stage = /* @__PURE__ */ (0,
|
|
14093
|
+
else stage = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
|
|
13767
14094
|
}
|
|
13768
14095
|
const Kind = doc.data ? icons3[doc.data.kind] : import_lucide_react10.FileText;
|
|
13769
14096
|
const top = Math.min(...outline2.map((h) => h.level));
|
|
@@ -13774,8 +14101,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13774
14101
|
}, []);
|
|
13775
14102
|
const now = reading?.documentId === here.documentId ? reading : null;
|
|
13776
14103
|
const reached = now ? chapters.findIndex((c) => c.head.id === now.id || c.subs.some((s) => s.id === now.id)) : -1;
|
|
13777
|
-
const
|
|
13778
|
-
const hit = (h) =>
|
|
14104
|
+
const words3 = hunt.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
14105
|
+
const hit = (h) => words3.every((w) => h.text.toLocaleLowerCase().includes(w));
|
|
13779
14106
|
const reach = (h) => h.go ? h.go() : document.getElementById(h.id)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
13780
14107
|
const crumbs = doc.data ? [names2.get(doc.data.spaceId), doc.data.folder].filter(Boolean) : space ? [space.name] : [];
|
|
13781
14108
|
const panelTabs = [["outline", import_lucide_react10.ListTree, t.outline], ["versions", import_lucide_react10.History, t.versions], ["details", import_lucide_react10.Info, t.details]];
|
|
@@ -13783,7 +14110,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13783
14110
|
if (text && host.comments && !versionId) panelTabs.push(["comments", import_lucide_react10.MessagesSquare, t.comments]);
|
|
13784
14111
|
const sharing = !!host.links && !!doc.data?.rights.edit && !versionId;
|
|
13785
14112
|
if (sharing) panelTabs.push(["sharing", import_lucide_react10.Share2, t.sharing]);
|
|
13786
|
-
const listToggle = /* @__PURE__ */ (0,
|
|
14113
|
+
const listToggle = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13787
14114
|
"button",
|
|
13788
14115
|
{
|
|
13789
14116
|
ref: listButton,
|
|
@@ -13793,10 +14120,10 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13793
14120
|
onClick: () => side2("list", !listOpen),
|
|
13794
14121
|
"aria-label": listOpen ? t.closeList : t.openList,
|
|
13795
14122
|
title: listOpen ? t.closeList : t.openList,
|
|
13796
|
-
children: listOpen ? /* @__PURE__ */ (0,
|
|
14123
|
+
children: listOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelLeftClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelLeftOpen, { "aria-hidden": true })
|
|
13797
14124
|
}
|
|
13798
14125
|
);
|
|
13799
|
-
const panelToggle = doc.data && /* @__PURE__ */ (0,
|
|
14126
|
+
const panelToggle = doc.data && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13800
14127
|
"button",
|
|
13801
14128
|
{
|
|
13802
14129
|
ref: panelButton,
|
|
@@ -13806,16 +14133,16 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13806
14133
|
onClick: () => side2("panel", !panelOpen),
|
|
13807
14134
|
"aria-label": panelOpen ? t.closePanel : t.openPanel,
|
|
13808
14135
|
title: panelOpen ? t.closePanel : t.openPanel,
|
|
13809
|
-
children: panelOpen ? /* @__PURE__ */ (0,
|
|
14136
|
+
children: panelOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelRightClose, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.PanelRightOpen, { "aria-hidden": true })
|
|
13810
14137
|
}
|
|
13811
14138
|
);
|
|
13812
|
-
return /* @__PURE__ */ (0,
|
|
13813
|
-
/* @__PURE__ */ (0,
|
|
13814
|
-
start && /* @__PURE__ */ (0,
|
|
14139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs", "data-theme": theme, children: [
|
|
14140
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("header", { className: "w100n-docs-bar", children: [
|
|
14141
|
+
start && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-start w100n-docs-slot", children: slot(start) }),
|
|
13815
14142
|
narrow && listToggle,
|
|
13816
|
-
/* @__PURE__ */ (0,
|
|
13817
|
-
/* @__PURE__ */ (0,
|
|
13818
|
-
renaming !== null && doc.data ? /* @__PURE__ */ (0,
|
|
14143
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-tile", "data-kind": doc.data?.kind, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Kind, { "aria-hidden": true }) }),
|
|
14144
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-heading", children: [
|
|
14145
|
+
renaming !== null && doc.data ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13819
14146
|
"input",
|
|
13820
14147
|
{
|
|
13821
14148
|
className: "w100n-docs-title w100n-docs-rename",
|
|
@@ -13833,7 +14160,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13833
14160
|
}
|
|
13834
14161
|
}
|
|
13835
14162
|
}
|
|
13836
|
-
) : /* @__PURE__ */ (0,
|
|
14163
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
13837
14164
|
"strong",
|
|
13838
14165
|
{
|
|
13839
14166
|
className: "w100n-docs-title",
|
|
@@ -13842,205 +14169,209 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
13842
14169
|
children: doc.data?.name ?? t.documents
|
|
13843
14170
|
}
|
|
13844
14171
|
),
|
|
13845
|
-
docbar ? /* @__PURE__ */ (0,
|
|
13846
|
-
i > 0 && /* @__PURE__ */ (0,
|
|
14172
|
+
docbar ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: setMenusAt, className: "w100n-docs-menus" }) : crumbs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-crumbs", children: crumbs.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
14173
|
+
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true }),
|
|
13847
14174
|
item
|
|
13848
|
-
] }, i)) }) : /* @__PURE__ */ (0,
|
|
14175
|
+
] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-hint", children: t.hint })
|
|
13849
14176
|
] }),
|
|
13850
|
-
versionId && /* @__PURE__ */ (0,
|
|
13851
|
-
versionId &&
|
|
13852
|
-
/* @__PURE__ */ (0,
|
|
14177
|
+
versionId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: versions.data?.find((v) => v.id === versionId) && date(versions.data.find((v) => v.id === versionId).createdAt) }),
|
|
14178
|
+
versionId && text && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "blue", "aria-pressed": comparing, onClick: () => setComparing(!comparing), children: [
|
|
14179
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDiff, { "aria-hidden": true }),
|
|
14180
|
+
comparing ? t.hideChanges : t.showChanges
|
|
14181
|
+
] }),
|
|
14182
|
+
versionId && here.documentId && host.restore && doc.data?.rights.edit && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: restoring === "busy", onClick: () => void restore(here.documentId, versionId), children: [
|
|
14183
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.RotateCcw, { "aria-hidden": true }),
|
|
13853
14184
|
t.restore
|
|
13854
14185
|
] }),
|
|
13855
|
-
restoring === "failed" && /* @__PURE__ */ (0,
|
|
13856
|
-
doc.data?.convert && host.copyAs && !versionId && /* @__PURE__ */ (0,
|
|
13857
|
-
/* @__PURE__ */ (0,
|
|
14186
|
+
restoring === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.restoreFailed }),
|
|
14187
|
+
doc.data?.convert && host.copyAs && !versionId && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "green", disabled: copying === "busy", onClick: () => void copyAs(doc.data), children: [
|
|
14188
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileSpreadsheet, { "aria-hidden": true }),
|
|
13858
14189
|
t.copyAs
|
|
13859
14190
|
] }),
|
|
13860
|
-
copying === "failed" && /* @__PURE__ */ (0,
|
|
13861
|
-
renamed2 === "failed" && /* @__PURE__ */ (0,
|
|
13862
|
-
docbar && /* @__PURE__ */ (0,
|
|
13863
|
-
sharing && /* @__PURE__ */ (0,
|
|
14191
|
+
copying === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.copyFailed }),
|
|
14192
|
+
renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
|
|
14193
|
+
docbar && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
|
|
14194
|
+
sharing && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.share, title: t.share, onClick: () => {
|
|
13864
14195
|
setTab("sharing");
|
|
13865
14196
|
side2("panel", true);
|
|
13866
14197
|
}, children: [
|
|
13867
|
-
/* @__PURE__ */ (0,
|
|
13868
|
-
/* @__PURE__ */ (0,
|
|
14198
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Share2, { "aria-hidden": true }),
|
|
14199
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.share })
|
|
13869
14200
|
] }),
|
|
13870
14201
|
doc.data && !versionId && actions?.(doc.data),
|
|
13871
14202
|
narrow && panelToggle,
|
|
13872
|
-
end && /* @__PURE__ */ (0,
|
|
14203
|
+
end && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-end w100n-docs-slot", children: slot(end) })
|
|
13873
14204
|
] }),
|
|
13874
|
-
/* @__PURE__ */ (0,
|
|
13875
|
-
listOpen && /* @__PURE__ */ (0,
|
|
13876
|
-
/* @__PURE__ */ (0,
|
|
13877
|
-
/* @__PURE__ */ (0,
|
|
13878
|
-
/* @__PURE__ */ (0,
|
|
13879
|
-
/* @__PURE__ */ (0,
|
|
14205
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ref: body, className: "w100n-docs-body", children: [
|
|
14206
|
+
listOpen && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("aside", { className: "w100n-docs-side w100n-docs-list", "aria-label": t.documents, children: [
|
|
14207
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-head", children: [
|
|
14208
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-row", children: [
|
|
14209
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "w100n-docs-caption", children: [
|
|
14210
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Files, { "aria-hidden": true }),
|
|
13880
14211
|
t.documents,
|
|
13881
|
-
/* @__PURE__ */ (0,
|
|
14212
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: all.length })
|
|
13882
14213
|
] }),
|
|
13883
|
-
host.create && /* @__PURE__ */ (0,
|
|
14214
|
+
host.create && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-new", onKeyDown: (e) => {
|
|
13884
14215
|
if (e.key === "Escape" && adding) {
|
|
13885
14216
|
e.stopPropagation();
|
|
13886
14217
|
setAdding(false);
|
|
13887
14218
|
}
|
|
13888
14219
|
}, children: [
|
|
13889
|
-
/* @__PURE__ */ (0,
|
|
13890
|
-
/* @__PURE__ */ (0,
|
|
13891
|
-
/* @__PURE__ */ (0,
|
|
13892
|
-
/* @__PURE__ */ (0,
|
|
14220
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-haspopup": "menu", "aria-expanded": adding, disabled: sending === "busy", onClick: () => setAdding(!adding), children: [
|
|
14221
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Plus, { "aria-hidden": true }),
|
|
14222
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: sending === "busy" ? t.uploading : t.create }),
|
|
14223
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
|
|
13893
14224
|
] }),
|
|
13894
|
-
adding && /* @__PURE__ */ (0,
|
|
13895
|
-
/* @__PURE__ */ (0,
|
|
14225
|
+
adding && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "menu", className: "w100n-docs-menu", children: [
|
|
14226
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
13896
14227
|
setAdding(false);
|
|
13897
14228
|
setMaking(true);
|
|
13898
14229
|
}, children: [
|
|
13899
|
-
/* @__PURE__ */ (0,
|
|
13900
|
-
/* @__PURE__ */ (0,
|
|
14230
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FilePlus, { "aria-hidden": true }) }),
|
|
14231
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.newTitle })
|
|
13901
14232
|
] }),
|
|
13902
|
-
/* @__PURE__ */ (0,
|
|
14233
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
13903
14234
|
setAdding(false);
|
|
13904
14235
|
upload.current.click();
|
|
13905
14236
|
}, children: [
|
|
13906
|
-
/* @__PURE__ */ (0,
|
|
13907
|
-
/* @__PURE__ */ (0,
|
|
14237
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Upload, { "aria-hidden": true }) }),
|
|
14238
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.uploadFile })
|
|
13908
14239
|
] })
|
|
13909
14240
|
] }),
|
|
13910
|
-
/* @__PURE__ */ (0,
|
|
14241
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { ref: upload, type: "file", hidden: true, "aria-label": t.uploadFile, accept: ".docx,.md,.markdown,.pdf,.xlsx,.csv,.html,.htm", onChange: (e) => {
|
|
13911
14242
|
const file = e.target.files?.[0];
|
|
13912
14243
|
e.target.value = "";
|
|
13913
14244
|
if (file) void send(file);
|
|
13914
14245
|
} })
|
|
13915
14246
|
] }),
|
|
13916
|
-
/* @__PURE__ */ (0,
|
|
14247
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { ref: listClose, type: "button", className: "w100n-docs-close", onClick: () => side2("list", false), "aria-label": t.closeList, title: t.closeList, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
|
|
13917
14248
|
] }),
|
|
13918
|
-
(spaces.data?.length ?? 0) > 1 && /* @__PURE__ */ (0,
|
|
14249
|
+
(spaces.data?.length ?? 0) > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-picker", onKeyDown: (e) => {
|
|
13919
14250
|
if (e.key !== "Escape" || !picking) return;
|
|
13920
14251
|
e.stopPropagation();
|
|
13921
14252
|
setPicking(false);
|
|
13922
14253
|
e.currentTarget.querySelector("button").focus();
|
|
13923
14254
|
}, children: [
|
|
13924
|
-
/* @__PURE__ */ (0,
|
|
13925
|
-
space ? /* @__PURE__ */ (0,
|
|
13926
|
-
/* @__PURE__ */ (0,
|
|
13927
|
-
!space && /* @__PURE__ */ (0,
|
|
13928
|
-
/* @__PURE__ */ (0,
|
|
14255
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": picking, onClick: () => setPicking(!picking), children: [
|
|
14256
|
+
space ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-dot", style: { background: space.color ?? void 0 } }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
|
|
14257
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: space?.name ?? t.allProjects }),
|
|
14258
|
+
!space && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: all.length }),
|
|
14259
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
|
|
13929
14260
|
] }),
|
|
13930
|
-
picking && /* @__PURE__ */ (0,
|
|
13931
|
-
/* @__PURE__ */ (0,
|
|
13932
|
-
/* @__PURE__ */ (0,
|
|
13933
|
-
/* @__PURE__ */ (0,
|
|
13934
|
-
!spaceId && /* @__PURE__ */ (0,
|
|
14261
|
+
picking && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "listbox", className: "w100n-docs-menu", children: [
|
|
14262
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": !spaceId, onClick: () => pick(null), children: [
|
|
14263
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.LayoutGrid, { "aria-hidden": true }) }),
|
|
14264
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.allProjects }),
|
|
14265
|
+
!spaceId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
|
|
13935
14266
|
] }),
|
|
13936
|
-
groups2.map((group) => /* @__PURE__ */ (0,
|
|
13937
|
-
group && /* @__PURE__ */ (0,
|
|
13938
|
-
(spaces.data ?? []).filter((item) => (item.group ?? "") === group).map((item) => /* @__PURE__ */ (0,
|
|
13939
|
-
/* @__PURE__ */ (0,
|
|
13940
|
-
/* @__PURE__ */ (0,
|
|
13941
|
-
!spaceId && counts.get(item.id) ? /* @__PURE__ */ (0,
|
|
13942
|
-
item.id === spaceId && /* @__PURE__ */ (0,
|
|
14267
|
+
groups2.map((group) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "group", "aria-label": group || void 0, children: [
|
|
14268
|
+
group && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-menu-caption", children: group }),
|
|
14269
|
+
(spaces.data ?? []).filter((item) => (item.group ?? "") === group).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": item.id === spaceId, onClick: () => pick(item.id), children: [
|
|
14270
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-dot", style: { background: item.color ?? void 0 } }),
|
|
14271
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: item.name }),
|
|
14272
|
+
!spaceId && counts.get(item.id) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: counts.get(item.id) }) : null,
|
|
14273
|
+
item.id === spaceId && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true })
|
|
13943
14274
|
] }, item.id))
|
|
13944
14275
|
] }, group))
|
|
13945
14276
|
] })
|
|
13946
14277
|
] }),
|
|
13947
|
-
/* @__PURE__ */ (0,
|
|
13948
|
-
/* @__PURE__ */ (0,
|
|
13949
|
-
/* @__PURE__ */ (0,
|
|
13950
|
-
/* @__PURE__ */ (0,
|
|
14278
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-filters", children: [
|
|
14279
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
|
|
14280
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
|
|
14281
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { value: query, onChange: (event) => setQuery(event.target.value), placeholder: t.search, "aria-label": t.search })
|
|
13951
14282
|
] }),
|
|
13952
|
-
present.length > 1 && /* @__PURE__ */ (0,
|
|
14283
|
+
present.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-types", onKeyDown: (e) => {
|
|
13953
14284
|
if (e.key !== "Escape" || !typing) return;
|
|
13954
14285
|
e.stopPropagation();
|
|
13955
14286
|
setTyping(false);
|
|
13956
14287
|
e.currentTarget.querySelector("button").focus();
|
|
13957
14288
|
}, children: [
|
|
13958
|
-
/* @__PURE__ */ (0,
|
|
13959
|
-
/* @__PURE__ */ (0,
|
|
13960
|
-
/* @__PURE__ */ (0,
|
|
13961
|
-
picked.length > 0 && /* @__PURE__ */ (0,
|
|
13962
|
-
/* @__PURE__ */ (0,
|
|
14289
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": typing, "data-on": picked.length > 0, onClick: () => setTyping(!typing), children: [
|
|
14290
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ListFilter, { "aria-hidden": true }),
|
|
14291
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.typeFilter }),
|
|
14292
|
+
picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: picked.length }),
|
|
14293
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
|
|
13963
14294
|
] }),
|
|
13964
|
-
typing && /* @__PURE__ */ (0,
|
|
14295
|
+
typing && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { role: "listbox", "aria-multiselectable": true, "aria-label": t.kind, className: "w100n-docs-menu", children: [
|
|
13965
14296
|
present.map((item) => {
|
|
13966
14297
|
const Icon = icons3[item];
|
|
13967
14298
|
const on2 = picked.includes(item);
|
|
13968
|
-
return /* @__PURE__ */ (0,
|
|
13969
|
-
/* @__PURE__ */ (0,
|
|
13970
|
-
/* @__PURE__ */ (0,
|
|
13971
|
-
/* @__PURE__ */ (0,
|
|
13972
|
-
/* @__PURE__ */ (0,
|
|
14299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "option", "aria-selected": on2, onClick: () => setPicked(on2 ? picked.filter((k) => k !== item) : [...picked, item]), children: [
|
|
14300
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-box", children: on2 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { "aria-hidden": true }) }),
|
|
14301
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-tile", "data-kind": item, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { "aria-hidden": true }) }),
|
|
14302
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: t.kinds[item] }),
|
|
14303
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-count", children: all.filter((doc2) => doc2.kind === item).length })
|
|
13973
14304
|
] }, item);
|
|
13974
14305
|
}),
|
|
13975
|
-
/* @__PURE__ */ (0,
|
|
13976
|
-
/* @__PURE__ */ (0,
|
|
13977
|
-
/* @__PURE__ */ (0,
|
|
14306
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-menu-foot", children: [
|
|
14307
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => setPicked(present), children: t.selectAll }),
|
|
14308
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: () => setPicked([]), children: t.clearPick })
|
|
13978
14309
|
] })
|
|
13979
14310
|
] })
|
|
13980
14311
|
] })
|
|
13981
14312
|
] }),
|
|
13982
|
-
picked.length > 0 && /* @__PURE__ */ (0,
|
|
14313
|
+
picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.kind, children: picked.map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", "aria-pressed": true, "aria-label": `${t.clearPick}: ${t.kinds[item]}`, onClick: () => setPicked(picked.filter((k) => k !== item)), children: [
|
|
13983
14314
|
t.kinds[item],
|
|
13984
|
-
/* @__PURE__ */ (0,
|
|
14315
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true })
|
|
13985
14316
|
] }, item)) })
|
|
13986
14317
|
] }),
|
|
13987
|
-
/* @__PURE__ */ (0,
|
|
13988
|
-
sending === "failed" && /* @__PURE__ */ (0,
|
|
14318
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-cards", children: [
|
|
14319
|
+
sending === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.uploadFailed }),
|
|
13989
14320
|
list.error && failed(list.retry),
|
|
13990
|
-
list.loading && !list.data && /* @__PURE__ */ (0,
|
|
13991
|
-
list.data && !shown.length && /* @__PURE__ */ (0,
|
|
13992
|
-
folders.map((folder2) => /* @__PURE__ */ (0,
|
|
13993
|
-
folders.length > 1 && /* @__PURE__ */ (0,
|
|
13994
|
-
/* @__PURE__ */ (0,
|
|
13995
|
-
/* @__PURE__ */ (0,
|
|
13996
|
-
/* @__PURE__ */ (0,
|
|
13997
|
-
/* @__PURE__ */ (0,
|
|
13998
|
-
/* @__PURE__ */ (0,
|
|
14321
|
+
list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.loading }),
|
|
14322
|
+
list.data && !shown.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: all.length ? t.nothing : t.empty }),
|
|
14323
|
+
folders.map((folder2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-folder", role: "group", "aria-label": folder2 || t.loose, children: [
|
|
14324
|
+
folders.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-group", children: folder2 || t.loose }),
|
|
14325
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-grid", children: shown.filter((item) => !spaceId || (item.folder ?? "") === folder2).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-card", "aria-current": item.id === here.documentId, onClick: () => open(item), title: item.name, children: [
|
|
14326
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Thumb, { host, item, label: t.kinds[item.kind] }),
|
|
14327
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "w100n-docs-card-text", children: [
|
|
14328
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: item.name }),
|
|
14329
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [!spaceId && names2.get(item.spaceId), ago(item.updatedAt)].filter(Boolean).join(" \xB7 ") })
|
|
13999
14330
|
] })
|
|
14000
14331
|
] }, item.id)) })
|
|
14001
14332
|
] }, folder2))
|
|
14002
14333
|
] })
|
|
14003
14334
|
] }),
|
|
14004
14335
|
!narrow && !listOpen && listToggle,
|
|
14005
|
-
/* @__PURE__ */ (0,
|
|
14336
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("main", { className: "w100n-docs-stage", children: [
|
|
14006
14337
|
!narrow && !panelOpen && panelToggle,
|
|
14007
|
-
/* @__PURE__ */ (0,
|
|
14338
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-bare", children: stage })
|
|
14008
14339
|
] }),
|
|
14009
|
-
doc.data && panelOpen && /* @__PURE__ */ (0,
|
|
14010
|
-
/* @__PURE__ */ (0,
|
|
14011
|
-
/* @__PURE__ */ (0,
|
|
14012
|
-
/* @__PURE__ */ (0,
|
|
14013
|
-
(panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0,
|
|
14340
|
+
doc.data && panelOpen && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("aside", { ref: panel, className: "w100n-docs-side w100n-docs-panel", "aria-label": t.details, children: [
|
|
14341
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-head", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-row", children: [
|
|
14342
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-tabs", role: "tablist", "aria-label": t.details, "data-compact": panelTabs.length > 3, onKeyDown: rove, children: panelTabs.map(([key2, Icon, label]) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
|
|
14343
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { "aria-hidden": true }),
|
|
14344
|
+
(panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: label })
|
|
14014
14345
|
] }, key2)) }),
|
|
14015
|
-
/* @__PURE__ */ (0,
|
|
14346
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
|
|
14016
14347
|
] }) }),
|
|
14017
|
-
/* @__PURE__ */ (0,
|
|
14018
|
-
tab === "outline" && (outline2.length ? /* @__PURE__ */ (0,
|
|
14019
|
-
now && /* @__PURE__ */ (0,
|
|
14020
|
-
/* @__PURE__ */ (0,
|
|
14021
|
-
/* @__PURE__ */ (0,
|
|
14348
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2], children: [
|
|
14349
|
+
tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("nav", { className: "w100n-docs-outline", "aria-label": t.outline, children: [
|
|
14350
|
+
now && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-reading", children: [
|
|
14351
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { style: { width: `${Math.round(now.progress * 100)}%` } }) }),
|
|
14352
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("small", { children: [
|
|
14022
14353
|
Math.round(now.progress * 100),
|
|
14023
14354
|
"% ",
|
|
14024
14355
|
t.read
|
|
14025
14356
|
] })
|
|
14026
14357
|
] }),
|
|
14027
|
-
outline2.length > 8 && /* @__PURE__ */ (0,
|
|
14028
|
-
/* @__PURE__ */ (0,
|
|
14029
|
-
/* @__PURE__ */ (0,
|
|
14358
|
+
outline2.length > 8 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
|
|
14359
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
|
|
14360
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { value: hunt, onChange: (e) => setHunt(e.target.value), placeholder: t.findHeading, "aria-label": t.findHeading })
|
|
14030
14361
|
] }),
|
|
14031
14362
|
chapters.map((c, i) => {
|
|
14032
|
-
const subs =
|
|
14033
|
-
if (
|
|
14034
|
-
const opened3 =
|
|
14363
|
+
const subs = words3.length ? c.subs.filter(hit) : c.subs;
|
|
14364
|
+
if (words3.length && !hit(c.head) && !subs.length) return null;
|
|
14365
|
+
const opened3 = words3.length > 0 || (fold[c.head.id] ?? i === reached);
|
|
14035
14366
|
const named3 = /^(\d+)[.)]?\s+(.+)$/.exec(c.head.text);
|
|
14036
14367
|
const mark = c.subs.findIndex((s) => s.id === now?.id);
|
|
14037
|
-
return /* @__PURE__ */ (0,
|
|
14038
|
-
/* @__PURE__ */ (0,
|
|
14039
|
-
/* @__PURE__ */ (0,
|
|
14040
|
-
/* @__PURE__ */ (0,
|
|
14041
|
-
/* @__PURE__ */ (0,
|
|
14368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-chapter", "data-state": reached < 0 ? void 0 : i < reached ? "done" : i === reached ? "now" : void 0, children: [
|
|
14369
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-chapter-row", children: [
|
|
14370
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", className: "w100n-docs-chapter-go", "aria-label": c.head.text, "aria-current": now?.id === c.head.id ? "location" : void 0, onClick: () => reach(c.head), children: [
|
|
14371
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-chapter-num", children: named3 ? named3[1] : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Bookmark, { "aria-hidden": true }) }),
|
|
14372
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("b", { children: named3 ? named3[2] : c.head.text })
|
|
14042
14373
|
] }),
|
|
14043
|
-
c.subs.length > 0 && /* @__PURE__ */ (0,
|
|
14374
|
+
c.subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
14044
14375
|
"button",
|
|
14045
14376
|
{
|
|
14046
14377
|
type: "button",
|
|
@@ -14050,13 +14381,13 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14050
14381
|
title: opened3 ? t.hideSections : t.showSections,
|
|
14051
14382
|
onClick: () => setFold({ ...fold, [c.head.id]: !opened3 }),
|
|
14052
14383
|
children: [
|
|
14053
|
-
/* @__PURE__ */ (0,
|
|
14054
|
-
opened3 ? /* @__PURE__ */ (0,
|
|
14384
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: c.subs.length }),
|
|
14385
|
+
opened3 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true })
|
|
14055
14386
|
]
|
|
14056
14387
|
}
|
|
14057
14388
|
)
|
|
14058
14389
|
] }),
|
|
14059
|
-
opened3 && subs.length > 0 && /* @__PURE__ */ (0,
|
|
14390
|
+
opened3 && subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-sections", children: subs.map((s) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
14060
14391
|
"button",
|
|
14061
14392
|
{
|
|
14062
14393
|
type: "button",
|
|
@@ -14065,7 +14396,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14065
14396
|
"data-state": i < reached || i === reached && c.subs.indexOf(s) < mark ? "done" : void 0,
|
|
14066
14397
|
"aria-current": now?.id === s.id ? "location" : void 0,
|
|
14067
14398
|
children: [
|
|
14068
|
-
/* @__PURE__ */ (0,
|
|
14399
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { "aria-hidden": true }),
|
|
14069
14400
|
s.text
|
|
14070
14401
|
]
|
|
14071
14402
|
},
|
|
@@ -14073,46 +14404,46 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14073
14404
|
)) })
|
|
14074
14405
|
] }, c.head.id);
|
|
14075
14406
|
})
|
|
14076
|
-
] }) : /* @__PURE__ */ (0,
|
|
14077
|
-
tab === "versions" && /* @__PURE__ */ (0,
|
|
14407
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.noOutline })),
|
|
14408
|
+
tab === "versions" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-versions", children: [
|
|
14078
14409
|
versions.error && failed(versions.retry),
|
|
14079
|
-
(versions.data ?? []).map((item) => /* @__PURE__ */ (0,
|
|
14410
|
+
(versions.data ?? []).map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
14080
14411
|
"button",
|
|
14081
14412
|
{
|
|
14082
14413
|
type: "button",
|
|
14083
14414
|
"aria-pressed": (versionId ?? "current") === item.id || !versionId && item.current,
|
|
14084
14415
|
onClick: () => view(item.current ? null : item.id),
|
|
14085
14416
|
children: [
|
|
14086
|
-
/* @__PURE__ */ (0,
|
|
14417
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("b", { children: [
|
|
14087
14418
|
date(item.createdAt),
|
|
14088
|
-
item.current && /* @__PURE__ */ (0,
|
|
14419
|
+
item.current && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "w100n-docs-badge", children: t.current })
|
|
14089
14420
|
] }),
|
|
14090
|
-
/* @__PURE__ */ (0,
|
|
14421
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [item.author?.name, size2(item.size), item.note].filter(Boolean).join(" \xB7 ") })
|
|
14091
14422
|
]
|
|
14092
14423
|
},
|
|
14093
14424
|
item.id
|
|
14094
14425
|
))
|
|
14095
14426
|
] }),
|
|
14096
|
-
tab === "details" && /* @__PURE__ */ (0,
|
|
14097
|
-
/* @__PURE__ */ (0,
|
|
14098
|
-
/* @__PURE__ */ (0,
|
|
14099
|
-
/* @__PURE__ */ (0,
|
|
14100
|
-
/* @__PURE__ */ (0,
|
|
14101
|
-
/* @__PURE__ */ (0,
|
|
14102
|
-
/* @__PURE__ */ (0,
|
|
14103
|
-
doc.data.updatedBy && /* @__PURE__ */ (0,
|
|
14104
|
-
/* @__PURE__ */ (0,
|
|
14105
|
-
/* @__PURE__ */ (0,
|
|
14427
|
+
tab === "details" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dl", { className: "w100n-docs-details", children: [
|
|
14428
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.kind }),
|
|
14429
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: t.kinds[doc.data.kind] }),
|
|
14430
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.size }),
|
|
14431
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: size2(doc.data.size) }),
|
|
14432
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.updated }),
|
|
14433
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: date(doc.data.updatedAt) }),
|
|
14434
|
+
doc.data.updatedBy && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
14435
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.by }),
|
|
14436
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: doc.data.updatedBy.name })
|
|
14106
14437
|
] }),
|
|
14107
|
-
/* @__PURE__ */ (0,
|
|
14108
|
-
/* @__PURE__ */ (0,
|
|
14438
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t.rights }),
|
|
14439
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: [doc.data.rights.view && t.view, doc.data.rights.comment && t.comment, doc.data.rights.edit && t.edit].filter(Boolean).join(", ") })
|
|
14109
14440
|
] }),
|
|
14110
|
-
tab === "details" && host.exportAs && !!doc.data.exports?.length && /* @__PURE__ */ (0,
|
|
14111
|
-
/* @__PURE__ */ (0,
|
|
14112
|
-
/* @__PURE__ */ (0,
|
|
14441
|
+
tab === "details" && host.exportAs && !!doc.data.exports?.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-about", children: [
|
|
14442
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "w100n-docs-caption", children: [
|
|
14443
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
|
|
14113
14444
|
t.exportAs
|
|
14114
14445
|
] }),
|
|
14115
|
-
/* @__PURE__ */ (0,
|
|
14446
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w100n-docs-chips", children: doc.data.exports.map((format) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
14116
14447
|
"button",
|
|
14117
14448
|
{
|
|
14118
14449
|
type: "button",
|
|
@@ -14120,22 +14451,22 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14120
14451
|
disabled: exporting === "busy",
|
|
14121
14452
|
onClick: () => void exportAs(doc.data, format),
|
|
14122
14453
|
children: [
|
|
14123
|
-
/* @__PURE__ */ (0,
|
|
14454
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.FileDown, { "aria-hidden": true }),
|
|
14124
14455
|
format.toUpperCase()
|
|
14125
14456
|
]
|
|
14126
14457
|
},
|
|
14127
14458
|
format
|
|
14128
14459
|
)) }),
|
|
14129
|
-
exporting === "failed" && /* @__PURE__ */ (0,
|
|
14460
|
+
exporting === "failed" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.exportFailed })
|
|
14130
14461
|
] }),
|
|
14131
|
-
tab === "comments" && /* @__PURE__ */ (0,
|
|
14132
|
-
tab === "sharing" && sharing && /* @__PURE__ */ (0,
|
|
14133
|
-
tab === "signatures" && /* @__PURE__ */ (0,
|
|
14462
|
+
tab === "comments" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: setBox }),
|
|
14463
|
+
tab === "sharing" && sharing && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Sharing, { host, doc: doc.data, t, language, team: names2.get(doc.data.spaceId) }),
|
|
14464
|
+
tab === "signatures" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "w100n-docs-versions", children: [
|
|
14134
14465
|
signatures.error && failed(signatures.retry),
|
|
14135
|
-
signatures.data?.length === 0 && /* @__PURE__ */ (0,
|
|
14466
|
+
signatures.data?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "w100n-docs-muted", children: t.noSignatures }),
|
|
14136
14467
|
(signatures.data ?? []).map((entry2) => {
|
|
14137
14468
|
const signed = versions.data?.find((v) => v.id === entry2.versionId);
|
|
14138
|
-
return /* @__PURE__ */ (0,
|
|
14469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
14139
14470
|
"button",
|
|
14140
14471
|
{
|
|
14141
14472
|
type: "button",
|
|
@@ -14143,15 +14474,15 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14143
14474
|
"aria-pressed": !!signed && (versionId ?? versions.data?.find((v) => v.current)?.id) === signed.id,
|
|
14144
14475
|
onClick: () => view(signed.current ? null : signed.id),
|
|
14145
14476
|
children: [
|
|
14146
|
-
/* @__PURE__ */ (0,
|
|
14477
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("b", { children: [
|
|
14147
14478
|
entry2.signer.name,
|
|
14148
|
-
/* @__PURE__ */ (0,
|
|
14479
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "w100n-docs-badge", children: [
|
|
14149
14480
|
t.page,
|
|
14150
14481
|
" ",
|
|
14151
14482
|
entry2.page
|
|
14152
14483
|
] })
|
|
14153
14484
|
] }),
|
|
14154
|
-
/* @__PURE__ */ (0,
|
|
14485
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: [date(entry2.signedAt), t.methods[entry2.method], signed && (signed.current ? t.current : `${t.version} ${date(signed.createdAt)}`)].filter(Boolean).join(" \xB7 ") })
|
|
14155
14486
|
]
|
|
14156
14487
|
},
|
|
14157
14488
|
entry2.id
|
|
@@ -14162,7 +14493,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
14162
14493
|
] })
|
|
14163
14494
|
] })
|
|
14164
14495
|
] }),
|
|
14165
|
-
making && /* @__PURE__ */ (0,
|
|
14496
|
+
making && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(NewDocument, { host, t, onClose: () => setMaking(false), onMade: (made2) => {
|
|
14166
14497
|
setMaking(false);
|
|
14167
14498
|
opened2(made2);
|
|
14168
14499
|
} }),
|
|
@@ -14175,7 +14506,7 @@ var import_react17 = require("react");
|
|
|
14175
14506
|
var import_lucide_react11 = require("lucide-react");
|
|
14176
14507
|
init_text();
|
|
14177
14508
|
init_useLoad();
|
|
14178
|
-
var
|
|
14509
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
14179
14510
|
var TextEditor4 = (0, import_react17.lazy)(() => Promise.resolve().then(() => (init_TextEditor(), TextEditor_exports)));
|
|
14180
14511
|
var SheetView4 = (0, import_react17.lazy)(() => Promise.resolve().then(() => (init_SheetView(), SheetView_exports)));
|
|
14181
14512
|
var icons4 = { docx: import_lucide_react11.FileText, markdown: import_lucide_react11.FileType, pdf: import_lucide_react11.Files, sheet: import_lucide_react11.FileSpreadsheet, slides: import_lucide_react11.Presentation };
|
|
@@ -14210,7 +14541,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14210
14541
|
const [slot, setSlot] = (0, import_react17.useState)(null);
|
|
14211
14542
|
const [saving, setSaving] = (0, import_react17.useState)("idle");
|
|
14212
14543
|
const opened2 = useLoad((signal) => host.open(ask, { signal }), [host, ask]);
|
|
14213
|
-
const [
|
|
14544
|
+
const [notes3] = (0, import_react17.useState)(() => ({
|
|
14214
14545
|
me: { id: "", name: "" },
|
|
14215
14546
|
spaces: async () => [],
|
|
14216
14547
|
documents: async () => [],
|
|
@@ -14237,17 +14568,17 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14237
14568
|
const top = (file2, badge) => {
|
|
14238
14569
|
const kind2 = file2 ? kindOf(file2.name, file2.mimeType) : null;
|
|
14239
14570
|
const Kind = kind2 ? icons4[kind2] : import_lucide_react11.FileText;
|
|
14240
|
-
return /* @__PURE__ */ (0,
|
|
14241
|
-
brand && /* @__PURE__ */ (0,
|
|
14242
|
-
file2 && /* @__PURE__ */ (0,
|
|
14243
|
-
/* @__PURE__ */ (0,
|
|
14244
|
-
/* @__PURE__ */ (0,
|
|
14245
|
-
/* @__PURE__ */ (0,
|
|
14246
|
-
file2.sharedBy && /* @__PURE__ */ (0,
|
|
14571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("header", { className: "w100n-docs-bar w100n-guest-bar", children: [
|
|
14572
|
+
brand && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-guest-brand", children: brand }),
|
|
14573
|
+
file2 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
14574
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-tile", "data-kind": kind2, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Kind, { "aria-hidden": true }) }),
|
|
14575
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-heading", children: [
|
|
14576
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("strong", { className: "w100n-docs-title", children: file2.name }),
|
|
14577
|
+
file2.sharedBy && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-crumbs", children: t.sharedBy.replace("{name}", file2.sharedBy) })
|
|
14247
14578
|
] }),
|
|
14248
|
-
badge && /* @__PURE__ */ (0,
|
|
14249
|
-
file2.download && /* @__PURE__ */ (0,
|
|
14250
|
-
(kind2 === "docx" || kind2 === "markdown" || kind2 === "sheet" || kind2 === "slides") && /* @__PURE__ */ (0,
|
|
14579
|
+
badge && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-docs-badge", "data-kind": kind2, children: badge }),
|
|
14580
|
+
file2.download && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-end", children: [
|
|
14581
|
+
(kind2 === "docx" || kind2 === "markdown" || kind2 === "sheet" || kind2 === "slides") && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
14251
14582
|
"button",
|
|
14252
14583
|
{
|
|
14253
14584
|
type: "button",
|
|
@@ -14258,25 +14589,25 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14258
14589
|
"aria-label": t.pdfCopy,
|
|
14259
14590
|
title: t.pdfCopy,
|
|
14260
14591
|
children: [
|
|
14261
|
-
/* @__PURE__ */ (0,
|
|
14262
|
-
/* @__PURE__ */ (0,
|
|
14592
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.FileDown, { "aria-hidden": true }),
|
|
14593
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.pdfCopy })
|
|
14263
14594
|
]
|
|
14264
14595
|
}
|
|
14265
14596
|
),
|
|
14266
|
-
/* @__PURE__ */ (0,
|
|
14267
|
-
/* @__PURE__ */ (0,
|
|
14268
|
-
/* @__PURE__ */ (0,
|
|
14597
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "blue", disabled: saving === "busy", onClick: () => void download("file"), "aria-label": t.download, title: t.download, children: [
|
|
14598
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.Download, { "aria-hidden": true }),
|
|
14599
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.download })
|
|
14269
14600
|
] })
|
|
14270
14601
|
] })
|
|
14271
14602
|
] })
|
|
14272
14603
|
] });
|
|
14273
14604
|
};
|
|
14274
|
-
const gate = (tone, Icon, title, body, form) => /* @__PURE__ */ (0,
|
|
14605
|
+
const gate = (tone, Icon, title, body, form) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
|
|
14275
14606
|
top(null, null),
|
|
14276
|
-
/* @__PURE__ */ (0,
|
|
14277
|
-
/* @__PURE__ */ (0,
|
|
14278
|
-
/* @__PURE__ */ (0,
|
|
14279
|
-
/* @__PURE__ */ (0,
|
|
14607
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-guest-gate", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-guest-card", children: [
|
|
14608
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "w100n-share-tile", "data-tone": tone, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { "aria-hidden": true }) }),
|
|
14609
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { children: title }),
|
|
14610
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: body }),
|
|
14280
14611
|
form
|
|
14281
14612
|
] }) })
|
|
14282
14613
|
] });
|
|
@@ -14292,7 +14623,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14292
14623
|
password ? import_lucide_react11.Lock : import_lucide_react11.UserRound,
|
|
14293
14624
|
refused.file || t.documents,
|
|
14294
14625
|
shared + (password ? t.passwordAsk : t.nameAsk),
|
|
14295
|
-
/* @__PURE__ */ (0,
|
|
14626
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { className: "w100n-guest-form", onSubmit: (e) => {
|
|
14296
14627
|
e.preventDefault();
|
|
14297
14628
|
if (!typed.trim()) return;
|
|
14298
14629
|
if (password) setAsk({ ...ask, password: typed });
|
|
@@ -14302,7 +14633,7 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14302
14633
|
}
|
|
14303
14634
|
setTyped("");
|
|
14304
14635
|
}, children: [
|
|
14305
|
-
/* @__PURE__ */ (0,
|
|
14636
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
14306
14637
|
"input",
|
|
14307
14638
|
{
|
|
14308
14639
|
className: "w100n-share-input",
|
|
@@ -14315,21 +14646,21 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14315
14646
|
onChange: (e) => setTyped(e.target.value)
|
|
14316
14647
|
}
|
|
14317
14648
|
),
|
|
14318
|
-
refused.reason === "wrong" && /* @__PURE__ */ (0,
|
|
14319
|
-
/* @__PURE__ */ (0,
|
|
14320
|
-
/* @__PURE__ */ (0,
|
|
14649
|
+
refused.reason === "wrong" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.wrongPassword }),
|
|
14650
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { type: "submit", className: "w100n-docs-action", disabled: !typed.trim(), children: [
|
|
14651
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react11.Eye, { "aria-hidden": true }),
|
|
14321
14652
|
t.openDoc
|
|
14322
14653
|
] })
|
|
14323
14654
|
] })
|
|
14324
14655
|
);
|
|
14325
14656
|
}
|
|
14326
14657
|
if (refused?.reason === "busy") return gate("slate", import_lucide_react11.Ban, t.failed, t.tooMany);
|
|
14327
|
-
return gate("slate", import_lucide_react11.Ban, t.failed, "", /* @__PURE__ */ (0,
|
|
14658
|
+
return gate("slate", import_lucide_react11.Ban, t.failed, "", /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: "w100n-docs-action", onClick: opened2.retry, children: t.retry }));
|
|
14328
14659
|
}
|
|
14329
14660
|
const file = opened2.data;
|
|
14330
|
-
if (!file) return /* @__PURE__ */ (0,
|
|
14661
|
+
if (!file) return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
|
|
14331
14662
|
top(null, null),
|
|
14332
|
-
/* @__PURE__ */ (0,
|
|
14663
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading })
|
|
14333
14664
|
] });
|
|
14334
14665
|
const kind = kindOf(file.name, file.mimeType);
|
|
14335
14666
|
const text = kind === "docx" || kind === "markdown";
|
|
@@ -14337,23 +14668,23 @@ function GuestDocument({ host, language = "en", theme = "light", brand }) {
|
|
|
14337
14668
|
const rights = { view: true, comment: talk, edit: false };
|
|
14338
14669
|
const quiet3 = () => {
|
|
14339
14670
|
};
|
|
14340
|
-
let stage = /* @__PURE__ */ (0,
|
|
14341
|
-
if (text) stage = /* @__PURE__ */ (0,
|
|
14342
|
-
else if (kind === "pdf") stage = /* @__PURE__ */ (0,
|
|
14343
|
-
else if (kind === "slides") stage = /* @__PURE__ */ (0,
|
|
14344
|
-
else if (kind === "sheet") stage = /* @__PURE__ */ (0,
|
|
14345
|
-
return /* @__PURE__ */ (0,
|
|
14671
|
+
let stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
|
|
14672
|
+
if (text) stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TextEditor4, { kind, bytes: file.bytes, t, language, rights, host: talk ? notes3 : void 0, documentId: file.id, onOutline: quiet3, slot: talk ? slot : null }) });
|
|
14673
|
+
else if (kind === "pdf") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PdfView, { bytes: file.bytes, t, language, worker: host.pdfWorker, rights, documentId: file.id, onOutline: quiet3 });
|
|
14674
|
+
else if (kind === "slides") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SlidesView, { html: new TextDecoder().decode(file.bytes), name: file.name, rights, language, theme, onOutline: quiet3 });
|
|
14675
|
+
else if (kind === "sheet") stage = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react17.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-empty", children: t.loading }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SheetView4, { bytes: file.bytes, name: file.name, kind: /\.csv$/i.test(file.name) || file.mimeType === "text/csv" ? "csv" : "xlsx", rights, language, theme, documentId: file.id }) });
|
|
14676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs w100n-guest", "data-theme": theme, children: [
|
|
14346
14677
|
top(file, talk ? t.badgeComment : t.badgeRead),
|
|
14347
|
-
saving === "failed" && /* @__PURE__ */ (0,
|
|
14348
|
-
/* @__PURE__ */ (0,
|
|
14349
|
-
/* @__PURE__ */ (0,
|
|
14350
|
-
talk && /* @__PURE__ */ (0,
|
|
14351
|
-
/* @__PURE__ */ (0,
|
|
14352
|
-
/* @__PURE__ */ (0,
|
|
14353
|
-
/* @__PURE__ */ (0,
|
|
14678
|
+
saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted w100n-guest-note", role: "alert", children: t.exportFailed }),
|
|
14679
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-body w100n-guest-body", children: [
|
|
14680
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("main", { className: "w100n-docs-stage", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "w100n-docs-bare", children: stage }) }),
|
|
14681
|
+
talk && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("aside", { className: "w100n-docs-side w100n-docs-panel w100n-guest-panel", "aria-label": t.comments, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "w100n-docs-panel-body", children: [
|
|
14682
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "w100n-share-field", children: [
|
|
14683
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: t.yourName }),
|
|
14684
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { className: "w100n-share-input", value: name, autoComplete: "name", placeholder: t.yourName, onChange: (e) => typeName(e.target.value) })
|
|
14354
14685
|
] }),
|
|
14355
|
-
/* @__PURE__ */ (0,
|
|
14356
|
-
/* @__PURE__ */ (0,
|
|
14686
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "w100n-docs-muted", children: name.trim() ? t.nameHint : t.nameNeeded }),
|
|
14687
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ref: setSlot })
|
|
14357
14688
|
] }) })
|
|
14358
14689
|
] })
|
|
14359
14690
|
] });
|