@folijs/core 0.4.0 → 0.6.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 (153) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/model/schema.d.ts +9 -1
  3. package/dist/model/schema.d.ts.map +1 -1
  4. package/dist/model/schema.js +13 -3
  5. package/dist/model/schema.js.map +1 -1
  6. package/dist/state/commands.d.ts +10 -1
  7. package/dist/state/commands.d.ts.map +1 -1
  8. package/dist/state/commands.js +125 -40
  9. package/dist/state/commands.js.map +1 -1
  10. package/dist/state/comments.d.ts.map +1 -1
  11. package/dist/state/comments.js +15 -6
  12. package/dist/state/comments.js.map +1 -1
  13. package/dist/state/controls.d.ts +128 -0
  14. package/dist/state/controls.d.ts.map +1 -0
  15. package/dist/state/controls.js +1459 -0
  16. package/dist/state/controls.js.map +1 -0
  17. package/dist/state/editor.d.ts +86 -1
  18. package/dist/state/editor.d.ts.map +1 -1
  19. package/dist/state/editor.js +169 -41
  20. package/dist/state/editor.js.map +1 -1
  21. package/dist/state/fields.d.ts +79 -0
  22. package/dist/state/fields.d.ts.map +1 -0
  23. package/dist/state/fields.js +398 -0
  24. package/dist/state/fields.js.map +1 -0
  25. package/dist/state/fieldupdate.d.ts +178 -0
  26. package/dist/state/fieldupdate.d.ts.map +1 -0
  27. package/dist/state/fieldupdate.js +1574 -0
  28. package/dist/state/fieldupdate.js.map +1 -0
  29. package/dist/state/find.d.ts +68 -0
  30. package/dist/state/find.d.ts.map +1 -0
  31. package/dist/state/find.js +397 -0
  32. package/dist/state/find.js.map +1 -0
  33. package/dist/state/history.d.ts +12 -1
  34. package/dist/state/history.d.ts.map +1 -1
  35. package/dist/state/history.js +43 -7
  36. package/dist/state/history.js.map +1 -1
  37. package/dist/state/index.d.ts +15 -5
  38. package/dist/state/index.d.ts.map +1 -1
  39. package/dist/state/index.js +13 -3
  40. package/dist/state/index.js.map +1 -1
  41. package/dist/state/links.d.ts.map +1 -1
  42. package/dist/state/links.js +30 -19
  43. package/dist/state/links.js.map +1 -1
  44. package/dist/state/mark.d.ts.map +1 -1
  45. package/dist/state/mark.js +8 -1
  46. package/dist/state/mark.js.map +1 -1
  47. package/dist/state/navigation.d.ts +70 -0
  48. package/dist/state/navigation.d.ts.map +1 -0
  49. package/dist/state/navigation.js +226 -0
  50. package/dist/state/navigation.js.map +1 -0
  51. package/dist/state/notes.d.ts +94 -0
  52. package/dist/state/notes.d.ts.map +1 -0
  53. package/dist/state/notes.js +444 -0
  54. package/dist/state/notes.js.map +1 -0
  55. package/dist/state/pictures.d.ts +51 -0
  56. package/dist/state/pictures.d.ts.map +1 -0
  57. package/dist/state/pictures.js +140 -0
  58. package/dist/state/pictures.js.map +1 -0
  59. package/dist/state/review.d.ts +13 -4
  60. package/dist/state/review.d.ts.map +1 -1
  61. package/dist/state/review.js +223 -29
  62. package/dist/state/review.js.map +1 -1
  63. package/dist/state/sections.d.ts +101 -0
  64. package/dist/state/sections.d.ts.map +1 -0
  65. package/dist/state/sections.js +472 -0
  66. package/dist/state/sections.js.map +1 -0
  67. package/dist/state/selection.d.ts +12 -1
  68. package/dist/state/selection.d.ts.map +1 -1
  69. package/dist/state/selection.js +12 -0
  70. package/dist/state/selection.js.map +1 -1
  71. package/dist/state/state.d.ts +2 -0
  72. package/dist/state/state.d.ts.map +1 -1
  73. package/dist/state/state.js +4 -0
  74. package/dist/state/state.js.map +1 -1
  75. package/dist/state/stories.d.ts +41 -0
  76. package/dist/state/stories.d.ts.map +1 -0
  77. package/dist/state/stories.js +243 -0
  78. package/dist/state/stories.js.map +1 -0
  79. package/dist/state/tablecommands.d.ts +77 -0
  80. package/dist/state/tablecommands.d.ts.map +1 -0
  81. package/dist/state/tablecommands.js +675 -0
  82. package/dist/state/tablecommands.js.map +1 -0
  83. package/dist/state/tables.d.ts +110 -0
  84. package/dist/state/tables.d.ts.map +1 -0
  85. package/dist/state/tables.js +730 -0
  86. package/dist/state/tables.js.map +1 -0
  87. package/dist/state/track.d.ts +23 -0
  88. package/dist/state/track.d.ts.map +1 -1
  89. package/dist/state/track.js +113 -15
  90. package/dist/state/track.js.map +1 -1
  91. package/dist/state/word.d.ts +78 -16
  92. package/dist/state/word.d.ts.map +1 -1
  93. package/dist/state/word.js +231 -11
  94. package/dist/state/word.js.map +1 -1
  95. package/dist/state/wordclip.d.ts +15 -6
  96. package/dist/state/wordclip.d.ts.map +1 -1
  97. package/dist/state/wordclip.js +213 -18
  98. package/dist/state/wordclip.js.map +1 -1
  99. package/dist/state/wordformat.d.ts +10 -2
  100. package/dist/state/wordformat.d.ts.map +1 -1
  101. package/dist/state/wordformat.js +98 -17
  102. package/dist/state/wordformat.js.map +1 -1
  103. package/dist/v3/document.d.ts +237 -7
  104. package/dist/v3/document.d.ts.map +1 -1
  105. package/dist/v3/document.js +314 -15
  106. package/dist/v3/document.js.map +1 -1
  107. package/dist/v3/index.d.ts +2 -2
  108. package/dist/v3/index.d.ts.map +1 -1
  109. package/dist/v3/index.js +2 -2
  110. package/dist/v3/index.js.map +1 -1
  111. package/dist/v3/migrate.d.ts +2 -2
  112. package/dist/v3/migrate.d.ts.map +1 -1
  113. package/dist/v3/resolve.d.ts +57 -5
  114. package/dist/v3/resolve.d.ts.map +1 -1
  115. package/dist/v3/resolve.js +224 -16
  116. package/dist/v3/resolve.js.map +1 -1
  117. package/dist/v3/schema.d.ts +6 -0
  118. package/dist/v3/schema.d.ts.map +1 -1
  119. package/dist/v3/schema.js +254 -8
  120. package/dist/v3/schema.js.map +1 -1
  121. package/package.json +1 -1
  122. package/src/model/schema.ts +18 -2
  123. package/src/state/commands.ts +121 -32
  124. package/src/state/comments.ts +14 -6
  125. package/src/state/controls.ts +1596 -0
  126. package/src/state/editor.ts +292 -46
  127. package/src/state/fields.ts +432 -0
  128. package/src/state/fieldupdate.ts +1770 -0
  129. package/src/state/find.ts +510 -0
  130. package/src/state/history.ts +51 -7
  131. package/src/state/index.ts +157 -0
  132. package/src/state/links.ts +27 -17
  133. package/src/state/mark.ts +8 -1
  134. package/src/state/navigation.ts +305 -0
  135. package/src/state/notes.ts +519 -0
  136. package/src/state/numeric-pictures.word.json +172 -0
  137. package/src/state/pictures.ts +168 -0
  138. package/src/state/review.ts +265 -31
  139. package/src/state/sections.ts +571 -0
  140. package/src/state/selection.ts +15 -1
  141. package/src/state/state.ts +5 -0
  142. package/src/state/stories.ts +285 -0
  143. package/src/state/tablecommands.ts +741 -0
  144. package/src/state/tables.ts +761 -0
  145. package/src/state/track.ts +128 -16
  146. package/src/state/word.ts +276 -13
  147. package/src/state/wordclip.ts +231 -32
  148. package/src/state/wordformat.ts +96 -14
  149. package/src/v3/document.ts +572 -16
  150. package/src/v3/index.ts +21 -0
  151. package/src/v3/migrate.ts +2 -2
  152. package/src/v3/resolve.ts +289 -21
  153. package/src/v3/schema.ts +278 -9
package/src/v3/schema.ts CHANGED
@@ -126,17 +126,34 @@ const border = shape(
126
126
 
127
127
  const shading = shape({ pattern: token, color, fill: color, themeFill: token }, ["pattern"]);
128
128
 
129
+ const nullableAttr = (check: Check): AttributeSpec => ({
130
+ default: null,
131
+ validate: nullable(check),
132
+ });
133
+
129
134
  /** Who made a tracked change or comment, and when (ids are Word's `w:id`; authors may be empty). */
130
135
  const ID = int(0, 2_147_483_647);
131
136
  const revisionFields = { id: ID, author: str(), date: nullable(date) };
132
137
  const revision = shape(revisionFields, ["id", "author"]);
133
138
 
139
+ /** How notes are placed and numbered (`w:footnotePr`, `w:endnotePr`), for a document or section. */
140
+ export const checkNoteProperties: Check = shape({
141
+ position: oneOf(["pageBottom", "beneathText", "sectEnd", "docEnd"]),
142
+ format: token,
143
+ start: ID,
144
+ restart: oneOf(["continuous", "eachSect", "eachPage"]),
145
+ });
146
+
147
+ /** Word's limit on a section's columns. */
148
+ const MAX_SECTION_COLUMNS = 45;
149
+
134
150
  /**
135
151
  * A section's page setup (`w:sectPr`): on the last paragraph of each section, and the
136
152
  * envelope's for the last. Every part is optional (Word's defaults apply); `{}` is a section
137
153
  * break with Word's defaults.
138
154
  */
139
- export const checkSection: Check = shape(
155
+ export const checkSection: Check = (value) => sectionShape(value);
156
+ const sectionShape: Check = shape(
140
157
  {
141
158
  pageSize: shape({
142
159
  width: int(1, MAX_TWIPS),
@@ -156,12 +173,154 @@ export const checkSection: Check = shape(
156
173
  titlePage: bool,
157
174
  headers: shape({ default: text(), first: text(), even: text() }),
158
175
  footers: shape({ default: text(), first: text(), even: text() }),
176
+ /** `w:cols` (schema v5): `widths` when the columns are not equal. */
177
+ columns: shape({
178
+ count: int(1, MAX_SECTION_COLUMNS),
179
+ space: positiveTwips,
180
+ equalWidth: bool,
181
+ separator: bool,
182
+ widths: listOf(
183
+ shape({ width: positiveTwips, space: positiveTwips }, ["width"]),
184
+ MAX_SECTION_COLUMNS,
185
+ ),
186
+ }),
187
+ /** `w:pgNumType` (schema v5). */
188
+ pageNumbers: shape({ start: ID, format: token }),
189
+ footnotes: checkNoteProperties,
190
+ endnotes: checkNoteProperties,
191
+ /** `w:sectPrChange`: a tracked change of the page setup, and the setup before it. */
192
+ change: shape({ ...revisionFields, previous: checkSection }, ["id", "author", "previous"]),
159
193
  ext: xml,
160
194
  },
161
195
  [],
162
196
  true,
163
197
  );
164
198
 
199
+ /**
200
+ * A table measure (`w:tblW`, `w:tcW`, `w:tblInd`, cell margins): `value` in twips (`dxa`) or
201
+ * fiftieths of a percent (`pct`, 5000 = 100 %); `auto` and `nil` carry 0.
202
+ */
203
+ const measure = shape({ value: twips, type: oneOf(["auto", "dxa", "pct", "nil"]) }, [
204
+ "value",
205
+ "type",
206
+ ]);
207
+ const sides = (check: Check, extra: readonly string[] = []) =>
208
+ shape(
209
+ Object.fromEntries(
210
+ ["top", "left", "bottom", "right", "start", "end", ...extra].map((side) => [side, check]),
211
+ ),
212
+ );
213
+ /** Word's limit: 63 columns. Files beyond it stay valid up to this bound. */
214
+ const MAX_COLUMNS = 1000;
215
+
216
+ /** Table properties (`w:tblPr`), also a row's exceptions (`w:tblPrEx`) and a table style's. */
217
+ const tableProperties: Record<string, AttributeSpec> = {
218
+ style: nullableAttr(text()),
219
+ width: nullableAttr(measure),
220
+ justification: nullableAttr(oneOf(["left", "center", "right", "start", "end"])),
221
+ indent: nullableAttr(measure),
222
+ layout: nullableAttr(oneOf(["fixed", "autofit"])),
223
+ borders: nullableAttr(sides(border, ["insideH", "insideV"])),
224
+ cellMargins: nullableAttr(sides(measure)),
225
+ cellSpacing: nullableAttr(measure),
226
+ shading: nullableAttr(shading),
227
+ /** `w:tblLook`: which of the table style's conditional formats apply. */
228
+ look: nullableAttr(
229
+ shape({
230
+ firstRow: bool,
231
+ lastRow: bool,
232
+ firstColumn: bool,
233
+ lastColumn: bool,
234
+ noHBand: bool,
235
+ noVBand: bool,
236
+ }),
237
+ ),
238
+ /** Rows and columns per band of the table style's banding (`w:tblStyleRowBandSize`…). */
239
+ rowBandSize: nullableAttr(int(1, MAX_COLUMNS)),
240
+ columnBandSize: nullableAttr(int(1, MAX_COLUMNS)),
241
+ /** The element these properties were read from, verbatim. */
242
+ ext: nullableAttr(xml),
243
+ };
244
+
245
+ /** Row properties (`w:trPr`) as a row's attributes or a table style's. */
246
+ const rowProperties: Record<string, AttributeSpec> = {
247
+ /** In twips; `auto` lets the content decide (Word's default). */
248
+ height: nullableAttr(
249
+ shape({ value: positiveTwips, rule: oneOf(["auto", "exact", "atLeast"]) }, ["value"]),
250
+ ),
251
+ /** The row is never split across pages. */
252
+ cantSplit: nullableAttr(bool),
253
+ /** A header row: repeated at the top of each page the table continues on. */
254
+ header: nullableAttr(bool),
255
+ /** Grid columns left empty before the first cell and after the last, and their widths. */
256
+ gridBefore: nullableAttr(int(1, MAX_COLUMNS)),
257
+ widthBefore: nullableAttr(measure),
258
+ gridAfter: nullableAttr(int(1, MAX_COLUMNS)),
259
+ widthAfter: nullableAttr(measure),
260
+ ext: nullableAttr(xml),
261
+ };
262
+
263
+ /** Cell properties (`w:tcPr`) as a cell's attributes or a table style's. */
264
+ const cellProperties: Record<string, AttributeSpec> = {
265
+ width: nullableAttr(measure),
266
+ /** Grid columns the cell spans (null: one). */
267
+ gridSpan: nullableAttr(int(1, MAX_COLUMNS)),
268
+ /**
269
+ * A vertical merge: `restart` starts one, `continue` is covered by the cell above. Kept as
270
+ * Word writes it (a merged cell is present in every row it covers); layout derives the span.
271
+ */
272
+ vMerge: nullableAttr(oneOf(["restart", "continue"])),
273
+ borders: nullableAttr(sides(border, ["insideH", "insideV", "tl2br", "tr2bl"])),
274
+ shading: nullableAttr(shading),
275
+ margins: nullableAttr(sides(measure)),
276
+ verticalAlign: nullableAttr(oneOf(["top", "center", "bottom", "both"])),
277
+ textDirection: nullableAttr(token),
278
+ noWrap: nullableAttr(bool),
279
+ ext: nullableAttr(xml),
280
+ };
281
+
282
+ const propertiesCheck =
283
+ (specs: Record<string, AttributeSpec>): Check =>
284
+ (v) => {
285
+ if (!isRecord(v)) return "must be an object";
286
+ for (const [key, value] of Object.entries(v)) {
287
+ if (!Object.hasOwn(specs, key)) return `unknown key ${key}`;
288
+ const error =
289
+ value === null
290
+ ? "must not be null (leave it out)"
291
+ : (specs[key] as AttributeSpec).validate?.(value);
292
+ if (error) return `${key} ${error}`;
293
+ }
294
+ return undefined;
295
+ };
296
+
297
+ /** Table, row and cell properties as a table style or a row's exceptions give them. */
298
+ export const checkTableProperties: Check = propertiesCheck(tableProperties);
299
+ export const checkRowProperties: Check = propertiesCheck(rowProperties);
300
+ export const checkCellProperties: Check = propertiesCheck(cellProperties);
301
+
302
+ /** EMU (English Metric Units: 914 400 per inch), as DrawingML measures pictures. */
303
+ const emu = int(0, 2_147_483_647);
304
+ const offset = int(-2_147_483_648, 2_147_483_647);
305
+
306
+ /** Where a floating picture is (`wp:anchor`): null for an inline picture. */
307
+ const checkFloat: Check = shape(
308
+ {
309
+ /** `relativeFrom` (page, margin, column, paragraph, character…) and an offset or alignment. */
310
+ horizontal: shape({ relativeTo: token, offset, align: token }, ["relativeTo"]),
311
+ vertical: shape({ relativeTo: token, offset, align: token }, ["relativeTo"]),
312
+ /** How text goes around it; `behind` and `inFront` are no wrapping. */
313
+ wrap: oneOf(["square", "tight", "through", "topAndBottom", "behind", "inFront"]),
314
+ /** Which sides text goes on (`w:wrapText`). */
315
+ side: oneOf(["bothSides", "left", "right", "largest"]),
316
+ /** Distance from the text, in EMU. */
317
+ distance: shape({ top: emu, bottom: emu, left: emu, right: emu }),
318
+ allowOverlap: bool,
319
+ layoutInCell: bool,
320
+ },
321
+ ["horizontal", "vertical", "wrap"],
322
+ );
323
+
165
324
  /** Marks that describe how text looks: what a style, a paragraph mark or a recorded change holds. */
166
325
  export const RUN_PROPERTY_MARKS = [
167
326
  "characterStyle",
@@ -198,11 +357,6 @@ export const checkRunProperties: Check = (v) => {
198
357
  }
199
358
  };
200
359
 
201
- const nullableAttr = (check: Check): AttributeSpec => ({
202
- default: null,
203
- validate: nullable(check),
204
- });
205
-
206
360
  /**
207
361
  * Paragraph properties (`w:pPr`). The same attributes describe a style's, a numbering level's
208
362
  * and the defaults' paragraph properties.
@@ -308,6 +462,18 @@ const reviewMark: MarkSpec = {
308
462
  };
309
463
  /** A marker's own unknown attributes (`w:displacedByCustomXml`…). */
310
464
  const markerAttributes = { attributes: nullableAttr(attributes) };
465
+ /** Ids of content controls, outermost first: at least one, none twice. */
466
+ const controlIds: Check = (v) => {
467
+ const error = listOf(text(), 64)(v);
468
+ if (error) return error;
469
+ const ids = v as string[];
470
+ if (!ids.length) return "must not be empty (use null)";
471
+ return new Set(ids).size === ids.length ? undefined : "must not repeat an id";
472
+ };
473
+ /** The content controls around a block, row or cell (schema v5, ADR-0007). */
474
+ const controlsAttr = { controls: nullableAttr(controlIds) };
475
+ /** Part of a field (schema v5): stands in a run, verbatim XML of what the model does not hold. */
476
+ const fieldPart = { group: "inline", inline: true, selectable: false } as const;
311
477
  const fontName = markAttr(nullable(text()), null);
312
478
  const themeFont = markAttr(nullable(oneOf(THEME_FONTS)), null);
313
479
  const hexByte = (v: unknown) =>
@@ -321,6 +487,7 @@ export const schema = new Schema({
321
487
  content: "inline*",
322
488
  attrs: {
323
489
  ...paragraphProperties,
490
+ ...controlsAttr,
324
491
  /** Ends a section: its page setup. The last section's is the envelope's `section`. */
325
492
  section: nullableAttr(checkSection),
326
493
  /** The paragraph mark inserted and/or deleted as tracked changes. */
@@ -337,10 +504,45 @@ export const schema = new Schema({
337
504
  attributes: nullableAttr(attributes),
338
505
  },
339
506
  },
340
- /** Block content Foli does not model yet (tables until Phase 10…), kept verbatim. */
507
+ /**
508
+ * A table (`w:tbl`, schema v4): rows of cells holding blocks. Word's rules beyond the
509
+ * content expressions (no table right after a table, none ending the body or a cell, no
510
+ * section or page break in a cell) are checked by `parseContent`.
511
+ */
512
+ table: {
513
+ group: "block",
514
+ content: "tableRow+",
515
+ attrs: {
516
+ ...tableProperties,
517
+ ...controlsAttr,
518
+ /** The grid's column widths in twips (`w:tblGrid`). */
519
+ grid: { default: [], validate: listOf(positiveTwips, MAX_COLUMNS) },
520
+ /** The `w:tblGrid` the grid was read from, verbatim. */
521
+ gridExt: nullableAttr(xml),
522
+ },
523
+ },
524
+ tableRow: {
525
+ content: "tableCell+",
526
+ attrs: {
527
+ ...rowProperties,
528
+ ...controlsAttr,
529
+ /** The row inserted or deleted as a tracked change (`w:trPr/w:ins`, `w:del`). */
530
+ revision: nullableAttr(shape({ insertion: revision, deletion: revision })),
531
+ /** The row's table property exceptions (`w:tblPrEx`). */
532
+ exceptions: nullableAttr(checkTableProperties),
533
+ /** `w:tr`'s own unknown attributes (`w14:paraId`, revision save ids…). */
534
+ attributes: nullableAttr(attributes),
535
+ },
536
+ },
537
+ tableCell: {
538
+ // As Word requires, a cell ends with a paragraph.
539
+ content: "block* paragraph",
540
+ attrs: { ...cellProperties, ...controlsAttr },
541
+ },
542
+ /** Block content Foli does not model yet (a table inside a content control…), kept verbatim. */
341
543
  opaqueBlock: {
342
544
  group: "block",
343
- attrs: { xml: { validate: xml }, label: nullableAttr(text()) },
545
+ attrs: { xml: { validate: xml }, label: nullableAttr(text()), ...controlsAttr },
344
546
  },
345
547
  text: { group: "inline" },
346
548
  tab: { group: "inline", inline: true },
@@ -383,7 +585,74 @@ export const schema = new Schema({
383
585
  inline: true,
384
586
  attrs: { id: { validate: ID }, ...markerAttributes },
385
587
  },
386
- /** Inline content Foli does not model yet (fields, drawings, symbols…), kept verbatim. */
588
+ /**
589
+ * A field, as Word has it (schema v5, ADR-0007): start, code, optional separator, result,
590
+ * end. The code range runs from the start to the separator (or the end) and may hold other
591
+ * fields; the result is ordinary content.
592
+ */
593
+ fieldStart: {
594
+ ...fieldPart,
595
+ attrs: {
596
+ dirty: nullableAttr(bool),
597
+ locked: nullableAttr(bool),
598
+ /** Read from `w:fldSimple`, and written back as one. */
599
+ simple: nullableAttr(bool),
600
+ ext: nullableAttr(xml),
601
+ },
602
+ },
603
+ /** One `w:instrText`: part of a field's code. */
604
+ fieldCode: { ...fieldPart, attrs: { text: { validate: str(65_535) }, ...markerAttributes } },
605
+ fieldSeparator: { ...fieldPart, attrs: { ext: nullableAttr(xml) } },
606
+ fieldEnd: { ...fieldPart, attrs: { ext: nullableAttr(xml) } },
607
+ /** An inline content control's ends; its properties are the envelope's `controls[id]`. */
608
+ controlStart: {
609
+ group: "inline",
610
+ inline: true,
611
+ selectable: false,
612
+ attrs: { id: { validate: text() } },
613
+ },
614
+ controlEnd: {
615
+ group: "inline",
616
+ inline: true,
617
+ selectable: false,
618
+ attrs: { id: { validate: text() } },
619
+ },
620
+ /** A footnote's or endnote's reference: its text is the envelope's `stories[story]`. */
621
+ noteReference: {
622
+ group: "inline",
623
+ inline: true,
624
+ attrs: {
625
+ story: { validate: text() },
626
+ /** `w:customMarkFollows`: the mark is the text after it, not a number. */
627
+ customMark: nullableAttr(bool),
628
+ ...markerAttributes,
629
+ },
630
+ },
631
+ /** Where a note shows its own number (`w:footnoteRef`, `w:endnoteRef`). */
632
+ noteMark: { group: "inline", inline: true, selectable: false },
633
+ /**
634
+ * A picture (`w:drawing` holding `pic:pic`, schema v4), inline or floating. Its bytes are
635
+ * the envelope's `resources[resource]`.
636
+ */
637
+ picture: {
638
+ group: "inline",
639
+ inline: true,
640
+ attrs: {
641
+ resource: { validate: text() },
642
+ /** In EMU. */
643
+ width: { validate: emu },
644
+ height: { validate: emu },
645
+ /** Alt text (`wp:docPr/@descr`): allowed to be missing, as Word allows it. */
646
+ alt: nullableAttr(str(65_535)),
647
+ title: nullableAttr(str(65_535)),
648
+ /** Marked decorative: no alt text needed. */
649
+ decorative: nullableAttr(bool),
650
+ float: nullableAttr(checkFloat),
651
+ /** The `w:drawing` it was read from, verbatim (cropping, effects…). */
652
+ ext: nullableAttr(xml),
653
+ },
654
+ },
655
+ /** Inline content Foli does not model yet (fields, charts, shapes, symbols…), kept verbatim. */
387
656
  opaqueInline: {
388
657
  group: "inline",
389
658
  inline: true,