@a3s-lab/office 0.25.0 → 0.27.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 +76 -2
- package/dist/0~4595.js +16 -2
- package/dist/0~5093.js +463 -201
- package/dist/0~6090.js +77 -77
- package/dist/{0~2805.js → 0~7043.js} +305 -2
- package/dist/0~document-editor.js +2451 -985
- package/dist/0~spreadsheet-editor.js +22113 -20117
- package/dist/0~work-docx-export.js +492 -10
- package/dist/0~work-docx-import.js +171 -98
- package/dist/0~work-office-diagnostics.js +198 -4
- package/dist/{164.js → 1544.js} +1412 -1055
- package/dist/4104.js +145 -29
- package/dist/6282.js +1920 -544
- package/dist/9424.js +16 -0
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +102 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +83 -0
- package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +18 -0
- package/dist/internal/features/work/editors/document-font-dialog.d.ts +9 -0
- package/dist/internal/features/work/editors/document-home-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +6 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-strike-ribbon.d.ts +7 -0
- package/dist/internal/features/work/editors/document-text-case-ribbon.d.ts +4 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
- package/dist/internal/features/work/editors/document-underline-ribbon.d.ts +9 -0
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +1 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-fill-format.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +2 -1
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +18 -9
- package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +13 -2
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-panel.d.ts +13 -0
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-preview.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +1 -1
- package/dist/internal/features/work/editors/spreadsheet-operation-projection.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-dom-selection.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-paste.d.ts +22 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-controller.d.ts +38 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-format.d.ts +26 -0
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +9 -1
- package/dist/internal/features/work/work-css-color.d.ts +1 -0
- package/dist/internal/features/work/work-document-character-formatting.d.ts +16 -1
- package/dist/internal/features/work/work-document-character-position.d.ts +9 -0
- package/dist/internal/features/work/work-document-character-scale.d.ts +8 -0
- package/dist/internal/features/work/work-document-character-spacing.d.ts +8 -0
- package/dist/internal/features/work/work-document-emphasis.d.ts +7 -0
- package/dist/internal/features/work/work-document-equations.d.ts +2 -1
- package/dist/internal/features/work/work-document-format-changes.d.ts +16 -2
- package/dist/internal/features/work/work-document-hidden-text.d.ts +5 -0
- package/dist/internal/features/work/work-document-kerning.d.ts +10 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +1 -1
- package/dist/internal/features/work/work-document-script-font-extension.d.ts +2 -0
- package/dist/internal/features/work/work-document-script-fonts.d.ts +51 -0
- package/dist/internal/features/work/work-document-strike.d.ts +21 -0
- package/dist/internal/features/work/work-document-text-case.d.ts +10 -0
- package/dist/internal/features/work/work-document-underline.d.ts +37 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +12 -0
- package/dist/internal/features/work/work-docx-character-position.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-scale.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-spacing.d.ts +4 -0
- package/dist/internal/features/work/work-docx-emphasis-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-emphasis.d.ts +14 -0
- package/dist/internal/features/work/work-docx-hidden-text-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-hidden-text-export.d.ts +16 -0
- package/dist/internal/features/work/work-docx-hidden-text.d.ts +11 -0
- package/dist/internal/features/work/work-docx-kerning-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-kerning.d.ts +14 -0
- package/dist/internal/features/work/work-docx-run-fonts-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-fonts-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-run-fonts.d.ts +13 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +23 -2
- package/dist/internal/features/work/work-docx-run-script-font-import.d.ts +9 -0
- package/dist/internal/features/work/work-docx-strike.d.ts +8 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +1 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +6 -0
- package/dist/internal/features/work/work-docx-underline.d.ts +3 -0
- package/dist/internal/features/work/work-spreadsheet-gradient-fill-canvas.d.ts +10 -0
- package/dist/internal/features/work/work-spreadsheet-native-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-spreadsheet-pattern-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +2 -1
- package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +4 -0
- package/dist/internal/features/work/work-xlsx-gradient-fill.d.ts +31 -0
- package/dist/internal/features/work/work-xlsx-native-fill.d.ts +17 -0
- package/dist/internal/features/work/work-xlsx-pattern-fill.d.ts +21 -0
- package/dist/internal/features/work/work-xlsx-rich-text-edit.d.ts +28 -0
- package/dist/internal/features/work/work-xlsx-rich-text-model.d.ts +40 -0
- package/dist/internal/features/work/work-xlsx-rich-text.d.ts +4 -18
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +770 -80
- package/docs/latest/en/browser-editor-architecture.md +37 -0
- package/package.json +32 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { normalizeDocumentBookmarkName, applyDocumentImageIdentityToElement, DOCUMENT_PAGE_BORDER_EDGES,
|
|
2
|
+
import { normalizeDocumentBookmarkName, normalizeDocumentEmphasisMark, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, applyDocumentImageIdentityToElement, documentEmphasisMarkFromElement, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, documentScriptFontSlotFromElement, normalizeDocumentColumns, createDocumentImageIdentityRegistry, serializeDocumentScriptFonts, documentCharacterSpacingTwipsFromElement, uniqueDocumentParagraphIdentity, documentCharacterPositionHalfPointsFromElement, normalizeDocumentTableVerticalAlign, documentTableColumnPercentagesFromElement, normalizeDocumentTextCase, documentTableCellMarginOverridesFromElement, applyDocumentTableRowIdentityToElement, normalizeDocumentBookmarksHtml, documentImageIdentityFromElement, documentTableGeometryFromElement, normalizeDocumentTableRowHeightRule, normalizeDocumentScriptFonts, documentNoteKey, normalizeDocumentHiddenText, normalizeDocumentParagraphBorders, normalizeDocumentTableBorderWidth, normalizeDocumentCharacterSpacingTwips, normalizeDocumentParagraphId, documentStrikeFormattingFromElement, normalizeDocumentTableBorderStyle, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, parseDocumentParagraphBordersElement, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, documentScriptFontsFromElement, normalizeDocumentUnderlineStyle, documentPageMarginsForLayout, normalizeDocumentPageChrome, normalizeDocumentImageLayer, documentFontNameFromCssFamily, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, parseDocumentScriptFonts, documentCaptionLabel, documentCaptionKind, applyDocumentParagraphIdentityToElement, isContourImageLayout, parseDocxThemeReference, normalizeDocumentImageIdentity, normalizeDocumentStrikeStyle, normalizeTableColor, createDocumentParagraphIdentityRegistry, documentCitationTags, docxDocumentFieldKind, documentTableBordersFromElement, documentSections, wrapsBesideImage, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentKerningThresholdHalfPoints, DocxThemePatchCollector, defaultDocumentImageWrapContour, normalizeDocumentParagraphIdentity, normalizeDocumentPaperSource, documentEquationFromElement, DOCUMENT_PARAGRAPH_BORDER_EDGES, parseDocumentCharacterFormatting, documentScriptFontFamily, documentUnderlineFormattingFromElement, documentParagraphIdentityFromElement, normalizeDocumentEquation, patchDocxThemeReferences, parseDocumentParagraphShadingElement, normalizeDocumentBookmarkNativeId, parseDocumentParagraphFormatting, DOCUMENT_PAGE_MARGIN_KEYS, uniqueDocumentImageIdentity, documentHiddenTextFromElement, documentTableRowIdentityFromElement, documentImageLayoutFromElement, documentScriptFontSlotFromHint, collectDocumentNotes, documentPageHorizontalMarginTwips, documentPageGeometryForLayout, normalizeDocumentScriptFontSlot, normalizeDocumentPageMargins, documentCharacterScalePercentFromElement, documentNoteKind } from "./6282.js";
|
|
3
3
|
import { serializeUtf8Xml, directChildren, xmlNamespacePrefix, parseXml, decodeXmlBytes, descendants, resolvePartTarget, directChild, attribute as work_ooxml_package_attribute } from "./5184.js";
|
|
4
4
|
import { assignDocxNoteIds, patchDocxPageColor, normalizeDocxCommentId, assignDocxCommentThreads } from "./0~4980.js";
|
|
5
|
-
import { paragraphTabStops, mergeDocxIgnorableExtensionsAtPairs, patchDocxBibliography, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, paragraphSpacingOptions, xmlNamespaceUri, hasNonWhitespaceXmlText, cloneXmlElement, cssColorToHex, DocxParagraphDefaultCollapsedPatchCollector, assertXmlRoot, xmlDeclaredPrefix, paragraphIndent, domDirection, DOCX_WORDPROCESSING_NAMESPACES, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, patchDocxParagraphDefaultCollapsed, xmlAttributeNamespace, dataBoolean, mergeDocxIgnorableExtensions, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily } 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, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~7043.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 {
|
|
@@ -757,6 +757,160 @@ function hasAncestor(element, localName) {
|
|
|
757
757
|
}
|
|
758
758
|
return false;
|
|
759
759
|
}
|
|
760
|
+
const HIDDEN_TEXT_PART_PATTERN = /^word\/(?:document|header\d*|footer\d*|footnotes|endnotes|comments)\.xml$/i;
|
|
761
|
+
const WORD_RUN_PROPERTY_ORDER = [
|
|
762
|
+
'rStyle',
|
|
763
|
+
'rFonts',
|
|
764
|
+
'b',
|
|
765
|
+
'bCs',
|
|
766
|
+
'i',
|
|
767
|
+
'iCs',
|
|
768
|
+
'caps',
|
|
769
|
+
'smallCaps',
|
|
770
|
+
'strike',
|
|
771
|
+
'dstrike',
|
|
772
|
+
'outline',
|
|
773
|
+
'shadow',
|
|
774
|
+
'emboss',
|
|
775
|
+
'imprint',
|
|
776
|
+
'noProof',
|
|
777
|
+
'snapToGrid',
|
|
778
|
+
'vanish',
|
|
779
|
+
'webHidden',
|
|
780
|
+
'color',
|
|
781
|
+
'spacing',
|
|
782
|
+
'w',
|
|
783
|
+
'kern',
|
|
784
|
+
'position',
|
|
785
|
+
'sz',
|
|
786
|
+
'szCs',
|
|
787
|
+
'highlight',
|
|
788
|
+
'u',
|
|
789
|
+
'effect',
|
|
790
|
+
'bdr',
|
|
791
|
+
'shd',
|
|
792
|
+
'fitText',
|
|
793
|
+
'vertAlign',
|
|
794
|
+
'rtl',
|
|
795
|
+
'cs',
|
|
796
|
+
'em',
|
|
797
|
+
'lang',
|
|
798
|
+
'eastAsianLayout',
|
|
799
|
+
'specVanish',
|
|
800
|
+
'rPrChange'
|
|
801
|
+
];
|
|
802
|
+
const WORD_RUN_PROPERTY_RANK = new Map(WORD_RUN_PROPERTY_ORDER.map((name, index)=>[
|
|
803
|
+
name,
|
|
804
|
+
index
|
|
805
|
+
]));
|
|
806
|
+
const VANISH_RANK = WORD_RUN_PROPERTY_RANK.get('vanish') ?? 0;
|
|
807
|
+
class DocxHiddenTextPatchCollector {
|
|
808
|
+
patches = [];
|
|
809
|
+
nextMarker = 1;
|
|
810
|
+
occupied;
|
|
811
|
+
patchesByMarker = new Map();
|
|
812
|
+
markersByValueAndStyle = new Map();
|
|
813
|
+
constructor(source){
|
|
814
|
+
this.occupied = source;
|
|
815
|
+
}
|
|
816
|
+
marker(value, inheritedStyle) {
|
|
817
|
+
const style = this.originalStyle(inheritedStyle);
|
|
818
|
+
const key = JSON.stringify([
|
|
819
|
+
value,
|
|
820
|
+
style ?? null
|
|
821
|
+
]);
|
|
822
|
+
const existing = this.markersByValueAndStyle.get(key);
|
|
823
|
+
if (existing) return existing;
|
|
824
|
+
let marker = '';
|
|
825
|
+
do {
|
|
826
|
+
marker = `A3SOfficeHiddenText${value ? 'On' : 'Off'}${String(this.nextMarker).padStart(8, '0')}`;
|
|
827
|
+
this.nextMarker += 1;
|
|
828
|
+
}while (this.occupied.includes(marker) || this.patches.some((patch)=>patch.marker === marker))
|
|
829
|
+
const patch = {
|
|
830
|
+
marker,
|
|
831
|
+
value,
|
|
832
|
+
...style ? {
|
|
833
|
+
style
|
|
834
|
+
} : {}
|
|
835
|
+
};
|
|
836
|
+
this.patches.push(patch);
|
|
837
|
+
this.patchesByMarker.set(marker, patch);
|
|
838
|
+
this.markersByValueAndStyle.set(key, marker);
|
|
839
|
+
return marker;
|
|
840
|
+
}
|
|
841
|
+
originalStyle(style) {
|
|
842
|
+
let current = style;
|
|
843
|
+
const seen = new Set();
|
|
844
|
+
while(current && !seen.has(current)){
|
|
845
|
+
seen.add(current);
|
|
846
|
+
const patch = this.patchesByMarker.get(current);
|
|
847
|
+
if (!patch) break;
|
|
848
|
+
current = patch.style;
|
|
849
|
+
}
|
|
850
|
+
return current;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
async function patchDocxHiddenText(buffer, patches) {
|
|
854
|
+
if (!patches.length) return buffer;
|
|
855
|
+
const archive = await jszip.loadAsync(buffer);
|
|
856
|
+
const byMarker = new Map(patches.map((patch)=>[
|
|
857
|
+
patch.marker,
|
|
858
|
+
patch
|
|
859
|
+
]));
|
|
860
|
+
const applied = new Set();
|
|
861
|
+
for (const entry of Object.values(archive.files)){
|
|
862
|
+
if (entry.dir || !HIDDEN_TEXT_PART_PATTERN.test(entry.name)) continue;
|
|
863
|
+
const document = parseXml(decodeXmlBytes(await entry.async('uint8array'), `generated DOCX ${entry.name}`), `generated DOCX ${entry.name}`);
|
|
864
|
+
let changed = false;
|
|
865
|
+
for (const properties of descendants(document, 'rPr')){
|
|
866
|
+
if (!DOCX_WORDPROCESSING_NAMESPACES.has(properties.namespaceURI ?? '')) continue;
|
|
867
|
+
const markerStyles = directChildren(properties, 'rStyle').filter((style)=>{
|
|
868
|
+
if (!DOCX_WORDPROCESSING_NAMESPACES.has(style.namespaceURI ?? '')) return false;
|
|
869
|
+
const marker = wordValue(style);
|
|
870
|
+
return null !== marker && byMarker.has(marker);
|
|
871
|
+
});
|
|
872
|
+
if (!markerStyles.length) continue;
|
|
873
|
+
if (1 !== markerStyles.length) throw new Error('Generated DOCX hidden-text marker is duplicated in one run.');
|
|
874
|
+
const marker = wordValue(markerStyles[0]);
|
|
875
|
+
const patch = marker ? byMarker.get(marker) : void 0;
|
|
876
|
+
if (!marker || !patch) continue;
|
|
877
|
+
const existing = directChildren(properties, 'vanish').filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
878
|
+
if (existing.length) throw new Error('Generated DOCX hidden-text marker unexpectedly has a native value.');
|
|
879
|
+
if (patch.style) setWordValue(markerStyles[0], patch.style);
|
|
880
|
+
else markerStyles[0].remove();
|
|
881
|
+
insertHiddenTextProperty(document, properties, patch.value);
|
|
882
|
+
applied.add(marker);
|
|
883
|
+
changed = true;
|
|
884
|
+
}
|
|
885
|
+
if (changed) archive.file(entry.name, serializeUtf8Xml(document));
|
|
886
|
+
}
|
|
887
|
+
const missing = patches.filter((patch)=>!applied.has(patch.marker));
|
|
888
|
+
if (missing.length) throw new Error(`DOCX hidden-text markers were not emitted: ${missing.map((patch)=>patch.marker).join(', ')}.`);
|
|
889
|
+
return archive.generateAsync({
|
|
890
|
+
type: 'arraybuffer'
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
function insertHiddenTextProperty(document, properties, value) {
|
|
894
|
+
const namespace = properties.namespaceURI ?? '';
|
|
895
|
+
const prefix = properties.prefix || 'w';
|
|
896
|
+
const vanish = document.createElementNS(namespace, `${prefix}:vanish`);
|
|
897
|
+
if (!value) vanish.setAttributeNS(namespace, `${prefix}:val`, '0');
|
|
898
|
+
const next = directChildren(properties).find((child)=>{
|
|
899
|
+
if (!DOCX_WORDPROCESSING_NAMESPACES.has(child.namespaceURI ?? '')) return true;
|
|
900
|
+
return (WORD_RUN_PROPERTY_RANK.get(child.localName) ?? 1 / 0) > VANISH_RANK;
|
|
901
|
+
});
|
|
902
|
+
properties.insertBefore(vanish, next ?? null);
|
|
903
|
+
}
|
|
904
|
+
function wordValue(element) {
|
|
905
|
+
const values = Array.from(element.attributes).filter((attribute)=>'val' === xmlAttributeLocalName(attribute) && DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, attribute) ?? ''));
|
|
906
|
+
return 1 === values.length ? values[0].value : null;
|
|
907
|
+
}
|
|
908
|
+
function setWordValue(element, value) {
|
|
909
|
+
const namespace = element.namespaceURI ?? '';
|
|
910
|
+
const prefix = element.prefix || 'w';
|
|
911
|
+
for (const attribute of Array.from(element.attributes))if ('val' === xmlAttributeLocalName(attribute) && DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, attribute) ?? '')) element.removeAttributeNode(attribute);
|
|
912
|
+
element.setAttributeNS(namespace, `${prefix}:val`, value);
|
|
913
|
+
}
|
|
760
914
|
const MATH_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/math';
|
|
761
915
|
const work_docx_equation_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
762
916
|
const WORD_DATE_UTC_NAMESPACE = 'http://schemas.microsoft.com/office/word/2023/wordml/word16du';
|
|
@@ -2221,15 +2375,97 @@ function appendFormattingProperties(document, properties, namespace, prefix, ser
|
|
|
2221
2375
|
appendBooleanProperty(document, properties, namespace, prefix, byType, 'bold', 'bCs');
|
|
2222
2376
|
appendBooleanProperty(document, properties, namespace, prefix, byType, 'italic', 'i');
|
|
2223
2377
|
appendBooleanProperty(document, properties, namespace, prefix, byType, 'italic', 'iCs');
|
|
2224
|
-
|
|
2225
|
-
|
|
2378
|
+
appendUnderlineProperty(document, properties, namespace, prefix, byType.get('underline'));
|
|
2379
|
+
appendStrikeProperties(document, properties, namespace, prefix, byType.get('strike'));
|
|
2380
|
+
appendTextCaseProperties(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2381
|
+
appendHiddenTextProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2226
2382
|
appendColorProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2383
|
+
appendCharacterSpacingProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2384
|
+
appendCharacterScaleProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2385
|
+
appendKerningThresholdProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2386
|
+
appendCharacterPositionProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2227
2387
|
appendFontSizeProperties(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2228
2388
|
appendHighlightProperty(document, properties, namespace, prefix, byType.get('highlight'));
|
|
2229
2389
|
appendSnapToGridProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2230
2390
|
appendVerticalAlignProperty(document, properties, namespace, prefix, byType);
|
|
2391
|
+
appendEmphasisMarkProperty(document, properties, namespace, prefix, byType.get('textStyle'));
|
|
2392
|
+
}
|
|
2393
|
+
function appendHiddenTextProperty(document, properties, namespace, prefix, mark) {
|
|
2394
|
+
const hiddenText = normalizeDocumentHiddenText(mark?.attrs?.hiddenText);
|
|
2395
|
+
if (null === hiddenText) return;
|
|
2396
|
+
if (hiddenText) properties.append(wordElement(document, namespace, prefix, 'vanish'));
|
|
2397
|
+
else appendValuedProperty(document, properties, namespace, prefix, 'vanish', '0');
|
|
2398
|
+
}
|
|
2399
|
+
function appendEmphasisMarkProperty(document, properties, namespace, prefix, mark) {
|
|
2400
|
+
const emphasisMark = normalizeDocumentEmphasisMark(mark?.attrs?.emphasisMark);
|
|
2401
|
+
if (null === emphasisMark) return;
|
|
2402
|
+
appendValuedProperty(document, properties, namespace, prefix, 'em', emphasisMark);
|
|
2403
|
+
}
|
|
2404
|
+
function appendCharacterScaleProperty(document, properties, namespace, prefix, mark) {
|
|
2405
|
+
const scale = normalizeDocumentCharacterScalePercent(mark?.attrs?.characterScalePercent);
|
|
2406
|
+
if (null === scale) return;
|
|
2407
|
+
appendValuedProperty(document, properties, namespace, prefix, 'w', String(scale));
|
|
2408
|
+
}
|
|
2409
|
+
function appendKerningThresholdProperty(document, properties, namespace, prefix, mark) {
|
|
2410
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(mark?.attrs?.kerningThresholdHalfPoints);
|
|
2411
|
+
if (null === threshold) return;
|
|
2412
|
+
appendValuedProperty(document, properties, namespace, prefix, 'kern', String(threshold));
|
|
2413
|
+
}
|
|
2414
|
+
function appendCharacterPositionProperty(document, properties, namespace, prefix, mark) {
|
|
2415
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(mark?.attrs?.characterPositionHalfPoints);
|
|
2416
|
+
if (null === position) return;
|
|
2417
|
+
appendValuedProperty(document, properties, namespace, prefix, 'position', String(position));
|
|
2418
|
+
}
|
|
2419
|
+
function appendCharacterSpacingProperty(document, properties, namespace, prefix, mark) {
|
|
2420
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(mark?.attrs?.characterSpacingTwips);
|
|
2421
|
+
if (null === spacing) return;
|
|
2422
|
+
appendValuedProperty(document, properties, namespace, prefix, 'spacing', String(spacing));
|
|
2231
2423
|
}
|
|
2232
2424
|
function appendFontProperties(document, properties, namespace, prefix, mark) {
|
|
2425
|
+
const scriptFonts = parseDocumentScriptFonts('string' == typeof mark?.attrs?.scriptFonts ? mark.attrs.scriptFonts : void 0);
|
|
2426
|
+
if (scriptFonts) {
|
|
2427
|
+
const fonts = wordElement(document, namespace, prefix, 'rFonts');
|
|
2428
|
+
for (const [name, value] of [
|
|
2429
|
+
[
|
|
2430
|
+
'ascii',
|
|
2431
|
+
scriptFonts.ascii?.name
|
|
2432
|
+
],
|
|
2433
|
+
[
|
|
2434
|
+
'hAnsi',
|
|
2435
|
+
scriptFonts.highAnsi?.name
|
|
2436
|
+
],
|
|
2437
|
+
[
|
|
2438
|
+
'eastAsia',
|
|
2439
|
+
scriptFonts.eastAsia?.name
|
|
2440
|
+
],
|
|
2441
|
+
[
|
|
2442
|
+
'cs',
|
|
2443
|
+
scriptFonts.complexScript?.name
|
|
2444
|
+
],
|
|
2445
|
+
[
|
|
2446
|
+
'asciiTheme',
|
|
2447
|
+
scriptFonts.ascii?.theme
|
|
2448
|
+
],
|
|
2449
|
+
[
|
|
2450
|
+
'hAnsiTheme',
|
|
2451
|
+
scriptFonts.highAnsi?.theme
|
|
2452
|
+
],
|
|
2453
|
+
[
|
|
2454
|
+
'eastAsiaTheme',
|
|
2455
|
+
scriptFonts.eastAsia?.theme
|
|
2456
|
+
],
|
|
2457
|
+
[
|
|
2458
|
+
'cstheme',
|
|
2459
|
+
scriptFonts.complexScript?.theme
|
|
2460
|
+
],
|
|
2461
|
+
[
|
|
2462
|
+
'hint',
|
|
2463
|
+
scriptFonts.hint
|
|
2464
|
+
]
|
|
2465
|
+
])if (value) work_docx_format_change_export_setWordAttribute(fonts, namespace, prefix, name, value);
|
|
2466
|
+
properties.append(fonts);
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2233
2469
|
const family = firstFontFamily(mark?.attrs?.fontFamily);
|
|
2234
2470
|
if (!family) return;
|
|
2235
2471
|
const fonts = wordElement(document, namespace, prefix, 'rFonts');
|
|
@@ -2241,14 +2477,41 @@ function appendFontProperties(document, properties, namespace, prefix, mark) {
|
|
|
2241
2477
|
])work_docx_format_change_export_setWordAttribute(fonts, namespace, prefix, name, family);
|
|
2242
2478
|
properties.append(fonts);
|
|
2243
2479
|
}
|
|
2480
|
+
function appendUnderlineProperty(document, properties, namespace, prefix, mark) {
|
|
2481
|
+
if (!mark) return;
|
|
2482
|
+
const style = normalizeDocumentUnderlineStyle(mark.attrs?.underlineStyle) ?? 'single';
|
|
2483
|
+
const color = normalizedHex(mark.attrs?.underlineColor);
|
|
2484
|
+
const theme = themeReference(mark.attrs?.underlineThemeColor);
|
|
2485
|
+
const underline = wordElement(document, namespace, prefix, 'u');
|
|
2486
|
+
work_docx_format_change_export_setWordAttribute(underline, namespace, prefix, 'val', style);
|
|
2487
|
+
const resolved = color ?? normalizedHex(theme?.resolved);
|
|
2488
|
+
if (resolved) work_docx_format_change_export_setWordAttribute(underline, namespace, prefix, 'color', resolved);
|
|
2489
|
+
if (theme) setThemeAttributes(underline, namespace, prefix, theme, 'themeColor');
|
|
2490
|
+
properties.append(underline);
|
|
2491
|
+
}
|
|
2244
2492
|
function appendBooleanProperty(document, properties, namespace, prefix, marks, mark, property) {
|
|
2245
2493
|
if (marks.has(mark)) properties.append(wordElement(document, namespace, prefix, property));
|
|
2246
2494
|
}
|
|
2495
|
+
function appendStrikeProperties(document, properties, namespace, prefix, mark) {
|
|
2496
|
+
if (!mark) return;
|
|
2497
|
+
const style = normalizeDocumentStrikeStyle(mark.attrs?.strikeStyle) ?? 'single';
|
|
2498
|
+
appendValuedProperty(document, properties, namespace, prefix, 'strike', 'single' === style ? '1' : '0');
|
|
2499
|
+
appendValuedProperty(document, properties, namespace, prefix, 'dstrike', 'double' === style ? '1' : '0');
|
|
2500
|
+
}
|
|
2247
2501
|
function appendValuedProperty(document, properties, namespace, prefix, property, value) {
|
|
2248
2502
|
const element = wordElement(document, namespace, prefix, property);
|
|
2249
2503
|
work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', value);
|
|
2250
2504
|
properties.append(element);
|
|
2251
2505
|
}
|
|
2506
|
+
function appendTextCaseProperties(document, properties, namespace, prefix, mark) {
|
|
2507
|
+
const textCase = mark?.attrs?.textCase;
|
|
2508
|
+
if ('all-caps' === textCase) properties.append(wordElement(document, namespace, prefix, 'caps'));
|
|
2509
|
+
else if ('small-caps' === textCase) properties.append(wordElement(document, namespace, prefix, 'smallCaps'));
|
|
2510
|
+
else if ('none' === textCase) {
|
|
2511
|
+
appendValuedProperty(document, properties, namespace, prefix, 'caps', '0');
|
|
2512
|
+
appendValuedProperty(document, properties, namespace, prefix, 'smallCaps', '0');
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2252
2515
|
function appendColorProperty(document, properties, namespace, prefix, mark) {
|
|
2253
2516
|
const color = normalizedHex(mark?.attrs?.color);
|
|
2254
2517
|
const theme = themeReference(mark?.attrs?.themeColor);
|
|
@@ -7283,6 +7546,131 @@ function docxParagraphPartPaths(pathsByLower, contentTypes) {
|
|
|
7283
7546
|
function isObfuscatedFontContentType(type) {
|
|
7284
7547
|
return type?.trim().toLowerCase() === 'application/vnd.openxmlformats-officedocument.obfuscatedfont';
|
|
7285
7548
|
}
|
|
7549
|
+
const RUN_FONT_PART_PATTERN = /^word\/(?:document|header\d*|footer\d*|footnotes|endnotes|comments)\.xml$/i;
|
|
7550
|
+
const WORD_FONT_ATTRIBUTE_NAMES = new Set([
|
|
7551
|
+
'ascii',
|
|
7552
|
+
'hAnsi',
|
|
7553
|
+
'eastAsia',
|
|
7554
|
+
'cs',
|
|
7555
|
+
'asciiTheme',
|
|
7556
|
+
'hAnsiTheme',
|
|
7557
|
+
'eastAsiaTheme',
|
|
7558
|
+
'cstheme',
|
|
7559
|
+
'hint'
|
|
7560
|
+
]);
|
|
7561
|
+
class DocxRunFontsPatchCollector {
|
|
7562
|
+
patches = [];
|
|
7563
|
+
nextMarker = 1;
|
|
7564
|
+
occupied;
|
|
7565
|
+
markersByFonts = new Map();
|
|
7566
|
+
constructor(source){
|
|
7567
|
+
this.occupied = source;
|
|
7568
|
+
}
|
|
7569
|
+
marker(source, slot, currentFontFamily) {
|
|
7570
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
7571
|
+
const normalizedSlot = normalizeDocumentScriptFontSlot(slot) ?? documentScriptFontSlotFromHint(fonts?.hint);
|
|
7572
|
+
const expected = fonts ? documentScriptFontFamily(fonts, normalizedSlot) : void 0;
|
|
7573
|
+
const current = documentFontNameFromCssFamily(currentFontFamily);
|
|
7574
|
+
if (!fonts || (expected ? documentFontNameFromCssFamily(expected)?.toLocaleLowerCase() !== current?.toLocaleLowerCase() : Boolean(currentFontFamily.trim()))) return null;
|
|
7575
|
+
const key = serializeDocumentScriptFonts(fonts);
|
|
7576
|
+
if (!key) return null;
|
|
7577
|
+
const existing = this.markersByFonts.get(key);
|
|
7578
|
+
if (existing) return existing;
|
|
7579
|
+
let marker = '';
|
|
7580
|
+
do {
|
|
7581
|
+
marker = `A3SOfficeRunFonts${String(this.nextMarker).padStart(8, '0')}`;
|
|
7582
|
+
this.nextMarker += 1;
|
|
7583
|
+
}while (this.occupied.includes(marker) || this.patches.some((patch)=>patch.marker === marker))
|
|
7584
|
+
this.patches.push({
|
|
7585
|
+
marker,
|
|
7586
|
+
fonts
|
|
7587
|
+
});
|
|
7588
|
+
this.markersByFonts.set(key, marker);
|
|
7589
|
+
return marker;
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
async function patchDocxRunFonts(buffer, patches) {
|
|
7593
|
+
if (!patches.length) return buffer;
|
|
7594
|
+
const archive = await jszip.loadAsync(buffer);
|
|
7595
|
+
const byMarker = new Map(patches.map((patch)=>[
|
|
7596
|
+
patch.marker,
|
|
7597
|
+
patch.fonts
|
|
7598
|
+
]));
|
|
7599
|
+
const applied = new Set();
|
|
7600
|
+
for (const entry of Object.values(archive.files)){
|
|
7601
|
+
if (entry.dir || !RUN_FONT_PART_PATTERN.test(entry.name)) continue;
|
|
7602
|
+
const document = parseXml(decodeXmlBytes(await entry.async('uint8array'), `generated DOCX ${entry.name}`), `generated DOCX ${entry.name}`);
|
|
7603
|
+
let changedPart = false;
|
|
7604
|
+
for (const element of descendants(document, 'rFonts')){
|
|
7605
|
+
if (!DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? '')) continue;
|
|
7606
|
+
const marker = wordFontAttribute(element, 'ascii');
|
|
7607
|
+
if (!marker) continue;
|
|
7608
|
+
const fonts = byMarker.get(marker);
|
|
7609
|
+
if (fonts) {
|
|
7610
|
+
replaceWordFontAttributes(element, fonts);
|
|
7611
|
+
applied.add(marker);
|
|
7612
|
+
changedPart = true;
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
if (changedPart) archive.file(entry.name, serializeUtf8Xml(document));
|
|
7616
|
+
}
|
|
7617
|
+
const missing = patches.filter((patch)=>!applied.has(patch.marker));
|
|
7618
|
+
if (missing.length) throw new Error(`DOCX run-font markers were not emitted: ${missing.map((patch)=>patch.marker).join(', ')}.`);
|
|
7619
|
+
return archive.generateAsync({
|
|
7620
|
+
type: 'arraybuffer'
|
|
7621
|
+
});
|
|
7622
|
+
}
|
|
7623
|
+
function replaceWordFontAttributes(element, fonts) {
|
|
7624
|
+
for (const item of Array.from(element.attributes))if (item.namespaceURI !== work_docx_settings_xml_XMLNS_NAMESPACE && WORD_FONT_ATTRIBUTE_NAMES.has(xmlAttributeLocalName(item)) && DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, item) ?? '')) element.removeAttributeNode(item);
|
|
7625
|
+
const values = [
|
|
7626
|
+
[
|
|
7627
|
+
'ascii',
|
|
7628
|
+
fonts.ascii?.name
|
|
7629
|
+
],
|
|
7630
|
+
[
|
|
7631
|
+
'hAnsi',
|
|
7632
|
+
fonts.highAnsi?.name
|
|
7633
|
+
],
|
|
7634
|
+
[
|
|
7635
|
+
'eastAsia',
|
|
7636
|
+
fonts.eastAsia?.name
|
|
7637
|
+
],
|
|
7638
|
+
[
|
|
7639
|
+
'cs',
|
|
7640
|
+
fonts.complexScript?.name
|
|
7641
|
+
],
|
|
7642
|
+
[
|
|
7643
|
+
'asciiTheme',
|
|
7644
|
+
fonts.ascii?.theme
|
|
7645
|
+
],
|
|
7646
|
+
[
|
|
7647
|
+
'hAnsiTheme',
|
|
7648
|
+
fonts.highAnsi?.theme
|
|
7649
|
+
],
|
|
7650
|
+
[
|
|
7651
|
+
'eastAsiaTheme',
|
|
7652
|
+
fonts.eastAsia?.theme
|
|
7653
|
+
],
|
|
7654
|
+
[
|
|
7655
|
+
'cstheme',
|
|
7656
|
+
fonts.complexScript?.theme
|
|
7657
|
+
],
|
|
7658
|
+
[
|
|
7659
|
+
'hint',
|
|
7660
|
+
fonts.hint
|
|
7661
|
+
]
|
|
7662
|
+
];
|
|
7663
|
+
for (const [name, value] of values)if (value) setWordFontAttribute(element, name, value);
|
|
7664
|
+
}
|
|
7665
|
+
function wordFontAttribute(element, name) {
|
|
7666
|
+
const values = Array.from(element.attributes).filter((item)=>xmlAttributeLocalName(item) === name && DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, item) ?? ''));
|
|
7667
|
+
return 1 === values.length ? values[0]?.value ?? null : null;
|
|
7668
|
+
}
|
|
7669
|
+
function setWordFontAttribute(element, name, value) {
|
|
7670
|
+
const namespace = element.namespaceURI ?? '';
|
|
7671
|
+
const prefix = element.prefix || 'w';
|
|
7672
|
+
element.setAttributeNS(namespace, `${prefix}:${name}`, value);
|
|
7673
|
+
}
|
|
7286
7674
|
async function createDocxBlob(content, sourcePackage) {
|
|
7287
7675
|
const docx = await import("docx");
|
|
7288
7676
|
const normalizedContent = {
|
|
@@ -7317,7 +7705,11 @@ async function createDocxBlob(content, sourcePackage) {
|
|
|
7317
7705
|
paragraphIdentityPatches: new DocxParagraphIdentityPatchCollector(JSON.stringify(normalizedContent)),
|
|
7318
7706
|
equationPatches: new DocxEquationPatchCollector(JSON.stringify(normalizedContent)),
|
|
7319
7707
|
formattingChangePatches: new DocxRunFormattingChangePatchCollector(),
|
|
7320
|
-
|
|
7708
|
+
runFontPatches: new DocxRunFontsPatchCollector(JSON.stringify(normalizedContent)),
|
|
7709
|
+
hiddenTextPatches: new DocxHiddenTextPatchCollector(JSON.stringify(normalizedContent)),
|
|
7710
|
+
paragraphFormattingChangePatches: new DocxParagraphFormattingChangePatchCollector(),
|
|
7711
|
+
hasExplicitZeroCharacterSpacing: false,
|
|
7712
|
+
hasExplicitZeroKerningThreshold: false
|
|
7321
7713
|
};
|
|
7322
7714
|
const commentRecords = createDocxCommentRecords(commentThreads, docx, noteContext.commentIds);
|
|
7323
7715
|
const sections = [];
|
|
@@ -7364,7 +7756,11 @@ async function createDocxBlob(content, sourcePackage) {
|
|
|
7364
7756
|
}
|
|
7365
7757
|
});
|
|
7366
7758
|
const packed = await docx.Packer.toBlob(document);
|
|
7367
|
-
const
|
|
7759
|
+
const characterSpacingPatched = noteContext.hasExplicitZeroCharacterSpacing ? await patchDocxExplicitZeroCharacterSpacing(await packed.arrayBuffer()) : await packed.arrayBuffer();
|
|
7760
|
+
const kerningPatched = noteContext.hasExplicitZeroKerningThreshold ? await patchDocxExplicitZeroKerningThresholds(characterSpacingPatched) : characterSpacingPatched;
|
|
7761
|
+
const runFontsPatched = await patchDocxRunFonts(kerningPatched, noteContext.runFontPatches.patches);
|
|
7762
|
+
const hiddenTextPatched = await patchDocxHiddenText(runFontsPatched, noteContext.hiddenTextPatches.patches);
|
|
7763
|
+
const formattingChangesPatched = await patchDocxRunFormattingChanges(hiddenTextPatched, noteContext.formattingChangePatches.patches);
|
|
7368
7764
|
const noteImageRelationshipsPatched = await patchDocxNoteImageRelationships(formattingChangesPatched);
|
|
7369
7765
|
const commentMetadataPatched = await patchDocxCommentMetadata(noteImageRelationshipsPatched, commentThreads);
|
|
7370
7766
|
const numberingPatched = await patchDocxNumberingRestartRules(commentMetadataPatched, noteContext.numberingRestartRules);
|
|
@@ -7624,22 +8020,50 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
7624
8020
|
fill: backgroundColor
|
|
7625
8021
|
} : inherited.shading;
|
|
7626
8022
|
const themeFillMarker = noteContext.themePatches.marker('fill', parseDocxThemeReference(node.dataset.officeThemeFill), resolvedShading?.fill ? `#${resolvedShading.fill}` : null);
|
|
8023
|
+
const explicitTextCase = normalizeDocumentTextCase(node.dataset.officeTextCase);
|
|
8024
|
+
const explicitCharacterSpacing = documentCharacterSpacingTwipsFromElement(node);
|
|
8025
|
+
const explicitCharacterScale = documentCharacterScalePercentFromElement(node);
|
|
8026
|
+
const explicitKerningThreshold = documentKerningThresholdHalfPointsFromElement(node);
|
|
8027
|
+
const explicitEmphasisMark = documentEmphasisMarkFromElement(node);
|
|
8028
|
+
const explicitHiddenText = documentHiddenTextFromElement(node);
|
|
8029
|
+
const explicitCharacterPosition = documentCharacterPositionHalfPointsFromElement(node);
|
|
8030
|
+
if (0 === explicitCharacterSpacing) noteContext.hasExplicitZeroCharacterSpacing = true;
|
|
8031
|
+
if (0 === explicitKerningThreshold) noteContext.hasExplicitZeroKerningThreshold = true;
|
|
8032
|
+
const characterSpacing = null === explicitCharacterSpacing ? inherited.characterSpacing : docxCharacterSpacingValue(explicitCharacterSpacing);
|
|
8033
|
+
const scale = null === explicitCharacterScale ? inherited.scale : docxCharacterScaleValue(explicitCharacterScale);
|
|
8034
|
+
const kern = null === explicitKerningThreshold ? inherited.kern : docxKerningThresholdValue(explicitKerningThreshold);
|
|
8035
|
+
const position = null === explicitCharacterPosition ? inherited.position : docxCharacterPositionValue(explicitCharacterPosition);
|
|
8036
|
+
const emphasisMark = null === explicitEmphasisMark ? inherited.emphasisMark : docxEmphasisMarkRunOptions(explicitEmphasisMark);
|
|
8037
|
+
const textCaseOptions = docxTextCaseRunOptions(explicitTextCase, inherited);
|
|
8038
|
+
const hiddenTextStyle = null === explicitHiddenText ? inherited.style : noteContext.hiddenTextPatches.marker(explicitHiddenText, inherited.style);
|
|
8039
|
+
const underline = docxUnderlineRunOptions(node, inherited.underline, noteContext.themePatches);
|
|
8040
|
+
const strike = docxStrikeRunOptions(node, inherited);
|
|
8041
|
+
const scriptFontMarker = noteContext.runFontPatches.marker(documentScriptFontsFromElement(node), documentScriptFontSlotFromElement(node), node.style.fontFamily);
|
|
7627
8042
|
const style = {
|
|
7628
8043
|
...inherited,
|
|
8044
|
+
style: hiddenTextStyle,
|
|
7629
8045
|
bold: inherited.bold || 'strong' === tag || 'b' === tag,
|
|
7630
8046
|
italics: inherited.italics || 'em' === tag || 'i' === tag,
|
|
7631
|
-
underline
|
|
7632
|
-
strike
|
|
8047
|
+
underline,
|
|
8048
|
+
...strike,
|
|
7633
8049
|
subScript: inherited.subScript || 'sub' === tag,
|
|
7634
8050
|
superScript: inherited.superScript || 'sup' === tag,
|
|
7635
8051
|
color: themeColorMarker ?? resolvedColor,
|
|
7636
|
-
font:
|
|
8052
|
+
font: scriptFontMarker ? {
|
|
8053
|
+
ascii: scriptFontMarker
|
|
8054
|
+
} : cssFontFamily(node.style.fontFamily) ?? inherited.font,
|
|
7637
8055
|
size: cssFontSize(node.style.fontSize) ?? inherited.size,
|
|
8056
|
+
characterSpacing,
|
|
8057
|
+
scale,
|
|
8058
|
+
kern,
|
|
8059
|
+
position,
|
|
8060
|
+
emphasisMark,
|
|
7638
8061
|
shading: themeFillMarker ? {
|
|
7639
8062
|
fill: themeFillMarker
|
|
7640
8063
|
} : resolvedShading,
|
|
7641
8064
|
snapToGrid: dataBoolean(node.dataset.officeWordSnapToGrid) ?? inherited.snapToGrid,
|
|
7642
|
-
rightToLeft: void 0 === direction ? inherited.rightToLeft : 'rtl' === direction
|
|
8065
|
+
rightToLeft: void 0 === direction ? inherited.rightToLeft : 'rtl' === direction,
|
|
8066
|
+
...textCaseOptions
|
|
7643
8067
|
};
|
|
7644
8068
|
if ('br' === tag) return [
|
|
7645
8069
|
new docx.TextRun({
|
|
@@ -7692,6 +8116,64 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
|
|
|
7692
8116
|
for (const node of root.childNodes)runs.push(...await visit(node, inheritedDirection));
|
|
7693
8117
|
return runs;
|
|
7694
8118
|
}
|
|
8119
|
+
function docxStrikeRunOptions(element, inherited) {
|
|
8120
|
+
if (element.hasAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE) && !element.hasAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE)) return {
|
|
8121
|
+
doubleStrike: inherited.doubleStrike,
|
|
8122
|
+
strike: inherited.strike
|
|
8123
|
+
};
|
|
8124
|
+
const formatting = documentStrikeFormattingFromElement(element);
|
|
8125
|
+
if (!formatting) return {
|
|
8126
|
+
doubleStrike: inherited.doubleStrike,
|
|
8127
|
+
strike: inherited.strike
|
|
8128
|
+
};
|
|
8129
|
+
return {
|
|
8130
|
+
doubleStrike: 'double' === formatting.style,
|
|
8131
|
+
strike: 'single' === formatting.style
|
|
8132
|
+
};
|
|
8133
|
+
}
|
|
8134
|
+
function docxUnderlineRunOptions(element, inherited, themePatches) {
|
|
8135
|
+
if (element.hasAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE) && !element.hasAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE)) return inherited;
|
|
8136
|
+
const formatting = documentUnderlineFormattingFromElement(element);
|
|
8137
|
+
if (!formatting) return inherited;
|
|
8138
|
+
const color = docxUnderlineColor(formatting, themePatches);
|
|
8139
|
+
return {
|
|
8140
|
+
type: formatting.style,
|
|
8141
|
+
...color ? {
|
|
8142
|
+
color
|
|
8143
|
+
} : {}
|
|
8144
|
+
};
|
|
8145
|
+
}
|
|
8146
|
+
function docxUnderlineColor(formatting, themePatches) {
|
|
8147
|
+
const direct = formatting.color ? cssColorToHex(formatting.color) : void 0;
|
|
8148
|
+
return themePatches.marker('underline', formatting.themeColor ?? null, direct ? `#${direct}` : null) ?? direct;
|
|
8149
|
+
}
|
|
8150
|
+
function docxTextCaseRunOptions(explicitTextCase, inherited) {
|
|
8151
|
+
if (null === explicitTextCase) {
|
|
8152
|
+
if (void 0 !== inherited.smallCaps) return {
|
|
8153
|
+
allCaps: void 0,
|
|
8154
|
+
smallCaps: inherited.smallCaps
|
|
8155
|
+
};
|
|
8156
|
+
return void 0 === inherited.allCaps ? {} : {
|
|
8157
|
+
allCaps: inherited.allCaps,
|
|
8158
|
+
smallCaps: void 0
|
|
8159
|
+
};
|
|
8160
|
+
}
|
|
8161
|
+
if ('all-caps' === explicitTextCase) return {
|
|
8162
|
+
allCaps: true,
|
|
8163
|
+
smallCaps: void 0
|
|
8164
|
+
};
|
|
8165
|
+
if ('small-caps' === explicitTextCase) return {
|
|
8166
|
+
allCaps: void 0,
|
|
8167
|
+
smallCaps: true
|
|
8168
|
+
};
|
|
8169
|
+
return inherited.smallCaps ? {
|
|
8170
|
+
allCaps: void 0,
|
|
8171
|
+
smallCaps: false
|
|
8172
|
+
} : {
|
|
8173
|
+
allCaps: false,
|
|
8174
|
+
smallCaps: void 0
|
|
8175
|
+
};
|
|
8176
|
+
}
|
|
7695
8177
|
function docxTextRevision(element, kind, context) {
|
|
7696
8178
|
const id = docxRevisionId(element, context);
|
|
7697
8179
|
const sourceDate = element.dataset.changeDate?.trim() ?? '';
|