@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.
Files changed (53) hide show
  1. package/dist/{SheetView-3XTEV2VT.css → SheetView-43MPR64N.css} +5 -4
  2. package/dist/{SheetView-3XTEV2VT.css.map → SheetView-43MPR64N.css.map} +1 -1
  3. package/dist/{SheetView-3UAFXGZS.js → SheetView-72KXS4DM.js} +51 -10
  4. package/dist/SheetView-72KXS4DM.js.map +1 -0
  5. package/dist/TextEditor-NSICFE6U.js +1562 -0
  6. package/dist/TextEditor-NSICFE6U.js.map +1 -0
  7. package/dist/{chunk-L765DZPO.js → chunk-2CA3HQTI.js} +3 -3
  8. package/dist/{chunk-L765DZPO.js.map → chunk-2CA3HQTI.js.map} +1 -1
  9. package/dist/{chunk-WR3MT7KP.js → chunk-M4OQG3EN.js} +754 -57
  10. package/dist/chunk-M4OQG3EN.js.map +1 -0
  11. package/dist/{chunk-T7XCGDE5.js → chunk-OXC4PUOC.js} +2 -2
  12. package/dist/{chunk-MRP3EURG.js → chunk-Z7UNJ4ND.js} +194 -25
  13. package/dist/chunk-Z7UNJ4ND.js.map +1 -0
  14. package/dist/collab.cjs +927 -80
  15. package/dist/collab.cjs.map +1 -1
  16. package/dist/collab.d.cts +2 -2
  17. package/dist/collab.d.ts +2 -2
  18. package/dist/collab.js +2 -2
  19. package/dist/{grid-EI5JNZAA.js → grid-Q4XBPQFY.js} +3 -3
  20. package/dist/grid-Q4XBPQFY.js.map +1 -0
  21. package/dist/index.cjs +2136 -420
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.css +1047 -171
  24. package/dist/index.css.map +1 -1
  25. package/dist/index.d.cts +9 -4
  26. package/dist/index.d.ts +9 -4
  27. package/dist/index.js +283 -33
  28. package/dist/index.js.map +1 -1
  29. package/dist/kinds.cjs +2 -2
  30. package/dist/kinds.cjs.map +1 -1
  31. package/dist/kinds.d.cts +2 -2
  32. package/dist/kinds.d.ts +2 -2
  33. package/dist/kinds.js +1 -1
  34. package/dist/memory.cjs +3 -0
  35. package/dist/memory.cjs.map +1 -1
  36. package/dist/memory.d.cts +1 -1
  37. package/dist/memory.d.ts +1 -1
  38. package/dist/memory.js +4 -1
  39. package/dist/memory.js.map +1 -1
  40. package/dist/{types-Er60M5kL.d.ts → types-BTsVooZw.d.cts} +2 -1
  41. package/dist/{types-Er60M5kL.d.cts → types-BTsVooZw.d.ts} +2 -1
  42. package/dist/write-BCI8yool.d.cts +16 -0
  43. package/dist/write-BCI8yool.d.ts +16 -0
  44. package/package.json +1 -1
  45. package/dist/SheetView-3UAFXGZS.js.map +0 -1
  46. package/dist/TextEditor-OLBLWC6F.js +0 -983
  47. package/dist/TextEditor-OLBLWC6F.js.map +0 -1
  48. package/dist/chunk-MRP3EURG.js.map +0 -1
  49. package/dist/chunk-WR3MT7KP.js.map +0 -1
  50. package/dist/grid-EI5JNZAA.js.map +0 -1
  51. package/dist/write-DaVtTJCS.d.cts +0 -6
  52. package/dist/write-DaVtTJCS.d.ts +0 -6
  53. /package/dist/{chunk-T7XCGDE5.js.map → chunk-OXC4PUOC.js.map} +0 -0
package/dist/collab.cjs CHANGED
@@ -38,7 +38,7 @@ __export(collab_exports, {
38
38
  filled: () => filled,
39
39
  follow: () => follow,
40
40
  ours: () => ours,
41
- parse: () => parse2,
41
+ parse: () => parse3,
42
42
  pending: () => pending,
43
43
  save: () => save,
44
44
  seed: () => seed
@@ -50,7 +50,7 @@ var import_y_tiptap2 = require("@tiptap/y-tiptap");
50
50
  var Y2 = __toESM(require("yjs"), 1);
51
51
 
52
52
  // package.json
53
- var version = "0.13.0";
53
+ var version = "0.15.0";
54
54
 
55
55
  // src/docx/xml.ts
56
56
  function parse(s) {
@@ -294,7 +294,7 @@ function zip(entries2) {
294
294
  }
295
295
 
296
296
  // src/docx/pkg.ts
297
- var plain = { b: false, i: false, u: false, s: false, code: false, link: null, hl: null, color: null, size: null, font: null, rev: null };
297
+ var 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 };
298
298
  var highlights = {
299
299
  yellow: "ffff00",
300
300
  green: "00ff00",
@@ -346,6 +346,8 @@ function fmtOf(marks) {
346
346
  else if (m.type === "underline") f.u = true;
347
347
  else if (m.type === "strike") f.s = true;
348
348
  else if (m.type === "code") f.code = true;
349
+ else if (m.type === "superscript") f.va = "sup";
350
+ else if (m.type === "subscript") f.va = "sub";
349
351
  else if (m.type === "link" && typeof a.href === "string" && a.href) f.link = a.href;
350
352
  else if (m.type === "highlight") f.hl = color(a.color) ?? "#ffff00";
351
353
  else if (m.type === "textStyle") {
@@ -364,6 +366,7 @@ function marksOf(f) {
364
366
  if (f.u) out.push({ type: "underline" });
365
367
  if (f.s) out.push({ type: "strike" });
366
368
  if (f.code) out.push({ type: "code" });
369
+ if (f.va) out.push({ type: f.va === "sup" ? "superscript" : "subscript" });
367
370
  if (f.link) out.push({ type: "link", attrs: { href: f.link } });
368
371
  if (f.hl) out.push({ type: "highlight", attrs: { color: f.hl } });
369
372
  if (f.color || f.size || f.font) out.push({ type: "textStyle", attrs: { color: f.color, fontSize: f.size, fontFamily: f.font } });
@@ -374,7 +377,7 @@ function marksOf(f) {
374
377
  return out.length ? out : void 0;
375
378
  }
376
379
  function keyOf(f) {
377
- return `${+f.b}${+f.i}${+f.u}${+f.s}${+f.code}|${f.link ?? ""}|${f.hl ?? ""}|${f.color ?? ""}|${f.size ?? ""}|${f.font ?? ""}|${f.rev ?? ""}`;
380
+ 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 ?? ""}`;
378
381
  }
379
382
  var Styles = class {
380
383
  constructor(s, fonts) {
@@ -521,6 +524,11 @@ function props(s, rPr, fonts) {
521
524
  case "w:sz":
522
525
  out.size = size(+(attr(s, k, "w:val") ?? 0) / 2);
523
526
  break;
527
+ case "w:vertAlign": {
528
+ const v = attr(s, k, "w:val");
529
+ out.va = v === "superscript" ? "sup" : v === "subscript" ? "sub" : null;
530
+ break;
531
+ }
524
532
  case "w:highlight": {
525
533
  const v = attr(s, k, "w:val") ?? "none";
526
534
  out.hl = highlights[v] ? "#" + highlights[v] : null;
@@ -664,8 +672,268 @@ function resolve(dir, target) {
664
672
  return out.join("/");
665
673
  }
666
674
 
675
+ // src/editor/math.ts
676
+ var words = {
677
+ alpha: "\u03B1",
678
+ beta: "\u03B2",
679
+ gamma: "\u03B3",
680
+ delta: "\u03B4",
681
+ epsilon: "\u03B5",
682
+ zeta: "\u03B6",
683
+ eta: "\u03B7",
684
+ theta: "\u03B8",
685
+ iota: "\u03B9",
686
+ kappa: "\u03BA",
687
+ lambda: "\u03BB",
688
+ mu: "\u03BC",
689
+ nu: "\u03BD",
690
+ xi: "\u03BE",
691
+ pi: "\u03C0",
692
+ rho: "\u03C1",
693
+ sigma: "\u03C3",
694
+ tau: "\u03C4",
695
+ upsilon: "\u03C5",
696
+ phi: "\u03C6",
697
+ chi: "\u03C7",
698
+ psi: "\u03C8",
699
+ omega: "\u03C9",
700
+ Gamma: "\u0393",
701
+ Delta: "\u0394",
702
+ Theta: "\u0398",
703
+ Lambda: "\u039B",
704
+ Xi: "\u039E",
705
+ Pi: "\u03A0",
706
+ Sigma: "\u03A3",
707
+ Phi: "\u03A6",
708
+ Psi: "\u03A8",
709
+ Omega: "\u03A9",
710
+ infty: "\u221E",
711
+ partial: "\u2202",
712
+ nabla: "\u2207"
713
+ };
714
+ var ops = {
715
+ cdot: "\xB7",
716
+ times: "\xD7",
717
+ div: "\xF7",
718
+ pm: "\xB1",
719
+ mp: "\u2213",
720
+ le: "\u2264",
721
+ leq: "\u2264",
722
+ ge: "\u2265",
723
+ geq: "\u2265",
724
+ ne: "\u2260",
725
+ neq: "\u2260",
726
+ approx: "\u2248",
727
+ equiv: "\u2261",
728
+ to: "\u2192",
729
+ rightarrow: "\u2192",
730
+ leftarrow: "\u2190",
731
+ Rightarrow: "\u21D2",
732
+ in: "\u2208",
733
+ notin: "\u2209",
734
+ subset: "\u2282",
735
+ cup: "\u222A",
736
+ cap: "\u2229",
737
+ forall: "\u2200",
738
+ exists: "\u2203",
739
+ sum: "\u2211",
740
+ prod: "\u220F",
741
+ int: "\u222B",
742
+ oint: "\u222E",
743
+ degree: "\xB0"
744
+ };
745
+ var big = /* @__PURE__ */ new Set(["\u2211", "\u220F", "\u222B", "\u222E"]);
746
+ var glyph = {};
747
+ for (const [k, v] of [...Object.entries(words), ...Object.entries(ops)]) glyph[v] ?? (glyph[v] = k);
748
+ function parse2(src) {
749
+ let i = 0;
750
+ const group = () => {
751
+ if (src[i] === "{") {
752
+ i++;
753
+ const kids2 = row2("}");
754
+ i++;
755
+ return kids2.length === 1 ? kids2[0] : { t: "row", kids: kids2 };
756
+ }
757
+ return one2() ?? { t: "row", kids: [] };
758
+ };
759
+ const one2 = () => {
760
+ while (src[i] === " ") i++;
761
+ if (i >= src.length) return null;
762
+ const c = src[i];
763
+ if (c === "{") return group();
764
+ if (c === "\\") {
765
+ const m = /^\\([a-zA-Z]+|.)/.exec(src.slice(i));
766
+ if (!m) {
767
+ i++;
768
+ return { t: "tok", v: "\\", kind: "mo" };
769
+ }
770
+ i += m[0].length;
771
+ const name = m[1];
772
+ if (name === "frac") return { t: "frac", num: group(), den: group() };
773
+ if (name === "sqrt") {
774
+ let deg = null;
775
+ if (src[i] === "[") {
776
+ const end = src.indexOf("]", i);
777
+ deg = parse2(src.slice(i + 1, end < 0 ? src.length : end));
778
+ i = end < 0 ? src.length : end + 1;
779
+ }
780
+ return { t: "sqrt", body: group(), deg };
781
+ }
782
+ if (name === "text" || name === "mathrm") {
783
+ const g = src[i] === "{" ? src.indexOf("}", i) : -1;
784
+ const v = g < 0 ? "" : src.slice(i + 1, g);
785
+ i = g < 0 ? i : g + 1;
786
+ return { t: "tok", v, kind: "mtext" };
787
+ }
788
+ if (name === "left" || name === "right") return one2();
789
+ if (words[name]) return { t: "tok", v: words[name], kind: "mi" };
790
+ if (ops[name]) return { t: "tok", v: ops[name], kind: "mo" };
791
+ return { t: "tok", v: name.length === 1 ? name : `\\${name}`, kind: name.length === 1 ? "mo" : "mi" };
792
+ }
793
+ if (/[0-9.]/.test(c)) {
794
+ const m = /^[0-9]*\.?[0-9]+|^[0-9]+/.exec(src.slice(i));
795
+ i += m[0].length;
796
+ return { t: "tok", v: m[0], kind: "mn" };
797
+ }
798
+ i++;
799
+ if (/[\p{L}]/u.test(c)) return { t: "tok", v: c, kind: big.has(c) ? "mo" : "mi" };
800
+ return { t: "tok", v: c, kind: "mo" };
801
+ };
802
+ const row2 = (stop) => {
803
+ const kids2 = [];
804
+ while (i < src.length && src[i] !== stop) {
805
+ while (src[i] === " ") i++;
806
+ if (i >= src.length || src[i] === stop) break;
807
+ if (src[i] === "^" || src[i] === "_") {
808
+ const base = kids2.pop() ?? { t: "row", kids: [] };
809
+ const s = base.t === "script" && !base.sub !== !base.sup ? base : { t: "script", base, sub: null, sup: null };
810
+ const which = src[i++] === "^" ? "sup" : "sub";
811
+ s[which] = group();
812
+ kids2.push(s);
813
+ continue;
814
+ }
815
+ if (src[i] === "}") {
816
+ i++;
817
+ continue;
818
+ }
819
+ const a = one2();
820
+ if (a) kids2.push(a);
821
+ }
822
+ return kids2;
823
+ };
824
+ const kids = row2("\0");
825
+ return kids.length === 1 ? kids[0] : { t: "row", kids };
826
+ }
827
+ var esc = (v) => v.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
828
+ function ml(a) {
829
+ switch (a.t) {
830
+ case "tok":
831
+ return `<${a.kind}>${esc(a.v)}</${a.kind}>`;
832
+ case "row":
833
+ return `<mrow>${a.kids.map(ml).join("")}</mrow>`;
834
+ case "frac":
835
+ return `<mfrac>${ml(a.num)}${ml(a.den)}</mfrac>`;
836
+ case "sqrt":
837
+ return a.deg ? `<mroot>${ml(a.body)}${ml(a.deg)}</mroot>` : `<msqrt>${ml(a.body)}</msqrt>`;
838
+ case "script": {
839
+ const over = a.base.t === "tok" && big.has(a.base.v);
840
+ if (a.sub && a.sup) return `<${over ? "munderover" : "msubsup"}>${ml(a.base)}${ml(a.sub)}${ml(a.sup)}</${over ? "munderover" : "msubsup"}>`;
841
+ if (a.sub) return `<${over ? "munder" : "msub"}>${ml(a.base)}${ml(a.sub)}</${over ? "munder" : "msub"}>`;
842
+ return `<${over ? "mover" : "msup"}>${ml(a.base)}${ml(a.sup)}</${over ? "mover" : "msup"}>`;
843
+ }
844
+ }
845
+ }
846
+ var mathml = (latex) => `<math xmlns="http://www.w3.org/1998/Math/MathML">${ml(parse2(latex))}</math>`;
847
+ var 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>`;
848
+ function om(a) {
849
+ switch (a.t) {
850
+ case "tok":
851
+ return run(a.v, a.kind === "mtext" || a.kind === "mo" && !big.has(a.v));
852
+ case "row":
853
+ return a.kids.map(om).join("");
854
+ case "frac":
855
+ return `<m:f><m:num>${om(a.num)}</m:num><m:den>${om(a.den)}</m:den></m:f>`;
856
+ case "sqrt":
857
+ 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>`;
858
+ case "script": {
859
+ 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>`;
860
+ 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>`;
861
+ if (a.sub) return `<m:sSub><m:e>${om(a.base)}</m:e><m:sub>${om(a.sub)}</m:sub></m:sSub>`;
862
+ return `<m:sSup><m:e>${om(a.base)}</m:e><m:sup>${om(a.sup)}</m:sup></m:sSup>`;
863
+ }
864
+ }
865
+ }
866
+ var omml = (latex) => `<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">${om(parse2(latex))}</m:oMath>`;
867
+ function tree(xml) {
868
+ const root = { name: "", kids: [], text: "", attrs: {} };
869
+ const stack = [root];
870
+ for (const m of xml.matchAll(/<(\/?)([\w:]+)([^>]*?)(\/?)>|([^<]+)/g)) {
871
+ const top = stack[stack.length - 1];
872
+ if (m[5] !== void 0) {
873
+ top.text += m[5];
874
+ continue;
875
+ }
876
+ if (m[1]) {
877
+ stack.pop();
878
+ continue;
879
+ }
880
+ const attrs2 = Object.fromEntries([...m[3].matchAll(/([\w:]+)="([^"]*)"/g)].map((a) => [a[1], a[2]]));
881
+ const node = { name: m[2], kids: [], text: "", attrs: attrs2 };
882
+ top.kids.push(node);
883
+ if (!m[4]) stack.push(node);
884
+ }
885
+ return root;
886
+ }
887
+ var unesc = (v) => v.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
888
+ var brace = (v) => v.length === 1 ? v : `{${v}}`;
889
+ function tex(n) {
890
+ const part = (name) => n.kids.find((k) => k.name === name);
891
+ const all = (k) => k ? k.kids.map(tex).join("") : "";
892
+ switch (n.name) {
893
+ case "m:t":
894
+ return [...unesc(n.text)].map((ch) => glyph[ch] ? `\\${glyph[ch]} ` : ch).join("");
895
+ case "m:f":
896
+ return `\\frac{${all(part("m:num"))}}{${all(part("m:den"))}}`;
897
+ case "m:sSup":
898
+ return `${brace(all(part("m:e")))}^${brace(all(part("m:sup")))}`;
899
+ case "m:sSub":
900
+ return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}`;
901
+ case "m:sSubSup":
902
+ return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}^${brace(all(part("m:sup")))}`;
903
+ case "m:rad": {
904
+ const deg = all(part("m:deg"));
905
+ return `\\sqrt${deg ? `[${deg}]` : ""}{${all(part("m:e"))}}`;
906
+ }
907
+ case "m:nary": {
908
+ const chr = part("m:naryPr")?.kids.find((k) => k.name === "m:chr")?.attrs["m:val"] ?? "\u222B";
909
+ const sub = all(part("m:sub")), sup = all(part("m:sup"));
910
+ return `${glyph[chr] ? `\\${glyph[chr]}` : chr}${sub ? `_${brace(sub)}` : ""}${sup ? `^${brace(sup)}` : ""} ${all(part("m:e"))}`.trim();
911
+ }
912
+ case "m:d": {
913
+ const pr = part("m:dPr")?.kids ?? [];
914
+ const beg = pr.find((k) => k.name === "m:begChr")?.attrs["m:val"] ?? "(";
915
+ const end = pr.find((k) => k.name === "m:endChr")?.attrs["m:val"] ?? ")";
916
+ return `${beg}${n.kids.filter((k) => k.name === "m:e").map(all).join(",")}${end}`;
917
+ }
918
+ case "m:rPr":
919
+ case "m:ctrlPr":
920
+ case "w:rPr":
921
+ case "m:naryPr":
922
+ case "m:dPr":
923
+ case "m:radPr":
924
+ case "m:fPr":
925
+ case "m:sSupPr":
926
+ case "m:sSubPr":
927
+ case "m:sSubSupPr":
928
+ return "";
929
+ default:
930
+ return n.kids.map(tex).join("");
931
+ }
932
+ }
933
+ var latexOf = (xml) => tex(tree(xml)).replace(/\s+/g, " ").trim();
934
+
667
935
  // src/docx/read.ts
668
- var blank = () => ({ align: null, indent: 0, ref: null });
936
+ var blank = () => ({ align: null, indent: 0, line: null, after: null, ref: null });
669
937
  var mimes = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", bmp: "image/bmp", webp: "image/webp", svg: "image/svg+xml" };
670
938
  function align(v) {
671
939
  if (v === "center") return "center";
@@ -683,6 +951,7 @@ var Reader = class {
683
951
  this.pkg = pkg;
684
952
  this.n = 0;
685
953
  this.refs = /* @__PURE__ */ new Map();
954
+ this.footnotes = null;
686
955
  this.counters = /* @__PURE__ */ new Map();
687
956
  this.fmts = /* @__PURE__ */ new Map();
688
957
  this.media = /* @__PURE__ */ new Map();
@@ -783,7 +1052,14 @@ var Reader = class {
783
1052
  const src = p.pic && this.src(p.pic.embed);
784
1053
  if (!src) continue;
785
1054
  const meta2 = Object.fromEntries(attrs(/<wp:docPr\b[^>]*>/.exec(p.raw)?.[0] ?? "<x>"));
786
- p.img = { src, alt: meta2.descr ?? null, title: meta2.title ?? null, width: Math.round(p.pic.cx / 9525), height: Math.round(p.pic.cy / 9525) };
1055
+ p.img = {
1056
+ src,
1057
+ alt: meta2.descr ?? null,
1058
+ title: meta2.title ?? null,
1059
+ width: Math.round(p.pic.cx / 9525),
1060
+ height: Math.round(p.pic.cy / 9525),
1061
+ wrap: /<wp:anchor\b/.test(p.raw) ? /<wp:positionH\b[^>]*>\s*<wp:align>right</.test(p.raw) ? "right" : "left" : null
1062
+ };
787
1063
  }
788
1064
  const pPr = kid(el, "w:pPr");
789
1065
  const styles = this.pkg.styles;
@@ -811,7 +1087,11 @@ var Reader = class {
811
1087
  const ind = pPr && kid(pPr, "w:ind");
812
1088
  const left = ind && (attr(s, ind, "w:left") ?? attr(s, ind, "w:start"));
813
1089
  const indent = isList ? 0 : Math.max(0, Math.round((left !== null && left !== void 0 ? +left : styles.left(style)) / 720));
814
- const base = { align: align(jc ? attr(s, jc, "w:val") : styles.jc(style)), indent, ref };
1090
+ const sp = pPr && kid(pPr, "w:spacing");
1091
+ const lineAt = sp && attr(s, sp, "w:line");
1092
+ const afterAt = sp && attr(s, sp, "w:after");
1093
+ const auto = !sp || !attr(s, sp, "w:lineRule") || attr(s, sp, "w:lineRule") === "auto";
1094
+ const base = { align: align(jc ? attr(s, jc, "w:val") : styles.jc(style)), indent, line: lineAt && auto ? Math.round(+lineAt / 2.4) / 100 : null, after: afterAt ? +afterAt / 20 : null, ref };
815
1095
  const node = level ? { type: "heading", attrs: { level, ...base } } : { type: "paragraph", attrs: base };
816
1096
  const content = inline(final);
817
1097
  if (content.length) node.content = content;
@@ -829,6 +1109,14 @@ var Reader = class {
829
1109
  }
830
1110
  return b;
831
1111
  }
1112
+ notes() {
1113
+ if (!this.footnotes) {
1114
+ const rel = this.pkg.byType("/footnotes");
1115
+ const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
1116
+ this.footnotes = new Map([...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"[^>]*>([\s\S]*?)<\/w:footnote>/g)].map((m) => [m[1], noteText(m[2])]));
1117
+ }
1118
+ return this.footnotes;
1119
+ }
832
1120
  src(embed) {
833
1121
  if (!this.media.has(embed)) {
834
1122
  const rel = this.pkg.rels.get(embed);
@@ -874,10 +1162,8 @@ var Reader = class {
874
1162
  const inside = [];
875
1163
  this.walk(k.kids, ctx, k, inside, { lock: null, task: false, box: false });
876
1164
  this.span(s.slice(k.start, k.end), inside, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
877
- } else if (name === "m:oMath") {
878
- const text = s.slice(k.start, k.end).match(/<m:t(?:\s[^>]*)?>[^<]*<\/m:t>/g)?.map((t) => inner(t, parse(t).kids[0])).join("") ?? "";
879
- this.span(s.slice(k.start, k.end), text ? [{ text, raw: null, run: null, ctx, span: null }] : [], out, ctx, null);
880
- } else if (name === "m:oMathPara") st.lock = "Equation";
1165
+ } 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)) });
1166
+ else if (name === "m:oMathPara") st.lock = "Equation";
881
1167
  else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
882
1168
  }
883
1169
  }
@@ -898,17 +1184,17 @@ var Reader = class {
898
1184
  out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
899
1185
  return;
900
1186
  }
901
- const run = { open: opened(s, k), rPr: rPrEl ? s.slice(rPrEl.start, rPrEl.end) : "", fmt: f, el: k, parent };
1187
+ const run2 = { open: opened(s, k), rPr: rPrEl ? s.slice(rPrEl.start, rPrEl.end) : "", fmt: f, el: k, parent };
902
1188
  const push = (text, raw, extra) => {
903
1189
  if (text !== null && st.box) {
904
1190
  st.box = false;
905
1191
  if (text.startsWith(" ") && raw === null) {
906
- out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run, ctx, span: null, box: true });
1192
+ out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run: run2, ctx, span: null, box: true });
907
1193
  text = text.slice(1);
908
1194
  if (!text) return;
909
1195
  }
910
1196
  }
911
- out.push({ text, raw, run, ctx, span: null, ...extra });
1197
+ out.push({ text, raw, run: run2, ctx, span: null, ...extra });
912
1198
  };
913
1199
  for (const c of k.kids) {
914
1200
  const raw = s.slice(c.start, c.end);
@@ -941,6 +1227,11 @@ var Reader = class {
941
1227
  else push("\n", raw);
942
1228
  break;
943
1229
  }
1230
+ case "w:footnoteReference": {
1231
+ const id = attr(s, c, "w:id") ?? "";
1232
+ push("\uE001", raw, { note: { id, text: this.notes().get(id) ?? "" } });
1233
+ break;
1234
+ }
944
1235
  case "w:fldChar":
945
1236
  push(null, raw, { fld: attr(s, c, "w:fldCharType") ?? "" });
946
1237
  break;
@@ -1019,10 +1310,13 @@ var Reader = class {
1019
1310
  const ref = this.ref();
1020
1311
  const pr = kid(el, "w:tblPr");
1021
1312
  const jc = pr && kid(pr, "w:jc");
1022
- const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, ref }, content: [] };
1313
+ const bd = pr && kid(pr, "w:tblBorders");
1314
+ const bare = !!bd && bd.kids.length > 0 && bd.kids.every((k) => /^(none|nil)$/.test(attr(s, k, "w:val") ?? ""));
1315
+ const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, borders: bare ? "none" : null, ref }, content: [] };
1023
1316
  const b = this.block("tbl", el, node, ref);
1024
1317
  const grid2 = kid(el, "w:tblGrid");
1025
1318
  b.cols = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").length : 0;
1319
+ const widths = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").map((k) => Math.floor(+(attr(s, k, "w:w") ?? 0) / 15)) : [];
1026
1320
  const open = [];
1027
1321
  let prev = grid2 ? grid2.end : pr ? pr.end : el.open;
1028
1322
  for (const tr of el.kids) {
@@ -1058,7 +1352,10 @@ var Reader = class {
1058
1352
  if (vm === "continue") open[col].attrs.rowspan++;
1059
1353
  else {
1060
1354
  const content = assemble(inside.list);
1061
- cell2.node = { type: header ? "tableHeader" : "tableCell", attrs: { colspan: span2, rowspan: 1, align: null, indent: 0, ref: cref }, content: content.length ? content : [{ type: "paragraph", attrs: blank() }] };
1355
+ const own = widths.slice(col, col + span2);
1356
+ const shd = tcPr && kid(tcPr, "w:shd");
1357
+ const fill3 = shd ? attr(s, shd, "w:fill") : null;
1358
+ 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: blank() }] };
1062
1359
  row2.node.content.push(cell2.node);
1063
1360
  for (let c = col; c < col + span2; c++) open[c] = null;
1064
1361
  if (vm === "restart") open[col] = cell2.node;
@@ -1139,10 +1436,16 @@ function fmtAt(p) {
1139
1436
  link ?? (link = p.span?.link ?? null);
1140
1437
  return link === f.link && rev === f.rev ? f : { ...f, link, rev };
1141
1438
  }
1439
+ var noteText = (xml) => [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&").trim();
1142
1440
  function inline(pieces2) {
1143
1441
  const out = [];
1144
1442
  let key2 = "";
1145
1443
  for (const p of pieces2) {
1444
+ if (p.math !== void 0 || p.note) {
1445
+ out.push(p.note ? { type: "footnote", attrs: { id: p.note.id, text: p.note.text } } : { type: "math", attrs: { latex: p.math } });
1446
+ key2 = "";
1447
+ continue;
1448
+ }
1146
1449
  if (p.img) {
1147
1450
  out.push({ type: "image", attrs: { ...p.img } });
1148
1451
  key2 = "";
@@ -1264,20 +1567,23 @@ var TC = ["w:cnfStyle", "w:tcW", "w:gridSpan", "w:hMerge", "w:vMerge", "w:tcBord
1264
1567
  var REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
1265
1568
  var special = { " ": "<w:tab/>", "\n": "<w:br/>", "\u2011": "<w:noBreakHyphen/>", "\xAD": "<w:softHyphen/>" };
1266
1569
  var keys = {
1267
- paragraph: [["align", null], ["indent", 0]],
1268
- heading: [["level", 1], ["align", null], ["indent", 0]],
1269
- table: [["align", null]],
1270
- tableCell: [["colspan", 1], ["rowspan", 1]],
1271
- tableHeader: [["colspan", 1], ["rowspan", 1]],
1570
+ paragraph: [["align", null], ["indent", 0], ["line", null], ["after", null]],
1571
+ heading: [["level", 1], ["align", null], ["indent", 0], ["line", null], ["after", null]],
1572
+ table: [["align", null], ["borders", null]],
1573
+ tableCell: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1574
+ tableHeader: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1272
1575
  orderedList: [["start", 1]],
1273
1576
  taskItem: [["checked", false]],
1274
1577
  codeBlock: [["language", null]],
1275
- toc: [["entries", "[]"], ["title", null]]
1578
+ toc: [["entries", "[]"], ["title", null]],
1579
+ image: [["src", null], ["alt", null], ["title", null], ["width", null], ["height", null], ["wrap", null]]
1276
1580
  };
1277
1581
  function value(key2, v) {
1278
1582
  if (v === void 0 || v === "" || v === null) return null;
1279
1583
  if (key2 === "align") return v === "left" ? null : v;
1280
1584
  if (key2 === "width" || key2 === "height") return Math.round(Number(v)) || null;
1585
+ if (key2 === "line" || key2 === "after") return Number.isFinite(Number(v)) ? Number(v) : null;
1586
+ if (key2 === "colwidth") return Array.isArray(v) && v.length && v.every((w) => Number(w) > 0) ? v.map((w) => Math.round(Number(w))) : null;
1281
1587
  if (key2 === "indent" || key2 === "level" || key2 === "colspan" || key2 === "rowspan" || key2 === "start") return Number(v) || 0;
1282
1588
  if (key2 === "checked") return !!v;
1283
1589
  return v;
@@ -1304,14 +1610,14 @@ function inlineSig(kids) {
1304
1610
  out += (next === key2 ? "" : `${next}`) + k.text;
1305
1611
  key2 = next;
1306
1612
  } else {
1307
- out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : ""}`;
1613
+ out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : k.type === "math" ? k.attrs?.latex : k.type === "footnote" ? `${k.attrs?.id}:${k.attrs?.text}` : ""}`;
1308
1614
  key2 = null;
1309
1615
  }
1310
1616
  }
1311
1617
  return out;
1312
1618
  }
1313
1619
  function picture2(a) {
1314
- return JSON.stringify([a.src ?? null, a.alt || null, a.title || null, Math.round(Number(a.width)) || null, Math.round(Number(a.height)) || null]);
1620
+ 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]);
1315
1621
  }
1316
1622
  var groups = 0;
1317
1623
  function flatten(content, out = [], quote = false) {
@@ -1435,6 +1741,7 @@ var Writer = class {
1435
1741
  this.srcs = null;
1436
1742
  this.tocs = false;
1437
1743
  this.revs = /* @__PURE__ */ new Map();
1744
+ this.lastNote = null;
1438
1745
  this.r = new Reader(pkg);
1439
1746
  this.s = pkg.doc;
1440
1747
  for (const id of pkg.rels.keys()) this.relIds.add(id);
@@ -1445,7 +1752,7 @@ var Writer = class {
1445
1752
  this.docPr = max + 1;
1446
1753
  this.nextRev = Math.max(0, ...[...this.s.matchAll(/\bw:id="(\d+)"/g)].map((m) => +m[1])) + 1;
1447
1754
  }
1448
- run(doc) {
1755
+ run(doc, setup) {
1449
1756
  const s = this.s;
1450
1757
  this.body = this.r.body();
1451
1758
  const { list, tail, body } = this.body;
@@ -1455,8 +1762,9 @@ var Writer = class {
1455
1762
  this.carryOver(list, (x) => rest = x);
1456
1763
  let xml = this.container(flatten(doc.content ?? []), list, null);
1457
1764
  if (this.last === "tbl" && list[list.length - 1]?.kind !== "tbl") xml += "<w:p/>";
1458
- const text = s.slice(0, body.open) + xml + rest + s.slice(tail);
1459
1765
  const changed2 = /* @__PURE__ */ new Map();
1766
+ const text = this.marginal(s.slice(0, body.open) + xml + rest + s.slice(tail), setup, changed2);
1767
+ this.footnotes(doc, changed2);
1460
1768
  if (text !== s) changed2.set(this.pkg.main, text);
1461
1769
  if (this.rels.length) {
1462
1770
  const path = this.pkg.relsPath(this.pkg.main);
@@ -1582,6 +1890,110 @@ var Writer = class {
1582
1890
  if (o.kind === "toc") return b && sig(o.node) === sig(b.node) ? s.slice(b.start, b.end) : this.toc(o.node);
1583
1891
  return this.code(o);
1584
1892
  }
1893
+ noteId() {
1894
+ const rel = this.pkg.byType("/footnotes");
1895
+ const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
1896
+ this.lastNote ?? (this.lastNote = Math.max(0, ...[...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"/g)].map((m) => +m[1])));
1897
+ return ++this.lastNote;
1898
+ }
1899
+ footnotes(doc, changed2) {
1900
+ const notes2 = [];
1901
+ const walk = (n) => {
1902
+ if (n.type === "footnote" && n.attrs?.id) notes2.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
1903
+ n.content?.forEach(walk);
1904
+ };
1905
+ walk(doc);
1906
+ const rel = this.pkg.byType("/footnotes");
1907
+ const old = rel ? this.pkg.text(rel.target) : null;
1908
+ if (!notes2.length) return;
1909
+ const path = rel ? rel.target : "word/footnotes.xml";
1910
+ let xml = old ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1911
+ <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>`;
1912
+ const fresh = (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"> ${escape(words2)}</w:t></w:r></w:p></w:footnote>`;
1913
+ for (const n of notes2) {
1914
+ const found = new RegExp(`<w:footnote\\b[^>]*\\bw:id="${n.id}"[^>]*>([\\s\\S]*?)</w:footnote>`).exec(xml);
1915
+ if (found && noteText(found[1]) === n.text) continue;
1916
+ xml = found ? xml.replace(found[0], fresh(n.id, n.text)) : xml.replace(/<\/w:footnotes>\s*$/, fresh(n.id, n.text) + "</w:footnotes>");
1917
+ }
1918
+ if (xml === old) return;
1919
+ changed2.set(path, xml);
1920
+ if (rel) return;
1921
+ this.rels.push(`<Relationship Id="${this.relId()}" Type="${REL}/footnotes" Target="footnotes.xml"/>`);
1922
+ this.types.add(`<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>`);
1923
+ }
1924
+ marginal(text, setup, changed2) {
1925
+ if (!setup || !setup.page && setup.header === void 0 && setup.footer === void 0 && setup.numbers === void 0) return text;
1926
+ const end = text.lastIndexOf("</w:body>");
1927
+ const opens2 = (i) => /^<w:sectPr[\s>/]/.test(text.slice(i, i + 11));
1928
+ let start = -1;
1929
+ let close = text.lastIndexOf("</w:sectPr>", end);
1930
+ if (close >= 0 && !text.slice(close + 11, end).trim()) {
1931
+ let depth = 1;
1932
+ let i = close;
1933
+ while (depth > 0 && i > 0) {
1934
+ let o = text.lastIndexOf("<w:sectPr", i - 1);
1935
+ while (o >= 0 && !opens2(o)) o = text.lastIndexOf("<w:sectPr", o - 1);
1936
+ const c = text.lastIndexOf("</w:sectPr>", i - 1);
1937
+ if (c > o) {
1938
+ depth++;
1939
+ i = c;
1940
+ } else if (o < 0) break;
1941
+ else {
1942
+ if (text[text.indexOf(">", o) - 1] !== "/") depth--;
1943
+ i = o;
1944
+ }
1945
+ }
1946
+ start = i;
1947
+ close += 11;
1948
+ } else {
1949
+ start = close = end;
1950
+ }
1951
+ let sec = start === end ? "<w:sectPr></w:sectPr>" : text.slice(start, close);
1952
+ if (sec.endsWith("/>") && !sec.includes("</w:sectPr>")) sec = sec.slice(0, -2) + "></w:sectPr>";
1953
+ 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"];
1954
+ const put = (name, xml, before) => {
1955
+ const re = new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`);
1956
+ if (re.test(sec)) {
1957
+ sec = sec.replace(re, xml);
1958
+ return;
1959
+ }
1960
+ const at = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
1961
+ const i = at.length ? Math.min(...at) : sec.lastIndexOf("</w:sectPr>");
1962
+ sec = sec.slice(0, i) + xml + sec.slice(i);
1963
+ };
1964
+ const tw = (px2) => Math.round(px2 * 15);
1965
+ if (setup.page) {
1966
+ const { width, height, margins: [top, right, bottom, left] } = setup.page;
1967
+ put("w:pgSz", `<w:pgSz w:w="${tw(width)}" w:h="${tw(height)}"${width > height ? ' w:orient="landscape"' : ""}/>`, after);
1968
+ const was = /<w:pgMar\b[^>]*\/>/.exec(sec)?.[0] ?? "";
1969
+ const keep = attrs(was.replace(/^<w:pgMar|\/>$/g, "")).filter(([k]) => !["w:top", "w:right", "w:bottom", "w:left"].includes(k));
1970
+ if (!keep.some(([k]) => k === "w:header")) keep.push(["w:header", "708"], ["w:footer", "708"], ["w:gutter", "0"]);
1971
+ 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}="${escape(v)}"`).join(" ")}/>`, after.slice(1));
1972
+ }
1973
+ const part = (kind, body) => {
1974
+ sec = sec.replace(new RegExp(`<w:${kind}Reference\\b[^>]*\\bw:type="default"[^>]*/>`), "");
1975
+ if (!body) return;
1976
+ let n = 1;
1977
+ while (this.pkg.files.has(`word/${kind}${n}.xml`) || changed2.has(`word/${kind}${n}.xml`)) n++;
1978
+ const id = this.relId();
1979
+ const tag = kind === "header" ? "w:hdr" : "w:ftr";
1980
+ changed2.set(`word/${kind}${n}.xml`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1981
+ <${tag} xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}">${body}</${tag}>`);
1982
+ this.rels.push(`<Relationship Id="${id}" Type="${REL}/${kind}" Target="${kind}${n}.xml"/>`);
1983
+ this.types.add(`<Override PartName="/word/${kind}${n}.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${kind}+xml"/>`);
1984
+ const open = sec.indexOf(">") + 1;
1985
+ sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
1986
+ };
1987
+ const line = (words2, page) => {
1988
+ 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>';
1989
+ const run2 = words2 ? `<w:r><w:t xml:space="preserve">${escape(words2)}</w:t></w:r>` : "";
1990
+ if (!words2 && !page) return "";
1991
+ 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>${run2}${page && words2 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
1992
+ };
1993
+ if (setup.header !== void 0) part("header", line(setup.header, false));
1994
+ if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
1995
+ return text.slice(0, start) + sec + text.slice(close);
1996
+ }
1585
1997
  toc(node) {
1586
1998
  this.tocs = true;
1587
1999
  const styles = this.pkg.styles;
@@ -1699,6 +2111,20 @@ var Writer = class {
1699
2111
  if (align(direct ?? styles.jc(style)) !== want) {
1700
2112
  set["w:jc"] = align(styles.jc(style)) === want ? null : `<w:jc w:val="${{ center: "center", right: "right", justify: "both" }[want ?? ""] ?? "left"}"/>`;
1701
2113
  }
2114
+ const spEl = get("w:spacing");
2115
+ const spacing = spEl ? attrs(xml.slice(spEl.start, spEl.open)) : [];
2116
+ const had = (name) => spacing.find(([k]) => k === name)?.[1] ?? null;
2117
+ const line = value("line", o.node.attrs?.line);
2118
+ const after = value("after", o.node.attrs?.after);
2119
+ const auto = !had("w:lineRule") || had("w:lineRule") === "auto";
2120
+ 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;
2121
+ if ((b || line !== null || after !== null) && drift) {
2122
+ const kept = spacing.filter(([k]) => k !== "w:line" && k !== "w:lineRule" && k !== "w:after" && !(k === "w:afterAutospacing" && after !== null));
2123
+ if (line !== null) kept.push(["w:line", String(Math.round(line * 240))], ["w:lineRule", "auto"]);
2124
+ else if (had("w:line") && !auto) kept.push(["w:line", had("w:line")], ["w:lineRule", had("w:lineRule")]);
2125
+ if (after !== null) kept.push(["w:after", String(Math.round(after * 20))]);
2126
+ set["w:spacing"] = kept.length ? `<w:spacing ${kept.map(([k, v]) => `${k}="${escape(v)}"`).join(" ")}/>` : null;
2127
+ }
1702
2128
  if (!pr) {
1703
2129
  const indEl = "w:ind" in set ? void 0 : get("w:ind");
1704
2130
  const list = indEl ? attrs(xml.slice(indEl.start, indEl.open)).filter(([k]) => k !== "w:left" && k !== "w:start") : [];
@@ -1755,7 +2181,7 @@ var Writer = class {
1755
2181
  const base = p.span ? fmtAt({ ...p, span: null }) : fmt;
1756
2182
  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 });
1757
2183
  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 });
1758
- 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 });
2184
+ 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 });
1759
2185
  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 });
1760
2186
  if (p.run) counts.set(p.run, n);
1761
2187
  }
@@ -1770,6 +2196,8 @@ var Writer = class {
1770
2196
  for (const ch of n.text ?? "") B.push({ ch: ch === "\r" ? "\n" : ch, fmt: f, key: k });
1771
2197
  } else if (n.type === "hardBreak") B.push({ ch: "\n", fmt: lastFmt, key: keyOf(lastFmt) });
1772
2198
  else if (n.type === "image") B.push({ ch: "\uFFFC", fmt: lastFmt, key: keyOf(lastFmt), img: n.attrs ?? {} });
2199
+ else if (n.type === "math") B.push({ ch: "\uE000", fmt: lastFmt, key: keyOf(lastFmt), math: String(n.attrs?.latex ?? "") });
2200
+ else if (n.type === "footnote") B.push({ ch: "\uE001", fmt: lastFmt, key: keyOf(lastFmt), note: n.attrs ?? (n.attrs = {}) });
1773
2201
  }
1774
2202
  const boxes2 = units.filter((u) => u.box);
1775
2203
  let box2 = null;
@@ -1825,6 +2253,20 @@ var Writer = class {
1825
2253
  } 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 });
1826
2254
  continue;
1827
2255
  }
2256
+ if (want.math !== void 0) {
2257
+ const u = i >= 0 ? A[i] : null;
2258
+ 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 });
2259
+ continue;
2260
+ }
2261
+ if (want.note) {
2262
+ const u = i >= 0 ? A[i] : null;
2263
+ 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 });
2264
+ else {
2265
+ want.note.id = typeof want.note.id === "string" && want.note.id ? want.note.id : String(this.noteId());
2266
+ 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 });
2267
+ }
2268
+ continue;
2269
+ }
1828
2270
  if (i >= 0) {
1829
2271
  const u = A[i];
1830
2272
  if (u.span && intact.has(u.span)) {
@@ -1834,18 +2276,18 @@ var Writer = class {
1834
2276
  const from = u.span ? u.base : u.fmt;
1835
2277
  const keep = u.ch === "\n" || keyOf(from) === want.key;
1836
2278
  const fmt = keep ? from : want.fmt;
1837
- const run = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
1838
- out.push({ ch: u.ch, raw: u.raw, run, ctx: this.revised(this.linked(u.ctx, fmt.link, lastChar()), fmt.rev), u: keep && u.run ? u : null, fmt });
2279
+ const run2 = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
2280
+ out.push({ ch: u.ch, raw: u.raw, run: run2, ctx: this.revised(this.linked(u.ctx, fmt.link, lastChar()), fmt.rev), u: keep && u.run ? u : null, fmt });
1839
2281
  } else {
1840
2282
  const left = lastChar();
1841
2283
  const right = next[j + 1] >= 0 ? A[next[j + 1]] : null;
1842
2284
  const base = left ? { run: left.run, fmt: left.fmt } : right ? { run: right.run ?? paraBase.run, fmt: right.span ? right.base : right.fmt } : paraBase;
1843
- const run = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
2285
+ const run2 = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
1844
2286
  const shared = [];
1845
2287
  if (left && right) {
1846
2288
  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]);
1847
2289
  }
1848
- out.push({ ch: want.ch, raw: null, run, ctx: this.revised(this.linked(shared, want.fmt.link, left), want.fmt.rev), u: null, fmt: want.fmt });
2290
+ out.push({ ch: want.ch, raw: null, run: run2, ctx: this.revised(this.linked(shared, want.fmt.link, left), want.fmt.rev), u: null, fmt: want.fmt });
1849
2291
  }
1850
2292
  }
1851
2293
  let xml = "";
@@ -1928,10 +2370,10 @@ var Writer = class {
1928
2370
  this.relIds.add(`rId${n}`);
1929
2371
  return `rId${n}`;
1930
2372
  }
1931
- derive(run, from, to) {
1932
- const cache = run.derived ?? (run.derived = /* @__PURE__ */ new Map());
2373
+ derive(run2, from, to) {
2374
+ const cache = run2.derived ?? (run2.derived = /* @__PURE__ */ new Map());
1933
2375
  const key2 = keyOf(from) + ">" + keyOf(to);
1934
- if (!cache.has(key2)) cache.set(key2, { open: run.open, rPr: this.delta(run.rPr, from, to), fmt: to, el: null, parent: null });
2376
+ if (!cache.has(key2)) cache.set(key2, { open: run2.open, rPr: this.delta(run2.rPr, from, to), fmt: to, el: null, parent: null });
1935
2377
  return cache.get(key2);
1936
2378
  }
1937
2379
  delta(rPr, from, to) {
@@ -1953,6 +2395,7 @@ var Writer = class {
1953
2395
  set["w:strike"] = to.s ? "<w:strike/>" : sf.s ? '<w:strike w:val="0"/>' : null;
1954
2396
  if (!to.s) set["w:dstrike"] = null;
1955
2397
  }
2398
+ 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;
1956
2399
  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;
1957
2400
  if (to.size !== from.size) {
1958
2401
  const hp = to.size ? Math.round(parseFloat(to.size) * 2) : 0;
@@ -1979,8 +2422,8 @@ var Writer = class {
1979
2422
  } else if (!to.link && from.link && this.pkg.styles.isLink(style)) set["w:rStyle"] = null;
1980
2423
  return Object.keys(set).length ? rebuild(rPr, "w:rPr", R, set) : rPr;
1981
2424
  }
1982
- runXml(run, glyphs, counts) {
1983
- if (run.el && glyphs.length === counts.get(run) && glyphs.every((g, n) => g.u && g.u.run === run && g.u.idx === n)) return this.s.slice(run.el.start, run.el.end);
2425
+ runXml(run2, glyphs, counts) {
2426
+ if (run2.el && glyphs.length === counts.get(run2) && glyphs.every((g, n) => g.u && g.u.run === run2 && g.u.idx === n)) return this.s.slice(run2.el.start, run2.el.end);
1984
2427
  let body = "";
1985
2428
  let text = "";
1986
2429
  const tag = glyphs[0]?.ctx.some((w) => w.rev?.startsWith('["del"')) ? "w:delText" : "w:t";
@@ -1995,7 +2438,7 @@ var Writer = class {
1995
2438
  } else text += g.ch;
1996
2439
  }
1997
2440
  flush();
1998
- return run.open + run.rPr + body + "</w:r>";
2441
+ return run2.open + run2.rPr + body + "</w:r>";
1999
2442
  }
2000
2443
  embed(src) {
2001
2444
  if (!this.srcs) {
@@ -2011,6 +2454,17 @@ var Writer = class {
2011
2454
  this.srcs.set(src, added.id);
2012
2455
  return added;
2013
2456
  }
2457
+ wrapped(raw, side2) {
2458
+ const anchor = /<wp:anchor\b/.test(raw);
2459
+ if (!side2 && !anchor) return raw;
2460
+ const ns = (tag) => attrs(/<wp:(?:inline|anchor)\b([^>]*)>/.exec(tag)?.[1] ?? "").filter(([k]) => k.startsWith("xmlns")).map(([k, v]) => ` ${k}="${v}"`).join("");
2461
+ const part = (name) => new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`).exec(raw)?.[0] ?? "";
2462
+ const body = part("wp:extent") + part("wp:effectExtent");
2463
+ const rest = part("wp:docPr") + part("wp:cNvGraphicFramePr") + part("a:graphic");
2464
+ 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>`);
2465
+ const head = `<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>`;
2466
+ return raw.replace(anchor ? /<wp:anchor\b[\s\S]*<\/wp:anchor>/ : /<wp:inline\b[\s\S]*<\/wp:inline>/, `${head}${body}<wp:wrapSquare wrapText="bothSides"/>${rest}</wp:anchor>`);
2467
+ }
2014
2468
  drawing(img) {
2015
2469
  const media = this.embed(String(img.src ?? ""));
2016
2470
  const max = Math.round(this.textWidth() / 15);
@@ -2022,7 +2476,8 @@ var Writer = class {
2022
2476
  else if (!w) w = Math.round(h * nw / nh);
2023
2477
  const id = this.docPr++;
2024
2478
  const ext = `cx="${Math.round(w * 9525)}" cy="${Math.round(h * 9525)}"`;
2025
- return `<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>`;
2479
+ 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>`;
2480
+ return img.wrap ? this.wrapped(xml, img.wrap) : xml;
2026
2481
  }
2027
2482
  patch(raw, old, img) {
2028
2483
  let xml = raw;
@@ -2034,6 +2489,7 @@ var Writer = class {
2034
2489
  }
2035
2490
  if ((img.alt || null) !== (old.alt || null) || (img.title || null) !== (old.title || null)) xml = xml.replace(/<wp:docPr\b[^>]*>/, (tag) => meta(tag, img));
2036
2491
  if (img.src !== old.src) xml = xml.replace(/(<a:blip\b[^>]*\br:embed=")[^"]*"/, `$1${this.embed(String(img.src ?? "")).id}"`);
2492
+ if ((img.wrap || null) !== (old.wrap || null)) xml = this.wrapped(xml, img.wrap);
2037
2493
  return xml;
2038
2494
  }
2039
2495
  textWidth() {
@@ -2099,6 +2555,27 @@ var Writer = class {
2099
2555
  head = `<w:tbl>${tblPr}<w:tblGrid>${`<w:gridCol w:w="${Math.floor(this.textWidth() / cols)}"/>`.repeat(cols)}</w:tblGrid>`;
2100
2556
  }
2101
2557
  const width = Math.floor(this.textWidth() / cols);
2558
+ const sized = [];
2559
+ for (const r of layout) for (const sl of r) {
2560
+ const own2 = sl.cell && value("colwidth", sl.cell.attrs?.colwidth);
2561
+ if (own2 && own2.length === sl.span) own2.forEach((w, k) => {
2562
+ var _a;
2563
+ return sized[_a = sl.col + k] ?? (sized[_a] = w);
2564
+ });
2565
+ }
2566
+ const known = sized.length === cols && sized.every(Boolean);
2567
+ const had = [...head.matchAll(/<w:gridCol\b[^>]*\bw:w="(\d+)"/g)].map((m) => Math.floor(+m[1] / 15));
2568
+ if (known && had.join() !== sized.join()) {
2569
+ const list = sized.map((w) => `<w:gridCol w:w="${Math.round(w * 15)}"/>`).join("");
2570
+ head = head.replace(/(<w:tblGrid\b[^>]*>)[\s\S]*?(<\/w:tblGrid>)/, `$1${list}$2`);
2571
+ }
2572
+ const own = (col, span2) => known ? sized.slice(col, col + span2) : null;
2573
+ const borders = value("borders", o.node.attrs?.borders);
2574
+ if (borders !== value("borders", b?.node.attrs?.borders)) {
2575
+ const line = (side2) => `<w:${side2} w:val="${borders === "none" ? "none" : "single"}" w:sz="4" w:space="0" w:color="${borders === "none" ? "auto" : "94A3B8"}"/>`;
2576
+ const all = `<w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(line).join("")}</w:tblBorders>`;
2577
+ head = /<w:tblBorders\b/.test(head) ? head.replace(/<w:tblBorders\b[\s\S]*?<\/w:tblBorders>|<w:tblBorders\/>/, all) : head.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`);
2578
+ }
2102
2579
  let xml = head;
2103
2580
  let above = [];
2104
2581
  let aboveRow = null;
@@ -2129,7 +2606,7 @@ var Writer = class {
2129
2606
  if (!sl.cell) {
2130
2607
  const cont = R2?.cells.find((c) => c.vm === "continue" && c.col === sl.col);
2131
2608
  if (cont) xml += cont.lead + s.slice(cont.el.start, cont.el.end);
2132
- else xml += `<w:tc>${this.tcPr(cover.get(sl.from) ?? above[sl.col] ?? null, sl.span, "continue", width)}<w:p/></w:tc>`;
2609
+ 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>`;
2133
2610
  now[sl.col] = cover.get(sl.from) ?? null;
2134
2611
  continue;
2135
2612
  }
@@ -2145,7 +2622,7 @@ var Writer = class {
2145
2622
  const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
2146
2623
  let inside = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
2147
2624
  if (!this.last || this.last === "tbl") inside += "<w:p/>";
2148
- xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C) + inside + (C ? C.tail : "") + "</w:tc>";
2625
+ 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>";
2149
2626
  }
2150
2627
  const lastCell = R2?.cells[R2.cells.length - 1];
2151
2628
  xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
@@ -2154,15 +2631,21 @@ var Writer = class {
2154
2631
  });
2155
2632
  return xml + tail + "</w:tbl>";
2156
2633
  }
2157
- tcPr(src, span2, vm, width, clone = true) {
2634
+ tcPr(src, span2, vm, width, clone = true, own = null, fill3) {
2158
2635
  const s = this.s;
2159
2636
  const el = src && kid(src.el, "w:tcPr");
2160
2637
  const xml = el ? s.slice(el.start, el.end) : "";
2161
- if (!clone && src && src.span === span2 && src.vm === vm) return xml;
2638
+ const tcW = el && kid(el, "w:tcW");
2639
+ const sized = own ? Math.round(own.reduce((a, w) => a + w, 0) * 15) : null;
2640
+ const resized = sized !== null && !(tcW && attr(s, tcW, "w:type") === "dxa" && Math.abs(+(attr(s, tcW, "w:w") ?? 0) - sized) < 15);
2641
+ const was = src?.node ? value("background", src.node.attrs?.background) : null;
2642
+ const painted = fill3 !== void 0 && fill3 !== was;
2643
+ if (!clone && src && src.span === span2 && src.vm === vm && !resized && !painted) return xml;
2162
2644
  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 };
2163
2645
  if (clone) Object.assign(set, { "w:cellIns": null, "w:cellDel": null, "w:cellMerge": null, "w:tcPrChange": null });
2164
- const tcW = el && kid(el, "w:tcW");
2165
- if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span2}" w:type="dxa"/>`;
2646
+ if (painted) set["w:shd"] = fill3 ? `<w:shd w:val="clear" w:color="auto" w:fill="${fill3.slice(1).toUpperCase()}"/>` : null;
2647
+ if (resized) set["w:tcW"] = `<w:tcW w:w="${sized}" w:type="dxa"/>`;
2648
+ else if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span2}" w:type="dxa"/>`;
2166
2649
  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"/>`;
2167
2650
  return rebuild(xml, "w:tcPr", TC, set);
2168
2651
  }
@@ -2194,15 +2677,24 @@ async function readDocx(bytes) {
2194
2677
  const size2 = sect && kid(sect, "w:pgSz");
2195
2678
  const mar = sect && kid(sect, "w:pgMar");
2196
2679
  const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
2680
+ const words2 = (kind) => {
2681
+ const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
2682
+ const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
2683
+ const xml = part ? pkg.text(part.target) ?? "" : "";
2684
+ return { text: [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").trim(), page: /\bPAGE\b/.test(xml) };
2685
+ };
2686
+ const head = words2("header");
2687
+ const foot = words2("footer");
2197
2688
  return {
2689
+ marginal: { header: head.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
2198
2690
  doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
2199
2691
  styles: pkg.styles.list(),
2200
2692
  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)] }
2201
2693
  };
2202
2694
  }
2203
- async function writeDocx(original, doc, load2 = fetched) {
2695
+ async function writeDocx(original, doc, load2 = fetched, setup) {
2204
2696
  const pkg = new Pkg(new Uint8Array(original));
2205
- const out = new Writer(pkg, await images(doc, load2)).run(doc);
2697
+ const out = new Writer(pkg, await images(doc, load2)).run(doc, setup);
2206
2698
  return out ? out.slice().buffer : original.slice(0);
2207
2699
  }
2208
2700
 
@@ -2234,6 +2726,10 @@ function measure(view) {
2234
2726
  const room = page.height - top - bottom;
2235
2727
  const els = [...view.dom.children];
2236
2728
  const gaps = [];
2729
+ const line = page.width - page.margins[1] - page.margins[3];
2730
+ const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
2731
+ let notes2 = [];
2732
+ let count = 0;
2237
2733
  let i = 0;
2238
2734
  let shift = 0;
2239
2735
  let start = 0;
@@ -2247,17 +2743,25 @@ function measure(view) {
2247
2743
  if (!el) return;
2248
2744
  const y = el.offsetTop - shift;
2249
2745
  const end = y + el.offsetHeight;
2746
+ const mine = [];
2747
+ node.descendants((d) => {
2748
+ if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
2749
+ });
2250
2750
  if (node.type.name === "pageBreak") {
2251
- gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1 });
2751
+ gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
2752
+ notes2 = [];
2252
2753
  start = end;
2253
- } else if (end > start + room && y > start) {
2254
- gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1 });
2754
+ } else if (end > start + room - area([...notes2, ...mine]) && y > start) {
2755
+ gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
2756
+ notes2 = [];
2255
2757
  start = y;
2256
2758
  }
2759
+ notes2.push(...mine);
2760
+ count += mine.length;
2257
2761
  while (end > start + room) start += room;
2258
2762
  last = end;
2259
2763
  });
2260
- gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true });
2764
+ gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true, notes: notes2 });
2261
2765
  return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
2262
2766
  }
2263
2767
  var Pager = import_core.Extension.create({
@@ -2265,42 +2769,71 @@ var Pager = import_core.Extension.create({
2265
2769
  addProseMirrorPlugins: () => [new import_state.Plugin({
2266
2770
  key: paging,
2267
2771
  state: {
2268
- init: () => ({ set: import_view.DecorationSet.empty, page: a4 }),
2772
+ init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" } }),
2269
2773
  apply(tr, value3) {
2270
2774
  const next = tr.getMeta(paging);
2271
- return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page };
2775
+ return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks };
2272
2776
  }
2273
2777
  },
2274
2778
  props: { decorations: (state) => paging.getState(state).set },
2275
2779
  view(view) {
2276
2780
  let timer = 0;
2277
2781
  let sig2 = "";
2278
- const run = () => {
2782
+ const run2 = () => {
2279
2783
  if (!view.dom.isConnected) return;
2280
2784
  const gaps = measure(view);
2281
- const next = gaps.map((g) => `${g.pos}:${g.height}`).join();
2785
+ const { marks } = paging.getState(view.state);
2786
+ const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks.header}|${marks.footer}`;
2282
2787
  if (next === sig2) return;
2283
2788
  sig2 = next;
2284
- const set = import_view.DecorationSet.create(view.state.doc, gaps.map((g) => import_view.Decoration.widget(g.pos, () => {
2789
+ const line = (parent, cls, text) => {
2790
+ if (!text) return;
2791
+ const span2 = document.createElement("span");
2792
+ span2.className = cls;
2793
+ span2.textContent = text;
2794
+ parent.append(span2);
2795
+ };
2796
+ const first = import_view.Decoration.widget(0, () => {
2797
+ const el = document.createElement("div");
2798
+ el.className = "w100n-text-first";
2799
+ el.contentEditable = "false";
2800
+ line(el, "w100n-text-head", marks.header);
2801
+ return el;
2802
+ }, { key: `first:${marks.header}`, side: -1, ignoreSelection: true });
2803
+ const set = import_view.DecorationSet.create(view.state.doc, [first, ...gaps.map((g) => import_view.Decoration.widget(g.pos, () => {
2285
2804
  const el = document.createElement("div");
2286
2805
  el.className = g.end ? "w100n-text-gap is-end" : "w100n-text-gap";
2287
2806
  el.style.height = `${g.height}px`;
2288
2807
  el.dataset.page = String(g.page);
2289
2808
  el.contentEditable = "false";
2809
+ line(el, "w100n-text-foot", marks.footer);
2810
+ if (!g.end) line(el, "w100n-text-head", marks.header);
2811
+ if (g.notes.length) {
2812
+ const list = document.createElement("div");
2813
+ list.className = "w100n-text-footnotes";
2814
+ for (const note of g.notes) {
2815
+ const p = document.createElement("p");
2816
+ const n = document.createElement("sup");
2817
+ n.textContent = note.slice(0, note.indexOf(" "));
2818
+ p.append(n, note.slice(note.indexOf(" ")));
2819
+ list.append(p);
2820
+ }
2821
+ el.append(list);
2822
+ }
2290
2823
  return el;
2291
- }, { key: `${g.pos}:${g.height}:${g.page}`, side: -1, ignoreSelection: true })));
2824
+ }, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}:${g.notes.join("\n")}`, side: -1, ignoreSelection: true }))]);
2292
2825
  view.dispatch(view.state.tr.setMeta(paging, { set }).setMeta("addToHistory", false));
2293
2826
  };
2294
2827
  const later = (ms) => {
2295
2828
  clearTimeout(timer);
2296
- timer = window.setTimeout(run, ms);
2829
+ timer = window.setTimeout(run2, ms);
2297
2830
  };
2298
2831
  const watch = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => later(200));
2299
2832
  watch?.observe(view.dom);
2300
2833
  later(0);
2301
2834
  return {
2302
2835
  update: (next, prev) => {
2303
- if (paging.getState(next.state).page !== paging.getState(prev).page) later(0);
2836
+ if (paging.getState(next.state).page !== paging.getState(prev).page || paging.getState(next.state).marks !== paging.getState(prev).marks) later(0);
2304
2837
  else if (next.state.doc !== prev.doc) later(400);
2305
2838
  },
2306
2839
  destroy: () => {
@@ -2343,6 +2876,51 @@ var changed = (trs) => {
2343
2876
  }));
2344
2877
  return ranges;
2345
2878
  };
2879
+ var Cells = import_core2.Extension.create({
2880
+ name: "cells",
2881
+ addGlobalAttributes: () => [
2882
+ { 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}` } : {} } } },
2883
+ { types: ["table"], attributes: { borders: { default: null, parseHTML: (el) => el.dataset.borders ?? null, renderHTML: (attrs2) => attrs2.borders ? { "data-borders": attrs2.borders } : {} } } }
2884
+ ]
2885
+ });
2886
+ var searching = new import_state2.PluginKey("w100n-search");
2887
+ var lookup = (doc, query, matchCase) => {
2888
+ const hits = [];
2889
+ if (!query) return hits;
2890
+ const needle = matchCase ? query : query.toLowerCase();
2891
+ doc.descendants((node, pos) => {
2892
+ if (!node.isTextblock) return true;
2893
+ let text = "";
2894
+ const at = [];
2895
+ node.forEach((child, offset) => {
2896
+ const part = child.isText ? child.text : "\uFFFC";
2897
+ for (let i = 0; i < part.length; i++) at.push(pos + 1 + offset + i);
2898
+ text += part;
2899
+ });
2900
+ const hay = matchCase ? text : text.toLowerCase();
2901
+ 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 });
2902
+ return false;
2903
+ });
2904
+ return hits;
2905
+ };
2906
+ var Search = import_core2.Extension.create({
2907
+ name: "search",
2908
+ addProseMirrorPlugins: () => [new import_state2.Plugin({
2909
+ key: searching,
2910
+ state: {
2911
+ init: () => ({ query: "", matchCase: false, hits: [], at: 0, set: import_view2.DecorationSet.empty }),
2912
+ apply(tr, value3) {
2913
+ const meta2 = tr.getMeta(searching);
2914
+ if (!meta2 && !tr.docChanged) return value3;
2915
+ const next = { ...value3, ...meta2 };
2916
+ const hits = lookup(tr.doc, next.query, next.matchCase);
2917
+ const at = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
2918
+ 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" }))) };
2919
+ }
2920
+ },
2921
+ props: { decorations: (state) => searching.getState(state).set }
2922
+ })]
2923
+ });
2346
2924
  var Blocks = import_core2.Extension.create({
2347
2925
  name: "blocks",
2348
2926
  addGlobalAttributes: () => [{
@@ -2350,6 +2928,8 @@ var Blocks = import_core2.Extension.create({
2350
2928
  attributes: {
2351
2929
  align: { default: null, parseHTML: (el) => el.style.textAlign || null, renderHTML: (attrs2) => attrs2.align ? { style: `text-align: ${attrs2.align}` } : {} },
2352
2930
  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` } : {} },
2931
+ 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}` } : {} },
2932
+ 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` } },
2353
2933
  ref: { default: null, rendered: false, keepOnSplit: false }
2354
2934
  }
2355
2935
  }],
@@ -2401,6 +2981,37 @@ var PageBreak = import_core2.Node.create({
2401
2981
  return ["div", { "data-page-break": "", "data-label": this.options.label, class: "w100n-text-break", contenteditable: "false" }];
2402
2982
  }
2403
2983
  });
2984
+ var Formula = import_core2.Node.create({
2985
+ name: "math",
2986
+ group: "inline",
2987
+ inline: true,
2988
+ atom: true,
2989
+ selectable: true,
2990
+ addAttributes: () => ({ latex: { default: "", parseHTML: (el) => el.getAttribute("data-math") ?? "" } }),
2991
+ parseHTML: () => [{ tag: "span[data-math]" }],
2992
+ renderHTML: ({ node }) => ["span", { "data-math": node.attrs.latex, class: "w100n-math" }],
2993
+ addNodeView: () => ({ node }) => {
2994
+ const dom = document.createElement("span");
2995
+ dom.className = "w100n-math";
2996
+ dom.dataset.math = node.attrs.latex;
2997
+ dom.contentEditable = "false";
2998
+ dom.innerHTML = mathml(node.attrs.latex);
2999
+ return { dom };
3000
+ }
3001
+ });
3002
+ var Footnote = import_core2.Node.create({
3003
+ name: "footnote",
3004
+ group: "inline",
3005
+ inline: true,
3006
+ atom: true,
3007
+ selectable: true,
3008
+ addAttributes: () => ({
3009
+ id: { default: null, parseHTML: (el) => el.getAttribute("data-note-id") },
3010
+ text: { default: "", parseHTML: (el) => el.getAttribute("title") ?? "" }
3011
+ }),
3012
+ parseHTML: () => [{ tag: "sup[data-footnote]" }],
3013
+ renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
3014
+ });
2404
3015
  var headings = (doc, after) => {
2405
3016
  const found = [];
2406
3017
  doc.descendants((node, pos) => {
@@ -2664,24 +3275,41 @@ var Notes = import_core2.Extension.create({
2664
3275
  props: { decorations: (state) => notes.getState(state).set }
2665
3276
  })]
2666
3277
  });
3278
+ var script = (name, tag, other) => import_core2.Mark.create({
3279
+ name,
3280
+ excludes: other,
3281
+ parseHTML: () => [{ tag }, { style: `vertical-align=${name === "superscript" ? "super" : "sub"}` }],
3282
+ renderHTML: () => [tag, 0],
3283
+ addKeyboardShortcuts() {
3284
+ return { [name === "superscript" ? "Mod-." : "Mod-,"]: () => this.editor.commands.toggleMark(name) };
3285
+ }
3286
+ });
2667
3287
  function kit(kind, t, live) {
2668
3288
  return [
2669
3289
  import_starter_kit.default.configure({ trailingNode: false, link: { openOnClick: false, autolink: true, defaultProtocol: "https" }, dropcursor: { color: "#8b5cf6", width: 2 }, ...live ? { undoRedo: false } : {} }),
2670
3290
  import_extension_list.TaskList,
2671
3291
  import_extension_list.TaskItem.configure({ nested: true, a11y: { checkboxLabel: (node) => node.textContent || t.tasks } }),
2672
- import_extension_table.TableKit.configure({ table: { resizable: false } }),
2673
- import_extension_image.default.configure({ inline: true, allowBase64: true }),
3292
+ import_extension_table.TableKit.configure({ table: { resizable: true, cellMinWidth: 32 } }),
3293
+ Cells,
3294
+ Search,
3295
+ import_extension_image.default.extend({
3296
+ addAttributes() {
3297
+ return { ...this.parent?.(), wrap: { default: null, parseHTML: (el) => el.dataset.wrap ?? null, renderHTML: (attrs2) => attrs2.wrap ? { "data-wrap": attrs2.wrap } : {} } };
3298
+ }
3299
+ }).configure({ inline: true, allowBase64: true, resize: { enabled: true, directions: ["top-left", "top-right", "bottom-left", "bottom-right"], minWidth: 24, minHeight: 24, alwaysPreserveAspectRatio: true } }),
2674
3300
  import_extension_highlight.default.configure({ multicolor: true }),
2675
3301
  import_extension_text_style.TextStyle,
2676
3302
  import_extension_text_style.Color,
2677
3303
  import_extension_text_style.FontSize,
2678
3304
  import_extension_text_style.FontFamily,
3305
+ script("superscript", "sup", "subscript"),
3306
+ script("subscript", "sub", "superscript"),
2679
3307
  Blocks,
2680
3308
  PageBreak.configure({ label: t.pageBreak }),
2681
3309
  Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
2682
3310
  Note,
2683
3311
  Notes,
2684
- ...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
3312
+ ...kind === "docx" ? [Formula, Footnote, Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
2685
3313
  ...live ? [import_extension_collaboration.default.configure({ document: live.doc }), import_extension_collaboration_caret.default.configure({ provider: live.link, user: live.user })] : []
2686
3314
  ];
2687
3315
  }
@@ -2862,7 +3490,7 @@ var track = ({ doc: _json, ...parsed }, doc) => {
2862
3490
  return nodes.length === parsed.raws.length ? { ...parsed, nodes } : { ...parsed, nodes: [], raws: [], head: "", tail: "\n" };
2863
3491
  };
2864
3492
  var ticks = (node, side2) => {
2865
- const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((run) => run.length));
3493
+ const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((run2) => run2.length));
2866
3494
  return len ? side2 > 0 ? ` ${"`".repeat(len + 1)}` : `${"`".repeat(len + 1)} ` : "`";
2867
3495
  };
2868
3496
  var plain2 = (mark, parent, index) => {
@@ -2880,7 +3508,7 @@ var plain2 = (mark, parent, index) => {
2880
3508
  function serializer(style, hints, before, cell2 = false) {
2881
3509
  let form = null;
2882
3510
  const hint = (node) => hints[node.attrs.ref] ?? {};
2883
- const run = (parent, index, types) => {
3511
+ const run2 = (parent, index, types) => {
2884
3512
  let n = 0;
2885
3513
  for (let i = index - 1; i >= 0 && types.includes(parent.child(i).type.name); i--) n++;
2886
3514
  if (!index && before && types.includes(before.type.name)) n++;
@@ -2894,7 +3522,7 @@ function serializer(style, hints, before, cell2 = false) {
2894
3522
  state.options.tightLists = was;
2895
3523
  };
2896
3524
  const list = (state, node, parent, index) => {
2897
- const bullet = hint(node).bullet ?? (run(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
3525
+ const bullet = hint(node).bullet ?? (run2(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
2898
3526
  tight(state, node, () => state.renderList(node, " ", () => `${bullet} `));
2899
3527
  };
2900
3528
  const blank3 = { open: "", close: "", mixable: true };
@@ -2942,7 +3570,7 @@ ${lines2.join("")}<!-- /toc -->`);
2942
3570
  taskList: list,
2943
3571
  orderedList(state, node, parent, index) {
2944
3572
  const start = node.attrs.start ?? 1;
2945
- const delim = hint(node).delim ?? (run(parent, index, ["orderedList"]) ? style.delim === "." ? ")" : "." : style.delim);
3573
+ const delim = hint(node).delim ?? (run2(parent, index, ["orderedList"]) ? style.delim === "." ? ")" : "." : style.delim);
2946
3574
  const width = String(start + node.childCount - 1).length;
2947
3575
  tight(state, node, () => state.renderList(node, " ".repeat(width + 2), (i) => `${start + i}${delim} `));
2948
3576
  },
@@ -4373,7 +5001,7 @@ function equalValue(a, b) {
4373
5001
  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));
4374
5002
  return a === b;
4375
5003
  }
4376
- function lookup(book, s) {
5004
+ function lookup2(book, s) {
4377
5005
  if (!s) return {};
4378
5006
  return (typeof s === "string" ? book.styles[s] : s) ?? {};
4379
5007
  }
@@ -4531,7 +5159,7 @@ function writeXlsx(original, model) {
4531
5159
  const id = typeof s === "string" ? (bk === cur ? "c" : "b") + s : "";
4532
5160
  const known = id && seen.get(id);
4533
5161
  if (known) return known;
4534
- const look = norm({ ...defaults, ...lookup(bk, s) });
5162
+ const look = norm({ ...defaults, ...lookup2(bk, s) });
4535
5163
  const made2 = { look, json: JSON.stringify(look) };
4536
5164
  if (id) seen.set(id, made2);
4537
5165
  return made2;
@@ -4572,8 +5200,8 @@ function writeXlsx(original, model) {
4572
5200
  changed2 = true;
4573
5201
  tag = setAttr(tag, "hidden", hidden ? "1" : null);
4574
5202
  }
4575
- const look = rd.s ? norm({ ...defaults, ...lookup(cur, rd.s) }) : null;
4576
- const was = od.s ? norm({ ...defaults, ...lookup(base.book, od.s) }) : null;
5203
+ const look = rd.s ? norm({ ...defaults, ...lookup2(cur, rd.s) }) : null;
5204
+ const was = od.s ? norm({ ...defaults, ...lookup2(base.book, od.s) }) : null;
4577
5205
  if (!same(look, was)) {
4578
5206
  changed2 = true;
4579
5207
  tag = setAttr(setAttr(tag, "s", look ? String(xfFor(look, xfOf(od.s))) : null), "customFormat", look ? "1" : null);
@@ -4864,7 +5492,7 @@ function cellXml(p, ref, xf, x, f, v) {
4864
5492
  function columns(p, rec, sheet, old, cols, defaults, cur, baseBook, xfFor, xfOf) {
4865
5493
  const now = sheet.columnData ?? {}, was = old.columnData ?? {};
4866
5494
  const count = sheet.columnCount ?? 26;
4867
- const look = (bk, s) => s ? norm({ ...defaults, ...lookup(bk, s) }) : null;
5495
+ const look = (bk, s) => s ? norm({ ...defaults, ...lookup2(bk, s) }) : null;
4868
5496
  let differs = cols.moved;
4869
5497
  for (let c = 0; c < count && !differs; c++) {
4870
5498
  const c0 = cols.from(c);
@@ -5217,6 +5845,11 @@ function applyCells(doc, list, origin) {
5217
5845
 
5218
5846
  // src/sheets/text.ts
5219
5847
  var en = {
5848
+ asCurrency: "Format as euro",
5849
+ asPercent: "Format as percent",
5850
+ fewerDecimals: "Fewer decimal places",
5851
+ moreDecimals: "More decimal places",
5852
+ sum: "Sum",
5220
5853
  tools: "Sheet tools",
5221
5854
  loading: "Opening the sheet",
5222
5855
  failed: "This sheet could not be opened",
@@ -5285,6 +5918,11 @@ var en = {
5285
5918
  }
5286
5919
  };
5287
5920
  var pl = {
5921
+ asCurrency: "Formatuj jako euro",
5922
+ asPercent: "Formatuj jako procent",
5923
+ fewerDecimals: "Mniej miejsc po przecinku",
5924
+ moreDecimals: "Wi\u0119cej miejsc po przecinku",
5925
+ sum: "Suma",
5288
5926
  tools: "Narz\u0119dzia arkusza",
5289
5927
  loading: "Otwieranie arkusza",
5290
5928
  failed: "Nie uda\u0142o si\u0119 otworzy\u0107 tego arkusza",
@@ -5353,6 +5991,11 @@ var pl = {
5353
5991
  }
5354
5992
  };
5355
5993
  var uk = {
5994
+ asCurrency: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0454\u0432\u0440\u043E",
5995
+ asPercent: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0432\u0456\u0434\u0441\u043E\u0442\u043A\u0456\u0432",
5996
+ fewerDecimals: "\u041C\u0435\u043D\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
5997
+ moreDecimals: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
5998
+ sum: "\u0421\u0443\u043C\u0430",
5356
5999
  tools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
5357
6000
  loading: "\u0412\u0456\u0434\u043A\u0440\u0438\u0432\u0430\u0454\u043C\u043E \u0442\u0430\u0431\u043B\u0438\u0446\u044E",
5358
6001
  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",
@@ -5438,6 +6081,10 @@ var en2 = {
5438
6081
  versions: "Versions",
5439
6082
  details: "Details",
5440
6083
  noOutline: "This document has no headings",
6084
+ findHeading: "Find a heading",
6085
+ read: "read",
6086
+ showSections: "Show sections",
6087
+ hideSections: "Hide sections",
5441
6088
  current: "Current",
5442
6089
  size: "Size",
5443
6090
  updated: "Updated",
@@ -5485,6 +6132,12 @@ var en2 = {
5485
6132
  save: "Save",
5486
6133
  saving: "Saving",
5487
6134
  saved: "Saved",
6135
+ align: "Align",
6136
+ moreTools: "More tools",
6137
+ fewerTools: "Fewer tools",
6138
+ typeFilter: "Type",
6139
+ selectAll: "Select all",
6140
+ clearPick: "Clear",
5488
6141
  saveFailed: "Could not save",
5489
6142
  remove: "Remove",
5490
6143
  notePlaceholder: "Write a note",
@@ -5548,6 +6201,14 @@ var en2 = {
5548
6201
  chooseFile: "Choose a file",
5549
6202
  put: "Insert",
5550
6203
  link: "Link",
6204
+ footnote: "Footnote",
6205
+ footnoteText: "Footnote text",
6206
+ formula: "Formula",
6207
+ formulaHint: "Saved as a Word equation",
6208
+ symbols: "Special characters",
6209
+ symbolSearch: "Search, for example arrow",
6210
+ update: "Update",
6211
+ removeFootnote: "Remove footnote",
5551
6212
  linkAddress: "Link address",
5552
6213
  apply: "Apply",
5553
6214
  unlink: "Remove link",
@@ -5594,6 +6255,11 @@ var en2 = {
5594
6255
  someone: "Someone",
5595
6256
  copyAs: "Make an XLSX copy",
5596
6257
  copyFailed: "Could not make the copy",
6258
+ downloadAs: "Download as",
6259
+ makeCopy: "Make a copy",
6260
+ copyOf: "Copy of",
6261
+ rename: "Rename",
6262
+ renameFailed: "Could not rename",
5597
6263
  editComment: "Edit",
5598
6264
  delete: "Delete",
5599
6265
  deleteAsk: "Delete this comment?",
@@ -5679,7 +6345,52 @@ var en2 = {
5679
6345
  untitled: "Untitled",
5680
6346
  kindHints: { docx: "Word, DOCX", markdown: "MD, same editor", sheet: "Excel, XLSX", slides: "HTML slides" },
5681
6347
  newKinds: { docx: "Document", markdown: "Markdown", sheet: "Spreadsheet", slides: "Presentation" },
5682
- templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" }
6348
+ templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" },
6349
+ menuFile: "File",
6350
+ menuEdit: "Edit",
6351
+ menuFormat: "Format",
6352
+ menuTools: "Tools",
6353
+ zoom: "Zoom",
6354
+ font: "Font",
6355
+ fontSize: "Font size",
6356
+ defaultFont: "Default",
6357
+ lineSpacing: "Line and paragraph spacing",
6358
+ single: "Single",
6359
+ double: "Double",
6360
+ spaceAfter: "Add space after paragraph",
6361
+ noSpaceAfter: "Remove space after paragraph",
6362
+ superscript: "Superscript",
6363
+ subscript: "Subscript",
6364
+ painter: "Paint format",
6365
+ painterHint: "Select text to paint, double click keeps it on, Esc stops",
6366
+ pageSetup: "Page setup",
6367
+ orientation: "Orientation",
6368
+ portrait: "Portrait",
6369
+ landscape: "Landscape",
6370
+ marginsCm: "Margins, cm",
6371
+ mTop: "Top",
6372
+ mRight: "Right",
6373
+ mBottom: "Bottom",
6374
+ mLeft: "Left",
6375
+ headerText: "Header",
6376
+ footerText: "Footer",
6377
+ pageNumbers: "Page numbers in the footer",
6378
+ wrapInline: "In line with text",
6379
+ wrapLeft: "Text wraps on the right",
6380
+ wrapRight: "Text wraps on the left",
6381
+ cellFill: "Cell fill",
6382
+ tableBorders: "Table borders",
6383
+ findReplace: "Find and replace",
6384
+ replaceWith: "Replace with",
6385
+ replaceOne: "Replace",
6386
+ replaceAll: "Replace all",
6387
+ matchCase: "Match case",
6388
+ words: "Words",
6389
+ print: "Print",
6390
+ autosavedNote: "Autosaved",
6391
+ uploadFile: "Upload a file",
6392
+ uploading: "Uploading",
6393
+ uploadFailed: "Could not upload the file"
5683
6394
  };
5684
6395
  var pl2 = {
5685
6396
  documents: "Dokumenty",
@@ -5696,6 +6407,10 @@ var pl2 = {
5696
6407
  versions: "Wersje",
5697
6408
  details: "Szczeg\xF3\u0142y",
5698
6409
  noOutline: "Ten dokument nie ma nag\u0142\xF3wk\xF3w",
6410
+ findHeading: "Znajd\u017A nag\u0142\xF3wek",
6411
+ read: "przeczytano",
6412
+ showSections: "Poka\u017C sekcje",
6413
+ hideSections: "Ukryj sekcje",
5699
6414
  current: "Bie\u017C\u0105ca",
5700
6415
  size: "Rozmiar",
5701
6416
  updated: "Zmieniono",
@@ -5743,6 +6458,12 @@ var pl2 = {
5743
6458
  save: "Zapisz",
5744
6459
  saving: "Zapisywanie",
5745
6460
  saved: "Zapisano",
6461
+ align: "Wyr\xF3wnanie",
6462
+ moreTools: "Wi\u0119cej narz\u0119dzi",
6463
+ fewerTools: "Mniej narz\u0119dzi",
6464
+ typeFilter: "Typ",
6465
+ selectAll: "Zaznacz wszystkie",
6466
+ clearPick: "Wyczy\u015B\u0107",
5746
6467
  saveFailed: "Nie uda\u0142o si\u0119 zapisa\u0107",
5747
6468
  remove: "Usu\u0144",
5748
6469
  notePlaceholder: "Napisz notatk\u0119",
@@ -5806,6 +6527,14 @@ var pl2 = {
5806
6527
  chooseFile: "Wybierz plik",
5807
6528
  put: "Wstaw",
5808
6529
  link: "Link",
6530
+ footnote: "Przypis",
6531
+ footnoteText: "Tekst przypisu",
6532
+ formula: "Wz\xF3r",
6533
+ formulaHint: "Zapisany jako r\xF3wnanie Word",
6534
+ symbols: "Znaki specjalne",
6535
+ symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
6536
+ update: "Zmie\u0144",
6537
+ removeFootnote: "Usu\u0144 przypis",
5809
6538
  linkAddress: "Adres linku",
5810
6539
  apply: "Zastosuj",
5811
6540
  unlink: "Usu\u0144 link",
@@ -5851,6 +6580,11 @@ var pl2 = {
5851
6580
  removed: "Usuni\u0119to",
5852
6581
  someone: "Kto\u015B",
5853
6582
  copyAs: "Zr\xF3b kopi\u0119 XLSX",
6583
+ downloadAs: "Pobierz jako",
6584
+ makeCopy: "Utw\xF3rz kopi\u0119",
6585
+ copyOf: "Kopia",
6586
+ rename: "Zmie\u0144 nazw\u0119",
6587
+ renameFailed: "Nie uda\u0142o si\u0119 zmieni\u0107 nazwy",
5854
6588
  copyFailed: "Nie uda\u0142o si\u0119 zrobi\u0107 kopii",
5855
6589
  editComment: "Edytuj",
5856
6590
  delete: "Usu\u0144",
@@ -5937,7 +6671,52 @@ var pl2 = {
5937
6671
  untitled: "Bez tytu\u0142u",
5938
6672
  kindHints: { docx: "Word, DOCX", markdown: "MD, ten sam edytor", sheet: "Excel, XLSX", slides: "Slajdy HTML" },
5939
6673
  newKinds: { docx: "Dokument", markdown: "Markdown", sheet: "Arkusz", slides: "Prezentacja" },
5940
- templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" }
6674
+ templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" },
6675
+ menuFile: "Plik",
6676
+ menuEdit: "Edycja",
6677
+ menuFormat: "Format",
6678
+ menuTools: "Narz\u0119dzia",
6679
+ zoom: "Powi\u0119kszenie",
6680
+ font: "Czcionka",
6681
+ fontSize: "Rozmiar czcionki",
6682
+ defaultFont: "Domy\u015Blna",
6683
+ lineSpacing: "Interlinia i odst\u0119py",
6684
+ single: "Pojedyncza",
6685
+ double: "Podw\xF3jna",
6686
+ spaceAfter: "Dodaj odst\u0119p po akapicie",
6687
+ noSpaceAfter: "Usu\u0144 odst\u0119p po akapicie",
6688
+ superscript: "Indeks g\xF3rny",
6689
+ subscript: "Indeks dolny",
6690
+ painter: "Malarz format\xF3w",
6691
+ painterHint: "Zaznacz tekst, dwuklik zostawia w\u0142\u0105czone, Esc ko\u0144czy",
6692
+ pageSetup: "Ustawienia strony",
6693
+ orientation: "Orientacja",
6694
+ portrait: "Pionowa",
6695
+ landscape: "Pozioma",
6696
+ marginsCm: "Marginesy, cm",
6697
+ mTop: "G\xF3rny",
6698
+ mRight: "Prawy",
6699
+ mBottom: "Dolny",
6700
+ mLeft: "Lewy",
6701
+ headerText: "Nag\u0142\xF3wek",
6702
+ footerText: "Stopka",
6703
+ pageNumbers: "Numery stron w stopce",
6704
+ wrapInline: "W linii z tekstem",
6705
+ wrapLeft: "Tekst op\u0142ywa z prawej",
6706
+ wrapRight: "Tekst op\u0142ywa z lewej",
6707
+ cellFill: "Wype\u0142nienie kom\xF3rki",
6708
+ tableBorders: "Obramowanie tabeli",
6709
+ findReplace: "Znajd\u017A i zamie\u0144",
6710
+ replaceWith: "Zamie\u0144 na",
6711
+ replaceOne: "Zamie\u0144",
6712
+ replaceAll: "Zamie\u0144 wszystko",
6713
+ matchCase: "Uwzgl\u0119dnij wielko\u015B\u0107 liter",
6714
+ words: "S\u0142owa",
6715
+ print: "Drukuj",
6716
+ autosavedNote: "Zapisano automatycznie",
6717
+ uploadFile: "Wgraj plik",
6718
+ uploading: "Wysy\u0142anie",
6719
+ uploadFailed: "Nie uda\u0142o si\u0119 wgra\u0107 pliku"
5941
6720
  };
5942
6721
  var uk2 = {
5943
6722
  documents: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0438",
@@ -5954,6 +6733,10 @@ var uk2 = {
5954
6733
  versions: "\u0412\u0435\u0440\u0441\u0456\u0457",
5955
6734
  details: "\u0414\u0435\u0442\u0430\u043B\u0456",
5956
6735
  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",
6736
+ findHeading: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A",
6737
+ read: "\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043E",
6738
+ showSections: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
6739
+ hideSections: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
5957
6740
  current: "\u041F\u043E\u0442\u043E\u0447\u043D\u0430",
5958
6741
  size: "\u0420\u043E\u0437\u043C\u0456\u0440",
5959
6742
  updated: "\u0417\u043C\u0456\u043D\u0435\u043D\u043E",
@@ -6001,6 +6784,12 @@ var uk2 = {
6001
6784
  save: "\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
6002
6785
  saving: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043D\u044F",
6003
6786
  saved: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E",
6787
+ align: "\u0412\u0438\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u043D\u043D\u044F",
6788
+ moreTools: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
6789
+ fewerTools: "\u041C\u0435\u043D\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
6790
+ typeFilter: "\u0422\u0438\u043F",
6791
+ selectAll: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0441\u0456",
6792
+ clearPick: "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",
6004
6793
  saveFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
6005
6794
  remove: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
6006
6795
  notePlaceholder: "\u041D\u0430\u043F\u0438\u0448\u0456\u0442\u044C \u043D\u043E\u0442\u0430\u0442\u043A\u0443",
@@ -6063,6 +6852,14 @@ var uk2 = {
6063
6852
  imageLink: "\u0410\u0434\u0440\u0435\u0441\u0430 \u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u043D\u044F",
6064
6853
  chooseFile: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0444\u0430\u0439\u043B",
6065
6854
  put: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
6855
+ footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
6856
+ footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
6857
+ formula: "\u0424\u043E\u0440\u043C\u0443\u043B\u0430",
6858
+ formulaHint: "\u0417\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044C\u0441\u044F \u044F\u043A \u0440\u0456\u0432\u043D\u044F\u043D\u043D\u044F Word",
6859
+ symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
6860
+ symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
6861
+ update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
6862
+ removeFootnote: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0432\u0438\u043D\u043E\u0441\u043A\u0443",
6066
6863
  link: "\u041F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
6067
6864
  linkAddress: "\u0410\u0434\u0440\u0435\u0441\u0430 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
6068
6865
  apply: "\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438",
@@ -6109,6 +6906,11 @@ var uk2 = {
6109
6906
  removed: "\u0412\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
6110
6907
  someone: "\u0425\u0442\u043E\u0441\u044C",
6111
6908
  copyAs: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E XLSX",
6909
+ downloadAs: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u044F\u043A",
6910
+ makeCopy: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
6911
+ copyOf: "\u041A\u043E\u043F\u0456\u044F",
6912
+ rename: "\u041F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
6913
+ renameFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u043F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
6112
6914
  copyFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
6113
6915
  editComment: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
6114
6916
  delete: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
@@ -6195,7 +6997,52 @@ var uk2 = {
6195
6997
  untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0438",
6196
6998
  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" },
6197
6999
  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" },
6198
- 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" }
7000
+ 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" },
7001
+ menuFile: "\u0424\u0430\u0439\u043B",
7002
+ menuEdit: "\u041F\u0440\u0430\u0432\u043A\u0430",
7003
+ menuFormat: "\u0424\u043E\u0440\u043C\u0430\u0442",
7004
+ menuTools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438",
7005
+ zoom: "\u041C\u0430\u0441\u0448\u0442\u0430\u0431",
7006
+ font: "\u0428\u0440\u0438\u0444\u0442",
7007
+ fontSize: "\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443",
7008
+ defaultFont: "\u0422\u0438\u043F\u043E\u0432\u0438\u0439",
7009
+ 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",
7010
+ single: "\u041E\u0434\u0438\u043D\u0430\u0440\u043D\u0438\u0439",
7011
+ double: "\u041F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439",
7012
+ 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",
7013
+ 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",
7014
+ superscript: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
7015
+ subscript: "\u041D\u0438\u0436\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
7016
+ painter: "\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438 \u0444\u043E\u0440\u043C\u0430\u0442",
7017
+ 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",
7018
+ pageSetup: "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
7019
+ orientation: "\u041E\u0440\u0456\u0454\u043D\u0442\u0430\u0446\u0456\u044F",
7020
+ portrait: "\u041A\u043D\u0438\u0436\u043A\u043E\u0432\u0430",
7021
+ landscape: "\u0410\u043B\u044C\u0431\u043E\u043C\u043D\u0430",
7022
+ marginsCm: "\u041F\u043E\u043B\u044F, \u0441\u043C",
7023
+ mTop: "\u0412\u0435\u0440\u0445\u043D\u0454",
7024
+ mRight: "\u041F\u0440\u0430\u0432\u0435",
7025
+ mBottom: "\u041D\u0438\u0436\u043D\u0454",
7026
+ mLeft: "\u041B\u0456\u0432\u0435",
7027
+ headerText: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
7028
+ footerText: "\u041D\u0438\u0436\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
7029
+ pageNumbers: "\u041D\u043E\u043C\u0435\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043E\u043A \u0443\u043D\u0438\u0437\u0443",
7030
+ wrapInline: "\u0423 \u0440\u044F\u0434\u043A\u0443 \u0437 \u0442\u0435\u043A\u0441\u0442\u043E\u043C",
7031
+ wrapLeft: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043F\u0440\u0430\u0432\u043E\u0440\u0443\u0447",
7032
+ wrapRight: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043B\u0456\u0432\u043E\u0440\u0443\u0447",
7033
+ cellFill: "\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043A\u043B\u0456\u0442\u0438\u043D\u043A\u0438",
7034
+ tableBorders: "\u041C\u0435\u0436\u0456 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
7035
+ findReplace: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0439 \u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
7036
+ replaceWith: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u043D\u0430",
7037
+ replaceOne: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
7038
+ replaceAll: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u0432\u0441\u0456",
7039
+ matchCase: "\u0417 \u0443\u0440\u0430\u0445\u0443\u0432\u0430\u043D\u043D\u044F\u043C \u0440\u0435\u0433\u0456\u0441\u0442\u0440\u0443",
7040
+ words: "\u0421\u043B\u043E\u0432\u0430",
7041
+ print: "\u0414\u0440\u0443\u043A",
7042
+ autosavedNote: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u043D\u043E",
7043
+ uploadFile: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B",
7044
+ uploading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
7045
+ 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"
6199
7046
  };
6200
7047
  var texts = { en: en2, pl: pl2, uk: uk2 };
6201
7048
 
@@ -6203,8 +7050,8 @@ var texts = { en: en2, pl: pl2, uk: uk2 };
6203
7050
  var ours = "w100n-collab";
6204
7051
  var schemas = /* @__PURE__ */ new Map();
6205
7052
  var schemaOf = (kind) => schemas.get(kind) ?? schemas.set(kind, (0, import_core3.getSchema)(kit(kind, texts.en))).get(kind);
6206
- var parse2 = async (kind, bytes) => kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc;
6207
- var edits = (tr) => tr.changedParentTypes.has(tr.doc.get("default")) || tr.changedParentTypes.has(tr.doc.get("book"));
7053
+ var parse3 = async (kind, bytes) => kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc;
7054
+ var edits = (tr) => tr.changedParentTypes.has(tr.doc.get("default")) || tr.changedParentTypes.has(tr.doc.get("book")) || tr.changedParentTypes.has(tr.doc.get("setup"));
6208
7055
  var filled = (doc) => doc.getXmlFragment("default").length > 0 || doc.getMap("book").size > 0;
6209
7056
  function seed(doc, kind, bytes, json) {
6210
7057
  if (filled(doc)) return false;
@@ -6249,11 +7096,11 @@ function applyText(doc, kind, changes, origin) {
6249
7096
  if (c.replace) step.replaceWith(at, at + c.find.length, schema.text(c.replace, step.doc.resolve(at + 1).marks()));
6250
7097
  else step.delete(at, at + c.find.length);
6251
7098
  }
6252
- (0, import_y_tiptap2.updateYFragment)({ transact: (run) => doc.transact(run, origin) }, fragment, step.doc, { mapping: /* @__PURE__ */ new Map(), isOMark: /* @__PURE__ */ new Map() });
7099
+ (0, import_y_tiptap2.updateYFragment)({ transact: (run2) => doc.transact(run2, origin) }, fragment, step.doc, { mapping: /* @__PURE__ */ new Map(), isOMark: /* @__PURE__ */ new Map() });
6253
7100
  return changes.length;
6254
7101
  }
6255
- async function write2(kind, base, node, load2) {
6256
- if (kind === "docx") return writeDocx(base, node.toJSON(), load2);
7102
+ async function write2(kind, base, node, load2, setup) {
7103
+ if (kind === "docx") return writeDocx(base, node.toJSON(), load2, setup);
6257
7104
  const parsed = fromMarkdown(new TextDecoder().decode(base));
6258
7105
  return new TextEncoder().encode(toMarkdown(node, track(parsed, node.type.schema.nodeFromJSON(parsed.doc))).text).buffer;
6259
7106
  }
@@ -6290,11 +7137,11 @@ async function save(doc, kind, base, put, load2, note) {
6290
7137
  };
6291
7138
  doc.on("afterTransaction", watch);
6292
7139
  try {
6293
- const bytes = await write2(kind, base, node, load2);
7140
+ const bytes = await write2(kind, base, node, load2, doc.getMap("setup").size ? doc.getMap("setup").toJSON() : void 0);
6294
7141
  const changed2 = !same2(bytes, base);
6295
7142
  const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
6296
7143
  const refs2 = [];
6297
- if (changed2) schema.nodeFromJSON(await parse2(kind, bytes)).descendants((n) => {
7144
+ if (changed2) schema.nodeFromJSON(await parse3(kind, bytes)).descendants((n) => {
6298
7145
  if (n.isBlock) refs2.push([n.type.name, n.attrs.ref ?? null]);
6299
7146
  });
6300
7147
  doc.transact(() => {