@harbour-enterprises/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
@@ -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,24 +41736,32 @@ 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
41766
  tags.push(...removeUndefined);
41752
41767
  }
@@ -41937,7 +41952,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41937
41952
  return numericIds.length ? Math.max(...numericIds) : 0;
41938
41953
  };
41939
41954
  const mergeRelationshipElements = (existingRelationships = [], newRelationships = []) => {
41940
- if (!newRelationships?.length) return existingRelationships;
41955
+ if (!newRelationships?.length) {
41956
+ return existingRelationships;
41957
+ }
41941
41958
  let largestId = getLargestRelationshipId(existingRelationships);
41942
41959
  const seenIds = new Set(existingRelationships.map((rel) => rel?.attributes?.Id).filter(Boolean));
41943
41960
  for (const rel of newRelationships) {
@@ -41971,7 +41988,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41971
41988
  seenIds.add(attributes.Id);
41972
41989
  additions.push(rel);
41973
41990
  });
41974
- return additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41991
+ const result = additions.length ? [...existingRelationships, ...additions] : existingRelationships;
41992
+ return result;
41975
41993
  };
41976
41994
  const FONT_FAMILY_FALLBACKS$1 = Object.freeze({
41977
41995
  swiss: "Arial, sans-serif",
@@ -42044,6 +42062,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42044
42062
  this.footers = {};
42045
42063
  this.footerIds = { default: null, even: null, odd: null, first: null };
42046
42064
  this.footerEditors = [];
42065
+ this.importedBodyHasHeaderRef = false;
42066
+ this.importedBodyHasFooterRef = false;
42067
+ this.headerFooterModified = false;
42047
42068
  this.linkedStyles = [];
42048
42069
  this.json = params2?.json;
42049
42070
  this.tagsNotInSchema = ["w:body"];
@@ -42186,7 +42207,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42186
42207
  static getStoredSuperdocVersion(docx) {
42187
42208
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42188
42209
  }
42189
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.56") {
42210
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.58") {
42190
42211
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42191
42212
  }
42192
42213
  /**
@@ -42577,6 +42598,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42577
42598
  if (!this.headerIds.ids.includes(rId)) {
42578
42599
  this.headerIds.ids.push(rId);
42579
42600
  }
42601
+ this.headerFooterModified = true;
42580
42602
  this.documentModified = true;
42581
42603
  return rId;
42582
42604
  }
@@ -42630,6 +42652,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42630
42652
  if (!this.footerIds.ids.includes(rId)) {
42631
42653
  this.footerIds.ids.push(rId);
42632
42654
  }
42655
+ this.headerFooterModified = true;
42633
42656
  this.documentModified = true;
42634
42657
  return rId;
42635
42658
  }
@@ -53353,7 +53376,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53353
53376
  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
53377
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53355
53378
  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;
53379
+ 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
53380
  var GOOD_LEAF_SIZE = 200;
53358
53381
  var RopeSequence = function RopeSequence2() {
53359
53382
  };
@@ -66834,7 +66857,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66834
66857
  }
66835
66858
  }
66836
66859
  if (targetMode.toLowerCase() !== "external" && !looksExternal(target)) {
66837
- const likelyPath = `word/${target.replace(/^\.?\//, "")}`;
66860
+ let likelyPath;
66861
+ if (target.startsWith("../")) {
66862
+ likelyPath = target.replace(/^\.\.\//, "");
66863
+ } else {
66864
+ likelyPath = `word/${target.replace(/^\.?\//, "")}`;
66865
+ }
66838
66866
  if (!(likelyPath in convertedXml)) {
66839
66867
  if (!isImageType(type2)) {
66840
66868
  results.push(`Removed relationship ${id} with missing target: ${target}`);
@@ -67225,7 +67253,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67225
67253
  const shouldSkipNodeView = (editor) => {
67226
67254
  return isHeadless(editor);
67227
67255
  };
67228
- const summaryVersion = "1.0.0-beta.56";
67256
+ const summaryVersion = "1.0.0-beta.58";
67229
67257
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67230
67258
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67231
67259
  function mapAttributes(attrs) {
@@ -68014,7 +68042,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68014
68042
  { default: remarkStringify2 },
68015
68043
  { default: remarkGfm2 }
68016
68044
  ] = await Promise.all([
68017
- Promise.resolve().then(() => indexDYnUncjo),
68045
+ Promise.resolve().then(() => indexBWMksCRw),
68018
68046
  Promise.resolve().then(() => indexDRCvimau),
68019
68047
  Promise.resolve().then(() => indexC_x_N6Uh),
68020
68048
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68219,7 +68247,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68219
68247
  * Process collaboration migrations
68220
68248
  */
68221
68249
  processCollaborationMigrations() {
68222
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.56");
68250
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.58");
68223
68251
  if (!this.options.ydoc) return;
68224
68252
  const metaMap = this.options.ydoc.getMap("meta");
68225
68253
  let docVersion = metaMap.get("version");
@@ -70695,6 +70723,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70695
70723
  case "center":
70696
70724
  case "right":
70697
70725
  case "justify":
70726
+ case "left":
70698
70727
  return value;
70699
70728
  case "both":
70700
70729
  case "distribute":
@@ -80250,9 +80279,11 @@ ${l}
80250
80279
  const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
80251
80280
  const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
80252
80281
  if (!isListFirstLine) {
80253
- if (isFirstLine && hasExplicitSegmentPositioning && firstLineOffset !== 0) {
80254
- const adjustedPadding = paraIndentLeft + firstLineOffset;
80255
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
80282
+ if (hasExplicitSegmentPositioning) {
80283
+ if (isFirstLine && firstLineOffset !== 0) {
80284
+ const adjustedPadding = paraIndentLeft + firstLineOffset;
80285
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
80286
+ }
80256
80287
  } else if (paraIndentLeft) {
80257
80288
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
80258
80289
  }
@@ -81683,6 +81714,13 @@ ${l}
81683
81714
  }
81684
81715
  }
81685
81716
  if (hasExplicitPositioning && line.segments) {
81717
+ const paraIndent = block.attrs?.indent;
81718
+ const indentLeft = paraIndent?.left ?? 0;
81719
+ const firstLine = paraIndent?.firstLine ?? 0;
81720
+ const hanging = paraIndent?.hanging ?? 0;
81721
+ const isFirstLineOfPara = lineIndex === 0 || lineIndex === void 0;
81722
+ const firstLineOffsetForCumX = isFirstLineOfPara ? firstLine - hanging : 0;
81723
+ const indentOffset = indentLeft + firstLineOffsetForCumX;
81686
81724
  let cumulativeX = 0;
81687
81725
  const segmentsByRun = /* @__PURE__ */ new Map();
81688
81726
  line.segments.forEach((segment) => {
@@ -81714,7 +81752,7 @@ ${l}
81714
81752
  const actualTabWidth = tabEndX - tabStartX;
81715
81753
  const tabEl = this.doc.createElement("span");
81716
81754
  tabEl.style.position = "absolute";
81717
- tabEl.style.left = `${tabStartX}px`;
81755
+ tabEl.style.left = `${tabStartX + indentOffset}px`;
81718
81756
  tabEl.style.top = "0px";
81719
81757
  tabEl.style.width = `${actualTabWidth}px`;
81720
81758
  tabEl.style.height = `${line.lineHeight}px`;
@@ -81745,12 +81783,13 @@ ${l}
81745
81783
  elem.setAttribute("styleid", styleId);
81746
81784
  }
81747
81785
  const runSegments2 = segmentsByRun.get(runIndex);
81748
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
81786
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
81787
+ const segX = baseSegX + indentOffset;
81749
81788
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : elem.offsetWidth) ?? 0;
81750
81789
  elem.style.position = "absolute";
81751
81790
  elem.style.left = `${segX}px`;
81752
81791
  el.appendChild(elem);
81753
- cumulativeX = segX + segWidth;
81792
+ cumulativeX = baseSegX + segWidth;
81754
81793
  }
81755
81794
  continue;
81756
81795
  }
@@ -81767,12 +81806,13 @@ ${l}
81767
81806
  elem.setAttribute("styleid", styleId);
81768
81807
  }
81769
81808
  const runSegments2 = segmentsByRun.get(runIndex);
81770
- const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
81809
+ const baseSegX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
81810
+ const segX = baseSegX + indentOffset;
81771
81811
  const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
81772
81812
  elem.style.position = "absolute";
81773
81813
  elem.style.left = `${segX}px`;
81774
81814
  el.appendChild(elem);
81775
- cumulativeX = segX + segWidth;
81815
+ cumulativeX = baseSegX + segWidth;
81776
81816
  }
81777
81817
  continue;
81778
81818
  }
@@ -81802,7 +81842,8 @@ ${l}
81802
81842
  if (styleId) {
81803
81843
  elem.setAttribute("styleid", styleId);
81804
81844
  }
81805
- const xPos = segment.x !== void 0 ? segment.x : cumulativeX;
81845
+ const baseX = segment.x !== void 0 ? segment.x : cumulativeX;
81846
+ const xPos = baseX + indentOffset;
81806
81847
  elem.style.position = "absolute";
81807
81848
  elem.style.left = `${xPos}px`;
81808
81849
  el.appendChild(elem);
@@ -81816,7 +81857,7 @@ ${l}
81816
81857
  width = measureEl.offsetWidth;
81817
81858
  this.doc.body.removeChild(measureEl);
81818
81859
  }
81819
- cumulativeX = xPos + width;
81860
+ cumulativeX = baseX + width;
81820
81861
  }
81821
81862
  });
81822
81863
  }
@@ -83192,7 +83233,7 @@ ${l}
83192
83233
  sectionFooterIds: /* @__PURE__ */ new Map(),
83193
83234
  sectionTitlePg: /* @__PURE__ */ new Map()
83194
83235
  });
83195
- function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
83236
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2, converterIds) {
83196
83237
  const identifier = defaultMultiSectionIdentifier();
83197
83238
  identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
83198
83239
  identifier.sectionCount = sectionMetadata.length;
@@ -83227,6 +83268,18 @@ ${l}
83227
83268
  identifier.footerIds = { ...section0Footers };
83228
83269
  }
83229
83270
  identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
83271
+ if (converterIds?.headerIds) {
83272
+ identifier.headerIds.default = identifier.headerIds.default ?? converterIds.headerIds.default ?? null;
83273
+ identifier.headerIds.first = identifier.headerIds.first ?? converterIds.headerIds.first ?? null;
83274
+ identifier.headerIds.even = identifier.headerIds.even ?? converterIds.headerIds.even ?? null;
83275
+ identifier.headerIds.odd = identifier.headerIds.odd ?? converterIds.headerIds.odd ?? null;
83276
+ }
83277
+ if (converterIds?.footerIds) {
83278
+ identifier.footerIds.default = identifier.footerIds.default ?? converterIds.footerIds.default ?? null;
83279
+ identifier.footerIds.first = identifier.footerIds.first ?? converterIds.footerIds.first ?? null;
83280
+ identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
83281
+ identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
83282
+ }
83230
83283
  return identifier;
83231
83284
  }
83232
83285
  function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
@@ -84206,6 +84259,32 @@ ${l}
84206
84259
  state2.page.fragments.push(fragment);
84207
84260
  state2.cursorY += requiredHeight;
84208
84261
  }
84262
+ function getTableIndentWidth(attrs) {
84263
+ if (!attrs) {
84264
+ return 0;
84265
+ }
84266
+ const tableIndent = attrs.tableIndent;
84267
+ if (!tableIndent || typeof tableIndent !== "object") {
84268
+ return 0;
84269
+ }
84270
+ const width = tableIndent.width;
84271
+ if (width === void 0 || width === null) {
84272
+ return 0;
84273
+ }
84274
+ if (typeof width !== "number") {
84275
+ return 0;
84276
+ }
84277
+ if (!Number.isFinite(width)) {
84278
+ return 0;
84279
+ }
84280
+ return width;
84281
+ }
84282
+ function applyTableIndent(x2, width, indent2) {
84283
+ return {
84284
+ x: x2 + indent2,
84285
+ width: Math.max(0, width - indent2)
84286
+ };
84287
+ }
84209
84288
  function calculateColumnMinWidth(columnIndex, measure) {
84210
84289
  const DEFAULT_MIN_WIDTH = 25;
84211
84290
  const measuredWidth = measure.columnWidths[columnIndex] || DEFAULT_MIN_WIDTH;
@@ -84420,14 +84499,18 @@ ${l}
84420
84499
  columnBoundaries: generateColumnBoundaries(context.measure),
84421
84500
  coordinateSystem: "fragment"
84422
84501
  };
84502
+ const tableIndent = getTableIndentWidth(context.block.attrs);
84503
+ const baseX = context.columnX(state2.columnIndex);
84504
+ const baseWidth = Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth);
84505
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
84423
84506
  const fragment = {
84424
84507
  kind: "table",
84425
84508
  blockId: context.block.id,
84426
84509
  fromRow: 0,
84427
84510
  toRow: context.block.rows.length,
84428
- x: context.columnX(state2.columnIndex),
84511
+ x: x2,
84429
84512
  y: state2.cursorY,
84430
- width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
84513
+ width,
84431
84514
  height,
84432
84515
  metadata
84433
84516
  };
@@ -84494,14 +84577,18 @@ ${l}
84494
84577
  columnBoundaries: generateColumnBoundaries(measure),
84495
84578
  coordinateSystem: "fragment"
84496
84579
  };
84580
+ const tableIndent = getTableIndentWidth(block.attrs);
84581
+ const baseX = columnX(state2.columnIndex);
84582
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
84583
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
84497
84584
  const fragment = {
84498
84585
  kind: "table",
84499
84586
  blockId: block.id,
84500
84587
  fromRow: 0,
84501
84588
  toRow: 0,
84502
- x: columnX(state2.columnIndex),
84589
+ x: x2,
84503
84590
  y: state2.cursorY,
84504
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
84591
+ width,
84505
84592
  height,
84506
84593
  metadata
84507
84594
  };
@@ -84549,14 +84636,18 @@ ${l}
84549
84636
  });
84550
84637
  const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
84551
84638
  if (fragmentHeight2 > 0 && madeProgress) {
84639
+ const tableIndent2 = getTableIndentWidth(block.attrs);
84640
+ const baseX2 = columnX(state2.columnIndex);
84641
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
84642
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
84552
84643
  const fragment2 = {
84553
84644
  kind: "table",
84554
84645
  blockId: block.id,
84555
84646
  fromRow: rowIndex,
84556
84647
  toRow: rowIndex + 1,
84557
- x: columnX(state2.columnIndex),
84648
+ x: x22,
84558
84649
  y: state2.cursorY,
84559
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
84650
+ width: width2,
84560
84651
  height: fragmentHeight2,
84561
84652
  continuesFromPrev: true,
84562
84653
  continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
@@ -84589,14 +84680,18 @@ ${l}
84589
84680
  const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
84590
84681
  const forcedEndRow = bodyStartRow + 1;
84591
84682
  const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
84683
+ const tableIndent2 = getTableIndentWidth(block.attrs);
84684
+ const baseX2 = columnX(state2.columnIndex);
84685
+ const baseWidth2 = Math.min(columnWidth, measure.totalWidth || columnWidth);
84686
+ const { x: x22, width: width2 } = applyTableIndent(baseX2, baseWidth2, tableIndent2);
84592
84687
  const fragment2 = {
84593
84688
  kind: "table",
84594
84689
  blockId: block.id,
84595
84690
  fromRow: bodyStartRow,
84596
84691
  toRow: forcedEndRow,
84597
- x: columnX(state2.columnIndex),
84692
+ x: x22,
84598
84693
  y: state2.cursorY,
84599
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
84694
+ width: width2,
84600
84695
  height: fragmentHeight2,
84601
84696
  continuesFromPrev: isTableContinuation,
84602
84697
  continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
@@ -84620,14 +84715,18 @@ ${l}
84620
84715
  measure
84621
84716
  );
84622
84717
  }
84718
+ const tableIndent = getTableIndentWidth(block.attrs);
84719
+ const baseX = columnX(state2.columnIndex);
84720
+ const baseWidth = Math.min(columnWidth, measure.totalWidth || columnWidth);
84721
+ const { x: x2, width } = applyTableIndent(baseX, baseWidth, tableIndent);
84623
84722
  const fragment = {
84624
84723
  kind: "table",
84625
84724
  blockId: block.id,
84626
84725
  fromRow: bodyStartRow,
84627
84726
  toRow: endRow,
84628
- x: columnX(state2.columnIndex),
84727
+ x: x2,
84629
84728
  y: state2.cursorY,
84630
- width: Math.min(columnWidth, measure.totalWidth || columnWidth),
84729
+ width,
84631
84730
  height: fragmentHeight,
84632
84731
  continuesFromPrev: isTableContinuation,
84633
84732
  continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
@@ -89415,7 +89514,15 @@ ${l}
89415
89514
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
89416
89515
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
89417
89516
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
89418
- appendSegment(currentLine.segments, runIndex, wordStartChar, wordEndNoSpace, wordOnlyWidth, segmentStartX);
89517
+ const useExplicitXHere = wordIndex === 0 && segmentStartX !== void 0;
89518
+ appendSegment(
89519
+ currentLine.segments,
89520
+ runIndex,
89521
+ wordStartChar,
89522
+ wordEndNoSpace,
89523
+ wordOnlyWidth,
89524
+ useExplicitXHere ? segmentStartX : void 0
89525
+ );
89419
89526
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
89420
89527
  const completedLine = { ...currentLine, ...metrics };
89421
89528
  addBarTabsToLine(completedLine);
@@ -90139,6 +90246,9 @@ ${l}
90139
90246
  }
90140
90247
  mainEditor.converter[`${type2}s`][sectionId] = updatedData;
90141
90248
  mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
90249
+ if (editor.docChanged && mainEditor.converter) {
90250
+ mainEditor.converter.headerFooterModified = true;
90251
+ }
90142
90252
  await updateYdocDocxData(mainEditor);
90143
90253
  };
90144
90254
  const setEditorToolbar = ({ editor }, mainEditor) => {
@@ -90420,17 +90530,20 @@ ${l}
90420
90530
  * ```
90421
90531
  */
90422
90532
  getDocumentJson(descriptor) {
90423
- if (!descriptor?.id) return null;
90533
+ if (!descriptor?.id) {
90534
+ return null;
90535
+ }
90424
90536
  const liveEntry = __privateGet$1(this, _editorEntries).get(descriptor.id);
90425
90537
  if (liveEntry) {
90426
90538
  try {
90427
- const json = liveEntry.editor.getJSON?.();
90428
- return json;
90539
+ return liveEntry.editor.getJSON?.();
90429
90540
  } catch {
90430
90541
  }
90431
90542
  }
90432
90543
  const collections = __privateGet$1(this, _collections);
90433
- if (!collections) return null;
90544
+ if (!collections) {
90545
+ return null;
90546
+ }
90434
90547
  if (descriptor.kind === "header") {
90435
90548
  return collections.headers?.[descriptor.id] ?? null;
90436
90549
  }
@@ -90816,7 +90929,9 @@ ${l}
90816
90929
  */
90817
90930
  getBatch(kind) {
90818
90931
  const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
90819
- if (!descriptors.length) return void 0;
90932
+ if (!descriptors.length) {
90933
+ return void 0;
90934
+ }
90820
90935
  const batch2 = {};
90821
90936
  let hasBlocks = false;
90822
90937
  descriptors.forEach((descriptor) => {
@@ -91049,13 +91164,7 @@ ${l}
91049
91164
  showEditingOverlay(pageElement, region, zoom) {
91050
91165
  try {
91051
91166
  const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, region.kind);
91052
- if (!decorationContainer) {
91053
- return {
91054
- success: false,
91055
- reason: `Decoration container not found for ${region.kind} on page ${region.pageIndex}`
91056
- };
91057
- }
91058
- const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind);
91167
+ const editorHost = __privateMethod$1(this, _EditorOverlayManager_instances, ensureEditorHost_fn).call(this, pageElement, region.kind, decorationContainer);
91059
91168
  if (!editorHost) {
91060
91169
  return {
91061
91170
  success: false,
@@ -91063,7 +91172,9 @@ ${l}
91063
91172
  };
91064
91173
  }
91065
91174
  __privateMethod$1(this, _EditorOverlayManager_instances, positionEditorHost_fn).call(this, editorHost, region, decorationContainer, zoom);
91066
- decorationContainer.style.visibility = "hidden";
91175
+ if (decorationContainer) {
91176
+ decorationContainer.style.visibility = "hidden";
91177
+ }
91067
91178
  editorHost.style.visibility = "visible";
91068
91179
  editorHost.style.zIndex = EDITOR_HOST_Z_INDEX;
91069
91180
  if (region.kind === "footer") {
@@ -91075,7 +91186,7 @@ ${l}
91075
91186
  }
91076
91187
  }
91077
91188
  }
91078
- __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer);
91189
+ __privateMethod$1(this, _EditorOverlayManager_instances, showHeaderFooterBorder_fn).call(this, pageElement, region, decorationContainer, zoom);
91079
91190
  __privateSet(this, _activeEditorHost, editorHost);
91080
91191
  __privateSet(this, _activeDecorationContainer, decorationContainer);
91081
91192
  __privateSet(this, _activeRegion, region);
@@ -91193,7 +91304,7 @@ ${l}
91193
91304
  const className = kind === "header" ? "superdoc-page-header" : "superdoc-page-footer";
91194
91305
  return pageElement.querySelector(`.${className}`);
91195
91306
  };
91196
- ensureEditorHost_fn = function(pageElement, kind) {
91307
+ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
91197
91308
  const className = kind === "header" ? "superdoc-header-editor-host" : "superdoc-footer-editor-host";
91198
91309
  let editorHost = pageElement.querySelector(`.${className}`);
91199
91310
  if (!editorHost) {
@@ -91208,34 +91319,44 @@ ${l}
91208
91319
  overflow: "hidden",
91209
91320
  boxSizing: "border-box"
91210
91321
  });
91211
- const decorationContainer = __privateMethod$1(this, _EditorOverlayManager_instances, findDecorationContainer_fn).call(this, pageElement, kind);
91212
- if (!decorationContainer) {
91213
- console.error(`[EditorOverlayManager] Decoration container not found for ${kind}`);
91214
- return null;
91322
+ if (decorationContainer) {
91323
+ decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
91324
+ } else {
91325
+ pageElement.appendChild(editorHost);
91215
91326
  }
91216
- decorationContainer.parentNode?.insertBefore(editorHost, decorationContainer.nextSibling);
91217
91327
  }
91218
91328
  return editorHost;
91219
91329
  };
91220
- positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
91221
- const decorationRect = decorationContainer.getBoundingClientRect();
91330
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
91222
91331
  const pageElement = editorHost.parentElement;
91223
91332
  if (!pageElement) {
91224
91333
  console.error("[EditorOverlayManager] Editor host has no parent element");
91225
91334
  return;
91226
91335
  }
91227
- const pageRect = pageElement.getBoundingClientRect();
91228
- const top2 = decorationRect.top - pageRect.top;
91229
- const left2 = decorationRect.left - pageRect.left;
91230
- const width = decorationRect.width;
91231
- const height = decorationRect.height;
91336
+ let top2;
91337
+ let left2;
91338
+ let width;
91339
+ let height;
91340
+ if (decorationContainer) {
91341
+ const decorationRect = decorationContainer.getBoundingClientRect();
91342
+ const pageRect = pageElement.getBoundingClientRect();
91343
+ top2 = decorationRect.top - pageRect.top;
91344
+ left2 = decorationRect.left - pageRect.left;
91345
+ width = decorationRect.width;
91346
+ height = decorationRect.height;
91347
+ } else {
91348
+ top2 = region.localY * zoom;
91349
+ left2 = region.localX * zoom;
91350
+ width = region.width * zoom;
91351
+ height = region.height * zoom;
91352
+ }
91232
91353
  Object.assign(editorHost.style, {
91233
91354
  top: `${top2}px`,
91234
91355
  left: `${left2}px`,
91235
91356
  width: `${width}px`,
91236
91357
  height: `${height}px`
91237
91358
  });
91238
- if (region.kind === "footer") {
91359
+ if (region.kind === "footer" && decorationContainer) {
91239
91360
  const fragment = decorationContainer.querySelector(".superdoc-fragment");
91240
91361
  if (fragment instanceof HTMLElement) {
91241
91362
  const fragmentTop = parseFloat(fragment.style.top) || 0;
@@ -91243,14 +91364,19 @@ ${l}
91243
91364
  }
91244
91365
  }
91245
91366
  };
91246
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer) {
91367
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
91247
91368
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
91248
91369
  __privateSet(this, _borderLine, document.createElement("div"));
91249
91370
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
91250
- const decorationRect = decorationContainer.getBoundingClientRect();
91251
- const pageRect = pageElement.getBoundingClientRect();
91371
+ let topPosition;
91252
91372
  const isHeader = region.kind === "header";
91253
- const topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
91373
+ if (decorationContainer) {
91374
+ const decorationRect = decorationContainer.getBoundingClientRect();
91375
+ const pageRect = pageElement.getBoundingClientRect();
91376
+ topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
91377
+ } else {
91378
+ topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
91379
+ }
91254
91380
  Object.assign(__privateGet$1(this, _borderLine).style, {
91255
91381
  position: "absolute",
91256
91382
  left: "0",
@@ -93856,7 +93982,10 @@ ${l}
93856
93982
  }
93857
93983
  __privateSet(this, _sectionMetadata, sectionMetadata);
93858
93984
  const converter = __privateGet$1(this, _editor3).converter;
93859
- __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
93985
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
93986
+ headerIds: converter?.headerIds,
93987
+ footerIds: converter?.footerIds
93988
+ }));
93860
93989
  const anchorMap = __privateMethod$1(this, _PresentationEditor_instances, computeAnchorMap_fn).call(this, bookmarks, layout);
93861
93990
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout, bookmarks, anchorMap });
93862
93991
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
@@ -94294,41 +94423,71 @@ ${l}
94294
94423
  return { x: left2, width, height, offset: offset2 };
94295
94424
  }
94296
94425
  };
94426
+ computeExpectedSectionType_fn = function(kind, page, sectionFirstPageNumbers) {
94427
+ const sectionIndex = page.sectionIndex ?? 0;
94428
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
94429
+ const sectionPageNumber = typeof firstPageInSection === "number" ? page.number - firstPageInSection + 1 : page.number;
94430
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
94431
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier);
94432
+ let titlePgEnabled = false;
94433
+ let alternateHeaders = false;
94434
+ if (multiSectionId) {
94435
+ titlePgEnabled = multiSectionId.sectionTitlePg?.get(sectionIndex) ?? multiSectionId.titlePg;
94436
+ alternateHeaders = multiSectionId.alternateHeaders;
94437
+ } else if (legacyIdentifier) {
94438
+ titlePgEnabled = legacyIdentifier.titlePg;
94439
+ alternateHeaders = legacyIdentifier.alternateHeaders;
94440
+ }
94441
+ if (sectionPageNumber === 1 && titlePgEnabled) {
94442
+ return "first";
94443
+ }
94444
+ if (alternateHeaders) {
94445
+ return page.number % 2 === 0 ? "even" : "odd";
94446
+ }
94447
+ return "default";
94448
+ };
94297
94449
  rebuildHeaderFooterRegions_fn = function(layout) {
94298
94450
  __privateGet$1(this, _headerRegions).clear();
94299
94451
  __privateGet$1(this, _footerRegions).clear();
94300
94452
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
94301
94453
  if (pageHeight <= 0) return;
94454
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
94455
+ for (const p2 of layout.pages) {
94456
+ const idx = p2.sectionIndex ?? 0;
94457
+ if (!sectionFirstPageNumbers.has(idx)) {
94458
+ sectionFirstPageNumbers.set(idx, p2.number);
94459
+ }
94460
+ }
94302
94461
  layout.pages.forEach((page, pageIndex) => {
94303
94462
  var _a2, _b2;
94304
- const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, page.margins, page);
94305
- if (headerPayload?.hitRegion) {
94306
- __privateGet$1(this, _headerRegions).set(pageIndex, {
94307
- kind: "header",
94308
- headerId: headerPayload.headerId,
94309
- sectionType: headerPayload.sectionType,
94310
- pageIndex,
94311
- pageNumber: page.number,
94312
- localX: headerPayload.hitRegion.x ?? 0,
94313
- localY: headerPayload.hitRegion.y ?? 0,
94314
- width: headerPayload.hitRegion.width ?? headerPayload.box?.width ?? 0,
94315
- height: headerPayload.hitRegion.height ?? headerPayload.box?.height ?? 0
94316
- });
94317
- }
94318
- const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, page.margins, page);
94319
- if (footerPayload?.hitRegion) {
94320
- __privateGet$1(this, _footerRegions).set(pageIndex, {
94321
- kind: "footer",
94322
- headerId: footerPayload.headerId,
94323
- sectionType: footerPayload.sectionType,
94324
- pageIndex,
94325
- pageNumber: page.number,
94326
- localX: footerPayload.hitRegion.x ?? 0,
94327
- localY: footerPayload.hitRegion.y ?? 0,
94328
- width: footerPayload.hitRegion.width ?? footerPayload.box?.width ?? 0,
94329
- height: footerPayload.hitRegion.height ?? footerPayload.box?.height ?? 0
94330
- });
94331
- }
94463
+ const margins = page.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
94464
+ const actualPageHeight = page.size?.h ?? pageHeight;
94465
+ const headerPayload = (_a2 = __privateGet$1(this, _headerDecorationProvider)) == null ? void 0 : _a2.call(this, page.number, margins, page);
94466
+ const headerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "header", margins, actualPageHeight);
94467
+ __privateGet$1(this, _headerRegions).set(pageIndex, {
94468
+ kind: "header",
94469
+ headerId: headerPayload?.headerId,
94470
+ sectionType: headerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "header", page, sectionFirstPageNumbers),
94471
+ pageIndex,
94472
+ pageNumber: page.number,
94473
+ localX: headerPayload?.hitRegion?.x ?? headerBox.x,
94474
+ localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
94475
+ width: headerPayload?.hitRegion?.width ?? headerBox.width,
94476
+ height: headerPayload?.hitRegion?.height ?? headerBox.height
94477
+ });
94478
+ const footerPayload = (_b2 = __privateGet$1(this, _footerDecorationProvider)) == null ? void 0 : _b2.call(this, page.number, margins, page);
94479
+ const footerBox = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, "footer", margins, actualPageHeight);
94480
+ __privateGet$1(this, _footerRegions).set(pageIndex, {
94481
+ kind: "footer",
94482
+ headerId: footerPayload?.headerId,
94483
+ sectionType: footerPayload?.sectionType ?? __privateMethod$1(this, _PresentationEditor_instances, computeExpectedSectionType_fn).call(this, "footer", page, sectionFirstPageNumbers),
94484
+ pageIndex,
94485
+ pageNumber: page.number,
94486
+ localX: footerPayload?.hitRegion?.x ?? footerBox.x,
94487
+ localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
94488
+ width: footerPayload?.hitRegion?.width ?? footerBox.width,
94489
+ height: footerPayload?.hitRegion?.height ?? footerBox.height
94490
+ });
94332
94491
  });
94333
94492
  };
94334
94493
  hitTestHeaderFooterRegion_fn = function(x2, y2) {
@@ -94518,6 +94677,7 @@ ${l}
94518
94677
  };
94519
94678
  exitHeaderFooterMode_fn = function() {
94520
94679
  if (__privateGet$1(this, _session).mode === "body") return;
94680
+ const editedHeaderId = __privateGet$1(this, _session).headerId;
94521
94681
  if (__privateGet$1(this, _activeHeaderFooterEditor)) {
94522
94682
  __privateGet$1(this, _activeHeaderFooterEditor).setEditable(false);
94523
94683
  __privateGet$1(this, _activeHeaderFooterEditor).setOptions({ documentMode: "viewing" });
@@ -94529,6 +94689,12 @@ ${l}
94529
94689
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterModeChanged_fn).call(this);
94530
94690
  __privateMethod$1(this, _PresentationEditor_instances, emitHeaderFooterEditingContext_fn).call(this, __privateGet$1(this, _editor3));
94531
94691
  __privateGet$1(this, _inputBridge)?.notifyTargetChanged();
94692
+ if (editedHeaderId) {
94693
+ __privateGet$1(this, _headerFooterAdapter)?.invalidate(editedHeaderId);
94694
+ }
94695
+ __privateGet$1(this, _headerFooterManager)?.refresh();
94696
+ __privateSet(this, _pendingDocChange, true);
94697
+ __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
94532
94698
  __privateGet$1(this, _editor3).view?.focus();
94533
94699
  };
94534
94700
  getActiveDomTarget_fn = function() {
@@ -94624,29 +94790,15 @@ ${l}
94624
94790
  createDefaultHeaderFooter_fn = function(region) {
94625
94791
  const converter = __privateGet$1(this, _editor3).converter;
94626
94792
  if (!converter) {
94627
- console.error("[PresentationEditor] Converter not available for creating header/footer");
94628
94793
  return;
94629
94794
  }
94630
94795
  const variant = region.sectionType ?? "default";
94631
- try {
94632
- if (region.kind === "header") {
94633
- if (typeof converter.createDefaultHeader === "function") {
94634
- const headerId = converter.createDefaultHeader(variant);
94635
- console.log(`[PresentationEditor] Created default header: ${headerId}`);
94636
- } else {
94637
- console.error("[PresentationEditor] converter.createDefaultHeader is not a function");
94638
- }
94639
- } else if (region.kind === "footer") {
94640
- if (typeof converter.createDefaultFooter === "function") {
94641
- const footerId = converter.createDefaultFooter(variant);
94642
- console.log(`[PresentationEditor] Created default footer: ${footerId}`);
94643
- } else {
94644
- console.error("[PresentationEditor] converter.createDefaultFooter is not a function");
94645
- }
94646
- }
94647
- } catch (error) {
94648
- console.error("[PresentationEditor] Failed to create default header/footer:", error);
94796
+ if (region.kind === "header" && typeof converter.createDefaultHeader === "function") {
94797
+ converter.createDefaultHeader(variant);
94798
+ } else if (region.kind === "footer" && typeof converter.createDefaultFooter === "function") {
94799
+ converter.createDefaultFooter(variant);
94649
94800
  }
94801
+ __privateSet(this, _headerFooterIdentifier, extractIdentifierFromConverter(converter));
94650
94802
  };
94651
94803
  getPageElement_fn = function(pageIndex) {
94652
94804
  if (!__privateGet$1(this, _painterHost)) return null;
@@ -148997,7 +149149,7 @@ ${style2}
148997
149149
  this.config.colors = shuffleArray(this.config.colors);
148998
149150
  this.userColorMap = /* @__PURE__ */ new Map();
148999
149151
  this.colorIndex = 0;
149000
- this.version = "1.0.0-beta.56";
149152
+ this.version = "1.0.0-beta.58";
149001
149153
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
149002
149154
  this.superdocId = config2.superdocId || v4();
149003
149155
  this.colors = this.config.colors;
@@ -151463,7 +151615,7 @@ ${style2}
151463
151615
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
151464
151616
  );
151465
151617
  }
151466
- const indexDYnUncjo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
151618
+ const indexBWMksCRw = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
151467
151619
  __proto__: null,
151468
151620
  unified
151469
151621
  }, Symbol.toStringTag, { value: "Module" }));