@forevka/wordcanvas 0.7.0 → 0.7.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.
Files changed (47) hide show
  1. package/README.md +48 -1
  2. package/dist-lib/assets/{worker-BsOsK39A.js → worker-D8rUOKfg.js} +9603 -9451
  3. package/dist-lib/assets/worker-wXuuyshQ.js +2258 -0
  4. package/dist-lib/{blockFactory-Bcy0U40y.js → blockFactory-CUI4Rqiq.js} +50 -42
  5. package/dist-lib/{browser-5Sv4CuNy.js → browser-DkKxreJM.js} +404 -383
  6. package/dist-lib/builder.js +364 -109
  7. package/dist-lib/editorApp-DLXMmtu5.js +8023 -0
  8. package/dist-lib/export.js +3820 -3768
  9. package/dist-lib/generate-toc.js +4 -4
  10. package/dist-lib/import.js +4 -1538
  11. package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
  12. package/dist-lib/pipeline-CbxmCE84.js +1705 -0
  13. package/dist-lib/recalc-docx.js +2 -2
  14. package/dist-lib/recalcToc-g1hFKSNs.js +3935 -0
  15. package/dist-lib/toc-B6VpkJge.js +213 -0
  16. package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-6WxRNKCc.js} +2 -2
  17. package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-CFqpDK0k.js} +1 -1
  18. package/dist-lib/wordcanvas.js +1 -1
  19. package/dist-node/{chunk-GXFDF7UY.js → chunk-22JHAERT.js} +95 -23
  20. package/dist-node/chunk-22JHAERT.js.map +7 -0
  21. package/dist-node/{chunk-2RCPB7UZ.js → chunk-6AJJMHKY.js} +1 -1
  22. package/dist-node/chunk-6AJJMHKY.js.map +7 -0
  23. package/dist-node/{chunk-XDUDPPJW.js → chunk-CDN6WU2P.js} +89 -26
  24. package/dist-node/chunk-CDN6WU2P.js.map +7 -0
  25. package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
  26. package/dist-node/chunk-EGSAVPCC.js.map +7 -0
  27. package/dist-node/{chunk-IJLL6IFJ.js → chunk-RNB336F3.js} +116 -5
  28. package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-RNB336F3.js.map} +2 -2
  29. package/dist-node/{engine-FRCX7PXF.js → engine-5FGDJD2H.js} +3 -3
  30. package/dist-node/export.js +92 -31
  31. package/dist-node/export.js.map +2 -2
  32. package/dist-node/generate-toc.js +5 -5
  33. package/dist-node/import.js +3 -3
  34. package/dist-node/recalc-docx.js +4 -4
  35. package/dist-node/recalc-docx.js.map +1 -1
  36. package/package.json +1 -1
  37. package/types/model.d.ts +231 -225
  38. package/types/recalc-docx.d.ts +27 -27
  39. package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
  40. package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
  41. package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
  42. package/dist-lib/toc-CZel_Kk3.js +0 -127
  43. package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
  44. package/dist-node/chunk-GXFDF7UY.js.map +0 -7
  45. package/dist-node/chunk-TBSXA2I4.js.map +0 -7
  46. package/dist-node/chunk-XDUDPPJW.js.map +0 -7
  47. /package/dist-node/{engine-FRCX7PXF.js.map → engine-5FGDJD2H.js.map} +0 -0
@@ -8,8 +8,8 @@ import {
8
8
  createLayoutEngine,
9
9
  effectiveSection,
10
10
  resolveSections
11
- } from "./chunk-IJLL6IFJ.js";
12
- import "./chunk-XDUDPPJW.js";
11
+ } from "./chunk-RNB336F3.js";
12
+ import "./chunk-CDN6WU2P.js";
13
13
  import "./chunk-4ICCHZX4.js";
14
14
  import "./chunk-XSRSBST2.js";
15
15
  export {
@@ -17,4 +17,4 @@ export {
17
17
  effectiveSection,
18
18
  resolveSections
19
19
  };
20
- //# sourceMappingURL=engine-FRCX7PXF.js.map
20
+ //# sourceMappingURL=engine-5FGDJD2H.js.map
@@ -34,20 +34,20 @@ import {
34
34
  } from "./chunk-4PDVRJF6.js";
35
35
  import {
36
36
  pageOfBlockMap
37
- } from "./chunk-TBSXA2I4.js";
37
+ } from "./chunk-EGSAVPCC.js";
38
38
  import {
39
39
  strToU8,
40
40
  zipSync
41
41
  } from "./chunk-5PUCGN47.js";
42
42
  import {
43
43
  createLayoutEngine
44
- } from "./chunk-IJLL6IFJ.js";
44
+ } from "./chunk-RNB336F3.js";
45
45
  import {
46
46
  detectTocHeadings,
47
47
  inRange,
48
48
  parseTocInstruction,
49
49
  textOfRuns
50
- } from "./chunk-XDUDPPJW.js";
50
+ } from "./chunk-CDN6WU2P.js";
51
51
  import {
52
52
  DEFAULT_GRID_COLOR,
53
53
  FOOTNOTE_RULE_COLOR,
@@ -24545,7 +24545,7 @@ function toBuffer(bytes) {
24545
24545
  var PT = 72 / 96;
24546
24546
  async function renderPdf(doc, opts = {}) {
24547
24547
  await installMeasureHost();
24548
- const { createLayoutEngine: createLayoutEngine2 } = await import("./engine-FRCX7PXF.js");
24548
+ const { createLayoutEngine: createLayoutEngine2 } = await import("./engine-5FGDJD2H.js");
24549
24549
  const tree = createLayoutEngine2().layout(doc);
24550
24550
  const warnings = new WarningSink();
24551
24551
  const images = opts.images ?? {};
@@ -24751,9 +24751,33 @@ function runsXml(runs, ctx) {
24751
24751
  const sdtId = runs[i].style.sdtId;
24752
24752
  if (sdtId) {
24753
24753
  let j = i;
24754
- let inner = "";
24755
- while (j < runs.length && runs[j].style.sdtId === sdtId) inner += singleRun(runs[j++], ctx);
24756
- out += el("w:sdt", void 0, sdtPrXml(ctx.sdts[sdtId]) + el("w:sdtContent", void 0, inner));
24754
+ const seg = [];
24755
+ while (j < runs.length && runs[j].style.sdtId === sdtId) seg.push(runs[j++]);
24756
+ out += el("w:sdt", void 0, sdtPrXml(ctx.sdts[sdtId]) + el("w:sdtContent", void 0, fieldRunsXml(seg, ctx)));
24757
+ i = j;
24758
+ } else {
24759
+ let j = i;
24760
+ const seg = [];
24761
+ while (j < runs.length && !runs[j].style.sdtId) seg.push(runs[j++]);
24762
+ out += fieldRunsXml(seg, ctx);
24763
+ i = j;
24764
+ }
24765
+ }
24766
+ return out;
24767
+ }
24768
+ function fieldRunsXml(runs, ctx) {
24769
+ let out = "";
24770
+ let i = 0;
24771
+ while (i < runs.length) {
24772
+ const fid = runs[i].style.fieldId;
24773
+ const def = fid ? ctx.fields?.[fid] : void 0;
24774
+ if (fid && def && def.kind === "builtin") {
24775
+ let j = i;
24776
+ const seg = [];
24777
+ while (j < runs.length && runs[j].style.fieldId === fid) seg.push(runs[j++]);
24778
+ const isToken = def.spec?.type === "PAGE" || def.spec?.type === "NUMPAGES";
24779
+ const result = seg.map((r) => el("w:r", void 0, runPropsXml(r.style) + (isToken ? "" : runContent(r.text)))).join("");
24780
+ out += fldRun("begin") + instrRun(def.instruction) + fldRun("separate") + result + fldRun("end");
24757
24781
  i = j;
24758
24782
  } else {
24759
24783
  out += singleRun(runs[i], ctx);
@@ -24820,10 +24844,24 @@ function paragraphXml(p, ctx) {
24820
24844
  const flush = (upto) => {
24821
24845
  while (mi < sorted.length && sorted[mi].offset <= upto) body += bookmarkEl(sorted[mi++]);
24822
24846
  };
24823
- for (const run of runs) {
24847
+ let ri = 0;
24848
+ while (ri < runs.length) {
24824
24849
  flush(cum);
24825
- body += singleRun(run, ctx);
24826
- cum += run.text.length;
24850
+ const fid = runs[ri].style.fieldId;
24851
+ const def = fid ? ctx.fields?.[fid] : void 0;
24852
+ if (fid && def && def.kind === "builtin") {
24853
+ const seg = [];
24854
+ while (ri < runs.length && runs[ri].style.fieldId === fid) {
24855
+ seg.push(runs[ri]);
24856
+ cum += runs[ri].text.length;
24857
+ ri++;
24858
+ }
24859
+ body += fieldRunsXml(seg, ctx);
24860
+ } else {
24861
+ body += singleRun(runs[ri], ctx);
24862
+ cum += runs[ri].text.length;
24863
+ ri++;
24864
+ }
24827
24865
  }
24828
24866
  flush(cum);
24829
24867
  while (mi < sorted.length) body += bookmarkEl(sorted[mi++]);
@@ -24984,35 +25022,58 @@ function imageParagraphXml(img, ctx) {
24984
25022
  const relId = ctx.rels.add(REL.image, target);
24985
25023
  const cx = pxToEmu(img.widthPx);
24986
25024
  const cy = pxToEmu(img.heightPx);
24987
- const drawing = el(
24988
- "w:drawing",
25025
+ const graphic = el(
25026
+ "a:graphic",
24989
25027
  void 0,
24990
25028
  el(
24991
- "wp:inline",
24992
- { distT: 0, distB: 0, distL: 0, distR: 0 },
24993
- el("wp:extent", { cx, cy }) + el("wp:docPr", { id: ctx.nextId(), name: "image" }) + el(
24994
- "a:graphic",
25029
+ "a:graphicData",
25030
+ { uri: "http://schemas.openxmlformats.org/drawingml/2006/picture" },
25031
+ el(
25032
+ "pic:pic",
24995
25033
  void 0,
24996
25034
  el(
24997
- "a:graphicData",
24998
- { uri: "http://schemas.openxmlformats.org/drawingml/2006/picture" },
24999
- el(
25000
- "pic:pic",
25001
- void 0,
25002
- el(
25003
- "pic:nvPicPr",
25004
- void 0,
25005
- el("pic:cNvPr", { id: 0, name: "image" }) + el("pic:cNvPicPr")
25006
- ) + el("pic:blipFill", void 0, el("a:blip", { "r:embed": relId }) + el("a:stretch", void 0, el("a:fillRect"))) + el(
25007
- "pic:spPr",
25008
- void 0,
25009
- el("a:xfrm", void 0, el("a:off", { x: 0, y: 0 }) + el("a:ext", { cx, cy })) + el("a:prstGeom", { prst: "rect" }, el("a:avLst"))
25010
- )
25011
- )
25035
+ "pic:nvPicPr",
25036
+ void 0,
25037
+ el("pic:cNvPr", { id: 0, name: "image" }) + el("pic:cNvPicPr")
25038
+ ) + el("pic:blipFill", void 0, el("a:blip", { "r:embed": relId }) + el("a:stretch", void 0, el("a:fillRect"))) + el(
25039
+ "pic:spPr",
25040
+ void 0,
25041
+ el("a:xfrm", void 0, el("a:off", { x: 0, y: 0 }) + el("a:ext", { cx, cy })) + el("a:prstGeom", { prst: "rect" }, el("a:avLst"))
25012
25042
  )
25013
25043
  )
25014
25044
  )
25015
25045
  );
25046
+ if (img.anchor) {
25047
+ const a = img.anchor;
25048
+ const anchor = el(
25049
+ "wp:anchor",
25050
+ {
25051
+ distT: 0,
25052
+ distB: 0,
25053
+ distL: 0,
25054
+ distR: 0,
25055
+ simplePos: 0,
25056
+ // relativeHeight is an unsigned int in OOXML; clamp the (possibly
25057
+ // negative, from repeated "send to back") z into the valid range.
25058
+ relativeHeight: Math.max(0, Math.round(a.z ?? 0)),
25059
+ behindDoc: a.behind ? 1 : 0,
25060
+ locked: 0,
25061
+ layoutInCell: 1,
25062
+ allowOverlap: 1
25063
+ },
25064
+ el("wp:simplePos", { x: 0, y: 0 }) + el("wp:positionH", { relativeFrom: a.relFromH }, el("wp:posOffset", void 0, String(pxToEmu(a.offsetXPx)))) + el("wp:positionV", { relativeFrom: a.relFromV }, el("wp:posOffset", void 0, String(pxToEmu(a.offsetYPx)))) + el("wp:extent", { cx, cy }) + el("wp:wrapNone") + el("wp:docPr", { id: ctx.nextId(), name: "image" }) + graphic
25065
+ );
25066
+ return el("w:p", void 0, el("w:r", void 0, el("w:drawing", void 0, anchor)));
25067
+ }
25068
+ const drawing = el(
25069
+ "w:drawing",
25070
+ void 0,
25071
+ el(
25072
+ "wp:inline",
25073
+ { distT: 0, distB: 0, distL: 0, distR: 0 },
25074
+ el("wp:extent", { cx, cy }) + el("wp:docPr", { id: ctx.nextId(), name: "image" }) + graphic
25075
+ )
25076
+ );
25016
25077
  const align = img.align === "center" ? "center" : img.align === "right" ? "right" : "left";
25017
25078
  return el("w:p", void 0, el("w:pPr", void 0, el("w:jc", { "w:val": align })) + el("w:r", void 0, drawing));
25018
25079
  }