superdoc 1.0.0-beta.20 → 1.0.0-beta.22

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 (28) hide show
  1. package/dist/chunks/{PdfViewer-CPnD95lv.es.js → PdfViewer-B42JCeYb.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DbSf6FKU.cjs → PdfViewer-CswYWp1h.cjs} +1 -1
  3. package/dist/chunks/{index-DHhKY9FZ-CyEU4GWR.es.js → index-895wSAjT-C4ksiI6n.es.js} +1 -1
  4. package/dist/chunks/{index-DHhKY9FZ-DORT-UR6.cjs → index-895wSAjT-CWlZl8zz.cjs} +1 -1
  5. package/dist/chunks/{index-DLco7m-w.cjs → index-CK4eX_iu.cjs} +7 -5
  6. package/dist/chunks/{index-BSHAWPko.es.js → index-DBmh710D.es.js} +7 -5
  7. package/dist/chunks/{super-editor.es-B6lsvAAY.cjs → super-editor.es-BkRizaIE.cjs} +594 -105
  8. package/dist/chunks/{super-editor.es-C0tdU_gq.es.js → super-editor.es-V792hb-6.es.js} +594 -105
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-m2x13P8G.js → converter-DhkZt4Pv.js} +9 -9
  12. package/dist/super-editor/chunks/{docx-zipper-CRSKJF-o.js → docx-zipper-Bajmc-RM.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-C9r_Jbbg.js → editor-oZjoYNA0.js} +594 -103
  14. package/dist/super-editor/chunks/{index-DHhKY9FZ.js → index-895wSAjT.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-fnptYAcU.js → toolbar-Bn5LTbq9.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +6 -6
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +600 -109
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -34681,7 +34681,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34681
34681
  }
34682
34682
  return { nodes: nodesToCombine, handled: false };
34683
34683
  };
34684
- const preProcessPageFieldsOnly = (nodes = []) => {
34684
+ const preProcessPageFieldsOnly = (nodes = [], depth = 0) => {
34685
34685
  const processedNodes = [];
34686
34686
  let i2 = 0;
34687
34687
  while (i2 < nodes.length) {
@@ -34702,7 +34702,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34702
34702
  for (let j2 = i2; j2 <= fieldInfo.endIndex; j2++) {
34703
34703
  const passNode = nodes[j2];
34704
34704
  if (Array.isArray(passNode.elements)) {
34705
- const childResult = preProcessPageFieldsOnly(passNode.elements);
34705
+ const childResult = preProcessPageFieldsOnly(passNode.elements, depth + 1);
34706
34706
  passNode.elements = childResult.processedNodes;
34707
34707
  }
34708
34708
  processedNodes.push(passNode);
@@ -34713,7 +34713,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34713
34713
  }
34714
34714
  }
34715
34715
  if (Array.isArray(node2.elements)) {
34716
- const childResult = preProcessPageFieldsOnly(node2.elements);
34716
+ const childResult = preProcessPageFieldsOnly(node2.elements, depth + 1);
34717
34717
  node2.elements = childResult.processedNodes;
34718
34718
  }
34719
34719
  processedNodes.push(node2);
@@ -36389,7 +36389,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36389
36389
  static getStoredSuperdocVersion(docx) {
36390
36390
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
36391
36391
  }
36392
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.20") {
36392
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.22") {
36393
36393
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36394
36394
  }
36395
36395
  /**
@@ -47552,7 +47552,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
47552
47552
  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);
47553
47553
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
47554
47554
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
47555
- 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, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _headerLayoutResults, _footerLayoutResults, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_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, 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, _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;
47555
+ 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, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _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, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _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, 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;
47556
47556
  var GOOD_LEAF_SIZE = 200;
47557
47557
  var RopeSequence = function RopeSequence2() {
47558
47558
  };
@@ -57454,6 +57454,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57454
57454
  return true;
57455
57455
  };
57456
57456
  }
57457
+ const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
57458
+ const handled = changeListLevel(-1, editor, tr);
57459
+ if (handled && dispatch) {
57460
+ dispatch(tr);
57461
+ }
57462
+ return handled;
57463
+ };
57464
+ const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
57465
+ const { tr, state: state2, editor, dispatch } = props;
57466
+ const { node: paragraph2, pos } = findParentNode(isList)(state2.selection) || {};
57467
+ if (!paragraph2) return false;
57468
+ if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph2)) return false;
57469
+ if (checkType === "startParagraph") {
57470
+ const { $from, empty: empty2 } = state2.selection;
57471
+ if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph2)) return false;
57472
+ }
57473
+ const ilvl = getResolvedParagraphProperties(paragraph2).numberingProperties.ilvl;
57474
+ if (ilvl > 0) {
57475
+ const outdented = decreaseListIndent()(props);
57476
+ if (outdented) {
57477
+ tr.scrollIntoView();
57478
+ }
57479
+ return outdented;
57480
+ } else {
57481
+ updateNumberingProperties(null, paragraph2, pos, editor, tr);
57482
+ }
57483
+ if (dispatch) dispatch(tr);
57484
+ return true;
57485
+ };
57486
+ function isVisuallyEmptyParagraph(node2) {
57487
+ if (!node2 || node2.type.name !== "paragraph") return false;
57488
+ let hasHardBreak = false;
57489
+ node2.descendants((n) => {
57490
+ if (n.type && n.type.name === "hardBreak") {
57491
+ hasHardBreak = true;
57492
+ return false;
57493
+ }
57494
+ return true;
57495
+ });
57496
+ if (hasHardBreak) return false;
57497
+ const text2 = (node2.textContent || "").replace(/\u200b/g, "").trim();
57498
+ if (text2.length > 0) return false;
57499
+ let hasInlineLeaf = false;
57500
+ node2.descendants((n) => {
57501
+ if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
57502
+ hasInlineLeaf = true;
57503
+ return false;
57504
+ }
57505
+ return true;
57506
+ });
57507
+ if (hasInlineLeaf) return false;
57508
+ return true;
57509
+ }
57457
57510
  const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
57458
57511
  let predicate;
57459
57512
  if (listType === "orderedList") {
@@ -57473,19 +57526,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57473
57526
  const { from: from2, to } = selection;
57474
57527
  let firstListNode = null;
57475
57528
  let hasNonListParagraphs = false;
57476
- let paragraphsInSelection = [];
57529
+ let allParagraphsInSelection = [];
57477
57530
  state2.doc.nodesBetween(from2, to, (node2, pos) => {
57478
57531
  if (node2.type.name === "paragraph") {
57479
- paragraphsInSelection.push({ node: node2, pos });
57480
- if (!firstListNode && predicate(node2)) {
57481
- firstListNode = node2;
57482
- } else if (!predicate(node2)) {
57483
- hasNonListParagraphs = true;
57484
- }
57532
+ allParagraphsInSelection.push({ node: node2, pos });
57485
57533
  return false;
57486
57534
  }
57487
57535
  return true;
57488
57536
  });
57537
+ let paragraphsInSelection = allParagraphsInSelection.length === 1 ? allParagraphsInSelection : allParagraphsInSelection.filter(({ node: node2 }) => !isVisuallyEmptyParagraph(node2));
57538
+ for (const { node: node2 } of paragraphsInSelection) {
57539
+ if (!firstListNode && predicate(node2)) {
57540
+ firstListNode = node2;
57541
+ } else if (!predicate(node2)) {
57542
+ hasNonListParagraphs = true;
57543
+ }
57544
+ }
57489
57545
  if (!firstListNode && from2 > 0) {
57490
57546
  const $from = state2.doc.resolve(from2);
57491
57547
  const parentIndex = $from.index(-1);
@@ -57529,11 +57585,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57529
57585
  }
57530
57586
  updateNumberingProperties(sharedNumberingProperties, node2, pos, editor, tr);
57531
57587
  }
57532
- const newTo = tr.mapping.map(to);
57533
- if (newTo >= 0 && newTo <= tr.doc.content.size) {
57534
- try {
57535
- tr.setSelection(state2.selection.constructor.near(tr.doc.resolve(newTo)));
57536
- } catch {
57588
+ if (paragraphsInSelection.length > 0) {
57589
+ const firstPara = paragraphsInSelection[0];
57590
+ const lastPara = paragraphsInSelection[paragraphsInSelection.length - 1];
57591
+ const mappedFirstPos = tr.mapping.map(firstPara.pos);
57592
+ const mappedLastPos = tr.mapping.map(lastPara.pos);
57593
+ const $firstPos = tr.doc.resolve(mappedFirstPos);
57594
+ const $lastPos = tr.doc.resolve(mappedLastPos);
57595
+ const firstNode = $firstPos.nodeAfter;
57596
+ const lastNode = $lastPos.nodeAfter;
57597
+ if (firstNode && lastNode) {
57598
+ let selFrom = mappedFirstPos + 1;
57599
+ let selTo = mappedLastPos + lastNode.nodeSize - 1;
57600
+ if (firstNode.firstChild && firstNode.firstChild.type.name === "run") {
57601
+ selFrom = mappedFirstPos + 2;
57602
+ }
57603
+ if (lastNode.lastChild && lastNode.lastChild.type.name === "run") {
57604
+ selTo = mappedLastPos + lastNode.nodeSize - 2;
57605
+ }
57606
+ if (selFrom >= 0 && selTo <= tr.doc.content.size && selFrom <= selTo) {
57607
+ try {
57608
+ tr.setSelection(TextSelection$1.create(tr.doc, selFrom, selTo));
57609
+ } catch {
57610
+ }
57611
+ }
57537
57612
  }
57538
57613
  }
57539
57614
  if (dispatch) dispatch(tr);
@@ -57546,59 +57621,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57546
57621
  }
57547
57622
  return handled;
57548
57623
  };
57549
- const decreaseListIndent = () => ({ editor, tr, dispatch }) => {
57550
- const handled = changeListLevel(-1, editor, tr);
57551
- if (handled && dispatch) {
57552
- dispatch(tr);
57553
- }
57554
- return handled;
57555
- };
57556
- const removeNumberingProperties = ({ checkType = "startParagraph" } = {}) => (props) => {
57557
- const { tr, state: state2, editor, dispatch } = props;
57558
- const { node: paragraph2, pos } = findParentNode(isList)(state2.selection) || {};
57559
- if (!paragraph2) return false;
57560
- if (checkType === "empty" && !isVisuallyEmptyParagraph(paragraph2)) return false;
57561
- if (checkType === "startParagraph") {
57562
- const { $from, empty: empty2 } = state2.selection;
57563
- if ((!empty2 || $from.parentOffset !== 0) && !isVisuallyEmptyParagraph(paragraph2)) return false;
57564
- }
57565
- const ilvl = getResolvedParagraphProperties(paragraph2).numberingProperties.ilvl;
57566
- if (ilvl > 0) {
57567
- const outdented = decreaseListIndent()(props);
57568
- if (outdented) {
57569
- tr.scrollIntoView();
57570
- }
57571
- return outdented;
57572
- } else {
57573
- updateNumberingProperties(null, paragraph2, pos, editor, tr);
57574
- }
57575
- if (dispatch) dispatch(tr);
57576
- return true;
57577
- };
57578
- function isVisuallyEmptyParagraph(node2) {
57579
- if (!node2 || node2.type.name !== "paragraph") return false;
57580
- let hasHardBreak = false;
57581
- node2.descendants((n) => {
57582
- if (n.type && n.type.name === "hardBreak") {
57583
- hasHardBreak = true;
57584
- return false;
57585
- }
57586
- return true;
57587
- });
57588
- if (hasHardBreak) return false;
57589
- const text2 = (node2.textContent || "").replace(/\u200b/g, "").trim();
57590
- if (text2.length > 0) return false;
57591
- let hasInlineLeaf = false;
57592
- node2.descendants((n) => {
57593
- if (n.isInline && n.isLeaf && n.type?.name !== "hardBreak" && n.type?.name !== "run") {
57594
- hasInlineLeaf = true;
57595
- return false;
57596
- }
57597
- return true;
57598
- });
57599
- if (hasInlineLeaf) return false;
57600
- return true;
57601
- }
57602
57624
  const restoreSelection = () => ({ editor, state: state2, tr }) => {
57603
57625
  if (editor.options.lastSelection) {
57604
57626
  const selectionTr = tr.setSelection(
@@ -57681,6 +57703,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57681
57703
  insertTabCharacter,
57682
57704
  insertTabNode,
57683
57705
  isStyleTokenEnabled,
57706
+ isVisuallyEmptyParagraph,
57684
57707
  joinBackward,
57685
57708
  joinDown,
57686
57709
  joinForward,
@@ -57799,12 +57822,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
57799
57822
  const Editable = Extension.create({
57800
57823
  name: "editable",
57801
57824
  addPmPlugins() {
57825
+ const editor = this.editor;
57802
57826
  const editablePlugin = new Plugin({
57803
57827
  key: new PluginKey("editable"),
57804
57828
  props: {
57805
- editable: () => {
57806
- return this.editor.options.editable;
57807
- }
57829
+ editable: () => editor.options.editable,
57830
+ handleDOMEvents: {
57831
+ beforeinput: (_view, event) => {
57832
+ if (!editor.options.editable) {
57833
+ event.preventDefault();
57834
+ return true;
57835
+ }
57836
+ return false;
57837
+ },
57838
+ mousedown: (_view, event) => {
57839
+ if (!editor.options.editable) {
57840
+ event.preventDefault();
57841
+ return true;
57842
+ }
57843
+ return false;
57844
+ },
57845
+ focus: (view, event) => {
57846
+ if (!editor.options.editable) {
57847
+ event.preventDefault();
57848
+ view.dom.blur();
57849
+ return true;
57850
+ }
57851
+ return false;
57852
+ }
57853
+ },
57854
+ handleClick: () => !editor.options.editable,
57855
+ handleDoubleClick: () => !editor.options.editable,
57856
+ handleTripleClick: () => !editor.options.editable
57808
57857
  }
57809
57858
  });
57810
57859
  return [editablePlugin];
@@ -58742,7 +58791,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
58742
58791
  comments.forEach((c2) => {
58743
58792
  commentMap.set(c2.commentId, c2);
58744
58793
  });
58745
- new Set(comments.filter((c2) => c2.parentCommentId).map((c2) => c2.parentCommentId));
58746
58794
  const startNodes = [];
58747
58795
  const endNodes = [];
58748
58796
  const seen = /* @__PURE__ */ new Set();
@@ -61363,7 +61411,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61363
61411
  const shouldSkipNodeView = (editor) => {
61364
61412
  return isHeadless(editor);
61365
61413
  };
61366
- const summaryVersion = "1.0.0-beta.20";
61414
+ const summaryVersion = "1.0.0-beta.22";
61367
61415
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
61368
61416
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
61369
61417
  function mapAttributes(attrs) {
@@ -61768,10 +61816,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61768
61816
  this.view.updateState(this.state);
61769
61817
  }
61770
61818
  /**
61771
- * Set whether the editor is editable
61819
+ * Set whether the editor is editable.
61820
+ *
61821
+ * When setting to non-editable, this method:
61822
+ * - Forces ProseMirror to re-evaluate the editable prop from the Editable plugin
61823
+ * - Blurs the editor to remove the cursor
61824
+ *
61825
+ * @param editable - Whether the editor should accept user input (default: true)
61826
+ * @param emitUpdate - Whether to emit an update event after changing editability (default: true)
61772
61827
  */
61773
61828
  setEditable(editable = true, emitUpdate = true) {
61774
61829
  this.setOptions({ editable });
61830
+ if (this.view) {
61831
+ this.view.setProps({});
61832
+ if (!editable && this.view.dom) {
61833
+ this.view.dom.blur();
61834
+ }
61835
+ }
61775
61836
  if (emitUpdate) {
61776
61837
  this.emit("update", { editor: this, transaction: this.state.tr });
61777
61838
  }
@@ -62139,7 +62200,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62139
62200
  { default: remarkStringify2 },
62140
62201
  { default: remarkGfm2 }
62141
62202
  ] = await Promise.all([
62142
- Promise.resolve().then(() => indexDHhKY9FZ),
62203
+ Promise.resolve().then(() => index895wSAjT),
62143
62204
  Promise.resolve().then(() => indexDRCvimau),
62144
62205
  Promise.resolve().then(() => indexC_x_N6Uh),
62145
62206
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -62344,7 +62405,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62344
62405
  * Process collaboration migrations
62345
62406
  */
62346
62407
  processCollaborationMigrations() {
62347
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.20");
62408
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.22");
62348
62409
  if (!this.options.ydoc) return;
62349
62410
  const metaMap = this.options.ydoc.getMap("meta");
62350
62411
  let docVersion = metaMap.get("version");
@@ -63031,8 +63092,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63031
63092
  const fmt = validFormats.includes(fmtRaw) ? fmtRaw : void 0;
63032
63093
  const startRaw = pgNumType.attributes["w:start"];
63033
63094
  const startNum = startRaw != null ? Number(startRaw) : void 0;
63095
+ const effectiveFormat = fmt ?? (Number.isFinite(startNum) ? "decimal" : void 0);
63034
63096
  return {
63035
- format: fmt,
63097
+ format: effectiveFormat,
63036
63098
  ...Number.isFinite(startNum) ? { start: Number(startNum) } : {}
63037
63099
  };
63038
63100
  }
@@ -70254,6 +70316,84 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70254
70316
  }
70255
70317
  return null;
70256
70318
  };
70319
+ const defaultMultiSectionIdentifier = () => ({
70320
+ headerIds: { default: null, first: null, even: null, odd: null },
70321
+ footerIds: { default: null, first: null, even: null, odd: null },
70322
+ titlePg: false,
70323
+ alternateHeaders: false,
70324
+ sectionCount: 0,
70325
+ sectionHeaderIds: /* @__PURE__ */ new Map(),
70326
+ sectionFooterIds: /* @__PURE__ */ new Map(),
70327
+ sectionTitlePg: /* @__PURE__ */ new Map()
70328
+ });
70329
+ function buildMultiSectionIdentifier(sectionMetadata, pageStyles2) {
70330
+ const identifier = defaultMultiSectionIdentifier();
70331
+ identifier.alternateHeaders = Boolean(pageStyles2?.alternateHeaders ?? false);
70332
+ identifier.sectionCount = sectionMetadata.length;
70333
+ for (const section of sectionMetadata) {
70334
+ const idx = section.sectionIndex;
70335
+ if (section.headerRefs) {
70336
+ identifier.sectionHeaderIds.set(idx, {
70337
+ default: section.headerRefs.default ?? null,
70338
+ first: section.headerRefs.first ?? null,
70339
+ even: section.headerRefs.even ?? null,
70340
+ odd: section.headerRefs.odd ?? null
70341
+ });
70342
+ }
70343
+ if (section.footerRefs) {
70344
+ identifier.sectionFooterIds.set(idx, {
70345
+ default: section.footerRefs.default ?? null,
70346
+ first: section.footerRefs.first ?? null,
70347
+ even: section.footerRefs.even ?? null,
70348
+ odd: section.footerRefs.odd ?? null
70349
+ });
70350
+ }
70351
+ const hasFirstHeader = Boolean(section.headerRefs?.first);
70352
+ const hasFirstFooter = Boolean(section.footerRefs?.first);
70353
+ if (hasFirstHeader || hasFirstFooter) {
70354
+ identifier.sectionTitlePg.set(idx, true);
70355
+ }
70356
+ }
70357
+ const section0Headers = identifier.sectionHeaderIds.get(0);
70358
+ const section0Footers = identifier.sectionFooterIds.get(0);
70359
+ if (section0Headers) {
70360
+ identifier.headerIds = { ...section0Headers };
70361
+ }
70362
+ if (section0Footers) {
70363
+ identifier.footerIds = { ...section0Footers };
70364
+ }
70365
+ identifier.titlePg = identifier.sectionTitlePg.get(0) ?? false;
70366
+ return identifier;
70367
+ }
70368
+ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
70369
+ if (pageNumber <= 0) return null;
70370
+ const kind = options?.kind ?? "header";
70371
+ const sectionPageNumber = options?.sectionPageNumber ?? pageNumber;
70372
+ const sectionIds = kind === "header" ? identifier.sectionHeaderIds.get(sectionIndex) : identifier.sectionFooterIds.get(sectionIndex);
70373
+ const ids = sectionIds ?? (kind === "header" ? identifier.headerIds : identifier.footerIds);
70374
+ const hasFirst = Boolean(ids.first);
70375
+ const hasEven = Boolean(ids.even);
70376
+ const hasOdd = Boolean(ids.odd);
70377
+ const hasDefault = Boolean(ids.default);
70378
+ const sectionTitlePg = identifier.sectionTitlePg.get(sectionIndex) ?? identifier.titlePg;
70379
+ const titlePgEnabled = sectionTitlePg && hasFirst;
70380
+ const isFirstPageOfSection = sectionPageNumber === 1;
70381
+ if (isFirstPageOfSection && titlePgEnabled) {
70382
+ return "first";
70383
+ }
70384
+ if (identifier.alternateHeaders) {
70385
+ if (pageNumber % 2 === 0 && (hasEven || hasDefault)) {
70386
+ return hasEven ? "even" : "default";
70387
+ }
70388
+ if (pageNumber % 2 === 1 && (hasOdd || hasDefault)) {
70389
+ return hasOdd ? "odd" : "default";
70390
+ }
70391
+ }
70392
+ if (hasDefault) {
70393
+ return "default";
70394
+ }
70395
+ return null;
70396
+ }
70257
70397
  function createFloatingObjectManager(columns, margins, pageWidth) {
70258
70398
  const zones = [];
70259
70399
  const marginLeft = Math.max(0, margins?.left ?? 0);
@@ -71404,23 +71544,54 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71404
71544
  const headerCount = countHeaderRows(block);
71405
71545
  const headerHeight = headerCount > 0 ? sumRowHeights(measure.rows, 0, headerCount) : 0;
71406
71546
  let state2 = ensurePage();
71547
+ const availableHeight = state2.contentBottom - state2.cursorY;
71548
+ let minRequiredHeight = 0;
71549
+ if (measure.rows.length > 0) {
71550
+ minRequiredHeight = sumRowHeights(measure.rows, 0, 1);
71551
+ } else if (measure.totalHeight > 0) {
71552
+ minRequiredHeight = measure.totalHeight;
71553
+ }
71554
+ if (minRequiredHeight > availableHeight && state2.page.fragments.length > 0) {
71555
+ state2 = advanceColumn(state2);
71556
+ }
71407
71557
  let currentRow = 0;
71408
71558
  let isTableContinuation = false;
71409
71559
  let pendingPartialRow = null;
71560
+ if (block.rows.length === 0 && measure.totalHeight > 0) {
71561
+ const height = Math.min(measure.totalHeight, state2.contentBottom - state2.cursorY);
71562
+ const metadata = {
71563
+ columnBoundaries: generateColumnBoundaries(measure),
71564
+ coordinateSystem: "fragment"
71565
+ };
71566
+ const fragment = {
71567
+ kind: "table",
71568
+ blockId: block.id,
71569
+ fromRow: 0,
71570
+ toRow: 0,
71571
+ x: columnX(state2.columnIndex),
71572
+ y: state2.cursorY,
71573
+ width: Math.min(columnWidth, measure.totalWidth || columnWidth),
71574
+ height,
71575
+ metadata
71576
+ };
71577
+ state2.page.fragments.push(fragment);
71578
+ state2.cursorY += height;
71579
+ return;
71580
+ }
71410
71581
  while (currentRow < block.rows.length || pendingPartialRow !== null) {
71411
71582
  state2 = ensurePage();
71412
- const availableHeight = state2.contentBottom - state2.cursorY;
71583
+ const availableHeight2 = state2.contentBottom - state2.cursorY;
71413
71584
  let repeatHeaderCount = 0;
71414
71585
  if (currentRow === 0 && !pendingPartialRow) {
71415
71586
  repeatHeaderCount = 0;
71416
71587
  } else {
71417
- if (headerCount > 0 && headerHeight <= availableHeight) {
71588
+ if (headerCount > 0 && headerHeight <= availableHeight2) {
71418
71589
  repeatHeaderCount = headerCount;
71419
- } else if (headerCount > 0 && headerHeight > availableHeight) {
71590
+ } else if (headerCount > 0 && headerHeight > availableHeight2) {
71420
71591
  repeatHeaderCount = 0;
71421
71592
  }
71422
71593
  }
71423
- const availableForBody = repeatHeaderCount > 0 ? availableHeight - headerHeight : availableHeight;
71594
+ const availableForBody = repeatHeaderCount > 0 ? availableHeight2 - headerHeight : availableHeight2;
71424
71595
  const fullPageHeight = state2.contentBottom;
71425
71596
  if (pendingPartialRow !== null) {
71426
71597
  const rowIndex = pendingPartialRow.rowIndex;
@@ -71799,7 +71970,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71799
71970
  let currentSectionIndex = -1;
71800
71971
  for (let i2 = 0; i2 < pages.length; i2++) {
71801
71972
  const page = pages[i2];
71802
- const pageSectionIndex = 0;
71973
+ const pageSectionIndex = page.sectionIndex ?? 0;
71803
71974
  if (pageSectionIndex !== currentSectionIndex) {
71804
71975
  const sectionMetadata2 = sectionMap.get(pageSectionIndex);
71805
71976
  if (sectionMetadata2?.numbering?.start !== void 0) {
@@ -72048,6 +72219,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72048
72219
  };
72049
72220
  layoutLog(`[Layout] First section: Scheduled pendingSectionRefs:`, pendingSectionRefs);
72050
72221
  }
72222
+ const firstSectionIndexRaw = block.attrs?.sectionIndex;
72223
+ const firstMetadataIndex = typeof firstSectionIndexRaw === "number" ? firstSectionIndexRaw : Number(firstSectionIndexRaw ?? NaN);
72224
+ if (Number.isFinite(firstMetadataIndex)) {
72225
+ activeSectionIndex = firstMetadataIndex;
72226
+ }
72227
+ const firstSectionMetadata = Number.isFinite(firstMetadataIndex) ? sectionMetadataList[firstMetadataIndex] : void 0;
72228
+ if (firstSectionMetadata?.numbering) {
72229
+ if (firstSectionMetadata.numbering.format) activeNumberFormat = firstSectionMetadata.numbering.format;
72230
+ if (typeof firstSectionMetadata.numbering.start === "number") {
72231
+ activePageCounter = firstSectionMetadata.numbering.start;
72232
+ }
72233
+ }
72051
72234
  return { decision: { forcePageBreak: false, forceMidPageRegion: false }, state: next2 };
72052
72235
  }
72053
72236
  const headerPx = block.margins?.header;
@@ -72064,7 +72247,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72064
72247
  if (block.orientation) next2.pendingOrientation = block.orientation;
72065
72248
  const sectionType = block.type ?? "continuous";
72066
72249
  const isColumnsChanging = !!block.columns && (block.columns.count !== next2.activeColumns.count || block.columns.gap !== next2.activeColumns.gap);
72067
- if (block.numbering) {
72250
+ const sectionIndexRaw = block.attrs?.sectionIndex;
72251
+ const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
72252
+ if (Number.isFinite(metadataIndex)) {
72253
+ pendingSectionIndex = metadataIndex;
72254
+ }
72255
+ const sectionMetadata = Number.isFinite(metadataIndex) ? sectionMetadataList[metadataIndex] : void 0;
72256
+ if (sectionMetadata?.numbering) {
72257
+ pendingNumbering = { ...sectionMetadata.numbering };
72258
+ } else if (block.numbering) {
72068
72259
  pendingNumbering = { ...block.numbering };
72069
72260
  }
72070
72261
  if (block.headerRefs || block.footerRefs) {
@@ -72133,6 +72324,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72133
72324
  ...initialSectionMetadata.footerRefs && { footerRefs: initialSectionMetadata.footerRefs }
72134
72325
  };
72135
72326
  }
72327
+ let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
72328
+ let pendingSectionIndex = null;
72136
72329
  const paginator = createPaginator({
72137
72330
  margins: { left: margins.left, right: margins.right },
72138
72331
  getActiveTopMargin: () => activeTopMargin,
@@ -72189,6 +72382,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72189
72382
  activeSectionRefs = pendingSectionRefs;
72190
72383
  pendingSectionRefs = null;
72191
72384
  }
72385
+ if (pendingSectionIndex !== null) {
72386
+ activeSectionIndex = pendingSectionIndex;
72387
+ pendingSectionIndex = null;
72388
+ }
72192
72389
  if (pendingVAlign !== null) {
72193
72390
  activeVAlign = pendingVAlign;
72194
72391
  pendingVAlign = null;
@@ -72198,6 +72395,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72198
72395
  }
72199
72396
  if (state2?.page) {
72200
72397
  state2.page.numberText = formatPageNumber(activePageCounter, activeNumberFormat);
72398
+ state2.page.sectionIndex = activeSectionIndex;
72399
+ layoutLog(`[Layout] Page ${state2.page.number}: Stamped sectionIndex:`, activeSectionIndex);
72201
72400
  if (activeSectionRefs) {
72202
72401
  state2.page.sectionRefs = {
72203
72402
  ...activeSectionRefs.headerRefs && { headerRefs: activeSectionRefs.headerRefs },
@@ -72384,8 +72583,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72384
72583
  activeOrientation = updatedState.activeOrientation;
72385
72584
  pendingOrientation = updatedState.pendingOrientation;
72386
72585
  if (effectiveBlock.vAlign) {
72387
- const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
72388
- if (isFirstSection) {
72586
+ const isFirstSection2 = effectiveBlock.attrs?.isFirstSection && states.length === 0;
72587
+ if (isFirstSection2) {
72389
72588
  activeVAlign = effectiveBlock.vAlign;
72390
72589
  pendingVAlign = null;
72391
72590
  } else {
@@ -72399,6 +72598,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72399
72598
  };
72400
72599
  layoutLog(`[Layout] After scheduleSectionBreakCompat: Scheduled pendingSectionRefs:`, pendingSectionRefs);
72401
72600
  }
72601
+ const sectionIndexRaw = effectiveBlock.attrs?.sectionIndex;
72602
+ const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
72603
+ const isFirstSection = effectiveBlock.attrs?.isFirstSection && states.length === 0;
72604
+ if (Number.isFinite(metadataIndex)) {
72605
+ if (isFirstSection) {
72606
+ activeSectionIndex = metadataIndex;
72607
+ } else {
72608
+ pendingSectionIndex = metadataIndex;
72609
+ }
72610
+ }
72611
+ const sectionMetadata = Number.isFinite(metadataIndex) ? sectionMetadataList[metadataIndex] : void 0;
72612
+ if (sectionMetadata?.numbering) {
72613
+ if (isFirstSection) {
72614
+ if (sectionMetadata.numbering.format) activeNumberFormat = sectionMetadata.numbering.format;
72615
+ if (typeof sectionMetadata.numbering.start === "number") {
72616
+ activePageCounter = sectionMetadata.numbering.start;
72617
+ }
72618
+ } else {
72619
+ pendingNumbering = { ...sectionMetadata.numbering };
72620
+ }
72621
+ } else if (effectiveBlock.numbering) {
72622
+ if (isFirstSection) {
72623
+ if (effectiveBlock.numbering.format) activeNumberFormat = effectiveBlock.numbering.format;
72624
+ if (typeof effectiveBlock.numbering.start === "number") {
72625
+ activePageCounter = effectiveBlock.numbering.start;
72626
+ }
72627
+ } else {
72628
+ pendingNumbering = { ...effectiveBlock.numbering };
72629
+ }
72630
+ }
72402
72631
  if (breakInfo.forceMidPageRegion && block.columns) {
72403
72632
  let state2 = paginator.ensurePage();
72404
72633
  const columnIndexBefore = state2.columnIndex;
@@ -73378,8 +73607,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73378
73607
  const { totalPages: docTotalPages } = pageResolver(1);
73379
73608
  const useBucketing = FeatureFlags.HF_DIGIT_BUCKETING && docTotalPages >= MIN_PAGES_FOR_BUCKETING;
73380
73609
  for (const [type2, blocks2] of Object.entries(sections)) {
73381
- if (!blocks2 || blocks2.length === 0) continue;
73382
- if (!hasPageTokens(blocks2)) {
73610
+ if (!blocks2 || blocks2.length === 0) {
73611
+ continue;
73612
+ }
73613
+ const hasTokens = hasPageTokens(blocks2);
73614
+ if (!hasTokens) {
73383
73615
  const measures = await cache2.measureBlocks(blocks2, constraints, measureBlock2);
73384
73616
  const layout = layoutHeaderFooter(blocks2, measures, constraints);
73385
73617
  result[type2] = { blocks: blocks2, measures, layout };
@@ -73401,7 +73633,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73401
73633
  for (const pageNum of pagesToLayout) {
73402
73634
  const clonedBlocks = cloneHeaderFooterBlocks(blocks2);
73403
73635
  const { displayText, totalPages: totalPagesForPage } = pageResolver(pageNum);
73404
- resolveHeaderFooterTokens(clonedBlocks, parseInt(displayText, 10) || pageNum, totalPagesForPage);
73636
+ const resolvedPageNum = parseInt(displayText, 10) || pageNum;
73637
+ resolveHeaderFooterTokens(clonedBlocks, resolvedPageNum, totalPagesForPage);
73405
73638
  const measures = await cache2.measureBlocks(clonedBlocks, constraints, measureBlock2);
73406
73639
  const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints);
73407
73640
  pages.push({
@@ -80243,9 +80476,36 @@ ${l}
80243
80476
  }
80244
80477
  return base2;
80245
80478
  };
80479
+ const hasListMarkerProperties = (attrs) => {
80480
+ if (!attrs || typeof attrs !== "object") return false;
80481
+ const obj = attrs;
80482
+ if (!obj.numberingProperties || typeof obj.numberingProperties !== "object") return false;
80483
+ const numProps = obj.numberingProperties;
80484
+ if ("numId" in numProps) {
80485
+ const numId = numProps.numId;
80486
+ if (typeof numId !== "number" && typeof numId !== "string") return false;
80487
+ }
80488
+ if ("ilvl" in numProps) {
80489
+ const ilvl = numProps.ilvl;
80490
+ if (typeof ilvl !== "number") return false;
80491
+ }
80492
+ if ("wordLayout" in obj && obj.wordLayout !== void 0) {
80493
+ if (typeof obj.wordLayout !== "object" || obj.wordLayout === null) return false;
80494
+ const wordLayout = obj.wordLayout;
80495
+ if ("marker" in wordLayout && wordLayout.marker !== void 0) {
80496
+ if (typeof wordLayout.marker !== "object" || wordLayout.marker === null) return false;
80497
+ const marker = wordLayout.marker;
80498
+ if ("markerText" in marker && marker.markerText !== void 0) {
80499
+ if (typeof marker.markerText !== "string") return false;
80500
+ }
80501
+ }
80502
+ }
80503
+ return true;
80504
+ };
80246
80505
  const deriveBlockVersion = (block) => {
80247
80506
  if (block.kind === "paragraph") {
80248
- return block.runs.map((run2) => {
80507
+ const markerVersion = hasListMarkerProperties(block.attrs) ? `marker:${block.attrs.numberingProperties.numId ?? ""}:${block.attrs.numberingProperties.ilvl ?? 0}:${block.attrs.wordLayout?.marker?.markerText ?? ""}` : "";
80508
+ const runsVersion = block.runs.map((run2) => {
80249
80509
  if (run2.kind === "image") {
80250
80510
  const imgRun = run2;
80251
80511
  return [
@@ -80288,6 +80548,7 @@ ${l}
80288
80548
  textRun.token ?? ""
80289
80549
  ].join(",");
80290
80550
  }).join("|");
80551
+ return markerVersion ? `${markerVersion}|${runsVersion}` : runsVersion;
80291
80552
  }
80292
80553
  if (block.kind === "list") {
80293
80554
  return block.items.map((item) => `${item.id}:${item.marker.text}:${deriveBlockVersion(item.paragraph)}`).join("|");
@@ -82706,6 +82967,49 @@ ${l}
82706
82967
  });
82707
82968
  return hasBlocks ? batch2 : void 0;
82708
82969
  }
82970
+ /**
82971
+ * Retrieves FlowBlocks for ALL header/footer content, keyed by relationship ID.
82972
+ *
82973
+ * Unlike getBatch() which only returns content for variant-associated IDs,
82974
+ * this method returns content for ALL registered header/footer IDs. This is
82975
+ * essential for multi-section documents where different sections may use
82976
+ * different content for the same variant type.
82977
+ *
82978
+ * @param kind - The type of section to retrieve: 'header' or 'footer'
82979
+ * @returns A Map of rId to FlowBlock arrays, or undefined if no content exists
82980
+ *
82981
+ * @example
82982
+ * ```typescript
82983
+ * const footersByRId = adapter.getBlocksByRId('footer');
82984
+ * if (footersByRId) {
82985
+ * // footersByRId.get('rId14') - blocks for footer with rId14
82986
+ * // footersByRId.get('rId18') - blocks for footer with rId18 (different section)
82987
+ * }
82988
+ * ```
82989
+ */
82990
+ getBlocksByRId(kind) {
82991
+ const descriptors = __privateGet$1(this, _manager).getDescriptors(kind);
82992
+ if (!descriptors.length) return void 0;
82993
+ const blocksMap = /* @__PURE__ */ new Map();
82994
+ descriptors.forEach((descriptor) => {
82995
+ const blocks2 = __privateMethod$1(this, _HeaderFooterLayoutAdapter_instances, getBlocks_fn).call(this, descriptor);
82996
+ if (blocks2 && blocks2.length > 0) {
82997
+ blocksMap.set(descriptor.id, blocks2);
82998
+ }
82999
+ });
83000
+ return blocksMap.size > 0 ? blocksMap : void 0;
83001
+ }
83002
+ /**
83003
+ * Retrieves FlowBlocks for a specific header/footer by its relationship ID.
83004
+ *
83005
+ * @param rId - The relationship ID (e.g., 'rId14')
83006
+ * @returns FlowBlock array for the specified rId, or undefined if not found
83007
+ */
83008
+ getBlocksForRId(rId) {
83009
+ const descriptor = __privateGet$1(this, _manager).getDescriptorById(rId);
83010
+ if (!descriptor) return void 0;
83011
+ return __privateMethod$1(this, _HeaderFooterLayoutAdapter_instances, getBlocks_fn).call(this, descriptor);
83012
+ }
82709
83013
  /**
82710
83014
  * Invalidates the cached FlowBlocks for a specific header/footer section.
82711
83015
  *
@@ -83166,8 +83470,11 @@ ${l}
83166
83470
  __privateAdd$1(this, _headerFooterManager, null);
83167
83471
  __privateAdd$1(this, _headerFooterAdapter, null);
83168
83472
  __privateAdd$1(this, _headerFooterIdentifier, null);
83473
+ __privateAdd$1(this, _multiSectionIdentifier, null);
83169
83474
  __privateAdd$1(this, _headerLayoutResults, null);
83170
83475
  __privateAdd$1(this, _footerLayoutResults, null);
83476
+ __privateAdd$1(this, _headerLayoutsByRId, /* @__PURE__ */ new Map());
83477
+ __privateAdd$1(this, _footerLayoutsByRId, /* @__PURE__ */ new Map());
83171
83478
  __privateAdd$1(this, _headerDecorationProvider);
83172
83479
  __privateAdd$1(this, _footerDecorationProvider);
83173
83480
  __privateAdd$1(this, _headerFooterManagerCleanups, []);
@@ -84324,8 +84631,11 @@ ${l}
84324
84631
  __privateSet(this, _headerFooterManager, null);
84325
84632
  }, "Header/footer manager");
84326
84633
  __privateSet(this, _headerFooterIdentifier, null);
84634
+ __privateSet(this, _multiSectionIdentifier, null);
84327
84635
  __privateSet(this, _headerLayoutResults, null);
84328
84636
  __privateSet(this, _footerLayoutResults, null);
84637
+ __privateGet$1(this, _headerLayoutsByRId).clear();
84638
+ __privateGet$1(this, _footerLayoutsByRId).clear();
84329
84639
  __privateSet(this, _headerDecorationProvider, void 0);
84330
84640
  __privateSet(this, _footerDecorationProvider, void 0);
84331
84641
  __privateSet(this, _session, { mode: "body" });
@@ -84379,8 +84689,11 @@ ${l}
84379
84689
  _headerFooterManager = /* @__PURE__ */ new WeakMap();
84380
84690
  _headerFooterAdapter = /* @__PURE__ */ new WeakMap();
84381
84691
  _headerFooterIdentifier = /* @__PURE__ */ new WeakMap();
84692
+ _multiSectionIdentifier = /* @__PURE__ */ new WeakMap();
84382
84693
  _headerLayoutResults = /* @__PURE__ */ new WeakMap();
84383
84694
  _footerLayoutResults = /* @__PURE__ */ new WeakMap();
84695
+ _headerLayoutsByRId = /* @__PURE__ */ new WeakMap();
84696
+ _footerLayoutsByRId = /* @__PURE__ */ new WeakMap();
84384
84697
  _headerDecorationProvider = /* @__PURE__ */ new WeakMap();
84385
84698
  _footerDecorationProvider = /* @__PURE__ */ new WeakMap();
84386
84699
  _headerFooterManagerCleanups = /* @__PURE__ */ new WeakMap();
@@ -84739,7 +85052,12 @@ ${l}
84739
85052
  setupInputBridge_fn = function() {
84740
85053
  __privateGet$1(this, _inputBridge)?.destroy();
84741
85054
  const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
84742
- __privateSet(this, _inputBridge, new PresentationInputBridge(win, __privateGet$1(this, _visibleHost), () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this)));
85055
+ __privateSet(this, _inputBridge, new PresentationInputBridge(
85056
+ win,
85057
+ __privateGet$1(this, _visibleHost),
85058
+ () => __privateMethod$1(this, _PresentationEditor_instances, getActiveDomTarget_fn).call(this),
85059
+ () => __privateGet$1(this, _documentMode) !== "viewing"
85060
+ ));
84743
85061
  __privateGet$1(this, _inputBridge).bind();
84744
85062
  };
84745
85063
  initHeaderFooterRegistry_fn = function() {
@@ -84974,11 +85292,11 @@ ${l}
84974
85292
  const sectionMetadata = [];
84975
85293
  let blocks2;
84976
85294
  try {
84977
- const converter = __privateGet$1(this, _editor3).converter;
84978
- const converterContext = converter ? {
84979
- docx: converter.convertedXml,
84980
- numbering: converter.numbering,
84981
- linkedStyles: converter.linkedStyles
85295
+ const converter2 = __privateGet$1(this, _editor3).converter;
85296
+ const converterContext = converter2 ? {
85297
+ docx: converter2.convertedXml,
85298
+ numbering: converter2.numbering,
85299
+ linkedStyles: converter2.linkedStyles
84982
85300
  } : void 0;
84983
85301
  const result = toFlowBlocks(docJson, {
84984
85302
  mediaFiles: __privateGet$1(this, _options).mediaFiles,
@@ -85036,9 +85354,12 @@ ${l}
85036
85354
  return;
85037
85355
  }
85038
85356
  __privateSet(this, _sectionMetadata, sectionMetadata);
85357
+ const converter = __privateGet$1(this, _editor3).converter;
85358
+ __privateSet(this, _multiSectionIdentifier, buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles));
85039
85359
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout });
85040
85360
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
85041
85361
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
85362
+ await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
85042
85363
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
85043
85364
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks2, measures);
85044
85365
  if (typeof painter.setProviders === "function") {
@@ -85052,6 +85373,10 @@ ${l}
85052
85373
  headerMeasures.push(...headerResult.measures);
85053
85374
  }
85054
85375
  }
85376
+ for (const rIdResult of __privateGet$1(this, _headerLayoutsByRId).values()) {
85377
+ headerBlocks.push(...rIdResult.blocks);
85378
+ headerMeasures.push(...rIdResult.measures);
85379
+ }
85055
85380
  const footerBlocks = [];
85056
85381
  const footerMeasures = [];
85057
85382
  if (footerLayouts) {
@@ -85060,6 +85385,10 @@ ${l}
85060
85385
  footerMeasures.push(...footerResult.measures);
85061
85386
  }
85062
85387
  }
85388
+ for (const rIdResult of __privateGet$1(this, _footerLayoutsByRId).values()) {
85389
+ footerBlocks.push(...rIdResult.blocks);
85390
+ footerMeasures.push(...rIdResult.measures);
85391
+ }
85063
85392
  painter.setData?.(
85064
85393
  blocks2,
85065
85394
  measures,
@@ -85116,6 +85445,10 @@ ${l}
85116
85445
  if (!__privateGet$1(this, _localSelectionLayer)) {
85117
85446
  return;
85118
85447
  }
85448
+ if (__privateGet$1(this, _documentMode) === "viewing") {
85449
+ __privateGet$1(this, _localSelectionLayer).innerHTML = "";
85450
+ return;
85451
+ }
85119
85452
  const layout = __privateGet$1(this, _layoutState).layout;
85120
85453
  const selection = this.getActiveEditor().state?.selection;
85121
85454
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
@@ -85165,7 +85498,9 @@ ${l}
85165
85498
  }
85166
85499
  const headerBlocks = __privateGet$1(this, _headerFooterAdapter).getBatch("header");
85167
85500
  const footerBlocks = __privateGet$1(this, _headerFooterAdapter).getBatch("footer");
85168
- if (!headerBlocks && !footerBlocks) {
85501
+ const headerBlocksByRId = __privateGet$1(this, _headerFooterAdapter).getBlocksByRId("header");
85502
+ const footerBlocksByRId = __privateGet$1(this, _headerFooterAdapter).getBlocksByRId("footer");
85503
+ if (!headerBlocks && !footerBlocks && !headerBlocksByRId && !footerBlocksByRId) {
85169
85504
  return null;
85170
85505
  }
85171
85506
  const constraints = __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterConstraints_fn).call(this);
@@ -85175,6 +85510,8 @@ ${l}
85175
85510
  return {
85176
85511
  headerBlocks,
85177
85512
  footerBlocks,
85513
+ headerBlocksByRId,
85514
+ footerBlocksByRId,
85178
85515
  constraints
85179
85516
  };
85180
85517
  };
@@ -85197,6 +85534,80 @@ ${l}
85197
85534
  margins: { left: marginLeft, right: marginRight }
85198
85535
  };
85199
85536
  };
85537
+ layoutPerRIdHeaderFooters_fn = async function(headerFooterInput, layout, sectionMetadata) {
85538
+ __privateGet$1(this, _headerLayoutsByRId).clear();
85539
+ __privateGet$1(this, _footerLayoutsByRId).clear();
85540
+ if (!headerFooterInput) return;
85541
+ const { headerBlocksByRId, footerBlocksByRId, constraints } = headerFooterInput;
85542
+ const displayPages = computeDisplayPageNumber(layout.pages, sectionMetadata);
85543
+ const totalPages = layout.pages.length;
85544
+ const pageResolver = (pageNumber) => {
85545
+ const pageIndex = pageNumber - 1;
85546
+ const displayInfo = displayPages[pageIndex];
85547
+ return {
85548
+ displayText: displayInfo?.displayText ?? String(pageNumber),
85549
+ totalPages
85550
+ };
85551
+ };
85552
+ if (headerBlocksByRId) {
85553
+ for (const [rId, blocks2] of headerBlocksByRId) {
85554
+ if (!blocks2 || blocks2.length === 0) continue;
85555
+ try {
85556
+ const batchResult = await layoutHeaderFooterWithCache(
85557
+ { default: blocks2 },
85558
+ // Treat each rId as a 'default' variant
85559
+ constraints,
85560
+ (block, c2) => measureBlock(block, c2),
85561
+ void 0,
85562
+ // Use shared cache
85563
+ void 0,
85564
+ // No legacy totalPages
85565
+ pageResolver
85566
+ );
85567
+ if (batchResult.default) {
85568
+ __privateGet$1(this, _headerLayoutsByRId).set(rId, {
85569
+ kind: "header",
85570
+ type: "default",
85571
+ layout: batchResult.default.layout,
85572
+ blocks: batchResult.default.blocks,
85573
+ measures: batchResult.default.measures
85574
+ });
85575
+ }
85576
+ } catch (error) {
85577
+ console.warn(`[PresentationEditor] Failed to layout header rId=${rId}:`, error);
85578
+ }
85579
+ }
85580
+ }
85581
+ if (footerBlocksByRId) {
85582
+ for (const [rId, blocks2] of footerBlocksByRId) {
85583
+ if (!blocks2 || blocks2.length === 0) continue;
85584
+ try {
85585
+ const batchResult = await layoutHeaderFooterWithCache(
85586
+ { default: blocks2 },
85587
+ // Treat each rId as a 'default' variant
85588
+ constraints,
85589
+ (block, c2) => measureBlock(block, c2),
85590
+ void 0,
85591
+ // Use shared cache
85592
+ void 0,
85593
+ // No legacy totalPages
85594
+ pageResolver
85595
+ );
85596
+ if (batchResult.default) {
85597
+ __privateGet$1(this, _footerLayoutsByRId).set(rId, {
85598
+ kind: "footer",
85599
+ type: "default",
85600
+ layout: batchResult.default.layout,
85601
+ blocks: batchResult.default.blocks,
85602
+ measures: batchResult.default.measures
85603
+ });
85604
+ }
85605
+ } catch (error) {
85606
+ console.warn(`[PresentationEditor] Failed to layout footer rId=${rId}:`, error);
85607
+ }
85608
+ }
85609
+ }
85610
+ };
85200
85611
  updateDecorationProviders_fn = function(layout) {
85201
85612
  __privateSet(this, _headerDecorationProvider, __privateMethod$1(this, _PresentationEditor_instances, createDecorationProvider_fn).call(this, "header", layout));
85202
85613
  __privateSet(this, _footerDecorationProvider, __privateMethod$1(this, _PresentationEditor_instances, createDecorationProvider_fn).call(this, "footer", layout));
@@ -85204,15 +85615,63 @@ ${l}
85204
85615
  };
85205
85616
  createDecorationProvider_fn = function(kind, layout) {
85206
85617
  const results = kind === "header" ? __privateGet$1(this, _headerLayoutResults) : __privateGet$1(this, _footerLayoutResults);
85207
- if (!results || results.length === 0) {
85618
+ const layoutsByRId = kind === "header" ? __privateGet$1(this, _headerLayoutsByRId) : __privateGet$1(this, _footerLayoutsByRId);
85619
+ if ((!results || results.length === 0) && layoutsByRId.size === 0) {
85208
85620
  return void 0;
85209
85621
  }
85210
- const identifier = __privateGet$1(this, _headerFooterIdentifier) ?? extractIdentifierFromConverter(__privateGet$1(this, _editor3).converter);
85622
+ const multiSectionId = __privateGet$1(this, _multiSectionIdentifier);
85623
+ const legacyIdentifier = __privateGet$1(this, _headerFooterIdentifier) ?? extractIdentifierFromConverter(__privateGet$1(this, _editor3).converter);
85624
+ const sectionFirstPageNumbers = /* @__PURE__ */ new Map();
85625
+ for (const p2 of layout.pages) {
85626
+ const idx = p2.sectionIndex ?? 0;
85627
+ if (!sectionFirstPageNumbers.has(idx)) {
85628
+ sectionFirstPageNumbers.set(idx, p2.number);
85629
+ }
85630
+ }
85211
85631
  return (pageNumber, pageMargins, page) => {
85212
- const headerFooterType = getHeaderFooterType(pageNumber, identifier, { kind });
85632
+ const sectionIndex = page?.sectionIndex ?? 0;
85633
+ const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
85634
+ const sectionPageNumber = typeof firstPageInSection === "number" ? pageNumber - firstPageInSection + 1 : pageNumber;
85635
+ const headerFooterType = multiSectionId ? getHeaderFooterTypeForSection(pageNumber, sectionIndex, multiSectionId, { kind, sectionPageNumber }) : getHeaderFooterType(pageNumber, legacyIdentifier, { kind });
85636
+ const sectionRId = page?.sectionRefs && kind === "header" ? page.sectionRefs.headerRefs?.[headerFooterType] ?? void 0 : page?.sectionRefs && kind === "footer" ? page.sectionRefs.footerRefs?.[headerFooterType] ?? void 0 : void 0;
85213
85637
  if (!headerFooterType) {
85214
85638
  return null;
85215
85639
  }
85640
+ if (sectionRId && layoutsByRId.has(sectionRId)) {
85641
+ const rIdLayout = layoutsByRId.get(sectionRId);
85642
+ const slotPage2 = __privateMethod$1(this, _PresentationEditor_instances, findHeaderFooterPageForPageNumber_fn).call(this, rIdLayout.layout.pages, pageNumber);
85643
+ if (slotPage2) {
85644
+ const fragments2 = slotPage2.fragments ?? [];
85645
+ const pageHeight2 = page?.size?.h ?? layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
85646
+ const margins2 = pageMargins ?? layout.pages[0]?.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
85647
+ const box2 = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins2, pageHeight2);
85648
+ return {
85649
+ fragments: fragments2,
85650
+ height: box2.height,
85651
+ contentHeight: rIdLayout.layout.height ?? box2.height,
85652
+ offset: box2.offset,
85653
+ marginLeft: box2.x,
85654
+ contentWidth: box2.width,
85655
+ headerId: sectionRId,
85656
+ sectionType: headerFooterType,
85657
+ box: {
85658
+ x: box2.x,
85659
+ y: box2.offset,
85660
+ width: box2.width,
85661
+ height: box2.height
85662
+ },
85663
+ hitRegion: {
85664
+ x: box2.x,
85665
+ y: box2.offset,
85666
+ width: box2.width,
85667
+ height: box2.height
85668
+ }
85669
+ };
85670
+ }
85671
+ }
85672
+ if (!results || results.length === 0) {
85673
+ return null;
85674
+ }
85216
85675
  const variant = results.find((entry) => entry.type === headerFooterType);
85217
85676
  if (!variant || !variant.layout?.pages?.length) {
85218
85677
  return null;
@@ -85225,9 +85684,8 @@ ${l}
85225
85684
  const pageHeight = page?.size?.h ?? layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
85226
85685
  const margins = pageMargins ?? layout.pages[0]?.margins ?? __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
85227
85686
  const box = __privateMethod$1(this, _PresentationEditor_instances, computeDecorationBox_fn).call(this, kind, margins, pageHeight);
85228
- const headerId = page?.sectionRefs && kind === "header" ? page.sectionRefs.headerRefs?.[headerFooterType] ?? void 0 : page?.sectionRefs && kind === "footer" ? page.sectionRefs.footerRefs?.[headerFooterType] ?? void 0 : void 0;
85229
85687
  const fallbackId = __privateGet$1(this, _headerFooterManager)?.getVariantId(kind, headerFooterType);
85230
- const finalHeaderId = headerId ?? fallbackId ?? void 0;
85688
+ const finalHeaderId = sectionRId ?? fallbackId ?? void 0;
85231
85689
  return {
85232
85690
  fragments,
85233
85691
  height: box.height,
@@ -85457,7 +85915,8 @@ ${l}
85457
85915
  const doc2 = editor.state?.doc;
85458
85916
  if (doc2) {
85459
85917
  const endPos = doc2.content.size - 1;
85460
- editor.commands?.setTextSelection?.(Math.max(1, endPos));
85918
+ const pos = Math.max(1, endPos);
85919
+ editor.commands?.setTextSelection?.({ from: pos, to: pos });
85461
85920
  }
85462
85921
  } catch (cursorError) {
85463
85922
  console.warn("[PresentationEditor] Could not set cursor to end:", cursorError);
@@ -86295,11 +86754,27 @@ ${l}
86295
86754
  };
86296
86755
  let PresentationEditor = _PresentationEditor;
86297
86756
  class PresentationInputBridge {
86298
- constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
86757
+ /**
86758
+ * Creates a new PresentationInputBridge that forwards user input events from the visible layout
86759
+ * surface to the hidden editor DOM. This enables input handling when the actual editor is not
86760
+ * directly visible to the user.
86761
+ *
86762
+ * @param windowRoot - The window object containing the layout surface and editor target
86763
+ * @param layoutSurface - The visible HTML element that receives user input events (e.g., keyboard, mouse)
86764
+ * @param getTargetDom - Callback that returns the hidden editor's DOM element where events should be forwarded
86765
+ * @param isEditable - Callback that returns whether the editor is in an editable mode (editing/suggesting).
86766
+ * When this returns false (e.g., in viewing mode), keyboard, text, and composition
86767
+ * events will not be forwarded to prevent document modification.
86768
+ * @param onTargetChanged - Optional callback invoked when the target editor DOM element changes
86769
+ * @param options - Optional configuration including:
86770
+ * - useWindowFallback: Whether to attach window-level event listeners as fallback
86771
+ */
86772
+ constructor(windowRoot, layoutSurface, getTargetDom, isEditable, onTargetChanged, options) {
86299
86773
  __privateAdd$1(this, _PresentationInputBridge_instances);
86300
86774
  __privateAdd$1(this, _windowRoot);
86301
86775
  __privateAdd$1(this, _layoutSurfaces);
86302
86776
  __privateAdd$1(this, _getTargetDom);
86777
+ __privateAdd$1(this, _isEditable);
86303
86778
  __privateAdd$1(this, _onTargetChanged);
86304
86779
  __privateAdd$1(this, _listeners);
86305
86780
  __privateAdd$1(this, _currentTarget, null);
@@ -86308,6 +86783,7 @@ ${l}
86308
86783
  __privateSet(this, _windowRoot, windowRoot);
86309
86784
  __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
86310
86785
  __privateSet(this, _getTargetDom, getTargetDom);
86786
+ __privateSet(this, _isEditable, isEditable);
86311
86787
  __privateSet(this, _onTargetChanged, onTargetChanged);
86312
86788
  __privateSet(this, _listeners, []);
86313
86789
  __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
@@ -86374,6 +86850,7 @@ ${l}
86374
86850
  _windowRoot = /* @__PURE__ */ new WeakMap();
86375
86851
  _layoutSurfaces = /* @__PURE__ */ new WeakMap();
86376
86852
  _getTargetDom = /* @__PURE__ */ new WeakMap();
86853
+ _isEditable = /* @__PURE__ */ new WeakMap();
86377
86854
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
86378
86855
  _listeners = /* @__PURE__ */ new WeakMap();
86379
86856
  _currentTarget = /* @__PURE__ */ new WeakMap();
@@ -86404,6 +86881,9 @@ ${l}
86404
86881
  }
86405
86882
  };
86406
86883
  forwardKeyboardEvent_fn = function(event) {
86884
+ if (!__privateGet$1(this, _isEditable).call(this)) {
86885
+ return;
86886
+ }
86407
86887
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86408
86888
  return;
86409
86889
  }
@@ -86431,6 +86911,9 @@ ${l}
86431
86911
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
86432
86912
  };
86433
86913
  forwardTextEvent_fn = function(event) {
86914
+ if (!__privateGet$1(this, _isEditable).call(this)) {
86915
+ return;
86916
+ }
86434
86917
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86435
86918
  return;
86436
86919
  }
@@ -86461,6 +86944,9 @@ ${l}
86461
86944
  });
86462
86945
  };
86463
86946
  forwardCompositionEvent_fn = function(event) {
86947
+ if (!__privateGet$1(this, _isEditable).call(this)) {
86948
+ return;
86949
+ }
86464
86950
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86465
86951
  return;
86466
86952
  }
@@ -86480,6 +86966,9 @@ ${l}
86480
86966
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
86481
86967
  };
86482
86968
  forwardContextMenu_fn = function(event) {
86969
+ if (!__privateGet$1(this, _isEditable).call(this)) {
86970
+ return;
86971
+ }
86483
86972
  if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
86484
86973
  return;
86485
86974
  }
@@ -139476,7 +139965,7 @@ ${style2}
139476
139965
  this.config.colors = shuffleArray(this.config.colors);
139477
139966
  this.userColorMap = /* @__PURE__ */ new Map();
139478
139967
  this.colorIndex = 0;
139479
- this.version = "1.0.0-beta.20";
139968
+ this.version = "1.0.0-beta.22";
139480
139969
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
139481
139970
  this.superdocId = config2.superdocId || v4();
139482
139971
  this.colors = this.config.colors;
@@ -139887,7 +140376,9 @@ ${style2}
139887
140376
  editing: () => this.#setModeEditing(),
139888
140377
  suggesting: () => this.#setModeSuggesting()
139889
140378
  };
139890
- if (types2[type2]) types2[type2]();
140379
+ if (types2[type2]) {
140380
+ types2[type2]();
140381
+ }
139891
140382
  }
139892
140383
  /**
139893
140384
  * Set the document mode on a document's editor (PresentationEditor or Editor).
@@ -139959,7 +140450,7 @@ ${style2}
139959
140450
  }
139960
140451
  #setModeViewing() {
139961
140452
  this.toolbar.activeEditor = null;
139962
- this.setTrackedChangesPreferences({ mode: "final", enabled: false });
140453
+ this.setTrackedChangesPreferences({ mode: "original", enabled: false });
139963
140454
  this.superdocStore.documents.forEach((doc2) => {
139964
140455
  doc2.removeComments();
139965
140456
  this.#applyDocumentMode(doc2, "viewing");
@@ -141919,7 +142410,7 @@ ${style2}
141919
142410
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
141920
142411
  );
141921
142412
  }
141922
- const indexDHhKY9FZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
142413
+ const index895wSAjT = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
141923
142414
  __proto__: null,
141924
142415
  unified
141925
142416
  }, Symbol.toStringTag, { value: "Module" }));