@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
@@ -40558,6 +40558,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40558
40558
  const { processedNodes } = preProcessNodesForFldChar(node2.elements ?? [], docx);
40559
40559
  node2.elements = processedNodes;
40560
40560
  const bodySectPr = node2.elements?.find((n) => n.name === "w:sectPr");
40561
+ const bodySectPrElements = bodySectPr?.elements ?? [];
40562
+ if (converter) {
40563
+ converter.importedBodyHasHeaderRef = bodySectPrElements.some((el) => el?.name === "w:headerReference");
40564
+ converter.importedBodyHasFooterRef = bodySectPrElements.some((el) => el?.name === "w:footerReference");
40565
+ }
40561
40566
  const contentElements = node2.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
40562
40567
  const content2 = pruneIgnoredNodes(contentElements);
40563
40568
  const comments = importCommentData({ docx, converter, editor });
@@ -41494,15 +41499,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41494
41499
  }
41495
41500
  sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
41496
41501
  if (params2.converter) {
41502
+ const canExportHeaderRef = params2.converter.importedBodyHasHeaderRef || params2.converter.headerFooterModified;
41503
+ const canExportFooterRef = params2.converter.importedBodyHasFooterRef || params2.converter.headerFooterModified;
41497
41504
  const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
41498
41505
  const hasDefaultHeader = params2.converter.headerIds?.default;
41499
- if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
41506
+ if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter && canExportHeaderRef) {
41500
41507
  const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
41501
41508
  sectPr.elements.push(defaultHeader);
41502
41509
  }
41503
41510
  const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
41504
41511
  const hasDefaultFooter = params2.converter.footerIds?.default;
41505
- if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
41512
+ if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter && canExportFooterRef) {
41506
41513
  const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
41507
41514
  sectPr.elements.push(defaultFooter);
41508
41515
  }
@@ -41729,26 +41736,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41729
41736
  const textContent2 = (elements || []).map((child) => typeof child?.text === "string" ? child.text : "").join("");
41730
41737
  tags.push(__privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, textContent2));
41731
41738
  } else if (name === "w:t" || name === "w:delText" || name === "wp:posOffset") {
41732
- try {
41733
- let text2 = String(elements[0].text);
41739
+ if (elements.length === 0) {
41740
+ console.error(`${name} element has no child elements. Expected text node. Element will be self-closing.`);
41741
+ } else if (elements[0] == null || typeof elements[0].text !== "string") {
41742
+ console.error(
41743
+ `${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.`
41744
+ );
41745
+ tags.push("");
41746
+ } else {
41747
+ let text2 = elements[0].text.replace(/\[\[sdspace\]\]/g, "");
41734
41748
  text2 = __privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, text2);
41735
41749
  tags.push(text2);
41736
- } catch (error) {
41737
- console.error("Text element does not contain valid string:", error);
41738
41750
  }
41739
41751
  } else {
41740
41752
  if (elements) {
41741
41753
  for (let child of elements) {
41742
41754
  const newElements = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, child);
41743
- if (!newElements) continue;
41755
+ if (!newElements) {
41756
+ continue;
41757
+ }
41744
41758
  if (typeof newElements === "string") {
41745
41759
  tags.push(newElements);
41746
41760
  continue;
41747
41761
  }
41748
41762
  const removeUndefined = newElements.filter((el) => {
41749
- return el !== "<undefined>" && el !== "</undefined>";
41763
+ const isUndefined = el === "<undefined>" || el === "</undefined>";
41764
+ return !isUndefined;
41750
41765
  });
41751
- tags.push(...removeUndefined);
41766
+ for (const element2 of removeUndefined) {
41767
+ tags.push(element2);
41768
+ }
41752
41769
  }
41753
41770
  }
41754
41771
  }
@@ -41937,7 +41954,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41937
41954
  return numericIds.length ? Math.max(...numericIds) : 0;
41938
41955
  };
41939
41956
  const mergeRelationshipElements = (existingRelationships = [], newRelationships = []) => {
41940
- if (!newRelationships?.length) return existingRelationships;
41957
+ if (!newRelationships?.length) {
41958
+ return existingRelationships;
41959
+ }
41941
41960
  let largestId = getLargestRelationshipId(existingRelationships);
41942
41961
  const seenIds = new Set(existingRelationships.map((rel) => rel?.attributes?.Id).filter(Boolean));
41943
41962
  for (const rel of newRelationships) {
@@ -41971,7 +41990,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41971
41990
  seenIds.add(attributes.Id);
41972
41991
  additions.push(rel);
41973
41992
  });
41974
- return additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41993
+ const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41994
+ return result;
41975
41995
  };
41976
41996
  const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
41977
41997
  swiss: "Arial, sans-serif",
@@ -42044,6 +42064,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42044
42064
  this.footers = {};
42045
42065
  this.footerIds = { default: null, even: null, odd: null, first: null };
42046
42066
  this.footerEditors = [];
42067
+ this.importedBodyHasHeaderRef = false;
42068
+ this.importedBodyHasFooterRef = false;
42069
+ this.headerFooterModified = false;
42047
42070
  this.linkedStyles = [];
42048
42071
  this.json = params2?.json;
42049
42072
  this.tagsNotInSchema = ["w:body"];
@@ -42186,7 +42209,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42186
42209
  static getStoredSuperdocVersion(docx) {
42187
42210
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42188
42211
  }
42189
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.57") {
42212
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.59") {
42190
42213
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42191
42214
  }
42192
42215
  /**
@@ -42577,6 +42600,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42577
42600
  if (!this.headerIds.ids.includes(rId)) {
42578
42601
  this.headerIds.ids.push(rId);
42579
42602
  }
42603
+ this.headerFooterModified = true;
42580
42604
  this.documentModified = true;
42581
42605
  return rId;
42582
42606
  }
@@ -42630,6 +42654,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42630
42654
  if (!this.footerIds.ids.includes(rId)) {
42631
42655
  this.footerIds.ids.push(rId);
42632
42656
  }
42657
+ this.headerFooterModified = true;
42633
42658
  this.documentModified = true;
42634
42659
  return rId;
42635
42660
  }
@@ -53353,7 +53378,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53353
53378
  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);
53354
53379
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53355
53380
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53356
- 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;
53381
+ 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;
53357
53382
  var GOOD_LEAF_SIZE = 200;
53358
53383
  var RopeSequence = function RopeSequence2() {
53359
53384
  };
@@ -66834,7 +66859,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66834
66859
  }
66835
66860
  }
66836
66861
  if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
66837
- const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
66862
+ let likelyPath;
66863
+ if (target.startsWith("../")) {
66864
+ likelyPath = target.replace(/^\.\.\//, "");
66865
+ } else {
66866
+ likelyPath = `word/${target.replace(/^\.?\//, "")}`;
66867
+ }
66838
66868
  if (!(likelyPath in convertedXml)) {
66839
66869
  if (!isImageType(type2)) {
66840
66870
  results.push(`Removed relationship ${id} with missing target: ${target}`);
@@ -67225,7 +67255,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67225
67255
  const shouldSkipNodeView = (editor) => {
67226
67256
  return isHeadless(editor);
67227
67257
  };
67228
- const summaryVersion = "1.0.0-beta.57";
67258
+ const summaryVersion = "1.0.0-beta.59";
67229
67259
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67230
67260
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67231
67261
  function mapAttributes(attrs) {
@@ -68014,7 +68044,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68014
68044
  { default: remarkStringify2 },
68015
68045
  { default: remarkGfm2 }
68016
68046
  ] = await Promise.all([
68017
- Promise.resolve().then(() => indexD5IkZjf9),
68047
+ Promise.resolve().then(() => indexP5nUefNA),
68018
68048
  Promise.resolve().then(() => indexDRCvimau),
68019
68049
  Promise.resolve().then(() => indexC_x_N6Uh),
68020
68050
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68219,7 +68249,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68219
68249
  * Process collaboration migrations
68220
68250
  */
68221
68251
  processCollaborationMigrations() {
68222
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.57");
68252
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.59");
68223
68253
  if (!this.options.ydoc) return;
68224
68254
  const metaMap = this.options.ydoc.getMap("meta");
68225
68255
  let docVersion = metaMap.get("version");
@@ -83205,7 +83235,7 @@ ${l}
83205
83235
  sectionFooterIds: /* @__PURE__ */ new Map(),
83206
83236
  sectionTitlePg: /* @__PURE__ */ new Map()
83207
83237
  });
83208
- function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
83238
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2, converterIds) {
83209
83239
  const identifier = defaultMultiSectionIdentifier();
83210
83240
  identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
83211
83241
  identifier.sectionCount = sectionMetadata.length;
@@ -83240,6 +83270,18 @@ ${l}
83240
83270
  identifier.footerIds = { ...section0Footers };
83241
83271
  }
83242
83272
  identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
83273
+ if (converterIds?.headerIds) {
83274
+ identifier.headerIds.default = identifier.headerIds.default ?? converterIds.headerIds.default ?? null;
83275
+ identifier.headerIds.first = identifier.headerIds.first ?? converterIds.headerIds.first ?? null;
83276
+ identifier.headerIds.even = identifier.headerIds.even ?? converterIds.headerIds.even ?? null;
83277
+ identifier.headerIds.odd = identifier.headerIds.odd ?? converterIds.headerIds.odd ?? null;
83278
+ }
83279
+ if (converterIds?.footerIds) {
83280
+ identifier.footerIds.default = identifier.footerIds.default ?? converterIds.footerIds.default ?? null;
83281
+ identifier.footerIds.first = identifier.footerIds.first ?? converterIds.footerIds.first ?? null;
83282
+ identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
83283
+ identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
83284
+ }
83243
83285
  return identifier;
83244
83286
  }
83245
83287
  function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
@@ -89393,6 +89435,59 @@ ${l}
89393
89435
  for (let segmentIndex = 0; segmentIndex < tabSegments.length; segmentIndex++) {
89394
89436
  const segment = tabSegments[segmentIndex];
89395
89437
  const isLastSegment = segmentIndex === tabSegments.length - 1;
89438
+ if (/^[ ]+$/.test(segment)) {
89439
+ const spacesLength = segment.length;
89440
+ const spacesStartChar = charPosInRun;
89441
+ const spacesEndChar = charPosInRun + spacesLength;
89442
+ const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
89443
+ if (!currentLine) {
89444
+ currentLine = {
89445
+ fromRun: runIndex,
89446
+ fromChar: spacesStartChar,
89447
+ toRun: runIndex,
89448
+ toChar: spacesEndChar,
89449
+ width: spacesWidth,
89450
+ maxFontSize: run2.fontSize,
89451
+ maxFontInfo: getFontInfoFromRun(run2),
89452
+ maxWidth: getEffectiveWidth(initialAvailableWidth),
89453
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
89454
+ };
89455
+ } else {
89456
+ const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
89457
+ if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
89458
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
89459
+ const completedLine = {
89460
+ ...currentLine,
89461
+ ...metrics
89462
+ };
89463
+ addBarTabsToLine(completedLine);
89464
+ lines.push(completedLine);
89465
+ tabStopCursor = 0;
89466
+ pendingTabAlignment = null;
89467
+ lastAppliedTabAlign = null;
89468
+ currentLine = {
89469
+ fromRun: runIndex,
89470
+ fromChar: spacesStartChar,
89471
+ toRun: runIndex,
89472
+ toChar: spacesEndChar,
89473
+ width: spacesWidth,
89474
+ maxFontSize: run2.fontSize,
89475
+ maxFontInfo: getFontInfoFromRun(run2),
89476
+ maxWidth: getEffectiveWidth(contentWidth),
89477
+ segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }]
89478
+ };
89479
+ } else {
89480
+ currentLine.toRun = runIndex;
89481
+ currentLine.toChar = spacesEndChar;
89482
+ currentLine.width = roundValue(currentLine.width + boundarySpacing + spacesWidth);
89483
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
89484
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
89485
+ appendSegment(currentLine.segments, runIndex, spacesStartChar, spacesEndChar, spacesWidth);
89486
+ }
89487
+ }
89488
+ charPosInRun = spacesEndChar;
89489
+ continue;
89490
+ }
89396
89491
  const words = segment.split(" ");
89397
89492
  let segmentStartX;
89398
89493
  if (currentLine && pendingTabAlignment) {
@@ -90206,6 +90301,9 @@ ${l}
90206
90301
  }
90207
90302
  mainEditor.converter[`${type2}s`][sectionId] = updatedData;
90208
90303
  mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
90304
+ if (editor.docChanged && mainEditor.converter) {
90305
+ mainEditor.converter.headerFooterModified = true;
90306
+ }
90209
90307
  await updateYdocDocxData(mainEditor);
90210
90308
  };
90211
90309
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -90487,17 +90585,20 @@ ${l}
90487
90585
  * ```
90488
90586
  */
90489
90587
  getDocumentJson(descriptor) {
90490
- if (!descriptor?.id) return null;
90588
+ if (!descriptor?.id) {
90589
+ return null;
90590
+ }
90491
90591
  const liveEntry = __privateGet$1(this, _editorEntries).get(descriptor.id);
90492
90592
  if (liveEntry) {
90493
90593
  try {
90494
- const json = liveEntry.editor.getJSON?.();
90495
- return json;
90594
+ return liveEntry.editor.getJSON?.();
90496
90595
  } catch {
90497
90596
  }
90498
90597
  }
90499
90598
  const collections = __privateGet$1(this, _collections);
90500
- if (!collections) return null;
90599
+ if (!collections) {
90600
+ return null;
90601
+ }
90501
90602
  if (descriptor.kind === "header") {
90502
90603
  return collections.headers?.[descriptor.id] ?? null;
90503
90604
  }
@@ -90883,7 +90984,9 @@ ${l}
90883
90984
  */
90884
90985
  getBatch(kind) {
90885
90986
  const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
90886
- if (!descriptors.length) return void 0;
90987
+ if (!descriptors.length) {
90988
+ return void 0;
90989
+ }
90887
90990
  const batch2 = {};
90888
90991
  let hasBlocks = false;
90889
90992
  descriptors.forEach((descriptor) => {
@@ -91116,13 +91219,7 @@ ${l}
91116
91219
  showEditingOverlay(pageElement, region, zoom) {
91117
91220
  try {
91118
91221
  const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
91119
- if (!decorationContainer) {
91120
- return {
91121
- success: false,
91122
- reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
91123
- };
91124
- }
91125
- const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
91222
+ const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind, decorationContainer);
91126
91223
  if (!editorHost) {
91127
91224
  return {
91128
91225
  success: false,
@@ -91130,7 +91227,9 @@ ${l}
91130
91227
  };
91131
91228
  }
91132
91229
  __privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
91133
- decorationContainer.style.visibility = "hidden";
91230
+ if (decorationContainer) {
91231
+ decorationContainer.style.visibility = "hidden";
91232
+ }
91134
91233
  editorHost.style.visibility = "visible";
91135
91234
  editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
91136
91235
  if (region.kind === "footer") {
@@ -91142,7 +91241,7 @@ ${l}
91142
91241
  }
91143
91242
  }
91144
91243
  }
91145
- __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
91244
+ __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer, zoom);
91146
91245
  __privateSet(this, _activeEditorHost, editorHost);
91147
91246
  __privateSet(this, _activeDecorationContainer, decorationContainer);
91148
91247
  __privateSet(this, _activeRegion, region);
@@ -91260,7 +91359,7 @@ ${l}
91260
91359
  const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
91261
91360
  return pageElement.querySelector(`.${className}`);
91262
91361
  };
91263
- ensureEditorHost_fn = function(pageElement, kind) {
91362
+ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
91264
91363
  const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
91265
91364
  let editorHost = pageElement.querySelector(`.${className}`);
91266
91365
  if (!editorHost) {
@@ -91275,34 +91374,44 @@ ${l}
91275
91374
  overflow: "hidden",
91276
91375
  boxSizing: "border-box"
91277
91376
  });
91278
- const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
91279
- if (!decorationContainer) {
91280
- console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
91281
- return null;
91377
+ if (decorationContainer) {
91378
+ decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
91379
+ } else {
91380
+ pageElement.appendChild(editorHost);
91282
91381
  }
91283
- decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
91284
91382
  }
91285
91383
  return editorHost;
91286
91384
  };
91287
- positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
91288
- const decorationRect = decorationContainer.getBoundingClientRect();
91385
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
91289
91386
  const pageElement = editorHost.parentElement;
91290
91387
  if (!pageElement) {
91291
91388
  console.error("[EditorOverlayManager] Editor host has no parent element");
91292
91389
  return;
91293
91390
  }
91294
- const pageRect = pageElement.getBoundingClientRect();
91295
- const top2 = decorationRect.top - pageRect.top;
91296
- const left2 = decorationRect.left - pageRect.left;
91297
- const width = decorationRect.width;
91298
- const height = decorationRect.height;
91391
+ let top2;
91392
+ let left2;
91393
+ let width;
91394
+ let height;
91395
+ if (decorationContainer) {
91396
+ const decorationRect = decorationContainer.getBoundingClientRect();
91397
+ const pageRect = pageElement.getBoundingClientRect();
91398
+ top2 = decorationRect.top - pageRect.top;
91399
+ left2 = decorationRect.left - pageRect.left;
91400
+ width = decorationRect.width;
91401
+ height = decorationRect.height;
91402
+ } else {
91403
+ top2 = region.localY * zoom;
91404
+ left2 = region.localX * zoom;
91405
+ width = region.width * zoom;
91406
+ height = region.height * zoom;
91407
+ }
91299
91408
  Object.assign(editorHost.style, {
91300
91409
  top: `${top2}px`,
91301
91410
  left: `${left2}px`,
91302
91411
  width: `${width}px`,
91303
91412
  height: `${height}px`
91304
91413
  });
91305
- if (region.kind === "footer") {
91414
+ if (region.kind === "footer" && decorationContainer) {
91306
91415
  const fragment = decorationContainer.querySelector(".superdoc-fragment");
91307
91416
  if (fragment instanceof HTMLElement) {
91308
91417
  const fragmentTop = parseFloat(fragment.style.top) || 0;
@@ -91310,14 +91419,19 @@ ${l}
91310
91419
  }
91311
91420
  }
91312
91421
  };
91313
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
91422
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
91314
91423
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
91315
91424
  __privateSet(this, _borderLine, document.createElement("div"));
91316
91425
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
91317
- const decorationRect = decorationContainer.getBoundingClientRect();
91318
- const pageRect = pageElement.getBoundingClientRect();
91426
+ let topPosition;
91319
91427
  const isHeader = region.kind === "header";
91320
- const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
91428
+ if (decorationContainer) {
91429
+ const decorationRect = decorationContainer.getBoundingClientRect();
91430
+ const pageRect = pageElement.getBoundingClientRect();
91431
+ topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
91432
+ } else {
91433
+ topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
91434
+ }
91321
91435
  Object.assign(__privateGet$1(this, _borderLine).style, {
91322
91436
  position: "absolute",
91323
91437
  left: "0",
@@ -93923,7 +94037,10 @@ ${l}
93923
94037
  }
93924
94038
  __privateSet(this, _sectionMetadata, sectionMetadata);
93925
94039
  const converter = __privateGet$1(this, _editor3).converter;
93926
- __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
94040
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
94041
+ headerIds: converter?.headerIds,
94042
+ footerIds: converter?.footerIds
94043
+ }));
93927
94044
  const anchorMap = __privateMethod$1(this, _PresentationEditor_instances, computeAnchorMap_fn).call(this, bookmarks, layout);
93928
94045
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout, bookmarks, anchorMap });
93929
94046
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
@@ -94361,41 +94478,71 @@ ${l}
94361
94478
  return { x: left2, width, height, offset: offset2 };
94362
94479
  }
94363
94480
  };
94481
+ computeExpectedSectionType_fn = function(kind, page, sectionFirstPageNumbers) {
94482
+ const sectionIndex = page.sectionIndex ?? 0;
94483
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
94484
+ const sectionPageNumber = typeof firstPageInSection === "number" ? page.number - firstPageInSection + 1 : page.number;
94485
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
94486
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier);
94487
+ let titlePgEnabled = false;
94488
+ let alternateHeaders = false;
94489
+ if (multiSectionId) {
94490
+ titlePgEnabled = multiSectionId.sectionTitlePg?.get(sectionIndex) ?? multiSectionId.titlePg;
94491
+ alternateHeaders = multiSectionId.alternateHeaders;
94492
+ } else if (legacyIdentifier) {
94493
+ titlePgEnabled = legacyIdentifier.titlePg;
94494
+ alternateHeaders = legacyIdentifier.alternateHeaders;
94495
+ }
94496
+ if (sectionPageNumber === 1 && titlePgEnabled) {
94497
+ return "first";
94498
+ }
94499
+ if (alternateHeaders) {
94500
+ return page.number % 2 === 0 ? "even" : "odd";
94501
+ }
94502
+ return "default";
94503
+ };
94364
94504
  rebuildHeaderFooterRegions_fn = function(layout) {
94365
94505
  __privateGet$1(this, _headerRegions).clear();
94366
94506
  __privateGet$1(this, _footerRegions).clear();
94367
94507
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
94368
94508
  if (pageHeight <= 0) return;
94509
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
94510
+ for (const p2 of layout.pages) {
94511
+ const idx = p2.sectionIndex ?? 0;
94512
+ if (!sectionFirstPageNumbers.has(idx)) {
94513
+ sectionFirstPageNumbers.set(idx, p2.number);
94514
+ }
94515
+ }
94369
94516
  layout.pages.forEach((page, pageIndex) => {
94370
94517
  var _a2, _b2;
94371
- const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, page.margins, page);
94372
- if (headerPayload?.hitRegion) {
94373
- __privateGet$1(this, _headerRegions).set(pageIndex, {
94374
- kind: "header",
94375
- headerId: headerPayload.headerId,
94376
- sectionType: headerPayload.sectionType,
94377
- pageIndex,
94378
- pageNumber: page.number,
94379
- localX: headerPayload.hitRegion.x ?? 0,
94380
- localY: headerPayload.hitRegion.y ?? 0,
94381
- width: headerPayload.hitRegion.width ?? headerPayload.box?.width ?? 0,
94382
- height: headerPayload.hitRegion.height ?? headerPayload.box?.height ?? 0
94383
- });
94384
- }
94385
- const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, page.margins, page);
94386
- if (footerPayload?.hitRegion) {
94387
- __privateGet$1(this, _footerRegions).set(pageIndex, {
94388
- kind: "footer",
94389
- headerId: footerPayload.headerId,
94390
- sectionType: footerPayload.sectionType,
94391
- pageIndex,
94392
- pageNumber: page.number,
94393
- localX: footerPayload.hitRegion.x ?? 0,
94394
- localY: footerPayload.hitRegion.y ?? 0,
94395
- width: footerPayload.hitRegion.width ?? footerPayload.box?.width ?? 0,
94396
- height: footerPayload.hitRegion.height ?? footerPayload.box?.height ?? 0
94397
- });
94398
- }
94518
+ const margins = page.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
94519
+ const actualPageHeight = page.size?.h ?? pageHeight;
94520
+ const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
94521
+ const headerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
94522
+ __privateGet$1(this, _headerRegions).set(pageIndex, {
94523
+ kind: "header",
94524
+ headerId: headerPayload?.headerId,
94525
+ sectionType: headerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "header", page, sectionFirstPageNumbers),
94526
+ pageIndex,
94527
+ pageNumber: page.number,
94528
+ localX: headerPayload?.hitRegion?.x ?? headerBox.x,
94529
+ localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
94530
+ width: headerPayload?.hitRegion?.width ?? headerBox.width,
94531
+ height: headerPayload?.hitRegion?.height ?? headerBox.height
94532
+ });
94533
+ const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, margins, page);
94534
+ const footerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "footer", margins, actualPageHeight);
94535
+ __privateGet$1(this, _footerRegions).set(pageIndex, {
94536
+ kind: "footer",
94537
+ headerId: footerPayload?.headerId,
94538
+ sectionType: footerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "footer", page, sectionFirstPageNumbers),
94539
+ pageIndex,
94540
+ pageNumber: page.number,
94541
+ localX: footerPayload?.hitRegion?.x ?? footerBox.x,
94542
+ localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
94543
+ width: footerPayload?.hitRegion?.width ?? footerBox.width,
94544
+ height: footerPayload?.hitRegion?.height ?? footerBox.height
94545
+ });
94399
94546
  });
94400
94547
  };
94401
94548
  hitTestHeaderFooterRegion_fn = function(x2, y2) {
@@ -94585,6 +94732,7 @@ ${l}
94585
94732
  };
94586
94733
  exitHeaderFooterMode_fn = function() {
94587
94734
  if (__privateGet$1(this, _session).mode === "body") return;
94735
+ const editedHeaderId = __privateGet$1(this, _session).headerId;
94588
94736
  if (__privateGet$1(this, _activeHeaderFooterEditor)) {
94589
94737
  __privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
94590
94738
  __privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
@@ -94596,6 +94744,12 @@ ${l}
94596
94744
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
94597
94745
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
94598
94746
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
94747
+ if (editedHeaderId) {
94748
+ __privateGet$1(this, _headerFooterAdapter)?.invalidate(editedHeaderId);
94749
+ }
94750
+ __privateGet$1(this, _headerFooterManager)?.refresh();
94751
+ __privateSet(this, _pendingDocChange, true);
94752
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
94599
94753
  __privateGet$1(this, _editor3).view?.focus();
94600
94754
  };
94601
94755
  getActiveDomTarget_fn = function() {
@@ -94691,29 +94845,15 @@ ${l}
94691
94845
  createDefaultHeaderFooter_fn = function(region) {
94692
94846
  const converter = __privateGet$1(this, _editor3).converter;
94693
94847
  if (!converter) {
94694
- console.error("[PresentationEditor] Converter not available for creating header/footer");
94695
94848
  return;
94696
94849
  }
94697
94850
  const variant = region.sectionType ?? "default";
94698
- try {
94699
- if (region.kind === "header") {
94700
- if (typeof converter.createDefaultHeader === "function") {
94701
- const headerId = converter.createDefaultHeader(variant);
94702
- console.log(`[PresentationEditor] Created default header: ${headerId}`);
94703
- } else {
94704
- console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
94705
- }
94706
- } else if (region.kind === "footer") {
94707
- if (typeof converter.createDefaultFooter === "function") {
94708
- const footerId = converter.createDefaultFooter(variant);
94709
- console.log(`[PresentationEditor] Created default footer: ${footerId}`);
94710
- } else {
94711
- console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
94712
- }
94713
- }
94714
- } catch (error) {
94715
- console.error("[PresentationEditor] Failed to create default header/footer:", error);
94851
+ if (region.kind === "header" && typeof converter.createDefaultHeader === "function") {
94852
+ converter.createDefaultHeader(variant);
94853
+ } else if (region.kind === "footer" && typeof converter.createDefaultFooter === "function") {
94854
+ converter.createDefaultFooter(variant);
94716
94855
  }
94856
+ __privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
94717
94857
  };
94718
94858
  getPageElement_fn = function(pageIndex) {
94719
94859
  if (!__privateGet$1(this, _painterHost)) return null;
@@ -149064,7 +149204,7 @@ ${style2}
149064
149204
  this.config.colors = shuffleArray(this.config.colors);
149065
149205
  this.userColorMap = /* @__PURE__ */ new Map();
149066
149206
  this.colorIndex = 0;
149067
- this.version = "1.0.0-beta.57";
149207
+ this.version = "1.0.0-beta.59";
149068
149208
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
149069
149209
  this.superdocId = config2.superdocId || v4();
149070
149210
  this.colors = this.config.colors;
@@ -151530,7 +151670,7 @@ ${style2}
151530
151670
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
151531
151671
  );
151532
151672
  }
151533
- const indexD5IkZjf9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
151673
+ const indexP5nUefNA = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
151534
151674
  __proto__: null,
151535
151675
  unified
151536
151676
  }, Symbol.toStringTag, { value: "Module" }));