documents.js 1.98.2 → 1.99.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.
@@ -135,6 +135,14 @@ const TRANSFORMS = {
135
135
  "presentation->wordprocessing": (doc) => {
136
136
  if (doc.kind !== "presentation") throw new Error("presentationToWordprocessing: expected a presentation ContentDocument");
137
137
  return require_convert_variant_bridges.presentationToWordprocessing(doc);
138
+ },
139
+ "drawing->presentation": (doc) => {
140
+ if (doc.kind !== "drawing") throw new Error("drawingToPresentation: expected a drawing ContentDocument");
141
+ return require_convert_variant_bridges.drawingToPresentation(doc);
142
+ },
143
+ "presentation->drawing": (doc) => {
144
+ if (doc.kind !== "presentation") throw new Error("presentationToDrawing: expected a presentation ContentDocument");
145
+ return require_convert_variant_bridges.presentationToDrawing(doc);
138
146
  }
139
147
  };
140
148
  const LAYOUT_ENGINES = {
@@ -21,7 +21,7 @@ import { throwIfAborted } from "../ports/abort.js";
21
21
  import { convertSpreadsheetToLayout } from "../layout/sheets.js";
22
22
  import { convertDrawingToLayout } from "../layout/drawing.js";
23
23
  import { reconstructDrawing, reconstructPresentation, reconstructSpreadsheet, reconstructWordprocessing } from "../layout/reconstruct.js";
24
- import { presentationToWordprocessing, wordprocessingToPresentation } from "./variant-bridges.js";
24
+ import { drawingToPresentation, presentationToDrawing, presentationToWordprocessing, wordprocessingToPresentation } from "./variant-bridges.js";
25
25
  import { UnsupportedConversionError } from "./capability.js";
26
26
  import { buildXlsxPackage, decodePackage, encodePackage, readXlsxContent } from "ooxml.js";
27
27
  import { DOCUMENT_PACKAGE_FORMAT_VERSION } from "document-schema.js";
@@ -134,6 +134,14 @@ const TRANSFORMS = {
134
134
  "presentation->wordprocessing": (doc) => {
135
135
  if (doc.kind !== "presentation") throw new Error("presentationToWordprocessing: expected a presentation ContentDocument");
136
136
  return presentationToWordprocessing(doc);
137
+ },
138
+ "drawing->presentation": (doc) => {
139
+ if (doc.kind !== "drawing") throw new Error("drawingToPresentation: expected a drawing ContentDocument");
140
+ return drawingToPresentation(doc);
141
+ },
142
+ "presentation->drawing": (doc) => {
143
+ if (doc.kind !== "presentation") throw new Error("presentationToDrawing: expected a presentation ContentDocument");
144
+ return presentationToDrawing(doc);
137
145
  }
138
146
  };
139
147
  const LAYOUT_ENGINES = {
@@ -69,6 +69,34 @@ function presentationToWordprocessing(doc) {
69
69
  sections: [section]
70
70
  };
71
71
  }
72
+ function drawingToPresentation(doc) {
73
+ const slides = doc.pages.map((page) => ({
74
+ size: page.size,
75
+ shapes: page.shapes,
76
+ notes: ""
77
+ }));
78
+ return {
79
+ kind: "presentation",
80
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
81
+ metadata: doc.metadata,
82
+ slides
83
+ };
84
+ }
85
+ function presentationToDrawing(doc) {
86
+ const pages = doc.slides.map((slide) => ({
87
+ size: slide.size,
88
+ shapes: slide.shapes,
89
+ vectors: []
90
+ }));
91
+ return {
92
+ kind: "drawing",
93
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
94
+ metadata: doc.metadata,
95
+ pages
96
+ };
97
+ }
72
98
  //#endregion
99
+ exports.drawingToPresentation = drawingToPresentation;
100
+ exports.presentationToDrawing = presentationToDrawing;
73
101
  exports.presentationToWordprocessing = presentationToWordprocessing;
74
102
  exports.wordprocessingToPresentation = wordprocessingToPresentation;
@@ -6,7 +6,12 @@ type WordprocessingContentDocument = Extract<ContentDocument, {
6
6
  type PresentationContentDocument = Extract<ContentDocument, {
7
7
  kind: 'presentation';
8
8
  }>;
9
+ type DrawingContentDocument = Extract<ContentDocument, {
10
+ kind: 'drawing';
11
+ }>;
9
12
  declare function wordprocessingToPresentation(doc: WordprocessingContentDocument): PresentationContentDocument;
10
13
  declare function presentationToWordprocessing(doc: PresentationContentDocument): WordprocessingContentDocument;
14
+ declare function drawingToPresentation(doc: DrawingContentDocument): PresentationContentDocument;
15
+ declare function presentationToDrawing(doc: PresentationContentDocument): DrawingContentDocument;
11
16
  //#endregion
12
- export { presentationToWordprocessing, wordprocessingToPresentation };
17
+ export { drawingToPresentation, presentationToDrawing, presentationToWordprocessing, wordprocessingToPresentation };
@@ -6,7 +6,12 @@ type WordprocessingContentDocument = Extract<ContentDocument, {
6
6
  type PresentationContentDocument = Extract<ContentDocument, {
7
7
  kind: 'presentation';
8
8
  }>;
9
+ type DrawingContentDocument = Extract<ContentDocument, {
10
+ kind: 'drawing';
11
+ }>;
9
12
  declare function wordprocessingToPresentation(doc: WordprocessingContentDocument): PresentationContentDocument;
10
13
  declare function presentationToWordprocessing(doc: PresentationContentDocument): WordprocessingContentDocument;
14
+ declare function drawingToPresentation(doc: DrawingContentDocument): PresentationContentDocument;
15
+ declare function presentationToDrawing(doc: PresentationContentDocument): DrawingContentDocument;
11
16
  //#endregion
12
- export { presentationToWordprocessing, wordprocessingToPresentation };
17
+ export { drawingToPresentation, presentationToDrawing, presentationToWordprocessing, wordprocessingToPresentation };
@@ -68,5 +68,31 @@ function presentationToWordprocessing(doc) {
68
68
  sections: [section]
69
69
  };
70
70
  }
71
+ function drawingToPresentation(doc) {
72
+ const slides = doc.pages.map((page) => ({
73
+ size: page.size,
74
+ shapes: page.shapes,
75
+ notes: ""
76
+ }));
77
+ return {
78
+ kind: "presentation",
79
+ formatVersion: CONTENT_FORMAT_VERSION,
80
+ metadata: doc.metadata,
81
+ slides
82
+ };
83
+ }
84
+ function presentationToDrawing(doc) {
85
+ const pages = doc.slides.map((slide) => ({
86
+ size: slide.size,
87
+ shapes: slide.shapes,
88
+ vectors: []
89
+ }));
90
+ return {
91
+ kind: "drawing",
92
+ formatVersion: CONTENT_FORMAT_VERSION,
93
+ metadata: doc.metadata,
94
+ pages
95
+ };
96
+ }
71
97
  //#endregion
72
- export { presentationToWordprocessing, wordprocessingToPresentation };
98
+ export { drawingToPresentation, presentationToDrawing, presentationToWordprocessing, wordprocessingToPresentation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "documents.js",
3
- "version": "1.98.2",
3
+ "version": "1.99.1",
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": {
@@ -94,7 +94,7 @@
94
94
  },
95
95
  "devDependencies": {
96
96
  "@arethetypeswrong/cli": "^0.18.5",
97
- "@cloudflare/vitest-pool-workers": "^0.20.2",
97
+ "@cloudflare/vitest-pool-workers": "^0.20.3",
98
98
  "@commitlint/cli": "^21.2.1",
99
99
  "@commitlint/config-conventional": "^21.2.0",
100
100
  "@eslint/js": "^10.0.1",