@folijs/core 0.2.0 → 0.3.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 (115) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -1
  3. package/dist/document.d.ts +10 -16
  4. package/dist/document.d.ts.map +1 -1
  5. package/dist/document.js +22 -22
  6. package/dist/document.js.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/model/fragment.d.ts +5 -2
  12. package/dist/model/fragment.d.ts.map +1 -1
  13. package/dist/model/fragment.js +5 -2
  14. package/dist/model/fragment.js.map +1 -1
  15. package/dist/model/node.d.ts +1 -1
  16. package/dist/model/node.d.ts.map +1 -1
  17. package/dist/model/node.js.map +1 -1
  18. package/dist/schema.d.ts +10 -1
  19. package/dist/schema.d.ts.map +1 -1
  20. package/dist/schema.js +11 -1
  21. package/dist/schema.js.map +1 -1
  22. package/dist/state/commands.d.ts +7 -6
  23. package/dist/state/commands.d.ts.map +1 -1
  24. package/dist/state/commands.js +134 -97
  25. package/dist/state/commands.js.map +1 -1
  26. package/dist/state/editor.d.ts +25 -15
  27. package/dist/state/editor.d.ts.map +1 -1
  28. package/dist/state/editor.js +44 -16
  29. package/dist/state/editor.js.map +1 -1
  30. package/dist/state/format.d.ts +8 -22
  31. package/dist/state/format.d.ts.map +1 -1
  32. package/dist/state/format.js +16 -140
  33. package/dist/state/format.js.map +1 -1
  34. package/dist/state/index.d.ts +8 -4
  35. package/dist/state/index.d.ts.map +1 -1
  36. package/dist/state/index.js +8 -4
  37. package/dist/state/index.js.map +1 -1
  38. package/dist/state/links.d.ts.map +1 -1
  39. package/dist/state/links.js +10 -2
  40. package/dist/state/links.js.map +1 -1
  41. package/dist/state/lists.d.ts +19 -32
  42. package/dist/state/lists.d.ts.map +1 -1
  43. package/dist/state/lists.js +23 -372
  44. package/dist/state/lists.js.map +1 -1
  45. package/dist/state/mark.d.ts +25 -0
  46. package/dist/state/mark.d.ts.map +1 -0
  47. package/dist/state/mark.js +40 -0
  48. package/dist/state/mark.js.map +1 -0
  49. package/dist/state/state.d.ts.map +1 -1
  50. package/dist/state/state.js +11 -0
  51. package/dist/state/state.js.map +1 -1
  52. package/dist/state/word.d.ts +72 -0
  53. package/dist/state/word.d.ts.map +1 -0
  54. package/dist/state/word.js +173 -0
  55. package/dist/state/word.js.map +1 -0
  56. package/dist/state/wordclip.d.ts +43 -0
  57. package/dist/state/wordclip.d.ts.map +1 -0
  58. package/dist/state/wordclip.js +412 -0
  59. package/dist/state/wordclip.js.map +1 -0
  60. package/dist/state/wordformat.d.ts +136 -0
  61. package/dist/state/wordformat.d.ts.map +1 -0
  62. package/dist/state/wordformat.js +846 -0
  63. package/dist/state/wordformat.js.map +1 -0
  64. package/dist/v3/check.d.ts +33 -0
  65. package/dist/v3/check.d.ts.map +1 -0
  66. package/dist/v3/check.js +90 -0
  67. package/dist/v3/check.js.map +1 -0
  68. package/dist/v3/document.d.ts +217 -0
  69. package/dist/v3/document.d.ts.map +1 -0
  70. package/dist/v3/document.js +225 -0
  71. package/dist/v3/document.js.map +1 -0
  72. package/dist/v3/index.d.ts +6 -0
  73. package/dist/v3/index.d.ts.map +1 -0
  74. package/dist/v3/index.js +6 -0
  75. package/dist/v3/index.js.map +1 -0
  76. package/dist/v3/migrate.d.ts +19 -0
  77. package/dist/v3/migrate.d.ts.map +1 -0
  78. package/dist/v3/migrate.js +227 -0
  79. package/dist/v3/migrate.js.map +1 -0
  80. package/dist/v3/resolve.d.ts +129 -0
  81. package/dist/v3/resolve.d.ts.map +1 -0
  82. package/dist/v3/resolve.js +534 -0
  83. package/dist/v3/resolve.js.map +1 -0
  84. package/dist/v3/schema.d.ts +27 -0
  85. package/dist/v3/schema.d.ts.map +1 -0
  86. package/dist/v3/schema.js +429 -0
  87. package/dist/v3/schema.js.map +1 -0
  88. package/dist/v3/units.d.ts +16 -0
  89. package/dist/v3/units.d.ts.map +1 -0
  90. package/dist/v3/units.js +28 -0
  91. package/dist/v3/units.js.map +1 -0
  92. package/package.json +1 -1
  93. package/src/document.ts +26 -26
  94. package/src/index.ts +3 -6
  95. package/src/model/fragment.ts +11 -3
  96. package/src/model/node.ts +6 -1
  97. package/src/schema.ts +13 -1
  98. package/src/state/commands.ts +147 -91
  99. package/src/state/editor.ts +81 -35
  100. package/src/state/format.ts +24 -122
  101. package/src/state/index.ts +34 -3
  102. package/src/state/links.ts +10 -2
  103. package/src/state/lists.ts +31 -408
  104. package/src/state/mark.ts +47 -0
  105. package/src/state/state.ts +11 -0
  106. package/src/state/word.ts +245 -0
  107. package/src/state/wordclip.ts +445 -0
  108. package/src/state/wordformat.ts +982 -0
  109. package/src/v3/check.ts +119 -0
  110. package/src/v3/document.ts +456 -0
  111. package/src/v3/index.ts +33 -0
  112. package/src/v3/migrate.ts +267 -0
  113. package/src/v3/resolve.ts +646 -0
  114. package/src/v3/schema.ts +479 -0
  115. package/src/v3/units.ts +34 -0
@@ -0,0 +1,429 @@
1
+ import { Schema } from "../model/index.js";
2
+ import { attributes, bool, color, date, int, isRecord, listOf, nullable, oneOf, shape, str, text, token, xml, } from "./check.js";
3
+ /**
4
+ * Schema v3: Word's document model ([ADR-0005](../../../../docs/decisions/ADR-0005-word-compatible-model.md)).
5
+ * Paragraphs carry Word's paragraph properties as attributes and text carries its run
6
+ * properties as marks, in Word's units (twips, half-points, eighths of a point), so values
7
+ * survive a DOCX round trip exactly. Headings are paragraphs with a heading style; lists are
8
+ * numbered paragraphs. An unset property is null (the style decides).
9
+ *
10
+ * Validation accepts what Word accepts: it rejects only what the engine cannot work with
11
+ * (wrong types, out-of-range numbers), never a property combination Word would open.
12
+ *
13
+ * Lossless: an `ext` attribute holds the element the properties were read from (`w:pPr`,
14
+ * `w:rPr`, `w:sectPr`…), verbatim. Export writes it back as it was while the modeled values
15
+ * still match it, and otherwise rewrites the modeled values into it, keeping its unknown
16
+ * children (in Word's order) and unknown attributes. `attributes` holds an element's own
17
+ * unknown attributes (`w14:paraId` on a paragraph). Opaque nodes hold whole elements Foli does
18
+ * not model yet.
19
+ *
20
+ * The editor still runs on schema v2 until rendering and editing move to v3 (8.6, 8.7); this
21
+ * schema, the v3 envelope and the v2 → v3 migration exist alongside it until then.
22
+ */
23
+ const MAX_TWIPS = 31_680; // 22 inches: Word's largest page dimension
24
+ const twips = int(-MAX_TWIPS, MAX_TWIPS);
25
+ const positiveTwips = int(0, MAX_TWIPS);
26
+ /** Line spacing: 240ths of a line ("auto") or twips. */
27
+ const lineSpacing = int(-MAX_TWIPS, MAX_TWIPS);
28
+ /** Word's paragraph justification (ST_Jc). */
29
+ export const JUSTIFICATIONS = [
30
+ "left",
31
+ "center",
32
+ "right",
33
+ "both",
34
+ "start",
35
+ "end",
36
+ "distribute",
37
+ "mediumKashida",
38
+ "highKashida",
39
+ "lowKashida",
40
+ "thaiDistribute",
41
+ "numTab",
42
+ ];
43
+ export const LINE_RULES = ["auto", "exact", "atLeast"];
44
+ export const TAB_KINDS = [
45
+ "left",
46
+ "center",
47
+ "right",
48
+ "decimal",
49
+ "bar",
50
+ "clear",
51
+ "num",
52
+ "start",
53
+ "end",
54
+ ];
55
+ export const TAB_LEADERS = ["none", "dot", "hyphen", "underscore", "heavy", "middleDot"];
56
+ export const SECTION_TYPES = [
57
+ "nextPage",
58
+ "continuous",
59
+ "evenPage",
60
+ "oddPage",
61
+ "nextColumn",
62
+ ];
63
+ export const VERTICAL_ALIGNS = ["baseline", "superscript", "subscript"];
64
+ /** Word's highlight colors (ST_HighlightColor); any other color is shading. */
65
+ export const HIGHLIGHT_COLORS = [
66
+ "black",
67
+ "blue",
68
+ "cyan",
69
+ "green",
70
+ "magenta",
71
+ "red",
72
+ "yellow",
73
+ "white",
74
+ "darkBlue",
75
+ "darkCyan",
76
+ "darkGreen",
77
+ "darkMagenta",
78
+ "darkRed",
79
+ "darkYellow",
80
+ "darkGray",
81
+ "lightGray",
82
+ "none",
83
+ ];
84
+ export const THEME_FONTS = [
85
+ "majorAscii",
86
+ "majorHAnsi",
87
+ "majorEastAsia",
88
+ "majorBidi",
89
+ "minorAscii",
90
+ "minorHAnsi",
91
+ "minorEastAsia",
92
+ "minorBidi",
93
+ ];
94
+ const border = shape({
95
+ style: token,
96
+ size: int(0, 96), // eighths of a point
97
+ space: int(0, 31), // points
98
+ color,
99
+ themeColor: token,
100
+ }, ["style"]);
101
+ const shading = shape({ pattern: token, color, fill: color, themeFill: token }, ["pattern"]);
102
+ /** Who made a tracked change or comment, and when (ids are Word's `w:id`; authors may be empty). */
103
+ const ID = int(0, 2_147_483_647);
104
+ const revisionFields = { id: ID, author: str(), date: nullable(date) };
105
+ const revision = shape(revisionFields, ["id", "author"]);
106
+ /**
107
+ * A section's page setup (`w:sectPr`): on the last paragraph of each section, and the
108
+ * envelope's for the last. Every part is optional (Word's defaults apply); `{}` is a section
109
+ * break with Word's defaults.
110
+ */
111
+ export const checkSection = shape({
112
+ pageSize: shape({
113
+ width: int(1, MAX_TWIPS),
114
+ height: int(1, MAX_TWIPS),
115
+ orientation: oneOf(["portrait", "landscape"]),
116
+ }),
117
+ margins: shape({
118
+ top: twips,
119
+ right: positiveTwips,
120
+ bottom: twips,
121
+ left: positiveTwips,
122
+ header: positiveTwips,
123
+ footer: positiveTwips,
124
+ gutter: positiveTwips,
125
+ }),
126
+ type: oneOf(SECTION_TYPES),
127
+ titlePage: bool,
128
+ headers: shape({ default: text(), first: text(), even: text() }),
129
+ footers: shape({ default: text(), first: text(), even: text() }),
130
+ ext: xml,
131
+ }, [], true);
132
+ /** Marks that describe how text looks: what a style, a paragraph mark or a recorded change holds. */
133
+ export const RUN_PROPERTY_MARKS = [
134
+ "characterStyle",
135
+ "bold",
136
+ "italic",
137
+ "underline",
138
+ "strike",
139
+ "doubleStrike",
140
+ "caps",
141
+ "smallCaps",
142
+ "hidden",
143
+ "font",
144
+ "fontSize",
145
+ "color",
146
+ "highlight",
147
+ "shading",
148
+ "verticalAlign",
149
+ "characterSpacing",
150
+ ];
151
+ /** Run properties given as marks JSON (a style's, a paragraph mark's, a recorded change's previous). */
152
+ export const checkRunProperties = (v) => {
153
+ if (!Array.isArray(v))
154
+ return "must be an array of marks";
155
+ for (const mark of v) {
156
+ if (!isRecord(mark) || !RUN_PROPERTY_MARKS.includes(mark.type)) {
157
+ return `${isRecord(mark) ? String(mark.type) : "a non-object"} is not a run property`;
158
+ }
159
+ }
160
+ try {
161
+ schema.nodeFromJSON({ type: "text", text: "x", marks: v });
162
+ return undefined;
163
+ }
164
+ catch (error) {
165
+ return error.message;
166
+ }
167
+ };
168
+ const nullableAttr = (check) => ({
169
+ default: null,
170
+ validate: nullable(check),
171
+ });
172
+ /**
173
+ * Paragraph properties (`w:pPr`). The same attributes describe a style's, a numbering level's
174
+ * and the defaults' paragraph properties.
175
+ */
176
+ const paragraphProperties = {
177
+ style: nullableAttr(text()),
178
+ justification: nullableAttr(oneOf(JUSTIFICATIONS)),
179
+ /** In twips. With both `firstLine` and `hanging`, Word applies `hanging`. */
180
+ indent: nullableAttr(shape({ left: twips, right: twips, firstLine: positiveTwips, hanging: positiveTwips })),
181
+ spacing: nullableAttr(shape({
182
+ before: positiveTwips,
183
+ after: positiveTwips,
184
+ line: lineSpacing,
185
+ lineRule: oneOf(LINE_RULES),
186
+ beforeAutospacing: bool,
187
+ afterAutospacing: bool,
188
+ })),
189
+ keepNext: nullableAttr(bool),
190
+ keepLines: nullableAttr(bool),
191
+ widowControl: nullableAttr(bool),
192
+ pageBreakBefore: nullableAttr(bool),
193
+ contextualSpacing: nullableAttr(bool),
194
+ outlineLevel: nullableAttr(int(0, 9)),
195
+ /**
196
+ * `id` is the numbering instance (`w:numId`; 0 removes numbering), `level` 0–8 (`w:ilvl`).
197
+ * Either may be missing, as in Word: the style supplies the other (a style's numbering
198
+ * often has only `id`; a paragraph demoting a style-numbered item only `level`).
199
+ */
200
+ numbering: nullableAttr(shape({ id: ID, level: int(0, 8) })),
201
+ tabs: nullableAttr(listOf(shape({ position: twips, kind: oneOf(TAB_KINDS), leader: oneOf(TAB_LEADERS) }, [
202
+ "position",
203
+ "kind",
204
+ ]), 64)),
205
+ borders: nullableAttr(shape({
206
+ top: border,
207
+ bottom: border,
208
+ left: border,
209
+ right: border,
210
+ between: border,
211
+ bar: border,
212
+ })),
213
+ shading: nullableAttr(shading),
214
+ /** The paragraph mark's run properties (`w:pPr/w:rPr`): the mark's look, the numbering's. */
215
+ markFormat: nullableAttr(checkRunProperties),
216
+ /** The `w:pPr` these properties were read from, verbatim (see the module comment). */
217
+ ext: nullableAttr(xml),
218
+ };
219
+ /** Paragraph properties as a style, a numbering level, the defaults or a recorded change give them. */
220
+ export const checkParagraphProperties = (v) => {
221
+ if (!isRecord(v))
222
+ return "must be an object";
223
+ for (const [key, value] of Object.entries(v)) {
224
+ if (!Object.hasOwn(paragraphProperties, key))
225
+ return `unknown key ${key}`;
226
+ const error = value === null
227
+ ? "must not be null (leave it out)"
228
+ : paragraphProperties[key].validate?.(value);
229
+ if (error)
230
+ return `${key} ${error}`;
231
+ }
232
+ return undefined;
233
+ };
234
+ const markAttr = (check, defaultValue) => defaultValue === undefined ? { validate: check } : { default: defaultValue, validate: check };
235
+ /** A run property that is on unless `value` is false (`<w:b w:val="0"/>` turns off a style's bold). */
236
+ const toggle = { attrs: { value: markAttr(bool, true) } };
237
+ /**
238
+ * Bold and italic have a complex-script twin (`w:bCs`, `w:iCs`): `value` null when only the
239
+ * twin is set.
240
+ */
241
+ const toggleWithComplexScript = {
242
+ attrs: {
243
+ value: markAttr(nullable(bool), true),
244
+ complexScript: markAttr(nullable(bool), null),
245
+ },
246
+ };
247
+ const reviewMark = {
248
+ attrs: {
249
+ id: markAttr(ID),
250
+ author: markAttr(str()),
251
+ date: markAttr(nullable(date), null),
252
+ /** A tracked move (`w:moveFrom`, `w:moveTo`): the move's name, shared by both ends. */
253
+ move: markAttr(nullable(text()), null),
254
+ /** The change element's other attributes (`w16du:dateUtc`…). */
255
+ attributes: markAttr(nullable(attributes), null),
256
+ },
257
+ inclusive: false,
258
+ };
259
+ /** A marker's own unknown attributes (`w:displacedByCustomXml`…). */
260
+ const markerAttributes = { attributes: nullableAttr(attributes) };
261
+ const fontName = markAttr(nullable(text()), null);
262
+ const themeFont = markAttr(nullable(oneOf(THEME_FONTS)), null);
263
+ const hexByte = (v) => typeof v === "string" && /^[0-9A-Fa-f]{2}$/.test(v) ? undefined : "must be a hex byte";
264
+ export const schema = new Schema({
265
+ nodes: {
266
+ doc: { content: "block+" },
267
+ paragraph: {
268
+ group: "block",
269
+ content: "inline*",
270
+ attrs: {
271
+ ...paragraphProperties,
272
+ /** Ends a section: its page setup. The last section's is the envelope's `section`. */
273
+ section: nullableAttr(checkSection),
274
+ /** The paragraph mark inserted and/or deleted as tracked changes. */
275
+ revision: nullableAttr(shape({ insertion: revision, deletion: revision })),
276
+ /** A tracked formatting change: the paragraph properties before it. */
277
+ formatChange: nullableAttr(shape({ ...revisionFields, previous: checkParagraphProperties }, [
278
+ "id",
279
+ "author",
280
+ "previous",
281
+ ])),
282
+ /** `w:p`'s own unknown attributes (`w14:paraId`, revision save ids…). */
283
+ attributes: nullableAttr(attributes),
284
+ },
285
+ },
286
+ /** Block content Foli does not model yet (tables until Phase 10…), kept verbatim. */
287
+ opaqueBlock: {
288
+ group: "block",
289
+ attrs: { xml: { validate: xml }, label: nullableAttr(text()) },
290
+ },
291
+ text: { group: "inline" },
292
+ tab: { group: "inline", inline: true },
293
+ hardBreak: {
294
+ group: "inline",
295
+ inline: true,
296
+ selectable: false,
297
+ attrs: { clear: nullableAttr(oneOf(["none", "left", "right", "all"])) },
298
+ },
299
+ pageBreak: { group: "inline", inline: true, selectable: false },
300
+ columnBreak: { group: "inline", inline: true, selectable: false },
301
+ /** A bookmark's ends (`w:bookmarkStart`/`End`): what cross-references and internal links point at. */
302
+ bookmarkStart: {
303
+ group: "inline",
304
+ inline: true,
305
+ selectable: false,
306
+ attrs: { id: { validate: ID }, name: { validate: str() }, ...markerAttributes },
307
+ },
308
+ bookmarkEnd: {
309
+ group: "inline",
310
+ inline: true,
311
+ selectable: false,
312
+ attrs: { id: { validate: ID }, ...markerAttributes },
313
+ },
314
+ /** Where a comment's range starts and ends (`w:commentRangeStart`/`End`), and its reference mark. */
315
+ commentStart: {
316
+ group: "inline",
317
+ inline: true,
318
+ selectable: false,
319
+ attrs: { id: { validate: ID }, ...markerAttributes },
320
+ },
321
+ commentEnd: {
322
+ group: "inline",
323
+ inline: true,
324
+ selectable: false,
325
+ attrs: { id: { validate: ID }, ...markerAttributes },
326
+ },
327
+ commentReference: {
328
+ group: "inline",
329
+ inline: true,
330
+ attrs: { id: { validate: ID }, ...markerAttributes },
331
+ },
332
+ /** Inline content Foli does not model yet (fields, drawings, symbols…), kept verbatim. */
333
+ opaqueInline: {
334
+ group: "inline",
335
+ inline: true,
336
+ attrs: {
337
+ xml: { validate: xml },
338
+ label: nullableAttr(text()),
339
+ /**
340
+ * Content of a run (`w:drawing`, `w:fldChar`… inside `w:r`): written back inside a run
341
+ * with the node's run properties. Otherwise it stands between runs (`w:sdt`…).
342
+ */
343
+ run: { default: false, validate: bool },
344
+ },
345
+ },
346
+ },
347
+ marks: {
348
+ // Order: the canonical order of mark sets, and of nesting when rendered (outermost first).
349
+ link: {
350
+ attrs: {
351
+ /**
352
+ * The target as the file has it (`file:`, network paths…): not checked here. Whether
353
+ * a link may be opened is decided where it is opened (`isSafeHref`).
354
+ */
355
+ href: markAttr(nullable(text(8192)), null),
356
+ /** A bookmark in this document (`w:anchor`). */
357
+ anchor: markAttr(nullable(text()), null),
358
+ tooltip: markAttr(nullable(str(1024)), null),
359
+ /** `w:hyperlink`'s other attributes (`w:history`, `w:tgtFrame`…). */
360
+ attributes: markAttr(nullable(attributes), null),
361
+ },
362
+ inclusive: false,
363
+ },
364
+ insertion: reviewMark,
365
+ deletion: reviewMark,
366
+ characterStyle: { attrs: { id: markAttr(text()) } },
367
+ bold: toggleWithComplexScript,
368
+ italic: toggleWithComplexScript,
369
+ underline: {
370
+ attrs: { style: markAttr(token, "single"), color: markAttr(nullable(color), null) },
371
+ },
372
+ strike: toggle,
373
+ doubleStrike: toggle,
374
+ caps: toggle,
375
+ smallCaps: toggle,
376
+ hidden: toggle,
377
+ font: {
378
+ attrs: {
379
+ ascii: fontName,
380
+ hAnsi: fontName,
381
+ eastAsia: fontName,
382
+ cs: fontName,
383
+ asciiTheme: themeFont,
384
+ hAnsiTheme: themeFont,
385
+ eastAsiaTheme: themeFont,
386
+ csTheme: themeFont,
387
+ hint: markAttr(nullable(oneOf(["default", "eastAsia", "cs"])), null),
388
+ },
389
+ },
390
+ /** In half-points (`w:sz`; 24 = 12 pt), and for complex scripts (`w:szCs`); either may be missing. */
391
+ fontSize: {
392
+ attrs: {
393
+ value: markAttr(nullable(int(1, 3276)), null),
394
+ complexScript: markAttr(nullable(int(1, 3276)), null),
395
+ },
396
+ },
397
+ color: {
398
+ attrs: {
399
+ value: markAttr(color),
400
+ themeColor: markAttr(nullable(token), null),
401
+ themeTint: markAttr(nullable(hexByte), null),
402
+ themeShade: markAttr(nullable(hexByte), null),
403
+ },
404
+ },
405
+ highlight: { attrs: { value: markAttr(oneOf(HIGHLIGHT_COLORS)) } },
406
+ shading: {
407
+ attrs: {
408
+ pattern: markAttr(token),
409
+ color: markAttr(color, "auto"),
410
+ fill: markAttr(color, "auto"),
411
+ },
412
+ },
413
+ verticalAlign: { attrs: { value: markAttr(oneOf(VERTICAL_ALIGNS)) } },
414
+ /** Character spacing in twips (`w:spacing`), expanded or condensed. */
415
+ characterSpacing: { attrs: { value: markAttr(twips) } },
416
+ /** A tracked formatting change: the run properties before it. */
417
+ formatChange: {
418
+ attrs: {
419
+ id: markAttr(ID),
420
+ author: markAttr(str()),
421
+ date: markAttr(nullable(date), null),
422
+ previous: markAttr(checkRunProperties),
423
+ },
424
+ },
425
+ /** The `w:rPr` these marks were read from, verbatim (see the module comment). */
426
+ runExt: { attrs: { xml: markAttr(xml) } },
427
+ },
428
+ });
429
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/v3/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,KAAK,EACL,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,GAAG,EACH,IAAI,EACJ,KAAK,EACL,GAAG,GACJ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,2CAA2C;AACrE,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACzC,MAAM,aAAa,GAAG,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACxC,wDAAwD;AACxD,MAAM,WAAW,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAE/C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM;IACN,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,YAAY;IACZ,eAAe;IACf,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,QAAQ;CACA,CAAC;AAGX,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM;IACN,QAAQ;IACR,OAAO;IACP,SAAS;IACT,KAAK;IACL,OAAO;IACP,KAAK;IACL,OAAO;IACP,KAAK;CACG,CAAC;AACX,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAA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EAAE;gBACL,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAChB,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;gBACpC,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC;aACvC;SACF;QACD,iFAAiF;QACjF,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE;KAC1C;CACF,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Word's units, as schema v3 stores them, and conversions for the API and the view.
3
+ * twip: 1/20 point, 1/1440 inch (page geometry, indentation, spacing, tab stops);
4
+ * half-point: font sizes; eighth of a point: border widths.
5
+ */
6
+ export declare const TWIPS_PER_INCH = 1440;
7
+ export declare const TWIPS_PER_POINT = 20;
8
+ /** Millimetres to whole twips (rounding: under 0.02 mm). */
9
+ export declare function mmToTwips(mm: number): number;
10
+ export declare function twipsToMm(twips: number): number;
11
+ export declare function twipsToPt(twips: number): number;
12
+ export declare function ptToTwips(pt: number): number;
13
+ /** CSS pixels (96 per inch). */
14
+ export declare function twipsToPx(twips: number): number;
15
+ export declare function halfPointsToPt(halfPoints: number): number;
16
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/v3/units.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,gCAAgC;AAChC,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Word's units, as schema v3 stores them, and conversions for the API and the view.
3
+ * twip: 1/20 point, 1/1440 inch (page geometry, indentation, spacing, tab stops);
4
+ * half-point: font sizes; eighth of a point: border widths.
5
+ */
6
+ export const TWIPS_PER_INCH = 1440;
7
+ export const TWIPS_PER_POINT = 20;
8
+ /** Millimetres to whole twips (rounding: under 0.02 mm). */
9
+ export function mmToTwips(mm) {
10
+ return Math.round((mm * TWIPS_PER_INCH) / 25.4);
11
+ }
12
+ export function twipsToMm(twips) {
13
+ return (twips * 25.4) / TWIPS_PER_INCH;
14
+ }
15
+ export function twipsToPt(twips) {
16
+ return twips / TWIPS_PER_POINT;
17
+ }
18
+ export function ptToTwips(pt) {
19
+ return Math.round(pt * TWIPS_PER_POINT);
20
+ }
21
+ /** CSS pixels (96 per inch). */
22
+ export function twipsToPx(twips) {
23
+ return (twips * 96) / TWIPS_PER_INCH;
24
+ }
25
+ export function halfPointsToPt(halfPoints) {
26
+ return halfPoints / 2;
27
+ }
28
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/v3/units.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,4DAA4D;AAC5D,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,cAAc,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK,GAAG,eAAe,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED,gCAAgC;AAChC,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,cAAc,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,GAAG,CAAC,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folijs/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Document model and headless editing engine of Foli: format, validation, schema, transactions, history, commands. No DOM.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/document.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { FoliDocumentError, type Node } from "./model/index.js";
2
- import { type DocJSON, schema } from "./schema.js";
2
+ import { type DocJSON, schemaV2 } from "./schema.js";
3
3
 
4
4
  /**
5
- * Bump when the persisted envelope or content schema changes; add a migration from the previous
6
- * version to MIGRATIONS. A published version never changes in place: documents saved with it
7
- * exist (v1: 0.1.0).
5
+ * Schema v2 (0.2.0) and v1 (0.1.0): kept to read documents saved with them, which
6
+ * `parseDocument` migrates to the current schema (v3). A published version never changes in
7
+ * place: documents saved with it exist.
8
8
  */
9
- export const SCHEMA_VERSION = 2;
9
+ const VERSION = 2;
10
10
 
11
11
  type Envelope = Record<string, unknown>;
12
12
 
13
13
  /**
14
- * `MIGRATIONS[n]` turns a version-n envelope into version n + 1; `parseDocument` runs them in
15
- * order, then validates against the current schema. Migrations never drop content.
14
+ * `MIGRATIONS[n]` turns a version-n envelope into version n + 1; `parseDocumentV2` runs them in
15
+ * order, then validates against schema v2. Migrations never drop content.
16
16
  */
17
17
  const MIGRATIONS: Readonly<Record<number, (doc: Envelope) => Envelope>> = {
18
18
  // v2 adds lists, horizontal rules, links, text color, highlight and alignment. Every v1
@@ -38,9 +38,9 @@ export interface DocumentSettings {
38
38
  margins: PageMargins;
39
39
  }
40
40
 
41
- /** The persisted document: a versioned envelope around the content tree. */
42
- export interface FoliDocument {
43
- schemaVersion: typeof SCHEMA_VERSION;
41
+ /** A document saved by 0.2.0 (schema v2): what `parseDocument` reads and migrates. */
42
+ export interface FoliDocumentV2 {
43
+ schemaVersion: 2;
44
44
  settings: DocumentSettings;
45
45
  content: DocJSON;
46
46
  }
@@ -55,45 +55,45 @@ export const DEFAULT_SETTINGS: DocumentSettings = {
55
55
  margins: { top: 25.4, right: 25.4, bottom: 25.4, left: 25.4 },
56
56
  };
57
57
 
58
- export function createDocument(
58
+ /** A schema v2 document, for tests of migration and of editing migrated documents. */
59
+ export function createDocumentV2(
59
60
  content: DocJSON = { type: "doc", content: [{ type: "paragraph" }] },
60
61
  settings: Partial<DocumentSettings> = {},
61
- ): FoliDocument {
62
- return { schemaVersion: SCHEMA_VERSION, settings: { ...DEFAULT_SETTINGS, ...settings }, content };
62
+ ): FoliDocumentV2 {
63
+ return { schemaVersion: VERSION, settings: { ...DEFAULT_SETTINGS, ...settings }, content };
63
64
  }
64
65
 
65
66
  /**
66
- * Validates untrusted input (e.g. JSON loaded from storage) against the schema and returns a
67
- * FoliDocument with content in canonical form (see docs/document-model.md, "Normalization").
68
- * Throws FoliDocumentError instead of silently dropping invalid content.
67
+ * Validates a schema v1 or v2 document against schema v2 and returns it as v2, content in
68
+ * canonical form. Throws FoliDocumentError instead of silently dropping invalid content.
69
69
  */
70
- export function parseDocument(input: unknown): FoliDocument {
70
+ export function parseDocumentV2(input: unknown): FoliDocumentV2 {
71
71
  if (!isRecord(input)) throw new FoliDocumentError("Document must be an object");
72
72
  const version = input.schemaVersion;
73
73
  if (!Number.isInteger(version) || (version as number) < 1) {
74
74
  throw new FoliDocumentError(`Unsupported schemaVersion: ${String(version)}`);
75
75
  }
76
- if ((version as number) > SCHEMA_VERSION) {
76
+ if ((version as number) > VERSION) {
77
77
  throw new FoliDocumentError(
78
78
  `Unsupported schemaVersion: ${version} (this version of @folijs/core reads 1 to ` +
79
- `${SCHEMA_VERSION}; the document was saved by a newer one)`,
79
+ `${VERSION}; the document was saved by a newer one)`,
80
80
  );
81
81
  }
82
82
  let doc: Envelope = input;
83
- for (let v = version as number; v < SCHEMA_VERSION; v++) {
83
+ for (let v = version as number; v < VERSION; v++) {
84
84
  const migrate = MIGRATIONS[v];
85
85
  if (!migrate) throw new FoliDocumentError(`No migration from schemaVersion ${v}`);
86
86
  doc = migrate(doc);
87
87
  }
88
88
  const settings = parseSettings(doc.settings);
89
- const content = parseContent(doc.content).toJSON() as DocJSON;
90
- return { schemaVersion: SCHEMA_VERSION, settings, content };
89
+ const content = parseContentV2(doc.content).toJSON() as DocJSON;
90
+ return { schemaVersion: VERSION, settings, content };
91
91
  }
92
92
 
93
- /** Parses untrusted content JSON into a `doc` node of the current schema (v2). */
94
- export function parseContent(value: unknown, path = "content"): Node {
95
- const doc = schema.nodeFromJSON(value, path);
96
- if (doc.type !== schema.topNodeType) {
93
+ /** Parses untrusted content JSON into a `doc` node of schema v2. */
94
+ export function parseContentV2(value: unknown, path = "content"): Node {
95
+ const doc = schemaV2.nodeFromJSON(value, path);
96
+ if (doc.type !== schemaV2.topNodeType) {
97
97
  throw new FoliDocumentError(`${path}: root node must be of type "doc"`);
98
98
  }
99
99
  // The root has no parent to check its marks against.
package/src/index.ts CHANGED
@@ -1,14 +1,11 @@
1
1
  export {
2
- createDocument,
3
2
  DEFAULT_SETTINGS,
4
3
  type DocumentSettings,
5
- type FoliDocument,
4
+ type FoliDocumentV2,
6
5
  PAGE_SIZES,
7
6
  type PageMargins,
8
7
  type PageSize,
9
- parseContent,
10
- parseDocument,
11
- SCHEMA_VERSION,
8
+ parseContentV2,
12
9
  } from "./document.js";
13
10
  export * from "./model/index.js";
14
11
  export {
@@ -38,8 +35,8 @@ export {
38
35
  SIMPLE_MARK_TYPES,
39
36
  type SimpleMarkJSON,
40
37
  type SimpleMarkName,
41
- schema,
42
38
  type TextJSON,
43
39
  } from "./schema.js";
44
40
  export * from "./state/index.js";
45
41
  export * from "./transform/index.js";
42
+ export * from "./v3/index.js";