oasis-editor 0.0.157 → 0.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OasisEditorApp-BfdBu3ui.js → OasisEditorApp-D8XC2a93.js} +268 -3
- package/dist/assets/{importDocxWorker-DpJa1l2G.js → importDocxWorker-CEVODY5C.js} +1 -1
- package/dist/core/model/types/runSdtAugmentation.d.ts +7 -0
- package/dist/core/model.d.ts +1 -9
- package/dist/export/docx/synchronizeBoundContentControls.d.ts +3 -0
- package/dist/export/docx/text/blocksXml.d.ts +0 -6
- package/dist/export/docx/text/inlineSdtXml.d.ts +8 -0
- package/dist/import/docx/runs/types.d.ts +3 -1
- package/dist/{index-DQLjp1z0.js → index-0LIU1rxH.js} +427 -366
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ooxml/word/customXmlBinding.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
3
3
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
4
|
-
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, q as assertNever, r as cloneRun, s as createSignal, t as createEditorStateFromDocument, u as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, v as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as stylesEqual, A as cloneStyle, B as createEditorStyledRun, C as cloneParagraphList, D as cloneParagraph, G as getParagraphLength, H as getActiveZone, I as getActiveSectionIndex, J as getParagraphs, K as normalizeSelection, L as positionToParagraphOffset, M as cloneParagraphs, N as paragraphOffsetToPosition, O as findParagraphIndex, P as createCollapsedSelection, Q as isSelectionCollapsed, R as MATH_OBJECT_REPLACEMENT, T as setValueStyle, U as setBooleanStyle, V as parseFontSizePtToPx, W as formatFontSizePt, X as setParagraphStyleValue, Y as createEditorParagraph, Z as cloneBlocks, _ as resolveDefaultParagraphStyleId, $ as findParagraphTablePathLocation, a0 as findParagraphLocation, a1 as resolveTablePath, a2 as buildTableCellLayout, a3 as PT_PER_PX, a4 as createEditorTableCell, a5 as createEditorTableRow, a6 as createEditorTable, a7 as clampPosition, a8 as PX_PER_POINT, a9 as underlineStyleToCssDecorationStyle, aa as resolveImageSrc, ab as listKindForTag, ac as isParagraphTag, ad as collectInlineRuns, ae as parseParagraphStyle, af as getRunImage, ag as InlineShell, ah as BalloonShell, ai as DocumentShell, aj as findParagraphTableLocation, ak as createMemo, al as getCaretRectFromSnapshot, am as getParagraphRectFromSnapshot, an as createComponent, ao as CaretOverlay, ap as Show, aq as createRenderEffect, ar as style, as as setStyleProperty, at as setAttribute, au as memo, av as template, aw as Button, ax as useI18n, ay as createEffect, az as TextField, aA as Dialog, aB as insert, aC as className, aD as Grid, aE as SelectField, aF as StatusText, aG as ColorField, aH as UNDERLINE_STYLE_OPTIONS, aI as Stack, aJ as For, aK as ToggleChip, aL as FormField, aM as Checkbox, aN as FieldGroup, aO as Tabs, aP as NumberField, aQ as parseNumber, aR as createStore, aS as reconcile, aT as RadioGroup, aU as Radio$1, aV as TextAreaField, aW as COMMON_SYMBOLS, aX as getRecentSymbols, aY as SYMBOL_CATEGORIES, aZ as rememberSymbol, a_ as delegateEvents, a$ as EMPTY_EDITOR_MATH_EXPRESSION, b0 as serializeLinearMath, b1 as parseLinearMath, b2 as Text, b3 as SurfaceButton, b4 as onMount, b5 as onCleanup, b6 as CheckIcon, b7 as use, b8 as PluginUiHost, b9 as OasisEditorEditor, ba as OasisBrandMark, bb as setPreciseFontPreference, bc as setWelcomeSeen, bd as enablePreciseFontMode, be as WORD_NS$6, bf as XMLSerializer, bg as DOMParser, bh as WORD14_NS, bi as mergeNestedExtensionMarkup, bj as resolveOpcRelationships, bk as parseOpcRelationships, bl as JSZip, bm as normalizeOpcPartPath, bn as OPC_CONTENT_TYPES_PATH, bo as getOpcRelationshipOwnerPath, bp as serializeOpcRelationships, bq as OPC_ROOT_RELATIONSHIPS_PATH, br as hashDocxPartBytes, bs as parseOpcContentTypes, bt as serializeOpcContentTypes, bu as mergeParagraphPropertiesXmlSource, bv as setEditorRunOoxmlSource, bw as mergeRunOoxmlSourceIntoGeneratedXml, bx as mergeTableCellPropertiesXmlSource, by as mergeTableRowPropertiesXmlSource, bz as mergeTablePropertiesXmlSource, bA as
|
|
4
|
+
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, q as assertNever, r as cloneRun, s as createSignal, t as createEditorStateFromDocument, u as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, v as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as stylesEqual, A as cloneStyle, B as createEditorStyledRun, C as cloneParagraphList, D as cloneParagraph, G as getParagraphLength, H as getActiveZone, I as getActiveSectionIndex, J as getParagraphs, K as normalizeSelection, L as positionToParagraphOffset, M as cloneParagraphs, N as paragraphOffsetToPosition, O as findParagraphIndex, P as createCollapsedSelection, Q as isSelectionCollapsed, R as MATH_OBJECT_REPLACEMENT, T as setValueStyle, U as setBooleanStyle, V as parseFontSizePtToPx, W as formatFontSizePt, X as setParagraphStyleValue, Y as createEditorParagraph, Z as cloneBlocks, _ as resolveDefaultParagraphStyleId, $ as findParagraphTablePathLocation, a0 as findParagraphLocation, a1 as resolveTablePath, a2 as buildTableCellLayout, a3 as PT_PER_PX, a4 as createEditorTableCell, a5 as createEditorTableRow, a6 as createEditorTable, a7 as clampPosition, a8 as PX_PER_POINT, a9 as underlineStyleToCssDecorationStyle, aa as resolveImageSrc, ab as listKindForTag, ac as isParagraphTag, ad as collectInlineRuns, ae as parseParagraphStyle, af as getRunImage, ag as InlineShell, ah as BalloonShell, ai as DocumentShell, aj as findParagraphTableLocation, ak as createMemo, al as getCaretRectFromSnapshot, am as getParagraphRectFromSnapshot, an as createComponent, ao as CaretOverlay, ap as Show, aq as createRenderEffect, ar as style, as as setStyleProperty, at as setAttribute, au as memo, av as template, aw as Button, ax as useI18n, ay as createEffect, az as TextField, aA as Dialog, aB as insert, aC as className, aD as Grid, aE as SelectField, aF as StatusText, aG as ColorField, aH as UNDERLINE_STYLE_OPTIONS, aI as Stack, aJ as For, aK as ToggleChip, aL as FormField, aM as Checkbox, aN as FieldGroup, aO as Tabs, aP as NumberField, aQ as parseNumber, aR as createStore, aS as reconcile, aT as RadioGroup, aU as Radio$1, aV as TextAreaField, aW as COMMON_SYMBOLS, aX as getRecentSymbols, aY as SYMBOL_CATEGORIES, aZ as rememberSymbol, a_ as delegateEvents, a$ as EMPTY_EDITOR_MATH_EXPRESSION, b0 as serializeLinearMath, b1 as parseLinearMath, b2 as Text, b3 as SurfaceButton, b4 as onMount, b5 as onCleanup, b6 as CheckIcon, b7 as use, b8 as PluginUiHost, b9 as OasisEditorEditor, ba as OasisBrandMark, bb as setPreciseFontPreference, bc as setWelcomeSeen, bd as enablePreciseFontMode, be as WORD_NS$6, bf as XMLSerializer, bg as DOMParser, bh as WORD14_NS, bi as mergeNestedExtensionMarkup, bj as resolveOpcRelationships, bk as parseOpcRelationships, bl as JSZip, bm as normalizeOpcPartPath, bn as OPC_CONTENT_TYPES_PATH, bo as getOpcRelationshipOwnerPath, bp as serializeOpcRelationships, bq as OPC_ROOT_RELATIONSHIPS_PATH, br as hashDocxPartBytes, bs as parseOpcContentTypes, bt as serializeOpcContentTypes, bu as mergeParagraphPropertiesXmlSource, bv as setEditorRunOoxmlSource, bw as mergeRunOoxmlSourceIntoGeneratedXml, bx as mergeTableCellPropertiesXmlSource, by as mergeTableRowPropertiesXmlSource, bz as mergeTablePropertiesXmlSource, bA as getDocumentSectionsCanonical, bB as exportEditorDocumentToDocxBlob, bC as exportEditorDocumentToDocx, bD as pxToPt$1, bE as resolveFloatingObjectRect, bF as getTextBoxFloatingGeometry, bG as getPresetPathSegments, bH as buildListLabels, bI as lineDashPatternPt, bJ as DEFAULT_FONT_SIZE_PX, bK as resolveGradientAxis, bL as isDoubleUnderlineStyle, bM as isWavyUnderlineStyle, bN as underlineStyleLineWidthPx, bO as WAVY_UNDERLINE_WAVELENGTH_PX, bP as WAVY_UNDERLINE_AMPLITUDE_PX, bQ as DOUBLE_UNDERLINE_OFFSET_PX, bR as underlineStyleDashArray, bS as resolveEffectiveParagraphStyle, bT as EMPHASIS_GLYPH, bU as parseHexColorToRgb255, bV as rgb255ToHex, bW as getImageFloatingGeometry, bX as resolveEffectiveTextStyleForParagraph, bY as textStyleToFontSizePt, bZ as mathDisplayText, b_ as TEXT_BASELINE_RATIO, b$ as resolveTextAlignmentBaselineOffset, c0 as resolveRenderedTextChar, c1 as resolveOpenTypeFeatureTags, c2 as isLowercaseSmallCapsChar, c3 as resolveDecorationLineY, c4 as DOUBLE_STRIKE_OFFSET_PX, c5 as resolveListLabel, c6 as getListLabelInset, c7 as getAlignedListLabelInset, c8 as getParagraphBorderInsets, c9 as buildSegmentTable, ca as buildCanvasTableLayout, cb as resolveCanvasTableWidth, cc as resolveFloatingTableRect, cd as paragraphBetweenBorderMatches, ce as normalizeFamily, cf as ROBOTO_FONT_FILES, cg as loadFontAsset, ch as getRemotePdfFontFaces, ci as OFFICE_COMPAT_FONT_FAMILIES, cj as BinaryReader, ck as buildSfnt, cl as defaultFontDecoderRegistry, cm as SfntFontProgram, cn as zlibSync, co as renumberImageCaptionsInDocument, cp as collectPdfFontFamilies, cq as outlineFrom, cr as getPageHeaderZoneTop, cs as getPageColumnRects, ct as findFootnoteReference, cu as resolveImporterForFile, cv as roundTo, cw as getDocumentParagraphsCanonical, cx as getDocumentParagraphs, cy as getImageCaptionText, cz as isImageCaptionParagraph, cA as updateImageCaptionParagraph, cB as createImageCaptionParagraph, cC as renumberImageCaptionParagraphs, cD as getCaptionSelectionOffset, cE as PX_PER_CM, cF as getDocumentPageSettings, cG as getTableCellContentWidthForParagraph, cH as layoutMetricsEpoch, cI as bumpLayoutMetricsEpoch, cJ as createCanvasLayoutSnapshotProvider, cK as on, cL as debounce, cM as unwrap, cN as perfTimer, cO as prepareDocumentFonts, cP as getRunTextBox, cQ as EMU_PER_PX, cR as createEditorDocument, cS as resolveResizedDimensions, cT as axisSignForDirection, cU as clamp$1, cV as MIN_RESIZE_SIZE_PX, cW as resolveTextBoxRenderHeight, cX as getToolbarStyleState, cY as VERTICAL_HIT_WEIGHT, cZ as getCachedCanvasImage, c_ as measureParagraphMinContentWidthPx, c$ as createSectionBoundaryParagraph, d0 as normalizePageSettings, d1 as DEFAULT_EDITOR_PAGE_SETTINGS, d2 as markStart, d3 as markEnd, d4 as getParagraphEntries, d5 as getParagraphById, d6 as createEditorFootnote, d7 as createFootnoteReferenceRun, d8 as renumberFootnotes, d9 as iterateFootnoteReferenceRuns, da as preciseFontModeVersion, db as isPreciseFontModeEnabled, dc as getRunFieldChar, dd as getRunFieldInstruction, de as getHeadingLevel, df as createEditorRun, dg as TWIPS_PER_INCH, dh as PX_PER_INCH, di as togglePreciseFontMode, dj as nextFontSizePt, dk as previousFontSizePt, dl as fontSizePtToPx, dm as resolveNamedTextStyle, dn as resolveNamedTableStyle, dp as resolveEffectiveTableStyle, dq as createDefaultToolbarPreset, dr as MenuRegistry, ds as createToolbarRegistry, dt as Editor, du as resolveCommandRef, dv as commandRefName, dw as createOasisEditorClient, dx as createEditorZoom, dy as startLongTaskObserver, dz as installGlobalReport, dA as applyStoredPreciseFontPreference, dB as getWelcomeSeen, dC as isLocalFontAccessSupported, dD as EDITOR_SCROLL_PADDING_PX, dE as Toolbar, dF as OasisEditorLoading, dG as I18nProvider, dH as createTranslator, dI as registerDomStatsSurface, dJ as createEditorLogger } from "./index-0LIU1rxH.js";
|
|
5
5
|
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
6
6
|
const {
|
|
7
7
|
pageIndex,
|
|
@@ -40621,12 +40621,277 @@ async function patchRebuiltDocxPreservingSource(document2, rebuiltBuffer) {
|
|
|
40621
40621
|
sourceAwareRebuiltBuffer
|
|
40622
40622
|
);
|
|
40623
40623
|
}
|
|
40624
|
+
const CUSTOM_XML_PROPS_RELATIONSHIP_SUFFIX = "/customXmlProps";
|
|
40625
|
+
const DATASTORE_NS = "http://schemas.openxmlformats.org/officeDocument/2006/customXml";
|
|
40626
|
+
function normalizeStoreItemId(value) {
|
|
40627
|
+
return value.trim().replace(/[{}]/g, "").toLowerCase();
|
|
40628
|
+
}
|
|
40629
|
+
function readStoreItemId(xml) {
|
|
40630
|
+
const document2 = new DOMParser().parseFromString(xml, "application/xml");
|
|
40631
|
+
const root = document2.documentElement;
|
|
40632
|
+
if (!root) return null;
|
|
40633
|
+
const itemId = root.getAttributeNS(DATASTORE_NS, "itemID") ?? root.getAttribute("ds:itemID") ?? root.getAttribute("itemID");
|
|
40634
|
+
return (itemId == null ? void 0 : itemId.trim()) || null;
|
|
40635
|
+
}
|
|
40636
|
+
function parsePrefixMappings(value) {
|
|
40637
|
+
const result = /* @__PURE__ */ new Map();
|
|
40638
|
+
if (!value) return result;
|
|
40639
|
+
const pattern = /xmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])(.*?)\2/g;
|
|
40640
|
+
for (const match of value.matchAll(pattern)) {
|
|
40641
|
+
result.set(match[1], match[3]);
|
|
40642
|
+
}
|
|
40643
|
+
return result;
|
|
40644
|
+
}
|
|
40645
|
+
function parseStep(step) {
|
|
40646
|
+
const match = /^(([^:\[]+):)?([^\[]+?)(?:\[(\d+)\])?$/.exec(step);
|
|
40647
|
+
if (!match) return null;
|
|
40648
|
+
const index = match[4] ? Number.parseInt(match[4], 10) : 1;
|
|
40649
|
+
if (!Number.isFinite(index) || index < 1) return null;
|
|
40650
|
+
return {
|
|
40651
|
+
...match[2] ? { prefix: match[2] } : {},
|
|
40652
|
+
localName: match[3],
|
|
40653
|
+
index
|
|
40654
|
+
};
|
|
40655
|
+
}
|
|
40656
|
+
function matchesExpandedName(element, prefix, localName2, namespaces) {
|
|
40657
|
+
if (element.localName !== localName2) return false;
|
|
40658
|
+
if (!prefix) return !element.namespaceURI;
|
|
40659
|
+
const namespaceUri = namespaces.get(prefix);
|
|
40660
|
+
return namespaceUri !== void 0 && element.namespaceURI === namespaceUri;
|
|
40661
|
+
}
|
|
40662
|
+
function childElements(element) {
|
|
40663
|
+
const children2 = [];
|
|
40664
|
+
for (let index = 0; index < element.childNodes.length; index += 1) {
|
|
40665
|
+
const child = element.childNodes[index];
|
|
40666
|
+
if ((child == null ? void 0 : child.nodeType) === child.ELEMENT_NODE) {
|
|
40667
|
+
children2.push(child);
|
|
40668
|
+
}
|
|
40669
|
+
}
|
|
40670
|
+
return children2;
|
|
40671
|
+
}
|
|
40672
|
+
function findStore(sourcePackage, storeItemId) {
|
|
40673
|
+
var _a;
|
|
40674
|
+
const wantedStoreItemId = normalizeStoreItemId(storeItemId);
|
|
40675
|
+
for (const part of Object.values(sourcePackage.parts)) {
|
|
40676
|
+
if (part.kind !== "xml" || !/^customXml\/item\d+\.xml$/i.test(part.path)) {
|
|
40677
|
+
continue;
|
|
40678
|
+
}
|
|
40679
|
+
const propsRelationship = (_a = part.relationships) == null ? void 0 : _a.find(
|
|
40680
|
+
(relationship) => relationship.targetMode !== "External" && relationship.type.endsWith(CUSTOM_XML_PROPS_RELATIONSHIP_SUFFIX) && relationship.resolvedTarget
|
|
40681
|
+
);
|
|
40682
|
+
const itemPropsPartPath = propsRelationship == null ? void 0 : propsRelationship.resolvedTarget;
|
|
40683
|
+
if (!itemPropsPartPath) continue;
|
|
40684
|
+
const itemPropsPart = sourcePackage.parts[itemPropsPartPath];
|
|
40685
|
+
if (!itemPropsPart || itemPropsPart.kind !== "xml") continue;
|
|
40686
|
+
const actualStoreItemId = readStoreItemId(itemPropsPart.data);
|
|
40687
|
+
if (!actualStoreItemId || normalizeStoreItemId(actualStoreItemId) !== wantedStoreItemId) {
|
|
40688
|
+
continue;
|
|
40689
|
+
}
|
|
40690
|
+
return {
|
|
40691
|
+
storeItemId: actualStoreItemId,
|
|
40692
|
+
itemPartPath: part.path,
|
|
40693
|
+
itemPropsPartPath,
|
|
40694
|
+
xml: part.data
|
|
40695
|
+
};
|
|
40696
|
+
}
|
|
40697
|
+
return null;
|
|
40698
|
+
}
|
|
40699
|
+
function locateBindingTarget(xml, xpath, namespaces) {
|
|
40700
|
+
var _a;
|
|
40701
|
+
const document2 = new DOMParser().parseFromString(xml, "application/xml");
|
|
40702
|
+
const root = document2.documentElement;
|
|
40703
|
+
if (!root) return null;
|
|
40704
|
+
const normalized = xpath.trim().replace(/\/text\(\)$/, "");
|
|
40705
|
+
if (!normalized.startsWith("/") || normalized.startsWith("//")) return null;
|
|
40706
|
+
const steps = normalized.split("/").filter(Boolean);
|
|
40707
|
+
if (steps.length === 0) return null;
|
|
40708
|
+
const attributeStep = ((_a = steps.at(-1)) == null ? void 0 : _a.startsWith("@")) ? steps.pop() : null;
|
|
40709
|
+
const first = parseStep(steps[0]);
|
|
40710
|
+
if (!first || first.index !== 1) return null;
|
|
40711
|
+
if (!matchesExpandedName(root, first.prefix, first.localName, namespaces)) {
|
|
40712
|
+
return null;
|
|
40713
|
+
}
|
|
40714
|
+
let current = root;
|
|
40715
|
+
for (let index = 1; index < steps.length; index += 1) {
|
|
40716
|
+
const step = parseStep(steps[index]);
|
|
40717
|
+
if (!step) return null;
|
|
40718
|
+
const candidates = childElements(current).filter(
|
|
40719
|
+
(child) => matchesExpandedName(child, step.prefix, step.localName, namespaces)
|
|
40720
|
+
);
|
|
40721
|
+
const candidate = candidates[step.index - 1];
|
|
40722
|
+
if (!candidate) return null;
|
|
40723
|
+
current = candidate;
|
|
40724
|
+
}
|
|
40725
|
+
if (!attributeStep) return { document: document2, element: current };
|
|
40726
|
+
const rawName = attributeStep.slice(1);
|
|
40727
|
+
const separator = rawName.indexOf(":");
|
|
40728
|
+
if (separator < 0) {
|
|
40729
|
+
return {
|
|
40730
|
+
document: document2,
|
|
40731
|
+
element: current,
|
|
40732
|
+
attribute: { localName: rawName, qualifiedName: rawName }
|
|
40733
|
+
};
|
|
40734
|
+
}
|
|
40735
|
+
const prefix = rawName.slice(0, separator);
|
|
40736
|
+
const localName2 = rawName.slice(separator + 1);
|
|
40737
|
+
const namespaceUri = namespaces.get(prefix);
|
|
40738
|
+
if (!namespaceUri) return null;
|
|
40739
|
+
return {
|
|
40740
|
+
document: document2,
|
|
40741
|
+
element: current,
|
|
40742
|
+
attribute: {
|
|
40743
|
+
namespaceUri,
|
|
40744
|
+
localName: localName2,
|
|
40745
|
+
qualifiedName: `${prefix}:${localName2}`
|
|
40746
|
+
}
|
|
40747
|
+
};
|
|
40748
|
+
}
|
|
40749
|
+
function writeCustomXmlBinding(sourcePackage, binding, value) {
|
|
40750
|
+
if (!sourcePackage || !(binding == null ? void 0 : binding.storeItemID) || !binding.xpath) return false;
|
|
40751
|
+
const store = findStore(sourcePackage, binding.storeItemID);
|
|
40752
|
+
if (!store) return false;
|
|
40753
|
+
const target = locateBindingTarget(
|
|
40754
|
+
store.xml,
|
|
40755
|
+
binding.xpath,
|
|
40756
|
+
parsePrefixMappings(binding.prefixMappings)
|
|
40757
|
+
);
|
|
40758
|
+
if (!target) return false;
|
|
40759
|
+
if (target.attribute) {
|
|
40760
|
+
if (target.attribute.namespaceUri) {
|
|
40761
|
+
target.element.setAttributeNS(
|
|
40762
|
+
target.attribute.namespaceUri,
|
|
40763
|
+
target.attribute.qualifiedName,
|
|
40764
|
+
value
|
|
40765
|
+
);
|
|
40766
|
+
} else {
|
|
40767
|
+
target.element.setAttribute(target.attribute.localName, value);
|
|
40768
|
+
}
|
|
40769
|
+
} else {
|
|
40770
|
+
if (childElements(target.element).length > 0) return false;
|
|
40771
|
+
while (target.element.firstChild) {
|
|
40772
|
+
target.element.removeChild(target.element.firstChild);
|
|
40773
|
+
}
|
|
40774
|
+
target.element.appendChild(target.document.createTextNode(value));
|
|
40775
|
+
}
|
|
40776
|
+
const part = sourcePackage.parts[store.itemPartPath];
|
|
40777
|
+
if (!part) return false;
|
|
40778
|
+
part.data = new XMLSerializer().serializeToString(target.document);
|
|
40779
|
+
return true;
|
|
40780
|
+
}
|
|
40781
|
+
function appendBoundControlText(controls, wrapper, text, separator) {
|
|
40782
|
+
if (!wrapper.sdtPr.dataBinding) return;
|
|
40783
|
+
const current = controls.get(wrapper.groupId);
|
|
40784
|
+
if (current) {
|
|
40785
|
+
current.value += `${separator}${text}`;
|
|
40786
|
+
} else {
|
|
40787
|
+
controls.set(wrapper.groupId, { wrapper, value: text });
|
|
40788
|
+
}
|
|
40789
|
+
}
|
|
40790
|
+
function collectBlockText(block) {
|
|
40791
|
+
if (block.type === "paragraph") return getParagraphText(block);
|
|
40792
|
+
const values = [];
|
|
40793
|
+
for (const row of block.rows) {
|
|
40794
|
+
for (const cell of row.cells) {
|
|
40795
|
+
for (const nested of cell.blocks) {
|
|
40796
|
+
const value = collectBlockText(nested);
|
|
40797
|
+
if (value) values.push(value);
|
|
40798
|
+
}
|
|
40799
|
+
}
|
|
40800
|
+
}
|
|
40801
|
+
return values.join("\n");
|
|
40802
|
+
}
|
|
40803
|
+
function collectInlineBoundControls(paragraph, controls) {
|
|
40804
|
+
for (const run of paragraph.runs) {
|
|
40805
|
+
for (const wrapper of run.sdtWrappers ?? []) {
|
|
40806
|
+
appendBoundControlText(controls, wrapper, run.text, "");
|
|
40807
|
+
}
|
|
40808
|
+
if (run.kind === "textBox") {
|
|
40809
|
+
collectBoundControlsFromBlocks(run.textBox.blocks, controls);
|
|
40810
|
+
}
|
|
40811
|
+
}
|
|
40812
|
+
}
|
|
40813
|
+
function collectBoundControlsFromBlocks(blocks, controls) {
|
|
40814
|
+
if (!blocks) return;
|
|
40815
|
+
for (const block of blocks) {
|
|
40816
|
+
const text = collectBlockText(block);
|
|
40817
|
+
for (const wrapper of block.sdtWrappers ?? []) {
|
|
40818
|
+
appendBoundControlText(controls, wrapper, text, "\n");
|
|
40819
|
+
}
|
|
40820
|
+
if (block.type === "paragraph") {
|
|
40821
|
+
collectInlineBoundControls(block, controls);
|
|
40822
|
+
} else {
|
|
40823
|
+
for (const row of block.rows) {
|
|
40824
|
+
for (const cell of row.cells) {
|
|
40825
|
+
collectBoundControlsFromBlocks(cell.blocks, controls);
|
|
40826
|
+
}
|
|
40827
|
+
}
|
|
40828
|
+
}
|
|
40829
|
+
}
|
|
40830
|
+
}
|
|
40831
|
+
function synchronizeBoundContentControls(document2) {
|
|
40832
|
+
if (!document2.sourcePackage) return 0;
|
|
40833
|
+
const controls = /* @__PURE__ */ new Map();
|
|
40834
|
+
for (const section of getDocumentSectionsCanonical(document2)) {
|
|
40835
|
+
collectBoundControlsFromBlocks(section.blocks, controls);
|
|
40836
|
+
collectBoundControlsFromBlocks(section.header, controls);
|
|
40837
|
+
collectBoundControlsFromBlocks(section.firstPageHeader, controls);
|
|
40838
|
+
collectBoundControlsFromBlocks(section.evenPageHeader, controls);
|
|
40839
|
+
collectBoundControlsFromBlocks(section.footer, controls);
|
|
40840
|
+
collectBoundControlsFromBlocks(section.firstPageFooter, controls);
|
|
40841
|
+
collectBoundControlsFromBlocks(section.evenPageFooter, controls);
|
|
40842
|
+
}
|
|
40843
|
+
let synchronized = 0;
|
|
40844
|
+
for (const { wrapper, value } of controls.values()) {
|
|
40845
|
+
const binding = wrapper.sdtPr.dataBinding;
|
|
40846
|
+
if (!binding) continue;
|
|
40847
|
+
if (writeCustomXmlBinding(document2.sourcePackage, binding, value)) {
|
|
40848
|
+
synchronized += 1;
|
|
40849
|
+
}
|
|
40850
|
+
}
|
|
40851
|
+
return synchronized;
|
|
40852
|
+
}
|
|
40853
|
+
function cloneSourcePackage(sourcePackage) {
|
|
40854
|
+
return {
|
|
40855
|
+
...sourcePackage,
|
|
40856
|
+
contentTypes: {
|
|
40857
|
+
defaults: { ...sourcePackage.contentTypes.defaults },
|
|
40858
|
+
overrides: { ...sourcePackage.contentTypes.overrides }
|
|
40859
|
+
},
|
|
40860
|
+
rootRelationships: sourcePackage.rootRelationships.map((relationship) => ({
|
|
40861
|
+
...relationship
|
|
40862
|
+
})),
|
|
40863
|
+
parts: Object.fromEntries(
|
|
40864
|
+
Object.entries(sourcePackage.parts).map(([path, part]) => [
|
|
40865
|
+
path,
|
|
40866
|
+
{
|
|
40867
|
+
...part,
|
|
40868
|
+
...part.relationships ? {
|
|
40869
|
+
relationships: part.relationships.map((relationship) => ({
|
|
40870
|
+
...relationship
|
|
40871
|
+
}))
|
|
40872
|
+
} : {}
|
|
40873
|
+
}
|
|
40874
|
+
])
|
|
40875
|
+
),
|
|
40876
|
+
...sourcePackage.diagnostics ? {
|
|
40877
|
+
diagnostics: sourcePackage.diagnostics.map((diagnostic) => ({
|
|
40878
|
+
...diagnostic
|
|
40879
|
+
}))
|
|
40880
|
+
} : {},
|
|
40881
|
+
...sourcePackage.rebuiltPartHashes ? { rebuiltPartHashes: { ...sourcePackage.rebuiltPartHashes } } : {}
|
|
40882
|
+
};
|
|
40883
|
+
}
|
|
40624
40884
|
async function exportEditorDocumentToDocxPreservingSource(document2) {
|
|
40625
40885
|
if (!document2.sourcePackage) {
|
|
40626
40886
|
return exportEditorDocumentToDocx(document2);
|
|
40627
40887
|
}
|
|
40628
|
-
const
|
|
40629
|
-
|
|
40888
|
+
const exportDocument = {
|
|
40889
|
+
...document2,
|
|
40890
|
+
sourcePackage: cloneSourcePackage(document2.sourcePackage)
|
|
40891
|
+
};
|
|
40892
|
+
synchronizeBoundContentControls(exportDocument);
|
|
40893
|
+
const rebuilt = await exportEditorDocumentToDocx(exportDocument);
|
|
40894
|
+
return patchRebuiltDocxPreservingSource(exportDocument, rebuilt);
|
|
40630
40895
|
}
|
|
40631
40896
|
async function exportEditorDocumentToDocxBlobPreservingSource(document2) {
|
|
40632
40897
|
if (!document2.sourcePackage) {
|