@a3s-lab/office 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -3
- package/dist/{0~7043.js → 0~7231.js} +160 -2
- package/dist/{0~5093.js → 0~7360.js} +233 -52
- package/dist/0~document-editor.js +1159 -149
- package/dist/0~spreadsheet-editor.js +183 -34
- package/dist/0~work-docx-export.js +299 -11
- package/dist/0~work-docx-import.js +30 -7
- package/dist/0~work-office-diagnostics.js +125 -5
- package/dist/1544.js +13 -1
- package/dist/4104.js +29 -6
- package/dist/4121.js +1939 -1
- package/dist/6282.js +501 -1006
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +18 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +5 -2
- package/dist/internal/features/work/editors/document-font-dialog-run-shading-model.d.ts +23 -0
- package/dist/internal/features/work/editors/document-font-dialog-run-shading-section.d.ts +8 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-proofing-dialog-model.d.ts +22 -0
- package/dist/internal/features/work/editors/document-proofing-dialog.d.ts +7 -0
- package/dist/internal/features/work/editors/document-table-of-contents-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
- package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +7 -1
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +2 -0
- package/dist/internal/features/work/work-document-character-formatting.d.ts +8 -0
- package/dist/internal/features/work/work-document-format-changes.d.ts +6 -0
- package/dist/internal/features/work/work-document-highlight.d.ts +9 -0
- package/dist/internal/features/work/work-document-outline.d.ts +1 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +6 -0
- package/dist/internal/features/work/work-document-proofing.d.ts +19 -0
- package/dist/internal/features/work/work-document-run-shading.d.ts +12 -0
- package/dist/internal/features/work/work-document-table-of-contents-node.d.ts +18 -0
- package/dist/internal/features/work/work-document-table-of-contents.d.ts +51 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +1 -1
- package/dist/internal/features/work/work-docx-import.d.ts +3 -1
- package/dist/internal/features/work/work-docx-proofing-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-proofing.d.ts +38 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +7 -0
- package/dist/internal/features/work/work-docx-run-shading-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-shading-export.d.ts +17 -0
- package/dist/internal/features/work/work-docx-run-shading.d.ts +20 -0
- package/dist/internal/features/work/work-docx-table-of-contents-export.d.ts +11 -0
- package/dist/internal/features/work/work-docx-table-of-contents-import.d.ts +15 -0
- package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +7 -0
- package/dist/internal/features/work/work-types.d.ts +9 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +311 -4
- package/docs/latest/en/browser-editor-architecture.md +50 -1
- package/package.json +12 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { normalizeDocumentBookmarkName, normalizeDocumentEmphasisMark, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, applyDocumentImageIdentityToElement, documentEmphasisMarkFromElement, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE,
|
|
3
|
-
import { normalizeDocumentParagraphBorders, serializeUtf8Xml, DOCUMENT_PARAGRAPH_BORDER_EDGES,
|
|
2
|
+
import { normalizeDocumentBookmarkName, normalizeDocumentEmphasisMark, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, applyDocumentImageIdentityToElement, documentEmphasisMarkFromElement, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, documentCharacterSpacingTwipsFromElement, documentCharacterPositionHalfPointsFromElement, documentTableColumnPercentagesFromElement, documentTableCellMarginOverridesFromElement, applyDocumentTableRowIdentityToElement, normalizeDocumentBookmarksHtml, documentImageIdentityFromElement, documentTableGeometryFromElement, normalizeDocumentTableRowHeightRule, documentNoteKey, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, normalizeDocumentTableBorderWidth, normalizeDocumentCharacterSpacingTwips, documentStrikeFormattingFromElement, normalizeDocumentTableBorderStyle, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, normalizeDocumentUnderlineStyle, normalizeDocumentPageChrome, documentPageMarginsForLayout, normalizeDocumentImageLayer, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, normalizeDocumentLegacyTextEffects, documentCaptionLabel, documentCaptionKind, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, isContourImageLayout, normalizeDocumentImageIdentity, normalizeTableColor, normalizeDocumentStrikeStyle, documentTableBordersFromElement, documentSections, documentCitationTags, docxDocumentFieldKind, wrapsBesideImage, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentKerningThresholdHalfPoints, defaultDocumentImageWrapContour, normalizeDocumentPaperSource, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, documentEquationFromElement, documentLegacyTextEffectsFromElement, parseDocumentCharacterFormatting, documentUnderlineFormattingFromElement, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, normalizeDocumentEquation, parseDocumentParagraphFormatting, documentTableRowIdentityFromElement, normalizeDocumentBookmarkNativeId, collectDocumentNotes, DOCUMENT_PAGE_MARGIN_KEYS, uniqueDocumentImageIdentity, documentHiddenTextFromElement, documentImageLayoutFromElement, documentPageHorizontalMarginTwips, documentPageGeometryForLayout, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, documentCharacterScalePercentFromElement, normalizeDocumentPageMargins, normalizeDocumentLegacyTextEffect, documentNoteKind } from "./6282.js";
|
|
3
|
+
import { normalizeDocumentRunBorder, parseDocumentScriptFonts, parseDocxThemeReference, parseXml, parseDocumentRunShading, applyDocumentParagraphIdentityToElement, DOCUMENT_RUN_SHADING_ATTRIBUTE, documentScriptFontSlotFromElement, DOCUMENT_HIGHLIGHT_ATTRIBUTE, serializeDocumentScriptFonts, attribute as work_ooxml_package_attribute, createDocumentParagraphIdentityRegistry, uniqueDocumentParagraphIdentity, DOCUMENT_NO_PROOF_ATTRIBUTE, documentHighlightForCssColor, directChildren, documentTableOfContentsValueFromElement, DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE, DocxThemePatchCollector, normalizeDocumentScriptFonts, normalizeDocumentParagraphIdentity, normalizeDocumentHighlight, normalizeDocumentParagraphBorders, serializeUtf8Xml, DOCUMENT_PARAGRAPH_BORDER_EDGES, parseDocumentRunBorder, normalizeDocumentNoProof, decodeXmlBytes, documentParagraphIdentityFromElement, normalizeDocumentParagraphId, documentScriptFontFamily, descendants, resolvePartTarget, documentProofingLanguagesFromElement, documentHighlightFromElement, parseDocumentRunShadingElement, parseDocumentProofingLanguages, patchDocxThemeReferences, parseDocumentParagraphBordersElement, DOCUMENT_RUN_BORDER_ATTRIBUTE, parseDocumentRunBorderElement, xmlNamespacePrefix, documentScriptFontSlotFromHint, documentNoProofFromElement, documentScriptFontsFromElement, normalizeDocumentRunShading, normalizeDocumentScriptFontSlot, directChild, parseDocumentParagraphShadingElement, documentFontNameFromCssFamily } from "./4121.js";
|
|
4
4
|
import { assignDocxNoteIds, patchDocxPageColor, normalizeDocxCommentId, assignDocxCommentThreads } from "./0~4980.js";
|
|
5
|
-
import { paragraphTabStops, mergeDocxIgnorableExtensionsAtPairs, patchDocxBibliography, docxKerningThresholdValue, docxCharacterPositionValue, docxCharacterScaleValue, docxEmphasisMarkRunOptions, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, paragraphSpacingOptions, xmlNamespaceUri, hasNonWhitespaceXmlText, patchDocxExplicitZeroCharacterSpacing, cloneXmlElement, cssColorToHex, DocxParagraphDefaultCollapsedPatchCollector, assertXmlRoot, xmlDeclaredPrefix, paragraphIndent, domDirection, DOCX_WORDPROCESSING_NAMESPACES, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, patchDocxParagraphDefaultCollapsed, xmlAttributeNamespace, dataBoolean, mergeDocxIgnorableExtensions, patchDocxExplicitZeroKerningThresholds, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~
|
|
5
|
+
import { paragraphTabStops, mergeDocxIgnorableExtensionsAtPairs, patchDocxBibliography, docxKerningThresholdValue, docxCharacterPositionValue, docxCharacterScaleValue, docxEmphasisMarkRunOptions, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, paragraphSpacingOptions, xmlNamespaceUri, hasNonWhitespaceXmlText, patchDocxExplicitZeroCharacterSpacing, cloneXmlElement, cssColorToHex, DocxParagraphDefaultCollapsedPatchCollector, assertXmlRoot, xmlDeclaredPrefix, paragraphIndent, domDirection, DOCX_WORDPROCESSING_NAMESPACES, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, patchDocxParagraphDefaultCollapsed, xmlAttributeNamespace, dataBoolean, mergeDocxIgnorableExtensions, patchDocxExplicitZeroKerningThresholds, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, documentProofingLanguageDocxOptions, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~7231.js";
|
|
6
6
|
import { normalizeDocumentHref } from "./0~work-document-links.js";
|
|
7
7
|
const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
8
8
|
class DocxBookmarkPatchCollector {
|
|
@@ -2374,6 +2374,113 @@ function docxDocumentFieldRun(element, docx) {
|
|
|
2374
2374
|
if (!docxDocumentFieldKind(instruction)) return new docx.TextRun(display);
|
|
2375
2375
|
return new docx.SimpleField(instruction, display);
|
|
2376
2376
|
}
|
|
2377
|
+
const work_docx_run_shading_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
2378
|
+
class DocxRunShadingPatchCollector {
|
|
2379
|
+
patches = [];
|
|
2380
|
+
nextMarker = 1;
|
|
2381
|
+
usedColors;
|
|
2382
|
+
constructor(sourceHtml){
|
|
2383
|
+
this.usedColors = work_docx_run_shading_export_sourceColors(sourceHtml);
|
|
2384
|
+
}
|
|
2385
|
+
marker(source) {
|
|
2386
|
+
const shading = normalizeDocumentRunShading(source);
|
|
2387
|
+
if (!shading) return null;
|
|
2388
|
+
let marker = '';
|
|
2389
|
+
do {
|
|
2390
|
+
const value = 0xd00000 + this.nextMarker;
|
|
2391
|
+
if (value > 0xdfffff) throw new Error('DOCX character shading marker space is exhausted.');
|
|
2392
|
+
marker = value.toString(16).padStart(6, '0').toUpperCase();
|
|
2393
|
+
this.nextMarker += 1;
|
|
2394
|
+
}while (this.usedColors.has(marker))
|
|
2395
|
+
this.usedColors.add(marker);
|
|
2396
|
+
this.patches.push({
|
|
2397
|
+
marker,
|
|
2398
|
+
shading
|
|
2399
|
+
});
|
|
2400
|
+
return marker;
|
|
2401
|
+
}
|
|
2402
|
+
hasMarker(value) {
|
|
2403
|
+
const marker = value?.toUpperCase();
|
|
2404
|
+
return Boolean(marker && this.patches.some((patch)=>patch.marker === marker));
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
function documentRunShadingDocxOptions(source, collector) {
|
|
2408
|
+
const marker = collector.marker(source);
|
|
2409
|
+
return marker ? {
|
|
2410
|
+
shading: {
|
|
2411
|
+
type: 'clear',
|
|
2412
|
+
color: 'auto',
|
|
2413
|
+
fill: marker
|
|
2414
|
+
}
|
|
2415
|
+
} : {};
|
|
2416
|
+
}
|
|
2417
|
+
async function patchDocxRunShading(buffer, patches) {
|
|
2418
|
+
if (!patches.length) return buffer;
|
|
2419
|
+
const archive = await jszip.loadAsync(buffer);
|
|
2420
|
+
const byMarker = new Map(patches.map((patch)=>[
|
|
2421
|
+
patch.marker,
|
|
2422
|
+
patch
|
|
2423
|
+
]));
|
|
2424
|
+
const applied = new Set();
|
|
2425
|
+
for (const entry of Object.values(archive.files)){
|
|
2426
|
+
if (entry.dir || !/^word\/(?:document|header\d+|footer\d+|footnotes|endnotes|comments)\.xml$/i.test(entry.name)) continue;
|
|
2427
|
+
const document = parseXml(await entry.async('text'), entry.name);
|
|
2428
|
+
let changed = false;
|
|
2429
|
+
for (const element of Array.from(document.getElementsByTagName('*'))){
|
|
2430
|
+
if ('shd' !== element.localName || element.namespaceURI !== work_docx_run_shading_export_WORD_NAMESPACE || element.parentElement?.localName !== 'rPr') continue;
|
|
2431
|
+
const marker = work_docx_run_shading_export_wordAttribute(element, 'fill')?.toUpperCase();
|
|
2432
|
+
const patch = marker ? byMarker.get(marker) : void 0;
|
|
2433
|
+
if (marker && patch) {
|
|
2434
|
+
replaceRunShadingAttributes(document, element, patch.shading);
|
|
2435
|
+
applied.add(marker);
|
|
2436
|
+
changed = true;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (changed) archive.file(entry.name, serializeUtf8Xml(document));
|
|
2440
|
+
}
|
|
2441
|
+
const missing = patches.filter((patch)=>!applied.has(patch.marker));
|
|
2442
|
+
if (missing.length) throw new Error(`Generated DOCX is missing ${missing.length} character shading marker(s).`);
|
|
2443
|
+
return archive.generateAsync({
|
|
2444
|
+
type: 'arraybuffer'
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
function setDocxRunShadingAttributes(document, element, source) {
|
|
2448
|
+
const shading = normalizeDocumentRunShading(source);
|
|
2449
|
+
if (!shading) return false;
|
|
2450
|
+
work_docx_run_shading_export_setWordAttribute(document, element, 'val', shading.pattern);
|
|
2451
|
+
setShadingColorAttributes(document, element, shading.color, 'color');
|
|
2452
|
+
setShadingColorAttributes(document, element, shading.fill, 'fill');
|
|
2453
|
+
return true;
|
|
2454
|
+
}
|
|
2455
|
+
function replaceRunShadingAttributes(document, element, shading) {
|
|
2456
|
+
for (const attribute of Array.from(element.attributes))if ('xmlns' !== attribute.name && !attribute.name.startsWith('xmlns:')) element.removeAttributeNode(attribute);
|
|
2457
|
+
element.replaceChildren();
|
|
2458
|
+
setDocxRunShadingAttributes(document, element, shading);
|
|
2459
|
+
}
|
|
2460
|
+
function setShadingColorAttributes(document, element, color, kind) {
|
|
2461
|
+
if (!color) return;
|
|
2462
|
+
work_docx_run_shading_export_setWordAttribute(document, element, kind, 'auto' === color.value ? 'auto' : color.value.slice(1).toUpperCase());
|
|
2463
|
+
if (!color.theme) return;
|
|
2464
|
+
const themeName = 'color' === kind ? 'themeColor' : 'themeFill';
|
|
2465
|
+
const tintName = 'color' === kind ? 'themeTint' : 'themeFillTint';
|
|
2466
|
+
const shadeName = 'color' === kind ? 'themeShade' : 'themeFillShade';
|
|
2467
|
+
work_docx_run_shading_export_setWordAttribute(document, element, themeName, color.theme.theme);
|
|
2468
|
+
if (color.theme.tint) work_docx_run_shading_export_setWordAttribute(document, element, tintName, color.theme.tint);
|
|
2469
|
+
if (color.theme.shade) work_docx_run_shading_export_setWordAttribute(document, element, shadeName, color.theme.shade);
|
|
2470
|
+
}
|
|
2471
|
+
function work_docx_run_shading_export_sourceColors(source) {
|
|
2472
|
+
const colors = new Set();
|
|
2473
|
+
for (const match of source.matchAll(/#([0-9a-f]{6})\b/gi))if (match[1]) colors.add(match[1].toUpperCase());
|
|
2474
|
+
return colors;
|
|
2475
|
+
}
|
|
2476
|
+
function work_docx_run_shading_export_wordAttribute(element, name) {
|
|
2477
|
+
return element.getAttributeNS(element.namespaceURI ?? work_docx_run_shading_export_WORD_NAMESPACE, name) ?? element.getAttribute(`${element.prefix ?? 'w'}:${name}`);
|
|
2478
|
+
}
|
|
2479
|
+
function work_docx_run_shading_export_setWordAttribute(document, element, name, value) {
|
|
2480
|
+
const namespace = element.namespaceURI ?? work_docx_run_shading_export_WORD_NAMESPACE;
|
|
2481
|
+
const prefix = element.prefix ?? xmlNamespacePrefix(document.documentElement, namespace) ?? 'w';
|
|
2482
|
+
element.setAttributeNS(namespace, `${prefix}:${name}`, value);
|
|
2483
|
+
}
|
|
2377
2484
|
const MAX_RUN_FORMATTING_CHANGE_PATCHES = 65536;
|
|
2378
2485
|
const RUN_FORMATTING_PART_PATTERN = /^word\/(?:document|header\d*|footer\d*|footnotes|endnotes)\.xml$/i;
|
|
2379
2486
|
class DocxRunFormattingChangePatchCollector {
|
|
@@ -2503,6 +2610,7 @@ function appendFormattingProperties(document, properties, namespace, prefix, ser
|
|
|
2503
2610
|
appendTextCaseProperties(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2504
2611
|
appendStrikeProperties(document, properties, namespace, prefix, byType.get('strike'));
|
|
2505
2612
|
appendLegacyTextEffectsProperties(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2613
|
+
appendNoProofProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2506
2614
|
appendSnapToGridProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2507
2615
|
appendHiddenTextProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2508
2616
|
appendColorProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
@@ -2511,11 +2619,28 @@ function appendFormattingProperties(document, properties, namespace, prefix, ser
|
|
|
2511
2619
|
appendKerningThresholdProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2512
2620
|
appendCharacterPositionProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2513
2621
|
appendFontSizeProperties(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2514
|
-
appendHighlightProperty(document, properties, namespace, prefix, byType.get('highlight'));
|
|
2622
|
+
appendHighlightProperty(document, properties, namespace, prefix, byType.get('highlight'), !parseDocumentRunShading(byType.get('textStyle')?.attrs?.runShading));
|
|
2515
2623
|
appendUnderlineProperty(document, properties, namespace, prefix, byType.get('underline'));
|
|
2516
2624
|
appendRunBorderProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2625
|
+
appendRunShadingProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2517
2626
|
appendVerticalAlignProperty(document, properties, namespace, prefix, byType);
|
|
2518
2627
|
appendEmphasisMarkProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2628
|
+
appendProofingLanguagesProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2629
|
+
}
|
|
2630
|
+
function appendNoProofProperty(document, properties, namespace, prefix, mark) {
|
|
2631
|
+
const noProof = normalizeDocumentNoProof(mark?.attrs?.noProof);
|
|
2632
|
+
if (null === noProof) return;
|
|
2633
|
+
if (noProof) properties.append(wordElement(document, namespace, prefix, 'noProof'));
|
|
2634
|
+
else appendValuedProperty(document, properties, namespace, prefix, 'noProof', '0');
|
|
2635
|
+
}
|
|
2636
|
+
function appendProofingLanguagesProperty(document, properties, namespace, prefix, mark) {
|
|
2637
|
+
const languages = parseDocumentProofingLanguages(mark?.attrs?.proofingLanguages);
|
|
2638
|
+
if (!languages) return;
|
|
2639
|
+
const element = wordElement(document, namespace, prefix, 'lang');
|
|
2640
|
+
if (languages.latin) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', languages.latin);
|
|
2641
|
+
if (languages.eastAsia) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'eastAsia', languages.eastAsia);
|
|
2642
|
+
if (languages.bidi) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'bidi', languages.bidi);
|
|
2643
|
+
properties.append(element);
|
|
2519
2644
|
}
|
|
2520
2645
|
function appendRunBorderProperty(document, properties, namespace, prefix, mark) {
|
|
2521
2646
|
const border = parseDocumentRunBorder(mark?.attrs?.runBorder);
|
|
@@ -2536,6 +2661,13 @@ function appendRunBorderProperty(document, properties, namespace, prefix, mark)
|
|
|
2536
2661
|
if (void 0 !== border.frame) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'frame', border.frame ? '1' : '0');
|
|
2537
2662
|
properties.append(element);
|
|
2538
2663
|
}
|
|
2664
|
+
function appendRunShadingProperty(document, properties, namespace, prefix, mark) {
|
|
2665
|
+
const shading = parseDocumentRunShading(mark?.attrs?.runShading);
|
|
2666
|
+
if (!shading) return;
|
|
2667
|
+
const element = wordElement(document, namespace, prefix, 'shd');
|
|
2668
|
+
if (!setDocxRunShadingAttributes(document, element, shading)) return;
|
|
2669
|
+
properties.append(element);
|
|
2670
|
+
}
|
|
2539
2671
|
function appendLegacyTextEffectsProperties(document, properties, namespace, prefix, mark) {
|
|
2540
2672
|
const effects = {};
|
|
2541
2673
|
const attributes = [
|
|
@@ -2704,7 +2836,10 @@ function appendFontSizeProperties(document, properties, namespace, prefix, mark)
|
|
|
2704
2836
|
appendValuedProperty(document, properties, namespace, prefix, 'sz', String(halfPoints));
|
|
2705
2837
|
appendValuedProperty(document, properties, namespace, prefix, 'szCs', String(halfPoints));
|
|
2706
2838
|
}
|
|
2707
|
-
function appendHighlightProperty(document, properties, namespace, prefix, mark) {
|
|
2839
|
+
function appendHighlightProperty(document, properties, namespace, prefix, mark, allowFallbackShading) {
|
|
2840
|
+
const nativeHighlight = normalizeDocumentHighlight(mark?.attrs?.nativeHighlight) ?? documentHighlightForCssColor(mark?.attrs?.color);
|
|
2841
|
+
if (nativeHighlight) return void appendValuedProperty(document, properties, namespace, prefix, 'highlight', nativeHighlight);
|
|
2842
|
+
if (!allowFallbackShading) return;
|
|
2708
2843
|
const fill = normalizedHex(mark?.attrs?.color);
|
|
2709
2844
|
const theme = themeReference(mark?.attrs?.themeFill);
|
|
2710
2845
|
if (!fill && !theme) return;
|
|
@@ -3971,6 +4106,127 @@ function docxBorderStyle(style, docx) {
|
|
|
3971
4106
|
function docxColor(color) {
|
|
3972
4107
|
return color.replace(/^#/, '').toUpperCase();
|
|
3973
4108
|
}
|
|
4109
|
+
const work_docx_table_of_contents_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4110
|
+
const work_docx_table_of_contents_export_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4111
|
+
class DocxTableOfContentsPatchCollector {
|
|
4112
|
+
patches = [];
|
|
4113
|
+
add(element) {
|
|
4114
|
+
const value = documentTableOfContentsValueFromElement(element);
|
|
4115
|
+
const patch = {
|
|
4116
|
+
options: value.options,
|
|
4117
|
+
entries: value.entries
|
|
4118
|
+
};
|
|
4119
|
+
this.patches.push(patch);
|
|
4120
|
+
return patch;
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
function docxTableOfContents(element, docx, collector) {
|
|
4124
|
+
const patch = collector.add(element);
|
|
4125
|
+
const options = patch.options;
|
|
4126
|
+
return new docx.TableOfContents('Table of Contents', {
|
|
4127
|
+
hyperlink: options.hyperlinks,
|
|
4128
|
+
headingStyleRange: `${options.minLevel}-${options.maxLevel}`,
|
|
4129
|
+
pageNumbersEntryLevelsRange: options.showPageNumbers ? void 0 : `${options.minLevel}-${options.maxLevel}`,
|
|
4130
|
+
entryAndPageNumberSeparator: options.showPageNumbers && !options.rightAlignPageNumbers ? ' ' : void 0,
|
|
4131
|
+
useAppliedParagraphOutlineLevel: true,
|
|
4132
|
+
hideTabAndPageNumbersInWebView: true,
|
|
4133
|
+
cachedEntries: patch.entries.map((entry)=>({
|
|
4134
|
+
title: entry.title,
|
|
4135
|
+
level: entry.level,
|
|
4136
|
+
page: options.showPageNumbers ? entry.pageNumber : void 0,
|
|
4137
|
+
href: options.hyperlinks ? entry.targetId : void 0
|
|
4138
|
+
}))
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
async function patchDocxTableOfContents(buffer, patches) {
|
|
4142
|
+
if (!patches.length) return buffer;
|
|
4143
|
+
const archive = await jszip.loadAsync(buffer);
|
|
4144
|
+
const entry = archive.file('word/document.xml');
|
|
4145
|
+
if (!entry) return buffer;
|
|
4146
|
+
const document = parseXml(await entry.async('text'), 'generated DOCX word/document.xml');
|
|
4147
|
+
const tables = descendants(document, 'sdt').filter((element)=>descendants(element, 'instrText').some((instruction)=>/^\s*TOC\b/i.test(instruction.textContent ?? '')));
|
|
4148
|
+
if (tables.length !== patches.length) throw new Error(`Generated DOCX emitted ${tables.length} table(s) of contents for ${patches.length} source block(s).`);
|
|
4149
|
+
for (const [index, table] of tables.entries()){
|
|
4150
|
+
const patch = patches[index];
|
|
4151
|
+
if (patch) patchTableOfContents(document, table, patch.options);
|
|
4152
|
+
}
|
|
4153
|
+
addTableOfContentsBookmarks(document, patches);
|
|
4154
|
+
archive.file('word/document.xml', new XMLSerializer().serializeToString(document));
|
|
4155
|
+
return archive.generateAsync({
|
|
4156
|
+
type: 'arraybuffer'
|
|
4157
|
+
});
|
|
4158
|
+
}
|
|
4159
|
+
function patchTableOfContents(document, table, options) {
|
|
4160
|
+
for (const tabStop of descendants(table, 'tab')){
|
|
4161
|
+
if (tabStop.parentElement?.localName !== 'tabs') continue;
|
|
4162
|
+
const value = work_ooxml_package_attribute(tabStop, 'val');
|
|
4163
|
+
if ('right' !== value) continue;
|
|
4164
|
+
if (!options.showPageNumbers || !options.rightAlignPageNumbers) {
|
|
4165
|
+
const parent = tabStop.parentElement;
|
|
4166
|
+
tabStop.remove();
|
|
4167
|
+
if (parent && !directChildren(parent, 'tab').length) parent.remove();
|
|
4168
|
+
continue;
|
|
4169
|
+
}
|
|
4170
|
+
const leader = docxTableOfContentsLeader(options.leader);
|
|
4171
|
+
if (leader) work_docx_table_of_contents_export_setWordAttribute(document, tabStop, 'leader', leader);
|
|
4172
|
+
else removeWordAttribute(tabStop, 'leader');
|
|
4173
|
+
}
|
|
4174
|
+
if (options.showPageNumbers && options.rightAlignPageNumbers) return;
|
|
4175
|
+
for (const tab of descendants(table, 'tab')){
|
|
4176
|
+
if (tab.parentElement?.localName === 'tabs') continue;
|
|
4177
|
+
if (!options.showPageNumbers) {
|
|
4178
|
+
tab.remove();
|
|
4179
|
+
continue;
|
|
4180
|
+
}
|
|
4181
|
+
const text = document.createElementNS(work_docx_table_of_contents_export_WORD_NAMESPACE, work_docx_table_of_contents_export_wordQualifiedName(document.documentElement, 't'));
|
|
4182
|
+
text.setAttributeNS(work_docx_table_of_contents_export_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4183
|
+
text.textContent = ' ';
|
|
4184
|
+
tab.replaceWith(text);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
function addTableOfContentsBookmarks(document, patches) {
|
|
4188
|
+
const names = new Set(descendants(document, 'bookmarkStart').flatMap((bookmark)=>{
|
|
4189
|
+
const name = work_ooxml_package_attribute(bookmark, 'name')?.trim();
|
|
4190
|
+
return name ? [
|
|
4191
|
+
name
|
|
4192
|
+
] : [];
|
|
4193
|
+
}));
|
|
4194
|
+
let nextId = Math.max(0, ...descendants(document, 'bookmarkStart').map((bookmark)=>Number(work_ooxml_package_attribute(bookmark, 'id') ?? 0))) + 1;
|
|
4195
|
+
const targets = new Set(patches.flatMap((patch)=>patch.options.hyperlinks ? patch.entries.map((candidate)=>candidate.targetId) : []));
|
|
4196
|
+
for (const target of targets){
|
|
4197
|
+
if (names.has(target)) continue;
|
|
4198
|
+
const paragraphId = /^heading-([0-9a-f]{8})$/i.exec(target)?.[1];
|
|
4199
|
+
if (!paragraphId) continue;
|
|
4200
|
+
const paragraph = descendants(document, 'p').find((candidate)=>work_ooxml_package_attribute(candidate, 'paraId')?.toLowerCase() === paragraphId.toLowerCase());
|
|
4201
|
+
if (!paragraph) continue;
|
|
4202
|
+
const start = document.createElementNS(work_docx_table_of_contents_export_WORD_NAMESPACE, work_docx_table_of_contents_export_wordQualifiedName(document.documentElement, 'bookmarkStart'));
|
|
4203
|
+
const end = document.createElementNS(work_docx_table_of_contents_export_WORD_NAMESPACE, work_docx_table_of_contents_export_wordQualifiedName(document.documentElement, 'bookmarkEnd'));
|
|
4204
|
+
work_docx_table_of_contents_export_setWordAttribute(document, start, 'id', String(nextId));
|
|
4205
|
+
work_docx_table_of_contents_export_setWordAttribute(document, start, 'name', target);
|
|
4206
|
+
work_docx_table_of_contents_export_setWordAttribute(document, end, 'id', String(nextId));
|
|
4207
|
+
nextId += 1;
|
|
4208
|
+
const properties = directChild(paragraph, 'pPr');
|
|
4209
|
+
paragraph.insertBefore(start, properties?.nextSibling ?? paragraph.firstChild);
|
|
4210
|
+
paragraph.append(end);
|
|
4211
|
+
names.add(target);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
function docxTableOfContentsLeader(value) {
|
|
4215
|
+
if ('dash' === value) return 'hyphen';
|
|
4216
|
+
if ('underline' === value) return 'underscore';
|
|
4217
|
+
if ('dot' === value) return 'dot';
|
|
4218
|
+
return null;
|
|
4219
|
+
}
|
|
4220
|
+
function work_docx_table_of_contents_export_setWordAttribute(document, element, localName, value) {
|
|
4221
|
+
removeWordAttribute(element, localName);
|
|
4222
|
+
element.setAttributeNS(work_docx_table_of_contents_export_WORD_NAMESPACE, work_docx_table_of_contents_export_wordQualifiedName(document.documentElement, localName), value);
|
|
4223
|
+
}
|
|
4224
|
+
function removeWordAttribute(element, localName) {
|
|
4225
|
+
for (const candidate of Array.from(element.attributes))if (candidate.localName === localName && (candidate.namespaceURI === work_docx_table_of_contents_export_WORD_NAMESPACE || !candidate.namespaceURI)) element.removeAttributeNode(candidate);
|
|
4226
|
+
}
|
|
4227
|
+
function work_docx_table_of_contents_export_wordQualifiedName(root, localName) {
|
|
4228
|
+
return `${xmlNamespacePrefix(root, work_docx_table_of_contents_export_WORD_NAMESPACE) ?? 'w'}:${localName}`;
|
|
4229
|
+
}
|
|
3974
4230
|
const work_docx_table_sizing_export_TWIPS_PER_PIXEL = 15;
|
|
3975
4231
|
function documentTableSizingDocxOptions(table, docx) {
|
|
3976
4232
|
const geometry = documentTableGeometryFromElement(table);
|
|
@@ -7991,8 +8247,11 @@ async function createDocxBlob(content, sourcePackage) {
|
|
|
7991
8247
|
legacyTextEffectsPatches: new DocxLegacyTextEffectsPatchCollector(JSON.stringify(normalizedContent)),
|
|
7992
8248
|
runBorderPatches: new DocxRunBorderPatchCollector(JSON.stringify(normalizedContent)),
|
|
7993
8249
|
usedRunBorderMarkers: new Set(),
|
|
8250
|
+
runShadingPatches: new DocxRunShadingPatchCollector(JSON.stringify(normalizedContent)),
|
|
8251
|
+
usedRunShadingMarkers: new Set(),
|
|
7994
8252
|
usedNativeTextEffectMarkers: new Set(),
|
|
7995
8253
|
paragraphFormattingChangePatches: new DocxParagraphFormattingChangePatchCollector(),
|
|
8254
|
+
tableOfContentsPatches: new DocxTableOfContentsPatchCollector(),
|
|
7996
8255
|
hasExplicitZeroCharacterSpacing: false,
|
|
7997
8256
|
hasExplicitZeroKerningThreshold: false
|
|
7998
8257
|
};
|
|
@@ -8047,7 +8306,8 @@ async function createDocxBlob(content, sourcePackage) {
|
|
|
8047
8306
|
const hiddenTextPatched = await patchDocxHiddenText(runFontsPatched, noteContext.hiddenTextPatches.patches.filter((patch)=>noteContext.usedNativeTextEffectMarkers.has(patch.marker)));
|
|
8048
8307
|
const legacyTextEffectsPatched = await patchDocxLegacyTextEffects(hiddenTextPatched, noteContext.legacyTextEffectsPatches.patches.filter((patch)=>noteContext.usedNativeTextEffectMarkers.has(patch.marker)));
|
|
8049
8308
|
const runBordersPatched = await patchDocxRunBorders(legacyTextEffectsPatched, noteContext.runBorderPatches.patches.filter((patch)=>noteContext.usedRunBorderMarkers.has(patch.marker)));
|
|
8050
|
-
const
|
|
8309
|
+
const runShadingPatched = await patchDocxRunShading(runBordersPatched, noteContext.runShadingPatches.patches.filter((patch)=>noteContext.usedRunShadingMarkers.has(patch.marker)));
|
|
8310
|
+
const formattingChangesPatched = await patchDocxRunFormattingChanges(runShadingPatched, noteContext.formattingChangePatches.patches);
|
|
8051
8311
|
const noteImageRelationshipsPatched = await patchDocxNoteImageRelationships(formattingChangesPatched);
|
|
8052
8312
|
const commentMetadataPatched = await patchDocxCommentMetadata(noteImageRelationshipsPatched, commentThreads);
|
|
8053
8313
|
const numberingPatched = await patchDocxNumberingRestartRules(commentMetadataPatched, noteContext.numberingRestartRules);
|
|
@@ -8062,7 +8322,8 @@ async function createDocxBlob(content, sourcePackage) {
|
|
|
8062
8322
|
const bookmarkPatched = await patchDocxBookmarks(imageIdentityPatched, noteContext.bookmarkPatches.patches);
|
|
8063
8323
|
const paragraphDefaultCollapsedPatched = await patchDocxParagraphDefaultCollapsed(bookmarkPatched, noteContext.paragraphDefaultCollapsedPatches.patches);
|
|
8064
8324
|
const paragraphIdentityPatched = await patchDocxParagraphIdentities(paragraphDefaultCollapsedPatched, noteContext.paragraphIdentityPatches.patches);
|
|
8065
|
-
const
|
|
8325
|
+
const tableOfContentsPatched = await patchDocxTableOfContents(paragraphIdentityPatched, noteContext.tableOfContentsPatches.patches);
|
|
8326
|
+
const paragraphFormattingChangesPatched = await patchDocxParagraphFormattingChanges(tableOfContentsPatched, noteContext.paragraphFormattingChangePatches.patches);
|
|
8066
8327
|
const equationPatched = await patchDocxEquations(paragraphFormattingChangesPatched, noteContext.equationPatches.patches);
|
|
8067
8328
|
const patched = await patchDocxPageColor(equationPatched, normalizedContent.pageColor);
|
|
8068
8329
|
const preserved = sourcePackage ? await preserveDocxSourcePackage(patched, sourcePackage, {
|
|
@@ -8132,6 +8393,10 @@ function markDocxRunBorderUsed(border, context) {
|
|
|
8132
8393
|
const marker = border?.color?.toUpperCase();
|
|
8133
8394
|
if (context.runBorderPatches.hasMarker(marker)) context.usedRunBorderMarkers.add(marker);
|
|
8134
8395
|
}
|
|
8396
|
+
function markDocxRunShadingUsed(shading, context) {
|
|
8397
|
+
const marker = shading?.fill?.toUpperCase();
|
|
8398
|
+
if (context.runShadingPatches.hasMarker(marker)) context.usedRunShadingMarkers.add(marker);
|
|
8399
|
+
}
|
|
8135
8400
|
function work_docx_export_sectionProperties(layout, docx) {
|
|
8136
8401
|
const landscape = 'landscape' === layout.orientation;
|
|
8137
8402
|
const dimensions = documentPageGeometryForLayout(layout);
|
|
@@ -8229,6 +8494,9 @@ async function blockToFileChildren(element, docx, noteContext) {
|
|
|
8229
8494
|
if (element.hasAttribute('data-document-bibliography')) return [
|
|
8230
8495
|
docxBibliographyParagraph(element, docx, paragraphBidirectional(element))
|
|
8231
8496
|
];
|
|
8497
|
+
if (element.hasAttribute('data-document-table-of-contents')) return [
|
|
8498
|
+
docxTableOfContents(element, docx, noteContext.tableOfContentsPatches)
|
|
8499
|
+
];
|
|
8232
8500
|
if (element.hasAttribute('data-document-caption')) return [
|
|
8233
8501
|
docxCaptionParagraph(element, await paragraphRuns(element, docx, noteContext), docx, paragraphBidirectional(element))
|
|
8234
8502
|
];
|
|
@@ -8303,6 +8571,7 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
8303
8571
|
if (!node.textContent) return [];
|
|
8304
8572
|
markDocxNativeTextEffectStyleUsed(inherited.style, noteContext);
|
|
8305
8573
|
markDocxRunBorderUsed(inherited.border, noteContext);
|
|
8574
|
+
markDocxRunShadingUsed(inherited.shading, noteContext);
|
|
8306
8575
|
if (revision?.kind === 'insertion') return [
|
|
8307
8576
|
new docx.InsertedTextRun({
|
|
8308
8577
|
...inherited,
|
|
@@ -8360,19 +8629,32 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
8360
8629
|
const formattingChange = node.hasAttribute('data-document-change') && 'formatting' === node.dataset.changeKind ? noteContext.formattingChangePatches.register(node, docxRevisionId(node, noteContext)) : null;
|
|
8361
8630
|
const commentBoundary = node.hasAttribute('data-document-comment') ? nextDocxCommentBoundary(node.dataset.commentId, noteContext) : null;
|
|
8362
8631
|
const backgroundColor = cssColorToHex(node.style.backgroundColor);
|
|
8632
|
+
const hasExplicitRunShading = 'span' === tag && node.hasAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE);
|
|
8633
|
+
const explicitRunShading = hasExplicitRunShading ? parseDocumentRunShadingElement(node) : null;
|
|
8634
|
+
if (hasExplicitRunShading && !explicitRunShading) throw new Error('Document contains invalid character shading.');
|
|
8635
|
+
const hasHighlightSemantics = node.hasAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE) || node.hasAttribute('data-color') || 'mark' === tag || Boolean(backgroundColor) && !hasExplicitRunShading;
|
|
8636
|
+
const explicitHighlight = hasHighlightSemantics ? documentHighlightFromElement(node) : null;
|
|
8363
8637
|
const direction = domDirection(node);
|
|
8364
8638
|
const resolvedColor = cssColorToHex(node.style.color) ?? inherited.color;
|
|
8365
8639
|
const themeColorMarker = noteContext.themePatches.marker('color', parseDocxThemeReference(node.dataset.officeThemeColor), resolvedColor ? `#${resolvedColor}` : null);
|
|
8366
|
-
const
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8640
|
+
const runShading = explicitRunShading ? documentRunShadingDocxOptions(explicitRunShading, noteContext.runShadingPatches).shading : void 0;
|
|
8641
|
+
const customHighlightFill = hasHighlightSemantics && !explicitHighlight ? backgroundColor : null;
|
|
8642
|
+
const resolvedShading = runShading ?? (customHighlightFill ? {
|
|
8643
|
+
fill: customHighlightFill
|
|
8644
|
+
} : inherited.shading);
|
|
8645
|
+
const themeFillMarker = !runShading && customHighlightFill ? noteContext.themePatches.marker('fill', parseDocxThemeReference(node.dataset.officeThemeFill), `#${customHighlightFill}`) : null;
|
|
8370
8646
|
const explicitTextCase = normalizeDocumentTextCase(node.dataset.officeTextCase);
|
|
8371
8647
|
const explicitCharacterSpacing = documentCharacterSpacingTwipsFromElement(node);
|
|
8372
8648
|
const explicitCharacterScale = documentCharacterScalePercentFromElement(node);
|
|
8373
8649
|
const explicitKerningThreshold = documentKerningThresholdHalfPointsFromElement(node);
|
|
8374
8650
|
const explicitEmphasisMark = documentEmphasisMarkFromElement(node);
|
|
8375
8651
|
const explicitHiddenText = documentHiddenTextFromElement(node);
|
|
8652
|
+
const hasExplicitProofingLanguages = 'span' === tag && node.hasAttribute(DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE);
|
|
8653
|
+
const explicitProofingLanguages = hasExplicitProofingLanguages ? documentProofingLanguagesFromElement(node) : null;
|
|
8654
|
+
if (hasExplicitProofingLanguages && !explicitProofingLanguages) throw new Error('Document contains invalid proofing languages.');
|
|
8655
|
+
const hasExplicitNoProof = 'span' === tag && node.hasAttribute(DOCUMENT_NO_PROOF_ATTRIBUTE);
|
|
8656
|
+
const explicitNoProof = hasExplicitNoProof ? documentNoProofFromElement(node) : null;
|
|
8657
|
+
if (hasExplicitNoProof && null === explicitNoProof) throw new Error('Document contains invalid proofing state.');
|
|
8376
8658
|
const hasExplicitLegacyTextEffects = 'span' === tag && [
|
|
8377
8659
|
DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE,
|
|
8378
8660
|
DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE,
|
|
@@ -8410,6 +8692,8 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
8410
8692
|
const strike = docxStrikeRunOptions(node, inherited);
|
|
8411
8693
|
const scriptFontMarker = noteContext.runFontPatches.marker(documentScriptFontsFromElement(node), documentScriptFontSlotFromElement(node), node.style.fontFamily);
|
|
8412
8694
|
const runBorder = explicitRunBorder ? documentRunBorderDocxOptions(explicitRunBorder, noteContext.runBorderPatches).border : inherited.border;
|
|
8695
|
+
const language = hasExplicitProofingLanguages ? documentProofingLanguageDocxOptions(explicitProofingLanguages) : inherited.language;
|
|
8696
|
+
const noProof = hasExplicitNoProof ? explicitNoProof ?? false : inherited.noProof;
|
|
8413
8697
|
const style = {
|
|
8414
8698
|
...inherited,
|
|
8415
8699
|
style: nativeTextEffectStyle,
|
|
@@ -8429,10 +8713,13 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
8429
8713
|
kern,
|
|
8430
8714
|
position,
|
|
8431
8715
|
emphasisMark,
|
|
8716
|
+
language,
|
|
8717
|
+
noProof,
|
|
8432
8718
|
border: runBorder,
|
|
8433
8719
|
shading: themeFillMarker ? {
|
|
8434
8720
|
fill: themeFillMarker
|
|
8435
8721
|
} : resolvedShading,
|
|
8722
|
+
highlight: hasHighlightSemantics ? explicitHighlight ?? (customHighlightFill ? 'none' : void 0) : inherited.highlight,
|
|
8436
8723
|
snapToGrid: dataBoolean(node.dataset.officeWordSnapToGrid) ?? inherited.snapToGrid,
|
|
8437
8724
|
rightToLeft: void 0 === direction ? inherited.rightToLeft : 'rtl' === direction,
|
|
8438
8725
|
...textCaseOptions
|
|
@@ -8440,6 +8727,7 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
8440
8727
|
if ('br' === tag) {
|
|
8441
8728
|
markDocxNativeTextEffectStyleUsed(style.style, noteContext);
|
|
8442
8729
|
markDocxRunBorderUsed(style.border, noteContext);
|
|
8730
|
+
markDocxRunShadingUsed(style.shading, noteContext);
|
|
8443
8731
|
return [
|
|
8444
8732
|
new docx.TextRun({
|
|
8445
8733
|
...style,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { documentRunBorderDomAttributes, contentTypeForPart,
|
|
3
|
-
import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, documentCharacterPositionDomAttributes, createDocumentImageIdentityRegistry, normalizeDocumentColumns, documentStrikeDomAttributes, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, documentCharacterSpacingDomAttributes, normalizeDocumentImageAlignment,
|
|
4
|
-
import { markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, hasImportedDocxParagraphSpacingMarkers, docxTablePropertySources, parseDocxPageMargins, parseDirectDocxParagraphShading, markDocxPackageEquations, parseDocxPageGeometry, markDocxParagraphIndents, resolveDocxRunBorder, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, importedDocxStrike, docxTableRunPropertySources, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphTabStopMarkers, docxCaptionSequenceKind, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, resolveDocxHiddenText, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver,
|
|
5
|
-
import { readDocxBibliography, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~
|
|
2
|
+
import { documentRunBorderDomAttributes, contentTypeForPart, bytesToDataUrl, OoxmlPackage, firstDescendant, normalizeDocumentParagraphId, applyDocumentParagraphIdentityToElement, descendants, documentHighlightDomAttributes, attribute as work_ooxml_package_attribute, documentHighlightFromDocxValue, serializeDocxThemeReference, normalizeDocumentTableOfContentsHtml, directChildren, documentParagraphShadingDomAttributes, documentProofingDomAttributes, documentParagraphBordersDomAttributes, directChild, documentScriptFontSegments, normalizeDocumentParagraphIdentity, documentRunShadingDomAttributes } from "./4121.js";
|
|
3
|
+
import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, documentCharacterPositionDomAttributes, createDocumentImageIdentityRegistry, normalizeDocumentColumns, documentStrikeDomAttributes, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, documentCharacterSpacingDomAttributes, normalizeDocumentImageAlignment, applyDocumentImageLayerToElement, normalizeDocumentNotesHtml, normalizeDocumentBookmarkReferencesHtml, documentCitationTagsFromInstruction, applyDocumentImageWrapContourToElement, documentUnderlineDomAttributes, documentHiddenTextDomAttributes, normalizeDocumentPageChrome, normalizeDocumentImageLayoutOptions, applyDocumentImageCropToElement, documentPageMarginsForLayout, applyDocumentPageGeometry, createDocumentNoteElement, normalizeDocumentImageLayer, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, documentBookmarkReferenceInstruction, documentInitialSectionLayout, normalizeDocumentFieldsHtml, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, documentKerningDomAttributes, docxDocumentFieldKind, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentCharacterScaleDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, documentPageMarginBody, documentLegacyTextEffectsDomAttributes, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes } from "./6282.js";
|
|
4
|
+
import { markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, markDocxTablesOfContents, hasImportedDocxParagraphSpacingMarkers, docxTablePropertySources, applyImportedDocxTableOfContentsMarkers, parseDocxPageMargins, parseDirectDocxParagraphShading, markDocxPackageEquations, parseDocxPageGeometry, markDocxParagraphIndents, resolveDocxRunBorder, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, importedDocxStrike, docxTableRunPropertySources, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxTableOfContentsMarkers, hasImportedDocxParagraphTabStopMarkers, resolveDocxRunShading, docxCaptionSequenceKind, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, resolveDocxHiddenText, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphAlignmentMarkers, markDocxParagraphPagination, importedDocxUnderline, markDocxParagraphBorders, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxParagraphPaginationMarkers, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, docxRunPropertySources, markDocxParagraphFormattingChanges, markDocxParagraphShading, parseDocxPageBorders } from "./0~7360.js";
|
|
5
|
+
import { readDocxBibliography, resolveDocxProofing, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~7231.js";
|
|
6
6
|
import { importDocxPageColor, importedDocumentNoteId } from "./0~4980.js";
|
|
7
7
|
const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
8
8
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
@@ -1824,8 +1824,14 @@ async function runHtml(run, field, context) {
|
|
|
1824
1824
|
if (void 0 !== emphasisMark) content = `<span${htmlAttributes(documentEmphasisMarkDomAttributes(emphasisMark))}>${content}</span>`;
|
|
1825
1825
|
const hiddenText = resolveDocxHiddenText(propertySources);
|
|
1826
1826
|
if (void 0 !== hiddenText) content = `<span${htmlAttributes(documentHiddenTextDomAttributes(hiddenText))}>${content}</span>`;
|
|
1827
|
+
const proofing = resolveDocxProofing(propertySources);
|
|
1828
|
+
if (proofing.languages || void 0 !== proofing.noProof) content = `<span${htmlAttributes(documentProofingDomAttributes(proofing.languages, proofing.noProof, documentScriptFontSegments(run.textContent ?? '')[0]?.slot))}>${content}</span>`;
|
|
1827
1829
|
const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
|
|
1828
1830
|
if (legacyTextEffects) content = `<span${htmlAttributes(documentLegacyTextEffectsDomAttributes(legacyTextEffects))}>${content}</span>`;
|
|
1831
|
+
const highlight = resolvePageChromeHighlight(propertySources);
|
|
1832
|
+
if (highlight) content = `<span${htmlAttributes(documentHighlightDomAttributes(highlight))}>${content}</span>`;
|
|
1833
|
+
const runShading = resolveDocxRunShading(propertySources, context.theme).shading;
|
|
1834
|
+
if (runShading) content = `<span${htmlAttributes(documentRunShadingDomAttributes(runShading))}>${content}</span>`;
|
|
1829
1835
|
const runBorder = resolveDocxRunBorder(propertySources, context.theme).border;
|
|
1830
1836
|
if (runBorder) content = `<span${htmlAttributes(documentRunBorderDomAttributes(runBorder))}>${content}</span>`;
|
|
1831
1837
|
const characterSpacing = docxCharacterSpacingTwipsFromProperties(properties ?? run);
|
|
@@ -1905,6 +1911,14 @@ function resolveDocxPageChromeFontSizePoints(propertySources) {
|
|
|
1905
1911
|
}
|
|
1906
1912
|
return fontSize;
|
|
1907
1913
|
}
|
|
1914
|
+
function resolvePageChromeHighlight(propertySources) {
|
|
1915
|
+
let highlight = null;
|
|
1916
|
+
for (const properties of propertySources){
|
|
1917
|
+
const element = directChild(properties, 'highlight');
|
|
1918
|
+
if (element) highlight = documentHighlightFromDocxValue(work_ooxml_package_attribute(element, 'val'));
|
|
1919
|
+
}
|
|
1920
|
+
return highlight;
|
|
1921
|
+
}
|
|
1908
1922
|
function docxPageChromeFontSizePointsFromProperties(properties) {
|
|
1909
1923
|
const localMatches = directChildren(properties, 'sz');
|
|
1910
1924
|
const nativeMatches = localMatches.filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
@@ -2882,6 +2896,9 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
2882
2896
|
fieldMarkers: {
|
|
2883
2897
|
fields: []
|
|
2884
2898
|
},
|
|
2899
|
+
tableOfContentsMarkers: {
|
|
2900
|
+
tables: []
|
|
2901
|
+
},
|
|
2885
2902
|
equationMarkers: {
|
|
2886
2903
|
equations: []
|
|
2887
2904
|
},
|
|
@@ -2947,6 +2964,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
2947
2964
|
};
|
|
2948
2965
|
const document = await archive.xml('word/document.xml');
|
|
2949
2966
|
const pageColor = importDocxPageColor(document);
|
|
2967
|
+
const tableOfContentsMarkers = markDocxTablesOfContents(document);
|
|
2950
2968
|
const paragraphIdentityMarkers = markDocxParagraphIdentities(document);
|
|
2951
2969
|
const numbering = archive.has('word/numbering.xml') ? await archive.xml('word/numbering.xml') : null;
|
|
2952
2970
|
const commentMarkers = await markDocxComments(document, archive);
|
|
@@ -2991,7 +3009,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
2991
3009
|
const trackChanges = Boolean(settings && firstDescendant(settings, 'trackRevisions')) || changeMarkers.changes.length > 0 || paragraphFormattingChangeMarkers.paragraphs.length > 0 || runFormattingMarkers.runs.some((run)=>Boolean(run.change));
|
|
2992
3010
|
const sectionElements = effectiveSectionProperties(document);
|
|
2993
3011
|
if (!sectionElements.length) return {
|
|
2994
|
-
conversionBuffer: hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
|
|
3012
|
+
conversionBuffer: hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
|
|
2995
3013
|
sections: [
|
|
2996
3014
|
{
|
|
2997
3015
|
id: 'document-section-1',
|
|
@@ -3004,6 +3022,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
3004
3022
|
changeMarkers,
|
|
3005
3023
|
commentMarkers,
|
|
3006
3024
|
fieldMarkers,
|
|
3025
|
+
tableOfContentsMarkers,
|
|
3007
3026
|
equationMarkers: equationMarkers.markers,
|
|
3008
3027
|
citationMarkers,
|
|
3009
3028
|
listMarkers,
|
|
@@ -3039,7 +3058,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
3039
3058
|
}
|
|
3040
3059
|
if (sections.length > 1) addSectionMarkers(document, sectionElements);
|
|
3041
3060
|
return {
|
|
3042
|
-
conversionBuffer: sections.length > 1 || hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
|
|
3061
|
+
conversionBuffer: sections.length > 1 || hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
|
|
3043
3062
|
sections,
|
|
3044
3063
|
pageColor,
|
|
3045
3064
|
captionMarkers,
|
|
@@ -3047,6 +3066,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
3047
3066
|
changeMarkers,
|
|
3048
3067
|
commentMarkers,
|
|
3049
3068
|
fieldMarkers,
|
|
3069
|
+
tableOfContentsMarkers,
|
|
3050
3070
|
equationMarkers: equationMarkers.markers,
|
|
3051
3071
|
citationMarkers,
|
|
3052
3072
|
listMarkers,
|
|
@@ -3082,6 +3102,8 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
|
|
|
3082
3102
|
ranges: []
|
|
3083
3103
|
}, fieldMarkers = {
|
|
3084
3104
|
fields: []
|
|
3105
|
+
}, tableOfContentsMarkers = {
|
|
3106
|
+
tables: []
|
|
3085
3107
|
}, equationMarkers = {
|
|
3086
3108
|
equations: []
|
|
3087
3109
|
}, citationMarkers = {
|
|
@@ -3149,6 +3171,7 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
|
|
|
3149
3171
|
applyImportedDocxChangeMarkers(document, changeMarkers);
|
|
3150
3172
|
applyImportedDocxCommentMarkers(document, commentMarkers);
|
|
3151
3173
|
applyImportedDocxParagraphIdentityMarkers(document, paragraphIdentityMarkers);
|
|
3174
|
+
applyImportedDocxTableOfContentsMarkers(document, tableOfContentsMarkers);
|
|
3152
3175
|
const notes = extractMammothDocumentNotes(document);
|
|
3153
3176
|
const sourceNodes = Array.from(document.body.childNodes);
|
|
3154
3177
|
document.body.replaceChildren();
|
|
@@ -3173,7 +3196,7 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
|
|
|
3173
3196
|
document.body.append(missing);
|
|
3174
3197
|
}
|
|
3175
3198
|
placeMammothDocumentNotes(document, notes);
|
|
3176
|
-
return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(document.body.innerHTML))), bibliography)));
|
|
3199
|
+
return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentTableOfContentsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(document.body.innerHTML)))), bibliography)));
|
|
3177
3200
|
}
|
|
3178
3201
|
async function readDocxLayout(buffer) {
|
|
3179
3202
|
const prepared = await prepareDocxImport(buffer);
|