document-model.js 3.2.0 → 4.0.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 (43) hide show
  1. package/README.md +82 -31
  2. package/dist/codec.d.cts +2 -7
  3. package/dist/codec.d.ts +2 -7
  4. package/dist/content-BN0PWqpt.d.cts +2393 -0
  5. package/dist/content-CiZf6Fqn.d.ts +2393 -0
  6. package/dist/content-json-schema-defs.cjs +1006 -1
  7. package/dist/content-json-schema-defs.js +1006 -1
  8. package/dist/content.cjs +2 -8
  9. package/dist/content.d.cts +2 -2354
  10. package/dist/content.d.ts +2 -2354
  11. package/dist/content.js +2 -8
  12. package/dist/definitions.cjs +109 -0
  13. package/dist/definitions.d.cts +115 -0
  14. package/dist/definitions.d.ts +115 -0
  15. package/dist/definitions.js +99 -0
  16. package/dist/index.cjs +42 -18
  17. package/dist/index.d.cts +7 -6
  18. package/dist/index.d.ts +7 -6
  19. package/dist/index.js +6 -5
  20. package/dist/package-node-DDPSNOvy.d.cts +441 -0
  21. package/dist/package-node-QVFHQcm8.d.ts +441 -0
  22. package/dist/package-node.cjs +120 -0
  23. package/dist/package-node.d.cts +2 -0
  24. package/dist/package-node.d.ts +2 -0
  25. package/dist/package-node.js +93 -0
  26. package/dist/package.cjs +37 -7
  27. package/dist/package.d.cts +452 -755
  28. package/dist/package.d.ts +452 -755
  29. package/dist/package.js +39 -8
  30. package/dist/schema-io.cjs +55 -25
  31. package/dist/schema-io.d.cts +13 -11
  32. package/dist/schema-io.d.ts +13 -11
  33. package/dist/schema-io.js +54 -25
  34. package/dist/style.d.cts +2 -2
  35. package/dist/style.d.ts +2 -2
  36. package/package.json +2 -2
  37. package/schemas/content-document.schema.json +1476 -69
  38. package/schemas/document-package.schema.json +3056 -30
  39. package/dist/layout.cjs +0 -150
  40. package/dist/layout.d.cts +0 -684
  41. package/dist/layout.d.ts +0 -684
  42. package/dist/layout.js +0 -136
  43. package/schemas/layout-document.schema.json +0 -760
package/dist/content.js CHANGED
@@ -20,7 +20,7 @@ const ContentRunSchema = z.object({
20
20
  frames: z.array(LayoutFrameSchema).optional()
21
21
  });
22
22
  const ContentListMembershipSchema = z.object({
23
- numId: z.string(),
23
+ numId: z.string().optional(),
24
24
  level: z.number().int().nonnegative()
25
25
  });
26
26
  const ContentParagraphSchema = z.object({
@@ -358,44 +358,38 @@ const ContentFormulaSchema = z.object({
358
358
  content: MathExpressionSchema.optional(),
359
359
  provenance: MathProvenanceSchema.optional()
360
360
  });
361
- const CONTENT_FORMAT_VERSION = 3;
362
361
  const contentDocumentSharedFields = { symbolTable: SymbolTableSchema.optional() };
363
362
  const ContentDocumentSchema = z.discriminatedUnion("kind", [
364
363
  z.object({
365
364
  kind: z.literal("wordprocessing"),
366
- formatVersion: z.literal(3),
367
365
  metadata: LayoutMetadataSchema,
368
366
  ...contentDocumentSharedFields,
369
367
  sections: z.array(ContentSectionSchema)
370
368
  }),
371
369
  z.object({
372
370
  kind: z.literal("presentation"),
373
- formatVersion: z.literal(3),
374
371
  metadata: LayoutMetadataSchema,
375
372
  ...contentDocumentSharedFields,
376
373
  slides: z.array(ContentSlideSchema)
377
374
  }),
378
375
  z.object({
379
376
  kind: z.literal("spreadsheet"),
380
- formatVersion: z.literal(3),
381
377
  metadata: LayoutMetadataSchema,
382
378
  ...contentDocumentSharedFields,
383
379
  sheets: z.array(ContentSheetSchema)
384
380
  }),
385
381
  z.object({
386
382
  kind: z.literal("drawing"),
387
- formatVersion: z.literal(3),
388
383
  metadata: LayoutMetadataSchema,
389
384
  ...contentDocumentSharedFields,
390
385
  pages: z.array(ContentDrawPageSchema)
391
386
  }),
392
387
  z.object({
393
388
  kind: z.literal("formula"),
394
- formatVersion: z.literal(3),
395
389
  metadata: LayoutMetadataSchema,
396
390
  ...contentDocumentSharedFields,
397
391
  formula: ContentFormulaSchema
398
392
  })
399
393
  ]);
400
394
  //#endregion
401
- export { CONTENT_FORMAT_VERSION, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFormulaSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DecimalStringSchema, clampHeadingLevel, isContentBlock };
395
+ export { ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFormulaSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DecimalStringSchema, clampHeadingLevel, contentDocumentSharedFields, isContentBlock };
@@ -0,0 +1,109 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_color = require("./color.cjs");
3
+ const require_style = require("./style.cjs");
4
+ const require_content = require("./content.cjs");
5
+ let zod = require("zod");
6
+ //#region src/definitions.ts
7
+ const StyleParagraphPropertiesSchema = zod.z.strictObject({
8
+ alignment: require_style.AlignmentSchema.optional(),
9
+ list: require_content.ContentListMembershipSchema.optional(),
10
+ spacingBeforePt: zod.z.number().optional(),
11
+ spacingAfterPt: zod.z.number().optional(),
12
+ lineSpacing: zod.z.number().positive().optional(),
13
+ indentLeftPt: zod.z.number().optional(),
14
+ indentFirstLinePt: zod.z.number().optional()
15
+ });
16
+ const StyleRunPropertiesSchema = zod.z.strictObject({
17
+ bold: zod.z.boolean().optional(),
18
+ italic: zod.z.boolean().optional(),
19
+ underline: zod.z.boolean().optional(),
20
+ strike: zod.z.boolean().optional(),
21
+ fontFamily: zod.z.string().optional(),
22
+ sizePt: zod.z.number().positive().optional(),
23
+ color: require_color.ColorSchema.optional()
24
+ });
25
+ const StyleEntrySchema = zod.z.strictObject({
26
+ paragraph: StyleParagraphPropertiesSchema.optional(),
27
+ run: StyleRunPropertiesSchema.optional()
28
+ });
29
+ const StylesTableSchema = zod.z.record(zod.z.string(), StyleEntrySchema);
30
+ const DefinitionEntrySchema = zod.z.looseObject({ kind: zod.z.string() });
31
+ const DefinitionsTableSchema = zod.z.record(zod.z.string(), DefinitionEntrySchema);
32
+ function overlayStyleEntries(outer, inner) {
33
+ const paragraph = overlayParagraphProperties(outer.paragraph, inner.paragraph);
34
+ const run = overlayRunProperties(outer.run, inner.run);
35
+ return {
36
+ ...paragraph !== void 0 ? { paragraph } : {},
37
+ ...run !== void 0 ? { run } : {}
38
+ };
39
+ }
40
+ function overlayParagraphProperties(outer, inner) {
41
+ if (outer === void 0) return inner;
42
+ if (inner === void 0) return outer;
43
+ const merged = { ...outer };
44
+ if (inner.alignment !== void 0) merged.alignment = inner.alignment;
45
+ if (inner.list !== void 0) merged.list = inner.list;
46
+ if (inner.spacingBeforePt !== void 0) merged.spacingBeforePt = inner.spacingBeforePt;
47
+ if (inner.spacingAfterPt !== void 0) merged.spacingAfterPt = inner.spacingAfterPt;
48
+ if (inner.lineSpacing !== void 0) merged.lineSpacing = inner.lineSpacing;
49
+ if (inner.indentLeftPt !== void 0) merged.indentLeftPt = inner.indentLeftPt;
50
+ if (inner.indentFirstLinePt !== void 0) merged.indentFirstLinePt = inner.indentFirstLinePt;
51
+ return merged;
52
+ }
53
+ function overlayRunProperties(outer, inner) {
54
+ if (outer === void 0) return inner;
55
+ if (inner === void 0) return outer;
56
+ const merged = { ...outer };
57
+ if (inner.bold !== void 0) merged.bold = inner.bold;
58
+ if (inner.italic !== void 0) merged.italic = inner.italic;
59
+ if (inner.underline !== void 0) merged.underline = inner.underline;
60
+ if (inner.strike !== void 0) merged.strike = inner.strike;
61
+ if (inner.fontFamily !== void 0) merged.fontFamily = inner.fontFamily;
62
+ if (inner.sizePt !== void 0) merged.sizePt = inner.sizePt;
63
+ if (inner.color !== void 0) merged.color = inner.color;
64
+ return merged;
65
+ }
66
+ function resolveStyleChain(styles, refs) {
67
+ let resolved = {};
68
+ for (const ref of refs) {
69
+ const entry = styles[ref];
70
+ if (entry === void 0) throw new Error(`resolveStyleChain: style ref "${ref}" names no entry in the styles table`);
71
+ resolved = overlayStyleEntries(resolved, entry);
72
+ }
73
+ return resolved;
74
+ }
75
+ function applyParagraphStyleProperties(properties, paragraph) {
76
+ if (properties === void 0) return paragraph;
77
+ const effective = { ...paragraph };
78
+ if (effective.alignment === void 0 && properties.alignment !== void 0) effective.alignment = properties.alignment;
79
+ if (effective.list === void 0 && properties.list !== void 0) effective.list = properties.list;
80
+ if (effective.spacingBeforePt === void 0 && properties.spacingBeforePt !== void 0) effective.spacingBeforePt = properties.spacingBeforePt;
81
+ if (effective.spacingAfterPt === void 0 && properties.spacingAfterPt !== void 0) effective.spacingAfterPt = properties.spacingAfterPt;
82
+ if (effective.lineSpacing === void 0 && properties.lineSpacing !== void 0) effective.lineSpacing = properties.lineSpacing;
83
+ if (effective.indentLeftPt === void 0 && properties.indentLeftPt !== void 0) effective.indentLeftPt = properties.indentLeftPt;
84
+ if (effective.indentFirstLinePt === void 0 && properties.indentFirstLinePt !== void 0) effective.indentFirstLinePt = properties.indentFirstLinePt;
85
+ return effective;
86
+ }
87
+ function applyRunStyleProperties(properties, run) {
88
+ if (properties === void 0) return run;
89
+ const effective = { ...run };
90
+ if (effective.bold === void 0 && properties.bold !== void 0) effective.bold = properties.bold;
91
+ if (effective.italic === void 0 && properties.italic !== void 0) effective.italic = properties.italic;
92
+ if (effective.underline === void 0 && properties.underline !== void 0) effective.underline = properties.underline;
93
+ if (effective.strike === void 0 && properties.strike !== void 0) effective.strike = properties.strike;
94
+ if (effective.fontFamily === void 0 && properties.fontFamily !== void 0) effective.fontFamily = properties.fontFamily;
95
+ if (effective.sizePt === void 0 && properties.sizePt !== void 0) effective.sizePt = properties.sizePt;
96
+ if (effective.color === void 0 && properties.color !== void 0) effective.color = properties.color;
97
+ return effective;
98
+ }
99
+ //#endregion
100
+ exports.DefinitionEntrySchema = DefinitionEntrySchema;
101
+ exports.DefinitionsTableSchema = DefinitionsTableSchema;
102
+ exports.StyleEntrySchema = StyleEntrySchema;
103
+ exports.StyleParagraphPropertiesSchema = StyleParagraphPropertiesSchema;
104
+ exports.StyleRunPropertiesSchema = StyleRunPropertiesSchema;
105
+ exports.StylesTableSchema = StylesTableSchema;
106
+ exports.applyParagraphStyleProperties = applyParagraphStyleProperties;
107
+ exports.applyRunStyleProperties = applyRunStyleProperties;
108
+ exports.overlayStyleEntries = overlayStyleEntries;
109
+ exports.resolveStyleChain = resolveStyleChain;
@@ -0,0 +1,115 @@
1
+ import { E as ContentParagraph, M as ContentRun } from "./content-BN0PWqpt.cjs";
2
+ import { z } from "zod";
3
+ //#region src/definitions.d.ts
4
+ declare const StyleParagraphPropertiesSchema: z.ZodObject<{
5
+ alignment: z.ZodOptional<z.ZodEnum<{
6
+ left: "left";
7
+ center: "center";
8
+ right: "right";
9
+ justify: "justify";
10
+ }>>;
11
+ list: z.ZodOptional<z.ZodObject<{
12
+ numId: z.ZodOptional<z.ZodString>;
13
+ level: z.ZodNumber;
14
+ }, z.core.$strip>>;
15
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
16
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
17
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
18
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
19
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strict>;
21
+ type StyleParagraphProperties = z.infer<typeof StyleParagraphPropertiesSchema>;
22
+ declare const StyleRunPropertiesSchema: z.ZodObject<{
23
+ bold: z.ZodOptional<z.ZodBoolean>;
24
+ italic: z.ZodOptional<z.ZodBoolean>;
25
+ underline: z.ZodOptional<z.ZodBoolean>;
26
+ strike: z.ZodOptional<z.ZodBoolean>;
27
+ fontFamily: z.ZodOptional<z.ZodString>;
28
+ sizePt: z.ZodOptional<z.ZodNumber>;
29
+ color: z.ZodOptional<z.ZodObject<{
30
+ r: z.ZodNumber;
31
+ g: z.ZodNumber;
32
+ b: z.ZodNumber;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strict>;
35
+ type StyleRunProperties = z.infer<typeof StyleRunPropertiesSchema>;
36
+ declare const StyleEntrySchema: z.ZodObject<{
37
+ paragraph: z.ZodOptional<z.ZodObject<{
38
+ alignment: z.ZodOptional<z.ZodEnum<{
39
+ left: "left";
40
+ center: "center";
41
+ right: "right";
42
+ justify: "justify";
43
+ }>>;
44
+ list: z.ZodOptional<z.ZodObject<{
45
+ numId: z.ZodOptional<z.ZodString>;
46
+ level: z.ZodNumber;
47
+ }, z.core.$strip>>;
48
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
49
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
50
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
51
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
52
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>>;
54
+ run: z.ZodOptional<z.ZodObject<{
55
+ bold: z.ZodOptional<z.ZodBoolean>;
56
+ italic: z.ZodOptional<z.ZodBoolean>;
57
+ underline: z.ZodOptional<z.ZodBoolean>;
58
+ strike: z.ZodOptional<z.ZodBoolean>;
59
+ fontFamily: z.ZodOptional<z.ZodString>;
60
+ sizePt: z.ZodOptional<z.ZodNumber>;
61
+ color: z.ZodOptional<z.ZodObject<{
62
+ r: z.ZodNumber;
63
+ g: z.ZodNumber;
64
+ b: z.ZodNumber;
65
+ }, z.core.$strip>>;
66
+ }, z.core.$strict>>;
67
+ }, z.core.$strict>;
68
+ type StyleEntry = z.infer<typeof StyleEntrySchema>;
69
+ declare const StylesTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
70
+ paragraph: z.ZodOptional<z.ZodObject<{
71
+ alignment: z.ZodOptional<z.ZodEnum<{
72
+ left: "left";
73
+ center: "center";
74
+ right: "right";
75
+ justify: "justify";
76
+ }>>;
77
+ list: z.ZodOptional<z.ZodObject<{
78
+ numId: z.ZodOptional<z.ZodString>;
79
+ level: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
82
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
83
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
84
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
85
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strict>>;
87
+ run: z.ZodOptional<z.ZodObject<{
88
+ bold: z.ZodOptional<z.ZodBoolean>;
89
+ italic: z.ZodOptional<z.ZodBoolean>;
90
+ underline: z.ZodOptional<z.ZodBoolean>;
91
+ strike: z.ZodOptional<z.ZodBoolean>;
92
+ fontFamily: z.ZodOptional<z.ZodString>;
93
+ sizePt: z.ZodOptional<z.ZodNumber>;
94
+ color: z.ZodOptional<z.ZodObject<{
95
+ r: z.ZodNumber;
96
+ g: z.ZodNumber;
97
+ b: z.ZodNumber;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>>;
101
+ type StylesTable = z.infer<typeof StylesTableSchema>;
102
+ declare const DefinitionEntrySchema: z.ZodObject<{
103
+ kind: z.ZodString;
104
+ }, z.core.$loose>;
105
+ type DefinitionEntry = z.infer<typeof DefinitionEntrySchema>;
106
+ declare const DefinitionsTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
107
+ kind: z.ZodString;
108
+ }, z.core.$loose>>;
109
+ type DefinitionsTable = z.infer<typeof DefinitionsTableSchema>;
110
+ declare function overlayStyleEntries(outer: StyleEntry, inner: StyleEntry): StyleEntry;
111
+ declare function resolveStyleChain(styles: StylesTable, refs: readonly string[]): StyleEntry;
112
+ declare function applyParagraphStyleProperties(properties: StyleParagraphProperties | undefined, paragraph: ContentParagraph): ContentParagraph;
113
+ declare function applyRunStyleProperties(properties: StyleRunProperties | undefined, run: ContentRun): ContentRun;
114
+ //#endregion
115
+ export { DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StylesTable, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
@@ -0,0 +1,115 @@
1
+ import { E as ContentParagraph, M as ContentRun } from "./content-CiZf6Fqn.js";
2
+ import { z } from "zod";
3
+ //#region src/definitions.d.ts
4
+ declare const StyleParagraphPropertiesSchema: z.ZodObject<{
5
+ alignment: z.ZodOptional<z.ZodEnum<{
6
+ left: "left";
7
+ center: "center";
8
+ right: "right";
9
+ justify: "justify";
10
+ }>>;
11
+ list: z.ZodOptional<z.ZodObject<{
12
+ numId: z.ZodOptional<z.ZodString>;
13
+ level: z.ZodNumber;
14
+ }, z.core.$strip>>;
15
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
16
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
17
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
18
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
19
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strict>;
21
+ type StyleParagraphProperties = z.infer<typeof StyleParagraphPropertiesSchema>;
22
+ declare const StyleRunPropertiesSchema: z.ZodObject<{
23
+ bold: z.ZodOptional<z.ZodBoolean>;
24
+ italic: z.ZodOptional<z.ZodBoolean>;
25
+ underline: z.ZodOptional<z.ZodBoolean>;
26
+ strike: z.ZodOptional<z.ZodBoolean>;
27
+ fontFamily: z.ZodOptional<z.ZodString>;
28
+ sizePt: z.ZodOptional<z.ZodNumber>;
29
+ color: z.ZodOptional<z.ZodObject<{
30
+ r: z.ZodNumber;
31
+ g: z.ZodNumber;
32
+ b: z.ZodNumber;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strict>;
35
+ type StyleRunProperties = z.infer<typeof StyleRunPropertiesSchema>;
36
+ declare const StyleEntrySchema: z.ZodObject<{
37
+ paragraph: z.ZodOptional<z.ZodObject<{
38
+ alignment: z.ZodOptional<z.ZodEnum<{
39
+ left: "left";
40
+ center: "center";
41
+ right: "right";
42
+ justify: "justify";
43
+ }>>;
44
+ list: z.ZodOptional<z.ZodObject<{
45
+ numId: z.ZodOptional<z.ZodString>;
46
+ level: z.ZodNumber;
47
+ }, z.core.$strip>>;
48
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
49
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
50
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
51
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
52
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>>;
54
+ run: z.ZodOptional<z.ZodObject<{
55
+ bold: z.ZodOptional<z.ZodBoolean>;
56
+ italic: z.ZodOptional<z.ZodBoolean>;
57
+ underline: z.ZodOptional<z.ZodBoolean>;
58
+ strike: z.ZodOptional<z.ZodBoolean>;
59
+ fontFamily: z.ZodOptional<z.ZodString>;
60
+ sizePt: z.ZodOptional<z.ZodNumber>;
61
+ color: z.ZodOptional<z.ZodObject<{
62
+ r: z.ZodNumber;
63
+ g: z.ZodNumber;
64
+ b: z.ZodNumber;
65
+ }, z.core.$strip>>;
66
+ }, z.core.$strict>>;
67
+ }, z.core.$strict>;
68
+ type StyleEntry = z.infer<typeof StyleEntrySchema>;
69
+ declare const StylesTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
70
+ paragraph: z.ZodOptional<z.ZodObject<{
71
+ alignment: z.ZodOptional<z.ZodEnum<{
72
+ left: "left";
73
+ center: "center";
74
+ right: "right";
75
+ justify: "justify";
76
+ }>>;
77
+ list: z.ZodOptional<z.ZodObject<{
78
+ numId: z.ZodOptional<z.ZodString>;
79
+ level: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
82
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
83
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
84
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
85
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strict>>;
87
+ run: z.ZodOptional<z.ZodObject<{
88
+ bold: z.ZodOptional<z.ZodBoolean>;
89
+ italic: z.ZodOptional<z.ZodBoolean>;
90
+ underline: z.ZodOptional<z.ZodBoolean>;
91
+ strike: z.ZodOptional<z.ZodBoolean>;
92
+ fontFamily: z.ZodOptional<z.ZodString>;
93
+ sizePt: z.ZodOptional<z.ZodNumber>;
94
+ color: z.ZodOptional<z.ZodObject<{
95
+ r: z.ZodNumber;
96
+ g: z.ZodNumber;
97
+ b: z.ZodNumber;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>>;
101
+ type StylesTable = z.infer<typeof StylesTableSchema>;
102
+ declare const DefinitionEntrySchema: z.ZodObject<{
103
+ kind: z.ZodString;
104
+ }, z.core.$loose>;
105
+ type DefinitionEntry = z.infer<typeof DefinitionEntrySchema>;
106
+ declare const DefinitionsTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
107
+ kind: z.ZodString;
108
+ }, z.core.$loose>>;
109
+ type DefinitionsTable = z.infer<typeof DefinitionsTableSchema>;
110
+ declare function overlayStyleEntries(outer: StyleEntry, inner: StyleEntry): StyleEntry;
111
+ declare function resolveStyleChain(styles: StylesTable, refs: readonly string[]): StyleEntry;
112
+ declare function applyParagraphStyleProperties(properties: StyleParagraphProperties | undefined, paragraph: ContentParagraph): ContentParagraph;
113
+ declare function applyRunStyleProperties(properties: StyleRunProperties | undefined, run: ContentRun): ContentRun;
114
+ //#endregion
115
+ export { DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StylesTable, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
@@ -0,0 +1,99 @@
1
+ import { ColorSchema } from "./color.js";
2
+ import { AlignmentSchema } from "./style.js";
3
+ import { ContentListMembershipSchema } from "./content.js";
4
+ import { z } from "zod";
5
+ //#region src/definitions.ts
6
+ const StyleParagraphPropertiesSchema = z.strictObject({
7
+ alignment: AlignmentSchema.optional(),
8
+ list: ContentListMembershipSchema.optional(),
9
+ spacingBeforePt: z.number().optional(),
10
+ spacingAfterPt: z.number().optional(),
11
+ lineSpacing: z.number().positive().optional(),
12
+ indentLeftPt: z.number().optional(),
13
+ indentFirstLinePt: z.number().optional()
14
+ });
15
+ const StyleRunPropertiesSchema = z.strictObject({
16
+ bold: z.boolean().optional(),
17
+ italic: z.boolean().optional(),
18
+ underline: z.boolean().optional(),
19
+ strike: z.boolean().optional(),
20
+ fontFamily: z.string().optional(),
21
+ sizePt: z.number().positive().optional(),
22
+ color: ColorSchema.optional()
23
+ });
24
+ const StyleEntrySchema = z.strictObject({
25
+ paragraph: StyleParagraphPropertiesSchema.optional(),
26
+ run: StyleRunPropertiesSchema.optional()
27
+ });
28
+ const StylesTableSchema = z.record(z.string(), StyleEntrySchema);
29
+ const DefinitionEntrySchema = z.looseObject({ kind: z.string() });
30
+ const DefinitionsTableSchema = z.record(z.string(), DefinitionEntrySchema);
31
+ function overlayStyleEntries(outer, inner) {
32
+ const paragraph = overlayParagraphProperties(outer.paragraph, inner.paragraph);
33
+ const run = overlayRunProperties(outer.run, inner.run);
34
+ return {
35
+ ...paragraph !== void 0 ? { paragraph } : {},
36
+ ...run !== void 0 ? { run } : {}
37
+ };
38
+ }
39
+ function overlayParagraphProperties(outer, inner) {
40
+ if (outer === void 0) return inner;
41
+ if (inner === void 0) return outer;
42
+ const merged = { ...outer };
43
+ if (inner.alignment !== void 0) merged.alignment = inner.alignment;
44
+ if (inner.list !== void 0) merged.list = inner.list;
45
+ if (inner.spacingBeforePt !== void 0) merged.spacingBeforePt = inner.spacingBeforePt;
46
+ if (inner.spacingAfterPt !== void 0) merged.spacingAfterPt = inner.spacingAfterPt;
47
+ if (inner.lineSpacing !== void 0) merged.lineSpacing = inner.lineSpacing;
48
+ if (inner.indentLeftPt !== void 0) merged.indentLeftPt = inner.indentLeftPt;
49
+ if (inner.indentFirstLinePt !== void 0) merged.indentFirstLinePt = inner.indentFirstLinePt;
50
+ return merged;
51
+ }
52
+ function overlayRunProperties(outer, inner) {
53
+ if (outer === void 0) return inner;
54
+ if (inner === void 0) return outer;
55
+ const merged = { ...outer };
56
+ if (inner.bold !== void 0) merged.bold = inner.bold;
57
+ if (inner.italic !== void 0) merged.italic = inner.italic;
58
+ if (inner.underline !== void 0) merged.underline = inner.underline;
59
+ if (inner.strike !== void 0) merged.strike = inner.strike;
60
+ if (inner.fontFamily !== void 0) merged.fontFamily = inner.fontFamily;
61
+ if (inner.sizePt !== void 0) merged.sizePt = inner.sizePt;
62
+ if (inner.color !== void 0) merged.color = inner.color;
63
+ return merged;
64
+ }
65
+ function resolveStyleChain(styles, refs) {
66
+ let resolved = {};
67
+ for (const ref of refs) {
68
+ const entry = styles[ref];
69
+ if (entry === void 0) throw new Error(`resolveStyleChain: style ref "${ref}" names no entry in the styles table`);
70
+ resolved = overlayStyleEntries(resolved, entry);
71
+ }
72
+ return resolved;
73
+ }
74
+ function applyParagraphStyleProperties(properties, paragraph) {
75
+ if (properties === void 0) return paragraph;
76
+ const effective = { ...paragraph };
77
+ if (effective.alignment === void 0 && properties.alignment !== void 0) effective.alignment = properties.alignment;
78
+ if (effective.list === void 0 && properties.list !== void 0) effective.list = properties.list;
79
+ if (effective.spacingBeforePt === void 0 && properties.spacingBeforePt !== void 0) effective.spacingBeforePt = properties.spacingBeforePt;
80
+ if (effective.spacingAfterPt === void 0 && properties.spacingAfterPt !== void 0) effective.spacingAfterPt = properties.spacingAfterPt;
81
+ if (effective.lineSpacing === void 0 && properties.lineSpacing !== void 0) effective.lineSpacing = properties.lineSpacing;
82
+ if (effective.indentLeftPt === void 0 && properties.indentLeftPt !== void 0) effective.indentLeftPt = properties.indentLeftPt;
83
+ if (effective.indentFirstLinePt === void 0 && properties.indentFirstLinePt !== void 0) effective.indentFirstLinePt = properties.indentFirstLinePt;
84
+ return effective;
85
+ }
86
+ function applyRunStyleProperties(properties, run) {
87
+ if (properties === void 0) return run;
88
+ const effective = { ...run };
89
+ if (effective.bold === void 0 && properties.bold !== void 0) effective.bold = properties.bold;
90
+ if (effective.italic === void 0 && properties.italic !== void 0) effective.italic = properties.italic;
91
+ if (effective.underline === void 0 && properties.underline !== void 0) effective.underline = properties.underline;
92
+ if (effective.strike === void 0 && properties.strike !== void 0) effective.strike = properties.strike;
93
+ if (effective.fontFamily === void 0 && properties.fontFamily !== void 0) effective.fontFamily = properties.fontFamily;
94
+ if (effective.sizePt === void 0 && properties.sizePt !== void 0) effective.sizePt = properties.sizePt;
95
+ if (effective.color === void 0 && properties.color !== void 0) effective.color = properties.color;
96
+ return effective;
97
+ }
98
+ //#endregion
99
+ export { DefinitionEntrySchema, DefinitionsTableSchema, StyleEntrySchema, StyleParagraphPropertiesSchema, StyleRunPropertiesSchema, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
package/dist/index.cjs CHANGED
@@ -8,7 +8,8 @@ const require_mathml = require("./mathml.cjs");
8
8
  const require_metadata = require("./metadata.cjs");
9
9
  const require_style = require("./style.cjs");
10
10
  const require_content = require("./content.cjs");
11
- const require_layout = require("./layout.cjs");
11
+ const require_definitions = require("./definitions.cjs");
12
+ const require_package_node = require("./package-node.cjs");
12
13
  const require_package = require("./package.cjs");
13
14
  const require_schema_io = require("./schema-io.cjs");
14
15
  const require_content_json_schema_defs = require("./content-json-schema-defs.cjs");
@@ -20,7 +21,6 @@ exports.BoxSchema = require_geometry.BoxSchema;
20
21
  exports.COLOR_BLACK = require_color.COLOR_BLACK;
21
22
  exports.CONTENT_DEFS = require_content_json_schema_defs.CONTENT_DEFS;
22
23
  exports.CONTENT_DOCUMENT_URI = require_content_json_schema_defs.CONTENT_DOCUMENT_URI;
23
- exports.CONTENT_FORMAT_VERSION = require_content.CONTENT_FORMAT_VERSION;
24
24
  exports.ColorSchema = require_color.ColorSchema;
25
25
  exports.ContentBlockSchema = require_content.ContentBlockSchema;
26
26
  exports.ContentBorderSchema = require_content.ContentBorderSchema;
@@ -58,29 +58,23 @@ exports.ContentTableRowSchema = require_content.ContentTableRowSchema;
58
58
  exports.ContentTableSchema = require_content.ContentTableSchema;
59
59
  exports.ContentVectorSchema = require_content.ContentVectorSchema;
60
60
  exports.DEFAULT_LAYOUT_FONT = require_style.DEFAULT_LAYOUT_FONT;
61
- exports.DOCUMENT_PACKAGE_FORMAT_VERSION = require_package.DOCUMENT_PACKAGE_FORMAT_VERSION;
62
61
  exports.DecimalStringSchema = require_content.DecimalStringSchema;
62
+ exports.DefinitionEntrySchema = require_definitions.DefinitionEntrySchema;
63
+ exports.DefinitionsTableSchema = require_definitions.DefinitionsTableSchema;
63
64
  exports.DimensionVectorSchema = require_math.DimensionVectorSchema;
64
65
  exports.DocumentPackageSchema = require_package.DocumentPackageSchema;
66
+ exports.DrawPageDescriptorSchema = require_package_node.DrawPageDescriptorSchema;
67
+ exports.DrawPageGroupSchema = require_package_node.DrawPageGroupSchema;
65
68
  exports.EMBEDDED_OBJECT_KINDS = require_content_json_schema_defs.EMBEDDED_OBJECT_KINDS;
66
69
  exports.ExactRationalSchema = require_math.ExactRationalSchema;
67
- exports.LAYOUT_FORMAT_VERSION = require_layout.LAYOUT_FORMAT_VERSION;
68
- exports.LayoutDocumentSchema = require_layout.LayoutDocumentSchema;
69
- exports.LayoutEllipseSchema = require_layout.LayoutEllipseSchema;
70
+ exports.HeadingGroupSchema = require_package_node.HeadingGroupSchema;
71
+ exports.HeadingParagraphSchema = require_package_node.HeadingParagraphSchema;
70
72
  exports.LayoutFontSchema = require_style.LayoutFontSchema;
71
73
  exports.LayoutFrameSchema = require_geometry.LayoutFrameSchema;
72
- exports.LayoutImageAssetSchema = require_layout.LayoutImageAssetSchema;
73
- exports.LayoutImageSchema = require_layout.LayoutImageSchema;
74
- exports.LayoutItemSchema = require_layout.LayoutItemSchema;
75
- exports.LayoutLineSchema = require_layout.LayoutLineSchema;
76
- exports.LayoutLinkSchema = require_layout.LayoutLinkSchema;
77
74
  exports.LayoutMetadataSchema = require_metadata.LayoutMetadataSchema;
78
- exports.LayoutPageSchema = require_layout.LayoutPageSchema;
79
- exports.LayoutPathSchema = require_layout.LayoutPathSchema;
80
- exports.LayoutPathSegmentSchema = require_layout.LayoutPathSegmentSchema;
81
- exports.LayoutRectSchema = require_layout.LayoutRectSchema;
82
- exports.LayoutSubpathSchema = require_layout.LayoutSubpathSchema;
83
- exports.LayoutTextSchema = require_layout.LayoutTextSchema;
75
+ exports.LayoutSchemaDemotedError = require_schema_io.LayoutSchemaDemotedError;
76
+ exports.ListGroupSchema = require_package_node.ListGroupSchema;
77
+ exports.ListParagraphSchema = require_package_node.ListParagraphSchema;
84
78
  exports.MAX_SAFE_INTEGER = require_content_json_schema_defs.MAX_SAFE_INTEGER;
85
79
  exports.MarginsSchema = require_geometry.MarginsSchema;
86
80
  exports.MathAppSchema = require_math.MathAppSchema;
@@ -108,28 +102,58 @@ exports.MathUnitSchema = require_math.MathUnitSchema;
108
102
  exports.MathUnparsedSchema = require_math.MathUnparsedSchema;
109
103
  exports.PAGE_SIZE_A4 = require_geometry.PAGE_SIZE_A4;
110
104
  exports.PAGE_SIZE_LETTER = require_geometry.PAGE_SIZE_LETTER;
105
+ exports.PackageGroupSchema = require_package_node.PackageGroupSchema;
106
+ exports.PackageLeafSchema = require_package_node.PackageLeafSchema;
107
+ exports.PackageNodeSchema = require_package_node.PackageNodeSchema;
111
108
  exports.PageSizeSchema = require_geometry.PageSizeSchema;
112
109
  exports.SCHEMA_FILE_NAMES = require_schema_io.SCHEMA_FILE_NAMES;
113
110
  exports.SI_BASE_DIMENSIONS = require_math.SI_BASE_DIMENSIONS;
114
111
  exports.SLIDE_SIZE_STANDARD = require_geometry.SLIDE_SIZE_STANDARD;
115
112
  exports.SLIDE_SIZE_WIDESCREEN = require_geometry.SLIDE_SIZE_WIDESCREEN;
113
+ exports.SchemaVersionMismatchError = require_schema_io.SchemaVersionMismatchError;
114
+ exports.SectionDescriptorSchema = require_package_node.SectionDescriptorSchema;
115
+ exports.SectionGroupSchema = require_package_node.SectionGroupSchema;
116
+ exports.ShapeDescriptorSchema = require_package_node.ShapeDescriptorSchema;
117
+ exports.ShapeGroupSchema = require_package_node.ShapeGroupSchema;
118
+ exports.SheetDescriptorSchema = require_package_node.SheetDescriptorSchema;
119
+ exports.SheetGroupSchema = require_package_node.SheetGroupSchema;
120
+ exports.SlideDescriptorSchema = require_package_node.SlideDescriptorSchema;
121
+ exports.SlideGroupSchema = require_package_node.SlideGroupSchema;
122
+ exports.StyleEntrySchema = require_definitions.StyleEntrySchema;
123
+ exports.StyleParagraphPropertiesSchema = require_definitions.StyleParagraphPropertiesSchema;
124
+ exports.StyleRunPropertiesSchema = require_definitions.StyleRunPropertiesSchema;
125
+ exports.StylesTableSchema = require_definitions.StylesTableSchema;
116
126
  exports.SymbolTableSchema = require_math.SymbolTableSchema;
117
127
  exports.UnrecognizedDocumentSchemaError = require_schema_io.UnrecognizedDocumentSchemaError;
128
+ exports.applyParagraphStyleProperties = require_definitions.applyParagraphStyleProperties;
129
+ exports.applyRunStyleProperties = require_definitions.applyRunStyleProperties;
118
130
  exports.cellReference = require_a1.cellReference;
119
131
  exports.clampHeadingLevel = require_content.clampHeadingLevel;
120
132
  exports.colorToRgbHex = require_color.colorToRgbHex;
121
133
  exports.columnIndexToLetters = require_a1.columnIndexToLetters;
122
134
  exports.columnLettersToIndex = require_a1.columnLettersToIndex;
135
+ exports.contentDocumentSharedFields = require_content.contentDocumentSharedFields;
123
136
  exports.contentDocumentWithSchema = require_schema_io.contentDocumentWithSchema;
124
137
  exports.documentFromJson = require_schema_io.documentFromJson;
125
138
  exports.documentPackageWithSchema = require_schema_io.documentPackageWithSchema;
126
139
  exports.documentSchemaKindOf = require_schema_io.documentSchemaKindOf;
127
140
  exports.isContentBlock = require_content.isContentBlock;
141
+ exports.isDrawPageGroupNode = require_package_node.isDrawPageGroupNode;
142
+ exports.isHeadingGroupNode = require_package_node.isHeadingGroupNode;
143
+ exports.isListGroupNode = require_package_node.isListGroupNode;
128
144
  exports.isMathExpression = require_math.isMathExpression;
129
145
  exports.isMathMlNode = require_mathml.isMathMlNode;
130
- exports.layoutDocumentWithSchema = require_schema_io.layoutDocumentWithSchema;
146
+ exports.isPackageGroup = require_package_node.isPackageGroup;
147
+ exports.isPackageLeaf = require_package_node.isPackageLeaf;
148
+ exports.isPackageNode = require_package_node.isPackageNode;
149
+ exports.isSectionGroupNode = require_package_node.isSectionGroupNode;
150
+ exports.isShapeGroupNode = require_package_node.isShapeGroupNode;
151
+ exports.isSheetGroupNode = require_package_node.isSheetGroupNode;
152
+ exports.isSlideGroupNode = require_package_node.isSlideGroupNode;
153
+ exports.overlayStyleEntries = require_definitions.overlayStyleEntries;
131
154
  exports.parseCellReference = require_a1.parseCellReference;
132
155
  exports.parseRangeReference = require_a1.parseRangeReference;
133
156
  exports.rangeReference = require_a1.rangeReference;
157
+ exports.resolveStyleChain = require_definitions.resolveStyleChain;
134
158
  exports.rgbHexToColor = require_color.rgbHexToColor;
135
159
  exports.schemaUriFor = require_schema_io.schemaUriFor;