@stll/folio-core 0.47.7 → 0.48.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/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 +59 -17
- 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 +5 -4
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +77 -62
- 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/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 +2 -1
- package/dist/docx/groupDrawingParser.js +3 -6
- 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/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +381 -362
- 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 +17 -6
- 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 +172 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/serializer/paragraphSerializer.js +42 -38
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -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 +8 -3
- package/dist/docx/textBoxParser.js +3 -3
- 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/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 +258 -35
- 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 +70 -11
- 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 +11 -5
- package/dist/layout-engine/keep-together.js +39 -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 +4 -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 +42 -8
- package/dist/layout-engine/measure/measureContainer.js +5 -5
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +21 -5
- package/dist/layout-engine/measure/measureParagraph.js +109 -30
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -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 +10 -1
- package/dist/layout-engine/paginator.js +13 -1
- package/dist/layout-engine/tableRowBreak.js +3 -1
- package/dist/layout-engine/types.d.ts +89 -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 +34 -22
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +43 -11
- package/dist/prosemirror/conversion/fromProseDoc.js +8 -1
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +77 -41
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +2 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +2 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +13 -1
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- 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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isValidHexId } from "../utils/hexId.js";
|
|
2
2
|
import { attributeRemainder } from "./attributeRemainder.js";
|
|
3
3
|
import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
|
|
4
|
-
import { CAPTURE,
|
|
4
|
+
import { CAPTURE, dispatchChildrenWithContext, ownedElsewhere, transitionalNamespaceOf, withPreservedChildren } from "./containerChildren.js";
|
|
5
5
|
import { parseFieldType } from "./fieldParser.js";
|
|
6
6
|
import { fieldStateOf, parseFieldState } from "./fieldState.js";
|
|
7
|
-
import {
|
|
7
|
+
import { HYPERLINK_CHILD_HANDLERS, parseHyperlink as parseHyperlink$1, parseHyperlinkShell } from "./hyperlinkParser.js";
|
|
8
8
|
import { isHyperlinkContent, isInlineSdtContent, isTrackedChangeWrapperChild } from "./inlineWrapperContent.js";
|
|
9
9
|
import { inlineWrapperOf } from "./inlineWrapperParser.js";
|
|
10
10
|
import { parseMarkupRangeMarker, parseMoveBookmarkMarker } from "./markupRangeMarker.js";
|
|
@@ -15,6 +15,7 @@ import { paraIdInRange } from "./paraIdRangeNormalization.js";
|
|
|
15
15
|
import { parseParagraphProperties } from "./paragraphProperties.js";
|
|
16
16
|
import { assignParagraphPropertySource } from "./paragraphPropertySource.js";
|
|
17
17
|
import { preserveInlineChild, preserveRunChild, preservedInlineCapture } from "./preservedRunContent.js";
|
|
18
|
+
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
18
19
|
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
19
20
|
import { parseRun } from "./runParser.js";
|
|
20
21
|
import { runHoldsPayload } from "./runPayload.js";
|
|
@@ -303,8 +304,8 @@ function pushInlineSdtSegments({ contents, properties, parsedContent }) {
|
|
|
303
304
|
*
|
|
304
305
|
* Delegates to hyperlinkParser module which resolves URLs via relationships.
|
|
305
306
|
*/
|
|
306
|
-
function parseHyperlink(node, rels, styles, theme, media, rootXmlns
|
|
307
|
-
return parseHyperlink$1(node, rels, styles, theme, media, rootXmlns);
|
|
307
|
+
function parseHyperlink(node, rels, styles, theme, media, rootXmlns, previews) {
|
|
308
|
+
return parseHyperlink$1(node, rels, styles, theme, media, rootXmlns, previews);
|
|
308
309
|
}
|
|
309
310
|
/**
|
|
310
311
|
* The four `CT_RunTrackChange` wrappers a `w:hyperlink` may hold.
|
|
@@ -342,6 +343,39 @@ const mathContentOf = (child) => {
|
|
|
342
343
|
if (plainText) equation.plainText = plainText;
|
|
343
344
|
return equation;
|
|
344
345
|
};
|
|
346
|
+
const hoistRevision = (wrapper) => (child, { styles, theme, rels, media, previews, inScopeXmlns, items, linkOver }) => {
|
|
347
|
+
const wrapped = parseParagraphContents(child, styles, theme, null, rels, media, previews, wrapper === "deletion" || wrapper === "moveFrom" ? "deletion" : "default", inScopeXmlns);
|
|
348
|
+
const content = [];
|
|
349
|
+
let linked = [];
|
|
350
|
+
const flushLinked = () => {
|
|
351
|
+
if (linked.length > 0) {
|
|
352
|
+
content.push(linkOver(linked));
|
|
353
|
+
linked = [];
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
for (const item of wrapped) {
|
|
357
|
+
if (isHyperlinkContent(item)) {
|
|
358
|
+
linked.push(item);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
flushLinked();
|
|
362
|
+
if (isTrackedChangeWrapperChild(item)) content.push(item);
|
|
363
|
+
}
|
|
364
|
+
flushLinked();
|
|
365
|
+
items.push({
|
|
366
|
+
type: "hoistedRevision",
|
|
367
|
+
wrapper,
|
|
368
|
+
info: parseTrackedChangeInfo(child),
|
|
369
|
+
content
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
const HYPERLINK_REVISION_HOISTING_HANDLERS = {
|
|
373
|
+
...HYPERLINK_CHILD_HANDLERS,
|
|
374
|
+
ins: hoistRevision("insertion"),
|
|
375
|
+
del: hoistRevision("deletion"),
|
|
376
|
+
moveFrom: hoistRevision("moveFrom"),
|
|
377
|
+
moveTo: hoistRevision("moveTo")
|
|
378
|
+
};
|
|
345
379
|
/**
|
|
346
380
|
* A `w:hyperlink` as paragraph content, with any revision wrapper it holds
|
|
347
381
|
* hoisted around it.
|
|
@@ -351,60 +385,32 @@ const mathContentOf = (child) => {
|
|
|
351
385
|
* reads and a link that is half deleted is two links to it. This is the exact
|
|
352
386
|
* inverse of what the serializer writes, so a package survives the round trip.
|
|
353
387
|
*/
|
|
354
|
-
function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootXmlns) {
|
|
355
|
-
if (!getChildElements(node).some((child) => HYPERLINK_REVISION_WRAPPERS.has(getLocalName(child.name)))) return [parseHyperlink(node, rels, styles, theme, media, rootXmlns)];
|
|
388
|
+
function parseHyperlinkParagraphContents(node, rels, styles, theme, media, rootXmlns, previews) {
|
|
389
|
+
if (!getChildElements(node).some((child) => HYPERLINK_REVISION_WRAPPERS.has(getLocalName(child.name)))) return [parseHyperlink(node, rels, styles, theme, media, rootXmlns, previews)];
|
|
356
390
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, node);
|
|
357
|
-
const shell =
|
|
391
|
+
const shell = parseHyperlinkShell(node, rels);
|
|
358
392
|
const linkOver = (linkChildren) => ({
|
|
359
393
|
...shell,
|
|
360
394
|
children: [...linkChildren]
|
|
361
395
|
});
|
|
362
396
|
const items = [];
|
|
363
|
-
const
|
|
364
|
-
const wrapped = parseParagraphContents(child, styles, theme, null, rels, media, wrapper === "deletion" || wrapper === "moveFrom" ? "deletion" : "default", inScopeXmlns);
|
|
365
|
-
const content = [];
|
|
366
|
-
let linked = [];
|
|
367
|
-
const flushLinked = () => {
|
|
368
|
-
if (linked.length > 0) {
|
|
369
|
-
content.push(linkOver(linked));
|
|
370
|
-
linked = [];
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
for (const item of wrapped) {
|
|
374
|
-
if (isHyperlinkContent(item)) {
|
|
375
|
-
linked.push(item);
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
flushLinked();
|
|
379
|
-
if (isTrackedChangeWrapperChild(item)) content.push(item);
|
|
380
|
-
}
|
|
381
|
-
flushLinked();
|
|
382
|
-
items.push({
|
|
383
|
-
type: "hoistedRevision",
|
|
384
|
-
wrapper,
|
|
385
|
-
info: parseTrackedChangeInfo(child),
|
|
386
|
-
content
|
|
387
|
-
});
|
|
388
|
-
};
|
|
389
|
-
const preserved = dispatchChildren({
|
|
397
|
+
const preserved = dispatchChildrenWithContext({
|
|
390
398
|
element: node,
|
|
391
399
|
container: "w:hyperlink",
|
|
392
400
|
capturePosition: () => items.length,
|
|
393
|
-
handlers:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
moveFrom: hoistRevision("moveFrom"),
|
|
407
|
-
moveTo: hoistRevision("moveTo")
|
|
401
|
+
handlers: HYPERLINK_REVISION_HOISTING_HANDLERS,
|
|
402
|
+
context: {
|
|
403
|
+
push: (child) => {
|
|
404
|
+
items.push(child);
|
|
405
|
+
},
|
|
406
|
+
styles,
|
|
407
|
+
theme,
|
|
408
|
+
rels,
|
|
409
|
+
media,
|
|
410
|
+
previews,
|
|
411
|
+
inScopeXmlns,
|
|
412
|
+
items,
|
|
413
|
+
linkOver
|
|
408
414
|
}
|
|
409
415
|
});
|
|
410
416
|
const contents = [];
|
|
@@ -449,7 +455,7 @@ function parseBookmarkEnd(node) {
|
|
|
449
455
|
/**
|
|
450
456
|
* Parse simple field (w:fldSimple)
|
|
451
457
|
*/
|
|
452
|
-
function parseSimpleField(node, styles, theme, rels, media, rootXmlns
|
|
458
|
+
function parseSimpleField(node, styles, theme, rels, media, rootXmlns, previews) {
|
|
453
459
|
const instruction = getAttribute(node, "w", "instr") ?? "";
|
|
454
460
|
const field = {
|
|
455
461
|
type: "simpleField",
|
|
@@ -460,11 +466,12 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
|
|
|
460
466
|
};
|
|
461
467
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, node);
|
|
462
468
|
const content = [];
|
|
463
|
-
field.content = withPreservedChildren(content,
|
|
469
|
+
field.content = withPreservedChildren(content, dispatchChildrenWithContext({
|
|
464
470
|
element: node,
|
|
465
471
|
container: "w:fldSimple",
|
|
466
472
|
capturePosition: () => content.length,
|
|
467
|
-
handlers:
|
|
473
|
+
handlers: SIMPLE_FIELD_CHILD_HANDLERS,
|
|
474
|
+
context: {
|
|
468
475
|
push: (child) => {
|
|
469
476
|
content.push(child);
|
|
470
477
|
},
|
|
@@ -472,11 +479,16 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
|
|
|
472
479
|
theme,
|
|
473
480
|
rels,
|
|
474
481
|
media,
|
|
482
|
+
previews,
|
|
475
483
|
inScopeXmlns
|
|
476
|
-
}
|
|
484
|
+
}
|
|
477
485
|
}), preservedInlineCapture);
|
|
478
486
|
return field;
|
|
479
487
|
}
|
|
488
|
+
/** A transparent wrapper the field holds, read as the wrapper it is. */
|
|
489
|
+
const fieldInlineWrapper = (element) => (child, context) => {
|
|
490
|
+
context.push(parseFieldInlineWrapper(element, child, context));
|
|
491
|
+
};
|
|
480
492
|
/**
|
|
481
493
|
* What a `w:fldSimple` does with every child its content model declares.
|
|
482
494
|
*
|
|
@@ -485,52 +497,46 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
|
|
|
485
497
|
* `CT_BdoContentRun` and its three siblings are the same `EG_PContent` the
|
|
486
498
|
* field is, so the decision per child is the field's own.
|
|
487
499
|
*/
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
permEnd: CAPTURE,
|
|
529
|
-
permStart: CAPTURE,
|
|
530
|
-
proofErr: CAPTURE,
|
|
531
|
-
sdt: CAPTURE,
|
|
532
|
-
subDoc: CAPTURE
|
|
533
|
-
};
|
|
500
|
+
const SIMPLE_FIELD_CHILD_HANDLERS = {
|
|
501
|
+
r: (child, { push, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
502
|
+
push(parseRun(child, styles, theme, rels, media, inScopeXmlns, previews));
|
|
503
|
+
},
|
|
504
|
+
hyperlink: (child, { push, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
505
|
+
push(parseHyperlink(child, rels, styles, theme, media, inScopeXmlns, previews));
|
|
506
|
+
},
|
|
507
|
+
bdo: fieldInlineWrapper("bdo"),
|
|
508
|
+
dir: fieldInlineWrapper("dir"),
|
|
509
|
+
customXml: fieldInlineWrapper("customXml"),
|
|
510
|
+
smartTag: fieldInlineWrapper("smartTag"),
|
|
511
|
+
bookmarkEnd: CAPTURE,
|
|
512
|
+
bookmarkStart: CAPTURE,
|
|
513
|
+
commentRangeEnd: CAPTURE,
|
|
514
|
+
commentRangeStart: CAPTURE,
|
|
515
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
516
|
+
customXmlDelRangeStart: CAPTURE,
|
|
517
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
518
|
+
customXmlInsRangeStart: CAPTURE,
|
|
519
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
520
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
521
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
522
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
523
|
+
del: CAPTURE,
|
|
524
|
+
fldData: CAPTURE,
|
|
525
|
+
fldSimple: (child, { push }) => {
|
|
526
|
+
push(preserveInlineChild(child));
|
|
527
|
+
},
|
|
528
|
+
ins: CAPTURE,
|
|
529
|
+
moveFrom: CAPTURE,
|
|
530
|
+
moveFromRangeEnd: CAPTURE,
|
|
531
|
+
moveFromRangeStart: CAPTURE,
|
|
532
|
+
moveTo: CAPTURE,
|
|
533
|
+
moveToRangeEnd: CAPTURE,
|
|
534
|
+
moveToRangeStart: CAPTURE,
|
|
535
|
+
permEnd: CAPTURE,
|
|
536
|
+
permStart: CAPTURE,
|
|
537
|
+
proofErr: CAPTURE,
|
|
538
|
+
sdt: CAPTURE,
|
|
539
|
+
subDoc: CAPTURE
|
|
534
540
|
};
|
|
535
541
|
/**
|
|
536
542
|
* A transparent wrapper a simple field holds, with the content the field holds.
|
|
@@ -543,21 +549,17 @@ const simpleFieldChildHandlers = (context) => {
|
|
|
543
549
|
const parseFieldInlineWrapper = (element, node, context) => {
|
|
544
550
|
const inScopeXmlns = mergeXmlnsDeclarations(context.inScopeXmlns, node);
|
|
545
551
|
const content = [];
|
|
546
|
-
return inlineWrapperOf(element, node, withPreservedChildren(content,
|
|
552
|
+
return inlineWrapperOf(element, node, withPreservedChildren(content, dispatchChildrenWithContext({
|
|
547
553
|
element: node,
|
|
548
554
|
container: "run-level-content",
|
|
549
555
|
capturePosition: () => content.length,
|
|
550
|
-
handlers:
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}),
|
|
558
|
-
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
559
|
-
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
560
|
-
pPr: CAPTURE
|
|
556
|
+
handlers: FIELD_INLINE_WRAPPER_HANDLERS,
|
|
557
|
+
context: {
|
|
558
|
+
...context,
|
|
559
|
+
inScopeXmlns,
|
|
560
|
+
push: (child) => {
|
|
561
|
+
content.push(child);
|
|
562
|
+
}
|
|
561
563
|
}
|
|
562
564
|
}), preservedInlineCapture));
|
|
563
565
|
};
|
|
@@ -666,267 +668,282 @@ const CUSTOM_XML_PROPERTIES_OWNER = ownedElsewhere({
|
|
|
666
668
|
child: "customXmlPr",
|
|
667
669
|
reader: "inlineWrapperParser#inlineWrapperOf"
|
|
668
670
|
});
|
|
671
|
+
/** The field's own map over a transparent wrapper it holds; see `parseFieldInlineWrapper`. */
|
|
672
|
+
const FIELD_INLINE_WRAPPER_HANDLERS = {
|
|
673
|
+
...SIMPLE_FIELD_CHILD_HANDLERS,
|
|
674
|
+
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
675
|
+
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
676
|
+
pPr: CAPTURE
|
|
677
|
+
};
|
|
678
|
+
/**
|
|
679
|
+
* A transparent wrapper at paragraph level. All four hold ordinary inline
|
|
680
|
+
* content and say something about it rather than about the text, so the
|
|
681
|
+
* recursion is this same walk and `inlineWrapperOf` reads what the element
|
|
682
|
+
* adds.
|
|
683
|
+
*/
|
|
684
|
+
const paragraphInlineWrapper = (element) => (child, { styles, theme, rels, media, previews, trackedContext, inScopeXmlns, contents }) => {
|
|
685
|
+
contents.push(inlineWrapperOf(element, child, parseParagraphContents(child, styles, theme, null, rels, media, previews, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child))));
|
|
686
|
+
};
|
|
687
|
+
const PARAGRAPH_CONTENT_UNDECLARED = { AlternateContent: (child, { contents, styles, theme, rels, media, previews, trackedContext, inScopeXmlns }) => {
|
|
688
|
+
const selectedBranch = selectAlternateContentBranch(child);
|
|
689
|
+
if (selectedBranch) contents.push(...parseParagraphContents(selectedBranch, styles, theme, null, rels, media, previews, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child)));
|
|
690
|
+
} };
|
|
691
|
+
const PARAGRAPH_CONTENT_UNDECLARED_NAMESPACES = { [OMML_NAMESPACE]: (child, { contents }) => {
|
|
692
|
+
const equation = mathContentOf(child);
|
|
693
|
+
if (equation !== void 0) contents.push(equation);
|
|
694
|
+
} };
|
|
695
|
+
const PARAGRAPH_CONTENT_HANDLERS = {
|
|
696
|
+
r: (child, { contents, styles, theme, rels, media, previews, trackedContext, inScopeXmlns, scan }) => {
|
|
697
|
+
const runElement = trackedContext === "deletion" ? normalizeDeletionContentElement(child) : child;
|
|
698
|
+
const run = parseRun(runElement, styles, theme, rels, media, inScopeXmlns, previews);
|
|
699
|
+
const commentReferenceId = getCommentReferenceId(runElement);
|
|
700
|
+
let hasFieldBegin = false;
|
|
701
|
+
let beginFieldState = {};
|
|
702
|
+
const beginFallbackDisplay = getLegacyFormCheckboxDisplay(runElement);
|
|
703
|
+
let hasFieldSeparate = false;
|
|
704
|
+
let hasFieldEnd = false;
|
|
705
|
+
let endOriginalValue;
|
|
706
|
+
let instrText = "";
|
|
707
|
+
for (const content of run.content) if (content.type === "fieldChar") if (content.charType === "begin") {
|
|
708
|
+
hasFieldBegin = true;
|
|
709
|
+
beginFieldState = fieldStateOf(content);
|
|
710
|
+
} else if (content.charType === "separate") hasFieldSeparate = true;
|
|
711
|
+
else {
|
|
712
|
+
hasFieldEnd = true;
|
|
713
|
+
if (content.originalValue !== void 0) endOriginalValue = content.originalValue;
|
|
714
|
+
}
|
|
715
|
+
else if (content.type === "instrText") instrText += content.text;
|
|
716
|
+
if (hasFieldBegin) {
|
|
717
|
+
if (scan.inComplexField && scan.afterSeparator) {
|
|
718
|
+
contents.push(...scan.complexFieldResultRuns);
|
|
719
|
+
scan.inComplexField = false;
|
|
720
|
+
}
|
|
721
|
+
scan.inComplexField = true;
|
|
722
|
+
scan.afterSeparator = false;
|
|
723
|
+
scan.complexFieldInstr = "";
|
|
724
|
+
scan.complexFieldCodeRuns = [];
|
|
725
|
+
scan.complexFieldResultRuns = [];
|
|
726
|
+
scan.complexFieldOpenRuns = [];
|
|
727
|
+
scan.complexFieldState = beginFieldState;
|
|
728
|
+
scan.complexFieldFallbackDisplay = beginFallbackDisplay;
|
|
729
|
+
scan.complexFieldFormatting = run.formatting;
|
|
730
|
+
}
|
|
731
|
+
if (scan.inComplexField) {
|
|
732
|
+
scan.complexFieldOpenRuns.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
733
|
+
if (instrText) scan.complexFieldInstr += instrText;
|
|
734
|
+
if ((!scan.complexFieldFormatting || Object.keys(scan.complexFieldFormatting).length === 0) && run.formatting && Object.keys(run.formatting).length > 0) scan.complexFieldFormatting = run.formatting;
|
|
735
|
+
let inFieldCodeRegion = !hasFieldBegin && !scan.afterSeparator;
|
|
736
|
+
const fieldCodeContent = [];
|
|
737
|
+
for (const content of run.content) {
|
|
738
|
+
if (content.type === "fieldChar") {
|
|
739
|
+
inFieldCodeRegion = content.charType === "begin";
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
if (inFieldCodeRegion) fieldCodeContent.push(content);
|
|
743
|
+
}
|
|
744
|
+
if (fieldCodeContent.length > 0) scan.complexFieldCodeRuns.push(fieldCodeContent.length === run.content.length ? run : {
|
|
745
|
+
...run,
|
|
746
|
+
content: fieldCodeContent
|
|
747
|
+
});
|
|
748
|
+
if (hasFieldSeparate) scan.afterSeparator = true;
|
|
749
|
+
if (scan.afterSeparator && !hasFieldEnd) {
|
|
750
|
+
if (!hasFieldSeparate) scan.complexFieldResultRuns.push(run);
|
|
751
|
+
}
|
|
752
|
+
if (hasFieldEnd) {
|
|
753
|
+
let resultRuns = scan.complexFieldResultRuns;
|
|
754
|
+
if (resultRuns.length === 0 && scan.complexFieldFallbackDisplay !== void 0 && isLegacyFormCheckboxInstruction(scan.complexFieldInstr)) resultRuns = [createLegacyFormCheckboxResultRun(scan.complexFieldFallbackDisplay, scan.complexFieldFormatting)];
|
|
755
|
+
if (resultRuns.length === 0 && !scan.afterSeparator && endOriginalValue !== void 0) resultRuns = [{
|
|
756
|
+
type: "run",
|
|
757
|
+
content: [{
|
|
758
|
+
type: "text",
|
|
759
|
+
text: endOriginalValue
|
|
760
|
+
}]
|
|
761
|
+
}];
|
|
762
|
+
const complexField = {
|
|
763
|
+
type: "complexField",
|
|
764
|
+
instruction: scan.complexFieldInstr,
|
|
765
|
+
fieldType: parseFieldType(scan.complexFieldInstr),
|
|
766
|
+
fieldCode: scan.complexFieldCodeRuns,
|
|
767
|
+
fieldResult: resultRuns,
|
|
768
|
+
...scan.complexFieldState
|
|
769
|
+
};
|
|
770
|
+
if (scan.complexFieldFormatting) complexField.formatting = scan.complexFieldFormatting;
|
|
771
|
+
contents.push(complexField);
|
|
772
|
+
if (commentReferenceId !== null) contents.push({
|
|
773
|
+
type: "commentReference",
|
|
774
|
+
id: commentReferenceId
|
|
775
|
+
});
|
|
776
|
+
scan.inComplexField = false;
|
|
777
|
+
}
|
|
778
|
+
} else if (commentReferenceId !== null) {
|
|
779
|
+
if (runHoldsPayload(run)) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
780
|
+
contents.push({
|
|
781
|
+
type: "commentReference",
|
|
782
|
+
id: commentReferenceId
|
|
783
|
+
});
|
|
784
|
+
} else if (hasRunPayload({
|
|
785
|
+
run,
|
|
786
|
+
runElement,
|
|
787
|
+
rels,
|
|
788
|
+
media
|
|
789
|
+
})) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
790
|
+
},
|
|
791
|
+
hyperlink: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
792
|
+
contents.push(...parseHyperlinkParagraphContents(child, rels, styles, theme, media, inScopeXmlns, previews));
|
|
793
|
+
},
|
|
794
|
+
bookmarkStart: (child, { contents }) => {
|
|
795
|
+
contents.push(parseBookmarkStart(child));
|
|
796
|
+
},
|
|
797
|
+
bookmarkEnd: (child, { contents }) => {
|
|
798
|
+
contents.push(parseBookmarkEnd(child));
|
|
799
|
+
},
|
|
800
|
+
fldSimple: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
801
|
+
contents.push(parseSimpleField(child, styles, theme, rels, media, inScopeXmlns, previews));
|
|
802
|
+
},
|
|
803
|
+
pPr: PARAGRAPH_PROPERTIES_OWNER,
|
|
804
|
+
customXml: paragraphInlineWrapper("customXml"),
|
|
805
|
+
proofErr: CAPTURE,
|
|
806
|
+
permStart: CAPTURE,
|
|
807
|
+
permEnd: CAPTURE,
|
|
808
|
+
subDoc: CAPTURE,
|
|
809
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
810
|
+
customXmlDelRangeStart: CAPTURE,
|
|
811
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
812
|
+
customXmlInsRangeStart: CAPTURE,
|
|
813
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
814
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
815
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
816
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
817
|
+
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
818
|
+
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
819
|
+
sdt: (child, { contents, styles, theme, rels, media, previews, trackedContext, inScopeXmlns }) => {
|
|
820
|
+
const sdtPr = findWordprocessingChild(child, "sdtPr");
|
|
821
|
+
const sdtEndPr = findWordprocessingChild(child, "sdtEndPr");
|
|
822
|
+
const sdtContentEl = findWordprocessingChild(child, "sdtContent");
|
|
823
|
+
if (sdtContentEl) {
|
|
824
|
+
const sdtParsed = parseParagraphContents(sdtContentEl, styles, theme, null, rels, media, previews, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child));
|
|
825
|
+
const properties = parseSdtProperties(sdtPr, sdtEndPr);
|
|
826
|
+
const captured = captureSdtSiblingMarkers(child);
|
|
827
|
+
if (captured.before.length > 0) properties.rawSdtChildrenBeforeContent = captured.before;
|
|
828
|
+
if (captured.after.length > 0) properties.rawSdtChildrenAfterContent = captured.after;
|
|
829
|
+
pushInlineSdtSegments({
|
|
830
|
+
contents,
|
|
831
|
+
properties,
|
|
832
|
+
parsedContent: sdtParsed
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
ins: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
837
|
+
pushTrackedChangeSegments({
|
|
838
|
+
contents,
|
|
839
|
+
type: "insertion",
|
|
840
|
+
info: parseTrackedChangeInfo(child),
|
|
841
|
+
parsedContent: parseParagraphContents(child, styles, theme, null, rels, media, previews, "default", inScopeXmlns)
|
|
842
|
+
});
|
|
843
|
+
},
|
|
844
|
+
del: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
845
|
+
pushTrackedChangeSegments({
|
|
846
|
+
contents,
|
|
847
|
+
type: "deletion",
|
|
848
|
+
info: parseTrackedChangeInfo(child),
|
|
849
|
+
parsedContent: parseParagraphContents(child, styles, theme, null, rels, media, previews, "deletion", inScopeXmlns)
|
|
850
|
+
});
|
|
851
|
+
},
|
|
852
|
+
moveFrom: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
853
|
+
pushTrackedChangeSegments({
|
|
854
|
+
contents,
|
|
855
|
+
type: "moveFrom",
|
|
856
|
+
info: parseTrackedChangeInfo(child),
|
|
857
|
+
parsedContent: parseParagraphContents(child, styles, theme, null, rels, media, previews, "deletion", inScopeXmlns)
|
|
858
|
+
});
|
|
859
|
+
},
|
|
860
|
+
moveTo: (child, { contents, styles, theme, rels, media, previews, inScopeXmlns }) => {
|
|
861
|
+
pushTrackedChangeSegments({
|
|
862
|
+
contents,
|
|
863
|
+
type: "moveTo",
|
|
864
|
+
info: parseTrackedChangeInfo(child),
|
|
865
|
+
parsedContent: parseParagraphContents(child, styles, theme, null, rels, media, previews, "default", inScopeXmlns)
|
|
866
|
+
});
|
|
867
|
+
},
|
|
868
|
+
smartTag: paragraphInlineWrapper("smartTag"),
|
|
869
|
+
moveFromRangeStart: (child, { contents }) => {
|
|
870
|
+
contents.push({
|
|
871
|
+
type: "moveFromRangeStart",
|
|
872
|
+
...parseMoveBookmarkMarker(child)
|
|
873
|
+
});
|
|
874
|
+
},
|
|
875
|
+
moveFromRangeEnd: (child, { contents }) => {
|
|
876
|
+
contents.push({
|
|
877
|
+
type: "moveFromRangeEnd",
|
|
878
|
+
...parseMarkupRangeMarker(child)
|
|
879
|
+
});
|
|
880
|
+
},
|
|
881
|
+
moveToRangeStart: (child, { contents }) => {
|
|
882
|
+
contents.push({
|
|
883
|
+
type: "moveToRangeStart",
|
|
884
|
+
...parseMoveBookmarkMarker(child)
|
|
885
|
+
});
|
|
886
|
+
},
|
|
887
|
+
moveToRangeEnd: (child, { contents }) => {
|
|
888
|
+
contents.push({
|
|
889
|
+
type: "moveToRangeEnd",
|
|
890
|
+
...parseMarkupRangeMarker(child)
|
|
891
|
+
});
|
|
892
|
+
},
|
|
893
|
+
commentRangeStart: (child, { contents }) => {
|
|
894
|
+
contents.push({
|
|
895
|
+
type: "commentRangeStart",
|
|
896
|
+
...parseMarkupRangeMarker(child)
|
|
897
|
+
});
|
|
898
|
+
},
|
|
899
|
+
commentRangeEnd: (child, { contents }) => {
|
|
900
|
+
contents.push({
|
|
901
|
+
type: "commentRangeEnd",
|
|
902
|
+
...parseMarkupRangeMarker(child)
|
|
903
|
+
});
|
|
904
|
+
},
|
|
905
|
+
bdo: paragraphInlineWrapper("bdo"),
|
|
906
|
+
dir: paragraphInlineWrapper("dir")
|
|
907
|
+
};
|
|
669
908
|
/**
|
|
670
909
|
* Parse all content within a paragraph
|
|
671
910
|
*
|
|
672
911
|
* Returns the parsed content and any complex fields that span multiple runs
|
|
673
912
|
*/
|
|
674
|
-
function parseParagraphContents(paraElement, styles, theme, _numbering, rels, media, trackedContext = "default", rootXmlns = {}) {
|
|
913
|
+
function parseParagraphContents(paraElement, styles, theme, _numbering, rels, media, previews, trackedContext = "default", rootXmlns = {}) {
|
|
675
914
|
const contents = [];
|
|
676
915
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, paraElement);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
916
|
+
const scan = {
|
|
917
|
+
inComplexField: false,
|
|
918
|
+
complexFieldInstr: "",
|
|
919
|
+
complexFieldCodeRuns: [],
|
|
920
|
+
complexFieldResultRuns: [],
|
|
921
|
+
complexFieldOpenRuns: [],
|
|
922
|
+
afterSeparator: false,
|
|
923
|
+
complexFieldState: {},
|
|
924
|
+
complexFieldFallbackDisplay: void 0,
|
|
925
|
+
complexFieldFormatting: void 0
|
|
926
|
+
};
|
|
927
|
+
const preserved = dispatchChildrenWithContext({
|
|
688
928
|
element: paraElement,
|
|
689
929
|
container: "run-level-content",
|
|
690
930
|
capturePosition: () => contents.length,
|
|
691
|
-
undeclared:
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
let hasFieldBegin = false;
|
|
705
|
-
let beginFieldState = {};
|
|
706
|
-
const beginFallbackDisplay = getLegacyFormCheckboxDisplay(runElement);
|
|
707
|
-
let hasFieldSeparate = false;
|
|
708
|
-
let hasFieldEnd = false;
|
|
709
|
-
let endOriginalValue;
|
|
710
|
-
let instrText = "";
|
|
711
|
-
for (const content of run.content) if (content.type === "fieldChar") if (content.charType === "begin") {
|
|
712
|
-
hasFieldBegin = true;
|
|
713
|
-
beginFieldState = fieldStateOf(content);
|
|
714
|
-
} else if (content.charType === "separate") hasFieldSeparate = true;
|
|
715
|
-
else {
|
|
716
|
-
hasFieldEnd = true;
|
|
717
|
-
if (content.originalValue !== void 0) endOriginalValue = content.originalValue;
|
|
718
|
-
}
|
|
719
|
-
else if (content.type === "instrText") instrText += content.text;
|
|
720
|
-
if (hasFieldBegin) {
|
|
721
|
-
if (inComplexField && afterSeparator) {
|
|
722
|
-
contents.push(...complexFieldResultRuns);
|
|
723
|
-
inComplexField = false;
|
|
724
|
-
}
|
|
725
|
-
inComplexField = true;
|
|
726
|
-
afterSeparator = false;
|
|
727
|
-
complexFieldInstr = "";
|
|
728
|
-
complexFieldCodeRuns = [];
|
|
729
|
-
complexFieldResultRuns = [];
|
|
730
|
-
complexFieldOpenRuns = [];
|
|
731
|
-
complexFieldState = beginFieldState;
|
|
732
|
-
complexFieldFallbackDisplay = beginFallbackDisplay;
|
|
733
|
-
complexFieldFormatting = run.formatting;
|
|
734
|
-
}
|
|
735
|
-
if (inComplexField) {
|
|
736
|
-
complexFieldOpenRuns.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
737
|
-
if (instrText) complexFieldInstr += instrText;
|
|
738
|
-
if ((!complexFieldFormatting || Object.keys(complexFieldFormatting).length === 0) && run.formatting && Object.keys(run.formatting).length > 0) complexFieldFormatting = run.formatting;
|
|
739
|
-
let inFieldCodeRegion = !hasFieldBegin && !afterSeparator;
|
|
740
|
-
const fieldCodeContent = [];
|
|
741
|
-
for (const content of run.content) {
|
|
742
|
-
if (content.type === "fieldChar") {
|
|
743
|
-
inFieldCodeRegion = content.charType === "begin";
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
if (inFieldCodeRegion) fieldCodeContent.push(content);
|
|
747
|
-
}
|
|
748
|
-
if (fieldCodeContent.length > 0) complexFieldCodeRuns.push(fieldCodeContent.length === run.content.length ? run : {
|
|
749
|
-
...run,
|
|
750
|
-
content: fieldCodeContent
|
|
751
|
-
});
|
|
752
|
-
if (hasFieldSeparate) afterSeparator = true;
|
|
753
|
-
if (afterSeparator && !hasFieldEnd) {
|
|
754
|
-
if (!hasFieldSeparate) complexFieldResultRuns.push(run);
|
|
755
|
-
}
|
|
756
|
-
if (hasFieldEnd) {
|
|
757
|
-
let resultRuns = complexFieldResultRuns;
|
|
758
|
-
if (resultRuns.length === 0 && complexFieldFallbackDisplay !== void 0 && isLegacyFormCheckboxInstruction(complexFieldInstr)) resultRuns = [createLegacyFormCheckboxResultRun(complexFieldFallbackDisplay, complexFieldFormatting)];
|
|
759
|
-
if (resultRuns.length === 0 && !afterSeparator && endOriginalValue !== void 0) resultRuns = [{
|
|
760
|
-
type: "run",
|
|
761
|
-
content: [{
|
|
762
|
-
type: "text",
|
|
763
|
-
text: endOriginalValue
|
|
764
|
-
}]
|
|
765
|
-
}];
|
|
766
|
-
const complexField = {
|
|
767
|
-
type: "complexField",
|
|
768
|
-
instruction: complexFieldInstr,
|
|
769
|
-
fieldType: parseFieldType(complexFieldInstr),
|
|
770
|
-
fieldCode: complexFieldCodeRuns,
|
|
771
|
-
fieldResult: resultRuns,
|
|
772
|
-
...complexFieldState
|
|
773
|
-
};
|
|
774
|
-
if (complexFieldFormatting) complexField.formatting = complexFieldFormatting;
|
|
775
|
-
contents.push(complexField);
|
|
776
|
-
if (commentReferenceId !== null) contents.push({
|
|
777
|
-
type: "commentReference",
|
|
778
|
-
id: commentReferenceId
|
|
779
|
-
});
|
|
780
|
-
inComplexField = false;
|
|
781
|
-
}
|
|
782
|
-
} else if (commentReferenceId !== null) {
|
|
783
|
-
if (runHoldsPayload(run)) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
784
|
-
contents.push({
|
|
785
|
-
type: "commentReference",
|
|
786
|
-
id: commentReferenceId
|
|
787
|
-
});
|
|
788
|
-
} else if (hasRunPayload({
|
|
789
|
-
run,
|
|
790
|
-
runElement,
|
|
791
|
-
rels,
|
|
792
|
-
media
|
|
793
|
-
})) contents.push(withOrphanFieldCharsPreserved(run, runElement));
|
|
794
|
-
},
|
|
795
|
-
hyperlink: (child) => {
|
|
796
|
-
contents.push(...parseHyperlinkParagraphContents(child, rels, styles, theme, media, inScopeXmlns));
|
|
797
|
-
},
|
|
798
|
-
bookmarkStart: (child) => {
|
|
799
|
-
contents.push(parseBookmarkStart(child));
|
|
800
|
-
},
|
|
801
|
-
bookmarkEnd: (child) => {
|
|
802
|
-
contents.push(parseBookmarkEnd(child));
|
|
803
|
-
},
|
|
804
|
-
fldSimple: (child) => {
|
|
805
|
-
contents.push(parseSimpleField(child, styles, theme, rels, media, inScopeXmlns));
|
|
806
|
-
},
|
|
807
|
-
pPr: PARAGRAPH_PROPERTIES_OWNER,
|
|
808
|
-
customXml: (child) => {
|
|
809
|
-
contents.push(parseInlineWrapper(child, "customXml"));
|
|
810
|
-
},
|
|
811
|
-
proofErr: CAPTURE,
|
|
812
|
-
permStart: CAPTURE,
|
|
813
|
-
permEnd: CAPTURE,
|
|
814
|
-
subDoc: CAPTURE,
|
|
815
|
-
customXmlDelRangeEnd: CAPTURE,
|
|
816
|
-
customXmlDelRangeStart: CAPTURE,
|
|
817
|
-
customXmlInsRangeEnd: CAPTURE,
|
|
818
|
-
customXmlInsRangeStart: CAPTURE,
|
|
819
|
-
customXmlMoveFromRangeEnd: CAPTURE,
|
|
820
|
-
customXmlMoveFromRangeStart: CAPTURE,
|
|
821
|
-
customXmlMoveToRangeEnd: CAPTURE,
|
|
822
|
-
customXmlMoveToRangeStart: CAPTURE,
|
|
823
|
-
smartTagPr: SMART_TAG_PROPERTIES_OWNER,
|
|
824
|
-
customXmlPr: CUSTOM_XML_PROPERTIES_OWNER,
|
|
825
|
-
sdt: (child) => {
|
|
826
|
-
const sdtPr = findWordprocessingChild(child, "sdtPr");
|
|
827
|
-
const sdtEndPr = findWordprocessingChild(child, "sdtEndPr");
|
|
828
|
-
const sdtContentEl = findWordprocessingChild(child, "sdtContent");
|
|
829
|
-
if (sdtContentEl) {
|
|
830
|
-
const sdtParsed = parseParagraphContents(sdtContentEl, styles, theme, null, rels, media, trackedContext, mergeXmlnsDeclarations(inScopeXmlns, child));
|
|
831
|
-
const properties = parseSdtProperties(sdtPr, sdtEndPr);
|
|
832
|
-
const captured = captureSdtSiblingMarkers(child);
|
|
833
|
-
if (captured.before.length > 0) properties.rawSdtChildrenBeforeContent = captured.before;
|
|
834
|
-
if (captured.after.length > 0) properties.rawSdtChildrenAfterContent = captured.after;
|
|
835
|
-
pushInlineSdtSegments({
|
|
836
|
-
contents,
|
|
837
|
-
properties,
|
|
838
|
-
parsedContent: sdtParsed
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
},
|
|
842
|
-
ins: (child) => {
|
|
843
|
-
const insInfo = parseTrackedChangeInfo(child);
|
|
844
|
-
const insContent = parseParagraphContents(child, styles, theme, null, rels, media, "default", inScopeXmlns);
|
|
845
|
-
pushTrackedChangeSegments({
|
|
846
|
-
contents,
|
|
847
|
-
type: "insertion",
|
|
848
|
-
info: insInfo,
|
|
849
|
-
parsedContent: insContent
|
|
850
|
-
});
|
|
851
|
-
},
|
|
852
|
-
del: (child) => {
|
|
853
|
-
const delInfo = parseTrackedChangeInfo(child);
|
|
854
|
-
const delContent = parseParagraphContents(child, styles, theme, null, rels, media, "deletion", inScopeXmlns);
|
|
855
|
-
pushTrackedChangeSegments({
|
|
856
|
-
contents,
|
|
857
|
-
type: "deletion",
|
|
858
|
-
info: delInfo,
|
|
859
|
-
parsedContent: delContent
|
|
860
|
-
});
|
|
861
|
-
},
|
|
862
|
-
moveFrom: (child) => {
|
|
863
|
-
const moveFromInfo = parseTrackedChangeInfo(child);
|
|
864
|
-
const moveFromContent = parseParagraphContents(child, styles, theme, null, rels, media, "deletion", inScopeXmlns);
|
|
865
|
-
pushTrackedChangeSegments({
|
|
866
|
-
contents,
|
|
867
|
-
type: "moveFrom",
|
|
868
|
-
info: moveFromInfo,
|
|
869
|
-
parsedContent: moveFromContent
|
|
870
|
-
});
|
|
871
|
-
},
|
|
872
|
-
moveTo: (child) => {
|
|
873
|
-
const moveToInfo = parseTrackedChangeInfo(child);
|
|
874
|
-
const moveToContent = parseParagraphContents(child, styles, theme, null, rels, media, "default", inScopeXmlns);
|
|
875
|
-
pushTrackedChangeSegments({
|
|
876
|
-
contents,
|
|
877
|
-
type: "moveTo",
|
|
878
|
-
info: moveToInfo,
|
|
879
|
-
parsedContent: moveToContent
|
|
880
|
-
});
|
|
881
|
-
},
|
|
882
|
-
smartTag: (child) => {
|
|
883
|
-
contents.push(parseInlineWrapper(child, "smartTag"));
|
|
884
|
-
},
|
|
885
|
-
moveFromRangeStart: (child) => {
|
|
886
|
-
contents.push({
|
|
887
|
-
type: "moveFromRangeStart",
|
|
888
|
-
...parseMoveBookmarkMarker(child)
|
|
889
|
-
});
|
|
890
|
-
},
|
|
891
|
-
moveFromRangeEnd: (child) => {
|
|
892
|
-
contents.push({
|
|
893
|
-
type: "moveFromRangeEnd",
|
|
894
|
-
...parseMarkupRangeMarker(child)
|
|
895
|
-
});
|
|
896
|
-
},
|
|
897
|
-
moveToRangeStart: (child) => {
|
|
898
|
-
contents.push({
|
|
899
|
-
type: "moveToRangeStart",
|
|
900
|
-
...parseMoveBookmarkMarker(child)
|
|
901
|
-
});
|
|
902
|
-
},
|
|
903
|
-
moveToRangeEnd: (child) => {
|
|
904
|
-
contents.push({
|
|
905
|
-
type: "moveToRangeEnd",
|
|
906
|
-
...parseMarkupRangeMarker(child)
|
|
907
|
-
});
|
|
908
|
-
},
|
|
909
|
-
commentRangeStart: (child) => {
|
|
910
|
-
contents.push({
|
|
911
|
-
type: "commentRangeStart",
|
|
912
|
-
...parseMarkupRangeMarker(child)
|
|
913
|
-
});
|
|
914
|
-
},
|
|
915
|
-
commentRangeEnd: (child) => {
|
|
916
|
-
contents.push({
|
|
917
|
-
type: "commentRangeEnd",
|
|
918
|
-
...parseMarkupRangeMarker(child)
|
|
919
|
-
});
|
|
920
|
-
},
|
|
921
|
-
bdo: (child) => {
|
|
922
|
-
contents.push(parseInlineWrapper(child, "bdo"));
|
|
923
|
-
},
|
|
924
|
-
dir: (child) => {
|
|
925
|
-
contents.push(parseInlineWrapper(child, "dir"));
|
|
926
|
-
}
|
|
931
|
+
undeclared: PARAGRAPH_CONTENT_UNDECLARED,
|
|
932
|
+
undeclaredNamespaces: PARAGRAPH_CONTENT_UNDECLARED_NAMESPACES,
|
|
933
|
+
handlers: PARAGRAPH_CONTENT_HANDLERS,
|
|
934
|
+
context: {
|
|
935
|
+
styles,
|
|
936
|
+
theme,
|
|
937
|
+
rels,
|
|
938
|
+
media,
|
|
939
|
+
previews,
|
|
940
|
+
trackedContext,
|
|
941
|
+
inScopeXmlns,
|
|
942
|
+
contents,
|
|
943
|
+
scan
|
|
927
944
|
}
|
|
928
945
|
});
|
|
929
|
-
if (inComplexField) contents.push(...complexFieldOpenRuns);
|
|
946
|
+
if (scan.inComplexField) contents.push(...scan.complexFieldOpenRuns);
|
|
930
947
|
return withPreservedChildren(contents, preserved, preservedInlineCapture);
|
|
931
948
|
}
|
|
932
949
|
function getCommentReferenceId(runElement) {
|
|
@@ -956,7 +973,8 @@ const PARAGRAPH_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
956
973
|
* @param numbering - Numbering definitions for list info
|
|
957
974
|
* @param rels - Relationship map for resolving hyperlink URLs
|
|
958
975
|
* @param media - Media files map for image data
|
|
959
|
-
* @param options - Parsing options for context-specific body behavior
|
|
976
|
+
* @param options - Parsing options for context-specific body behavior; a
|
|
977
|
+
* paragraph read without them charges its previews to no package
|
|
960
978
|
* @returns Parsed Paragraph object
|
|
961
979
|
*/
|
|
962
980
|
function parseParagraph(node, styles, theme, numbering, rels = null, media = null, options) {
|
|
@@ -986,7 +1004,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
986
1004
|
const sectPr = findChild(pPr, "w", "sectPr");
|
|
987
1005
|
if (sectPr) paragraph.sectionProperties = parseSectionProperties(sectPr);
|
|
988
1006
|
}
|
|
989
|
-
const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, "default", options?.rootXmlns ?? {});
|
|
1007
|
+
const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, options?.previews ?? standalonePreviewLedger(), "default", options?.rootXmlns ?? {});
|
|
990
1008
|
paragraph.content = options?.runConsolidation === "deferred" ? rawContent : consolidateParagraphContent(rawContent);
|
|
991
1009
|
const paragraphFormatting = paragraph.formatting;
|
|
992
1010
|
const directNumPr = paragraphFormatting?.numPr;
|
|
@@ -1033,6 +1051,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1033
1051
|
const markerAlignment = markerAlignmentForLevel(level.lvlJc);
|
|
1034
1052
|
if (markerAlignment !== void 0) listRendering.markerAlignment = markerAlignment;
|
|
1035
1053
|
if (level.suffix) listRendering.markerSuffix = level.suffix;
|
|
1054
|
+
if (level.pPr?.tabs?.length) listRendering.levelTabs = level.pPr.tabs;
|
|
1036
1055
|
let implicitChildLevelAdvances = 0;
|
|
1037
1056
|
const foldedMarkerSuffix = [];
|
|
1038
1057
|
const filteredContent = [];
|