@a3s-lab/office 0.9.2 → 0.10.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/COLLABORATION_ROADMAP.md +19 -5
- package/README.md +16 -6
- package/dist/{0~7754.js → 0~4705.js} +500 -3
- package/dist/0~document-editor.js +7 -1
- package/dist/0~work-docx-export.js +260 -13
- package/dist/0~work-docx-import.js +9 -391
- package/dist/0~work-office-diagnostics.js +6 -4
- package/dist/8928.js +325 -22
- package/dist/internal/features/work/work-document-format-change-tracking.d.ts +9 -0
- package/dist/internal/features/work/work-document-format-changes.d.ts +28 -0
- package/dist/internal/features/work/work-docx-format-change-export.d.ts +17 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +10 -0
- package/dist/internal/features/work/work-types.d.ts +1 -1
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +20 -0
- package/package.json +5 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
2
|
import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage, firstDescendant, descendants, directChild, attribute } from "./5184.js";
|
|
3
|
-
import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, normalizeDocumentTabStops, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, normalizeDocumentImageAlignment, normalizeDocumentParagraphId, applyDocumentImageLayerToElement, normalizeDocumentNotesHtml, normalizeDocumentBookmarkReferencesHtml, documentCitationTagsFromInstruction, applyDocumentImageWrapContourToElement, renderDocumentAutoLineHeight, applyDocumentPageGeometry, normalizeDocumentPageChrome, normalizeDocumentImageLayoutOptions, applyDocumentImageCropToElement, documentPageMarginsForLayout, createDocumentNoteElement, serializeDocumentTabStops, normalizeDocumentImageLayer, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, documentBookmarkReferenceInstruction, documentInitialSectionLayout, normalizeDocumentFieldsHtml, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, applyDocumentParagraphIdentityToElement, documentAutoLineHeight, docxDocumentFieldKind, serializeDocxThemeReference, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentParagraphShadingDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentParagraphBordersDomAttributes, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, normalizeDocumentParagraphIdentity, documentPageMarginBody, normalizeDocumentParagraphIndent, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties
|
|
4
|
-
import {
|
|
5
|
-
import { xmlAttributeLocalName,
|
|
3
|
+
import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, normalizeDocumentTabStops, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, normalizeDocumentImageAlignment, normalizeDocumentParagraphId, applyDocumentImageLayerToElement, normalizeDocumentNotesHtml, normalizeDocumentBookmarkReferencesHtml, documentCitationTagsFromInstruction, applyDocumentImageWrapContourToElement, renderDocumentAutoLineHeight, applyDocumentPageGeometry, normalizeDocumentPageChrome, normalizeDocumentImageLayoutOptions, applyDocumentImageCropToElement, documentPageMarginsForLayout, createDocumentNoteElement, serializeDocumentTabStops, normalizeDocumentImageLayer, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, documentBookmarkReferenceInstruction, documentInitialSectionLayout, normalizeDocumentFieldsHtml, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, applyDocumentParagraphIdentityToElement, documentAutoLineHeight, docxDocumentFieldKind, serializeDocxThemeReference, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentParagraphShadingDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentParagraphBordersDomAttributes, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, normalizeDocumentParagraphIdentity, documentPageMarginBody, normalizeDocumentParagraphIndent, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties } from "./8928.js";
|
|
4
|
+
import { parseDocxPageGeometry, parseDocxPageBorders, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, docxParagraphPropertySources, docxCaptionSequenceKind, resolveDocxParagraphBordersForParagraph, applyImportedDocxRunFormattingMarkers, applyImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphBorderMarkers, docxCaptionBookmark, docxFieldResultText, resolveDocxParagraphStyleResolver, createDocxParagraphStyleResolver, docxEquationHtml, docxFieldOccurrences, docxTableParagraphPropertySources, resolveDocxTableStyleResolver, docxTableCellStyleLayers, markDocxParagraphBorders, markDocxRunFormatting, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, parseDocxPaperSource, docxTablePropertySources, parseDirectDocxParagraphShading, parseDocxPageMargins, markDocxParagraphShading, markDocxPackageEquations } from "./0~4705.js";
|
|
5
|
+
import { xmlAttributeLocalName, readDocxBibliography, createDocxThemeResolver, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~2805.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';
|
|
@@ -2593,388 +2593,6 @@ function work_docx_paragraph_spacing_import_textNodes(root) {
|
|
|
2593
2593
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
2594
2594
|
return nodes;
|
|
2595
2595
|
}
|
|
2596
|
-
const work_docx_run_formatting_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
2597
|
-
const work_docx_run_formatting_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
2598
|
-
const RUN_FORMATTING_MARKER_PATTERN = /__A3S_WORK_RUN_(?:START|END)_\d+__/g;
|
|
2599
|
-
function markDocxRunFormatting(document, styleSource, themeSource, tableStyleSource) {
|
|
2600
|
-
const runs = [];
|
|
2601
|
-
const styles = resolveDocxParagraphStyleResolver(styleSource);
|
|
2602
|
-
const theme = resolveDocxThemeResolver(themeSource);
|
|
2603
|
-
const tableStyles = resolveDocxTableStyleResolver(tableStyleSource);
|
|
2604
|
-
for (const run of descendants(document, 'r')){
|
|
2605
|
-
const runText = directRunText(run);
|
|
2606
|
-
if (!runText || runText.includes('__A3S_')) continue;
|
|
2607
|
-
const paragraph = work_docx_run_formatting_import_closestAncestor(run, 'p');
|
|
2608
|
-
if (!paragraph) continue;
|
|
2609
|
-
const paragraphProperties = directChild(paragraph, 'pPr');
|
|
2610
|
-
const runProperties = directChild(run, 'rPr');
|
|
2611
|
-
const formatting = resolvedRunFormatting(docxRunPropertySources(paragraphProperties, runProperties, styles, docxTableRunPropertySources(run, tableStyles)), theme, runText);
|
|
2612
|
-
if (!Object.keys(formatting).length) continue;
|
|
2613
|
-
const index = runs.length + 1;
|
|
2614
|
-
const startMarker = `__A3S_WORK_RUN_START_${index}__`;
|
|
2615
|
-
const endMarker = `__A3S_WORK_RUN_END_${index}__`;
|
|
2616
|
-
insertRunMarkers(document, run, runProperties, startMarker, endMarker);
|
|
2617
|
-
runs.push({
|
|
2618
|
-
startMarker,
|
|
2619
|
-
endMarker,
|
|
2620
|
-
formatting
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
|
-
return {
|
|
2624
|
-
runs
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
function applyImportedDocxRunFormattingMarkers(document, markers) {
|
|
2628
|
-
const replacements = new Map();
|
|
2629
|
-
for (const marker of markers.runs){
|
|
2630
|
-
const markup = formattingMarkup(document, marker.formatting);
|
|
2631
|
-
replacements.set(marker.startMarker, markup.start);
|
|
2632
|
-
replacements.set(marker.endMarker, markup.end);
|
|
2633
|
-
}
|
|
2634
|
-
document.body.innerHTML = document.body.innerHTML.replace(RUN_FORMATTING_MARKER_PATTERN, (marker)=>replacements.get(marker) ?? '');
|
|
2635
|
-
}
|
|
2636
|
-
function hasImportedDocxRunFormattingMarkers(markers) {
|
|
2637
|
-
return markers.runs.length > 0;
|
|
2638
|
-
}
|
|
2639
|
-
function resolvedRunFormatting(propertySources, theme, runText) {
|
|
2640
|
-
const fonts = {};
|
|
2641
|
-
let fontSize;
|
|
2642
|
-
let complexFontSize;
|
|
2643
|
-
let color;
|
|
2644
|
-
let backgroundColor;
|
|
2645
|
-
let themeColor;
|
|
2646
|
-
let themeFill;
|
|
2647
|
-
let bold;
|
|
2648
|
-
let complexBold;
|
|
2649
|
-
let italic;
|
|
2650
|
-
let complexItalic;
|
|
2651
|
-
let underline;
|
|
2652
|
-
let strike;
|
|
2653
|
-
let snapToGrid;
|
|
2654
|
-
let complexScriptFormatting;
|
|
2655
|
-
let rightToLeft;
|
|
2656
|
-
let fontHint;
|
|
2657
|
-
for (const properties of propertySources){
|
|
2658
|
-
bold = overriddenBoolean(bold, onOffProperty(properties, 'b'));
|
|
2659
|
-
complexBold = overriddenBoolean(complexBold, onOffProperty(properties, 'bCs'));
|
|
2660
|
-
italic = overriddenBoolean(italic, onOffProperty(properties, 'i'));
|
|
2661
|
-
complexItalic = overriddenBoolean(complexItalic, onOffProperty(properties, 'iCs'));
|
|
2662
|
-
underline = overriddenBoolean(underline, underlineProperty(properties));
|
|
2663
|
-
strike = overriddenBoolean(strike, onOffProperty(properties, 'strike'));
|
|
2664
|
-
strike = overriddenBoolean(strike, onOffProperty(properties, 'dstrike'));
|
|
2665
|
-
snapToGrid = overriddenBoolean(snapToGrid, onOffProperty(properties, 'snapToGrid'));
|
|
2666
|
-
complexScriptFormatting = overriddenBoolean(complexScriptFormatting, onOffProperty(properties, 'cs'));
|
|
2667
|
-
rightToLeft = overriddenBoolean(rightToLeft, onOffProperty(properties, 'rtl'));
|
|
2668
|
-
const runFonts = directChild(properties, 'rFonts');
|
|
2669
|
-
if (runFonts) {
|
|
2670
|
-
fontHint = resolvedFontHint(runFonts) ?? fontHint;
|
|
2671
|
-
assignFont(fonts, 'ascii', resolvedFont(runFonts, 'ascii', 'asciiTheme', theme));
|
|
2672
|
-
assignFont(fonts, 'hAnsi', resolvedFont(runFonts, 'hAnsi', 'hAnsiTheme', theme));
|
|
2673
|
-
assignFont(fonts, 'eastAsia', resolvedFont(runFonts, 'eastAsia', 'eastAsiaTheme', theme));
|
|
2674
|
-
assignFont(fonts, 'complex', resolvedFont(runFonts, 'cs', 'cstheme', theme));
|
|
2675
|
-
}
|
|
2676
|
-
const size = work_docx_run_formatting_import_numericAttribute(directChild(properties, 'sz'), 'val');
|
|
2677
|
-
if (void 0 !== size && size > 0) fontSize = Math.min(512, size / 2);
|
|
2678
|
-
const complexSize = work_docx_run_formatting_import_numericAttribute(directChild(properties, 'szCs'), 'val');
|
|
2679
|
-
if (void 0 !== complexSize && complexSize > 0) complexFontSize = Math.min(512, complexSize / 2);
|
|
2680
|
-
const colorElement = directChild(properties, 'color');
|
|
2681
|
-
if (colorElement) {
|
|
2682
|
-
const value = work_docx_run_formatting_import_wordAttribute(colorElement, 'val')?.trim();
|
|
2683
|
-
const themed = docxThemeColor(theme, work_docx_run_formatting_import_wordAttribute(colorElement, 'themeColor'), work_docx_run_formatting_import_wordAttribute(colorElement, 'themeTint'), work_docx_run_formatting_import_wordAttribute(colorElement, 'themeShade'));
|
|
2684
|
-
if (themed) {
|
|
2685
|
-
color = `#${themed}`;
|
|
2686
|
-
themeColor = themeReference(colorElement, 'themeColor', 'themeTint', 'themeShade', color);
|
|
2687
|
-
} else if (value?.toLowerCase() === 'auto') {
|
|
2688
|
-
color = 'inherit';
|
|
2689
|
-
themeColor = void 0;
|
|
2690
|
-
} else if (value && /^[0-9a-f]{6}$/i.test(value)) {
|
|
2691
|
-
color = `#${value.toLowerCase()}`;
|
|
2692
|
-
themeColor = void 0;
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
const highlight = directChild(properties, 'highlight');
|
|
2696
|
-
if (highlight) {
|
|
2697
|
-
const value = work_docx_run_formatting_import_wordAttribute(highlight, 'val')?.trim().toLowerCase();
|
|
2698
|
-
if (value) {
|
|
2699
|
-
backgroundColor = wordHighlightColor(value);
|
|
2700
|
-
themeFill = void 0;
|
|
2701
|
-
}
|
|
2702
|
-
} else {
|
|
2703
|
-
const shading = directChild(properties, 'shd');
|
|
2704
|
-
const fill = shading ? work_docx_run_formatting_import_wordAttribute(shading, 'fill')?.trim() : void 0;
|
|
2705
|
-
const themed = shading ? docxThemeColor(theme, work_docx_run_formatting_import_wordAttribute(shading, 'themeFill'), work_docx_run_formatting_import_wordAttribute(shading, 'themeFillTint'), work_docx_run_formatting_import_wordAttribute(shading, 'themeFillShade')) : void 0;
|
|
2706
|
-
if (themed) {
|
|
2707
|
-
backgroundColor = `#${themed}`;
|
|
2708
|
-
themeFill = themeReference(shading, 'themeFill', 'themeFillTint', 'themeFillShade', backgroundColor);
|
|
2709
|
-
} else if (fill?.toLowerCase() === 'auto') {
|
|
2710
|
-
backgroundColor = 'transparent';
|
|
2711
|
-
themeFill = void 0;
|
|
2712
|
-
} else if (fill && /^[0-9a-f]{6}$/i.test(fill)) {
|
|
2713
|
-
backgroundColor = `#${fill.toLowerCase()}`;
|
|
2714
|
-
themeFill = void 0;
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
const fontSlot = true === complexScriptFormatting || true === rightToLeft ? 'complex' : docxFontSlotForText(runText, fontHint);
|
|
2719
|
-
const usesComplexFormatting = 'complex' === fontSlot;
|
|
2720
|
-
const resolvedBold = usesComplexFormatting ? complexBold ?? bold : bold;
|
|
2721
|
-
const resolvedItalic = usesComplexFormatting ? complexItalic ?? italic : italic;
|
|
2722
|
-
const resolvedFontSize = usesComplexFormatting ? complexFontSize ?? fontSize : fontSize;
|
|
2723
|
-
let fontFamily = uniqueFonts(orderedFonts(fonts, fontSlot));
|
|
2724
|
-
if (!fontFamily) fontFamily = uniqueFonts(orderedFonts({
|
|
2725
|
-
ascii: docxThemeFont(theme, 'minorAscii'),
|
|
2726
|
-
hAnsi: docxThemeFont(theme, 'minorHAnsi'),
|
|
2727
|
-
eastAsia: docxThemeFont(theme, 'minorEastAsia'),
|
|
2728
|
-
complex: docxThemeFont(theme, 'minorBidi')
|
|
2729
|
-
}, fontSlot));
|
|
2730
|
-
const hasRunPropertySource = propertySources.length > 0;
|
|
2731
|
-
return {
|
|
2732
|
-
...void 0 !== resolvedBold || hasRunPropertySource ? {
|
|
2733
|
-
bold: resolvedBold ?? false
|
|
2734
|
-
} : {},
|
|
2735
|
-
...void 0 !== resolvedItalic || hasRunPropertySource ? {
|
|
2736
|
-
italic: resolvedItalic ?? false
|
|
2737
|
-
} : {},
|
|
2738
|
-
...void 0 !== underline || hasRunPropertySource ? {
|
|
2739
|
-
underline: underline ?? false
|
|
2740
|
-
} : {},
|
|
2741
|
-
...void 0 !== strike || hasRunPropertySource ? {
|
|
2742
|
-
strike: strike ?? false
|
|
2743
|
-
} : {},
|
|
2744
|
-
...fontFamily ? {
|
|
2745
|
-
fontFamily,
|
|
2746
|
-
wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
|
|
2747
|
-
} : {},
|
|
2748
|
-
...void 0 !== resolvedFontSize ? {
|
|
2749
|
-
fontSize: resolvedFontSize
|
|
2750
|
-
} : {},
|
|
2751
|
-
...void 0 !== snapToGrid ? {
|
|
2752
|
-
wordSnapToGrid: snapToGrid
|
|
2753
|
-
} : {},
|
|
2754
|
-
...color ? {
|
|
2755
|
-
color
|
|
2756
|
-
} : {},
|
|
2757
|
-
...backgroundColor ? {
|
|
2758
|
-
backgroundColor
|
|
2759
|
-
} : {},
|
|
2760
|
-
...themeColor ? {
|
|
2761
|
-
themeColor
|
|
2762
|
-
} : {},
|
|
2763
|
-
...themeFill ? {
|
|
2764
|
-
themeFill
|
|
2765
|
-
} : {}
|
|
2766
|
-
};
|
|
2767
|
-
}
|
|
2768
|
-
function insertRunMarkers(document, run, properties, startMarker, endMarker) {
|
|
2769
|
-
const start = work_docx_run_formatting_import_markerText(document, startMarker);
|
|
2770
|
-
const end = work_docx_run_formatting_import_markerText(document, endMarker);
|
|
2771
|
-
run.insertBefore(start, properties?.nextSibling ?? run.firstChild);
|
|
2772
|
-
run.append(end);
|
|
2773
|
-
}
|
|
2774
|
-
function work_docx_run_formatting_import_markerText(document, marker) {
|
|
2775
|
-
const text = document.createElementNS(work_docx_run_formatting_import_WORD_NAMESPACE, 'w:t');
|
|
2776
|
-
text.setAttributeNS(work_docx_run_formatting_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
2777
|
-
text.textContent = marker;
|
|
2778
|
-
return text;
|
|
2779
|
-
}
|
|
2780
|
-
function formattingMarkup(document, formatting) {
|
|
2781
|
-
const span = document.createElement('span');
|
|
2782
|
-
if (false === formatting.bold) span.style.fontWeight = 'normal';
|
|
2783
|
-
if (false === formatting.italic) span.style.fontStyle = 'normal';
|
|
2784
|
-
if ((false === formatting.underline || false === formatting.strike) && !formatting.underline && !formatting.strike) span.style.textDecorationLine = 'none';
|
|
2785
|
-
if (formatting.fontFamily) span.style.fontFamily = formatting.fontFamily;
|
|
2786
|
-
if (void 0 !== formatting.wordLineHeightFactor) {
|
|
2787
|
-
const factor = formatLineHeightFactor(formatting.wordLineHeightFactor);
|
|
2788
|
-
span.dataset.officeWordLineHeightFactor = factor;
|
|
2789
|
-
span.style.setProperty('--work-document-word-line-height-factor', factor);
|
|
2790
|
-
}
|
|
2791
|
-
if (void 0 !== formatting.wordSnapToGrid) span.dataset.officeWordSnapToGrid = String(formatting.wordSnapToGrid);
|
|
2792
|
-
if (void 0 !== formatting.fontSize) span.style.fontSize = `${work_docx_run_formatting_import_formatNumber(formatting.fontSize)}pt`;
|
|
2793
|
-
if (formatting.color) span.style.color = formatting.color;
|
|
2794
|
-
const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
|
|
2795
|
-
if (themeColor) span.dataset.officeThemeColor = themeColor;
|
|
2796
|
-
if (formatting.backgroundColor) span.style.backgroundColor = formatting.backgroundColor;
|
|
2797
|
-
const themeFill = serializeDocxThemeReference(formatting.themeFill ?? null);
|
|
2798
|
-
if (themeFill) span.dataset.officeThemeFill = themeFill;
|
|
2799
|
-
const html = span.outerHTML;
|
|
2800
|
-
const tags = [
|
|
2801
|
-
...formatting.bold ? [
|
|
2802
|
-
'strong'
|
|
2803
|
-
] : [],
|
|
2804
|
-
...formatting.italic ? [
|
|
2805
|
-
'em'
|
|
2806
|
-
] : [],
|
|
2807
|
-
...formatting.underline ? [
|
|
2808
|
-
'u'
|
|
2809
|
-
] : [],
|
|
2810
|
-
...formatting.strike ? [
|
|
2811
|
-
's'
|
|
2812
|
-
] : []
|
|
2813
|
-
];
|
|
2814
|
-
return {
|
|
2815
|
-
start: `${html.slice(0, html.indexOf('>') + 1)}${tags.map((tag)=>`<${tag}>`).join('')}`,
|
|
2816
|
-
end: `${[
|
|
2817
|
-
...tags
|
|
2818
|
-
].reverse().map((tag)=>`</${tag}>`).join('')}</span>`
|
|
2819
|
-
};
|
|
2820
|
-
}
|
|
2821
|
-
function themeReference(element, themeName, tintName, shadeName, resolved) {
|
|
2822
|
-
const theme = work_docx_run_formatting_import_wordAttribute(element, themeName)?.trim();
|
|
2823
|
-
if (!theme) return;
|
|
2824
|
-
const tint = normalizedByteHex(work_docx_run_formatting_import_wordAttribute(element, tintName));
|
|
2825
|
-
const shade = normalizedByteHex(work_docx_run_formatting_import_wordAttribute(element, shadeName));
|
|
2826
|
-
return {
|
|
2827
|
-
theme,
|
|
2828
|
-
resolved,
|
|
2829
|
-
...tint ? {
|
|
2830
|
-
tint
|
|
2831
|
-
} : {},
|
|
2832
|
-
...shade ? {
|
|
2833
|
-
shade
|
|
2834
|
-
} : {}
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
function normalizedByteHex(value) {
|
|
2838
|
-
const normalized = value?.trim().toUpperCase();
|
|
2839
|
-
return normalized && /^[0-9A-F]{2}$/.test(normalized) ? normalized : void 0;
|
|
2840
|
-
}
|
|
2841
|
-
function overriddenBoolean(current, next) {
|
|
2842
|
-
return void 0 === next ? current : next;
|
|
2843
|
-
}
|
|
2844
|
-
function onOffProperty(properties, propertyName) {
|
|
2845
|
-
const element = directChild(properties, propertyName);
|
|
2846
|
-
if (!element) return;
|
|
2847
|
-
const value = work_docx_run_formatting_import_wordAttribute(element, 'val')?.trim().toLowerCase();
|
|
2848
|
-
return '0' !== value && 'false' !== value && 'off' !== value;
|
|
2849
|
-
}
|
|
2850
|
-
function underlineProperty(properties) {
|
|
2851
|
-
const element = directChild(properties, 'u');
|
|
2852
|
-
if (!element) return;
|
|
2853
|
-
const value = work_docx_run_formatting_import_wordAttribute(element, 'val')?.trim().toLowerCase();
|
|
2854
|
-
return '0' !== value && 'false' !== value && 'off' !== value && 'none' !== value;
|
|
2855
|
-
}
|
|
2856
|
-
function directRunText(run) {
|
|
2857
|
-
return Array.from(run.children).filter((child)=>'t' === child.localName || 'delText' === child.localName).map((child)=>child.textContent ?? '').join('');
|
|
2858
|
-
}
|
|
2859
|
-
function work_docx_run_formatting_import_closestAncestor(element, localName) {
|
|
2860
|
-
let current = element.parentElement;
|
|
2861
|
-
while(current){
|
|
2862
|
-
if (current.localName === localName) return current;
|
|
2863
|
-
current = current.parentElement;
|
|
2864
|
-
}
|
|
2865
|
-
return null;
|
|
2866
|
-
}
|
|
2867
|
-
function assignFont(fonts, key, value) {
|
|
2868
|
-
const normalized = value?.trim();
|
|
2869
|
-
if (normalized) fonts[key] = normalized;
|
|
2870
|
-
}
|
|
2871
|
-
function resolvedFontHint(element) {
|
|
2872
|
-
const hint = work_docx_run_formatting_import_wordAttribute(element, 'hint')?.trim().toLowerCase();
|
|
2873
|
-
if ('eastasia' === hint) return 'eastAsia';
|
|
2874
|
-
if ('cs' === hint) return 'complex';
|
|
2875
|
-
if ('default' === hint) return 'ascii';
|
|
2876
|
-
}
|
|
2877
|
-
function orderedFonts(fonts, preferred) {
|
|
2878
|
-
const order = {
|
|
2879
|
-
ascii: [
|
|
2880
|
-
'ascii',
|
|
2881
|
-
'hAnsi',
|
|
2882
|
-
'eastAsia',
|
|
2883
|
-
'complex'
|
|
2884
|
-
],
|
|
2885
|
-
hAnsi: [
|
|
2886
|
-
'hAnsi',
|
|
2887
|
-
'ascii',
|
|
2888
|
-
'eastAsia',
|
|
2889
|
-
'complex'
|
|
2890
|
-
],
|
|
2891
|
-
eastAsia: [
|
|
2892
|
-
'eastAsia',
|
|
2893
|
-
'hAnsi',
|
|
2894
|
-
'ascii',
|
|
2895
|
-
'complex'
|
|
2896
|
-
],
|
|
2897
|
-
complex: [
|
|
2898
|
-
'complex',
|
|
2899
|
-
'hAnsi',
|
|
2900
|
-
'ascii',
|
|
2901
|
-
'eastAsia'
|
|
2902
|
-
]
|
|
2903
|
-
};
|
|
2904
|
-
return order[preferred].map((slot)=>fonts[slot]);
|
|
2905
|
-
}
|
|
2906
|
-
function docxFontSlotForText(text, hint) {
|
|
2907
|
-
for (const character of text){
|
|
2908
|
-
const codePoint = character.codePointAt(0);
|
|
2909
|
-
if (!(void 0 === codePoint || isNeutralCodePoint(codePoint))) {
|
|
2910
|
-
if (isComplexScriptCodePoint(codePoint)) return 'complex';
|
|
2911
|
-
if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
|
|
2912
|
-
return codePoint <= 0x7f ? 'ascii' : 'hAnsi';
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
return hint ?? 'ascii';
|
|
2916
|
-
}
|
|
2917
|
-
function isNeutralCodePoint(codePoint) {
|
|
2918
|
-
return codePoint <= 0x20 || codePoint <= 0x7f && !(codePoint >= 0x41 && codePoint <= 0x5a || codePoint >= 0x61 && codePoint <= 0x7a) || codePoint >= 0x300 && codePoint <= 0x36f || codePoint >= 0x2000 && codePoint <= 0x206f;
|
|
2919
|
-
}
|
|
2920
|
-
function isComplexScriptCodePoint(codePoint) {
|
|
2921
|
-
return codePoint >= 0x0590 && codePoint <= 0x08ff || codePoint >= 0xfb1d && codePoint <= 0xfdff || codePoint >= 0xfe70 && codePoint <= 0xfeff || codePoint >= 0x1ee00 && codePoint <= 0x1eeff;
|
|
2922
|
-
}
|
|
2923
|
-
function isEastAsianCodePoint(codePoint) {
|
|
2924
|
-
return codePoint >= 0x1100 && codePoint <= 0x11ff || codePoint >= 0x2e80 && codePoint <= 0xa4cf || codePoint >= 0xac00 && codePoint <= 0xd7af || codePoint >= 0xf900 && codePoint <= 0xfaff || codePoint >= 0xfe10 && codePoint <= 0xfe6f || codePoint >= 0xff00 && codePoint <= 0xffef || codePoint >= 0x20000 && codePoint <= 0x323af;
|
|
2925
|
-
}
|
|
2926
|
-
function resolvedFont(element, explicitName, themeName, theme) {
|
|
2927
|
-
const explicit = work_docx_run_formatting_import_wordAttribute(element, explicitName);
|
|
2928
|
-
if (explicit?.trim()) return explicit;
|
|
2929
|
-
return docxThemeFont(theme, work_docx_run_formatting_import_wordAttribute(element, themeName)) ?? null;
|
|
2930
|
-
}
|
|
2931
|
-
function uniqueFonts(values) {
|
|
2932
|
-
const fonts = [
|
|
2933
|
-
...new Set(values.filter((value)=>!!value))
|
|
2934
|
-
];
|
|
2935
|
-
return fonts.length ? fonts.map(cssFontFamily).join(', ') : void 0;
|
|
2936
|
-
}
|
|
2937
|
-
function cssFontFamily(value) {
|
|
2938
|
-
return /[\s"',]/.test(value) ? `"${value.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"` : value;
|
|
2939
|
-
}
|
|
2940
|
-
function work_docx_run_formatting_import_numericAttribute(element, name) {
|
|
2941
|
-
if (!element) return;
|
|
2942
|
-
const raw = work_docx_run_formatting_import_wordAttribute(element, name);
|
|
2943
|
-
if (null === raw || !raw.trim()) return;
|
|
2944
|
-
const value = Number(raw);
|
|
2945
|
-
return Number.isFinite(value) ? value : void 0;
|
|
2946
|
-
}
|
|
2947
|
-
function work_docx_run_formatting_import_wordAttribute(element, name) {
|
|
2948
|
-
return attribute(element, name) ?? attribute(element, `w:${name}`);
|
|
2949
|
-
}
|
|
2950
|
-
function wordHighlightColor(value) {
|
|
2951
|
-
const colors = {
|
|
2952
|
-
black: '#000000',
|
|
2953
|
-
blue: '#0000ff',
|
|
2954
|
-
cyan: '#00ffff',
|
|
2955
|
-
darkblue: '#000080',
|
|
2956
|
-
darkcyan: '#008080',
|
|
2957
|
-
darkgray: '#808080',
|
|
2958
|
-
darkgreen: '#008000',
|
|
2959
|
-
darkmagenta: '#800080',
|
|
2960
|
-
darkred: '#800000',
|
|
2961
|
-
darkyellow: '#808000',
|
|
2962
|
-
green: '#00ff00',
|
|
2963
|
-
lightgray: '#c0c0c0',
|
|
2964
|
-
magenta: '#ff00ff',
|
|
2965
|
-
none: 'transparent',
|
|
2966
|
-
red: '#ff0000',
|
|
2967
|
-
white: '#ffffff',
|
|
2968
|
-
yellow: '#ffff00'
|
|
2969
|
-
};
|
|
2970
|
-
return colors[value] ?? 'transparent';
|
|
2971
|
-
}
|
|
2972
|
-
function work_docx_run_formatting_import_formatNumber(value) {
|
|
2973
|
-
return Number(value.toFixed(2)).toString();
|
|
2974
|
-
}
|
|
2975
|
-
function formatLineHeightFactor(value) {
|
|
2976
|
-
return Number(value.toFixed(4)).toString();
|
|
2977
|
-
}
|
|
2978
2596
|
const work_docx_tab_stop_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
2979
2597
|
const work_docx_tab_stop_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
2980
2598
|
const work_docx_tab_stop_import_TWIPS_PER_CSS_PIXEL = 15;
|
|
@@ -3369,7 +2987,7 @@ function parseBorder(edge, theme) {
|
|
|
3369
2987
|
style,
|
|
3370
2988
|
width: Math.max(0.5, Math.min(6, Math.round(2 * width) / 2)),
|
|
3371
2989
|
...themed ? {
|
|
3372
|
-
theme:
|
|
2990
|
+
theme: themeReference(edge, 'themeColor', 'themeTint', 'themeShade', color)
|
|
3373
2991
|
} : {}
|
|
3374
2992
|
};
|
|
3375
2993
|
}
|
|
@@ -3389,7 +3007,7 @@ function tableCellBackgroundColor(shading, theme) {
|
|
|
3389
3007
|
const color = `#${themed}`;
|
|
3390
3008
|
return {
|
|
3391
3009
|
color,
|
|
3392
|
-
theme:
|
|
3010
|
+
theme: themeReference(shading, 'themeFill', 'themeFillTint', 'themeFillShade', color)
|
|
3393
3011
|
};
|
|
3394
3012
|
}
|
|
3395
3013
|
const color = ooxmlColor(attribute(shading, 'fill'));
|
|
@@ -3397,10 +3015,10 @@ function tableCellBackgroundColor(shading, theme) {
|
|
|
3397
3015
|
color
|
|
3398
3016
|
} : null;
|
|
3399
3017
|
}
|
|
3400
|
-
function
|
|
3018
|
+
function themeReference(element, themeName, tintName, shadeName, resolved) {
|
|
3401
3019
|
const theme = attribute(element, themeName)?.trim() ?? '';
|
|
3402
|
-
const tint =
|
|
3403
|
-
const shade =
|
|
3020
|
+
const tint = normalizedByteHex(attribute(element, tintName));
|
|
3021
|
+
const shade = normalizedByteHex(attribute(element, shadeName));
|
|
3404
3022
|
return {
|
|
3405
3023
|
theme,
|
|
3406
3024
|
resolved,
|
|
@@ -3412,7 +3030,7 @@ function work_docx_table_cell_import_themeReference(element, themeName, tintName
|
|
|
3412
3030
|
} : {}
|
|
3413
3031
|
};
|
|
3414
3032
|
}
|
|
3415
|
-
function
|
|
3033
|
+
function normalizedByteHex(value) {
|
|
3416
3034
|
const normalized = value?.trim().toUpperCase();
|
|
3417
3035
|
return normalized && /^[0-9A-F]{2}$/.test(normalized) ? normalized : void 0;
|
|
3418
3036
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { descendants, directChildren, directChild, OoxmlPackage, attribute, firstDescendant, contentTypeForPart } from "./5184.js";
|
|
2
2
|
import { normalizeDocumentBookmarkName, docxBookmarkReferenceTarget, normalizeDocumentBookmarkNativeId, isDocumentParagraphArtBorderStyle, supportedDocxBookmarkReferenceInstruction, documentCitationTagsFromInstruction, docxDocumentFieldKind } from "./8928.js";
|
|
3
|
-
import { markDocxParagraphShading, inspectDocxPageSize, docxCaptionBookmark, hasInvalidDocxFieldStructure, inspectDocxPageMargins, inspectDocxPaperSource, createDocxParagraphStyleResolver, createDocxTableStyleResolver, docxFieldOccurrences, inspectDocxEquation, inspectDocxPageMarginSettings, markDocxParagraphBorders, docxFieldOccurrenceIsInlineEditable, docxCaptionSequenceKind, inspectDocxPageBorders, docxFieldInstructions, isSupportedDocxEquationPlacement } from "./0~
|
|
3
|
+
import { markDocxParagraphShading, inspectDocxPageSize, docxCaptionBookmark, hasInvalidDocxFieldStructure, inspectDocxPageMargins, inspectDocxPaperSource, createDocxParagraphStyleResolver, createDocxTableStyleResolver, docxFieldOccurrences, inspectDocxEquation, inspectDocxPageMarginSettings, markDocxParagraphBorders, docxFieldOccurrenceIsInlineEditable, docxCaptionSequenceKind, inspectDocxPageBorders, isSupportedDocxRunFormattingChange, docxFieldInstructions, isSupportedDocxEquationPlacement } from "./0~4705.js";
|
|
4
4
|
import { normalizeDocumentHref } from "./0~work-document-links.js";
|
|
5
5
|
import { xmlAttributeLocalName, parseDocxParagraphDefaultCollapsed, readDocxBibliography, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, createDocxThemeResolver } from "./0~2805.js";
|
|
6
6
|
import { isSupportedXlsxCombinationChartNodes, MAX_XLSX_WORKSHEET_IMAGE_BYTES, inspectXlsxPivotTables, isSupportedXlsxWorksheetImageContentType, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, xlsxChartNodeUsesStackedGrouping, isSupportedXlsxChartSeriesFormatting, readXlsxFormulaFeaturesFromPackage, inspectXlsxHeaderFooterText, isEditableXlsxPaperSizeCode, diagnoseXlsxProtection, xlsxChartSeriesFormattingShapeProperties } from "./4104.js";
|
|
@@ -1690,18 +1690,20 @@ async function analyzeDocxCompatibility(file, messages) {
|
|
|
1690
1690
|
...descendants(document, 'ins'),
|
|
1691
1691
|
...descendants(document, 'del')
|
|
1692
1692
|
];
|
|
1693
|
+
const runFormattingRevisions = descendants(document, 'rPrChange');
|
|
1694
|
+
const supportedRunFormattingRevisionCount = runFormattingRevisions.filter(isSupportedDocxRunFormattingChange).length;
|
|
1693
1695
|
if (textRevisions.some((revision)=>descendants(revision, 't').length || descendants(revision, 'delText').length)) issues.push(work_office_diagnostics_issue('docx.revisions', 'Tracked changes', 'Body-text insertions and deletions preserve their author and date, remain reviewable in Work, and round-trip as native DOCX revisions.', 'info'));
|
|
1694
|
-
if (
|
|
1696
|
+
if (supportedRunFormattingRevisionCount) issues.push(work_office_diagnostics_issue('docx.revisions.formatting', 'Character-formatting revisions', `${supportedRunFormattingRevisionCount} bounded character-formatting revision(s) preserve author, date, current formatting, and prior bold, italic, underline, strike, subscript, superscript, font, size, color, highlight, and grid state. They remain reviewable in Work and round-trip as native w:rPrChange records.`, 'info'));
|
|
1697
|
+
if (textRevisions.some((revision)=>!descendants(revision, 't').length && !descendants(revision, 'delText').length) || supportedRunFormattingRevisionCount !== runFormattingRevisions.length || [
|
|
1695
1698
|
'moveFrom',
|
|
1696
1699
|
'moveTo',
|
|
1697
|
-
'rPrChange',
|
|
1698
1700
|
'pPrChange',
|
|
1699
1701
|
'tblPrChange',
|
|
1700
1702
|
'trPrChange',
|
|
1701
1703
|
'tcPrChange',
|
|
1702
1704
|
'sectPrChange',
|
|
1703
1705
|
'numberingChange'
|
|
1704
|
-
].some((name)=>descendants(document, name).length)) issues.push(work_office_diagnostics_issue('docx.revisions.structural', 'Structural revisions', 'Moved content plus formatting, numbering, section, row, cell, and table-property revisions may be normalized; Work currently reviews body-text insertions and
|
|
1706
|
+
].some((name)=>descendants(document, name).length)) issues.push(work_office_diagnostics_issue('docx.revisions.structural', 'Structural revisions', 'Moved content plus unsupported character formatting, paragraph formatting, numbering, section, row, cell, and table-property revisions may be normalized; Work currently reviews body-text insertions/deletions and the bounded character-formatting subset.'));
|
|
1705
1707
|
if (captionDiagnostics.hasUnsupportedFields) issues.push(work_office_diagnostics_issue('docx.fields', 'Fields', 'Fields beyond supported body fields, citations, bibliographies, caption SEQ fields, and bookmark or caption REF fields are converted to their current displayed value.'));
|
|
1706
1708
|
const sectionProperties = descendants(document, 'sectPr');
|
|
1707
1709
|
const columnProperties = descendants(document, 'cols');
|