@w100n/documents 0.13.0 → 0.15.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/{SheetView-3XTEV2VT.css → SheetView-43MPR64N.css} +5 -4
- package/dist/{SheetView-3XTEV2VT.css.map → SheetView-43MPR64N.css.map} +1 -1
- package/dist/{SheetView-3UAFXGZS.js → SheetView-72KXS4DM.js} +51 -10
- package/dist/SheetView-72KXS4DM.js.map +1 -0
- package/dist/TextEditor-NSICFE6U.js +1562 -0
- package/dist/TextEditor-NSICFE6U.js.map +1 -0
- package/dist/{chunk-L765DZPO.js → chunk-2CA3HQTI.js} +3 -3
- package/dist/{chunk-L765DZPO.js.map → chunk-2CA3HQTI.js.map} +1 -1
- package/dist/{chunk-WR3MT7KP.js → chunk-M4OQG3EN.js} +754 -57
- package/dist/chunk-M4OQG3EN.js.map +1 -0
- package/dist/{chunk-T7XCGDE5.js → chunk-OXC4PUOC.js} +2 -2
- package/dist/{chunk-MRP3EURG.js → chunk-Z7UNJ4ND.js} +194 -25
- package/dist/chunk-Z7UNJ4ND.js.map +1 -0
- package/dist/collab.cjs +927 -80
- package/dist/collab.cjs.map +1 -1
- package/dist/collab.d.cts +2 -2
- package/dist/collab.d.ts +2 -2
- package/dist/collab.js +2 -2
- package/dist/{grid-EI5JNZAA.js → grid-Q4XBPQFY.js} +3 -3
- package/dist/grid-Q4XBPQFY.js.map +1 -0
- package/dist/index.cjs +2136 -420
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1047 -171
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +283 -33
- package/dist/index.js.map +1 -1
- package/dist/kinds.cjs +2 -2
- package/dist/kinds.cjs.map +1 -1
- package/dist/kinds.d.cts +2 -2
- package/dist/kinds.d.ts +2 -2
- package/dist/kinds.js +1 -1
- package/dist/memory.cjs +3 -0
- package/dist/memory.cjs.map +1 -1
- package/dist/memory.d.cts +1 -1
- package/dist/memory.d.ts +1 -1
- package/dist/memory.js +4 -1
- package/dist/memory.js.map +1 -1
- package/dist/{types-Er60M5kL.d.ts → types-BTsVooZw.d.cts} +2 -1
- package/dist/{types-Er60M5kL.d.cts → types-BTsVooZw.d.ts} +2 -1
- package/dist/write-BCI8yool.d.cts +16 -0
- package/dist/write-BCI8yool.d.ts +16 -0
- package/package.json +1 -1
- package/dist/SheetView-3UAFXGZS.js.map +0 -1
- package/dist/TextEditor-OLBLWC6F.js +0 -983
- package/dist/TextEditor-OLBLWC6F.js.map +0 -1
- package/dist/chunk-MRP3EURG.js.map +0 -1
- package/dist/chunk-WR3MT7KP.js.map +0 -1
- package/dist/grid-EI5JNZAA.js.map +0 -1
- package/dist/write-DaVtTJCS.d.cts +0 -6
- package/dist/write-DaVtTJCS.d.ts +0 -6
- /package/dist/{chunk-T7XCGDE5.js.map → chunk-OXC4PUOC.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,10 @@ var init_text = __esm({
|
|
|
81
81
|
versions: "Versions",
|
|
82
82
|
details: "Details",
|
|
83
83
|
noOutline: "This document has no headings",
|
|
84
|
+
findHeading: "Find a heading",
|
|
85
|
+
read: "read",
|
|
86
|
+
showSections: "Show sections",
|
|
87
|
+
hideSections: "Hide sections",
|
|
84
88
|
current: "Current",
|
|
85
89
|
size: "Size",
|
|
86
90
|
updated: "Updated",
|
|
@@ -128,6 +132,12 @@ var init_text = __esm({
|
|
|
128
132
|
save: "Save",
|
|
129
133
|
saving: "Saving",
|
|
130
134
|
saved: "Saved",
|
|
135
|
+
align: "Align",
|
|
136
|
+
moreTools: "More tools",
|
|
137
|
+
fewerTools: "Fewer tools",
|
|
138
|
+
typeFilter: "Type",
|
|
139
|
+
selectAll: "Select all",
|
|
140
|
+
clearPick: "Clear",
|
|
131
141
|
saveFailed: "Could not save",
|
|
132
142
|
remove: "Remove",
|
|
133
143
|
notePlaceholder: "Write a note",
|
|
@@ -191,6 +201,14 @@ var init_text = __esm({
|
|
|
191
201
|
chooseFile: "Choose a file",
|
|
192
202
|
put: "Insert",
|
|
193
203
|
link: "Link",
|
|
204
|
+
footnote: "Footnote",
|
|
205
|
+
footnoteText: "Footnote text",
|
|
206
|
+
formula: "Formula",
|
|
207
|
+
formulaHint: "Saved as a Word equation",
|
|
208
|
+
symbols: "Special characters",
|
|
209
|
+
symbolSearch: "Search, for example arrow",
|
|
210
|
+
update: "Update",
|
|
211
|
+
removeFootnote: "Remove footnote",
|
|
194
212
|
linkAddress: "Link address",
|
|
195
213
|
apply: "Apply",
|
|
196
214
|
unlink: "Remove link",
|
|
@@ -237,6 +255,11 @@ var init_text = __esm({
|
|
|
237
255
|
someone: "Someone",
|
|
238
256
|
copyAs: "Make an XLSX copy",
|
|
239
257
|
copyFailed: "Could not make the copy",
|
|
258
|
+
downloadAs: "Download as",
|
|
259
|
+
makeCopy: "Make a copy",
|
|
260
|
+
copyOf: "Copy of",
|
|
261
|
+
rename: "Rename",
|
|
262
|
+
renameFailed: "Could not rename",
|
|
240
263
|
editComment: "Edit",
|
|
241
264
|
delete: "Delete",
|
|
242
265
|
deleteAsk: "Delete this comment?",
|
|
@@ -322,7 +345,52 @@ var init_text = __esm({
|
|
|
322
345
|
untitled: "Untitled",
|
|
323
346
|
kindHints: { docx: "Word, DOCX", markdown: "MD, same editor", sheet: "Excel, XLSX", slides: "HTML slides" },
|
|
324
347
|
newKinds: { docx: "Document", markdown: "Markdown", sheet: "Spreadsheet", slides: "Presentation" },
|
|
325
|
-
templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" }
|
|
348
|
+
templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" },
|
|
349
|
+
menuFile: "File",
|
|
350
|
+
menuEdit: "Edit",
|
|
351
|
+
menuFormat: "Format",
|
|
352
|
+
menuTools: "Tools",
|
|
353
|
+
zoom: "Zoom",
|
|
354
|
+
font: "Font",
|
|
355
|
+
fontSize: "Font size",
|
|
356
|
+
defaultFont: "Default",
|
|
357
|
+
lineSpacing: "Line and paragraph spacing",
|
|
358
|
+
single: "Single",
|
|
359
|
+
double: "Double",
|
|
360
|
+
spaceAfter: "Add space after paragraph",
|
|
361
|
+
noSpaceAfter: "Remove space after paragraph",
|
|
362
|
+
superscript: "Superscript",
|
|
363
|
+
subscript: "Subscript",
|
|
364
|
+
painter: "Paint format",
|
|
365
|
+
painterHint: "Select text to paint, double click keeps it on, Esc stops",
|
|
366
|
+
pageSetup: "Page setup",
|
|
367
|
+
orientation: "Orientation",
|
|
368
|
+
portrait: "Portrait",
|
|
369
|
+
landscape: "Landscape",
|
|
370
|
+
marginsCm: "Margins, cm",
|
|
371
|
+
mTop: "Top",
|
|
372
|
+
mRight: "Right",
|
|
373
|
+
mBottom: "Bottom",
|
|
374
|
+
mLeft: "Left",
|
|
375
|
+
headerText: "Header",
|
|
376
|
+
footerText: "Footer",
|
|
377
|
+
pageNumbers: "Page numbers in the footer",
|
|
378
|
+
wrapInline: "In line with text",
|
|
379
|
+
wrapLeft: "Text wraps on the right",
|
|
380
|
+
wrapRight: "Text wraps on the left",
|
|
381
|
+
cellFill: "Cell fill",
|
|
382
|
+
tableBorders: "Table borders",
|
|
383
|
+
findReplace: "Find and replace",
|
|
384
|
+
replaceWith: "Replace with",
|
|
385
|
+
replaceOne: "Replace",
|
|
386
|
+
replaceAll: "Replace all",
|
|
387
|
+
matchCase: "Match case",
|
|
388
|
+
words: "Words",
|
|
389
|
+
print: "Print",
|
|
390
|
+
autosavedNote: "Autosaved",
|
|
391
|
+
uploadFile: "Upload a file",
|
|
392
|
+
uploading: "Uploading",
|
|
393
|
+
uploadFailed: "Could not upload the file"
|
|
326
394
|
};
|
|
327
395
|
pl2 = {
|
|
328
396
|
documents: "Dokumenty",
|
|
@@ -339,6 +407,10 @@ var init_text = __esm({
|
|
|
339
407
|
versions: "Wersje",
|
|
340
408
|
details: "Szczeg\xF3\u0142y",
|
|
341
409
|
noOutline: "Ten dokument nie ma nag\u0142\xF3wk\xF3w",
|
|
410
|
+
findHeading: "Znajd\u017A nag\u0142\xF3wek",
|
|
411
|
+
read: "przeczytano",
|
|
412
|
+
showSections: "Poka\u017C sekcje",
|
|
413
|
+
hideSections: "Ukryj sekcje",
|
|
342
414
|
current: "Bie\u017C\u0105ca",
|
|
343
415
|
size: "Rozmiar",
|
|
344
416
|
updated: "Zmieniono",
|
|
@@ -386,6 +458,12 @@ var init_text = __esm({
|
|
|
386
458
|
save: "Zapisz",
|
|
387
459
|
saving: "Zapisywanie",
|
|
388
460
|
saved: "Zapisano",
|
|
461
|
+
align: "Wyr\xF3wnanie",
|
|
462
|
+
moreTools: "Wi\u0119cej narz\u0119dzi",
|
|
463
|
+
fewerTools: "Mniej narz\u0119dzi",
|
|
464
|
+
typeFilter: "Typ",
|
|
465
|
+
selectAll: "Zaznacz wszystkie",
|
|
466
|
+
clearPick: "Wyczy\u015B\u0107",
|
|
389
467
|
saveFailed: "Nie uda\u0142o si\u0119 zapisa\u0107",
|
|
390
468
|
remove: "Usu\u0144",
|
|
391
469
|
notePlaceholder: "Napisz notatk\u0119",
|
|
@@ -449,6 +527,14 @@ var init_text = __esm({
|
|
|
449
527
|
chooseFile: "Wybierz plik",
|
|
450
528
|
put: "Wstaw",
|
|
451
529
|
link: "Link",
|
|
530
|
+
footnote: "Przypis",
|
|
531
|
+
footnoteText: "Tekst przypisu",
|
|
532
|
+
formula: "Wz\xF3r",
|
|
533
|
+
formulaHint: "Zapisany jako r\xF3wnanie Word",
|
|
534
|
+
symbols: "Znaki specjalne",
|
|
535
|
+
symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
|
|
536
|
+
update: "Zmie\u0144",
|
|
537
|
+
removeFootnote: "Usu\u0144 przypis",
|
|
452
538
|
linkAddress: "Adres linku",
|
|
453
539
|
apply: "Zastosuj",
|
|
454
540
|
unlink: "Usu\u0144 link",
|
|
@@ -494,6 +580,11 @@ var init_text = __esm({
|
|
|
494
580
|
removed: "Usuni\u0119to",
|
|
495
581
|
someone: "Kto\u015B",
|
|
496
582
|
copyAs: "Zr\xF3b kopi\u0119 XLSX",
|
|
583
|
+
downloadAs: "Pobierz jako",
|
|
584
|
+
makeCopy: "Utw\xF3rz kopi\u0119",
|
|
585
|
+
copyOf: "Kopia",
|
|
586
|
+
rename: "Zmie\u0144 nazw\u0119",
|
|
587
|
+
renameFailed: "Nie uda\u0142o si\u0119 zmieni\u0107 nazwy",
|
|
497
588
|
copyFailed: "Nie uda\u0142o si\u0119 zrobi\u0107 kopii",
|
|
498
589
|
editComment: "Edytuj",
|
|
499
590
|
delete: "Usu\u0144",
|
|
@@ -580,7 +671,52 @@ var init_text = __esm({
|
|
|
580
671
|
untitled: "Bez tytu\u0142u",
|
|
581
672
|
kindHints: { docx: "Word, DOCX", markdown: "MD, ten sam edytor", sheet: "Excel, XLSX", slides: "Slajdy HTML" },
|
|
582
673
|
newKinds: { docx: "Dokument", markdown: "Markdown", sheet: "Arkusz", slides: "Prezentacja" },
|
|
583
|
-
templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" }
|
|
674
|
+
templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" },
|
|
675
|
+
menuFile: "Plik",
|
|
676
|
+
menuEdit: "Edycja",
|
|
677
|
+
menuFormat: "Format",
|
|
678
|
+
menuTools: "Narz\u0119dzia",
|
|
679
|
+
zoom: "Powi\u0119kszenie",
|
|
680
|
+
font: "Czcionka",
|
|
681
|
+
fontSize: "Rozmiar czcionki",
|
|
682
|
+
defaultFont: "Domy\u015Blna",
|
|
683
|
+
lineSpacing: "Interlinia i odst\u0119py",
|
|
684
|
+
single: "Pojedyncza",
|
|
685
|
+
double: "Podw\xF3jna",
|
|
686
|
+
spaceAfter: "Dodaj odst\u0119p po akapicie",
|
|
687
|
+
noSpaceAfter: "Usu\u0144 odst\u0119p po akapicie",
|
|
688
|
+
superscript: "Indeks g\xF3rny",
|
|
689
|
+
subscript: "Indeks dolny",
|
|
690
|
+
painter: "Malarz format\xF3w",
|
|
691
|
+
painterHint: "Zaznacz tekst, dwuklik zostawia w\u0142\u0105czone, Esc ko\u0144czy",
|
|
692
|
+
pageSetup: "Ustawienia strony",
|
|
693
|
+
orientation: "Orientacja",
|
|
694
|
+
portrait: "Pionowa",
|
|
695
|
+
landscape: "Pozioma",
|
|
696
|
+
marginsCm: "Marginesy, cm",
|
|
697
|
+
mTop: "G\xF3rny",
|
|
698
|
+
mRight: "Prawy",
|
|
699
|
+
mBottom: "Dolny",
|
|
700
|
+
mLeft: "Lewy",
|
|
701
|
+
headerText: "Nag\u0142\xF3wek",
|
|
702
|
+
footerText: "Stopka",
|
|
703
|
+
pageNumbers: "Numery stron w stopce",
|
|
704
|
+
wrapInline: "W linii z tekstem",
|
|
705
|
+
wrapLeft: "Tekst op\u0142ywa z prawej",
|
|
706
|
+
wrapRight: "Tekst op\u0142ywa z lewej",
|
|
707
|
+
cellFill: "Wype\u0142nienie kom\xF3rki",
|
|
708
|
+
tableBorders: "Obramowanie tabeli",
|
|
709
|
+
findReplace: "Znajd\u017A i zamie\u0144",
|
|
710
|
+
replaceWith: "Zamie\u0144 na",
|
|
711
|
+
replaceOne: "Zamie\u0144",
|
|
712
|
+
replaceAll: "Zamie\u0144 wszystko",
|
|
713
|
+
matchCase: "Uwzgl\u0119dnij wielko\u015B\u0107 liter",
|
|
714
|
+
words: "S\u0142owa",
|
|
715
|
+
print: "Drukuj",
|
|
716
|
+
autosavedNote: "Zapisano automatycznie",
|
|
717
|
+
uploadFile: "Wgraj plik",
|
|
718
|
+
uploading: "Wysy\u0142anie",
|
|
719
|
+
uploadFailed: "Nie uda\u0142o si\u0119 wgra\u0107 pliku"
|
|
584
720
|
};
|
|
585
721
|
uk2 = {
|
|
586
722
|
documents: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0438",
|
|
@@ -597,6 +733,10 @@ var init_text = __esm({
|
|
|
597
733
|
versions: "\u0412\u0435\u0440\u0441\u0456\u0457",
|
|
598
734
|
details: "\u0414\u0435\u0442\u0430\u043B\u0456",
|
|
599
735
|
noOutline: "\u0423 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0456 \u043D\u0435\u043C\u0430\u0454 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0456\u0432",
|
|
736
|
+
findHeading: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A",
|
|
737
|
+
read: "\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043E",
|
|
738
|
+
showSections: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
|
|
739
|
+
hideSections: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
|
|
600
740
|
current: "\u041F\u043E\u0442\u043E\u0447\u043D\u0430",
|
|
601
741
|
size: "\u0420\u043E\u0437\u043C\u0456\u0440",
|
|
602
742
|
updated: "\u0417\u043C\u0456\u043D\u0435\u043D\u043E",
|
|
@@ -644,6 +784,12 @@ var init_text = __esm({
|
|
|
644
784
|
save: "\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
|
|
645
785
|
saving: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043D\u044F",
|
|
646
786
|
saved: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E",
|
|
787
|
+
align: "\u0412\u0438\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u043D\u043D\u044F",
|
|
788
|
+
moreTools: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
|
|
789
|
+
fewerTools: "\u041C\u0435\u043D\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
|
|
790
|
+
typeFilter: "\u0422\u0438\u043F",
|
|
791
|
+
selectAll: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0441\u0456",
|
|
792
|
+
clearPick: "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",
|
|
647
793
|
saveFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
|
|
648
794
|
remove: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
|
|
649
795
|
notePlaceholder: "\u041D\u0430\u043F\u0438\u0448\u0456\u0442\u044C \u043D\u043E\u0442\u0430\u0442\u043A\u0443",
|
|
@@ -706,6 +852,14 @@ var init_text = __esm({
|
|
|
706
852
|
imageLink: "\u0410\u0434\u0440\u0435\u0441\u0430 \u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u043D\u044F",
|
|
707
853
|
chooseFile: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0444\u0430\u0439\u043B",
|
|
708
854
|
put: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
|
|
855
|
+
footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
|
|
856
|
+
footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
|
|
857
|
+
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
|
+
symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
|
|
860
|
+
symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
|
|
861
|
+
update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
|
|
862
|
+
removeFootnote: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0432\u0438\u043D\u043E\u0441\u043A\u0443",
|
|
709
863
|
link: "\u041F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
|
|
710
864
|
linkAddress: "\u0410\u0434\u0440\u0435\u0441\u0430 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
|
|
711
865
|
apply: "\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438",
|
|
@@ -752,6 +906,11 @@ var init_text = __esm({
|
|
|
752
906
|
removed: "\u0412\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
|
|
753
907
|
someone: "\u0425\u0442\u043E\u0441\u044C",
|
|
754
908
|
copyAs: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E XLSX",
|
|
909
|
+
downloadAs: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u044F\u043A",
|
|
910
|
+
makeCopy: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
|
|
911
|
+
copyOf: "\u041A\u043E\u043F\u0456\u044F",
|
|
912
|
+
rename: "\u041F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
|
|
913
|
+
renameFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u043F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
|
|
755
914
|
copyFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
|
|
756
915
|
editComment: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
|
|
757
916
|
delete: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
|
|
@@ -838,7 +997,52 @@ var init_text = __esm({
|
|
|
838
997
|
untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0438",
|
|
839
998
|
kindHints: { docx: "Word, DOCX", markdown: "MD, \u0442\u043E\u0439 \u0441\u0430\u043C\u0438\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440", sheet: "Excel, XLSX", slides: "HTML-\u0441\u043B\u0430\u0439\u0434\u0438" },
|
|
840
999
|
newKinds: { docx: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442", markdown: "Markdown", sheet: "\u0422\u0430\u0431\u043B\u0438\u0446\u044F", slides: "\u041F\u0440\u0435\u0437\u0435\u043D\u0442\u0430\u0446\u0456\u044F" },
|
|
841
|
-
templates: { blank: "\u041F\u043E\u0440\u043E\u0436\u043D\u0456\u0439", letter: "\u041B\u0438\u0441\u0442", contract: "\u0414\u043E\u0433\u043E\u0432\u0456\u0440", notes: "\u041D\u043E\u0442\u0430\u0442\u043A\u0438 \u0437\u0443\u0441\u0442\u0440\u0456\u0447\u0456", invoice: "\u0420\u0430\u0445\u0443\u043D\u043E\u043A", report: "\u0417\u0432\u0456\u0442" }
|
|
1000
|
+
templates: { blank: "\u041F\u043E\u0440\u043E\u0436\u043D\u0456\u0439", letter: "\u041B\u0438\u0441\u0442", contract: "\u0414\u043E\u0433\u043E\u0432\u0456\u0440", notes: "\u041D\u043E\u0442\u0430\u0442\u043A\u0438 \u0437\u0443\u0441\u0442\u0440\u0456\u0447\u0456", invoice: "\u0420\u0430\u0445\u0443\u043D\u043E\u043A", report: "\u0417\u0432\u0456\u0442" },
|
|
1001
|
+
menuFile: "\u0424\u0430\u0439\u043B",
|
|
1002
|
+
menuEdit: "\u041F\u0440\u0430\u0432\u043A\u0430",
|
|
1003
|
+
menuFormat: "\u0424\u043E\u0440\u043C\u0430\u0442",
|
|
1004
|
+
menuTools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438",
|
|
1005
|
+
zoom: "\u041C\u0430\u0441\u0448\u0442\u0430\u0431",
|
|
1006
|
+
font: "\u0428\u0440\u0438\u0444\u0442",
|
|
1007
|
+
fontSize: "\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443",
|
|
1008
|
+
defaultFont: "\u0422\u0438\u043F\u043E\u0432\u0438\u0439",
|
|
1009
|
+
lineSpacing: "\u041C\u0456\u0436\u0440\u044F\u0434\u043A\u043E\u0432\u0438\u0439 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B \u0456 \u0432\u0456\u0434\u0441\u0442\u0443\u043F\u0438",
|
|
1010
|
+
single: "\u041E\u0434\u0438\u043D\u0430\u0440\u043D\u0438\u0439",
|
|
1011
|
+
double: "\u041F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439",
|
|
1012
|
+
spaceAfter: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0432\u0456\u0434\u0441\u0442\u0443\u043F \u043F\u0456\u0441\u043B\u044F \u0430\u0431\u0437\u0430\u0446\u0443",
|
|
1013
|
+
noSpaceAfter: "\u041F\u0440\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0456\u0434\u0441\u0442\u0443\u043F \u043F\u0456\u0441\u043B\u044F \u0430\u0431\u0437\u0430\u0446\u0443",
|
|
1014
|
+
superscript: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
|
|
1015
|
+
subscript: "\u041D\u0438\u0436\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
|
|
1016
|
+
painter: "\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438 \u0444\u043E\u0440\u043C\u0430\u0442",
|
|
1017
|
+
painterHint: "\u0412\u0438\u0434\u0456\u043B\u0456\u0442\u044C \u0442\u0435\u043A\u0441\u0442, \u043F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439 \u043A\u043B\u0456\u043A \u043B\u0438\u0448\u0430\u0454 \u0443\u0432\u0456\u043C\u043A\u043D\u0435\u043D\u0438\u043C, Esc \u0432\u0438\u043C\u0438\u043A\u0430\u0454",
|
|
1018
|
+
pageSetup: "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
|
|
1019
|
+
orientation: "\u041E\u0440\u0456\u0454\u043D\u0442\u0430\u0446\u0456\u044F",
|
|
1020
|
+
portrait: "\u041A\u043D\u0438\u0436\u043A\u043E\u0432\u0430",
|
|
1021
|
+
landscape: "\u0410\u043B\u044C\u0431\u043E\u043C\u043D\u0430",
|
|
1022
|
+
marginsCm: "\u041F\u043E\u043B\u044F, \u0441\u043C",
|
|
1023
|
+
mTop: "\u0412\u0435\u0440\u0445\u043D\u0454",
|
|
1024
|
+
mRight: "\u041F\u0440\u0430\u0432\u0435",
|
|
1025
|
+
mBottom: "\u041D\u0438\u0436\u043D\u0454",
|
|
1026
|
+
mLeft: "\u041B\u0456\u0432\u0435",
|
|
1027
|
+
headerText: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
|
|
1028
|
+
footerText: "\u041D\u0438\u0436\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
|
|
1029
|
+
pageNumbers: "\u041D\u043E\u043C\u0435\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043E\u043A \u0443\u043D\u0438\u0437\u0443",
|
|
1030
|
+
wrapInline: "\u0423 \u0440\u044F\u0434\u043A\u0443 \u0437 \u0442\u0435\u043A\u0441\u0442\u043E\u043C",
|
|
1031
|
+
wrapLeft: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043F\u0440\u0430\u0432\u043E\u0440\u0443\u0447",
|
|
1032
|
+
wrapRight: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043B\u0456\u0432\u043E\u0440\u0443\u0447",
|
|
1033
|
+
cellFill: "\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043A\u043B\u0456\u0442\u0438\u043D\u043A\u0438",
|
|
1034
|
+
tableBorders: "\u041C\u0435\u0436\u0456 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
|
|
1035
|
+
findReplace: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0439 \u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
|
|
1036
|
+
replaceWith: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u043D\u0430",
|
|
1037
|
+
replaceOne: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
|
|
1038
|
+
replaceAll: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u0432\u0441\u0456",
|
|
1039
|
+
matchCase: "\u0417 \u0443\u0440\u0430\u0445\u0443\u0432\u0430\u043D\u043D\u044F\u043C \u0440\u0435\u0433\u0456\u0441\u0442\u0440\u0443",
|
|
1040
|
+
words: "\u0421\u043B\u043E\u0432\u0430",
|
|
1041
|
+
print: "\u0414\u0440\u0443\u043A",
|
|
1042
|
+
autosavedNote: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u043D\u043E",
|
|
1043
|
+
uploadFile: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B",
|
|
1044
|
+
uploading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
|
|
1045
|
+
uploadFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B"
|
|
842
1046
|
};
|
|
843
1047
|
texts = { en: en2, pl: pl2, uk: uk2 };
|
|
844
1048
|
}
|
|
@@ -1237,6 +1441,8 @@ function fmtOf(marks2) {
|
|
|
1237
1441
|
else if (m.type === "underline") f.u = true;
|
|
1238
1442
|
else if (m.type === "strike") f.s = true;
|
|
1239
1443
|
else if (m.type === "code") f.code = true;
|
|
1444
|
+
else if (m.type === "superscript") f.va = "sup";
|
|
1445
|
+
else if (m.type === "subscript") f.va = "sub";
|
|
1240
1446
|
else if (m.type === "link" && typeof a.href === "string" && a.href) f.link = a.href;
|
|
1241
1447
|
else if (m.type === "highlight") f.hl = color(a.color) ?? "#ffff00";
|
|
1242
1448
|
else if (m.type === "textStyle") {
|
|
@@ -1255,6 +1461,7 @@ function marksOf(f) {
|
|
|
1255
1461
|
if (f.u) out.push({ type: "underline" });
|
|
1256
1462
|
if (f.s) out.push({ type: "strike" });
|
|
1257
1463
|
if (f.code) out.push({ type: "code" });
|
|
1464
|
+
if (f.va) out.push({ type: f.va === "sup" ? "superscript" : "subscript" });
|
|
1258
1465
|
if (f.link) out.push({ type: "link", attrs: { href: f.link } });
|
|
1259
1466
|
if (f.hl) out.push({ type: "highlight", attrs: { color: f.hl } });
|
|
1260
1467
|
if (f.color || f.size || f.font) out.push({ type: "textStyle", attrs: { color: f.color, fontSize: f.size, fontFamily: f.font } });
|
|
@@ -1265,7 +1472,7 @@ function marksOf(f) {
|
|
|
1265
1472
|
return out.length ? out : void 0;
|
|
1266
1473
|
}
|
|
1267
1474
|
function keyOf(f) {
|
|
1268
|
-
return `${+f.b}${+f.i}${+f.u}${+f.s}${+f.code}|${f.link ?? ""}|${f.hl ?? ""}|${f.color ?? ""}|${f.size ?? ""}|${f.font ?? ""}|${f.rev ?? ""}`;
|
|
1475
|
+
return `${+f.b}${+f.i}${+f.u}${+f.s}${+f.code}|${f.link ?? ""}|${f.hl ?? ""}|${f.color ?? ""}|${f.size ?? ""}|${f.font ?? ""}|${f.rev ?? ""}|${f.va ?? ""}`;
|
|
1269
1476
|
}
|
|
1270
1477
|
function outline(v) {
|
|
1271
1478
|
const n = Number(v);
|
|
@@ -1303,6 +1510,11 @@ function props(s, rPr, fonts) {
|
|
|
1303
1510
|
case "w:sz":
|
|
1304
1511
|
out.size = size(+(attr(s, k, "w:val") ?? 0) / 2);
|
|
1305
1512
|
break;
|
|
1513
|
+
case "w:vertAlign": {
|
|
1514
|
+
const v = attr(s, k, "w:val");
|
|
1515
|
+
out.va = v === "superscript" ? "sup" : v === "subscript" ? "sub" : null;
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1306
1518
|
case "w:highlight": {
|
|
1307
1519
|
const v = attr(s, k, "w:val") ?? "none";
|
|
1308
1520
|
out.hl = highlights[v] ? "#" + highlights[v] : null;
|
|
@@ -1338,7 +1550,7 @@ var init_pkg = __esm({
|
|
|
1338
1550
|
"use strict";
|
|
1339
1551
|
init_xml();
|
|
1340
1552
|
init_zip();
|
|
1341
|
-
plain = { b: false, i: false, u: false, s: false, code: false, link: null, hl: null, color: null, size: null, font: null, rev: null };
|
|
1553
|
+
plain = { b: false, i: false, u: false, s: false, code: false, link: null, hl: null, color: null, size: null, font: null, rev: null, va: null };
|
|
1342
1554
|
highlights = {
|
|
1343
1555
|
yellow: "ffff00",
|
|
1344
1556
|
green: "00ff00",
|
|
@@ -1584,6 +1796,272 @@ var init_pkg = __esm({
|
|
|
1584
1796
|
}
|
|
1585
1797
|
});
|
|
1586
1798
|
|
|
1799
|
+
// src/editor/math.ts
|
|
1800
|
+
function parse3(src) {
|
|
1801
|
+
let i = 0;
|
|
1802
|
+
const group = () => {
|
|
1803
|
+
if (src[i] === "{") {
|
|
1804
|
+
i++;
|
|
1805
|
+
const kids2 = row2("}");
|
|
1806
|
+
i++;
|
|
1807
|
+
return kids2.length === 1 ? kids2[0] : { t: "row", kids: kids2 };
|
|
1808
|
+
}
|
|
1809
|
+
return one2() ?? { t: "row", kids: [] };
|
|
1810
|
+
};
|
|
1811
|
+
const one2 = () => {
|
|
1812
|
+
while (src[i] === " ") i++;
|
|
1813
|
+
if (i >= src.length) return null;
|
|
1814
|
+
const c = src[i];
|
|
1815
|
+
if (c === "{") return group();
|
|
1816
|
+
if (c === "\\") {
|
|
1817
|
+
const m = /^\\([a-zA-Z]+|.)/.exec(src.slice(i));
|
|
1818
|
+
if (!m) {
|
|
1819
|
+
i++;
|
|
1820
|
+
return { t: "tok", v: "\\", kind: "mo" };
|
|
1821
|
+
}
|
|
1822
|
+
i += m[0].length;
|
|
1823
|
+
const name = m[1];
|
|
1824
|
+
if (name === "frac") return { t: "frac", num: group(), den: group() };
|
|
1825
|
+
if (name === "sqrt") {
|
|
1826
|
+
let deg = null;
|
|
1827
|
+
if (src[i] === "[") {
|
|
1828
|
+
const end = src.indexOf("]", i);
|
|
1829
|
+
deg = parse3(src.slice(i + 1, end < 0 ? src.length : end));
|
|
1830
|
+
i = end < 0 ? src.length : end + 1;
|
|
1831
|
+
}
|
|
1832
|
+
return { t: "sqrt", body: group(), deg };
|
|
1833
|
+
}
|
|
1834
|
+
if (name === "text" || name === "mathrm") {
|
|
1835
|
+
const g = src[i] === "{" ? src.indexOf("}", i) : -1;
|
|
1836
|
+
const v = g < 0 ? "" : src.slice(i + 1, g);
|
|
1837
|
+
i = g < 0 ? i : g + 1;
|
|
1838
|
+
return { t: "tok", v, kind: "mtext" };
|
|
1839
|
+
}
|
|
1840
|
+
if (name === "left" || name === "right") return one2();
|
|
1841
|
+
if (words[name]) return { t: "tok", v: words[name], kind: "mi" };
|
|
1842
|
+
if (ops[name]) return { t: "tok", v: ops[name], kind: "mo" };
|
|
1843
|
+
return { t: "tok", v: name.length === 1 ? name : `\\${name}`, kind: name.length === 1 ? "mo" : "mi" };
|
|
1844
|
+
}
|
|
1845
|
+
if (/[0-9.]/.test(c)) {
|
|
1846
|
+
const m = /^[0-9]*\.?[0-9]+|^[0-9]+/.exec(src.slice(i));
|
|
1847
|
+
i += m[0].length;
|
|
1848
|
+
return { t: "tok", v: m[0], kind: "mn" };
|
|
1849
|
+
}
|
|
1850
|
+
i++;
|
|
1851
|
+
if (/[\p{L}]/u.test(c)) return { t: "tok", v: c, kind: big.has(c) ? "mo" : "mi" };
|
|
1852
|
+
return { t: "tok", v: c, kind: "mo" };
|
|
1853
|
+
};
|
|
1854
|
+
const row2 = (stop) => {
|
|
1855
|
+
const kids2 = [];
|
|
1856
|
+
while (i < src.length && src[i] !== stop) {
|
|
1857
|
+
while (src[i] === " ") i++;
|
|
1858
|
+
if (i >= src.length || src[i] === stop) break;
|
|
1859
|
+
if (src[i] === "^" || src[i] === "_") {
|
|
1860
|
+
const base = kids2.pop() ?? { t: "row", kids: [] };
|
|
1861
|
+
const s = base.t === "script" && !base.sub !== !base.sup ? base : { t: "script", base, sub: null, sup: null };
|
|
1862
|
+
const which = src[i++] === "^" ? "sup" : "sub";
|
|
1863
|
+
s[which] = group();
|
|
1864
|
+
kids2.push(s);
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
if (src[i] === "}") {
|
|
1868
|
+
i++;
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
const a = one2();
|
|
1872
|
+
if (a) kids2.push(a);
|
|
1873
|
+
}
|
|
1874
|
+
return kids2;
|
|
1875
|
+
};
|
|
1876
|
+
const kids = row2("\0");
|
|
1877
|
+
return kids.length === 1 ? kids[0] : { t: "row", kids };
|
|
1878
|
+
}
|
|
1879
|
+
function ml(a) {
|
|
1880
|
+
switch (a.t) {
|
|
1881
|
+
case "tok":
|
|
1882
|
+
return `<${a.kind}>${esc(a.v)}</${a.kind}>`;
|
|
1883
|
+
case "row":
|
|
1884
|
+
return `<mrow>${a.kids.map(ml).join("")}</mrow>`;
|
|
1885
|
+
case "frac":
|
|
1886
|
+
return `<mfrac>${ml(a.num)}${ml(a.den)}</mfrac>`;
|
|
1887
|
+
case "sqrt":
|
|
1888
|
+
return a.deg ? `<mroot>${ml(a.body)}${ml(a.deg)}</mroot>` : `<msqrt>${ml(a.body)}</msqrt>`;
|
|
1889
|
+
case "script": {
|
|
1890
|
+
const over = a.base.t === "tok" && big.has(a.base.v);
|
|
1891
|
+
if (a.sub && a.sup) return `<${over ? "munderover" : "msubsup"}>${ml(a.base)}${ml(a.sub)}${ml(a.sup)}</${over ? "munderover" : "msubsup"}>`;
|
|
1892
|
+
if (a.sub) return `<${over ? "munder" : "msub"}>${ml(a.base)}${ml(a.sub)}</${over ? "munder" : "msub"}>`;
|
|
1893
|
+
return `<${over ? "mover" : "msup"}>${ml(a.base)}${ml(a.sup)}</${over ? "mover" : "msup"}>`;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
function om(a) {
|
|
1898
|
+
switch (a.t) {
|
|
1899
|
+
case "tok":
|
|
1900
|
+
return run(a.v, a.kind === "mtext" || a.kind === "mo" && !big.has(a.v));
|
|
1901
|
+
case "row":
|
|
1902
|
+
return a.kids.map(om).join("");
|
|
1903
|
+
case "frac":
|
|
1904
|
+
return `<m:f><m:num>${om(a.num)}</m:num><m:den>${om(a.den)}</m:den></m:f>`;
|
|
1905
|
+
case "sqrt":
|
|
1906
|
+
return a.deg ? `<m:rad><m:deg>${om(a.deg)}</m:deg><m:e>${om(a.body)}</m:e></m:rad>` : `<m:rad><m:radPr><m:degHide m:val="1"/></m:radPr><m:deg/><m:e>${om(a.body)}</m:e></m:rad>`;
|
|
1907
|
+
case "script": {
|
|
1908
|
+
if (a.base.t === "tok" && big.has(a.base.v)) return `<m:nary><m:naryPr><m:chr m:val="${a.base.v}"/>${a.sub ? "" : '<m:subHide m:val="1"/>'}${a.sup ? "" : '<m:supHide m:val="1"/>'}</m:naryPr><m:sub>${a.sub ? om(a.sub) : ""}</m:sub><m:sup>${a.sup ? om(a.sup) : ""}</m:sup><m:e/></m:nary>`;
|
|
1909
|
+
if (a.sub && a.sup) return `<m:sSubSup><m:e>${om(a.base)}</m:e><m:sub>${om(a.sub)}</m:sub><m:sup>${om(a.sup)}</m:sup></m:sSubSup>`;
|
|
1910
|
+
if (a.sub) return `<m:sSub><m:e>${om(a.base)}</m:e><m:sub>${om(a.sub)}</m:sub></m:sSub>`;
|
|
1911
|
+
return `<m:sSup><m:e>${om(a.base)}</m:e><m:sup>${om(a.sup)}</m:sup></m:sSup>`;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
function tree(xml) {
|
|
1916
|
+
const root = { name: "", kids: [], text: "", attrs: {} };
|
|
1917
|
+
const stack = [root];
|
|
1918
|
+
for (const m of xml.matchAll(/<(\/?)([\w:]+)([^>]*?)(\/?)>|([^<]+)/g)) {
|
|
1919
|
+
const top = stack[stack.length - 1];
|
|
1920
|
+
if (m[5] !== void 0) {
|
|
1921
|
+
top.text += m[5];
|
|
1922
|
+
continue;
|
|
1923
|
+
}
|
|
1924
|
+
if (m[1]) {
|
|
1925
|
+
stack.pop();
|
|
1926
|
+
continue;
|
|
1927
|
+
}
|
|
1928
|
+
const attrs2 = Object.fromEntries([...m[3].matchAll(/([\w:]+)="([^"]*)"/g)].map((a) => [a[1], a[2]]));
|
|
1929
|
+
const node = { name: m[2], kids: [], text: "", attrs: attrs2 };
|
|
1930
|
+
top.kids.push(node);
|
|
1931
|
+
if (!m[4]) stack.push(node);
|
|
1932
|
+
}
|
|
1933
|
+
return root;
|
|
1934
|
+
}
|
|
1935
|
+
function tex(n) {
|
|
1936
|
+
const part = (name) => n.kids.find((k) => k.name === name);
|
|
1937
|
+
const all = (k) => k ? k.kids.map(tex).join("") : "";
|
|
1938
|
+
switch (n.name) {
|
|
1939
|
+
case "m:t":
|
|
1940
|
+
return [...unesc(n.text)].map((ch) => glyph[ch] ? `\\${glyph[ch]} ` : ch).join("");
|
|
1941
|
+
case "m:f":
|
|
1942
|
+
return `\\frac{${all(part("m:num"))}}{${all(part("m:den"))}}`;
|
|
1943
|
+
case "m:sSup":
|
|
1944
|
+
return `${brace(all(part("m:e")))}^${brace(all(part("m:sup")))}`;
|
|
1945
|
+
case "m:sSub":
|
|
1946
|
+
return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}`;
|
|
1947
|
+
case "m:sSubSup":
|
|
1948
|
+
return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}^${brace(all(part("m:sup")))}`;
|
|
1949
|
+
case "m:rad": {
|
|
1950
|
+
const deg = all(part("m:deg"));
|
|
1951
|
+
return `\\sqrt${deg ? `[${deg}]` : ""}{${all(part("m:e"))}}`;
|
|
1952
|
+
}
|
|
1953
|
+
case "m:nary": {
|
|
1954
|
+
const chr = part("m:naryPr")?.kids.find((k) => k.name === "m:chr")?.attrs["m:val"] ?? "\u222B";
|
|
1955
|
+
const sub = all(part("m:sub")), sup = all(part("m:sup"));
|
|
1956
|
+
return `${glyph[chr] ? `\\${glyph[chr]}` : chr}${sub ? `_${brace(sub)}` : ""}${sup ? `^${brace(sup)}` : ""} ${all(part("m:e"))}`.trim();
|
|
1957
|
+
}
|
|
1958
|
+
case "m:d": {
|
|
1959
|
+
const pr = part("m:dPr")?.kids ?? [];
|
|
1960
|
+
const beg = pr.find((k) => k.name === "m:begChr")?.attrs["m:val"] ?? "(";
|
|
1961
|
+
const end = pr.find((k) => k.name === "m:endChr")?.attrs["m:val"] ?? ")";
|
|
1962
|
+
return `${beg}${n.kids.filter((k) => k.name === "m:e").map(all).join(",")}${end}`;
|
|
1963
|
+
}
|
|
1964
|
+
case "m:rPr":
|
|
1965
|
+
case "m:ctrlPr":
|
|
1966
|
+
case "w:rPr":
|
|
1967
|
+
case "m:naryPr":
|
|
1968
|
+
case "m:dPr":
|
|
1969
|
+
case "m:radPr":
|
|
1970
|
+
case "m:fPr":
|
|
1971
|
+
case "m:sSupPr":
|
|
1972
|
+
case "m:sSubPr":
|
|
1973
|
+
case "m:sSubSupPr":
|
|
1974
|
+
return "";
|
|
1975
|
+
default:
|
|
1976
|
+
return n.kids.map(tex).join("");
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
var words, ops, big, glyph, esc, mathml, run, omml, unesc, brace, latexOf;
|
|
1980
|
+
var init_math = __esm({
|
|
1981
|
+
"src/editor/math.ts"() {
|
|
1982
|
+
"use strict";
|
|
1983
|
+
words = {
|
|
1984
|
+
alpha: "\u03B1",
|
|
1985
|
+
beta: "\u03B2",
|
|
1986
|
+
gamma: "\u03B3",
|
|
1987
|
+
delta: "\u03B4",
|
|
1988
|
+
epsilon: "\u03B5",
|
|
1989
|
+
zeta: "\u03B6",
|
|
1990
|
+
eta: "\u03B7",
|
|
1991
|
+
theta: "\u03B8",
|
|
1992
|
+
iota: "\u03B9",
|
|
1993
|
+
kappa: "\u03BA",
|
|
1994
|
+
lambda: "\u03BB",
|
|
1995
|
+
mu: "\u03BC",
|
|
1996
|
+
nu: "\u03BD",
|
|
1997
|
+
xi: "\u03BE",
|
|
1998
|
+
pi: "\u03C0",
|
|
1999
|
+
rho: "\u03C1",
|
|
2000
|
+
sigma: "\u03C3",
|
|
2001
|
+
tau: "\u03C4",
|
|
2002
|
+
upsilon: "\u03C5",
|
|
2003
|
+
phi: "\u03C6",
|
|
2004
|
+
chi: "\u03C7",
|
|
2005
|
+
psi: "\u03C8",
|
|
2006
|
+
omega: "\u03C9",
|
|
2007
|
+
Gamma: "\u0393",
|
|
2008
|
+
Delta: "\u0394",
|
|
2009
|
+
Theta: "\u0398",
|
|
2010
|
+
Lambda: "\u039B",
|
|
2011
|
+
Xi: "\u039E",
|
|
2012
|
+
Pi: "\u03A0",
|
|
2013
|
+
Sigma: "\u03A3",
|
|
2014
|
+
Phi: "\u03A6",
|
|
2015
|
+
Psi: "\u03A8",
|
|
2016
|
+
Omega: "\u03A9",
|
|
2017
|
+
infty: "\u221E",
|
|
2018
|
+
partial: "\u2202",
|
|
2019
|
+
nabla: "\u2207"
|
|
2020
|
+
};
|
|
2021
|
+
ops = {
|
|
2022
|
+
cdot: "\xB7",
|
|
2023
|
+
times: "\xD7",
|
|
2024
|
+
div: "\xF7",
|
|
2025
|
+
pm: "\xB1",
|
|
2026
|
+
mp: "\u2213",
|
|
2027
|
+
le: "\u2264",
|
|
2028
|
+
leq: "\u2264",
|
|
2029
|
+
ge: "\u2265",
|
|
2030
|
+
geq: "\u2265",
|
|
2031
|
+
ne: "\u2260",
|
|
2032
|
+
neq: "\u2260",
|
|
2033
|
+
approx: "\u2248",
|
|
2034
|
+
equiv: "\u2261",
|
|
2035
|
+
to: "\u2192",
|
|
2036
|
+
rightarrow: "\u2192",
|
|
2037
|
+
leftarrow: "\u2190",
|
|
2038
|
+
Rightarrow: "\u21D2",
|
|
2039
|
+
in: "\u2208",
|
|
2040
|
+
notin: "\u2209",
|
|
2041
|
+
subset: "\u2282",
|
|
2042
|
+
cup: "\u222A",
|
|
2043
|
+
cap: "\u2229",
|
|
2044
|
+
forall: "\u2200",
|
|
2045
|
+
exists: "\u2203",
|
|
2046
|
+
sum: "\u2211",
|
|
2047
|
+
prod: "\u220F",
|
|
2048
|
+
int: "\u222B",
|
|
2049
|
+
oint: "\u222E",
|
|
2050
|
+
degree: "\xB0"
|
|
2051
|
+
};
|
|
2052
|
+
big = /* @__PURE__ */ new Set(["\u2211", "\u220F", "\u222B", "\u222E"]);
|
|
2053
|
+
glyph = {};
|
|
2054
|
+
for (const [k, v] of [...Object.entries(words), ...Object.entries(ops)]) glyph[v] ?? (glyph[v] = k);
|
|
2055
|
+
esc = (v) => v.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2056
|
+
mathml = (latex) => `<math xmlns="http://www.w3.org/1998/Math/MathML">${ml(parse3(latex))}</math>`;
|
|
2057
|
+
run = (v, plain4 = false) => `<m:r>${plain4 ? '<m:rPr><m:sty m:val="p"/></m:rPr>' : ""}<m:t xml:space="preserve">${esc(v)}</m:t></m:r>`;
|
|
2058
|
+
omml = (latex) => `<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">${om(parse3(latex))}</m:oMath>`;
|
|
2059
|
+
unesc = (v) => v.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
|
|
2060
|
+
brace = (v) => v.length === 1 ? v : `{${v}}`;
|
|
2061
|
+
latexOf = (xml) => tex(tree(xml)).replace(/\s+/g, " ").trim();
|
|
2062
|
+
}
|
|
2063
|
+
});
|
|
2064
|
+
|
|
1587
2065
|
// src/docx/read.ts
|
|
1588
2066
|
function align(v) {
|
|
1589
2067
|
if (v === "center") return "center";
|
|
@@ -1667,6 +2145,11 @@ function inline2(pieces2) {
|
|
|
1667
2145
|
const out = [];
|
|
1668
2146
|
let key2 = "";
|
|
1669
2147
|
for (const p of pieces2) {
|
|
2148
|
+
if (p.math !== void 0 || p.note) {
|
|
2149
|
+
out.push(p.note ? { type: "footnote", attrs: { id: p.note.id, text: p.note.text } } : { type: "math", attrs: { latex: p.math } });
|
|
2150
|
+
key2 = "";
|
|
2151
|
+
continue;
|
|
2152
|
+
}
|
|
1670
2153
|
if (p.img) {
|
|
1671
2154
|
out.push({ type: "image", attrs: { ...p.img } });
|
|
1672
2155
|
key2 = "";
|
|
@@ -1732,19 +2215,21 @@ function nest(list) {
|
|
|
1732
2215
|
}
|
|
1733
2216
|
return root;
|
|
1734
2217
|
}
|
|
1735
|
-
var blank2, mimes, Reader;
|
|
2218
|
+
var blank2, mimes, Reader, noteText;
|
|
1736
2219
|
var init_read = __esm({
|
|
1737
2220
|
"src/docx/read.ts"() {
|
|
1738
2221
|
"use strict";
|
|
1739
2222
|
init_pkg();
|
|
1740
2223
|
init_xml();
|
|
1741
|
-
|
|
2224
|
+
init_math();
|
|
2225
|
+
blank2 = () => ({ align: null, indent: 0, line: null, after: null, ref: null });
|
|
1742
2226
|
mimes = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", bmp: "image/bmp", webp: "image/webp", svg: "image/svg+xml" };
|
|
1743
2227
|
Reader = class {
|
|
1744
2228
|
constructor(pkg) {
|
|
1745
2229
|
this.pkg = pkg;
|
|
1746
2230
|
this.n = 0;
|
|
1747
2231
|
this.refs = /* @__PURE__ */ new Map();
|
|
2232
|
+
this.footnotes = null;
|
|
1748
2233
|
this.counters = /* @__PURE__ */ new Map();
|
|
1749
2234
|
this.fmts = /* @__PURE__ */ new Map();
|
|
1750
2235
|
this.media = /* @__PURE__ */ new Map();
|
|
@@ -1845,7 +2330,14 @@ var init_read = __esm({
|
|
|
1845
2330
|
const src = p.pic && this.src(p.pic.embed);
|
|
1846
2331
|
if (!src) continue;
|
|
1847
2332
|
const meta2 = Object.fromEntries(attrs(/<wp:docPr\b[^>]*>/.exec(p.raw)?.[0] ?? "<x>"));
|
|
1848
|
-
p.img = {
|
|
2333
|
+
p.img = {
|
|
2334
|
+
src,
|
|
2335
|
+
alt: meta2.descr ?? null,
|
|
2336
|
+
title: meta2.title ?? null,
|
|
2337
|
+
width: Math.round(p.pic.cx / 9525),
|
|
2338
|
+
height: Math.round(p.pic.cy / 9525),
|
|
2339
|
+
wrap: /<wp:anchor\b/.test(p.raw) ? /<wp:positionH\b[^>]*>\s*<wp:align>right</.test(p.raw) ? "right" : "left" : null
|
|
2340
|
+
};
|
|
1849
2341
|
}
|
|
1850
2342
|
const pPr = kid(el, "w:pPr");
|
|
1851
2343
|
const styles2 = this.pkg.styles;
|
|
@@ -1873,7 +2365,11 @@ var init_read = __esm({
|
|
|
1873
2365
|
const ind = pPr && kid(pPr, "w:ind");
|
|
1874
2366
|
const left = ind && (attr(s, ind, "w:left") ?? attr(s, ind, "w:start"));
|
|
1875
2367
|
const indent2 = isList ? 0 : Math.max(0, Math.round((left !== null && left !== void 0 ? +left : styles2.left(style)) / 720));
|
|
1876
|
-
const
|
|
2368
|
+
const sp = pPr && kid(pPr, "w:spacing");
|
|
2369
|
+
const lineAt = sp && attr(s, sp, "w:line");
|
|
2370
|
+
const afterAt = sp && attr(s, sp, "w:after");
|
|
2371
|
+
const auto = !sp || !attr(s, sp, "w:lineRule") || attr(s, sp, "w:lineRule") === "auto";
|
|
2372
|
+
const base = { align: align(jc ? attr(s, jc, "w:val") : styles2.jc(style)), indent: indent2, line: lineAt && auto ? Math.round(+lineAt / 2.4) / 100 : null, after: afterAt ? +afterAt / 20 : null, ref };
|
|
1877
2373
|
const node = level ? { type: "heading", attrs: { level, ...base } } : { type: "paragraph", attrs: base };
|
|
1878
2374
|
const content = inline2(final);
|
|
1879
2375
|
if (content.length) node.content = content;
|
|
@@ -1891,6 +2387,14 @@ var init_read = __esm({
|
|
|
1891
2387
|
}
|
|
1892
2388
|
return b;
|
|
1893
2389
|
}
|
|
2390
|
+
notes() {
|
|
2391
|
+
if (!this.footnotes) {
|
|
2392
|
+
const rel = this.pkg.byType("/footnotes");
|
|
2393
|
+
const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
|
|
2394
|
+
this.footnotes = new Map([...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"[^>]*>([\s\S]*?)<\/w:footnote>/g)].map((m) => [m[1], noteText(m[2])]));
|
|
2395
|
+
}
|
|
2396
|
+
return this.footnotes;
|
|
2397
|
+
}
|
|
1894
2398
|
src(embed) {
|
|
1895
2399
|
if (!this.media.has(embed)) {
|
|
1896
2400
|
const rel = this.pkg.rels.get(embed);
|
|
@@ -1936,10 +2440,8 @@ var init_read = __esm({
|
|
|
1936
2440
|
const inside = [];
|
|
1937
2441
|
this.walk(k.kids, ctx, k, inside, { lock: null, task: false, box: false });
|
|
1938
2442
|
this.span(s.slice(k.start, k.end), inside, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
|
|
1939
|
-
} else if (name === "m:oMath") {
|
|
1940
|
-
|
|
1941
|
-
this.span(s.slice(k.start, k.end), text ? [{ text, raw: null, run: null, ctx, span: null }] : [], out, ctx, null);
|
|
1942
|
-
} else if (name === "m:oMathPara") st.lock = "Equation";
|
|
2443
|
+
} 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
|
+
else if (name === "m:oMathPara") st.lock = "Equation";
|
|
1943
2445
|
else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
|
|
1944
2446
|
}
|
|
1945
2447
|
}
|
|
@@ -1960,17 +2462,17 @@ var init_read = __esm({
|
|
|
1960
2462
|
out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
|
|
1961
2463
|
return;
|
|
1962
2464
|
}
|
|
1963
|
-
const
|
|
2465
|
+
const run3 = { open: opened(s, k), rPr: rPrEl ? s.slice(rPrEl.start, rPrEl.end) : "", fmt: f, el: k, parent };
|
|
1964
2466
|
const push = (text, raw, extra) => {
|
|
1965
2467
|
if (text !== null && st.box) {
|
|
1966
2468
|
st.box = false;
|
|
1967
2469
|
if (text.startsWith(" ") && raw === null) {
|
|
1968
|
-
out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run:
|
|
2470
|
+
out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run: run3, ctx, span: null, box: true });
|
|
1969
2471
|
text = text.slice(1);
|
|
1970
2472
|
if (!text) return;
|
|
1971
2473
|
}
|
|
1972
2474
|
}
|
|
1973
|
-
out.push({ text, raw, run:
|
|
2475
|
+
out.push({ text, raw, run: run3, ctx, span: null, ...extra });
|
|
1974
2476
|
};
|
|
1975
2477
|
for (const c of k.kids) {
|
|
1976
2478
|
const raw = s.slice(c.start, c.end);
|
|
@@ -2003,6 +2505,11 @@ var init_read = __esm({
|
|
|
2003
2505
|
else push("\n", raw);
|
|
2004
2506
|
break;
|
|
2005
2507
|
}
|
|
2508
|
+
case "w:footnoteReference": {
|
|
2509
|
+
const id = attr(s, c, "w:id") ?? "";
|
|
2510
|
+
push("\uE001", raw, { note: { id, text: this.notes().get(id) ?? "" } });
|
|
2511
|
+
break;
|
|
2512
|
+
}
|
|
2006
2513
|
case "w:fldChar":
|
|
2007
2514
|
push(null, raw, { fld: attr(s, c, "w:fldCharType") ?? "" });
|
|
2008
2515
|
break;
|
|
@@ -2081,10 +2588,13 @@ var init_read = __esm({
|
|
|
2081
2588
|
const ref = this.ref();
|
|
2082
2589
|
const pr = kid(el, "w:tblPr");
|
|
2083
2590
|
const jc = pr && kid(pr, "w:jc");
|
|
2084
|
-
const
|
|
2591
|
+
const bd = pr && kid(pr, "w:tblBorders");
|
|
2592
|
+
const bare2 = !!bd && bd.kids.length > 0 && bd.kids.every((k) => /^(none|nil)$/.test(attr(s, k, "w:val") ?? ""));
|
|
2593
|
+
const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, borders: bare2 ? "none" : null, ref }, content: [] };
|
|
2085
2594
|
const b = this.block("tbl", el, node, ref);
|
|
2086
2595
|
const grid3 = kid(el, "w:tblGrid");
|
|
2087
2596
|
b.cols = grid3 ? grid3.kids.filter((k) => k.name === "w:gridCol").length : 0;
|
|
2597
|
+
const widths = grid3 ? grid3.kids.filter((k) => k.name === "w:gridCol").map((k) => Math.floor(+(attr(s, k, "w:w") ?? 0) / 15)) : [];
|
|
2088
2598
|
const open = [];
|
|
2089
2599
|
let prev = grid3 ? grid3.end : pr ? pr.end : el.open;
|
|
2090
2600
|
for (const tr of el.kids) {
|
|
@@ -2120,7 +2630,10 @@ var init_read = __esm({
|
|
|
2120
2630
|
if (vm === "continue") open[col].attrs.rowspan++;
|
|
2121
2631
|
else {
|
|
2122
2632
|
const content = assemble(inside.list);
|
|
2123
|
-
|
|
2633
|
+
const own = widths.slice(col, col + span2);
|
|
2634
|
+
const shd = tcPr && kid(tcPr, "w:shd");
|
|
2635
|
+
const fill3 = shd ? attr(s, shd, "w:fill") : null;
|
|
2636
|
+
cell2.node = { type: header ? "tableHeader" : "tableCell", attrs: { colspan: span2, rowspan: 1, colwidth: own.length === span2 && own.every((w) => w > 0) ? own : null, background: fill3 && /^[0-9a-f]{6}$/i.test(fill3) ? `#${fill3.toLowerCase()}` : null, align: null, indent: 0, ref: cref }, content: content.length ? content : [{ type: "paragraph", attrs: blank2() }] };
|
|
2124
2637
|
row2.node.content.push(cell2.node);
|
|
2125
2638
|
for (let c = col; c < col + span2; c++) open[c] = null;
|
|
2126
2639
|
if (vm === "restart") open[col] = cell2.node;
|
|
@@ -2134,6 +2647,7 @@ var init_read = __esm({
|
|
|
2134
2647
|
return b;
|
|
2135
2648
|
}
|
|
2136
2649
|
};
|
|
2650
|
+
noteText = (xml) => [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&").trim();
|
|
2137
2651
|
}
|
|
2138
2652
|
});
|
|
2139
2653
|
|
|
@@ -2195,6 +2709,8 @@ function value(key2, v) {
|
|
|
2195
2709
|
if (v === void 0 || v === "" || v === null) return null;
|
|
2196
2710
|
if (key2 === "align") return v === "left" ? null : v;
|
|
2197
2711
|
if (key2 === "width" || key2 === "height") return Math.round(Number(v)) || null;
|
|
2712
|
+
if (key2 === "line" || key2 === "after") return Number.isFinite(Number(v)) ? Number(v) : null;
|
|
2713
|
+
if (key2 === "colwidth") return Array.isArray(v) && v.length && v.every((w) => Number(w) > 0) ? v.map((w) => Math.round(Number(w))) : null;
|
|
2198
2714
|
if (key2 === "indent" || key2 === "level" || key2 === "colspan" || key2 === "rowspan" || key2 === "start") return Number(v) || 0;
|
|
2199
2715
|
if (key2 === "checked") return !!v;
|
|
2200
2716
|
return v;
|
|
@@ -2221,14 +2737,14 @@ function inlineSig(kids) {
|
|
|
2221
2737
|
out += (next === key2 ? "" : `${next}`) + k.text;
|
|
2222
2738
|
key2 = next;
|
|
2223
2739
|
} else {
|
|
2224
|
-
out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : ""}`;
|
|
2740
|
+
out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : k.type === "math" ? k.attrs?.latex : k.type === "footnote" ? `${k.attrs?.id}:${k.attrs?.text}` : ""}`;
|
|
2225
2741
|
key2 = null;
|
|
2226
2742
|
}
|
|
2227
2743
|
}
|
|
2228
2744
|
return out;
|
|
2229
2745
|
}
|
|
2230
2746
|
function picture2(a) {
|
|
2231
|
-
return JSON.stringify([a.src ?? null, a.alt || null, a.title || null, Math.round(Number(a.width)) || null, Math.round(Number(a.height)) || null]);
|
|
2747
|
+
return JSON.stringify([a.src ?? null, a.alt || null, a.title || null, Math.round(Number(a.width)) || null, Math.round(Number(a.height)) || null, a.wrap || null]);
|
|
2232
2748
|
}
|
|
2233
2749
|
function flatten(content, out = [], quote2 = false) {
|
|
2234
2750
|
for (const node of content) {
|
|
@@ -2354,21 +2870,23 @@ var init_write = __esm({
|
|
|
2354
2870
|
init_read();
|
|
2355
2871
|
init_xml();
|
|
2356
2872
|
init_zip();
|
|
2873
|
+
init_math();
|
|
2357
2874
|
P = ["w:pStyle", "w:keepNext", "w:keepLines", "w:pageBreakBefore", "w:framePr", "w:widowControl", "w:numPr", "w:suppressLineNumbers", "w:pBdr", "w:shd", "w:tabs", "w:suppressAutoHyphens", "w:kinsoku", "w:wordWrap", "w:overflowPunct", "w:topLinePunct", "w:autoSpaceDE", "w:autoSpaceDN", "w:bidi", "w:adjustRightInd", "w:snapToGrid", "w:spacing", "w:ind", "w:contextualSpacing", "w:mirrorIndents", "w:suppressOverlap", "w:jc", "w:textDirection", "w:textAlignment", "w:textboxTightWrap", "w:outlineLvl", "w:divId", "w:cnfStyle", "w:rPr", "w:sectPr", "w:pPrChange"];
|
|
2358
2875
|
R = ["w:rStyle", "w:rFonts", "w:b", "w:bCs", "w:i", "w:iCs", "w:caps", "w:smallCaps", "w:strike", "w:dstrike", "w:outline", "w:shadow", "w:emboss", "w:imprint", "w:noProof", "w:snapToGrid", "w:vanish", "w:webHidden", "w:color", "w:spacing", "w:w", "w:kern", "w:position", "w:sz", "w:szCs", "w:highlight", "w:u", "w:effect", "w:bdr", "w:shd", "w:fitText", "w:vertAlign", "w:rtl", "w:cs", "w:em", "w:lang", "w:eastAsianLayout", "w:specVanish", "w:oMath"];
|
|
2359
2876
|
TC = ["w:cnfStyle", "w:tcW", "w:gridSpan", "w:hMerge", "w:vMerge", "w:tcBorders", "w:shd", "w:noWrap", "w:tcMar", "w:textDirection", "w:tcFitText", "w:vAlign", "w:hideMark", "w:headers", "w:cellIns", "w:cellDel", "w:cellMerge", "w:tcPrChange"];
|
|
2360
2877
|
REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
2361
2878
|
special = { " ": "<w:tab/>", "\n": "<w:br/>", "\u2011": "<w:noBreakHyphen/>", "\xAD": "<w:softHyphen/>" };
|
|
2362
2879
|
keys = {
|
|
2363
|
-
paragraph: [["align", null], ["indent", 0]],
|
|
2364
|
-
heading: [["level", 1], ["align", null], ["indent", 0]],
|
|
2365
|
-
table: [["align", null]],
|
|
2366
|
-
tableCell: [["colspan", 1], ["rowspan", 1]],
|
|
2367
|
-
tableHeader: [["colspan", 1], ["rowspan", 1]],
|
|
2880
|
+
paragraph: [["align", null], ["indent", 0], ["line", null], ["after", null]],
|
|
2881
|
+
heading: [["level", 1], ["align", null], ["indent", 0], ["line", null], ["after", null]],
|
|
2882
|
+
table: [["align", null], ["borders", null]],
|
|
2883
|
+
tableCell: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
|
|
2884
|
+
tableHeader: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
|
|
2368
2885
|
orderedList: [["start", 1]],
|
|
2369
2886
|
taskItem: [["checked", false]],
|
|
2370
2887
|
codeBlock: [["language", null]],
|
|
2371
|
-
toc: [["entries", "[]"], ["title", null]]
|
|
2888
|
+
toc: [["entries", "[]"], ["title", null]],
|
|
2889
|
+
image: [["src", null], ["alt", null], ["title", null], ["width", null], ["height", null], ["wrap", null]]
|
|
2372
2890
|
};
|
|
2373
2891
|
groups = 0;
|
|
2374
2892
|
Writer = class {
|
|
@@ -2394,6 +2912,7 @@ var init_write = __esm({
|
|
|
2394
2912
|
this.srcs = null;
|
|
2395
2913
|
this.tocs = false;
|
|
2396
2914
|
this.revs = /* @__PURE__ */ new Map();
|
|
2915
|
+
this.lastNote = null;
|
|
2397
2916
|
this.r = new Reader(pkg);
|
|
2398
2917
|
this.s = pkg.doc;
|
|
2399
2918
|
for (const id of pkg.rels.keys()) this.relIds.add(id);
|
|
@@ -2404,7 +2923,7 @@ var init_write = __esm({
|
|
|
2404
2923
|
this.docPr = max + 1;
|
|
2405
2924
|
this.nextRev = Math.max(0, ...[...this.s.matchAll(/\bw:id="(\d+)"/g)].map((m) => +m[1])) + 1;
|
|
2406
2925
|
}
|
|
2407
|
-
run(doc) {
|
|
2926
|
+
run(doc, setup) {
|
|
2408
2927
|
const s = this.s;
|
|
2409
2928
|
this.body = this.r.body();
|
|
2410
2929
|
const { list, tail, body } = this.body;
|
|
@@ -2414,8 +2933,9 @@ var init_write = __esm({
|
|
|
2414
2933
|
this.carryOver(list, (x) => rest = x);
|
|
2415
2934
|
let xml = this.container(flatten(doc.content ?? []), list, null);
|
|
2416
2935
|
if (this.last === "tbl" && list[list.length - 1]?.kind !== "tbl") xml += "<w:p/>";
|
|
2417
|
-
const text = s.slice(0, body.open) + xml + rest + s.slice(tail);
|
|
2418
2936
|
const changed2 = /* @__PURE__ */ new Map();
|
|
2937
|
+
const text = this.marginal(s.slice(0, body.open) + xml + rest + s.slice(tail), setup, changed2);
|
|
2938
|
+
this.footnotes(doc, changed2);
|
|
2419
2939
|
if (text !== s) changed2.set(this.pkg.main, text);
|
|
2420
2940
|
if (this.rels.length) {
|
|
2421
2941
|
const path = this.pkg.relsPath(this.pkg.main);
|
|
@@ -2541,6 +3061,110 @@ var init_write = __esm({
|
|
|
2541
3061
|
if (o.kind === "toc") return b && sig(o.node) === sig(b.node) ? s.slice(b.start, b.end) : this.toc(o.node);
|
|
2542
3062
|
return this.code(o);
|
|
2543
3063
|
}
|
|
3064
|
+
noteId() {
|
|
3065
|
+
const rel = this.pkg.byType("/footnotes");
|
|
3066
|
+
const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
|
|
3067
|
+
this.lastNote ?? (this.lastNote = Math.max(0, ...[...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"/g)].map((m) => +m[1])));
|
|
3068
|
+
return ++this.lastNote;
|
|
3069
|
+
}
|
|
3070
|
+
footnotes(doc, changed2) {
|
|
3071
|
+
const notes2 = [];
|
|
3072
|
+
const walk = (n) => {
|
|
3073
|
+
if (n.type === "footnote" && n.attrs?.id) notes2.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
|
|
3074
|
+
n.content?.forEach(walk);
|
|
3075
|
+
};
|
|
3076
|
+
walk(doc);
|
|
3077
|
+
const rel = this.pkg.byType("/footnotes");
|
|
3078
|
+
const old = rel ? this.pkg.text(rel.target) : null;
|
|
3079
|
+
if (!notes2.length) return;
|
|
3080
|
+
const path = rel ? rel.target : "word/footnotes.xml";
|
|
3081
|
+
let xml = old ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3082
|
+
<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, words2) => `<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(words2)}</w:t></w:r></w:p></w:footnote>`;
|
|
3084
|
+
for (const n of notes2) {
|
|
3085
|
+
const found = new RegExp(`<w:footnote\\b[^>]*\\bw:id="${n.id}"[^>]*>([\\s\\S]*?)</w:footnote>`).exec(xml);
|
|
3086
|
+
if (found && noteText(found[1]) === n.text) continue;
|
|
3087
|
+
xml = found ? xml.replace(found[0], fresh2(n.id, n.text)) : xml.replace(/<\/w:footnotes>\s*$/, fresh2(n.id, n.text) + "</w:footnotes>");
|
|
3088
|
+
}
|
|
3089
|
+
if (xml === old) return;
|
|
3090
|
+
changed2.set(path, xml);
|
|
3091
|
+
if (rel) return;
|
|
3092
|
+
this.rels.push(`<Relationship Id="${this.relId()}" Type="${REL}/footnotes" Target="footnotes.xml"/>`);
|
|
3093
|
+
this.types.add(`<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>`);
|
|
3094
|
+
}
|
|
3095
|
+
marginal(text, setup, changed2) {
|
|
3096
|
+
if (!setup || !setup.page && setup.header === void 0 && setup.footer === void 0 && setup.numbers === void 0) return text;
|
|
3097
|
+
const end = text.lastIndexOf("</w:body>");
|
|
3098
|
+
const opens2 = (i) => /^<w:sectPr[\s>/]/.test(text.slice(i, i + 11));
|
|
3099
|
+
let start = -1;
|
|
3100
|
+
let close = text.lastIndexOf("</w:sectPr>", end);
|
|
3101
|
+
if (close >= 0 && !text.slice(close + 11, end).trim()) {
|
|
3102
|
+
let depth = 1;
|
|
3103
|
+
let i = close;
|
|
3104
|
+
while (depth > 0 && i > 0) {
|
|
3105
|
+
let o = text.lastIndexOf("<w:sectPr", i - 1);
|
|
3106
|
+
while (o >= 0 && !opens2(o)) o = text.lastIndexOf("<w:sectPr", o - 1);
|
|
3107
|
+
const c = text.lastIndexOf("</w:sectPr>", i - 1);
|
|
3108
|
+
if (c > o) {
|
|
3109
|
+
depth++;
|
|
3110
|
+
i = c;
|
|
3111
|
+
} else if (o < 0) break;
|
|
3112
|
+
else {
|
|
3113
|
+
if (text[text.indexOf(">", o) - 1] !== "/") depth--;
|
|
3114
|
+
i = o;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
start = i;
|
|
3118
|
+
close += 11;
|
|
3119
|
+
} else {
|
|
3120
|
+
start = close = end;
|
|
3121
|
+
}
|
|
3122
|
+
let sec = start === end ? "<w:sectPr></w:sectPr>" : text.slice(start, close);
|
|
3123
|
+
if (sec.endsWith("/>") && !sec.includes("</w:sectPr>")) sec = sec.slice(0, -2) + "></w:sectPr>";
|
|
3124
|
+
const after = ["w:pgMar", "w:paperSrc", "w:pgBorders", "w:lnNumType", "w:pgNumType", "w:cols", "w:formProt", "w:vAlign", "w:noEndnote", "w:titlePg", "w:textDirection", "w:bidi", "w:rtlGutter", "w:docGrid", "w:printerSettings", "w:sectPrChange"];
|
|
3125
|
+
const put = (name, xml, before) => {
|
|
3126
|
+
const re = new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`);
|
|
3127
|
+
if (re.test(sec)) {
|
|
3128
|
+
sec = sec.replace(re, xml);
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
const at = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
|
|
3132
|
+
const i = at.length ? Math.min(...at) : sec.lastIndexOf("</w:sectPr>");
|
|
3133
|
+
sec = sec.slice(0, i) + xml + sec.slice(i);
|
|
3134
|
+
};
|
|
3135
|
+
const tw = (px2) => Math.round(px2 * 15);
|
|
3136
|
+
if (setup.page) {
|
|
3137
|
+
const { width, height, margins: [top, right, bottom, left] } = setup.page;
|
|
3138
|
+
put("w:pgSz", `<w:pgSz w:w="${tw(width)}" w:h="${tw(height)}"${width > height ? ' w:orient="landscape"' : ""}/>`, after);
|
|
3139
|
+
const was = /<w:pgMar\b[^>]*\/>/.exec(sec)?.[0] ?? "";
|
|
3140
|
+
const keep = attrs(was.replace(/^<w:pgMar|\/>$/g, "")).filter(([k]) => !["w:top", "w:right", "w:bottom", "w:left"].includes(k));
|
|
3141
|
+
if (!keep.some(([k]) => k === "w:header")) keep.push(["w:header", "708"], ["w:footer", "708"], ["w:gutter", "0"]);
|
|
3142
|
+
put("w:pgMar", `<w:pgMar w:top="${tw(top)}" w:right="${tw(right)}" w:bottom="${tw(bottom)}" w:left="${tw(left)}" ${keep.map(([k, v]) => `${k}="${escape2(v)}"`).join(" ")}/>`, after.slice(1));
|
|
3143
|
+
}
|
|
3144
|
+
const part = (kind, body) => {
|
|
3145
|
+
sec = sec.replace(new RegExp(`<w:${kind}Reference\\b[^>]*\\bw:type="default"[^>]*/>`), "");
|
|
3146
|
+
if (!body) return;
|
|
3147
|
+
let n = 1;
|
|
3148
|
+
while (this.pkg.files.has(`word/${kind}${n}.xml`) || changed2.has(`word/${kind}${n}.xml`)) n++;
|
|
3149
|
+
const id = this.relId();
|
|
3150
|
+
const tag = kind === "header" ? "w:hdr" : "w:ftr";
|
|
3151
|
+
changed2.set(`word/${kind}${n}.xml`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3152
|
+
<${tag} xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}">${body}</${tag}>`);
|
|
3153
|
+
this.rels.push(`<Relationship Id="${id}" Type="${REL}/${kind}" Target="${kind}${n}.xml"/>`);
|
|
3154
|
+
this.types.add(`<Override PartName="/word/${kind}${n}.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${kind}+xml"/>`);
|
|
3155
|
+
const open = sec.indexOf(">") + 1;
|
|
3156
|
+
sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
|
|
3157
|
+
};
|
|
3158
|
+
const line = (words2, page) => {
|
|
3159
|
+
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 = words2 ? `<w:r><w:t xml:space="preserve">${escape2(words2)}</w:t></w:r>` : "";
|
|
3161
|
+
if (!words2 && !page) return "";
|
|
3162
|
+
return `<w:p><w:pPr>${page && words2 ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run3}${page && words2 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
|
|
3163
|
+
};
|
|
3164
|
+
if (setup.header !== void 0) part("header", line(setup.header, false));
|
|
3165
|
+
if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
|
|
3166
|
+
return text.slice(0, start) + sec + text.slice(close);
|
|
3167
|
+
}
|
|
2544
3168
|
toc(node) {
|
|
2545
3169
|
this.tocs = true;
|
|
2546
3170
|
const styles2 = this.pkg.styles;
|
|
@@ -2658,6 +3282,20 @@ var init_write = __esm({
|
|
|
2658
3282
|
if (align(direct ?? styles2.jc(style)) !== want) {
|
|
2659
3283
|
set["w:jc"] = align(styles2.jc(style)) === want ? null : `<w:jc w:val="${{ center: "center", right: "right", justify: "both" }[want ?? ""] ?? "left"}"/>`;
|
|
2660
3284
|
}
|
|
3285
|
+
const spEl = get("w:spacing");
|
|
3286
|
+
const spacing2 = spEl ? attrs(xml.slice(spEl.start, spEl.open)) : [];
|
|
3287
|
+
const had = (name) => spacing2.find(([k]) => k === name)?.[1] ?? null;
|
|
3288
|
+
const line = value("line", o.node.attrs?.line);
|
|
3289
|
+
const after = value("after", o.node.attrs?.after);
|
|
3290
|
+
const auto = !had("w:lineRule") || had("w:lineRule") === "auto";
|
|
3291
|
+
const drift = (had("w:line") && auto ? Math.round(+had("w:line") / 2.4) / 100 : null) !== line || (had("w:after") ? +had("w:after") / 20 : null) !== after;
|
|
3292
|
+
if ((b || line !== null || after !== null) && drift) {
|
|
3293
|
+
const kept = spacing2.filter(([k]) => k !== "w:line" && k !== "w:lineRule" && k !== "w:after" && !(k === "w:afterAutospacing" && after !== null));
|
|
3294
|
+
if (line !== null) kept.push(["w:line", String(Math.round(line * 240))], ["w:lineRule", "auto"]);
|
|
3295
|
+
else if (had("w:line") && !auto) kept.push(["w:line", had("w:line")], ["w:lineRule", had("w:lineRule")]);
|
|
3296
|
+
if (after !== null) kept.push(["w:after", String(Math.round(after * 20))]);
|
|
3297
|
+
set["w:spacing"] = kept.length ? `<w:spacing ${kept.map(([k, v]) => `${k}="${escape2(v)}"`).join(" ")}/>` : null;
|
|
3298
|
+
}
|
|
2661
3299
|
if (!pr) {
|
|
2662
3300
|
const indEl = "w:ind" in set ? void 0 : get("w:ind");
|
|
2663
3301
|
const list = indEl ? attrs(xml.slice(indEl.start, indEl.open)).filter(([k]) => k !== "w:left" && k !== "w:start") : [];
|
|
@@ -2714,7 +3352,7 @@ var init_write = __esm({
|
|
|
2714
3352
|
const base = p.span ? fmtAt({ ...p, span: null }) : fmt;
|
|
2715
3353
|
if (p.img) units.push({ ch: "\uFFFC", raw: p.raw, run: p.run, ctx: p.ctx, span: null, idx: n++, fmt, base, img: p.img });
|
|
2716
3354
|
else if (p.text === null) units.push({ ch: null, raw: p.raw, run: p.run, ctx: p.ctx, span: null, idx: n++, fmt, base, box: p.box });
|
|
2717
|
-
else if (p.raw !== null) units.push({ ch: p.text, raw: p.raw, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base });
|
|
3355
|
+
else if (p.raw !== null) units.push({ ch: p.text, raw: p.raw, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base, math: p.math, note: p.note });
|
|
2718
3356
|
else for (const ch of p.text) units.push({ ch, raw: null, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base });
|
|
2719
3357
|
if (p.run) counts.set(p.run, n);
|
|
2720
3358
|
}
|
|
@@ -2729,6 +3367,8 @@ var init_write = __esm({
|
|
|
2729
3367
|
for (const ch of n.text ?? "") B.push({ ch: ch === "\r" ? "\n" : ch, fmt: f, key: k });
|
|
2730
3368
|
} else if (n.type === "hardBreak") B.push({ ch: "\n", fmt: lastFmt, key: keyOf(lastFmt) });
|
|
2731
3369
|
else if (n.type === "image") B.push({ ch: "\uFFFC", fmt: lastFmt, key: keyOf(lastFmt), img: n.attrs ?? {} });
|
|
3370
|
+
else if (n.type === "math") B.push({ ch: "\uE000", fmt: lastFmt, key: keyOf(lastFmt), math: String(n.attrs?.latex ?? "") });
|
|
3371
|
+
else if (n.type === "footnote") B.push({ ch: "\uE001", fmt: lastFmt, key: keyOf(lastFmt), note: n.attrs ?? (n.attrs = {}) });
|
|
2732
3372
|
}
|
|
2733
3373
|
const boxes3 = units.filter((u) => u.box);
|
|
2734
3374
|
let box2 = null;
|
|
@@ -2784,6 +3424,20 @@ var init_write = __esm({
|
|
|
2784
3424
|
} else out.push({ ch: want.ch, raw: this.drawing(want.img), run: { open: "<w:r>", rPr: "", fmt: plain, el: null, parent: null }, ctx: [], u: null, fmt: plain });
|
|
2785
3425
|
continue;
|
|
2786
3426
|
}
|
|
3427
|
+
if (want.math !== void 0) {
|
|
3428
|
+
const u = i >= 0 ? A[i] : null;
|
|
3429
|
+
out.push(u?.math === want.math ? { ch: u.ch, raw: u.raw, run: null, ctx: u.ctx, u, fmt: u.fmt } : { ch: want.ch, raw: omml(want.math), run: null, ctx: u?.ctx ?? [], u: null, fmt: plain });
|
|
3430
|
+
continue;
|
|
3431
|
+
}
|
|
3432
|
+
if (want.note) {
|
|
3433
|
+
const u = i >= 0 ? A[i] : null;
|
|
3434
|
+
if (u?.note && u.note.id === want.note.id) out.push({ ch: u.ch, raw: u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
|
|
3435
|
+
else {
|
|
3436
|
+
want.note.id = typeof want.note.id === "string" && want.note.id ? want.note.id : String(this.noteId());
|
|
3437
|
+
out.push({ ch: want.ch, raw: `<w:footnoteReference w:id="${want.note.id}"/>`, run: { open: "<w:r>", rPr: '<w:rPr><w:vertAlign w:val="superscript"/></w:rPr>', fmt: plain, el: null, parent: null }, ctx: [], u: null, fmt: plain });
|
|
3438
|
+
}
|
|
3439
|
+
continue;
|
|
3440
|
+
}
|
|
2787
3441
|
if (i >= 0) {
|
|
2788
3442
|
const u = A[i];
|
|
2789
3443
|
if (u.span && intact.has(u.span)) {
|
|
@@ -2793,18 +3447,18 @@ var init_write = __esm({
|
|
|
2793
3447
|
const from = u.span ? u.base : u.fmt;
|
|
2794
3448
|
const keep = u.ch === "\n" || keyOf(from) === want.key;
|
|
2795
3449
|
const fmt = keep ? from : want.fmt;
|
|
2796
|
-
const
|
|
2797
|
-
out.push({ ch: u.ch, raw: u.raw, run:
|
|
3450
|
+
const run3 = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
|
|
3451
|
+
out.push({ ch: u.ch, raw: u.raw, run: run3, ctx: this.revised(this.linked(u.ctx, fmt.link, lastChar()), fmt.rev), u: keep && u.run ? u : null, fmt });
|
|
2798
3452
|
} else {
|
|
2799
3453
|
const left = lastChar();
|
|
2800
3454
|
const right = next[j + 1] >= 0 ? A[next[j + 1]] : null;
|
|
2801
3455
|
const base = left ? { run: left.run, fmt: left.fmt } : right ? { run: right.run ?? paraBase.run, fmt: right.span ? right.base : right.fmt } : paraBase;
|
|
2802
|
-
const
|
|
3456
|
+
const run3 = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
|
|
2803
3457
|
const shared = [];
|
|
2804
3458
|
if (left && right) {
|
|
2805
3459
|
for (let k = 0; k < left.ctx.length && left.ctx[k] === right.ctx[k]; k++) if (!left.ctx[k].link) shared.push(left.ctx[k]);
|
|
2806
3460
|
}
|
|
2807
|
-
out.push({ ch: want.ch, raw: null, run:
|
|
3461
|
+
out.push({ ch: want.ch, raw: null, run: run3, ctx: this.revised(this.linked(shared, want.fmt.link, left), want.fmt.rev), u: null, fmt: want.fmt });
|
|
2808
3462
|
}
|
|
2809
3463
|
}
|
|
2810
3464
|
let xml = "";
|
|
@@ -2887,10 +3541,10 @@ var init_write = __esm({
|
|
|
2887
3541
|
this.relIds.add(`rId${n}`);
|
|
2888
3542
|
return `rId${n}`;
|
|
2889
3543
|
}
|
|
2890
|
-
derive(
|
|
2891
|
-
const cache2 =
|
|
3544
|
+
derive(run3, from, to) {
|
|
3545
|
+
const cache2 = run3.derived ?? (run3.derived = /* @__PURE__ */ new Map());
|
|
2892
3546
|
const key2 = keyOf(from) + ">" + keyOf(to);
|
|
2893
|
-
if (!cache2.has(key2)) cache2.set(key2, { open:
|
|
3547
|
+
if (!cache2.has(key2)) cache2.set(key2, { open: run3.open, rPr: this.delta(run3.rPr, from, to), fmt: to, el: null, parent: null });
|
|
2894
3548
|
return cache2.get(key2);
|
|
2895
3549
|
}
|
|
2896
3550
|
delta(rPr, from, to) {
|
|
@@ -2912,6 +3566,7 @@ var init_write = __esm({
|
|
|
2912
3566
|
set["w:strike"] = to.s ? "<w:strike/>" : sf.s ? '<w:strike w:val="0"/>' : null;
|
|
2913
3567
|
if (!to.s) set["w:dstrike"] = null;
|
|
2914
3568
|
}
|
|
3569
|
+
if (to.va !== from.va) set["w:vertAlign"] = to.va ? `<w:vertAlign w:val="${to.va === "sup" ? "superscript" : "subscript"}"/>` : sf.va ? '<w:vertAlign w:val="baseline"/>' : null;
|
|
2915
3570
|
if (to.color !== from.color) set["w:color"] = to.color ? `<w:color w:val="${to.color.slice(1).toUpperCase()}"/>` : sf.color ? '<w:color w:val="auto"/>' : null;
|
|
2916
3571
|
if (to.size !== from.size) {
|
|
2917
3572
|
const hp = to.size ? Math.round(parseFloat(to.size) * 2) : 0;
|
|
@@ -2938,8 +3593,8 @@ var init_write = __esm({
|
|
|
2938
3593
|
} else if (!to.link && from.link && this.pkg.styles.isLink(style)) set["w:rStyle"] = null;
|
|
2939
3594
|
return Object.keys(set).length ? rebuild(rPr, "w:rPr", R, set) : rPr;
|
|
2940
3595
|
}
|
|
2941
|
-
runXml(
|
|
2942
|
-
if (
|
|
3596
|
+
runXml(run3, glyphs, counts) {
|
|
3597
|
+
if (run3.el && glyphs.length === counts.get(run3) && glyphs.every((g, n) => g.u && g.u.run === run3 && g.u.idx === n)) return this.s.slice(run3.el.start, run3.el.end);
|
|
2943
3598
|
let body = "";
|
|
2944
3599
|
let text = "";
|
|
2945
3600
|
const tag = glyphs[0]?.ctx.some((w) => w.rev?.startsWith('["del"')) ? "w:delText" : "w:t";
|
|
@@ -2954,7 +3609,7 @@ var init_write = __esm({
|
|
|
2954
3609
|
} else text += g.ch;
|
|
2955
3610
|
}
|
|
2956
3611
|
flush();
|
|
2957
|
-
return
|
|
3612
|
+
return run3.open + run3.rPr + body + "</w:r>";
|
|
2958
3613
|
}
|
|
2959
3614
|
embed(src) {
|
|
2960
3615
|
if (!this.srcs) {
|
|
@@ -2970,6 +3625,17 @@ var init_write = __esm({
|
|
|
2970
3625
|
this.srcs.set(src, added.id);
|
|
2971
3626
|
return added;
|
|
2972
3627
|
}
|
|
3628
|
+
wrapped(raw, side2) {
|
|
3629
|
+
const anchor = /<wp:anchor\b/.test(raw);
|
|
3630
|
+
if (!side2 && !anchor) return raw;
|
|
3631
|
+
const ns = (tag) => attrs(/<wp:(?:inline|anchor)\b([^>]*)>/.exec(tag)?.[1] ?? "").filter(([k]) => k.startsWith("xmlns")).map(([k, v]) => ` ${k}="${v}"`).join("");
|
|
3632
|
+
const part = (name) => new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`).exec(raw)?.[0] ?? "";
|
|
3633
|
+
const body = part("wp:extent") + part("wp:effectExtent");
|
|
3634
|
+
const rest = part("wp:docPr") + part("wp:cNvGraphicFramePr") + part("a:graphic");
|
|
3635
|
+
if (!side2) return raw.replace(/<wp:anchor\b[\s\S]*<\/wp:anchor>/, `<wp:inline distT="0" distB="0" distL="0" distR="0"${ns(raw)}>${body}${rest}</wp:inline>`);
|
|
3636
|
+
const head2 = `<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1"${ns(raw)}><wp:simplePos x="0" y="0"/><wp:positionH relativeFrom="column"><wp:align>${side2 === "right" ? "right" : "left"}</wp:align></wp:positionH><wp:positionV relativeFrom="paragraph"><wp:posOffset>0</wp:posOffset></wp:positionV>`;
|
|
3637
|
+
return raw.replace(anchor ? /<wp:anchor\b[\s\S]*<\/wp:anchor>/ : /<wp:inline\b[\s\S]*<\/wp:inline>/, `${head2}${body}<wp:wrapSquare wrapText="bothSides"/>${rest}</wp:anchor>`);
|
|
3638
|
+
}
|
|
2973
3639
|
drawing(img) {
|
|
2974
3640
|
const media = this.embed(String(img.src ?? ""));
|
|
2975
3641
|
const max = Math.round(this.textWidth() / 15);
|
|
@@ -2981,7 +3647,8 @@ var init_write = __esm({
|
|
|
2981
3647
|
else if (!w) w = Math.round(h * nw / nh);
|
|
2982
3648
|
const id = this.docPr++;
|
|
2983
3649
|
const ext = `cx="${Math.round(w * 9525)}" cy="${Math.round(h * 9525)}"`;
|
|
2984
|
-
|
|
3650
|
+
const xml = `<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><wp:extent ${ext}/><wp:effectExtent l="0" t="0" r="0" b="0"/>${meta(`<wp:docPr id="${id}" name="Picture ${id}"/>`, img)}<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="${id}" name="Picture ${id}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${media.id}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext ${ext}/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing>`;
|
|
3651
|
+
return img.wrap ? this.wrapped(xml, img.wrap) : xml;
|
|
2985
3652
|
}
|
|
2986
3653
|
patch(raw, old, img) {
|
|
2987
3654
|
let xml = raw;
|
|
@@ -2993,6 +3660,7 @@ var init_write = __esm({
|
|
|
2993
3660
|
}
|
|
2994
3661
|
if ((img.alt || null) !== (old.alt || null) || (img.title || null) !== (old.title || null)) xml = xml.replace(/<wp:docPr\b[^>]*>/, (tag) => meta(tag, img));
|
|
2995
3662
|
if (img.src !== old.src) xml = xml.replace(/(<a:blip\b[^>]*\br:embed=")[^"]*"/, `$1${this.embed(String(img.src ?? "")).id}"`);
|
|
3663
|
+
if ((img.wrap || null) !== (old.wrap || null)) xml = this.wrapped(xml, img.wrap);
|
|
2996
3664
|
return xml;
|
|
2997
3665
|
}
|
|
2998
3666
|
textWidth() {
|
|
@@ -3058,6 +3726,27 @@ var init_write = __esm({
|
|
|
3058
3726
|
head2 = `<w:tbl>${tblPr}<w:tblGrid>${`<w:gridCol w:w="${Math.floor(this.textWidth() / cols)}"/>`.repeat(cols)}</w:tblGrid>`;
|
|
3059
3727
|
}
|
|
3060
3728
|
const width = Math.floor(this.textWidth() / cols);
|
|
3729
|
+
const sized = [];
|
|
3730
|
+
for (const r of layout2) for (const sl of r) {
|
|
3731
|
+
const own2 = sl.cell && value("colwidth", sl.cell.attrs?.colwidth);
|
|
3732
|
+
if (own2 && own2.length === sl.span) own2.forEach((w, k) => {
|
|
3733
|
+
var _a;
|
|
3734
|
+
return sized[_a = sl.col + k] ?? (sized[_a] = w);
|
|
3735
|
+
});
|
|
3736
|
+
}
|
|
3737
|
+
const known = sized.length === cols && sized.every(Boolean);
|
|
3738
|
+
const had = [...head2.matchAll(/<w:gridCol\b[^>]*\bw:w="(\d+)"/g)].map((m) => Math.floor(+m[1] / 15));
|
|
3739
|
+
if (known && had.join() !== sized.join()) {
|
|
3740
|
+
const list = sized.map((w) => `<w:gridCol w:w="${Math.round(w * 15)}"/>`).join("");
|
|
3741
|
+
head2 = head2.replace(/(<w:tblGrid\b[^>]*>)[\s\S]*?(<\/w:tblGrid>)/, `$1${list}$2`);
|
|
3742
|
+
}
|
|
3743
|
+
const own = (col, span2) => known ? sized.slice(col, col + span2) : null;
|
|
3744
|
+
const borders = value("borders", o.node.attrs?.borders);
|
|
3745
|
+
if (borders !== value("borders", b?.node.attrs?.borders)) {
|
|
3746
|
+
const line = (side2) => `<w:${side2} w:val="${borders === "none" ? "none" : "single"}" w:sz="4" w:space="0" w:color="${borders === "none" ? "auto" : "94A3B8"}"/>`;
|
|
3747
|
+
const all = `<w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(line).join("")}</w:tblBorders>`;
|
|
3748
|
+
head2 = /<w:tblBorders\b/.test(head2) ? head2.replace(/<w:tblBorders\b[\s\S]*?<\/w:tblBorders>|<w:tblBorders\/>/, all) : head2.replace(/(<w:tblPr\b[^>]*>(?:(?!<\/w:tblPr>)[\s\S])*?)(<w:shd\b|<w:tblLayout\b|<w:tblCellMar\b|<w:tblLook\b|<w:tblCaption\b|<w:tblDescription\b|<w:tblPrChange\b|<\/w:tblPr>)/, `$1${all}$2`);
|
|
3749
|
+
}
|
|
3061
3750
|
let xml = head2;
|
|
3062
3751
|
let above = [];
|
|
3063
3752
|
let aboveRow = null;
|
|
@@ -3088,7 +3777,7 @@ var init_write = __esm({
|
|
|
3088
3777
|
if (!sl.cell) {
|
|
3089
3778
|
const cont = R2?.cells.find((c) => c.vm === "continue" && c.col === sl.col);
|
|
3090
3779
|
if (cont) xml += cont.lead + s.slice(cont.el.start, cont.el.end);
|
|
3091
|
-
else xml += `<w:tc>${this.tcPr(cover.get(sl.from) ?? above[sl.col] ?? null, sl.span, "continue", width)}<w:p/></w:tc>`;
|
|
3780
|
+
else xml += `<w:tc>${this.tcPr(cover.get(sl.from) ?? above[sl.col] ?? null, sl.span, "continue", width, true, own(sl.col, sl.span))}<w:p/></w:tc>`;
|
|
3092
3781
|
now[sl.col] = cover.get(sl.from) ?? null;
|
|
3093
3782
|
continue;
|
|
3094
3783
|
}
|
|
@@ -3104,7 +3793,7 @@ var init_write = __esm({
|
|
|
3104
3793
|
const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
|
|
3105
3794
|
let inside = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
|
|
3106
3795
|
if (!this.last || this.last === "tbl") inside += "<w:p/>";
|
|
3107
|
-
xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C) + inside + (C ? C.tail : "") + "</w:tc>";
|
|
3796
|
+
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)) + inside + (C ? C.tail : "") + "</w:tc>";
|
|
3108
3797
|
}
|
|
3109
3798
|
const lastCell = R2?.cells[R2.cells.length - 1];
|
|
3110
3799
|
xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
|
|
@@ -3113,15 +3802,21 @@ var init_write = __esm({
|
|
|
3113
3802
|
});
|
|
3114
3803
|
return xml + tail + "</w:tbl>";
|
|
3115
3804
|
}
|
|
3116
|
-
tcPr(src, span2, vm, width, clone = true) {
|
|
3805
|
+
tcPr(src, span2, vm, width, clone = true, own = null, fill3) {
|
|
3117
3806
|
const s = this.s;
|
|
3118
3807
|
const el = src && kid(src.el, "w:tcPr");
|
|
3119
3808
|
const xml = el ? s.slice(el.start, el.end) : "";
|
|
3120
|
-
|
|
3809
|
+
const tcW = el && kid(el, "w:tcW");
|
|
3810
|
+
const sized = own ? Math.round(own.reduce((a, w) => a + w, 0) * 15) : null;
|
|
3811
|
+
const resized = sized !== null && !(tcW && attr(s, tcW, "w:type") === "dxa" && Math.abs(+(attr(s, tcW, "w:w") ?? 0) - sized) < 15);
|
|
3812
|
+
const was = src?.node ? value("background", src.node.attrs?.background) : null;
|
|
3813
|
+
const painted = fill3 !== void 0 && fill3 !== was;
|
|
3814
|
+
if (!clone && src && src.span === span2 && src.vm === vm && !resized && !painted) return xml;
|
|
3121
3815
|
const set = { "w:gridSpan": span2 > 1 ? `<w:gridSpan w:val="${span2}"/>` : null, "w:vMerge": vm === "restart" ? '<w:vMerge w:val="restart"/>' : vm ? "<w:vMerge/>" : null, "w:hMerge": null };
|
|
3122
3816
|
if (clone) Object.assign(set, { "w:cellIns": null, "w:cellDel": null, "w:cellMerge": null, "w:tcPrChange": null });
|
|
3123
|
-
|
|
3124
|
-
if (
|
|
3817
|
+
if (painted) set["w:shd"] = fill3 ? `<w:shd w:val="clear" w:color="auto" w:fill="${fill3.slice(1).toUpperCase()}"/>` : null;
|
|
3818
|
+
if (resized) set["w:tcW"] = `<w:tcW w:w="${sized}" w:type="dxa"/>`;
|
|
3819
|
+
else if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span2}" w:type="dxa"/>`;
|
|
3125
3820
|
else if (tcW && src && src.span !== span2 && attr(xml, tcW, "w:type") === "dxa") set["w:tcW"] = `<w:tcW w:w="${Math.round(+(attr(xml, tcW, "w:w") ?? 0) * span2 / src.span)}" w:type="dxa"/>`;
|
|
3126
3821
|
return rebuild(xml, "w:tcPr", TC, set);
|
|
3127
3822
|
}
|
|
@@ -3138,15 +3833,24 @@ async function readDocx(bytes) {
|
|
|
3138
3833
|
const size2 = sect && kid(sect, "w:pgSz");
|
|
3139
3834
|
const mar = sect && kid(sect, "w:pgMar");
|
|
3140
3835
|
const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
|
|
3836
|
+
const words2 = (kind) => {
|
|
3837
|
+
const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
|
|
3838
|
+
const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
|
|
3839
|
+
const xml = part ? pkg.text(part.target) ?? "" : "";
|
|
3840
|
+
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) };
|
|
3841
|
+
};
|
|
3842
|
+
const head2 = words2("header");
|
|
3843
|
+
const foot = words2("footer");
|
|
3141
3844
|
return {
|
|
3845
|
+
marginal: { header: head2.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
|
|
3142
3846
|
doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
|
|
3143
3847
|
styles: pkg.styles.list(),
|
|
3144
3848
|
page: { width: px2(size2, "w:w", 12240), height: px2(size2, "w:h", 15840), margins: [px2(mar, "w:top", 1440), px2(mar, "w:right", 1440), px2(mar, "w:bottom", 1440), px2(mar, "w:left", 1440)] }
|
|
3145
3849
|
};
|
|
3146
3850
|
}
|
|
3147
|
-
async function writeDocx(original, doc, load3 = fetched) {
|
|
3851
|
+
async function writeDocx(original, doc, load3 = fetched, setup) {
|
|
3148
3852
|
const pkg = new Pkg(new Uint8Array(original));
|
|
3149
|
-
const out = new Writer(pkg, await images(doc, load3)).run(doc);
|
|
3853
|
+
const out = new Writer(pkg, await images(doc, load3)).run(doc, setup);
|
|
3150
3854
|
return out ? out.slice().buffer : original.slice(0);
|
|
3151
3855
|
}
|
|
3152
3856
|
var init_docx = __esm({
|
|
@@ -3227,6 +3931,10 @@ function measure(view) {
|
|
|
3227
3931
|
const room = page.height - top - bottom;
|
|
3228
3932
|
const els = [...view.dom.children];
|
|
3229
3933
|
const gaps = [];
|
|
3934
|
+
const line = page.width - page.margins[1] - page.margins[3];
|
|
3935
|
+
const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
|
|
3936
|
+
let notes2 = [];
|
|
3937
|
+
let count = 0;
|
|
3230
3938
|
let i = 0;
|
|
3231
3939
|
let shift = 0;
|
|
3232
3940
|
let start = 0;
|
|
@@ -3240,17 +3948,25 @@ function measure(view) {
|
|
|
3240
3948
|
if (!el) return;
|
|
3241
3949
|
const y = el.offsetTop - shift;
|
|
3242
3950
|
const end = y + el.offsetHeight;
|
|
3951
|
+
const mine = [];
|
|
3952
|
+
node.descendants((d) => {
|
|
3953
|
+
if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
|
|
3954
|
+
});
|
|
3243
3955
|
if (node.type.name === "pageBreak") {
|
|
3244
|
-
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1 });
|
|
3956
|
+
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
|
|
3957
|
+
notes2 = [];
|
|
3245
3958
|
start = end;
|
|
3246
|
-
} else if (end > start + room && y > start) {
|
|
3247
|
-
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1 });
|
|
3959
|
+
} else if (end > start + room - area([...notes2, ...mine]) && y > start) {
|
|
3960
|
+
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
|
|
3961
|
+
notes2 = [];
|
|
3248
3962
|
start = y;
|
|
3249
3963
|
}
|
|
3964
|
+
notes2.push(...mine);
|
|
3965
|
+
count += mine.length;
|
|
3250
3966
|
while (end > start + room) start += room;
|
|
3251
3967
|
last2 = end;
|
|
3252
3968
|
});
|
|
3253
|
-
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true });
|
|
3969
|
+
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last2), page: gaps.length + 1, end: true, notes: notes2 });
|
|
3254
3970
|
return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
|
|
3255
3971
|
}
|
|
3256
3972
|
var import_core, import_state, import_view, a4, letter, paging, skip2, Pager;
|
|
@@ -3269,42 +3985,71 @@ var init_pager = __esm({
|
|
|
3269
3985
|
addProseMirrorPlugins: () => [new import_state.Plugin({
|
|
3270
3986
|
key: paging,
|
|
3271
3987
|
state: {
|
|
3272
|
-
init: () => ({ set: import_view.DecorationSet.empty, page: a4 }),
|
|
3988
|
+
init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" } }),
|
|
3273
3989
|
apply(tr, value3) {
|
|
3274
3990
|
const next = tr.getMeta(paging);
|
|
3275
|
-
return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page };
|
|
3991
|
+
return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks };
|
|
3276
3992
|
}
|
|
3277
3993
|
},
|
|
3278
3994
|
props: { decorations: (state) => paging.getState(state).set },
|
|
3279
3995
|
view(view) {
|
|
3280
3996
|
let timer = 0;
|
|
3281
3997
|
let sig2 = "";
|
|
3282
|
-
const
|
|
3998
|
+
const run3 = () => {
|
|
3283
3999
|
if (!view.dom.isConnected) return;
|
|
3284
4000
|
const gaps = measure(view);
|
|
3285
|
-
const
|
|
4001
|
+
const { marks: marks2 } = paging.getState(view.state);
|
|
4002
|
+
const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks2.header}|${marks2.footer}`;
|
|
3286
4003
|
if (next === sig2) return;
|
|
3287
4004
|
sig2 = next;
|
|
3288
|
-
const
|
|
4005
|
+
const line = (parent, cls, text) => {
|
|
4006
|
+
if (!text) return;
|
|
4007
|
+
const span2 = document.createElement("span");
|
|
4008
|
+
span2.className = cls;
|
|
4009
|
+
span2.textContent = text;
|
|
4010
|
+
parent.append(span2);
|
|
4011
|
+
};
|
|
4012
|
+
const first = import_view.Decoration.widget(0, () => {
|
|
4013
|
+
const el = document.createElement("div");
|
|
4014
|
+
el.className = "w100n-text-first";
|
|
4015
|
+
el.contentEditable = "false";
|
|
4016
|
+
line(el, "w100n-text-head", marks2.header);
|
|
4017
|
+
return el;
|
|
4018
|
+
}, { key: `first:${marks2.header}`, side: -1, ignoreSelection: true });
|
|
4019
|
+
const set = import_view.DecorationSet.create(view.state.doc, [first, ...gaps.map((g) => import_view.Decoration.widget(g.pos, () => {
|
|
3289
4020
|
const el = document.createElement("div");
|
|
3290
4021
|
el.className = g.end ? "w100n-text-gap is-end" : "w100n-text-gap";
|
|
3291
4022
|
el.style.height = `${g.height}px`;
|
|
3292
4023
|
el.dataset.page = String(g.page);
|
|
3293
4024
|
el.contentEditable = "false";
|
|
4025
|
+
line(el, "w100n-text-foot", marks2.footer);
|
|
4026
|
+
if (!g.end) line(el, "w100n-text-head", marks2.header);
|
|
4027
|
+
if (g.notes.length) {
|
|
4028
|
+
const list = document.createElement("div");
|
|
4029
|
+
list.className = "w100n-text-footnotes";
|
|
4030
|
+
for (const note of g.notes) {
|
|
4031
|
+
const p = document.createElement("p");
|
|
4032
|
+
const n = document.createElement("sup");
|
|
4033
|
+
n.textContent = note.slice(0, note.indexOf(" "));
|
|
4034
|
+
p.append(n, note.slice(note.indexOf(" ")));
|
|
4035
|
+
list.append(p);
|
|
4036
|
+
}
|
|
4037
|
+
el.append(list);
|
|
4038
|
+
}
|
|
3294
4039
|
return el;
|
|
3295
|
-
}, { key: `${g.pos}:${g.height}:${g.page}`, side: -1, ignoreSelection: true })));
|
|
4040
|
+
}, { key: `${g.pos}:${g.height}:${g.page}:${marks2.header}:${marks2.footer}:${g.notes.join("\n")}`, side: -1, ignoreSelection: true }))]);
|
|
3296
4041
|
view.dispatch(view.state.tr.setMeta(paging, { set }).setMeta("addToHistory", false));
|
|
3297
4042
|
};
|
|
3298
4043
|
const later = (ms) => {
|
|
3299
4044
|
clearTimeout(timer);
|
|
3300
|
-
timer = window.setTimeout(
|
|
4045
|
+
timer = window.setTimeout(run3, ms);
|
|
3301
4046
|
};
|
|
3302
4047
|
const watch = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => later(200));
|
|
3303
4048
|
watch?.observe(view.dom);
|
|
3304
4049
|
later(0);
|
|
3305
4050
|
return {
|
|
3306
4051
|
update: (next, prev) => {
|
|
3307
|
-
if (paging.getState(next.state).page !== paging.getState(prev).page) later(0);
|
|
4052
|
+
if (paging.getState(next.state).page !== paging.getState(prev).page || paging.getState(next.state).marks !== paging.getState(prev).marks) later(0);
|
|
3308
4053
|
else if (next.state.doc !== prev.doc) later(400);
|
|
3309
4054
|
},
|
|
3310
4055
|
destroy: () => {
|
|
@@ -3353,19 +4098,27 @@ function kit(kind, t, live) {
|
|
|
3353
4098
|
import_starter_kit.default.configure({ trailingNode: false, link: { openOnClick: false, autolink: true, defaultProtocol: "https" }, dropcursor: { color: "#8b5cf6", width: 2 }, ...live ? { undoRedo: false } : {} }),
|
|
3354
4099
|
import_extension_list.TaskList,
|
|
3355
4100
|
import_extension_list.TaskItem.configure({ nested: true, a11y: { checkboxLabel: (node) => node.textContent || t.tasks } }),
|
|
3356
|
-
import_extension_table.TableKit.configure({ table: { resizable:
|
|
3357
|
-
|
|
4101
|
+
import_extension_table.TableKit.configure({ table: { resizable: true, cellMinWidth: 32 } }),
|
|
4102
|
+
Cells,
|
|
4103
|
+
Search2,
|
|
4104
|
+
import_extension_image.default.extend({
|
|
4105
|
+
addAttributes() {
|
|
4106
|
+
return { ...this.parent?.(), wrap: { default: null, parseHTML: (el) => el.dataset.wrap ?? null, renderHTML: (attrs2) => attrs2.wrap ? { "data-wrap": attrs2.wrap } : {} } };
|
|
4107
|
+
}
|
|
4108
|
+
}).configure({ inline: true, allowBase64: true, resize: { enabled: true, directions: ["top-left", "top-right", "bottom-left", "bottom-right"], minWidth: 24, minHeight: 24, alwaysPreserveAspectRatio: true } }),
|
|
3358
4109
|
import_extension_highlight.default.configure({ multicolor: true }),
|
|
3359
4110
|
import_extension_text_style.TextStyle,
|
|
3360
4111
|
import_extension_text_style.Color,
|
|
3361
4112
|
import_extension_text_style.FontSize,
|
|
3362
4113
|
import_extension_text_style.FontFamily,
|
|
4114
|
+
script("superscript", "sup", "subscript"),
|
|
4115
|
+
script("subscript", "sub", "superscript"),
|
|
3363
4116
|
Blocks,
|
|
3364
4117
|
PageBreak.configure({ label: t.pageBreak }),
|
|
3365
4118
|
Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
|
|
3366
4119
|
Note,
|
|
3367
4120
|
Notes,
|
|
3368
|
-
...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
|
|
4121
|
+
...kind === "docx" ? [Formula, Footnote, Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
|
|
3369
4122
|
...live ? [import_extension_collaboration.default.configure({ document: live.doc }), import_extension_collaboration_caret.default.configure({ provider: live.link, user: live.user })] : []
|
|
3370
4123
|
];
|
|
3371
4124
|
}
|
|
@@ -3408,7 +4161,7 @@ function locate(doc, list) {
|
|
|
3408
4161
|
return range ? [{ id: c.id, from: range.from, to: range.to }] : [];
|
|
3409
4162
|
});
|
|
3410
4163
|
}
|
|
3411
|
-
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, Blocks, PageBreak, headings, Toc, revision, seen, suggesting, Suggest, Note, locks, locked, scan, Locks, paint, remap, Notes, textblocks, align2, indent, clear;
|
|
4164
|
+
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;
|
|
3412
4165
|
var init_extensions = __esm({
|
|
3413
4166
|
"src/editor/extensions.ts"() {
|
|
3414
4167
|
"use strict";
|
|
@@ -3426,6 +4179,7 @@ var init_extensions = __esm({
|
|
|
3426
4179
|
import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
3427
4180
|
import_y_tiptap = require("@tiptap/y-tiptap");
|
|
3428
4181
|
init_pager();
|
|
4182
|
+
init_math();
|
|
3429
4183
|
notes = new import_state2.PluginKey("w100n-notes");
|
|
3430
4184
|
blocks = [
|
|
3431
4185
|
"paragraph",
|
|
@@ -3456,6 +4210,63 @@ var init_extensions = __esm({
|
|
|
3456
4210
|
}));
|
|
3457
4211
|
return ranges;
|
|
3458
4212
|
};
|
|
4213
|
+
Cells = import_core2.Extension.create({
|
|
4214
|
+
name: "cells",
|
|
4215
|
+
addGlobalAttributes: () => [
|
|
4216
|
+
{ types: ["tableCell", "tableHeader"], attributes: { background: { default: null, parseHTML: (el) => el.dataset.fill ?? null, renderHTML: (attrs2) => attrs2.background ? { "data-fill": attrs2.background, style: `background-color: ${attrs2.background}` } : {} } } },
|
|
4217
|
+
{ types: ["table"], attributes: { borders: { default: null, parseHTML: (el) => el.dataset.borders ?? null, renderHTML: (attrs2) => attrs2.borders ? { "data-borders": attrs2.borders } : {} } } }
|
|
4218
|
+
]
|
|
4219
|
+
});
|
|
4220
|
+
searching = new import_state2.PluginKey("w100n-search");
|
|
4221
|
+
lookup = (doc, query, matchCase) => {
|
|
4222
|
+
const hits = [];
|
|
4223
|
+
if (!query) return hits;
|
|
4224
|
+
const needle = matchCase ? query : query.toLowerCase();
|
|
4225
|
+
doc.descendants((node, pos) => {
|
|
4226
|
+
if (!node.isTextblock) return true;
|
|
4227
|
+
let text = "";
|
|
4228
|
+
const at = [];
|
|
4229
|
+
node.forEach((child, offset) => {
|
|
4230
|
+
const part = child.isText ? child.text : "\uFFFC";
|
|
4231
|
+
for (let i = 0; i < part.length; i++) at.push(pos + 1 + offset + i);
|
|
4232
|
+
text += part;
|
|
4233
|
+
});
|
|
4234
|
+
const hay = matchCase ? text : text.toLowerCase();
|
|
4235
|
+
for (let i = hay.indexOf(needle); i >= 0; i = hay.indexOf(needle, i + needle.length)) hits.push({ from: at[i], to: at[i + needle.length - 1] + 1 });
|
|
4236
|
+
return false;
|
|
4237
|
+
});
|
|
4238
|
+
return hits;
|
|
4239
|
+
};
|
|
4240
|
+
Search2 = import_core2.Extension.create({
|
|
4241
|
+
name: "search",
|
|
4242
|
+
addProseMirrorPlugins: () => [new import_state2.Plugin({
|
|
4243
|
+
key: searching,
|
|
4244
|
+
state: {
|
|
4245
|
+
init: () => ({ query: "", matchCase: false, hits: [], at: 0, set: import_view2.DecorationSet.empty }),
|
|
4246
|
+
apply(tr, value3) {
|
|
4247
|
+
const meta2 = tr.getMeta(searching);
|
|
4248
|
+
if (!meta2 && !tr.docChanged) return value3;
|
|
4249
|
+
const next = { ...value3, ...meta2 };
|
|
4250
|
+
const hits = lookup(tr.doc, next.query, next.matchCase);
|
|
4251
|
+
const at = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
|
|
4252
|
+
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 === at ? "w100n-found is-current" : "w100n-found" }))) };
|
|
4253
|
+
}
|
|
4254
|
+
},
|
|
4255
|
+
props: { decorations: (state) => searching.getState(state).set }
|
|
4256
|
+
})]
|
|
4257
|
+
});
|
|
4258
|
+
replace = (editor, text, all) => {
|
|
4259
|
+
const { hits, at } = searching.getState(editor.state);
|
|
4260
|
+
if (!hits.length) return 0;
|
|
4261
|
+
const tr = editor.state.tr;
|
|
4262
|
+
for (const hit of all ? [...hits].reverse() : [hits[at]]) tr.insertText(text, hit.from, hit.to);
|
|
4263
|
+
editor.view.dispatch(tr);
|
|
4264
|
+
return all ? hits.length : 1;
|
|
4265
|
+
};
|
|
4266
|
+
cleanPaste = (html) => html.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/g, "").replace(/<o:p>[\s\S]*?<\/o:p>/g, "").replace(/\sclass=("|')?Mso[^"'\s>]*\1?/g, "").replace(/<img\b[^>]*\ssrc=("|')file:[^"']*\1[^>]*>/gi, "").replace(/\sstyle=("|')([^"']*)\1/g, (_, q, css2) => {
|
|
4267
|
+
const kept = css2.split(";").map((x) => x.trim()).filter((x) => x && !/^mso-|^tab-stops|^font-family:\s*["']?(Symbol|Wingdings)/i.test(x)).join("; ");
|
|
4268
|
+
return kept ? ` style=${q}${kept}${q}` : "";
|
|
4269
|
+
});
|
|
3459
4270
|
Blocks = import_core2.Extension.create({
|
|
3460
4271
|
name: "blocks",
|
|
3461
4272
|
addGlobalAttributes: () => [{
|
|
@@ -3463,6 +4274,8 @@ var init_extensions = __esm({
|
|
|
3463
4274
|
attributes: {
|
|
3464
4275
|
align: { default: null, parseHTML: (el) => el.style.textAlign || null, renderHTML: (attrs2) => attrs2.align ? { style: `text-align: ${attrs2.align}` } : {} },
|
|
3465
4276
|
indent: { default: 0, parseHTML: (el) => Number(el.dataset.indent) || 0, renderHTML: (attrs2) => attrs2.indent ? { "data-indent": attrs2.indent, style: `margin-left: ${attrs2.indent * 0.5}in` } : {} },
|
|
4277
|
+
line: { default: null, parseHTML: (el) => Number(el.dataset.line) || null, renderHTML: (attrs2) => attrs2.line ? { "data-line": attrs2.line, style: `line-height: ${attrs2.line * 1.15}` } : {} },
|
|
4278
|
+
after: { default: null, parseHTML: (el) => el.dataset.after ? Number(el.dataset.after) : null, renderHTML: (attrs2) => attrs2.after === null || attrs2.after === void 0 ? {} : { "data-after": attrs2.after, style: `margin-bottom: ${attrs2.after}pt` } },
|
|
3466
4279
|
ref: { default: null, rendered: false, keepOnSplit: false }
|
|
3467
4280
|
}
|
|
3468
4281
|
}],
|
|
@@ -3514,6 +4327,37 @@ var init_extensions = __esm({
|
|
|
3514
4327
|
return ["div", { "data-page-break": "", "data-label": this.options.label, class: "w100n-text-break", contenteditable: "false" }];
|
|
3515
4328
|
}
|
|
3516
4329
|
});
|
|
4330
|
+
Formula = import_core2.Node.create({
|
|
4331
|
+
name: "math",
|
|
4332
|
+
group: "inline",
|
|
4333
|
+
inline: true,
|
|
4334
|
+
atom: true,
|
|
4335
|
+
selectable: true,
|
|
4336
|
+
addAttributes: () => ({ latex: { default: "", parseHTML: (el) => el.getAttribute("data-math") ?? "" } }),
|
|
4337
|
+
parseHTML: () => [{ tag: "span[data-math]" }],
|
|
4338
|
+
renderHTML: ({ node }) => ["span", { "data-math": node.attrs.latex, class: "w100n-math" }],
|
|
4339
|
+
addNodeView: () => ({ node }) => {
|
|
4340
|
+
const dom = document.createElement("span");
|
|
4341
|
+
dom.className = "w100n-math";
|
|
4342
|
+
dom.dataset.math = node.attrs.latex;
|
|
4343
|
+
dom.contentEditable = "false";
|
|
4344
|
+
dom.innerHTML = mathml(node.attrs.latex);
|
|
4345
|
+
return { dom };
|
|
4346
|
+
}
|
|
4347
|
+
});
|
|
4348
|
+
Footnote = import_core2.Node.create({
|
|
4349
|
+
name: "footnote",
|
|
4350
|
+
group: "inline",
|
|
4351
|
+
inline: true,
|
|
4352
|
+
atom: true,
|
|
4353
|
+
selectable: true,
|
|
4354
|
+
addAttributes: () => ({
|
|
4355
|
+
id: { default: null, parseHTML: (el) => el.getAttribute("data-note-id") },
|
|
4356
|
+
text: { default: "", parseHTML: (el) => el.getAttribute("title") ?? "" }
|
|
4357
|
+
}),
|
|
4358
|
+
parseHTML: () => [{ tag: "sup[data-footnote]" }],
|
|
4359
|
+
renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
|
|
4360
|
+
});
|
|
3517
4361
|
headings = (doc, after) => {
|
|
3518
4362
|
const found = [];
|
|
3519
4363
|
doc.descendants((node, pos) => {
|
|
@@ -3773,6 +4617,15 @@ var init_extensions = __esm({
|
|
|
3773
4617
|
props: { decorations: (state) => notes.getState(state).set }
|
|
3774
4618
|
})]
|
|
3775
4619
|
});
|
|
4620
|
+
script = (name, tag, other) => import_core2.Mark.create({
|
|
4621
|
+
name,
|
|
4622
|
+
excludes: other,
|
|
4623
|
+
parseHTML: () => [{ tag }, { style: `vertical-align=${name === "superscript" ? "super" : "sub"}` }],
|
|
4624
|
+
renderHTML: () => [tag, 0],
|
|
4625
|
+
addKeyboardShortcuts() {
|
|
4626
|
+
return { [name === "superscript" ? "Mod-." : "Mod-,"]: () => this.editor.commands.toggleMark(name) };
|
|
4627
|
+
}
|
|
4628
|
+
});
|
|
3776
4629
|
textblocks = (editor, change) => editor.chain().focus().command(({ tr, state }) => {
|
|
3777
4630
|
state.doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
|
|
3778
4631
|
if (!node.isTextblock) return true;
|
|
@@ -3782,6 +4635,7 @@ var init_extensions = __esm({
|
|
|
3782
4635
|
return true;
|
|
3783
4636
|
}).run();
|
|
3784
4637
|
align2 = (editor, value3) => textblocks(editor, () => ({ align: value3 === "left" ? null : value3 }));
|
|
4638
|
+
spacing = (editor, change) => textblocks(editor, () => change);
|
|
3785
4639
|
indent = (editor, step) => {
|
|
3786
4640
|
const type = editor.isActive("taskItem") ? "taskItem" : editor.isActive("listItem") ? "listItem" : null;
|
|
3787
4641
|
if (type) return step > 0 ? editor.chain().focus().sinkListItem(type).run() : editor.chain().focus().liftListItem(type).run();
|
|
@@ -3800,7 +4654,7 @@ var init_extensions = __esm({
|
|
|
3800
4654
|
var version;
|
|
3801
4655
|
var init_package = __esm({
|
|
3802
4656
|
"package.json"() {
|
|
3803
|
-
version = "0.
|
|
4657
|
+
version = "0.15.0";
|
|
3804
4658
|
}
|
|
3805
4659
|
});
|
|
3806
4660
|
|
|
@@ -3962,7 +4816,7 @@ function fromMarkdown(source) {
|
|
|
3962
4816
|
function serializer(style, hints, before, cell2 = false) {
|
|
3963
4817
|
let form = null;
|
|
3964
4818
|
const hint = (node) => hints[node.attrs.ref] ?? {};
|
|
3965
|
-
const
|
|
4819
|
+
const run3 = (parent, index, types2) => {
|
|
3966
4820
|
let n = 0;
|
|
3967
4821
|
for (let i = index - 1; i >= 0 && types2.includes(parent.child(i).type.name); i--) n++;
|
|
3968
4822
|
if (!index && before && types2.includes(before.type.name)) n++;
|
|
@@ -3976,7 +4830,7 @@ function serializer(style, hints, before, cell2 = false) {
|
|
|
3976
4830
|
state.options.tightLists = was;
|
|
3977
4831
|
};
|
|
3978
4832
|
const list = (state, node, parent, index) => {
|
|
3979
|
-
const bullet = hint(node).bullet ?? (
|
|
4833
|
+
const bullet = hint(node).bullet ?? (run3(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
|
|
3980
4834
|
tight(state, node, () => state.renderList(node, " ", () => `${bullet} `));
|
|
3981
4835
|
};
|
|
3982
4836
|
const blank6 = { open: "", close: "", mixable: true };
|
|
@@ -4024,7 +4878,7 @@ ${lines2.join("")}<!-- /toc -->`);
|
|
|
4024
4878
|
taskList: list,
|
|
4025
4879
|
orderedList(state, node, parent, index) {
|
|
4026
4880
|
const start = node.attrs.start ?? 1;
|
|
4027
|
-
const delim = hint(node).delim ?? (
|
|
4881
|
+
const delim = hint(node).delim ?? (run3(parent, index, ["orderedList"]) ? style.delim === "." ? ")" : "." : style.delim);
|
|
4028
4882
|
const width = String(start + node.childCount - 1).length;
|
|
4029
4883
|
tight(state, node, () => state.renderList(node, " ".repeat(width + 2), (i) => `${start + i}${delim} `));
|
|
4030
4884
|
},
|
|
@@ -4153,7 +5007,7 @@ var init_markdown = __esm({
|
|
|
4153
5007
|
return nodes.length === parsed.raws.length ? { ...parsed, nodes } : { ...parsed, nodes: [], raws: [], head: "", tail: "\n" };
|
|
4154
5008
|
};
|
|
4155
5009
|
ticks = (node, side2) => {
|
|
4156
|
-
const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((
|
|
5010
|
+
const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((run3) => run3.length));
|
|
4157
5011
|
return len ? side2 > 0 ? ` ${"`".repeat(len + 1)}` : `${"`".repeat(len + 1)} ` : "`";
|
|
4158
5012
|
};
|
|
4159
5013
|
plain2 = (mark, parent, index) => {
|
|
@@ -5503,7 +6357,7 @@ function equalValue(a, b) {
|
|
|
5503
6357
|
if (typeof a === "number" && typeof b === "number") return a === b || Math.abs(a - b) <= 1e-9 * Math.max(1, Math.abs(a), Math.abs(b));
|
|
5504
6358
|
return a === b;
|
|
5505
6359
|
}
|
|
5506
|
-
function
|
|
6360
|
+
function lookup2(book, s) {
|
|
5507
6361
|
if (!s) return {};
|
|
5508
6362
|
return (typeof s === "string" ? book.styles[s] : s) ?? {};
|
|
5509
6363
|
}
|
|
@@ -5643,7 +6497,7 @@ function writeXlsx(original, model) {
|
|
|
5643
6497
|
const id = typeof s === "string" ? (bk === cur ? "c" : "b") + s : "";
|
|
5644
6498
|
const known = id && seen2.get(id);
|
|
5645
6499
|
if (known) return known;
|
|
5646
|
-
const look = norm({ ...defaults, ...
|
|
6500
|
+
const look = norm({ ...defaults, ...lookup2(bk, s) });
|
|
5647
6501
|
const made2 = { look, json: JSON.stringify(look) };
|
|
5648
6502
|
if (id) seen2.set(id, made2);
|
|
5649
6503
|
return made2;
|
|
@@ -5684,8 +6538,8 @@ function writeXlsx(original, model) {
|
|
|
5684
6538
|
changed2 = true;
|
|
5685
6539
|
tag = setAttr(tag, "hidden", hidden ? "1" : null);
|
|
5686
6540
|
}
|
|
5687
|
-
const look = rd.s ? norm({ ...defaults, ...
|
|
5688
|
-
const was = od.s ? norm({ ...defaults, ...
|
|
6541
|
+
const look = rd.s ? norm({ ...defaults, ...lookup2(cur, rd.s) }) : null;
|
|
6542
|
+
const was = od.s ? norm({ ...defaults, ...lookup2(base.book, od.s) }) : null;
|
|
5689
6543
|
if (!same2(look, was)) {
|
|
5690
6544
|
changed2 = true;
|
|
5691
6545
|
tag = setAttr(setAttr(tag, "s", look ? String(xfFor(look, xfOf(od.s))) : null), "customFormat", look ? "1" : null);
|
|
@@ -5975,7 +6829,7 @@ function cellXml(p, ref, xf, x, f, v) {
|
|
|
5975
6829
|
function columns(p, rec, sheet2, old, cols, defaults, cur, baseBook, xfFor, xfOf) {
|
|
5976
6830
|
const now = sheet2.columnData ?? {}, was = old.columnData ?? {};
|
|
5977
6831
|
const count = sheet2.columnCount ?? 26;
|
|
5978
|
-
const look = (bk, s) => s ? norm({ ...defaults, ...
|
|
6832
|
+
const look = (bk, s) => s ? norm({ ...defaults, ...lookup2(bk, s) }) : null;
|
|
5979
6833
|
let differs2 = cols.moved;
|
|
5980
6834
|
for (let c = 0; c < count && !differs2; c++) {
|
|
5981
6835
|
const c0 = cols.from(c);
|
|
@@ -6448,6 +7302,11 @@ var init_text2 = __esm({
|
|
|
6448
7302
|
"src/sheets/text.ts"() {
|
|
6449
7303
|
"use strict";
|
|
6450
7304
|
en3 = {
|
|
7305
|
+
asCurrency: "Format as euro",
|
|
7306
|
+
asPercent: "Format as percent",
|
|
7307
|
+
fewerDecimals: "Fewer decimal places",
|
|
7308
|
+
moreDecimals: "More decimal places",
|
|
7309
|
+
sum: "Sum",
|
|
6451
7310
|
tools: "Sheet tools",
|
|
6452
7311
|
loading: "Opening the sheet",
|
|
6453
7312
|
failed: "This sheet could not be opened",
|
|
@@ -6516,6 +7375,11 @@ var init_text2 = __esm({
|
|
|
6516
7375
|
}
|
|
6517
7376
|
};
|
|
6518
7377
|
pl3 = {
|
|
7378
|
+
asCurrency: "Formatuj jako euro",
|
|
7379
|
+
asPercent: "Formatuj jako procent",
|
|
7380
|
+
fewerDecimals: "Mniej miejsc po przecinku",
|
|
7381
|
+
moreDecimals: "Wi\u0119cej miejsc po przecinku",
|
|
7382
|
+
sum: "Suma",
|
|
6519
7383
|
tools: "Narz\u0119dzia arkusza",
|
|
6520
7384
|
loading: "Otwieranie arkusza",
|
|
6521
7385
|
failed: "Nie uda\u0142o si\u0119 otworzy\u0107 tego arkusza",
|
|
@@ -6584,6 +7448,11 @@ var init_text2 = __esm({
|
|
|
6584
7448
|
}
|
|
6585
7449
|
};
|
|
6586
7450
|
uk3 = {
|
|
7451
|
+
asCurrency: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0454\u0432\u0440\u043E",
|
|
7452
|
+
asPercent: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0432\u0456\u0434\u0441\u043E\u0442\u043A\u0456\u0432",
|
|
7453
|
+
fewerDecimals: "\u041C\u0435\u043D\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
|
|
7454
|
+
moreDecimals: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
|
|
7455
|
+
sum: "\u0421\u0443\u043C\u0430",
|
|
6587
7456
|
tools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
|
|
6588
7457
|
loading: "\u0412\u0456\u0434\u043A\u0440\u0438\u0432\u0430\u0454\u043C\u043E \u0442\u0430\u0431\u043B\u0438\u0446\u044E",
|
|
6589
7458
|
failed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0432\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u0446\u044E \u0442\u0430\u0431\u043B\u0438\u0446\u044E",
|
|
@@ -6679,8 +7548,8 @@ function follow(doc, author) {
|
|
|
6679
7548
|
doc.off("afterTransaction", after);
|
|
6680
7549
|
};
|
|
6681
7550
|
}
|
|
6682
|
-
async function write3(kind, base, node, load3) {
|
|
6683
|
-
if (kind === "docx") return writeDocx(base, node.toJSON(), load3);
|
|
7551
|
+
async function write3(kind, base, node, load3, setup) {
|
|
7552
|
+
if (kind === "docx") return writeDocx(base, node.toJSON(), load3, setup);
|
|
6684
7553
|
const parsed = fromMarkdown(new TextDecoder().decode(base));
|
|
6685
7554
|
return new TextEncoder().encode(toMarkdown(node, track(parsed, node.type.schema.nodeFromJSON(parsed.doc))).text).buffer;
|
|
6686
7555
|
}
|
|
@@ -6699,11 +7568,11 @@ async function save(doc, kind, base, put, load3, note) {
|
|
|
6699
7568
|
};
|
|
6700
7569
|
doc.on("afterTransaction", watch);
|
|
6701
7570
|
try {
|
|
6702
|
-
const bytes = await write3(kind, base, node, load3);
|
|
7571
|
+
const bytes = await write3(kind, base, node, load3, doc.getMap("setup").size ? doc.getMap("setup").toJSON() : void 0);
|
|
6703
7572
|
const changed2 = !same3(bytes, base);
|
|
6704
7573
|
const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
|
|
6705
7574
|
const refs2 = [];
|
|
6706
|
-
if (changed2) schema.nodeFromJSON(await
|
|
7575
|
+
if (changed2) schema.nodeFromJSON(await parse4(kind, bytes)).descendants((n) => {
|
|
6707
7576
|
if (n.isBlock) refs2.push([n.type.name, n.attrs.ref ?? null]);
|
|
6708
7577
|
});
|
|
6709
7578
|
doc.transact(() => {
|
|
@@ -6743,7 +7612,7 @@ async function workbook(doc, kind, base, put, who, note) {
|
|
|
6743
7612
|
doc.off("afterTransaction", watch);
|
|
6744
7613
|
}
|
|
6745
7614
|
}
|
|
6746
|
-
var import_core3, import_transform2, import_y_tiptap2, Y2, ours, schemas, schemaOf,
|
|
7615
|
+
var import_core3, import_transform2, import_y_tiptap2, Y2, ours, schemas, schemaOf, parse4, edits, filled, pending, blocks2, same3, named2;
|
|
6747
7616
|
var init_collab = __esm({
|
|
6748
7617
|
"src/collab.ts"() {
|
|
6749
7618
|
"use strict";
|
|
@@ -6762,8 +7631,8 @@ var init_collab = __esm({
|
|
|
6762
7631
|
ours = "w100n-collab";
|
|
6763
7632
|
schemas = /* @__PURE__ */ new Map();
|
|
6764
7633
|
schemaOf = (kind) => schemas.get(kind) ?? schemas.set(kind, (0, import_core3.getSchema)(kit(kind, texts.en))).get(kind);
|
|
6765
|
-
|
|
6766
|
-
edits = (tr) => tr.changedParentTypes.has(tr.doc.get("default")) || tr.changedParentTypes.has(tr.doc.get("book"));
|
|
7634
|
+
parse4 = async (kind, bytes) => kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc;
|
|
7635
|
+
edits = (tr) => tr.changedParentTypes.has(tr.doc.get("default")) || tr.changedParentTypes.has(tr.doc.get("book")) || tr.changedParentTypes.has(tr.doc.get("setup"));
|
|
6767
7636
|
filled = (doc) => doc.getXmlFragment("default").length > 0 || doc.getMap("book").size > 0;
|
|
6768
7637
|
pending = (doc) => doc.getMap("editors").size > 0;
|
|
6769
7638
|
blocks2 = (fragment, schema) => {
|
|
@@ -6857,13 +7726,13 @@ var init_room = __esm({
|
|
|
6857
7726
|
}
|
|
6858
7727
|
store() {
|
|
6859
7728
|
const room = this.room;
|
|
6860
|
-
const
|
|
7729
|
+
const run3 = room.busy.then(async () => {
|
|
6861
7730
|
const done = await save(room.doc, this.kind, room.base ?? await this.host.content(this.id), async (bytes, note) => (await this.host.save(this.id, bytes, note)).versionId);
|
|
6862
7731
|
if (done) room.base = done.bytes;
|
|
6863
7732
|
return done;
|
|
6864
7733
|
});
|
|
6865
|
-
room.busy =
|
|
6866
|
-
return
|
|
7734
|
+
room.busy = run3.catch(() => null);
|
|
7735
|
+
return run3;
|
|
6867
7736
|
}
|
|
6868
7737
|
sendStateless(payload) {
|
|
6869
7738
|
if (!this.live || this.authorizedScope !== "read-write" || !JSON.parse(payload).save) return;
|
|
@@ -6988,7 +7857,7 @@ var TextEditor_exports = {};
|
|
|
6988
7857
|
__export(TextEditor_exports, {
|
|
6989
7858
|
default: () => TextEditor
|
|
6990
7859
|
});
|
|
6991
|
-
function TextEditor({ kind, bytes, t, language, rights, host, together, documentId, onSaved, onOutline, onPanel, slot, guard }) {
|
|
7860
|
+
function TextEditor({ kind, bytes, t, language, rights, host, together, documentId, onSaved, onOutline, onReading, onPanel, slot, head: head2, file, guard }) {
|
|
6992
7861
|
const docx2 = kind === "docx";
|
|
6993
7862
|
const can = { edit: !!host?.save && !!rights?.edit, comment: !!host?.comment && !!rights && (rights.comment || rights.edit) };
|
|
6994
7863
|
const source = useLoad(async () => {
|
|
@@ -7002,8 +7871,11 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7002
7871
|
const baseline = (0, import_react10.useRef)(null);
|
|
7003
7872
|
const anchors2 = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
7004
7873
|
const scroller = (0, import_react10.useRef)(null);
|
|
7005
|
-
const
|
|
7874
|
+
const root = (0, import_react10.useRef)(null);
|
|
7006
7875
|
const [pop, setPop] = (0, import_react10.useState)(null);
|
|
7876
|
+
const [dialog, setDialog] = (0, import_react10.useState)(null);
|
|
7877
|
+
const field = (0, import_react10.useRef)(null);
|
|
7878
|
+
const [more, setMore] = (0, import_react10.useState)(() => typeof localStorage !== "undefined" && localStorage.getItem("w100n-docs-more") === "1");
|
|
7007
7879
|
const [zoom, setZoom] = (0, import_react10.useState)(null);
|
|
7008
7880
|
const [layout2, setLayout] = (0, import_react10.useState)(null);
|
|
7009
7881
|
const [room, setRoom] = (0, import_react10.useState)(0);
|
|
@@ -7020,6 +7892,14 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7020
7892
|
const [editing, setEditing] = (0, import_react10.useState)(null);
|
|
7021
7893
|
const [dropping, setDropping] = (0, import_react10.useState)(null);
|
|
7022
7894
|
const [failed, setFailed] = (0, import_react10.useState)(false);
|
|
7895
|
+
const [paint2, setPaint] = (0, import_react10.useState)(null);
|
|
7896
|
+
const [query, setQuery] = (0, import_react10.useState)("");
|
|
7897
|
+
const [swap, setSwap] = (0, import_react10.useState)("");
|
|
7898
|
+
const [matchCase, setMatchCase] = (0, import_react10.useState)(false);
|
|
7899
|
+
const [count, setCount] = (0, import_react10.useState)({ words: 0, pages: 0 });
|
|
7900
|
+
const [marg, setMarg] = (0, import_react10.useState)(null);
|
|
7901
|
+
const [unsetup, setUnsetup] = (0, import_react10.useState)(false);
|
|
7902
|
+
const [draft2, setDraft2] = (0, import_react10.useState)(null);
|
|
7023
7903
|
useRestore(pop !== null);
|
|
7024
7904
|
useRestore(editing !== null);
|
|
7025
7905
|
useRestore(dropping !== null);
|
|
@@ -7029,7 +7909,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7029
7909
|
editable: can.edit && (!live || !!shared),
|
|
7030
7910
|
immediatelyRender: true,
|
|
7031
7911
|
shouldRerenderOnTransaction: false,
|
|
7032
|
-
editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText } },
|
|
7912
|
+
editorProps: { attributes: { class: "w100n-docs-prose w100n-text-body", "aria-label": t.documentText }, transformPastedHTML: cleanPaste },
|
|
7033
7913
|
onCreate: ({ editor: made2 }) => {
|
|
7034
7914
|
if (source.data && !live) baseline.current = { bytes, doc: made2.state.doc, base: source.data.md && track(source.data.md, made2.state.doc) };
|
|
7035
7915
|
}
|
|
@@ -7055,6 +7935,15 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7055
7935
|
link: e.isActive("link"),
|
|
7056
7936
|
color: e.getAttributes("textStyle").color ?? null,
|
|
7057
7937
|
glow: e.isActive("highlight"),
|
|
7938
|
+
font: e.getAttributes("textStyle").fontFamily ?? null,
|
|
7939
|
+
size: e.getAttributes("textStyle").fontSize ?? null,
|
|
7940
|
+
fill: e.getAttributes("tableCell").background ?? e.getAttributes("tableHeader").background ?? null,
|
|
7941
|
+
bare: e.getAttributes("table").borders === "none",
|
|
7942
|
+
sup: e.isActive("superscript"),
|
|
7943
|
+
sub: e.isActive("subscript"),
|
|
7944
|
+
img: e.isActive("image") ? e.getAttributes("image").wrap ?? "inline" : null,
|
|
7945
|
+
line: block2.attrs.line ?? null,
|
|
7946
|
+
after: block2.attrs.after ?? null,
|
|
7058
7947
|
undo: e.can().undo(),
|
|
7059
7948
|
redo: e.can().redo(),
|
|
7060
7949
|
empty,
|
|
@@ -7065,6 +7954,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7065
7954
|
});
|
|
7066
7955
|
return at;
|
|
7067
7956
|
})(),
|
|
7957
|
+
find: (({ at, hits }) => `${at}/${hits.length}`)(searching.getState(e.state)),
|
|
7068
7958
|
suggest: !!suggesting.getState(e.state)?.on,
|
|
7069
7959
|
revs: docx2 ? changes(e.state.doc) : [],
|
|
7070
7960
|
dirty: !!baseline.current && !e.state.doc.eq(baseline.current.doc)
|
|
@@ -7072,9 +7962,43 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7072
7962
|
}
|
|
7073
7963
|
});
|
|
7074
7964
|
const page = layout2 ?? source.data?.page ?? a4;
|
|
7965
|
+
const print = () => {
|
|
7966
|
+
if (!editor) return;
|
|
7967
|
+
const frame = document.createElement("iframe");
|
|
7968
|
+
frame.style.cssText = "position:fixed;width:0;height:0;border:0;opacity:0";
|
|
7969
|
+
document.body.append(frame);
|
|
7970
|
+
const [mt, mr, mb, ml2] = page.margins;
|
|
7971
|
+
const size2 = docx2 ? `${page.width}px ${page.height}px` : "A4";
|
|
7972
|
+
frame.contentDocument.open();
|
|
7973
|
+
frame.contentDocument.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>${editor.state.doc.firstChild?.textContent.slice(0, 80).replace(/[<&]/g, "") ?? ""}</title><style>
|
|
7974
|
+
@page { size: ${size2}; margin: ${docx2 ? `${mt}px ${mr}px ${mb}px ${ml2}px` : "20mm"}; }
|
|
7975
|
+
body { margin: 0; font: 11pt/1.5 Arial, sans-serif; color: #111; }
|
|
7976
|
+
h1 { font-size: 20pt; } h2 { font-size: 15pt; } h3 { font-size: 13pt; }
|
|
7977
|
+
table { border-collapse: collapse; width: 100%; } td, th { border: 1px solid #94a3b8; padding: 4px 6px; vertical-align: top; } table[data-borders='none'] td, table[data-borders='none'] th { border-color: transparent; }
|
|
7978
|
+
img { max-width: 100%; } img[data-wrap='left'] { float: left; margin: 0 12pt 6pt 0; } img[data-wrap='right'] { float: right; margin: 0 0 6pt 12pt; }
|
|
7979
|
+
[data-type='page-break'], .page-break { break-after: page; height: 0; overflow: hidden; }
|
|
7980
|
+
</style></head><body>${editor.getHTML()}</body></html>`);
|
|
7981
|
+
frame.contentDocument.close();
|
|
7982
|
+
frame.contentWindow.focus();
|
|
7983
|
+
frame.contentWindow.print();
|
|
7984
|
+
setTimeout(() => frame.remove(), 1e3);
|
|
7985
|
+
};
|
|
7986
|
+
const marginal = marg ?? (source.data && "marginal" in source.data ? source.data.marginal : null) ?? { header: "", footer: "", numbers: false };
|
|
7987
|
+
(0, import_react10.useEffect)(() => {
|
|
7988
|
+
if (editor && docx2 && source.data) editor.view.dispatch(editor.state.tr.setMeta(paging, { page, marks: { header: marginal.header, footer: marginal.footer } }));
|
|
7989
|
+
}, [editor, source.data, page, marginal.header, marginal.footer]);
|
|
7075
7990
|
(0, import_react10.useEffect)(() => {
|
|
7076
|
-
if (
|
|
7077
|
-
|
|
7991
|
+
if (!shared || !docx2) return;
|
|
7992
|
+
const map = shared.doc.getMap("setup");
|
|
7993
|
+
const sync = () => {
|
|
7994
|
+
const v = map.toJSON();
|
|
7995
|
+
if (v.page) setLayout(v.page);
|
|
7996
|
+
if (v.header !== void 0 || v.footer !== void 0 || v.numbers !== void 0) setMarg({ header: v.header ?? "", footer: v.footer ?? "", numbers: !!v.numbers });
|
|
7997
|
+
};
|
|
7998
|
+
sync();
|
|
7999
|
+
map.observe(sync);
|
|
8000
|
+
return () => map.unobserve(sync);
|
|
8001
|
+
}, [shared, docx2]);
|
|
7078
8002
|
const loaded = useLoad((signal) => host?.comments ? host.comments(documentId, { signal }) : Promise.resolve([]), [host, documentId]);
|
|
7079
8003
|
const all = [...loaded.data ?? [], ...added].flatMap((c) => c.id in changed2 ? changed2[c.id] ?? [] : [c]).filter((c) => !c.replyTo || changed2[c.replyTo] !== null);
|
|
7080
8004
|
const open = all.filter((c) => !c.replyTo && !c.resolved);
|
|
@@ -7084,8 +8008,8 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7084
8008
|
if (!editor || !source.data) return;
|
|
7085
8009
|
const have = new Map(notes.getState(editor.state).spots.map((s) => [s.id, s]));
|
|
7086
8010
|
const fresh2 = open.filter((c) => !have.has(c.id));
|
|
7087
|
-
const
|
|
7088
|
-
editor.view.dispatch(editor.state.tr.setMeta(notes, { spots: [...open.flatMap((c) => have.get(c.id) ?? []), ...
|
|
8011
|
+
const found2 = locate(editor.state.doc, fresh2.map((c) => ({ id: c.id, quote: c.quote, anchor: anchors2.current.get(c.id) })));
|
|
8012
|
+
editor.view.dispatch(editor.state.tr.setMeta(notes, { spots: [...open.flatMap((c) => have.get(c.id) ?? []), ...found2] }));
|
|
7089
8013
|
}, [editor, source.data, openIds]);
|
|
7090
8014
|
(0, import_react10.useEffect)(() => {
|
|
7091
8015
|
if (editor && source.data) editor.view.dispatch(editor.state.tr.setMeta(notes, { active }));
|
|
@@ -7094,7 +8018,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7094
8018
|
if (!editor || !source.data) return;
|
|
7095
8019
|
let timer = 0;
|
|
7096
8020
|
let last2 = "";
|
|
7097
|
-
const
|
|
8021
|
+
const run3 = () => {
|
|
7098
8022
|
const list = [];
|
|
7099
8023
|
editor.state.doc.forEach((node, offset) => {
|
|
7100
8024
|
if (node.type.name !== "heading" || !node.textContent.trim()) return;
|
|
@@ -7103,6 +8027,8 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7103
8027
|
editor.commands.setTextSelection(offset + 1);
|
|
7104
8028
|
} });
|
|
7105
8029
|
});
|
|
8030
|
+
const text = editor.state.doc.textBetween(0, editor.state.doc.content.size, " ", " ");
|
|
8031
|
+
setCount({ words: (text.match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu) ?? []).length, pages: scroller.current?.querySelectorAll(".w100n-text-gap").length ?? 0 });
|
|
7106
8032
|
const key2 = JSON.stringify(list.map((h) => [h.id, h.level, h.text]));
|
|
7107
8033
|
if (key2 === last2) return;
|
|
7108
8034
|
last2 = key2;
|
|
@@ -7110,16 +8036,44 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7110
8036
|
};
|
|
7111
8037
|
const later = () => {
|
|
7112
8038
|
clearTimeout(timer);
|
|
7113
|
-
timer = window.setTimeout(
|
|
8039
|
+
timer = window.setTimeout(run3, 300);
|
|
7114
8040
|
};
|
|
7115
|
-
|
|
8041
|
+
run3();
|
|
7116
8042
|
editor.on("update", later);
|
|
7117
8043
|
return () => {
|
|
7118
8044
|
clearTimeout(timer);
|
|
7119
8045
|
editor.off("update", later);
|
|
7120
8046
|
};
|
|
7121
8047
|
}, [editor, source.data, onOutline]);
|
|
7122
|
-
|
|
8048
|
+
(0, import_react10.useEffect)(() => {
|
|
8049
|
+
const el = scroller.current;
|
|
8050
|
+
if (!el || !editor || !onReading) return;
|
|
8051
|
+
let frame = 0;
|
|
8052
|
+
let last2 = "";
|
|
8053
|
+
const look = () => {
|
|
8054
|
+
cancelAnimationFrame(frame);
|
|
8055
|
+
frame = requestAnimationFrame(() => {
|
|
8056
|
+
const line = el.getBoundingClientRect().top + el.clientHeight / 3;
|
|
8057
|
+
let id = null;
|
|
8058
|
+
editor.state.doc.forEach((node, offset) => {
|
|
8059
|
+
const dom = node.type.name === "heading" && node.textContent.trim() ? editor.view.nodeDOM(offset) : null;
|
|
8060
|
+
if (dom && dom.getBoundingClientRect().top <= line) id = `h${offset}`;
|
|
8061
|
+
});
|
|
8062
|
+
const room2 = el.scrollHeight - el.clientHeight;
|
|
8063
|
+
const progress = room2 > 0 ? Math.round(el.scrollTop / room2 * 100) / 100 : 1;
|
|
8064
|
+
if (`${id}:${progress}` === last2) return;
|
|
8065
|
+
last2 = `${id}:${progress}`;
|
|
8066
|
+
onReading({ documentId, id, progress });
|
|
8067
|
+
});
|
|
8068
|
+
};
|
|
8069
|
+
look();
|
|
8070
|
+
el.addEventListener("scroll", look, { passive: true });
|
|
8071
|
+
return () => {
|
|
8072
|
+
cancelAnimationFrame(frame);
|
|
8073
|
+
el.removeEventListener("scroll", look);
|
|
8074
|
+
};
|
|
8075
|
+
}, [editor, source.data, onReading, documentId]);
|
|
8076
|
+
const dirty = live ? live.pending : !!state?.dirty || unsetup;
|
|
7123
8077
|
const unsent = live ? live.unsynced && can.edit : dirty;
|
|
7124
8078
|
(0, import_react10.useEffect)(() => {
|
|
7125
8079
|
if (!guard || live || !dirty || !source.data || !editor) return;
|
|
@@ -7128,6 +8082,11 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7128
8082
|
guard.current = null;
|
|
7129
8083
|
};
|
|
7130
8084
|
});
|
|
8085
|
+
(0, import_react10.useEffect)(() => {
|
|
8086
|
+
if (live || !dirty || !can.edit || saving === "busy" || !editor) return;
|
|
8087
|
+
const timer = window.setTimeout(() => void save2(true), 3e3);
|
|
8088
|
+
return () => clearTimeout(timer);
|
|
8089
|
+
});
|
|
7131
8090
|
(0, import_react10.useEffect)(() => {
|
|
7132
8091
|
if (!unsent) return;
|
|
7133
8092
|
const stop = (e) => e.preventDefault();
|
|
@@ -7141,6 +8100,30 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7141
8100
|
watch.observe(el);
|
|
7142
8101
|
return () => watch.disconnect();
|
|
7143
8102
|
}, [editor, source.data]);
|
|
8103
|
+
(0, import_react10.useEffect)(() => {
|
|
8104
|
+
const el = root.current;
|
|
8105
|
+
if (!el) return;
|
|
8106
|
+
const open2 = () => {
|
|
8107
|
+
setPop("find");
|
|
8108
|
+
el.querySelector(".w100n-text-find input")?.focus();
|
|
8109
|
+
};
|
|
8110
|
+
el.addEventListener("docs-find", open2);
|
|
8111
|
+
return () => el.removeEventListener("docs-find", open2);
|
|
8112
|
+
}, [editor, source.data]);
|
|
8113
|
+
(0, import_react10.useEffect)(() => {
|
|
8114
|
+
const shown = pop === "find" ? query : "";
|
|
8115
|
+
if (editor && searching.getState(editor.state).query !== shown) editor.view.dispatch(editor.state.tr.setMeta(searching, { query: shown }));
|
|
8116
|
+
}, [editor, pop, query]);
|
|
8117
|
+
(0, import_react10.useEffect)(() => {
|
|
8118
|
+
const press = (e) => {
|
|
8119
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey || e.key.toLowerCase() !== "p") return;
|
|
8120
|
+
e.preventDefault();
|
|
8121
|
+
e.stopPropagation();
|
|
8122
|
+
print();
|
|
8123
|
+
};
|
|
8124
|
+
window.addEventListener("keydown", press, true);
|
|
8125
|
+
return () => window.removeEventListener("keydown", press, true);
|
|
8126
|
+
});
|
|
7144
8127
|
(0, import_react10.useEffect)(() => {
|
|
7145
8128
|
if (!pop) return;
|
|
7146
8129
|
const close = (e) => {
|
|
@@ -7151,7 +8134,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7151
8134
|
}, [pop]);
|
|
7152
8135
|
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 });
|
|
7153
8136
|
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 });
|
|
7154
|
-
const save2 = async () => {
|
|
8137
|
+
const save2 = async (auto = false) => {
|
|
7155
8138
|
if (live) {
|
|
7156
8139
|
if (!can.edit || !live.ready || !live.online || !live.pending || saving === "busy") return false;
|
|
7157
8140
|
setSaving("busy");
|
|
@@ -7161,17 +8144,18 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7161
8144
|
}
|
|
7162
8145
|
const was = baseline.current;
|
|
7163
8146
|
const doc = editor.state.doc;
|
|
7164
|
-
if (!can.edit || !was || saving === "busy" || doc.eq(was.doc)) return false;
|
|
8147
|
+
if (!can.edit || !was || saving === "busy" || doc.eq(was.doc) && !unsetup) return false;
|
|
7165
8148
|
setSaving("busy");
|
|
7166
8149
|
try {
|
|
7167
8150
|
const md = was.base && toMarkdown(doc, was.base);
|
|
7168
|
-
const out = md ? new TextEncoder().encode(md.text).buffer : await writeDocx(was.bytes, editor.getJSON());
|
|
7169
|
-
await host.save(documentId, out, t.editedNote);
|
|
8151
|
+
const out = md ? new TextEncoder().encode(md.text).buffer : await writeDocx(was.bytes, editor.getJSON(), void 0, unsetup ? { page, ...marginal } : void 0);
|
|
8152
|
+
await host.save(documentId, out, auto ? t.autosavedNote : t.editedNote, auto);
|
|
7170
8153
|
baseline.current = { bytes: md ? out : was.bytes, doc, base: md ? md.base : null };
|
|
7171
8154
|
if (!md && editor.state.doc === doc) {
|
|
7172
8155
|
const fresh2 = (await readDocx(out)).doc;
|
|
7173
8156
|
if (editor.state.doc === doc && renew(fresh2)) baseline.current = { bytes: out, doc: editor.state.doc, base: null };
|
|
7174
8157
|
}
|
|
8158
|
+
setUnsetup(false);
|
|
7175
8159
|
setSaving("done");
|
|
7176
8160
|
onSaved?.();
|
|
7177
8161
|
return true;
|
|
@@ -7199,7 +8183,6 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7199
8183
|
};
|
|
7200
8184
|
const linkUp = () => {
|
|
7201
8185
|
setHref(editor.getAttributes("link").href ?? "");
|
|
7202
|
-
setTab("insert");
|
|
7203
8186
|
setPop("link");
|
|
7204
8187
|
};
|
|
7205
8188
|
const putLink = () => {
|
|
@@ -7300,20 +8283,22 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7300
8283
|
const keys2 = (e) => {
|
|
7301
8284
|
if (e.defaultPrevented) return;
|
|
7302
8285
|
const key2 = e.key.toLowerCase();
|
|
7303
|
-
const
|
|
7304
|
-
if (key2 === "escape" && (pop || draft)) {
|
|
8286
|
+
const mod2 = e.metaKey || e.ctrlKey;
|
|
8287
|
+
if (key2 === "escape" && (pop || draft || paint2)) {
|
|
7305
8288
|
e.stopPropagation();
|
|
7306
|
-
if (
|
|
8289
|
+
if (paint2) setPaint(null);
|
|
8290
|
+
else if (pop) setPop(null);
|
|
7307
8291
|
else drop2();
|
|
7308
8292
|
return;
|
|
7309
8293
|
}
|
|
7310
|
-
if (!
|
|
7311
|
-
const act = (
|
|
8294
|
+
if (!mod2) return;
|
|
8295
|
+
const act = (run3) => {
|
|
7312
8296
|
e.preventDefault();
|
|
7313
|
-
|
|
8297
|
+
run3();
|
|
7314
8298
|
};
|
|
7315
8299
|
if (key2 === "s" && can.edit) act(() => void save2());
|
|
7316
8300
|
else if (key2 === "k" && can.edit) act(linkUp);
|
|
8301
|
+
else if (key2 === "f" && !e.altKey) act(() => setPop("find"));
|
|
7317
8302
|
else if (key2 === "m" && e.altKey && can.comment) act(begin);
|
|
7318
8303
|
else if (!can.edit || e.altKey) return;
|
|
7319
8304
|
else if (key2 === "]" || key2 === "[") act(() => indent(editor, key2 === "]" ? 1 : -1));
|
|
@@ -7321,10 +8306,10 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7321
8306
|
else if (key2 === "enter" && docx2) act(() => editor.chain().focus().insertContent({ type: "pageBreak" }).run());
|
|
7322
8307
|
else if (e.shiftKey && docx2 && ["l", "e", "r", "j"].includes(key2)) act(() => align2(editor, { l: "left", e: "center", r: "right", j: "justify" }[key2]));
|
|
7323
8308
|
};
|
|
7324
|
-
const tool = (icon, label,
|
|
8309
|
+
const tool = (icon, label, run3, pressed, disabled) => {
|
|
7325
8310
|
const Icon = icon;
|
|
7326
8311
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": label, title: label, "aria-pressed": pressed, disabled, onClick: () => {
|
|
7327
|
-
|
|
8312
|
+
run3();
|
|
7328
8313
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { "aria-hidden": true }) });
|
|
7329
8314
|
};
|
|
7330
8315
|
const gap = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-pdf-gap" });
|
|
@@ -7344,14 +8329,6 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7344
8329
|
["quote", named3((s) => /quote/i.test(s.name)) || t.quote, () => editor.chain().focus().clearNodes().setParagraph().setBlockquote().run()],
|
|
7345
8330
|
["code", t.code, () => editor.chain().focus().setCodeBlock().run()]
|
|
7346
8331
|
];
|
|
7347
|
-
const tabs = [
|
|
7348
|
-
...can.edit ? [["home", t.home], ["insert", t.insert]] : [],
|
|
7349
|
-
...can.edit && docx2 ? [["layout", t.layout]] : [],
|
|
7350
|
-
...can.edit ? [["refs", t.references]] : [],
|
|
7351
|
-
...host?.comments && (can.comment || open.length > 0) ? [["review", t.review]] : [],
|
|
7352
|
-
["view", t.viewTab]
|
|
7353
|
-
];
|
|
7354
|
-
const shown = tabs.some(([key2]) => key2 === tab) ? tab : "view";
|
|
7355
8332
|
const margins = [[t.marginsNormal, [96, 96, 96, 96]], [t.marginsNarrow, [48, 48, 48, 48]], [t.marginsWide, [96, 192, 96, 192]]];
|
|
7356
8333
|
const when = (iso) => new Intl.DateTimeFormat(language, { day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }).format(new Date(iso));
|
|
7357
8334
|
const person = (c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { children: [
|
|
@@ -7374,7 +8351,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7374
8351
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Trash2, { "aria-hidden": true }) })
|
|
7375
8352
|
] })
|
|
7376
8353
|
] });
|
|
7377
|
-
const
|
|
8354
|
+
const words2 = (c) => editing?.id === c.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply w100n-text-edit", onClick: (e) => e.stopPropagation(), children: [
|
|
7378
8355
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7379
8356
|
"textarea",
|
|
7380
8357
|
{
|
|
@@ -7415,14 +8392,281 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7415
8392
|
setPop(null);
|
|
7416
8393
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { style: { background: c } }) }, i))
|
|
7417
8394
|
] });
|
|
7418
|
-
|
|
7419
|
-
|
|
8395
|
+
const mod = /Mac|iPhone|iPad/.test(navigator.platform) ? "\u2318" : "Ctrl+";
|
|
8396
|
+
const item = (label, run3, more2 = {}) => ({ label, run: run3, ...more2 });
|
|
8397
|
+
const insertToc = () => {
|
|
8398
|
+
const at = editor.state.selection.$from.before(1);
|
|
8399
|
+
editor.chain().focus().insertContentAt(at, { type: "toc", attrs: { entries: JSON.stringify(entries(editor.state.doc, !docx2, at - 1)) } }).run();
|
|
8400
|
+
};
|
|
8401
|
+
const suggest = () => editor.view.dispatch(editor.state.tr.setMeta(suggesting, { on: !state.suggest, me: host?.me.name ?? "" }));
|
|
8402
|
+
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"]];
|
|
8403
|
+
const lines2 = [[1, t.single], [1.15, "1.15"], [1.5, "1.5"], [2, t.double]];
|
|
8404
|
+
const menus = [
|
|
8405
|
+
["file", t.menuFile, [
|
|
8406
|
+
...can.edit ? [
|
|
8407
|
+
item(t.save, () => void save2(), { keys: `${mod}S`, off: !dirty }),
|
|
8408
|
+
item(t.print, print, { keys: `${mod}P` }),
|
|
8409
|
+
...docx2 ? ["-", item(t.pageSetup, () => setDraft2({ width: page.width, height: page.height, margins: page.margins.map(cm), ...marginal }))] : []
|
|
8410
|
+
] : [],
|
|
8411
|
+
...can.edit && (file?.formats.length || file?.copy || file?.rename) ? ["-"] : [],
|
|
8412
|
+
...(file?.formats ?? []).map((f) => item(`${t.downloadAs} ${f === "md" ? "Markdown" : f.toUpperCase()}`, () => file.download(f))),
|
|
8413
|
+
!!file?.copy && item(t.makeCopy, file.copy),
|
|
8414
|
+
!!file?.rename && item(t.rename, file.rename)
|
|
8415
|
+
]],
|
|
8416
|
+
["edit", t.menuEdit, can.edit ? [
|
|
8417
|
+
item(t.undo, () => editor.chain().focus().undo().run(), { keys: `${mod}Z`, off: !state.undo }),
|
|
8418
|
+
item(t.redo, () => editor.chain().focus().redo().run(), { keys: `${mod}\u21E7Z`, off: !state.redo }),
|
|
8419
|
+
"-",
|
|
8420
|
+
item(t.findReplace, () => setPop("find"), { keys: `${mod}F` }),
|
|
8421
|
+
"-",
|
|
8422
|
+
item(t.clearFormat, () => clear(editor), { keys: `${mod}\\` })
|
|
8423
|
+
] : []],
|
|
8424
|
+
["view", t.viewTab, [
|
|
8425
|
+
item(t.zoomIn, () => zoomBy(10)),
|
|
8426
|
+
item(t.zoomOut, () => zoomBy(-10)),
|
|
8427
|
+
docx2 && item(t.fitWidth, () => setZoom(null), { on: zoom === null }),
|
|
8428
|
+
item(t.fit, () => setZoom(100)),
|
|
8429
|
+
"-",
|
|
8430
|
+
item(t.outline, () => onPanel?.("outline")),
|
|
8431
|
+
"-",
|
|
8432
|
+
item([docx2 && count.pages ? `${t.pages}: ${count.pages}` : "", `${t.words}: ${count.words.toLocaleString(language)}`].filter(Boolean).join(" \xB7 "), () => {
|
|
8433
|
+
}, { off: true })
|
|
8434
|
+
]],
|
|
8435
|
+
["insert", t.insert, can.edit ? [
|
|
8436
|
+
item(t.table, () => setPop("table")),
|
|
8437
|
+
item(t.image, () => {
|
|
8438
|
+
setHref("");
|
|
8439
|
+
setPop("image");
|
|
8440
|
+
}),
|
|
8441
|
+
item(t.link, linkUp, { keys: `${mod}K` }),
|
|
8442
|
+
docx2 && item(t.pageBreak, () => editor.chain().focus().insertContent({ type: "pageBreak" }).run(), { keys: `${mod}\u21B5` }),
|
|
8443
|
+
item(t.rule, () => editor.chain().focus().setHorizontalRule().run()),
|
|
8444
|
+
"-",
|
|
8445
|
+
state.toc < 0 ? item(t.tocInsert, insertToc) : item(t.tocRemove, () => editor.chain().focus().deleteRange({ from: state.toc, to: state.toc + editor.state.doc.nodeAt(state.toc).nodeSize }).run()),
|
|
8446
|
+
can.comment && item(t.addComment, begin, { off: state.empty, keys: `${mod}\u2325M` }),
|
|
8447
|
+
"-",
|
|
8448
|
+
item(t.symbols, () => setDialog({ kind: "symbol", query: "" })),
|
|
8449
|
+
docx2 && item(t.formula, () => setDialog({ kind: "formula", latex: "", at: null })),
|
|
8450
|
+
docx2 && item(t.footnote, () => setDialog({ kind: "note", text: "", at: null }))
|
|
8451
|
+
] : []],
|
|
8452
|
+
["format", t.menuFormat, can.edit ? [
|
|
8453
|
+
...styles2.map(([key2, label, run3]) => item(label, run3, { on: state.style === key2 })),
|
|
8454
|
+
"-",
|
|
8455
|
+
item(t.bold, () => editor.chain().focus().toggleBold().run(), { on: state.bold, keys: `${mod}B` }),
|
|
8456
|
+
item(t.italic, () => editor.chain().focus().toggleItalic().run(), { on: state.italic, keys: `${mod}I` }),
|
|
8457
|
+
docx2 && item(t.underline, () => editor.chain().focus().toggleUnderline().run(), { on: state.underline, keys: `${mod}U` }),
|
|
8458
|
+
item(t.strike, () => editor.chain().focus().toggleStrike().run(), { on: state.strike }),
|
|
8459
|
+
docx2 && item(t.superscript, () => editor.chain().focus().toggleMark("superscript").run(), { on: state.sup, keys: `${mod}.` }),
|
|
8460
|
+
docx2 && item(t.subscript, () => editor.chain().focus().toggleMark("subscript").run(), { on: state.sub, keys: `${mod},` }),
|
|
8461
|
+
...docx2 ? [
|
|
8462
|
+
"-",
|
|
8463
|
+
...aligns.map(([, label, value3]) => item(label, () => align2(editor, value3), { on: state.align === value3 })),
|
|
8464
|
+
"-",
|
|
8465
|
+
...lines2.map(([v, label]) => item(`${t.lineSpacing}: ${label}`, () => spacing(editor, { line: v }), { on: state.line === v }))
|
|
8466
|
+
] : [],
|
|
8467
|
+
"-",
|
|
8468
|
+
item(t.bullets, () => editor.chain().focus().toggleBulletList().run(), { on: state.bullets }),
|
|
8469
|
+
item(t.numbers, () => editor.chain().focus().toggleOrderedList().run(), { on: state.numbers }),
|
|
8470
|
+
item(t.tasks, () => editor.chain().focus().toggleTaskList().run(), { on: state.tasks }),
|
|
8471
|
+
"-",
|
|
8472
|
+
item(t.outdent, () => indent(editor, -1), { keys: `${mod}[` }),
|
|
8473
|
+
item(t.indent, () => indent(editor, 1), { keys: `${mod}]` })
|
|
8474
|
+
] : []],
|
|
8475
|
+
["tools", t.menuTools, [
|
|
8476
|
+
docx2 && can.edit && item(t.suggest, suggest, { on: state.suggest }),
|
|
8477
|
+
docx2 && can.edit && state.revs.length > 0 && item(t.acceptAll, () => decide(editor, true)),
|
|
8478
|
+
docx2 && can.edit && state.revs.length > 0 && item(t.rejectAll, () => decide(editor, false)),
|
|
8479
|
+
!!host?.comments && (can.comment || open.length > 0) && item(t.comments, () => onPanel?.("comments"))
|
|
8480
|
+
]]
|
|
8481
|
+
];
|
|
8482
|
+
const menu = ([key2, label, list]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8483
|
+
/* @__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 }),
|
|
8484
|
+
pop === key2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-menu", role: "menu", "aria-label": label, children: list.filter((x) => x !== false).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: () => {
|
|
8485
|
+
setPop(null);
|
|
8486
|
+
x.run();
|
|
8487
|
+
}, children: [
|
|
8488
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
8489
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: x.label }),
|
|
8490
|
+
x.keys && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: x.keys })
|
|
8491
|
+
] }, i)) })
|
|
8492
|
+
] }, key2);
|
|
8493
|
+
const seek = (next) => {
|
|
8494
|
+
editor.view.dispatch(editor.state.tr.setMeta(searching, next));
|
|
8495
|
+
const found2 = searching.getState(editor.state);
|
|
8496
|
+
const hit = found2.hits[found2.at];
|
|
8497
|
+
if (hit && next.at !== void 0) {
|
|
8498
|
+
editor.commands.setTextSelection(hit);
|
|
8499
|
+
editor.view.dom.querySelector(".w100n-found.is-current")?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
8500
|
+
}
|
|
8501
|
+
};
|
|
8502
|
+
const found = searching.getState(editor.state);
|
|
8503
|
+
const finder = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8504
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "find", "aria-label": t.findReplace, title: t.findReplace, onClick: () => pick("find"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Search, { "aria-hidden": true }) }),
|
|
8505
|
+
pop === "find" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-find", role: "search", "aria-label": t.findReplace, children: [
|
|
8506
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-docs-row", children: [
|
|
8507
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
8508
|
+
"input",
|
|
8509
|
+
{
|
|
8510
|
+
autoFocus: true,
|
|
8511
|
+
value: query,
|
|
8512
|
+
placeholder: t.find,
|
|
8513
|
+
"aria-label": t.find,
|
|
8514
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
8515
|
+
onChange: (e) => {
|
|
8516
|
+
setQuery(e.target.value);
|
|
8517
|
+
seek({ query: e.target.value, at: 0 });
|
|
8518
|
+
},
|
|
8519
|
+
onKeyDown: (e) => {
|
|
8520
|
+
if (e.key === "Enter") {
|
|
8521
|
+
e.preventDefault();
|
|
8522
|
+
seek({ at: (found?.at ?? 0) + (e.shiftKey ? -1 : 1) });
|
|
8523
|
+
}
|
|
8524
|
+
}
|
|
8525
|
+
}
|
|
8526
|
+
),
|
|
8527
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { "aria-live": "polite", children: query ? found?.hits.length ? `${(found.at ?? 0) + 1} / ${found.hits.length}` : t.noHits : "" }),
|
|
8528
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": t.previous, title: t.previous, disabled: !found?.hits.length, onClick: () => seek({ at: found.at - 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronUp, { "aria-hidden": true }) }),
|
|
8529
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": t.next, title: t.next, disabled: !found?.hits.length, onClick: () => seek({ at: found.at + 1 }), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true }) })
|
|
8530
|
+
] }),
|
|
8531
|
+
can.edit && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-docs-row", children: [
|
|
8532
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: swap, placeholder: t.replaceWith, "aria-label": t.replaceWith, onChange: (e) => setSwap(e.target.value) }),
|
|
8533
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-pdf-link", disabled: !found?.hits.length, onClick: () => {
|
|
8534
|
+
replace(editor, swap, false);
|
|
8535
|
+
seek({});
|
|
8536
|
+
}, children: t.replaceOne }),
|
|
8537
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-docs-action", disabled: !found?.hits.length, onClick: () => {
|
|
8538
|
+
replace(editor, swap, true);
|
|
8539
|
+
seek({});
|
|
8540
|
+
}, children: t.replaceAll })
|
|
8541
|
+
] }),
|
|
8542
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-setup-check", children: [
|
|
8543
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "checkbox", checked: matchCase, onChange: (e) => {
|
|
8544
|
+
setMatchCase(e.target.checked);
|
|
8545
|
+
seek({ matchCase: e.target.checked, at: 0 });
|
|
8546
|
+
} }),
|
|
8547
|
+
t.matchCase
|
|
8548
|
+
] })
|
|
8549
|
+
] })
|
|
8550
|
+
] });
|
|
8551
|
+
const formats = ["bold", "italic", "underline", "strike", "code", "highlight", "textStyle", "superscript", "subscript"];
|
|
8552
|
+
const take = (keep2) => {
|
|
8553
|
+
if (paint2 && !keep2) return setPaint(null);
|
|
8554
|
+
const { $from } = editor.state.selection;
|
|
8555
|
+
const marks2 = (editor.state.storedMarks ?? $from.marks()).filter((m) => formats.includes(m.type.name)).map((m) => ({ type: m.type.name, attrs: m.attrs }));
|
|
8556
|
+
setPaint({ marks: marks2, block: { align: $from.parent.attrs.align, line: $from.parent.attrs.line, after: $from.parent.attrs.after }, keep: keep2 });
|
|
8557
|
+
};
|
|
8558
|
+
const lay = () => {
|
|
8559
|
+
if (!paint2 || editor.state.selection.empty) return;
|
|
8560
|
+
const chain = editor.chain().focus();
|
|
8561
|
+
for (const name of formats) chain.unsetMark(name);
|
|
8562
|
+
for (const m of paint2.marks) chain.setMark(m.type, m.attrs);
|
|
8563
|
+
chain.run();
|
|
8564
|
+
align2(editor, paint2.block.align);
|
|
8565
|
+
spacing(editor, { line: paint2.block.line, after: paint2.block.after });
|
|
8566
|
+
if (!paint2.keep) setPaint(null);
|
|
8567
|
+
};
|
|
8568
|
+
const fontPicker = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8569
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-picker", "data-size": "mid", "data-pop": true, "aria-haspopup": "listbox", "aria-expanded": pop === "font", "aria-label": t.font, title: t.font, onClick: () => pick("font"), children: [
|
|
8570
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontFamily: state.font ?? void 0 }, children: state.font ?? t.defaultFont }),
|
|
8571
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true })
|
|
8572
|
+
] }),
|
|
8573
|
+
pop === "font" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.font, children: [
|
|
8574
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": !state.font, onClick: () => {
|
|
8575
|
+
editor.chain().focus().unsetFontFamily().run();
|
|
8576
|
+
setPop(null);
|
|
8577
|
+
}, children: t.defaultFont }),
|
|
8578
|
+
faces.map((f) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": state.font === f, style: { fontFamily: f }, onClick: () => {
|
|
8579
|
+
editor.chain().focus().setFontFamily(f).run();
|
|
8580
|
+
setPop(null);
|
|
8581
|
+
}, children: f }, f))
|
|
8582
|
+
] })
|
|
8583
|
+
] });
|
|
8584
|
+
const sizePicker = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8585
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-picker", "data-size": "small", "data-pop": true, "aria-haspopup": "listbox", "aria-expanded": pop === "size", "aria-label": t.fontSize, title: t.fontSize, onClick: () => pick("size"), children: [
|
|
8586
|
+
state.size ? parseFloat(state.size) : t.defaultFont,
|
|
8587
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true })
|
|
8588
|
+
] }),
|
|
8589
|
+
pop === "size" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.fontSize, children: [
|
|
8590
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": !state.size, onClick: () => {
|
|
8591
|
+
editor.chain().focus().unsetFontSize().run();
|
|
8592
|
+
setPop(null);
|
|
8593
|
+
}, children: t.defaultFont }),
|
|
8594
|
+
sizes.map((n) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": state.size !== null && parseFloat(state.size) === n, onClick: () => {
|
|
8595
|
+
editor.chain().focus().setFontSize(`${n}pt`).run();
|
|
8596
|
+
setPop(null);
|
|
8597
|
+
}, children: n }, n))
|
|
8598
|
+
] })
|
|
8599
|
+
] });
|
|
8600
|
+
const spacer = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8601
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "spacing", "aria-label": t.lineSpacing, title: t.lineSpacing, onClick: () => pick("spacing"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.UnfoldVertical, { "aria-hidden": true }) }),
|
|
8602
|
+
pop === "spacing" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.lineSpacing, children: [
|
|
8603
|
+
lines2.map(([v, label]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": state.line === v, onClick: () => {
|
|
8604
|
+
spacing(editor, { line: v });
|
|
8605
|
+
setPop(null);
|
|
8606
|
+
}, children: label }, v)),
|
|
8607
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("hr", {}),
|
|
8608
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": false, onClick: () => {
|
|
8609
|
+
spacing(editor, { after: state.after === 0 ? 8 : 0 });
|
|
8610
|
+
setPop(null);
|
|
8611
|
+
}, children: state.after === 0 ? t.spaceAfter : t.noSpaceAfter })
|
|
8612
|
+
] })
|
|
8613
|
+
] });
|
|
8614
|
+
const applySetup = () => {
|
|
8615
|
+
const d = draft2;
|
|
8616
|
+
const next = { width: d.width, height: d.height, margins: d.margins.map((v) => Math.round(v / 2.54 * 96 * 100) / 100) };
|
|
8617
|
+
const marks2 = { header: d.header.trim(), footer: d.footer.trim(), numbers: d.numbers };
|
|
8618
|
+
if (shared) shared.doc.transact(() => {
|
|
8619
|
+
const map = shared.doc.getMap("setup");
|
|
8620
|
+
map.set("page", next);
|
|
8621
|
+
for (const [key2, v] of Object.entries(marks2)) map.set(key2, v);
|
|
8622
|
+
});
|
|
8623
|
+
else {
|
|
8624
|
+
setLayout(next);
|
|
8625
|
+
setMarg(marks2);
|
|
8626
|
+
setUnsetup(true);
|
|
8627
|
+
}
|
|
8628
|
+
setDraft2(null);
|
|
8629
|
+
};
|
|
8630
|
+
const zooms = [50, 75, 90, 100, 125, 150, 200];
|
|
8631
|
+
const zoomer = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8632
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-picker", "data-size": "small", "data-pop": true, "aria-haspopup": "listbox", "aria-expanded": pop === "zoom", "aria-label": t.zoom, title: t.zoom, onClick: () => pick("zoom"), children: [
|
|
8633
|
+
percent,
|
|
8634
|
+
"%",
|
|
8635
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true })
|
|
8636
|
+
] }),
|
|
8637
|
+
pop === "zoom" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.zoom, children: [
|
|
8638
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "option", "aria-selected": zoom === null, onClick: () => {
|
|
8639
|
+
setZoom(null);
|
|
8640
|
+
setPop(null);
|
|
8641
|
+
}, children: t.fitWidth }),
|
|
8642
|
+
zooms.map((z) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", role: "option", "aria-selected": zoom === z, onClick: () => {
|
|
8643
|
+
setZoom(z);
|
|
8644
|
+
setPop(null);
|
|
8645
|
+
}, children: [
|
|
8646
|
+
z,
|
|
8647
|
+
"%"
|
|
8648
|
+
] }, z))
|
|
8649
|
+
] })
|
|
8650
|
+
] });
|
|
8651
|
+
const Aligned = aligns.find(([, , value3]) => value3 === state.align)?.[0] ?? import_lucide_react5.AlignLeft;
|
|
8652
|
+
const aligner = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8653
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "align", "aria-label": t.align, title: t.align, onClick: () => pick("align"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Aligned, { "aria-hidden": true }) }),
|
|
8654
|
+
pop === "align" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop", role: "group", "aria-label": t.align, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-tools", children: aligns.map(([icon, label, value3], i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react10.Fragment, { children: tool(icon, label, () => {
|
|
8655
|
+
align2(editor, value3);
|
|
8656
|
+
setPop(null);
|
|
8657
|
+
}, state.align === value3) }, i)) }) })
|
|
8658
|
+
] });
|
|
8659
|
+
const widen = () => {
|
|
8660
|
+
localStorage.setItem("w100n-docs-more", more ? "" : "1");
|
|
8661
|
+
setMore(!more);
|
|
8662
|
+
};
|
|
8663
|
+
const main = can.edit ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7420
8664
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7421
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-picker", "data-pop": true, "aria-haspopup": "listbox", "aria-expanded": pop === "style", "aria-label": t.paragraphStyle, title: t.paragraphStyle, onClick: () => pick("style"), children: [
|
|
8665
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-picker", "data-size": "mid", "data-pop": true, "aria-haspopup": "listbox", "aria-expanded": pop === "style", "aria-label": t.paragraphStyle, title: t.paragraphStyle, onClick: () => pick("style"), children: [
|
|
7422
8666
|
styles2.find(([key2]) => key2 === state.style)?.[1] ?? t.normal,
|
|
7423
8667
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true })
|
|
7424
8668
|
] }),
|
|
7425
|
-
pop === "style" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.paragraphStyle, children: styles2.map(([key2, label,
|
|
8669
|
+
pop === "style" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-pop w100n-text-styles", role: "listbox", "aria-label": t.paragraphStyle, children: styles2.map(([key2, label, run3]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7426
8670
|
"button",
|
|
7427
8671
|
{
|
|
7428
8672
|
type: "button",
|
|
@@ -7430,7 +8674,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7430
8674
|
"data-style": key2,
|
|
7431
8675
|
"aria-selected": state.style === key2,
|
|
7432
8676
|
onClick: () => {
|
|
7433
|
-
|
|
8677
|
+
run3();
|
|
7434
8678
|
setPop(null);
|
|
7435
8679
|
},
|
|
7436
8680
|
children: label
|
|
@@ -7441,8 +8685,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7441
8685
|
gap,
|
|
7442
8686
|
tool(import_lucide_react5.Bold, t.bold, () => editor.chain().focus().toggleBold().run(), state.bold),
|
|
7443
8687
|
tool(import_lucide_react5.Italic, t.italic, () => editor.chain().focus().toggleItalic().run(), state.italic),
|
|
7444
|
-
docx2
|
|
7445
|
-
tool(import_lucide_react5.Strikethrough, t.strike, () => editor.chain().focus().toggleStrike().run(), state.strike),
|
|
8688
|
+
docx2 ? tool(import_lucide_react5.Underline, t.underline, () => editor.chain().focus().toggleUnderline().run(), state.underline) : tool(import_lucide_react5.Strikethrough, t.strike, () => editor.chain().focus().toggleStrike().run(), state.strike),
|
|
7446
8689
|
!docx2 && tool(import_lucide_react5.Code, t.code, () => editor.chain().focus().toggleCode().run(), state.code),
|
|
7447
8690
|
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7448
8691
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "color", "aria-label": t.textColour, title: t.textColour, onClick: () => pick("color"), children: [
|
|
@@ -7451,60 +8694,34 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7451
8694
|
] }),
|
|
7452
8695
|
pop === "color" && swatches(inks, state.color, (c) => c ? editor.chain().focus().setColor(c).run() : editor.chain().focus().unsetColor().run(), t.automatic)
|
|
7453
8696
|
] }),
|
|
7454
|
-
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7455
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "mark", "aria-pressed": state.glow, "aria-label": t.highlight, title: t.highlight, onClick: () => pick("mark"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Highlighter, { "aria-hidden": true }) }),
|
|
7456
|
-
pop === "mark" && swatches(glows, null, (c) => c ? editor.chain().focus().setHighlight({ color: c }).run() : editor.chain().focus().unsetHighlight().run(), t.noColour)
|
|
7457
|
-
] }),
|
|
7458
8697
|
gap,
|
|
8698
|
+
docx2 && aligner,
|
|
7459
8699
|
tool(import_lucide_react5.List, t.bullets, () => editor.chain().focus().toggleBulletList().run(), state.bullets),
|
|
7460
8700
|
tool(import_lucide_react5.ListOrdered, t.numbers, () => editor.chain().focus().toggleOrderedList().run(), state.numbers),
|
|
7461
|
-
tool(import_lucide_react5.ListChecks, t.tasks, () => editor.chain().focus().toggleTaskList().run(), state.tasks),
|
|
7462
|
-
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7463
|
-
gap,
|
|
7464
|
-
[[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"]].map(([icon, label, value3], i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react10.Fragment, { children: tool(icon, label, () => align2(editor, value3), state.align === value3) }, i))
|
|
7465
|
-
] }),
|
|
8701
|
+
!docx2 && tool(import_lucide_react5.ListChecks, t.tasks, () => editor.chain().focus().toggleTaskList().run(), state.tasks),
|
|
7466
8702
|
gap,
|
|
7467
|
-
tool(import_lucide_react5.ListIndentDecrease, t.outdent, () => indent(editor, -1)),
|
|
7468
|
-
tool(import_lucide_react5.ListIndentIncrease, t.indent, () => indent(editor, 1)),
|
|
7469
|
-
tool(import_lucide_react5.RemoveFormatting, t.clearFormat, () => clear(editor))
|
|
7470
|
-
] });
|
|
7471
|
-
else if (shown === "insert") tools = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7472
8703
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7473
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "
|
|
7474
|
-
pop === "
|
|
7475
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
);
|
|
7492
|
-
}) }),
|
|
7493
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: grid3.rows ? `${grid3.rows} \xD7 ${grid3.cols}` : t.table })
|
|
8704
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "link", "aria-pressed": state.link, "aria-label": t.link, title: t.link, onClick: () => pop === "link" ? setPop(null) : linkUp(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Link, { "aria-hidden": true }) }),
|
|
8705
|
+
pop === "link" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-pop w100n-text-form", children: [
|
|
8706
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { autoFocus: true, value: href, placeholder: t.linkAddress, "aria-label": t.linkAddress, onChange: (e) => setHref(e.target.value), onKeyDown: (e) => {
|
|
8707
|
+
if (e.key === "Enter") putLink();
|
|
8708
|
+
} }),
|
|
8709
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-docs-row", children: [
|
|
8710
|
+
state.link && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-pdf-link", onClick: () => {
|
|
8711
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
8712
|
+
setPop(null);
|
|
8713
|
+
}, children: [
|
|
8714
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Link2Off, { "aria-hidden": true }),
|
|
8715
|
+
t.unlink
|
|
8716
|
+
] }),
|
|
8717
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !href.trim(), onClick: putLink, children: [
|
|
8718
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Link, { "aria-hidden": true }),
|
|
8719
|
+
t.apply
|
|
8720
|
+
] })
|
|
8721
|
+
] })
|
|
7494
8722
|
] })
|
|
7495
8723
|
] }),
|
|
7496
|
-
|
|
7497
|
-
tool(import_lucide_react5.BetweenHorizontalStart, t.rowAbove, () => editor.chain().focus().addRowBefore().run()),
|
|
7498
|
-
tool(import_lucide_react5.BetweenHorizontalEnd, t.rowBelow, () => editor.chain().focus().addRowAfter().run()),
|
|
7499
|
-
tool(import_lucide_react5.BetweenVerticalStart, t.columnLeft, () => editor.chain().focus().addColumnBefore().run()),
|
|
7500
|
-
tool(import_lucide_react5.BetweenVerticalEnd, t.columnRight, () => editor.chain().focus().addColumnAfter().run()),
|
|
7501
|
-
tool(import_lucide_react5.PanelTop, t.headerRow, () => editor.chain().focus().toggleHeaderRow().run()),
|
|
7502
|
-
docx2 && tool(import_lucide_react5.TableCellsMerge, t.mergeCells, () => editor.chain().focus().mergeOrSplit().run()),
|
|
7503
|
-
tool(import_lucide_react5.TableRowsSplit, t.deleteRow, () => editor.chain().focus().deleteRow().run()),
|
|
7504
|
-
tool(import_lucide_react5.TableColumnsSplit, t.deleteColumn, () => editor.chain().focus().deleteColumn().run()),
|
|
7505
|
-
tool(import_lucide_react5.Trash2, t.deleteTable, () => editor.chain().focus().deleteTable().run())
|
|
7506
|
-
] }),
|
|
7507
|
-
gap,
|
|
8724
|
+
can.comment && tool(import_lucide_react5.MessageSquarePlus, t.addComment, begin, void 0, state.empty),
|
|
7508
8725
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7509
8726
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "image", "aria-label": t.image, title: t.image, onClick: () => {
|
|
7510
8727
|
setHref("");
|
|
@@ -7531,14 +8748,14 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7531
8748
|
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-pdf-link", children: [
|
|
7532
8749
|
t.chooseFile,
|
|
7533
8750
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "file", accept: "image/png,image/jpeg,image/gif", hidden: true, onChange: (e) => {
|
|
7534
|
-
const
|
|
7535
|
-
if (!
|
|
8751
|
+
const file2 = e.target.files?.[0];
|
|
8752
|
+
if (!file2) return;
|
|
7536
8753
|
const reader = new FileReader();
|
|
7537
8754
|
reader.onload = () => {
|
|
7538
|
-
editor.chain().focus().setImage({ src: String(reader.result), alt:
|
|
8755
|
+
editor.chain().focus().setImage({ src: String(reader.result), alt: file2.name }).run();
|
|
7539
8756
|
setPop(null);
|
|
7540
8757
|
};
|
|
7541
|
-
reader.readAsDataURL(
|
|
8758
|
+
reader.readAsDataURL(file2);
|
|
7542
8759
|
} })
|
|
7543
8760
|
] }),
|
|
7544
8761
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !href.trim(), onClick: () => {
|
|
@@ -7552,162 +8769,321 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7552
8769
|
] })
|
|
7553
8770
|
] }),
|
|
7554
8771
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
7555
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "
|
|
7556
|
-
pop === "
|
|
7557
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
8772
|
+
/* @__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 }) }),
|
|
8773
|
+
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: [
|
|
8774
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: Array.from({ length: 48 }, (_, i) => {
|
|
8775
|
+
const rows = Math.floor(i / 8) + 1;
|
|
8776
|
+
const cols = i % 8 + 1;
|
|
8777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
8778
|
+
"button",
|
|
8779
|
+
{
|
|
8780
|
+
type: "button",
|
|
8781
|
+
"aria-label": `${rows} \xD7 ${cols}`,
|
|
8782
|
+
"data-on": rows <= grid3.rows && cols <= grid3.cols,
|
|
8783
|
+
onPointerEnter: () => setGrid({ rows, cols }),
|
|
8784
|
+
onClick: () => {
|
|
8785
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
8786
|
+
setPop(null);
|
|
8787
|
+
}
|
|
8788
|
+
},
|
|
8789
|
+
i
|
|
8790
|
+
);
|
|
8791
|
+
}) }),
|
|
8792
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: grid3.rows ? `${grid3.rows} \xD7 ${grid3.cols}` : t.table })
|
|
7573
8793
|
] })
|
|
7574
8794
|
] }),
|
|
7575
|
-
docx2 && tool(import_lucide_react5.SeparatorHorizontal, t.pageBreak, () => editor.chain().focus().insertContent({ type: "pageBreak" }).run()),
|
|
7576
|
-
tool(import_lucide_react5.Minus, t.rule, () => editor.chain().focus().setHorizontalRule().run())
|
|
7577
|
-
] });
|
|
7578
|
-
else if (shown === "layout") tools = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7579
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-label", children: t.pageSize }),
|
|
7580
|
-
[["A4", a4], ["Letter", letter]].map(([label, size2], i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7581
|
-
"button",
|
|
7582
|
-
{
|
|
7583
|
-
type: "button",
|
|
7584
|
-
className: "w100n-text-word",
|
|
7585
|
-
"aria-pressed": Math.abs(page.width - size2.width) < 2 && Math.abs(page.height - size2.height) < 2,
|
|
7586
|
-
onClick: () => setLayout({ ...page, width: size2.width, height: size2.height }),
|
|
7587
|
-
children: label
|
|
7588
|
-
},
|
|
7589
|
-
i
|
|
7590
|
-
)),
|
|
7591
8795
|
gap,
|
|
7592
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
{
|
|
7596
|
-
|
|
7597
|
-
className: "w100n-text-word",
|
|
7598
|
-
"aria-pressed": values.every((v, n) => Math.abs(page.margins[n] - v) < 2),
|
|
7599
|
-
onClick: () => setLayout({ ...page, margins: values }),
|
|
7600
|
-
children: label
|
|
7601
|
-
},
|
|
7602
|
-
i
|
|
7603
|
-
))
|
|
7604
|
-
] });
|
|
7605
|
-
else if (shown === "refs") tools = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7606
|
-
state.toc < 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", onClick: () => {
|
|
7607
|
-
const at = editor.state.selection.$from.before(1);
|
|
7608
|
-
editor.chain().focus().insertContentAt(at, { type: "toc", attrs: { entries: JSON.stringify(entries(editor.state.doc, !docx2, at - 1)) } }).run();
|
|
7609
|
-
}, children: [
|
|
7610
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.TableOfContents, { "aria-hidden": true }),
|
|
7611
|
-
t.tocInsert
|
|
7612
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7613
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-word", onClick: () => editor.view.nodeDOM(state.toc)?.scrollIntoView({ behavior: "smooth", block: "start" }), children: [
|
|
7614
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.TableOfContents, { "aria-hidden": true }),
|
|
7615
|
-
t.tocGo
|
|
7616
|
-
] }),
|
|
7617
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "red", onClick: () => editor.chain().focus().deleteRange({ from: state.toc, to: state.toc + editor.state.doc.nodeAt(state.toc).nodeSize }).run(), children: [
|
|
7618
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Trash2, { "aria-hidden": true }),
|
|
7619
|
-
t.tocRemove
|
|
7620
|
-
] })
|
|
7621
|
-
] }),
|
|
7622
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-label", children: t.tocHint })
|
|
7623
|
-
] });
|
|
7624
|
-
else if (shown === "review") tools = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7625
|
-
can.comment && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: state.empty, onClick: begin, children: [
|
|
7626
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.MessageSquarePlus, { "aria-hidden": true }),
|
|
7627
|
-
t.addComment
|
|
8796
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-expanded": more, "aria-label": more ? t.fewerTools : t.moreTools, title: more ? t.fewerTools : t.moreTools, onClick: widen, children: more ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronDown, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ChevronUp, { "aria-hidden": true }) })
|
|
8797
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8798
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-word", onClick: () => onPanel?.("outline"), children: [
|
|
8799
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.ListTree, { "aria-hidden": true }),
|
|
8800
|
+
t.outline
|
|
7628
8801
|
] }),
|
|
7629
|
-
|
|
7630
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
7631
|
-
|
|
7632
|
-
{
|
|
7633
|
-
|
|
7634
|
-
className: "w100n-text-word",
|
|
7635
|
-
"aria-pressed": state.suggest,
|
|
7636
|
-
onClick: () => editor.view.dispatch(editor.state.tr.setMeta(suggesting, { on: !state.suggest, me: host?.me.name ?? "" })),
|
|
7637
|
-
children: [
|
|
7638
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.FilePenLine, { "aria-hidden": true }),
|
|
7639
|
-
t.suggest
|
|
7640
|
-
]
|
|
7641
|
-
}
|
|
7642
|
-
),
|
|
7643
|
-
state.revs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7644
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "green", onClick: () => decide(editor, true), children: [
|
|
7645
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.CheckCheck, { "aria-hidden": true }),
|
|
7646
|
-
t.acceptAll
|
|
7647
|
-
] }),
|
|
7648
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", "data-tone": "red", onClick: () => decide(editor, false), children: [
|
|
7649
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.X, { "aria-hidden": true }),
|
|
7650
|
-
t.rejectAll
|
|
7651
|
-
] })
|
|
8802
|
+
can.comment && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-grow" }),
|
|
8804
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: state.empty, onClick: begin, children: [
|
|
8805
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.MessageSquarePlus, { "aria-hidden": true }),
|
|
8806
|
+
t.addComment
|
|
7652
8807
|
] })
|
|
7653
8808
|
] }),
|
|
7654
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-word", onClick: () => onPanel?.("comments"), children: [
|
|
8809
|
+
!!host?.comments && (can.comment || open.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-word", onClick: () => onPanel?.("comments"), children: [
|
|
7655
8810
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.MessagesSquare, { "aria-hidden": true }),
|
|
7656
8811
|
t.comments,
|
|
7657
8812
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: open.length })
|
|
7658
8813
|
] })
|
|
7659
8814
|
] });
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
8815
|
+
const extra = can.edit && more && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8816
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8817
|
+
fontPicker,
|
|
8818
|
+
sizePicker,
|
|
8819
|
+
gap
|
|
7665
8820
|
] }),
|
|
7666
|
-
tool(import_lucide_react5.
|
|
7667
|
-
docx2 && tool(import_lucide_react5.
|
|
7668
|
-
tool(import_lucide_react5.
|
|
8821
|
+
docx2 && tool(import_lucide_react5.Strikethrough, t.strike, () => editor.chain().focus().toggleStrike().run(), state.strike),
|
|
8822
|
+
docx2 && tool(import_lucide_react5.Superscript, t.superscript, () => editor.chain().focus().toggleMark("superscript").run(), state.sup),
|
|
8823
|
+
docx2 && tool(import_lucide_react5.Subscript, t.subscript, () => editor.chain().focus().toggleMark("subscript").run(), state.sub),
|
|
8824
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8825
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "mark", "aria-pressed": state.glow, "aria-label": t.highlight, title: t.highlight, onClick: () => pick("mark"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Highlighter, { "aria-hidden": true }) }),
|
|
8826
|
+
pop === "mark" && swatches(glows, null, (c) => c ? editor.chain().focus().setHighlight({ color: c }).run() : editor.chain().focus().unsetHighlight().run(), t.noColour)
|
|
8827
|
+
] }),
|
|
8828
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8829
|
+
gap,
|
|
8830
|
+
spacer
|
|
8831
|
+
] }),
|
|
8832
|
+
tool(import_lucide_react5.ListIndentDecrease, t.outdent, () => indent(editor, -1)),
|
|
8833
|
+
tool(import_lucide_react5.ListIndentIncrease, t.indent, () => indent(editor, 1)),
|
|
8834
|
+
docx2 && tool(import_lucide_react5.ListChecks, t.tasks, () => editor.chain().focus().toggleTaskList().run(), state.tasks),
|
|
7669
8835
|
gap,
|
|
7670
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
7671
|
-
|
|
7672
|
-
|
|
8836
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": t.painter, title: paint2 ? t.painterHint : t.painter, "aria-pressed": !!paint2, onClick: () => take(false), onDoubleClick: () => take(true), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.PaintRoller, { "aria-hidden": true }) }),
|
|
8837
|
+
tool(import_lucide_react5.RemoveFormatting, t.clearFormat, () => clear(editor)),
|
|
8838
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8839
|
+
gap,
|
|
8840
|
+
tool(import_lucide_react5.FilePenLine, t.suggest, suggest, state.suggest)
|
|
7673
8841
|
] })
|
|
7674
8842
|
] });
|
|
7675
|
-
const
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
live && (live.ready ? !live.online : live.late || live.denied) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-live", title: live.denied ? void 0 : t.offlineHint, children: [
|
|
7687
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.WifiOff, { "aria-hidden": true }),
|
|
7688
|
-
live.denied ? t.liveOff : t.offline
|
|
7689
|
-
] }),
|
|
7690
|
-
live && live.people.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-people", role: "group", "aria-label": t.people, children: live.people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsx)("img", { src: p.avatarUrl, alt: "" }) : p.name.slice(0, 1).toUpperCase() }, p.id)) }),
|
|
7691
|
-
state.suggest && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-badge", children: t.suggesting }),
|
|
7692
|
-
can.edit && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
7693
|
-
tool(import_lucide_react5.Undo2, t.undo, () => editor.chain().focus().undo().run(), void 0, !state.undo),
|
|
7694
|
-
tool(import_lucide_react5.Redo2, t.redo, () => editor.chain().focus().redo().run(), void 0, !state.redo),
|
|
7695
|
-
saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-muted", children: t.saveFailed }),
|
|
7696
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: !dirty || saving === "busy" || !!live && !live.online, onClick: () => void save2(), children: [
|
|
7697
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Save, { "aria-hidden": true }),
|
|
7698
|
-
saving === "busy" ? t.saving : !dirty && saving === "done" ? t.saved : t.save
|
|
7699
|
-
] })
|
|
7700
|
-
] })
|
|
7701
|
-
] })
|
|
8843
|
+
const context = can.edit && (state.table ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8844
|
+
tool(import_lucide_react5.BetweenHorizontalStart, t.rowAbove, () => editor.chain().focus().addRowBefore().run()),
|
|
8845
|
+
tool(import_lucide_react5.BetweenHorizontalEnd, t.rowBelow, () => editor.chain().focus().addRowAfter().run()),
|
|
8846
|
+
tool(import_lucide_react5.BetweenVerticalStart, t.columnLeft, () => editor.chain().focus().addColumnBefore().run()),
|
|
8847
|
+
tool(import_lucide_react5.BetweenVerticalEnd, t.columnRight, () => editor.chain().focus().addColumnAfter().run()),
|
|
8848
|
+
tool(import_lucide_react5.PanelTop, t.headerRow, () => editor.chain().focus().toggleHeaderRow().run()),
|
|
8849
|
+
docx2 && tool(import_lucide_react5.TableCellsMerge, t.mergeCells, () => editor.chain().focus().mergeOrSplit().run()),
|
|
8850
|
+
docx2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-anchor", children: [
|
|
8851
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", "data-pop": true, "aria-expanded": pop === "fill", "aria-label": t.cellFill, title: t.cellFill, onClick: () => pick("fill"), children: [
|
|
8852
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.PaintBucket, { "aria-hidden": true }),
|
|
8853
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: "w100n-text-bar", style: { background: state.fill ?? "transparent" } })
|
|
7702
8854
|
] }),
|
|
7703
|
-
|
|
8855
|
+
pop === "fill" && swatches(glows, state.fill, (c) => editor.chain().focus().setCellAttribute("background", c).run(), t.noColour)
|
|
8856
|
+
] }),
|
|
8857
|
+
docx2 && tool(import_lucide_react5.Grid3x3, t.tableBorders, () => editor.chain().focus().updateAttributes("table", { borders: state.bare ? null : "none" }).run(), !state.bare),
|
|
8858
|
+
tool(import_lucide_react5.TableRowsSplit, t.deleteRow, () => editor.chain().focus().deleteRow().run()),
|
|
8859
|
+
tool(import_lucide_react5.TableColumnsSplit, t.deleteColumn, () => editor.chain().focus().deleteColumn().run()),
|
|
8860
|
+
tool(import_lucide_react5.Trash2, t.deleteTable, () => editor.chain().focus().deleteTable().run())
|
|
8861
|
+
] }) : state.img && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: [[import_lucide_react5.Image, t.wrapInline, "inline"], [import_lucide_react5.PanelLeft, t.wrapLeft, "left"], [import_lucide_react5.PanelRight, t.wrapRight, "right"]].map(([icon, label, value3]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react10.Fragment, { children: tool(icon, label, () => editor.chain().focus().updateAttributes("image", { wrap: value3 === "inline" ? null : value3 }).run(), state.img === value3) }, value3)) }));
|
|
8862
|
+
const status = (can.edit || live) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-end", children: [
|
|
8863
|
+
live && (live.ready ? !live.online : live.late || live.denied) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-text-live", title: live.denied ? void 0 : t.offlineHint, children: [
|
|
8864
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.WifiOff, { "aria-hidden": true }),
|
|
8865
|
+
live.denied ? t.liveOff : t.offline
|
|
8866
|
+
] }),
|
|
8867
|
+
state.suggest && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-badge", children: t.suggesting }),
|
|
8868
|
+
can.edit && saving === "failed" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-text-saved", title: `${t.save} (${mod}S)`, onClick: () => void save2(), children: [
|
|
8869
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.CloudAlert, { "aria-hidden": true }),
|
|
8870
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.saveFailed })
|
|
8871
|
+
] }),
|
|
8872
|
+
live && live.people.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-people", role: "group", "aria-label": t.people, children: live.people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsx)("img", { src: p.avatarUrl, alt: "" }) : p.name.split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase() }, p.id)) })
|
|
8873
|
+
] });
|
|
8874
|
+
const menubar = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-text-menus", role: "menubar", "aria-label": t.textTools, children: menus.filter(([, , list]) => list.some((x) => x && x !== "-")).map(menu) });
|
|
8875
|
+
const keep = (e) => {
|
|
8876
|
+
if (e.target.closest("button")) e.preventDefault();
|
|
8877
|
+
};
|
|
8878
|
+
const sheet2 = docx2 ? { "--page-w": `${page.width}px`, "--page-h": `${page.height}px`, "--mt": `${page.margins[0]}px`, "--mr": `${page.margins[1]}px`, "--mb": `${page.margins[2]}px`, "--ml": `${page.margins[3]}px` } : void 0;
|
|
8879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: root, className: "w100n-text", "data-kind": kind, "data-docs-find": true, onKeyDown: keys2, children: [
|
|
8880
|
+
head2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8881
|
+
head2.menus && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-ribbon w100n-text-docbar", onKeyDown: rove, onPointerDown: keep, children: menubar }), head2.menus),
|
|
8882
|
+
head2.status && status && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-ribbon w100n-text-docbar", onPointerDown: keep, children: status }), head2.status)
|
|
8883
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-ribbon w100n-text-top", onKeyDown: rove, onPointerDown: keep, children: [
|
|
8884
|
+
menubar,
|
|
8885
|
+
status
|
|
7704
8886
|
] }),
|
|
7705
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", onClick: (e) => {
|
|
8887
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: scroller, className: "w100n-text-scroll", "data-paint": !!paint2, onMouseUp: lay, onClick: (e) => {
|
|
8888
|
+
const atom = can.edit ? e.target.closest(".w100n-math, sup[data-footnote]") : null;
|
|
8889
|
+
if (atom) {
|
|
8890
|
+
const at = editor.view.posAtDOM(atom, 0);
|
|
8891
|
+
const node = editor.state.doc.nodeAt(at);
|
|
8892
|
+
if (node?.type.name === "math") setDialog({ kind: "formula", latex: node.attrs.latex, at });
|
|
8893
|
+
if (node?.type.name === "footnote") setDialog({ kind: "note", text: node.attrs.text, at });
|
|
8894
|
+
return;
|
|
8895
|
+
}
|
|
7706
8896
|
const id = e.target.closest("[data-note]")?.getAttribute("data-note");
|
|
7707
8897
|
if (!id) return;
|
|
7708
8898
|
setActive(id);
|
|
7709
8899
|
onPanel?.("comments");
|
|
7710
8900
|
}, 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" : "w100n-docs-page w100n-text-column", style: sheet2, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.EditorContent, { editor }) }) }) }),
|
|
8901
|
+
/* @__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: [
|
|
8902
|
+
tool(import_lucide_react5.Minus, t.zoomOut, () => zoomBy(-10)),
|
|
8903
|
+
zoomer,
|
|
8904
|
+
tool(import_lucide_react5.Plus, t.zoomIn, () => zoomBy(10))
|
|
8905
|
+
] }) }),
|
|
8906
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-ribbon w100n-text-island", role: "toolbar", "aria-label": t.textTools, onKeyDown: rove, onPointerDown: keep, children: [
|
|
8907
|
+
context && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-tools", role: "group", "aria-label": state.table ? t.table : t.image, children: context }),
|
|
8908
|
+
extra && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-tools", role: "group", "aria-label": t.moreTools, children: extra }),
|
|
8909
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-tools", role: "group", "aria-label": t.textTools, children: main })
|
|
8910
|
+
] }),
|
|
8911
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-text-ribbon w100n-text-corner", "data-side": "right", onPointerDown: keep, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-tools", role: "group", "aria-label": t.findReplace, children: [
|
|
8912
|
+
can.edit && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
8913
|
+
tool(import_lucide_react5.Undo2, t.undo, () => editor.chain().focus().undo().run(), void 0, !state.undo),
|
|
8914
|
+
tool(import_lucide_react5.Redo2, t.redo, () => editor.chain().focus().redo().run(), void 0, !state.redo),
|
|
8915
|
+
gap
|
|
8916
|
+
] }),
|
|
8917
|
+
finder
|
|
8918
|
+
] }) }),
|
|
8919
|
+
dialog && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-pdf-back", onKeyDown: (e) => {
|
|
8920
|
+
if (e.key === "Escape") {
|
|
8921
|
+
e.stopPropagation();
|
|
8922
|
+
setDialog(null);
|
|
8923
|
+
}
|
|
8924
|
+
}, children: dialog.kind === "symbol" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-pdf-dialog w100n-insert", role: "dialog", "aria-modal": true, "aria-label": t.symbols, children: [
|
|
8925
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
8926
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-new-tile", "data-tone": "pink", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Omega, { "aria-hidden": true }) }),
|
|
8927
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.symbols }),
|
|
8928
|
+
/* @__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 }) })
|
|
8929
|
+
] }),
|
|
8930
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
|
|
8931
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Search, { "aria-hidden": true }),
|
|
8932
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { autoFocus: true, value: dialog.query, placeholder: t.symbolSearch, "aria-label": t.symbolSearch, onChange: (e) => setDialog({ kind: "symbol", query: e.target.value }) })
|
|
8933
|
+
] }),
|
|
8934
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-insert-grid", role: "group", "aria-label": t.symbols, children: symbols.filter(([ch, name]) => !dialog.query.trim() || name.includes(dialog.query.trim().toLowerCase()) || ch === dialog.query.trim()).map(([ch, name]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": name, title: name, onClick: () => {
|
|
8935
|
+
editor.chain().focus().insertContent(ch).run();
|
|
8936
|
+
setDialog(null);
|
|
8937
|
+
}, children: ch }, ch)) })
|
|
8938
|
+
] }) : dialog.kind === "formula" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "w100n-pdf-dialog w100n-insert", role: "dialog", "aria-modal": true, "aria-label": t.formula, onSubmit: (e) => {
|
|
8939
|
+
e.preventDefault();
|
|
8940
|
+
const latex = dialog.latex.trim();
|
|
8941
|
+
if (!latex) return;
|
|
8942
|
+
if (dialog.at !== null) editor.chain().focus().command(({ tr }) => {
|
|
8943
|
+
tr.setNodeMarkup(dialog.at, void 0, { latex });
|
|
8944
|
+
return true;
|
|
8945
|
+
}).run();
|
|
8946
|
+
else editor.chain().focus().insertContent({ type: "math", attrs: { latex } }).run();
|
|
8947
|
+
setDialog(null);
|
|
8948
|
+
}, children: [
|
|
8949
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
8950
|
+
/* @__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 }) }),
|
|
8951
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.formula }),
|
|
8952
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-docs-badge", children: t.formulaHint }),
|
|
8953
|
+
/* @__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 }) })
|
|
8954
|
+
] }),
|
|
8955
|
+
/* @__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 }) }),
|
|
8956
|
+
/* @__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: () => {
|
|
8957
|
+
const el = field.current;
|
|
8958
|
+
const at = el.selectionStart ?? dialog.latex.length;
|
|
8959
|
+
const latex = dialog.latex.slice(0, at) + code + dialog.latex.slice(el.selectionEnd ?? at);
|
|
8960
|
+
setDialog({ ...dialog, latex });
|
|
8961
|
+
const caret = at + (code.indexOf("{}") >= 0 ? code.indexOf("{}") + 1 : code.length);
|
|
8962
|
+
requestAnimationFrame(() => {
|
|
8963
|
+
el.focus();
|
|
8964
|
+
el.setSelectionRange(caret, caret);
|
|
8965
|
+
});
|
|
8966
|
+
}, children: label }, label)) }),
|
|
8967
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-insert-preview", "aria-live": "polite", dangerouslySetInnerHTML: { __html: dialog.latex.trim() ? mathml(dialog.latex) : "" } }),
|
|
8968
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
|
|
8969
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setDialog(null), children: t.cancel }),
|
|
8970
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "submit", className: "w100n-docs-action", disabled: !dialog.latex.trim(), children: [
|
|
8971
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
8972
|
+
dialog.at !== null ? t.update : t.put
|
|
8973
|
+
] })
|
|
8974
|
+
] })
|
|
8975
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "w100n-pdf-dialog w100n-insert", role: "dialog", "aria-modal": true, "aria-label": t.footnote, onSubmit: (e) => {
|
|
8976
|
+
e.preventDefault();
|
|
8977
|
+
const text = dialog.text.trim();
|
|
8978
|
+
if (!text) return;
|
|
8979
|
+
if (dialog.at !== null) editor.chain().focus().command(({ tr }) => {
|
|
8980
|
+
tr.setNodeAttribute(dialog.at, "text", text);
|
|
8981
|
+
return true;
|
|
8982
|
+
}).run();
|
|
8983
|
+
else editor.chain().focus().insertContent({ type: "footnote", attrs: { id: null, text } }).run();
|
|
8984
|
+
setDialog(null);
|
|
8985
|
+
}, children: [
|
|
8986
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
8987
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-new-tile", "data-tone": "violet", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Superscript, { "aria-hidden": true }) }),
|
|
8988
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.footnote }),
|
|
8989
|
+
/* @__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 }) })
|
|
8990
|
+
] }),
|
|
8991
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
8992
|
+
"textarea",
|
|
8993
|
+
{
|
|
8994
|
+
autoFocus: true,
|
|
8995
|
+
className: "w100n-insert-note",
|
|
8996
|
+
value: dialog.text,
|
|
8997
|
+
"aria-label": t.footnoteText,
|
|
8998
|
+
placeholder: t.footnoteText,
|
|
8999
|
+
onChange: (e) => setDialog({ ...dialog, text: e.target.value }),
|
|
9000
|
+
onKeyDown: (e) => {
|
|
9001
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) e.currentTarget.form?.requestSubmit();
|
|
9002
|
+
}
|
|
9003
|
+
}
|
|
9004
|
+
),
|
|
9005
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "w100n-pdf-dialog-end", children: [
|
|
9006
|
+
dialog.at !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => {
|
|
9007
|
+
editor.chain().focus().deleteRange({ from: dialog.at, to: dialog.at + 1 }).run();
|
|
9008
|
+
setDialog(null);
|
|
9009
|
+
}, children: t.removeFootnote }),
|
|
9010
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setDialog(null), children: t.cancel }),
|
|
9011
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "submit", className: "w100n-docs-action", disabled: !dialog.text.trim(), children: [
|
|
9012
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
9013
|
+
dialog.at !== null ? t.update : t.put
|
|
9014
|
+
] })
|
|
9015
|
+
] })
|
|
9016
|
+
] }) }),
|
|
9017
|
+
draft2 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-pdf-back", onKeyDown: (e) => {
|
|
9018
|
+
if (e.key === "Escape") {
|
|
9019
|
+
e.stopPropagation();
|
|
9020
|
+
setDraft2(null);
|
|
9021
|
+
}
|
|
9022
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "w100n-pdf-dialog w100n-setup", role: "dialog", "aria-modal": true, "aria-label": t.pageSetup, onSubmit: (e) => {
|
|
9023
|
+
e.preventDefault();
|
|
9024
|
+
applySetup();
|
|
9025
|
+
}, children: [
|
|
9026
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-new-head", children: [
|
|
9027
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w100n-new-tile", "data-tone": "blue", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Ruler, { "aria-hidden": true }) }),
|
|
9028
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { className: "w100n-pdf-dialog-title", children: t.pageSetup }),
|
|
9029
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => setDraft2(null), "aria-label": t.close, title: t.close, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.X, { "aria-hidden": true }) })
|
|
9030
|
+
] }),
|
|
9031
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "w100n-docs-caption", children: t.pageSize }),
|
|
9032
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.pageSize, children: [["A4", a4], ["Letter", letter], ["Legal", legal]].map(([label, size2]) => {
|
|
9033
|
+
const land = draft2.width > draft2.height;
|
|
9034
|
+
const on2 = Math.abs(Math.min(draft2.width, draft2.height) - size2.width) < 2 && Math.abs(Math.max(draft2.width, draft2.height) - size2.height) < 2;
|
|
9035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-pressed": on2, onClick: () => setDraft2({ ...draft2, width: land ? size2.height : size2.width, height: land ? size2.width : size2.height }), children: label }, label);
|
|
9036
|
+
}) }),
|
|
9037
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "w100n-docs-caption", children: t.orientation }),
|
|
9038
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.orientation, children: [[false, t.portrait], [true, t.landscape]].map(([land, label]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9039
|
+
"button",
|
|
9040
|
+
{
|
|
9041
|
+
type: "button",
|
|
9042
|
+
"aria-pressed": draft2.width > draft2.height === land,
|
|
9043
|
+
onClick: () => {
|
|
9044
|
+
if (draft2.width > draft2.height !== land) setDraft2({ ...draft2, width: draft2.height, height: draft2.width });
|
|
9045
|
+
},
|
|
9046
|
+
children: label
|
|
9047
|
+
},
|
|
9048
|
+
label
|
|
9049
|
+
)) }),
|
|
9050
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "w100n-docs-caption", children: t.marginsCm }),
|
|
9051
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.margins, children: margins.map(([label, values]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-pressed": values.every((v, n) => Math.abs(cm(v) - draft2.margins[n]) < 0.05), onClick: () => setDraft2({ ...draft2, margins: values.map(cm) }), children: label }, label)) }),
|
|
9052
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w100n-setup-grid", children: [t.mTop, t.mRight, t.mBottom, t.mLeft].map((label, n) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
9053
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: label }),
|
|
9054
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9055
|
+
"input",
|
|
9056
|
+
{
|
|
9057
|
+
className: "w100n-docs-field",
|
|
9058
|
+
type: "number",
|
|
9059
|
+
min: 0,
|
|
9060
|
+
max: 10,
|
|
9061
|
+
step: 0.1,
|
|
9062
|
+
value: draft2.margins[n],
|
|
9063
|
+
onChange: (e) => setDraft2({ ...draft2, margins: draft2.margins.map((v, i) => i === n ? Math.max(0, Math.min(10, Number(e.target.value) || 0)) : v) })
|
|
9064
|
+
}
|
|
9065
|
+
)
|
|
9066
|
+
] }, n)) }),
|
|
9067
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-setup-line", children: [
|
|
9068
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.headerText }),
|
|
9069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { className: "w100n-docs-field", value: draft2.header, onChange: (e) => setDraft2({ ...draft2, header: e.target.value }) })
|
|
9070
|
+
] }),
|
|
9071
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-setup-line", children: [
|
|
9072
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.footerText }),
|
|
9073
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { className: "w100n-docs-field", value: draft2.footer, onChange: (e) => setDraft2({ ...draft2, footer: e.target.value }) })
|
|
9074
|
+
] }),
|
|
9075
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "w100n-setup-check", children: [
|
|
9076
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "checkbox", checked: draft2.numbers, onChange: (e) => setDraft2({ ...draft2, numbers: e.target.checked }) }),
|
|
9077
|
+
t.pageNumbers
|
|
9078
|
+
] }),
|
|
9079
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-pdf-dialog-end", children: [
|
|
9080
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "w100n-pdf-link", onClick: () => setDraft2(null), children: t.cancel }),
|
|
9081
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "w100n-docs-action", onClick: applySetup, children: [
|
|
9082
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Check, { "aria-hidden": true }),
|
|
9083
|
+
t.apply
|
|
9084
|
+
] })
|
|
9085
|
+
] })
|
|
9086
|
+
] }) }),
|
|
7711
9087
|
slot && (0, import_react_dom2.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-notes", children: [
|
|
7712
9088
|
draft && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-card w100n-text-draft", children: [
|
|
7713
9089
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("blockquote", { children: draft.quote }),
|
|
@@ -7777,10 +9153,10 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7777
9153
|
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: [
|
|
7778
9154
|
person(c),
|
|
7779
9155
|
c.quote && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("blockquote", { children: c.quote }),
|
|
7780
|
-
|
|
9156
|
+
words2(c),
|
|
7781
9157
|
all.filter((r) => r.replyTo === c.id).map((r) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", children: [
|
|
7782
9158
|
person(r),
|
|
7783
|
-
|
|
9159
|
+
words2(r)
|
|
7784
9160
|
] }, r.id)),
|
|
7785
9161
|
reply?.id === c.id && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w100n-text-reply", onClick: (e) => e.stopPropagation(), children: [
|
|
7786
9162
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -7819,7 +9195,7 @@ function TextEditor({ kind, bytes, t, language, rights, host, together, document
|
|
|
7819
9195
|
] }), slot)
|
|
7820
9196
|
] });
|
|
7821
9197
|
}
|
|
7822
|
-
var import_react9, import_lucide_react5, import_react10, import_react_dom2, import_jsx_runtime6, inks, glows, uid2;
|
|
9198
|
+
var import_react9, import_lucide_react5, import_react10, import_react_dom2, import_jsx_runtime6, legal, symbols, helpers, cm, inks, glows, faces, sizes, uid2;
|
|
7823
9199
|
var init_TextEditor = __esm({
|
|
7824
9200
|
"src/editor/TextEditor.tsx"() {
|
|
7825
9201
|
"use strict";
|
|
@@ -7834,10 +9210,68 @@ var init_TextEditor = __esm({
|
|
|
7834
9210
|
init_extensions();
|
|
7835
9211
|
init_live();
|
|
7836
9212
|
init_markdown();
|
|
9213
|
+
init_math();
|
|
7837
9214
|
init_pager();
|
|
7838
9215
|
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
9216
|
+
legal = { width: 816, height: 1344 };
|
|
9217
|
+
symbols = [
|
|
9218
|
+
["\xA9", "copyright"],
|
|
9219
|
+
["\xAE", "registered"],
|
|
9220
|
+
["\u2122", "trademark"],
|
|
9221
|
+
["\xA7", "section"],
|
|
9222
|
+
["\xB6", "paragraph"],
|
|
9223
|
+
["\u2020", "dagger"],
|
|
9224
|
+
["\u2021", "double dagger"],
|
|
9225
|
+
["\u2022", "bullet"],
|
|
9226
|
+
["\u2026", "ellipsis"],
|
|
9227
|
+
["\u2030", "per mille"],
|
|
9228
|
+
["\u20AC", "euro"],
|
|
9229
|
+
["\xA3", "pound"],
|
|
9230
|
+
["\xA5", "yen"],
|
|
9231
|
+
["\u20B4", "hryvnia"],
|
|
9232
|
+
["z\u0142", "zloty"],
|
|
9233
|
+
["\xB0", "degree"],
|
|
9234
|
+
["\xB1", "plus minus"],
|
|
9235
|
+
["\xD7", "times multiply"],
|
|
9236
|
+
["\xF7", "divide"],
|
|
9237
|
+
["\u2248", "approximately"],
|
|
9238
|
+
["\u2260", "not equal"],
|
|
9239
|
+
["\u2264", "less or equal"],
|
|
9240
|
+
["\u2265", "greater or equal"],
|
|
9241
|
+
["\u221E", "infinity"],
|
|
9242
|
+
["\u221A", "square root"],
|
|
9243
|
+
["\u2211", "sum"],
|
|
9244
|
+
["\u03C0", "pi"],
|
|
9245
|
+
["\u03A9", "omega"],
|
|
9246
|
+
["\xB5", "micro"],
|
|
9247
|
+
["\u03B1", "alpha"],
|
|
9248
|
+
["\u03B2", "beta"],
|
|
9249
|
+
["\u03B3", "gamma"],
|
|
9250
|
+
["\u0394", "delta"],
|
|
9251
|
+
["\u03BB", "lambda"],
|
|
9252
|
+
["\u2192", "arrow right"],
|
|
9253
|
+
["\u2190", "arrow left"],
|
|
9254
|
+
["\u2191", "arrow up"],
|
|
9255
|
+
["\u2193", "arrow down"],
|
|
9256
|
+
["\u21D2", "arrow implies"],
|
|
9257
|
+
["\u2713", "check tick"],
|
|
9258
|
+
["\u2014", "em dash"],
|
|
9259
|
+
["\u2013", "en dash"],
|
|
9260
|
+
["\xAB", "quote left"],
|
|
9261
|
+
["\xBB", "quote right"],
|
|
9262
|
+
["\u201E", "quote low"],
|
|
9263
|
+
["\u2116", "number"],
|
|
9264
|
+
["\xBD", "half"],
|
|
9265
|
+
["\xBC", "quarter"],
|
|
9266
|
+
["\xB2", "squared"],
|
|
9267
|
+
["\xB3", "cubed"]
|
|
9268
|
+
];
|
|
9269
|
+
helpers = [["x\xB2", "^{2}"], ["x\u2099", "_{n}"], ["\u221Ax", "\\sqrt{}"], ["a/b", "\\frac{}{}"], ["\u2211", "\\sum_{}^{}"], ["\u222B", "\\int "], ["\u03C0", "\\pi "], ["\u2264", "\\le "], ["\u2265", "\\ge "], ["\u2260", "\\ne "], ["\xB1", "\\pm "], ["\xB7", "\\cdot "]];
|
|
9270
|
+
cm = (px2) => Math.round(px2 / 96 * 254) / 100;
|
|
7839
9271
|
inks = ["#0f172a", "#475569", "#dc2626", "#ea580c", "#ca8a04", "#16a34a", "#0891b2", "#2563eb", "#7c3aed", "#db2777"];
|
|
7840
9272
|
glows = ["#fef08a", "#bbf7d0", "#bfdbfe", "#fbcfe8", "#fed7aa", "#ddd6fe"];
|
|
9273
|
+
faces = ["Arial", "Calibri", "Cambria", "Courier New", "Georgia", "Inter", "Roboto", "Times New Roman", "Verdana"];
|
|
9274
|
+
sizes = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 72];
|
|
7841
9275
|
uid2 = () => Math.random().toString(36).slice(2, 10);
|
|
7842
9276
|
}
|
|
7843
9277
|
});
|
|
@@ -7917,7 +9351,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
7917
9351
|
let open = true;
|
|
7918
9352
|
const looks = wb.getStyles();
|
|
7919
9353
|
const commands = injector.get(import_core4.ICommandService);
|
|
7920
|
-
const
|
|
9354
|
+
const run3 = (id, params) => commands.hasCommand(id) && commands.syncExecuteCommand(id, { unitId: unit, ...params }, { fromCollab: true });
|
|
7921
9355
|
const ws = (sid) => wb.getSheetBySheetId(sid);
|
|
7922
9356
|
const at = /* @__PURE__ */ new Map();
|
|
7923
9357
|
const index = (sid) => at.get(sid) ?? at.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);
|
|
@@ -8154,12 +9588,12 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8154
9588
|
const r = rows.get(row2), c = cols.get(col);
|
|
8155
9589
|
if (r !== void 0 && c !== void 0) (cellValue[r] ?? (cellValue[r] = {}))[c] = full(sid, key2, cells.get(key2));
|
|
8156
9590
|
}
|
|
8157
|
-
if (Object.keys(cellValue).length)
|
|
9591
|
+
if (Object.keys(cellValue).length) run3("sheet.mutation.set-range-values", { subUnitId: sid, cellValue, isOverrideStyle: true });
|
|
8158
9592
|
};
|
|
8159
9593
|
const linesTo = (sid, ids, row2) => {
|
|
8160
9594
|
const { rowData, colData } = pieces(sheets.get(sid));
|
|
8161
9595
|
const map = row2 ? index(sid).rows : index(sid).cols;
|
|
8162
|
-
const info = {},
|
|
9596
|
+
const info = {}, sizes2 = {};
|
|
8163
9597
|
const ranges = [];
|
|
8164
9598
|
for (const id of ids) {
|
|
8165
9599
|
const i = map.get(id);
|
|
@@ -8168,16 +9602,16 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8168
9602
|
const s = x?.s ? styles2.get(x.s) : void 0;
|
|
8169
9603
|
info[i] = x ? row2 ? { h: x.h, hd: x.hd, ia: x.ia, s } : { w: x.w, hd: x.hd, s } : null;
|
|
8170
9604
|
const size2 = row2 ? x?.h : x?.w;
|
|
8171
|
-
if (size2 !== void 0)
|
|
9605
|
+
if (size2 !== void 0) sizes2[i] = size2;
|
|
8172
9606
|
ranges.push({ startRow: row2 ? i : 0, endRow: row2 ? i : 0, startColumn: row2 ? 0 : i, endColumn: row2 ? 0 : i });
|
|
8173
9607
|
}
|
|
8174
9608
|
if (!ranges.length) return;
|
|
8175
9609
|
if (row2) {
|
|
8176
|
-
|
|
8177
|
-
|
|
9610
|
+
run3("sheet.mutation.set-row-data", { subUnitId: sid, rowData: info });
|
|
9611
|
+
run3("sheet.mutation.set-worksheet-row-height", { subUnitId: sid, ranges, rowHeight: sizes2 });
|
|
8178
9612
|
} else {
|
|
8179
|
-
|
|
8180
|
-
|
|
9613
|
+
run3("sheet.mutation.set-col-data", { subUnitId: sid, columnData: info });
|
|
9614
|
+
run3("sheet.mutation.set-worksheet-col-width", { subUnitId: sid, ranges, colWidth: sizes2 });
|
|
8181
9615
|
}
|
|
8182
9616
|
};
|
|
8183
9617
|
const mergesTo = (sid) => {
|
|
@@ -8186,16 +9620,16 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8186
9620
|
const want = [...kept.keys()].map((k) => k.split(":")).map(([r0, c0, r1, c1]) => ({ startRow: rows.get(r0), startColumn: cols.get(c0), endRow: rows.get(r1), endColumn: cols.get(c1) })).filter((b) => [b.startRow, b.startColumn, b.endRow, b.endColumn].every((n) => n !== void 0));
|
|
8187
9621
|
const has = ws(sid).getMergeData().map((b) => ({ startRow: b.startRow, startColumn: b.startColumn, endRow: b.endRow, endColumn: b.endColumn }));
|
|
8188
9622
|
const gone = has.filter((b) => !want.some((w) => canon(w) === canon(b))), added = want.filter((w) => !has.some((b) => canon(w) === canon(b)));
|
|
8189
|
-
if (gone.length)
|
|
8190
|
-
if (added.length)
|
|
9623
|
+
if (gone.length) run3("sheet.mutation.remove-worksheet-merge", { subUnitId: sid, ranges: gone });
|
|
9624
|
+
if (added.length) run3("sheet.mutation.add-worksheet-merge", { subUnitId: sid, ranges: added });
|
|
8191
9625
|
};
|
|
8192
9626
|
const notesTo = (sid) => {
|
|
8193
9627
|
const want = notesOf2(sheets.get(sid), lines2[sid]);
|
|
8194
9628
|
const shown = api.getWorkbook(unit).getSheetBySheetId(sid).getNotes();
|
|
8195
|
-
for (const n of shown) if (!want.some((w) => w.row === n.row && w.col === n.col))
|
|
9629
|
+
for (const n of shown) if (!want.some((w) => w.row === n.row && w.col === n.col)) run3("sheet.mutation.remove-note", { sheetId: sid, noteId: n.id, row: n.row, col: n.col });
|
|
8196
9630
|
for (const w of want) {
|
|
8197
9631
|
const n = shown.find((x) => x.row === w.row && x.col === w.col);
|
|
8198
|
-
if (!n || n.note !== w.note || n.width !== w.width || n.height !== w.height)
|
|
9632
|
+
if (!n || n.note !== w.note || n.width !== w.width || n.height !== w.height) run3("sheet.mutation.update-note", { sheetId: sid, row: w.row, col: w.col, note: { note: w.note, width: w.width, height: w.height } });
|
|
8199
9633
|
}
|
|
8200
9634
|
};
|
|
8201
9635
|
const shape3 = () => {
|
|
@@ -8207,7 +9641,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8207
9641
|
const other = want.find((x) => wb.getSheetBySheetId(x));
|
|
8208
9642
|
if (other) api.syncExecuteCommand("sheet.operation.set-worksheet-active", { unitId: unit, subUnitId: other });
|
|
8209
9643
|
}
|
|
8210
|
-
|
|
9644
|
+
run3("sheet.mutation.remove-sheet", { subUnitId: sid });
|
|
8211
9645
|
delete lines2[sid];
|
|
8212
9646
|
at.delete(sid);
|
|
8213
9647
|
}
|
|
@@ -8215,12 +9649,12 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8215
9649
|
if (wb.getSheetBySheetId(sid)) return;
|
|
8216
9650
|
const { rows, cols } = pieces(sheets.get(sid));
|
|
8217
9651
|
lines2[sid] = { rows: rows.toArray(), cols: cols.toArray() };
|
|
8218
|
-
|
|
9652
|
+
run3("sheet.mutation.insert-sheet", { index: Math.min(i, wb.getSheets().length), sheet: (0, import_core4.mergeWorksheetSnapshotWithDefault)(sheetOf(doc, sid, lines2[sid])), styles: styles2.toJSON() });
|
|
8219
9653
|
notesTo(sid);
|
|
8220
9654
|
});
|
|
8221
9655
|
want.forEach((sid, i) => {
|
|
8222
9656
|
const now = wb.getSheetOrders().indexOf(sid);
|
|
8223
|
-
if (now >= 0 && now !== i)
|
|
9657
|
+
if (now >= 0 && now !== i) run3("sheet.mutation.set-worksheet-order", { subUnitId: sid, fromOrder: now, toOrder: i });
|
|
8224
9658
|
});
|
|
8225
9659
|
};
|
|
8226
9660
|
const move2 = (sid, delta, row2) => {
|
|
@@ -8232,15 +9666,15 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8232
9666
|
if (d.retain) i += d.retain;
|
|
8233
9667
|
if (d.delete) {
|
|
8234
9668
|
const end = i + d.delete - 1;
|
|
8235
|
-
if (row2)
|
|
8236
|
-
else
|
|
9669
|
+
if (row2) run3("sheet.mutation.remove-rows", { subUnitId: sid, range: { startRow: i, endRow: end, startColumn: 0, endColumn: lines2[sid].cols.length - 1, rangeType: 1 } });
|
|
9670
|
+
else run3("sheet.mutation.remove-col", { subUnitId: sid, range: { startRow: 0, endRow: lines2[sid].rows.length - 1, startColumn: i, endColumn: end, rangeType: 2 } });
|
|
8237
9671
|
list.splice(i, d.delete);
|
|
8238
9672
|
}
|
|
8239
9673
|
if (d.insert) {
|
|
8240
9674
|
const ids = d.insert;
|
|
8241
9675
|
const end = i + ids.length - 1;
|
|
8242
|
-
if (row2)
|
|
8243
|
-
else
|
|
9676
|
+
if (row2) run3("sheet.mutation.insert-row", { subUnitId: sid, range: { startRow: i, endRow: end, startColumn: 0, endColumn: lines2[sid].cols.length - 1 } });
|
|
9677
|
+
else run3("sheet.mutation.insert-col", { subUnitId: sid, range: { startRow: 0, endRow: lines2[sid].rows.length - 1, startColumn: i, endColumn: end } });
|
|
8244
9678
|
list.splice(i, 0, ...ids);
|
|
8245
9679
|
ids.forEach((id) => added.add(id));
|
|
8246
9680
|
i += ids.length;
|
|
@@ -8286,7 +9720,7 @@ function bind(api, injector, doc, model, edit) {
|
|
|
8286
9720
|
if (s.rows || s.cols) structural = true;
|
|
8287
9721
|
for (const [name, id, key2, empty] of setters) if (s.props.has(name)) {
|
|
8288
9722
|
const v = sheets.get(sid).get(name) ?? empty;
|
|
8289
|
-
|
|
9723
|
+
run3(id, { subUnitId: sid, ...key2 ? { [key2]: v } : v });
|
|
8290
9724
|
}
|
|
8291
9725
|
const keys2 = new Set(s.cells);
|
|
8292
9726
|
if (rows.size || cols.size) {
|
|
@@ -8343,7 +9777,7 @@ __export(grid_exports, {
|
|
|
8343
9777
|
grid: () => grid2,
|
|
8344
9778
|
marks: () => marks
|
|
8345
9779
|
});
|
|
8346
|
-
function grid2(container, language,
|
|
9780
|
+
function grid2(container, language, edit) {
|
|
8347
9781
|
return (0, import_presets.createUniver)({
|
|
8348
9782
|
locale: language === "pl" ? import_presets.LocaleType.PL_PL : import_presets.LocaleType.EN_US,
|
|
8349
9783
|
locales: {
|
|
@@ -8351,7 +9785,7 @@ function grid2(container, language, dark, edit) {
|
|
|
8351
9785
|
[import_presets.LocaleType.PL_PL]: (0, import_presets.mergeLocales)(import_pl_PL.default, import_pl_PL2.default, import_pl_PL3.default, import_pl_PL4.default, import_pl_PL5.default, import_pl_PL6.default)
|
|
8352
9786
|
},
|
|
8353
9787
|
theme: import_presets.purpleTheme,
|
|
8354
|
-
darkMode:
|
|
9788
|
+
darkMode: false,
|
|
8355
9789
|
presets: [
|
|
8356
9790
|
(0, import_preset_sheets_core.UniverSheetsCorePreset)({
|
|
8357
9791
|
container,
|
|
@@ -8432,10 +9866,26 @@ var init_grid = __esm({
|
|
|
8432
9866
|
var SheetView_exports = {};
|
|
8433
9867
|
__export(SheetView_exports, {
|
|
8434
9868
|
SheetView: () => SheetView,
|
|
9869
|
+
autoSum: () => autoSum,
|
|
9870
|
+
decimals: () => decimals,
|
|
8435
9871
|
default: () => SheetView_default,
|
|
8436
9872
|
readSheet: () => readSheet,
|
|
8437
9873
|
writeSheet: () => writeSheet
|
|
8438
9874
|
});
|
|
9875
|
+
function autoSum(r, numeric2) {
|
|
9876
|
+
if (r.startRow !== r.endRow || r.startColumn !== r.endColumn) {
|
|
9877
|
+
return Array.from({ length: r.endColumn - r.startColumn + 1 }, (_, i) => {
|
|
9878
|
+
const col = r.startColumn + i;
|
|
9879
|
+
return { row: r.endRow + 1, col, f: `=SUM(${letters2(col)}${r.startRow + 1}:${letters2(col)}${r.endRow + 1})` };
|
|
9880
|
+
});
|
|
9881
|
+
}
|
|
9882
|
+
let top = r.startRow;
|
|
9883
|
+
while (top > 0 && numeric2(top - 1, r.startColumn)) top--;
|
|
9884
|
+
if (top < r.startRow) return [{ row: r.startRow, col: r.startColumn, f: `=SUM(${letters2(r.startColumn)}${top + 1}:${letters2(r.startColumn)}${r.startRow})` }];
|
|
9885
|
+
let left = r.startColumn;
|
|
9886
|
+
while (left > 0 && numeric2(r.startRow, left - 1)) left--;
|
|
9887
|
+
return left < r.startColumn ? [{ row: r.startRow, col: r.startColumn, f: `=SUM(${letters2(left)}${r.startRow + 1}:${letters2(r.startColumn - 1)}${r.startRow + 1})` }] : [];
|
|
9888
|
+
}
|
|
8439
9889
|
function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSaveRequest, guard, host, together, documentId = "", onSaved }) {
|
|
8440
9890
|
const t = sheetTexts[language];
|
|
8441
9891
|
const box2 = (0, import_react11.useRef)(null);
|
|
@@ -8480,7 +9930,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8480
9930
|
if (kind === "csv") model.book.sheets.s1.name = name.replace(/\.[^.]+$/, "") || "Sheet1";
|
|
8481
9931
|
const host2 = box2.current.appendChild(document.createElement("div"));
|
|
8482
9932
|
host2.className = "w100n-sheet-host";
|
|
8483
|
-
const view = grid3(host2, language,
|
|
9933
|
+
const view = grid3(host2, language, edit);
|
|
8484
9934
|
const { univer, univerAPI: api2 } = view;
|
|
8485
9935
|
const wb = api2.createWorkbook(model.book);
|
|
8486
9936
|
if (model.active) wb.setActiveSheet(model.active);
|
|
@@ -8547,9 +9997,6 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8547
9997
|
(0, import_react11.useEffect)(() => {
|
|
8548
9998
|
live.current?.marks?.show((room?.people ?? []).flatMap((p) => !p.me && p.selection ? [{ ...p.selection, color: p.color }] : []));
|
|
8549
9999
|
}, [room?.people, phase]);
|
|
8550
|
-
(0, import_react11.useEffect)(() => {
|
|
8551
|
-
live.current?.api.toggleDarkMode(theme === "dark");
|
|
8552
|
-
}, [theme]);
|
|
8553
10000
|
(0, import_react11.useEffect)(() => {
|
|
8554
10001
|
live.current?.api.setLocale(language === "pl" ? "plPL" : "enUS");
|
|
8555
10002
|
}, [language]);
|
|
@@ -8606,7 +10053,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8606
10053
|
});
|
|
8607
10054
|
useRestore(pop !== null);
|
|
8608
10055
|
const api = () => live.current?.api;
|
|
8609
|
-
const
|
|
10056
|
+
const run3 = (id, params) => {
|
|
8610
10057
|
void api()?.executeCommand(id, params);
|
|
8611
10058
|
setPop(null);
|
|
8612
10059
|
};
|
|
@@ -8644,6 +10091,13 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8644
10091
|
[t.time, "hh:mm"],
|
|
8645
10092
|
[t.text, "@"]
|
|
8646
10093
|
];
|
|
10094
|
+
const places = (step) => range()?.setNumberFormat(decimals(look?.n ?? "General", step));
|
|
10095
|
+
const sum = () => {
|
|
10096
|
+
const r = range()?.getRange();
|
|
10097
|
+
const ws = sheet2();
|
|
10098
|
+
const numeric2 = (row2, c) => ws?.getRange(row2, c).getCellData()?.t === import_core5.CellValueType.NUMBER;
|
|
10099
|
+
if (r && ws) for (const x of autoSum(r, numeric2)) ws.getRange(x.row, x.col).setValue({ f: x.f });
|
|
10100
|
+
};
|
|
8647
10101
|
const shown = formats.find(([, p]) => p === look?.n)?.[0] ?? (look && look.n !== "General" ? look.n : t.general);
|
|
8648
10102
|
const border = (type) => {
|
|
8649
10103
|
range()?.setBorder(type, type === "none" ? 0 : 1, "#000000");
|
|
@@ -8704,19 +10158,23 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8704
10158
|
i
|
|
8705
10159
|
)) })
|
|
8706
10160
|
),
|
|
10161
|
+
tool(import_lucide_react6.Euro, t.asCurrency, () => range()?.setNumberFormat('#,##0.00 "\u20AC"'), look?.n === '#,##0.00 "\u20AC"'),
|
|
10162
|
+
tool(import_lucide_react6.Percent, t.asPercent, () => range()?.setNumberFormat("0.00%"), look?.n === "0.00%"),
|
|
10163
|
+
tool(import_lucide_react6.DecimalsArrowLeft, t.fewerDecimals, () => places(-1)),
|
|
10164
|
+
tool(import_lucide_react6.DecimalsArrowRight, t.moreDecimals, () => places(1)),
|
|
8707
10165
|
gap,
|
|
8708
|
-
tool(import_lucide_react6.Bold, t.bold, () =>
|
|
8709
|
-
tool(import_lucide_react6.Italic, t.italic, () =>
|
|
8710
|
-
tool(import_lucide_react6.Underline, t.underline, () =>
|
|
8711
|
-
tool(import_lucide_react6.Strikethrough, t.strike, () =>
|
|
10166
|
+
tool(import_lucide_react6.Bold, t.bold, () => run3("sheet.command.set-range-bold"), look?.bl),
|
|
10167
|
+
tool(import_lucide_react6.Italic, t.italic, () => run3("sheet.command.set-range-italic"), look?.it),
|
|
10168
|
+
tool(import_lucide_react6.Underline, t.underline, () => run3("sheet.command.set-range-underline"), look?.ul),
|
|
10169
|
+
tool(import_lucide_react6.Strikethrough, t.strike, () => run3("sheet.command.set-range-stroke"), look?.st),
|
|
8712
10170
|
anchor(
|
|
8713
10171
|
"text",
|
|
8714
10172
|
opener("text", import_lucide_react6.Baseline, t.textColour, look?.cl ?? ""),
|
|
8715
10173
|
swatches(
|
|
8716
10174
|
["#0f172a", "#475569", "#dc2626", "#ea580c", "#ca8a04", "#16a34a", "#0891b2", "#2563eb", "#7c3aed", "#db2777"],
|
|
8717
|
-
(c) =>
|
|
10175
|
+
(c) => run3("sheet.command.set-range-text-color", { value: c }),
|
|
8718
10176
|
t.automatic,
|
|
8719
|
-
() =>
|
|
10177
|
+
() => run3("sheet.command.reset-range-text-color"),
|
|
8720
10178
|
look?.cl ?? ""
|
|
8721
10179
|
)
|
|
8722
10180
|
),
|
|
@@ -8725,9 +10183,9 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8725
10183
|
opener("fill", import_lucide_react6.PaintBucket, t.fill, look?.bg ?? ""),
|
|
8726
10184
|
swatches(
|
|
8727
10185
|
["#fee2e2", "#ffedd5", "#fef9c3", "#dcfce7", "#cffafe", "#dbeafe", "#ede9fe", "#fce7f3", "#f1f5f9", "#cbd5e1"],
|
|
8728
|
-
(c) =>
|
|
10186
|
+
(c) => run3("sheet.command.set-background-color", { value: c }),
|
|
8729
10187
|
t.noFill,
|
|
8730
|
-
() =>
|
|
10188
|
+
() => run3("sheet.command.reset-background-color"),
|
|
8731
10189
|
look?.bg ?? ""
|
|
8732
10190
|
)
|
|
8733
10191
|
),
|
|
@@ -8740,16 +10198,16 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8740
10198
|
] }, type)) })
|
|
8741
10199
|
),
|
|
8742
10200
|
gap,
|
|
8743
|
-
tool(import_lucide_react6.TextAlignStart, t.alignLeft, () =>
|
|
8744
|
-
tool(import_lucide_react6.TextAlignCenter, t.alignCenter, () =>
|
|
8745
|
-
tool(import_lucide_react6.TextAlignEnd, t.alignRight, () =>
|
|
8746
|
-
tool(import_lucide_react6.TextWrap, t.wrap, () =>
|
|
8747
|
-
look?.merged ? tool(import_lucide_react6.TableCellsSplit, t.unmerge, () =>
|
|
10201
|
+
tool(import_lucide_react6.TextAlignStart, t.alignLeft, () => run3("sheet.command.set-horizontal-text-align", { value: 1 }), look?.ht === 1),
|
|
10202
|
+
tool(import_lucide_react6.TextAlignCenter, t.alignCenter, () => run3("sheet.command.set-horizontal-text-align", { value: 2 }), look?.ht === 2),
|
|
10203
|
+
tool(import_lucide_react6.TextAlignEnd, t.alignRight, () => run3("sheet.command.set-horizontal-text-align", { value: 3 }), look?.ht === 3),
|
|
10204
|
+
tool(import_lucide_react6.TextWrap, t.wrap, () => run3("sheet.command.set-text-wrap", { value: look?.tb ? 1 : 3 }), look?.tb),
|
|
10205
|
+
look?.merged ? tool(import_lucide_react6.TableCellsSplit, t.unmerge, () => run3("sheet.command.remove-worksheet-merge"), true) : tool(import_lucide_react6.TableCellsMerge, t.merge, () => run3("sheet.command.add-worksheet-merge-all")),
|
|
8748
10206
|
gap,
|
|
8749
|
-
tool(import_lucide_react6.BetweenHorizontalStart, t.rowAbove, () =>
|
|
8750
|
-
tool(import_lucide_react6.BetweenHorizontalEnd, t.rowBelow, () =>
|
|
8751
|
-
tool(import_lucide_react6.BetweenVerticalStart, t.columnLeft, () =>
|
|
8752
|
-
tool(import_lucide_react6.BetweenVerticalEnd, t.columnRight, () =>
|
|
10207
|
+
tool(import_lucide_react6.BetweenHorizontalStart, t.rowAbove, () => run3("sheet.command.insert-row-before")),
|
|
10208
|
+
tool(import_lucide_react6.BetweenHorizontalEnd, t.rowBelow, () => run3("sheet.command.insert-row-after")),
|
|
10209
|
+
tool(import_lucide_react6.BetweenVerticalStart, t.columnLeft, () => run3("sheet.command.insert-col-before")),
|
|
10210
|
+
tool(import_lucide_react6.BetweenVerticalEnd, t.columnRight, () => run3("sheet.command.insert-col-after")),
|
|
8753
10211
|
tool(import_lucide_react6.TableRowsSplit, t.deleteRows, () => lines2(true)),
|
|
8754
10212
|
tool(import_lucide_react6.TableColumnsSplit, t.deleteColumns, () => lines2(false)),
|
|
8755
10213
|
anchor(
|
|
@@ -8764,7 +10222,7 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8764
10222
|
sheet2()?.setFrozenColumns(1);
|
|
8765
10223
|
setPop(null);
|
|
8766
10224
|
}, children: t.freezeColumn }),
|
|
8767
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () =>
|
|
10225
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => run3("sheet.command.set-selection-frozen"), children: t.freezeHere }),
|
|
8768
10226
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => {
|
|
8769
10227
|
sheet2()?.cancelFreeze();
|
|
8770
10228
|
setPop(null);
|
|
@@ -8772,20 +10230,21 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8772
10230
|
] })
|
|
8773
10231
|
),
|
|
8774
10232
|
gap,
|
|
8775
|
-
tool(import_lucide_react6.
|
|
8776
|
-
tool(import_lucide_react6.
|
|
8777
|
-
|
|
10233
|
+
tool(import_lucide_react6.Sigma, t.sum, sum),
|
|
10234
|
+
tool(import_lucide_react6.ArrowDownAZ, t.sortUp, () => run3("sheet.command.sort-range-asc")),
|
|
10235
|
+
tool(import_lucide_react6.ArrowDownZA, t.sortDown, () => run3("sheet.command.sort-range-desc")),
|
|
10236
|
+
!room && tool(import_lucide_react6.Funnel, t.filter, () => run3("sheet.command.smart-toggle-filter")),
|
|
8778
10237
|
gap
|
|
8779
10238
|
] }),
|
|
8780
|
-
(edit || notes2) && tool(import_lucide_react6.StickyNote, t.note, () =>
|
|
8781
|
-
tool(import_lucide_react6.Search, t.find, () =>
|
|
10239
|
+
(edit || notes2) && tool(import_lucide_react6.StickyNote, t.note, () => run3("sheet.operation.add-note-popup")),
|
|
10240
|
+
tool(import_lucide_react6.Search, t.find, () => run3("ui.operation.open-find-dialog"))
|
|
8782
10241
|
] }),
|
|
8783
10242
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-sheet-end", children: [
|
|
8784
10243
|
room && (room.ready ? !room.online : room.late || room.denied) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "w100n-text-live", title: room.denied ? void 0 : t.offlineHint, children: [
|
|
8785
10244
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react6.WifiOff, { "aria-hidden": true }),
|
|
8786
10245
|
room.denied ? t.liveOff : t.offline
|
|
8787
10246
|
] }),
|
|
8788
|
-
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.slice(0,
|
|
10247
|
+
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)) }),
|
|
8789
10248
|
!edit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "w100n-docs-badge", children: notes2 ? t.notesOnly : t.viewOnly }),
|
|
8790
10249
|
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 }),
|
|
8791
10250
|
(edit || notes2) && /* @__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: [
|
|
@@ -8803,12 +10262,13 @@ function SheetView({ bytes, name, kind, rights, language, theme, onChange, onSav
|
|
|
8803
10262
|
] })
|
|
8804
10263
|
] });
|
|
8805
10264
|
}
|
|
8806
|
-
var import_react11, import_lucide_react6, import_jsx_runtime7, SheetView_default;
|
|
10265
|
+
var import_react11, import_lucide_react6, import_core5, import_jsx_runtime7, decimals, letters2, SheetView_default;
|
|
8807
10266
|
var init_SheetView = __esm({
|
|
8808
10267
|
"src/sheets/SheetView.tsx"() {
|
|
8809
10268
|
"use strict";
|
|
8810
10269
|
import_react11 = require("react");
|
|
8811
10270
|
import_lucide_react6 = require("lucide-react");
|
|
10271
|
+
import_core5 = require("@univerjs/core");
|
|
8812
10272
|
init_live();
|
|
8813
10273
|
init_focus();
|
|
8814
10274
|
init_bind();
|
|
@@ -8821,6 +10281,16 @@ var init_SheetView = __esm({
|
|
|
8821
10281
|
init_xlsx();
|
|
8822
10282
|
init_sheets();
|
|
8823
10283
|
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
10284
|
+
decimals = (pattern, step) => {
|
|
10285
|
+
const p = pattern === "General" ? "0" : pattern;
|
|
10286
|
+
const next = Math.max(0, (/0(?:\.(0+))?/.exec(p)?.[1]?.length ?? 0) + step);
|
|
10287
|
+
return p.replace(/0(?:\.0+)?/, `0${next ? `.${"0".repeat(next)}` : ""}`);
|
|
10288
|
+
};
|
|
10289
|
+
letters2 = (c) => {
|
|
10290
|
+
let s = "";
|
|
10291
|
+
for (let n = c + 1; n > 0; n = Math.floor((n - 1) / 26)) s = String.fromCharCode(65 + (n - 1) % 26) + s;
|
|
10292
|
+
return s;
|
|
10293
|
+
};
|
|
8824
10294
|
SheetView_default = SheetView;
|
|
8825
10295
|
}
|
|
8826
10296
|
});
|
|
@@ -8881,9 +10351,9 @@ function readable(name, mimeType) {
|
|
|
8881
10351
|
const kind = kindOf(name, mimeType);
|
|
8882
10352
|
return kind !== "sheet" || /\.(xlsx|csv)$/i.test(name) || /spreadsheetml|text\/csv/.test(mimeType ?? "") ? kind : null;
|
|
8883
10353
|
}
|
|
8884
|
-
function matches(doc, query,
|
|
8885
|
-
const
|
|
8886
|
-
return (
|
|
10354
|
+
function matches(doc, query, picked) {
|
|
10355
|
+
const words2 = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
10356
|
+
return (!picked.length || picked.includes(doc.kind)) && words2.every((word) => doc.name.toLocaleLowerCase().includes(word));
|
|
8887
10357
|
}
|
|
8888
10358
|
|
|
8889
10359
|
// src/slides/SlidesView.tsx
|
|
@@ -9391,8 +10861,8 @@ function moveSlide(deck, from, to) {
|
|
|
9391
10861
|
const slide = deck.slides[from];
|
|
9392
10862
|
const rest = deck.slides.filter((_, i) => i !== from);
|
|
9393
10863
|
let at = Math.max(0, Math.min(rest.length, to));
|
|
9394
|
-
const
|
|
9395
|
-
if (
|
|
10864
|
+
const run3 = rest.flatMap((other, i) => slide.stack !== null && other.stack === slide.stack ? [i] : []);
|
|
10865
|
+
if (run3.length) at = Math.max(run3[0], Math.min(run3[run3.length - 1] + 1, at));
|
|
9396
10866
|
else if (at > 0 && at < rest.length && rest[at].stack !== null && rest[at - 1].stack === rest[at].stack) {
|
|
9397
10867
|
let end = at;
|
|
9398
10868
|
while (end < rest.length && rest[end].stack === rest[at].stack) end++;
|
|
@@ -9982,7 +11452,7 @@ function SlidesView({ html, name, rights, language = "en", theme = "light", base
|
|
|
9982
11452
|
popup.close();
|
|
9983
11453
|
};
|
|
9984
11454
|
}, [popup]);
|
|
9985
|
-
const tool = (Icon, text,
|
|
11455
|
+
const tool = (Icon, text, run3, disabled = false) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": text, title: text, disabled, onClick: run3, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { "aria-hidden": true }) });
|
|
9986
11456
|
const thumb = 148;
|
|
9987
11457
|
const seconds = Math.floor(Math.max(0, (timer.stop ?? now) - timer.from) / 1e3);
|
|
9988
11458
|
const elapsed = `${seconds >= 3600 ? `${Math.floor(seconds / 3600)}:` : ""}${String(Math.floor(seconds / 60) % 60).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
@@ -10234,7 +11704,7 @@ var same = (a, b) => !!b && a.page === b.page && a.start === b.start;
|
|
|
10234
11704
|
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) });
|
|
10235
11705
|
function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
10236
11706
|
const paint2 = (0, import_react5.useRef)(null);
|
|
10237
|
-
const
|
|
11707
|
+
const words2 = (0, import_react5.useRef)(null);
|
|
10238
11708
|
const forms = (0, import_react5.useRef)(null);
|
|
10239
11709
|
const focus = (0, import_react5.useRef)(null);
|
|
10240
11710
|
const rubbed = (0, import_react5.useRef)(null);
|
|
@@ -10246,7 +11716,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
10246
11716
|
const hitKey = layers ? layers.hits.map((hit) => `${hit.start}:${hit.end}`).join() : "";
|
|
10247
11717
|
(0, import_react5.useEffect)(() => {
|
|
10248
11718
|
if (!live) return;
|
|
10249
|
-
const holders = [paint2,
|
|
11719
|
+
const holders = [paint2, words2, forms].flatMap((ref) => ref.current ? [ref.current] : []);
|
|
10250
11720
|
return () => {
|
|
10251
11721
|
for (const holder of holders) {
|
|
10252
11722
|
for (const canvas of holder.querySelectorAll("canvas")) {
|
|
@@ -10331,7 +11801,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
10331
11801
|
const end = document.createElement("div");
|
|
10332
11802
|
end.className = "endOfContent";
|
|
10333
11803
|
layer.append(end);
|
|
10334
|
-
|
|
11804
|
+
words2.current.replaceChildren(layer);
|
|
10335
11805
|
const annotations = await page.getAnnotations();
|
|
10336
11806
|
for (const a of annotations) {
|
|
10337
11807
|
if (!a.fieldName || a.pushButton || !["Tx", "Btn", "Ch"].includes(a.fieldType)) continue;
|
|
@@ -10367,7 +11837,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
10367
11837
|
};
|
|
10368
11838
|
}, [pdf, n, live, fill3]);
|
|
10369
11839
|
(0, import_react5.useLayoutEffect)(() => {
|
|
10370
|
-
const layer =
|
|
11840
|
+
const layer = words2.current?.firstElementChild;
|
|
10371
11841
|
if (!layers || !layer || !hitKey) {
|
|
10372
11842
|
setBoxes([]);
|
|
10373
11843
|
return;
|
|
@@ -10462,7 +11932,7 @@ function PdfPage({ pdf, n, size: size2, scale, live, id, layers }) {
|
|
|
10462
11932
|
};
|
|
10463
11933
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "w100n-pdf-page", id, "data-n": n, style, children: [
|
|
10464
11934
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: paint2, className: "w100n-pdf-paint" }),
|
|
10465
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref:
|
|
11935
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: words2, className: "w100n-pdf-words" }),
|
|
10466
11936
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: forms, className: "w100n-pdf-forms" }),
|
|
10467
11937
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { className: "w100n-pdf-marks", viewBox: `0 0 ${size2.w} ${size2.h}`, preserveAspectRatio: "none", "aria-hidden": true, children: [
|
|
10468
11938
|
marks2.map((mark) => {
|
|
@@ -10578,10 +12048,10 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10578
12048
|
const pad = (0, import_react6.useRef)(null);
|
|
10579
12049
|
const inked = (0, import_react6.useRef)(null);
|
|
10580
12050
|
const widgets = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
|
|
10581
|
-
const
|
|
12051
|
+
const words2 = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
|
|
10582
12052
|
const anchor = (0, import_react6.useRef)({ scale: 0, page: 0, frac: 0 });
|
|
10583
12053
|
const [pdf, setPdf] = (0, import_react6.useState)(null);
|
|
10584
|
-
const [
|
|
12054
|
+
const [sizes2, setSizes] = (0, import_react6.useState)([]);
|
|
10585
12055
|
const [error, setError] = (0, import_react6.useState)(false);
|
|
10586
12056
|
const [box2, setBox] = (0, import_react6.useState)({ w: 0, h: 0 });
|
|
10587
12057
|
const [top, setTop] = (0, import_react6.useState)(0);
|
|
@@ -10620,7 +12090,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10620
12090
|
setFilled(false);
|
|
10621
12091
|
setOpen(null);
|
|
10622
12092
|
widgets.current = /* @__PURE__ */ new Map();
|
|
10623
|
-
|
|
12093
|
+
words2.current = /* @__PURE__ */ new Map();
|
|
10624
12094
|
(async () => {
|
|
10625
12095
|
var _a;
|
|
10626
12096
|
const pdfjs = await import("pdfjs-dist");
|
|
@@ -10691,23 +12161,23 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10691
12161
|
document.addEventListener("pointerdown", close);
|
|
10692
12162
|
return () => document.removeEventListener("pointerdown", close);
|
|
10693
12163
|
}, [more, palette2]);
|
|
10694
|
-
const widest = Math.max(1, ...
|
|
10695
|
-
const tallest = Math.max(1, ...
|
|
12164
|
+
const widest = Math.max(1, ...sizes2.map((s) => s.w));
|
|
12165
|
+
const tallest = Math.max(1, ...sizes2.map((s) => s.h));
|
|
10696
12166
|
const room = { w: Math.max(120, box2.w - 32), h: Math.max(120, box2.h - 32) };
|
|
10697
12167
|
const scale = fit === "auto" ? Math.min(room.w / widest, 5 / 3) : fit === "width" ? room.w / widest : fit === "page" ? Math.min(room.w / widest, room.h / tallest) : zoom / 75;
|
|
10698
12168
|
const percent = Math.round(scale * 75);
|
|
10699
12169
|
const tops = [];
|
|
10700
12170
|
let end = 16;
|
|
10701
|
-
for (const s of
|
|
12171
|
+
for (const s of sizes2) {
|
|
10702
12172
|
tops.push(end);
|
|
10703
12173
|
end += s.h * scale + 16;
|
|
10704
12174
|
}
|
|
10705
12175
|
let page = 1;
|
|
10706
12176
|
while (page < tops.length && tops[page] <= top + box2.h / 3) page++;
|
|
10707
|
-
const live = (i) => !!pdf && tops[i] < top + box2.h * 2 && tops[i] +
|
|
12177
|
+
const live = (i) => !!pdf && tops[i] < top + box2.h * 2 && tops[i] + sizes2[i].h * scale > top - box2.h;
|
|
10708
12178
|
const thumbTops = [];
|
|
10709
12179
|
let thumbEnd = 10;
|
|
10710
|
-
for (const s of
|
|
12180
|
+
for (const s of sizes2) {
|
|
10711
12181
|
thumbTops.push(thumbEnd);
|
|
10712
12182
|
thumbEnd += s.h * 96 / s.w + 34;
|
|
10713
12183
|
}
|
|
@@ -10715,11 +12185,11 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10715
12185
|
const centre = (y) => {
|
|
10716
12186
|
let i = 0;
|
|
10717
12187
|
while (i + 1 < tops.length && tops[i + 1] <= y + box2.h / 2) i++;
|
|
10718
|
-
return { page: i, frac:
|
|
12188
|
+
return { page: i, frac: sizes2[i] ? (y + box2.h / 2 - tops[i]) / (sizes2[i].h * scale) : 0 };
|
|
10719
12189
|
};
|
|
10720
12190
|
(0, import_react6.useLayoutEffect)(() => {
|
|
10721
12191
|
const was = anchor.current;
|
|
10722
|
-
if (was.scale && was.scale !== scale &&
|
|
12192
|
+
if (was.scale && was.scale !== scale && sizes2[was.page]) scroller.current.scrollTop = tops[was.page] + was.frac * sizes2[was.page].h * scale - box2.h / 2;
|
|
10723
12193
|
anchor.current = { ...was, scale };
|
|
10724
12194
|
}, [scale]);
|
|
10725
12195
|
(0, import_react6.useEffect)(() => {
|
|
@@ -10745,11 +12215,11 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10745
12215
|
const timer = setTimeout(async () => {
|
|
10746
12216
|
const found = [];
|
|
10747
12217
|
for (let n = 1; n <= pdf.numPages && !stop; n++) {
|
|
10748
|
-
let text =
|
|
12218
|
+
let text = words2.current.get(n);
|
|
10749
12219
|
if (text === void 0) {
|
|
10750
12220
|
const content = await (await pdf.getPage(n)).getTextContent();
|
|
10751
12221
|
text = content.items.map((piece) => "str" in piece ? piece.str + (piece.hasEOL ? " " : "") : "").join("").toLowerCase();
|
|
10752
|
-
|
|
12222
|
+
words2.current.set(n, text);
|
|
10753
12223
|
}
|
|
10754
12224
|
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 });
|
|
10755
12225
|
if (!stop && (n % 20 === 0 || n === pdf.numPages)) setHits({ list: [...found], done: n === pdf.numPages });
|
|
@@ -10796,7 +12266,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10796
12266
|
const next = (at + d + hits.list.length) % hits.list.length;
|
|
10797
12267
|
setAt(next);
|
|
10798
12268
|
const n = hits.list[next].page;
|
|
10799
|
-
if (tops[n - 1] +
|
|
12269
|
+
if (tops[n - 1] + sizes2[n - 1].h * scale < top || tops[n - 1] > top + box2.h) go(n);
|
|
10800
12270
|
};
|
|
10801
12271
|
const markText = (kind) => {
|
|
10802
12272
|
const picked = document.getSelection();
|
|
@@ -10852,7 +12322,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
10852
12322
|
}),
|
|
10853
12323
|
place: (n, p) => {
|
|
10854
12324
|
if (!pending2) return;
|
|
10855
|
-
const size2 =
|
|
12325
|
+
const size2 = sizes2[n - 1];
|
|
10856
12326
|
const w = Math.min(180, size2.w / 2);
|
|
10857
12327
|
const h = w / pending2.ratio;
|
|
10858
12328
|
const mark = {
|
|
@@ -11032,7 +12502,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
11032
12502
|
),
|
|
11033
12503
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
11034
12504
|
"/ ",
|
|
11035
|
-
|
|
12505
|
+
sizes2.length || ""
|
|
11036
12506
|
] })
|
|
11037
12507
|
] }) },
|
|
11038
12508
|
{ key: "g1", at: 2, node: gap },
|
|
@@ -11148,7 +12618,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
11148
12618
|
}, children: t.cancel })
|
|
11149
12619
|
] }),
|
|
11150
12620
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "w100n-pdf-body", children: [
|
|
11151
|
-
rail && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { ref: railBox, className: "w100n-pdf-rail", "aria-label": t.pages, onScroll: (e) => setRailTop(Math.round(e.currentTarget.scrollTop / 80) * 80), children:
|
|
12621
|
+
rail && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { ref: railBox, className: "w100n-pdf-rail", "aria-label": t.pages, onScroll: (e) => setRailTop(Math.round(e.currentTarget.scrollTop / 80) * 80), children: sizes2.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "w100n-pdf-thumb", "aria-current": page === i + 1, onClick: () => go(i + 1), "aria-label": `${t.page} ${i + 1}`, children: [
|
|
11152
12622
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PdfPage, { pdf, n: i + 1, size: s, scale: 96 / s.w, live: !!pdf && thumbLive(i) }),
|
|
11153
12623
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: i + 1 })
|
|
11154
12624
|
] }, i)) }),
|
|
@@ -11175,7 +12645,7 @@ function PdfView({ bytes, t, language, worker, rights, host, documentId, onSaved
|
|
|
11175
12645
|
},
|
|
11176
12646
|
children: [
|
|
11177
12647
|
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "w100n-docs-note", children: t.failed }),
|
|
11178
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w100n-pdf-pages", children:
|
|
12648
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w100n-pdf-pages", children: sizes2.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PdfPage, { id: `${prefix}-${i + 1}`, pdf, n: i + 1, size: s, scale, live: live(i), layers: {
|
|
11179
12649
|
forms: can.edit,
|
|
11180
12650
|
tool,
|
|
11181
12651
|
marks: byPage.get(i + 1) ?? [],
|
|
@@ -11424,12 +12894,12 @@ var templates = {
|
|
|
11424
12894
|
[null, "What comes next and who owns it."]
|
|
11425
12895
|
]
|
|
11426
12896
|
};
|
|
11427
|
-
var
|
|
11428
|
-
var para = ([style, text]) => `<w:p>${style ? `<w:pPr><w:pStyle w:val="${style}"/></w:pPr>` : ""}${
|
|
12897
|
+
var run2 = (text) => text ? `<w:r><w:t xml:space="preserve">${escape2(text)}</w:t></w:r>` : "";
|
|
12898
|
+
var para = ([style, text]) => `<w:p>${style ? `<w:pPr><w:pStyle w:val="${style}"/></w:pPr>` : ""}${run2(text)}</w:p>`;
|
|
11429
12899
|
var table2 = (rows) => {
|
|
11430
12900
|
const width = Math.floor(9638 / rows[0].length);
|
|
11431
12901
|
const border = (side2) => `<w:${side2} w:val="single" w:sz="4" w:space="0" w:color="94A3B8"/>`;
|
|
11432
|
-
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>` :
|
|
12902
|
+
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/>";
|
|
11433
12903
|
};
|
|
11434
12904
|
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>`;
|
|
11435
12905
|
function docx(blocks3) {
|
|
@@ -11935,7 +13405,12 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11935
13405
|
onPlace?.(next);
|
|
11936
13406
|
};
|
|
11937
13407
|
const [query, setQuery] = (0, import_react16.useState)("");
|
|
11938
|
-
const [
|
|
13408
|
+
const [picked, setPicked] = (0, import_react16.useState)([]);
|
|
13409
|
+
const [typing, setTyping] = (0, import_react16.useState)(false);
|
|
13410
|
+
const [menusAt, setMenusAt] = (0, import_react16.useState)(null);
|
|
13411
|
+
const [renaming, setRenaming] = (0, import_react16.useState)(null);
|
|
13412
|
+
const [renamed2, setRenamed] = (0, import_react16.useState)("idle");
|
|
13413
|
+
const [statusAt, setStatusAt] = (0, import_react16.useState)(null);
|
|
11939
13414
|
const [listOpen, setListOpen] = (0, import_react16.useState)(true);
|
|
11940
13415
|
const [panelOpen, setPanelOpen] = (0, import_react16.useState)(true);
|
|
11941
13416
|
const [narrow, setNarrow] = (0, import_react16.useState)(false);
|
|
@@ -11949,13 +13424,13 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11949
13424
|
const el = body.current;
|
|
11950
13425
|
let was = false;
|
|
11951
13426
|
const check = () => {
|
|
11952
|
-
const
|
|
11953
|
-
if (
|
|
13427
|
+
const now2 = getComputedStyle(el).getPropertyValue("--docs-narrow").trim() === "1";
|
|
13428
|
+
if (now2 && !was) {
|
|
11954
13429
|
setPanelOpen(false);
|
|
11955
13430
|
if (here.documentId) setListOpen(false);
|
|
11956
13431
|
}
|
|
11957
|
-
was =
|
|
11958
|
-
setNarrow(
|
|
13432
|
+
was = now2;
|
|
13433
|
+
setNarrow(now2);
|
|
11959
13434
|
};
|
|
11960
13435
|
check();
|
|
11961
13436
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -11964,6 +13439,23 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11964
13439
|
return () => watch.disconnect();
|
|
11965
13440
|
}, [here.documentId]);
|
|
11966
13441
|
const [picking, setPicking] = (0, import_react16.useState)(false);
|
|
13442
|
+
const [adding, setAdding] = (0, import_react16.useState)(false);
|
|
13443
|
+
(0, import_react16.useEffect)(() => {
|
|
13444
|
+
if (!adding) return;
|
|
13445
|
+
const close = (e) => {
|
|
13446
|
+
if (!e.target.closest(".w100n-docs-new")) setAdding(false);
|
|
13447
|
+
};
|
|
13448
|
+
document.addEventListener("pointerdown", close);
|
|
13449
|
+
return () => document.removeEventListener("pointerdown", close);
|
|
13450
|
+
}, [adding]);
|
|
13451
|
+
(0, import_react16.useEffect)(() => {
|
|
13452
|
+
if (!typing) return;
|
|
13453
|
+
const close = (e) => {
|
|
13454
|
+
if (!e.target.closest(".w100n-docs-types")) setTyping(false);
|
|
13455
|
+
};
|
|
13456
|
+
document.addEventListener("pointerdown", close);
|
|
13457
|
+
return () => document.removeEventListener("pointerdown", close);
|
|
13458
|
+
}, [typing]);
|
|
11967
13459
|
(0, import_react16.useEffect)(() => {
|
|
11968
13460
|
if (!picking) return;
|
|
11969
13461
|
const close = (e) => {
|
|
@@ -11974,6 +13466,9 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11974
13466
|
}, [picking]);
|
|
11975
13467
|
const [tab, setTab] = (0, import_react16.useState)("outline");
|
|
11976
13468
|
const [outline2, setOutline] = (0, import_react16.useState)([]);
|
|
13469
|
+
const [reading, setReading] = (0, import_react16.useState)(null);
|
|
13470
|
+
const [hunt, setHunt] = (0, import_react16.useState)("");
|
|
13471
|
+
const [fold, setFold] = (0, import_react16.useState)({});
|
|
11977
13472
|
const [version2, setVersion] = (0, import_react16.useState)({ documentId: null, id: null });
|
|
11978
13473
|
const versionId = version2.documentId === here.documentId ? version2.id : null;
|
|
11979
13474
|
const [restoring, setRestoring] = (0, import_react16.useState)("idle");
|
|
@@ -11981,6 +13476,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11981
13476
|
const [copying, setCopying] = (0, import_react16.useState)("idle");
|
|
11982
13477
|
const [box2, setBox] = (0, import_react16.useState)(null);
|
|
11983
13478
|
const [making, setMaking] = (0, import_react16.useState)(false);
|
|
13479
|
+
const [sending, setSending] = (0, import_react16.useState)("idle");
|
|
13480
|
+
const upload = (0, import_react16.useRef)(null);
|
|
11984
13481
|
const spaces = useLoad((signal) => host.spaces({ signal }), [host]);
|
|
11985
13482
|
const single = spaces.data?.length === 1 ? spaces.data[0].id : null;
|
|
11986
13483
|
const spaceId = here.spaceId ?? single;
|
|
@@ -11991,14 +13488,30 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
11991
13488
|
const all2 = await host.spaces({ signal });
|
|
11992
13489
|
return (await Promise.all(all2.map((item) => host.documents(item.id, { signal })))).flat();
|
|
11993
13490
|
}, [host, spaceId]);
|
|
13491
|
+
(0, import_react16.useEffect)(() => {
|
|
13492
|
+
const sync = () => {
|
|
13493
|
+
if (document.visibilityState !== "visible") return;
|
|
13494
|
+
spaces.retry();
|
|
13495
|
+
list.retry();
|
|
13496
|
+
};
|
|
13497
|
+
const timer = window.setInterval(sync, 3e4);
|
|
13498
|
+
window.addEventListener("focus", sync);
|
|
13499
|
+
document.addEventListener("visibilitychange", sync);
|
|
13500
|
+
return () => {
|
|
13501
|
+
clearInterval(timer);
|
|
13502
|
+
window.removeEventListener("focus", sync);
|
|
13503
|
+
document.removeEventListener("visibilitychange", sync);
|
|
13504
|
+
};
|
|
13505
|
+
}, []);
|
|
11994
13506
|
const doc = useLoad((signal) => here.documentId ? host.document(here.documentId, { signal }) : Promise.resolve(null), [host, here.documentId]);
|
|
11995
13507
|
const versions = useLoad((signal) => here.documentId ? host.versions(here.documentId, { signal }) : Promise.resolve([]), [host, here.documentId]);
|
|
11996
13508
|
const content = useLoad((signal) => here.documentId ? host.content(here.documentId, versionId, { signal }) : Promise.resolve(null), [host, here.documentId, versionId]);
|
|
11997
13509
|
const pdf = doc.data?.kind === "pdf";
|
|
11998
13510
|
const text = doc.data?.kind === "markdown" || doc.data?.kind === "docx";
|
|
13511
|
+
const docbar = text && !versionId && !narrow;
|
|
11999
13512
|
const signatures = useLoad((signal) => here.documentId && pdf && host.signatures ? host.signatures(here.documentId, { signal }) : Promise.resolve([]), [host, here.documentId, pdf]);
|
|
12000
13513
|
const all = list.data ?? [];
|
|
12001
|
-
const shown = all.filter((item) => matches(item, query,
|
|
13514
|
+
const shown = all.filter((item) => matches(item, query, picked));
|
|
12002
13515
|
const present = kinds.filter((item) => all.some((doc2) => doc2.kind === item));
|
|
12003
13516
|
const folders = spaceId ? [.../* @__PURE__ */ new Set(["", ...shown.map((item) => item.folder ?? "")])].filter((folder2) => shown.some((item) => (item.folder ?? "") === folder2)) : [""];
|
|
12004
13517
|
const names2 = new Map((spaces.data ?? []).map((item) => [item.id, item.name]));
|
|
@@ -12036,6 +13549,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12036
13549
|
}
|
|
12037
13550
|
ask(() => {
|
|
12038
13551
|
setOutline([]);
|
|
13552
|
+
setHunt("");
|
|
13553
|
+
setFold({});
|
|
12039
13554
|
setTab("outline");
|
|
12040
13555
|
go({ spaceId: here.spaceId, documentId: item.id });
|
|
12041
13556
|
if (narrow) setListOpen(false);
|
|
@@ -12044,7 +13559,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12044
13559
|
const pick = (next) => {
|
|
12045
13560
|
setPicking(false);
|
|
12046
13561
|
ask(() => {
|
|
12047
|
-
|
|
13562
|
+
setPicked([]);
|
|
12048
13563
|
go({ spaceId: next, documentId: null });
|
|
12049
13564
|
});
|
|
12050
13565
|
};
|
|
@@ -12095,6 +13610,44 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12095
13610
|
setCopying("failed");
|
|
12096
13611
|
}
|
|
12097
13612
|
};
|
|
13613
|
+
const copy2 = async (file) => {
|
|
13614
|
+
setCopying("busy");
|
|
13615
|
+
try {
|
|
13616
|
+
const made2 = await host.create({ name: `${t.copyOf} ${file.name}`, bytes: await host.content(file.id), mimeType: file.mimeType ?? "application/octet-stream" });
|
|
13617
|
+
setCopying("idle");
|
|
13618
|
+
opened2(made2);
|
|
13619
|
+
} catch {
|
|
13620
|
+
setCopying("failed");
|
|
13621
|
+
}
|
|
13622
|
+
};
|
|
13623
|
+
const rename = async (file, draft) => {
|
|
13624
|
+
setRenaming(null);
|
|
13625
|
+
const ext = /\.[^.]+$/.exec(file.name)?.[0] ?? "";
|
|
13626
|
+
const name = draft.trim() && (/\.[^.\s]+$/.test(draft.trim()) ? draft.trim() : draft.trim() + ext);
|
|
13627
|
+
if (!name || name === file.name) return;
|
|
13628
|
+
try {
|
|
13629
|
+
await host.rename(file.id, name);
|
|
13630
|
+
setRenamed("idle");
|
|
13631
|
+
doc.retry();
|
|
13632
|
+
list.retry();
|
|
13633
|
+
} catch {
|
|
13634
|
+
setRenamed("failed");
|
|
13635
|
+
}
|
|
13636
|
+
};
|
|
13637
|
+
const opened2 = (made2) => {
|
|
13638
|
+
spaces.retry();
|
|
13639
|
+
list.retry();
|
|
13640
|
+
ask(() => go({ spaceId: here.spaceId && made2.spaceId, documentId: made2.id }));
|
|
13641
|
+
};
|
|
13642
|
+
const send = async (file) => {
|
|
13643
|
+
setSending("busy");
|
|
13644
|
+
try {
|
|
13645
|
+
opened2(await host.create({ name: file.name, bytes: await file.arrayBuffer(), mimeType: file.type || "application/octet-stream" }));
|
|
13646
|
+
setSending("idle");
|
|
13647
|
+
} catch {
|
|
13648
|
+
setSending("failed");
|
|
13649
|
+
}
|
|
13650
|
+
};
|
|
12098
13651
|
let stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-empty", children: [
|
|
12099
13652
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FileText, { "aria-hidden": true }),
|
|
12100
13653
|
t.pick
|
|
@@ -12117,13 +13670,21 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12117
13670
|
together: doc.data.live,
|
|
12118
13671
|
documentId: doc.data.id,
|
|
12119
13672
|
onOutline: setOutline,
|
|
13673
|
+
onReading: setReading,
|
|
12120
13674
|
onPanel: (next) => {
|
|
12121
13675
|
setPanelOpen(true);
|
|
12122
13676
|
setTab(next);
|
|
12123
13677
|
if (narrow) setListOpen(false);
|
|
12124
13678
|
},
|
|
12125
13679
|
slot: tab === "comments" && panelOpen ? box2 : null,
|
|
13680
|
+
head: docbar ? { menus: menusAt, status: statusAt } : void 0,
|
|
12126
13681
|
guard,
|
|
13682
|
+
file: versionId ? void 0 : {
|
|
13683
|
+
formats: host.exportAs ? doc.data.exports ?? [] : [],
|
|
13684
|
+
download: (f) => void exportAs(doc.data, f),
|
|
13685
|
+
copy: host.create ? () => void copy2(doc.data) : void 0,
|
|
13686
|
+
rename: host.rename && doc.data.rights.edit ? () => setRenaming(doc.data.name.replace(/\.[^.]+$/, "")) : void 0
|
|
13687
|
+
},
|
|
12127
13688
|
onSaved: () => {
|
|
12128
13689
|
versions.retry();
|
|
12129
13690
|
doc.retry();
|
|
@@ -12203,6 +13764,17 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12203
13764
|
else stage = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-empty", children: t.unsupported });
|
|
12204
13765
|
}
|
|
12205
13766
|
const Kind = doc.data ? icons3[doc.data.kind] : import_lucide_react10.FileText;
|
|
13767
|
+
const top = Math.min(...outline2.map((h) => h.level));
|
|
13768
|
+
const chapters = outline2.reduce((all2, h) => {
|
|
13769
|
+
if (h.level === top || !all2.length) all2.push({ head: h, subs: [] });
|
|
13770
|
+
else all2[all2.length - 1].subs.push(h);
|
|
13771
|
+
return all2;
|
|
13772
|
+
}, []);
|
|
13773
|
+
const now = reading?.documentId === here.documentId ? reading : null;
|
|
13774
|
+
const reached = now ? chapters.findIndex((c) => c.head.id === now.id || c.subs.some((s) => s.id === now.id)) : -1;
|
|
13775
|
+
const words2 = hunt.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
13776
|
+
const hit = (h) => words2.every((w) => h.text.toLocaleLowerCase().includes(w));
|
|
13777
|
+
const reach = (h) => h.go ? h.go() : document.getElementById(h.id)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
12206
13778
|
const crumbs = doc.data ? [names2.get(doc.data.spaceId), doc.data.folder].filter(Boolean) : space ? [space.name] : [];
|
|
12207
13779
|
const panelTabs = [["outline", import_lucide_react10.ListTree, t.outline], ["versions", import_lucide_react10.History, t.versions], ["details", import_lucide_react10.Info, t.details]];
|
|
12208
13780
|
if (pdf && host.signatures) panelTabs.push(["signatures", import_lucide_react10.Signature, t.signatures]);
|
|
@@ -12241,13 +13813,38 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12241
13813
|
narrow && listToggle,
|
|
12242
13814
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-tile", "data-kind": doc.data?.kind, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Kind, { "aria-hidden": true }) }),
|
|
12243
13815
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-heading", children: [
|
|
12244
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
12245
|
-
|
|
13816
|
+
renaming !== null && doc.data ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
13817
|
+
"input",
|
|
13818
|
+
{
|
|
13819
|
+
className: "w100n-docs-title w100n-docs-rename",
|
|
13820
|
+
autoFocus: true,
|
|
13821
|
+
value: renaming,
|
|
13822
|
+
"aria-label": t.rename,
|
|
13823
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
13824
|
+
onChange: (e) => setRenaming(e.target.value),
|
|
13825
|
+
onBlur: () => void rename(doc.data, renaming),
|
|
13826
|
+
onKeyDown: (e) => {
|
|
13827
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
13828
|
+
if (e.key === "Escape") {
|
|
13829
|
+
e.stopPropagation();
|
|
13830
|
+
setRenaming(null);
|
|
13831
|
+
}
|
|
13832
|
+
}
|
|
13833
|
+
}
|
|
13834
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
13835
|
+
"strong",
|
|
13836
|
+
{
|
|
13837
|
+
className: "w100n-docs-title",
|
|
13838
|
+
title: docbar ? crumbs.join(" / ") : void 0,
|
|
13839
|
+
onDoubleClick: host.rename && doc.data?.rights.edit && !versionId ? () => setRenaming(doc.data.name.replace(/\.[^.]+$/, "")) : void 0,
|
|
13840
|
+
children: doc.data?.name ?? t.documents
|
|
13841
|
+
}
|
|
13842
|
+
),
|
|
13843
|
+
docbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: setMenusAt, className: "w100n-docs-menus" }) : crumbs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-crumbs", children: crumbs.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { children: [
|
|
12246
13844
|
i > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true }),
|
|
12247
13845
|
item
|
|
12248
13846
|
] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-hint", children: t.hint })
|
|
12249
13847
|
] }),
|
|
12250
|
-
doc.data && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", "data-kind": doc.data.kind, children: t.kinds[doc.data.kind] }),
|
|
12251
13848
|
versionId && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", children: versions.data?.find((v) => v.id === versionId) && date(versions.data.find((v) => v.id === versionId).createdAt) }),
|
|
12252
13849
|
versionId && here.documentId && host.restore && doc.data?.rights.edit && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", disabled: restoring === "busy", onClick: () => void restore(here.documentId, versionId), children: [
|
|
12253
13850
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.RotateCcw, { "aria-hidden": true }),
|
|
@@ -12259,6 +13856,8 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12259
13856
|
t.copyAs
|
|
12260
13857
|
] }),
|
|
12261
13858
|
copying === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-muted", children: t.copyFailed }),
|
|
13859
|
+
renamed2 === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-muted", children: t.renameFailed }),
|
|
13860
|
+
docbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { ref: setStatusAt, className: "w100n-docs-status" }),
|
|
12262
13861
|
sharing && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.share, title: t.share, onClick: () => {
|
|
12263
13862
|
setTab("sharing");
|
|
12264
13863
|
side2("panel", true);
|
|
@@ -12267,10 +13866,6 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12267
13866
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: t.share })
|
|
12268
13867
|
] }),
|
|
12269
13868
|
doc.data && !versionId && actions?.(doc.data),
|
|
12270
|
-
host.create && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-label": t.create, title: t.create, onClick: () => setMaking(true), children: [
|
|
12271
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Plus, { "aria-hidden": true }),
|
|
12272
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: t.create })
|
|
12273
|
-
] }),
|
|
12274
13869
|
narrow && panelToggle,
|
|
12275
13870
|
end && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-end w100n-docs-slot", children: slot(end) })
|
|
12276
13871
|
] }),
|
|
@@ -12283,6 +13878,39 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12283
13878
|
t.documents,
|
|
12284
13879
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: all.length })
|
|
12285
13880
|
] }),
|
|
13881
|
+
host.create && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-new", onKeyDown: (e) => {
|
|
13882
|
+
if (e.key === "Escape" && adding) {
|
|
13883
|
+
e.stopPropagation();
|
|
13884
|
+
setAdding(false);
|
|
13885
|
+
}
|
|
13886
|
+
}, children: [
|
|
13887
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-action", "aria-haspopup": "menu", "aria-expanded": adding, disabled: sending === "busy", onClick: () => setAdding(!adding), children: [
|
|
13888
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Plus, { "aria-hidden": true }),
|
|
13889
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: sending === "busy" ? t.uploading : t.create }),
|
|
13890
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
|
|
13891
|
+
] }),
|
|
13892
|
+
adding && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "menu", className: "w100n-docs-menu", children: [
|
|
13893
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
13894
|
+
setAdding(false);
|
|
13895
|
+
setMaking(true);
|
|
13896
|
+
}, children: [
|
|
13897
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.FilePlus, { "aria-hidden": true }) }),
|
|
13898
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.newTitle })
|
|
13899
|
+
] }),
|
|
13900
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "menuitem", onClick: () => {
|
|
13901
|
+
setAdding(false);
|
|
13902
|
+
upload.current.click();
|
|
13903
|
+
}, children: [
|
|
13904
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-all", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Upload, { "aria-hidden": true }) }),
|
|
13905
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.uploadFile })
|
|
13906
|
+
] })
|
|
13907
|
+
] }),
|
|
13908
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: upload, type: "file", hidden: true, "aria-label": t.uploadFile, accept: ".docx,.md,.markdown,.pdf,.xlsx,.csv,.html,.htm", onChange: (e) => {
|
|
13909
|
+
const file = e.target.files?.[0];
|
|
13910
|
+
e.target.value = "";
|
|
13911
|
+
if (file) void send(file);
|
|
13912
|
+
} })
|
|
13913
|
+
] }),
|
|
12286
13914
|
/* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
|
|
12287
13915
|
] }),
|
|
12288
13916
|
(spaces.data?.length ?? 0) > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-picker", onKeyDown: (e) => {
|
|
@@ -12314,16 +13942,48 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12314
13942
|
] }, group))
|
|
12315
13943
|
] })
|
|
12316
13944
|
] }),
|
|
12317
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("
|
|
12318
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
12319
|
-
|
|
13945
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-filters", children: [
|
|
13946
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
|
|
13947
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
|
|
13948
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: query, onChange: (event) => setQuery(event.target.value), placeholder: t.search, "aria-label": t.search })
|
|
13949
|
+
] }),
|
|
13950
|
+
present.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-types", onKeyDown: (e) => {
|
|
13951
|
+
if (e.key !== "Escape" || !typing) return;
|
|
13952
|
+
e.stopPropagation();
|
|
13953
|
+
setTyping(false);
|
|
13954
|
+
e.currentTarget.querySelector("button").focus();
|
|
13955
|
+
}, children: [
|
|
13956
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: "w100n-docs-field", "aria-haspopup": "listbox", "aria-expanded": typing, "data-on": picked.length > 0, onClick: () => setTyping(!typing), children: [
|
|
13957
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ListFilter, { "aria-hidden": true }),
|
|
13958
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.typeFilter }),
|
|
13959
|
+
picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-badge", children: picked.length }),
|
|
13960
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true })
|
|
13961
|
+
] }),
|
|
13962
|
+
typing && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { role: "listbox", "aria-multiselectable": true, "aria-label": t.kind, className: "w100n-docs-menu", children: [
|
|
13963
|
+
present.map((item) => {
|
|
13964
|
+
const Icon = icons3[item];
|
|
13965
|
+
const on2 = picked.includes(item);
|
|
13966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", role: "option", "aria-selected": on2, onClick: () => setPicked(on2 ? picked.filter((k) => k !== item) : [...picked, item]), children: [
|
|
13967
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-box", children: on2 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Check, { "aria-hidden": true }) }),
|
|
13968
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-tile", "data-kind": item, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { "aria-hidden": true }) }),
|
|
13969
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: t.kinds[item] }),
|
|
13970
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-count", children: all.filter((doc2) => doc2.kind === item).length })
|
|
13971
|
+
] }, item);
|
|
13972
|
+
}),
|
|
13973
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-menu-foot", children: [
|
|
13974
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setPicked(present), children: t.selectAll }),
|
|
13975
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", onClick: () => setPicked([]), children: t.clearPick })
|
|
13976
|
+
] })
|
|
13977
|
+
] })
|
|
13978
|
+
] })
|
|
12320
13979
|
] }),
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
13980
|
+
picked.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-chips", role: "group", "aria-label": t.kind, children: picked.map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", "aria-pressed": true, "aria-label": `${t.clearPick}: ${t.kinds[item]}`, onClick: () => setPicked(picked.filter((k) => k !== item)), children: [
|
|
13981
|
+
t.kinds[item],
|
|
13982
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true })
|
|
12324
13983
|
] }, item)) })
|
|
12325
13984
|
] }),
|
|
12326
13985
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-cards", children: [
|
|
13986
|
+
sending === "failed" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", role: "alert", children: t.uploadFailed }),
|
|
12327
13987
|
list.error && failed(list.retry),
|
|
12328
13988
|
list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.loading }),
|
|
12329
13989
|
list.data && !shown.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: all.length ? t.nothing : t.empty }),
|
|
@@ -12348,12 +14008,70 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12348
14008
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-head", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-row", children: [
|
|
12349
14009
|
/* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsxs)("button", { type: "button", role: "tab", "aria-selected": tab === key2, tabIndex: tab === key2 ? 0 : -1, "aria-label": label, title: label, onClick: () => setTab(key2), children: [
|
|
12350
14010
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { "aria-hidden": true }),
|
|
12351
|
-
(panelTabs.length < 4 || tab === key2) && label
|
|
14011
|
+
(panelTabs.length < 4 || tab === key2 && panelTabs.length < 5) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: label })
|
|
12352
14012
|
] }, key2)) }),
|
|
12353
14013
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "w100n-docs-close", onClick: () => side2("panel", false), "aria-label": t.closePanel, title: t.closePanel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.X, { "aria-hidden": true }) })
|
|
12354
14014
|
] }) }),
|
|
12355
14015
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-panel-body", role: "tabpanel", "aria-label": panelTabs.find(([key2]) => key2 === tab)?.[2], children: [
|
|
12356
|
-
tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime12.
|
|
14016
|
+
tab === "outline" && (outline2.length ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("nav", { className: "w100n-docs-outline", "aria-label": t.outline, children: [
|
|
14017
|
+
now && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-reading", children: [
|
|
14018
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", { style: { width: `${Math.round(now.progress * 100)}%` } }) }),
|
|
14019
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("small", { children: [
|
|
14020
|
+
Math.round(now.progress * 100),
|
|
14021
|
+
"% ",
|
|
14022
|
+
t.read
|
|
14023
|
+
] })
|
|
14024
|
+
] }),
|
|
14025
|
+
outline2.length > 8 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "w100n-docs-field w100n-docs-search", children: [
|
|
14026
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Search, { "aria-hidden": true }),
|
|
14027
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { value: hunt, onChange: (e) => setHunt(e.target.value), placeholder: t.findHeading, "aria-label": t.findHeading })
|
|
14028
|
+
] }),
|
|
14029
|
+
chapters.map((c, i) => {
|
|
14030
|
+
const subs = words2.length ? c.subs.filter(hit) : c.subs;
|
|
14031
|
+
if (words2.length && !hit(c.head) && !subs.length) return null;
|
|
14032
|
+
const opened3 = words2.length > 0 || (fold[c.head.id] ?? i === reached);
|
|
14033
|
+
const named3 = /^(\d+)[.)]?\s+(.+)$/.exec(c.head.text);
|
|
14034
|
+
const mark = c.subs.findIndex((s) => s.id === now?.id);
|
|
14035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-chapter", "data-state": reached < 0 ? void 0 : i < reached ? "done" : i === reached ? "now" : void 0, children: [
|
|
14036
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-chapter-row", children: [
|
|
14037
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.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: [
|
|
14038
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w100n-docs-chapter-num", children: named3 ? named3[1] : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.Bookmark, { "aria-hidden": true }) }),
|
|
14039
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("b", { children: named3 ? named3[2] : c.head.text })
|
|
14040
|
+
] }),
|
|
14041
|
+
c.subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14042
|
+
"button",
|
|
14043
|
+
{
|
|
14044
|
+
type: "button",
|
|
14045
|
+
className: "w100n-docs-chapter-fold",
|
|
14046
|
+
"aria-expanded": opened3,
|
|
14047
|
+
"aria-label": opened3 ? t.hideSections : t.showSections,
|
|
14048
|
+
title: opened3 ? t.hideSections : t.showSections,
|
|
14049
|
+
onClick: () => setFold({ ...fold, [c.head.id]: !opened3 }),
|
|
14050
|
+
children: [
|
|
14051
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("small", { children: c.subs.length }),
|
|
14052
|
+
opened3 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronRight, { "aria-hidden": true })
|
|
14053
|
+
]
|
|
14054
|
+
}
|
|
14055
|
+
)
|
|
14056
|
+
] }),
|
|
14057
|
+
opened3 && subs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w100n-docs-sections", children: subs.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
14058
|
+
"button",
|
|
14059
|
+
{
|
|
14060
|
+
type: "button",
|
|
14061
|
+
"data-level": s.level - top,
|
|
14062
|
+
onClick: () => reach(s),
|
|
14063
|
+
"data-state": i < reached || i === reached && c.subs.indexOf(s) < mark ? "done" : void 0,
|
|
14064
|
+
"aria-current": now?.id === s.id ? "location" : void 0,
|
|
14065
|
+
children: [
|
|
14066
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", { "aria-hidden": true }),
|
|
14067
|
+
s.text
|
|
14068
|
+
]
|
|
14069
|
+
},
|
|
14070
|
+
s.id
|
|
14071
|
+
)) })
|
|
14072
|
+
] }, c.head.id);
|
|
14073
|
+
})
|
|
14074
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "w100n-docs-muted", children: t.noOutline })),
|
|
12357
14075
|
tab === "versions" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w100n-docs-versions", children: [
|
|
12358
14076
|
versions.error && failed(versions.retry),
|
|
12359
14077
|
(versions.data ?? []).map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -12444,9 +14162,7 @@ function DocumentsWorkspace({ host, language = "en", theme = "light", place: pla
|
|
|
12444
14162
|
] }),
|
|
12445
14163
|
making && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NewDocument, { host, t, onClose: () => setMaking(false), onMade: (made2) => {
|
|
12446
14164
|
setMaking(false);
|
|
12447
|
-
|
|
12448
|
-
list.retry();
|
|
12449
|
-
ask(() => go({ spaceId: here.spaceId && made2.spaceId, documentId: made2.id }));
|
|
14165
|
+
opened2(made2);
|
|
12450
14166
|
} }),
|
|
12451
14167
|
dialog
|
|
12452
14168
|
] });
|