documents.js 1.64.0 → 1.66.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 (117) hide show
  1. package/README.md +20 -11
  2. package/dist/color-C98dn-pT.d.ts +2 -0
  3. package/dist/edit/docx/content.cjs +5 -0
  4. package/dist/edit/docx/content.js +5 -0
  5. package/dist/edit/docx/image.cjs +1 -0
  6. package/dist/edit/docx/image.d.cts +2 -2
  7. package/dist/edit/docx/image.d.ts +2 -2
  8. package/dist/edit/docx/image.js +1 -1
  9. package/dist/edit/docx/paragraph.cjs +10 -1
  10. package/dist/edit/docx/paragraph.d.cts +4 -3
  11. package/dist/edit/docx/paragraph.d.ts +4 -3
  12. package/dist/edit/docx/paragraph.js +13 -4
  13. package/dist/edit/docx/props.d.ts +1 -1
  14. package/dist/edit/docx/run.cjs +8 -1
  15. package/dist/edit/docx/run.d.cts +2 -2
  16. package/dist/edit/docx/run.d.ts +2 -2
  17. package/dist/edit/docx/run.js +8 -2
  18. package/dist/edit/docx/vector.cjs +69 -0
  19. package/dist/edit/docx/vector.d.cts +6 -0
  20. package/dist/edit/docx/vector.d.ts +6 -0
  21. package/dist/edit/docx/vector.js +68 -0
  22. package/dist/edit/drawingml/vector.cjs +113 -0
  23. package/dist/edit/drawingml/vector.d.cts +9 -0
  24. package/dist/edit/drawingml/vector.d.ts +9 -0
  25. package/dist/edit/drawingml/vector.js +109 -0
  26. package/dist/edit/odg/content.cjs +1 -26
  27. package/dist/edit/odg/content.js +1 -26
  28. package/dist/edit/odg/page.cjs +14 -1
  29. package/dist/edit/odg/page.d.cts +5 -3
  30. package/dist/edit/odg/page.d.ts +5 -3
  31. package/dist/edit/odg/page.js +14 -1
  32. package/dist/edit/odg/style.cjs +17 -3
  33. package/dist/edit/odg/style.d.cts +1 -0
  34. package/dist/edit/odg/style.d.ts +1 -0
  35. package/dist/edit/odg/style.js +17 -3
  36. package/dist/edit/odg/vector.cjs +65 -3
  37. package/dist/edit/odg/vector.d.cts +2 -2
  38. package/dist/edit/odg/vector.d.ts +2 -2
  39. package/dist/edit/odg/vector.js +63 -4
  40. package/dist/edit/odp/content.cjs +4 -1
  41. package/dist/edit/odp/content.js +5 -2
  42. package/dist/edit/odp/shape.cjs +1 -1
  43. package/dist/edit/odp/shape.d.cts +1 -1
  44. package/dist/edit/odp/shape.d.ts +1 -1
  45. package/dist/edit/odp/shape.js +1 -1
  46. package/dist/edit/odp/slide.cjs +4 -0
  47. package/dist/edit/odp/slide.d.cts +8 -5
  48. package/dist/edit/odp/slide.d.ts +9 -6
  49. package/dist/edit/odp/slide.js +4 -0
  50. package/dist/edit/odt/content.cjs +5 -0
  51. package/dist/edit/odt/content.d.ts +2 -2
  52. package/dist/edit/odt/content.js +5 -0
  53. package/dist/edit/odt/editor.cjs +7 -0
  54. package/dist/edit/odt/editor.d.cts +3 -2
  55. package/dist/edit/odt/editor.d.ts +5 -4
  56. package/dist/edit/odt/editor.js +7 -0
  57. package/dist/edit/odt/list.cjs +13 -0
  58. package/dist/edit/odt/list.d.cts +1 -1
  59. package/dist/edit/odt/list.d.ts +1 -1
  60. package/dist/edit/odt/list.js +13 -0
  61. package/dist/edit/odt/paragraph.d.ts +1 -1
  62. package/dist/edit/odt/run.d.ts +1 -1
  63. package/dist/edit/odt/table.d.ts +1 -1
  64. package/dist/edit/pptx/content.cjs +5 -2
  65. package/dist/edit/pptx/content.js +5 -2
  66. package/dist/edit/pptx/shape.cjs +2 -5
  67. package/dist/edit/pptx/shape.d.ts +1 -1
  68. package/dist/edit/pptx/shape.js +2 -5
  69. package/dist/edit/pptx/slide.cjs +7 -0
  70. package/dist/edit/pptx/slide.d.cts +6 -4
  71. package/dist/edit/pptx/slide.d.ts +8 -6
  72. package/dist/edit/pptx/slide.js +7 -0
  73. package/dist/edit/pptx/table.d.ts +1 -1
  74. package/dist/edit/pptx/vector.cjs +17 -0
  75. package/dist/edit/pptx/vector.d.cts +6 -0
  76. package/dist/edit/pptx/vector.d.ts +6 -0
  77. package/dist/edit/pptx/vector.js +16 -0
  78. package/dist/{image-BfRLAD9B.d.cts → image-DRqXQmEg.d.cts} +2 -1
  79. package/dist/{image-BfRLAD9B.d.ts → image-DRqXQmEg.d.ts} +2 -1
  80. package/dist/index.cjs +2 -2
  81. package/dist/index.d.cts +7 -7
  82. package/dist/index.d.ts +13 -13
  83. package/dist/index.js +2 -2
  84. package/dist/layout/shared.cjs +1 -0
  85. package/dist/layout/shared.js +1 -0
  86. package/dist/{list-BuBM9rwQ.d.cts → list-BzcN-LTJ.d.cts} +3 -0
  87. package/dist/{list-CvKxhy3y.d.ts → list-nlhN5bat.d.ts} +4 -1
  88. package/dist/markdown/write.cjs +1 -1
  89. package/dist/markdown/write.js +1 -1
  90. package/dist/mathml/compose.cjs +8 -0
  91. package/dist/mathml/compose.js +8 -0
  92. package/dist/mathml/layout-types.d.cts +14 -2
  93. package/dist/mathml/layout-types.d.ts +14 -2
  94. package/dist/mathml/layout.cjs +62 -3
  95. package/dist/mathml/layout.js +62 -3
  96. package/dist/mathml/metrics.d.cts +17 -1
  97. package/dist/mathml/metrics.d.ts +17 -1
  98. package/dist/mathml/operators.cjs +1 -1
  99. package/dist/mathml/operators.js +1 -1
  100. package/dist/model/color.d.ts +1 -1
  101. package/dist/model/embedded-drawing.cjs +47 -0
  102. package/dist/model/embedded-drawing.d.cts +4 -2
  103. package/dist/model/embedded-drawing.d.ts +4 -2
  104. package/dist/model/embedded-drawing.js +46 -1
  105. package/dist/{paragraph-CoUi_88j.d.ts → paragraph-DndYbWuT.d.ts} +1 -1
  106. package/dist/{run-D2rTWHbt.d.ts → run-BhYv2wJf.d.ts} +3 -2
  107. package/dist/{run-CJfh8rv3.d.ts → run-DtrwZwN6.d.ts} +1 -1
  108. package/dist/{run-B3GNScJH.d.cts → run-P0b2pDdX.d.cts} +2 -1
  109. package/dist/{shape-BkVcwPcf.d.ts → shape-B-TjU_Ej.d.ts} +1 -1
  110. package/dist/{shape-CXZ6fejV.d.cts → shape-C8qDhn0l.d.cts} +1 -1
  111. package/dist/{shape-CVXedeL7.d.ts → shape-XGp__l-J.d.ts} +2 -2
  112. package/dist/{table-DqfqMkVq.d.ts → table-BHeUmLzZ.d.ts} +1 -1
  113. package/dist/{table-DvS_7UQS.d.ts → table-DQpKafyl.d.ts} +1 -1
  114. package/dist/{vector-Puuqu_IT.d.cts → vector-D03KX8Ux.d.cts} +15 -2
  115. package/dist/{vector-Puuqu_IT.d.ts → vector-D03KX8Ux.d.ts} +15 -2
  116. package/package.json +3 -3
  117. package/dist/color-Bo228AY2.d.ts +0 -2
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model_formula = require("../model/formula.cjs");
3
2
  const require_model_embedded_drawing = require("../model/embedded-drawing.cjs");
3
+ const require_model_formula = require("../model/formula.cjs");
4
4
  let markdown_codec = require("markdown-codec");
5
5
  //#region src/markdown/write.ts
6
6
  function toLegacyEmbeddedDocument(document) {
@@ -1,5 +1,5 @@
1
- import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
2
1
  import { drawingOfBlock } from "../model/embedded-drawing.js";
2
+ import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
3
3
  import { MarkdownUnsupportedDocumentKindError, writeMarkdown } from "markdown-codec";
4
4
  //#region src/markdown/write.ts
5
5
  function toLegacyEmbeddedDocument(document) {
@@ -17,6 +17,14 @@ function shiftItems(items, dxPt, dyPt) {
17
17
  yPt: p.yPt + dyPt
18
18
  }))
19
19
  };
20
+ if (item.kind === "assembled-glyphs") return {
21
+ ...item,
22
+ placements: item.placements.map((p) => ({
23
+ glyphId: p.glyphId,
24
+ xPt: p.xPt + dxPt,
25
+ yPt: p.yPt + dyPt
26
+ }))
27
+ };
20
28
  return {
21
29
  ...item,
22
30
  xPt: item.xPt + dxPt,
@@ -16,6 +16,14 @@ function shiftItems(items, dxPt, dyPt) {
16
16
  yPt: p.yPt + dyPt
17
17
  }))
18
18
  };
19
+ if (item.kind === "assembled-glyphs") return {
20
+ ...item,
21
+ placements: item.placements.map((p) => ({
22
+ glyphId: p.glyphId,
23
+ xPt: p.xPt + dxPt,
24
+ yPt: p.yPt + dyPt
25
+ }))
26
+ };
19
27
  return {
20
28
  ...item,
21
29
  xPt: item.xPt + dxPt,
@@ -29,7 +29,19 @@ interface MathStroke {
29
29
  readonly widthPt: number;
30
30
  readonly color: MathColor;
31
31
  }
32
- type MathLayoutItem = MathGlyphRun | MathRule | MathStroke;
32
+ interface MathGlyphPlacement {
33
+ readonly glyphId: number;
34
+ readonly xPt: number;
35
+ readonly yPt: number;
36
+ }
37
+ interface MathAssembledGlyphs {
38
+ readonly kind: 'assembled-glyphs';
39
+ readonly placements: readonly MathGlyphPlacement[];
40
+ readonly text: string;
41
+ readonly sizePt: number;
42
+ readonly color: MathColor;
43
+ }
44
+ type MathLayoutItem = MathGlyphRun | MathRule | MathStroke | MathAssembledGlyphs;
33
45
  interface MathBox {
34
46
  readonly widthPt: number;
35
47
  readonly heightPt: number;
@@ -47,4 +59,4 @@ interface MathLayoutResult {
47
59
  readonly diagnostics: readonly MathDiagnostic[];
48
60
  }
49
61
  //#endregion
50
- export { MathBox, MathColor, MathDiagnostic, MathDiagnosticKind, MathGlyphRun, MathLayoutItem, MathLayoutResult, MathRule, MathStroke };
62
+ export { MathAssembledGlyphs, MathBox, MathColor, MathDiagnostic, MathDiagnosticKind, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathLayoutResult, MathRule, MathStroke };
@@ -29,7 +29,19 @@ interface MathStroke {
29
29
  readonly widthPt: number;
30
30
  readonly color: MathColor;
31
31
  }
32
- type MathLayoutItem = MathGlyphRun | MathRule | MathStroke;
32
+ interface MathGlyphPlacement {
33
+ readonly glyphId: number;
34
+ readonly xPt: number;
35
+ readonly yPt: number;
36
+ }
37
+ interface MathAssembledGlyphs {
38
+ readonly kind: 'assembled-glyphs';
39
+ readonly placements: readonly MathGlyphPlacement[];
40
+ readonly text: string;
41
+ readonly sizePt: number;
42
+ readonly color: MathColor;
43
+ }
44
+ type MathLayoutItem = MathGlyphRun | MathRule | MathStroke | MathAssembledGlyphs;
33
45
  interface MathBox {
34
46
  readonly widthPt: number;
35
47
  readonly heightPt: number;
@@ -47,4 +59,4 @@ interface MathLayoutResult {
47
59
  readonly diagnostics: readonly MathDiagnostic[];
48
60
  }
49
61
  //#endregion
50
- export { MathBox, MathColor, MathDiagnostic, MathDiagnosticKind, MathGlyphRun, MathLayoutItem, MathLayoutResult, MathRule, MathStroke };
62
+ export { MathAssembledGlyphs, MathBox, MathColor, MathDiagnostic, MathDiagnosticKind, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathLayoutResult, MathRule, MathStroke };
@@ -37,7 +37,11 @@ function unsupported(ctx, element) {
37
37
  }
38
38
  function layoutToken(rawText, variant, ctx) {
39
39
  const styled = require_mathml_variant.applyMathVariant(rawText, variant);
40
+ const nominalAscentPt = ctx.metrics.ascentPerEm * ctx.sizePt;
41
+ const nominalDescentPt = ctx.metrics.descentPerEm * ctx.sizePt;
40
42
  let widthPt = 0;
43
+ let ascentPt = 0;
44
+ let descentPt = 0;
41
45
  let text = "";
42
46
  for (const ch of styled) {
43
47
  const codePoint = ch.codePointAt(0);
@@ -52,10 +56,10 @@ function layoutToken(rawText, variant, ctx) {
52
56
  }
53
57
  text += ch;
54
58
  widthPt += glyph.advanceWidthPt;
59
+ ascentPt = Math.max(ascentPt, glyph.inkAscentPt ?? nominalAscentPt);
60
+ descentPt = Math.max(descentPt, glyph.inkDescentPt ?? nominalDescentPt);
55
61
  }
56
62
  if (text.length === 0) return require_mathml_compose.EMPTY_BOX;
57
- const ascentPt = ctx.metrics.ascentPerEm * ctx.sizePt;
58
- const descentPt = ctx.metrics.descentPerEm * ctx.sizePt;
59
63
  const items = [{
60
64
  kind: "glyphs",
61
65
  xPt: 0,
@@ -80,8 +84,63 @@ function tokenVariant(element, intrinsicDefault, ctx) {
80
84
  function miIntrinsicDefault(content) {
81
85
  return [...content].length === 1 ? "italic" : "normal";
82
86
  }
87
+ function isStretchyOperator(element) {
88
+ if (require_mathml_nodes.elementLocalName(element) !== "mo") return false;
89
+ if (require_mathml_nodes.attrValue(element, "stretchy") === "false") return false;
90
+ return require_mathml_operators.operatorProperties(require_mathml_nodes.textContent(element).trim()).stretchy;
91
+ }
92
+ function stretchedBox(result, text, ctx) {
93
+ const axisPt = ctx.metrics.axisHeightPt;
94
+ const inkHeightPt = result.inkAscentPt + result.inkDescentPt;
95
+ const originAboveBaselinePt = axisPt - (result.inkAscentPt - result.inkDescentPt) / 2;
96
+ const ascentPt = axisPt + inkHeightPt / 2;
97
+ const descentPt = inkHeightPt / 2 - axisPt;
98
+ const items = [{
99
+ kind: "assembled-glyphs",
100
+ placements: result.placements.map((placement) => ({
101
+ glyphId: placement.glyphId,
102
+ xPt: 0,
103
+ yPt: ascentPt - originAboveBaselinePt - placement.offsetPt
104
+ })),
105
+ text,
106
+ sizePt: ctx.sizePt,
107
+ color: ctx.color
108
+ }];
109
+ return {
110
+ widthPt: result.advanceWidthPt,
111
+ ascentPt,
112
+ descentPt,
113
+ heightPt: ascentPt + descentPt,
114
+ items
115
+ };
116
+ }
117
+ function stretchOperator(element, targetSizePt, ctx) {
118
+ const text = require_mathml_nodes.textContent(element).trim();
119
+ const codePoints = [...text];
120
+ if (codePoints.length !== 1) return;
121
+ const codePoint = codePoints[0]?.codePointAt(0);
122
+ if (codePoint === void 0) return;
123
+ const result = ctx.metrics.stretch(codePoint, "vertical", targetSizePt, ctx.sizePt);
124
+ if (result === void 0 || result.kind === "base") return;
125
+ return stretchedBox(result, text, ctx);
126
+ }
127
+ function stretchRowOperators(children, boxes, ctx) {
128
+ const stretchy = children.map(isStretchyOperator);
129
+ if (!stretchy.includes(true)) return boxes;
130
+ const others = boxes.filter((_, index) => stretchy[index] !== true);
131
+ if (others.length === 0) return boxes;
132
+ const axisPt = ctx.metrics.axisHeightPt;
133
+ const maxAscentPt = others.reduce((max, box) => Math.max(max, box.ascentPt), 0);
134
+ const maxDescentPt = others.reduce((max, box) => Math.max(max, box.descentPt), 0);
135
+ const targetSizePt = 2 * Math.max(maxAscentPt - axisPt, maxDescentPt + axisPt);
136
+ return boxes.map((box, index) => {
137
+ if (stretchy[index] !== true) return box;
138
+ const element = children[index];
139
+ return (element === void 0 ? void 0 : stretchOperator(element, targetSizePt, ctx)) ?? box;
140
+ });
141
+ }
83
142
  function layoutRowChildren(children, ctx) {
84
- const boxes = children.map((child) => layoutNode(child, ctx));
143
+ const boxes = stretchRowOperators(children, children.map((child) => layoutNode(child, ctx)), ctx);
85
144
  const gapsPt = children.map((child, index) => {
86
145
  if (index === 0) return 0;
87
146
  const previous = children[index - 1];
@@ -36,7 +36,11 @@ function unsupported(ctx, element) {
36
36
  }
37
37
  function layoutToken(rawText, variant, ctx) {
38
38
  const styled = applyMathVariant(rawText, variant);
39
+ const nominalAscentPt = ctx.metrics.ascentPerEm * ctx.sizePt;
40
+ const nominalDescentPt = ctx.metrics.descentPerEm * ctx.sizePt;
39
41
  let widthPt = 0;
42
+ let ascentPt = 0;
43
+ let descentPt = 0;
40
44
  let text = "";
41
45
  for (const ch of styled) {
42
46
  const codePoint = ch.codePointAt(0);
@@ -51,10 +55,10 @@ function layoutToken(rawText, variant, ctx) {
51
55
  }
52
56
  text += ch;
53
57
  widthPt += glyph.advanceWidthPt;
58
+ ascentPt = Math.max(ascentPt, glyph.inkAscentPt ?? nominalAscentPt);
59
+ descentPt = Math.max(descentPt, glyph.inkDescentPt ?? nominalDescentPt);
54
60
  }
55
61
  if (text.length === 0) return EMPTY_BOX;
56
- const ascentPt = ctx.metrics.ascentPerEm * ctx.sizePt;
57
- const descentPt = ctx.metrics.descentPerEm * ctx.sizePt;
58
62
  const items = [{
59
63
  kind: "glyphs",
60
64
  xPt: 0,
@@ -79,8 +83,63 @@ function tokenVariant(element, intrinsicDefault, ctx) {
79
83
  function miIntrinsicDefault(content) {
80
84
  return [...content].length === 1 ? "italic" : "normal";
81
85
  }
86
+ function isStretchyOperator(element) {
87
+ if (elementLocalName(element) !== "mo") return false;
88
+ if (attrValue(element, "stretchy") === "false") return false;
89
+ return operatorProperties(textContent(element).trim()).stretchy;
90
+ }
91
+ function stretchedBox(result, text, ctx) {
92
+ const axisPt = ctx.metrics.axisHeightPt;
93
+ const inkHeightPt = result.inkAscentPt + result.inkDescentPt;
94
+ const originAboveBaselinePt = axisPt - (result.inkAscentPt - result.inkDescentPt) / 2;
95
+ const ascentPt = axisPt + inkHeightPt / 2;
96
+ const descentPt = inkHeightPt / 2 - axisPt;
97
+ const items = [{
98
+ kind: "assembled-glyphs",
99
+ placements: result.placements.map((placement) => ({
100
+ glyphId: placement.glyphId,
101
+ xPt: 0,
102
+ yPt: ascentPt - originAboveBaselinePt - placement.offsetPt
103
+ })),
104
+ text,
105
+ sizePt: ctx.sizePt,
106
+ color: ctx.color
107
+ }];
108
+ return {
109
+ widthPt: result.advanceWidthPt,
110
+ ascentPt,
111
+ descentPt,
112
+ heightPt: ascentPt + descentPt,
113
+ items
114
+ };
115
+ }
116
+ function stretchOperator(element, targetSizePt, ctx) {
117
+ const text = textContent(element).trim();
118
+ const codePoints = [...text];
119
+ if (codePoints.length !== 1) return;
120
+ const codePoint = codePoints[0]?.codePointAt(0);
121
+ if (codePoint === void 0) return;
122
+ const result = ctx.metrics.stretch(codePoint, "vertical", targetSizePt, ctx.sizePt);
123
+ if (result === void 0 || result.kind === "base") return;
124
+ return stretchedBox(result, text, ctx);
125
+ }
126
+ function stretchRowOperators(children, boxes, ctx) {
127
+ const stretchy = children.map(isStretchyOperator);
128
+ if (!stretchy.includes(true)) return boxes;
129
+ const others = boxes.filter((_, index) => stretchy[index] !== true);
130
+ if (others.length === 0) return boxes;
131
+ const axisPt = ctx.metrics.axisHeightPt;
132
+ const maxAscentPt = others.reduce((max, box) => Math.max(max, box.ascentPt), 0);
133
+ const maxDescentPt = others.reduce((max, box) => Math.max(max, box.descentPt), 0);
134
+ const targetSizePt = 2 * Math.max(maxAscentPt - axisPt, maxDescentPt + axisPt);
135
+ return boxes.map((box, index) => {
136
+ if (stretchy[index] !== true) return box;
137
+ const element = children[index];
138
+ return (element === void 0 ? void 0 : stretchOperator(element, targetSizePt, ctx)) ?? box;
139
+ });
140
+ }
82
141
  function layoutRowChildren(children, ctx) {
83
- const boxes = children.map((child) => layoutNode(child, ctx));
142
+ const boxes = stretchRowOperators(children, children.map((child) => layoutNode(child, ctx)), ctx);
84
143
  const gapsPt = children.map((child, index) => {
85
144
  if (index === 0) return 0;
86
145
  const previous = children[index - 1];
@@ -3,6 +3,21 @@ interface MathGlyphMetrics {
3
3
  readonly advanceWidthPt: number;
4
4
  readonly italicCorrectionPt: number;
5
5
  readonly topAccentXPt?: number;
6
+ readonly inkAscentPt?: number;
7
+ readonly inkDescentPt?: number;
8
+ }
9
+ type MathStretchAxis = 'vertical' | 'horizontal';
10
+ interface MathStretchGlyph {
11
+ readonly glyphId: number;
12
+ readonly offsetPt: number;
13
+ }
14
+ interface MathStretchResult {
15
+ readonly kind: 'base' | 'variant' | 'assembly';
16
+ readonly sizePt: number;
17
+ readonly advanceWidthPt: number;
18
+ readonly inkAscentPt: number;
19
+ readonly inkDescentPt: number;
20
+ readonly placements: readonly MathStretchGlyph[];
6
21
  }
7
22
  interface MathFontMetrics {
8
23
  readonly ascentPerEm: number;
@@ -39,6 +54,7 @@ interface MathFontMetrics {
39
54
  readonly scriptScriptPercentScaleDown: number;
40
55
  readonly defaultRuleThicknessPt: number;
41
56
  glyph(codePoint: number, sizePt: number): MathGlyphMetrics | undefined;
57
+ stretch(codePoint: number, axis: MathStretchAxis, targetSizePt: number, sizePt: number): MathStretchResult | undefined;
42
58
  }
43
59
  //#endregion
44
- export { MathFontMetrics, MathGlyphMetrics };
60
+ export { MathFontMetrics, MathGlyphMetrics, MathStretchAxis, MathStretchGlyph, MathStretchResult };
@@ -3,6 +3,21 @@ interface MathGlyphMetrics {
3
3
  readonly advanceWidthPt: number;
4
4
  readonly italicCorrectionPt: number;
5
5
  readonly topAccentXPt?: number;
6
+ readonly inkAscentPt?: number;
7
+ readonly inkDescentPt?: number;
8
+ }
9
+ type MathStretchAxis = 'vertical' | 'horizontal';
10
+ interface MathStretchGlyph {
11
+ readonly glyphId: number;
12
+ readonly offsetPt: number;
13
+ }
14
+ interface MathStretchResult {
15
+ readonly kind: 'base' | 'variant' | 'assembly';
16
+ readonly sizePt: number;
17
+ readonly advanceWidthPt: number;
18
+ readonly inkAscentPt: number;
19
+ readonly inkDescentPt: number;
20
+ readonly placements: readonly MathStretchGlyph[];
6
21
  }
7
22
  interface MathFontMetrics {
8
23
  readonly ascentPerEm: number;
@@ -39,6 +54,7 @@ interface MathFontMetrics {
39
54
  readonly scriptScriptPercentScaleDown: number;
40
55
  readonly defaultRuleThicknessPt: number;
41
56
  glyph(codePoint: number, sizePt: number): MathGlyphMetrics | undefined;
57
+ stretch(codePoint: number, axis: MathStretchAxis, targetSizePt: number, sizePt: number): MathStretchResult | undefined;
42
58
  }
43
59
  //#endregion
44
- export { MathFontMetrics, MathGlyphMetrics };
60
+ export { MathFontMetrics, MathGlyphMetrics, MathStretchAxis, MathStretchGlyph, MathStretchResult };
@@ -51,7 +51,7 @@ function bigOperatorMovable() {
51
51
  rspaceEm: THIN_SPACE,
52
52
  largeop: true,
53
53
  movablelimits: true,
54
- stretchy: true
54
+ stretchy: false
55
55
  };
56
56
  }
57
57
  function bigOperatorFixed() {
@@ -50,7 +50,7 @@ function bigOperatorMovable() {
50
50
  rspaceEm: THIN_SPACE,
51
51
  largeop: true,
52
52
  movablelimits: true,
53
- stretchy: true
53
+ stretchy: false
54
54
  };
55
55
  }
56
56
  function bigOperatorFixed() {
@@ -1,2 +1,2 @@
1
- import { a as rgbHexToColor, i as colorToRgbHex, n as LayoutColor, r as LayoutColorSchema, t as COLOR_BLACK } from "../color-Bo228AY2.js";
1
+ import { a as rgbHexToColor, i as colorToRgbHex, n as LayoutColor, r as LayoutColorSchema, t as COLOR_BLACK } from "../color-C98dn-pT.js";
2
2
  export { COLOR_BLACK, type LayoutColor, LayoutColorSchema, colorToRgbHex, rgbHexToColor };
@@ -27,6 +27,53 @@ function buildDrawingBlock(size, vectors) {
27
27
  function drawingOfBlock(block) {
28
28
  return block.document.kind === "drawing" ? block.document : void 0;
29
29
  }
30
+ function shiftBox(frame, dxPt, dyPt) {
31
+ return {
32
+ ...frame,
33
+ xPt: frame.xPt + dxPt,
34
+ yPt: frame.yPt + dyPt
35
+ };
36
+ }
37
+ function shiftPoint(point, dxPt, dyPt) {
38
+ return {
39
+ xPt: point.xPt + dxPt,
40
+ yPt: point.yPt + dyPt
41
+ };
42
+ }
43
+ function translateVector(vector, dxPt, dyPt) {
44
+ switch (vector.kind) {
45
+ case "line": return {
46
+ ...vector,
47
+ from: shiftPoint(vector.from, dxPt, dyPt),
48
+ to: shiftPoint(vector.to, dxPt, dyPt)
49
+ };
50
+ case "rect": return {
51
+ ...vector,
52
+ frame: shiftBox(vector.frame, dxPt, dyPt)
53
+ };
54
+ case "ellipse": return {
55
+ ...vector,
56
+ frame: shiftBox(vector.frame, dxPt, dyPt)
57
+ };
58
+ case "path": return {
59
+ ...vector,
60
+ frame: shiftBox(vector.frame, dxPt, dyPt)
61
+ };
62
+ }
63
+ }
64
+ const FLOW_CONTAINER_ORIGIN = {
65
+ xPt: 0,
66
+ yPt: 0
67
+ };
68
+ function embeddedDrawingVectors(block, containerOriginPt) {
69
+ const drawing = drawingOfBlock(block);
70
+ if (drawing === void 0) return [];
71
+ const dxPt = block.frame.xPt + containerOriginPt.xPt;
72
+ const dyPt = block.frame.yPt + containerOriginPt.yPt;
73
+ return drawing.pages.flatMap((page) => page.vectors.map((vector) => translateVector(vector, dxPt, dyPt)));
74
+ }
30
75
  //#endregion
76
+ exports.FLOW_CONTAINER_ORIGIN = FLOW_CONTAINER_ORIGIN;
31
77
  exports.buildDrawingBlock = buildDrawingBlock;
32
78
  exports.drawingOfBlock = drawingOfBlock;
79
+ exports.embeddedDrawingVectors = embeddedDrawingVectors;
@@ -1,8 +1,10 @@
1
- import { ContentDocument, ContentEmbeddedObjectBlock, ContentVector, PageSize } from "document-schema.js";
1
+ import { ContentDocument, ContentEmbeddedObjectBlock, ContentPathPoint, ContentVector, PageSize } from "document-schema.js";
2
2
  //#region src/model/embedded-drawing.d.ts
3
3
  declare function buildDrawingBlock(size: PageSize, vectors: readonly ContentVector[]): ContentEmbeddedObjectBlock;
4
4
  declare function drawingOfBlock(block: ContentEmbeddedObjectBlock): Extract<ContentDocument, {
5
5
  kind: 'drawing';
6
6
  }> | undefined;
7
+ declare const FLOW_CONTAINER_ORIGIN: ContentPathPoint;
8
+ declare function embeddedDrawingVectors(block: ContentEmbeddedObjectBlock, containerOriginPt: ContentPathPoint): ContentVector[];
7
9
  //#endregion
8
- export { buildDrawingBlock, drawingOfBlock };
10
+ export { FLOW_CONTAINER_ORIGIN, buildDrawingBlock, drawingOfBlock, embeddedDrawingVectors };
@@ -1,8 +1,10 @@
1
- import { ContentDocument, ContentEmbeddedObjectBlock, ContentVector, PageSize } from "document-schema.js";
1
+ import { ContentDocument, ContentEmbeddedObjectBlock, ContentPathPoint, ContentVector, PageSize } from "document-schema.js";
2
2
  //#region src/model/embedded-drawing.d.ts
3
3
  declare function buildDrawingBlock(size: PageSize, vectors: readonly ContentVector[]): ContentEmbeddedObjectBlock;
4
4
  declare function drawingOfBlock(block: ContentEmbeddedObjectBlock): Extract<ContentDocument, {
5
5
  kind: 'drawing';
6
6
  }> | undefined;
7
+ declare const FLOW_CONTAINER_ORIGIN: ContentPathPoint;
8
+ declare function embeddedDrawingVectors(block: ContentEmbeddedObjectBlock, containerOriginPt: ContentPathPoint): ContentVector[];
7
9
  //#endregion
8
- export { buildDrawingBlock, drawingOfBlock };
10
+ export { FLOW_CONTAINER_ORIGIN, buildDrawingBlock, drawingOfBlock, embeddedDrawingVectors };
@@ -26,5 +26,50 @@ function buildDrawingBlock(size, vectors) {
26
26
  function drawingOfBlock(block) {
27
27
  return block.document.kind === "drawing" ? block.document : void 0;
28
28
  }
29
+ function shiftBox(frame, dxPt, dyPt) {
30
+ return {
31
+ ...frame,
32
+ xPt: frame.xPt + dxPt,
33
+ yPt: frame.yPt + dyPt
34
+ };
35
+ }
36
+ function shiftPoint(point, dxPt, dyPt) {
37
+ return {
38
+ xPt: point.xPt + dxPt,
39
+ yPt: point.yPt + dyPt
40
+ };
41
+ }
42
+ function translateVector(vector, dxPt, dyPt) {
43
+ switch (vector.kind) {
44
+ case "line": return {
45
+ ...vector,
46
+ from: shiftPoint(vector.from, dxPt, dyPt),
47
+ to: shiftPoint(vector.to, dxPt, dyPt)
48
+ };
49
+ case "rect": return {
50
+ ...vector,
51
+ frame: shiftBox(vector.frame, dxPt, dyPt)
52
+ };
53
+ case "ellipse": return {
54
+ ...vector,
55
+ frame: shiftBox(vector.frame, dxPt, dyPt)
56
+ };
57
+ case "path": return {
58
+ ...vector,
59
+ frame: shiftBox(vector.frame, dxPt, dyPt)
60
+ };
61
+ }
62
+ }
63
+ const FLOW_CONTAINER_ORIGIN = {
64
+ xPt: 0,
65
+ yPt: 0
66
+ };
67
+ function embeddedDrawingVectors(block, containerOriginPt) {
68
+ const drawing = drawingOfBlock(block);
69
+ if (drawing === void 0) return [];
70
+ const dxPt = block.frame.xPt + containerOriginPt.xPt;
71
+ const dyPt = block.frame.yPt + containerOriginPt.yPt;
72
+ return drawing.pages.flatMap((page) => page.vectors.map((vector) => translateVector(vector, dxPt, dyPt)));
73
+ }
29
74
  //#endregion
30
- export { buildDrawingBlock, drawingOfBlock };
75
+ export { FLOW_CONTAINER_ORIGIN, buildDrawingBlock, drawingOfBlock, embeddedDrawingVectors };
@@ -1,5 +1,5 @@
1
1
  import { t as Alignment } from "./style-DkamR3aY.js";
2
- import { n as RunInit, t as OdtRun } from "./run-CJfh8rv3.js";
2
+ import { n as RunInit, t as OdtRun } from "./run-DtrwZwN6.js";
3
3
  import { Package, XmlElement, XmlNode } from "odf.js";
4
4
  //#region src/edit/odt/paragraph.d.ts
5
5
  interface ParagraphInit {
@@ -1,6 +1,7 @@
1
- import { n as LayoutColor } from "./color-Bo228AY2.js";
1
+ import { n as LayoutColor } from "./color-C98dn-pT.js";
2
2
  import { XmlElement, XmlNode } from "ooxml.js";
3
3
  //#region src/edit/docx/run.d.ts
4
+ declare function wordprocessingText(element: XmlElement): string;
4
5
  interface RunInit {
5
6
  readonly text?: string;
6
7
  readonly bold?: boolean;
@@ -35,4 +36,4 @@ declare class DocxRun {
35
36
  }
36
37
  declare function buildRun(init?: RunInit): XmlElement;
37
38
  //#endregion
38
- export { RunInit as n, buildRun as r, DocxRun as t };
39
+ export { wordprocessingText as i, RunInit as n, buildRun as r, DocxRun as t };
@@ -1,4 +1,4 @@
1
- import { n as LayoutColor } from "./color-Bo228AY2.js";
1
+ import { n as LayoutColor } from "./color-C98dn-pT.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/run.d.ts
4
4
  interface RunInit {
@@ -1,6 +1,7 @@
1
1
  import { n as LayoutColor } from "./color-71eoF1Up.cjs";
2
2
  import { XmlElement, XmlNode } from "ooxml.js";
3
3
  //#region src/edit/docx/run.d.ts
4
+ declare function wordprocessingText(element: XmlElement): string;
4
5
  interface RunInit {
5
6
  readonly text?: string;
6
7
  readonly bold?: boolean;
@@ -35,4 +36,4 @@ declare class DocxRun {
35
36
  }
36
37
  declare function buildRun(init?: RunInit): XmlElement;
37
38
  //#endregion
38
- export { RunInit as n, buildRun as r, DocxRun as t };
39
+ export { wordprocessingText as i, RunInit as n, buildRun as r, DocxRun as t };
@@ -1,4 +1,4 @@
1
- import { n as LayoutColor } from "./color-Bo228AY2.js";
1
+ import { n as LayoutColor } from "./color-C98dn-pT.js";
2
2
  import { t as Box } from "./geometry-DaJr8yQW.js";
3
3
  import { t as Alignment } from "./style-DkamR3aY.js";
4
4
  import { XmlElement, XmlNode } from "ooxml.js";
@@ -1,6 +1,6 @@
1
1
  import { t as Box } from "./geometry-DaJr8yQW.cjs";
2
2
  import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-BXbXKPy3.cjs";
3
- import { t as OdtList } from "./list-BuBM9rwQ.cjs";
3
+ import { t as OdtList } from "./list-BzcN-LTJ.cjs";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
5
5
  //#region src/edit/odp/shape.d.ts
6
6
  declare class OdpShape {
@@ -1,6 +1,6 @@
1
1
  import { t as Box } from "./geometry-DaJr8yQW.js";
2
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CoUi_88j.js";
3
- import { t as OdtList } from "./list-CvKxhy3y.js";
2
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-DndYbWuT.js";
3
+ import { t as OdtList } from "./list-nlhN5bat.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
5
5
  //#region src/edit/odp/shape.d.ts
6
6
  declare class OdpShape {
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CoUi_88j.js";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-DndYbWuT.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/table.d.ts
4
4
  interface TableInit {
@@ -1,5 +1,5 @@
1
1
  import { t as Box } from "./geometry-DaJr8yQW.js";
2
- import { t as DrawingParagraphInit } from "./shape-BkVcwPcf.js";
2
+ import { t as DrawingParagraphInit } from "./shape-B-TjU_Ej.js";
3
3
  import { XmlElement } from "ooxml.js";
4
4
  //#region src/edit/pptx/table.d.ts
5
5
  interface PptxTableInit {
@@ -1,10 +1,11 @@
1
- import { Box, Color, ContentPathPoint, ContentStroke, ContentSubpath } from "document-schema.js";
1
+ import { Box, Color, ContentPathPoint, ContentStroke, ContentSubpath, ContentVector } from "document-schema.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odg/vector.d.ts
4
4
  interface BoxVectorInit {
5
5
  readonly frame: Box;
6
6
  readonly fill?: Color;
7
7
  readonly stroke?: ContentStroke;
8
+ readonly textFlowAnchored?: boolean;
8
9
  }
9
10
  type OdgBoxVectorKind = 'rect' | 'ellipse';
10
11
  declare function buildRectElement(pkg: Package, init: BoxVectorInit): XmlElement;
@@ -32,9 +33,11 @@ interface LineVectorInit {
32
33
  readonly from: ContentPathPoint;
33
34
  readonly to: ContentPathPoint;
34
35
  readonly stroke: ContentStroke;
36
+ readonly textFlowAnchored?: boolean;
35
37
  }
36
38
  declare function buildLineElement(pkg: Package, init: LineVectorInit): XmlElement;
37
39
  declare class OdgLineVector {
40
+ readonly kind = "line";
38
41
  private readonly container;
39
42
  private readonly node;
40
43
  private readonly pkg;
@@ -55,9 +58,11 @@ interface PathVectorInit {
55
58
  readonly subpaths: readonly ContentSubpath[];
56
59
  readonly fill?: Color;
57
60
  readonly stroke?: ContentStroke;
61
+ readonly textFlowAnchored?: boolean;
58
62
  }
59
63
  declare function buildPathElement(pkg: Package, init: PathVectorInit): XmlElement;
60
64
  declare class OdgPathVector {
65
+ readonly kind = "path";
61
66
  private readonly container;
62
67
  private readonly node;
63
68
  private readonly pkg;
@@ -76,5 +81,13 @@ declare class OdgPathVector {
76
81
  get subpaths(): ContentSubpath[];
77
82
  remove(): void;
78
83
  }
84
+ type OdgVectorKind = OdgBoxVectorKind | 'line' | 'path';
85
+ type OdgVector = OdgBoxVector | OdgLineVector | OdgPathVector;
86
+ declare function wrapVectorElement(container: XmlNode[], node: XmlElement, pkg: Package): OdgVector | undefined;
87
+ interface VectorElementOptions {
88
+ readonly textFlowAnchored?: boolean;
89
+ }
90
+ declare function buildVectorElement(pkg: Package, vector: ContentVector, options?: VectorElementOptions): XmlElement;
91
+ declare function appendVectorTo(container: XmlNode[], pkg: Package, vector: ContentVector, options?: VectorElementOptions): OdgVector;
79
92
  //#endregion
80
- export { OdgLineVector as a, buildEllipseElement as c, buildRectElement as d, OdgBoxVectorKind as i, buildLineElement as l, LineVectorInit as n, OdgPathVector as o, OdgBoxVector as r, PathVectorInit as s, BoxVectorInit as t, buildPathElement as u };
93
+ export { wrapVectorElement as _, OdgLineVector as a, OdgVectorKind as c, appendVectorTo as d, buildEllipseElement as f, buildVectorElement as g, buildRectElement as h, OdgBoxVectorKind as i, PathVectorInit as l, buildPathElement as m, LineVectorInit as n, OdgPathVector as o, buildLineElement as p, OdgBoxVector as r, OdgVector as s, BoxVectorInit as t, VectorElementOptions as u };