@stll/folio-core 0.47.7 → 0.49.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/dist/ai-edits/apply.js +565 -121
- package/dist/ai-edits/minimal-replacement.d.ts +64 -0
- package/dist/ai-edits/minimal-replacement.js +282 -0
- package/dist/controller/fontReadiness.js +3 -3
- package/dist/controller/hyphenationReadiness.d.ts +19 -0
- package/dist/controller/hyphenationReadiness.js +47 -0
- package/dist/controller/layoutPipeline.d.ts +3 -0
- package/dist/controller/layoutPipeline.js +70 -18
- package/dist/display-list/build/buildDisplayList.js +39 -12
- package/dist/display-list/build/pageFurniture.d.ts +7 -1
- package/dist/display-list/build/pageFurniture.js +21 -8
- package/dist/display-list/build/paragraphPrimitives.js +68 -11
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/display-list/build/textBoxPrimitives.js +1 -1
- package/dist/display-list/build/unsupported.d.ts +2 -2
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +79 -64
- package/dist/docx/bulletMarkers.d.ts +18 -2
- package/dist/docx/bulletMarkers.js +27 -2
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +57 -45
- package/dist/docx/containerChildren.d.ts +21 -8
- package/dist/docx/containerChildren.js +39 -9
- package/dist/docx/documentParser.d.ts +5 -1
- package/dist/docx/documentParser.js +8 -5
- package/dist/docx/documentSectionFacts.d.ts +22 -0
- package/dist/docx/documentSectionFacts.js +43 -0
- package/dist/docx/drawingGroupChildren.d.ts +60 -0
- package/dist/docx/drawingGroupChildren.js +176 -0
- package/dist/docx/drawingUtils.js +3 -0
- package/dist/docx/fieldParser.d.ts +8 -1
- package/dist/docx/fieldParser.js +47 -3
- package/dist/docx/fontTableParser.js +34 -27
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +15 -12
- package/dist/docx/groupDrawingParser.d.ts +9 -2
- package/dist/docx/groupDrawingParser.js +125 -37
- package/dist/docx/headerFooterParser.d.ts +7 -2
- package/dist/docx/headerFooterParser.js +15 -5
- package/dist/docx/hyperlinkParser.d.ts +48 -36
- package/dist/docx/hyperlinkParser.js +97 -82
- package/dist/docx/numberingParser.js +108 -84
- package/dist/docx/packageParts.d.ts +45 -1
- package/dist/docx/packageParts.js +93 -2
- package/dist/docx/paraIdAttribute.d.ts +3 -2
- package/dist/docx/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +468 -365
- package/dist/docx/paragraphProperties.js +123 -109
- package/dist/docx/paragraphPropertySource.d.ts +6 -1
- package/dist/docx/paragraphPropertySource.js +9 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
- package/dist/docx/parser.d.ts +7 -1
- package/dist/docx/parser.js +33 -16
- package/dist/docx/previewBudget.d.ts +55 -33
- package/dist/docx/previewBudget.js +59 -65
- package/dist/docx/rezip.js +41 -58
- package/dist/docx/runParser.d.ts +4 -1
- package/dist/docx/runParser.js +182 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/selectiveSaveFlags.d.ts +10 -3
- package/dist/docx/selectiveSaveFlags.js +1 -1
- package/dist/docx/selectiveXmlPatch.d.ts +56 -34
- package/dist/docx/selectiveXmlPatch.js +222 -115
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
- package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
- package/dist/docx/serializer/paragraphSerializer.js +47 -42
- package/dist/docx/serializer/runSerializer.d.ts +5 -1
- package/dist/docx/serializer/runSerializer.js +4 -3
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -0
- package/dist/docx/shapeAlternateContent.d.ts +25 -0
- package/dist/docx/shapeAlternateContent.js +52 -0
- package/dist/docx/streamingXmlParser.d.ts +6 -2
- package/dist/docx/streamingXmlParser.js +12 -7
- package/dist/docx/styleParser.js +34 -8
- package/dist/docx/tableParser.d.ts +21 -12
- package/dist/docx/tableParser.js +518 -441
- package/dist/docx/textBoxParser.d.ts +18 -5
- package/dist/docx/textBoxParser.js +12 -6
- package/dist/docx/verbatimCapture.d.ts +10 -8
- package/dist/docx/verbatimCapture.js +45 -2
- package/dist/docx/vmlImageParser.d.ts +15 -13
- package/dist/docx/vmlImageParser.js +75 -60
- package/dist/docx/vmlPreview.d.ts +3 -3
- package/dist/docx/vmlPreview.js +3 -4
- package/dist/docx/xmlNamespaceContext.d.ts +9 -0
- package/dist/docx/xmlNamespaceContext.js +54 -0
- package/dist/docx/xmlParser.d.ts +6 -3
- package/dist/docx/xmlParser.js +11 -41
- package/dist/docx/xmlResourceLimits.d.ts +2 -1
- package/dist/docx/xmlResourceLimits.js +4 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.d.ts +11 -2
- package/dist/headless-layout.js +153 -107
- package/dist/internal/headlessRevisionResolution.js +50 -13
- package/dist/internal/paragraphFormattingSerialization.js +3 -3
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
- package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
- package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
- package/dist/layout-bridge/engine/hitTest.js +5 -3
- package/dist/layout-bridge/engine/selectionRects.js +5 -3
- package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
- package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +102 -14
- package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
- package/dist/layout-engine/justificationCompatibility.js +9 -5
- package/dist/layout-engine/keep-together.d.ts +15 -6
- package/dist/layout-engine/keep-together.js +43 -16
- package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
- package/dist/layout-engine/layoutInstrumentation.js +8 -1
- package/dist/layout-engine/measure/advanceComposition.js +50 -7
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
- package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
- package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
- package/dist/layout-engine/measure/lineBreaks.js +10 -3
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
- package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
- package/dist/layout-engine/measure/measureBlocks.js +46 -10
- package/dist/layout-engine/measure/measureContainer.js +51 -8
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +34 -8
- package/dist/layout-engine/measure/measureParagraph.js +143 -101
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
- package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
- package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
- package/dist/layout-engine/measure/tabCalculator.js +2 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +51 -19
- package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
- package/dist/layout-engine/measure/tableCellGrid.js +45 -5
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
- package/dist/layout-engine/noteAreaFlow.js +83 -0
- package/dist/layout-engine/paginator.d.ts +12 -1
- package/dist/layout-engine/paginator.js +18 -2
- package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
- package/dist/layout-engine/paragraphSpacing.js +2 -1
- package/dist/layout-engine/tableRowBreak.d.ts +8 -1
- package/dist/layout-engine/tableRowBreak.js +25 -2
- package/dist/layout-engine/types.d.ts +108 -3
- package/dist/layout-engine/types.js +96 -1
- package/dist/layout-painter/index.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +32 -83
- package/dist/layout-painter/renderParagraph.d.ts +6 -1
- package/dist/layout-painter/renderParagraph.js +75 -26
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/layout-painter/renderTextBox.d.ts +12 -2
- package/dist/layout-painter/renderTextBox.js +26 -2
- package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
- package/dist/prosemirror/alternateContentAttrs.js +35 -0
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +133 -11
- package/dist/prosemirror/commands/comments.js +51 -41
- package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
- package/dist/prosemirror/contentControlRevisions.js +84 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +117 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +4 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/paragraphDirection.d.ts +29 -2
- package/dist/prosemirror/paragraphDirection.js +21 -2
- package/dist/prosemirror/plugins/suggestionMode.js +37 -8
- package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
- package/dist/prosemirror/rejoinRunCarriers.js +66 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
- package/dist/prosemirror/schema/nodes.d.ts +50 -6
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +10 -1
- package/dist/utils/scriptSegments.d.ts +33 -4
- package/dist/utils/scriptSegments.js +39 -6
- package/dist/utils/textFormattingMerge.d.ts +17 -3
- package/dist/utils/textFormattingMerge.js +18 -12
- package/dist/utils/trailingText.d.ts +22 -0
- package/dist/utils/trailingText.js +32 -0
- package/package.json +2 -2
- package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
- package/dist/layout-engine/justifiedLineFit.js +0 -6
|
@@ -5,7 +5,7 @@ import { collectFloatingImages, pageGeometryOf } from "./floatingImages.js";
|
|
|
5
5
|
import { FontTable } from "./fontTable.js";
|
|
6
6
|
import { paintPageFurniture } from "./furniture.js";
|
|
7
7
|
import { ImageTable, paintImageFragment } from "./imagePrimitives.js";
|
|
8
|
-
import { paintColumnSeparators, paintPageBackground } from "./pageFurniture.js";
|
|
8
|
+
import { paintColumnSeparators, paintFlowedNoteSeparators, paintPageBackground } from "./pageFurniture.js";
|
|
9
9
|
import { paintParagraphFragment } from "./paragraphPrimitives.js";
|
|
10
10
|
import { blockRegion, createPageComposer } from "./regions.js";
|
|
11
11
|
import { paintTableFragment } from "./tablePrimitives.js";
|
|
@@ -231,24 +231,51 @@ const buildPage = ({ page, pageIndex, totalPages, blockLookup, pageBackground, b
|
|
|
231
231
|
unsupported.report(UNSUPPORTED_CONSTRUCT.missingBlock, pageIndex, `no block lookup entry for ${fragment.kind} fragment ${String(fragment.blockId)}`);
|
|
232
232
|
continue;
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
kind: FRAGMENT_REGION_KIND[fragment.kind],
|
|
237
|
-
context
|
|
238
|
-
}), () => {
|
|
239
|
-
paintFragment({
|
|
234
|
+
const paint = (fragmentContext) => {
|
|
235
|
+
composer.region(blockRegion({
|
|
240
236
|
fragment,
|
|
241
|
-
|
|
242
|
-
context
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
237
|
+
kind: FRAGMENT_REGION_KIND[fragment.kind],
|
|
238
|
+
context: fragmentContext
|
|
239
|
+
}), () => {
|
|
240
|
+
paintFragment({
|
|
241
|
+
fragment,
|
|
242
|
+
entry,
|
|
243
|
+
context: fragmentContext,
|
|
244
|
+
composer,
|
|
245
|
+
prevEntry: entries[index - 1],
|
|
246
|
+
nextEntry: entries[index + 1]
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const noteStory = entry.noteStory;
|
|
251
|
+
if (noteStory === void 0) {
|
|
252
|
+
paint(context);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const story = {
|
|
256
|
+
kind: noteStory.kind,
|
|
257
|
+
id: noteStory.noteId
|
|
258
|
+
};
|
|
259
|
+
composer.region({
|
|
260
|
+
kind: HIT_REGION_KINDS.note,
|
|
261
|
+
rect: {
|
|
262
|
+
xPx: fragment.x,
|
|
263
|
+
yPx: fragment.y,
|
|
264
|
+
widthPx: fragment.width,
|
|
265
|
+
heightPx: fragment.height
|
|
266
|
+
},
|
|
267
|
+
model: { story }
|
|
268
|
+
}, () => {
|
|
269
|
+
paint({
|
|
270
|
+
...context,
|
|
271
|
+
story
|
|
246
272
|
});
|
|
247
273
|
});
|
|
248
274
|
}
|
|
249
275
|
});
|
|
250
276
|
composer.push(frontFloats);
|
|
251
277
|
composer.push(paintColumnSeparators(page));
|
|
278
|
+
composer.push(paintFlowedNoteSeparators(page));
|
|
252
279
|
above(composer);
|
|
253
280
|
return {
|
|
254
281
|
pageNumber: page.number,
|
|
@@ -11,6 +11,12 @@ declare const paintPageBackground: (page: Page, fill: DisplayColor) => DisplayPr
|
|
|
11
11
|
* never drew them.
|
|
12
12
|
*/
|
|
13
13
|
declare const paintColumnSeparators: (page: Page) => readonly DisplayPrimitive[];
|
|
14
|
+
/**
|
|
15
|
+
* The separator rules of a note area laid out in the body flow (endnotes): the
|
|
16
|
+
* paginator records where each `w:separator` / `w:continuationSeparator` mark
|
|
17
|
+
* landed, so like the column rules they are derivable from the `Layout` alone.
|
|
18
|
+
*/
|
|
19
|
+
declare const paintFlowedNoteSeparators: (page: Page) => readonly DisplayPrimitive[];
|
|
14
20
|
type FootnoteAreaPaintOptions = {
|
|
15
21
|
readonly composer: PageComposer;
|
|
16
22
|
readonly page: Page;
|
|
@@ -32,4 +38,4 @@ type FootnoteAreaPaintOptions = {
|
|
|
32
38
|
*/
|
|
33
39
|
declare const paintFootnoteArea: ({ composer, page, context, contentById }: FootnoteAreaPaintOptions) => void;
|
|
34
40
|
//#endregion
|
|
35
|
-
export { FootnoteAreaPaintOptions, paintColumnSeparators, paintFootnoteArea, paintPageBackground };
|
|
41
|
+
export { FootnoteAreaPaintOptions, paintColumnSeparators, paintFlowedNoteSeparators, paintFootnoteArea, paintPageBackground };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../layout-engine/types.js";
|
|
1
|
+
import { NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION } from "../../layout-engine/types.js";
|
|
2
2
|
import { calculateFootnoteAreaRenderHeight } from "../../layout-painter/renderPage.js";
|
|
3
3
|
import { HIT_REGION_KINDS } from "../primitives.js";
|
|
4
4
|
import { DOC_CANVAS_TEXT } from "./colors.js";
|
|
@@ -20,10 +20,8 @@ import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
|
|
|
20
20
|
*/
|
|
21
21
|
/** `renderPage.ts:2049`: a hairline in the canvas ink colour. */
|
|
22
22
|
const COLUMN_SEPARATOR_WIDTH_PX = .5;
|
|
23
|
-
/** `
|
|
24
|
-
const
|
|
25
|
-
const FOOTNOTE_RULE_WIDTH_FRACTION = .33;
|
|
26
|
-
const FOOTNOTE_RULE_MARGIN_PX = (12 - FOOTNOTE_RULE_THICKNESS_PX) / 2;
|
|
23
|
+
/** `renderFootnoteArea`: a hairline across a third of the column, centred in its 12px slot. */
|
|
24
|
+
const FOOTNOTE_RULE_MARGIN_PX = (12 - NOTE_SEPARATOR_RULE_THICKNESS) / 2;
|
|
27
25
|
const paintPageBackground = (page, fill) => ({
|
|
28
26
|
kind: "rect",
|
|
29
27
|
rect: {
|
|
@@ -63,6 +61,21 @@ const paintColumnSeparators = (page) => {
|
|
|
63
61
|
return primitives;
|
|
64
62
|
};
|
|
65
63
|
/**
|
|
64
|
+
* The separator rules of a note area laid out in the body flow (endnotes): the
|
|
65
|
+
* paginator records where each `w:separator` / `w:continuationSeparator` mark
|
|
66
|
+
* landed, so like the column rules they are derivable from the `Layout` alone.
|
|
67
|
+
*/
|
|
68
|
+
const paintFlowedNoteSeparators = (page) => (page.noteSeparators ?? []).map((rule) => ({
|
|
69
|
+
kind: "rect",
|
|
70
|
+
rect: {
|
|
71
|
+
xPx: rule.x,
|
|
72
|
+
yPx: rule.y,
|
|
73
|
+
widthPx: rule.width,
|
|
74
|
+
heightPx: NOTE_SEPARATOR_RULE_THICKNESS
|
|
75
|
+
},
|
|
76
|
+
fill: DOC_CANVAS_TEXT
|
|
77
|
+
}));
|
|
78
|
+
/**
|
|
66
79
|
* The footnote band at the foot of the body column: the separator rule, then
|
|
67
80
|
* one body per note the paginator put on this page.
|
|
68
81
|
*
|
|
@@ -98,8 +111,8 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
98
111
|
rect: {
|
|
99
112
|
xPx: page.margins.left,
|
|
100
113
|
yPx: areaTopPx + FOOTNOTE_RULE_MARGIN_PX,
|
|
101
|
-
widthPx: contentWidthPx *
|
|
102
|
-
heightPx:
|
|
114
|
+
widthPx: contentWidthPx * NOTE_SEPARATOR_WIDTH_FRACTION,
|
|
115
|
+
heightPx: NOTE_SEPARATOR_RULE_THICKNESS
|
|
103
116
|
},
|
|
104
117
|
fill: DOC_CANVAS_TEXT
|
|
105
118
|
}];
|
|
@@ -138,4 +151,4 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
138
151
|
}
|
|
139
152
|
};
|
|
140
153
|
//#endregion
|
|
141
|
-
export { paintColumnSeparators, paintFootnoteArea, paintPageBackground };
|
|
154
|
+
export { paintColumnSeparators, paintFlowedNoteSeparators, paintFootnoteArea, paintPageBackground };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { getListMarkerInlineWidth, getListMarkerVisualOffset, resolveListMarkerFont } from "../../layout-engine/measure/listMarkerWidth.js";
|
|
2
2
|
import { DEFAULT_FONT_FAMILY, buildRunFontStyle, ptToPx } from "../../layout-engine/measure/measureHelpers.js";
|
|
3
3
|
import { getFontMetrics, measureTextWidth } from "../../layout-engine/measure/measureProvider.js";
|
|
4
|
+
import { SMALL_CAPS_SCALE, smallCapsSegments } from "../../layout-engine/measure/smallCapsCasing.js";
|
|
4
5
|
import { calculateTabWidth, pixelsToTwips } from "../../layout-engine/measure/tabCalculator.js";
|
|
5
6
|
import { countCompressibleSpaces, toPaintedText } from "../../layout-engine/measure/textMeasurementPolicy.js";
|
|
6
7
|
import { isFloatingImageRun } from "../../layout-engine/types.js";
|
|
7
8
|
import { resolveParagraphBorderHorizontalOutsets } from "../../layout-painter/borderStroke.js";
|
|
8
9
|
import { getAutomaticTextColorForBackground } from "../../layout-painter/documentColors.js";
|
|
9
|
-
import { UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableTextColor, paragraphHasTrackedChanges, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap } from "../../layout-painter/renderParagraph.js";
|
|
10
|
+
import { UNICODE_BIDI_BY_WRAPPER_CONTROL, getLeaderChar, getRenderableListMarkerColor, getRenderableTextColor, paragraphHasTrackedChanges, sliceRunsForLine, splitCollapsibleLineEdgeSpaces, splitTextRunsByEastAsia, startsAfterSoftWrap } from "../../layout-painter/renderParagraph.js";
|
|
10
11
|
import { getHorizontalScaleFactor } from "../../utils/horizontalScale.js";
|
|
11
12
|
import { resolvePhysicalParagraphInlineLayout } from "../../utils/paragraphInlineLayout.js";
|
|
12
13
|
import { inlineImageBoundingBox } from "../../utils/rotationBoundingBox.js";
|
|
@@ -315,6 +316,39 @@ const runGlyphDirection = (run, paragraphIsRtl) => run.bidiWrapper?.direction ??
|
|
|
315
316
|
*/
|
|
316
317
|
const runUnicodeBidi = (run) => run.bidiWrapper === void 0 ? void 0 : UNICODE_BIDI_BY_WRAPPER_CONTROL[run.bidiWrapper.control];
|
|
317
318
|
/**
|
|
319
|
+
* `glyphs` split into same-size stretches for a `w:smallCaps` run, or
|
|
320
|
+
* `undefined` when it has no lowercase letter (a heading typed in caps, a run
|
|
321
|
+
* of digits and punctuation): that run paints as the single glyph run it
|
|
322
|
+
* always did, no backend work spent on a split it does not need.
|
|
323
|
+
*
|
|
324
|
+
* Every backend draws one glyph size per `glyphRun` (a PDF's `Tf` sets the
|
|
325
|
+
* whole text-showing operation's size; a DOM span sets one `font-size`), so a
|
|
326
|
+
* mixed-size run becomes a short run of primitives instead of one primitive
|
|
327
|
+
* with glyphs a backend cannot all draw at the size it is told. `advancesPx`
|
|
328
|
+
* is sliced from the already-measured run — the widths line breaking decided
|
|
329
|
+
* on — never re-measured, so the split cannot disagree with the width the
|
|
330
|
+
* line was fitted at.
|
|
331
|
+
*/
|
|
332
|
+
const smallCapsGlyphRunSegments = (glyphs, fontSizePx) => {
|
|
333
|
+
const segments = smallCapsSegments(glyphs.text);
|
|
334
|
+
if (!segments.some((segment) => segment.small)) return;
|
|
335
|
+
const smallFontSizePx = fontSizePx * SMALL_CAPS_SCALE;
|
|
336
|
+
const result = [];
|
|
337
|
+
let advanceIndex = 0;
|
|
338
|
+
for (const segment of segments) {
|
|
339
|
+
const codePointCount = [...segment.text].length;
|
|
340
|
+
const advancesPx = glyphs.advancesPx.slice(advanceIndex, advanceIndex + codePointCount);
|
|
341
|
+
advanceIndex += codePointCount;
|
|
342
|
+
result.push({
|
|
343
|
+
text: segment.text,
|
|
344
|
+
fontSizePx: segment.small ? smallFontSizePx : fontSizePx,
|
|
345
|
+
advancesPx,
|
|
346
|
+
widthPx: advancesPx.reduce((sum, advance) => sum + advance, 0)
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
318
352
|
* One `glyphRun` plus everything painted around it: the run's background rect
|
|
319
353
|
* first, then the glyphs, then the decorations whose geometry CSS would have
|
|
320
354
|
* derived from the font.
|
|
@@ -368,7 +402,7 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
368
402
|
} else context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `run background ${background}`);
|
|
369
403
|
}
|
|
370
404
|
const font = context.fonts.intern({
|
|
371
|
-
fontFamily: style.fontFamily ?? "
|
|
405
|
+
fontFamily: style.fontFamily ?? "Times New Roman",
|
|
372
406
|
...style.alternateFontFamily === void 0 ? {} : { alternateFontFamily: style.alternateFontFamily },
|
|
373
407
|
...style.bold === void 0 ? {} : { bold: style.bold },
|
|
374
408
|
...style.italic === void 0 ? {} : { italic: style.italic },
|
|
@@ -380,20 +414,43 @@ const emitGlyphRun = ({ sink, context, run, glyphs, style, paintXPx, baselineYPx
|
|
|
380
414
|
pattern: "solid"
|
|
381
415
|
} : void 0;
|
|
382
416
|
const unicodeBidi = runUnicodeBidi(run);
|
|
383
|
-
|
|
384
|
-
|
|
417
|
+
const direction = runGlyphDirection(run, isRtl);
|
|
418
|
+
const commonFields = {
|
|
385
419
|
font,
|
|
386
|
-
fontSizePx,
|
|
387
420
|
color,
|
|
388
|
-
xPx: paintXPx,
|
|
389
421
|
baselineYPx: runBaselineYPx,
|
|
390
|
-
|
|
391
|
-
direction: runGlyphDirection(run, isRtl),
|
|
422
|
+
direction,
|
|
392
423
|
...unicodeBidi === void 0 ? {} : { unicodeBidi },
|
|
393
424
|
...stroke === void 0 ? {} : { stroke },
|
|
394
425
|
...pmRange === void 0 ? {} : { pmRange },
|
|
395
426
|
...collapsedEdge === void 0 ? {} : { collapsedEdge }
|
|
427
|
+
};
|
|
428
|
+
const smallCapsRuns = style.fontVariant === "small-caps" && direction === "ltr" ? smallCapsGlyphRunSegments(glyphs, fontSizePx) : void 0;
|
|
429
|
+
if (smallCapsRuns === void 0) sink.glyphs.push({
|
|
430
|
+
kind: "glyphRun",
|
|
431
|
+
fontSizePx,
|
|
432
|
+
xPx: paintXPx,
|
|
433
|
+
...glyphRunText(glyphs),
|
|
434
|
+
...commonFields
|
|
396
435
|
});
|
|
436
|
+
else {
|
|
437
|
+
const adjustments = glyphs.adjustments === void 0 ? {} : { adjustments: glyphs.adjustments };
|
|
438
|
+
let segmentXPx = paintXPx;
|
|
439
|
+
for (const segment of smallCapsRuns) {
|
|
440
|
+
sink.glyphs.push({
|
|
441
|
+
kind: "glyphRun",
|
|
442
|
+
fontSizePx: segment.fontSizePx,
|
|
443
|
+
xPx: segmentXPx,
|
|
444
|
+
text: segment.text,
|
|
445
|
+
advancesPx: segment.advancesPx,
|
|
446
|
+
kerning: glyphs.kerning,
|
|
447
|
+
smallCaps: true,
|
|
448
|
+
...adjustments,
|
|
449
|
+
...commonFields
|
|
450
|
+
});
|
|
451
|
+
segmentXPx += segment.widthPx;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
397
454
|
emitDecorations({
|
|
398
455
|
sink,
|
|
399
456
|
run,
|
|
@@ -506,7 +563,6 @@ const emitDecorations = ({ sink, run, color, context, xPx, glyphs, baselineYPx,
|
|
|
506
563
|
*/
|
|
507
564
|
const reportRunEffects = (run, context) => {
|
|
508
565
|
const { unsupported, pageIndex } = context;
|
|
509
|
-
if (run.smallCaps) unsupported.report(UNSUPPORTED_CONSTRUCT.smallCaps, pageIndex, "w:smallCaps is carried on the run and painted by the DOM backend; the PDF backend paints full-size glyphs for it");
|
|
510
566
|
if (getHorizontalScaleFactor(run.horizontalScale) !== 1) unsupported.report(UNSUPPORTED_CONSTRUCT.horizontalScale, pageIndex, `w:w ${String(run.horizontalScale)}% is carried on the run and painted by the DOM backend; the PDF backend paints unnarrowed glyphs at the measured advances`);
|
|
511
567
|
if (run.textEffect) unsupported.report(UNSUPPORTED_CONSTRUCT.textEffect, pageIndex, `w:effect ${run.textEffect}`);
|
|
512
568
|
if (run.emphasisMark) unsupported.report(UNSUPPORTED_CONSTRUCT.emphasisMark, pageIndex, `w:em ${run.emphasisMark}`);
|
|
@@ -729,6 +785,7 @@ const paintLine = ({ block, line, geometry, context, alignment, isRtl, isFirstLi
|
|
|
729
785
|
tabRegions
|
|
730
786
|
};
|
|
731
787
|
};
|
|
788
|
+
const parseMarkerColor = (color) => color === void 0 ? void 0 : parseDisplayColor(color);
|
|
732
789
|
const paintListMarker = ({ sink, block, context, paintXPx, baselineYPx, isRtl }) => {
|
|
733
790
|
const marker = block.attrs?.listMarker;
|
|
734
791
|
if (marker === void 0 || marker.length === 0) return;
|
|
@@ -742,7 +799,7 @@ const paintListMarker = ({ sink, block, context, paintXPx, baselineYPx, isRtl })
|
|
|
742
799
|
collapsed: false
|
|
743
800
|
});
|
|
744
801
|
const revision = block.attrs?.listMarkerRevision;
|
|
745
|
-
const color = revision ? trackedChangeColor(context.authorColors, revision.author, void 0) : DOC_CANVAS_TEXT;
|
|
802
|
+
const color = revision ? trackedChangeColor(context.authorColors, revision.author, void 0) : parseMarkerColor(getRenderableListMarkerColor(formatting.color)) ?? DOC_CANVAS_TEXT;
|
|
746
803
|
const font = context.fonts.intern({
|
|
747
804
|
fontFamily: formatting.fontFamily,
|
|
748
805
|
...formatting.alternateFontFamily === void 0 ? {} : { alternateFontFamily: formatting.alternateFontFamily },
|
|
@@ -813,7 +870,7 @@ const paintTab = ({ sink, context, runs, index, run, tabContext, layoutXPx, pain
|
|
|
813
870
|
collapsed: false
|
|
814
871
|
});
|
|
815
872
|
const font = context.fonts.intern({
|
|
816
|
-
fontFamily: style.fontFamily ?? "
|
|
873
|
+
fontFamily: style.fontFamily ?? "Times New Roman",
|
|
817
874
|
...style.bold === void 0 ? {} : { bold: style.bold },
|
|
818
875
|
...style.italic === void 0 ? {} : { italic: style.italic },
|
|
819
876
|
measureStyle: style
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createTableCellFlowState, placeTableCellBlock } from "../../layout-engine/measure/tableCellFlow.js";
|
|
2
|
-
import { buildTableCellGrid, buildTableCellPlacements, getSourceCellAt } from "../../layout-engine/measure/tableCellGrid.js";
|
|
2
|
+
import { buildTableCellGrid, buildTableCellPlacements, getSourceCellAt, getTableCellSpacingInsetsY } from "../../layout-engine/measure/tableCellGrid.js";
|
|
3
3
|
import { tableFragmentBottomBorders } from "../../layout-engine/measure/tableFragmentBorderGeometry.js";
|
|
4
4
|
import { resolveTableCellPadding } from "../../layout-engine/types.js";
|
|
5
5
|
import { cellTextRotationDegrees } from "../../layout-painter/renderTable.js";
|
|
@@ -253,8 +253,10 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
253
253
|
const placements = buildTableCellPlacements({
|
|
254
254
|
grid,
|
|
255
255
|
columnWidths: measure.columnWidths,
|
|
256
|
-
bidi: block.bidi === true
|
|
256
|
+
bidi: block.bidi === true,
|
|
257
|
+
cellSpacing: block.cellSpacing
|
|
257
258
|
});
|
|
259
|
+
const bordersSeparated = (block.cellSpacing ?? 0) > 0;
|
|
258
260
|
const rowTops = [0];
|
|
259
261
|
for (const rowMeasure of measure.rows) rowTops.push((rowTops.at(-1) ?? 0) + rowMeasure.height);
|
|
260
262
|
const paintRow = (rowIndex, rowYPx) => {
|
|
@@ -283,7 +285,9 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
283
285
|
if (!placement) continue;
|
|
284
286
|
const rowSpan = Math.max(1, Math.trunc(cell.rowSpan ?? 1));
|
|
285
287
|
const spanEnd = Math.min(rowTops.length - 1, rowIndex + rowSpan);
|
|
286
|
-
const
|
|
288
|
+
const slotHeightPx = spanEnd > rowIndex ? rowTops[spanEnd] - rowTops[rowIndex] : rowMeasure.height;
|
|
289
|
+
const spacing = getTableCellSpacingInsetsY(block.cellSpacing, rowIndex, rowSpan, block.rows.length);
|
|
290
|
+
const heightPx = Math.max(0, slotHeightPx - spacing.top - spacing.bottom);
|
|
287
291
|
const atLogicalStart = placement.sourceColumn === 0;
|
|
288
292
|
const atLogicalEnd = placement.sourceColumn + placement.columnSpan >= measure.columnWidths.length;
|
|
289
293
|
const isFirstColumn = block.bidi === true ? atLogicalEnd : atLogicalStart;
|
|
@@ -292,7 +296,7 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
292
296
|
const leftCell = getSourceCellAt(grid, rowIndex, leftNeighborColumn);
|
|
293
297
|
const box = {
|
|
294
298
|
xPx: xPx + placement.left,
|
|
295
|
-
yPx: rowYPx,
|
|
299
|
+
yPx: rowYPx + spacing.top,
|
|
296
300
|
widthPx: placement.width,
|
|
297
301
|
heightPx
|
|
298
302
|
};
|
|
@@ -312,9 +316,9 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
312
316
|
context,
|
|
313
317
|
paintTextBox,
|
|
314
318
|
sides: {
|
|
315
|
-
top: rowIndex === fromRow || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
319
|
+
top: bordersSeparated || rowIndex === fromRow || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
316
320
|
bottom: true,
|
|
317
|
-
left: isFirstColumn || !hasVisibleBorder(leftCell?.borders?.right),
|
|
321
|
+
left: bordersSeparated || isFirstColumn || !hasVisibleBorder(leftCell?.borders?.right),
|
|
318
322
|
right: true
|
|
319
323
|
}
|
|
320
324
|
});
|
|
@@ -64,7 +64,7 @@ const paintUnrotatedTextBoxFragment = ({ composer, fragment, block, measure, con
|
|
|
64
64
|
fill
|
|
65
65
|
});
|
|
66
66
|
else context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `text box fill ${block.fillColor}`);
|
|
67
|
-
}
|
|
67
|
+
} else if (block.fillGradient) context.unsupported.report(UNSUPPORTED_CONSTRUCT.textBoxGradientFill, context.pageIndex, "text box gradient fill");
|
|
68
68
|
let outlineWidthPx = 0;
|
|
69
69
|
const outlineDash = presetDashForOutlineAttr(block.outlineStyle) ?? "solid";
|
|
70
70
|
if (block.outlineWidth !== void 0 && block.outlineWidth > 0 && outlineDash !== "none") {
|
|
@@ -7,8 +7,6 @@ import { DisplayUnsupported } from "../types.js";
|
|
|
7
7
|
declare const UNSUPPORTED_CONSTRUCT: {
|
|
8
8
|
/** `w:effect` animations (blinkBackground, shimmer, …). */
|
|
9
9
|
readonly textEffect: "textEffect";
|
|
10
|
-
/** `w:smallCaps`: advances are correct, the small-cap glyph choice is not expressible. */
|
|
11
|
-
readonly smallCaps: "smallCaps";
|
|
12
10
|
/** `w:w` horizontal scale: folded into advances, but the glyphs are not narrowed. */
|
|
13
11
|
readonly horizontalScale: "horizontalScale";
|
|
14
12
|
/** `w:em` emphasis marks. */
|
|
@@ -39,6 +37,8 @@ declare const UNSUPPORTED_CONSTRUCT: {
|
|
|
39
37
|
readonly headerFooterContent: "headerFooterContent";
|
|
40
38
|
/** `a:bodyPr` middle/bottom anchoring inside a text box. */
|
|
41
39
|
readonly textBoxVerticalAlign: "textBoxVerticalAlign";
|
|
40
|
+
/** A text box's `a:gradFill`: the primitives carry no gradient. */
|
|
41
|
+
readonly textBoxGradientFill: "textBoxGradientFill";
|
|
42
42
|
/** A fragment kind with no builder. */
|
|
43
43
|
readonly fragmentKind: "fragmentKind";
|
|
44
44
|
/** A fragment whose block or measure is missing from the block lookup. */
|
|
Binary file
|
|
@@ -297,7 +297,6 @@ const paintGlyphRun = (run, context) => {
|
|
|
297
297
|
if (run.unicodeBidi !== void 0) span.style.unicodeBidi = run.unicodeBidi;
|
|
298
298
|
if (run.stroke !== void 0) span.style.webkitTextStroke = `${px(run.stroke.thicknessPx)} ${cssColor(run.stroke.color)}`;
|
|
299
299
|
span.style.fontKerning = run.kerning ? "normal" : "none";
|
|
300
|
-
if (run.smallCaps) span.style.fontVariant = "small-caps";
|
|
301
300
|
applyAdjustments(span, run.adjustments);
|
|
302
301
|
span.dataset["advanceSum"] = String(advanceSum);
|
|
303
302
|
applyModelRange(span, run.pmRange);
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { modelledAttributeNames } from "./propertyElementAttributes.js";
|
|
2
2
|
import { OOXML_NAMESPACES } from "./serializer/partNamespaces.js";
|
|
3
|
+
import { XML_NAMESPACE_URI } from "./xmlNamespaceContext.js";
|
|
3
4
|
import { getLocalName, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
4
5
|
import { TaggedError } from "better-result";
|
|
5
6
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
6
7
|
//#region src/docx/attributeRemainder.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Namespace URI to the prefix a rebuilt part binds for it.
|
|
10
|
+
*
|
|
11
|
+
* `xml` is reserved rather than declared — {@link OOXML_NAMESPACES} excludes
|
|
12
|
+
* it because a rebuilt part must never write `xmlns:xml` — so it is added
|
|
13
|
+
* here on its own: the remainder still has to spell `xml:space`, `xml:lang`
|
|
14
|
+
* and `xml:id` back, or the attribute is written unprefixed instead of dropped.
|
|
15
|
+
*/
|
|
16
|
+
const CANONICAL_PREFIX = new Map([...Object.entries(OOXML_NAMESPACES).map(([prefix, { uri }]) => [uri, prefix]), [XML_NAMESPACE_URI, "xml"]]);
|
|
9
17
|
const XML_LOCAL_NAME = /^[\p{L}_][\p{L}\p{M}\p{N}._\-\u{00B7}\u{203F}-\u{2040}]*$/u;
|
|
10
18
|
var InvalidPreservedAttributeError = class extends TaggedError("InvalidPreservedAttributeError") {};
|
|
11
19
|
/** Whether an attribute remainder can be emitted under a bound canonical name. */
|
|
@@ -2,12 +2,14 @@ import { document_d_exports } from "../types/document.js";
|
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
3
|
import { ParseContext } from "./parseContext.js";
|
|
4
4
|
import { XmlElement } from "./xmlParser.js";
|
|
5
|
+
import { PreviewLedger } from "./previewBudget.js";
|
|
5
6
|
import { StyleMap } from "./styleParser.js";
|
|
6
7
|
//#region src/docx/blockContentParser.d.ts
|
|
7
8
|
type ParseBlockContentOptions = {
|
|
8
9
|
inHeaderFooter?: boolean;
|
|
9
10
|
rootXmlns?: Record<string, string>;
|
|
10
11
|
context?: ParseContext | undefined;
|
|
12
|
+
previews?: PreviewLedger;
|
|
11
13
|
};
|
|
12
14
|
declare const parseBlockContent: (parent: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: ParseBlockContentOptions) => document_d_exports.BlockContent[];
|
|
13
15
|
//#endregion
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
2
|
-
import { convertBulletToUnicode } from "./bulletMarkers.js";
|
|
3
|
-
import { CAPTURE,
|
|
2
|
+
import { bulletMarkerFontName, convertBulletToUnicode } from "./bulletMarkers.js";
|
|
3
|
+
import { CAPTURE, dispatchChildrenWithContext, ownedElsewhere, withPreservedChildren } from "./containerChildren.js";
|
|
4
4
|
import { isNumberingReference } from "./numberingReference.js";
|
|
5
5
|
import { formatOoxmlCounter } from "./ooxmlCounterFormatter.js";
|
|
6
6
|
import { parseParagraph } from "./paragraphParser.js";
|
|
7
7
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
8
|
+
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
8
9
|
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
9
10
|
import { parseTable } from "./tableParser.js";
|
|
10
11
|
import { findWordprocessingChild, mergeXmlnsDeclarations, selectAlternateContentBranch } from "./xmlParser.js";
|
|
@@ -61,7 +62,7 @@ const computeListMarker = (paragraph, { numbering, listCounters, abstractCounter
|
|
|
61
62
|
previousList.numId = numId;
|
|
62
63
|
const pattern = listRendering.marker;
|
|
63
64
|
if (listRendering.isBullet) {
|
|
64
|
-
listRendering.marker = convertBulletToUnicode(pattern || "");
|
|
65
|
+
listRendering.marker = convertBulletToUnicode(pattern || "", bulletMarkerFontName(listRendering.markerFormatting));
|
|
65
66
|
previousList.abstractNumId = null;
|
|
66
67
|
previousList.fromStyle = false;
|
|
67
68
|
previousList.numId = null;
|
|
@@ -84,7 +85,7 @@ const withContainerXmlns = (state, element) => ({
|
|
|
84
85
|
...state,
|
|
85
86
|
options: {
|
|
86
87
|
...state.options,
|
|
87
|
-
rootXmlns: mergeXmlnsDeclarations(state.options
|
|
88
|
+
rootXmlns: mergeXmlnsDeclarations(state.options.rootXmlns ?? {}, element)
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
/**
|
|
@@ -121,74 +122,88 @@ const parseBlockContent = (parent, styles, theme, numbering, rels, media, option
|
|
|
121
122
|
},
|
|
122
123
|
options: {
|
|
123
124
|
...options,
|
|
124
|
-
rootXmlns: mergeXmlnsDeclarations(options?.rootXmlns ?? {}, parent)
|
|
125
|
+
rootXmlns: mergeXmlnsDeclarations(options?.rootXmlns ?? {}, parent),
|
|
126
|
+
previews: options?.previews ?? standalonePreviewLedger()
|
|
125
127
|
}
|
|
126
128
|
});
|
|
129
|
+
const BLOCK_CONTENT_UNDECLARED = { AlternateContent: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
130
|
+
const selectedBranch = selectAlternateContentBranch(child);
|
|
131
|
+
if (!selectedBranch) return;
|
|
132
|
+
modelled.push(...parseBlockContentWithState(selectedBranch, styles, theme, numbering, rels, media, withContainerXmlns(withContainerXmlns(state, child), selectedBranch)));
|
|
133
|
+
} };
|
|
134
|
+
const BLOCK_CONTENT_HANDLERS = {
|
|
135
|
+
p: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
136
|
+
const paragraph = parseParagraph(child, styles, theme, numbering, rels, media, {
|
|
137
|
+
...state.options,
|
|
138
|
+
runConsolidation: "deferred"
|
|
139
|
+
});
|
|
140
|
+
enrichParagraphTextBoxes(paragraph, child, styles, theme, numbering, rels, media, parseTable, state.options.previews, state.options.context);
|
|
141
|
+
computeListMarker(paragraph, {
|
|
142
|
+
numbering,
|
|
143
|
+
listCounters: state.listCounters,
|
|
144
|
+
abstractCounters: state.abstractCounters,
|
|
145
|
+
restartedNumIds: state.restartedNumIds,
|
|
146
|
+
previousList: state.previousList
|
|
147
|
+
});
|
|
148
|
+
modelled.push(paragraph);
|
|
149
|
+
},
|
|
150
|
+
tbl: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
151
|
+
const table = parseTable(child, styles, theme, numbering, rels, media, state.options);
|
|
152
|
+
if (!table) return;
|
|
153
|
+
modelled.push(table);
|
|
154
|
+
},
|
|
155
|
+
sdt: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
156
|
+
modelled.push(parseBlockSdt(child, styles, theme, numbering, rels, media, state));
|
|
157
|
+
},
|
|
158
|
+
bookmarkStart: (child, { modelled }) => {
|
|
159
|
+
modelled.push(parseBookmarkStart(child));
|
|
160
|
+
},
|
|
161
|
+
bookmarkEnd: (child, { modelled }) => {
|
|
162
|
+
modelled.push(parseBookmarkEnd(child));
|
|
163
|
+
},
|
|
164
|
+
...BLOCK_CHILD_OWNERS,
|
|
165
|
+
altChunk: CAPTURE,
|
|
166
|
+
commentRangeEnd: CAPTURE,
|
|
167
|
+
commentRangeStart: CAPTURE,
|
|
168
|
+
customXml: CAPTURE,
|
|
169
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
170
|
+
customXmlDelRangeStart: CAPTURE,
|
|
171
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
172
|
+
customXmlInsRangeStart: CAPTURE,
|
|
173
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
174
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
175
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
176
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
177
|
+
del: CAPTURE,
|
|
178
|
+
ins: CAPTURE,
|
|
179
|
+
moveFrom: CAPTURE,
|
|
180
|
+
moveFromRangeEnd: CAPTURE,
|
|
181
|
+
moveFromRangeStart: CAPTURE,
|
|
182
|
+
moveTo: CAPTURE,
|
|
183
|
+
moveToRangeEnd: CAPTURE,
|
|
184
|
+
moveToRangeStart: CAPTURE,
|
|
185
|
+
permEnd: CAPTURE,
|
|
186
|
+
permStart: CAPTURE,
|
|
187
|
+
proofErr: CAPTURE
|
|
188
|
+
};
|
|
127
189
|
const parseBlockContentWithState = (parent, styles, theme, numbering, rels, media, state) => {
|
|
128
190
|
const modelled = [];
|
|
129
|
-
return withPreservedChildren(modelled,
|
|
191
|
+
return withPreservedChildren(modelled, dispatchChildrenWithContext({
|
|
130
192
|
element: parent,
|
|
131
193
|
container: "block-content",
|
|
132
194
|
capturePosition: () => modelled.length,
|
|
133
|
-
undeclared:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
runConsolidation: "deferred"
|
|
143
|
-
});
|
|
144
|
-
enrichParagraphTextBoxes(paragraph, child, styles, theme, numbering, rels, media, parseTable, state.options?.context);
|
|
145
|
-
computeListMarker(paragraph, {
|
|
146
|
-
numbering,
|
|
147
|
-
listCounters: state.listCounters,
|
|
148
|
-
abstractCounters: state.abstractCounters,
|
|
149
|
-
restartedNumIds: state.restartedNumIds,
|
|
150
|
-
previousList: state.previousList
|
|
151
|
-
});
|
|
152
|
-
modelled.push(paragraph);
|
|
153
|
-
},
|
|
154
|
-
tbl: (child) => {
|
|
155
|
-
const table = parseTable(child, styles, theme, numbering, rels, media, state.options);
|
|
156
|
-
if (!table) return;
|
|
157
|
-
modelled.push(table);
|
|
158
|
-
},
|
|
159
|
-
sdt: (child) => {
|
|
160
|
-
modelled.push(parseBlockSdt(child, styles, theme, numbering, rels, media, state));
|
|
161
|
-
},
|
|
162
|
-
bookmarkStart: (child) => {
|
|
163
|
-
modelled.push(parseBookmarkStart(child));
|
|
164
|
-
},
|
|
165
|
-
bookmarkEnd: (child) => {
|
|
166
|
-
modelled.push(parseBookmarkEnd(child));
|
|
195
|
+
undeclared: BLOCK_CONTENT_UNDECLARED,
|
|
196
|
+
handlers: BLOCK_CONTENT_HANDLERS,
|
|
197
|
+
context: {
|
|
198
|
+
resources: {
|
|
199
|
+
styles,
|
|
200
|
+
theme,
|
|
201
|
+
numbering,
|
|
202
|
+
rels,
|
|
203
|
+
media
|
|
167
204
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
commentRangeEnd: CAPTURE,
|
|
171
|
-
commentRangeStart: CAPTURE,
|
|
172
|
-
customXml: CAPTURE,
|
|
173
|
-
customXmlDelRangeEnd: CAPTURE,
|
|
174
|
-
customXmlDelRangeStart: CAPTURE,
|
|
175
|
-
customXmlInsRangeEnd: CAPTURE,
|
|
176
|
-
customXmlInsRangeStart: CAPTURE,
|
|
177
|
-
customXmlMoveFromRangeEnd: CAPTURE,
|
|
178
|
-
customXmlMoveFromRangeStart: CAPTURE,
|
|
179
|
-
customXmlMoveToRangeEnd: CAPTURE,
|
|
180
|
-
customXmlMoveToRangeStart: CAPTURE,
|
|
181
|
-
del: CAPTURE,
|
|
182
|
-
ins: CAPTURE,
|
|
183
|
-
moveFrom: CAPTURE,
|
|
184
|
-
moveFromRangeEnd: CAPTURE,
|
|
185
|
-
moveFromRangeStart: CAPTURE,
|
|
186
|
-
moveTo: CAPTURE,
|
|
187
|
-
moveToRangeEnd: CAPTURE,
|
|
188
|
-
moveToRangeStart: CAPTURE,
|
|
189
|
-
permEnd: CAPTURE,
|
|
190
|
-
permStart: CAPTURE,
|
|
191
|
-
proofErr: CAPTURE
|
|
205
|
+
state,
|
|
206
|
+
modelled
|
|
192
207
|
}
|
|
193
208
|
}), (xml) => ({
|
|
194
209
|
type: "preservedBlock",
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
//#region src/docx/bulletMarkers.d.ts
|
|
2
|
-
|
|
2
|
+
type MarkerFontFamily = {
|
|
3
|
+
ascii?: string | undefined;
|
|
4
|
+
hAnsi?: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
/** The face a bullet level's `w:rFonts` names for its (Latin-range) marker character. */
|
|
7
|
+
declare const bulletMarkerFontName: (formatting: {
|
|
8
|
+
fontFamily?: MarkerFontFamily | undefined;
|
|
9
|
+
} | null | undefined) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Map a bullet level's `w:lvlText` to the character painted for it.
|
|
12
|
+
*
|
|
13
|
+
* `fontName` is the level's own `w:rFonts` face. When it is an ordinary text
|
|
14
|
+
* font, a Latin-range character is the letter itself (the common `o` bullet
|
|
15
|
+
* in a monospace face); without a named face the character is read as a
|
|
16
|
+
* symbol-font code.
|
|
17
|
+
*/
|
|
18
|
+
declare const convertBulletToUnicode: (bulletChar: string, fontName?: string) => string;
|
|
3
19
|
//#endregion
|
|
4
|
-
export { convertBulletToUnicode };
|
|
20
|
+
export { bulletMarkerFontName, convertBulletToUnicode };
|