@stll/folio-core 0.7.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/blockRange.d.ts +13 -2
- package/dist/ai-edits/blockRange.js +23 -2
- package/dist/ai-edits/headless.d.ts +31 -4
- package/dist/ai-edits/headless.js +148 -35
- package/dist/ai-edits/index.d.ts +6 -4
- package/dist/ai-edits/index.js +4 -1
- package/dist/ai-edits/scoped-reading.d.ts +9 -0
- package/dist/ai-edits/scoped-reading.js +60 -0
- package/dist/ai-edits/snapshot.js +53 -7
- package/dist/ai-edits/types.d.ts +46 -3
- package/dist/compat/eigenpal.d.ts +8 -3
- package/dist/compat/eigenpal.js +7 -2
- package/dist/controller/fontReadiness.d.ts +29 -0
- package/dist/controller/fontReadiness.js +139 -0
- package/dist/controller/latestRequestGate.d.ts +13 -0
- package/dist/controller/latestRequestGate.js +16 -0
- package/dist/controller/layoutPipeline.js +88 -10
- package/dist/document-operations.d.ts +10 -3
- package/dist/document-operations.js +29 -14
- package/dist/docx/blockContentParser.js +53 -10
- package/dist/docx/commentParser.js +1 -1
- package/dist/docx/compatibility.d.ts +30 -2
- package/dist/docx/compatibility.js +118 -39
- package/dist/docx/conformance.d.ts +6 -0
- package/dist/docx/conformance.js +18 -0
- 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/ensureParaIds.d.ts +29 -0
- package/dist/docx/ensureParaIds.js +423 -0
- 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 +2 -0
- package/dist/docx/paragraphParser.js +21 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +141 -2
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +14 -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/selectiveXmlPatch.d.ts +10 -1
- package/dist/docx/selectiveXmlPatch.js +1 -1
- 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 +8 -0
- package/dist/docx/serializer/runSerializer.js +14 -2
- 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 +29 -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 +19 -1
- package/dist/docx/textBoxParser.js +6 -1
- package/dist/docx/vmlImageParser.js +146 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
- package/dist/i18n/messages/catalogs.gen.js +5910 -5910
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7 -2
- 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 +22 -3
- package/dist/layout-bridge/convert/paragraphFrames.d.ts +7 -0
- package/dist/layout-bridge/convert/paragraphFrames.js +136 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +93 -17
- package/dist/layout-bridge/engine/hitTest.js +2 -1
- package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
- package/dist/layout-bridge/engine/measuring/index.js +2 -1
- package/dist/layout-bridge/engine/selectionRects.js +2 -1
- package/dist/layout-engine/headerFooterRefs.d.ts +7 -0
- package/dist/layout-engine/headerFooterRefs.js +40 -0
- package/dist/layout-engine/index.d.ts +3 -2
- package/dist/layout-engine/index.js +68 -106
- 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 +4 -1
- package/dist/layout-engine/measure/listMarkerWidth.js +33 -8
- package/dist/layout-engine/measure/measureBlocks.d.ts +4 -2
- package/dist/layout-engine/measure/measureBlocks.js +138 -86
- 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 +346 -74
- 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.d.ts +15 -0
- package/dist/layout-engine/measure/tableCellGrid.js +62 -0
- package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +18 -0
- package/dist/layout-engine/measure/textBoxParagraphLayout.js +32 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
- package/dist/layout-engine/paginator.d.ts +2 -1
- package/dist/layout-engine/paginator.js +7 -6
- package/dist/layout-engine/paragraphFrame.d.ts +22 -0
- package/dist/layout-engine/paragraphFrame.js +17 -0
- package/dist/layout-engine/paragraphSequence.d.ts +7 -0
- package/dist/layout-engine/paragraphSequence.js +25 -0
- package/dist/layout-engine/paragraphSpacing.d.ts +17 -0
- package/dist/layout-engine/paragraphSpacing.js +30 -0
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +63 -0
- package/dist/layout-engine/renderedBreakReconciliation.js +86 -0
- package/dist/layout-engine/tableRowBreak.d.ts +5 -2
- package/dist/layout-engine/tableRowBreak.js +62 -29
- package/dist/layout-engine/types.d.ts +54 -12
- package/dist/layout-engine/types.js +15 -2
- 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 +15 -101
- package/dist/layout-painter/renderParagraph.js +45 -26
- package/dist/layout-painter/renderTable.d.ts +2 -0
- package/dist/layout-painter/renderTable.js +257 -47
- package/dist/layout-painter/renderTextBox.js +17 -7
- package/dist/managers/DocumentLoaderManager.d.ts +1 -1
- package/dist/managers/DocumentLoaderManager.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +9 -0
- package/dist/paged-layout/sectionGeometry.js +1 -1
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +32 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +35 -18
- package/dist/prosemirror/conversion/toProseDoc.js +73 -37
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +2 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +68 -16
- 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/extensions/nodes/TextBoxExtension.d.ts +2 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +7 -0
- 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 +16 -12
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -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 +9 -4
- package/dist/server.js +7 -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/types/index.d.ts +2 -1
- package/dist/utils/createDocument.d.ts +12 -2
- package/dist/utils/createDocument.js +55 -36
- package/dist/utils/fontResolver.js +6 -6
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/utils/hexId.d.ts +8 -1
- package/dist/utils/hexId.js +11 -3
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
- package/dist/utils/paragraphFormattingMerge.js +14 -4
- package/package.json +5 -1
|
@@ -18,6 +18,11 @@ const IMAGE_CSS_FLOATS = [
|
|
|
18
18
|
"right",
|
|
19
19
|
"none"
|
|
20
20
|
];
|
|
21
|
+
const TEXT_BOX_AUTO_FIT_VALUES = [
|
|
22
|
+
"none",
|
|
23
|
+
"normal",
|
|
24
|
+
"shape"
|
|
25
|
+
];
|
|
21
26
|
const FIELD_KINDS = ["simple", "complex"];
|
|
22
27
|
const MATH_DISPLAYS = ["inline", "block"];
|
|
23
28
|
const SHAPE_FILL_TYPES = [
|
|
@@ -123,6 +128,7 @@ const highlightAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
123
128
|
const runShadingAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
124
129
|
const fontSizeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
125
130
|
const fontFamilyAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
131
|
+
const languageAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
126
132
|
const characterSpacingAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
127
133
|
const characterStyleAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
128
134
|
const emphasisMarkAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -140,6 +146,9 @@ const readParagraphAttrs = (node) => {
|
|
|
140
146
|
optionalString(attrs, "textId", "paragraph.attrs.textId", issues);
|
|
141
147
|
optionalOneOf(attrs, "alignment", "paragraph.attrs.alignment", issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
142
148
|
optionalString(attrs, "styleId", "paragraph.attrs.styleId", issues);
|
|
149
|
+
optionalBoolean(attrs, "kinsoku", "paragraph.attrs.kinsoku", issues);
|
|
150
|
+
optionalBoolean(attrs, "overflowPunctuation", "paragraph.attrs.overflowPunctuation", issues);
|
|
151
|
+
optionalBoolean(attrs, "suppressAutoHyphens", "paragraph.attrs.suppressAutoHyphens", issues);
|
|
143
152
|
optionalNumber(attrs, "spaceBefore", "paragraph.attrs.spaceBefore", issues);
|
|
144
153
|
optionalNumber(attrs, "spaceAfter", "paragraph.attrs.spaceAfter", issues);
|
|
145
154
|
optionalNumber(attrs, "lineSpacing", "paragraph.attrs.lineSpacing", issues);
|
|
@@ -156,6 +165,12 @@ const readParagraphAttrs = (node) => {
|
|
|
156
165
|
optionalBoolean(attrs, "listMarkerHidden", "paragraph.attrs.listMarkerHidden", issues);
|
|
157
166
|
optionalString(attrs, "listMarkerFontFamily", "paragraph.attrs.listMarkerFontFamily", issues);
|
|
158
167
|
optionalNumber(attrs, "listMarkerFontSize", "paragraph.attrs.listMarkerFontSize", issues);
|
|
168
|
+
optionalBoolean(attrs, "listMarkerBold", "paragraph.attrs.listMarkerBold", issues);
|
|
169
|
+
optionalOneOf(attrs, "listMarkerAlignment", "paragraph.attrs.listMarkerAlignment", issues, [
|
|
170
|
+
"left",
|
|
171
|
+
"center",
|
|
172
|
+
"right"
|
|
173
|
+
]);
|
|
159
174
|
optionalString(attrs, "listMarkerSuffix", "paragraph.attrs.listMarkerSuffix", issues);
|
|
160
175
|
optionalBoolean(attrs, "listMarkerAllCaps", "paragraph.attrs.listMarkerAllCaps", issues);
|
|
161
176
|
optionalNumber(attrs, "listImplicitChildLevelAdvances", "paragraph.attrs.listImplicitChildLevelAdvances", issues);
|
|
@@ -254,13 +269,16 @@ const readTableCellAttrs = (node) => {
|
|
|
254
269
|
optionalOneOf(attrs, "widthType", "tableCell.attrs.widthType", issues, TABLE_WIDTH_TYPE_VALUES);
|
|
255
270
|
optionalOneOf(attrs, "verticalAlign", "tableCell.attrs.verticalAlign", issues, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES);
|
|
256
271
|
optionalString(attrs, "backgroundColor", "tableCell.attrs.backgroundColor", issues);
|
|
272
|
+
optionalString(attrs, "_resolvedBackgroundColor", "tableCell.attrs._resolvedBackgroundColor", issues);
|
|
257
273
|
optionalOneOf(attrs, "textDirection", "tableCell.attrs.textDirection", issues, TABLE_CELL_TEXT_DIRECTION_VALUES);
|
|
258
274
|
optionalBoolean(attrs, "noWrap", "tableCell.attrs.noWrap", issues);
|
|
259
275
|
optionalBorderMap(attrs, "borders", "tableCell.attrs.borders", issues, [
|
|
260
276
|
"top",
|
|
261
277
|
"bottom",
|
|
262
278
|
"left",
|
|
263
|
-
"right"
|
|
279
|
+
"right",
|
|
280
|
+
"topLeftToBottomRight",
|
|
281
|
+
"topRightToBottomLeft"
|
|
264
282
|
]);
|
|
265
283
|
optionalInsetMap(attrs, "margins", "tableCell.attrs.margins", issues);
|
|
266
284
|
optionalRecord(attrs, "_originalFormatting", "tableCell.attrs._originalFormatting", issues);
|
|
@@ -294,6 +312,7 @@ const readImageAttrs = (node) => {
|
|
|
294
312
|
optionalOneOf(attrs, "wrapText", "image.attrs.wrapText", issues, IMAGE_WRAP_TEXT_VALUES);
|
|
295
313
|
optionalString(attrs, "hlinkHref", "image.attrs.hlinkHref", issues);
|
|
296
314
|
optionalString(attrs, "_docxRawXml", "image.attrs._docxRawXml", issues);
|
|
315
|
+
optionalBoolean(attrs, "_docxObjectPreview", "image.attrs._docxObjectPreview", issues);
|
|
297
316
|
return attrsResult(attrs, issues);
|
|
298
317
|
};
|
|
299
318
|
const expectImageAttrs = (node) => expectCachedNodeAttrs(node, imageAttrsCache, readImageAttrs, "image attrs");
|
|
@@ -410,6 +429,7 @@ const readTextBoxAttrs = (node) => {
|
|
|
410
429
|
expectNodeType(node, "textBox", issues);
|
|
411
430
|
optionalNumber(attrs, "width", "textBox.attrs.width", issues);
|
|
412
431
|
optionalNumber(attrs, "height", "textBox.attrs.height", issues);
|
|
432
|
+
optionalOneOf(attrs, "autoFit", "textBox.attrs.autoFit", issues, TEXT_BOX_AUTO_FIT_VALUES);
|
|
413
433
|
optionalString(attrs, "textBoxId", "textBox.attrs.textBoxId", issues);
|
|
414
434
|
optionalString(attrs, "fillColor", "textBox.attrs.fillColor", issues);
|
|
415
435
|
optionalNumber(attrs, "outlineWidth", "textBox.attrs.outlineWidth", issues);
|
|
@@ -509,6 +529,16 @@ const readFontFamilyMarkAttrs = (mark) => {
|
|
|
509
529
|
return attrsResult(attrs, issues);
|
|
510
530
|
};
|
|
511
531
|
const expectFontFamilyMarkAttrs = (mark) => expectCachedMarkAttrs(mark, fontFamilyAttrsCache, readFontFamilyMarkAttrs, "font family attrs");
|
|
532
|
+
const readLanguageMarkAttrs = (mark) => {
|
|
533
|
+
const attrs = attrsRecord(mark.attrs);
|
|
534
|
+
const issues = [];
|
|
535
|
+
expectMarkType(mark, "language", issues);
|
|
536
|
+
optionalString(attrs, "val", "language.attrs.val", issues);
|
|
537
|
+
optionalString(attrs, "eastAsia", "language.attrs.eastAsia", issues);
|
|
538
|
+
optionalString(attrs, "bidi", "language.attrs.bidi", issues);
|
|
539
|
+
return attrsResult(attrs, issues);
|
|
540
|
+
};
|
|
541
|
+
const expectLanguageMarkAttrs = (mark) => expectCachedMarkAttrs(mark, languageAttrsCache, readLanguageMarkAttrs, "language attrs");
|
|
512
542
|
const readCharacterSpacingMarkAttrs = (mark) => {
|
|
513
543
|
const attrs = attrsRecord(mark.attrs);
|
|
514
544
|
const issues = [];
|
|
@@ -1218,4 +1248,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
|
|
|
1218
1248
|
}
|
|
1219
1249
|
};
|
|
1220
1250
|
//#endregion
|
|
1221
|
-
export { 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, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
1251
|
+
export { 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, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { directionFromBidi } from "../paragraphDirection.js";
|
|
2
1
|
import { setAutospacingBaseValue } from "../autospacingBase.js";
|
|
2
|
+
import { directionFromBidi } from "../paragraphDirection.js";
|
|
3
3
|
//#region src/prosemirror/commands/propertyChangeScope.ts
|
|
4
4
|
/**
|
|
5
5
|
* Paragraph attrs governed by a `w:pPrChange` — the attrs
|
|
@@ -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,8 @@ 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 },
|
|
214
|
+
...attrs.listMarkerAlignment != null && { markerAlignment: attrs.listMarkerAlignment },
|
|
213
215
|
...attrs.listMarkerSuffix != null && { markerSuffix: attrs.listMarkerSuffix },
|
|
214
216
|
...attrs.listMarkerAllCaps != null && { markerAllCaps: attrs.listMarkerAllCaps },
|
|
215
217
|
...attrs.listImplicitChildLevelAdvances != null && { implicitChildLevelAdvances: attrs.listImplicitChildLevelAdvances },
|
|
@@ -342,6 +344,9 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
342
344
|
else delete result.styleId;
|
|
343
345
|
assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
|
|
344
346
|
assignBooleanToggle(result, attrs, orig, "widowControl");
|
|
347
|
+
assignBooleanToggle(result, attrs, orig, "kinsoku");
|
|
348
|
+
assignBooleanToggle(result, attrs, orig, "overflowPunctuation");
|
|
349
|
+
assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
|
|
345
350
|
if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
|
|
346
351
|
else delete result.spacingExplicit;
|
|
347
352
|
const bidi = directionToBidi(attrs.direction);
|
|
@@ -351,7 +356,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
351
356
|
}
|
|
352
357
|
const outlineLevel = Reflect.get(attrs, "outlineLevel");
|
|
353
358
|
const bidi = directionToBidi(attrs.direction);
|
|
354
|
-
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;
|
|
355
360
|
const f = {};
|
|
356
361
|
if (attrs.alignment) f.alignment = attrs.alignment;
|
|
357
362
|
if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
|
|
@@ -375,6 +380,9 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
375
380
|
if (bidi != null) f.bidi = bidi;
|
|
376
381
|
if (attrs.pageBreakBefore != null) f.pageBreakBefore = attrs.pageBreakBefore;
|
|
377
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;
|
|
378
386
|
return f;
|
|
379
387
|
}
|
|
380
388
|
/**
|
|
@@ -450,11 +458,6 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
450
458
|
syncCommentRanges(node, offset);
|
|
451
459
|
const linkMark = node.marks.find((m) => m.type.name === "hyperlink");
|
|
452
460
|
const noteRefMark = node.marks.find((m) => m.type.name === "footnoteRef");
|
|
453
|
-
if (noteRefMark && !linkMark) {
|
|
454
|
-
flushCurrentInline();
|
|
455
|
-
content.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
461
|
const insertionMark = node.marks.find((m) => m.type.name === "insertion");
|
|
459
462
|
const deletionMark = node.marks.find((m) => m.type.name === "deletion");
|
|
460
463
|
if (insertionMark || deletionMark) {
|
|
@@ -491,6 +494,11 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
491
494
|
});
|
|
492
495
|
return;
|
|
493
496
|
}
|
|
497
|
+
if (noteRefMark && !linkMark) {
|
|
498
|
+
flushCurrentInline();
|
|
499
|
+
content.push(createNoteReferenceRun(noteRefMark, node.marks));
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
494
502
|
if (linkMark) {
|
|
495
503
|
const linkKey = getLinkKey(linkMark);
|
|
496
504
|
if (currentHyperlink && currentHyperlinkKey === linkKey) {} else {
|
|
@@ -564,6 +572,8 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks) {
|
|
|
564
572
|
return content;
|
|
565
573
|
}
|
|
566
574
|
function createTrackedChangeRun(node, marks) {
|
|
575
|
+
const noteRefMark = marks.find((mark) => mark.type.name === "footnoteRef");
|
|
576
|
+
if (noteRefMark) return createNoteReferenceRun(noteRefMark, marks);
|
|
567
577
|
if (node.isText) {
|
|
568
578
|
const formatting = marksToTextFormatting(marks);
|
|
569
579
|
return {
|
|
@@ -857,7 +867,7 @@ function createInlineSdtFromNode(node) {
|
|
|
857
867
|
return {
|
|
858
868
|
type: "inlineSdt",
|
|
859
869
|
properties,
|
|
860
|
-
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")
|
|
861
871
|
};
|
|
862
872
|
}
|
|
863
873
|
function parseSdtListItems(rawItems) {
|
|
@@ -1072,6 +1082,15 @@ function marksToTextFormatting(marks) {
|
|
|
1072
1082
|
formatting.fontFamily = ff;
|
|
1073
1083
|
break;
|
|
1074
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
|
+
}
|
|
1075
1094
|
case "superscript":
|
|
1076
1095
|
formatting.vertAlign = "superscript";
|
|
1077
1096
|
break;
|
|
@@ -1452,11 +1471,9 @@ function convertPMTableCell(node, documentCounts) {
|
|
|
1452
1471
|
if (Array.isArray(attrs.tcPrChange) && attrs.tcPrChange.length > 0) cell.propertyChanges = [...attrs.tcPrChange];
|
|
1453
1472
|
return cell;
|
|
1454
1473
|
}
|
|
1455
|
-
|
|
1456
|
-
* Convert ProseMirror table cell attrs to TableCellFormatting
|
|
1457
|
-
* Borders are stored as full BorderSpec objects — no conversion needed.
|
|
1458
|
-
*/
|
|
1474
|
+
const cellShadingFromAttrs = (attrs) => attrs.backgroundColor ? { fill: { rgb: attrs.backgroundColor } } : { pattern: "nil" };
|
|
1459
1475
|
function tableCellAttrsToFormatting(attrs) {
|
|
1476
|
+
const backgroundChanged = attrs.backgroundColor !== attrs._resolvedBackgroundColor;
|
|
1460
1477
|
if (attrs._originalFormatting) {
|
|
1461
1478
|
const orig = attrs._originalFormatting;
|
|
1462
1479
|
const result = { ...orig };
|
|
@@ -1470,8 +1487,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1470
1487
|
};
|
|
1471
1488
|
if (attrs.verticalAlign !== (orig.verticalAlign ?? void 0)) if (attrs.verticalAlign) result.verticalAlign = attrs.verticalAlign;
|
|
1472
1489
|
else delete result.verticalAlign;
|
|
1473
|
-
if (
|
|
1474
|
-
else if (!attrs.backgroundColor && orig.shading) delete result.shading;
|
|
1490
|
+
if (backgroundChanged) result.shading = cellShadingFromAttrs(attrs);
|
|
1475
1491
|
if (attrs.borders) result.borders = attrs.borders;
|
|
1476
1492
|
if (attrs.margins) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1477
1493
|
if (attrs.textDirection !== (orig.textDirection ?? void 0)) if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
@@ -1479,7 +1495,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1479
1495
|
return result;
|
|
1480
1496
|
}
|
|
1481
1497
|
const cellWidth = attrs.width;
|
|
1482
|
-
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;
|
|
1483
1499
|
const f = {};
|
|
1484
1500
|
if (attrs.colspan > 1) f.gridSpan = attrs.colspan;
|
|
1485
1501
|
if (attrs.rowspan > 1) f.vMerge = "restart";
|
|
@@ -1489,7 +1505,7 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
1489
1505
|
};
|
|
1490
1506
|
if (attrs.verticalAlign) f.verticalAlign = attrs.verticalAlign;
|
|
1491
1507
|
if (attrs.textDirection) f.textDirection = attrs.textDirection;
|
|
1492
|
-
if (
|
|
1508
|
+
if (backgroundChanged) f.shading = cellShadingFromAttrs(attrs);
|
|
1493
1509
|
if (attrs.borders) f.borders = attrs.borders;
|
|
1494
1510
|
if (attrs.margins) f.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
1495
1511
|
return f;
|
|
@@ -1516,6 +1532,7 @@ function convertPMTextBox(node) {
|
|
|
1516
1532
|
type: "paragraph",
|
|
1517
1533
|
content: []
|
|
1518
1534
|
}],
|
|
1535
|
+
...attrs.autoFit !== void 0 ? { autoFit: attrs.autoFit } : {},
|
|
1519
1536
|
margins: (() => {
|
|
1520
1537
|
const m = {};
|
|
1521
1538
|
if (typeof attrs.marginTop === "number") m.top = pixelsToEmu(attrs.marginTop);
|
|
@@ -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,8 @@ 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;
|
|
241
|
+
if (paragraph.listRendering?.markerAlignment) attrs.listMarkerAlignment = paragraph.listRendering.markerAlignment;
|
|
230
242
|
if (paragraph.listRendering?.markerSuffix) attrs.listMarkerSuffix = paragraph.listRendering.markerSuffix;
|
|
231
243
|
if (paragraph.listRendering?.markerAllCaps) attrs.listMarkerAllCaps = paragraph.listRendering.markerAllCaps;
|
|
232
244
|
if (paragraph.listRendering?.implicitChildLevelAdvances !== void 0) attrs.listImplicitChildLevelAdvances = paragraph.listRendering.implicitChildLevelAdvances;
|
|
@@ -259,14 +271,17 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
259
271
|
if (formatting?.spaceBefore === void 0 && tableParagraphOverlay?.spaceBefore === void 0 && paragraphStyle?.pPr?.spaceBefore === void 0 && docDefaultSpacing?.spaceBefore !== void 0) spacingFromDocDefaults.before = true;
|
|
260
272
|
if (formatting?.spaceAfter === void 0 && tableParagraphOverlay?.spaceAfter === void 0 && paragraphStyle?.pPr?.spaceAfter === void 0 && docDefaultSpacing?.spaceAfter !== void 0) spacingFromDocDefaults.after = true;
|
|
261
273
|
if (spacingFromDocDefaults.before || spacingFromDocDefaults.after) attrs.spacingFromDocDefaults = spacingFromDocDefaults;
|
|
262
|
-
|
|
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);
|
|
263
276
|
set("indentRight", formatting?.indentRight ?? stylePpr?.indentRight);
|
|
264
|
-
|
|
265
|
-
set("
|
|
266
|
-
set("hangingIndent", formatting?.hangingIndent ?? styleFirstLine?.hangingIndent);
|
|
277
|
+
set("indentFirstLine", effectiveIndent?.indentFirstLine);
|
|
278
|
+
set("hangingIndent", effectiveIndent?.hangingIndent);
|
|
267
279
|
set("borders", formatting?.borders ?? stylePpr?.borders);
|
|
268
280
|
set("shading", formatting?.shading ?? stylePpr?.shading);
|
|
269
|
-
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);
|
|
270
285
|
set("pageBreakBefore", formatting?.pageBreakBefore ?? stylePpr?.pageBreakBefore);
|
|
271
286
|
set("keepNext", formatting?.keepNext ?? stylePpr?.keepNext);
|
|
272
287
|
set("keepLines", formatting?.keepLines ?? stylePpr?.keepLines);
|
|
@@ -294,6 +309,9 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
294
309
|
set("borders", formatting?.borders);
|
|
295
310
|
set("shading", formatting?.shading);
|
|
296
311
|
set("tabs", formatting?.tabs);
|
|
312
|
+
set("kinsoku", formatting?.kinsoku);
|
|
313
|
+
set("overflowPunctuation", formatting?.overflowPunctuation);
|
|
314
|
+
set("suppressAutoHyphens", formatting?.suppressAutoHyphens);
|
|
297
315
|
set("pageBreakBefore", formatting?.pageBreakBefore);
|
|
298
316
|
set("keepNext", formatting?.keepNext);
|
|
299
317
|
set("keepLines", formatting?.keepLines);
|
|
@@ -301,7 +319,7 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
301
319
|
set("runInWithNext", formatting?.runInWithNext);
|
|
302
320
|
set("outlineLevel", formatting?.outlineLevel);
|
|
303
321
|
set("direction", directionFromBidi(formatting?.bidi));
|
|
304
|
-
set("defaultTextFormatting", resolveTextFormatting(formatting?.runProperties, styleResolver));
|
|
322
|
+
set("defaultTextFormatting", stripParagraphMarkOnlyFormatting(resolveTextFormatting(formatting?.runProperties, styleResolver) ?? {}));
|
|
305
323
|
}
|
|
306
324
|
if (paragraph.sectionProperties) {
|
|
307
325
|
attrs._sectionProperties = paragraph.sectionProperties;
|
|
@@ -401,33 +419,39 @@ function hasDirectRunFormatting(formatting) {
|
|
|
401
419
|
return Object.entries(formatting).some(([key, value]) => key !== "styleId" && value !== void 0);
|
|
402
420
|
}
|
|
403
421
|
function stripParagraphMarkOnlyFormatting(formatting) {
|
|
404
|
-
const { allCaps: _ac, highlight: _h, shading: _s, smallCaps: _sc, ...rest } = formatting;
|
|
422
|
+
const { allCaps: _ac, highlight: _h, shading: _s, smallCaps: _sc, vertAlign: _va, ...rest } = formatting;
|
|
405
423
|
return Object.keys(rest).length > 0 ? rest : void 0;
|
|
406
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
|
+
}
|
|
407
431
|
function suppressParagraphMarkFormatting(base, paragraphMark, direct, paragraphMarkPrecedesStyle = false) {
|
|
408
432
|
if (!paragraphMark) return base;
|
|
409
433
|
const result = (paragraphMarkPrecedesStyle ? mergeTextFormatting(paragraphMark, base) : mergeTextFormatting(base, paragraphMark)) ?? {};
|
|
410
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "bold");
|
|
411
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "italic");
|
|
412
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "strike");
|
|
413
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "doubleStrike");
|
|
414
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "allCaps");
|
|
415
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "smallCaps");
|
|
416
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "hidden");
|
|
417
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "emboss");
|
|
418
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "imprint");
|
|
419
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "shadow");
|
|
420
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "outline");
|
|
421
|
-
suppressBooleanParagraphMark(result, paragraphMark, direct, "rtl");
|
|
434
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "bold");
|
|
435
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "italic");
|
|
436
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "strike");
|
|
437
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "doubleStrike");
|
|
438
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "allCaps");
|
|
439
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "smallCaps");
|
|
440
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "hidden");
|
|
441
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "emboss");
|
|
442
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "imprint");
|
|
443
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "shadow");
|
|
444
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "outline");
|
|
445
|
+
suppressBooleanParagraphMark(result, base, paragraphMark, direct, "rtl");
|
|
422
446
|
if (paragraphMark.fontSize !== void 0 && direct?.fontSize === void 0 && base?.fontSize !== void 0) result.fontSize = base.fontSize;
|
|
423
447
|
if (paragraphMark.fontSizeCs !== void 0 && direct?.fontSizeCs === void 0 && base?.fontSizeCs !== void 0) result.fontSizeCs = base.fontSizeCs;
|
|
424
448
|
if (paragraphMark.underline !== void 0 && direct?.underline === void 0) result.underline = { style: "none" };
|
|
425
449
|
if (paragraphMark.spacing !== void 0 && direct?.spacing === void 0) result.spacing = 0;
|
|
426
450
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
427
451
|
}
|
|
428
|
-
function suppressBooleanParagraphMark(result, paragraphMark, direct, key) {
|
|
452
|
+
function suppressBooleanParagraphMark(result, base, paragraphMark, direct, key) {
|
|
429
453
|
if (paragraphMark[key] === void 0 || direct?.[key] !== void 0) return;
|
|
430
|
-
result[key] = false;
|
|
454
|
+
result[key] = base?.[key] ?? false;
|
|
431
455
|
}
|
|
432
456
|
function resolveTextFormatting(formatting, styleResolver) {
|
|
433
457
|
if (!formatting) return styleResolver?.resolveRunStyle(null);
|
|
@@ -456,7 +480,7 @@ function calculateRowSpans(table) {
|
|
|
456
480
|
clearActiveVerticalMerges(activeMerges, result);
|
|
457
481
|
continue;
|
|
458
482
|
}
|
|
459
|
-
let colIndex = 0;
|
|
483
|
+
let colIndex = row.formatting?.gridBefore ?? 0;
|
|
460
484
|
const rowCells = row.cells.map((cell) => {
|
|
461
485
|
const colspan = cell.formatting?.gridSpan ?? 1;
|
|
462
486
|
const vMerge = cell.formatting?.vMerge;
|
|
@@ -616,8 +640,9 @@ function convertTable(table, styleResolver, context) {
|
|
|
616
640
|
function countTableColumns(rows) {
|
|
617
641
|
let maxColumns = 0;
|
|
618
642
|
for (const row of rows) {
|
|
619
|
-
let rowColumns = 0;
|
|
643
|
+
let rowColumns = row.formatting?.gridBefore ?? 0;
|
|
620
644
|
for (const cell of row.cells) rowColumns += cell.formatting?.gridSpan ?? 1;
|
|
645
|
+
rowColumns += row.formatting?.gridAfter ?? 0;
|
|
621
646
|
maxColumns = Math.max(maxColumns, rowColumns);
|
|
622
647
|
}
|
|
623
648
|
return maxColumns;
|
|
@@ -651,7 +676,7 @@ function convertTableRow(row, styleResolver, context, isHeaderRow, columnWidths,
|
|
|
651
676
|
if (totalCols > 1) fallback.formatting = { gridSpan: totalCols };
|
|
652
677
|
effectiveCells = [fallback];
|
|
653
678
|
}
|
|
654
|
-
let colIndex = 0;
|
|
679
|
+
let colIndex = row.formatting?.gridBefore ?? 0;
|
|
655
680
|
const cells = [];
|
|
656
681
|
for (const cellIndex_item of effectiveCells) {
|
|
657
682
|
const cell = cellIndex_item;
|
|
@@ -710,7 +735,9 @@ const TABLE_BORDER_SIDES = [
|
|
|
710
735
|
"left",
|
|
711
736
|
"right",
|
|
712
737
|
"insideH",
|
|
713
|
-
"insideV"
|
|
738
|
+
"insideV",
|
|
739
|
+
"topLeftToBottomRight",
|
|
740
|
+
"topRightToBottomLeft"
|
|
714
741
|
];
|
|
715
742
|
function resolveThemedBorderColors(borders, theme) {
|
|
716
743
|
if (!borders || !theme?.colorScheme) return borders;
|
|
@@ -739,7 +766,7 @@ function convertTableCell(cell, styleResolver, context, isHeader, gridWidthPerce
|
|
|
739
766
|
width = gridWidthPercent;
|
|
740
767
|
widthType = "pct";
|
|
741
768
|
}
|
|
742
|
-
const backgroundColor = formatting?.shading
|
|
769
|
+
const backgroundColor = resolveShadingFill(formatting?.shading ?? conditionalStyle?.tcPr?.shading, theme).replace(/^#/u, "");
|
|
743
770
|
const baseBorders = (() => {
|
|
744
771
|
if (tableBorders) return {
|
|
745
772
|
top: isFirstRow ? tableBorders.top : tableBorders.insideH,
|
|
@@ -770,7 +797,10 @@ function convertTableCell(cell, styleResolver, context, isHeader, gridWidthPerce
|
|
|
770
797
|
if (width !== void 0) attrs.width = width;
|
|
771
798
|
if (widthType) attrs.widthType = widthType;
|
|
772
799
|
if (formatting?.verticalAlign) attrs.verticalAlign = formatting.verticalAlign;
|
|
773
|
-
if (backgroundColor)
|
|
800
|
+
if (backgroundColor) {
|
|
801
|
+
attrs.backgroundColor = backgroundColor;
|
|
802
|
+
attrs._resolvedBackgroundColor = backgroundColor;
|
|
803
|
+
}
|
|
774
804
|
if (formatting?.textDirection) attrs.textDirection = formatting.textDirection;
|
|
775
805
|
if (formatting?.noWrap !== void 0) attrs.noWrap = formatting.noWrap;
|
|
776
806
|
if (borders) attrs.borders = borders;
|
|
@@ -849,7 +879,9 @@ function convertInlineSdt(sdt, getInheritedRunFormatting, styleResolver) {
|
|
|
849
879
|
} else if (content.type === "inlineSdt") {
|
|
850
880
|
const nestedSdt = convertInlineSdt(content, getInheritedRunFormatting, styleResolver);
|
|
851
881
|
if (nestedSdt) inlineNodes.push(nestedSdt);
|
|
852
|
-
} 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 {
|
|
853
885
|
const mathNode = convertMathEquation(content);
|
|
854
886
|
if (mathNode) inlineNodes.push(mathNode);
|
|
855
887
|
}
|
|
@@ -1045,7 +1077,8 @@ function convertImage(image, rawXml) {
|
|
|
1045
1077
|
borderStyle,
|
|
1046
1078
|
wrapText,
|
|
1047
1079
|
hlinkHref: image.hlinkHref,
|
|
1048
|
-
_docxRawXml: rawXml
|
|
1080
|
+
_docxRawXml: rawXml,
|
|
1081
|
+
_docxObjectPreview: rawXml !== void 0 && /<(?:[A-Za-z_][\w.-]*:)?object(?:\s|>)/u.test(rawXml)
|
|
1049
1082
|
});
|
|
1050
1083
|
}
|
|
1051
1084
|
/**
|
|
@@ -1106,6 +1139,7 @@ function textFormattingToMarks(formatting) {
|
|
|
1106
1139
|
eastAsiaTheme: formatting.fontFamily.eastAsiaTheme,
|
|
1107
1140
|
csTheme: formatting.fontFamily.csTheme
|
|
1108
1141
|
}));
|
|
1142
|
+
if (formatting.language) marks.push(schema.mark("language", formatting.language));
|
|
1109
1143
|
if (formatting.vertAlign === "superscript") marks.push(schema.mark("superscript"));
|
|
1110
1144
|
else if (formatting.vertAlign === "subscript") marks.push(schema.mark("subscript"));
|
|
1111
1145
|
if (formatting.allCaps) marks.push(schema.mark("allCaps"));
|
|
@@ -1264,6 +1298,7 @@ function extractTextBoxesFromParagraph(paragraph) {
|
|
|
1264
1298
|
if (shape.fill) textBox.fill = shape.fill;
|
|
1265
1299
|
if (shape.outline) textBox.outline = shape.outline;
|
|
1266
1300
|
if (shape.textBody.margins) textBox.margins = shape.textBody.margins;
|
|
1301
|
+
if (shape.textBody.autoFit) textBox.autoFit = shape.textBody.autoFit;
|
|
1267
1302
|
textBoxes.push(textBox);
|
|
1268
1303
|
}
|
|
1269
1304
|
}
|
|
@@ -1332,6 +1367,7 @@ function convertTextBox(textBox, styleResolver, options = {}) {
|
|
|
1332
1367
|
return schema.node("textBox", {
|
|
1333
1368
|
width: widthPx,
|
|
1334
1369
|
height: heightPx,
|
|
1370
|
+
autoFit: textBox.autoFit,
|
|
1335
1371
|
textBoxId: textBox.id,
|
|
1336
1372
|
fillColor,
|
|
1337
1373
|
outlineWidth,
|
|
@@ -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,8 @@ const paragraphNodeSpec = {
|
|
|
199
202
|
listMarkerHidden: { default: null },
|
|
200
203
|
listMarkerFontFamily: { default: null },
|
|
201
204
|
listMarkerFontSize: { default: null },
|
|
205
|
+
listMarkerBold: { default: null },
|
|
206
|
+
listMarkerAlignment: { default: null },
|
|
202
207
|
listMarkerSuffix: { default: null },
|
|
203
208
|
listMarkerAllCaps: { default: null },
|
|
204
209
|
listImplicitChildLevelAdvances: { default: null },
|
|
@@ -213,6 +218,7 @@ const paragraphNodeSpec = {
|
|
|
213
218
|
tabs: { default: null },
|
|
214
219
|
pageBreakBefore: { default: null },
|
|
215
220
|
renderedPageBreakBefore: { default: null },
|
|
221
|
+
_pageBreakCarrier: { default: null },
|
|
216
222
|
keepNext: { default: null },
|
|
217
223
|
keepLines: { default: null },
|
|
218
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
|