@stll/folio-core 0.10.0 → 0.12.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 +602 -50
- package/dist/ai-edits/block-identity.d.ts +4 -0
- package/dist/ai-edits/block-identity.js +9 -0
- package/dist/ai-edits/blockRange.d.ts +28 -1
- package/dist/ai-edits/blockRange.js +67 -1
- package/dist/ai-edits/headless.d.ts +4 -4
- package/dist/ai-edits/headless.js +9 -9
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/read.d.ts +7 -7
- package/dist/ai-edits/read.js +110 -3
- package/dist/ai-edits/table-cell-mutations.d.ts +48 -0
- package/dist/ai-edits/table-cell-mutations.js +237 -0
- package/dist/ai-edits/table-mutation-plan.d.ts +38 -0
- package/dist/ai-edits/table-mutation-plan.js +90 -0
- package/dist/ai-edits/table-row-column-mutations.d.ts +100 -0
- package/dist/ai-edits/table-row-column-mutations.js +300 -0
- package/dist/ai-edits/table-targets.d.ts +32 -0
- package/dist/ai-edits/table-targets.js +70 -0
- package/dist/ai-edits/types.d.ts +34 -0
- package/dist/compat/eigenpal.js +1 -1
- package/dist/content-controls/mutateContentControls.js +1 -1
- package/dist/controller/activeEditorStory.d.ts +36 -0
- package/dist/controller/activeEditorStory.js +30 -0
- package/dist/controller/collaborationModules.d.ts +7 -0
- package/dist/controller/collaborationModules.js +15 -0
- package/dist/controller/contentControlWidgetController.d.ts +55 -0
- package/dist/controller/contentControlWidgetController.js +141 -0
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.js +2 -0
- package/dist/controller/headerFooterEditorManager.d.ts +41 -0
- package/dist/controller/headerFooterEditorManager.js +182 -0
- package/dist/controller/hiddenEditorApi.js +2 -2
- package/dist/controller/hiddenEditorManager.d.ts +13 -2
- package/dist/controller/hiddenEditorManager.js +32 -11
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +16 -1
- package/dist/controller/noteEditorManager.d.ts +36 -0
- package/dist/controller/noteEditorManager.js +210 -0
- package/dist/document-operations.d.ts +35 -3
- package/dist/document-operations.js +161 -3
- package/dist/docx/blockContentParser.js +2 -2
- package/dist/docx/commentParser.js +6 -1
- package/dist/docx/conformance.js +8 -1
- package/dist/docx/documentGrid.d.ts +8 -0
- package/dist/docx/documentGrid.js +8 -0
- package/dist/docx/drawingUtils.js +1 -1
- package/dist/docx/ensureParaIds.js +1 -1
- package/dist/docx/fieldParser.js +1 -1
- package/dist/docx/notePropertiesParser.js +1 -1
- package/dist/docx/numberingParser.js +1 -1
- package/dist/docx/paragraphParser.js +63 -58
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +67 -13
- package/dist/docx/paragraphTraversal.js +1 -1
- package/dist/docx/parser.js +3 -3
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/runParser.js +4 -2
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sectionParser.js +1 -1
- package/dist/docx/selectiveSave.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -2
- package/dist/docx/serializer/documentSerializer.js +2 -2
- package/dist/docx/serializer/headerFooterSerializer.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +2 -2
- package/dist/docx/serializer/paragraphSerializer.js +7 -1
- package/dist/docx/serializer/runSerializer.js +4 -2
- package/dist/docx/serializer/stylesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.d.ts +5 -4
- package/dist/docx/serializer/tableSerializer.js +17 -13
- package/dist/docx/server/applyDocxXmlPatchProposal.d.ts +87 -0
- package/dist/docx/server/applyDocxXmlPatchProposal.js +204 -0
- package/dist/docx/server/boundedArchive.d.ts +14 -3
- package/dist/docx/server/boundedArchive.js +56 -11
- package/dist/docx/server/evaluateDocxXmlPatchProposal.d.ts +85 -0
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +361 -0
- package/dist/docx/server/inspectDocxPackage.d.ts +70 -0
- package/dist/docx/server/inspectDocxPackage.js +217 -0
- package/dist/docx/server/validateDocxConformance.d.ts +41 -0
- package/dist/docx/server/validateDocxConformance.js +336 -0
- package/dist/docx/settingsParser.js +11 -1
- package/dist/docx/shapeParser.js +1 -1
- package/dist/docx/styleParser.js +4 -2
- package/dist/docx/tableParser.js +18 -7
- package/dist/docx/textBoxParser.d.ts +3 -3
- package/dist/docx/textBoxParser.js +16 -12
- package/dist/docx/xmlSafety.d.ts +5 -0
- package/dist/docx/xmlSafety.js +9 -0
- package/dist/fields/resolveFieldValues.js +1 -3
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +47 -40
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +3 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +3 -3
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +136 -20
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +6 -0
- package/dist/layout-bridge/dom/noteStoryDom.js +17 -0
- package/dist/layout-bridge/engine/clickToPosition.js +2 -2
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +43 -28
- package/dist/layout-engine/justificationCompatibility.d.ts +6 -0
- package/dist/layout-engine/justificationCompatibility.js +8 -0
- package/dist/layout-engine/keep-together.js +11 -1
- package/dist/layout-engine/measure/cache.js +21 -5
- package/dist/layout-engine/measure/lineBreakProvider.js +53 -34
- package/dist/layout-engine/measure/measureBlocks.js +6 -3
- package/dist/layout-engine/measure/measureContainer.js +1 -1
- package/dist/layout-engine/measure/measureHelpers.d.ts +1 -1
- package/dist/layout-engine/measure/measureHelpers.js +3 -3
- package/dist/layout-engine/measure/measureParagraph.js +69 -25
- package/dist/layout-engine/measure/measureProvider.js +4 -3
- package/dist/layout-engine/measure/tableCellFlow.js +5 -2
- package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +9 -7
- package/dist/layout-engine/measure/textBoxParagraphLayout.js +22 -6
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +3 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.js +7 -1
- package/dist/layout-engine/paginator.js +5 -1
- package/dist/layout-engine/paragraphSpacing.d.ts +28 -4
- package/dist/layout-engine/paragraphSpacing.js +107 -13
- package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
- package/dist/layout-engine/types.d.ts +26 -13
- package/dist/layout-painter/registry/modules/textBox.js +5 -1
- package/dist/layout-painter/renderPage.d.ts +5 -2
- package/dist/layout-painter/renderPage.js +56 -12
- package/dist/layout-painter/renderParagraph.js +22 -6
- package/dist/layout-painter/renderTable.d.ts +5 -1
- package/dist/layout-painter/renderTable.js +5 -2
- package/dist/layout-painter/renderTextBox.d.ts +2 -1
- package/dist/layout-painter/renderTextBox.js +25 -14
- package/dist/managers/DocumentLoaderManager.js +1 -1
- package/dist/managers/FindReplaceManager.d.ts +8 -0
- package/dist/managers/FindReplaceManager.js +18 -0
- package/dist/managers/TableSelectionManager.d.ts +6 -0
- package/dist/managers/TableSelectionManager.js +14 -0
- package/dist/model.js +1 -1
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +154 -18
- package/dist/prosemirror/commands/comments.d.ts +3 -3
- package/dist/prosemirror/commands/comments.js +248 -12
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/index.js +1 -1
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +2 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +3 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +9 -0
- package/dist/prosemirror/commands/tableCellMergeResolution.js +181 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +286 -61
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +9 -0
- package/dist/prosemirror/conversion/sdtAttrs.js +49 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +2 -1
- package/dist/prosemirror/conversion/toProseDoc.js +347 -98
- package/dist/prosemirror/extensions/ExtensionManager.js +1 -1
- package/dist/prosemirror/extensions/StarterKit.js +6 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +4 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +10 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +93 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +2 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +6 -2
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +9 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +24 -1
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +22 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +9 -3
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.js +41 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +5 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +6 -1
- package/dist/prosemirror/findReplaceSelection.js +57 -13
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +34 -8
- package/dist/prosemirror/plugins/contentControlWidgets.js +125 -91
- package/dist/prosemirror/plugins/selectionTracker.js +1 -0
- package/dist/prosemirror/plugins/suggestionMode.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +5 -1
- package/dist/prosemirror/schema/nodes.d.ts +64 -7
- package/dist/prosemirror/selectionState.js +1 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/tableCellMergeRevision.d.ts +9 -0
- package/dist/prosemirror/tableCellMergeRevision.js +22 -0
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +9 -0
- package/dist/prosemirror/textBoxAnchorAttrs.js +33 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +1 -1
- package/dist/prosemirror/utils/extractTrackedChanges.js +62 -14
- package/dist/prosemirror/validation.js +9 -1
- package/dist/render-dom/BodySelectionOverlay.d.ts +31 -0
- package/dist/render-dom/BodySelectionOverlay.js +76 -0
- package/dist/render-dom/HeaderFooterSelectionOverlay.d.ts +28 -0
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +121 -0
- package/dist/render-dom/RemoteSelectionOverlay.d.ts +30 -0
- package/dist/render-dom/RemoteSelectionOverlay.js +67 -0
- package/dist/render-dom/RenderedDomContext.d.ts +40 -0
- package/dist/render-dom/RenderedDomContext.js +126 -0
- package/dist/render-dom/resolveSidebarItemPositions.d.ts +33 -0
- package/dist/render-dom/resolveSidebarItemPositions.js +45 -0
- package/dist/server.d.ts +6 -2
- package/dist/server.js +5 -1
- package/dist/utils/findReplace.d.ts +32 -0
- package/dist/utils/findReplace.js +118 -0
- package/dist/utils/fontFamilyMerge.js +9 -11
- package/dist/utils/fontLoader.js +3 -2
- package/dist/utils/fontResolver.js +22 -4
- package/dist/utils/fontWeights.d.ts +1 -1
- package/dist/utils/fontWeights.js +1 -1
- package/dist/utils/headerFooter.js +24 -1
- package/dist/utils/paragraphFormattingMerge.js +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { elementToXml, findChild, findChildren, getAttribute, getChildElements, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
2
|
-
import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
|
|
3
1
|
import { BorderStyleSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, TabLeaderSchema, TabStopAlignmentSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
+
import { elementToXml, findChild, findChildren, getAttribute, getChildElements, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
4
3
|
import { parseRun, parseRunProperties } from "./runParser.js";
|
|
5
4
|
import { parseFieldType } from "./fieldParser.js";
|
|
5
|
+
import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
|
|
6
6
|
import { parseHyperlink as parseHyperlink$1 } from "./hyperlinkParser.js";
|
|
7
7
|
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
8
8
|
import { parseSdtProperties } from "./sdtProperties.js";
|
|
@@ -191,6 +191,9 @@ function collectFirstParagraphPropertyChildren(pPr) {
|
|
|
191
191
|
case "shd":
|
|
192
192
|
children.shd ??= child;
|
|
193
193
|
break;
|
|
194
|
+
case "snapToGrid":
|
|
195
|
+
children.snapToGrid ??= child;
|
|
196
|
+
break;
|
|
194
197
|
case "spacing":
|
|
195
198
|
children.spacing ??= child;
|
|
196
199
|
break;
|
|
@@ -243,6 +246,8 @@ function parseParagraphProperties(pPr, theme, styles) {
|
|
|
243
246
|
}
|
|
244
247
|
const bidi = propertyChildren.bidi;
|
|
245
248
|
if (bidi) formatting.bidi = parseBooleanElement(bidi);
|
|
249
|
+
const snapToGrid = propertyChildren.snapToGrid;
|
|
250
|
+
if (snapToGrid) formatting.snapToGrid = parseBooleanElement(snapToGrid);
|
|
246
251
|
const spacing = propertyChildren.spacing;
|
|
247
252
|
if (spacing) {
|
|
248
253
|
const before = parseNumericAttribute(spacing, "w", "before");
|
|
@@ -369,64 +374,64 @@ function getLocalName(name) {
|
|
|
369
374
|
const colonIndex = name.indexOf(":");
|
|
370
375
|
return colonIndex !== -1 ? name.slice(colonIndex + 1) : name;
|
|
371
376
|
}
|
|
377
|
+
const RENDERED_BREAK_INLINE_WRAPPERS = /* @__PURE__ */ new Set([
|
|
378
|
+
"hyperlink",
|
|
379
|
+
"smartTag",
|
|
380
|
+
"sdt",
|
|
381
|
+
"sdtContent",
|
|
382
|
+
"fldSimple",
|
|
383
|
+
"customXml",
|
|
384
|
+
"ins",
|
|
385
|
+
"del",
|
|
386
|
+
"moveFrom",
|
|
387
|
+
"moveTo"
|
|
388
|
+
]);
|
|
389
|
+
const RENDERED_BREAK_NON_CONTENT_MARKERS = /* @__PURE__ */ new Set([
|
|
390
|
+
"pPr",
|
|
391
|
+
"proofErr",
|
|
392
|
+
"bookmarkStart",
|
|
393
|
+
"bookmarkEnd",
|
|
394
|
+
"commentRangeStart",
|
|
395
|
+
"commentRangeEnd",
|
|
396
|
+
"commentReference",
|
|
397
|
+
"permStart",
|
|
398
|
+
"permEnd",
|
|
399
|
+
"rsidR"
|
|
400
|
+
]);
|
|
401
|
+
const RENDERED_BREAK_VISIBLE_RUN_CONTENT = /* @__PURE__ */ new Set([
|
|
402
|
+
"t",
|
|
403
|
+
"tab",
|
|
404
|
+
"br",
|
|
405
|
+
"cr",
|
|
406
|
+
"sym",
|
|
407
|
+
"drawing",
|
|
408
|
+
"pict",
|
|
409
|
+
"object",
|
|
410
|
+
"softHyphen",
|
|
411
|
+
"noBreakHyphen",
|
|
412
|
+
"fldChar",
|
|
413
|
+
"instrText",
|
|
414
|
+
"pgNum",
|
|
415
|
+
"separator",
|
|
416
|
+
"continuationSeparator",
|
|
417
|
+
"footnoteRef",
|
|
418
|
+
"endnoteRef",
|
|
419
|
+
"footnoteReference",
|
|
420
|
+
"endnoteReference",
|
|
421
|
+
"ptab",
|
|
422
|
+
"monthShort",
|
|
423
|
+
"monthLong",
|
|
424
|
+
"yearShort",
|
|
425
|
+
"yearLong",
|
|
426
|
+
"dayShort",
|
|
427
|
+
"dayLong"
|
|
428
|
+
]);
|
|
372
429
|
function paragraphStartsWithRenderedPageBreak(node) {
|
|
373
|
-
const inlineWrappers = /* @__PURE__ */ new Set([
|
|
374
|
-
"hyperlink",
|
|
375
|
-
"smartTag",
|
|
376
|
-
"sdt",
|
|
377
|
-
"sdtContent",
|
|
378
|
-
"fldSimple",
|
|
379
|
-
"customXml",
|
|
380
|
-
"ins",
|
|
381
|
-
"del",
|
|
382
|
-
"moveFrom",
|
|
383
|
-
"moveTo"
|
|
384
|
-
]);
|
|
385
|
-
const nonContentMarkers = /* @__PURE__ */ new Set([
|
|
386
|
-
"pPr",
|
|
387
|
-
"proofErr",
|
|
388
|
-
"bookmarkStart",
|
|
389
|
-
"bookmarkEnd",
|
|
390
|
-
"commentRangeStart",
|
|
391
|
-
"commentRangeEnd",
|
|
392
|
-
"commentReference",
|
|
393
|
-
"permStart",
|
|
394
|
-
"permEnd",
|
|
395
|
-
"rsidR"
|
|
396
|
-
]);
|
|
397
|
-
const visibleRunContent = /* @__PURE__ */ new Set([
|
|
398
|
-
"t",
|
|
399
|
-
"tab",
|
|
400
|
-
"br",
|
|
401
|
-
"cr",
|
|
402
|
-
"sym",
|
|
403
|
-
"drawing",
|
|
404
|
-
"pict",
|
|
405
|
-
"object",
|
|
406
|
-
"softHyphen",
|
|
407
|
-
"noBreakHyphen",
|
|
408
|
-
"fldChar",
|
|
409
|
-
"instrText",
|
|
410
|
-
"pgNum",
|
|
411
|
-
"separator",
|
|
412
|
-
"continuationSeparator",
|
|
413
|
-
"footnoteRef",
|
|
414
|
-
"endnoteRef",
|
|
415
|
-
"footnoteReference",
|
|
416
|
-
"endnoteReference",
|
|
417
|
-
"ptab",
|
|
418
|
-
"monthShort",
|
|
419
|
-
"monthLong",
|
|
420
|
-
"yearShort",
|
|
421
|
-
"yearLong",
|
|
422
|
-
"dayShort",
|
|
423
|
-
"dayLong"
|
|
424
|
-
]);
|
|
425
430
|
let sawRenderedPageBreak = false;
|
|
426
431
|
const visit = (element) => {
|
|
427
432
|
for (const child of getChildElements(element)) {
|
|
428
433
|
const childName = getLocalName(child.name);
|
|
429
|
-
if (
|
|
434
|
+
if (RENDERED_BREAK_NON_CONTENT_MARKERS.has(childName)) continue;
|
|
430
435
|
if (childName === "lastRenderedPageBreak") {
|
|
431
436
|
sawRenderedPageBreak = true;
|
|
432
437
|
continue;
|
|
@@ -440,11 +445,11 @@ function paragraphStartsWithRenderedPageBreak(node) {
|
|
|
440
445
|
continue;
|
|
441
446
|
}
|
|
442
447
|
if (runChildName === "br" && getAttribute(runChild, "w", "type") === "page") return "forced";
|
|
443
|
-
if (
|
|
448
|
+
if (RENDERED_BREAK_VISIBLE_RUN_CONTENT.has(runChildName)) return "visible";
|
|
444
449
|
}
|
|
445
450
|
continue;
|
|
446
451
|
}
|
|
447
|
-
if (
|
|
452
|
+
if (RENDERED_BREAK_INLINE_WRAPPERS.has(childName)) {
|
|
448
453
|
const result = visit(child);
|
|
449
454
|
if (result !== "continue") return result;
|
|
450
455
|
continue;
|
|
@@ -535,7 +540,7 @@ function isTrackedChangeWrapperChild(content) {
|
|
|
535
540
|
return content.type === "run" || content.type === "hyperlink";
|
|
536
541
|
}
|
|
537
542
|
function isInlineSdtContent(content) {
|
|
538
|
-
return content.type === "run" || content.type === "hyperlink" || content.type === "simpleField" || content.type === "complexField" || content.type === "inlineSdt" || content.type === "insertion" || content.type === "deletion" || content.type === "mathEquation";
|
|
543
|
+
return content.type === "run" || content.type === "hyperlink" || content.type === "simpleField" || content.type === "complexField" || content.type === "inlineSdt" || content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo" || content.type === "mathEquation";
|
|
539
544
|
}
|
|
540
545
|
function pushTrackedChangeWrapper({ contents, type, info, content, preserveEmpty = false }) {
|
|
541
546
|
if (content.length === 0 && !preserveEmpty) return;
|
|
@@ -2,8 +2,9 @@ import { document_d_exports } from "../types/document.js";
|
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
3
|
import { StyleMap } from "./styleParser.js";
|
|
4
4
|
import { XmlElement } from "./xmlParser.js";
|
|
5
|
+
import { TableParserFn } from "./textBoxParser.js";
|
|
5
6
|
|
|
6
7
|
//#region src/docx/paragraphTextBoxEnrichment.d.ts
|
|
7
|
-
declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: 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) => void;
|
|
8
|
+
declare const enrichParagraphTextBoxes: (paragraph: document_d_exports.Paragraph, paraXml: 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, parseTable: TableParserFn) => void;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { enrichParagraphTextBoxes };
|
|
@@ -72,26 +72,80 @@ const vmlWrapType = (positioned, zIndex) => {
|
|
|
72
72
|
if (Number.isFinite(zIndex) && zIndex < 0) return "behind";
|
|
73
73
|
return "inFront";
|
|
74
74
|
};
|
|
75
|
-
const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media) => {
|
|
76
|
-
|
|
75
|
+
const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering, rels, media, parseTable) => {
|
|
76
|
+
enrichTextBoxRuns({
|
|
77
|
+
content: paragraph.content,
|
|
78
|
+
xmlChildren: getChildElements(paraXml),
|
|
79
|
+
styles,
|
|
80
|
+
theme,
|
|
81
|
+
numbering,
|
|
82
|
+
rels,
|
|
83
|
+
media,
|
|
84
|
+
parseTable
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const trackedChangeTypeFromXml = (localName) => {
|
|
88
|
+
if (localName === "ins") return "insertion";
|
|
89
|
+
if (localName === "del") return "deletion";
|
|
90
|
+
if (localName === "moveFrom" || localName === "moveTo") return localName;
|
|
91
|
+
};
|
|
92
|
+
const enrichTextBoxRuns = ({ content, xmlChildren, styles, theme, numbering, rels, media, parseTable }) => {
|
|
77
93
|
let parsedIndex = 0;
|
|
78
94
|
let lastConsumedRun;
|
|
79
95
|
for (const xmlChild of xmlChildren) {
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
const localName = getLocalName(xmlChild.name ?? "");
|
|
97
|
+
if (localName === "pPr") continue;
|
|
98
|
+
const trackedChangeType = trackedChangeTypeFromXml(localName);
|
|
99
|
+
const parsedContent = content[parsedIndex];
|
|
100
|
+
if (trackedChangeType && parsedContent?.type === trackedChangeType) enrichTextBoxRuns({
|
|
101
|
+
content: parsedContent.content,
|
|
102
|
+
xmlChildren: getChildElements(xmlChild),
|
|
103
|
+
styles,
|
|
104
|
+
theme,
|
|
105
|
+
numbering,
|
|
106
|
+
rels,
|
|
107
|
+
media,
|
|
108
|
+
parseTable
|
|
109
|
+
});
|
|
110
|
+
if (localName === "sdt" && parsedContent?.type === "inlineSdt") {
|
|
111
|
+
const properties = parsedContent.properties;
|
|
112
|
+
const nestedContent = [];
|
|
113
|
+
let lastSegmentIndex = parsedIndex;
|
|
114
|
+
for (let index = parsedIndex; index < content.length; index += 1) {
|
|
115
|
+
const candidate = content[index];
|
|
116
|
+
if (candidate?.type !== "inlineSdt" || candidate.properties !== properties) continue;
|
|
117
|
+
nestedContent.push(...candidate.content);
|
|
118
|
+
lastSegmentIndex = index;
|
|
119
|
+
}
|
|
120
|
+
const sdtContent = getChildElements(xmlChild).find((child) => getLocalName(child.name ?? "") === "sdtContent");
|
|
121
|
+
if (sdtContent) enrichTextBoxRuns({
|
|
122
|
+
content: nestedContent,
|
|
123
|
+
xmlChildren: getChildElements(sdtContent),
|
|
124
|
+
styles,
|
|
125
|
+
theme,
|
|
126
|
+
numbering,
|
|
127
|
+
rels,
|
|
128
|
+
media,
|
|
129
|
+
parseTable
|
|
130
|
+
});
|
|
131
|
+
parsedIndex = lastSegmentIndex + 1;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (localName !== "r") {
|
|
135
|
+
if (parsedIndex < content.length && parsedContent?.type !== "run") parsedIndex += 1;
|
|
82
136
|
continue;
|
|
83
137
|
}
|
|
84
138
|
const { textBoxDrawings, vmlTextBoxes, hasNonTextBoxContent } = scanRunForTextBoxDrawings(xmlChild);
|
|
85
|
-
const parsedContent = paragraph.content[parsedIndex];
|
|
86
139
|
const parsedRun = parsedContent?.type === "run" ? parsedContent : void 0;
|
|
87
140
|
const targetRun = parsedRun ?? (hasNonTextBoxContent ? lastConsumedRun : void 0);
|
|
141
|
+
const targetRunMatchesXml = targetRun !== void 0 && (hasNonTextBoxContent || parsedRun?.content.length === 0);
|
|
88
142
|
for (const runEl of textBoxDrawings) {
|
|
89
143
|
const textBox = parseTextBox(runEl);
|
|
90
144
|
if (!textBox) continue;
|
|
91
145
|
const wsp = findDeep(runEl, "wps", "wsp");
|
|
92
146
|
if (wsp) {
|
|
93
147
|
const txbxContentEl = getTextBoxContentElement(wsp);
|
|
94
|
-
if (txbxContentEl) textBox.content = parseTextBoxContent(txbxContentEl, parseParagraph,
|
|
148
|
+
if (txbxContentEl) textBox.content = parseTextBoxContent(txbxContentEl, parseParagraph, parseTable, styles, theme, numbering, rels, media);
|
|
95
149
|
}
|
|
96
150
|
const shape = {
|
|
97
151
|
type: "shape",
|
|
@@ -112,31 +166,31 @@ const enrichParagraphTextBoxes = (paragraph, paraXml, styles, theme, numbering,
|
|
|
112
166
|
type: "shape",
|
|
113
167
|
shape
|
|
114
168
|
};
|
|
115
|
-
if (
|
|
169
|
+
if (targetRunMatchesXml) targetRun.content.push(shapeContent);
|
|
116
170
|
else {
|
|
117
171
|
const newRun = {
|
|
118
172
|
type: "run",
|
|
119
173
|
content: [shapeContent]
|
|
120
174
|
};
|
|
121
|
-
|
|
175
|
+
content.splice(parsedIndex, 0, newRun);
|
|
122
176
|
lastConsumedRun = newRun;
|
|
123
177
|
parsedIndex += 1;
|
|
124
178
|
}
|
|
125
179
|
}
|
|
126
180
|
for (const pictEl of vmlTextBoxes) {
|
|
127
|
-
const shape = parseVmlTextBoxShape(pictEl, styles, theme, numbering, rels, media);
|
|
181
|
+
const shape = parseVmlTextBoxShape(pictEl, styles, theme, numbering, rels, media, parseTable);
|
|
128
182
|
if (!shape) continue;
|
|
129
183
|
const shapeContent = {
|
|
130
184
|
type: "shape",
|
|
131
185
|
shape
|
|
132
186
|
};
|
|
133
|
-
if (
|
|
187
|
+
if (targetRunMatchesXml) targetRun.content.push(shapeContent);
|
|
134
188
|
else {
|
|
135
189
|
const newRun = {
|
|
136
190
|
type: "run",
|
|
137
191
|
content: [shapeContent]
|
|
138
192
|
};
|
|
139
|
-
|
|
193
|
+
content.splice(parsedIndex, 0, newRun);
|
|
140
194
|
lastConsumedRun = newRun;
|
|
141
195
|
parsedIndex += 1;
|
|
142
196
|
}
|
|
@@ -196,7 +250,7 @@ const scanRunForTextBoxDrawings = (xmlRun) => {
|
|
|
196
250
|
hasNonTextBoxContent
|
|
197
251
|
};
|
|
198
252
|
};
|
|
199
|
-
const parseVmlTextBoxShape = (pictEl, styles, theme, numbering, rels, media) => {
|
|
253
|
+
const parseVmlTextBoxShape = (pictEl, styles, theme, numbering, rels, media, parseTable) => {
|
|
200
254
|
const shapeEl = findDeep(pictEl, "v", "shape");
|
|
201
255
|
const textBoxEl = shapeEl ? findDeep(shapeEl, "v", "textbox") : null;
|
|
202
256
|
const contentEl = textBoxEl ? findDeep(textBoxEl, "w", "txbxContent") : null;
|
|
@@ -221,7 +275,7 @@ const parseVmlTextBoxShape = (pictEl, styles, theme, numbering, rels, media) =>
|
|
|
221
275
|
...fill === void 0 ? {} : { fill },
|
|
222
276
|
wrap: { type: vmlWrapType(positioned, zIndex) },
|
|
223
277
|
textBody: {
|
|
224
|
-
content: parseTextBoxContent(contentEl, parseParagraph,
|
|
278
|
+
content: parseTextBoxContent(contentEl, parseParagraph, parseTable, styles, theme, numbering, rels, media),
|
|
225
279
|
...margins === void 0 ? {} : { margins }
|
|
226
280
|
}
|
|
227
281
|
};
|
|
@@ -10,7 +10,7 @@ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnot
|
|
|
10
10
|
const visitRun = (run) => {
|
|
11
11
|
for (const content of run.content) {
|
|
12
12
|
if (content.type !== "shape" || !content.shape.textBody) continue;
|
|
13
|
-
for (const
|
|
13
|
+
for (const block of content.shape.textBody.content) visitBlock(block);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
const visitHyperlink = (hyperlink) => {
|
package/dist/docx/parser.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { parseNumbering } from "./numberingParser.js";
|
|
2
|
+
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
3
|
+
import { applyThemeFontLang, parseTheme } from "./themeParser.js";
|
|
1
4
|
import { toArrayBuffer } from "../utils/docxInput.js";
|
|
2
5
|
import { loadFontsWithMapping } from "../utils/fontLoader.js";
|
|
3
6
|
import { convertTiffToPngDataUrl, isTiffMimeType } from "../utils/tiffConverter.js";
|
|
4
|
-
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
5
|
-
import { applyThemeFontLang, parseTheme } from "./themeParser.js";
|
|
6
7
|
import { parseComments } from "./commentParser.js";
|
|
7
8
|
import { normalizeCommentReferences } from "./commentReferenceNormalization.js";
|
|
8
9
|
import { detectDocxConformanceClass } from "./conformance.js";
|
|
9
10
|
import { parseCoreProperties } from "./corePropertiesParser.js";
|
|
10
|
-
import { parseNumbering } from "./numberingParser.js";
|
|
11
11
|
import { extractAllTemplateVariables, parseDocumentBody } from "./documentParser.js";
|
|
12
12
|
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
13
13
|
import { parseFooter, parseHeader } from "./headerFooterParser.js";
|
package/dist/docx/rezip.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
2
1
|
import { parseNumbering } from "./numberingParser.js";
|
|
2
|
+
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
3
3
|
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
4
4
|
import { assertValidFolioDocumentModel } from "./modelValidation.js";
|
|
5
5
|
import { isPreservableDocxEntry } from "./unzip.js";
|
package/dist/docx/runParser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
2
1
|
import { EmphasisMarkSchema, FontThemeSchema, HighlightColorSchema, ShadingPatternSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
+
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
3
3
|
import { parseImage } from "./imageParser.js";
|
|
4
4
|
import { parseGroupDrawing } from "./groupDrawingParser.js";
|
|
5
5
|
import { parseShapeFromDrawing, shouldPreserveRawShapeDrawing } from "./shapeParser.js";
|
|
@@ -551,7 +551,9 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
551
551
|
break;
|
|
552
552
|
}
|
|
553
553
|
case "rPr": break;
|
|
554
|
-
case "lastRenderedPageBreak":
|
|
554
|
+
case "lastRenderedPageBreak":
|
|
555
|
+
contents.push({ type: "renderedPageBreak" });
|
|
556
|
+
break;
|
|
555
557
|
case "cr":
|
|
556
558
|
contents.push({
|
|
557
559
|
type: "break",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { elementToXml, findChild, getAttributeAnyPrefix, getLocalName, parseBooleanElement } from "./xmlParser.js";
|
|
2
1
|
import { SdtLockSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
+
import { elementToXml, findChild, getAttributeAnyPrefix, getLocalName, parseBooleanElement } from "./xmlParser.js";
|
|
3
3
|
//#region src/docx/sdtProperties.ts
|
|
4
4
|
function parseListItems(el) {
|
|
5
5
|
const items = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { findChild, findChildren, getAttribute, getChildElements, getLocalName, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
2
1
|
import { BorderStyleSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
+
import { findChild, findChildren, getAttribute, getChildElements, getLocalName, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
3
3
|
import { parseFooterReference, parseHeaderReference } from "./headerFooterRefParser.js";
|
|
4
4
|
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
5
5
|
//#region src/docx/sectionParser.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { parseNumbering } from "./numberingParser.js";
|
|
1
2
|
import { RELATIONSHIP_TYPES } from "./relsParser.js";
|
|
2
3
|
import { parseCommentsExtended } from "./commentParser.js";
|
|
3
|
-
import { parseNumbering } from "./numberingParser.js";
|
|
4
4
|
import { validateFolioDocumentModel } from "./modelValidation.js";
|
|
5
5
|
import { hasUnsynthesizedReplyRanges } from "./commentReplyMarkers.js";
|
|
6
6
|
import { buildPatchedDocumentXml, buildPatchedNoteXml, buildPatchedNumberingXml, collectChangedNumberingDefs, collectParaIds } from "./selectiveXmlPatch.js";
|
|
@@ -46,8 +46,7 @@ function serializeParagraphWithAnnotationRef(p) {
|
|
|
46
46
|
return xml;
|
|
47
47
|
}
|
|
48
48
|
function serializeComment(comment) {
|
|
49
|
-
const attrs = [`w:id="${comment.id}"`];
|
|
50
|
-
if (comment.author) attrs.push(`w:author="${escapeXml(comment.author)}"`);
|
|
49
|
+
const attrs = [`w:id="${comment.id}"`, `w:author="${escapeXml(comment.author)}"`];
|
|
51
50
|
if (comment.initials) attrs.push(`w:initials="${escapeXml(comment.initials)}"`);
|
|
52
51
|
if (comment.date) attrs.push(`w:date="${escapeXml(comment.date)}"`);
|
|
53
52
|
let xml = `<w:comment ${attrs.join(" ")}>`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
2
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
2
3
|
import { resetAutoIdCounter } from "./runSerializer.js";
|
|
3
4
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
4
5
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
5
|
-
import { serializeTable } from "./tableSerializer.js";
|
|
6
6
|
//#region src/docx/serializer/documentSerializer.ts
|
|
7
7
|
/**
|
|
8
8
|
* Standard OOXML namespaces for document.xml
|
|
@@ -74,7 +74,7 @@ function buildNamespaceDeclarations() {
|
|
|
74
74
|
*/
|
|
75
75
|
function serializeBlockContent(block) {
|
|
76
76
|
if (block.type === "paragraph") return serializeParagraph(block);
|
|
77
|
-
if (block.type === "table") return serializeTable(block);
|
|
77
|
+
if (block.type === "table") return serializeTable(block, serializeParagraph);
|
|
78
78
|
return serializeBlockSdt(block, serializeBlockContent);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { canReplayHeaderFooterVerbatim, getHeaderFooterVerbatimXml } from "../headerFooterVerbatim.js";
|
|
2
2
|
import { escapeXml } from "./xmlUtils.js";
|
|
3
3
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
4
|
-
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
5
4
|
import { serializeTable } from "./tableSerializer.js";
|
|
5
|
+
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
6
6
|
//#region src/docx/serializer/headerFooterSerializer.ts
|
|
7
7
|
const NAMESPACES = {
|
|
8
8
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -36,7 +36,7 @@ function buildNamespaceDeclarations() {
|
|
|
36
36
|
*/
|
|
37
37
|
function serializeBlock(block) {
|
|
38
38
|
if (block.type === "paragraph") return serializeParagraph(block);
|
|
39
|
-
if (block.type === "table") return serializeTable(block);
|
|
39
|
+
if (block.type === "table") return serializeTable(block, serializeParagraph);
|
|
40
40
|
return serializeBlockSdt(block, serializeBlock);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
2
|
-
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
3
2
|
import { serializeTable } from "./tableSerializer.js";
|
|
3
|
+
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
4
4
|
//#region src/docx/serializer/noteSerializer.ts
|
|
5
5
|
const NAMESPACES = {
|
|
6
6
|
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -34,7 +34,7 @@ function buildNamespaceDeclarations() {
|
|
|
34
34
|
*/
|
|
35
35
|
function serializeBlock(block) {
|
|
36
36
|
if (block.type === "paragraph") return serializeParagraph(block);
|
|
37
|
-
if (block.type === "table") return serializeTable(block);
|
|
37
|
+
if (block.type === "table") return serializeTable(block, serializeParagraph);
|
|
38
38
|
return serializeBlockSdt(block, serializeBlock);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -155,6 +155,7 @@ function serializeParagraphFormatting(formatting, propertyChanges, pPrMark) {
|
|
|
155
155
|
const frameXml = serializeFrameProperties(formatting.frame);
|
|
156
156
|
if (frameXml) parts.push(frameXml);
|
|
157
157
|
pushToggle("widowControl", formatting.widowControl);
|
|
158
|
+
pushToggle("snapToGrid", formatting.snapToGrid);
|
|
158
159
|
const numPrXml = formatting.numPrFromStyle != null && numPrEqual(formatting.numPr, formatting.numPrFromStyle) ? "" : serializeNumbering(formatting.numPr);
|
|
159
160
|
if (numPrXml) parts.push(numPrXml);
|
|
160
161
|
const bordersXml = serializeParagraphBorders(formatting.borders);
|
|
@@ -354,6 +355,8 @@ function serializeInlineSdt(sdt) {
|
|
|
354
355
|
case "inlineSdt": return serializeInlineSdt(item);
|
|
355
356
|
case "insertion": return serializeTrackedChange("ins", item);
|
|
356
357
|
case "deletion": return serializeTrackedChange("del", item);
|
|
358
|
+
case "moveFrom": return serializeTrackedChange("moveFrom", item);
|
|
359
|
+
case "moveTo": return serializeTrackedChange("moveTo", item);
|
|
357
360
|
case "mathEquation": return item.ommlXml || "";
|
|
358
361
|
default: return item;
|
|
359
362
|
}
|
|
@@ -478,7 +481,10 @@ function serializeParagraph(paragraph) {
|
|
|
478
481
|
}
|
|
479
482
|
function injectRenderedPageBreakIntoFirstRun(xml) {
|
|
480
483
|
const runOpeningTag = /<w:r(?=[\s>/])[^>]*>/u;
|
|
481
|
-
|
|
484
|
+
const openingTag = runOpeningTag.exec(xml);
|
|
485
|
+
if (!openingTag) return null;
|
|
486
|
+
const runEnd = xml.indexOf("</w:r>", openingTag.index + openingTag[0].length);
|
|
487
|
+
if (runEnd !== -1 && xml.slice(openingTag.index + openingTag[0].length, runEnd).includes("<w:lastRenderedPageBreak/>")) return xml;
|
|
482
488
|
return xml.replace(runOpeningTag, (match) => `${match}<w:lastRenderedPageBreak/>`);
|
|
483
489
|
}
|
|
484
490
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HIGHLIGHT_COLOR_VALUES } from "../../types/documentEnumValues.js";
|
|
2
2
|
import { escapeXml, intAttr } from "./xmlUtils.js";
|
|
3
|
+
import { serializeTable } from "./tableSerializer.js";
|
|
3
4
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
4
5
|
import { panic } from "better-result";
|
|
5
6
|
//#region src/docx/serializer/runSerializer.ts
|
|
@@ -418,8 +419,8 @@ function serializeDrawingContent(content) {
|
|
|
418
419
|
].join("");
|
|
419
420
|
}
|
|
420
421
|
/** Serialize text body content for shapes/textboxes */
|
|
421
|
-
function serializeShapeTextBody(
|
|
422
|
-
return
|
|
422
|
+
function serializeShapeTextBody(blocks) {
|
|
423
|
+
return blocks.map((block) => block.type === "paragraph" ? serializeParagraph(block) : serializeTable(block, serializeParagraph)).join("");
|
|
423
424
|
}
|
|
424
425
|
/**
|
|
425
426
|
* Serialize shape content to full DrawingML XML (wps:wsp inside w:drawing)
|
|
@@ -534,6 +535,7 @@ function serializeRunContent(content) {
|
|
|
534
535
|
case "instrText": return serializeInstrText(content);
|
|
535
536
|
case "softHyphen": return serializeSoftHyphen(content);
|
|
536
537
|
case "noBreakHyphen": return serializeNoBreakHyphen(content);
|
|
538
|
+
case "renderedPageBreak": return "<w:lastRenderedPageBreak/>";
|
|
537
539
|
case "drawing":
|
|
538
540
|
if (content.rawXml) return content.rawXml;
|
|
539
541
|
return serializeDrawingContent(content);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { escapeXml } from "./xmlUtils.js";
|
|
2
|
+
import { serializeTableCellFormatting, serializeTableFormatting, serializeTableRowFormatting } from "./tableSerializer.js";
|
|
2
3
|
import { serializeTextFormatting } from "./runSerializer.js";
|
|
3
4
|
import { serializeParagraphFormatting } from "./paragraphSerializer.js";
|
|
4
|
-
import { serializeTableCellFormatting, serializeTableFormatting, serializeTableRowFormatting } from "./tableSerializer.js";
|
|
5
5
|
//#region src/docx/serializer/stylesSerializer.ts
|
|
6
6
|
const W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
7
7
|
const serializeStylesXml = (definitions) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
|
|
3
3
|
//#region src/docx/serializer/tableSerializer.d.ts
|
|
4
|
+
type ParagraphSerializer = (paragraph: document_d_exports.Paragraph) => string;
|
|
4
5
|
/**
|
|
5
6
|
* Serialize table formatting properties (w:tblPr)
|
|
6
7
|
*/
|
|
@@ -16,25 +17,25 @@ declare function serializeTableCellFormatting(formatting: document_d_exports.Tab
|
|
|
16
17
|
/**
|
|
17
18
|
* Serialize a table cell (w:tc)
|
|
18
19
|
*/
|
|
19
|
-
declare function serializeTableCell(cell: document_d_exports.TableCell): string;
|
|
20
|
+
declare function serializeTableCell(cell: document_d_exports.TableCell, serializeParagraph: ParagraphSerializer): string;
|
|
20
21
|
/**
|
|
21
22
|
* Serialize a table row (w:tr)
|
|
22
23
|
*/
|
|
23
|
-
declare function serializeTableRow(row: document_d_exports.TableRow): string;
|
|
24
|
+
declare function serializeTableRow(row: document_d_exports.TableRow, serializeParagraph: ParagraphSerializer): string;
|
|
24
25
|
/**
|
|
25
26
|
* Serialize a table to OOXML XML (w:tbl)
|
|
26
27
|
*
|
|
27
28
|
* @param table - The table to serialize
|
|
28
29
|
* @returns XML string for the table
|
|
29
30
|
*/
|
|
30
|
-
declare function serializeTable(table: document_d_exports.Table): string;
|
|
31
|
+
declare function serializeTable(table: document_d_exports.Table, serializeParagraph: ParagraphSerializer): string;
|
|
31
32
|
/**
|
|
32
33
|
* Serialize multiple tables to OOXML XML
|
|
33
34
|
*
|
|
34
35
|
* @param tables - The tables to serialize
|
|
35
36
|
* @returns XML string for all tables
|
|
36
37
|
*/
|
|
37
|
-
declare function serializeTables(tables: document_d_exports.Table[]): string;
|
|
38
|
+
declare function serializeTables(tables: document_d_exports.Table[], serializeParagraph: ParagraphSerializer): string;
|
|
38
39
|
/**
|
|
39
40
|
* Check if a table has any rows
|
|
40
41
|
*/
|