@harbour-enterprises/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
@@ -9,11 +9,11 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- 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, hideDimmingOverlay_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, 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;
12
+ 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, hideDimmingOverlay_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, 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;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-B6-fwuLp.js";
16
- import { D as DocxZipper } from "./docx-zipper-DXUMayjk.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter---tUwTA4.js";
16
+ import { D as DocxZipper } from "./docx-zipper-B8zS8jbu.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -13952,7 +13952,7 @@ const isHeadless = (editor) => {
13952
13952
  const shouldSkipNodeView = (editor) => {
13953
13953
  return isHeadless(editor);
13954
13954
  };
13955
- const summaryVersion = "1.0.0-beta.100";
13955
+ const summaryVersion = "1.0.0-beta.101";
13956
13956
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13957
13957
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13958
13958
  function mapAttributes(attrs) {
@@ -14744,7 +14744,7 @@ const _Editor = class _Editor extends EventEmitter {
14744
14744
  { default: remarkStringify },
14745
14745
  { default: remarkGfm }
14746
14746
  ] = await Promise.all([
14747
- import("./index-Bd5TMBeR.js"),
14747
+ import("./index-N8gZUeSO.js"),
14748
14748
  import("./index-DRCvimau.js"),
14749
14749
  import("./index-C_x_N6Uh.js"),
14750
14750
  import("./index-D_sWOSiG.js"),
@@ -14949,7 +14949,7 @@ const _Editor = class _Editor extends EventEmitter {
14949
14949
  * Process collaboration migrations
14950
14950
  */
14951
14951
  processCollaborationMigrations() {
14952
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.100");
14952
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.101");
14953
14953
  if (!this.options.ydoc) return;
14954
14954
  const metaMap = this.options.ydoc.getMap("meta");
14955
14955
  let docVersion = metaMap.get("version");
@@ -27120,7 +27120,7 @@ const containerStyles = {
27120
27120
  alignItems: "center",
27121
27121
  background: "transparent",
27122
27122
  padding: "0",
27123
- gap: "24px",
27123
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
27124
27124
  overflowY: "auto"
27125
27125
  };
27126
27126
  const containerStylesHorizontal = {
@@ -27130,7 +27130,7 @@ const containerStylesHorizontal = {
27130
27130
  justifyContent: "safe center",
27131
27131
  background: "transparent",
27132
27132
  padding: "0",
27133
- gap: "20px",
27133
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
27134
27134
  overflowX: "auto",
27135
27135
  minHeight: "100%"
27136
27136
  };
@@ -28933,6 +28933,7 @@ function isMinimalWordLayout(value) {
28933
28933
  const LIST_MARKER_GAP$1 = 8;
28934
28934
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
28935
28935
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
28936
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
28936
28937
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
28937
28938
  const COMMENT_INTERNAL_COLOR = "#078383";
28938
28939
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -29062,10 +29063,11 @@ const _DomPainter = class _DomPainter {
29062
29063
  this.totalPages = 0;
29063
29064
  this.linkIdCounter = 0;
29064
29065
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
29066
+ this.pageGap = 24;
29065
29067
  this.virtualEnabled = false;
29066
29068
  this.virtualWindow = 5;
29067
29069
  this.virtualOverscan = 0;
29068
- this.virtualGap = 72;
29070
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
29069
29071
  this.virtualPaddingTop = null;
29070
29072
  this.topSpacerEl = null;
29071
29073
  this.bottomSpacerEl = null;
@@ -29084,13 +29086,14 @@ const _DomPainter = class _DomPainter {
29084
29086
  this.blockLookup = this.buildBlockLookup(blocks, measures);
29085
29087
  this.headerProvider = options.headerProvider;
29086
29088
  this.footerProvider = options.footerProvider;
29089
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
29090
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
29087
29091
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
29088
29092
  this.virtualEnabled = true;
29089
29093
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
29090
29094
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
29091
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
29092
- this.virtualGap = Math.max(0, options.virtualization.gap);
29093
- }
29095
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
29096
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
29094
29097
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
29095
29098
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
29096
29099
  }
@@ -29191,6 +29194,7 @@ const _DomPainter = class _DomPainter {
29191
29194
  const mode = this.layoutMode;
29192
29195
  if (mode === "horizontal") {
29193
29196
  applyStyles$2(mount, containerStylesHorizontal);
29197
+ mount.style.gap = `${this.pageGap}px`;
29194
29198
  this.renderHorizontal(layout, mount);
29195
29199
  this.currentLayout = layout;
29196
29200
  this.pageStates = [];
@@ -29213,6 +29217,7 @@ const _DomPainter = class _DomPainter {
29213
29217
  this.changedBlocks.clear();
29214
29218
  return;
29215
29219
  }
29220
+ mount.style.gap = `${this.pageGap}px`;
29216
29221
  if (!this.currentLayout || this.pageStates.length === 0) {
29217
29222
  this.fullRender(layout);
29218
29223
  } else {
@@ -32432,6 +32437,7 @@ const createDomPainter = (options) => {
32432
32437
  const painter = new DomPainter(options.blocks, options.measures, {
32433
32438
  pageStyles: options.pageStyles,
32434
32439
  layoutMode: options.layoutMode,
32440
+ pageGap: options.pageGap,
32435
32441
  headerProvider: options.headerProvider,
32436
32442
  footerProvider: options.footerProvider,
32437
32443
  virtualization: options.virtualization,
@@ -37729,6 +37735,285 @@ async function remeasureAffectedBlocks(blocks, measures, affectedBlockIds, const
37729
37735
  }
37730
37736
  return updatedMeasures;
37731
37737
  }
37738
+ class PageGeometryHelper {
37739
+ /**
37740
+ * Creates a new PageGeometryHelper instance.
37741
+ *
37742
+ * @param config - Page geometry configuration
37743
+ */
37744
+ constructor(config) {
37745
+ this.cache = null;
37746
+ this.config = config;
37747
+ }
37748
+ /**
37749
+ * Updates the layout and invalidates the cache.
37750
+ *
37751
+ * Call this whenever the layout changes (new pages, different heights, etc.)
37752
+ *
37753
+ * @param layout - New layout data
37754
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
37755
+ */
37756
+ updateLayout(layout, pageGap) {
37757
+ this.config.layout = layout;
37758
+ if (pageGap !== void 0) {
37759
+ this.config.pageGap = pageGap;
37760
+ }
37761
+ this.cache = null;
37762
+ }
37763
+ /**
37764
+ * Updates the page gap and invalidates the cache.
37765
+ *
37766
+ * @param pageGap - New gap between pages in pixels
37767
+ */
37768
+ updatePageGap(pageGap) {
37769
+ if (this.config.pageGap !== pageGap) {
37770
+ this.config.pageGap = pageGap;
37771
+ this.cache = null;
37772
+ }
37773
+ }
37774
+ /**
37775
+ * Gets the cumulative Y position (top edge) of a page in container space.
37776
+ *
37777
+ * The returned value is the distance from the top of the container to the
37778
+ * top of the specified page, accounting for all previous pages and gaps.
37779
+ *
37780
+ * @param pageIndex - Zero-based page index
37781
+ * @returns Y position in pixels, or 0 if page index is invalid
37782
+ *
37783
+ * @example
37784
+ * ```typescript
37785
+ * // Get Y position of page 0 (first page)
37786
+ * const y0 = helper.getPageTop(0); // Returns 0
37787
+ *
37788
+ * // Get Y position of page 2 (third page)
37789
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
37790
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
37791
+ * ```
37792
+ */
37793
+ getPageTop(pageIndex) {
37794
+ this.ensureCache();
37795
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
37796
+ return 0;
37797
+ }
37798
+ return this.cache.cumulativeY[pageIndex];
37799
+ }
37800
+ /**
37801
+ * Gets the height of a specific page.
37802
+ *
37803
+ * Uses per-page height if available (from layout.pages[i].size?.h),
37804
+ * otherwise falls back to layout.pageSize.h.
37805
+ *
37806
+ * @param pageIndex - Zero-based page index
37807
+ * @returns Page height in pixels, or 0 if page index is invalid
37808
+ *
37809
+ * @example
37810
+ * ```typescript
37811
+ * const height = helper.getPageHeight(0); // Returns page-specific height
37812
+ * ```
37813
+ */
37814
+ getPageHeight(pageIndex) {
37815
+ this.ensureCache();
37816
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
37817
+ return 0;
37818
+ }
37819
+ return this.cache.pageHeights[pageIndex];
37820
+ }
37821
+ /**
37822
+ * Gets the gap between pages.
37823
+ *
37824
+ * @returns Gap in pixels
37825
+ *
37826
+ * @example
37827
+ * ```typescript
37828
+ * const gap = helper.getPageGap(); // Returns 24
37829
+ * ```
37830
+ */
37831
+ getPageGap() {
37832
+ this.ensureCache();
37833
+ return this.cache.pageGap;
37834
+ }
37835
+ /**
37836
+ * Gets the total height of all pages including gaps.
37837
+ *
37838
+ * Total height = sum of all page heights + (pageCount - 1) * gap
37839
+ *
37840
+ * @returns Total height in pixels
37841
+ *
37842
+ * @example
37843
+ * ```typescript
37844
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
37845
+ * const total = helper.getTotalHeight();
37846
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
37847
+ * ```
37848
+ */
37849
+ getTotalHeight() {
37850
+ this.ensureCache();
37851
+ return this.cache.totalHeight;
37852
+ }
37853
+ /**
37854
+ * Gets the number of pages in the layout.
37855
+ *
37856
+ * @returns Page count
37857
+ */
37858
+ getPageCount() {
37859
+ return this.config.layout.pages.length;
37860
+ }
37861
+ /**
37862
+ * Finds the page index containing a given Y coordinate.
37863
+ *
37864
+ * This performs a linear search through cached cumulative positions.
37865
+ * For large documents, consider adding binary search optimization.
37866
+ *
37867
+ * @param containerY - Y coordinate in container space
37868
+ * @returns Page index, or null if Y is outside all pages
37869
+ *
37870
+ * @example
37871
+ * ```typescript
37872
+ * // Find which page contains Y = 1500
37873
+ * const pageIndex = helper.getPageIndexAtY(1500);
37874
+ * // Returns 1 (second page) if first page ends at Y=1024
37875
+ * ```
37876
+ */
37877
+ getPageIndexAtY(containerY) {
37878
+ this.ensureCache();
37879
+ const cache2 = this.cache;
37880
+ for (let i = 0; i < cache2.cumulativeY.length; i++) {
37881
+ const pageTop = cache2.cumulativeY[i];
37882
+ const pageBottom = pageTop + cache2.pageHeights[i];
37883
+ if (containerY >= pageTop && containerY < pageBottom) {
37884
+ return i;
37885
+ }
37886
+ }
37887
+ return null;
37888
+ }
37889
+ /**
37890
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
37891
+ *
37892
+ * Returns the page containing Y when inside a page; otherwise returns the
37893
+ * closest page based on distance to page center. Useful for dragging through
37894
+ * page gaps where getPageIndexAtY would return null.
37895
+ *
37896
+ * @param containerY - Y coordinate in container space
37897
+ * @returns Nearest page index, or null if there are no pages
37898
+ */
37899
+ getNearestPageIndex(containerY) {
37900
+ this.ensureCache();
37901
+ const cache2 = this.cache;
37902
+ const pageCount = cache2.pageHeights.length;
37903
+ if (pageCount === 0) return null;
37904
+ const direct = this.getPageIndexAtY(containerY);
37905
+ if (direct !== null) return direct;
37906
+ let nearestIndex = 0;
37907
+ let nearestDistance = Infinity;
37908
+ for (let i = 0; i < pageCount; i++) {
37909
+ const top2 = cache2.cumulativeY[i];
37910
+ const height = cache2.pageHeights[i];
37911
+ const center = top2 + height / 2;
37912
+ const distance = Math.abs(containerY - center);
37913
+ if (distance < nearestDistance) {
37914
+ nearestDistance = distance;
37915
+ nearestIndex = i;
37916
+ }
37917
+ }
37918
+ return nearestIndex;
37919
+ }
37920
+ /**
37921
+ * Ensures the cache is built and up-to-date.
37922
+ * Validates cache state and rebuilds if needed.
37923
+ * @private
37924
+ * @throws Never throws - handles errors gracefully with fallback values
37925
+ */
37926
+ ensureCache() {
37927
+ if (this.cache !== null) {
37928
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
37929
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
37930
+ this.cache = null;
37931
+ } else {
37932
+ return;
37933
+ }
37934
+ }
37935
+ this.buildCache();
37936
+ }
37937
+ /**
37938
+ * Builds the geometry cache from current layout data.
37939
+ * Handles errors gracefully by providing fallback values.
37940
+ * @private
37941
+ * @throws Never throws - catches all errors and provides safe defaults
37942
+ */
37943
+ buildCache() {
37944
+ try {
37945
+ const layout = this.config.layout;
37946
+ if (!layout || !Array.isArray(layout.pages)) {
37947
+ throw new Error("Invalid layout: missing or invalid pages array");
37948
+ }
37949
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
37950
+ const pageCount = layout.pages.length;
37951
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
37952
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
37953
+ }
37954
+ const cumulativeY = new Array(pageCount);
37955
+ const pageHeights = new Array(pageCount);
37956
+ let currentY = 0;
37957
+ for (let i = 0; i < pageCount; i++) {
37958
+ const page = layout.pages[i];
37959
+ if (!page) {
37960
+ throw new Error(`Invalid page at index ${i}: page is null or undefined`);
37961
+ }
37962
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
37963
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
37964
+ throw new Error(`Invalid page height at index ${i}: ${pageHeight} (must be non-negative finite number)`);
37965
+ }
37966
+ cumulativeY[i] = currentY;
37967
+ pageHeights[i] = pageHeight;
37968
+ currentY += pageHeight;
37969
+ if (i < pageCount - 1) {
37970
+ currentY += pageGap;
37971
+ }
37972
+ }
37973
+ const totalHeight = currentY;
37974
+ this.cache = {
37975
+ cumulativeY,
37976
+ pageHeights,
37977
+ pageGap,
37978
+ totalHeight,
37979
+ layoutVersion: 0
37980
+ // Placeholder for future version tracking
37981
+ };
37982
+ } catch (error) {
37983
+ const errorMessage = error instanceof Error ? error.message : String(error);
37984
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
37985
+ this.cache = {
37986
+ cumulativeY: [],
37987
+ pageHeights: [],
37988
+ pageGap: 0,
37989
+ totalHeight: 0,
37990
+ layoutVersion: 0
37991
+ };
37992
+ }
37993
+ }
37994
+ /**
37995
+ * Clears the cache, forcing recalculation on next access.
37996
+ * Useful for testing or manual cache invalidation.
37997
+ */
37998
+ clearCache() {
37999
+ this.cache = null;
38000
+ }
38001
+ /**
38002
+ * Gets debug information about the current cache state.
38003
+ * @internal
38004
+ */
38005
+ getDebugInfo() {
38006
+ this.ensureCache();
38007
+ return {
38008
+ isCached: this.cache !== null,
38009
+ pageCount: this.config.layout.pages.length,
38010
+ pageGap: this.cache.pageGap,
38011
+ totalHeight: this.cache.totalHeight,
38012
+ cumulativeY: [...this.cache.cumulativeY],
38013
+ pageHeights: [...this.cache.pageHeights]
38014
+ };
38015
+ }
38016
+ }
37732
38017
  var Priority = /* @__PURE__ */ ((Priority2) => {
37733
38018
  Priority2[Priority2["P0"] = 0] = "P0";
37734
38019
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -38022,18 +38307,41 @@ const rangesOverlap = (startA, endA, startB, endB) => {
38022
38307
  const effectiveEndA = endA ?? startA + 1;
38023
38308
  return effectiveEndA > startB && startA < endB;
38024
38309
  };
38025
- function hitTestPage(layout, point) {
38310
+ function hitTestPage(layout, point, geometryHelper) {
38311
+ if (geometryHelper) {
38312
+ const pageIndex = geometryHelper.getPageIndexAtY(point.y);
38313
+ if (pageIndex !== null) {
38314
+ return { pageIndex, page: layout.pages[pageIndex] };
38315
+ }
38316
+ const nearest = geometryHelper.getNearestPageIndex(point.y);
38317
+ if (nearest !== null) {
38318
+ return { pageIndex: nearest, page: layout.pages[nearest] };
38319
+ }
38320
+ return null;
38321
+ }
38026
38322
  const pageGap = layout.pageGap ?? 0;
38027
38323
  let cursorY = 0;
38324
+ let nearestIndex = null;
38325
+ let nearestDistance = Infinity;
38028
38326
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
38029
38327
  const page = layout.pages[pageIndex];
38328
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
38030
38329
  const top2 = cursorY;
38031
- const bottom2 = top2 + layout.pageSize.h;
38330
+ const bottom2 = top2 + pageHeight;
38032
38331
  if (point.y >= top2 && point.y < bottom2) {
38033
38332
  return { pageIndex, page };
38034
38333
  }
38334
+ const center = top2 + pageHeight / 2;
38335
+ const distance = Math.abs(point.y - center);
38336
+ if (distance < nearestDistance) {
38337
+ nearestDistance = distance;
38338
+ nearestIndex = pageIndex;
38339
+ }
38035
38340
  cursorY = bottom2 + pageGap;
38036
38341
  }
38342
+ if (nearestIndex !== null) {
38343
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
38344
+ }
38037
38345
  return null;
38038
38346
  }
38039
38347
  function hitTestFragment(layout, pageHit, blocks, measures, point) {
@@ -38194,7 +38502,7 @@ const hitTestTableFragment = (pageHit, blocks, measures, point) => {
38194
38502
  }
38195
38503
  return null;
38196
38504
  };
38197
- function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY) {
38505
+ function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
38198
38506
  logClickStage("log", "entry", {
38199
38507
  pages: layout.pages.length
38200
38508
  });
@@ -38237,75 +38545,132 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
38237
38545
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
38238
38546
  }
38239
38547
  }
38240
- const pageHit = hitTestPage(layout, containerPoint);
38548
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
38241
38549
  if (!pageHit) {
38242
38550
  return null;
38243
38551
  }
38244
- const pageGap = layout.pageGap ?? 0;
38552
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
38245
38553
  const pageRelativePoint = {
38246
38554
  x: containerPoint.x,
38247
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
38555
+ y: containerPoint.y - pageTopY
38248
38556
  };
38249
38557
  logClickStage("log", "page-hit", {
38250
38558
  pageIndex: pageHit.pageIndex
38251
38559
  });
38252
- const fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
38560
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
38561
+ if (!fragmentHit) {
38562
+ const page = pageHit.page;
38563
+ const fragments = page.fragments.filter(
38564
+ (f2) => f2 != null && typeof f2 === "object"
38565
+ );
38566
+ if (fragments.length > 0) {
38567
+ let nearest = null;
38568
+ let nearestDist = Infinity;
38569
+ for (const frag of fragments) {
38570
+ const top2 = frag.y;
38571
+ const bottom2 = frag.y + frag.height;
38572
+ let dist;
38573
+ if (pageRelativePoint.y < top2) {
38574
+ dist = top2 - pageRelativePoint.y;
38575
+ } else if (pageRelativePoint.y > bottom2) {
38576
+ dist = pageRelativePoint.y - bottom2;
38577
+ } else {
38578
+ dist = 0;
38579
+ }
38580
+ if (dist < nearestDist) {
38581
+ nearestDist = dist;
38582
+ nearest = frag;
38583
+ }
38584
+ }
38585
+ if (nearest) {
38586
+ const blockIndex = findBlockIndexByFragmentId(blocks, nearest.blockId);
38587
+ if (blockIndex !== -1) {
38588
+ const block = blocks[blockIndex];
38589
+ const measure = measures[blockIndex];
38590
+ if (block && measure) {
38591
+ fragmentHit = {
38592
+ fragment: nearest,
38593
+ block,
38594
+ measure,
38595
+ pageIndex: pageHit.pageIndex,
38596
+ pageY: 0
38597
+ };
38598
+ }
38599
+ }
38600
+ }
38601
+ }
38602
+ }
38253
38603
  if (fragmentHit) {
38254
38604
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
38255
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
38256
- logClickStage("warn", "fragment-type-mismatch", {
38257
- fragmentKind: fragment.kind,
38258
- measureKind: measure.kind,
38259
- blockKind: block.kind
38605
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
38606
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
38607
+ if (lineIndex == null) {
38608
+ logClickStage("warn", "no-line", {
38609
+ blockId: fragment.blockId
38610
+ });
38611
+ return null;
38612
+ }
38613
+ const line = measure.lines[lineIndex];
38614
+ const isRTL = isRtlBlock(block);
38615
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
38616
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
38617
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
38618
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
38619
+ const totalIndent = paraIndentLeft + paraIndentRight;
38620
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
38621
+ if (totalIndent > fragment.width) {
38622
+ console.warn(
38623
+ `[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.`
38624
+ );
38625
+ }
38626
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
38627
+ const isListItem3 = markerWidth > 0;
38628
+ const alignmentOverride = isListItem3 ? "left" : void 0;
38629
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
38630
+ if (pos == null) {
38631
+ logClickStage("warn", "no-position", {
38632
+ blockId: fragment.blockId
38633
+ });
38634
+ return null;
38635
+ }
38636
+ const column = determineColumn(layout, fragment.x);
38637
+ logPositionDebug({
38638
+ blockId: fragment.blockId,
38639
+ x: pageRelativePoint.x - fragment.x
38260
38640
  });
38261
- return null;
38262
- }
38263
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
38264
- if (lineIndex == null) {
38265
- logClickStage("warn", "no-line", {
38641
+ logClickStage("log", "success", {
38266
38642
  blockId: fragment.blockId
38267
38643
  });
38268
- return null;
38269
- }
38270
- const line = measure.lines[lineIndex];
38271
- const isRTL = isRtlBlock(block);
38272
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
38273
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
38274
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
38275
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
38276
- const totalIndent = paraIndentLeft + paraIndentRight;
38277
- const availableWidth = Math.max(0, fragment.width - totalIndent);
38278
- if (totalIndent > fragment.width) {
38279
- console.warn(
38280
- `[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.`
38281
- );
38644
+ return {
38645
+ pos,
38646
+ blockId: fragment.blockId,
38647
+ pageIndex,
38648
+ column,
38649
+ lineIndex
38650
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
38651
+ };
38282
38652
  }
38283
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
38284
- const isListItem3 = markerWidth > 0;
38285
- const alignmentOverride = isListItem3 ? "left" : void 0;
38286
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
38287
- if (pos == null) {
38288
- logClickStage("warn", "no-position", {
38289
- blockId: fragment.blockId
38653
+ if (isAtomicFragment(fragment)) {
38654
+ const pmRange = getAtomicPmRange(fragment, block);
38655
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
38656
+ if (pos == null) {
38657
+ logClickStage("warn", "atomic-without-range", {
38658
+ fragmentId: fragment.blockId
38659
+ });
38660
+ return null;
38661
+ }
38662
+ logClickStage("log", "success", {
38663
+ blockId: fragment.blockId,
38664
+ column: determineColumn(layout, fragment.x)
38290
38665
  });
38291
- return null;
38666
+ return {
38667
+ pos,
38668
+ blockId: fragment.blockId,
38669
+ pageIndex,
38670
+ column: determineColumn(layout, fragment.x),
38671
+ lineIndex: -1
38672
+ };
38292
38673
  }
38293
- const column = determineColumn(layout, fragment.x);
38294
- logPositionDebug({
38295
- blockId: fragment.blockId,
38296
- x: pageRelativePoint.x - fragment.x
38297
- });
38298
- logClickStage("log", "success", {
38299
- blockId: fragment.blockId
38300
- });
38301
- return {
38302
- pos,
38303
- blockId: fragment.blockId,
38304
- pageIndex,
38305
- column,
38306
- lineIndex
38307
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
38308
- };
38309
38674
  }
38310
38675
  const tableHit = hitTestTableFragment(pageHit, blocks, measures, pageRelativePoint);
38311
38676
  if (tableHit) {
@@ -38455,12 +38820,22 @@ const sumLineHeights = (measure, fromLine, toLine) => {
38455
38820
  }
38456
38821
  return height;
38457
38822
  };
38458
- function selectionToRects(layout, blocks, measures, from2, to) {
38823
+ const calculatePageTopFallback = (layout, pageIndex) => {
38824
+ const pageGap = layout.pageGap ?? 0;
38825
+ let y = 0;
38826
+ for (let i = 0; i < pageIndex; i++) {
38827
+ const pageHeight = layout.pages[i]?.size?.h ?? layout.pageSize.h;
38828
+ y += pageHeight + pageGap;
38829
+ }
38830
+ return y;
38831
+ };
38832
+ function selectionToRects(layout, blocks, measures, from2, to, geometryHelper) {
38459
38833
  if (from2 === to) {
38460
38834
  return [];
38461
38835
  }
38462
38836
  const rects = [];
38463
38837
  layout.pages.forEach((page, pageIndex) => {
38838
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
38464
38839
  page.fragments.forEach((fragment) => {
38465
38840
  if (fragment.kind === "para") {
38466
38841
  const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
@@ -38502,12 +38877,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38502
38877
  wordLayout
38503
38878
  });
38504
38879
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
38505
- const rectWidth = Math.max(1, Math.abs(endX - startX));
38880
+ const rectWidth = Math.max(
38881
+ 1,
38882
+ Math.min(Math.abs(endX - startX), line.width)
38883
+ // clamp to line width to prevent runaway widths
38884
+ );
38506
38885
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
38507
38886
  const rectY = fragment.y + lineOffset;
38508
38887
  rects.push({
38509
38888
  x: rectX,
38510
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
38889
+ y: rectY + pageTopY,
38511
38890
  width: rectWidth,
38512
38891
  height: line.lineHeight,
38513
38892
  pageIndex
@@ -38635,12 +39014,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38635
39014
  wordLayout: cellWordLayout
38636
39015
  });
38637
39016
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
38638
- const rectWidth = Math.max(1, Math.abs(endX - startX));
39017
+ const rectWidth = Math.max(
39018
+ 1,
39019
+ Math.min(Math.abs(endX - startX), line.width)
39020
+ // clamp to line width to prevent runaway widths
39021
+ );
38639
39022
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
38640
39023
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
38641
39024
  rects.push({
38642
39025
  x: rectX,
38643
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
39026
+ y: rectY + pageTopY,
38644
39027
  width: rectWidth,
38645
39028
  height: line.lineHeight,
38646
39029
  pageIndex
@@ -38669,7 +39052,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
38669
39052
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
38670
39053
  rects.push({
38671
39054
  x: fragment.x,
38672
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
39055
+ y: fragment.y + pageTopY,
38673
39056
  width: fragment.width,
38674
39057
  height: fragment.height,
38675
39058
  pageIndex
@@ -42027,6 +42410,7 @@ const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
42027
42410
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
42028
42411
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
42029
42412
  const DEFAULT_PAGE_GAP = 24;
42413
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
42030
42414
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
42031
42415
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
42032
42416
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -42050,6 +42434,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
42050
42434
  __privateAdd(this, _layoutOptions);
42051
42435
  __privateAdd(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
42052
42436
  __privateAdd(this, _domPainter, null);
42437
+ __privateAdd(this, _pageGeometryHelper, null);
42053
42438
  __privateAdd(this, _dragHandlerCleanup, null);
42054
42439
  __privateAdd(this, _layoutError, null);
42055
42440
  __privateAdd(this, _layoutErrorState, "healthy");
@@ -42218,7 +42603,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
42218
42603
  { x, y },
42219
42604
  __privateGet(this, _viewportHost),
42220
42605
  event.clientX,
42221
- event.clientY
42606
+ event.clientY,
42607
+ __privateGet(this, _pageGeometryHelper) ?? void 0
42222
42608
  );
42223
42609
  const doc2 = __privateGet(this, _editor3).state?.doc;
42224
42610
  const hit = rawHit && doc2 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc2.content.size)) } : rawHit;
@@ -42417,7 +42803,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
42417
42803
  { x: normalized.x, y: normalized.y },
42418
42804
  __privateGet(this, _viewportHost),
42419
42805
  event.clientX,
42420
- event.clientY
42806
+ event.clientY,
42807
+ __privateGet(this, _pageGeometryHelper) ?? void 0
42421
42808
  );
42422
42809
  if (!hit) return;
42423
42810
  const currentTableHit = __privateMethod(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -43307,7 +43694,14 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43307
43694
  return __privateMethod(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
43308
43695
  }
43309
43696
  if (!__privateGet(this, _layoutState).layout) return [];
43310
- const rects = selectionToRects(__privateGet(this, _layoutState).layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, start2, end2) ?? [];
43697
+ const rects = selectionToRects(
43698
+ __privateGet(this, _layoutState).layout,
43699
+ __privateGet(this, _layoutState).blocks,
43700
+ __privateGet(this, _layoutState).measures,
43701
+ start2,
43702
+ end2,
43703
+ __privateGet(this, _pageGeometryHelper) ?? void 0
43704
+ ) ?? [];
43311
43705
  return rects;
43312
43706
  };
43313
43707
  const rawRects = layoutRectSource();
@@ -43572,6 +43966,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43572
43966
  };
43573
43967
  }
43574
43968
  __privateSet(this, _domPainter, null);
43969
+ __privateSet(this, _pageGeometryHelper, null);
43575
43970
  __privateSet(this, _pendingDocChange, true);
43576
43971
  __privateMethod(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
43577
43972
  }
@@ -43604,7 +43999,16 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43604
43999
  x: localX,
43605
44000
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
43606
44001
  };
43607
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
44002
+ const hit2 = clickToPosition(
44003
+ context.layout,
44004
+ context.blocks,
44005
+ context.measures,
44006
+ headerPoint,
44007
+ void 0,
44008
+ void 0,
44009
+ void 0,
44010
+ void 0
44011
+ ) ?? null;
43608
44012
  return hit2;
43609
44013
  }
43610
44014
  if (!__privateGet(this, _layoutState).layout) {
@@ -43617,7 +44021,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43617
44021
  normalized,
43618
44022
  __privateGet(this, _viewportHost),
43619
44023
  clientX,
43620
- clientY
44024
+ clientY,
44025
+ __privateGet(this, _pageGeometryHelper) ?? void 0
43621
44026
  ) ?? null;
43622
44027
  return hit;
43623
44028
  }
@@ -43840,6 +44245,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43840
44245
  __privateSet(this, _session, { mode: "body" });
43841
44246
  __privateSet(this, _activeHeaderFooterEditor, null);
43842
44247
  __privateSet(this, _domPainter, null);
44248
+ __privateSet(this, _pageGeometryHelper, null);
43843
44249
  (_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
43844
44250
  __privateSet(this, _dragHandlerCleanup, null);
43845
44251
  __privateGet(this, _selectionOverlay2)?.remove();
@@ -43893,7 +44299,14 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
43893
44299
  if (!normalized) return false;
43894
44300
  const pmPos = __privateGet(this, _layoutState).bookmarks.get(normalized);
43895
44301
  if (pmPos == null) return false;
43896
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
44302
+ const rects = selectionToRects(
44303
+ layout,
44304
+ __privateGet(this, _layoutState).blocks,
44305
+ __privateGet(this, _layoutState).measures,
44306
+ pmPos,
44307
+ pmPos + 1,
44308
+ __privateGet(this, _pageGeometryHelper) ?? void 0
44309
+ ) ?? [];
43897
44310
  const rect = rects[0];
43898
44311
  let pageIndex = rect?.pageIndex ?? null;
43899
44312
  if (pageIndex == null) {
@@ -43957,6 +44370,7 @@ _hiddenHost = new WeakMap();
43957
44370
  _layoutOptions = new WeakMap();
43958
44371
  _layoutState = new WeakMap();
43959
44372
  _domPainter = new WeakMap();
44373
+ _pageGeometryHelper = new WeakMap();
43960
44374
  _dragHandlerCleanup = new WeakMap();
43961
44375
  _layoutError = new WeakMap();
43962
44376
  _layoutErrorState = new WeakMap();
@@ -44588,7 +45002,7 @@ renderRemoteSelection_fn = function(cursor) {
44588
45002
  if (!layout || !blocks || !measures) return;
44589
45003
  const start2 = Math.min(cursor.anchor, cursor.head);
44590
45004
  const end2 = Math.max(cursor.anchor, cursor.head);
44591
- const rects = selectionToRects(layout, blocks, measures, start2, end2) ?? [];
45005
+ const rects = selectionToRects(layout, blocks, measures, start2, end2, __privateGet(this, _pageGeometryHelper) ?? void 0) ?? [];
44592
45006
  const color = __privateMethod(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
44593
45007
  const opacity = __privateGet(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
44594
45008
  const pageHeight = layout.pageSize?.h ?? __privateGet(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -45081,15 +45495,25 @@ hitTestTable_fn = function(normalizedX, normalizedY) {
45081
45495
  const configuredPageSize = __privateGet(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
45082
45496
  let pageY = 0;
45083
45497
  let pageHit = null;
45084
- for (let i = 0; i < layout.pages.length; i++) {
45085
- const page = layout.pages[i];
45086
- const pageHeight = page.size?.h ?? configuredPageSize.h;
45087
- const gap = __privateGet(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
45088
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
45089
- pageHit = { pageIndex: i, page };
45090
- break;
45498
+ const geometryHelper = __privateGet(this, _pageGeometryHelper);
45499
+ if (geometryHelper) {
45500
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
45501
+ if (idx != null && layout.pages[idx]) {
45502
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
45503
+ pageY = geometryHelper.getPageTop(idx);
45504
+ }
45505
+ }
45506
+ if (!pageHit) {
45507
+ const gap = layout.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
45508
+ for (let i = 0; i < layout.pages.length; i++) {
45509
+ const page = layout.pages[i];
45510
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
45511
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
45512
+ pageHit = { pageIndex: i, page };
45513
+ break;
45514
+ }
45515
+ pageY += pageHeight + gap;
45091
45516
  }
45092
- pageY += pageHeight + gap;
45093
45517
  }
45094
45518
  if (!pageHit) {
45095
45519
  return null;
@@ -45401,12 +45825,7 @@ rerender_fn = async function() {
45401
45825
  return;
45402
45826
  }
45403
45827
  ({ layout, measures } = result);
45404
- if (__privateGet(this, _layoutOptions).virtualization?.enabled) {
45405
- const gap = __privateGet(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
45406
- layout.pageGap = Math.max(0, gap);
45407
- } else {
45408
- layout.pageGap = DEFAULT_PAGE_GAP;
45409
- }
45828
+ layout.pageGap = __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
45410
45829
  headerLayouts = result.headers;
45411
45830
  footerLayouts = result.footers;
45412
45831
  } catch (error) {
@@ -45423,6 +45842,17 @@ rerender_fn = async function() {
45423
45842
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
45424
45843
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
45425
45844
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
45845
+ if (__privateGet(this, _layoutState).layout) {
45846
+ const pageGap = __privateGet(this, _layoutState).layout.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
45847
+ if (!__privateGet(this, _pageGeometryHelper)) {
45848
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
45849
+ layout: __privateGet(this, _layoutState).layout,
45850
+ pageGap
45851
+ }));
45852
+ } else {
45853
+ __privateGet(this, _pageGeometryHelper).updateLayout(__privateGet(this, _layoutState).layout, pageGap);
45854
+ }
45855
+ }
45426
45856
  await __privateMethod(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
45427
45857
  __privateMethod(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
45428
45858
  const painter = __privateMethod(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -45492,7 +45922,8 @@ ensurePainter_fn = function(blocks, measures) {
45492
45922
  pageStyles: __privateGet(this, _layoutOptions).pageStyles,
45493
45923
  headerProvider: __privateGet(this, _headerDecorationProvider),
45494
45924
  footerProvider: __privateGet(this, _footerDecorationProvider),
45495
- ruler: __privateGet(this, _layoutOptions).ruler
45925
+ ruler: __privateGet(this, _layoutOptions).ruler,
45926
+ pageGap: __privateGet(this, _layoutState).layout?.pageGap ?? __privateMethod(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
45496
45927
  }));
45497
45928
  }
45498
45929
  return __privateGet(this, _domPainter);
@@ -45647,7 +46078,14 @@ updateSelection_fn = function() {
45647
46078
  }
45648
46079
  return;
45649
46080
  }
45650
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, from2, to) ?? [];
46081
+ const rects = selectionToRects(
46082
+ layout,
46083
+ __privateGet(this, _layoutState).blocks,
46084
+ __privateGet(this, _layoutState).measures,
46085
+ from2,
46086
+ to,
46087
+ __privateGet(this, _pageGeometryHelper) ?? void 0
46088
+ ) ?? [];
45651
46089
  let domStart = null;
45652
46090
  let domEnd = null;
45653
46091
  try {
@@ -45661,7 +46099,9 @@ updateSelection_fn = function() {
45661
46099
  const correctedRects = __privateMethod(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
45662
46100
  try {
45663
46101
  __privateGet(this, _localSelectionLayer).innerHTML = "";
45664
- __privateMethod(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
46102
+ if (correctedRects.length > 0) {
46103
+ __privateMethod(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
46104
+ }
45665
46105
  } catch (error) {
45666
46106
  if (process$1.env.NODE_ENV === "development") {
45667
46107
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -46514,6 +46954,19 @@ waitForPageMount_fn = async function(pageIndex, options = {}) {
46514
46954
  checkPage();
46515
46955
  });
46516
46956
  };
46957
+ /**
46958
+ * Get effective page gap based on layout mode and virtualization settings.
46959
+ * Keeps painter, layout, and geometry in sync.
46960
+ */
46961
+ getEffectivePageGap_fn = function() {
46962
+ if (__privateGet(this, _layoutOptions).virtualization?.enabled) {
46963
+ return Math.max(0, __privateGet(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
46964
+ }
46965
+ if (__privateGet(this, _layoutOptions).layoutMode === "horizontal") {
46966
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
46967
+ }
46968
+ return DEFAULT_PAGE_GAP;
46969
+ };
46517
46970
  getBodyPageHeight_fn = function() {
46518
46971
  return __privateGet(this, _layoutState).layout?.pageSize?.h ?? __privateGet(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
46519
46972
  };
@@ -46566,7 +47019,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46566
47019
  dy: domStart.y - layoutY
46567
47020
  };
46568
47021
  }
46569
- return rects.map((rect, idx) => {
47022
+ const corrected = rects.map((rect, idx) => {
46570
47023
  const delta = pageDelta[rect.pageIndex];
46571
47024
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
46572
47025
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -46581,6 +47034,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46581
47034
  }
46582
47035
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
46583
47036
  const endX = domEnd.x;
47037
+ adjustedX = Math.min(adjustedX, endX);
46584
47038
  adjustedWidth = Math.max(1, endX - adjustedX);
46585
47039
  }
46586
47040
  return {
@@ -46590,6 +47044,29 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
46590
47044
  width: adjustedWidth
46591
47045
  };
46592
47046
  });
47047
+ const MAX_DELTA_PX = 12;
47048
+ let invalid = false;
47049
+ if (domStart && corrected[0]) {
47050
+ const dx = Math.abs(corrected[0].x - domStart.x);
47051
+ const dy = Math.abs(corrected[0].y - domStart.y);
47052
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
47053
+ }
47054
+ if (domEnd && corrected[corrected.length - 1]) {
47055
+ const last = corrected[corrected.length - 1];
47056
+ const dx = Math.abs(last.x + last.width - domEnd.x);
47057
+ const dy = Math.abs(last.y - domEnd.y);
47058
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
47059
+ }
47060
+ if (invalid) {
47061
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
47062
+ domStart,
47063
+ domEnd,
47064
+ rectStart: corrected[0],
47065
+ rectEnd: corrected[corrected.length - 1]
47066
+ });
47067
+ return [];
47068
+ }
47069
+ return corrected;
46593
47070
  };
46594
47071
  /**
46595
47072
  * Renders visual highlighting for CellSelection (multiple table cells selected).
@@ -46907,7 +47384,7 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
46907
47384
  return [];
46908
47385
  }
46909
47386
  if (!bodyLayout) return [];
46910
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
47387
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
46911
47388
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
46912
47389
  const bodyPageHeight = __privateMethod(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
46913
47390
  return rects.map((rect) => {
@@ -47594,7 +48071,14 @@ getCurrentPageIndex_fn = function() {
47594
48071
  if (!layout || !selection) {
47595
48072
  return 0;
47596
48073
  }
47597
- const rects = selectionToRects(layout, __privateGet(this, _layoutState).blocks, __privateGet(this, _layoutState).measures, selection.from, selection.to) ?? [];
48074
+ const rects = selectionToRects(
48075
+ layout,
48076
+ __privateGet(this, _layoutState).blocks,
48077
+ __privateGet(this, _layoutState).measures,
48078
+ selection.from,
48079
+ selection.to,
48080
+ __privateGet(this, _pageGeometryHelper) ?? void 0
48081
+ ) ?? [];
47598
48082
  if (rects.length > 0) {
47599
48083
  return rects[0]?.pageIndex ?? 0;
47600
48084
  }