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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-DsYaXp0H.es.js → PdfViewer-BOtq_Mxx.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-CnvD--7P.cjs → PdfViewer-CPNlFudP.cjs} +1 -1
  3. package/dist/chunks/{index-DYnUncjo-Br0s3gQs.es.js → index-BWMksCRw-BE_kaq_r.es.js} +1 -1
  4. package/dist/chunks/{index-DYnUncjo-Uv8YzgRb.cjs → index-BWMksCRw-BtY5hIaC.cjs} +1 -1
  5. package/dist/chunks/{index-DF1aQt8V.es.js → index-Wqm4Y9w9.es.js} +3 -3
  6. package/dist/chunks/{index-BpBdSm3V.cjs → index-yDP_DAl6.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-BxMwj135.es.js → super-editor.es-BtTJyHJj.es.js} +270 -118
  8. package/dist/chunks/{super-editor.es-DkFw0sfq.cjs → super-editor.es-DsUuY-Pt.cjs} +270 -118
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DwC5XPQX.js → converter-w1IY5-V-.js} +70 -11
  11. package/dist/super-editor/chunks/{docx-zipper-BkCzC50U.js → docx-zipper-B7-XHg8m.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CoKNeouN.js → editor-CiTfe7Wr.js} +271 -117
  13. package/dist/super-editor/chunks/{index-DYnUncjo.js → index-BWMksCRw.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DUWk-Bwi.js → toolbar-yy1NR024.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +272 -120
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -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,24 +41718,32 @@ 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
41748
  tags.push(...removeUndefined);
41734
41749
  }
@@ -41919,7 +41934,9 @@ const getLargestRelationshipId = (relationships = []) => {
41919
41934
  return numericIds.length ? Math.max(...numericIds) : 0;
41920
41935
  };
41921
41936
  const mergeRelationshipElements = (existingRelationships = [], newRelationships = []) => {
41922
- if (!newRelationships?.length) return existingRelationships;
41937
+ if (!newRelationships?.length) {
41938
+ return existingRelationships;
41939
+ }
41923
41940
  let largestId = getLargestRelationshipId(existingRelationships);
41924
41941
  const seenIds = new Set(existingRelationships.map((rel) => rel?.attributes?.Id).filter(Boolean));
41925
41942
  for (const rel of newRelationships) {
@@ -41953,7 +41970,8 @@ const mergeRelationshipElements = (existingRelationships = [], newRelationships
41953
41970
  seenIds.add(attributes.Id);
41954
41971
  additions.push(rel);
41955
41972
  });
41956
- return additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41973
+ const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41974
+ return result;
41957
41975
  };
41958
41976
  const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
41959
41977
  swiss: "Arial, sans-serif",
@@ -42026,6 +42044,9 @@ const _SuperConverter = class _SuperConverter2 {
42026
42044
  this.footers = {};
42027
42045
  this.footerIds = { default: null, even: null, odd: null, first: null };
42028
42046
  this.footerEditors = [];
42047
+ this.importedBodyHasHeaderRef = false;
42048
+ this.importedBodyHasFooterRef = false;
42049
+ this.headerFooterModified = false;
42029
42050
  this.linkedStyles = [];
42030
42051
  this.json = params2?.json;
42031
42052
  this.tagsNotInSchema = ["w:body"];
@@ -42168,7 +42189,7 @@ const _SuperConverter = class _SuperConverter2 {
42168
42189
  static getStoredSuperdocVersion(docx) {
42169
42190
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42170
42191
  }
42171
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.56") {
42192
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.58") {
42172
42193
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42173
42194
  }
42174
42195
  /**
@@ -42559,6 +42580,7 @@ const _SuperConverter = class _SuperConverter2 {
42559
42580
  if (!this.headerIds.ids.includes(rId)) {
42560
42581
  this.headerIds.ids.push(rId);
42561
42582
  }
42583
+ this.headerFooterModified = true;
42562
42584
  this.documentModified = true;
42563
42585
  return rId;
42564
42586
  }
@@ -42612,6 +42634,7 @@ const _SuperConverter = class _SuperConverter2 {
42612
42634
  if (!this.footerIds.ids.includes(rId)) {
42613
42635
  this.footerIds.ids.push(rId);
42614
42636
  }
42637
+ this.headerFooterModified = true;
42615
42638
  this.documentModified = true;
42616
42639
  return rId;
42617
42640
  }
@@ -45478,7 +45501,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45478
45501
  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
45502
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45480
45503
  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;
45504
+ 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
45505
  var GOOD_LEAF_SIZE = 200;
45483
45506
  var RopeSequence = function RopeSequence2() {
45484
45507
  };
@@ -58959,7 +58982,12 @@ function processRelationships(root2, convertedXml, results) {
58959
58982
  }
58960
58983
  }
58961
58984
  if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
58962
- const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
58985
+ let likelyPath;
58986
+ if (target.startsWith("../")) {
58987
+ likelyPath = target.replace(/^\.\.\//, "");
58988
+ } else {
58989
+ likelyPath = `word/${target.replace(/^\.?\//, "")}`;
58990
+ }
58963
58991
  if (!(likelyPath in convertedXml)) {
58964
58992
  if (!isImageType(type2)) {
58965
58993
  results.push(`Removed relationship ${id} with missing target: ${target}`);
@@ -59350,7 +59378,7 @@ const isHeadless = (editor) => {
59350
59378
  const shouldSkipNodeView = (editor) => {
59351
59379
  return isHeadless(editor);
59352
59380
  };
59353
- const summaryVersion = "1.0.0-beta.56";
59381
+ const summaryVersion = "1.0.0-beta.58";
59354
59382
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59355
59383
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59356
59384
  function mapAttributes(attrs) {
@@ -60139,7 +60167,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60139
60167
  { default: remarkStringify },
60140
60168
  { default: remarkGfm }
60141
60169
  ] = await Promise.all([
60142
- import("./index-DYnUncjo-Br0s3gQs.es.js"),
60170
+ import("./index-BWMksCRw-BE_kaq_r.es.js"),
60143
60171
  import("./index-DRCvimau-Cw339678.es.js"),
60144
60172
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60145
60173
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60344,7 +60372,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60344
60372
  * Process collaboration migrations
60345
60373
  */
60346
60374
  processCollaborationMigrations() {
60347
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.56");
60375
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.58");
60348
60376
  if (!this.options.ydoc) return;
60349
60377
  const metaMap = this.options.ydoc.getMap("meta");
60350
60378
  let docVersion = metaMap.get("version");
@@ -62820,6 +62848,7 @@ const normalizeAlignment = (value) => {
62820
62848
  case "center":
62821
62849
  case "right":
62822
62850
  case "justify":
62851
+ case "left":
62823
62852
  return value;
62824
62853
  case "both":
62825
62854
  case "distribute":
@@ -72375,9 +72404,11 @@ const _DomPainter = class _DomPainter2 {
72375
72404
  const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
72376
72405
  const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
72377
72406
  if (!isListFirstLine) {
72378
- if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
72379
- const adjustedPadding = paraIndentLeft + firstLineOffset;
72380
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
72407
+ if (hasExplicitSegmentPositioning) {
72408
+ if (isFirstLine && firstLineOffset !== 0) {
72409
+ const adjustedPadding = paraIndentLeft + firstLineOffset;
72410
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
72411
+ }
72381
72412
  } else if (paraIndentLeft) {
72382
72413
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
72383
72414
  }
@@ -73808,6 +73839,13 @@ const _DomPainter = class _DomPainter2 {
73808
73839
  }
73809
73840
  }
73810
73841
  if (hasExplicitPositioning && line.segments) {
73842
+ const paraIndent = block.attrs?.indent;
73843
+ const indentLeft = paraIndent?.left ?? 0;
73844
+ const firstLine = paraIndent?.firstLine ?? 0;
73845
+ const hanging = paraIndent?.hanging ?? 0;
73846
+ const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
73847
+ const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
73848
+ const indentOffset = indentLeft + firstLineOffsetForCumX;
73811
73849
  let cumulativeX = 0;
73812
73850
  const segmentsByRun = /* @__PURE__ */ new Map();
73813
73851
  line.segments.forEach((segment) => {
@@ -73839,7 +73877,7 @@ const _DomPainter = class _DomPainter2 {
73839
73877
  const actualTabWidth = tabEndX - tabStartX;
73840
73878
  const tabEl = this.doc.createElement("span");
73841
73879
  tabEl.style.position = "absolute";
73842
- tabEl.style.left = `${tabStartX}px`;
73880
+ tabEl.style.left = `${tabStartX + indentOffset}px`;
73843
73881
  tabEl.style.top = "0px";
73844
73882
  tabEl.style.width = `${actualTabWidth}px`;
73845
73883
  tabEl.style.height = `${line.lineHeight}px`;
@@ -73870,12 +73908,13 @@ const _DomPainter = class _DomPainter2 {
73870
73908
  elem.setAttribute("styleid", styleId);
73871
73909
  }
73872
73910
  const runSegments2 = segmentsByRun.get(runIndex);
73873
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73911
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73912
+ const segX = baseSegX + indentOffset;
73874
73913
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
73875
73914
  elem.style.position = "absolute";
73876
73915
  elem.style.left = `${segX}px`;
73877
73916
  el.appendChild(elem);
73878
- cumulativeX = segX + segWidth;
73917
+ cumulativeX = baseSegX + segWidth;
73879
73918
  }
73880
73919
  continue;
73881
73920
  }
@@ -73892,12 +73931,13 @@ const _DomPainter = class _DomPainter2 {
73892
73931
  elem.setAttribute("styleid", styleId);
73893
73932
  }
73894
73933
  const runSegments2 = segmentsByRun.get(runIndex);
73895
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73934
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
73935
+ const segX = baseSegX + indentOffset;
73896
73936
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
73897
73937
  elem.style.position = "absolute";
73898
73938
  elem.style.left = `${segX}px`;
73899
73939
  el.appendChild(elem);
73900
- cumulativeX = segX + segWidth;
73940
+ cumulativeX = baseSegX + segWidth;
73901
73941
  }
73902
73942
  continue;
73903
73943
  }
@@ -73927,7 +73967,8 @@ const _DomPainter = class _DomPainter2 {
73927
73967
  if (styleId) {
73928
73968
  elem.setAttribute("styleid", styleId);
73929
73969
  }
73930
- const xPos = segment.x !== void 0 ? segment.x : cumulativeX;
73970
+ const baseX = segment.x !== void 0 ? segment.x : cumulativeX;
73971
+ const xPos = baseX + indentOffset;
73931
73972
  elem.style.position = "absolute";
73932
73973
  elem.style.left = `${xPos}px`;
73933
73974
  el.appendChild(elem);
@@ -73941,7 +73982,7 @@ const _DomPainter = class _DomPainter2 {
73941
73982
  width = measureEl.offsetWidth;
73942
73983
  this.doc.body.removeChild(measureEl);
73943
73984
  }
73944
- cumulativeX = xPos + width;
73985
+ cumulativeX = baseX + width;
73945
73986
  }
73946
73987
  });
73947
73988
  }
@@ -75317,7 +75358,7 @@ const defaultMultiSectionIdentifier = () => ({
75317
75358
  sectionFooterIds: /* @__PURE__ */ new Map(),
75318
75359
  sectionTitlePg: /* @__PURE__ */ new Map()
75319
75360
  });
75320
- function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75361
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2, converterIds) {
75321
75362
  const identifier = defaultMultiSectionIdentifier();
75322
75363
  identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
75323
75364
  identifier.sectionCount = sectionMetadata.length;
@@ -75352,6 +75393,18 @@ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
75352
75393
  identifier.footerIds = { ...section0Footers };
75353
75394
  }
75354
75395
  identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
75396
+ if (converterIds?.headerIds) {
75397
+ identifier.headerIds.default = identifier.headerIds.default ?? converterIds.headerIds.default ?? null;
75398
+ identifier.headerIds.first = identifier.headerIds.first ?? converterIds.headerIds.first ?? null;
75399
+ identifier.headerIds.even = identifier.headerIds.even ?? converterIds.headerIds.even ?? null;
75400
+ identifier.headerIds.odd = identifier.headerIds.odd ?? converterIds.headerIds.odd ?? null;
75401
+ }
75402
+ if (converterIds?.footerIds) {
75403
+ identifier.footerIds.default = identifier.footerIds.default ?? converterIds.footerIds.default ?? null;
75404
+ identifier.footerIds.first = identifier.footerIds.first ?? converterIds.footerIds.first ?? null;
75405
+ identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
75406
+ identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
75407
+ }
75355
75408
  return identifier;
75356
75409
  }
75357
75410
  function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
@@ -76331,6 +76384,32 @@ function layoutDrawingBlock({
76331
76384
  state2.page.fragments.push(fragment);
76332
76385
  state2.cursorY += requiredHeight;
76333
76386
  }
76387
+ function getTableIndentWidth(attrs) {
76388
+ if (!attrs) {
76389
+ return 0;
76390
+ }
76391
+ const tableIndent = attrs.tableIndent;
76392
+ if (!tableIndent || typeof tableIndent !== "object") {
76393
+ return 0;
76394
+ }
76395
+ const width = tableIndent.width;
76396
+ if (width === void 0 || width === null) {
76397
+ return 0;
76398
+ }
76399
+ if (typeof width !== "number") {
76400
+ return 0;
76401
+ }
76402
+ if (!Number.isFinite(width)) {
76403
+ return 0;
76404
+ }
76405
+ return width;
76406
+ }
76407
+ function applyTableIndent(x2, width, indent) {
76408
+ return {
76409
+ x: x2 + indent,
76410
+ width: Math.max(0, width - indent)
76411
+ };
76412
+ }
76334
76413
  function calculateColumnMinWidth(columnIndex, measure) {
76335
76414
  const DEFAULT_MIN_WIDTH = 25;
76336
76415
  const measuredWidth = measure.columnWidths[columnIndex] || DEFAULT_MIN_WIDTH;
@@ -76545,14 +76624,18 @@ function layoutMonolithicTable(context) {
76545
76624
  columnBoundaries: generateColumnBoundaries(context.measure),
76546
76625
  coordinateSystem: "fragment"
76547
76626
  };
76627
+ const tableIndent = getTableIndentWidth(context.block.attrs);
76628
+ const baseX = context.columnX(state2.columnIndex);
76629
+ const baseWidth = Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth);
76630
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76548
76631
  const fragment = {
76549
76632
  kind: "table",
76550
76633
  blockId: context.block.id,
76551
76634
  fromRow: 0,
76552
76635
  toRow: context.block.rows.length,
76553
- x: context.columnX(state2.columnIndex),
76636
+ x: x2,
76554
76637
  y: state2.cursorY,
76555
- width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
76638
+ width,
76556
76639
  height,
76557
76640
  metadata
76558
76641
  };
@@ -76619,14 +76702,18 @@ function layoutTableBlock({
76619
76702
  columnBoundaries: generateColumnBoundaries(measure),
76620
76703
  coordinateSystem: "fragment"
76621
76704
  };
76705
+ const tableIndent = getTableIndentWidth(block.attrs);
76706
+ const baseX = columnX(state2.columnIndex);
76707
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
76708
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76622
76709
  const fragment = {
76623
76710
  kind: "table",
76624
76711
  blockId: block.id,
76625
76712
  fromRow: 0,
76626
76713
  toRow: 0,
76627
- x: columnX(state2.columnIndex),
76714
+ x: x2,
76628
76715
  y: state2.cursorY,
76629
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76716
+ width,
76630
76717
  height,
76631
76718
  metadata
76632
76719
  };
@@ -76674,14 +76761,18 @@ function layoutTableBlock({
76674
76761
  });
76675
76762
  const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
76676
76763
  if (fragmentHeight2 > 0 && madeProgress) {
76764
+ const tableIndent2 = getTableIndentWidth(block.attrs);
76765
+ const baseX2 = columnX(state2.columnIndex);
76766
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
76767
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
76677
76768
  const fragment2 = {
76678
76769
  kind: "table",
76679
76770
  blockId: block.id,
76680
76771
  fromRow: rowIndex,
76681
76772
  toRow: rowIndex + 1,
76682
- x: columnX(state2.columnIndex),
76773
+ x: x22,
76683
76774
  y: state2.cursorY,
76684
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76775
+ width: width2,
76685
76776
  height: fragmentHeight2,
76686
76777
  continuesFromPrev: true,
76687
76778
  continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
@@ -76714,14 +76805,18 @@ function layoutTableBlock({
76714
76805
  const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
76715
76806
  const forcedEndRow = bodyStartRow + 1;
76716
76807
  const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
76808
+ const tableIndent2 = getTableIndentWidth(block.attrs);
76809
+ const baseX2 = columnX(state2.columnIndex);
76810
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
76811
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
76717
76812
  const fragment2 = {
76718
76813
  kind: "table",
76719
76814
  blockId: block.id,
76720
76815
  fromRow: bodyStartRow,
76721
76816
  toRow: forcedEndRow,
76722
- x: columnX(state2.columnIndex),
76817
+ x: x22,
76723
76818
  y: state2.cursorY,
76724
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76819
+ width: width2,
76725
76820
  height: fragmentHeight2,
76726
76821
  continuesFromPrev: isTableContinuation,
76727
76822
  continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
@@ -76745,14 +76840,18 @@ function layoutTableBlock({
76745
76840
  measure
76746
76841
  );
76747
76842
  }
76843
+ const tableIndent = getTableIndentWidth(block.attrs);
76844
+ const baseX = columnX(state2.columnIndex);
76845
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
76846
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
76748
76847
  const fragment = {
76749
76848
  kind: "table",
76750
76849
  blockId: block.id,
76751
76850
  fromRow: bodyStartRow,
76752
76851
  toRow: endRow,
76753
- x: columnX(state2.columnIndex),
76852
+ x: x2,
76754
76853
  y: state2.cursorY,
76755
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
76854
+ width,
76756
76855
  height: fragmentHeight,
76757
76856
  continuesFromPrev: isTableContinuation,
76758
76857
  continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
@@ -81540,7 +81639,15 @@ async function measureParagraphBlock(block, maxWidth) {
81540
81639
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
81541
81640
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
81542
81641
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
81543
- appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, segmentStartX);
81642
+ const useExplicitXHere = wordIndex === 0 && segmentStartX !== void 0;
81643
+ appendSegment(
81644
+ currentLine.segments,
81645
+ runIndex,
81646
+ wordStartChar,
81647
+ wordEndNoSpace,
81648
+ wordOnlyWidth,
81649
+ useExplicitXHere ? segmentStartX : void 0
81650
+ );
81544
81651
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
81545
81652
  const completedLine = { ...currentLine, ...metrics };
81546
81653
  addBarTabsToLine(completedLine);
@@ -82264,6 +82371,9 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
82264
82371
  }
82265
82372
  mainEditor.converter[`${type2}s`][sectionId] = updatedData;
82266
82373
  mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
82374
+ if (editor.docChanged && mainEditor.converter) {
82375
+ mainEditor.converter.headerFooterModified = true;
82376
+ }
82267
82377
  await updateYdocDocxData(mainEditor);
82268
82378
  };
82269
82379
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -82545,17 +82655,20 @@ class HeaderFooterEditorManager extends EventEmitter$1 {
82545
82655
  * ```
82546
82656
  */
82547
82657
  getDocumentJson(descriptor) {
82548
- if (!descriptor?.id) return null;
82658
+ if (!descriptor?.id) {
82659
+ return null;
82660
+ }
82549
82661
  const liveEntry = __privateGet$1(this, _editorEntries).get(descriptor.id);
82550
82662
  if (liveEntry) {
82551
82663
  try {
82552
- const json = liveEntry.editor.getJSON?.();
82553
- return json;
82664
+ return liveEntry.editor.getJSON?.();
82554
82665
  } catch {
82555
82666
  }
82556
82667
  }
82557
82668
  const collections = __privateGet$1(this, _collections);
82558
- if (!collections) return null;
82669
+ if (!collections) {
82670
+ return null;
82671
+ }
82559
82672
  if (descriptor.kind === "header") {
82560
82673
  return collections.headers?.[descriptor.id] ?? null;
82561
82674
  }
@@ -82941,7 +83054,9 @@ class HeaderFooterLayoutAdapter {
82941
83054
  */
82942
83055
  getBatch(kind) {
82943
83056
  const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
82944
- if (!descriptors.length) return void 0;
83057
+ if (!descriptors.length) {
83058
+ return void 0;
83059
+ }
82945
83060
  const batch = {};
82946
83061
  let hasBlocks = false;
82947
83062
  descriptors.forEach((descriptor) => {
@@ -83174,13 +83289,7 @@ class EditorOverlayManager {
83174
83289
  showEditingOverlay(pageElement, region, zoom) {
83175
83290
  try {
83176
83291
  const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
83177
- if (!decorationContainer) {
83178
- return {
83179
- success: false,
83180
- reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
83181
- };
83182
- }
83183
- const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
83292
+ const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind, decorationContainer);
83184
83293
  if (!editorHost) {
83185
83294
  return {
83186
83295
  success: false,
@@ -83188,7 +83297,9 @@ class EditorOverlayManager {
83188
83297
  };
83189
83298
  }
83190
83299
  __privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
83191
- decorationContainer.style.visibility = "hidden";
83300
+ if (decorationContainer) {
83301
+ decorationContainer.style.visibility = "hidden";
83302
+ }
83192
83303
  editorHost.style.visibility = "visible";
83193
83304
  editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
83194
83305
  if (region.kind === "footer") {
@@ -83200,7 +83311,7 @@ class EditorOverlayManager {
83200
83311
  }
83201
83312
  }
83202
83313
  }
83203
- __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
83314
+ __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer, zoom);
83204
83315
  __privateSet(this, _activeEditorHost, editorHost);
83205
83316
  __privateSet(this, _activeDecorationContainer, decorationContainer);
83206
83317
  __privateSet(this, _activeRegion, region);
@@ -83318,7 +83429,7 @@ findDecorationContainer_fn = function(pageElement, kind) {
83318
83429
  const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
83319
83430
  return pageElement.querySelector(`.${className}`);
83320
83431
  };
83321
- ensureEditorHost_fn = function(pageElement, kind) {
83432
+ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
83322
83433
  const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
83323
83434
  let editorHost = pageElement.querySelector(`.${className}`);
83324
83435
  if (!editorHost) {
@@ -83333,34 +83444,44 @@ ensureEditorHost_fn = function(pageElement, kind) {
83333
83444
  overflow: "hidden",
83334
83445
  boxSizing: "border-box"
83335
83446
  });
83336
- const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
83337
- if (!decorationContainer) {
83338
- console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
83339
- return null;
83447
+ if (decorationContainer) {
83448
+ decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83449
+ } else {
83450
+ pageElement.appendChild(editorHost);
83340
83451
  }
83341
- decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
83342
83452
  }
83343
83453
  return editorHost;
83344
83454
  };
83345
- positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
83346
- const decorationRect = decorationContainer.getBoundingClientRect();
83455
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
83347
83456
  const pageElement = editorHost.parentElement;
83348
83457
  if (!pageElement) {
83349
83458
  console.error("[EditorOverlayManager] Editor host has no parent element");
83350
83459
  return;
83351
83460
  }
83352
- const pageRect = pageElement.getBoundingClientRect();
83353
- const top2 = decorationRect.top - pageRect.top;
83354
- const left2 = decorationRect.left - pageRect.left;
83355
- const width = decorationRect.width;
83356
- const height = decorationRect.height;
83461
+ let top2;
83462
+ let left2;
83463
+ let width;
83464
+ let height;
83465
+ if (decorationContainer) {
83466
+ const decorationRect = decorationContainer.getBoundingClientRect();
83467
+ const pageRect = pageElement.getBoundingClientRect();
83468
+ top2 = decorationRect.top - pageRect.top;
83469
+ left2 = decorationRect.left - pageRect.left;
83470
+ width = decorationRect.width;
83471
+ height = decorationRect.height;
83472
+ } else {
83473
+ top2 = region.localY * zoom;
83474
+ left2 = region.localX * zoom;
83475
+ width = region.width * zoom;
83476
+ height = region.height * zoom;
83477
+ }
83357
83478
  Object.assign(editorHost.style, {
83358
83479
  top: `${top2}px`,
83359
83480
  left: `${left2}px`,
83360
83481
  width: `${width}px`,
83361
83482
  height: `${height}px`
83362
83483
  });
83363
- if (region.kind === "footer") {
83484
+ if (region.kind === "footer" && decorationContainer) {
83364
83485
  const fragment = decorationContainer.querySelector(".superdoc-fragment");
83365
83486
  if (fragment instanceof HTMLElement) {
83366
83487
  const fragmentTop = parseFloat(fragment.style.top) || 0;
@@ -83368,14 +83489,19 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom)
83368
83489
  }
83369
83490
  }
83370
83491
  };
83371
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
83492
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
83372
83493
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
83373
83494
  __privateSet(this, _borderLine, document.createElement("div"));
83374
83495
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
83375
- const decorationRect = decorationContainer.getBoundingClientRect();
83376
- const pageRect = pageElement.getBoundingClientRect();
83496
+ let topPosition;
83377
83497
  const isHeader = region.kind === "header";
83378
- const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83498
+ if (decorationContainer) {
83499
+ const decorationRect = decorationContainer.getBoundingClientRect();
83500
+ const pageRect = pageElement.getBoundingClientRect();
83501
+ topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
83502
+ } else {
83503
+ topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
83504
+ }
83379
83505
  Object.assign(__privateGet$1(this, _borderLine).style, {
83380
83506
  position: "absolute",
83381
83507
  left: "0",
@@ -85981,7 +86107,10 @@ rerender_fn = async function() {
85981
86107
  }
85982
86108
  __privateSet(this, _sectionMetadata, sectionMetadata);
85983
86109
  const converter = __privateGet$1(this, _editor3).converter;
85984
- __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
86110
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
86111
+ headerIds: converter?.headerIds,
86112
+ footerIds: converter?.footerIds
86113
+ }));
85985
86114
  const anchorMap = __privateMethod$1(this, _PresentationEditor_instances, computeAnchorMap_fn).call(this, bookmarks, layout);
85986
86115
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
85987
86116
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
@@ -86419,41 +86548,71 @@ computeDecorationBox_fn = function(kind, pageMargins, pageHeight) {
86419
86548
  return { x: left2, width, height, offset: offset2 };
86420
86549
  }
86421
86550
  };
86551
+ computeExpectedSectionType_fn = function(kind, page, sectionFirstPageNumbers) {
86552
+ const sectionIndex = page.sectionIndex ?? 0;
86553
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
86554
+ const sectionPageNumber = typeof firstPageInSection === "number" ? page.number - firstPageInSection + 1 : page.number;
86555
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
86556
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier);
86557
+ let titlePgEnabled = false;
86558
+ let alternateHeaders = false;
86559
+ if (multiSectionId) {
86560
+ titlePgEnabled = multiSectionId.sectionTitlePg?.get(sectionIndex) ?? multiSectionId.titlePg;
86561
+ alternateHeaders = multiSectionId.alternateHeaders;
86562
+ } else if (legacyIdentifier) {
86563
+ titlePgEnabled = legacyIdentifier.titlePg;
86564
+ alternateHeaders = legacyIdentifier.alternateHeaders;
86565
+ }
86566
+ if (sectionPageNumber === 1 && titlePgEnabled) {
86567
+ return "first";
86568
+ }
86569
+ if (alternateHeaders) {
86570
+ return page.number % 2 === 0 ? "even" : "odd";
86571
+ }
86572
+ return "default";
86573
+ };
86422
86574
  rebuildHeaderFooterRegions_fn = function(layout) {
86423
86575
  __privateGet$1(this, _headerRegions).clear();
86424
86576
  __privateGet$1(this, _footerRegions).clear();
86425
86577
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
86426
86578
  if (pageHeight <= 0) return;
86579
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
86580
+ for (const p of layout.pages) {
86581
+ const idx = p.sectionIndex ?? 0;
86582
+ if (!sectionFirstPageNumbers.has(idx)) {
86583
+ sectionFirstPageNumbers.set(idx, p.number);
86584
+ }
86585
+ }
86427
86586
  layout.pages.forEach((page, pageIndex) => {
86428
86587
  var _a2, _b2;
86429
- const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, page.margins, page);
86430
- if (headerPayload?.hitRegion) {
86431
- __privateGet$1(this, _headerRegions).set(pageIndex, {
86432
- kind: "header",
86433
- headerId: headerPayload.headerId,
86434
- sectionType: headerPayload.sectionType,
86435
- pageIndex,
86436
- pageNumber: page.number,
86437
- localX: headerPayload.hitRegion.x ?? 0,
86438
- localY: headerPayload.hitRegion.y ?? 0,
86439
- width: headerPayload.hitRegion.width ?? headerPayload.box?.width ?? 0,
86440
- height: headerPayload.hitRegion.height ?? headerPayload.box?.height ?? 0
86441
- });
86442
- }
86443
- const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, page.margins, page);
86444
- if (footerPayload?.hitRegion) {
86445
- __privateGet$1(this, _footerRegions).set(pageIndex, {
86446
- kind: "footer",
86447
- headerId: footerPayload.headerId,
86448
- sectionType: footerPayload.sectionType,
86449
- pageIndex,
86450
- pageNumber: page.number,
86451
- localX: footerPayload.hitRegion.x ?? 0,
86452
- localY: footerPayload.hitRegion.y ?? 0,
86453
- width: footerPayload.hitRegion.width ?? footerPayload.box?.width ?? 0,
86454
- height: footerPayload.hitRegion.height ?? footerPayload.box?.height ?? 0
86455
- });
86456
- }
86588
+ const margins = page.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
86589
+ const actualPageHeight = page.size?.h ?? pageHeight;
86590
+ const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
86591
+ const headerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
86592
+ __privateGet$1(this, _headerRegions).set(pageIndex, {
86593
+ kind: "header",
86594
+ headerId: headerPayload?.headerId,
86595
+ sectionType: headerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "header", page, sectionFirstPageNumbers),
86596
+ pageIndex,
86597
+ pageNumber: page.number,
86598
+ localX: headerPayload?.hitRegion?.x ?? headerBox.x,
86599
+ localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
86600
+ width: headerPayload?.hitRegion?.width ?? headerBox.width,
86601
+ height: headerPayload?.hitRegion?.height ?? headerBox.height
86602
+ });
86603
+ const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, margins, page);
86604
+ const footerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "footer", margins, actualPageHeight);
86605
+ __privateGet$1(this, _footerRegions).set(pageIndex, {
86606
+ kind: "footer",
86607
+ headerId: footerPayload?.headerId,
86608
+ sectionType: footerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "footer", page, sectionFirstPageNumbers),
86609
+ pageIndex,
86610
+ pageNumber: page.number,
86611
+ localX: footerPayload?.hitRegion?.x ?? footerBox.x,
86612
+ localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
86613
+ width: footerPayload?.hitRegion?.width ?? footerBox.width,
86614
+ height: footerPayload?.hitRegion?.height ?? footerBox.height
86615
+ });
86457
86616
  });
86458
86617
  };
86459
86618
  hitTestHeaderFooterRegion_fn = function(x2, y2) {
@@ -86643,6 +86802,7 @@ enterHeaderFooterMode_fn = async function(region) {
86643
86802
  };
86644
86803
  exitHeaderFooterMode_fn = function() {
86645
86804
  if (__privateGet$1(this, _session).mode === "body") return;
86805
+ const editedHeaderId = __privateGet$1(this, _session).headerId;
86646
86806
  if (__privateGet$1(this, _activeHeaderFooterEditor)) {
86647
86807
  __privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
86648
86808
  __privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
@@ -86654,6 +86814,12 @@ exitHeaderFooterMode_fn = function() {
86654
86814
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
86655
86815
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
86656
86816
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
86817
+ if (editedHeaderId) {
86818
+ __privateGet$1(this, _headerFooterAdapter)?.invalidate(editedHeaderId);
86819
+ }
86820
+ __privateGet$1(this, _headerFooterManager)?.refresh();
86821
+ __privateSet(this, _pendingDocChange, true);
86822
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
86657
86823
  __privateGet$1(this, _editor3).view?.focus();
86658
86824
  };
86659
86825
  getActiveDomTarget_fn = function() {
@@ -86749,29 +86915,15 @@ resolveDescriptorForRegion_fn = function(region) {
86749
86915
  createDefaultHeaderFooter_fn = function(region) {
86750
86916
  const converter = __privateGet$1(this, _editor3).converter;
86751
86917
  if (!converter) {
86752
- console.error("[PresentationEditor] Converter not available for creating header/footer");
86753
86918
  return;
86754
86919
  }
86755
86920
  const variant = region.sectionType ?? "default";
86756
- try {
86757
- if (region.kind === "header") {
86758
- if (typeof converter.createDefaultHeader === "function") {
86759
- const headerId = converter.createDefaultHeader(variant);
86760
- console.log(`[PresentationEditor] Created default header: ${headerId}`);
86761
- } else {
86762
- console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
86763
- }
86764
- } else if (region.kind === "footer") {
86765
- if (typeof converter.createDefaultFooter === "function") {
86766
- const footerId = converter.createDefaultFooter(variant);
86767
- console.log(`[PresentationEditor] Created default footer: ${footerId}`);
86768
- } else {
86769
- console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
86770
- }
86771
- }
86772
- } catch (error) {
86773
- console.error("[PresentationEditor] Failed to create default header/footer:", error);
86921
+ if (region.kind === "header" && typeof converter.createDefaultHeader === "function") {
86922
+ converter.createDefaultHeader(variant);
86923
+ } else if (region.kind === "footer" && typeof converter.createDefaultFooter === "function") {
86924
+ converter.createDefaultFooter(variant);
86774
86925
  }
86926
+ __privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
86775
86927
  };
86776
86928
  getPageElement_fn = function(pageIndex) {
86777
86929
  if (!__privateGet$1(this, _painterHost)) return null;