@w100n/documents 0.13.0 → 0.14.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 (52) 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-4TPL7DES.js} +51 -10
  4. package/dist/SheetView-4TPL7DES.js.map +1 -0
  5. package/dist/{TextEditor-OLBLWC6F.js → TextEditor-VBHWUOZR.js} +636 -225
  6. package/dist/TextEditor-VBHWUOZR.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-MRP3EURG.js → chunk-5MH4WDW4.js} +133 -20
  10. package/dist/chunk-5MH4WDW4.js.map +1 -0
  11. package/dist/{chunk-WR3MT7KP.js → chunk-DR3TTJWZ.js} +374 -29
  12. package/dist/chunk-DR3TTJWZ.js.map +1 -0
  13. package/dist/{chunk-T7XCGDE5.js → chunk-RCQODE2Z.js} +2 -2
  14. package/dist/collab.cjs +487 -46
  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 +1449 -314
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.css +888 -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 +282 -32
  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.map +0 -1
  47. package/dist/chunk-MRP3EURG.js.map +0 -1
  48. package/dist/chunk-WR3MT7KP.js.map +0 -1
  49. package/dist/grid-EI5JNZAA.js.map +0 -1
  50. package/dist/write-DaVtTJCS.d.cts +0 -6
  51. package/dist/write-DaVtTJCS.d.ts +0 -6
  52. /package/dist/{chunk-T7XCGDE5.js.map → chunk-RCQODE2Z.js.map} +0 -0
package/dist/collab.cjs CHANGED
@@ -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.14.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;
@@ -665,7 +673,7 @@ function resolve(dir, target) {
665
673
  }
666
674
 
667
675
  // src/docx/read.ts
668
- var blank = () => ({ align: null, indent: 0, ref: null });
676
+ var blank = () => ({ align: null, indent: 0, line: null, after: null, ref: null });
669
677
  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
678
  function align(v) {
671
679
  if (v === "center") return "center";
@@ -783,7 +791,14 @@ var Reader = class {
783
791
  const src = p.pic && this.src(p.pic.embed);
784
792
  if (!src) continue;
785
793
  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) };
794
+ p.img = {
795
+ src,
796
+ alt: meta2.descr ?? null,
797
+ title: meta2.title ?? null,
798
+ width: Math.round(p.pic.cx / 9525),
799
+ height: Math.round(p.pic.cy / 9525),
800
+ wrap: /<wp:anchor\b/.test(p.raw) ? /<wp:positionH\b[^>]*>\s*<wp:align>right</.test(p.raw) ? "right" : "left" : null
801
+ };
787
802
  }
788
803
  const pPr = kid(el, "w:pPr");
789
804
  const styles = this.pkg.styles;
@@ -811,7 +826,11 @@ var Reader = class {
811
826
  const ind = pPr && kid(pPr, "w:ind");
812
827
  const left = ind && (attr(s, ind, "w:left") ?? attr(s, ind, "w:start"));
813
828
  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 };
829
+ const sp = pPr && kid(pPr, "w:spacing");
830
+ const lineAt = sp && attr(s, sp, "w:line");
831
+ const afterAt = sp && attr(s, sp, "w:after");
832
+ const auto = !sp || !attr(s, sp, "w:lineRule") || attr(s, sp, "w:lineRule") === "auto";
833
+ 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
834
  const node = level ? { type: "heading", attrs: { level, ...base } } : { type: "paragraph", attrs: base };
816
835
  const content = inline(final);
817
836
  if (content.length) node.content = content;
@@ -1019,10 +1038,13 @@ var Reader = class {
1019
1038
  const ref = this.ref();
1020
1039
  const pr = kid(el, "w:tblPr");
1021
1040
  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: [] };
1041
+ const bd = pr && kid(pr, "w:tblBorders");
1042
+ const bare = !!bd && bd.kids.length > 0 && bd.kids.every((k) => /^(none|nil)$/.test(attr(s, k, "w:val") ?? ""));
1043
+ const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, borders: bare ? "none" : null, ref }, content: [] };
1023
1044
  const b = this.block("tbl", el, node, ref);
1024
1045
  const grid2 = kid(el, "w:tblGrid");
1025
1046
  b.cols = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").length : 0;
1047
+ const widths = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").map((k) => Math.floor(+(attr(s, k, "w:w") ?? 0) / 15)) : [];
1026
1048
  const open = [];
1027
1049
  let prev = grid2 ? grid2.end : pr ? pr.end : el.open;
1028
1050
  for (const tr of el.kids) {
@@ -1058,7 +1080,10 @@ var Reader = class {
1058
1080
  if (vm === "continue") open[col].attrs.rowspan++;
1059
1081
  else {
1060
1082
  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() }] };
1083
+ const own = widths.slice(col, col + span2);
1084
+ const shd = tcPr && kid(tcPr, "w:shd");
1085
+ const fill3 = shd ? attr(s, shd, "w:fill") : null;
1086
+ 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
1087
  row2.node.content.push(cell2.node);
1063
1088
  for (let c = col; c < col + span2; c++) open[c] = null;
1064
1089
  if (vm === "restart") open[col] = cell2.node;
@@ -1264,20 +1289,23 @@ var TC = ["w:cnfStyle", "w:tcW", "w:gridSpan", "w:hMerge", "w:vMerge", "w:tcBord
1264
1289
  var REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
1265
1290
  var special = { " ": "<w:tab/>", "\n": "<w:br/>", "\u2011": "<w:noBreakHyphen/>", "\xAD": "<w:softHyphen/>" };
1266
1291
  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]],
1292
+ paragraph: [["align", null], ["indent", 0], ["line", null], ["after", null]],
1293
+ heading: [["level", 1], ["align", null], ["indent", 0], ["line", null], ["after", null]],
1294
+ table: [["align", null], ["borders", null]],
1295
+ tableCell: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1296
+ tableHeader: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1272
1297
  orderedList: [["start", 1]],
1273
1298
  taskItem: [["checked", false]],
1274
1299
  codeBlock: [["language", null]],
1275
- toc: [["entries", "[]"], ["title", null]]
1300
+ toc: [["entries", "[]"], ["title", null]],
1301
+ image: [["src", null], ["alt", null], ["title", null], ["width", null], ["height", null], ["wrap", null]]
1276
1302
  };
1277
1303
  function value(key2, v) {
1278
1304
  if (v === void 0 || v === "" || v === null) return null;
1279
1305
  if (key2 === "align") return v === "left" ? null : v;
1280
1306
  if (key2 === "width" || key2 === "height") return Math.round(Number(v)) || null;
1307
+ if (key2 === "line" || key2 === "after") return Number.isFinite(Number(v)) ? Number(v) : null;
1308
+ if (key2 === "colwidth") return Array.isArray(v) && v.length && v.every((w) => Number(w) > 0) ? v.map((w) => Math.round(Number(w))) : null;
1281
1309
  if (key2 === "indent" || key2 === "level" || key2 === "colspan" || key2 === "rowspan" || key2 === "start") return Number(v) || 0;
1282
1310
  if (key2 === "checked") return !!v;
1283
1311
  return v;
@@ -1311,7 +1339,7 @@ function inlineSig(kids) {
1311
1339
  return out;
1312
1340
  }
1313
1341
  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]);
1342
+ 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
1343
  }
1316
1344
  var groups = 0;
1317
1345
  function flatten(content, out = [], quote = false) {
@@ -1445,7 +1473,7 @@ var Writer = class {
1445
1473
  this.docPr = max + 1;
1446
1474
  this.nextRev = Math.max(0, ...[...this.s.matchAll(/\bw:id="(\d+)"/g)].map((m) => +m[1])) + 1;
1447
1475
  }
1448
- run(doc) {
1476
+ run(doc, setup) {
1449
1477
  const s = this.s;
1450
1478
  this.body = this.r.body();
1451
1479
  const { list, tail, body } = this.body;
@@ -1455,8 +1483,8 @@ var Writer = class {
1455
1483
  this.carryOver(list, (x) => rest = x);
1456
1484
  let xml = this.container(flatten(doc.content ?? []), list, null);
1457
1485
  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
1486
  const changed2 = /* @__PURE__ */ new Map();
1487
+ const text = this.marginal(s.slice(0, body.open) + xml + rest + s.slice(tail), setup, changed2);
1460
1488
  if (text !== s) changed2.set(this.pkg.main, text);
1461
1489
  if (this.rels.length) {
1462
1490
  const path = this.pkg.relsPath(this.pkg.main);
@@ -1582,6 +1610,79 @@ var Writer = class {
1582
1610
  if (o.kind === "toc") return b && sig(o.node) === sig(b.node) ? s.slice(b.start, b.end) : this.toc(o.node);
1583
1611
  return this.code(o);
1584
1612
  }
1613
+ marginal(text, setup, changed2) {
1614
+ if (!setup || !setup.page && setup.header === void 0 && setup.footer === void 0 && setup.numbers === void 0) return text;
1615
+ const end = text.lastIndexOf("</w:body>");
1616
+ const opens2 = (i) => /^<w:sectPr[\s>/]/.test(text.slice(i, i + 11));
1617
+ let start = -1;
1618
+ let close = text.lastIndexOf("</w:sectPr>", end);
1619
+ if (close >= 0 && !text.slice(close + 11, end).trim()) {
1620
+ let depth = 1;
1621
+ let i = close;
1622
+ while (depth > 0 && i > 0) {
1623
+ let o = text.lastIndexOf("<w:sectPr", i - 1);
1624
+ while (o >= 0 && !opens2(o)) o = text.lastIndexOf("<w:sectPr", o - 1);
1625
+ const c = text.lastIndexOf("</w:sectPr>", i - 1);
1626
+ if (c > o) {
1627
+ depth++;
1628
+ i = c;
1629
+ } else if (o < 0) break;
1630
+ else {
1631
+ if (text[text.indexOf(">", o) - 1] !== "/") depth--;
1632
+ i = o;
1633
+ }
1634
+ }
1635
+ start = i;
1636
+ close += 11;
1637
+ } else {
1638
+ start = close = end;
1639
+ }
1640
+ let sec = start === end ? "<w:sectPr></w:sectPr>" : text.slice(start, close);
1641
+ if (sec.endsWith("/>") && !sec.includes("</w:sectPr>")) sec = sec.slice(0, -2) + "></w:sectPr>";
1642
+ 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"];
1643
+ const put = (name, xml, before) => {
1644
+ const re = new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`);
1645
+ if (re.test(sec)) {
1646
+ sec = sec.replace(re, xml);
1647
+ return;
1648
+ }
1649
+ const at = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
1650
+ const i = at.length ? Math.min(...at) : sec.lastIndexOf("</w:sectPr>");
1651
+ sec = sec.slice(0, i) + xml + sec.slice(i);
1652
+ };
1653
+ const tw = (px2) => Math.round(px2 * 15);
1654
+ if (setup.page) {
1655
+ const { width, height, margins: [top, right, bottom, left] } = setup.page;
1656
+ put("w:pgSz", `<w:pgSz w:w="${tw(width)}" w:h="${tw(height)}"${width > height ? ' w:orient="landscape"' : ""}/>`, after);
1657
+ const was = /<w:pgMar\b[^>]*\/>/.exec(sec)?.[0] ?? "";
1658
+ const keep = attrs(was.replace(/^<w:pgMar|\/>$/g, "")).filter(([k]) => !["w:top", "w:right", "w:bottom", "w:left"].includes(k));
1659
+ if (!keep.some(([k]) => k === "w:header")) keep.push(["w:header", "708"], ["w:footer", "708"], ["w:gutter", "0"]);
1660
+ 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));
1661
+ }
1662
+ const part = (kind, body) => {
1663
+ sec = sec.replace(new RegExp(`<w:${kind}Reference\\b[^>]*\\bw:type="default"[^>]*/>`), "");
1664
+ if (!body) return;
1665
+ let n = 1;
1666
+ while (this.pkg.files.has(`word/${kind}${n}.xml`) || changed2.has(`word/${kind}${n}.xml`)) n++;
1667
+ const id = this.relId();
1668
+ const tag = kind === "header" ? "w:hdr" : "w:ftr";
1669
+ changed2.set(`word/${kind}${n}.xml`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1670
+ <${tag} xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}">${body}</${tag}>`);
1671
+ this.rels.push(`<Relationship Id="${id}" Type="${REL}/${kind}" Target="${kind}${n}.xml"/>`);
1672
+ this.types.add(`<Override PartName="/word/${kind}${n}.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${kind}+xml"/>`);
1673
+ const open = sec.indexOf(">") + 1;
1674
+ sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
1675
+ };
1676
+ const line = (words, page) => {
1677
+ 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>`;
1681
+ };
1682
+ if (setup.header !== void 0) part("header", line(setup.header, false));
1683
+ if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
1684
+ return text.slice(0, start) + sec + text.slice(close);
1685
+ }
1585
1686
  toc(node) {
1586
1687
  this.tocs = true;
1587
1688
  const styles = this.pkg.styles;
@@ -1699,6 +1800,20 @@ var Writer = class {
1699
1800
  if (align(direct ?? styles.jc(style)) !== want) {
1700
1801
  set["w:jc"] = align(styles.jc(style)) === want ? null : `<w:jc w:val="${{ center: "center", right: "right", justify: "both" }[want ?? ""] ?? "left"}"/>`;
1701
1802
  }
1803
+ const spEl = get("w:spacing");
1804
+ const spacing = spEl ? attrs(xml.slice(spEl.start, spEl.open)) : [];
1805
+ const had = (name) => spacing.find(([k]) => k === name)?.[1] ?? null;
1806
+ const line = value("line", o.node.attrs?.line);
1807
+ const after = value("after", o.node.attrs?.after);
1808
+ const auto = !had("w:lineRule") || had("w:lineRule") === "auto";
1809
+ 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;
1810
+ if ((b || line !== null || after !== null) && drift) {
1811
+ const kept = spacing.filter(([k]) => k !== "w:line" && k !== "w:lineRule" && k !== "w:after" && !(k === "w:afterAutospacing" && after !== null));
1812
+ if (line !== null) kept.push(["w:line", String(Math.round(line * 240))], ["w:lineRule", "auto"]);
1813
+ else if (had("w:line") && !auto) kept.push(["w:line", had("w:line")], ["w:lineRule", had("w:lineRule")]);
1814
+ if (after !== null) kept.push(["w:after", String(Math.round(after * 20))]);
1815
+ set["w:spacing"] = kept.length ? `<w:spacing ${kept.map(([k, v]) => `${k}="${escape(v)}"`).join(" ")}/>` : null;
1816
+ }
1702
1817
  if (!pr) {
1703
1818
  const indEl = "w:ind" in set ? void 0 : get("w:ind");
1704
1819
  const list = indEl ? attrs(xml.slice(indEl.start, indEl.open)).filter(([k]) => k !== "w:left" && k !== "w:start") : [];
@@ -1953,6 +2068,7 @@ var Writer = class {
1953
2068
  set["w:strike"] = to.s ? "<w:strike/>" : sf.s ? '<w:strike w:val="0"/>' : null;
1954
2069
  if (!to.s) set["w:dstrike"] = null;
1955
2070
  }
2071
+ 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
2072
  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
2073
  if (to.size !== from.size) {
1958
2074
  const hp = to.size ? Math.round(parseFloat(to.size) * 2) : 0;
@@ -2011,6 +2127,17 @@ var Writer = class {
2011
2127
  this.srcs.set(src, added.id);
2012
2128
  return added;
2013
2129
  }
2130
+ wrapped(raw, side2) {
2131
+ const anchor = /<wp:anchor\b/.test(raw);
2132
+ if (!side2 && !anchor) return raw;
2133
+ const ns = (tag) => attrs(/<wp:(?:inline|anchor)\b([^>]*)>/.exec(tag)?.[1] ?? "").filter(([k]) => k.startsWith("xmlns")).map(([k, v]) => ` ${k}="${v}"`).join("");
2134
+ const part = (name) => new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`).exec(raw)?.[0] ?? "";
2135
+ const body = part("wp:extent") + part("wp:effectExtent");
2136
+ const rest = part("wp:docPr") + part("wp:cNvGraphicFramePr") + part("a:graphic");
2137
+ 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>`);
2138
+ 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>`;
2139
+ 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>`);
2140
+ }
2014
2141
  drawing(img) {
2015
2142
  const media = this.embed(String(img.src ?? ""));
2016
2143
  const max = Math.round(this.textWidth() / 15);
@@ -2022,7 +2149,8 @@ var Writer = class {
2022
2149
  else if (!w) w = Math.round(h * nw / nh);
2023
2150
  const id = this.docPr++;
2024
2151
  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>`;
2152
+ 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>`;
2153
+ return img.wrap ? this.wrapped(xml, img.wrap) : xml;
2026
2154
  }
2027
2155
  patch(raw, old, img) {
2028
2156
  let xml = raw;
@@ -2034,6 +2162,7 @@ var Writer = class {
2034
2162
  }
2035
2163
  if ((img.alt || null) !== (old.alt || null) || (img.title || null) !== (old.title || null)) xml = xml.replace(/<wp:docPr\b[^>]*>/, (tag) => meta(tag, img));
2036
2164
  if (img.src !== old.src) xml = xml.replace(/(<a:blip\b[^>]*\br:embed=")[^"]*"/, `$1${this.embed(String(img.src ?? "")).id}"`);
2165
+ if ((img.wrap || null) !== (old.wrap || null)) xml = this.wrapped(xml, img.wrap);
2037
2166
  return xml;
2038
2167
  }
2039
2168
  textWidth() {
@@ -2099,6 +2228,27 @@ var Writer = class {
2099
2228
  head = `<w:tbl>${tblPr}<w:tblGrid>${`<w:gridCol w:w="${Math.floor(this.textWidth() / cols)}"/>`.repeat(cols)}</w:tblGrid>`;
2100
2229
  }
2101
2230
  const width = Math.floor(this.textWidth() / cols);
2231
+ const sized = [];
2232
+ for (const r of layout) for (const sl of r) {
2233
+ const own2 = sl.cell && value("colwidth", sl.cell.attrs?.colwidth);
2234
+ if (own2 && own2.length === sl.span) own2.forEach((w, k) => {
2235
+ var _a;
2236
+ return sized[_a = sl.col + k] ?? (sized[_a] = w);
2237
+ });
2238
+ }
2239
+ const known = sized.length === cols && sized.every(Boolean);
2240
+ const had = [...head.matchAll(/<w:gridCol\b[^>]*\bw:w="(\d+)"/g)].map((m) => Math.floor(+m[1] / 15));
2241
+ if (known && had.join() !== sized.join()) {
2242
+ const list = sized.map((w) => `<w:gridCol w:w="${Math.round(w * 15)}"/>`).join("");
2243
+ head = head.replace(/(<w:tblGrid\b[^>]*>)[\s\S]*?(<\/w:tblGrid>)/, `$1${list}$2`);
2244
+ }
2245
+ const own = (col, span2) => known ? sized.slice(col, col + span2) : null;
2246
+ const borders = value("borders", o.node.attrs?.borders);
2247
+ if (borders !== value("borders", b?.node.attrs?.borders)) {
2248
+ const line = (side2) => `<w:${side2} w:val="${borders === "none" ? "none" : "single"}" w:sz="4" w:space="0" w:color="${borders === "none" ? "auto" : "94A3B8"}"/>`;
2249
+ const all = `<w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(line).join("")}</w:tblBorders>`;
2250
+ 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`);
2251
+ }
2102
2252
  let xml = head;
2103
2253
  let above = [];
2104
2254
  let aboveRow = null;
@@ -2129,7 +2279,7 @@ var Writer = class {
2129
2279
  if (!sl.cell) {
2130
2280
  const cont = R2?.cells.find((c) => c.vm === "continue" && c.col === sl.col);
2131
2281
  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>`;
2282
+ 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
2283
  now[sl.col] = cover.get(sl.from) ?? null;
2134
2284
  continue;
2135
2285
  }
@@ -2145,7 +2295,7 @@ var Writer = class {
2145
2295
  const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
2146
2296
  let inside = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
2147
2297
  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>";
2298
+ 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
2299
  }
2150
2300
  const lastCell = R2?.cells[R2.cells.length - 1];
2151
2301
  xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
@@ -2154,15 +2304,21 @@ var Writer = class {
2154
2304
  });
2155
2305
  return xml + tail + "</w:tbl>";
2156
2306
  }
2157
- tcPr(src, span2, vm, width, clone = true) {
2307
+ tcPr(src, span2, vm, width, clone = true, own = null, fill3) {
2158
2308
  const s = this.s;
2159
2309
  const el = src && kid(src.el, "w:tcPr");
2160
2310
  const xml = el ? s.slice(el.start, el.end) : "";
2161
- if (!clone && src && src.span === span2 && src.vm === vm) return xml;
2311
+ const tcW = el && kid(el, "w:tcW");
2312
+ const sized = own ? Math.round(own.reduce((a, w) => a + w, 0) * 15) : null;
2313
+ const resized = sized !== null && !(tcW && attr(s, tcW, "w:type") === "dxa" && Math.abs(+(attr(s, tcW, "w:w") ?? 0) - sized) < 15);
2314
+ const was = src?.node ? value("background", src.node.attrs?.background) : null;
2315
+ const painted = fill3 !== void 0 && fill3 !== was;
2316
+ if (!clone && src && src.span === span2 && src.vm === vm && !resized && !painted) return xml;
2162
2317
  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
2318
  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"/>`;
2319
+ if (painted) set["w:shd"] = fill3 ? `<w:shd w:val="clear" w:color="auto" w:fill="${fill3.slice(1).toUpperCase()}"/>` : null;
2320
+ if (resized) set["w:tcW"] = `<w:tcW w:w="${sized}" w:type="dxa"/>`;
2321
+ else if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span2}" w:type="dxa"/>`;
2166
2322
  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
2323
  return rebuild(xml, "w:tcPr", TC, set);
2168
2324
  }
@@ -2194,15 +2350,24 @@ async function readDocx(bytes) {
2194
2350
  const size2 = sect && kid(sect, "w:pgSz");
2195
2351
  const mar = sect && kid(sect, "w:pgMar");
2196
2352
  const px2 = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
2353
+ const words = (kind) => {
2354
+ const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
2355
+ const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
2356
+ const xml = part ? pkg.text(part.target) ?? "" : "";
2357
+ 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
+ };
2359
+ const head = words("header");
2360
+ const foot = words("footer");
2197
2361
  return {
2362
+ marginal: { header: head.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
2198
2363
  doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
2199
2364
  styles: pkg.styles.list(),
2200
2365
  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
2366
  };
2202
2367
  }
2203
- async function writeDocx(original, doc, load2 = fetched) {
2368
+ async function writeDocx(original, doc, load2 = fetched, setup) {
2204
2369
  const pkg = new Pkg(new Uint8Array(original));
2205
- const out = new Writer(pkg, await images(doc, load2)).run(doc);
2370
+ const out = new Writer(pkg, await images(doc, load2)).run(doc, setup);
2206
2371
  return out ? out.slice().buffer : original.slice(0);
2207
2372
  }
2208
2373
 
@@ -2265,10 +2430,10 @@ var Pager = import_core.Extension.create({
2265
2430
  addProseMirrorPlugins: () => [new import_state.Plugin({
2266
2431
  key: paging,
2267
2432
  state: {
2268
- init: () => ({ set: import_view.DecorationSet.empty, page: a4 }),
2433
+ init: () => ({ set: import_view.DecorationSet.empty, page: a4, marks: { header: "", footer: "" } }),
2269
2434
  apply(tr, value3) {
2270
2435
  const next = tr.getMeta(paging);
2271
- return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page };
2436
+ return { set: next?.set ?? value3.set.map(tr.mapping, tr.doc), page: next?.page ?? value3.page, marks: next?.marks ?? value3.marks };
2272
2437
  }
2273
2438
  },
2274
2439
  props: { decorations: (state) => paging.getState(state).set },
@@ -2278,17 +2443,34 @@ var Pager = import_core.Extension.create({
2278
2443
  const run = () => {
2279
2444
  if (!view.dom.isConnected) return;
2280
2445
  const gaps = measure(view);
2281
- const next = gaps.map((g) => `${g.pos}:${g.height}`).join();
2446
+ const { marks } = paging.getState(view.state);
2447
+ const next = gaps.map((g) => `${g.pos}:${g.height}`).join() + `|${marks.header}|${marks.footer}`;
2282
2448
  if (next === sig2) return;
2283
2449
  sig2 = next;
2284
- const set = import_view.DecorationSet.create(view.state.doc, gaps.map((g) => import_view.Decoration.widget(g.pos, () => {
2450
+ const line = (parent, cls, text) => {
2451
+ if (!text) return;
2452
+ const span2 = document.createElement("span");
2453
+ span2.className = cls;
2454
+ span2.textContent = text;
2455
+ parent.append(span2);
2456
+ };
2457
+ const first = import_view.Decoration.widget(0, () => {
2458
+ const el = document.createElement("div");
2459
+ el.className = "w100n-text-first";
2460
+ el.contentEditable = "false";
2461
+ line(el, "w100n-text-head", marks.header);
2462
+ return el;
2463
+ }, { key: `first:${marks.header}`, side: -1, ignoreSelection: true });
2464
+ const set = import_view.DecorationSet.create(view.state.doc, [first, ...gaps.map((g) => import_view.Decoration.widget(g.pos, () => {
2285
2465
  const el = document.createElement("div");
2286
2466
  el.className = g.end ? "w100n-text-gap is-end" : "w100n-text-gap";
2287
2467
  el.style.height = `${g.height}px`;
2288
2468
  el.dataset.page = String(g.page);
2289
2469
  el.contentEditable = "false";
2470
+ line(el, "w100n-text-foot", marks.footer);
2471
+ if (!g.end) line(el, "w100n-text-head", marks.header);
2290
2472
  return el;
2291
- }, { key: `${g.pos}:${g.height}:${g.page}`, side: -1, ignoreSelection: true })));
2473
+ }, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}`, side: -1, ignoreSelection: true }))]);
2292
2474
  view.dispatch(view.state.tr.setMeta(paging, { set }).setMeta("addToHistory", false));
2293
2475
  };
2294
2476
  const later = (ms) => {
@@ -2300,7 +2482,7 @@ var Pager = import_core.Extension.create({
2300
2482
  later(0);
2301
2483
  return {
2302
2484
  update: (next, prev) => {
2303
- if (paging.getState(next.state).page !== paging.getState(prev).page) later(0);
2485
+ if (paging.getState(next.state).page !== paging.getState(prev).page || paging.getState(next.state).marks !== paging.getState(prev).marks) later(0);
2304
2486
  else if (next.state.doc !== prev.doc) later(400);
2305
2487
  },
2306
2488
  destroy: () => {
@@ -2343,6 +2525,51 @@ var changed = (trs) => {
2343
2525
  }));
2344
2526
  return ranges;
2345
2527
  };
2528
+ var Cells = import_core2.Extension.create({
2529
+ name: "cells",
2530
+ addGlobalAttributes: () => [
2531
+ { 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}` } : {} } } },
2532
+ { types: ["table"], attributes: { borders: { default: null, parseHTML: (el) => el.dataset.borders ?? null, renderHTML: (attrs2) => attrs2.borders ? { "data-borders": attrs2.borders } : {} } } }
2533
+ ]
2534
+ });
2535
+ var searching = new import_state2.PluginKey("w100n-search");
2536
+ var lookup = (doc, query, matchCase) => {
2537
+ const hits = [];
2538
+ if (!query) return hits;
2539
+ const needle = matchCase ? query : query.toLowerCase();
2540
+ doc.descendants((node, pos) => {
2541
+ if (!node.isTextblock) return true;
2542
+ let text = "";
2543
+ const at = [];
2544
+ node.forEach((child, offset) => {
2545
+ const part = child.isText ? child.text : "\uFFFC";
2546
+ for (let i = 0; i < part.length; i++) at.push(pos + 1 + offset + i);
2547
+ text += part;
2548
+ });
2549
+ const hay = matchCase ? text : text.toLowerCase();
2550
+ 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 });
2551
+ return false;
2552
+ });
2553
+ return hits;
2554
+ };
2555
+ var Search = import_core2.Extension.create({
2556
+ name: "search",
2557
+ addProseMirrorPlugins: () => [new import_state2.Plugin({
2558
+ key: searching,
2559
+ state: {
2560
+ init: () => ({ query: "", matchCase: false, hits: [], at: 0, set: import_view2.DecorationSet.empty }),
2561
+ apply(tr, value3) {
2562
+ const meta2 = tr.getMeta(searching);
2563
+ if (!meta2 && !tr.docChanged) return value3;
2564
+ const next = { ...value3, ...meta2 };
2565
+ const hits = lookup(tr.doc, next.query, next.matchCase);
2566
+ const at = hits.length ? (next.at % hits.length + hits.length) % hits.length : 0;
2567
+ 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" }))) };
2568
+ }
2569
+ },
2570
+ props: { decorations: (state) => searching.getState(state).set }
2571
+ })]
2572
+ });
2346
2573
  var Blocks = import_core2.Extension.create({
2347
2574
  name: "blocks",
2348
2575
  addGlobalAttributes: () => [{
@@ -2350,6 +2577,8 @@ var Blocks = import_core2.Extension.create({
2350
2577
  attributes: {
2351
2578
  align: { default: null, parseHTML: (el) => el.style.textAlign || null, renderHTML: (attrs2) => attrs2.align ? { style: `text-align: ${attrs2.align}` } : {} },
2352
2579
  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` } : {} },
2580
+ 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}` } : {} },
2581
+ 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
2582
  ref: { default: null, rendered: false, keepOnSplit: false }
2354
2583
  }
2355
2584
  }],
@@ -2664,18 +2893,35 @@ var Notes = import_core2.Extension.create({
2664
2893
  props: { decorations: (state) => notes.getState(state).set }
2665
2894
  })]
2666
2895
  });
2896
+ var script = (name, tag, other) => import_core2.Mark.create({
2897
+ name,
2898
+ excludes: other,
2899
+ parseHTML: () => [{ tag }, { style: `vertical-align=${name === "superscript" ? "super" : "sub"}` }],
2900
+ renderHTML: () => [tag, 0],
2901
+ addKeyboardShortcuts() {
2902
+ return { [name === "superscript" ? "Mod-." : "Mod-,"]: () => this.editor.commands.toggleMark(name) };
2903
+ }
2904
+ });
2667
2905
  function kit(kind, t, live) {
2668
2906
  return [
2669
2907
  import_starter_kit.default.configure({ trailingNode: false, link: { openOnClick: false, autolink: true, defaultProtocol: "https" }, dropcursor: { color: "#8b5cf6", width: 2 }, ...live ? { undoRedo: false } : {} }),
2670
2908
  import_extension_list.TaskList,
2671
2909
  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 }),
2910
+ import_extension_table.TableKit.configure({ table: { resizable: true, cellMinWidth: 32 } }),
2911
+ Cells,
2912
+ Search,
2913
+ import_extension_image.default.extend({
2914
+ addAttributes() {
2915
+ return { ...this.parent?.(), wrap: { default: null, parseHTML: (el) => el.dataset.wrap ?? null, renderHTML: (attrs2) => attrs2.wrap ? { "data-wrap": attrs2.wrap } : {} } };
2916
+ }
2917
+ }).configure({ inline: true, allowBase64: true, resize: { enabled: true, directions: ["top-left", "top-right", "bottom-left", "bottom-right"], minWidth: 24, minHeight: 24, alwaysPreserveAspectRatio: true } }),
2674
2918
  import_extension_highlight.default.configure({ multicolor: true }),
2675
2919
  import_extension_text_style.TextStyle,
2676
2920
  import_extension_text_style.Color,
2677
2921
  import_extension_text_style.FontSize,
2678
2922
  import_extension_text_style.FontFamily,
2923
+ script("superscript", "sup", "subscript"),
2924
+ script("subscript", "sub", "superscript"),
2679
2925
  Blocks,
2680
2926
  PageBreak.configure({ label: t.pageBreak }),
2681
2927
  Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
@@ -4373,7 +4619,7 @@ function equalValue(a, b) {
4373
4619
  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
4620
  return a === b;
4375
4621
  }
4376
- function lookup(book, s) {
4622
+ function lookup2(book, s) {
4377
4623
  if (!s) return {};
4378
4624
  return (typeof s === "string" ? book.styles[s] : s) ?? {};
4379
4625
  }
@@ -4531,7 +4777,7 @@ function writeXlsx(original, model) {
4531
4777
  const id = typeof s === "string" ? (bk === cur ? "c" : "b") + s : "";
4532
4778
  const known = id && seen.get(id);
4533
4779
  if (known) return known;
4534
- const look = norm({ ...defaults, ...lookup(bk, s) });
4780
+ const look = norm({ ...defaults, ...lookup2(bk, s) });
4535
4781
  const made2 = { look, json: JSON.stringify(look) };
4536
4782
  if (id) seen.set(id, made2);
4537
4783
  return made2;
@@ -4572,8 +4818,8 @@ function writeXlsx(original, model) {
4572
4818
  changed2 = true;
4573
4819
  tag = setAttr(tag, "hidden", hidden ? "1" : null);
4574
4820
  }
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;
4821
+ const look = rd.s ? norm({ ...defaults, ...lookup2(cur, rd.s) }) : null;
4822
+ const was = od.s ? norm({ ...defaults, ...lookup2(base.book, od.s) }) : null;
4577
4823
  if (!same(look, was)) {
4578
4824
  changed2 = true;
4579
4825
  tag = setAttr(setAttr(tag, "s", look ? String(xfFor(look, xfOf(od.s))) : null), "customFormat", look ? "1" : null);
@@ -4864,7 +5110,7 @@ function cellXml(p, ref, xf, x, f, v) {
4864
5110
  function columns(p, rec, sheet, old, cols, defaults, cur, baseBook, xfFor, xfOf) {
4865
5111
  const now = sheet.columnData ?? {}, was = old.columnData ?? {};
4866
5112
  const count = sheet.columnCount ?? 26;
4867
- const look = (bk, s) => s ? norm({ ...defaults, ...lookup(bk, s) }) : null;
5113
+ const look = (bk, s) => s ? norm({ ...defaults, ...lookup2(bk, s) }) : null;
4868
5114
  let differs = cols.moved;
4869
5115
  for (let c = 0; c < count && !differs; c++) {
4870
5116
  const c0 = cols.from(c);
@@ -5217,6 +5463,11 @@ function applyCells(doc, list, origin) {
5217
5463
 
5218
5464
  // src/sheets/text.ts
5219
5465
  var en = {
5466
+ asCurrency: "Format as euro",
5467
+ asPercent: "Format as percent",
5468
+ fewerDecimals: "Fewer decimal places",
5469
+ moreDecimals: "More decimal places",
5470
+ sum: "Sum",
5220
5471
  tools: "Sheet tools",
5221
5472
  loading: "Opening the sheet",
5222
5473
  failed: "This sheet could not be opened",
@@ -5285,6 +5536,11 @@ var en = {
5285
5536
  }
5286
5537
  };
5287
5538
  var pl = {
5539
+ asCurrency: "Formatuj jako euro",
5540
+ asPercent: "Formatuj jako procent",
5541
+ fewerDecimals: "Mniej miejsc po przecinku",
5542
+ moreDecimals: "Wi\u0119cej miejsc po przecinku",
5543
+ sum: "Suma",
5288
5544
  tools: "Narz\u0119dzia arkusza",
5289
5545
  loading: "Otwieranie arkusza",
5290
5546
  failed: "Nie uda\u0142o si\u0119 otworzy\u0107 tego arkusza",
@@ -5353,6 +5609,11 @@ var pl = {
5353
5609
  }
5354
5610
  };
5355
5611
  var uk = {
5612
+ asCurrency: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0454\u0432\u0440\u043E",
5613
+ asPercent: "\u0424\u043E\u0440\u043C\u0430\u0442 \u0432\u0456\u0434\u0441\u043E\u0442\u043A\u0456\u0432",
5614
+ fewerDecimals: "\u041C\u0435\u043D\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
5615
+ moreDecimals: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0437\u043D\u0430\u043A\u0456\u0432 \u043F\u0456\u0441\u043B\u044F \u043A\u043E\u043C\u0438",
5616
+ sum: "\u0421\u0443\u043C\u0430",
5356
5617
  tools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
5357
5618
  loading: "\u0412\u0456\u0434\u043A\u0440\u0438\u0432\u0430\u0454\u043C\u043E \u0442\u0430\u0431\u043B\u0438\u0446\u044E",
5358
5619
  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 +5699,10 @@ var en2 = {
5438
5699
  versions: "Versions",
5439
5700
  details: "Details",
5440
5701
  noOutline: "This document has no headings",
5702
+ findHeading: "Find a heading",
5703
+ read: "read",
5704
+ showSections: "Show sections",
5705
+ hideSections: "Hide sections",
5441
5706
  current: "Current",
5442
5707
  size: "Size",
5443
5708
  updated: "Updated",
@@ -5485,6 +5750,12 @@ var en2 = {
5485
5750
  save: "Save",
5486
5751
  saving: "Saving",
5487
5752
  saved: "Saved",
5753
+ align: "Align",
5754
+ moreTools: "More tools",
5755
+ fewerTools: "Fewer tools",
5756
+ typeFilter: "Type",
5757
+ selectAll: "Select all",
5758
+ clearPick: "Clear",
5488
5759
  saveFailed: "Could not save",
5489
5760
  remove: "Remove",
5490
5761
  notePlaceholder: "Write a note",
@@ -5594,6 +5865,11 @@ var en2 = {
5594
5865
  someone: "Someone",
5595
5866
  copyAs: "Make an XLSX copy",
5596
5867
  copyFailed: "Could not make the copy",
5868
+ downloadAs: "Download as",
5869
+ makeCopy: "Make a copy",
5870
+ copyOf: "Copy of",
5871
+ rename: "Rename",
5872
+ renameFailed: "Could not rename",
5597
5873
  editComment: "Edit",
5598
5874
  delete: "Delete",
5599
5875
  deleteAsk: "Delete this comment?",
@@ -5679,7 +5955,52 @@ var en2 = {
5679
5955
  untitled: "Untitled",
5680
5956
  kindHints: { docx: "Word, DOCX", markdown: "MD, same editor", sheet: "Excel, XLSX", slides: "HTML slides" },
5681
5957
  newKinds: { docx: "Document", markdown: "Markdown", sheet: "Spreadsheet", slides: "Presentation" },
5682
- templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" }
5958
+ templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" },
5959
+ menuFile: "File",
5960
+ menuEdit: "Edit",
5961
+ menuFormat: "Format",
5962
+ menuTools: "Tools",
5963
+ zoom: "Zoom",
5964
+ font: "Font",
5965
+ fontSize: "Font size",
5966
+ defaultFont: "Default",
5967
+ lineSpacing: "Line and paragraph spacing",
5968
+ single: "Single",
5969
+ double: "Double",
5970
+ spaceAfter: "Add space after paragraph",
5971
+ noSpaceAfter: "Remove space after paragraph",
5972
+ superscript: "Superscript",
5973
+ subscript: "Subscript",
5974
+ painter: "Paint format",
5975
+ painterHint: "Select text to paint, double click keeps it on, Esc stops",
5976
+ pageSetup: "Page setup",
5977
+ orientation: "Orientation",
5978
+ portrait: "Portrait",
5979
+ landscape: "Landscape",
5980
+ marginsCm: "Margins, cm",
5981
+ mTop: "Top",
5982
+ mRight: "Right",
5983
+ mBottom: "Bottom",
5984
+ mLeft: "Left",
5985
+ headerText: "Header",
5986
+ footerText: "Footer",
5987
+ pageNumbers: "Page numbers in the footer",
5988
+ wrapInline: "In line with text",
5989
+ wrapLeft: "Text wraps on the right",
5990
+ wrapRight: "Text wraps on the left",
5991
+ cellFill: "Cell fill",
5992
+ tableBorders: "Table borders",
5993
+ findReplace: "Find and replace",
5994
+ replaceWith: "Replace with",
5995
+ replaceOne: "Replace",
5996
+ replaceAll: "Replace all",
5997
+ matchCase: "Match case",
5998
+ words: "Words",
5999
+ print: "Print",
6000
+ autosavedNote: "Autosaved",
6001
+ uploadFile: "Upload a file",
6002
+ uploading: "Uploading",
6003
+ uploadFailed: "Could not upload the file"
5683
6004
  };
5684
6005
  var pl2 = {
5685
6006
  documents: "Dokumenty",
@@ -5696,6 +6017,10 @@ var pl2 = {
5696
6017
  versions: "Wersje",
5697
6018
  details: "Szczeg\xF3\u0142y",
5698
6019
  noOutline: "Ten dokument nie ma nag\u0142\xF3wk\xF3w",
6020
+ findHeading: "Znajd\u017A nag\u0142\xF3wek",
6021
+ read: "przeczytano",
6022
+ showSections: "Poka\u017C sekcje",
6023
+ hideSections: "Ukryj sekcje",
5699
6024
  current: "Bie\u017C\u0105ca",
5700
6025
  size: "Rozmiar",
5701
6026
  updated: "Zmieniono",
@@ -5743,6 +6068,12 @@ var pl2 = {
5743
6068
  save: "Zapisz",
5744
6069
  saving: "Zapisywanie",
5745
6070
  saved: "Zapisano",
6071
+ align: "Wyr\xF3wnanie",
6072
+ moreTools: "Wi\u0119cej narz\u0119dzi",
6073
+ fewerTools: "Mniej narz\u0119dzi",
6074
+ typeFilter: "Typ",
6075
+ selectAll: "Zaznacz wszystkie",
6076
+ clearPick: "Wyczy\u015B\u0107",
5746
6077
  saveFailed: "Nie uda\u0142o si\u0119 zapisa\u0107",
5747
6078
  remove: "Usu\u0144",
5748
6079
  notePlaceholder: "Napisz notatk\u0119",
@@ -5851,6 +6182,11 @@ var pl2 = {
5851
6182
  removed: "Usuni\u0119to",
5852
6183
  someone: "Kto\u015B",
5853
6184
  copyAs: "Zr\xF3b kopi\u0119 XLSX",
6185
+ downloadAs: "Pobierz jako",
6186
+ makeCopy: "Utw\xF3rz kopi\u0119",
6187
+ copyOf: "Kopia",
6188
+ rename: "Zmie\u0144 nazw\u0119",
6189
+ renameFailed: "Nie uda\u0142o si\u0119 zmieni\u0107 nazwy",
5854
6190
  copyFailed: "Nie uda\u0142o si\u0119 zrobi\u0107 kopii",
5855
6191
  editComment: "Edytuj",
5856
6192
  delete: "Usu\u0144",
@@ -5937,7 +6273,52 @@ var pl2 = {
5937
6273
  untitled: "Bez tytu\u0142u",
5938
6274
  kindHints: { docx: "Word, DOCX", markdown: "MD, ten sam edytor", sheet: "Excel, XLSX", slides: "Slajdy HTML" },
5939
6275
  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" }
6276
+ templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" },
6277
+ menuFile: "Plik",
6278
+ menuEdit: "Edycja",
6279
+ menuFormat: "Format",
6280
+ menuTools: "Narz\u0119dzia",
6281
+ zoom: "Powi\u0119kszenie",
6282
+ font: "Czcionka",
6283
+ fontSize: "Rozmiar czcionki",
6284
+ defaultFont: "Domy\u015Blna",
6285
+ lineSpacing: "Interlinia i odst\u0119py",
6286
+ single: "Pojedyncza",
6287
+ double: "Podw\xF3jna",
6288
+ spaceAfter: "Dodaj odst\u0119p po akapicie",
6289
+ noSpaceAfter: "Usu\u0144 odst\u0119p po akapicie",
6290
+ superscript: "Indeks g\xF3rny",
6291
+ subscript: "Indeks dolny",
6292
+ painter: "Malarz format\xF3w",
6293
+ painterHint: "Zaznacz tekst, dwuklik zostawia w\u0142\u0105czone, Esc ko\u0144czy",
6294
+ pageSetup: "Ustawienia strony",
6295
+ orientation: "Orientacja",
6296
+ portrait: "Pionowa",
6297
+ landscape: "Pozioma",
6298
+ marginsCm: "Marginesy, cm",
6299
+ mTop: "G\xF3rny",
6300
+ mRight: "Prawy",
6301
+ mBottom: "Dolny",
6302
+ mLeft: "Lewy",
6303
+ headerText: "Nag\u0142\xF3wek",
6304
+ footerText: "Stopka",
6305
+ pageNumbers: "Numery stron w stopce",
6306
+ wrapInline: "W linii z tekstem",
6307
+ wrapLeft: "Tekst op\u0142ywa z prawej",
6308
+ wrapRight: "Tekst op\u0142ywa z lewej",
6309
+ cellFill: "Wype\u0142nienie kom\xF3rki",
6310
+ tableBorders: "Obramowanie tabeli",
6311
+ findReplace: "Znajd\u017A i zamie\u0144",
6312
+ replaceWith: "Zamie\u0144 na",
6313
+ replaceOne: "Zamie\u0144",
6314
+ replaceAll: "Zamie\u0144 wszystko",
6315
+ matchCase: "Uwzgl\u0119dnij wielko\u015B\u0107 liter",
6316
+ words: "S\u0142owa",
6317
+ print: "Drukuj",
6318
+ autosavedNote: "Zapisano automatycznie",
6319
+ uploadFile: "Wgraj plik",
6320
+ uploading: "Wysy\u0142anie",
6321
+ uploadFailed: "Nie uda\u0142o si\u0119 wgra\u0107 pliku"
5941
6322
  };
5942
6323
  var uk2 = {
5943
6324
  documents: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0438",
@@ -5954,6 +6335,10 @@ var uk2 = {
5954
6335
  versions: "\u0412\u0435\u0440\u0441\u0456\u0457",
5955
6336
  details: "\u0414\u0435\u0442\u0430\u043B\u0456",
5956
6337
  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",
6338
+ findHeading: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A",
6339
+ read: "\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043E",
6340
+ showSections: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
6341
+ hideSections: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
5957
6342
  current: "\u041F\u043E\u0442\u043E\u0447\u043D\u0430",
5958
6343
  size: "\u0420\u043E\u0437\u043C\u0456\u0440",
5959
6344
  updated: "\u0417\u043C\u0456\u043D\u0435\u043D\u043E",
@@ -6001,6 +6386,12 @@ var uk2 = {
6001
6386
  save: "\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
6002
6387
  saving: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043D\u044F",
6003
6388
  saved: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E",
6389
+ align: "\u0412\u0438\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u043D\u043D\u044F",
6390
+ moreTools: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
6391
+ fewerTools: "\u041C\u0435\u043D\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
6392
+ typeFilter: "\u0422\u0438\u043F",
6393
+ selectAll: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0441\u0456",
6394
+ clearPick: "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",
6004
6395
  saveFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
6005
6396
  remove: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
6006
6397
  notePlaceholder: "\u041D\u0430\u043F\u0438\u0448\u0456\u0442\u044C \u043D\u043E\u0442\u0430\u0442\u043A\u0443",
@@ -6109,6 +6500,11 @@ var uk2 = {
6109
6500
  removed: "\u0412\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
6110
6501
  someone: "\u0425\u0442\u043E\u0441\u044C",
6111
6502
  copyAs: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E XLSX",
6503
+ downloadAs: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u044F\u043A",
6504
+ makeCopy: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
6505
+ copyOf: "\u041A\u043E\u043F\u0456\u044F",
6506
+ rename: "\u041F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
6507
+ renameFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u043F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
6112
6508
  copyFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
6113
6509
  editComment: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
6114
6510
  delete: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
@@ -6195,7 +6591,52 @@ var uk2 = {
6195
6591
  untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0438",
6196
6592
  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
6593
  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" }
6594
+ 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" },
6595
+ menuFile: "\u0424\u0430\u0439\u043B",
6596
+ menuEdit: "\u041F\u0440\u0430\u0432\u043A\u0430",
6597
+ menuFormat: "\u0424\u043E\u0440\u043C\u0430\u0442",
6598
+ menuTools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438",
6599
+ zoom: "\u041C\u0430\u0441\u0448\u0442\u0430\u0431",
6600
+ font: "\u0428\u0440\u0438\u0444\u0442",
6601
+ fontSize: "\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443",
6602
+ defaultFont: "\u0422\u0438\u043F\u043E\u0432\u0438\u0439",
6603
+ 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",
6604
+ single: "\u041E\u0434\u0438\u043D\u0430\u0440\u043D\u0438\u0439",
6605
+ double: "\u041F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439",
6606
+ 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",
6607
+ 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",
6608
+ superscript: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
6609
+ subscript: "\u041D\u0438\u0436\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
6610
+ painter: "\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438 \u0444\u043E\u0440\u043C\u0430\u0442",
6611
+ 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",
6612
+ pageSetup: "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
6613
+ orientation: "\u041E\u0440\u0456\u0454\u043D\u0442\u0430\u0446\u0456\u044F",
6614
+ portrait: "\u041A\u043D\u0438\u0436\u043A\u043E\u0432\u0430",
6615
+ landscape: "\u0410\u043B\u044C\u0431\u043E\u043C\u043D\u0430",
6616
+ marginsCm: "\u041F\u043E\u043B\u044F, \u0441\u043C",
6617
+ mTop: "\u0412\u0435\u0440\u0445\u043D\u0454",
6618
+ mRight: "\u041F\u0440\u0430\u0432\u0435",
6619
+ mBottom: "\u041D\u0438\u0436\u043D\u0454",
6620
+ mLeft: "\u041B\u0456\u0432\u0435",
6621
+ headerText: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
6622
+ footerText: "\u041D\u0438\u0436\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
6623
+ pageNumbers: "\u041D\u043E\u043C\u0435\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043E\u043A \u0443\u043D\u0438\u0437\u0443",
6624
+ wrapInline: "\u0423 \u0440\u044F\u0434\u043A\u0443 \u0437 \u0442\u0435\u043A\u0441\u0442\u043E\u043C",
6625
+ wrapLeft: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043F\u0440\u0430\u0432\u043E\u0440\u0443\u0447",
6626
+ wrapRight: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043B\u0456\u0432\u043E\u0440\u0443\u0447",
6627
+ cellFill: "\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043A\u043B\u0456\u0442\u0438\u043D\u043A\u0438",
6628
+ tableBorders: "\u041C\u0435\u0436\u0456 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
6629
+ findReplace: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0439 \u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
6630
+ replaceWith: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u043D\u0430",
6631
+ replaceOne: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
6632
+ replaceAll: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u0432\u0441\u0456",
6633
+ matchCase: "\u0417 \u0443\u0440\u0430\u0445\u0443\u0432\u0430\u043D\u043D\u044F\u043C \u0440\u0435\u0433\u0456\u0441\u0442\u0440\u0443",
6634
+ words: "\u0421\u043B\u043E\u0432\u0430",
6635
+ print: "\u0414\u0440\u0443\u043A",
6636
+ autosavedNote: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u043D\u043E",
6637
+ uploadFile: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B",
6638
+ uploading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
6639
+ 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
6640
  };
6200
6641
  var texts = { en: en2, pl: pl2, uk: uk2 };
6201
6642
 
@@ -6204,7 +6645,7 @@ var ours = "w100n-collab";
6204
6645
  var schemas = /* @__PURE__ */ new Map();
6205
6646
  var schemaOf = (kind) => schemas.get(kind) ?? schemas.set(kind, (0, import_core3.getSchema)(kit(kind, texts.en))).get(kind);
6206
6647
  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"));
6648
+ 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
6649
  var filled = (doc) => doc.getXmlFragment("default").length > 0 || doc.getMap("book").size > 0;
6209
6650
  function seed(doc, kind, bytes, json) {
6210
6651
  if (filled(doc)) return false;
@@ -6252,8 +6693,8 @@ function applyText(doc, kind, changes, origin) {
6252
6693
  (0, import_y_tiptap2.updateYFragment)({ transact: (run) => doc.transact(run, origin) }, fragment, step.doc, { mapping: /* @__PURE__ */ new Map(), isOMark: /* @__PURE__ */ new Map() });
6253
6694
  return changes.length;
6254
6695
  }
6255
- async function write2(kind, base, node, load2) {
6256
- if (kind === "docx") return writeDocx(base, node.toJSON(), load2);
6696
+ async function write2(kind, base, node, load2, setup) {
6697
+ if (kind === "docx") return writeDocx(base, node.toJSON(), load2, setup);
6257
6698
  const parsed = fromMarkdown(new TextDecoder().decode(base));
6258
6699
  return new TextEncoder().encode(toMarkdown(node, track(parsed, node.type.schema.nodeFromJSON(parsed.doc))).text).buffer;
6259
6700
  }
@@ -6290,7 +6731,7 @@ async function save(doc, kind, base, put, load2, note) {
6290
6731
  };
6291
6732
  doc.on("afterTransaction", watch);
6292
6733
  try {
6293
- const bytes = await write2(kind, base, node, load2);
6734
+ const bytes = await write2(kind, base, node, load2, doc.getMap("setup").size ? doc.getMap("setup").toJSON() : void 0);
6294
6735
  const changed2 = !same2(bytes, base);
6295
6736
  const id = changed2 ? await put(bytes, note ?? named2((texts[who[0].language] ?? texts.en).editedNote, who)) : null;
6296
6737
  const refs2 = [];