@w100n/documents 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.14.0";
53
+ var version = "0.15.1";
54
54
 
55
55
  // src/docx/xml.ts
56
56
  function parse(s) {
@@ -672,6 +672,266 @@ function resolve(dir, target) {
672
672
  return out.join("/");
673
673
  }
674
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
+
675
935
  // src/docx/read.ts
676
936
  var blank = () => ({ align: null, indent: 0, line: null, after: null, ref: null });
677
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" };
@@ -691,6 +951,7 @@ var Reader = class {
691
951
  this.pkg = pkg;
692
952
  this.n = 0;
693
953
  this.refs = /* @__PURE__ */ new Map();
954
+ this.footnotes = null;
694
955
  this.counters = /* @__PURE__ */ new Map();
695
956
  this.fmts = /* @__PURE__ */ new Map();
696
957
  this.media = /* @__PURE__ */ new Map();
@@ -848,6 +1109,14 @@ var Reader = class {
848
1109
  }
849
1110
  return b;
850
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
+ }
851
1120
  src(embed) {
852
1121
  if (!this.media.has(embed)) {
853
1122
  const rel = this.pkg.rels.get(embed);
@@ -893,10 +1162,8 @@ var Reader = class {
893
1162
  const inside = [];
894
1163
  this.walk(k.kids, ctx, k, inside, { lock: null, task: false, box: false });
895
1164
  this.span(s.slice(k.start, k.end), inside, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
896
- } else if (name === "m:oMath") {
897
- const text = s.slice(k.start, k.end).match(/<m:t(?:\s[^>]*)?>[^<]*<\/m:t>/g)?.map((t) => inner(t, parse(t).kids[0])).join("") ?? "";
898
- this.span(s.slice(k.start, k.end), text ? [{ text, raw: null, run: null, ctx, span: null }] : [], out, ctx, null);
899
- } 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";
900
1167
  else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
901
1168
  }
902
1169
  }
@@ -917,17 +1184,17 @@ var Reader = class {
917
1184
  out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
918
1185
  return;
919
1186
  }
920
- 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 };
921
1188
  const push = (text, raw, extra) => {
922
1189
  if (text !== null && st.box) {
923
1190
  st.box = false;
924
1191
  if (text.startsWith(" ") && raw === null) {
925
- 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 });
926
1193
  text = text.slice(1);
927
1194
  if (!text) return;
928
1195
  }
929
1196
  }
930
- out.push({ text, raw, run, ctx, span: null, ...extra });
1197
+ out.push({ text, raw, run: run2, ctx, span: null, ...extra });
931
1198
  };
932
1199
  for (const c of k.kids) {
933
1200
  const raw = s.slice(c.start, c.end);
@@ -960,6 +1227,11 @@ var Reader = class {
960
1227
  else push("\n", raw);
961
1228
  break;
962
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
+ }
963
1235
  case "w:fldChar":
964
1236
  push(null, raw, { fld: attr(s, c, "w:fldCharType") ?? "" });
965
1237
  break;
@@ -1164,10 +1436,16 @@ function fmtAt(p) {
1164
1436
  link ?? (link = p.span?.link ?? null);
1165
1437
  return link === f.link && rev === f.rev ? f : { ...f, link, rev };
1166
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();
1167
1440
  function inline(pieces2) {
1168
1441
  const out = [];
1169
1442
  let key2 = "";
1170
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
+ }
1171
1449
  if (p.img) {
1172
1450
  out.push({ type: "image", attrs: { ...p.img } });
1173
1451
  key2 = "";
@@ -1332,7 +1610,7 @@ function inlineSig(kids) {
1332
1610
  out += (next === key2 ? "" : `${next}`) + k.text;
1333
1611
  key2 = next;
1334
1612
  } else {
1335
- 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}` : ""}`;
1336
1614
  key2 = null;
1337
1615
  }
1338
1616
  }
@@ -1463,6 +1741,7 @@ var Writer = class {
1463
1741
  this.srcs = null;
1464
1742
  this.tocs = false;
1465
1743
  this.revs = /* @__PURE__ */ new Map();
1744
+ this.lastNote = null;
1466
1745
  this.r = new Reader(pkg);
1467
1746
  this.s = pkg.doc;
1468
1747
  for (const id of pkg.rels.keys()) this.relIds.add(id);
@@ -1485,6 +1764,7 @@ var Writer = class {
1485
1764
  if (this.last === "tbl" && list[list.length - 1]?.kind !== "tbl") xml += "<w:p/>";
1486
1765
  const changed2 = /* @__PURE__ */ new Map();
1487
1766
  const text = this.marginal(s.slice(0, body.open) + xml + rest + s.slice(tail), setup, changed2);
1767
+ this.footnotes(doc, changed2);
1488
1768
  if (text !== s) changed2.set(this.pkg.main, text);
1489
1769
  if (this.rels.length) {
1490
1770
  const path = this.pkg.relsPath(this.pkg.main);
@@ -1610,6 +1890,37 @@ var Writer = class {
1610
1890
  if (o.kind === "toc") return b && sig(o.node) === sig(b.node) ? s.slice(b.start, b.end) : this.toc(o.node);
1611
1891
  return this.code(o);
1612
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
+ }
1613
1924
  marginal(text, setup, changed2) {
1614
1925
  if (!setup || !setup.page && setup.header === void 0 && setup.footer === void 0 && setup.numbers === void 0) return text;
1615
1926
  const end = text.lastIndexOf("</w:body>");
@@ -1673,11 +1984,11 @@ var Writer = class {
1673
1984
  const open = sec.indexOf(">") + 1;
1674
1985
  sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
1675
1986
  };
1676
- const line = (words, page) => {
1987
+ const line = (words2, page) => {
1677
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>';
1678
- const run = words ? `<w:r><w:t xml:space="preserve">${escape(words)}</w:t></w:r>` : "";
1679
- if (!words && !page) return "";
1680
- return `<w:p><w:pPr>${page && words ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run}${page && words ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
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>`;
1681
1992
  };
1682
1993
  if (setup.header !== void 0) part("header", line(setup.header, false));
1683
1994
  if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
@@ -1870,7 +2181,7 @@ var Writer = class {
1870
2181
  const base = p.span ? fmtAt({ ...p, span: null }) : fmt;
1871
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 });
1872
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 });
1873
- 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 });
1874
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 });
1875
2186
  if (p.run) counts.set(p.run, n);
1876
2187
  }
@@ -1885,6 +2196,8 @@ var Writer = class {
1885
2196
  for (const ch of n.text ?? "") B.push({ ch: ch === "\r" ? "\n" : ch, fmt: f, key: k });
1886
2197
  } else if (n.type === "hardBreak") B.push({ ch: "\n", fmt: lastFmt, key: keyOf(lastFmt) });
1887
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 = {}) });
1888
2201
  }
1889
2202
  const boxes2 = units.filter((u) => u.box);
1890
2203
  let box2 = null;
@@ -1940,6 +2253,22 @@ var Writer = class {
1940
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 });
1941
2254
  continue;
1942
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 || !want.note.id)) {
2264
+ want.note.id = u.note.id;
2265
+ out.push({ ch: u.ch, raw: u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
2266
+ } else {
2267
+ want.note.id = typeof want.note.id === "string" && want.note.id ? want.note.id : String(this.noteId());
2268
+ 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 });
2269
+ }
2270
+ continue;
2271
+ }
1943
2272
  if (i >= 0) {
1944
2273
  const u = A[i];
1945
2274
  if (u.span && intact.has(u.span)) {
@@ -1949,18 +2278,18 @@ var Writer = class {
1949
2278
  const from = u.span ? u.base : u.fmt;
1950
2279
  const keep = u.ch === "\n" || keyOf(from) === want.key;
1951
2280
  const fmt = keep ? from : want.fmt;
1952
- const run = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
1953
- 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 });
2281
+ const run2 = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
2282
+ 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 });
1954
2283
  } else {
1955
2284
  const left = lastChar();
1956
2285
  const right = next[j + 1] >= 0 ? A[next[j + 1]] : null;
1957
2286
  const base = left ? { run: left.run, fmt: left.fmt } : right ? { run: right.run ?? paraBase.run, fmt: right.span ? right.base : right.fmt } : paraBase;
1958
- const run = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
2287
+ const run2 = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
1959
2288
  const shared = [];
1960
2289
  if (left && right) {
1961
2290
  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]);
1962
2291
  }
1963
- 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 });
2292
+ 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 });
1964
2293
  }
1965
2294
  }
1966
2295
  let xml = "";
@@ -2043,10 +2372,10 @@ var Writer = class {
2043
2372
  this.relIds.add(`rId${n}`);
2044
2373
  return `rId${n}`;
2045
2374
  }
2046
- derive(run, from, to) {
2047
- const cache = run.derived ?? (run.derived = /* @__PURE__ */ new Map());
2375
+ derive(run2, from, to) {
2376
+ const cache = run2.derived ?? (run2.derived = /* @__PURE__ */ new Map());
2048
2377
  const key2 = keyOf(from) + ">" + keyOf(to);
2049
- if (!cache.has(key2)) cache.set(key2, { open: run.open, rPr: this.delta(run.rPr, from, to), fmt: to, el: null, parent: null });
2378
+ if (!cache.has(key2)) cache.set(key2, { open: run2.open, rPr: this.delta(run2.rPr, from, to), fmt: to, el: null, parent: null });
2050
2379
  return cache.get(key2);
2051
2380
  }
2052
2381
  delta(rPr, from, to) {
@@ -2095,8 +2424,8 @@ var Writer = class {
2095
2424
  } else if (!to.link && from.link && this.pkg.styles.isLink(style)) set["w:rStyle"] = null;
2096
2425
  return Object.keys(set).length ? rebuild(rPr, "w:rPr", R, set) : rPr;
2097
2426
  }
2098
- runXml(run, glyphs, counts) {
2099
- 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);
2427
+ runXml(run2, glyphs, counts) {
2428
+ 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);
2100
2429
  let body = "";
2101
2430
  let text = "";
2102
2431
  const tag = glyphs[0]?.ctx.some((w) => w.rev?.startsWith('["del"')) ? "w:delText" : "w:t";
@@ -2111,7 +2440,7 @@ var Writer = class {
2111
2440
  } else text += g.ch;
2112
2441
  }
2113
2442
  flush();
2114
- return run.open + run.rPr + body + "</w:r>";
2443
+ return run2.open + run2.rPr + body + "</w:r>";
2115
2444
  }
2116
2445
  embed(src) {
2117
2446
  if (!this.srcs) {
@@ -2350,14 +2679,14 @@ async function readDocx(bytes) {
2350
2679
  const size2 = sect && kid(sect, "w:pgSz");
2351
2680
  const mar = sect && kid(sect, "w:pgMar");
2352
2681
  const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
2353
- const words = (kind) => {
2682
+ const words2 = (kind) => {
2354
2683
  const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
2355
2684
  const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
2356
2685
  const xml = part ? pkg.text(part.target) ?? "" : "";
2357
2686
  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) };
2358
2687
  };
2359
- const head = words("header");
2360
- const foot = words("footer");
2688
+ const head = words2("header");
2689
+ const foot = words2("footer");
2361
2690
  return {
2362
2691
  marginal: { header: head.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
2363
2692
  doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
@@ -2399,6 +2728,10 @@ function measure(view) {
2399
2728
  const room = page.height - top - bottom;
2400
2729
  const els = [...view.dom.children];
2401
2730
  const gaps = [];
2731
+ const line = page.width - page.margins[1] - page.margins[3];
2732
+ const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
2733
+ let notes2 = [];
2734
+ let count = 0;
2402
2735
  let i = 0;
2403
2736
  let shift = 0;
2404
2737
  let start = 0;
@@ -2412,17 +2745,25 @@ function measure(view) {
2412
2745
  if (!el) return;
2413
2746
  const y = el.offsetTop - shift;
2414
2747
  const end = y + el.offsetHeight;
2748
+ const mine = [];
2749
+ node.descendants((d) => {
2750
+ if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
2751
+ });
2415
2752
  if (node.type.name === "pageBreak") {
2416
- gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1 });
2753
+ gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
2754
+ notes2 = [];
2417
2755
  start = end;
2418
- } else if (end > start + room && y > start) {
2419
- gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1 });
2756
+ } else if (end > start + room - area([...notes2, ...mine]) && y > start) {
2757
+ gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
2758
+ notes2 = [];
2420
2759
  start = y;
2421
2760
  }
2761
+ notes2.push(...mine);
2762
+ count += mine.length;
2422
2763
  while (end > start + room) start += room;
2423
2764
  last = end;
2424
2765
  });
2425
- gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true });
2766
+ gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true, notes: notes2 });
2426
2767
  return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
2427
2768
  }
2428
2769
  var Pager = import_core.Extension.create({
@@ -2440,11 +2781,11 @@ var Pager = import_core.Extension.create({
2440
2781
  view(view) {
2441
2782
  let timer = 0;
2442
2783
  let sig2 = "";
2443
- const run = () => {
2784
+ const run2 = () => {
2444
2785
  if (!view.dom.isConnected) return;
2445
2786
  const gaps = measure(view);
2446
2787
  const { marks } = paging.getState(view.state);
2447
- const next = gaps.map((g) => `${g.pos}:${g.height}`).join() + `|${marks.header}|${marks.footer}`;
2788
+ const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks.header}|${marks.footer}`;
2448
2789
  if (next === sig2) return;
2449
2790
  sig2 = next;
2450
2791
  const line = (parent, cls, text) => {
@@ -2469,13 +2810,25 @@ var Pager = import_core.Extension.create({
2469
2810
  el.contentEditable = "false";
2470
2811
  line(el, "w100n-text-foot", marks.footer);
2471
2812
  if (!g.end) line(el, "w100n-text-head", marks.header);
2813
+ if (g.notes.length) {
2814
+ const list = document.createElement("div");
2815
+ list.className = "w100n-text-footnotes";
2816
+ for (const note of g.notes) {
2817
+ const p = document.createElement("p");
2818
+ const n = document.createElement("sup");
2819
+ n.textContent = note.slice(0, note.indexOf(" "));
2820
+ p.append(n, note.slice(note.indexOf(" ")));
2821
+ list.append(p);
2822
+ }
2823
+ el.append(list);
2824
+ }
2472
2825
  return el;
2473
- }, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}`, side: -1, ignoreSelection: true }))]);
2826
+ }, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}:${g.notes.join("\n")}`, side: -1, ignoreSelection: true }))]);
2474
2827
  view.dispatch(view.state.tr.setMeta(paging, { set }).setMeta("addToHistory", false));
2475
2828
  };
2476
2829
  const later = (ms) => {
2477
2830
  clearTimeout(timer);
2478
- timer = window.setTimeout(run, ms);
2831
+ timer = window.setTimeout(run2, ms);
2479
2832
  };
2480
2833
  const watch = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => later(200));
2481
2834
  watch?.observe(view.dom);
@@ -2630,6 +2983,37 @@ var PageBreak = import_core2.Node.create({
2630
2983
  return ["div", { "data-page-break": "", "data-label": this.options.label, class: "w100n-text-break", contenteditable: "false" }];
2631
2984
  }
2632
2985
  });
2986
+ var Formula = import_core2.Node.create({
2987
+ name: "math",
2988
+ group: "inline",
2989
+ inline: true,
2990
+ atom: true,
2991
+ selectable: true,
2992
+ addAttributes: () => ({ latex: { default: "", parseHTML: (el) => el.getAttribute("data-math") ?? "" } }),
2993
+ parseHTML: () => [{ tag: "span[data-math]" }],
2994
+ renderHTML: ({ node }) => ["span", { "data-math": node.attrs.latex, class: "w100n-math" }],
2995
+ addNodeView: () => ({ node }) => {
2996
+ const dom = document.createElement("span");
2997
+ dom.className = "w100n-math";
2998
+ dom.dataset.math = node.attrs.latex;
2999
+ dom.contentEditable = "false";
3000
+ dom.innerHTML = mathml(node.attrs.latex);
3001
+ return { dom };
3002
+ }
3003
+ });
3004
+ var Footnote = import_core2.Node.create({
3005
+ name: "footnote",
3006
+ group: "inline",
3007
+ inline: true,
3008
+ atom: true,
3009
+ selectable: true,
3010
+ addAttributes: () => ({
3011
+ id: { default: null, parseHTML: (el) => el.getAttribute("data-note-id") },
3012
+ text: { default: "", parseHTML: (el) => el.getAttribute("title") ?? "" }
3013
+ }),
3014
+ parseHTML: () => [{ tag: "sup[data-footnote]" }],
3015
+ renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
3016
+ });
2633
3017
  var headings = (doc, after) => {
2634
3018
  const found = [];
2635
3019
  doc.descendants((node, pos) => {
@@ -2927,7 +3311,7 @@ function kit(kind, t, live) {
2927
3311
  Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
2928
3312
  Note,
2929
3313
  Notes,
2930
- ...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
3314
+ ...kind === "docx" ? [Formula, Footnote, Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
2931
3315
  ...live ? [import_extension_collaboration.default.configure({ document: live.doc }), import_extension_collaboration_caret.default.configure({ provider: live.link, user: live.user })] : []
2932
3316
  ];
2933
3317
  }
@@ -3108,7 +3492,7 @@ var track = ({ doc: _json, ...parsed }, doc) => {
3108
3492
  return nodes.length === parsed.raws.length ? { ...parsed, nodes } : { ...parsed, nodes: [], raws: [], head: "", tail: "\n" };
3109
3493
  };
3110
3494
  var ticks = (node, side2) => {
3111
- const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((run) => run.length));
3495
+ const len = Math.max(0, ...(node.isText ? node.text.match(/`+/g) ?? [] : []).map((run2) => run2.length));
3112
3496
  return len ? side2 > 0 ? ` ${"`".repeat(len + 1)}` : `${"`".repeat(len + 1)} ` : "`";
3113
3497
  };
3114
3498
  var plain2 = (mark, parent, index) => {
@@ -3126,7 +3510,7 @@ var plain2 = (mark, parent, index) => {
3126
3510
  function serializer(style, hints, before, cell2 = false) {
3127
3511
  let form = null;
3128
3512
  const hint = (node) => hints[node.attrs.ref] ?? {};
3129
- const run = (parent, index, types) => {
3513
+ const run2 = (parent, index, types) => {
3130
3514
  let n = 0;
3131
3515
  for (let i = index - 1; i >= 0 && types.includes(parent.child(i).type.name); i--) n++;
3132
3516
  if (!index && before && types.includes(before.type.name)) n++;
@@ -3140,7 +3524,7 @@ function serializer(style, hints, before, cell2 = false) {
3140
3524
  state.options.tightLists = was;
3141
3525
  };
3142
3526
  const list = (state, node, parent, index) => {
3143
- const bullet = hint(node).bullet ?? (run(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
3527
+ const bullet = hint(node).bullet ?? (run2(parent, index, ["bulletList", "taskList"]) ? style.bullet === "-" ? "*" : "-" : style.bullet);
3144
3528
  tight(state, node, () => state.renderList(node, " ", () => `${bullet} `));
3145
3529
  };
3146
3530
  const blank3 = { open: "", close: "", mixable: true };
@@ -3188,7 +3572,7 @@ ${lines2.join("")}<!-- /toc -->`);
3188
3572
  taskList: list,
3189
3573
  orderedList(state, node, parent, index) {
3190
3574
  const start = node.attrs.start ?? 1;
3191
- const delim = hint(node).delim ?? (run(parent, index, ["orderedList"]) ? style.delim === "." ? ")" : "." : style.delim);
3575
+ const delim = hint(node).delim ?? (run2(parent, index, ["orderedList"]) ? style.delim === "." ? ")" : "." : style.delim);
3192
3576
  const width = String(start + node.childCount - 1).length;
3193
3577
  tight(state, node, () => state.renderList(node, " ".repeat(width + 2), (i) => `${start + i}${delim} `));
3194
3578
  },
@@ -5819,6 +6203,14 @@ var en2 = {
5819
6203
  chooseFile: "Choose a file",
5820
6204
  put: "Insert",
5821
6205
  link: "Link",
6206
+ footnote: "Footnote",
6207
+ footnoteText: "Footnote text",
6208
+ formula: "Formula",
6209
+ formulaHint: "Saved as a Word equation",
6210
+ symbols: "Special characters",
6211
+ symbolSearch: "Search, for example arrow",
6212
+ update: "Update",
6213
+ removeFootnote: "Remove footnote",
5822
6214
  linkAddress: "Link address",
5823
6215
  apply: "Apply",
5824
6216
  unlink: "Remove link",
@@ -6137,6 +6529,14 @@ var pl2 = {
6137
6529
  chooseFile: "Wybierz plik",
6138
6530
  put: "Wstaw",
6139
6531
  link: "Link",
6532
+ footnote: "Przypis",
6533
+ footnoteText: "Tekst przypisu",
6534
+ formula: "Wz\xF3r",
6535
+ formulaHint: "Zapisany jako r\xF3wnanie Word",
6536
+ symbols: "Znaki specjalne",
6537
+ symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
6538
+ update: "Zmie\u0144",
6539
+ removeFootnote: "Usu\u0144 przypis",
6140
6540
  linkAddress: "Adres linku",
6141
6541
  apply: "Zastosuj",
6142
6542
  unlink: "Usu\u0144 link",
@@ -6454,6 +6854,14 @@ var uk2 = {
6454
6854
  imageLink: "\u0410\u0434\u0440\u0435\u0441\u0430 \u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u043D\u044F",
6455
6855
  chooseFile: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0444\u0430\u0439\u043B",
6456
6856
  put: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
6857
+ footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
6858
+ footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
6859
+ formula: "\u0424\u043E\u0440\u043C\u0443\u043B\u0430",
6860
+ formulaHint: "\u0417\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044C\u0441\u044F \u044F\u043A \u0440\u0456\u0432\u043D\u044F\u043D\u043D\u044F Word",
6861
+ symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
6862
+ symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
6863
+ update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
6864
+ removeFootnote: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0432\u0438\u043D\u043E\u0441\u043A\u0443",
6457
6865
  link: "\u041F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
6458
6866
  linkAddress: "\u0410\u0434\u0440\u0435\u0441\u0430 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
6459
6867
  apply: "\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438",
@@ -6644,7 +7052,7 @@ var texts = { en: en2, pl: pl2, uk: uk2 };
6644
7052
  var ours = "w100n-collab";
6645
7053
  var schemas = /* @__PURE__ */ new Map();
6646
7054
  var schemaOf = (kind) => schemas.get(kind) ?? schemas.set(kind, (0, import_core3.getSchema)(kit(kind, texts.en))).get(kind);
6647
- var parse2 = async (kind, bytes) => kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc;
7055
+ var parse3 = async (kind, bytes) => kind === "docx" ? (await readDocx(bytes)).doc : fromMarkdown(new TextDecoder().decode(bytes)).doc;
6648
7056
  var edits = (tr) => tr.changedParentTypes.has(tr.doc.get("default")) || tr.changedParentTypes.has(tr.doc.get("book")) || tr.changedParentTypes.has(tr.doc.get("setup"));
6649
7057
  var filled = (doc) => doc.getXmlFragment("default").length > 0 || doc.getMap("book").size > 0;
6650
7058
  function seed(doc, kind, bytes, json) {
@@ -6690,7 +7098,7 @@ function applyText(doc, kind, changes, origin) {
6690
7098
  if (c.replace) step.replaceWith(at, at + c.find.length, schema.text(c.replace, step.doc.resolve(at + 1).marks()));
6691
7099
  else step.delete(at, at + c.find.length);
6692
7100
  }
6693
- (0, import_y_tiptap2.updateYFragment)({ transact: (run) => doc.transact(run, origin) }, fragment, step.doc, { mapping: /* @__PURE__ */ new Map(), isOMark: /* @__PURE__ */ new Map() });
7101
+ (0, import_y_tiptap2.updateYFragment)({ transact: (run2) => doc.transact(run2, origin) }, fragment, step.doc, { mapping: /* @__PURE__ */ new Map(), isOMark: /* @__PURE__ */ new Map() });
6694
7102
  return changes.length;
6695
7103
  }
6696
7104
  async function write2(kind, base, node, load2, setup) {
@@ -6735,7 +7143,7 @@ async function save(doc, kind, base, put, load2, note) {
6735
7143
  const changed2 = !same2(bytes, base);
6736
7144
  const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
6737
7145
  const refs2 = [];
6738
- if (changed2) schema.nodeFromJSON(await parse2(kind, bytes)).descendants((n) => {
7146
+ if (changed2) schema.nodeFromJSON(await parse3(kind, bytes)).descendants((n) => {
6739
7147
  if (n.isBlock) refs2.push([n.type.name, n.attrs.ref ?? null]);
6740
7148
  });
6741
7149
  doc.transact(() => {