@stll/folio-core 0.22.3 → 0.23.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 (40) hide show
  1. package/dist/ai-edits/apply.d.ts +1 -1
  2. package/dist/document-operations.d.ts +4 -4
  3. package/dist/document-operations.js +17 -1
  4. package/dist/docx/rezip.d.ts +1 -1
  5. package/dist/docx/rezip.js +12 -31
  6. package/dist/layout-bridge/convert/toFlowBlocks.js +35 -61
  7. package/dist/layout-painter/imageLayout.d.ts +1 -1
  8. package/dist/managers/AutoSaveManager.js +8 -40
  9. package/dist/managers/TableSelectionManager.d.ts +1 -1
  10. package/dist/managers/autoSaveCodec.d.ts +17 -0
  11. package/dist/managers/autoSaveCodec.js +109 -0
  12. package/dist/prosemirror/attrs/index.js +273 -25
  13. package/dist/prosemirror/commands/comments.js +3 -3
  14. package/dist/prosemirror/commands/formatting.js +19 -19
  15. package/dist/prosemirror/commands/index.d.ts +2 -2
  16. package/dist/prosemirror/commands/paragraph.js +32 -32
  17. package/dist/prosemirror/commands/propertyChangeScope.d.ts +4 -2
  18. package/dist/prosemirror/commands/propertyChangeScope.js +8 -8
  19. package/dist/prosemirror/commands/table.d.ts +10 -52
  20. package/dist/prosemirror/commands/table.js +34 -34
  21. package/dist/prosemirror/conversion/fromProseDoc.js +20 -17
  22. package/dist/prosemirror/conversion/sdtAttrs.d.ts +2 -1
  23. package/dist/prosemirror/conversion/sdtAttrs.js +9 -4
  24. package/dist/prosemirror/extensions/ExtensionManager.d.ts +6 -3
  25. package/dist/prosemirror/extensions/ExtensionManager.js +5 -3
  26. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +1 -1
  27. package/dist/prosemirror/extensions/features/ListExtension.js +4 -4
  28. package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +1 -1
  29. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +1 -1
  30. package/dist/prosemirror/extensions/types.d.ts +134 -1
  31. package/dist/prosemirror/index.d.ts +2 -2
  32. package/dist/prosemirror/plugins/selectionTracker.js +25 -99
  33. package/dist/prosemirror/revisionCarriers.js +3 -1
  34. package/dist/prosemirror/schema/index.d.ts +2 -2
  35. package/dist/prosemirror/schema/index.js +87 -0
  36. package/dist/prosemirror/schema/nodes.d.ts +13 -2
  37. package/dist/prosemirror/selectionState.d.ts +11 -5
  38. package/dist/prosemirror/selectionState.js +94 -57
  39. package/dist/utils/tableOperations.d.ts +7 -6
  40. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { FIELD_TYPE_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES, OUTLINE_STYLE_ATTR_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
1
+ import { EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
2
2
  import { isParagraphDirection } from "../paragraphDirection.js";
3
3
  import { TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
4
4
  import { panic } from "better-result";
@@ -89,21 +89,6 @@ const RUN_FORMATTING_OVERRIDE_FALSE_KEYS = [
89
89
  "shadow",
90
90
  "outline"
91
91
  ];
92
- const TEXT_FORMATTING_BOOLEAN_KEYS = [
93
- "bold",
94
- "boldCs",
95
- "italic",
96
- "italicCs",
97
- "strike",
98
- "doubleStrike",
99
- "smallCaps",
100
- "allCaps",
101
- "hidden",
102
- "emboss",
103
- "imprint",
104
- "shadow",
105
- "outline"
106
- ];
107
92
  const SECTION_ORIENTATIONS = ["portrait", "landscape"];
108
93
  const SECTION_START_TYPES = [
109
94
  "continuous",
@@ -160,6 +145,7 @@ const readParagraphAttrs = (node) => {
160
145
  optionalBoolean(attrs, "kinsoku", "paragraph.attrs.kinsoku", issues);
161
146
  optionalBoolean(attrs, "overflowPunctuation", "paragraph.attrs.overflowPunctuation", issues);
162
147
  optionalBoolean(attrs, "suppressAutoHyphens", "paragraph.attrs.suppressAutoHyphens", issues);
148
+ optionalBoolean(attrs, "suppressLineNumbers", "paragraph.attrs.suppressLineNumbers", issues);
163
149
  optionalNumber(attrs, "spaceBefore", "paragraph.attrs.spaceBefore", issues);
164
150
  optionalNumber(attrs, "spaceAfter", "paragraph.attrs.spaceAfter", issues);
165
151
  optionalNumber(attrs, "lineSpacing", "paragraph.attrs.lineSpacing", issues);
@@ -192,9 +178,11 @@ const readParagraphAttrs = (node) => {
192
178
  optionalBoolean(attrs, "pageBreakBefore", "paragraph.attrs.pageBreakBefore", issues);
193
179
  optionalBoolean(attrs, "renderedPageBreakBefore", "paragraph.attrs.renderedPageBreakBefore", issues);
194
180
  optionalBoolean(attrs, "_trailingPageBreak", "paragraph.attrs._trailingPageBreak", issues);
181
+ optionalBoolean(attrs, "_pageBreakCarrier", "paragraph.attrs._pageBreakCarrier", issues);
195
182
  optionalBoolean(attrs, "runInWithNext", "paragraph.attrs.runInWithNext", issues);
196
183
  optionalBoolean(attrs, "keepNext", "paragraph.attrs.keepNext", issues);
197
184
  optionalBoolean(attrs, "keepLines", "paragraph.attrs.keepLines", issues);
185
+ optionalBoolean(attrs, "widowControl", "paragraph.attrs.widowControl", issues);
198
186
  optionalBoolean(attrs, "contextualSpacing", "paragraph.attrs.contextualSpacing", issues);
199
187
  const direction = attrs["direction"];
200
188
  if (direction !== void 0 && direction !== null && !isParagraphDirection(direction)) issues.push({
@@ -223,7 +211,7 @@ const readParagraphAttrs = (node) => {
223
211
  validateNumPr(attrs["numPr"], issues);
224
212
  optionalBookmarkArray(attrs["bookmarks"], issues);
225
213
  optionalEmptyHyperlinkArray(attrs["_emptyHyperlinks"], issues);
226
- optionalAutospacingBase(attrs, issues);
214
+ optionalAutospacingBase(attrs, "paragraph.attrs._autospacingBase", issues);
227
215
  optionalSectionProperties(attrs, "_sectionProperties", "paragraph.attrs._sectionProperties", issues);
228
216
  optionalPropertyChanges(attrs, "_propertyChanges", "paragraph.attrs._propertyChanges", issues, ["paragraphPropertyChange"]);
229
217
  return attrsResult(attrs, issues);
@@ -1089,18 +1077,18 @@ const validateSdtAttrsRecord = (attrs, path, issues) => {
1089
1077
  optionalString(attrs, "rawPropertiesXml", `${path}.rawPropertiesXml`, issues);
1090
1078
  optionalString(attrs, "rawEndPropertiesXml", `${path}.rawEndPropertiesXml`, issues);
1091
1079
  };
1092
- const optionalAutospacingBase = (attrs, issues) => {
1080
+ const optionalAutospacingBase = (attrs, path, issues) => {
1093
1081
  const value = attrs["_autospacingBase"];
1094
1082
  if (value === void 0 || value === null) return;
1095
1083
  if (!isRecord(value)) {
1096
1084
  issues.push({
1097
- path: "paragraph.attrs._autospacingBase",
1085
+ path,
1098
1086
  message: "Expected an object."
1099
1087
  });
1100
1088
  return;
1101
1089
  }
1102
- optionalNumber(value, "before", "paragraph.attrs._autospacingBase.before", issues);
1103
- optionalNumber(value, "after", "paragraph.attrs._autospacingBase.after", issues);
1090
+ optionalNumber(value, "before", `${path}.before`, issues);
1091
+ optionalNumber(value, "after", `${path}.after`, issues);
1104
1092
  };
1105
1093
  const optionalArray = (attrs, key, path, issues) => {
1106
1094
  const value = attrs[key];
@@ -1201,11 +1189,42 @@ const optionalTextFormatting = (attrs, key, path, issues) => {
1201
1189
  });
1202
1190
  return;
1203
1191
  }
1204
- for (const booleanKey of TEXT_FORMATTING_BOOLEAN_KEYS) optionalBoolean(value, booleanKey, `${path}.${booleanKey}`, issues);
1192
+ validateTextFormatting(value, path, issues);
1193
+ };
1194
+ const validateTextFormatting = (value, path, issues) => {
1195
+ for (const booleanKey of [
1196
+ "bold",
1197
+ "boldCs",
1198
+ "italic",
1199
+ "italicCs",
1200
+ "strike",
1201
+ "doubleStrike",
1202
+ "smallCaps",
1203
+ "allCaps",
1204
+ "hidden",
1205
+ "emboss",
1206
+ "imprint",
1207
+ "outline",
1208
+ "shadow",
1209
+ "rtl",
1210
+ "cs"
1211
+ ]) optionalBoolean(value, booleanKey, `${path}.${booleanKey}`, issues);
1212
+ optionalOneOf(value, "vertAlign", `${path}.vertAlign`, issues, [
1213
+ "baseline",
1214
+ "superscript",
1215
+ "subscript"
1216
+ ]);
1205
1217
  optionalNumber(value, "fontSize", `${path}.fontSize`, issues);
1206
1218
  optionalNumber(value, "fontSizeCs", `${path}.fontSizeCs`, issues);
1207
- optionalOneOf(value, "highlight", `${path}.highlight`, issues, HIGHLIGHT_COLOR_VALUES);
1219
+ optionalNumber(value, "spacing", `${path}.spacing`, issues);
1220
+ optionalNumber(value, "position", `${path}.position`, issues);
1221
+ optionalNumber(value, "scale", `${path}.scale`, issues);
1222
+ optionalNumber(value, "kerning", `${path}.kerning`, issues);
1223
+ optionalString(value, "styleId", `${path}.styleId`, issues);
1224
+ optionalOneOf(value, "effect", `${path}.effect`, issues, TEXT_EFFECT_VALUES);
1225
+ optionalOneOf(value, "emphasisMark", `${path}.emphasisMark`, issues, EMPHASIS_MARK_VALUES);
1208
1226
  optionalColorValue(value, "color", `${path}.color`, issues);
1227
+ optionalOneOf(value, "highlight", `${path}.highlight`, issues, HIGHLIGHT_COLOR_VALUES);
1209
1228
  optionalShading(value, "shading", `${path}.shading`, issues);
1210
1229
  const underline = value["underline"];
1211
1230
  if (underline !== void 0 && underline !== null) if (!isRecord(underline)) issues.push({
@@ -1216,6 +1235,36 @@ const optionalTextFormatting = (attrs, key, path, issues) => {
1216
1235
  requiredOneOf(underline, "style", `${path}.underline.style`, issues, UNDERLINE_STYLE_VALUES);
1217
1236
  optionalColorValue(underline, "color", `${path}.underline.color`, issues);
1218
1237
  }
1238
+ const fontFamily = value["fontFamily"];
1239
+ if (fontFamily !== void 0 && fontFamily !== null) if (!isRecord(fontFamily)) issues.push({
1240
+ path: `${path}.fontFamily`,
1241
+ message: "Expected an object."
1242
+ });
1243
+ else {
1244
+ for (const key of [
1245
+ "ascii",
1246
+ "hAnsi",
1247
+ "eastAsia",
1248
+ "cs"
1249
+ ]) optionalString(fontFamily, key, `${path}.fontFamily.${key}`, issues);
1250
+ optionalOneOf(fontFamily, "hint", `${path}.fontFamily.hint`, issues, FONT_HINT_VALUES);
1251
+ for (const key of [
1252
+ "asciiTheme",
1253
+ "hAnsiTheme",
1254
+ "eastAsiaTheme",
1255
+ "csTheme"
1256
+ ]) optionalOneOf(fontFamily, key, `${path}.fontFamily.${key}`, issues, FONT_THEME_VALUES);
1257
+ }
1258
+ const language = value["language"];
1259
+ if (language !== void 0 && language !== null) if (!isRecord(language)) issues.push({
1260
+ path: `${path}.language`,
1261
+ message: "Expected an object."
1262
+ });
1263
+ else for (const key of [
1264
+ "val",
1265
+ "eastAsia",
1266
+ "bidi"
1267
+ ]) optionalString(language, key, `${path}.language.${key}`, issues);
1219
1268
  };
1220
1269
  const optionalInsetMap = (attrs, key, path, issues) => {
1221
1270
  const value = attrs[key];
@@ -1285,8 +1334,192 @@ const optionalPropertyChanges = (attrs, key, path, issues, allowedTypes) => {
1285
1334
  }
1286
1335
  requiredOneOf(item, "type", `${itemPath}.type`, issues, allowedTypes);
1287
1336
  validatePropertyChangeInfo(item["info"], `${itemPath}.info`, issues);
1288
- optionalRecord(item, "previousFormatting", `${itemPath}.previousFormatting`, issues);
1289
- optionalRecord(item, "currentFormatting", `${itemPath}.currentFormatting`, issues);
1337
+ let validateFormatting;
1338
+ if (allowedTypes.includes("paragraphPropertyChange")) validateFormatting = validateParagraphFormatting;
1339
+ else if (allowedTypes.includes("runPropertyChange")) validateFormatting = validateTextFormatting;
1340
+ if (validateFormatting) {
1341
+ optionalNestedRecord(item, "previousFormatting", `${itemPath}.previousFormatting`, issues, validateFormatting);
1342
+ optionalNestedRecord(item, "currentFormatting", `${itemPath}.currentFormatting`, issues, validateFormatting);
1343
+ } else {
1344
+ optionalRecord(item, "previousFormatting", `${itemPath}.previousFormatting`, issues);
1345
+ optionalRecord(item, "currentFormatting", `${itemPath}.currentFormatting`, issues);
1346
+ }
1347
+ }
1348
+ };
1349
+ const optionalNestedRecord = (attrs, key, path, issues, validate) => {
1350
+ const value = attrs[key];
1351
+ if (value === void 0 || value === null) return;
1352
+ if (!isRecord(value)) {
1353
+ issues.push({
1354
+ path,
1355
+ message: "Expected an object."
1356
+ });
1357
+ return;
1358
+ }
1359
+ validate(value, path, issues);
1360
+ };
1361
+ const PARAGRAPH_FORMATTING_BOOLEAN_KEYS = [
1362
+ "bidi",
1363
+ "kinsoku",
1364
+ "overflowPunctuation",
1365
+ "suppressAutoHyphens",
1366
+ "suppressLineNumbers",
1367
+ "snapToGrid",
1368
+ "beforeAutospacing",
1369
+ "afterAutospacing",
1370
+ "hangingIndent",
1371
+ "keepNext",
1372
+ "keepLines",
1373
+ "widowControl",
1374
+ "pageBreakBefore",
1375
+ "contextualSpacing",
1376
+ "runInWithNext"
1377
+ ];
1378
+ const PARAGRAPH_FORMATTING_NUMBER_KEYS = [
1379
+ "spaceBefore",
1380
+ "spaceAfter",
1381
+ "lineSpacing",
1382
+ "indentLeft",
1383
+ "indentRight",
1384
+ "indentFirstLine",
1385
+ "outlineLevel"
1386
+ ];
1387
+ const validateParagraphFormatting = (value, path, issues) => {
1388
+ optionalOneOf(value, "alignment", `${path}.alignment`, issues, PARAGRAPH_ALIGNMENT_VALUES);
1389
+ for (const key of PARAGRAPH_FORMATTING_BOOLEAN_KEYS) optionalBoolean(value, key, `${path}.${key}`, issues);
1390
+ for (const key of [
1391
+ "lineSpacingExplicit",
1392
+ "listIsBullet",
1393
+ "listIsLegal",
1394
+ "listMarkerHidden",
1395
+ "listMarkerBold",
1396
+ "listMarkerAllCaps"
1397
+ ]) optionalBoolean(value, key, `${path}.${key}`, issues);
1398
+ for (const key of PARAGRAPH_FORMATTING_NUMBER_KEYS) optionalNumber(value, key, `${path}.${key}`, issues);
1399
+ for (const key of [
1400
+ "listMarkerFontSize",
1401
+ "listImplicitChildLevelAdvances",
1402
+ "listMarkerSecondSlotOffsetTwips",
1403
+ "listAbstractNumId",
1404
+ "listStartOverride"
1405
+ ]) optionalNumber(value, key, `${path}.${key}`, issues);
1406
+ optionalOneOf(value, "lineSpacingRule", `${path}.lineSpacingRule`, issues, LINE_SPACING_RULE_VALUES);
1407
+ optionalString(value, "styleId", `${path}.styleId`, issues);
1408
+ optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, NUMBER_FORMAT_VALUES);
1409
+ optionalString(value, "listMarker", `${path}.listMarker`, issues);
1410
+ optionalString(value, "listMarkerFontFamily", `${path}.listMarkerFontFamily`, issues);
1411
+ optionalOneOf(value, "listMarkerAlignment", `${path}.listMarkerAlignment`, issues, [
1412
+ "left",
1413
+ "center",
1414
+ "right"
1415
+ ]);
1416
+ optionalOneOf(value, "listMarkerSuffix", `${path}.listMarkerSuffix`, issues, [
1417
+ "tab",
1418
+ "space",
1419
+ "nothing"
1420
+ ]);
1421
+ optionalOneOfArray(value, "listLevelNumFmts", `${path}.listLevelNumFmts`, issues, NUMBER_FORMAT_VALUES);
1422
+ optionalNumberArray(value, "listLevelStarts", `${path}.listLevelStarts`, issues);
1423
+ optionalAutospacingBase(value, `${path}._autospacingBase`, issues);
1424
+ for (const key of ["numPr", "numPrFromStyle"]) {
1425
+ const nested = value[key];
1426
+ if (nested === void 0 || nested === null) continue;
1427
+ if (!isRecord(nested)) {
1428
+ issues.push({
1429
+ path: `${path}.${key}`,
1430
+ message: "Expected an object."
1431
+ });
1432
+ continue;
1433
+ }
1434
+ optionalNumber(nested, "numId", `${path}.${key}.numId`, issues);
1435
+ optionalNumber(nested, "ilvl", `${path}.${key}.ilvl`, issues);
1436
+ }
1437
+ const direction = value["direction"];
1438
+ if (direction !== void 0 && direction !== null && !isParagraphDirection(direction)) issues.push({
1439
+ path: `${path}.direction`,
1440
+ message: "Expected a ParagraphDirection."
1441
+ });
1442
+ for (const key of [
1443
+ "spacingExplicit",
1444
+ "spacingFromDocDefaults",
1445
+ "spacingFromImplicitDefaultStyle"
1446
+ ]) {
1447
+ const nested = value[key];
1448
+ if (nested === void 0 || nested === null) continue;
1449
+ if (!isRecord(nested)) {
1450
+ issues.push({
1451
+ path: `${path}.${key}`,
1452
+ message: "Expected an object."
1453
+ });
1454
+ continue;
1455
+ }
1456
+ optionalBoolean(nested, "before", `${path}.${key}.before`, issues);
1457
+ optionalBoolean(nested, "after", `${path}.${key}.after`, issues);
1458
+ }
1459
+ optionalBorderMap(value, "borders", `${path}.borders`, issues, [
1460
+ "top",
1461
+ "bottom",
1462
+ "left",
1463
+ "right",
1464
+ "between",
1465
+ "bar"
1466
+ ]);
1467
+ optionalShading(value, "shading", `${path}.shading`, issues);
1468
+ optionalTabStops(value, "tabs", `${path}.tabs`, issues);
1469
+ optionalNestedRecord(value, "runProperties", `${path}.runProperties`, issues, validateTextFormatting);
1470
+ const frame = value["frame"];
1471
+ if (frame !== void 0 && frame !== null) if (!isRecord(frame)) issues.push({
1472
+ path: `${path}.frame`,
1473
+ message: "Expected an object."
1474
+ });
1475
+ else {
1476
+ optionalOneOf(frame, "dropCap", `${path}.frame.dropCap`, issues, [
1477
+ "none",
1478
+ "drop",
1479
+ "margin"
1480
+ ]);
1481
+ optionalOneOf(frame, "hAnchor", `${path}.frame.hAnchor`, issues, [
1482
+ "text",
1483
+ "margin",
1484
+ "page"
1485
+ ]);
1486
+ optionalOneOf(frame, "vAnchor", `${path}.frame.vAnchor`, issues, [
1487
+ "text",
1488
+ "margin",
1489
+ "page"
1490
+ ]);
1491
+ optionalOneOf(frame, "xAlign", `${path}.frame.xAlign`, issues, [
1492
+ "left",
1493
+ "center",
1494
+ "right",
1495
+ "inside",
1496
+ "outside"
1497
+ ]);
1498
+ optionalOneOf(frame, "yAlign", `${path}.frame.yAlign`, issues, [
1499
+ "top",
1500
+ "center",
1501
+ "bottom",
1502
+ "inside",
1503
+ "outside",
1504
+ "inline"
1505
+ ]);
1506
+ optionalOneOf(frame, "wrap", `${path}.frame.wrap`, issues, [
1507
+ "around",
1508
+ "auto",
1509
+ "none",
1510
+ "notBeside",
1511
+ "through",
1512
+ "tight"
1513
+ ]);
1514
+ for (const key of [
1515
+ "lines",
1516
+ "width",
1517
+ "height",
1518
+ "hSpace",
1519
+ "vSpace",
1520
+ "x",
1521
+ "y"
1522
+ ]) optionalNumber(frame, key, `${path}.frame.${key}`, issues);
1290
1523
  }
1291
1524
  };
1292
1525
  const validatePropertyChangeInfo = (value, path, issues) => {
@@ -1373,6 +1606,21 @@ const optionalStringArray = (attrs, key, path, issues) => {
1373
1606
  message: "Expected a string."
1374
1607
  });
1375
1608
  };
1609
+ const optionalOneOfArray = (attrs, key, path, issues, allowed) => {
1610
+ const value = attrs[key];
1611
+ if (value === void 0 || value === null) return;
1612
+ if (!Array.isArray(value)) {
1613
+ issues.push({
1614
+ path,
1615
+ message: "Expected an array."
1616
+ });
1617
+ return;
1618
+ }
1619
+ for (const [index, item] of value.entries()) if (typeof item !== "string" || !allowed.includes(item)) issues.push({
1620
+ path: `${path}[${index}]`,
1621
+ message: `Expected one of ${allowed.join(", ")}.`
1622
+ });
1623
+ };
1376
1624
  const validateNumPr = (value, issues) => {
1377
1625
  if (value === void 0 || value === null || !isRecord(value)) return;
1378
1626
  validateNonNegativeInteger(value["numId"], "paragraph.attrs.numPr.numId", issues);
@@ -1,4 +1,4 @@
1
- import { expectRunPropertyChangeMarkAttrs } from "../attrs/index.js";
1
+ import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs } from "../attrs/index.js";
2
2
  import { textFormattingToMarks } from "../conversion/toProseDoc.js";
3
3
  import { markStructuralChange } from "../extensions/features/ParagraphChangeTrackerExtension.js";
4
4
  import { getFolioNodeRevisionCarriers } from "../revisionCarriers.js";
@@ -72,7 +72,7 @@ function resolveChange(from, to, mode, revisionIds) {
72
72
  if (op) pPrMarkOps.push(op);
73
73
  const boundaryCovered = rangeCoversParagraphBoundary(from, to, pos, node);
74
74
  let nextAttrs = null;
75
- const propertyChanges = node.attrs["_propertyChanges"];
75
+ const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
76
76
  if (Array.isArray(propertyChanges) && propertyChanges.length > 0 && boundaryCovered) {
77
77
  const matches = propertyChanges.filter((c) => revisionSet === null || c.info && revisionSet.has(c.info.id));
78
78
  if (matches.length > 0) {
@@ -418,7 +418,7 @@ function findParagraphBoundaryChangeAtPosition(state, pos) {
418
418
  const paragraphPos = $pos.before($pos.depth);
419
419
  const pPrMark = node.attrs["pPrMark"];
420
420
  if (isPPrMarkAttr(pPrMark)) return toParagraphBoundaryChange(node, paragraphPos, pPrMark.kind === "ins" ? "insertion" : "deletion", pPrMark.info);
421
- const propertyChanges = node.attrs["_propertyChanges"];
421
+ const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
422
422
  if (!Array.isArray(propertyChanges)) return null;
423
423
  for (const change of propertyChanges) {
424
424
  const type = getListPropertyChangeType(node.attrs, change);
@@ -8,38 +8,38 @@ import { schema, singletonManager } from "../schema/index.js";
8
8
  function textFormattingToMarks(formatting) {
9
9
  return textFormattingToMarks$1(formatting, schema);
10
10
  }
11
- const cmds = singletonManager.getCommands();
12
- const toggleBold = cmds["toggleBold"]();
13
- const toggleItalic = cmds["toggleItalic"]();
14
- const toggleUnderline = cmds["toggleUnderline"]();
15
- const toggleStrike = cmds["toggleStrike"]();
16
- const toggleSuperscript = cmds["toggleSuperscript"]();
17
- const toggleSubscript = cmds["toggleSubscript"]();
11
+ const cmds = singletonManager;
12
+ const toggleBold = cmds.requireCommand("toggleBold")();
13
+ const toggleItalic = cmds.requireCommand("toggleItalic")();
14
+ const toggleUnderline = cmds.requireCommand("toggleUnderline")();
15
+ const toggleStrike = cmds.requireCommand("toggleStrike")();
16
+ const toggleSuperscript = cmds.requireCommand("toggleSuperscript")();
17
+ const toggleSubscript = cmds.requireCommand("toggleSubscript")();
18
18
  function setTextColor(attrs) {
19
- return cmds["setTextColor"](attrs);
19
+ return cmds.requireCommand("setTextColor")(attrs);
20
20
  }
21
- const clearTextColor = cmds["clearTextColor"]();
21
+ const clearTextColor = cmds.requireCommand("clearTextColor")();
22
22
  function setHighlight(color) {
23
- return cmds["setHighlight"](color);
23
+ return cmds.requireCommand("setHighlight")(color);
24
24
  }
25
- const clearHighlight = cmds["clearHighlight"]();
25
+ const clearHighlight = cmds.requireCommand("clearHighlight")();
26
26
  function setFontSize(size) {
27
- return cmds["setFontSize"](size);
27
+ return cmds.requireCommand("setFontSize")(size);
28
28
  }
29
- const clearFontSize = cmds["clearFontSize"]();
29
+ const clearFontSize = cmds.requireCommand("clearFontSize")();
30
30
  function setFontFamily(fontName) {
31
- return cmds["setFontFamily"](fontName);
31
+ return cmds.requireCommand("setFontFamily")(fontName);
32
32
  }
33
- const clearFontFamily = cmds["clearFontFamily"]();
33
+ const clearFontFamily = cmds.requireCommand("clearFontFamily")();
34
34
  function setUnderlineStyle(style, color) {
35
- return cmds["setUnderlineStyle"](style, color);
35
+ return cmds.requireCommand("setUnderlineStyle")(style, color);
36
36
  }
37
37
  function setHyperlink(href, tooltip) {
38
- return cmds["setHyperlink"](href, tooltip);
38
+ return cmds.requireCommand("setHyperlink")(href, tooltip);
39
39
  }
40
- const removeHyperlink = cmds["removeHyperlink"]();
40
+ const removeHyperlink = cmds.requireCommand("removeHyperlink")();
41
41
  function insertHyperlink(text, href, tooltip) {
42
- return cmds["insertHyperlink"](text, href, tooltip);
42
+ return cmds.requireCommand("insertHyperlink")(text, href, tooltip);
43
43
  }
44
44
  //#endregion
45
45
  export { clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, getHyperlinkAttrs, getMarkAttr, getSelectedText, insertHyperlink, isHyperlinkActive, isMarkActive, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, textFormattingToMarks, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
@@ -1,12 +1,12 @@
1
+ import { ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
2
+ import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
1
3
  import { AcceptSuggestionOptions, FolioSuggestion, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
2
4
  import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
3
5
  import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
4
6
  import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
5
7
  import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
6
- import { ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
7
8
  import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
8
9
  import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTOC, increaseIndent, increaseListLevel, oneAndHalfSpacing, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList } from "./paragraph.js";
9
- import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
10
10
  import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
11
11
  import { insertPageBreak } from "./pageBreak.js";
12
12
  import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
@@ -2,63 +2,63 @@ import { getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId }
2
2
  import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
3
3
  import { singletonManager } from "../schema/index.js";
4
4
  //#region src/prosemirror/commands/paragraph.ts
5
- const cmds = singletonManager.getCommands();
5
+ const cmds = singletonManager;
6
6
  function setAlignment(alignment) {
7
- return cmds["setAlignment"](alignment);
7
+ return cmds.requireCommand("setAlignment")(alignment);
8
8
  }
9
- const alignLeft = cmds["alignLeft"]();
10
- const alignCenter = cmds["alignCenter"]();
11
- const alignRight = cmds["alignRight"]();
12
- const alignJustify = cmds["alignJustify"]();
9
+ const alignLeft = cmds.requireCommand("alignLeft")();
10
+ const alignCenter = cmds.requireCommand("alignCenter")();
11
+ const alignRight = cmds.requireCommand("alignRight")();
12
+ const alignJustify = cmds.requireCommand("alignJustify")();
13
13
  function setLineSpacing(value, rule = "auto") {
14
- return cmds["setLineSpacing"](value, rule);
14
+ return cmds.requireCommand("setLineSpacing")(value, rule);
15
15
  }
16
- const singleSpacing = cmds["singleSpacing"]();
17
- const oneAndHalfSpacing = cmds["oneAndHalfSpacing"]();
18
- const doubleSpacing = cmds["doubleSpacing"]();
16
+ const singleSpacing = cmds.requireCommand("singleSpacing")();
17
+ const oneAndHalfSpacing = cmds.requireCommand("oneAndHalfSpacing")();
18
+ const doubleSpacing = cmds.requireCommand("doubleSpacing")();
19
19
  function increaseIndent(amount = 720) {
20
- return cmds["increaseIndent"](amount);
20
+ return cmds.requireCommand("increaseIndent")(amount);
21
21
  }
22
22
  function decreaseIndent(amount = 720) {
23
- return cmds["decreaseIndent"](amount);
23
+ return cmds.requireCommand("decreaseIndent")(amount);
24
24
  }
25
25
  function setIndentLeft(twips) {
26
- return cmds["setIndentLeft"](twips);
26
+ return cmds.requireCommand("setIndentLeft")(twips);
27
27
  }
28
28
  function setIndentRight(twips) {
29
- return cmds["setIndentRight"](twips);
29
+ return cmds.requireCommand("setIndentRight")(twips);
30
30
  }
31
31
  function setIndentFirstLine(twips, hanging) {
32
- return cmds["setIndentFirstLine"](twips, hanging);
32
+ return cmds.requireCommand("setIndentFirstLine")(twips, hanging);
33
33
  }
34
- const toggleBulletList = cmds["toggleBulletList"]();
35
- const toggleNumberedList = cmds["toggleNumberedList"]();
36
- const increaseListLevel = cmds["increaseListLevel"]();
37
- const decreaseListLevel = cmds["decreaseListLevel"]();
38
- const removeList = cmds["removeList"]();
34
+ const toggleBulletList = cmds.requireCommand("toggleBulletList")();
35
+ const toggleNumberedList = cmds.requireCommand("toggleNumberedList")();
36
+ const increaseListLevel = cmds.requireCommand("increaseListLevel")();
37
+ const decreaseListLevel = cmds.requireCommand("decreaseListLevel")();
38
+ const removeList = cmds.requireCommand("removeList")();
39
39
  function setSpaceBefore(twips) {
40
- return cmds["setSpaceBefore"](twips);
40
+ return cmds.requireCommand("setSpaceBefore")(twips);
41
41
  }
42
42
  function setSpaceAfter(twips) {
43
- return cmds["setSpaceAfter"](twips);
43
+ return cmds.requireCommand("setSpaceAfter")(twips);
44
44
  }
45
45
  function applyStyle(styleId, resolvedAttrs) {
46
- return cmds["applyStyle"](styleId, resolvedAttrs);
46
+ return cmds.requireCommand("applyStyle")(styleId, resolvedAttrs);
47
47
  }
48
- const clearStyle = cmds["clearStyle"]();
48
+ const clearStyle = cmds.requireCommand("clearStyle")();
49
49
  function insertSectionBreak(breakType) {
50
- return cmds["insertSectionBreak"](breakType);
50
+ return cmds.requireCommand("insertSectionBreak")(breakType);
51
51
  }
52
- const removeSectionBreak = cmds["removeSectionBreak"]();
52
+ const removeSectionBreak = cmds.requireCommand("removeSectionBreak")();
53
53
  function addTabStop(position, alignment = "left", leader = "none") {
54
- return cmds["addTabStop"](position, alignment, leader);
54
+ return cmds.requireCommand("addTabStop")(position, alignment, leader);
55
55
  }
56
56
  function removeTabStop(position) {
57
- return cmds["removeTabStop"](position);
57
+ return cmds.requireCommand("removeTabStop")(position);
58
58
  }
59
- const toggleBidi = cmds["toggleBidi"]();
60
- const setRtl = cmds["setRtl"]();
61
- const setLtr = cmds["setLtr"]();
62
- const generateTOC = cmds["generateTOC"]();
59
+ const toggleBidi = cmds.requireCommand("toggleBidi")();
60
+ const setRtl = cmds.requireCommand("setRtl")();
61
+ const setLtr = cmds.requireCommand("setLtr")();
62
+ const generateTOC = cmds.requireCommand("generateTOC")();
63
63
  //#endregion
64
64
  export { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTOC, getListInfo, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId, increaseIndent, increaseListLevel, insertSectionBreak, isInList, oneAndHalfSpacing, removeList, removeSectionBreak, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList };
@@ -1,6 +1,8 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
+ import { ParagraphPropertyChangeAttrs } from "../schema/nodes.js";
2
3
  //#region src/prosemirror/commands/propertyChangeScope.d.ts
3
4
  type AttrPatch = Record<string, unknown>;
5
+ type ParagraphPropertySnapshot = NonNullable<ParagraphPropertyChangeAttrs["previousFormatting"]>;
4
6
  /**
5
7
  * Paragraph attrs governed by a `w:pPrChange` — the attrs
6
8
  * `paragraphFormattingToAttrs` (conversion/toProseDoc.ts) can produce from a
@@ -27,7 +29,7 @@ declare const PPR_CHANGE_SCOPED_ATTR_KEYS: readonly ["styleId", "numPr", "alignm
27
29
  * the scoped set (editor-created list suggestions snapshot list-rendering
28
30
  * bookkeeping attrs) merge through 1:1 so their pre-change values restore too.
29
31
  */
30
- declare function paragraphRejectAttrPatch(previousFormatting: Record<string, unknown> | null | undefined): AttrPatch;
32
+ declare function paragraphRejectAttrPatch(previousFormatting: ParagraphPropertySnapshot | null | undefined): AttrPatch;
31
33
  /**
32
34
  * Rebuild the paragraph's `_originalFormatting` (the serializer's pPr source)
33
35
  * after a reject: the stored old pPr wholesale within CT_PPrBase scope, with
@@ -35,7 +37,7 @@ declare function paragraphRejectAttrPatch(previousFormatting: Record<string, unk
35
37
  * from the live original — a pPrChange cannot store them, so a reject must
36
38
  * not drop them.
37
39
  */
38
- declare function paragraphRejectOriginalFormatting(previousFormatting: Record<string, unknown> | null | undefined, liveOriginal: unknown): document_d_exports.ParagraphFormatting | null;
40
+ declare function paragraphRejectOriginalFormatting(previousFormatting: ParagraphPropertySnapshot | null | undefined, liveOriginal: unknown): document_d_exports.ParagraphFormatting | null;
39
41
  /**
40
42
  * Rejected section properties: the stored old sectPr wholesale, preserving
41
43
  * the live header/footer references — `EG_HdrFtrReferences` is not part of
@@ -112,7 +112,7 @@ function paragraphRejectAttrPatch(previousFormatting) {
112
112
  const prev = previousFormatting ?? {};
113
113
  const patch = {};
114
114
  for (const key of PPR_CHANGE_SCOPED_ATTR_KEYS) patch[key] = Object.hasOwn(prev, key) ? prev[key] ?? null : null;
115
- if (!Object.hasOwn(prev, "direction")) patch["direction"] = directionFromBidi(prev["bidi"]);
115
+ if (!Object.hasOwn(prev, "direction")) patch["direction"] = directionFromBidi(prev.bidi);
116
116
  if (!Object.hasOwn(prev, "_autospacingBase")) patch["_autospacingBase"] = autospacingBaseFromFormatting(prev);
117
117
  for (const [key, value] of Object.entries(prev)) {
118
118
  if (PPR_CHANGE_SCOPED_ATTR_KEY_SET.has(key) || PPR_PARSER_ONLY_KEYS.has(key)) continue;
@@ -132,21 +132,21 @@ function paragraphRejectOriginalFormatting(previousFormatting, liveOriginal) {
132
132
  const result = {};
133
133
  for (const key of PPR_CHANGE_SCOPED_FORMATTING_KEYS) {
134
134
  const value = Object.hasOwn(prev, key) ? prev[key] : void 0;
135
- if (value != null) result[key] = value;
135
+ if (value != null) Object.assign(result, { [key]: value });
136
136
  }
137
137
  const live = isRecord(liveOriginal) ? liveOriginal : {};
138
- if (live["runProperties"] != null) result["runProperties"] = live["runProperties"];
139
- if (live["runInWithNext"] != null) result["runInWithNext"] = live["runInWithNext"];
138
+ if (live["runProperties"] != null) Object.assign(result, { runProperties: live["runProperties"] });
139
+ if (live["runInWithNext"] != null) Object.assign(result, { runInWithNext: live["runInWithNext"] });
140
140
  if (Object.keys(result).length === 0) return null;
141
141
  return result;
142
142
  }
143
143
  function autospacingBaseFromFormatting(prev) {
144
- const before = prev["beforeAutospacing"] === true;
145
- const after = prev["afterAutospacing"] === true;
144
+ const before = prev.beforeAutospacing === true;
145
+ const after = prev.afterAutospacing === true;
146
146
  if (!before && !after) return null;
147
147
  const base = {};
148
- if (before) setAutospacingBaseValue(base, "before", prev["spaceBefore"]);
149
- if (after) setAutospacingBaseValue(base, "after", prev["spaceAfter"]);
148
+ if (before) setAutospacingBaseValue(base, "before", prev.spaceBefore);
149
+ if (after) setAutospacingBaseValue(base, "after", prev.spaceAfter);
150
150
  return base;
151
151
  }
152
152
  /**