@harbour-enterprises/superdoc 1.0.0-beta.57 → 1.0.0-beta.59

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-DvAhx37Y.cjs → PdfViewer-Cqk3l90H.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BpJ5YJmq.es.js → PdfViewer-zpn99sVp.es.js} +1 -1
  3. package/dist/chunks/{index-BbXDEDIW.cjs → index-Cjipvbt7.cjs} +3 -3
  4. package/dist/chunks/{index-BE9w4viZ.es.js → index-DjmaOC4E.es.js} +3 -3
  5. package/dist/chunks/{index-D5IkZjf9-XnnWMFi7.cjs → index-p5nUefNA-BBn8gZoL.cjs} +1 -1
  6. package/dist/chunks/{index-D5IkZjf9-CPmfOXHq.es.js → index-p5nUefNA-uQGvl206.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-BY9i51n2.es.js → super-editor.es-B_aU9Ilo.es.js} +238 -98
  8. package/dist/chunks/{super-editor.es-BjELk3Xl.cjs → super-editor.es-jT-SK1Sx.cjs} +238 -98
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-Aoe_RSZD.js → converter-CGbieO55.js} +73 -12
  11. package/dist/super-editor/chunks/{docx-zipper-Ct68kitw.js → docx-zipper-BFro6vIZ.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-Dfqm3VkC.js → editor-D4VwHdPT.js} +236 -96
  13. package/dist/super-editor/chunks/{index-D5IkZjf9.js → index-p5nUefNA.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-Dj_HCM6i.js → toolbar-CxnmhVxL.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 +240 -100
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -40540,6 +40540,11 @@ const createDocumentJson = (docx, converter, editor) => {
40540
40540
  const { processedNodes } = preProcessNodesForFldChar(node.elements ?? [], docx);
40541
40541
  node.elements = processedNodes;
40542
40542
  const bodySectPr = node.elements?.find((n) => n.name === "w:sectPr");
40543
+ const bodySectPrElements = bodySectPr?.elements ?? [];
40544
+ if (converter) {
40545
+ converter.importedBodyHasHeaderRef = bodySectPrElements.some((el) => el?.name === "w:headerReference");
40546
+ converter.importedBodyHasFooterRef = bodySectPrElements.some((el) => el?.name === "w:footerReference");
40547
+ }
40543
40548
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
40544
40549
  const content = pruneIgnoredNodes(contentElements);
40545
40550
  const comments = importCommentData({ docx, converter, editor });
@@ -41476,15 +41481,17 @@ function translateBodyNode(params2) {
41476
41481
  }
41477
41482
  sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
41478
41483
  if (params2.converter) {
41484
+ const canExportHeaderRef = params2.converter.importedBodyHasHeaderRef || params2.converter.headerFooterModified;
41485
+ const canExportFooterRef = params2.converter.importedBodyHasFooterRef || params2.converter.headerFooterModified;
41479
41486
  const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
41480
41487
  const hasDefaultHeader = params2.converter.headerIds?.default;
41481
- if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
41488
+ if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter && canExportHeaderRef) {
41482
41489
  const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
41483
41490
  sectPr.elements.push(defaultHeader);
41484
41491
  }
41485
41492
  const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
41486
41493
  const hasDefaultFooter = params2.converter.footerIds?.default;
41487
- if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
41494
+ if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter && canExportFooterRef) {
41488
41495
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
41489
41496
  sectPr.elements.push(defaultFooter);
41490
41497
  }
@@ -41711,26 +41718,36 @@ generateXml_fn = function(node) {
41711
41718
  const textContent2 = (elements || []).map((child) => typeof child?.text === "string" ? child.text : "").join("");
41712
41719
  tags.push(__privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, textContent2));
41713
41720
  } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
41714
- try {
41715
- let text = String(elements[0].text);
41721
+ if (elements.length === 0) {
41722
+ console.error(`${name} element has no child elements. Expected text node. Element will be self-closing.`);
41723
+ } else if (elements[0] == null || typeof elements[0].text !== "string") {
41724
+ console.error(
41725
+ `${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.`
41726
+ );
41727
+ tags.push("");
41728
+ } else {
41729
+ let text = elements[0].text.replace(/\[\[sdspace\]\]/g, "");
41716
41730
  text = __privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, text);
41717
41731
  tags.push(text);
41718
- } catch (error) {
41719
- console.error("Text element does not contain valid string:", error);
41720
41732
  }
41721
41733
  } else {
41722
41734
  if (elements) {
41723
41735
  for (let child of elements) {
41724
41736
  const newElements = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, child);
41725
- if (!newElements) continue;
41737
+ if (!newElements) {
41738
+ continue;
41739
+ }
41726
41740
  if (typeof newElements === "string") {
41727
41741
  tags.push(newElements);
41728
41742
  continue;
41729
41743
  }
41730
41744
  const removeUndefined = newElements.filter((el) => {
41731
- return el !== "<undefined>" && el !== "</undefined>";
41745
+ const isUndefined = el === "<undefined>" || el === "</undefined>";
41746
+ return !isUndefined;
41732
41747
  });
41733
- tags.push(...removeUndefined);
41748
+ for (const element of removeUndefined) {
41749
+ tags.push(element);
41750
+ }
41734
41751
  }
41735
41752
  }
41736
41753
  }
@@ -41919,7 +41936,9 @@ const getLargestRelationshipId = (relationships = []) => {
41919
41936
  return numericIds.length ? Math.max(...numericIds) : 0;
41920
41937
  };
41921
41938
  const mergeRelationshipElements = (existingRelationships = [], newRelationships = []) => {
41922
- if (!newRelationships?.length) return existingRelationships;
41939
+ if (!newRelationships?.length) {
41940
+ return existingRelationships;
41941
+ }
41923
41942
  let largestId = getLargestRelationshipId(existingRelationships);
41924
41943
  const seenIds = new Set(existingRelationships.map((rel) => rel?.attributes?.Id).filter(Boolean));
41925
41944
  for (const rel of newRelationships) {
@@ -41953,7 +41972,8 @@ const mergeRelationshipElements = (existingRelationships = [], newRelationships
41953
41972
  seenIds.add(attributes.Id);
41954
41973
  additions.push(rel);
41955
41974
  });
41956
- return additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41975
+ const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41976
+ return result;
41957
41977
  };
41958
41978
  const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
41959
41979
  swiss: "Arial, sans-serif",
@@ -42026,6 +42046,9 @@ const _SuperConverter = class _SuperConverter2 {
42026
42046
  this.footers = {};
42027
42047
  this.footerIds = { default: null, even: null, odd: null, first: null };
42028
42048
  this.footerEditors = [];
42049
+ this.importedBodyHasHeaderRef = false;
42050
+ this.importedBodyHasFooterRef = false;
42051
+ this.headerFooterModified = false;
42029
42052
  this.linkedStyles = [];
42030
42053
  this.json = params2?.json;
42031
42054
  this.tagsNotInSchema = ["w:body"];
@@ -42168,7 +42191,7 @@ const _SuperConverter = class _SuperConverter2 {
42168
42191
  static getStoredSuperdocVersion(docx) {
42169
42192
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42170
42193
  }
42171
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.57") {
42194
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.59") {
42172
42195
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42173
42196
  }
42174
42197
  /**
@@ -42559,6 +42582,7 @@ const _SuperConverter = class _SuperConverter2 {
42559
42582
  if (!this.headerIds.ids.includes(rId)) {
42560
42583
  this.headerIds.ids.push(rId);
42561
42584
  }
42585
+ this.headerFooterModified = true;
42562
42586
  this.documentModified = true;
42563
42587
  return rId;
42564
42588
  }
@@ -42612,6 +42636,7 @@ const _SuperConverter = class _SuperConverter2 {
42612
42636
  if (!this.footerIds.ids.includes(rId)) {
42613
42637
  this.footerIds.ids.push(rId);
42614
42638
  }
42639
+ this.headerFooterModified = true;
42615
42640
  this.documentModified = true;
42616
42641
  return rId;
42617
42642
  }
@@ -45478,7 +45503,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45478
45503
  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);
45479
45504
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45480
45505
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45481
- 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;
45506
+ 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;
45482
45507
  var GOOD_LEAF_SIZE = 200;
45483
45508
  var RopeSequence = function RopeSequence2() {
45484
45509
  };
@@ -58959,7 +58984,12 @@ function processRelationships(root2, convertedXml, results) {
58959
58984
  }
58960
58985
  }
58961
58986
  if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
58962
- const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
58987
+ let likelyPath;
58988
+ if (target.startsWith("../")) {
58989
+ likelyPath = target.replace(/^\.\.\//, "");
58990
+ } else {
58991
+ likelyPath = `word/${target.replace(/^\.?\//, "")}`;
58992
+ }
58963
58993
  if (!(likelyPath in convertedXml)) {
58964
58994
  if (!isImageType(type2)) {
58965
58995
  results.push(`Removed relationship ${id} with missing target: ${target}`);
@@ -59350,7 +59380,7 @@ const isHeadless = (editor) => {
59350
59380
  const shouldSkipNodeView = (editor) => {
59351
59381
  return isHeadless(editor);
59352
59382
  };
59353
- const summaryVersion = "1.0.0-beta.57";
59383
+ const summaryVersion = "1.0.0-beta.59";
59354
59384
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59355
59385
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59356
59386
  function mapAttributes(attrs) {
@@ -60139,7 +60169,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60139
60169
  { default: remarkStringify },
60140
60170
  { default: remarkGfm }
60141
60171
  ] = await Promise.all([
60142
- import("./index-D5IkZjf9-CPmfOXHq.es.js"),
60172
+ import("./index-p5nUefNA-uQGvl206.es.js"),
60143
60173
  import("./index-DRCvimau-Cw339678.es.js"),
60144
60174
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60145
60175
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60344,7 +60374,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60344
60374
  * Process collaboration migrations
60345
60375
  */
60346
60376
  processCollaborationMigrations() {
60347
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.57");
60377
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.59");
60348
60378
  if (!this.options.ydoc) return;
60349
60379
  const metaMap = this.options.ydoc.getMap("meta");
60350
60380
  let docVersion = metaMap.get("version");
@@ -75330,7 +75360,7 @@ const defaultMultiSectionIdentifier = () => ({
75330
75360
  sectionFooterIds: /* @__PURE__ */ new Map(),
75331
75361
  sectionTitlePg: /* @__PURE__ */ new Map()
75332
75362
  });
75333
- function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75363
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2, converterIds) {
75334
75364
  const identifier = defaultMultiSectionIdentifier();
75335
75365
  identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
75336
75366
  identifier.sectionCount = sectionMetadata.length;
@@ -75365,6 +75395,18 @@ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75365
75395
  identifier.footerIds = { ...section0Footers };
75366
75396
  }
75367
75397
  identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
75398
+ if (converterIds?.headerIds) {
75399
+ identifier.headerIds.default = identifier.headerIds.default ?? converterIds.headerIds.default ?? null;
75400
+ identifier.headerIds.first = identifier.headerIds.first ?? converterIds.headerIds.first ?? null;
75401
+ identifier.headerIds.even = identifier.headerIds.even ?? converterIds.headerIds.even ?? null;
75402
+ identifier.headerIds.odd = identifier.headerIds.odd ?? converterIds.headerIds.odd ?? null;
75403
+ }
75404
+ if (converterIds?.footerIds) {
75405
+ identifier.footerIds.default = identifier.footerIds.default ?? converterIds.footerIds.default ?? null;
75406
+ identifier.footerIds.first = identifier.footerIds.first ?? converterIds.footerIds.first ?? null;
75407
+ identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
75408
+ identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
75409
+ }
75368
75410
  return identifier;
75369
75411
  }
75370
75412
  function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
@@ -81518,6 +81560,59 @@ async function measureParagraphBlock(block, maxWidth) {
81518
81560
  for (let segmentIndex = 0; segmentIndex < tabSegments.length; segmentIndex++) {
81519
81561
  const segment = tabSegments[segmentIndex];
81520
81562
  const isLastSegment = segmentIndex === tabSegments.length - 1;
81563
+ if (/^[ ]+$/.test(segment)) {
81564
+ const spacesLength = segment.length;
81565
+ const spacesStartChar = charPosInRun;
81566
+ const spacesEndChar = charPosInRun + spacesLength;
81567
+ const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
81568
+ if (!currentLine) {
81569
+ currentLine = {
81570
+ fromRun: runIndex,
81571
+ fromChar: spacesStartChar,
81572
+ toRun: runIndex,
81573
+ toChar: spacesEndChar,
81574
+ width: spacesWidth,
81575
+ maxFontSize: run2.fontSize,
81576
+ maxFontInfo: getFontInfoFromRun(run2),
81577
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
81578
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
81579
+ };
81580
+ } else {
81581
+ const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
81582
+ if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
81583
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81584
+ const completedLine = {
81585
+ ...currentLine,
81586
+ ...metrics
81587
+ };
81588
+ addBarTabsToLine(completedLine);
81589
+ lines.push(completedLine);
81590
+ tabStopCursor = 0;
81591
+ pendingTabAlignment = null;
81592
+ lastAppliedTabAlign = null;
81593
+ currentLine = {
81594
+ fromRun: runIndex,
81595
+ fromChar: spacesStartChar,
81596
+ toRun: runIndex,
81597
+ toChar: spacesEndChar,
81598
+ width: spacesWidth,
81599
+ maxFontSize: run2.fontSize,
81600
+ maxFontInfo: getFontInfoFromRun(run2),
81601
+ maxWidth: getEffectiveWidth(contentWidth),
81602
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
81603
+ };
81604
+ } else {
81605
+ currentLine.toRun = runIndex;
81606
+ currentLine.toChar = spacesEndChar;
81607
+ currentLine.width = roundValue(currentLine.width + boundarySpacing + spacesWidth);
81608
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81609
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81610
+ appendSegment(currentLine.segments, runIndex, spacesStartChar, spacesEndChar, spacesWidth);
81611
+ }
81612
+ }
81613
+ charPosInRun = spacesEndChar;
81614
+ continue;
81615
+ }
81521
81616
  const words = segment.split(" ");
81522
81617
  let segmentStartX;
81523
81618
  if (currentLine && pendingTabAlignment) {
@@ -82331,6 +82426,9 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
82331
82426
  }
82332
82427
  mainEditor.converter[`${type2}s`][sectionId] = updatedData;
82333
82428
  mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
82429
+ if (editor.docChanged && mainEditor.converter) {
82430
+ mainEditor.converter.headerFooterModified = true;
82431
+ }
82334
82432
  await updateYdocDocxData(mainEditor);
82335
82433
  };
82336
82434
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -82612,17 +82710,20 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
82612
82710
  * ```
82613
82711
  */
82614
82712
  getDocumentJson(descriptor) {
82615
- if (!descriptor?.id) return null;
82713
+ if (!descriptor?.id) {
82714
+ return null;
82715
+ }
82616
82716
  const liveEntry = __privateGet$1(this, _editorEntries).get(descriptor.id);
82617
82717
  if (liveEntry) {
82618
82718
  try {
82619
- const json = liveEntry.editor.getJSON?.();
82620
- return json;
82719
+ return liveEntry.editor.getJSON?.();
82621
82720
  } catch {
82622
82721
  }
82623
82722
  }
82624
82723
  const collections = __privateGet$1(this, _collections);
82625
- if (!collections) return null;
82724
+ if (!collections) {
82725
+ return null;
82726
+ }
82626
82727
  if (descriptor.kind === "header") {
82627
82728
  return collections.headers?.[descriptor.id] ?? null;
82628
82729
  }
@@ -83008,7 +83109,9 @@ class HeaderFooterLayoutAdapter {
83008
83109
  */
83009
83110
  getBatch(kind) {
83010
83111
  const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
83011
- if (!descriptors.length) return void 0;
83112
+ if (!descriptors.length) {
83113
+ return void 0;
83114
+ }
83012
83115
  const batch = {};
83013
83116
  let hasBlocks = false;
83014
83117
  descriptors.forEach((descriptor) => {
@@ -83241,13 +83344,7 @@ class EditorOverlayManager {
83241
83344
  showEditingOverlay(pageElement, region, zoom) {
83242
83345
  try {
83243
83346
  const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
83244
- if (!decorationContainer) {
83245
- return {
83246
- success: false,
83247
- reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
83248
- };
83249
- }
83250
- const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
83347
+ const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind, decorationContainer);
83251
83348
  if (!editorHost) {
83252
83349
  return {
83253
83350
  success: false,
@@ -83255,7 +83352,9 @@ class EditorOverlayManager {
83255
83352
  };
83256
83353
  }
83257
83354
  __privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
83258
- decorationContainer.style.visibility = "hidden";
83355
+ if (decorationContainer) {
83356
+ decorationContainer.style.visibility = "hidden";
83357
+ }
83259
83358
  editorHost.style.visibility = "visible";
83260
83359
  editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
83261
83360
  if (region.kind === "footer") {
@@ -83267,7 +83366,7 @@ class EditorOverlayManager {
83267
83366
  }
83268
83367
  }
83269
83368
  }
83270
- __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
83369
+ __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer, zoom);
83271
83370
  __privateSet(this, _activeEditorHost, editorHost);
83272
83371
  __privateSet(this, _activeDecorationContainer, decorationContainer);
83273
83372
  __privateSet(this, _activeRegion, region);
@@ -83385,7 +83484,7 @@ findDecorationContainer_fn = function(pageElement, kind) {
83385
83484
  const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
83386
83485
  return pageElement.querySelector(`.${className}`);
83387
83486
  };
83388
- ensureEditorHost_fn = function(pageElement, kind) {
83487
+ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
83389
83488
  const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
83390
83489
  let editorHost = pageElement.querySelector(`.${className}`);
83391
83490
  if (!editorHost) {
@@ -83400,34 +83499,44 @@ ensureEditorHost_fn = function(pageElement, kind) {
83400
83499
  overflow: "hidden",
83401
83500
  boxSizing: "border-box"
83402
83501
  });
83403
- const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
83404
- if (!decorationContainer) {
83405
- console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
83406
- return null;
83502
+ if (decorationContainer) {
83503
+ decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83504
+ } else {
83505
+ pageElement.appendChild(editorHost);
83407
83506
  }
83408
- decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83409
83507
  }
83410
83508
  return editorHost;
83411
83509
  };
83412
- positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
83413
- const decorationRect = decorationContainer.getBoundingClientRect();
83510
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
83414
83511
  const pageElement = editorHost.parentElement;
83415
83512
  if (!pageElement) {
83416
83513
  console.error("[EditorOverlayManager] Editor host has no parent element");
83417
83514
  return;
83418
83515
  }
83419
- const pageRect = pageElement.getBoundingClientRect();
83420
- const top2 = decorationRect.top - pageRect.top;
83421
- const left2 = decorationRect.left - pageRect.left;
83422
- const width = decorationRect.width;
83423
- const height = decorationRect.height;
83516
+ let top2;
83517
+ let left2;
83518
+ let width;
83519
+ let height;
83520
+ if (decorationContainer) {
83521
+ const decorationRect = decorationContainer.getBoundingClientRect();
83522
+ const pageRect = pageElement.getBoundingClientRect();
83523
+ top2 = decorationRect.top - pageRect.top;
83524
+ left2 = decorationRect.left - pageRect.left;
83525
+ width = decorationRect.width;
83526
+ height = decorationRect.height;
83527
+ } else {
83528
+ top2 = region.localY * zoom;
83529
+ left2 = region.localX * zoom;
83530
+ width = region.width * zoom;
83531
+ height = region.height * zoom;
83532
+ }
83424
83533
  Object.assign(editorHost.style, {
83425
83534
  top: `${top2}px`,
83426
83535
  left: `${left2}px`,
83427
83536
  width: `${width}px`,
83428
83537
  height: `${height}px`
83429
83538
  });
83430
- if (region.kind === "footer") {
83539
+ if (region.kind === "footer" && decorationContainer) {
83431
83540
  const fragment = decorationContainer.querySelector(".superdoc-fragment");
83432
83541
  if (fragment instanceof HTMLElement) {
83433
83542
  const fragmentTop = parseFloat(fragment.style.top) || 0;
@@ -83435,14 +83544,19 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom)
83435
83544
  }
83436
83545
  }
83437
83546
  };
83438
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
83547
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
83439
83548
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
83440
83549
  __privateSet(this, _borderLine, document.createElement("div"));
83441
83550
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
83442
- const decorationRect = decorationContainer.getBoundingClientRect();
83443
- const pageRect = pageElement.getBoundingClientRect();
83551
+ let topPosition;
83444
83552
  const isHeader = region.kind === "header";
83445
- const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83553
+ if (decorationContainer) {
83554
+ const decorationRect = decorationContainer.getBoundingClientRect();
83555
+ const pageRect = pageElement.getBoundingClientRect();
83556
+ topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83557
+ } else {
83558
+ topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
83559
+ }
83446
83560
  Object.assign(__privateGet$1(this, _borderLine).style, {
83447
83561
  position: "absolute",
83448
83562
  left: "0",
@@ -86048,7 +86162,10 @@ rerender_fn = async function() {
86048
86162
  }
86049
86163
  __privateSet(this, _sectionMetadata, sectionMetadata);
86050
86164
  const converter = __privateGet$1(this, _editor3).converter;
86051
- __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
86165
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
86166
+ headerIds: converter?.headerIds,
86167
+ footerIds: converter?.footerIds
86168
+ }));
86052
86169
  const anchorMap = __privateMethod$1(this, _PresentationEditor_instances, computeAnchorMap_fn).call(this, bookmarks, layout);
86053
86170
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
86054
86171
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
@@ -86486,41 +86603,71 @@ computeDecorationBox_fn = function(kind, pageMargins, pageHeight) {
86486
86603
  return { x: left2, width, height, offset: offset2 };
86487
86604
  }
86488
86605
  };
86606
+ computeExpectedSectionType_fn = function(kind, page, sectionFirstPageNumbers) {
86607
+ const sectionIndex = page.sectionIndex ?? 0;
86608
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
86609
+ const sectionPageNumber = typeof firstPageInSection === "number" ? page.number - firstPageInSection + 1 : page.number;
86610
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
86611
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier);
86612
+ let titlePgEnabled = false;
86613
+ let alternateHeaders = false;
86614
+ if (multiSectionId) {
86615
+ titlePgEnabled = multiSectionId.sectionTitlePg?.get(sectionIndex) ?? multiSectionId.titlePg;
86616
+ alternateHeaders = multiSectionId.alternateHeaders;
86617
+ } else if (legacyIdentifier) {
86618
+ titlePgEnabled = legacyIdentifier.titlePg;
86619
+ alternateHeaders = legacyIdentifier.alternateHeaders;
86620
+ }
86621
+ if (sectionPageNumber === 1 && titlePgEnabled) {
86622
+ return "first";
86623
+ }
86624
+ if (alternateHeaders) {
86625
+ return page.number % 2 === 0 ? "even" : "odd";
86626
+ }
86627
+ return "default";
86628
+ };
86489
86629
  rebuildHeaderFooterRegions_fn = function(layout) {
86490
86630
  __privateGet$1(this, _headerRegions).clear();
86491
86631
  __privateGet$1(this, _footerRegions).clear();
86492
86632
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
86493
86633
  if (pageHeight <= 0) return;
86634
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
86635
+ for (const p of layout.pages) {
86636
+ const idx = p.sectionIndex ?? 0;
86637
+ if (!sectionFirstPageNumbers.has(idx)) {
86638
+ sectionFirstPageNumbers.set(idx, p.number);
86639
+ }
86640
+ }
86494
86641
  layout.pages.forEach((page, pageIndex) => {
86495
86642
  var _a2, _b2;
86496
- const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, page.margins, page);
86497
- if (headerPayload?.hitRegion) {
86498
- __privateGet$1(this, _headerRegions).set(pageIndex, {
86499
- kind: "header",
86500
- headerId: headerPayload.headerId,
86501
- sectionType: headerPayload.sectionType,
86502
- pageIndex,
86503
- pageNumber: page.number,
86504
- localX: headerPayload.hitRegion.x ?? 0,
86505
- localY: headerPayload.hitRegion.y ?? 0,
86506
- width: headerPayload.hitRegion.width ?? headerPayload.box?.width ?? 0,
86507
- height: headerPayload.hitRegion.height ?? headerPayload.box?.height ?? 0
86508
- });
86509
- }
86510
- const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, page.margins, page);
86511
- if (footerPayload?.hitRegion) {
86512
- __privateGet$1(this, _footerRegions).set(pageIndex, {
86513
- kind: "footer",
86514
- headerId: footerPayload.headerId,
86515
- sectionType: footerPayload.sectionType,
86516
- pageIndex,
86517
- pageNumber: page.number,
86518
- localX: footerPayload.hitRegion.x ?? 0,
86519
- localY: footerPayload.hitRegion.y ?? 0,
86520
- width: footerPayload.hitRegion.width ?? footerPayload.box?.width ?? 0,
86521
- height: footerPayload.hitRegion.height ?? footerPayload.box?.height ?? 0
86522
- });
86523
- }
86643
+ const margins = page.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
86644
+ const actualPageHeight = page.size?.h ?? pageHeight;
86645
+ const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
86646
+ const headerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
86647
+ __privateGet$1(this, _headerRegions).set(pageIndex, {
86648
+ kind: "header",
86649
+ headerId: headerPayload?.headerId,
86650
+ sectionType: headerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "header", page, sectionFirstPageNumbers),
86651
+ pageIndex,
86652
+ pageNumber: page.number,
86653
+ localX: headerPayload?.hitRegion?.x ?? headerBox.x,
86654
+ localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
86655
+ width: headerPayload?.hitRegion?.width ?? headerBox.width,
86656
+ height: headerPayload?.hitRegion?.height ?? headerBox.height
86657
+ });
86658
+ const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, margins, page);
86659
+ const footerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "footer", margins, actualPageHeight);
86660
+ __privateGet$1(this, _footerRegions).set(pageIndex, {
86661
+ kind: "footer",
86662
+ headerId: footerPayload?.headerId,
86663
+ sectionType: footerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "footer", page, sectionFirstPageNumbers),
86664
+ pageIndex,
86665
+ pageNumber: page.number,
86666
+ localX: footerPayload?.hitRegion?.x ?? footerBox.x,
86667
+ localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
86668
+ width: footerPayload?.hitRegion?.width ?? footerBox.width,
86669
+ height: footerPayload?.hitRegion?.height ?? footerBox.height
86670
+ });
86524
86671
  });
86525
86672
  };
86526
86673
  hitTestHeaderFooterRegion_fn = function(x2, y2) {
@@ -86710,6 +86857,7 @@ enterHeaderFooterMode_fn = async function(region) {
86710
86857
  };
86711
86858
  exitHeaderFooterMode_fn = function() {
86712
86859
  if (__privateGet$1(this, _session).mode === "body") return;
86860
+ const editedHeaderId = __privateGet$1(this, _session).headerId;
86713
86861
  if (__privateGet$1(this, _activeHeaderFooterEditor)) {
86714
86862
  __privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
86715
86863
  __privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
@@ -86721,6 +86869,12 @@ exitHeaderFooterMode_fn = function() {
86721
86869
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
86722
86870
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
86723
86871
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
86872
+ if (editedHeaderId) {
86873
+ __privateGet$1(this, _headerFooterAdapter)?.invalidate(editedHeaderId);
86874
+ }
86875
+ __privateGet$1(this, _headerFooterManager)?.refresh();
86876
+ __privateSet(this, _pendingDocChange, true);
86877
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
86724
86878
  __privateGet$1(this, _editor3).view?.focus();
86725
86879
  };
86726
86880
  getActiveDomTarget_fn = function() {
@@ -86816,29 +86970,15 @@ resolveDescriptorForRegion_fn = function(region) {
86816
86970
  createDefaultHeaderFooter_fn = function(region) {
86817
86971
  const converter = __privateGet$1(this, _editor3).converter;
86818
86972
  if (!converter) {
86819
- console.error("[PresentationEditor] Converter not available for creating header/footer");
86820
86973
  return;
86821
86974
  }
86822
86975
  const variant = region.sectionType ?? "default";
86823
- try {
86824
- if (region.kind === "header") {
86825
- if (typeof converter.createDefaultHeader === "function") {
86826
- const headerId = converter.createDefaultHeader(variant);
86827
- console.log(`[PresentationEditor] Created default header: ${headerId}`);
86828
- } else {
86829
- console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
86830
- }
86831
- } else if (region.kind === "footer") {
86832
- if (typeof converter.createDefaultFooter === "function") {
86833
- const footerId = converter.createDefaultFooter(variant);
86834
- console.log(`[PresentationEditor] Created default footer: ${footerId}`);
86835
- } else {
86836
- console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
86837
- }
86838
- }
86839
- } catch (error) {
86840
- console.error("[PresentationEditor] Failed to create default header/footer:", error);
86976
+ if (region.kind === "header" && typeof converter.createDefaultHeader === "function") {
86977
+ converter.createDefaultHeader(variant);
86978
+ } else if (region.kind === "footer" && typeof converter.createDefaultFooter === "function") {
86979
+ converter.createDefaultFooter(variant);
86841
86980
  }
86981
+ __privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
86842
86982
  };
86843
86983
  getPageElement_fn = function(pageIndex) {
86844
86984
  if (!__privateGet$1(this, _painterHost)) return null;