superdoc 1.0.0-beta.56 → 1.0.0-beta.58

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.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-DsYaXp0H.es.js → PdfViewer-BOtq_Mxx.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-CnvD--7P.cjs → PdfViewer-CPNlFudP.cjs} +1 -1
  3. package/dist/chunks/{index-DYnUncjo-Br0s3gQs.es.js → index-BWMksCRw-BE_kaq_r.es.js} +1 -1
  4. package/dist/chunks/{index-DYnUncjo-Uv8YzgRb.cjs → index-BWMksCRw-BtY5hIaC.cjs} +1 -1
  5. package/dist/chunks/{index-DF1aQt8V.es.js → index-Wqm4Y9w9.es.js} +3 -3
  6. package/dist/chunks/{index-BpBdSm3V.cjs → index-yDP_DAl6.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-BxMwj135.es.js → super-editor.es-BtTJyHJj.es.js} +270 -118
  8. package/dist/chunks/{super-editor.es-DkFw0sfq.cjs → super-editor.es-DsUuY-Pt.cjs} +270 -118
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DwC5XPQX.js → converter-w1IY5-V-.js} +70 -11
  11. package/dist/super-editor/chunks/{docx-zipper-BkCzC50U.js → docx-zipper-B7-XHg8m.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CoKNeouN.js → editor-CiTfe7Wr.js} +271 -117
  13. package/dist/super-editor/chunks/{index-DYnUncjo.js → index-BWMksCRw.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DUWk-Bwi.js → toolbar-yy1NR024.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +272 -120
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -40557,6 +40557,11 @@ const createDocumentJson = (docx, converter, editor) => {
40557
40557
  const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
40558
40558
  node.elements = processedNodes;
40559
40559
  const bodySectPr = node.elements?.find((n) => n.name === "w:sectPr");
40560
+ const bodySectPrElements = bodySectPr?.elements ?? [];
40561
+ if (converter) {
40562
+ converter.importedBodyHasHeaderRef = bodySectPrElements.some((el) => el?.name === "w:headerReference");
40563
+ converter.importedBodyHasFooterRef = bodySectPrElements.some((el) => el?.name === "w:footerReference");
40564
+ }
40560
40565
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
40561
40566
  const content = pruneIgnoredNodes(contentElements);
40562
40567
  const comments = importCommentData({ docx, converter, editor });
@@ -41493,15 +41498,17 @@ function translateBodyNode(params2) {
41493
41498
  }
41494
41499
  sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
41495
41500
  if (params2.converter) {
41501
+ const canExportHeaderRef = params2.converter.importedBodyHasHeaderRef || params2.converter.headerFooterModified;
41502
+ const canExportFooterRef = params2.converter.importedBodyHasFooterRef || params2.converter.headerFooterModified;
41496
41503
  const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
41497
41504
  const hasDefaultHeader = params2.converter.headerIds?.default;
41498
- if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
41505
+ if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter && canExportHeaderRef) {
41499
41506
  const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
41500
41507
  sectPr.elements.push(defaultHeader);
41501
41508
  }
41502
41509
  const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
41503
41510
  const hasDefaultFooter = params2.converter.footerIds?.default;
41504
- if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
41511
+ if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter && canExportFooterRef) {
41505
41512
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
41506
41513
  sectPr.elements.push(defaultFooter);
41507
41514
  }
@@ -41728,24 +41735,32 @@ generateXml_fn = function(node) {
41728
41735
  const textContent2 = (elements || []).map((child) => typeof child?.text === "string" ? child.text : "").join("");
41729
41736
  tags.push(__privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, textContent2));
41730
41737
  } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
41731
- try {
41732
- let text = String(elements[0].text);
41738
+ if (elements.length === 0) {
41739
+ console.error(`${name} element has no child elements. Expected text node. Element will be self-closing.`);
41740
+ } else if (elements[0] == null || typeof elements[0].text !== "string") {
41741
+ console.error(
41742
+ `${name} element's first child is missing or does not have a valid text property. Received: ${JSON.stringify(elements[0])}. Pushing empty string to maintain XML structure.`
41743
+ );
41744
+ tags.push("");
41745
+ } else {
41746
+ let text = elements[0].text.replace(/\[\[sdspace\]\]/g, "");
41733
41747
  text = __privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, text);
41734
41748
  tags.push(text);
41735
- } catch (error) {
41736
- console.error("Text element does not contain valid string:", error);
41737
41749
  }
41738
41750
  } else {
41739
41751
  if (elements) {
41740
41752
  for (let child of elements) {
41741
41753
  const newElements = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, child);
41742
- if (!newElements) continue;
41754
+ if (!newElements) {
41755
+ continue;
41756
+ }
41743
41757
  if (typeof newElements === "string") {
41744
41758
  tags.push(newElements);
41745
41759
  continue;
41746
41760
  }
41747
41761
  const removeUndefined = newElements.filter((el) => {
41748
- return el !== "<undefined>" && el !== "</undefined>";
41762
+ const isUndefined = el === "<undefined>" || el === "</undefined>";
41763
+ return !isUndefined;
41749
41764
  });
41750
41765
  tags.push(...removeUndefined);
41751
41766
  }
@@ -41936,7 +41951,9 @@ const getLargestRelationshipId = (relationships = []) => {
41936
41951
  return numericIds.length ? Math.max(...numericIds) : 0;
41937
41952
  };
41938
41953
  const mergeRelationshipElements = (existingRelationships = [], newRelationships = []) => {
41939
- if (!newRelationships?.length) return existingRelationships;
41954
+ if (!newRelationships?.length) {
41955
+ return existingRelationships;
41956
+ }
41940
41957
  let largestId = getLargestRelationshipId(existingRelationships);
41941
41958
  const seenIds = new Set(existingRelationships.map((rel) => rel?.attributes?.Id).filter(Boolean));
41942
41959
  for (const rel of newRelationships) {
@@ -41970,7 +41987,8 @@ const mergeRelationshipElements = (existingRelationships = [], newRelationships
41970
41987
  seenIds.add(attributes.Id);
41971
41988
  additions.push(rel);
41972
41989
  });
41973
- return additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41990
+ const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41991
+ return result;
41974
41992
  };
41975
41993
  const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
41976
41994
  swiss: "Arial, sans-serif",
@@ -42043,6 +42061,9 @@ const _SuperConverter = class _SuperConverter2 {
42043
42061
  this.footers = {};
42044
42062
  this.footerIds = { default: null, even: null, odd: null, first: null };
42045
42063
  this.footerEditors = [];
42064
+ this.importedBodyHasHeaderRef = false;
42065
+ this.importedBodyHasFooterRef = false;
42066
+ this.headerFooterModified = false;
42046
42067
  this.linkedStyles = [];
42047
42068
  this.json = params2?.json;
42048
42069
  this.tagsNotInSchema = ["w:body"];
@@ -42185,7 +42206,7 @@ const _SuperConverter = class _SuperConverter2 {
42185
42206
  static getStoredSuperdocVersion(docx) {
42186
42207
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42187
42208
  }
42188
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.56") {
42209
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.58") {
42189
42210
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42190
42211
  }
42191
42212
  /**
@@ -42576,6 +42597,7 @@ const _SuperConverter = class _SuperConverter2 {
42576
42597
  if (!this.headerIds.ids.includes(rId)) {
42577
42598
  this.headerIds.ids.push(rId);
42578
42599
  }
42600
+ this.headerFooterModified = true;
42579
42601
  this.documentModified = true;
42580
42602
  return rId;
42581
42603
  }
@@ -42629,6 +42651,7 @@ const _SuperConverter = class _SuperConverter2 {
42629
42651
  if (!this.footerIds.ids.includes(rId)) {
42630
42652
  this.footerIds.ids.push(rId);
42631
42653
  }
42654
+ this.headerFooterModified = true;
42632
42655
  this.documentModified = true;
42633
42656
  return rId;
42634
42657
  }
@@ -45495,7 +45518,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45495
45518
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45496
45519
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45497
45520
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45498
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45521
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45499
45522
  var GOOD_LEAF_SIZE = 200;
45500
45523
  var RopeSequence = function RopeSequence2() {
45501
45524
  };
@@ -58976,7 +58999,12 @@ function processRelationships(root2, convertedXml, results) {
58976
58999
  }
58977
59000
  }
58978
59001
  if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
58979
- const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
59002
+ let likelyPath;
59003
+ if (target.startsWith("../")) {
59004
+ likelyPath = target.replace(/^\.\.\//, "");
59005
+ } else {
59006
+ likelyPath = `word/${target.replace(/^\.?\//, "")}`;
59007
+ }
58980
59008
  if (!(likelyPath in convertedXml)) {
58981
59009
  if (!isImageType(type2)) {
58982
59010
  results.push(`Removed relationship ${id} with missing target: ${target}`);
@@ -59367,7 +59395,7 @@ const isHeadless = (editor) => {
59367
59395
  const shouldSkipNodeView = (editor) => {
59368
59396
  return isHeadless(editor);
59369
59397
  };
59370
- const summaryVersion = "1.0.0-beta.56";
59398
+ const summaryVersion = "1.0.0-beta.58";
59371
59399
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59372
59400
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59373
59401
  function mapAttributes(attrs) {
@@ -60156,7 +60184,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60156
60184
  { default: remarkStringify },
60157
60185
  { default: remarkGfm }
60158
60186
  ] = await Promise.all([
60159
- Promise.resolve().then(() => require("./index-DYnUncjo-Uv8YzgRb.cjs")),
60187
+ Promise.resolve().then(() => require("./index-BWMksCRw-BtY5hIaC.cjs")),
60160
60188
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60161
60189
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60162
60190
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60361,7 +60389,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60361
60389
  * Process collaboration migrations
60362
60390
  */
60363
60391
  processCollaborationMigrations() {
60364
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.56");
60392
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.58");
60365
60393
  if (!this.options.ydoc) return;
60366
60394
  const metaMap = this.options.ydoc.getMap("meta");
60367
60395
  let docVersion = metaMap.get("version");
@@ -62837,6 +62865,7 @@ const normalizeAlignment = (value) => {
62837
62865
  case "center":
62838
62866
  case "right":
62839
62867
  case "justify":
62868
+ case "left":
62840
62869
  return value;
62841
62870
  case "both":
62842
62871
  case "distribute":
@@ -72392,9 +72421,11 @@ const _DomPainter = class _DomPainter2 {
72392
72421
  const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
72393
72422
  const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
72394
72423
  if (!isListFirstLine) {
72395
- if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
72396
- const adjustedPadding = paraIndentLeft + firstLineOffset;
72397
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
72424
+ if (hasExplicitSegmentPositioning) {
72425
+ if (isFirstLine && firstLineOffset !== 0) {
72426
+ const adjustedPadding = paraIndentLeft + firstLineOffset;
72427
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
72428
+ }
72398
72429
  } else if (paraIndentLeft) {
72399
72430
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
72400
72431
  }
@@ -73825,6 +73856,13 @@ const _DomPainter = class _DomPainter2 {
73825
73856
  }
73826
73857
  }
73827
73858
  if (hasExplicitPositioning && line.segments) {
73859
+ const paraIndent = block.attrs?.indent;
73860
+ const indentLeft = paraIndent?.left ?? 0;
73861
+ const firstLine = paraIndent?.firstLine ?? 0;
73862
+ const hanging = paraIndent?.hanging ?? 0;
73863
+ const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
73864
+ const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
73865
+ const indentOffset = indentLeft + firstLineOffsetForCumX;
73828
73866
  let cumulativeX = 0;
73829
73867
  const segmentsByRun = /* @__PURE__ */ new Map();
73830
73868
  line.segments.forEach((segment) => {
@@ -73856,7 +73894,7 @@ const _DomPainter = class _DomPainter2 {
73856
73894
  const actualTabWidth = tabEndX - tabStartX;
73857
73895
  const tabEl = this.doc.createElement("span");
73858
73896
  tabEl.style.position = "absolute";
73859
- tabEl.style.left = `${tabStartX}px`;
73897
+ tabEl.style.left = `${tabStartX + indentOffset}px`;
73860
73898
  tabEl.style.top = "0px";
73861
73899
  tabEl.style.width = `${actualTabWidth}px`;
73862
73900
  tabEl.style.height = `${line.lineHeight}px`;
@@ -73887,12 +73925,13 @@ const _DomPainter = class _DomPainter2 {
73887
73925
  elem.setAttribute("styleid", styleId);
73888
73926
  }
73889
73927
  const runSegments2 = segmentsByRun.get(runIndex);
73890
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73928
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73929
+ const segX = baseSegX + indentOffset;
73891
73930
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
73892
73931
  elem.style.position = "absolute";
73893
73932
  elem.style.left = `${segX}px`;
73894
73933
  el.appendChild(elem);
73895
- cumulativeX = segX + segWidth;
73934
+ cumulativeX = baseSegX + segWidth;
73896
73935
  }
73897
73936
  continue;
73898
73937
  }
@@ -73909,12 +73948,13 @@ const _DomPainter = class _DomPainter2 {
73909
73948
  elem.setAttribute("styleid", styleId);
73910
73949
  }
73911
73950
  const runSegments2 = segmentsByRun.get(runIndex);
73912
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73951
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73952
+ const segX = baseSegX + indentOffset;
73913
73953
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
73914
73954
  elem.style.position = "absolute";
73915
73955
  elem.style.left = `${segX}px`;
73916
73956
  el.appendChild(elem);
73917
- cumulativeX = segX + segWidth;
73957
+ cumulativeX = baseSegX + segWidth;
73918
73958
  }
73919
73959
  continue;
73920
73960
  }
@@ -73944,7 +73984,8 @@ const _DomPainter = class _DomPainter2 {
73944
73984
  if (styleId) {
73945
73985
  elem.setAttribute("styleid", styleId);
73946
73986
  }
73947
- const xPos = segment.x !== void 0 ? segment.x : cumulativeX;
73987
+ const baseX = segment.x !== void 0 ? segment.x : cumulativeX;
73988
+ const xPos = baseX + indentOffset;
73948
73989
  elem.style.position = "absolute";
73949
73990
  elem.style.left = `${xPos}px`;
73950
73991
  el.appendChild(elem);
@@ -73958,7 +73999,7 @@ const _DomPainter = class _DomPainter2 {
73958
73999
  width = measureEl.offsetWidth;
73959
74000
  this.doc.body.removeChild(measureEl);
73960
74001
  }
73961
- cumulativeX = xPos + width;
74002
+ cumulativeX = baseX + width;
73962
74003
  }
73963
74004
  });
73964
74005
  }
@@ -75334,7 +75375,7 @@ const defaultMultiSectionIdentifier = () => ({
75334
75375
  sectionFooterIds: /* @__PURE__ */ new Map(),
75335
75376
  sectionTitlePg: /* @__PURE__ */ new Map()
75336
75377
  });
75337
- function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75378
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2, converterIds) {
75338
75379
  const identifier = defaultMultiSectionIdentifier();
75339
75380
  identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
75340
75381
  identifier.sectionCount = sectionMetadata.length;
@@ -75369,6 +75410,18 @@ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75369
75410
  identifier.footerIds = { ...section0Footers };
75370
75411
  }
75371
75412
  identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
75413
+ if (converterIds?.headerIds) {
75414
+ identifier.headerIds.default = identifier.headerIds.default ?? converterIds.headerIds.default ?? null;
75415
+ identifier.headerIds.first = identifier.headerIds.first ?? converterIds.headerIds.first ?? null;
75416
+ identifier.headerIds.even = identifier.headerIds.even ?? converterIds.headerIds.even ?? null;
75417
+ identifier.headerIds.odd = identifier.headerIds.odd ?? converterIds.headerIds.odd ?? null;
75418
+ }
75419
+ if (converterIds?.footerIds) {
75420
+ identifier.footerIds.default = identifier.footerIds.default ?? converterIds.footerIds.default ?? null;
75421
+ identifier.footerIds.first = identifier.footerIds.first ?? converterIds.footerIds.first ?? null;
75422
+ identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
75423
+ identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
75424
+ }
75372
75425
  return identifier;
75373
75426
  }
75374
75427
  function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
@@ -76348,6 +76401,32 @@ function layoutDrawingBlock({
76348
76401
  state2.page.fragments.push(fragment);
76349
76402
  state2.cursorY += requiredHeight;
76350
76403
  }
76404
+ function getTableIndentWidth(attrs) {
76405
+ if (!attrs) {
76406
+ return 0;
76407
+ }
76408
+ const tableIndent = attrs.tableIndent;
76409
+ if (!tableIndent || typeof tableIndent !== "object") {
76410
+ return 0;
76411
+ }
76412
+ const width = tableIndent.width;
76413
+ if (width === void 0 || width === null) {
76414
+ return 0;
76415
+ }
76416
+ if (typeof width !== "number") {
76417
+ return 0;
76418
+ }
76419
+ if (!Number.isFinite(width)) {
76420
+ return 0;
76421
+ }
76422
+ return width;
76423
+ }
76424
+ function applyTableIndent(x2, width, indent) {
76425
+ return {
76426
+ x: x2 + indent,
76427
+ width: Math.max(0, width - indent)
76428
+ };
76429
+ }
76351
76430
  function calculateColumnMinWidth(columnIndex, measure) {
76352
76431
  const DEFAULT_MIN_WIDTH = 25;
76353
76432
  const measuredWidth = measure.columnWidths[columnIndex] || DEFAULT_MIN_WIDTH;
@@ -76562,14 +76641,18 @@ function layoutMonolithicTable(context) {
76562
76641
  columnBoundaries: generateColumnBoundaries(context.measure),
76563
76642
  coordinateSystem: "fragment"
76564
76643
  };
76644
+ const tableIndent = getTableIndentWidth(context.block.attrs);
76645
+ const baseX = context.columnX(state2.columnIndex);
76646
+ const baseWidth = Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth);
76647
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76565
76648
  const fragment = {
76566
76649
  kind: "table",
76567
76650
  blockId: context.block.id,
76568
76651
  fromRow: 0,
76569
76652
  toRow: context.block.rows.length,
76570
- x: context.columnX(state2.columnIndex),
76653
+ x: x2,
76571
76654
  y: state2.cursorY,
76572
- width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
76655
+ width,
76573
76656
  height,
76574
76657
  metadata
76575
76658
  };
@@ -76636,14 +76719,18 @@ function layoutTableBlock({
76636
76719
  columnBoundaries: generateColumnBoundaries(measure),
76637
76720
  coordinateSystem: "fragment"
76638
76721
  };
76722
+ const tableIndent = getTableIndentWidth(block.attrs);
76723
+ const baseX = columnX(state2.columnIndex);
76724
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
76725
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76639
76726
  const fragment = {
76640
76727
  kind: "table",
76641
76728
  blockId: block.id,
76642
76729
  fromRow: 0,
76643
76730
  toRow: 0,
76644
- x: columnX(state2.columnIndex),
76731
+ x: x2,
76645
76732
  y: state2.cursorY,
76646
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76733
+ width,
76647
76734
  height,
76648
76735
  metadata
76649
76736
  };
@@ -76691,14 +76778,18 @@ function layoutTableBlock({
76691
76778
  });
76692
76779
  const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
76693
76780
  if (fragmentHeight2 > 0 && madeProgress) {
76781
+ const tableIndent2 = getTableIndentWidth(block.attrs);
76782
+ const baseX2 = columnX(state2.columnIndex);
76783
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
76784
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
76694
76785
  const fragment2 = {
76695
76786
  kind: "table",
76696
76787
  blockId: block.id,
76697
76788
  fromRow: rowIndex,
76698
76789
  toRow: rowIndex + 1,
76699
- x: columnX(state2.columnIndex),
76790
+ x: x22,
76700
76791
  y: state2.cursorY,
76701
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76792
+ width: width2,
76702
76793
  height: fragmentHeight2,
76703
76794
  continuesFromPrev: true,
76704
76795
  continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
@@ -76731,14 +76822,18 @@ function layoutTableBlock({
76731
76822
  const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
76732
76823
  const forcedEndRow = bodyStartRow + 1;
76733
76824
  const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
76825
+ const tableIndent2 = getTableIndentWidth(block.attrs);
76826
+ const baseX2 = columnX(state2.columnIndex);
76827
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
76828
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
76734
76829
  const fragment2 = {
76735
76830
  kind: "table",
76736
76831
  blockId: block.id,
76737
76832
  fromRow: bodyStartRow,
76738
76833
  toRow: forcedEndRow,
76739
- x: columnX(state2.columnIndex),
76834
+ x: x22,
76740
76835
  y: state2.cursorY,
76741
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76836
+ width: width2,
76742
76837
  height: fragmentHeight2,
76743
76838
  continuesFromPrev: isTableContinuation,
76744
76839
  continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
@@ -76762,14 +76857,18 @@ function layoutTableBlock({
76762
76857
  measure
76763
76858
  );
76764
76859
  }
76860
+ const tableIndent = getTableIndentWidth(block.attrs);
76861
+ const baseX = columnX(state2.columnIndex);
76862
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
76863
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76765
76864
  const fragment = {
76766
76865
  kind: "table",
76767
76866
  blockId: block.id,
76768
76867
  fromRow: bodyStartRow,
76769
76868
  toRow: endRow,
76770
- x: columnX(state2.columnIndex),
76869
+ x: x2,
76771
76870
  y: state2.cursorY,
76772
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76871
+ width,
76773
76872
  height: fragmentHeight,
76774
76873
  continuesFromPrev: isTableContinuation,
76775
76874
  continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
@@ -81557,7 +81656,15 @@ async function measureParagraphBlock(block, maxWidth) {
81557
81656
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
81558
81657
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81559
81658
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81560
- appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, segmentStartX);
81659
+ const useExplicitXHere = wordIndex === 0 && segmentStartX !== void 0;
81660
+ appendSegment(
81661
+ currentLine.segments,
81662
+ runIndex,
81663
+ wordStartChar,
81664
+ wordEndNoSpace,
81665
+ wordOnlyWidth,
81666
+ useExplicitXHere ? segmentStartX : void 0
81667
+ );
81561
81668
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81562
81669
  const completedLine = { ...currentLine, ...metrics };
81563
81670
  addBarTabsToLine(completedLine);
@@ -82281,6 +82388,9 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
82281
82388
  }
82282
82389
  mainEditor.converter[`${type2}s`][sectionId] = updatedData;
82283
82390
  mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
82391
+ if (editor.docChanged && mainEditor.converter) {
82392
+ mainEditor.converter.headerFooterModified = true;
82393
+ }
82284
82394
  await updateYdocDocxData(mainEditor);
82285
82395
  };
82286
82396
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -82562,17 +82672,20 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
82562
82672
  * ```
82563
82673
  */
82564
82674
  getDocumentJson(descriptor) {
82565
- if (!descriptor?.id) return null;
82675
+ if (!descriptor?.id) {
82676
+ return null;
82677
+ }
82566
82678
  const liveEntry = __privateGet$1(this, _editorEntries).get(descriptor.id);
82567
82679
  if (liveEntry) {
82568
82680
  try {
82569
- const json = liveEntry.editor.getJSON?.();
82570
- return json;
82681
+ return liveEntry.editor.getJSON?.();
82571
82682
  } catch {
82572
82683
  }
82573
82684
  }
82574
82685
  const collections = __privateGet$1(this, _collections);
82575
- if (!collections) return null;
82686
+ if (!collections) {
82687
+ return null;
82688
+ }
82576
82689
  if (descriptor.kind === "header") {
82577
82690
  return collections.headers?.[descriptor.id] ?? null;
82578
82691
  }
@@ -82958,7 +83071,9 @@ class HeaderFooterLayoutAdapter {
82958
83071
  */
82959
83072
  getBatch(kind) {
82960
83073
  const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
82961
- if (!descriptors.length) return void 0;
83074
+ if (!descriptors.length) {
83075
+ return void 0;
83076
+ }
82962
83077
  const batch = {};
82963
83078
  let hasBlocks = false;
82964
83079
  descriptors.forEach((descriptor) => {
@@ -83191,13 +83306,7 @@ class EditorOverlayManager {
83191
83306
  showEditingOverlay(pageElement, region, zoom) {
83192
83307
  try {
83193
83308
  const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
83194
- if (!decorationContainer) {
83195
- return {
83196
- success: false,
83197
- reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
83198
- };
83199
- }
83200
- const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
83309
+ const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind, decorationContainer);
83201
83310
  if (!editorHost) {
83202
83311
  return {
83203
83312
  success: false,
@@ -83205,7 +83314,9 @@ class EditorOverlayManager {
83205
83314
  };
83206
83315
  }
83207
83316
  __privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
83208
- decorationContainer.style.visibility = "hidden";
83317
+ if (decorationContainer) {
83318
+ decorationContainer.style.visibility = "hidden";
83319
+ }
83209
83320
  editorHost.style.visibility = "visible";
83210
83321
  editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
83211
83322
  if (region.kind === "footer") {
@@ -83217,7 +83328,7 @@ class EditorOverlayManager {
83217
83328
  }
83218
83329
  }
83219
83330
  }
83220
- __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
83331
+ __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer, zoom);
83221
83332
  __privateSet(this, _activeEditorHost, editorHost);
83222
83333
  __privateSet(this, _activeDecorationContainer, decorationContainer);
83223
83334
  __privateSet(this, _activeRegion, region);
@@ -83335,7 +83446,7 @@ findDecorationContainer_fn = function(pageElement, kind) {
83335
83446
  const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
83336
83447
  return pageElement.querySelector(`.${className}`);
83337
83448
  };
83338
- ensureEditorHost_fn = function(pageElement, kind) {
83449
+ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
83339
83450
  const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
83340
83451
  let editorHost = pageElement.querySelector(`.${className}`);
83341
83452
  if (!editorHost) {
@@ -83350,34 +83461,44 @@ ensureEditorHost_fn = function(pageElement, kind) {
83350
83461
  overflow: "hidden",
83351
83462
  boxSizing: "border-box"
83352
83463
  });
83353
- const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
83354
- if (!decorationContainer) {
83355
- console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
83356
- return null;
83464
+ if (decorationContainer) {
83465
+ decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83466
+ } else {
83467
+ pageElement.appendChild(editorHost);
83357
83468
  }
83358
- decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83359
83469
  }
83360
83470
  return editorHost;
83361
83471
  };
83362
- positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
83363
- const decorationRect = decorationContainer.getBoundingClientRect();
83472
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
83364
83473
  const pageElement = editorHost.parentElement;
83365
83474
  if (!pageElement) {
83366
83475
  console.error("[EditorOverlayManager] Editor host has no parent element");
83367
83476
  return;
83368
83477
  }
83369
- const pageRect = pageElement.getBoundingClientRect();
83370
- const top2 = decorationRect.top - pageRect.top;
83371
- const left2 = decorationRect.left - pageRect.left;
83372
- const width = decorationRect.width;
83373
- const height = decorationRect.height;
83478
+ let top2;
83479
+ let left2;
83480
+ let width;
83481
+ let height;
83482
+ if (decorationContainer) {
83483
+ const decorationRect = decorationContainer.getBoundingClientRect();
83484
+ const pageRect = pageElement.getBoundingClientRect();
83485
+ top2 = decorationRect.top - pageRect.top;
83486
+ left2 = decorationRect.left - pageRect.left;
83487
+ width = decorationRect.width;
83488
+ height = decorationRect.height;
83489
+ } else {
83490
+ top2 = region.localY * zoom;
83491
+ left2 = region.localX * zoom;
83492
+ width = region.width * zoom;
83493
+ height = region.height * zoom;
83494
+ }
83374
83495
  Object.assign(editorHost.style, {
83375
83496
  top: `${top2}px`,
83376
83497
  left: `${left2}px`,
83377
83498
  width: `${width}px`,
83378
83499
  height: `${height}px`
83379
83500
  });
83380
- if (region.kind === "footer") {
83501
+ if (region.kind === "footer" && decorationContainer) {
83381
83502
  const fragment = decorationContainer.querySelector(".superdoc-fragment");
83382
83503
  if (fragment instanceof HTMLElement) {
83383
83504
  const fragmentTop = parseFloat(fragment.style.top) || 0;
@@ -83385,14 +83506,19 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom)
83385
83506
  }
83386
83507
  }
83387
83508
  };
83388
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
83509
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
83389
83510
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
83390
83511
  __privateSet(this, _borderLine, document.createElement("div"));
83391
83512
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
83392
- const decorationRect = decorationContainer.getBoundingClientRect();
83393
- const pageRect = pageElement.getBoundingClientRect();
83513
+ let topPosition;
83394
83514
  const isHeader = region.kind === "header";
83395
- const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83515
+ if (decorationContainer) {
83516
+ const decorationRect = decorationContainer.getBoundingClientRect();
83517
+ const pageRect = pageElement.getBoundingClientRect();
83518
+ topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83519
+ } else {
83520
+ topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
83521
+ }
83396
83522
  Object.assign(__privateGet$1(this, _borderLine).style, {
83397
83523
  position: "absolute",
83398
83524
  left: "0",
@@ -85998,7 +86124,10 @@ rerender_fn = async function() {
85998
86124
  }
85999
86125
  __privateSet(this, _sectionMetadata, sectionMetadata);
86000
86126
  const converter = __privateGet$1(this, _editor3).converter;
86001
- __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
86127
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
86128
+ headerIds: converter?.headerIds,
86129
+ footerIds: converter?.footerIds
86130
+ }));
86002
86131
  const anchorMap = __privateMethod$1(this, _PresentationEditor_instances, computeAnchorMap_fn).call(this, bookmarks, layout);
86003
86132
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
86004
86133
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
@@ -86436,41 +86565,71 @@ computeDecorationBox_fn = function(kind, pageMargins, pageHeight) {
86436
86565
  return { x: left2, width, height, offset: offset2 };
86437
86566
  }
86438
86567
  };
86568
+ computeExpectedSectionType_fn = function(kind, page, sectionFirstPageNumbers) {
86569
+ const sectionIndex = page.sectionIndex ?? 0;
86570
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
86571
+ const sectionPageNumber = typeof firstPageInSection === "number" ? page.number - firstPageInSection + 1 : page.number;
86572
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
86573
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier);
86574
+ let titlePgEnabled = false;
86575
+ let alternateHeaders = false;
86576
+ if (multiSectionId) {
86577
+ titlePgEnabled = multiSectionId.sectionTitlePg?.get(sectionIndex) ?? multiSectionId.titlePg;
86578
+ alternateHeaders = multiSectionId.alternateHeaders;
86579
+ } else if (legacyIdentifier) {
86580
+ titlePgEnabled = legacyIdentifier.titlePg;
86581
+ alternateHeaders = legacyIdentifier.alternateHeaders;
86582
+ }
86583
+ if (sectionPageNumber === 1 && titlePgEnabled) {
86584
+ return "first";
86585
+ }
86586
+ if (alternateHeaders) {
86587
+ return page.number % 2 === 0 ? "even" : "odd";
86588
+ }
86589
+ return "default";
86590
+ };
86439
86591
  rebuildHeaderFooterRegions_fn = function(layout) {
86440
86592
  __privateGet$1(this, _headerRegions).clear();
86441
86593
  __privateGet$1(this, _footerRegions).clear();
86442
86594
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
86443
86595
  if (pageHeight <= 0) return;
86596
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
86597
+ for (const p of layout.pages) {
86598
+ const idx = p.sectionIndex ?? 0;
86599
+ if (!sectionFirstPageNumbers.has(idx)) {
86600
+ sectionFirstPageNumbers.set(idx, p.number);
86601
+ }
86602
+ }
86444
86603
  layout.pages.forEach((page, pageIndex) => {
86445
86604
  var _a2, _b2;
86446
- const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, page.margins, page);
86447
- if (headerPayload?.hitRegion) {
86448
- __privateGet$1(this, _headerRegions).set(pageIndex, {
86449
- kind: "header",
86450
- headerId: headerPayload.headerId,
86451
- sectionType: headerPayload.sectionType,
86452
- pageIndex,
86453
- pageNumber: page.number,
86454
- localX: headerPayload.hitRegion.x ?? 0,
86455
- localY: headerPayload.hitRegion.y ?? 0,
86456
- width: headerPayload.hitRegion.width ?? headerPayload.box?.width ?? 0,
86457
- height: headerPayload.hitRegion.height ?? headerPayload.box?.height ?? 0
86458
- });
86459
- }
86460
- const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, page.margins, page);
86461
- if (footerPayload?.hitRegion) {
86462
- __privateGet$1(this, _footerRegions).set(pageIndex, {
86463
- kind: "footer",
86464
- headerId: footerPayload.headerId,
86465
- sectionType: footerPayload.sectionType,
86466
- pageIndex,
86467
- pageNumber: page.number,
86468
- localX: footerPayload.hitRegion.x ?? 0,
86469
- localY: footerPayload.hitRegion.y ?? 0,
86470
- width: footerPayload.hitRegion.width ?? footerPayload.box?.width ?? 0,
86471
- height: footerPayload.hitRegion.height ?? footerPayload.box?.height ?? 0
86472
- });
86473
- }
86605
+ const margins = page.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
86606
+ const actualPageHeight = page.size?.h ?? pageHeight;
86607
+ const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
86608
+ const headerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
86609
+ __privateGet$1(this, _headerRegions).set(pageIndex, {
86610
+ kind: "header",
86611
+ headerId: headerPayload?.headerId,
86612
+ sectionType: headerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "header", page, sectionFirstPageNumbers),
86613
+ pageIndex,
86614
+ pageNumber: page.number,
86615
+ localX: headerPayload?.hitRegion?.x ?? headerBox.x,
86616
+ localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
86617
+ width: headerPayload?.hitRegion?.width ?? headerBox.width,
86618
+ height: headerPayload?.hitRegion?.height ?? headerBox.height
86619
+ });
86620
+ const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, margins, page);
86621
+ const footerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "footer", margins, actualPageHeight);
86622
+ __privateGet$1(this, _footerRegions).set(pageIndex, {
86623
+ kind: "footer",
86624
+ headerId: footerPayload?.headerId,
86625
+ sectionType: footerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "footer", page, sectionFirstPageNumbers),
86626
+ pageIndex,
86627
+ pageNumber: page.number,
86628
+ localX: footerPayload?.hitRegion?.x ?? footerBox.x,
86629
+ localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
86630
+ width: footerPayload?.hitRegion?.width ?? footerBox.width,
86631
+ height: footerPayload?.hitRegion?.height ?? footerBox.height
86632
+ });
86474
86633
  });
86475
86634
  };
86476
86635
  hitTestHeaderFooterRegion_fn = function(x2, y2) {
@@ -86660,6 +86819,7 @@ enterHeaderFooterMode_fn = async function(region) {
86660
86819
  };
86661
86820
  exitHeaderFooterMode_fn = function() {
86662
86821
  if (__privateGet$1(this, _session).mode === "body") return;
86822
+ const editedHeaderId = __privateGet$1(this, _session).headerId;
86663
86823
  if (__privateGet$1(this, _activeHeaderFooterEditor)) {
86664
86824
  __privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
86665
86825
  __privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
@@ -86671,6 +86831,12 @@ exitHeaderFooterMode_fn = function() {
86671
86831
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
86672
86832
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
86673
86833
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
86834
+ if (editedHeaderId) {
86835
+ __privateGet$1(this, _headerFooterAdapter)?.invalidate(editedHeaderId);
86836
+ }
86837
+ __privateGet$1(this, _headerFooterManager)?.refresh();
86838
+ __privateSet(this, _pendingDocChange, true);
86839
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
86674
86840
  __privateGet$1(this, _editor3).view?.focus();
86675
86841
  };
86676
86842
  getActiveDomTarget_fn = function() {
@@ -86766,29 +86932,15 @@ resolveDescriptorForRegion_fn = function(region) {
86766
86932
  createDefaultHeaderFooter_fn = function(region) {
86767
86933
  const converter = __privateGet$1(this, _editor3).converter;
86768
86934
  if (!converter) {
86769
- console.error("[PresentationEditor] Converter not available for creating header/footer");
86770
86935
  return;
86771
86936
  }
86772
86937
  const variant = region.sectionType ?? "default";
86773
- try {
86774
- if (region.kind === "header") {
86775
- if (typeof converter.createDefaultHeader === "function") {
86776
- const headerId = converter.createDefaultHeader(variant);
86777
- console.log(`[PresentationEditor] Created default header: ${headerId}`);
86778
- } else {
86779
- console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
86780
- }
86781
- } else if (region.kind === "footer") {
86782
- if (typeof converter.createDefaultFooter === "function") {
86783
- const footerId = converter.createDefaultFooter(variant);
86784
- console.log(`[PresentationEditor] Created default footer: ${footerId}`);
86785
- } else {
86786
- console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
86787
- }
86788
- }
86789
- } catch (error) {
86790
- console.error("[PresentationEditor] Failed to create default header/footer:", error);
86938
+ if (region.kind === "header" && typeof converter.createDefaultHeader === "function") {
86939
+ converter.createDefaultHeader(variant);
86940
+ } else if (region.kind === "footer" && typeof converter.createDefaultFooter === "function") {
86941
+ converter.createDefaultFooter(variant);
86791
86942
  }
86943
+ __privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
86792
86944
  };
86793
86945
  getPageElement_fn = function(pageIndex) {
86794
86946
  if (!__privateGet$1(this, _painterHost)) return null;