js.documents 6.5.0 → 6.5.2

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 (79) hide show
  1. package/dist/edit/docx/content.cjs +13 -8
  2. package/dist/edit/docx/content.js +13 -8
  3. package/dist/edit/docx/image.cjs +4 -0
  4. package/dist/edit/docx/image.d.cts +2 -2
  5. package/dist/edit/docx/image.d.ts +2 -2
  6. package/dist/edit/docx/image.js +4 -1
  7. package/dist/edit/docx/paragraph.d.cts +1 -1
  8. package/dist/edit/docx/paragraph.d.ts +1 -1
  9. package/dist/edit/odg/page.d.cts +2 -2
  10. package/dist/edit/odg/page.d.ts +2 -2
  11. package/dist/edit/odp/image.cjs +1 -1
  12. package/dist/edit/odp/image.d.cts +1 -1
  13. package/dist/edit/odp/image.d.ts +1 -1
  14. package/dist/edit/odp/image.js +1 -1
  15. package/dist/edit/odp/shape.cjs +5 -2
  16. package/dist/edit/odp/shape.d.cts +1 -1
  17. package/dist/edit/odp/shape.d.ts +1 -1
  18. package/dist/edit/odp/shape.js +6 -3
  19. package/dist/edit/odp/slide.d.cts +3 -3
  20. package/dist/edit/odp/slide.d.ts +3 -3
  21. package/dist/edit/odt/content.d.cts +2 -2
  22. package/dist/edit/odt/content.d.ts +2 -2
  23. package/dist/edit/odt/editor.d.cts +3 -3
  24. package/dist/edit/odt/editor.d.ts +3 -3
  25. package/dist/edit/odt/image.d.cts +1 -1
  26. package/dist/edit/odt/image.d.ts +1 -1
  27. package/dist/edit/odt/list.d.cts +1 -1
  28. package/dist/edit/odt/list.d.ts +1 -1
  29. package/dist/edit/odt/paragraph.d.cts +1 -1
  30. package/dist/edit/odt/paragraph.d.ts +1 -1
  31. package/dist/edit/odt/table.d.cts +1 -1
  32. package/dist/edit/odt/table.d.ts +1 -1
  33. package/dist/edit/pptx/content.cjs +1 -0
  34. package/dist/edit/pptx/content.js +1 -0
  35. package/dist/edit/pptx/image.cjs +1 -1
  36. package/dist/edit/pptx/image.d.cts +1 -1
  37. package/dist/edit/pptx/image.d.ts +1 -1
  38. package/dist/edit/pptx/image.js +1 -1
  39. package/dist/edit/pptx/shape.cjs +7 -5
  40. package/dist/edit/pptx/shape.d.cts +1 -1
  41. package/dist/edit/pptx/shape.d.ts +1 -1
  42. package/dist/edit/pptx/shape.js +7 -5
  43. package/dist/edit/pptx/slide.d.cts +3 -3
  44. package/dist/edit/pptx/slide.d.ts +3 -3
  45. package/dist/edit/pptx/table.d.cts +1 -1
  46. package/dist/edit/pptx/table.d.ts +1 -1
  47. package/dist/{image-DQxA-zGN.d.ts → image-BqMIKksf.d.cts} +1 -1
  48. package/dist/{image-DQxA-zGN.d.cts → image-BqMIKksf.d.ts} +1 -1
  49. package/dist/{image-fah3VkZg.d.cts → image-C3L2cCLQ.d.cts} +1 -1
  50. package/dist/{image-CwbCQ49u.d.ts → image-CAeD6ZbR.d.ts} +1 -1
  51. package/dist/{image-BQ7F9xxz.d.cts → image-CRzkqiWd.d.cts} +3 -2
  52. package/dist/{image-BQ7F9xxz.d.ts → image-CRzkqiWd.d.ts} +3 -2
  53. package/dist/{image-DzqEWMDw.d.ts → image-D1z0T9Za.d.cts} +1 -1
  54. package/dist/{image-DzqEWMDw.d.cts → image-D1z0T9Za.d.ts} +1 -1
  55. package/dist/index.d.cts +6 -6
  56. package/dist/index.d.ts +6 -6
  57. package/dist/layout/shared.cjs +1 -0
  58. package/dist/layout/shared.js +1 -0
  59. package/dist/{list-B_Sy668f.d.ts → list-C32h8MNc.d.ts} +1 -1
  60. package/dist/{list-BiTN6oop.d.cts → list-yc0dJrOX.d.cts} +1 -1
  61. package/dist/odf-package/media.d.cts +1 -1
  62. package/dist/odf-package/media.d.ts +1 -1
  63. package/dist/opc/content-types.cjs +2 -1
  64. package/dist/opc/content-types.js +2 -1
  65. package/dist/opc/media.cjs +2 -3
  66. package/dist/opc/media.d.cts +1 -1
  67. package/dist/opc/media.d.ts +1 -1
  68. package/dist/opc/media.js +2 -3
  69. package/dist/{paragraph-BBmkECjw.d.cts → paragraph-CRaLSzWz.d.cts} +1 -1
  70. package/dist/{paragraph-D_fDin5K.d.ts → paragraph-D4f705GG.d.ts} +1 -1
  71. package/dist/{shape-Ca-xsrde.d.cts → shape-C2ef6uwC.d.cts} +1 -1
  72. package/dist/{shape-xpgICOEx.d.ts → shape-CAm2tKw5.d.cts} +3 -3
  73. package/dist/{shape-DqkYq1OL.d.cts → shape-DAt3nOQm.d.ts} +3 -3
  74. package/dist/{shape-BY5P8kDn.d.ts → shape-DwZouh8R.d.ts} +1 -1
  75. package/dist/{table-CpEmblWG.d.cts → table-CnRh10dW.d.cts} +1 -1
  76. package/dist/{table-C_KDsX5R.d.cts → table-CtbzOK8s.d.cts} +1 -1
  77. package/dist/{table-C3VWWdjr.d.ts → table-D2CgT0Gf.d.ts} +1 -1
  78. package/dist/{table-Ck0fyr8d.d.ts → table-DCqmpGAB.d.ts} +1 -1
  79. package/package.json +12 -12
@@ -4,6 +4,7 @@ const require_ports_clock = require("../../ports/clock.cjs");
4
4
  const require_opc_rels = require("../../opc/rels.cjs");
5
5
  const require_model_units = require("../../model/units.cjs");
6
6
  const require_opc_content_types = require("../../opc/content-types.cjs");
7
+ const require_edit_docx_image = require("./image.cjs");
7
8
  const require_edit_docx_scaffold = require("./scaffold.cjs");
8
9
  const require_edit_docx_editor = require("./editor.cjs");
9
10
  const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs");
@@ -105,6 +106,7 @@ function appendBlocks(body, blocks, options) {
105
106
  paragraph.styleId = block.styleId;
106
107
  paragraph.alignment = block.alignment;
107
108
  paragraph.list = block.list;
109
+ require_edit_docx_image.assertDocxWritableImageFormat(next.format);
108
110
  paragraph.insertImageAfter({
109
111
  format: next.format,
110
112
  bytes: (0, ooxml_js.base64ToBytes)(next.base64),
@@ -201,14 +203,17 @@ function appendCellBlock(cell, block) {
201
203
  }
202
204
  function appendBlock(body, block, options) {
203
205
  if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
204
- else if (block.kind === "image") body.appendParagraph().insertImageAfter({
205
- format: block.format,
206
- bytes: (0, ooxml_js.base64ToBytes)(block.base64),
207
- widthPt: block.widthPt,
208
- heightPt: block.heightPt,
209
- altText: block.altText
210
- });
211
- else if (block.kind === "pageBreak") body.appendPageBreak();
206
+ else if (block.kind === "image") {
207
+ const paragraph = body.appendParagraph();
208
+ require_edit_docx_image.assertDocxWritableImageFormat(block.format);
209
+ paragraph.insertImageAfter({
210
+ format: block.format,
211
+ bytes: (0, ooxml_js.base64ToBytes)(block.base64),
212
+ widthPt: block.widthPt,
213
+ heightPt: block.heightPt,
214
+ altText: block.altText
215
+ });
216
+ } else if (block.kind === "pageBreak") body.appendPageBreak();
212
217
  else if (block.kind === "table") appendTable(body, block);
213
218
  else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
214
219
  }
@@ -3,6 +3,7 @@ import { systemClock } from "../../ports/clock.js";
3
3
  import { addRelationship } from "../../opc/rels.js";
4
4
  import { ptToTwips } from "../../model/units.js";
5
5
  import { ensureContentTypeOverride } from "../../opc/content-types.js";
6
+ import { assertDocxWritableImageFormat } from "./image.js";
6
7
  import { createEmptyDocxPackage } from "./scaffold.js";
7
8
  import { DocxEditor } from "./editor.js";
8
9
  import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from "../../model/embedded-drawing.js";
@@ -104,6 +105,7 @@ function appendBlocks(body, blocks, options) {
104
105
  paragraph.styleId = block.styleId;
105
106
  paragraph.alignment = block.alignment;
106
107
  paragraph.list = block.list;
108
+ assertDocxWritableImageFormat(next.format);
107
109
  paragraph.insertImageAfter({
108
110
  format: next.format,
109
111
  bytes: base64ToBytes(next.base64),
@@ -200,14 +202,17 @@ function appendCellBlock(cell, block) {
200
202
  }
201
203
  function appendBlock(body, block, options) {
202
204
  if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
203
- else if (block.kind === "image") body.appendParagraph().insertImageAfter({
204
- format: block.format,
205
- bytes: base64ToBytes(block.base64),
206
- widthPt: block.widthPt,
207
- heightPt: block.heightPt,
208
- altText: block.altText
209
- });
210
- else if (block.kind === "pageBreak") body.appendPageBreak();
205
+ else if (block.kind === "image") {
206
+ const paragraph = body.appendParagraph();
207
+ assertDocxWritableImageFormat(block.format);
208
+ paragraph.insertImageAfter({
209
+ format: block.format,
210
+ bytes: base64ToBytes(block.base64),
211
+ widthPt: block.widthPt,
212
+ heightPt: block.heightPt,
213
+ altText: block.altText
214
+ });
215
+ } else if (block.kind === "pageBreak") body.appendPageBreak();
211
216
  else if (block.kind === "table") appendTable(body, block);
212
217
  else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
213
218
  }
@@ -3,6 +3,9 @@ const require_xml_fragment = require("../../xml/fragment.cjs");
3
3
  const require_model_units = require("../../model/units.cjs");
4
4
  const require_opc_media = require("../../opc/media.cjs");
5
5
  //#region src/edit/docx/image.ts
6
+ function assertDocxWritableImageFormat(format) {
7
+ if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly -- png/jpeg/gif)");
8
+ }
6
9
  const DRAWING_NS = {
7
10
  wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
8
11
  a: "http://schemas.openxmlformats.org/drawingml/2006/main",
@@ -70,6 +73,7 @@ function insertImageMedia(context, documentRoot, image) {
70
73
  return buildInlineDrawing(relationshipId, image.widthPt, image.heightPt, id, image.altText);
71
74
  }
72
75
  //#endregion
76
+ exports.assertDocxWritableImageFormat = assertDocxWritableImageFormat;
73
77
  exports.buildInlineDrawing = buildInlineDrawing;
74
78
  exports.insertImageMedia = insertImageMedia;
75
79
  exports.nextDrawingId = nextDrawingId;
@@ -1,2 +1,2 @@
1
- import { a as nextDrawingId, i as insertImageMedia, n as MediaContext, r as buildInlineDrawing, t as ImageInit } from "../../image-BQ7F9xxz.cjs";
2
- export { ImageInit, MediaContext, buildInlineDrawing, insertImageMedia, nextDrawingId };
1
+ import { a as insertImageMedia, i as buildInlineDrawing, n as MediaContext, o as nextDrawingId, r as assertDocxWritableImageFormat, t as ImageInit } from "../../image-CRzkqiWd.cjs";
2
+ export { ImageInit, MediaContext, assertDocxWritableImageFormat, buildInlineDrawing, insertImageMedia, nextDrawingId };
@@ -1,2 +1,2 @@
1
- import { a as nextDrawingId, i as insertImageMedia, n as MediaContext, r as buildInlineDrawing, t as ImageInit } from "../../image-BQ7F9xxz.js";
2
- export { ImageInit, MediaContext, buildInlineDrawing, insertImageMedia, nextDrawingId };
1
+ import { a as insertImageMedia, i as buildInlineDrawing, n as MediaContext, o as nextDrawingId, r as assertDocxWritableImageFormat, t as ImageInit } from "../../image-CRzkqiWd.js";
2
+ export { ImageInit, MediaContext, assertDocxWritableImageFormat, buildInlineDrawing, insertImageMedia, nextDrawingId };
@@ -2,6 +2,9 @@ import { el } from "../../xml/fragment.js";
2
2
  import { ptToEmu } from "../../model/units.js";
3
3
  import { addImageMedia } from "../../opc/media.js";
4
4
  //#region src/edit/docx/image.ts
5
+ function assertDocxWritableImageFormat(format) {
6
+ if (format === "svg") throw new Error("buildDocxPackage: an image block in svg format has no OOXML blip this writer can produce (WordprocessingML's a:blip only references a raster part Word decodes directly -- png/jpeg/gif)");
7
+ }
5
8
  const DRAWING_NS = {
6
9
  wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
7
10
  a: "http://schemas.openxmlformats.org/drawingml/2006/main",
@@ -69,4 +72,4 @@ function insertImageMedia(context, documentRoot, image) {
69
72
  return buildInlineDrawing(relationshipId, image.widthPt, image.heightPt, id, image.altText);
70
73
  }
71
74
  //#endregion
72
- export { buildInlineDrawing, insertImageMedia, nextDrawingId };
75
+ export { assertDocxWritableImageFormat, buildInlineDrawing, insertImageMedia, nextDrawingId };
@@ -1,6 +1,6 @@
1
1
  import { r as MathMlNode$1 } from "../../nodes-jrlUmrNs.cjs";
2
2
  import { t as OmmlWriteResult } from "../../write-DWupt1QI.cjs";
3
- import { n as MediaContext, t as ImageInit } from "../../image-BQ7F9xxz.cjs";
3
+ import { n as MediaContext, t as ImageInit } from "../../image-CRzkqiWd.cjs";
4
4
  import { n as RunInit, t as DocxRun } from "../../run-swnb_wQO.cjs";
5
5
  import { ContentListMembership, ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "ooxml.js";
@@ -1,6 +1,6 @@
1
1
  import { r as MathMlNode$1 } from "../../nodes-jrlUmrNs.js";
2
2
  import { t as OmmlWriteResult } from "../../write-qKlz1R0J.js";
3
- import { n as MediaContext, t as ImageInit } from "../../image-BQ7F9xxz.js";
3
+ import { n as MediaContext, t as ImageInit } from "../../image-CRzkqiWd.js";
4
4
  import { n as RunInit, t as DocxRun } from "../../run-Bv6gpAMj.js";
5
5
  import { Package, XmlElement, XmlNode } from "ooxml.js";
6
6
  import { ContentListMembership, ContentVector } from "document-schema.js";
@@ -1,5 +1,5 @@
1
- import { t as ImageInit } from "../../image-DzqEWMDw.cjs";
2
- import { t as OdpShape } from "../../shape-DqkYq1OL.cjs";
1
+ import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
2
+ import { t as OdpShape } from "../../shape-CAm2tKw5.cjs";
3
3
  import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-DDP7hgvm.cjs";
4
4
  import { Box, ContentVector } from "document-schema.js";
5
5
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -1,5 +1,5 @@
1
- import { t as ImageInit } from "../../image-DzqEWMDw.js";
2
- import { t as OdpShape } from "../../shape-xpgICOEx.js";
1
+ import { t as ImageInit } from "../../image-D1z0T9Za.js";
2
+ import { t as OdpShape } from "../../shape-DAt3nOQm.js";
3
3
  import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-DDP7hgvm.js";
4
4
  import { Box, ContentVector } from "document-schema.js";
5
5
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -4,7 +4,7 @@ const require_edit_odp_shape = require("./shape.cjs");
4
4
  //#region src/edit/odp/image.ts
5
5
  function insertImageFrameMedia(context, frame, image) {
6
6
  const { partPath } = require_odf_package_media.addImageMedia(context.pkg, image.bytes, image.format);
7
- return require_edit_odp_shape.buildImageFrame(partPath, frame);
7
+ return require_edit_odp_shape.buildImageFrame(partPath, frame, image.altText);
8
8
  }
9
9
  //#endregion
10
10
  exports.insertImageFrameMedia = insertImageFrameMedia;
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertImageFrameMedia, t as ImageInit } from "../../image-DzqEWMDw.cjs";
1
+ import { n as MediaContext, r as insertImageFrameMedia, t as ImageInit } from "../../image-D1z0T9Za.cjs";
2
2
  export { ImageInit, MediaContext, insertImageFrameMedia };
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertImageFrameMedia, t as ImageInit } from "../../image-DzqEWMDw.js";
1
+ import { n as MediaContext, r as insertImageFrameMedia, t as ImageInit } from "../../image-D1z0T9Za.js";
2
2
  export { ImageInit, MediaContext, insertImageFrameMedia };
@@ -3,7 +3,7 @@ import { buildImageFrame } from "./shape.js";
3
3
  //#region src/edit/odp/image.ts
4
4
  function insertImageFrameMedia(context, frame, image) {
5
5
  const { partPath } = addImageMedia(context.pkg, image.bytes, image.format);
6
- return buildImageFrame(partPath, frame);
6
+ return buildImageFrame(partPath, frame, image.altText);
7
7
  }
8
8
  //#endregion
9
9
  export { insertImageFrameMedia };
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xml_fragment = require("../../xml/fragment.cjs");
3
+ const require_xml_entities = require("../../xml/entities.cjs");
3
4
  const require_xml_edit = require("../../xml/edit.cjs");
4
5
  const require_edit_geometry = require("../geometry.cjs");
5
6
  const require_edit_odt_paragraph = require("../odt/paragraph.cjs");
@@ -91,13 +92,15 @@ function buildTextBoxFrame(pkg, frame, text) {
91
92
  "svg:height": (0, odf_js.formatOdfLength)(frame.heightPt)
92
93
  }, [require_xml_fragment.el("draw:text-box", {}, [require_edit_odt_paragraph.buildParagraph(pkg, { text })])]);
93
94
  }
94
- function buildImageFrame(partPath, frame) {
95
+ function buildImageFrame(partPath, frame, altText) {
96
+ const children = [require_xml_fragment.el("draw:image", { "xlink:href": partPath })];
97
+ if (altText !== void 0) children.push(require_xml_fragment.el("svg:title", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(altText))]));
95
98
  return require_xml_fragment.el("draw:frame", {
96
99
  "svg:x": (0, odf_js.formatOdfLength)(frame.xPt),
97
100
  "svg:y": (0, odf_js.formatOdfLength)(frame.yPt),
98
101
  "svg:width": (0, odf_js.formatOdfLength)(frame.widthPt),
99
102
  "svg:height": (0, odf_js.formatOdfLength)(frame.heightPt)
100
- }, [require_xml_fragment.el("draw:image", { "xlink:href": partPath })]);
103
+ }, children);
101
104
  }
102
105
  function buildTableFrame(frame, tableElement) {
103
106
  return require_xml_fragment.el("draw:frame", {
@@ -1,2 +1,2 @@
1
- import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-DqkYq1OL.cjs";
1
+ import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-CAm2tKw5.cjs";
2
2
  export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
@@ -1,2 +1,2 @@
1
- import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-xpgICOEx.js";
1
+ import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-DAt3nOQm.js";
2
2
  export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
@@ -1,4 +1,5 @@
1
- import { el } from "../../xml/fragment.js";
1
+ import { el, txt } from "../../xml/fragment.js";
2
+ import { encodeXmlText as encodeXmlText$1 } from "../../xml/entities.js";
2
3
  import { removeChild } from "../../xml/edit.js";
3
4
  import { applyOdfGeometry } from "../geometry.js";
4
5
  import { OdtParagraph, buildParagraph } from "../odt/paragraph.js";
@@ -90,13 +91,15 @@ function buildTextBoxFrame(pkg, frame, text) {
90
91
  "svg:height": formatOdfLength(frame.heightPt)
91
92
  }, [el("draw:text-box", {}, [buildParagraph(pkg, { text })])]);
92
93
  }
93
- function buildImageFrame(partPath, frame) {
94
+ function buildImageFrame(partPath, frame, altText) {
95
+ const children = [el("draw:image", { "xlink:href": partPath })];
96
+ if (altText !== void 0) children.push(el("svg:title", {}, [txt(encodeXmlText$1(altText))]));
94
97
  return el("draw:frame", {
95
98
  "svg:x": formatOdfLength(frame.xPt),
96
99
  "svg:y": formatOdfLength(frame.yPt),
97
100
  "svg:width": formatOdfLength(frame.widthPt),
98
101
  "svg:height": formatOdfLength(frame.heightPt)
99
- }, [el("draw:image", { "xlink:href": partPath })]);
102
+ }, children);
100
103
  }
101
104
  function buildTableFrame(frame, tableElement) {
102
105
  return el("draw:frame", {
@@ -1,7 +1,7 @@
1
- import { t as ImageInit } from "../../image-DzqEWMDw.cjs";
2
- import { t as OdpShape } from "../../shape-DqkYq1OL.cjs";
1
+ import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
2
+ import { t as OdpShape } from "../../shape-CAm2tKw5.cjs";
3
3
  import { s as OdgVector } from "../../vector-DDP7hgvm.cjs";
4
- import { a as TableInit, n as OdtTable } from "../../table-CpEmblWG.cjs";
4
+ import { a as TableInit, n as OdtTable } from "../../table-CnRh10dW.cjs";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "odf.js";
7
7
  //#region src/edit/odp/slide.d.ts
@@ -1,7 +1,7 @@
1
- import { t as ImageInit } from "../../image-DzqEWMDw.js";
2
- import { t as OdpShape } from "../../shape-xpgICOEx.js";
1
+ import { t as ImageInit } from "../../image-D1z0T9Za.js";
2
+ import { t as OdpShape } from "../../shape-DAt3nOQm.js";
3
3
  import { s as OdgVector } from "../../vector-DDP7hgvm.js";
4
- import { a as TableInit, n as OdtTable } from "../../table-Ck0fyr8d.js";
4
+ import { a as TableInit, n as OdtTable } from "../../table-DCqmpGAB.js";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package, XmlElement, XmlNode } from "odf.js";
7
7
  //#region src/edit/odp/slide.d.ts
@@ -1,6 +1,6 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
2
- import { t as OdtParagraph } from "../../paragraph-BBmkECjw.cjs";
3
- import { n as OdtTable } from "../../table-CpEmblWG.cjs";
2
+ import { t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
3
+ import { n as OdtTable } from "../../table-CnRh10dW.cjs";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -1,6 +1,6 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.js";
2
- import { t as OdtParagraph } from "../../paragraph-D_fDin5K.js";
3
- import { n as OdtTable } from "../../table-Ck0fyr8d.js";
2
+ import { t as OdtParagraph } from "../../paragraph-D4f705GG.js";
3
+ import { n as OdtTable } from "../../table-DCqmpGAB.js";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -1,7 +1,7 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
2
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BBmkECjw.cjs";
3
- import { t as OdtList } from "../../list-BiTN6oop.cjs";
4
- import { a as TableInit, n as OdtTable } from "../../table-CpEmblWG.cjs";
2
+ import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
3
+ import { t as OdtList } from "../../list-yc0dJrOX.cjs";
4
+ import { a as TableInit, n as OdtTable } from "../../table-CnRh10dW.cjs";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package } from "odf.js";
7
7
  //#region src/edit/odt/editor.d.ts
@@ -1,7 +1,7 @@
1
1
  import { t as ClockPort } from "../../clock-C7SUuYN0.js";
2
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-D_fDin5K.js";
3
- import { t as OdtList } from "../../list-B_Sy668f.js";
4
- import { a as TableInit, n as OdtTable } from "../../table-Ck0fyr8d.js";
2
+ import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-D4f705GG.js";
3
+ import { t as OdtList } from "../../list-C32h8MNc.js";
4
+ import { a as TableInit, n as OdtTable } from "../../table-DCqmpGAB.js";
5
5
  import { Box, ContentFormula, ContentVector } from "document-schema.js";
6
6
  import { Package } from "odf.js";
7
7
  //#region src/edit/odt/editor.d.ts
@@ -1,2 +1,2 @@
1
- import { n as buildImageFrame, r as insertImageFrameMedia, t as ImageInit } from "../../image-DQxA-zGN.cjs";
1
+ import { n as buildImageFrame, r as insertImageFrameMedia, t as ImageInit } from "../../image-BqMIKksf.cjs";
2
2
  export { ImageInit, buildImageFrame, insertImageFrameMedia };
@@ -1,2 +1,2 @@
1
- import { n as buildImageFrame, r as insertImageFrameMedia, t as ImageInit } from "../../image-DQxA-zGN.js";
1
+ import { n as buildImageFrame, r as insertImageFrameMedia, t as ImageInit } from "../../image-BqMIKksf.js";
2
2
  export { ImageInit, buildImageFrame, insertImageFrameMedia };
@@ -1,2 +1,2 @@
1
- import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-BiTN6oop.cjs";
1
+ import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-yc0dJrOX.cjs";
2
2
  export { OdtList, OdtListItem, buildList };
@@ -1,2 +1,2 @@
1
- import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-B_Sy668f.js";
1
+ import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-C32h8MNc.js";
2
2
  export { OdtList, OdtListItem, buildList };
@@ -1,2 +1,2 @@
1
- import { i as headingStyleName, n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-BBmkECjw.cjs";
1
+ import { i as headingStyleName, n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
2
2
  export { OdtParagraph, ParagraphInit, buildParagraph, headingStyleName };
@@ -1,2 +1,2 @@
1
- import { i as headingStyleName, n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-D_fDin5K.js";
1
+ import { i as headingStyleName, n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-D4f705GG.js";
2
2
  export { OdtParagraph, ParagraphInit, buildParagraph, headingStyleName };
@@ -1,2 +1,2 @@
1
- import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-CpEmblWG.cjs";
1
+ import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-CnRh10dW.cjs";
2
2
  export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
@@ -1,2 +1,2 @@
1
- import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-Ck0fyr8d.js";
1
+ import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-DCqmpGAB.js";
2
2
  export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
@@ -42,6 +42,7 @@ function appendShape(slide, shape, options) {
42
42
  }
43
43
  }
44
44
  if (shape.blocks.length === 1 && onlyBlock?.kind === "image") {
45
+ if (onlyBlock.format === "svg") throw new Error("buildPptxPackage: an image block in svg format has no OOXML blip this writer can produce (PresentationML's a:blip only references a raster part PowerPoint decodes directly -- png/jpeg/gif)");
45
46
  const imageShape = slide.addImage({
46
47
  frame: shape.frame,
47
48
  format: onlyBlock.format,
@@ -41,6 +41,7 @@ function appendShape(slide, shape, options) {
41
41
  }
42
42
  }
43
43
  if (shape.blocks.length === 1 && onlyBlock?.kind === "image") {
44
+ if (onlyBlock.format === "svg") throw new Error("buildPptxPackage: an image block in svg format has no OOXML blip this writer can produce (PresentationML's a:blip only references a raster part PowerPoint decodes directly -- png/jpeg/gif)");
44
45
  const imageShape = slide.addImage({
45
46
  frame: shape.frame,
46
47
  format: onlyBlock.format,
@@ -21,7 +21,7 @@ function nextShapeId(slideRoot) {
21
21
  function insertPictureShapeMedia(context, slideRoot, frame, image) {
22
22
  const { relationshipId } = require_opc_media.addImageMedia(context.pkg, context.partPath, context.mediaDir, image.format, image.bytes);
23
23
  const id = nextShapeId(slideRoot);
24
- return require_edit_pptx_shape.buildPictureShape(frame, relationshipId, id);
24
+ return require_edit_pptx_shape.buildPictureShape(frame, relationshipId, id, image.altText);
25
25
  }
26
26
  //#endregion
27
27
  exports.insertPictureShapeMedia = insertPictureShapeMedia;
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-fah3VkZg.cjs";
1
+ import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-C3L2cCLQ.cjs";
2
2
  export { ImageInit, MediaContext, insertPictureShapeMedia };
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-CwbCQ49u.js";
1
+ import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-CAeD6ZbR.js";
2
2
  export { ImageInit, MediaContext, insertPictureShapeMedia };
@@ -20,7 +20,7 @@ function nextShapeId(slideRoot) {
20
20
  function insertPictureShapeMedia(context, slideRoot, frame, image) {
21
21
  const { relationshipId } = addImageMedia(context.pkg, context.partPath, context.mediaDir, image.format, image.bytes);
22
22
  const id = nextShapeId(slideRoot);
23
- return buildPictureShape(frame, relationshipId, id);
23
+ return buildPictureShape(frame, relationshipId, id, image.altText);
24
24
  }
25
25
  //#endregion
26
26
  export { insertPictureShapeMedia };
@@ -285,12 +285,14 @@ function buildTextBoxShape(frame, text, shapeId) {
285
285
  txBody
286
286
  ]);
287
287
  }
288
- function buildPictureShape(frame, relationshipId, shapeId) {
288
+ function buildPictureShape(frame, relationshipId, shapeId, altText) {
289
+ const cNvPrAttrs = {
290
+ id: String(shapeId),
291
+ name: `Picture ${shapeId}`
292
+ };
293
+ if (altText !== void 0) cNvPrAttrs.descr = require_xml_entities.encodeXmlText(altText);
289
294
  const nvPicPr = require_xml_fragment.el("p:nvPicPr", {}, [
290
- require_xml_fragment.el("p:cNvPr", {
291
- id: String(shapeId),
292
- name: `Picture ${shapeId}`
293
- }),
295
+ require_xml_fragment.el("p:cNvPr", cNvPrAttrs),
294
296
  require_xml_fragment.el("p:cNvPicPr"),
295
297
  require_xml_fragment.el("p:nvPr")
296
298
  ]);
@@ -1,2 +1,2 @@
1
- import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-Ca-xsrde.cjs";
1
+ import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-C2ef6uwC.cjs";
2
2
  export { DrawingParagraphInit, DrawingRunInit, PptxShape, ROTATION_UNITS_PER_DEGREE, buildDrawingParagraph, buildPictureShape, buildTextBoxShape };
@@ -1,2 +1,2 @@
1
- import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-BY5P8kDn.js";
1
+ import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-DwZouh8R.js";
2
2
  export { DrawingParagraphInit, DrawingRunInit, PptxShape, ROTATION_UNITS_PER_DEGREE, buildDrawingParagraph, buildPictureShape, buildTextBoxShape };
@@ -284,12 +284,14 @@ function buildTextBoxShape(frame, text, shapeId) {
284
284
  txBody
285
285
  ]);
286
286
  }
287
- function buildPictureShape(frame, relationshipId, shapeId) {
287
+ function buildPictureShape(frame, relationshipId, shapeId, altText) {
288
+ const cNvPrAttrs = {
289
+ id: String(shapeId),
290
+ name: `Picture ${shapeId}`
291
+ };
292
+ if (altText !== void 0) cNvPrAttrs.descr = encodeXmlText(altText);
288
293
  const nvPicPr = el("p:nvPicPr", {}, [
289
- el("p:cNvPr", {
290
- id: String(shapeId),
291
- name: `Picture ${shapeId}`
292
- }),
294
+ el("p:cNvPr", cNvPrAttrs),
293
295
  el("p:cNvPicPr"),
294
296
  el("p:nvPr")
295
297
  ]);
@@ -1,6 +1,6 @@
1
- import { t as ImageInit } from "../../image-fah3VkZg.cjs";
2
- import { r as PptxShape } from "../../shape-Ca-xsrde.cjs";
3
- import { r as PptxTableInit, t as PptxTable } from "../../table-C_KDsX5R.cjs";
1
+ import { t as ImageInit } from "../../image-C3L2cCLQ.cjs";
2
+ import { r as PptxShape } from "../../shape-C2ef6uwC.cjs";
3
+ import { r as PptxTableInit, t as PptxTable } from "../../table-CtbzOK8s.cjs";
4
4
  import { Box, ContentVector } from "document-schema.js";
5
5
  import { Package, XmlElement, XmlNode } from "ooxml.js";
6
6
  //#region src/edit/pptx/slide.d.ts
@@ -1,6 +1,6 @@
1
- import { t as ImageInit } from "../../image-CwbCQ49u.js";
2
- import { r as PptxShape } from "../../shape-BY5P8kDn.js";
3
- import { r as PptxTableInit, t as PptxTable } from "../../table-C3VWWdjr.js";
1
+ import { t as ImageInit } from "../../image-CAeD6ZbR.js";
2
+ import { r as PptxShape } from "../../shape-DwZouh8R.js";
3
+ import { r as PptxTableInit, t as PptxTable } from "../../table-D2CgT0Gf.js";
4
4
  import { Package, XmlElement, XmlNode } from "ooxml.js";
5
5
  import { Box, ContentVector } from "document-schema.js";
6
6
  //#region src/edit/pptx/slide.d.ts
@@ -1,2 +1,2 @@
1
- import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-C_KDsX5R.cjs";
1
+ import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-CtbzOK8s.cjs";
2
2
  export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
@@ -1,2 +1,2 @@
1
- import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-C3VWWdjr.js";
1
+ import { a as buildDrawingTable, i as PptxTableRow, n as PptxTableCell, o as buildTableGraphicFrame, r as PptxTableInit, s as findGraphicFrameTable, t as PptxTable } from "../../table-D2CgT0Gf.js";
2
2
  export { PptxTable, PptxTableCell, PptxTableInit, PptxTableRow, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable };
@@ -2,7 +2,7 @@ import { Box } from "document-schema.js";
2
2
  import { Package, XmlElement } from "odf.js";
3
3
  //#region src/edit/odt/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "svg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly widthPt: number;
8
8
  readonly heightPt: number;
@@ -2,7 +2,7 @@ import { Box } from "document-schema.js";
2
2
  import { Package, XmlElement } from "odf.js";
3
3
  //#region src/edit/odt/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "svg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly widthPt: number;
8
8
  readonly heightPt: number;
@@ -2,7 +2,7 @@ import { Box } from "document-schema.js";
2
2
  import { Package, XmlElement } from "ooxml.js";
3
3
  //#region src/edit/pptx/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly altText?: string;
8
8
  }
@@ -2,7 +2,7 @@ import { Package, XmlElement } from "ooxml.js";
2
2
  import { Box } from "document-schema.js";
3
3
  //#region src/edit/pptx/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly altText?: string;
8
8
  }
@@ -1,12 +1,13 @@
1
1
  import { Package, XmlElement, XmlNode } from "ooxml.js";
2
2
  //#region src/edit/docx/image.d.ts
3
3
  interface ImageInit {
4
- readonly format: "png" | "jpeg";
4
+ readonly format: "png" | "jpeg" | "gif";
5
5
  readonly bytes: Uint8Array<ArrayBuffer>;
6
6
  readonly widthPt: number;
7
7
  readonly heightPt: number;
8
8
  readonly altText?: string;
9
9
  }
10
+ declare function assertDocxWritableImageFormat(format: "png" | "jpeg" | "svg" | "gif"): asserts format is "png" | "jpeg" | "gif";
10
11
  declare function nextDrawingId(documentRoot: XmlElement): number;
11
12
  declare function buildInlineDrawing(relationshipId: string, widthPt: number, heightPt: number, id: number, altText: string | undefined): XmlElement;
12
13
  interface MediaContext {
@@ -16,4 +17,4 @@ interface MediaContext {
16
17
  }
17
18
  declare function insertImageMedia(context: MediaContext, documentRoot: XmlElement, image: ImageInit): XmlNode;
18
19
  //#endregion
19
- export { nextDrawingId as a, insertImageMedia as i, MediaContext as n, buildInlineDrawing as r, ImageInit as t };
20
+ export { insertImageMedia as a, buildInlineDrawing as i, MediaContext as n, nextDrawingId as o, assertDocxWritableImageFormat as r, ImageInit as t };
@@ -1,12 +1,13 @@
1
1
  import { Package, XmlElement, XmlNode } from "ooxml.js";
2
2
  //#region src/edit/docx/image.d.ts
3
3
  interface ImageInit {
4
- readonly format: "png" | "jpeg";
4
+ readonly format: "png" | "jpeg" | "gif";
5
5
  readonly bytes: Uint8Array<ArrayBuffer>;
6
6
  readonly widthPt: number;
7
7
  readonly heightPt: number;
8
8
  readonly altText?: string;
9
9
  }
10
+ declare function assertDocxWritableImageFormat(format: "png" | "jpeg" | "svg" | "gif"): asserts format is "png" | "jpeg" | "gif";
10
11
  declare function nextDrawingId(documentRoot: XmlElement): number;
11
12
  declare function buildInlineDrawing(relationshipId: string, widthPt: number, heightPt: number, id: number, altText: string | undefined): XmlElement;
12
13
  interface MediaContext {
@@ -16,4 +17,4 @@ interface MediaContext {
16
17
  }
17
18
  declare function insertImageMedia(context: MediaContext, documentRoot: XmlElement, image: ImageInit): XmlNode;
18
19
  //#endregion
19
- export { nextDrawingId as a, insertImageMedia as i, MediaContext as n, buildInlineDrawing as r, ImageInit as t };
20
+ export { insertImageMedia as a, buildInlineDrawing as i, MediaContext as n, nextDrawingId as o, assertDocxWritableImageFormat as r, ImageInit as t };
@@ -2,7 +2,7 @@ import { Box } from "document-schema.js";
2
2
  import { Package, XmlElement } from "odf.js";
3
3
  //#region src/edit/odp/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "svg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly altText?: string;
8
8
  }
@@ -2,7 +2,7 @@ import { Box } from "document-schema.js";
2
2
  import { Package, XmlElement } from "odf.js";
3
3
  //#region src/edit/odp/image.d.ts
4
4
  interface ImageInit {
5
- readonly format: "png" | "jpeg";
5
+ readonly format: "png" | "jpeg" | "svg" | "gif";
6
6
  readonly bytes: Uint8Array<ArrayBuffer>;
7
7
  readonly altText?: string;
8
8
  }
package/dist/index.d.cts CHANGED
@@ -33,15 +33,15 @@ import { MarkdownTable, MarkdownTableCell, MarkdownTableRow, TableInit } from ".
33
33
  import { CreateMarkdownEditorOptions, MarkdownBody, MarkdownEditor, createMarkdownEditor, openMarkdown } from "./edit/markdown/editor.cjs";
34
34
  import { BuildOdgPackageOptions, buildOdgPackage } from "./edit/odg/content.cjs";
35
35
  import { n as RunInit$1, t as OdtRun } from "./run-mzBHuFWz.cjs";
36
- import { n as ParagraphInit$1, t as OdtParagraph } from "./paragraph-BBmkECjw.cjs";
37
- import { n as OdtListItem, t as OdtList } from "./list-BiTN6oop.cjs";
38
- import { t as OdpShape } from "./shape-DqkYq1OL.cjs";
36
+ import { n as ParagraphInit$1, t as OdtParagraph } from "./paragraph-CRaLSzWz.cjs";
37
+ import { n as OdtListItem, t as OdtList } from "./list-yc0dJrOX.cjs";
38
+ import { t as OdpShape } from "./shape-CAm2tKw5.cjs";
39
39
  import { a as OdgLineVector, c as OdgVectorKind, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "./vector-DDP7hgvm.cjs";
40
40
  import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.cjs";
41
41
  import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.cjs";
42
42
  import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.cjs";
43
43
  import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.cjs";
44
- import { a as TableInit$1, i as OdtTableRow, n as OdtTable, r as OdtTableCell } from "./table-CpEmblWG.cjs";
44
+ import { a as TableInit$1, i as OdtTableRow, n as OdtTable, r as OdtTableCell } from "./table-CnRh10dW.cjs";
45
45
  import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.cjs";
46
46
  import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.cjs";
47
47
  import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.cjs";
@@ -57,8 +57,8 @@ import { a as PdfInternalLinkItem, c as PdfLineItem, d as PdfPathInit, f as PdfP
57
57
  import { PageInit, PdfPage } from "./edit/pdf/page.cjs";
58
58
  import { CreatePdfOptions, PdfEditor, createPdf, openPdf } from "./edit/pdf/editor.cjs";
59
59
  import { BuildPptxPackageOptions, buildPptxPackage, embeddedPresentationSerialiser } from "./edit/pptx/content.cjs";
60
- import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-Ca-xsrde.cjs";
61
- import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-C_KDsX5R.cjs";
60
+ import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-C2ef6uwC.cjs";
61
+ import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-CtbzOK8s.cjs";
62
62
  import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.cjs";
63
63
  import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.cjs";
64
64
  import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.cjs";
package/dist/index.d.ts CHANGED
@@ -33,15 +33,15 @@ import { MarkdownTable, MarkdownTableCell, MarkdownTableRow, TableInit } from ".
33
33
  import { CreateMarkdownEditorOptions, MarkdownBody, MarkdownEditor, createMarkdownEditor, openMarkdown } from "./edit/markdown/editor.js";
34
34
  import { BuildOdgPackageOptions, buildOdgPackage } from "./edit/odg/content.js";
35
35
  import { n as RunInit$1, t as OdtRun } from "./run-mzBHuFWz.js";
36
- import { n as ParagraphInit$1, t as OdtParagraph } from "./paragraph-D_fDin5K.js";
37
- import { n as OdtListItem, t as OdtList } from "./list-B_Sy668f.js";
38
- import { t as OdpShape } from "./shape-xpgICOEx.js";
36
+ import { n as ParagraphInit$1, t as OdtParagraph } from "./paragraph-D4f705GG.js";
37
+ import { n as OdtListItem, t as OdtList } from "./list-C32h8MNc.js";
38
+ import { t as OdpShape } from "./shape-DAt3nOQm.js";
39
39
  import { a as OdgLineVector, c as OdgVectorKind, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "./vector-DDP7hgvm.js";
40
40
  import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.js";
41
41
  import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.js";
42
42
  import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.js";
43
43
  import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.js";
44
- import { a as TableInit$1, i as OdtTableRow, n as OdtTable, r as OdtTableCell } from "./table-Ck0fyr8d.js";
44
+ import { a as TableInit$1, i as OdtTableRow, n as OdtTable, r as OdtTableCell } from "./table-DCqmpGAB.js";
45
45
  import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.js";
46
46
  import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.js";
47
47
  import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.js";
@@ -57,8 +57,8 @@ import { a as PdfInternalLinkItem, c as PdfLineItem, d as PdfPathInit, f as PdfP
57
57
  import { PageInit, PdfPage } from "./edit/pdf/page.js";
58
58
  import { CreatePdfOptions, PdfEditor, createPdf, openPdf } from "./edit/pdf/editor.js";
59
59
  import { BuildPptxPackageOptions, buildPptxPackage, embeddedPresentationSerialiser } from "./edit/pptx/content.js";
60
- import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-BY5P8kDn.js";
61
- import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-C3VWWdjr.js";
60
+ import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-DwZouh8R.js";
61
+ import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-D2CgT0Gf.js";
62
62
  import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.js";
63
63
  import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.js";
64
64
  import { CreateEmptyPptxPackageOptions } from "./edit/pptx/scaffold.js";
@@ -198,6 +198,7 @@ function decodeImageDimensions(format, bytes) {
198
198
  };
199
199
  }
200
200
  function registerImage(block, images) {
201
+ if (block.format === "svg" || block.format === "gif") throw new Error(`registerImage: an image block in ${block.format} format cannot be laid out to PDF -- pdf-codec's own LayoutImageAsset registry (and its writer, byte-codec's image encoders) supports png and jpeg only`);
201
202
  const bytes = (0, ooxml_js.base64ToBytes)(block.base64);
202
203
  const imageId = `img${(0, byte_codec.crc32)(bytes).toString(16)}`;
203
204
  if (!(imageId in images)) {
@@ -197,6 +197,7 @@ function decodeImageDimensions(format, bytes) {
197
197
  };
198
198
  }
199
199
  function registerImage(block, images) {
200
+ if (block.format === "svg" || block.format === "gif") throw new Error(`registerImage: an image block in ${block.format} format cannot be laid out to PDF -- pdf-codec's own LayoutImageAsset registry (and its writer, byte-codec's image encoders) supports png and jpeg only`);
200
201
  const bytes = base64ToBytes(block.base64);
201
202
  const imageId = `img${crc32(bytes).toString(16)}`;
202
203
  if (!(imageId in images)) {
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D_fDin5K.js";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D4f705GG.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/list.d.ts
4
4
  declare class OdtListItem {
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-BBmkECjw.cjs";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CRaLSzWz.cjs";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/list.d.ts
4
4
  declare class OdtListItem {
@@ -3,6 +3,6 @@ import { Package } from "odf.js";
3
3
  interface AddedOdfMedia {
4
4
  readonly partPath: string;
5
5
  }
6
- declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg"): AddedOdfMedia;
6
+ declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg" | "svg" | "gif"): AddedOdfMedia;
7
7
  //#endregion
8
8
  export { AddedOdfMedia, addImageMedia };
@@ -3,6 +3,6 @@ import { Package } from "odf.js";
3
3
  interface AddedOdfMedia {
4
4
  readonly partPath: string;
5
5
  }
6
- declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg"): AddedOdfMedia;
6
+ declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg" | "svg" | "gif"): AddedOdfMedia;
7
7
  //#endregion
8
8
  export { AddedOdfMedia, addImageMedia };
@@ -7,7 +7,8 @@ const CONTENT_TYPES_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/
7
7
  const DEFAULT_CONTENT_TYPES = {
8
8
  png: "image/png",
9
9
  jpeg: "image/jpeg",
10
- jpg: "image/jpeg"
10
+ jpg: "image/jpeg",
11
+ gif: "image/gif"
11
12
  };
12
13
  function defaultContentTypeForExtension(extension) {
13
14
  const contentType = DEFAULT_CONTENT_TYPES[extension.toLowerCase()];
@@ -6,7 +6,8 @@ const CONTENT_TYPES_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/
6
6
  const DEFAULT_CONTENT_TYPES = {
7
7
  png: "image/png",
8
8
  jpeg: "image/jpeg",
9
- jpg: "image/jpeg"
9
+ jpg: "image/jpeg",
10
+ gif: "image/gif"
10
11
  };
11
12
  function defaultContentTypeForExtension(extension) {
12
13
  const contentType = DEFAULT_CONTENT_TYPES[extension.toLowerCase()];
@@ -24,14 +24,13 @@ function nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension) {
24
24
  return max + 1;
25
25
  }
26
26
  function addImageMedia(pkg, fromPartPath, mediaDir, format, bytes) {
27
- const extension = format === "jpeg" ? "jpeg" : "png";
28
27
  const fileNamePrefix = "image";
29
- const partPath = `${mediaDir}/${fileNamePrefix}${nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension)}.${extension}`;
28
+ const partPath = `${mediaDir}/${fileNamePrefix}${nextMediaIndex(pkg, mediaDir, fileNamePrefix, format)}.${format}`;
30
29
  pkg.parts[partPath] = {
31
30
  kind: "binary",
32
31
  base64: (0, ooxml_js.bytesToBase64)(bytes)
33
32
  };
34
- require_opc_content_types.ensureDefaultContentType(pkg, extension, require_opc_content_types.defaultContentTypeForExtension(extension));
33
+ require_opc_content_types.ensureDefaultContentType(pkg, format, require_opc_content_types.defaultContentTypeForExtension(format));
35
34
  const target = require_opc_paths.buildRelativeTarget(fromPartPath, partPath);
36
35
  return {
37
36
  partPath,
@@ -5,6 +5,6 @@ interface AddedMedia {
5
5
  readonly relationshipId: string;
6
6
  }
7
7
  declare function addImageMedia(pkg: Package, fromPartPath: string, mediaDir: string // e.g. 'word/media' or 'ppt/media'
8
- , format: "png" | "jpeg", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
8
+ , format: "png" | "jpeg" | "gif", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
9
9
  //#endregion
10
10
  export { AddedMedia, addImageMedia };
@@ -5,6 +5,6 @@ interface AddedMedia {
5
5
  readonly relationshipId: string;
6
6
  }
7
7
  declare function addImageMedia(pkg: Package, fromPartPath: string, mediaDir: string // e.g. 'word/media' or 'ppt/media'
8
- , format: "png" | "jpeg", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
8
+ , format: "png" | "jpeg" | "gif", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
9
9
  //#endregion
10
10
  export { AddedMedia, addImageMedia };
package/dist/opc/media.js CHANGED
@@ -23,14 +23,13 @@ function nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension) {
23
23
  return max + 1;
24
24
  }
25
25
  function addImageMedia(pkg, fromPartPath, mediaDir, format, bytes) {
26
- const extension = format === "jpeg" ? "jpeg" : "png";
27
26
  const fileNamePrefix = "image";
28
- const partPath = `${mediaDir}/${fileNamePrefix}${nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension)}.${extension}`;
27
+ const partPath = `${mediaDir}/${fileNamePrefix}${nextMediaIndex(pkg, mediaDir, fileNamePrefix, format)}.${format}`;
29
28
  pkg.parts[partPath] = {
30
29
  kind: "binary",
31
30
  base64: bytesToBase64(bytes)
32
31
  };
33
- ensureDefaultContentType(pkg, extension, defaultContentTypeForExtension(extension));
32
+ ensureDefaultContentType(pkg, format, defaultContentTypeForExtension(format));
34
33
  const target = buildRelativeTarget(fromPartPath, partPath);
35
34
  return {
36
35
  partPath,
@@ -1,4 +1,4 @@
1
- import { t as ImageInit } from "./image-DQxA-zGN.cjs";
1
+ import { t as ImageInit } from "./image-BqMIKksf.cjs";
2
2
  import { n as RunInit, t as OdtRun } from "./run-mzBHuFWz.cjs";
3
3
  import { Alignment } from "document-schema.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -1,4 +1,4 @@
1
- import { t as ImageInit } from "./image-DQxA-zGN.js";
1
+ import { t as ImageInit } from "./image-BqMIKksf.js";
2
2
  import { n as RunInit, t as OdtRun } from "./run-mzBHuFWz.js";
3
3
  import { Alignment } from "document-schema.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -59,6 +59,6 @@ interface DrawingParagraphInit {
59
59
  }
60
60
  declare function buildDrawingParagraph(init: DrawingParagraphInit): XmlElement;
61
61
  declare function buildTextBoxShape(frame: Box, text: string, shapeId: number): XmlElement;
62
- declare function buildPictureShape(frame: Box, relationshipId: string, shapeId: number): XmlElement;
62
+ declare function buildPictureShape(frame: Box, relationshipId: string, shapeId: number, altText?: string): XmlElement;
63
63
  //#endregion
64
64
  export { buildDrawingParagraph as a, ROTATION_UNITS_PER_DEGREE as i, DrawingRunInit as n, buildPictureShape as o, PptxShape as r, buildTextBoxShape as s, DrawingParagraphInit as t };
@@ -1,5 +1,5 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D_fDin5K.js";
2
- import { t as OdtList } from "./list-B_Sy668f.js";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CRaLSzWz.cjs";
2
+ import { t as OdtList } from "./list-yc0dJrOX.cjs";
3
3
  import { Box } from "document-schema.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
5
5
  //#region src/edit/odp/shape.d.ts
@@ -25,7 +25,7 @@ declare class OdpShape {
25
25
  remove(): void;
26
26
  }
27
27
  declare function buildTextBoxFrame(pkg: Package, frame: Box, text: string): XmlElement;
28
- declare function buildImageFrame(partPath: string, frame: Box): XmlElement;
28
+ declare function buildImageFrame(partPath: string, frame: Box, altText?: string): XmlElement;
29
29
  declare function buildTableFrame(frame: Box, tableElement: XmlElement): XmlElement;
30
30
  //#endregion
31
31
  export { buildTextBoxFrame as i, buildImageFrame as n, buildTableFrame as r, OdpShape as t };
@@ -1,5 +1,5 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-BBmkECjw.cjs";
2
- import { t as OdtList } from "./list-BiTN6oop.cjs";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D4f705GG.js";
2
+ import { t as OdtList } from "./list-C32h8MNc.js";
3
3
  import { Box } from "document-schema.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
5
5
  //#region src/edit/odp/shape.d.ts
@@ -25,7 +25,7 @@ declare class OdpShape {
25
25
  remove(): void;
26
26
  }
27
27
  declare function buildTextBoxFrame(pkg: Package, frame: Box, text: string): XmlElement;
28
- declare function buildImageFrame(partPath: string, frame: Box): XmlElement;
28
+ declare function buildImageFrame(partPath: string, frame: Box, altText?: string): XmlElement;
29
29
  declare function buildTableFrame(frame: Box, tableElement: XmlElement): XmlElement;
30
30
  //#endregion
31
31
  export { buildTextBoxFrame as i, buildImageFrame as n, buildTableFrame as r, OdpShape as t };
@@ -59,6 +59,6 @@ interface DrawingParagraphInit {
59
59
  }
60
60
  declare function buildDrawingParagraph(init: DrawingParagraphInit): XmlElement;
61
61
  declare function buildTextBoxShape(frame: Box, text: string, shapeId: number): XmlElement;
62
- declare function buildPictureShape(frame: Box, relationshipId: string, shapeId: number): XmlElement;
62
+ declare function buildPictureShape(frame: Box, relationshipId: string, shapeId: number, altText?: string): XmlElement;
63
63
  //#endregion
64
64
  export { buildDrawingParagraph as a, ROTATION_UNITS_PER_DEGREE as i, DrawingRunInit as n, buildPictureShape as o, PptxShape as r, buildTextBoxShape as s, DrawingParagraphInit as t };
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-BBmkECjw.cjs";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CRaLSzWz.cjs";
2
2
  import { Color, ContentCellBorders } from "document-schema.js";
3
3
  import { Package, XmlElement, XmlNode } from "odf.js";
4
4
  //#region src/edit/odt/table.d.ts
@@ -1,4 +1,4 @@
1
- import { t as DrawingParagraphInit } from "./shape-Ca-xsrde.cjs";
1
+ import { t as DrawingParagraphInit } from "./shape-C2ef6uwC.cjs";
2
2
  import { Box, Color, ContentCellBorders } from "document-schema.js";
3
3
  import { XmlElement } from "ooxml.js";
4
4
  //#region src/edit/pptx/table.d.ts
@@ -1,4 +1,4 @@
1
- import { t as DrawingParagraphInit } from "./shape-BY5P8kDn.js";
1
+ import { t as DrawingParagraphInit } from "./shape-DwZouh8R.js";
2
2
  import { XmlElement } from "ooxml.js";
3
3
  import { Box, Color, ContentCellBorders } from "document-schema.js";
4
4
  //#region src/edit/pptx/table.d.ts
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D_fDin5K.js";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-D4f705GG.js";
2
2
  import { Color, ContentCellBorders } from "document-schema.js";
3
3
  import { Package, XmlElement, XmlNode } from "odf.js";
4
4
  //#region src/edit/odt/table.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "6.5.0",
3
+ "version": "6.5.2",
4
4
  "description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -77,21 +77,21 @@
77
77
  ],
78
78
  "license": "MIT",
79
79
  "dependencies": {
80
- "archive-codec": "^1.4.0",
80
+ "archive-codec": "^1.4.1",
81
81
  "byte-codec": "^1.2.0",
82
- "doc-codec": "^1.1.0",
83
- "document-schema.js": "^5.5.1",
82
+ "doc-codec": "^1.1.1",
83
+ "document-schema.js": "^5.6.0",
84
84
  "fflate": "^0.8.3",
85
- "markdown-codec": "^6.1.5",
86
- "odf.js": "^6.4.0",
87
- "ooxml.js": "^6.3.4",
88
- "pdf-codec": "^3.6.3",
89
- "ppt-codec": "^1.1.0",
90
- "rtf-codec": "^1.1.1",
85
+ "markdown-codec": "^6.1.6",
86
+ "odf.js": "^6.4.1",
87
+ "ooxml.js": "^6.3.6",
88
+ "pdf-codec": "^3.6.4",
89
+ "ppt-codec": "^1.1.1",
90
+ "rtf-codec": "^1.1.2",
91
91
  "temml": "0.13.4",
92
- "xls-codec": "^2.0.0",
92
+ "xls-codec": "^2.0.1",
93
93
  "zod": "^4.4.3",
94
- "wpd-codec": "^1.1.1"
94
+ "wpd-codec": "^1.1.2"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@arethetypeswrong/cli": "^0.18.5",