superdoc 1.0.0-beta.100 → 1.0.0-beta.101

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-DBk7W90L.es.js → PdfViewer-Cd9VR_tI.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-Bl_KAt28.cjs → PdfViewer-DZWkMtTG.cjs} +1 -1
  3. package/dist/chunks/{index-UIImjS8C.cjs → index-BavMv0sW.cjs} +3 -3
  4. package/dist/chunks/{index-BtLZer3S.es.js → index-BzQ_CQ_p.es.js} +3 -3
  5. package/dist/chunks/{index-Bd5TMBeR-D31VShf3.cjs → index-N8gZUeSO-BneVBXkH.cjs} +1 -1
  6. package/dist/chunks/{index-Bd5TMBeR-DcY3xcTG.es.js → index-N8gZUeSO-Dxit0pPr.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-oszwJ36j.es.js → super-editor.es-0IwuILla.es.js} +579 -99
  8. package/dist/chunks/{super-editor.es-BLGnf9gI.cjs → super-editor.es-BGncr3MA.cjs} +579 -99
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-B6-fwuLp.js → converter---tUwTA4.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-DXUMayjk.js → docx-zipper-B8zS8jbu.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BAK8u8dm.js → editor-3H6s48L7.js} +584 -100
  13. package/dist/super-editor/chunks/{index-Bd5TMBeR.js → index-N8gZUeSO.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DCCbbUQz.js → toolbar-FxiK-_cI.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 +581 -101
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +10 -1
@@ -42422,7 +42422,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42422
42422
  static getStoredSuperdocVersion(docx) {
42423
42423
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42424
42424
  }
42425
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.100") {
42425
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.101") {
42426
42426
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42427
42427
  }
42428
42428
  /**
@@ -53591,7 +53591,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53591
53591
  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);
53592
53592
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53593
53593
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53594
- 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, _cellAnchor, _cellDragMode, _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, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_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, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_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, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_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;
53594
+ 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, _pageGeometryHelper, _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, _cellAnchor, _cellDragMode, _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, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_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, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_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, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_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;
53595
53595
  var GOOD_LEAF_SIZE = 200;
53596
53596
  var RopeSequence = function RopeSequence2() {
53597
53597
  };
@@ -67497,7 +67497,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67497
67497
  const shouldSkipNodeView = (editor) => {
67498
67498
  return isHeadless(editor);
67499
67499
  };
67500
- const summaryVersion = "1.0.0-beta.100";
67500
+ const summaryVersion = "1.0.0-beta.101";
67501
67501
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67502
67502
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67503
67503
  function mapAttributes(attrs) {
@@ -68286,7 +68286,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68286
68286
  { default: remarkStringify2 },
68287
68287
  { default: remarkGfm2 }
68288
68288
  ] = await Promise.all([
68289
- Promise.resolve().then(() => indexBd5TMBeR),
68289
+ Promise.resolve().then(() => indexN8gZUeSO),
68290
68290
  Promise.resolve().then(() => indexDRCvimau),
68291
68291
  Promise.resolve().then(() => indexC_x_N6Uh),
68292
68292
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68491,7 +68491,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68491
68491
  * Process collaboration migrations
68492
68492
  */
68493
68493
  processCollaborationMigrations() {
68494
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.100");
68494
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.101");
68495
68495
  if (!this.options.ydoc) return;
68496
68496
  const metaMap = this.options.ydoc.getMap("meta");
68497
68497
  let docVersion = metaMap.get("version");
@@ -80574,7 +80574,7 @@ ${l}
80574
80574
  alignItems: "center",
80575
80575
  background: "transparent",
80576
80576
  padding: "0",
80577
- gap: "24px",
80577
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
80578
80578
  overflowY: "auto"
80579
80579
  };
80580
80580
  const containerStylesHorizontal = {
@@ -80584,7 +80584,7 @@ ${l}
80584
80584
  justifyContent: "safe center",
80585
80585
  background: "transparent",
80586
80586
  padding: "0",
80587
- gap: "20px",
80587
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
80588
80588
  overflowX: "auto",
80589
80589
  minHeight: "100%"
80590
80590
  };
@@ -82387,6 +82387,7 @@ ${l}
82387
82387
  const LIST_MARKER_GAP$1 = 8;
82388
82388
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
82389
82389
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
82390
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
82390
82391
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
82391
82392
  const COMMENT_INTERNAL_COLOR = "#078383";
82392
82393
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -82516,10 +82517,11 @@ ${l}
82516
82517
  this.totalPages = 0;
82517
82518
  this.linkIdCounter = 0;
82518
82519
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
82520
+ this.pageGap = 24;
82519
82521
  this.virtualEnabled = false;
82520
82522
  this.virtualWindow = 5;
82521
82523
  this.virtualOverscan = 0;
82522
- this.virtualGap = 72;
82524
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82523
82525
  this.virtualPaddingTop = null;
82524
82526
  this.topSpacerEl = null;
82525
82527
  this.bottomSpacerEl = null;
@@ -82538,13 +82540,14 @@ ${l}
82538
82540
  this.blockLookup = this.buildBlockLookup(blocks2, measures);
82539
82541
  this.headerProvider = options.headerProvider;
82540
82542
  this.footerProvider = options.footerProvider;
82543
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
82544
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
82541
82545
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
82542
82546
  this.virtualEnabled = true;
82543
82547
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
82544
82548
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
82545
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
82546
- this.virtualGap = Math.max(0, options.virtualization.gap);
82547
- }
82549
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
82550
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82548
82551
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
82549
82552
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
82550
82553
  }
@@ -82645,6 +82648,7 @@ ${l}
82645
82648
  const mode = this.layoutMode;
82646
82649
  if (mode === "horizontal") {
82647
82650
  applyStyles$2(mount2, containerStylesHorizontal);
82651
+ mount2.style.gap = `${this.pageGap}px`;
82648
82652
  this.renderHorizontal(layout, mount2);
82649
82653
  this.currentLayout = layout;
82650
82654
  this.pageStates = [];
@@ -82667,6 +82671,7 @@ ${l}
82667
82671
  this.changedBlocks.clear();
82668
82672
  return;
82669
82673
  }
82674
+ mount2.style.gap = `${this.pageGap}px`;
82670
82675
  if (!this.currentLayout || this.pageStates.length === 0) {
82671
82676
  this.fullRender(layout);
82672
82677
  } else {
@@ -85886,6 +85891,7 @@ ${l}
85886
85891
  const painter = new DomPainter(options.blocks, options.measures, {
85887
85892
  pageStyles: options.pageStyles,
85888
85893
  layoutMode: options.layoutMode,
85894
+ pageGap: options.pageGap,
85889
85895
  headerProvider: options.headerProvider,
85890
85896
  footerProvider: options.footerProvider,
85891
85897
  virtualization: options.virtualization,
@@ -91183,6 +91189,285 @@ ${l}
91183
91189
  }
91184
91190
  return updatedMeasures;
91185
91191
  }
91192
+ class PageGeometryHelper {
91193
+ /**
91194
+ * Creates a new PageGeometryHelper instance.
91195
+ *
91196
+ * @param config - Page geometry configuration
91197
+ */
91198
+ constructor(config2) {
91199
+ this.cache = null;
91200
+ this.config = config2;
91201
+ }
91202
+ /**
91203
+ * Updates the layout and invalidates the cache.
91204
+ *
91205
+ * Call this whenever the layout changes (new pages, different heights, etc.)
91206
+ *
91207
+ * @param layout - New layout data
91208
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
91209
+ */
91210
+ updateLayout(layout, pageGap) {
91211
+ this.config.layout = layout;
91212
+ if (pageGap !== void 0) {
91213
+ this.config.pageGap = pageGap;
91214
+ }
91215
+ this.cache = null;
91216
+ }
91217
+ /**
91218
+ * Updates the page gap and invalidates the cache.
91219
+ *
91220
+ * @param pageGap - New gap between pages in pixels
91221
+ */
91222
+ updatePageGap(pageGap) {
91223
+ if (this.config.pageGap !== pageGap) {
91224
+ this.config.pageGap = pageGap;
91225
+ this.cache = null;
91226
+ }
91227
+ }
91228
+ /**
91229
+ * Gets the cumulative Y position (top edge) of a page in container space.
91230
+ *
91231
+ * The returned value is the distance from the top of the container to the
91232
+ * top of the specified page, accounting for all previous pages and gaps.
91233
+ *
91234
+ * @param pageIndex - Zero-based page index
91235
+ * @returns Y position in pixels, or 0 if page index is invalid
91236
+ *
91237
+ * @example
91238
+ * ```typescript
91239
+ * // Get Y position of page 0 (first page)
91240
+ * const y0 = helper.getPageTop(0); // Returns 0
91241
+ *
91242
+ * // Get Y position of page 2 (third page)
91243
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
91244
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
91245
+ * ```
91246
+ */
91247
+ getPageTop(pageIndex) {
91248
+ this.ensureCache();
91249
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
91250
+ return 0;
91251
+ }
91252
+ return this.cache.cumulativeY[pageIndex];
91253
+ }
91254
+ /**
91255
+ * Gets the height of a specific page.
91256
+ *
91257
+ * Uses per-page height if available (from layout.pages[i].size?.h),
91258
+ * otherwise falls back to layout.pageSize.h.
91259
+ *
91260
+ * @param pageIndex - Zero-based page index
91261
+ * @returns Page height in pixels, or 0 if page index is invalid
91262
+ *
91263
+ * @example
91264
+ * ```typescript
91265
+ * const height = helper.getPageHeight(0); // Returns page-specific height
91266
+ * ```
91267
+ */
91268
+ getPageHeight(pageIndex) {
91269
+ this.ensureCache();
91270
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
91271
+ return 0;
91272
+ }
91273
+ return this.cache.pageHeights[pageIndex];
91274
+ }
91275
+ /**
91276
+ * Gets the gap between pages.
91277
+ *
91278
+ * @returns Gap in pixels
91279
+ *
91280
+ * @example
91281
+ * ```typescript
91282
+ * const gap = helper.getPageGap(); // Returns 24
91283
+ * ```
91284
+ */
91285
+ getPageGap() {
91286
+ this.ensureCache();
91287
+ return this.cache.pageGap;
91288
+ }
91289
+ /**
91290
+ * Gets the total height of all pages including gaps.
91291
+ *
91292
+ * Total height = sum of all page heights + (pageCount - 1) * gap
91293
+ *
91294
+ * @returns Total height in pixels
91295
+ *
91296
+ * @example
91297
+ * ```typescript
91298
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
91299
+ * const total = helper.getTotalHeight();
91300
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
91301
+ * ```
91302
+ */
91303
+ getTotalHeight() {
91304
+ this.ensureCache();
91305
+ return this.cache.totalHeight;
91306
+ }
91307
+ /**
91308
+ * Gets the number of pages in the layout.
91309
+ *
91310
+ * @returns Page count
91311
+ */
91312
+ getPageCount() {
91313
+ return this.config.layout.pages.length;
91314
+ }
91315
+ /**
91316
+ * Finds the page index containing a given Y coordinate.
91317
+ *
91318
+ * This performs a linear search through cached cumulative positions.
91319
+ * For large documents, consider adding binary search optimization.
91320
+ *
91321
+ * @param containerY - Y coordinate in container space
91322
+ * @returns Page index, or null if Y is outside all pages
91323
+ *
91324
+ * @example
91325
+ * ```typescript
91326
+ * // Find which page contains Y = 1500
91327
+ * const pageIndex = helper.getPageIndexAtY(1500);
91328
+ * // Returns 1 (second page) if first page ends at Y=1024
91329
+ * ```
91330
+ */
91331
+ getPageIndexAtY(containerY) {
91332
+ this.ensureCache();
91333
+ const cache2 = this.cache;
91334
+ for (let i2 = 0; i2 < cache2.cumulativeY.length; i2++) {
91335
+ const pageTop = cache2.cumulativeY[i2];
91336
+ const pageBottom = pageTop + cache2.pageHeights[i2];
91337
+ if (containerY >= pageTop && containerY < pageBottom) {
91338
+ return i2;
91339
+ }
91340
+ }
91341
+ return null;
91342
+ }
91343
+ /**
91344
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
91345
+ *
91346
+ * Returns the page containing Y when inside a page; otherwise returns the
91347
+ * closest page based on distance to page center. Useful for dragging through
91348
+ * page gaps where getPageIndexAtY would return null.
91349
+ *
91350
+ * @param containerY - Y coordinate in container space
91351
+ * @returns Nearest page index, or null if there are no pages
91352
+ */
91353
+ getNearestPageIndex(containerY) {
91354
+ this.ensureCache();
91355
+ const cache2 = this.cache;
91356
+ const pageCount = cache2.pageHeights.length;
91357
+ if (pageCount === 0) return null;
91358
+ const direct = this.getPageIndexAtY(containerY);
91359
+ if (direct !== null) return direct;
91360
+ let nearestIndex = 0;
91361
+ let nearestDistance = Infinity;
91362
+ for (let i2 = 0; i2 < pageCount; i2++) {
91363
+ const top2 = cache2.cumulativeY[i2];
91364
+ const height = cache2.pageHeights[i2];
91365
+ const center = top2 + height / 2;
91366
+ const distance = Math.abs(containerY - center);
91367
+ if (distance < nearestDistance) {
91368
+ nearestDistance = distance;
91369
+ nearestIndex = i2;
91370
+ }
91371
+ }
91372
+ return nearestIndex;
91373
+ }
91374
+ /**
91375
+ * Ensures the cache is built and up-to-date.
91376
+ * Validates cache state and rebuilds if needed.
91377
+ * @private
91378
+ * @throws Never throws - handles errors gracefully with fallback values
91379
+ */
91380
+ ensureCache() {
91381
+ if (this.cache !== null) {
91382
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
91383
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
91384
+ this.cache = null;
91385
+ } else {
91386
+ return;
91387
+ }
91388
+ }
91389
+ this.buildCache();
91390
+ }
91391
+ /**
91392
+ * Builds the geometry cache from current layout data.
91393
+ * Handles errors gracefully by providing fallback values.
91394
+ * @private
91395
+ * @throws Never throws - catches all errors and provides safe defaults
91396
+ */
91397
+ buildCache() {
91398
+ try {
91399
+ const layout = this.config.layout;
91400
+ if (!layout || !Array.isArray(layout.pages)) {
91401
+ throw new Error("Invalid layout: missing or invalid pages array");
91402
+ }
91403
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
91404
+ const pageCount = layout.pages.length;
91405
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
91406
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
91407
+ }
91408
+ const cumulativeY = new Array(pageCount);
91409
+ const pageHeights = new Array(pageCount);
91410
+ let currentY = 0;
91411
+ for (let i2 = 0; i2 < pageCount; i2++) {
91412
+ const page = layout.pages[i2];
91413
+ if (!page) {
91414
+ throw new Error(`Invalid page at index ${i2}: page is null or undefined`);
91415
+ }
91416
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91417
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
91418
+ throw new Error(`Invalid page height at index ${i2}: ${pageHeight} (must be non-negative finite number)`);
91419
+ }
91420
+ cumulativeY[i2] = currentY;
91421
+ pageHeights[i2] = pageHeight;
91422
+ currentY += pageHeight;
91423
+ if (i2 < pageCount - 1) {
91424
+ currentY += pageGap;
91425
+ }
91426
+ }
91427
+ const totalHeight = currentY;
91428
+ this.cache = {
91429
+ cumulativeY,
91430
+ pageHeights,
91431
+ pageGap,
91432
+ totalHeight,
91433
+ layoutVersion: 0
91434
+ // Placeholder for future version tracking
91435
+ };
91436
+ } catch (error) {
91437
+ const errorMessage = error instanceof Error ? error.message : String(error);
91438
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
91439
+ this.cache = {
91440
+ cumulativeY: [],
91441
+ pageHeights: [],
91442
+ pageGap: 0,
91443
+ totalHeight: 0,
91444
+ layoutVersion: 0
91445
+ };
91446
+ }
91447
+ }
91448
+ /**
91449
+ * Clears the cache, forcing recalculation on next access.
91450
+ * Useful for testing or manual cache invalidation.
91451
+ */
91452
+ clearCache() {
91453
+ this.cache = null;
91454
+ }
91455
+ /**
91456
+ * Gets debug information about the current cache state.
91457
+ * @internal
91458
+ */
91459
+ getDebugInfo() {
91460
+ this.ensureCache();
91461
+ return {
91462
+ isCached: this.cache !== null,
91463
+ pageCount: this.config.layout.pages.length,
91464
+ pageGap: this.cache.pageGap,
91465
+ totalHeight: this.cache.totalHeight,
91466
+ cumulativeY: [...this.cache.cumulativeY],
91467
+ pageHeights: [...this.cache.pageHeights]
91468
+ };
91469
+ }
91470
+ }
91186
91471
  var Priority = /* @__PURE__ */ ((Priority2) => {
91187
91472
  Priority2[Priority2["P0"] = 0] = "P0";
91188
91473
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -91476,18 +91761,41 @@ ${l}
91476
91761
  const effectiveEndA = endA ?? startA + 1;
91477
91762
  return effectiveEndA > startB && startA < endB;
91478
91763
  };
91479
- function hitTestPage(layout, point2) {
91764
+ function hitTestPage(layout, point2, geometryHelper) {
91765
+ if (geometryHelper) {
91766
+ const pageIndex = geometryHelper.getPageIndexAtY(point2.y);
91767
+ if (pageIndex !== null) {
91768
+ return { pageIndex, page: layout.pages[pageIndex] };
91769
+ }
91770
+ const nearest = geometryHelper.getNearestPageIndex(point2.y);
91771
+ if (nearest !== null) {
91772
+ return { pageIndex: nearest, page: layout.pages[nearest] };
91773
+ }
91774
+ return null;
91775
+ }
91480
91776
  const pageGap = layout.pageGap ?? 0;
91481
91777
  let cursorY = 0;
91778
+ let nearestIndex = null;
91779
+ let nearestDistance = Infinity;
91482
91780
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
91483
91781
  const page = layout.pages[pageIndex];
91782
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91484
91783
  const top2 = cursorY;
91485
- const bottom2 = top2 + layout.pageSize.h;
91784
+ const bottom2 = top2 + pageHeight;
91486
91785
  if (point2.y >= top2 && point2.y < bottom2) {
91487
91786
  return { pageIndex, page };
91488
91787
  }
91788
+ const center = top2 + pageHeight / 2;
91789
+ const distance = Math.abs(point2.y - center);
91790
+ if (distance < nearestDistance) {
91791
+ nearestDistance = distance;
91792
+ nearestIndex = pageIndex;
91793
+ }
91489
91794
  cursorY = bottom2 + pageGap;
91490
91795
  }
91796
+ if (nearestIndex !== null) {
91797
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
91798
+ }
91491
91799
  return null;
91492
91800
  }
91493
91801
  function hitTestFragment(layout, pageHit, blocks2, measures, point2) {
@@ -91648,7 +91956,7 @@ ${l}
91648
91956
  }
91649
91957
  return null;
91650
91958
  };
91651
- function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY) {
91959
+ function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
91652
91960
  logClickStage("log", "entry", {
91653
91961
  pages: layout.pages.length
91654
91962
  });
@@ -91691,75 +91999,132 @@ ${l}
91691
91999
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
91692
92000
  }
91693
92001
  }
91694
- const pageHit = hitTestPage(layout, containerPoint);
92002
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
91695
92003
  if (!pageHit) {
91696
92004
  return null;
91697
92005
  }
91698
- const pageGap = layout.pageGap ?? 0;
92006
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
91699
92007
  const pageRelativePoint = {
91700
92008
  x: containerPoint.x,
91701
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
92009
+ y: containerPoint.y - pageTopY
91702
92010
  };
91703
92011
  logClickStage("log", "page-hit", {
91704
92012
  pageIndex: pageHit.pageIndex
91705
92013
  });
91706
- const fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92014
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92015
+ if (!fragmentHit) {
92016
+ const page = pageHit.page;
92017
+ const fragments = page.fragments.filter(
92018
+ (f2) => f2 != null && typeof f2 === "object"
92019
+ );
92020
+ if (fragments.length > 0) {
92021
+ let nearest = null;
92022
+ let nearestDist = Infinity;
92023
+ for (const frag of fragments) {
92024
+ const top2 = frag.y;
92025
+ const bottom2 = frag.y + frag.height;
92026
+ let dist2;
92027
+ if (pageRelativePoint.y < top2) {
92028
+ dist2 = top2 - pageRelativePoint.y;
92029
+ } else if (pageRelativePoint.y > bottom2) {
92030
+ dist2 = pageRelativePoint.y - bottom2;
92031
+ } else {
92032
+ dist2 = 0;
92033
+ }
92034
+ if (dist2 < nearestDist) {
92035
+ nearestDist = dist2;
92036
+ nearest = frag;
92037
+ }
92038
+ }
92039
+ if (nearest) {
92040
+ const blockIndex = findBlockIndexByFragmentId(blocks2, nearest.blockId);
92041
+ if (blockIndex !== -1) {
92042
+ const block = blocks2[blockIndex];
92043
+ const measure = measures[blockIndex];
92044
+ if (block && measure) {
92045
+ fragmentHit = {
92046
+ fragment: nearest,
92047
+ block,
92048
+ measure,
92049
+ pageIndex: pageHit.pageIndex,
92050
+ pageY: 0
92051
+ };
92052
+ }
92053
+ }
92054
+ }
92055
+ }
92056
+ }
91707
92057
  if (fragmentHit) {
91708
92058
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
91709
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
91710
- logClickStage("warn", "fragment-type-mismatch", {
91711
- fragmentKind: fragment.kind,
91712
- measureKind: measure.kind,
91713
- blockKind: block.kind
92059
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
92060
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
92061
+ if (lineIndex == null) {
92062
+ logClickStage("warn", "no-line", {
92063
+ blockId: fragment.blockId
92064
+ });
92065
+ return null;
92066
+ }
92067
+ const line = measure.lines[lineIndex];
92068
+ const isRTL = isRtlBlock(block);
92069
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
92070
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
92071
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
92072
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
92073
+ const totalIndent = paraIndentLeft + paraIndentRight;
92074
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
92075
+ if (totalIndent > fragment.width) {
92076
+ console.warn(
92077
+ `[clickToPosition] Paragraph indents (${totalIndent}px) exceed fragment width (${fragment.width}px) for block ${fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
92078
+ );
92079
+ }
92080
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
92081
+ const isListItem3 = markerWidth > 0;
92082
+ const alignmentOverride = isListItem3 ? "left" : void 0;
92083
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
92084
+ if (pos == null) {
92085
+ logClickStage("warn", "no-position", {
92086
+ blockId: fragment.blockId
92087
+ });
92088
+ return null;
92089
+ }
92090
+ const column = determineColumn(layout, fragment.x);
92091
+ logPositionDebug({
92092
+ blockId: fragment.blockId,
92093
+ x: pageRelativePoint.x - fragment.x
91714
92094
  });
91715
- return null;
91716
- }
91717
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
91718
- if (lineIndex == null) {
91719
- logClickStage("warn", "no-line", {
92095
+ logClickStage("log", "success", {
91720
92096
  blockId: fragment.blockId
91721
92097
  });
91722
- return null;
91723
- }
91724
- const line = measure.lines[lineIndex];
91725
- const isRTL = isRtlBlock(block);
91726
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
91727
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
91728
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
91729
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
91730
- const totalIndent = paraIndentLeft + paraIndentRight;
91731
- const availableWidth = Math.max(0, fragment.width - totalIndent);
91732
- if (totalIndent > fragment.width) {
91733
- console.warn(
91734
- `[clickToPosition] Paragraph indents (${totalIndent}px) exceed fragment width (${fragment.width}px) for block ${fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
91735
- );
92098
+ return {
92099
+ pos,
92100
+ blockId: fragment.blockId,
92101
+ pageIndex,
92102
+ column,
92103
+ lineIndex
92104
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
92105
+ };
91736
92106
  }
91737
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
91738
- const isListItem3 = markerWidth > 0;
91739
- const alignmentOverride = isListItem3 ? "left" : void 0;
91740
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
91741
- if (pos == null) {
91742
- logClickStage("warn", "no-position", {
91743
- blockId: fragment.blockId
92107
+ if (isAtomicFragment(fragment)) {
92108
+ const pmRange = getAtomicPmRange(fragment, block);
92109
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
92110
+ if (pos == null) {
92111
+ logClickStage("warn", "atomic-without-range", {
92112
+ fragmentId: fragment.blockId
92113
+ });
92114
+ return null;
92115
+ }
92116
+ logClickStage("log", "success", {
92117
+ blockId: fragment.blockId,
92118
+ column: determineColumn(layout, fragment.x)
91744
92119
  });
91745
- return null;
92120
+ return {
92121
+ pos,
92122
+ blockId: fragment.blockId,
92123
+ pageIndex,
92124
+ column: determineColumn(layout, fragment.x),
92125
+ lineIndex: -1
92126
+ };
91746
92127
  }
91747
- const column = determineColumn(layout, fragment.x);
91748
- logPositionDebug({
91749
- blockId: fragment.blockId,
91750
- x: pageRelativePoint.x - fragment.x
91751
- });
91752
- logClickStage("log", "success", {
91753
- blockId: fragment.blockId
91754
- });
91755
- return {
91756
- pos,
91757
- blockId: fragment.blockId,
91758
- pageIndex,
91759
- column,
91760
- lineIndex
91761
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
91762
- };
91763
92128
  }
91764
92129
  const tableHit = hitTestTableFragment(pageHit, blocks2, measures, pageRelativePoint);
91765
92130
  if (tableHit) {
@@ -91909,12 +92274,22 @@ ${l}
91909
92274
  }
91910
92275
  return height;
91911
92276
  };
91912
- function selectionToRects(layout, blocks2, measures, from2, to) {
92277
+ const calculatePageTopFallback = (layout, pageIndex) => {
92278
+ const pageGap = layout.pageGap ?? 0;
92279
+ let y2 = 0;
92280
+ for (let i2 = 0; i2 < pageIndex; i2++) {
92281
+ const pageHeight = layout.pages[i2]?.size?.h ?? layout.pageSize.h;
92282
+ y2 += pageHeight + pageGap;
92283
+ }
92284
+ return y2;
92285
+ };
92286
+ function selectionToRects(layout, blocks2, measures, from2, to, geometryHelper) {
91913
92287
  if (from2 === to) {
91914
92288
  return [];
91915
92289
  }
91916
92290
  const rects = [];
91917
92291
  layout.pages.forEach((page, pageIndex) => {
92292
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
91918
92293
  page.fragments.forEach((fragment) => {
91919
92294
  if (fragment.kind === "para") {
91920
92295
  const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId, { from: from2, to });
@@ -91956,12 +92331,16 @@ ${l}
91956
92331
  wordLayout
91957
92332
  });
91958
92333
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
91959
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92334
+ const rectWidth = Math.max(
92335
+ 1,
92336
+ Math.min(Math.abs(endX - startX), line.width)
92337
+ // clamp to line width to prevent runaway widths
92338
+ );
91960
92339
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
91961
92340
  const rectY = fragment.y + lineOffset;
91962
92341
  rects.push({
91963
92342
  x: rectX,
91964
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92343
+ y: rectY + pageTopY,
91965
92344
  width: rectWidth,
91966
92345
  height: line.lineHeight,
91967
92346
  pageIndex
@@ -92089,12 +92468,16 @@ ${l}
92089
92468
  wordLayout: cellWordLayout
92090
92469
  });
92091
92470
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
92092
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92471
+ const rectWidth = Math.max(
92472
+ 1,
92473
+ Math.min(Math.abs(endX - startX), line.width)
92474
+ // clamp to line width to prevent runaway widths
92475
+ );
92093
92476
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
92094
92477
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
92095
92478
  rects.push({
92096
92479
  x: rectX,
92097
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92480
+ y: rectY + pageTopY,
92098
92481
  width: rectWidth,
92099
92482
  height: line.lineHeight,
92100
92483
  pageIndex
@@ -92123,7 +92506,7 @@ ${l}
92123
92506
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
92124
92507
  rects.push({
92125
92508
  x: fragment.x,
92126
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92509
+ y: fragment.y + pageTopY,
92127
92510
  width: fragment.width,
92128
92511
  height: fragment.height,
92129
92512
  pageIndex
@@ -95364,6 +95747,7 @@ ${l}
95364
95747
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
95365
95748
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
95366
95749
  const DEFAULT_PAGE_GAP = 24;
95750
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
95367
95751
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
95368
95752
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
95369
95753
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -95387,6 +95771,7 @@ ${l}
95387
95771
  __privateAdd$1(this, _layoutOptions);
95388
95772
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
95389
95773
  __privateAdd$1(this, _domPainter, null);
95774
+ __privateAdd$1(this, _pageGeometryHelper, null);
95390
95775
  __privateAdd$1(this, _dragHandlerCleanup, null);
95391
95776
  __privateAdd$1(this, _layoutError, null);
95392
95777
  __privateAdd$1(this, _layoutErrorState, "healthy");
@@ -95539,7 +95924,8 @@ ${l}
95539
95924
  { x: x2, y: y2 },
95540
95925
  __privateGet$1(this, _viewportHost),
95541
95926
  event.clientX,
95542
- event.clientY
95927
+ event.clientY,
95928
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95543
95929
  );
95544
95930
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
95545
95931
  const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
@@ -95738,7 +96124,8 @@ ${l}
95738
96124
  { x: normalized.x, y: normalized.y },
95739
96125
  __privateGet$1(this, _viewportHost),
95740
96126
  event.clientX,
95741
- event.clientY
96127
+ event.clientY,
96128
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95742
96129
  );
95743
96130
  if (!hit) return;
95744
96131
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -96585,7 +96972,14 @@ ${l}
96585
96972
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
96586
96973
  }
96587
96974
  if (!__privateGet$1(this, _layoutState).layout) return [];
96588
- const rects = selectionToRects(__privateGet$1(this, _layoutState).layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, start2, end2) ?? [];
96975
+ const rects = selectionToRects(
96976
+ __privateGet$1(this, _layoutState).layout,
96977
+ __privateGet$1(this, _layoutState).blocks,
96978
+ __privateGet$1(this, _layoutState).measures,
96979
+ start2,
96980
+ end2,
96981
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
96982
+ ) ?? [];
96589
96983
  return rects;
96590
96984
  };
96591
96985
  const rawRects = layoutRectSource();
@@ -96850,6 +97244,7 @@ ${l}
96850
97244
  };
96851
97245
  }
96852
97246
  __privateSet(this, _domPainter, null);
97247
+ __privateSet(this, _pageGeometryHelper, null);
96853
97248
  __privateSet(this, _pendingDocChange, true);
96854
97249
  __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
96855
97250
  }
@@ -96882,7 +97277,16 @@ ${l}
96882
97277
  x: localX,
96883
97278
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
96884
97279
  };
96885
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
97280
+ const hit2 = clickToPosition(
97281
+ context.layout,
97282
+ context.blocks,
97283
+ context.measures,
97284
+ headerPoint,
97285
+ void 0,
97286
+ void 0,
97287
+ void 0,
97288
+ void 0
97289
+ ) ?? null;
96886
97290
  return hit2;
96887
97291
  }
96888
97292
  if (!__privateGet$1(this, _layoutState).layout) {
@@ -96895,7 +97299,8 @@ ${l}
96895
97299
  normalized,
96896
97300
  __privateGet$1(this, _viewportHost),
96897
97301
  clientX,
96898
- clientY
97302
+ clientY,
97303
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
96899
97304
  ) ?? null;
96900
97305
  return hit;
96901
97306
  }
@@ -97118,6 +97523,7 @@ ${l}
97118
97523
  __privateSet(this, _session, { mode: "body" });
97119
97524
  __privateSet(this, _activeHeaderFooterEditor, null);
97120
97525
  __privateSet(this, _domPainter, null);
97526
+ __privateSet(this, _pageGeometryHelper, null);
97121
97527
  (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
97122
97528
  __privateSet(this, _dragHandlerCleanup, null);
97123
97529
  __privateGet$1(this, _selectionOverlay2)?.remove();
@@ -97171,7 +97577,14 @@ ${l}
97171
97577
  if (!normalized) return false;
97172
97578
  const pmPos = __privateGet$1(this, _layoutState).bookmarks.get(normalized);
97173
97579
  if (pmPos == null) return false;
97174
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
97580
+ const rects = selectionToRects(
97581
+ layout,
97582
+ __privateGet$1(this, _layoutState).blocks,
97583
+ __privateGet$1(this, _layoutState).measures,
97584
+ pmPos,
97585
+ pmPos + 1,
97586
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
97587
+ ) ?? [];
97175
97588
  const rect = rects[0];
97176
97589
  let pageIndex = rect?.pageIndex ?? null;
97177
97590
  if (pageIndex == null) {
@@ -97235,6 +97648,7 @@ ${l}
97235
97648
  _layoutOptions = /* @__PURE__ */ new WeakMap();
97236
97649
  _layoutState = /* @__PURE__ */ new WeakMap();
97237
97650
  _domPainter = /* @__PURE__ */ new WeakMap();
97651
+ _pageGeometryHelper = /* @__PURE__ */ new WeakMap();
97238
97652
  _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
97239
97653
  _layoutError = /* @__PURE__ */ new WeakMap();
97240
97654
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
@@ -97693,7 +98107,7 @@ ${l}
97693
98107
  if (!layout || !blocks2 || !measures) return;
97694
98108
  const start2 = Math.min(cursor.anchor, cursor.head);
97695
98109
  const end2 = Math.max(cursor.anchor, cursor.head);
97696
- const rects = selectionToRects(layout, blocks2, measures, start2, end2) ?? [];
98110
+ const rects = selectionToRects(layout, blocks2, measures, start2, end2, __privateGet$1(this, _pageGeometryHelper) ?? void 0) ?? [];
97697
98111
  const color2 = __privateMethod$1(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
97698
98112
  const opacity = __privateGet$1(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
97699
98113
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -98053,15 +98467,25 @@ ${l}
98053
98467
  const configuredPageSize = __privateGet$1(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
98054
98468
  let pageY = 0;
98055
98469
  let pageHit = null;
98056
- for (let i2 = 0; i2 < layout.pages.length; i2++) {
98057
- const page = layout.pages[i2];
98058
- const pageHeight = page.size?.h ?? configuredPageSize.h;
98059
- const gap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
98060
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
98061
- pageHit = { pageIndex: i2, page };
98062
- break;
98470
+ const geometryHelper = __privateGet$1(this, _pageGeometryHelper);
98471
+ if (geometryHelper) {
98472
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
98473
+ if (idx != null && layout.pages[idx]) {
98474
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
98475
+ pageY = geometryHelper.getPageTop(idx);
98476
+ }
98477
+ }
98478
+ if (!pageHit) {
98479
+ const gap = layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98480
+ for (let i2 = 0; i2 < layout.pages.length; i2++) {
98481
+ const page = layout.pages[i2];
98482
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
98483
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
98484
+ pageHit = { pageIndex: i2, page };
98485
+ break;
98486
+ }
98487
+ pageY += pageHeight + gap;
98063
98488
  }
98064
- pageY += pageHeight + gap;
98065
98489
  }
98066
98490
  if (!pageHit) {
98067
98491
  return null;
@@ -98313,12 +98737,7 @@ ${l}
98313
98737
  return;
98314
98738
  }
98315
98739
  ({ layout, measures } = result);
98316
- if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
98317
- const gap = __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
98318
- layout.pageGap = Math.max(0, gap);
98319
- } else {
98320
- layout.pageGap = DEFAULT_PAGE_GAP;
98321
- }
98740
+ layout.pageGap = __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98322
98741
  headerLayouts = result.headers;
98323
98742
  footerLayouts = result.footers;
98324
98743
  } catch (error) {
@@ -98335,6 +98754,17 @@ ${l}
98335
98754
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout, bookmarks, anchorMap });
98336
98755
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
98337
98756
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
98757
+ if (__privateGet$1(this, _layoutState).layout) {
98758
+ const pageGap = __privateGet$1(this, _layoutState).layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98759
+ if (!__privateGet$1(this, _pageGeometryHelper)) {
98760
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
98761
+ layout: __privateGet$1(this, _layoutState).layout,
98762
+ pageGap
98763
+ }));
98764
+ } else {
98765
+ __privateGet$1(this, _pageGeometryHelper).updateLayout(__privateGet$1(this, _layoutState).layout, pageGap);
98766
+ }
98767
+ }
98338
98768
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
98339
98769
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
98340
98770
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks2, measures);
@@ -98404,7 +98834,8 @@ ${l}
98404
98834
  pageStyles: __privateGet$1(this, _layoutOptions).pageStyles,
98405
98835
  headerProvider: __privateGet$1(this, _headerDecorationProvider),
98406
98836
  footerProvider: __privateGet$1(this, _footerDecorationProvider),
98407
- ruler: __privateGet$1(this, _layoutOptions).ruler
98837
+ ruler: __privateGet$1(this, _layoutOptions).ruler,
98838
+ pageGap: __privateGet$1(this, _layoutState).layout?.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
98408
98839
  }));
98409
98840
  }
98410
98841
  return __privateGet$1(this, _domPainter);
@@ -98492,7 +98923,14 @@ ${l}
98492
98923
  }
98493
98924
  return;
98494
98925
  }
98495
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
98926
+ const rects = selectionToRects(
98927
+ layout,
98928
+ __privateGet$1(this, _layoutState).blocks,
98929
+ __privateGet$1(this, _layoutState).measures,
98930
+ from2,
98931
+ to,
98932
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
98933
+ ) ?? [];
98496
98934
  let domStart = null;
98497
98935
  let domEnd = null;
98498
98936
  try {
@@ -98506,7 +98944,9 @@ ${l}
98506
98944
  const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
98507
98945
  try {
98508
98946
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
98509
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
98947
+ if (correctedRects.length > 0) {
98948
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
98949
+ }
98510
98950
  } catch (error) {
98511
98951
  if (process$1$1.env.NODE_ENV === "development") {
98512
98952
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -99294,6 +99734,15 @@ ${l}
99294
99734
  checkPage();
99295
99735
  });
99296
99736
  };
99737
+ getEffectivePageGap_fn = function() {
99738
+ if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
99739
+ return Math.max(0, __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
99740
+ }
99741
+ if (__privateGet$1(this, _layoutOptions).layoutMode === "horizontal") {
99742
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
99743
+ }
99744
+ return DEFAULT_PAGE_GAP;
99745
+ };
99297
99746
  getBodyPageHeight_fn = function() {
99298
99747
  return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
99299
99748
  };
@@ -99317,7 +99766,7 @@ ${l}
99317
99766
  dy: domStart.y - layoutY
99318
99767
  };
99319
99768
  }
99320
- return rects.map((rect, idx) => {
99769
+ const corrected = rects.map((rect, idx) => {
99321
99770
  const delta = pageDelta[rect.pageIndex];
99322
99771
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
99323
99772
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -99332,6 +99781,7 @@ ${l}
99332
99781
  }
99333
99782
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
99334
99783
  const endX = domEnd.x;
99784
+ adjustedX = Math.min(adjustedX, endX);
99335
99785
  adjustedWidth = Math.max(1, endX - adjustedX);
99336
99786
  }
99337
99787
  return {
@@ -99341,6 +99791,29 @@ ${l}
99341
99791
  width: adjustedWidth
99342
99792
  };
99343
99793
  });
99794
+ const MAX_DELTA_PX = 12;
99795
+ let invalid2 = false;
99796
+ if (domStart && corrected[0]) {
99797
+ const dx = Math.abs(corrected[0].x - domStart.x);
99798
+ const dy = Math.abs(corrected[0].y - domStart.y);
99799
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99800
+ }
99801
+ if (domEnd && corrected[corrected.length - 1]) {
99802
+ const last = corrected[corrected.length - 1];
99803
+ const dx = Math.abs(last.x + last.width - domEnd.x);
99804
+ const dy = Math.abs(last.y - domEnd.y);
99805
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99806
+ }
99807
+ if (invalid2) {
99808
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
99809
+ domStart,
99810
+ domEnd,
99811
+ rectStart: corrected[0],
99812
+ rectEnd: corrected[corrected.length - 1]
99813
+ });
99814
+ return [];
99815
+ }
99816
+ return corrected;
99344
99817
  };
99345
99818
  renderCellSelectionOverlay_fn = function(selection, layout) {
99346
99819
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
@@ -99624,7 +100097,7 @@ ${l}
99624
100097
  return [];
99625
100098
  }
99626
100099
  if (!bodyLayout) return [];
99627
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
100100
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
99628
100101
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
99629
100102
  const bodyPageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
99630
100103
  return rects.map((rect) => {
@@ -100091,7 +100564,14 @@ ${l}
100091
100564
  if (!layout || !selection) {
100092
100565
  return 0;
100093
100566
  }
100094
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
100567
+ const rects = selectionToRects(
100568
+ layout,
100569
+ __privateGet$1(this, _layoutState).blocks,
100570
+ __privateGet$1(this, _layoutState).measures,
100571
+ selection.from,
100572
+ selection.to,
100573
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
100574
+ ) ?? [];
100095
100575
  if (rects.length > 0) {
100096
100576
  return rects[0]?.pageIndex ?? 0;
100097
100577
  }
@@ -152285,7 +152765,7 @@ ${style2}
152285
152765
  this.config.colors = shuffleArray(this.config.colors);
152286
152766
  this.userColorMap = /* @__PURE__ */ new Map();
152287
152767
  this.colorIndex = 0;
152288
- this.version = "1.0.0-beta.100";
152768
+ this.version = "1.0.0-beta.101";
152289
152769
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
152290
152770
  this.superdocId = config2.superdocId || v4();
152291
152771
  this.colors = this.config.colors;
@@ -154757,7 +155237,7 @@ ${style2}
154757
155237
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
154758
155238
  );
154759
155239
  }
154760
- const indexBd5TMBeR = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
155240
+ const indexN8gZUeSO = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154761
155241
  __proto__: null,
154762
155242
  unified
154763
155243
  }, Symbol.toStringTag, { value: "Module" }));