@a3s-lab/office 0.46.0 → 0.47.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 +11 -0
- package/dist/0~2133.js +748 -748
- package/dist/0~document-editor.js +3877 -3847
- package/dist/0~work-docx-export.js +2 -2
- package/dist/0~work-docx-import.js +41 -5
- package/dist/0~work-office-diagnostics.js +21 -6
- package/dist/4174.js +1817 -1565
- package/dist/internal/features/work/work-document-field-node.d.ts +2 -2
- package/dist/internal/features/work/work-document-fields.d.ts +36 -2
- package/dist/internal/features/work/work-docx-bookmark-import.d.ts +1 -1
- package/dist/internal/features/work/work-docx-field-import.d.ts +5 -1
- package/dist/internal/features/work/work-docx-import.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
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, parseDocumentNumberingChange, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, normalizeDocumentUnderlineStyle, normalizeDocumentPageChrome, documentPageMarginsForLayout, normalizeDocumentImageLayer, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, serializeDocumentOpenTypeFeatures, documentCaptionLabel, documentCaptionKind, isContourImageLayout, normalizeDocumentLegacyTextEffects, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, normalizeDocumentImageIdentity,
|
|
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, parseDocumentNumberingChange, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, normalizeDocumentUnderlineStyle, normalizeDocumentPageChrome, documentPageMarginsForLayout, normalizeDocumentImageLayer, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, serializeDocumentOpenTypeFeatures, documentCaptionLabel, documentCaptionKind, isContourImageLayout, normalizeDocumentLegacyTextEffects, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, normalizeDocumentImageIdentity, supportedDocxDocumentFieldInstruction, normalizeDocumentStrikeStyle, normalizeDocumentOpenTypeFeatures, documentCitationTags, docxDocumentFieldKind, normalizeTableColor, documentTableBordersFromElement, documentSections, wrapsBesideImage, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentKerningThresholdHalfPoints, documentTextBoxPropertiesFromElement, defaultDocumentImageWrapContour, parseDocumentOpenTypeFeatures, normalizeDocumentPaperSource, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, documentEquationFromElement, documentImageTransformFromElement, parseDocumentCharacterFormatting, documentLegacyTextEffectsFromElement, documentUnderlineFormattingFromElement, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, normalizeDocumentEquation, parseDocumentParagraphFormatting, documentOpenTypeFeaturesFromElement, normalizeDocumentBookmarkNativeId, documentTableRowIdentityFromElement, DOCUMENT_PAGE_MARGIN_KEYS, uniqueDocumentImageIdentity, documentHiddenTextFromElement, collectDocumentNotes, documentImageLayoutFromElement, documentPageHorizontalMarginTwips, DOCUMENT_OPEN_TYPE_ATTRIBUTE, MAX_DOCUMENT_NUMBERING_START, documentPageGeometryForLayout, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, documentCharacterScalePercentFromElement, normalizeDocumentPageMargins, normalizeDocumentLegacyTextEffect, documentNoteKind } from "./4174.js";
|
|
3
3
|
import { normalizeDocumentRunBorder, parseDocumentScriptFonts, parseDocxThemeReference, parseXml, parseDocumentRunShading, applyDocumentParagraphIdentityToElement, DOCUMENT_RUN_SHADING_ATTRIBUTE, documentScriptFontSlotFromElement, DOCUMENT_HIGHLIGHT_ATTRIBUTE, normalizeDocumentIndexesHtml, 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, documentIndexEntryFromElement, documentIndexValueFromElement, parseDocumentParagraphShadingElement, documentFontNameFromCssFamily } from "./6968.js";
|
|
4
4
|
import { assignDocxNoteIds, patchDocxPageColor, normalizeDocxCommentId, assignDocxCommentThreads } from "./0~4980.js";
|
|
5
5
|
import { DocxImageTransformPatchCollector, paragraphTabStops, patchDocxImageTransforms, mergeDocxIgnorableExtensionsAtPairs, DOCX_WORD_2010_NAMESPACE, docxKerningThresholdValue, patchDocxBibliography, documentIndexInstruction, docxCharacterScaleValue, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, xmlNamespaceUri, paragraphSpacingOptions, docxCharacterPositionValue, documentIndexEntryInstruction, docxEmphasisMarkRunOptions, hasNonWhitespaceXmlText, patchDocxExplicitZeroCharacterSpacing, cloneXmlElement, cssColorToHex, xmlDeclaredPrefix, assertXmlRoot, DOCX_WORDPROCESSING_NAMESPACES, paragraphIndent, domDirection, xmlAttributeNamespace, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, mergeDocxIgnorableExtensions, DocxParagraphDefaultCollapsedPatchCollector, dataBoolean, patchDocxParagraphDefaultCollapsed, patchDocxExplicitZeroKerningThresholds, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, documentProofingLanguageDocxOptions, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~4042.js";
|
|
@@ -2093,7 +2093,7 @@ function imageDimensions(blob) {
|
|
|
2093
2093
|
function docxDocumentFieldRun(element, docx) {
|
|
2094
2094
|
const instruction = element.dataset.fieldInstruction?.trim() ?? '';
|
|
2095
2095
|
const display = element.dataset.fieldDisplay?.trim() || element.textContent?.trim() || '';
|
|
2096
|
-
if (!docxDocumentFieldKind(instruction)) return new docx.TextRun(display);
|
|
2096
|
+
if (!docxDocumentFieldKind(instruction) || !supportedDocxDocumentFieldInstruction(instruction)) return new docx.TextRun(display);
|
|
2097
2097
|
return new docx.SimpleField(instruction, display);
|
|
2098
2098
|
}
|
|
2099
2099
|
const work_docx_run_shading_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
2
|
import { documentRunBorderDomAttributes, contentTypeForPart, bytesToDataUrl, OoxmlPackage, normalizeDocumentIndexesHtml, firstDescendant, normalizeDocumentParagraphId, applyDocumentParagraphIdentityToElement, descendants, documentHighlightDomAttributes, attribute as work_ooxml_package_attribute, documentHighlightFromDocxValue, serializeDocxThemeReference, normalizeDocumentTableOfContentsHtml, directChildren, documentParagraphShadingDomAttributes, documentProofingDomAttributes, documentParagraphBordersDomAttributes, directChild, documentScriptFontSegments, normalizeDocumentParagraphIdentity, documentRunShadingDomAttributes } from "./6968.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, applyDocumentImageTransformToElement, 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, documentOpenTypeDomAttributes, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes } from "./4174.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, applyDocumentImageTransformToElement, documentInitialSectionLayout, normalizeDocumentFieldsHtml, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, supportedDocxDocumentFieldInstruction, documentKerningDomAttributes, docxDocumentFieldKind, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentCharacterScaleDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, documentPageMarginBody, documentLegacyTextEffectsDomAttributes, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, documentOpenTypeDomAttributes, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, docxDocumentFieldTarget } from "./4174.js";
|
|
4
4
|
import { hasImportedDocxIndexMarkers, markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxTextBoxMarkers, applyImportedDocxNumberingChangeMarkers, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, markDocxTextBoxes, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, markDocxTablesOfContents, hasImportedDocxParagraphSpacingMarkers, applyImportedDocxIndexMarkers, applyImportedDocxTableOfContentsMarkers, markDocxIndexes, docxTablePropertySources, parseDirectDocxParagraphShading, markDocxPackageEquations, markDocxParagraphIndents, parseDocxPageMargins, resolveDocxRunBorder, parseDocxPageGeometry, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, importedDocxStrike, docxTableRunPropertySources, hasImportedDocxNumberingChangeMarkers, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, hasImportedDocxTableOfContentsMarkers, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphTabStopMarkers, resolveDocxRunShading, docxCaptionSequenceKind, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, resolveDocxHiddenText, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver, hasImportedDocxTextBoxMarkers, markDocxNumberingChanges, markDocxParagraphPagination, importedDocxUnderline, markDocxParagraphBorders, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphAlignmentMarkers, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphTabStopMarkers, docxRunPropertySources, markDocxParagraphFormattingChanges, markDocxParagraphShading, parseDocxPageBorders } from "./0~2133.js";
|
|
5
5
|
import { readDocxBibliography, resolveDocxProofing, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, resolveDocxOpenTypeFeatures, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, readDocxImageTransform, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~4042.js";
|
|
6
6
|
import { importDocxPageColor, importedDocumentNoteId } from "./0~4980.js";
|
|
@@ -933,17 +933,34 @@ function work_docx_comment_import_compareDocumentOrder(left, right) {
|
|
|
933
933
|
}
|
|
934
934
|
const work_docx_field_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
935
935
|
const work_docx_field_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
936
|
-
function markDocxBodyFields(document) {
|
|
936
|
+
function markDocxBodyFields(document, bookmarks = []) {
|
|
937
|
+
const bookmarkTargets = bookmarks.length ? new Map(bookmarks.map((bookmark)=>[
|
|
938
|
+
bookmark.sourceName.trim().toLowerCase(),
|
|
939
|
+
{
|
|
940
|
+
id: bookmark.id,
|
|
941
|
+
name: bookmark.name
|
|
942
|
+
}
|
|
943
|
+
])) : pairedBookmarkTargets(document);
|
|
937
944
|
const fields = docxFieldOccurrences(document).flatMap((field, index)=>{
|
|
938
945
|
const kind = docxDocumentFieldKind(field.instruction);
|
|
939
|
-
if (!kind || !docxFieldOccurrenceIsInlineEditable(field)) return [];
|
|
946
|
+
if (!kind || !supportedDocxDocumentFieldInstruction(field.instruction) || !docxFieldOccurrenceIsInlineEditable(field)) return [];
|
|
947
|
+
const targetName = docxDocumentFieldTarget(field.instruction) ?? void 0;
|
|
948
|
+
const target = targetName ? bookmarkTargets.get(targetName.toLowerCase()) : void 0;
|
|
949
|
+
if ('pageReference' === kind && !target) return [];
|
|
940
950
|
const marker = {
|
|
941
951
|
start: `__A3S_WORK_FIELD_START_${index + 1}__`,
|
|
942
952
|
end: `__A3S_WORK_FIELD_END_${index + 1}__`,
|
|
943
953
|
id: `docx-field-${index + 1}`,
|
|
944
954
|
kind,
|
|
945
955
|
instruction: field.instruction,
|
|
946
|
-
display: docxFieldResultText(field)
|
|
956
|
+
display: docxFieldResultText(field),
|
|
957
|
+
...target ? {
|
|
958
|
+
targetId: target.id,
|
|
959
|
+
targetName: target.name
|
|
960
|
+
} : {},
|
|
961
|
+
...'pageReference' === kind ? {
|
|
962
|
+
orphaned: !target
|
|
963
|
+
} : {}
|
|
947
964
|
};
|
|
948
965
|
work_docx_field_import_insertFieldBoundaryMarkers(document, field, marker.start, marker.end);
|
|
949
966
|
return [
|
|
@@ -954,6 +971,22 @@ function markDocxBodyFields(document) {
|
|
|
954
971
|
fields
|
|
955
972
|
};
|
|
956
973
|
}
|
|
974
|
+
function pairedBookmarkTargets(document) {
|
|
975
|
+
const endIds = new Set(descendants(document, 'bookmarkEnd').map((element)=>work_ooxml_package_attribute(element, 'id')?.trim() ?? '').filter(Boolean));
|
|
976
|
+
return new Map(descendants(document, 'bookmarkStart').flatMap((element)=>{
|
|
977
|
+
const id = work_ooxml_package_attribute(element, 'id')?.trim() ?? '';
|
|
978
|
+
const name = work_ooxml_package_attribute(element, 'name')?.trim() ?? '';
|
|
979
|
+
return id && name && endIds.has(id) ? [
|
|
980
|
+
[
|
|
981
|
+
name.toLowerCase(),
|
|
982
|
+
{
|
|
983
|
+
id,
|
|
984
|
+
name
|
|
985
|
+
}
|
|
986
|
+
]
|
|
987
|
+
] : [];
|
|
988
|
+
}));
|
|
989
|
+
}
|
|
957
990
|
function applyImportedDocxFieldMarkers(document, markers) {
|
|
958
991
|
for (const field of markers.fields){
|
|
959
992
|
const element = document.createElement('span');
|
|
@@ -961,6 +994,9 @@ function applyImportedDocxFieldMarkers(document, markers) {
|
|
|
961
994
|
element.dataset.fieldId = field.id;
|
|
962
995
|
element.dataset.fieldKind = field.kind;
|
|
963
996
|
element.dataset.fieldInstruction = field.instruction;
|
|
997
|
+
if (field.targetId) element.dataset.fieldTargetId = field.targetId;
|
|
998
|
+
if (field.targetName) element.dataset.fieldTargetName = field.targetName;
|
|
999
|
+
if (field.orphaned) element.dataset.fieldOrphaned = 'true';
|
|
964
1000
|
const convertedDisplay = work_docx_field_import_replaceMarkerRange(document.body, field.start, field.end, element);
|
|
965
1001
|
const display = field.display.trim() || convertedDisplay.trim();
|
|
966
1002
|
element.dataset.fieldDisplay = display;
|
|
@@ -2975,7 +3011,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
|
|
|
2975
3011
|
const captionMarkers = markDocxCaptionFields(document);
|
|
2976
3012
|
const bookmarkMarkers = markDocxBookmarks(document);
|
|
2977
3013
|
const citationMarkers = markDocxCitationFields(document);
|
|
2978
|
-
const fieldMarkers = markDocxBodyFields(document);
|
|
3014
|
+
const fieldMarkers = markDocxBodyFields(document, bookmarkMarkers.bookmarks);
|
|
2979
3015
|
const listMarkers = markDocxLists(document, numbering);
|
|
2980
3016
|
const numberingChangeMarkers = markDocxNumberingChanges(document);
|
|
2981
3017
|
const imageLayoutMarkerState = createImportedDocxImageLayoutMarkerState();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
2
|
import { contentTypeForPart, directChildren, OoxmlPackage, parseXml, firstDescendant, isDocumentParagraphArtBorderStyle, descendants, directChild, xmlContainsAnyElement, attribute, documentRunBorderIsVisible } from "./6968.js";
|
|
3
|
-
import { normalizeDocumentBookmarkName, docxBookmarkReferenceTarget, normalizeDocumentBookmarkNativeId,
|
|
3
|
+
import { normalizeDocumentBookmarkName, docxBookmarkReferenceTarget, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, normalizeDocumentBookmarkNativeId, supportedDocxDocumentFieldInstruction, supportedDocxBookmarkReferenceInstruction, documentCitationTagsFromInstruction, docxDocumentFieldKind, docxDocumentFieldTarget } from "./4174.js";
|
|
4
4
|
import { isSupportedDocxEquationPlacement, inspectDocxPageSize, hasInvalidDocxFieldStructure, createDocxTableStyleResolver, inspectDocxRunBorder, inspectDocxEquation, inspectDocxPageMarginSettings, inspectDocxRunShading, supportedDocxIndexField, docxCaptionSequenceKind, inspectDocxPageBorders, docxCaptionBookmark, inspectDocxLegacyTextEffects, inspectDocxPageMargins, inspectDocxPaperSource, createDocxParagraphStyleResolver, inspectDocxRunFonts, supportedDocxTableOfContentsField, docxFieldOccurrences, supportedDocxIndexEntryField, inspectDocxTextBoxes, markDocxParagraphBorders, isSupportedDocxParagraphFormattingChange, docxFieldOccurrenceIsInlineEditable, inspectDocxHiddenText, isSupportedDocxRunFormattingChange, isSupportedDocxNumberingChange, markDocxParagraphShading, docxFieldInstructions } from "./0~2133.js";
|
|
5
5
|
import { normalizeDocumentHref } from "./0~work-document-links.js";
|
|
6
6
|
import { xmlAttributeLocalName, resolveDocxOpenTypeFeatures, inspectDocxProofingLanguages, readDocxBibliography, inspectDocxEmphasisMark, createDocxThemeResolver, DOCX_WORD_2010_NAMESPACE, inspectDocxNoProof, parseDocxParagraphDefaultCollapsed, readDocxImageTransform, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, inspectDocxKerningThresholdHalfPoints } from "./0~4042.js";
|
|
@@ -117,13 +117,15 @@ function diagnoseDocxCaptions(document) {
|
|
|
117
117
|
};
|
|
118
118
|
const isSupportedBlockField = (field)=>isTableOfContentsField(field) || isIndexField(field);
|
|
119
119
|
const sequences = fields.filter((field)=>docxCaptionSequenceKind(field.instruction));
|
|
120
|
-
const bodyFields = fields.filter((field)=>'orphan' !== field.syntax && Boolean(docxDocumentFieldKind(field.instruction)));
|
|
121
|
-
const editableBodyFields = bodyFields.filter(docxFieldOccurrenceIsInlineEditable);
|
|
122
|
-
const hasUnsupportedFieldStructure = hasInvalidDocxFieldStructure(document, isSupportedBlockField) || bodyFields.some((field)=>!docxFieldOccurrenceIsInlineEditable(field));
|
|
123
120
|
const bookmarkNames = new Set([
|
|
124
121
|
...captionBookmarkNames(sequences),
|
|
125
122
|
...pairedBookmarkNames(document)
|
|
126
123
|
]);
|
|
124
|
+
const bodyFields = fields.filter((field)=>'orphan' !== field.syntax && Boolean(docxDocumentFieldKind(field.instruction)));
|
|
125
|
+
const supportedBodyFields = bodyFields.filter((field)=>supportedBodyField(field, bookmarkNames));
|
|
126
|
+
const unsupportedBodyFields = bodyFields.filter((field)=>!supportedBodyField(field, bookmarkNames));
|
|
127
|
+
const editableBodyFields = supportedBodyFields.filter(docxFieldOccurrenceIsInlineEditable);
|
|
128
|
+
const hasUnsupportedFieldStructure = hasInvalidDocxFieldStructure(document, isSupportedBlockField) || bodyFields.some((field)=>!docxFieldOccurrenceIsInlineEditable(field));
|
|
127
129
|
return {
|
|
128
130
|
issues: [
|
|
129
131
|
...sequences.length ? [
|
|
@@ -138,10 +140,18 @@ function diagnoseDocxCaptions(document) {
|
|
|
138
140
|
{
|
|
139
141
|
code: 'docx.fields.body',
|
|
140
142
|
feature: 'Body fields',
|
|
141
|
-
message: 'PAGE, NUMPAGES, SECTION, SECTIONPAGES, DATE, and
|
|
143
|
+
message: 'PAGE, NUMPAGES, SECTION, SECTIONPAGES, NUMWORDS, NUMCHARS, DATE, TIME, and bookmark-backed PAGEREF fields remain live, editable body fields and update in preview, PDF, and native DOCX output.',
|
|
142
144
|
severity: 'info'
|
|
143
145
|
}
|
|
144
146
|
] : [],
|
|
147
|
+
...unsupportedBodyFields.length ? [
|
|
148
|
+
{
|
|
149
|
+
code: 'docx.fields.instructions',
|
|
150
|
+
feature: 'Field instructions',
|
|
151
|
+
message: 'Unsupported field switches or PAGEREF targets remain at their cached displayed value; only the bounded common instruction subset is made editable.',
|
|
152
|
+
severity: 'warning'
|
|
153
|
+
}
|
|
154
|
+
] : [],
|
|
145
155
|
...tableOfContentsFields.length ? [
|
|
146
156
|
{
|
|
147
157
|
code: 'docx.tableOfContents',
|
|
@@ -183,11 +193,16 @@ function captionBookmarkNames(fields) {
|
|
|
183
193
|
}
|
|
184
194
|
function isSupportedCaptionField(instruction, bookmarkNames) {
|
|
185
195
|
if (documentCitationTagsFromInstruction(instruction).length || /^\s*BIBLIOGRAPHY\b/i.test(instruction)) return true;
|
|
186
|
-
if (docxDocumentFieldKind(instruction)) return
|
|
196
|
+
if (docxDocumentFieldKind(instruction)) return supportedDocxDocumentFieldInstruction(instruction) && ('pageReference' !== docxDocumentFieldKind(instruction) || Boolean(docxDocumentFieldTarget(instruction) && bookmarkNames.has(docxDocumentFieldTarget(instruction)?.toLowerCase() ?? '')));
|
|
187
197
|
if (docxCaptionSequenceKind(instruction)) return true;
|
|
188
198
|
const target = docxBookmarkReferenceTarget(instruction);
|
|
189
199
|
return Boolean(target && bookmarkNames.has(target.toLowerCase()));
|
|
190
200
|
}
|
|
201
|
+
function supportedBodyField(field, bookmarkNames) {
|
|
202
|
+
if (!supportedDocxDocumentFieldInstruction(field.instruction)) return false;
|
|
203
|
+
const kind = docxDocumentFieldKind(field.instruction);
|
|
204
|
+
return 'pageReference' !== kind || Boolean(docxDocumentFieldTarget(field.instruction) && bookmarkNames.has(docxDocumentFieldTarget(field.instruction)?.toLowerCase() ?? ''));
|
|
205
|
+
}
|
|
191
206
|
function pairedBookmarkNames(document) {
|
|
192
207
|
const endIds = new Set(descendants(document, 'bookmarkEnd').map((bookmark)=>attribute(bookmark, 'id')?.trim() ?? ''));
|
|
193
208
|
return new Set(descendants(document, 'bookmarkStart').flatMap((bookmark)=>{
|