@stll/folio-core 0.8.0 → 0.9.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.
- package/README.md +39 -0
- package/dist/ai-edits/apply.js +18 -4
- package/dist/ai-edits/headless.d.ts +31 -4
- package/dist/ai-edits/headless.js +148 -35
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/snapshot.js +40 -3
- package/dist/ai-edits/types.d.ts +2 -1
- package/dist/compat/eigenpal.d.ts +6 -4
- package/dist/compat/eigenpal.js +5 -3
- package/dist/controller/latestRequestGate.d.ts +13 -0
- package/dist/controller/latestRequestGate.js +16 -0
- package/dist/controller/layoutPipeline.js +12 -1
- package/dist/document-operations.d.ts +10 -3
- package/dist/document-operations.js +29 -14
- package/dist/docx/blockContentParser.js +2 -2
- package/dist/docx/commentParser.js +1 -1
- package/dist/docx/compatibility.d.ts +3 -7
- package/dist/docx/compatibility.js +0 -11
- package/dist/docx/encryption/agileDecryption.js +1 -1
- package/dist/docx/encryption/encryptionInfo.js +1 -1
- package/dist/docx/encryption/openEncryptedDocx.js +1 -1
- package/dist/docx/fontTableParser.d.ts +6 -0
- package/dist/docx/fontTableParser.js +72 -0
- package/dist/docx/groupDrawingParser.js +7 -2
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/normalizeBaseDirection.js +1 -1
- package/dist/docx/numberingParser.js +1 -0
- package/dist/docx/paragraphParser.js +12 -1
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +12 -9
- package/dist/docx/rezip.js +70 -5
- package/dist/docx/runConsolidator.js +4 -0
- package/dist/docx/runParser.js +19 -1
- package/dist/docx/selectiveSave.js +3 -3
- package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
- package/dist/docx/serializer/fontTableSerializer.js +26 -0
- package/dist/docx/serializer/headerFooterSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +4 -0
- package/dist/docx/serializer/runSerializer.js +7 -0
- package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
- package/dist/docx/serializer/settingsSerializer.js +16 -0
- package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
- package/dist/docx/serializer/stylesSerializer.js +56 -0
- package/dist/docx/serializer/tableSerializer.js +25 -26
- package/dist/docx/serializer/themeSerializer.d.ts +6 -0
- package/dist/docx/serializer/themeSerializer.js +36 -0
- package/dist/docx/settingsParser.js +46 -0
- package/dist/docx/styleParser.js +26 -1
- package/dist/docx/tableParser.js +11 -1
- package/dist/docx/vmlImageParser.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
- package/dist/i18n/messages/catalogs.gen.js +5910 -5910
- package/dist/index.d.ts +6 -4
- package/dist/index.js +5 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +51 -14
- package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
- package/dist/layout-bridge/engine/measuring/index.js +2 -1
- package/dist/layout-engine/index.js +36 -28
- package/dist/layout-engine/measure/cache.js +11 -3
- package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
- package/dist/layout-engine/measure/index.d.ts +2 -1
- package/dist/layout-engine/measure/index.js +2 -1
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
- package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
- package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
- package/dist/layout-engine/measure/lineBreaks.js +11 -18
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +12 -6
- package/dist/layout-engine/measure/measureBlocks.d.ts +1 -2
- package/dist/layout-engine/measure/measureBlocks.js +6 -36
- package/dist/layout-engine/measure/measureContainer.js +32 -9
- package/dist/layout-engine/measure/measureHelpers.js +5 -2
- package/dist/layout-engine/measure/measureParagraph.js +335 -72
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
- package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
- package/dist/layout-engine/measure/measureWorker.js +8 -19
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
- package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
- package/dist/layout-engine/measure/tableCellFloating.js +37 -29
- package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
- package/dist/layout-engine/measure/tableCellFlow.js +73 -0
- package/dist/layout-engine/measure/tableCellGrid.js +1 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +6 -1
- package/dist/layout-engine/renderedBreakReconciliation.js +34 -11
- package/dist/layout-engine/tableRowBreak.d.ts +5 -2
- package/dist/layout-engine/tableRowBreak.js +62 -29
- package/dist/layout-engine/types.d.ts +40 -7
- package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
- package/dist/layout-painter/anchoredImagePosition.js +95 -0
- package/dist/layout-painter/borderStroke.d.ts +23 -0
- package/dist/layout-painter/borderStroke.js +39 -0
- package/dist/layout-painter/renderImage.d.ts +5 -4
- package/dist/layout-painter/renderImage.js +18 -4
- package/dist/layout-painter/renderPage.d.ts +2 -27
- package/dist/layout-painter/renderPage.js +13 -99
- package/dist/layout-painter/renderParagraph.js +41 -23
- package/dist/layout-painter/renderTable.d.ts +2 -0
- package/dist/layout-painter/renderTable.js +223 -43
- package/dist/managers/DocumentLoaderManager.d.ts +1 -1
- package/dist/managers/DocumentLoaderManager.js +2 -2
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +21 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +33 -18
- package/dist/prosemirror/conversion/toProseDoc.js +50 -18
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +7 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +6 -1
- package/dist/prosemirror/schema/nodes.d.ts +13 -11
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
- package/dist/prosemirror/utils/tabCalculator.js +12 -10
- package/dist/prosemirror/validation.js +4 -1
- package/dist/redline.js +13 -3
- package/dist/server.d.ts +6 -3
- package/dist/server.js +5 -2
- package/dist/style-sets/extract.d.ts +35 -0
- package/dist/style-sets/extract.js +123 -0
- package/dist/style-sets/stellaStyle.d.ts +13 -0
- package/dist/style-sets/stellaStyle.js +516 -0
- package/dist/style-sets/types.d.ts +31 -0
- package/dist/style-sets/types.js +5 -0
- package/dist/utils/createDocument.d.ts +12 -2
- package/dist/utils/createDocument.js +42 -31
- package/dist/utils/fontResolver.js +6 -6
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
- package/dist/utils/paragraphFormattingMerge.js +14 -4
- package/package.json +5 -1
- package/dist/docx/capabilities.d.ts +0 -41
- package/dist/docx/capabilities.js +0 -322
|
@@ -2,11 +2,11 @@ import { OUTLINE_STYLE_CSS_ALIASES } from "../../types/documentEnumValues.js";
|
|
|
2
2
|
import { ShapeOutlineStyleSchema, narrowEnum } from "../../docx/parserEnums.js";
|
|
3
3
|
import { pixelsToEmu } from "../../utils/units.js";
|
|
4
4
|
import { numPrEqual } from "../../docx/numberingParser.js";
|
|
5
|
-
import { directionToBidi } from "../paragraphDirection.js";
|
|
6
|
-
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
7
5
|
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
8
|
-
import {
|
|
6
|
+
import { directionToBidi } from "../paragraphDirection.js";
|
|
7
|
+
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
9
8
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
9
|
+
import { runShadingAttrsToShading } from "./runShadingMark.js";
|
|
10
10
|
//#region src/prosemirror/conversion/fromProseDoc.ts
|
|
11
11
|
function normalizeShapeOutlineStyle(style) {
|
|
12
12
|
if (!style) return;
|
|
@@ -210,6 +210,7 @@ function listRenderingFromAttrs(attrs) {
|
|
|
210
210
|
...attrs.listMarkerHidden != null && { markerHidden: attrs.listMarkerHidden },
|
|
211
211
|
...attrs.listMarkerFontFamily != null && { markerFontFamily: attrs.listMarkerFontFamily },
|
|
212
212
|
...attrs.listMarkerFontSize != null && { markerFontSize: attrs.listMarkerFontSize },
|
|
213
|
+
...attrs.listMarkerBold != null && { markerBold: attrs.listMarkerBold },
|
|
213
214
|
...attrs.listMarkerAlignment != null && { markerAlignment: attrs.listMarkerAlignment },
|
|
214
215
|
...attrs.listMarkerSuffix != null && { markerSuffix: attrs.listMarkerSuffix },
|
|
215
216
|
...attrs.listMarkerAllCaps != null && { markerAllCaps: attrs.listMarkerAllCaps },
|
|
@@ -343,6 +344,9 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
343
344
|
else delete result.styleId;
|
|
344
345
|
assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
|
|
345
346
|
assignBooleanToggle(result, attrs, orig, "widowControl");
|
|
347
|
+
assignBooleanToggle(result, attrs, orig, "kinsoku");
|
|
348
|
+
assignBooleanToggle(result, attrs, orig, "overflowPunctuation");
|
|
349
|
+
assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
|
|
346
350
|
if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
|
|
347
351
|
else delete result.spacingExplicit;
|
|
348
352
|
const bidi = directionToBidi(attrs.direction);
|
|
@@ -352,7 +356,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
352
356
|
}
|
|
353
357
|
const outlineLevel = Reflect.get(attrs, "outlineLevel");
|
|
354
358
|
const bidi = directionToBidi(attrs.direction);
|
|
355
|
-
if (!(attrs.alignment || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || attrs.lineSpacing || attrs.indentLeft || attrs.indentRight || attrs.indentFirstLine || attrs.numPr || attrs.styleId || attrs.borders || attrs.shading || attrs.tabs || typeof outlineLevel === "number" || attrs.contextualSpacing || attrs.spacingExplicit || bidi != null || attrs.pageBreakBefore != null || attrs.widowControl != null)) return;
|
|
359
|
+
if (!(attrs.alignment || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || attrs.lineSpacing || attrs.indentLeft || attrs.indentRight || attrs.indentFirstLine || attrs.numPr || attrs.styleId || attrs.borders || attrs.shading || attrs.tabs || typeof outlineLevel === "number" || attrs.contextualSpacing || attrs.spacingExplicit || bidi != null || attrs.pageBreakBefore != null || attrs.widowControl != null || attrs.kinsoku != null || attrs.overflowPunctuation != null || attrs.suppressAutoHyphens != null)) return;
|
|
356
360
|
const f = {};
|
|
357
361
|
if (attrs.alignment) f.alignment = attrs.alignment;
|
|
358
362
|
if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
|
|
@@ -376,6 +380,9 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
376
380
|
if (bidi != null) f.bidi = bidi;
|
|
377
381
|
if (attrs.pageBreakBefore != null) f.pageBreakBefore = attrs.pageBreakBefore;
|
|
378
382
|
if (attrs.widowControl != null) f.widowControl = attrs.widowControl;
|
|
383
|
+
if (attrs.kinsoku != null) f.kinsoku = attrs.kinsoku;
|
|
384
|
+
if (attrs.overflowPunctuation != null) f.overflowPunctuation = attrs.overflowPunctuation;
|
|
385
|
+
if (attrs.suppressAutoHyphens != null) f.suppressAutoHyphens = attrs.suppressAutoHyphens;
|
|
379
386
|
return f;
|
|
380
387
|
}
|
|
381
388
|
/**
|
|
@@ -451,11 +458,6 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
451
458
|
syncCommentRanges(node, offset);
|
|
452
459
|
const linkMark = node.marks.find((m) => m.type.name === "hyperlink");
|
|
453
460
|
const noteRefMark = node.marks.find((m) => m.type.name === "footnoteRef");
|
|
454
|
-
if (noteRefMark && !linkMark) {
|
|
455
|
-
flushCurrentInline();
|
|
456
|
-
content.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
461
|
const insertionMark = node.marks.find((m) => m.type.name === "insertion");
|
|
460
462
|
const deletionMark = node.marks.find((m) => m.type.name === "deletion");
|
|
461
463
|
if (insertionMark || deletionMark) {
|
|
@@ -492,6 +494,11 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
492
494
|
});
|
|
493
495
|
return;
|
|
494
496
|
}
|
|
497
|
+
if (noteRefMark && !linkMark) {
|
|
498
|
+
flushCurrentInline();
|
|
499
|
+
content.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
495
502
|
if (linkMark) {
|
|
496
503
|
const linkKey = getLinkKey(linkMark);
|
|
497
504
|
if (currentHyperlink && currentHyperlinkKey === linkKey) {} else {
|
|
@@ -565,6 +572,8 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
565
572
|
return content;
|
|
566
573
|
}
|
|
567
574
|
function createTrackedChangeRun(node, marks) {
|
|
575
|
+
const noteRefMark = marks.find((mark) => mark.type.name === "footnoteRef");
|
|
576
|
+
if (noteRefMark) return createNoteReferenceRun(noteRefMark, marks);
|
|
568
577
|
if (node.isText) {
|
|
569
578
|
const formatting = marksToTextFormatting(marks);
|
|
570
579
|
return {
|
|
@@ -858,7 +867,7 @@ function createInlineSdtFromNode(node) {
|
|
|
858
867
|
return {
|
|
859
868
|
type: "inlineSdt",
|
|
860
869
|
properties,
|
|
861
|
-
content: extractParagraphContent(node).filter((c) => c.type === "run" || c.type === "hyperlink" || c.type === "simpleField" || c.type === "complexField" || c.type === "inlineSdt" || c.type === "mathEquation")
|
|
870
|
+
content: extractParagraphContent(node).filter((c) => c.type === "run" || c.type === "hyperlink" || c.type === "simpleField" || c.type === "complexField" || c.type === "inlineSdt" || c.type === "insertion" || c.type === "deletion" || c.type === "mathEquation")
|
|
862
871
|
};
|
|
863
872
|
}
|
|
864
873
|
function parseSdtListItems(rawItems) {
|
|
@@ -1073,6 +1082,15 @@ function marksToTextFormatting(marks) {
|
|
|
1073
1082
|
formatting.fontFamily = ff;
|
|
1074
1083
|
break;
|
|
1075
1084
|
}
|
|
1085
|
+
case "language": {
|
|
1086
|
+
const attrs = expectLanguageMarkAttrs(mark);
|
|
1087
|
+
formatting.language = {
|
|
1088
|
+
...attrs.val ? { val: attrs.val } : {},
|
|
1089
|
+
...attrs.eastAsia ? { eastAsia: attrs.eastAsia } : {},
|
|
1090
|
+
...attrs.bidi ? { bidi: attrs.bidi } : {}
|
|
1091
|
+
};
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1076
1094
|
case "superscript":
|
|
1077
1095
|
formatting.vertAlign = "superscript";
|
|
1078
1096
|
break;
|
|
@@ -1453,11 +1471,9 @@ function convertPMTableCell(node, documentCounts) {
|
|
|
1453
1471
|
if (Array.isArray(attrs.tcPrChange) && attrs.tcPrChange.length > 0) cell.propertyChanges = [...attrs.tcPrChange];
|
|
1454
1472
|
return cell;
|
|
1455
1473
|
}
|
|
1456
|
-
|
|
1457
|
-
* Convert ProseMirror table cell attrs to TableCellFormatting
|
|
1458
|
-
* Borders are stored as full BorderSpec objects — no conversion needed.
|
|
1459
|
-
*/
|
|
1474
|
+
const cellShadingFromAttrs = (attrs) => attrs.backgroundColor ? { fill: { rgb: attrs.backgroundColor } } : { pattern: "nil" };
|
|
1460
1475
|
function tableCellAttrsToFormatting(attrs) {
|
|
1476
|
+
const backgroundChanged = attrs.backgroundColor !== attrs._resolvedBackgroundColor;
|
|
1461
1477
|
if (attrs._originalFormatting) {
|
|
1462
1478
|
const orig = attrs._originalFormatting;
|
|
1463
1479
|
const result = { ...orig };
|
|
@@ -1471,8 +1487,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1471
1487
|
};
|
|
1472
1488
|
if (attrs.verticalAlign !== (orig.verticalAlign ?? void 0)) if (attrs.verticalAlign) result.verticalAlign = attrs.verticalAlign;
|
|
1473
1489
|
else delete result.verticalAlign;
|
|
1474
|
-
if (
|
|
1475
|
-
else if (!attrs.backgroundColor && orig.shading) delete result.shading;
|
|
1490
|
+
if (backgroundChanged) result.shading = cellShadingFromAttrs(attrs);
|
|
1476
1491
|
if (attrs.borders) result.borders = attrs.borders;
|
|
1477
1492
|
if (attrs.margins) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1478
1493
|
if (attrs.textDirection !== (orig.textDirection ?? void 0)) if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
@@ -1480,7 +1495,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1480
1495
|
return result;
|
|
1481
1496
|
}
|
|
1482
1497
|
const cellWidth = attrs.width;
|
|
1483
|
-
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || cellWidth !== void 0 || attrs.verticalAlign ||
|
|
1498
|
+
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || cellWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection)) return;
|
|
1484
1499
|
const f = {};
|
|
1485
1500
|
if (attrs.colspan > 1) f.gridSpan = attrs.colspan;
|
|
1486
1501
|
if (attrs.rowspan > 1) f.vMerge = "restart";
|
|
@@ -1490,7 +1505,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1490
1505
|
};
|
|
1491
1506
|
if (attrs.verticalAlign) f.verticalAlign = attrs.verticalAlign;
|
|
1492
1507
|
if (attrs.textDirection) f.textDirection = attrs.textDirection;
|
|
1493
|
-
if (
|
|
1508
|
+
if (backgroundChanged) f.shading = cellShadingFromAttrs(attrs);
|
|
1494
1509
|
if (attrs.borders) f.borders = attrs.borders;
|
|
1495
1510
|
if (attrs.margins) f.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1496
1511
|
return f;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { emuToPixels } from "../../utils/units.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
3
|
+
import { mergeParagraphFormatting, mergeParagraphTabStops } from "../../utils/paragraphFormattingMerge.js";
|
|
4
4
|
import { setAutospacingBaseValue } from "../autospacingBase.js";
|
|
5
|
-
import {
|
|
5
|
+
import { directionFromBidi } from "../paragraphDirection.js";
|
|
6
6
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
7
|
-
import {
|
|
8
|
-
import { mergeParagraphFormatting } from "../../utils/paragraphFormattingMerge.js";
|
|
7
|
+
import { shadingToRunShadingAttrs } from "./runShadingMark.js";
|
|
9
8
|
import { marksToTextFormatting } from "./fromProseDoc.js";
|
|
10
9
|
import { createStyleEngine } from "../../style-engine/styleEngine.js";
|
|
10
|
+
import { resolveColor } from "../../utils/colorResolver.js";
|
|
11
|
+
import { resolveShadingFill } from "../../utils/formatToStyle.js";
|
|
11
12
|
import { buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
|
|
12
13
|
import { schema } from "../schema/index.js";
|
|
13
14
|
//#region src/prosemirror/conversion/toProseDoc.ts
|
|
@@ -30,7 +31,16 @@ function toProseDoc(document, options) {
|
|
|
30
31
|
for (const block of blocks) if (block.type === "paragraph") {
|
|
31
32
|
const pbPos = paragraphPageBreakPosition(block);
|
|
32
33
|
if (pbPos === "before") out.push(schema.node("pageBreak"));
|
|
33
|
-
|
|
34
|
+
const converted = convertParagraphWithTextBoxes(block, styleResolver, { textBoxGroupId: nextTextBoxGroupId() });
|
|
35
|
+
const firstConverted = converted.at(0);
|
|
36
|
+
if (pbPos === "before" && converted.length === 1 && firstConverted?.type.name === "paragraph" && firstConverted.content.size === 0 && document.package.settings?.splitPageBreakAndParagraphMark !== true) {
|
|
37
|
+
const paragraph = firstConverted;
|
|
38
|
+
converted[0] = paragraph.type.create({
|
|
39
|
+
...paragraph.attrs,
|
|
40
|
+
_pageBreakCarrier: true
|
|
41
|
+
}, paragraph.content, paragraph.marks);
|
|
42
|
+
}
|
|
43
|
+
out.push(...converted);
|
|
34
44
|
if (pbPos === "after") out.push(schema.node("pageBreak"));
|
|
35
45
|
} else if (block.type === "table") out.push(convertTable(block, styleResolver, {
|
|
36
46
|
theme,
|
|
@@ -105,13 +115,13 @@ function convertParagraph(paragraph, styleResolver, activeCommentIds, extraRunFo
|
|
|
105
115
|
if (styleResolver) styleRunFormatting = styleResolver.resolveParagraphStyle(paragraph.formatting?.styleId).runFormatting;
|
|
106
116
|
const paragraphRunFormatting = resolveParagraphMarkRunFormatting(paragraph.formatting?.runProperties, styleResolver);
|
|
107
117
|
let inheritableParagraphRunFormatting;
|
|
108
|
-
if (paragraphRunFormatting && !isTocParagraph) inheritableParagraphRunFormatting =
|
|
118
|
+
if (paragraphRunFormatting && !isTocParagraph) inheritableParagraphRunFormatting = stripParagraphMarkFormattingForBodyRuns(paragraphRunFormatting);
|
|
109
119
|
const baseRunFormatting = mergeTextFormatting(styleRunFormatting, extraRunFormatting);
|
|
110
120
|
const paragraphMarkPrecedesStyle = paragraph.formatting?.styleId !== void 0;
|
|
111
121
|
const defaultRunFormatting = paragraphMarkPrecedesStyle ? mergeTextFormatting(inheritableParagraphRunFormatting, baseRunFormatting) : mergeTextFormatting(baseRunFormatting, inheritableParagraphRunFormatting);
|
|
112
122
|
const getInheritedRunFormatting = (formatting, fieldType) => {
|
|
113
123
|
if (fieldType === "TOC") return hasDirectRunFormatting(formatting) ? suppressParagraphMarkFormatting(baseRunFormatting, void 0, formatting) : baseRunFormatting;
|
|
114
|
-
if (!hasDirectRunFormatting(formatting)) return defaultRunFormatting;
|
|
124
|
+
if (!(hasDirectRunFormatting(formatting) || formatting?.styleId !== void 0)) return defaultRunFormatting;
|
|
115
125
|
return suppressParagraphMarkFormatting(baseRunFormatting, inheritableParagraphRunFormatting, formatting, paragraphMarkPrecedesStyle);
|
|
116
126
|
};
|
|
117
127
|
const emitTrackedChange = (change, markType, moveKind) => {
|
|
@@ -227,6 +237,7 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
227
237
|
if (paragraph.listRendering?.markerHidden) attrs.listMarkerHidden = paragraph.listRendering.markerHidden;
|
|
228
238
|
if (paragraph.listRendering?.markerFontFamily) attrs.listMarkerFontFamily = paragraph.listRendering.markerFontFamily;
|
|
229
239
|
if (paragraph.listRendering?.markerFontSize) attrs.listMarkerFontSize = paragraph.listRendering.markerFontSize;
|
|
240
|
+
if (paragraph.listRendering?.markerBold !== void 0) attrs.listMarkerBold = paragraph.listRendering.markerBold;
|
|
230
241
|
if (paragraph.listRendering?.markerAlignment) attrs.listMarkerAlignment = paragraph.listRendering.markerAlignment;
|
|
231
242
|
if (paragraph.listRendering?.markerSuffix) attrs.listMarkerSuffix = paragraph.listRendering.markerSuffix;
|
|
232
243
|
if (paragraph.listRendering?.markerAllCaps) attrs.listMarkerAllCaps = paragraph.listRendering.markerAllCaps;
|
|
@@ -260,14 +271,17 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
260
271
|
if (formatting?.spaceBefore === void 0 && tableParagraphOverlay?.spaceBefore === void 0 && paragraphStyle?.pPr?.spaceBefore === void 0 && docDefaultSpacing?.spaceBefore !== void 0) spacingFromDocDefaults.before = true;
|
|
261
272
|
if (formatting?.spaceAfter === void 0 && tableParagraphOverlay?.spaceAfter === void 0 && paragraphStyle?.pPr?.spaceAfter === void 0 && docDefaultSpacing?.spaceAfter !== void 0) spacingFromDocDefaults.after = true;
|
|
262
273
|
if (spacingFromDocDefaults.before || spacingFromDocDefaults.after) attrs.spacingFromDocDefaults = spacingFromDocDefaults;
|
|
263
|
-
const
|
|
264
|
-
set("indentLeft",
|
|
274
|
+
const effectiveIndent = mergeParagraphFormatting(formatting?.numPr?.numId === 0 && stylePpr?.numPr !== void 0 && stylePpr.numPr.numId !== 0 ? void 0 : stylePpr, formatting);
|
|
275
|
+
set("indentLeft", effectiveIndent?.indentLeft);
|
|
265
276
|
set("indentRight", formatting?.indentRight ?? stylePpr?.indentRight);
|
|
266
|
-
set("indentFirstLine",
|
|
267
|
-
set("hangingIndent",
|
|
277
|
+
set("indentFirstLine", effectiveIndent?.indentFirstLine);
|
|
278
|
+
set("hangingIndent", effectiveIndent?.hangingIndent);
|
|
268
279
|
set("borders", formatting?.borders ?? stylePpr?.borders);
|
|
269
280
|
set("shading", formatting?.shading ?? stylePpr?.shading);
|
|
270
|
-
set("tabs",
|
|
281
|
+
set("tabs", mergeParagraphTabStops(stylePpr?.tabs, formatting?.tabs));
|
|
282
|
+
set("kinsoku", formatting?.kinsoku ?? stylePpr?.kinsoku);
|
|
283
|
+
set("overflowPunctuation", formatting?.overflowPunctuation ?? stylePpr?.overflowPunctuation);
|
|
284
|
+
set("suppressAutoHyphens", formatting?.suppressAutoHyphens ?? stylePpr?.suppressAutoHyphens);
|
|
271
285
|
set("pageBreakBefore", formatting?.pageBreakBefore ?? stylePpr?.pageBreakBefore);
|
|
272
286
|
set("keepNext", formatting?.keepNext ?? stylePpr?.keepNext);
|
|
273
287
|
set("keepLines", formatting?.keepLines ?? stylePpr?.keepLines);
|
|
@@ -295,6 +309,9 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
295
309
|
set("borders", formatting?.borders);
|
|
296
310
|
set("shading", formatting?.shading);
|
|
297
311
|
set("tabs", formatting?.tabs);
|
|
312
|
+
set("kinsoku", formatting?.kinsoku);
|
|
313
|
+
set("overflowPunctuation", formatting?.overflowPunctuation);
|
|
314
|
+
set("suppressAutoHyphens", formatting?.suppressAutoHyphens);
|
|
298
315
|
set("pageBreakBefore", formatting?.pageBreakBefore);
|
|
299
316
|
set("keepNext", formatting?.keepNext);
|
|
300
317
|
set("keepLines", formatting?.keepLines);
|
|
@@ -405,6 +422,12 @@ function stripParagraphMarkOnlyFormatting(formatting) {
|
|
|
405
422
|
const { allCaps: _ac, highlight: _h, shading: _s, smallCaps: _sc, vertAlign: _va, ...rest } = formatting;
|
|
406
423
|
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
407
424
|
}
|
|
425
|
+
function stripParagraphMarkFormattingForBodyRuns(formatting) {
|
|
426
|
+
const paragraphMarkFormatting = stripParagraphMarkOnlyFormatting(formatting);
|
|
427
|
+
if (!paragraphMarkFormatting) return;
|
|
428
|
+
const { fontFamily: _fontFamily, ...bodyRunFormatting } = paragraphMarkFormatting;
|
|
429
|
+
return Object.keys(bodyRunFormatting).length > 0 ? bodyRunFormatting : void 0;
|
|
430
|
+
}
|
|
408
431
|
function suppressParagraphMarkFormatting(base, paragraphMark, direct, paragraphMarkPrecedesStyle = false) {
|
|
409
432
|
if (!paragraphMark) return base;
|
|
410
433
|
const result = (paragraphMarkPrecedesStyle ? mergeTextFormatting(paragraphMark, base) : mergeTextFormatting(base, paragraphMark)) ?? {};
|
|
@@ -712,7 +735,9 @@ const TABLE_BORDER_SIDES = [
|
|
|
712
735
|
"left",
|
|
713
736
|
"right",
|
|
714
737
|
"insideH",
|
|
715
|
-
"insideV"
|
|
738
|
+
"insideV",
|
|
739
|
+
"topLeftToBottomRight",
|
|
740
|
+
"topRightToBottomLeft"
|
|
716
741
|
];
|
|
717
742
|
function resolveThemedBorderColors(borders, theme) {
|
|
718
743
|
if (!borders || !theme?.colorScheme) return borders;
|
|
@@ -741,7 +766,7 @@ function convertTableCell(cell, styleResolver, context, isHeader, gridWidthPerce
|
|
|
741
766
|
width = gridWidthPercent;
|
|
742
767
|
widthType = "pct";
|
|
743
768
|
}
|
|
744
|
-
const backgroundColor = formatting?.shading
|
|
769
|
+
const backgroundColor = resolveShadingFill(formatting?.shading ?? conditionalStyle?.tcPr?.shading, theme).replace(/^#/u, "");
|
|
745
770
|
const baseBorders = (() => {
|
|
746
771
|
if (tableBorders) return {
|
|
747
772
|
top: isFirstRow ? tableBorders.top : tableBorders.insideH,
|
|
@@ -772,7 +797,10 @@ function convertTableCell(cell, styleResolver, context, isHeader, gridWidthPerce
|
|
|
772
797
|
if (width !== void 0) attrs.width = width;
|
|
773
798
|
if (widthType) attrs.widthType = widthType;
|
|
774
799
|
if (formatting?.verticalAlign) attrs.verticalAlign = formatting.verticalAlign;
|
|
775
|
-
if (backgroundColor)
|
|
800
|
+
if (backgroundColor) {
|
|
801
|
+
attrs.backgroundColor = backgroundColor;
|
|
802
|
+
attrs._resolvedBackgroundColor = backgroundColor;
|
|
803
|
+
}
|
|
776
804
|
if (formatting?.textDirection) attrs.textDirection = formatting.textDirection;
|
|
777
805
|
if (formatting?.noWrap !== void 0) attrs.noWrap = formatting.noWrap;
|
|
778
806
|
if (borders) attrs.borders = borders;
|
|
@@ -851,7 +879,9 @@ function convertInlineSdt(sdt, getInheritedRunFormatting, styleResolver) {
|
|
|
851
879
|
} else if (content.type === "inlineSdt") {
|
|
852
880
|
const nestedSdt = convertInlineSdt(content, getInheritedRunFormatting, styleResolver);
|
|
853
881
|
if (nestedSdt) inlineNodes.push(nestedSdt);
|
|
854
|
-
} else
|
|
882
|
+
} else if (content.type === "insertion") inlineNodes.push(...convertTrackedChange(content, "insertion", getInheritedRunFormatting, styleResolver));
|
|
883
|
+
else if (content.type === "deletion") inlineNodes.push(...convertTrackedChange(content, "deletion", getInheritedRunFormatting, styleResolver));
|
|
884
|
+
else {
|
|
855
885
|
const mathNode = convertMathEquation(content);
|
|
856
886
|
if (mathNode) inlineNodes.push(mathNode);
|
|
857
887
|
}
|
|
@@ -1047,7 +1077,8 @@ function convertImage(image, rawXml) {
|
|
|
1047
1077
|
borderStyle,
|
|
1048
1078
|
wrapText,
|
|
1049
1079
|
hlinkHref: image.hlinkHref,
|
|
1050
|
-
_docxRawXml: rawXml
|
|
1080
|
+
_docxRawXml: rawXml,
|
|
1081
|
+
_docxObjectPreview: rawXml !== void 0 && /<(?:[A-Za-z_][\w.-]*:)?object(?:\s|>)/u.test(rawXml)
|
|
1051
1082
|
});
|
|
1052
1083
|
}
|
|
1053
1084
|
/**
|
|
@@ -1108,6 +1139,7 @@ function textFormattingToMarks(formatting) {
|
|
|
1108
1139
|
eastAsiaTheme: formatting.fontFamily.eastAsiaTheme,
|
|
1109
1140
|
csTheme: formatting.fontFamily.csTheme
|
|
1110
1141
|
}));
|
|
1142
|
+
if (formatting.language) marks.push(schema.mark("language", formatting.language));
|
|
1111
1143
|
if (formatting.vertAlign === "superscript") marks.push(schema.mark("superscript"));
|
|
1112
1144
|
else if (formatting.vertAlign === "subscript") marks.push(schema.mark("subscript"));
|
|
1113
1145
|
if (formatting.allCaps) marks.push(schema.mark("allCaps"));
|
|
@@ -31,6 +31,7 @@ import { HiddenTextExtension } from "./marks/HiddenTextExtension.js";
|
|
|
31
31
|
import { HighlightExtension } from "./marks/HighlightExtension.js";
|
|
32
32
|
import { HyperlinkExtension } from "./marks/HyperlinkExtension.js";
|
|
33
33
|
import { ItalicExtension } from "./marks/ItalicExtension.js";
|
|
34
|
+
import { LanguageExtension } from "./marks/LanguageExtension.js";
|
|
34
35
|
import { RtlExtension } from "./marks/RtlExtension.js";
|
|
35
36
|
import { RunShadingExtension } from "./marks/RunShadingExtension.js";
|
|
36
37
|
import { SmallCapsExtension } from "./marks/SmallCapsExtension.js";
|
|
@@ -79,6 +80,7 @@ function createStarterKit(options = {}) {
|
|
|
79
80
|
add("highlight", HighlightExtension());
|
|
80
81
|
add("fontSize", FontSizeExtension());
|
|
81
82
|
add("fontFamily", FontFamilyExtension());
|
|
83
|
+
add("language", LanguageExtension());
|
|
82
84
|
add("superscript", SuperscriptExtension());
|
|
83
85
|
add("subscript", SubscriptExtension());
|
|
84
86
|
add("hyperlink", HyperlinkExtension());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { autospacingMatchesBase } from "../../autospacingBase.js";
|
|
2
2
|
import { directionIsRtl } from "../../paragraphDirection.js";
|
|
3
3
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { paragraphToStyle } from "../../../utils/formatToStyle.js";
|
|
5
5
|
import { createNodeExtension } from "../create.js";
|
|
6
6
|
import { collectHeadings } from "../../../utils/headingCollector.js";
|
|
7
7
|
import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
@@ -180,6 +180,9 @@ const paragraphNodeSpec = {
|
|
|
180
180
|
paraId: { default: null },
|
|
181
181
|
textId: { default: null },
|
|
182
182
|
alignment: { default: null },
|
|
183
|
+
kinsoku: { default: null },
|
|
184
|
+
overflowPunctuation: { default: null },
|
|
185
|
+
suppressAutoHyphens: { default: null },
|
|
183
186
|
spaceBefore: { default: null },
|
|
184
187
|
spaceAfter: { default: null },
|
|
185
188
|
lineSpacing: { default: null },
|
|
@@ -199,6 +202,7 @@ const paragraphNodeSpec = {
|
|
|
199
202
|
listMarkerHidden: { default: null },
|
|
200
203
|
listMarkerFontFamily: { default: null },
|
|
201
204
|
listMarkerFontSize: { default: null },
|
|
205
|
+
listMarkerBold: { default: null },
|
|
202
206
|
listMarkerAlignment: { default: null },
|
|
203
207
|
listMarkerSuffix: { default: null },
|
|
204
208
|
listMarkerAllCaps: { default: null },
|
|
@@ -214,6 +218,7 @@ const paragraphNodeSpec = {
|
|
|
214
218
|
tabs: { default: null },
|
|
215
219
|
pageBreakBefore: { default: null },
|
|
216
220
|
renderedPageBreakBefore: { default: null },
|
|
221
|
+
_pageBreakCarrier: { default: null },
|
|
217
222
|
keepNext: { default: null },
|
|
218
223
|
keepLines: { default: null },
|
|
219
224
|
widowControl: { default: null },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { detectBaseDirection } from "../../../utils/baseDirection.js";
|
|
2
1
|
import { directionIsAutoManaged } from "../../paragraphDirection.js";
|
|
3
2
|
import { createExtension } from "../create.js";
|
|
4
3
|
import { getTransactionDirtyRange } from "../../../paged-layout/transactionDirtyRange.js";
|
|
4
|
+
import { detectBaseDirection } from "../../../utils/baseDirection.js";
|
|
5
5
|
import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
|
|
6
6
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
7
7
|
//#region src/prosemirror/extensions/features/AutoBidiDetectionExtension.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HIGHLIGHT_COLOR_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
|
-
import { resolveHighlightToCss } from "../../../utils/colorResolver.js";
|
|
3
2
|
import { expectHighlightMarkAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { resolveHighlightToCss } from "../../../utils/colorResolver.js";
|
|
4
4
|
import { createMarkExtension } from "../create.js";
|
|
5
5
|
import { removeMark, setMark } from "./markUtils.js";
|
|
6
6
|
import { panic } from "better-result";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MarkExtension } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/prosemirror/extensions/marks/LanguageExtension.d.ts
|
|
4
|
+
/** Preserve OOXML `w:lang` and expose its primary language to the editing DOM. */
|
|
5
|
+
declare const LanguageExtension: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { LanguageExtension };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expectLanguageMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { createMarkExtension } from "../create.js";
|
|
3
|
+
//#region src/prosemirror/extensions/marks/LanguageExtension.ts
|
|
4
|
+
/** Preserve OOXML `w:lang` and expose its primary language to the editing DOM. */
|
|
5
|
+
const LanguageExtension = createMarkExtension({
|
|
6
|
+
name: "language",
|
|
7
|
+
schemaMarkName: "language",
|
|
8
|
+
markSpec: {
|
|
9
|
+
attrs: {
|
|
10
|
+
val: { default: null },
|
|
11
|
+
eastAsia: { default: null },
|
|
12
|
+
bidi: { default: null }
|
|
13
|
+
},
|
|
14
|
+
parseDOM: [{
|
|
15
|
+
tag: "span[lang]",
|
|
16
|
+
getAttrs: (dom) => typeof dom === "string" ? false : { val: dom.getAttribute("lang") ?? void 0 }
|
|
17
|
+
}],
|
|
18
|
+
toDOM(mark) {
|
|
19
|
+
const { val, eastAsia, bidi } = expectLanguageMarkAttrs(mark);
|
|
20
|
+
const language = val ?? eastAsia ?? bidi;
|
|
21
|
+
return language ? [
|
|
22
|
+
"span",
|
|
23
|
+
{ lang: language },
|
|
24
|
+
0
|
|
25
|
+
] : ["span", 0];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { LanguageExtension };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ensureHexPrefix } from "../../../utils/colorResolver.js";
|
|
2
1
|
import { expectRunShadingMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { ensureHexPrefix } from "../../../utils/colorResolver.js";
|
|
3
3
|
import { createMarkExtension } from "../create.js";
|
|
4
4
|
import { normalizeCssColorKey, parseDOMHighlightColor } from "./HighlightExtension.js";
|
|
5
5
|
//#region src/prosemirror/extensions/marks/RunShadingExtension.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { textToStyle } from "../../../utils/formatToStyle.js";
|
|
2
1
|
import { expectTextColorMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { textToStyle } from "../../../utils/formatToStyle.js";
|
|
3
3
|
import { createMarkExtension } from "../create.js";
|
|
4
4
|
import { removeMark, setMark } from "./markUtils.js";
|
|
5
5
|
import { panic } from "better-result";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AUTHOR_COLORS, getAuthorColorIdx } from "../../../utils/authorColors.js";
|
|
2
1
|
import { expectTrackedChangeMarkAttrs } from "../../attrs/index.js";
|
|
3
2
|
import { createMarkExtension } from "../create.js";
|
|
3
|
+
import { AUTHOR_COLORS, getAuthorColorIdx } from "../../../utils/authorColors.js";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/TrackedChangeExtensions.ts
|
|
5
5
|
/**
|
|
6
6
|
* Tracked Change Mark Extensions — insertion and deletion marks
|
|
@@ -43,6 +43,17 @@ function marksToTextFormatting(marks) {
|
|
|
43
43
|
};
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
|
+
case "language": {
|
|
47
|
+
const val = mark.attrs["val"];
|
|
48
|
+
const eastAsia = mark.attrs["eastAsia"];
|
|
49
|
+
const bidi = mark.attrs["bidi"];
|
|
50
|
+
formatting.language = {
|
|
51
|
+
...typeof val === "string" ? { val } : {},
|
|
52
|
+
...typeof eastAsia === "string" ? { eastAsia } : {},
|
|
53
|
+
...typeof bidi === "string" ? { bidi } : {}
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
46
57
|
case "superscript":
|
|
47
58
|
formatting.vertAlign = "superscript";
|
|
48
59
|
break;
|
|
@@ -186,6 +197,7 @@ function textFormattingToMarks(formatting, schema) {
|
|
|
186
197
|
hAnsi: formatting.fontFamily.hAnsi,
|
|
187
198
|
asciiTheme: formatting.fontFamily.asciiTheme
|
|
188
199
|
}));
|
|
200
|
+
if (formatting.language && schema.marks["language"]) marks.push(schema.marks["language"].create(formatting.language));
|
|
189
201
|
if (formatting.vertAlign === "superscript" && schema.marks["superscript"]) marks.push(schema.marks["superscript"].create());
|
|
190
202
|
if (formatting.vertAlign === "subscript" && schema.marks["subscript"]) marks.push(schema.marks["subscript"].create());
|
|
191
203
|
if (formatting.rtl && schema.marks["rtl"]) marks.push(schema.marks["rtl"].create());
|
|
@@ -38,7 +38,8 @@ const ImageExtension = createNodeExtension({
|
|
|
38
38
|
borderStyle: { default: null },
|
|
39
39
|
wrapText: { default: null },
|
|
40
40
|
hlinkHref: { default: null },
|
|
41
|
-
_docxRawXml: { default: null }
|
|
41
|
+
_docxRawXml: { default: null },
|
|
42
|
+
_docxObjectPreview: { default: null }
|
|
42
43
|
},
|
|
43
44
|
parseDOM: [{
|
|
44
45
|
tag: "img[src]",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_WIDTH_TYPE_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
|
-
import { resolveColor } from "../../../utils/colorResolver.js";
|
|
3
2
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { resolveColor } from "../../../utils/colorResolver.js";
|
|
4
4
|
import { createExtension, createNodeExtension } from "../create.js";
|
|
5
5
|
import { panic } from "better-result";
|
|
6
6
|
import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
|
|
7
|
-
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
8
7
|
import { CellSelection, TableMap, columnResizing, mergeCells, removeRow, selectedRect, splitCell, tableEditing } from "prosemirror-tables";
|
|
8
|
+
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
9
9
|
//#region src/prosemirror/extensions/nodes/TableExtension.ts
|
|
10
10
|
/**
|
|
11
11
|
* Table Extension — 4 node specs + plugins + commands
|
|
@@ -310,6 +310,7 @@ const tableCellSpec = {
|
|
|
310
310
|
widthType: { default: null },
|
|
311
311
|
verticalAlign: { default: null },
|
|
312
312
|
backgroundColor: { default: null },
|
|
313
|
+
_resolvedBackgroundColor: { default: null },
|
|
313
314
|
borders: { default: null },
|
|
314
315
|
margins: { default: null },
|
|
315
316
|
textDirection: { default: null },
|
|
@@ -363,6 +364,7 @@ const tableHeaderSpec = {
|
|
|
363
364
|
widthType: { default: null },
|
|
364
365
|
verticalAlign: { default: null },
|
|
365
366
|
backgroundColor: { default: null },
|
|
367
|
+
_resolvedBackgroundColor: { default: null },
|
|
366
368
|
borders: { default: null },
|
|
367
369
|
margins: { default: null },
|
|
368
370
|
textDirection: { default: null },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionManager } from "../extensions/ExtensionManager.js";
|
|
2
2
|
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
3
|
-
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
3
|
+
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
4
4
|
|
|
5
5
|
//#region src/prosemirror/schema/index.d.ts
|
|
6
6
|
declare const singletonManager: ExtensionManager;
|
|
@@ -12,4 +12,4 @@ type DocxSchema = typeof schema;
|
|
|
12
12
|
type DocxNode = ReturnType<typeof schema.node>;
|
|
13
13
|
type DocxMark = ReturnType<typeof schema.mark>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { type BlockSdtAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type MathAttrs, type ParagraphAttrs, type RunFormattingOverrideAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
15
|
+
export { type BlockSdtAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type ParagraphAttrs, type RunFormattingOverrideAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
@@ -40,6 +40,11 @@ type FontFamilyAttrs = {
|
|
|
40
40
|
eastAsiaTheme?: string;
|
|
41
41
|
csTheme?: string;
|
|
42
42
|
};
|
|
43
|
+
type LanguageAttrs = {
|
|
44
|
+
val?: string;
|
|
45
|
+
eastAsia?: string;
|
|
46
|
+
bidi?: string;
|
|
47
|
+
};
|
|
43
48
|
type HighlightAttrs = {
|
|
44
49
|
color: NonNullable<document_d_exports.TextFormatting["highlight"]>;
|
|
45
50
|
};
|
|
@@ -115,4 +120,4 @@ type HyperlinkAttrs = {
|
|
|
115
120
|
_docxHyperlinkIndex?: number;
|
|
116
121
|
};
|
|
117
122
|
//#endregion
|
|
118
|
-
export { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs };
|
|
123
|
+
export { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs };
|
|
@@ -13,7 +13,10 @@ type HardBreakAttrs = {
|
|
|
13
13
|
type ParagraphAttrs = {
|
|
14
14
|
paraId?: string;
|
|
15
15
|
textId?: string;
|
|
16
|
-
alignment?: document_d_exports.ParagraphAlignment;
|
|
16
|
+
alignment?: document_d_exports.ParagraphAlignment; /** Effective East Asian line-edge policy (`w:kinsoku`). */
|
|
17
|
+
kinsoku?: boolean; /** Effective hanging-punctuation policy (`w:overflowPunct`). */
|
|
18
|
+
overflowPunctuation?: boolean; /** Effective paragraph opt-out from document automatic hyphenation. */
|
|
19
|
+
suppressAutoHyphens?: boolean;
|
|
17
20
|
spaceBefore?: number;
|
|
18
21
|
spaceAfter?: number;
|
|
19
22
|
lineSpacing?: number;
|
|
@@ -46,7 +49,8 @@ type ParagraphAttrs = {
|
|
|
46
49
|
listMarker?: string; /** Whether the list marker is hidden (w:vanish on numbering level rPr) */
|
|
47
50
|
listMarkerHidden?: boolean; /** Marker font family from numbering level rPr */
|
|
48
51
|
listMarkerFontFamily?: string; /** Marker font size from numbering level rPr, in points */
|
|
49
|
-
listMarkerFontSize?: number; /**
|
|
52
|
+
listMarkerFontSize?: number; /** Marker bold state from numbering level rPr */
|
|
53
|
+
listMarkerBold?: boolean; /** Horizontal alignment of the marker around the paragraph's list anchor. */
|
|
50
54
|
listMarkerAlignment?: "left" | "center" | "right";
|
|
51
55
|
/**
|
|
52
56
|
* `w:suff` (§17.9.25) — what follows the marker before body text.
|
|
@@ -83,7 +87,8 @@ type ParagraphAttrs = {
|
|
|
83
87
|
shading?: document_d_exports.ShadingProperties;
|
|
84
88
|
tabs?: document_d_exports.TabStop[];
|
|
85
89
|
pageBreakBefore?: boolean; /** Word's cached rendered-page-break marker; preserved for round-trip only. */
|
|
86
|
-
renderedPageBreakBefore?: boolean;
|
|
90
|
+
renderedPageBreakBefore?: boolean; /** Internal import marker for a paragraph whose only run content is a hard page break. */
|
|
91
|
+
_pageBreakCarrier?: boolean;
|
|
87
92
|
keepNext?: boolean;
|
|
88
93
|
keepLines?: boolean;
|
|
89
94
|
widowControl?: boolean; /** Contextual spacing — suppress space between same-style paragraphs */
|
|
@@ -198,7 +203,8 @@ type ImageAttrs = {
|
|
|
198
203
|
borderStyle?: string; /** Wrap text setting from DOCX (left, right, bothSides, largest) for round-trip */
|
|
199
204
|
wrapText?: NonNullable<document_d_exports.ImageWrap["wrapText"]>; /** Hyperlink URL for clickable image */
|
|
200
205
|
hlinkHref?: string; /** Original OOXML for opaque/unsupported DOCX drawings. */
|
|
201
|
-
_docxRawXml?: string;
|
|
206
|
+
_docxRawXml?: string; /** Embedded-object previews use their authored box as the exact line height. */
|
|
207
|
+
_docxObjectPreview?: boolean;
|
|
202
208
|
};
|
|
203
209
|
/**
|
|
204
210
|
* Field node attributes
|
|
@@ -375,15 +381,11 @@ type TableCellAttrs = {
|
|
|
375
381
|
width?: number; /** Cell width type */
|
|
376
382
|
widthType?: document_d_exports.TableWidthType; /** Vertical alignment */
|
|
377
383
|
verticalAlign?: "top" | "center" | "bottom"; /** Background color (RGB hex) */
|
|
378
|
-
backgroundColor?: string; /**
|
|
384
|
+
backgroundColor?: string; /** Resolved source color. PM-only; distinguishes theme rendering from a user override. */
|
|
385
|
+
_resolvedBackgroundColor?: string; /** OOXML text direction (e.g. 'tbRl', 'btLr') */
|
|
379
386
|
textDirection?: NonNullable<document_d_exports.TableCellFormatting["textDirection"]>; /** No text wrapping in cell */
|
|
380
387
|
noWrap?: boolean; /** Cell borders — full BorderSpec per side (style, color, size) */
|
|
381
|
-
borders?:
|
|
382
|
-
top?: document_d_exports.BorderSpec;
|
|
383
|
-
bottom?: document_d_exports.BorderSpec;
|
|
384
|
-
left?: document_d_exports.BorderSpec;
|
|
385
|
-
right?: document_d_exports.BorderSpec;
|
|
386
|
-
}; /** Cell margins/padding in twips per side */
|
|
388
|
+
borders?: document_d_exports.TableCellBorders; /** Cell margins/padding in twips per side */
|
|
387
389
|
margins?: {
|
|
388
390
|
top?: number;
|
|
389
391
|
bottom?: number;
|