superdoc 1.0.0-beta.100 → 1.0.0-beta.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/chunks/{PdfViewer-DBk7W90L.es.js → PdfViewer-BFqkSyYx.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-Bl_KAt28.cjs → PdfViewer-X1sOA7hm.cjs} +1 -1
  3. package/dist/chunks/{index-BtLZer3S.es.js → index-BP1yyX4N.es.js} +3 -3
  4. package/dist/chunks/{index-UIImjS8C.cjs → index-f4ON3m7j.cjs} +3 -3
  5. package/dist/chunks/{index-Bd5TMBeR-D31VShf3.cjs → index-nVrA3URL-BssoM7VE.cjs} +1 -1
  6. package/dist/chunks/{index-Bd5TMBeR-DcY3xcTG.es.js → index-nVrA3URL-vs_NmI3L.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-BLGnf9gI.cjs → super-editor.es-B7Xuihea.cjs} +641 -128
  8. package/dist/chunks/{super-editor.es-oszwJ36j.es.js → super-editor.es-BM69n_BR.es.js} +641 -128
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/super-editor/ai-writer.es.js +2 -2
  11. package/dist/super-editor/chunks/{converter-B6-fwuLp.js → converter-NrpPx2Xr.js} +12 -6
  12. package/dist/super-editor/chunks/{docx-zipper-DXUMayjk.js → docx-zipper-oyKPvmaC.js} +1 -1
  13. package/dist/super-editor/chunks/{editor-BAK8u8dm.js → editor-Dnw031hl.js} +631 -120
  14. package/dist/super-editor/chunks/{index-Bd5TMBeR.js → index-nVrA3URL.js} +1 -1
  15. package/dist/super-editor/chunks/{toolbar-DCCbbUQz.js → toolbar-OrlYExrD.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/super-editor.es.js +10 -10
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +643 -130
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +10 -1
@@ -39775,7 +39775,7 @@ function importCommentData({ docx, editor, converter }) {
39775
39775
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
39776
39776
  const date = new Date(createdDate);
39777
39777
  const unixTimestampMs = date.getTime();
39778
- const parsedComment = nodeListHandler.handler({
39778
+ const parsedElements = nodeListHandler.handler({
39779
39779
  nodes: el.elements,
39780
39780
  nodeListHandler,
39781
39781
  docx,
@@ -39783,7 +39783,7 @@ function importCommentData({ docx, editor, converter }) {
39783
39783
  converter,
39784
39784
  path: [el]
39785
39785
  });
39786
- const { attrs } = parsedComment[0];
39786
+ const { attrs } = parsedElements[0];
39787
39787
  const paraId = attrs["w14:paraId"];
39788
39788
  return {
39789
39789
  commentId: internalId || v4(),
@@ -39791,7 +39791,8 @@ function importCommentData({ docx, editor, converter }) {
39791
39791
  creatorName: authorName,
39792
39792
  creatorEmail: authorEmail,
39793
39793
  createdTime: unixTimestampMs,
39794
- textJson: parsedComment[0],
39794
+ textJson: parsedElements[0],
39795
+ elements: parsedElements,
39795
39796
  initials,
39796
39797
  paraId,
39797
39798
  trackedChange,
@@ -39817,7 +39818,12 @@ const generateCommentsWithExtendedData = ({ docx, comments }) => {
39817
39818
  const { elements = [] } = initialElements[0] ?? {};
39818
39819
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
39819
39820
  return comments.map((comment) => {
39820
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
39821
+ const extendedDef = commentEx.find((ce2) => {
39822
+ const isIncludedInCommentElements = comment.elements?.some(
39823
+ (el) => el.attrs?.["w14:paraId"] === ce2.attributes["w15:paraId"]
39824
+ );
39825
+ return isIncludedInCommentElements;
39826
+ });
39821
39827
  if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
39822
39828
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
39823
39829
  let parentComment;
@@ -41938,7 +41944,7 @@ const updateCommentsIdsAndExtensible = (comments = [], commentsIds, extensible)
41938
41944
  name: "w16cex:commentExtensible",
41939
41945
  attributes: {
41940
41946
  "w16cex:durableId": newDurableId,
41941
- "w16cex:dateUtc": toIsoNoFractional()
41947
+ "w16cex:dateUtc": toIsoNoFractional(comment.createdTime)
41942
41948
  }
41943
41949
  };
41944
41950
  extensibleUpdated.elements[0].elements.push(newExtensible);
@@ -42404,7 +42410,7 @@ const _SuperConverter = class _SuperConverter2 {
42404
42410
  static getStoredSuperdocVersion(docx) {
42405
42411
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42406
42412
  }
42407
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.100") {
42413
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.102") {
42408
42414
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42409
42415
  }
42410
42416
  /**
@@ -45716,7 +45722,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45716
45722
  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);
45717
45723
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45718
45724
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45719
- 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;
45725
+ 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;
45720
45726
  var GOOD_LEAF_SIZE = 200;
45721
45727
  var RopeSequence = function RopeSequence2() {
45722
45728
  };
@@ -54800,6 +54806,14 @@ const toggleNode = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state: state
54800
54806
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
54801
54807
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
54802
54808
  const { from: from2, to, empty: empty2 } = state2.selection;
54809
+ if (typeof document !== "undefined" && document.getSelection) {
54810
+ const currentDomSelection = document.getSelection();
54811
+ const selectedLength = currentDomSelection?.toString?.().length;
54812
+ const isCollapsed = currentDomSelection?.isCollapsed;
54813
+ if (!isCollapsed && selectedLength === 1) {
54814
+ return false;
54815
+ }
54816
+ }
54803
54817
  if (empty2) {
54804
54818
  return deleteSelection$1(state2, dispatch);
54805
54819
  }
@@ -57099,12 +57113,14 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
57099
57113
  importedId: node.attrs["w:id"]
57100
57114
  });
57101
57115
  if (type2.name === "commentRangeStart") {
57102
- toMark.push({
57103
- commentId: resolvedCommentId,
57104
- importedId,
57105
- internal,
57106
- start: pos
57107
- });
57116
+ if (!matchingImportedComment?.isDone) {
57117
+ toMark.push({
57118
+ commentId: resolvedCommentId,
57119
+ importedId,
57120
+ internal,
57121
+ start: pos
57122
+ });
57123
+ }
57108
57124
  ensureFallbackComment({
57109
57125
  converter,
57110
57126
  matchingImportedComment,
@@ -59622,7 +59638,7 @@ const isHeadless = (editor) => {
59622
59638
  const shouldSkipNodeView = (editor) => {
59623
59639
  return isHeadless(editor);
59624
59640
  };
59625
- const summaryVersion = "1.0.0-beta.100";
59641
+ const summaryVersion = "1.0.0-beta.102";
59626
59642
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59627
59643
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59628
59644
  function mapAttributes(attrs) {
@@ -60411,7 +60427,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60411
60427
  { default: remarkStringify },
60412
60428
  { default: remarkGfm }
60413
60429
  ] = await Promise.all([
60414
- import("./index-Bd5TMBeR-DcY3xcTG.es.js"),
60430
+ import("./index-nVrA3URL-vs_NmI3L.es.js"),
60415
60431
  import("./index-DRCvimau-Cw339678.es.js"),
60416
60432
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60417
60433
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60616,7 +60632,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60616
60632
  * Process collaboration migrations
60617
60633
  */
60618
60634
  processCollaborationMigrations() {
60619
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.100");
60635
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.102");
60620
60636
  if (!this.options.ydoc) return;
60621
60637
  const metaMap = this.options.ydoc.getMap("meta");
60622
60638
  let docVersion = metaMap.get("version");
@@ -72699,7 +72715,7 @@ const containerStyles = {
72699
72715
  alignItems: "center",
72700
72716
  background: "transparent",
72701
72717
  padding: "0",
72702
- gap: "24px",
72718
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
72703
72719
  overflowY: "auto"
72704
72720
  };
72705
72721
  const containerStylesHorizontal = {
@@ -72709,7 +72725,7 @@ const containerStylesHorizontal = {
72709
72725
  justifyContent: "safe center",
72710
72726
  background: "transparent",
72711
72727
  padding: "0",
72712
- gap: "20px",
72728
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
72713
72729
  overflowX: "auto",
72714
72730
  minHeight: "100%"
72715
72731
  };
@@ -74512,6 +74528,7 @@ function isMinimalWordLayout(value) {
74512
74528
  const LIST_MARKER_GAP$1 = 8;
74513
74529
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
74514
74530
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
74531
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
74515
74532
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
74516
74533
  const COMMENT_INTERNAL_COLOR = "#078383";
74517
74534
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -74641,10 +74658,11 @@ const _DomPainter = class _DomPainter2 {
74641
74658
  this.totalPages = 0;
74642
74659
  this.linkIdCounter = 0;
74643
74660
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
74661
+ this.pageGap = 24;
74644
74662
  this.virtualEnabled = false;
74645
74663
  this.virtualWindow = 5;
74646
74664
  this.virtualOverscan = 0;
74647
- this.virtualGap = 72;
74665
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
74648
74666
  this.virtualPaddingTop = null;
74649
74667
  this.topSpacerEl = null;
74650
74668
  this.bottomSpacerEl = null;
@@ -74663,13 +74681,14 @@ const _DomPainter = class _DomPainter2 {
74663
74681
  this.blockLookup = this.buildBlockLookup(blocks, measures);
74664
74682
  this.headerProvider = options.headerProvider;
74665
74683
  this.footerProvider = options.footerProvider;
74684
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
74685
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
74666
74686
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
74667
74687
  this.virtualEnabled = true;
74668
74688
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
74669
74689
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
74670
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
74671
- this.virtualGap = Math.max(0, options.virtualization.gap);
74672
- }
74690
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
74691
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
74673
74692
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
74674
74693
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
74675
74694
  }
@@ -74770,6 +74789,7 @@ const _DomPainter = class _DomPainter2 {
74770
74789
  const mode = this.layoutMode;
74771
74790
  if (mode === "horizontal") {
74772
74791
  applyStyles$2(mount2, containerStylesHorizontal);
74792
+ mount2.style.gap = `${this.pageGap}px`;
74773
74793
  this.renderHorizontal(layout, mount2);
74774
74794
  this.currentLayout = layout;
74775
74795
  this.pageStates = [];
@@ -74792,6 +74812,7 @@ const _DomPainter = class _DomPainter2 {
74792
74812
  this.changedBlocks.clear();
74793
74813
  return;
74794
74814
  }
74815
+ mount2.style.gap = `${this.pageGap}px`;
74795
74816
  if (!this.currentLayout || this.pageStates.length === 0) {
74796
74817
  this.fullRender(layout);
74797
74818
  } else {
@@ -78011,6 +78032,7 @@ const createDomPainter = (options) => {
78011
78032
  const painter = new DomPainter(options.blocks, options.measures, {
78012
78033
  pageStyles: options.pageStyles,
78013
78034
  layoutMode: options.layoutMode,
78035
+ pageGap: options.pageGap,
78014
78036
  headerProvider: options.headerProvider,
78015
78037
  footerProvider: options.footerProvider,
78016
78038
  virtualization: options.virtualization,
@@ -83308,6 +83330,285 @@ async function remeasureAffectedBlocks(blocks, measures, affectedBlockIds, const
83308
83330
  }
83309
83331
  return updatedMeasures;
83310
83332
  }
83333
+ class PageGeometryHelper {
83334
+ /**
83335
+ * Creates a new PageGeometryHelper instance.
83336
+ *
83337
+ * @param config - Page geometry configuration
83338
+ */
83339
+ constructor(config2) {
83340
+ this.cache = null;
83341
+ this.config = config2;
83342
+ }
83343
+ /**
83344
+ * Updates the layout and invalidates the cache.
83345
+ *
83346
+ * Call this whenever the layout changes (new pages, different heights, etc.)
83347
+ *
83348
+ * @param layout - New layout data
83349
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
83350
+ */
83351
+ updateLayout(layout, pageGap) {
83352
+ this.config.layout = layout;
83353
+ if (pageGap !== void 0) {
83354
+ this.config.pageGap = pageGap;
83355
+ }
83356
+ this.cache = null;
83357
+ }
83358
+ /**
83359
+ * Updates the page gap and invalidates the cache.
83360
+ *
83361
+ * @param pageGap - New gap between pages in pixels
83362
+ */
83363
+ updatePageGap(pageGap) {
83364
+ if (this.config.pageGap !== pageGap) {
83365
+ this.config.pageGap = pageGap;
83366
+ this.cache = null;
83367
+ }
83368
+ }
83369
+ /**
83370
+ * Gets the cumulative Y position (top edge) of a page in container space.
83371
+ *
83372
+ * The returned value is the distance from the top of the container to the
83373
+ * top of the specified page, accounting for all previous pages and gaps.
83374
+ *
83375
+ * @param pageIndex - Zero-based page index
83376
+ * @returns Y position in pixels, or 0 if page index is invalid
83377
+ *
83378
+ * @example
83379
+ * ```typescript
83380
+ * // Get Y position of page 0 (first page)
83381
+ * const y0 = helper.getPageTop(0); // Returns 0
83382
+ *
83383
+ * // Get Y position of page 2 (third page)
83384
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
83385
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
83386
+ * ```
83387
+ */
83388
+ getPageTop(pageIndex) {
83389
+ this.ensureCache();
83390
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
83391
+ return 0;
83392
+ }
83393
+ return this.cache.cumulativeY[pageIndex];
83394
+ }
83395
+ /**
83396
+ * Gets the height of a specific page.
83397
+ *
83398
+ * Uses per-page height if available (from layout.pages[i].size?.h),
83399
+ * otherwise falls back to layout.pageSize.h.
83400
+ *
83401
+ * @param pageIndex - Zero-based page index
83402
+ * @returns Page height in pixels, or 0 if page index is invalid
83403
+ *
83404
+ * @example
83405
+ * ```typescript
83406
+ * const height = helper.getPageHeight(0); // Returns page-specific height
83407
+ * ```
83408
+ */
83409
+ getPageHeight(pageIndex) {
83410
+ this.ensureCache();
83411
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
83412
+ return 0;
83413
+ }
83414
+ return this.cache.pageHeights[pageIndex];
83415
+ }
83416
+ /**
83417
+ * Gets the gap between pages.
83418
+ *
83419
+ * @returns Gap in pixels
83420
+ *
83421
+ * @example
83422
+ * ```typescript
83423
+ * const gap = helper.getPageGap(); // Returns 24
83424
+ * ```
83425
+ */
83426
+ getPageGap() {
83427
+ this.ensureCache();
83428
+ return this.cache.pageGap;
83429
+ }
83430
+ /**
83431
+ * Gets the total height of all pages including gaps.
83432
+ *
83433
+ * Total height = sum of all page heights + (pageCount - 1) * gap
83434
+ *
83435
+ * @returns Total height in pixels
83436
+ *
83437
+ * @example
83438
+ * ```typescript
83439
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
83440
+ * const total = helper.getTotalHeight();
83441
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
83442
+ * ```
83443
+ */
83444
+ getTotalHeight() {
83445
+ this.ensureCache();
83446
+ return this.cache.totalHeight;
83447
+ }
83448
+ /**
83449
+ * Gets the number of pages in the layout.
83450
+ *
83451
+ * @returns Page count
83452
+ */
83453
+ getPageCount() {
83454
+ return this.config.layout.pages.length;
83455
+ }
83456
+ /**
83457
+ * Finds the page index containing a given Y coordinate.
83458
+ *
83459
+ * This performs a linear search through cached cumulative positions.
83460
+ * For large documents, consider adding binary search optimization.
83461
+ *
83462
+ * @param containerY - Y coordinate in container space
83463
+ * @returns Page index, or null if Y is outside all pages
83464
+ *
83465
+ * @example
83466
+ * ```typescript
83467
+ * // Find which page contains Y = 1500
83468
+ * const pageIndex = helper.getPageIndexAtY(1500);
83469
+ * // Returns 1 (second page) if first page ends at Y=1024
83470
+ * ```
83471
+ */
83472
+ getPageIndexAtY(containerY) {
83473
+ this.ensureCache();
83474
+ const cache2 = this.cache;
83475
+ for (let i = 0; i < cache2.cumulativeY.length; i++) {
83476
+ const pageTop = cache2.cumulativeY[i];
83477
+ const pageBottom = pageTop + cache2.pageHeights[i];
83478
+ if (containerY >= pageTop && containerY < pageBottom) {
83479
+ return i;
83480
+ }
83481
+ }
83482
+ return null;
83483
+ }
83484
+ /**
83485
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
83486
+ *
83487
+ * Returns the page containing Y when inside a page; otherwise returns the
83488
+ * closest page based on distance to page center. Useful for dragging through
83489
+ * page gaps where getPageIndexAtY would return null.
83490
+ *
83491
+ * @param containerY - Y coordinate in container space
83492
+ * @returns Nearest page index, or null if there are no pages
83493
+ */
83494
+ getNearestPageIndex(containerY) {
83495
+ this.ensureCache();
83496
+ const cache2 = this.cache;
83497
+ const pageCount = cache2.pageHeights.length;
83498
+ if (pageCount === 0) return null;
83499
+ const direct = this.getPageIndexAtY(containerY);
83500
+ if (direct !== null) return direct;
83501
+ let nearestIndex = 0;
83502
+ let nearestDistance = Infinity;
83503
+ for (let i = 0; i < pageCount; i++) {
83504
+ const top2 = cache2.cumulativeY[i];
83505
+ const height = cache2.pageHeights[i];
83506
+ const center = top2 + height / 2;
83507
+ const distance = Math.abs(containerY - center);
83508
+ if (distance < nearestDistance) {
83509
+ nearestDistance = distance;
83510
+ nearestIndex = i;
83511
+ }
83512
+ }
83513
+ return nearestIndex;
83514
+ }
83515
+ /**
83516
+ * Ensures the cache is built and up-to-date.
83517
+ * Validates cache state and rebuilds if needed.
83518
+ * @private
83519
+ * @throws Never throws - handles errors gracefully with fallback values
83520
+ */
83521
+ ensureCache() {
83522
+ if (this.cache !== null) {
83523
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
83524
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
83525
+ this.cache = null;
83526
+ } else {
83527
+ return;
83528
+ }
83529
+ }
83530
+ this.buildCache();
83531
+ }
83532
+ /**
83533
+ * Builds the geometry cache from current layout data.
83534
+ * Handles errors gracefully by providing fallback values.
83535
+ * @private
83536
+ * @throws Never throws - catches all errors and provides safe defaults
83537
+ */
83538
+ buildCache() {
83539
+ try {
83540
+ const layout = this.config.layout;
83541
+ if (!layout || !Array.isArray(layout.pages)) {
83542
+ throw new Error("Invalid layout: missing or invalid pages array");
83543
+ }
83544
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
83545
+ const pageCount = layout.pages.length;
83546
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
83547
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
83548
+ }
83549
+ const cumulativeY = new Array(pageCount);
83550
+ const pageHeights = new Array(pageCount);
83551
+ let currentY = 0;
83552
+ for (let i = 0; i < pageCount; i++) {
83553
+ const page = layout.pages[i];
83554
+ if (!page) {
83555
+ throw new Error(`Invalid page at index ${i}: page is null or undefined`);
83556
+ }
83557
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
83558
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
83559
+ throw new Error(`Invalid page height at index ${i}: ${pageHeight} (must be non-negative finite number)`);
83560
+ }
83561
+ cumulativeY[i] = currentY;
83562
+ pageHeights[i] = pageHeight;
83563
+ currentY += pageHeight;
83564
+ if (i < pageCount - 1) {
83565
+ currentY += pageGap;
83566
+ }
83567
+ }
83568
+ const totalHeight = currentY;
83569
+ this.cache = {
83570
+ cumulativeY,
83571
+ pageHeights,
83572
+ pageGap,
83573
+ totalHeight,
83574
+ layoutVersion: 0
83575
+ // Placeholder for future version tracking
83576
+ };
83577
+ } catch (error) {
83578
+ const errorMessage = error instanceof Error ? error.message : String(error);
83579
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
83580
+ this.cache = {
83581
+ cumulativeY: [],
83582
+ pageHeights: [],
83583
+ pageGap: 0,
83584
+ totalHeight: 0,
83585
+ layoutVersion: 0
83586
+ };
83587
+ }
83588
+ }
83589
+ /**
83590
+ * Clears the cache, forcing recalculation on next access.
83591
+ * Useful for testing or manual cache invalidation.
83592
+ */
83593
+ clearCache() {
83594
+ this.cache = null;
83595
+ }
83596
+ /**
83597
+ * Gets debug information about the current cache state.
83598
+ * @internal
83599
+ */
83600
+ getDebugInfo() {
83601
+ this.ensureCache();
83602
+ return {
83603
+ isCached: this.cache !== null,
83604
+ pageCount: this.config.layout.pages.length,
83605
+ pageGap: this.cache.pageGap,
83606
+ totalHeight: this.cache.totalHeight,
83607
+ cumulativeY: [...this.cache.cumulativeY],
83608
+ pageHeights: [...this.cache.pageHeights]
83609
+ };
83610
+ }
83611
+ }
83311
83612
  var Priority = /* @__PURE__ */ ((Priority2) => {
83312
83613
  Priority2[Priority2["P0"] = 0] = "P0";
83313
83614
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -83601,18 +83902,41 @@ const rangesOverlap = (startA, endA, startB, endB) => {
83601
83902
  const effectiveEndA = endA ?? startA + 1;
83602
83903
  return effectiveEndA > startB && startA < endB;
83603
83904
  };
83604
- function hitTestPage(layout, point) {
83905
+ function hitTestPage(layout, point, geometryHelper) {
83906
+ if (geometryHelper) {
83907
+ const pageIndex = geometryHelper.getPageIndexAtY(point.y);
83908
+ if (pageIndex !== null) {
83909
+ return { pageIndex, page: layout.pages[pageIndex] };
83910
+ }
83911
+ const nearest = geometryHelper.getNearestPageIndex(point.y);
83912
+ if (nearest !== null) {
83913
+ return { pageIndex: nearest, page: layout.pages[nearest] };
83914
+ }
83915
+ return null;
83916
+ }
83605
83917
  const pageGap = layout.pageGap ?? 0;
83606
83918
  let cursorY = 0;
83919
+ let nearestIndex = null;
83920
+ let nearestDistance = Infinity;
83607
83921
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
83608
83922
  const page = layout.pages[pageIndex];
83923
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
83609
83924
  const top2 = cursorY;
83610
- const bottom2 = top2 + layout.pageSize.h;
83925
+ const bottom2 = top2 + pageHeight;
83611
83926
  if (point.y >= top2 && point.y < bottom2) {
83612
83927
  return { pageIndex, page };
83613
83928
  }
83929
+ const center = top2 + pageHeight / 2;
83930
+ const distance = Math.abs(point.y - center);
83931
+ if (distance < nearestDistance) {
83932
+ nearestDistance = distance;
83933
+ nearestIndex = pageIndex;
83934
+ }
83614
83935
  cursorY = bottom2 + pageGap;
83615
83936
  }
83937
+ if (nearestIndex !== null) {
83938
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
83939
+ }
83616
83940
  return null;
83617
83941
  }
83618
83942
  function hitTestFragment(layout, pageHit, blocks, measures, point) {
@@ -83773,7 +84097,7 @@ const hitTestTableFragment = (pageHit, blocks, measures, point) => {
83773
84097
  }
83774
84098
  return null;
83775
84099
  };
83776
- function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY) {
84100
+ function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
83777
84101
  logClickStage("log", "entry", {
83778
84102
  pages: layout.pages.length
83779
84103
  });
@@ -83816,75 +84140,132 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
83816
84140
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
83817
84141
  }
83818
84142
  }
83819
- const pageHit = hitTestPage(layout, containerPoint);
84143
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
83820
84144
  if (!pageHit) {
83821
84145
  return null;
83822
84146
  }
83823
- const pageGap = layout.pageGap ?? 0;
84147
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
83824
84148
  const pageRelativePoint = {
83825
84149
  x: containerPoint.x,
83826
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
84150
+ y: containerPoint.y - pageTopY
83827
84151
  };
83828
84152
  logClickStage("log", "page-hit", {
83829
84153
  pageIndex: pageHit.pageIndex
83830
84154
  });
83831
- const fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
84155
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
84156
+ if (!fragmentHit) {
84157
+ const page = pageHit.page;
84158
+ const fragments = page.fragments.filter(
84159
+ (f2) => f2 != null && typeof f2 === "object"
84160
+ );
84161
+ if (fragments.length > 0) {
84162
+ let nearest = null;
84163
+ let nearestDist = Infinity;
84164
+ for (const frag of fragments) {
84165
+ const top2 = frag.y;
84166
+ const bottom2 = frag.y + frag.height;
84167
+ let dist2;
84168
+ if (pageRelativePoint.y < top2) {
84169
+ dist2 = top2 - pageRelativePoint.y;
84170
+ } else if (pageRelativePoint.y > bottom2) {
84171
+ dist2 = pageRelativePoint.y - bottom2;
84172
+ } else {
84173
+ dist2 = 0;
84174
+ }
84175
+ if (dist2 < nearestDist) {
84176
+ nearestDist = dist2;
84177
+ nearest = frag;
84178
+ }
84179
+ }
84180
+ if (nearest) {
84181
+ const blockIndex = findBlockIndexByFragmentId(blocks, nearest.blockId);
84182
+ if (blockIndex !== -1) {
84183
+ const block = blocks[blockIndex];
84184
+ const measure = measures[blockIndex];
84185
+ if (block && measure) {
84186
+ fragmentHit = {
84187
+ fragment: nearest,
84188
+ block,
84189
+ measure,
84190
+ pageIndex: pageHit.pageIndex,
84191
+ pageY: 0
84192
+ };
84193
+ }
84194
+ }
84195
+ }
84196
+ }
84197
+ }
83832
84198
  if (fragmentHit) {
83833
84199
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
83834
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
83835
- logClickStage("warn", "fragment-type-mismatch", {
83836
- fragmentKind: fragment.kind,
83837
- measureKind: measure.kind,
83838
- blockKind: block.kind
84200
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
84201
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
84202
+ if (lineIndex == null) {
84203
+ logClickStage("warn", "no-line", {
84204
+ blockId: fragment.blockId
84205
+ });
84206
+ return null;
84207
+ }
84208
+ const line = measure.lines[lineIndex];
84209
+ const isRTL = isRtlBlock(block);
84210
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
84211
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
84212
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
84213
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
84214
+ const totalIndent = paraIndentLeft + paraIndentRight;
84215
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
84216
+ if (totalIndent > fragment.width) {
84217
+ console.warn(
84218
+ `[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.`
84219
+ );
84220
+ }
84221
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
84222
+ const isListItem3 = markerWidth > 0;
84223
+ const alignmentOverride = isListItem3 ? "left" : void 0;
84224
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
84225
+ if (pos == null) {
84226
+ logClickStage("warn", "no-position", {
84227
+ blockId: fragment.blockId
84228
+ });
84229
+ return null;
84230
+ }
84231
+ const column = determineColumn(layout, fragment.x);
84232
+ logPositionDebug({
84233
+ blockId: fragment.blockId,
84234
+ x: pageRelativePoint.x - fragment.x
83839
84235
  });
83840
- return null;
83841
- }
83842
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
83843
- if (lineIndex == null) {
83844
- logClickStage("warn", "no-line", {
84236
+ logClickStage("log", "success", {
83845
84237
  blockId: fragment.blockId
83846
84238
  });
83847
- return null;
83848
- }
83849
- const line = measure.lines[lineIndex];
83850
- const isRTL = isRtlBlock(block);
83851
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
83852
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
83853
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
83854
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
83855
- const totalIndent = paraIndentLeft + paraIndentRight;
83856
- const availableWidth = Math.max(0, fragment.width - totalIndent);
83857
- if (totalIndent > fragment.width) {
83858
- console.warn(
83859
- `[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.`
83860
- );
84239
+ return {
84240
+ pos,
84241
+ blockId: fragment.blockId,
84242
+ pageIndex,
84243
+ column,
84244
+ lineIndex
84245
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
84246
+ };
83861
84247
  }
83862
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
83863
- const isListItem3 = markerWidth > 0;
83864
- const alignmentOverride = isListItem3 ? "left" : void 0;
83865
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
83866
- if (pos == null) {
83867
- logClickStage("warn", "no-position", {
83868
- blockId: fragment.blockId
84248
+ if (isAtomicFragment(fragment)) {
84249
+ const pmRange = getAtomicPmRange(fragment, block);
84250
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
84251
+ if (pos == null) {
84252
+ logClickStage("warn", "atomic-without-range", {
84253
+ fragmentId: fragment.blockId
84254
+ });
84255
+ return null;
84256
+ }
84257
+ logClickStage("log", "success", {
84258
+ blockId: fragment.blockId,
84259
+ column: determineColumn(layout, fragment.x)
83869
84260
  });
83870
- return null;
84261
+ return {
84262
+ pos,
84263
+ blockId: fragment.blockId,
84264
+ pageIndex,
84265
+ column: determineColumn(layout, fragment.x),
84266
+ lineIndex: -1
84267
+ };
83871
84268
  }
83872
- const column = determineColumn(layout, fragment.x);
83873
- logPositionDebug({
83874
- blockId: fragment.blockId,
83875
- x: pageRelativePoint.x - fragment.x
83876
- });
83877
- logClickStage("log", "success", {
83878
- blockId: fragment.blockId
83879
- });
83880
- return {
83881
- pos,
83882
- blockId: fragment.blockId,
83883
- pageIndex,
83884
- column,
83885
- lineIndex
83886
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
83887
- };
83888
84269
  }
83889
84270
  const tableHit = hitTestTableFragment(pageHit, blocks, measures, pageRelativePoint);
83890
84271
  if (tableHit) {
@@ -84034,12 +84415,22 @@ const sumLineHeights = (measure, fromLine, toLine) => {
84034
84415
  }
84035
84416
  return height;
84036
84417
  };
84037
- function selectionToRects(layout, blocks, measures, from2, to) {
84418
+ const calculatePageTopFallback = (layout, pageIndex) => {
84419
+ const pageGap = layout.pageGap ?? 0;
84420
+ let y2 = 0;
84421
+ for (let i = 0; i < pageIndex; i++) {
84422
+ const pageHeight = layout.pages[i]?.size?.h ?? layout.pageSize.h;
84423
+ y2 += pageHeight + pageGap;
84424
+ }
84425
+ return y2;
84426
+ };
84427
+ function selectionToRects(layout, blocks, measures, from2, to, geometryHelper) {
84038
84428
  if (from2 === to) {
84039
84429
  return [];
84040
84430
  }
84041
84431
  const rects = [];
84042
84432
  layout.pages.forEach((page, pageIndex) => {
84433
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
84043
84434
  page.fragments.forEach((fragment) => {
84044
84435
  if (fragment.kind === "para") {
84045
84436
  const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
@@ -84081,12 +84472,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84081
84472
  wordLayout
84082
84473
  });
84083
84474
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
84084
- const rectWidth = Math.max(1, Math.abs(endX - startX));
84475
+ const rectWidth = Math.max(
84476
+ 1,
84477
+ Math.min(Math.abs(endX - startX), line.width)
84478
+ // clamp to line width to prevent runaway widths
84479
+ );
84085
84480
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
84086
84481
  const rectY = fragment.y + lineOffset;
84087
84482
  rects.push({
84088
84483
  x: rectX,
84089
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84484
+ y: rectY + pageTopY,
84090
84485
  width: rectWidth,
84091
84486
  height: line.lineHeight,
84092
84487
  pageIndex
@@ -84214,12 +84609,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84214
84609
  wordLayout: cellWordLayout
84215
84610
  });
84216
84611
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
84217
- const rectWidth = Math.max(1, Math.abs(endX - startX));
84612
+ const rectWidth = Math.max(
84613
+ 1,
84614
+ Math.min(Math.abs(endX - startX), line.width)
84615
+ // clamp to line width to prevent runaway widths
84616
+ );
84218
84617
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
84219
84618
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
84220
84619
  rects.push({
84221
84620
  x: rectX,
84222
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84621
+ y: rectY + pageTopY,
84223
84622
  width: rectWidth,
84224
84623
  height: line.lineHeight,
84225
84624
  pageIndex
@@ -84248,7 +84647,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84248
84647
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
84249
84648
  rects.push({
84250
84649
  x: fragment.x,
84251
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84650
+ y: fragment.y + pageTopY,
84252
84651
  width: fragment.width,
84253
84652
  height: fragment.height,
84254
84653
  pageIndex
@@ -87489,6 +87888,7 @@ const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
87489
87888
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
87490
87889
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
87491
87890
  const DEFAULT_PAGE_GAP = 24;
87891
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
87492
87892
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
87493
87893
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
87494
87894
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -87512,6 +87912,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87512
87912
  __privateAdd$1(this, _layoutOptions);
87513
87913
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
87514
87914
  __privateAdd$1(this, _domPainter, null);
87915
+ __privateAdd$1(this, _pageGeometryHelper, null);
87515
87916
  __privateAdd$1(this, _dragHandlerCleanup, null);
87516
87917
  __privateAdd$1(this, _layoutError, null);
87517
87918
  __privateAdd$1(this, _layoutErrorState, "healthy");
@@ -87664,7 +88065,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87664
88065
  { x: x2, y: y2 },
87665
88066
  __privateGet$1(this, _viewportHost),
87666
88067
  event.clientX,
87667
- event.clientY
88068
+ event.clientY,
88069
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
87668
88070
  );
87669
88071
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
87670
88072
  const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
@@ -87863,7 +88265,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87863
88265
  { x: normalized.x, y: normalized.y },
87864
88266
  __privateGet$1(this, _viewportHost),
87865
88267
  event.clientX,
87866
- event.clientY
88268
+ event.clientY,
88269
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
87867
88270
  );
87868
88271
  if (!hit) return;
87869
88272
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -88710,7 +89113,14 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
88710
89113
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
88711
89114
  }
88712
89115
  if (!__privateGet$1(this, _layoutState).layout) return [];
88713
- const rects = selectionToRects(__privateGet$1(this, _layoutState).layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, start2, end2) ?? [];
89116
+ const rects = selectionToRects(
89117
+ __privateGet$1(this, _layoutState).layout,
89118
+ __privateGet$1(this, _layoutState).blocks,
89119
+ __privateGet$1(this, _layoutState).measures,
89120
+ start2,
89121
+ end2,
89122
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89123
+ ) ?? [];
88714
89124
  return rects;
88715
89125
  };
88716
89126
  const rawRects = layoutRectSource();
@@ -88975,6 +89385,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
88975
89385
  };
88976
89386
  }
88977
89387
  __privateSet(this, _domPainter, null);
89388
+ __privateSet(this, _pageGeometryHelper, null);
88978
89389
  __privateSet(this, _pendingDocChange, true);
88979
89390
  __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
88980
89391
  }
@@ -89007,7 +89418,16 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89007
89418
  x: localX,
89008
89419
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
89009
89420
  };
89010
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
89421
+ const hit2 = clickToPosition(
89422
+ context.layout,
89423
+ context.blocks,
89424
+ context.measures,
89425
+ headerPoint,
89426
+ void 0,
89427
+ void 0,
89428
+ void 0,
89429
+ void 0
89430
+ ) ?? null;
89011
89431
  return hit2;
89012
89432
  }
89013
89433
  if (!__privateGet$1(this, _layoutState).layout) {
@@ -89020,7 +89440,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89020
89440
  normalized,
89021
89441
  __privateGet$1(this, _viewportHost),
89022
89442
  clientX,
89023
- clientY
89443
+ clientY,
89444
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89024
89445
  ) ?? null;
89025
89446
  return hit;
89026
89447
  }
@@ -89243,6 +89664,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89243
89664
  __privateSet(this, _session, { mode: "body" });
89244
89665
  __privateSet(this, _activeHeaderFooterEditor, null);
89245
89666
  __privateSet(this, _domPainter, null);
89667
+ __privateSet(this, _pageGeometryHelper, null);
89246
89668
  (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
89247
89669
  __privateSet(this, _dragHandlerCleanup, null);
89248
89670
  __privateGet$1(this, _selectionOverlay2)?.remove();
@@ -89296,7 +89718,14 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89296
89718
  if (!normalized) return false;
89297
89719
  const pmPos = __privateGet$1(this, _layoutState).bookmarks.get(normalized);
89298
89720
  if (pmPos == null) return false;
89299
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
89721
+ const rects = selectionToRects(
89722
+ layout,
89723
+ __privateGet$1(this, _layoutState).blocks,
89724
+ __privateGet$1(this, _layoutState).measures,
89725
+ pmPos,
89726
+ pmPos + 1,
89727
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89728
+ ) ?? [];
89300
89729
  const rect = rects[0];
89301
89730
  let pageIndex = rect?.pageIndex ?? null;
89302
89731
  if (pageIndex == null) {
@@ -89360,6 +89789,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
89360
89789
  _layoutOptions = /* @__PURE__ */ new WeakMap();
89361
89790
  _layoutState = /* @__PURE__ */ new WeakMap();
89362
89791
  _domPainter = /* @__PURE__ */ new WeakMap();
89792
+ _pageGeometryHelper = /* @__PURE__ */ new WeakMap();
89363
89793
  _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
89364
89794
  _layoutError = /* @__PURE__ */ new WeakMap();
89365
89795
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
@@ -89818,7 +90248,7 @@ renderRemoteSelection_fn = function(cursor) {
89818
90248
  if (!layout || !blocks || !measures) return;
89819
90249
  const start2 = Math.min(cursor.anchor, cursor.head);
89820
90250
  const end2 = Math.max(cursor.anchor, cursor.head);
89821
- const rects = selectionToRects(layout, blocks, measures, start2, end2) ?? [];
90251
+ const rects = selectionToRects(layout, blocks, measures, start2, end2, __privateGet$1(this, _pageGeometryHelper) ?? void 0) ?? [];
89822
90252
  const color = __privateMethod$1(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
89823
90253
  const opacity = __privateGet$1(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
89824
90254
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -90178,15 +90608,25 @@ hitTestTable_fn = function(normalizedX, normalizedY) {
90178
90608
  const configuredPageSize = __privateGet$1(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
90179
90609
  let pageY = 0;
90180
90610
  let pageHit = null;
90181
- for (let i = 0; i < layout.pages.length; i++) {
90182
- const page = layout.pages[i];
90183
- const pageHeight = page.size?.h ?? configuredPageSize.h;
90184
- const gap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
90185
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
90186
- pageHit = { pageIndex: i, page };
90187
- break;
90611
+ const geometryHelper = __privateGet$1(this, _pageGeometryHelper);
90612
+ if (geometryHelper) {
90613
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
90614
+ if (idx != null && layout.pages[idx]) {
90615
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
90616
+ pageY = geometryHelper.getPageTop(idx);
90617
+ }
90618
+ }
90619
+ if (!pageHit) {
90620
+ const gap = layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90621
+ for (let i = 0; i < layout.pages.length; i++) {
90622
+ const page = layout.pages[i];
90623
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
90624
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
90625
+ pageHit = { pageIndex: i, page };
90626
+ break;
90627
+ }
90628
+ pageY += pageHeight + gap;
90188
90629
  }
90189
- pageY += pageHeight + gap;
90190
90630
  }
90191
90631
  if (!pageHit) {
90192
90632
  return null;
@@ -90438,12 +90878,7 @@ rerender_fn = async function() {
90438
90878
  return;
90439
90879
  }
90440
90880
  ({ layout, measures } = result);
90441
- if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
90442
- const gap = __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
90443
- layout.pageGap = Math.max(0, gap);
90444
- } else {
90445
- layout.pageGap = DEFAULT_PAGE_GAP;
90446
- }
90881
+ layout.pageGap = __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90447
90882
  headerLayouts = result.headers;
90448
90883
  footerLayouts = result.footers;
90449
90884
  } catch (error) {
@@ -90460,6 +90895,17 @@ rerender_fn = async function() {
90460
90895
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
90461
90896
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
90462
90897
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
90898
+ if (__privateGet$1(this, _layoutState).layout) {
90899
+ const pageGap = __privateGet$1(this, _layoutState).layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90900
+ if (!__privateGet$1(this, _pageGeometryHelper)) {
90901
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
90902
+ layout: __privateGet$1(this, _layoutState).layout,
90903
+ pageGap
90904
+ }));
90905
+ } else {
90906
+ __privateGet$1(this, _pageGeometryHelper).updateLayout(__privateGet$1(this, _layoutState).layout, pageGap);
90907
+ }
90908
+ }
90463
90909
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
90464
90910
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
90465
90911
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -90529,7 +90975,8 @@ ensurePainter_fn = function(blocks, measures) {
90529
90975
  pageStyles: __privateGet$1(this, _layoutOptions).pageStyles,
90530
90976
  headerProvider: __privateGet$1(this, _headerDecorationProvider),
90531
90977
  footerProvider: __privateGet$1(this, _footerDecorationProvider),
90532
- ruler: __privateGet$1(this, _layoutOptions).ruler
90978
+ ruler: __privateGet$1(this, _layoutOptions).ruler,
90979
+ pageGap: __privateGet$1(this, _layoutState).layout?.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
90533
90980
  }));
90534
90981
  }
90535
90982
  return __privateGet$1(this, _domPainter);
@@ -90617,7 +91064,14 @@ updateSelection_fn = function() {
90617
91064
  }
90618
91065
  return;
90619
91066
  }
90620
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
91067
+ const rects = selectionToRects(
91068
+ layout,
91069
+ __privateGet$1(this, _layoutState).blocks,
91070
+ __privateGet$1(this, _layoutState).measures,
91071
+ from2,
91072
+ to,
91073
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
91074
+ ) ?? [];
90621
91075
  let domStart = null;
90622
91076
  let domEnd = null;
90623
91077
  try {
@@ -90631,7 +91085,9 @@ updateSelection_fn = function() {
90631
91085
  const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
90632
91086
  try {
90633
91087
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
90634
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
91088
+ if (correctedRects.length > 0) {
91089
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
91090
+ }
90635
91091
  } catch (error) {
90636
91092
  if (process$1$1.env.NODE_ENV === "development") {
90637
91093
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -91419,6 +91875,15 @@ waitForPageMount_fn = async function(pageIndex, options = {}) {
91419
91875
  checkPage();
91420
91876
  });
91421
91877
  };
91878
+ getEffectivePageGap_fn = function() {
91879
+ if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
91880
+ return Math.max(0, __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
91881
+ }
91882
+ if (__privateGet$1(this, _layoutOptions).layoutMode === "horizontal") {
91883
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
91884
+ }
91885
+ return DEFAULT_PAGE_GAP;
91886
+ };
91422
91887
  getBodyPageHeight_fn = function() {
91423
91888
  return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
91424
91889
  };
@@ -91442,7 +91907,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91442
91907
  dy: domStart.y - layoutY
91443
91908
  };
91444
91909
  }
91445
- return rects.map((rect, idx) => {
91910
+ const corrected = rects.map((rect, idx) => {
91446
91911
  const delta = pageDelta[rect.pageIndex];
91447
91912
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
91448
91913
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -91457,6 +91922,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91457
91922
  }
91458
91923
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
91459
91924
  const endX = domEnd.x;
91925
+ adjustedX = Math.min(adjustedX, endX);
91460
91926
  adjustedWidth = Math.max(1, endX - adjustedX);
91461
91927
  }
91462
91928
  return {
@@ -91466,6 +91932,29 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91466
91932
  width: adjustedWidth
91467
91933
  };
91468
91934
  });
91935
+ const MAX_DELTA_PX = 12;
91936
+ let invalid = false;
91937
+ if (domStart && corrected[0]) {
91938
+ const dx = Math.abs(corrected[0].x - domStart.x);
91939
+ const dy = Math.abs(corrected[0].y - domStart.y);
91940
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
91941
+ }
91942
+ if (domEnd && corrected[corrected.length - 1]) {
91943
+ const last = corrected[corrected.length - 1];
91944
+ const dx = Math.abs(last.x + last.width - domEnd.x);
91945
+ const dy = Math.abs(last.y - domEnd.y);
91946
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
91947
+ }
91948
+ if (invalid) {
91949
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
91950
+ domStart,
91951
+ domEnd,
91952
+ rectStart: corrected[0],
91953
+ rectEnd: corrected[corrected.length - 1]
91954
+ });
91955
+ return [];
91956
+ }
91957
+ return corrected;
91469
91958
  };
91470
91959
  renderCellSelectionOverlay_fn = function(selection, layout) {
91471
91960
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
@@ -91749,7 +92238,7 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
91749
92238
  return [];
91750
92239
  }
91751
92240
  if (!bodyLayout) return [];
91752
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
92241
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
91753
92242
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
91754
92243
  const bodyPageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
91755
92244
  return rects.map((rect) => {
@@ -92216,7 +92705,14 @@ getCurrentPageIndex_fn = function() {
92216
92705
  if (!layout || !selection) {
92217
92706
  return 0;
92218
92707
  }
92219
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
92708
+ const rects = selectionToRects(
92709
+ layout,
92710
+ __privateGet$1(this, _layoutState).blocks,
92711
+ __privateGet$1(this, _layoutState).measures,
92712
+ selection.from,
92713
+ selection.to,
92714
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
92715
+ ) ?? [];
92220
92716
  if (rects.length > 0) {
92221
92717
  return rects[0]?.pageIndex ?? 0;
92222
92718
  }
@@ -97648,14 +98144,19 @@ const createCell = (cellType, cellContent = null) => {
97648
98144
  }
97649
98145
  return cellType.createAndFill();
97650
98146
  };
97651
- const createTableBorders = ({ size: size2 = 0.66665, color = "#000000" } = {}) => {
98147
+ const createTableBorders = (borderSpec = {}) => {
98148
+ borderSpec = {
98149
+ size: 0.66665,
98150
+ color: "#000000",
98151
+ ...borderSpec
98152
+ };
97652
98153
  return {
97653
- top: { size: size2, color },
97654
- left: { size: size2, color },
97655
- bottom: { size: size2, color },
97656
- right: { size: size2, color },
97657
- insideH: { size: size2, color },
97658
- insideV: { size: size2, color }
98154
+ top: borderSpec,
98155
+ left: borderSpec,
98156
+ bottom: borderSpec,
98157
+ right: borderSpec,
98158
+ insideH: borderSpec,
98159
+ insideV: borderSpec
97659
98160
  };
97660
98161
  };
97661
98162
  const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent = null) => {
@@ -97783,12 +98284,17 @@ const deleteTableWhenSelected = ({ editor }) => {
97783
98284
  editor.commands.deleteTable();
97784
98285
  return true;
97785
98286
  };
97786
- const createCellBorders = ({ size: size2 = 0.66665, color = "#000000" } = {}) => {
98287
+ const createCellBorders = (borderSpec = {}) => {
98288
+ borderSpec = {
98289
+ size: 0.66665,
98290
+ color: "#000000",
98291
+ ...borderSpec
98292
+ };
97787
98293
  return {
97788
- top: { size: size2, color },
97789
- left: { size: size2, color },
97790
- bottom: { size: size2, color },
97791
- right: { size: size2, color }
98294
+ top: borderSpec,
98295
+ left: borderSpec,
98296
+ bottom: borderSpec,
98297
+ right: borderSpec
97792
98298
  };
97793
98299
  };
97794
98300
  function cellAround($pos) {
@@ -98555,13 +99061,20 @@ const Table = Node$1.create({
98555
99061
  if (["tableCell", "tableHeader"].includes(node.type.name)) {
98556
99062
  tr.setNodeMarkup(pos, void 0, {
98557
99063
  ...node.attrs,
98558
- borders: createCellBorders({ size: 0 })
99064
+ borders: createCellBorders({ size: 0, space: 0, val: "none", color: "auto" })
98559
99065
  });
98560
99066
  }
98561
99067
  });
98562
99068
  tr.setNodeMarkup(table.pos, void 0, {
98563
99069
  ...table.node.attrs,
98564
- borders: createTableBorders({ size: 0 })
99070
+ borders: createTableBorders({ size: 0 }),
99071
+ // TODO: This works around the issue that table borders are duplicated between
99072
+ // the attributes of the table and the tableProperties attribute.
99073
+ // This can be removed when the redundancy is eliminated.
99074
+ tableProperties: {
99075
+ ...table.node.attrs.tableProperties,
99076
+ borders: createTableBorders({ size: 0, space: 0, val: "none", color: "auto" })
99077
+ }
98565
99078
  });
98566
99079
  return true;
98567
99080
  }
@@ -122563,7 +123076,7 @@ const makeDefaultItems = ({
122563
123076
  }
122564
123077
  },
122565
123078
  {
122566
- label: toolbarTexts2.transparentBorders,
123079
+ label: toolbarTexts2.removeBorders,
122567
123080
  command: "deleteCellAndTableBorders",
122568
123081
  icon: toolbarIcons2.deleteBorders,
122569
123082
  bottomBorder: true,
@@ -123144,7 +123657,7 @@ const toolbarTexts = {
123144
123657
  deleteRow: "Delete row",
123145
123658
  deleteColumn: "Delete column",
123146
123659
  deleteTable: "Delete table",
123147
- transparentBorders: "Transparent borders",
123660
+ removeBorders: "Remove borders",
123148
123661
  mergeCells: "Merge cells",
123149
123662
  splitCell: "Split cell",
123150
123663
  fixTables: "Fix tables",
@@ -124182,7 +124695,7 @@ const TEXTS = {
124182
124695
  deleteRow: "Delete row",
124183
124696
  deleteColumn: "Delete column",
124184
124697
  deleteTable: "Delete table",
124185
- transparentBorders: "Transparent borders",
124698
+ removeBorders: "Remove borders",
124186
124699
  mergeCells: "Merge cells",
124187
124700
  splitCell: "Split cell",
124188
124701
  fixTables: "Fix tables",
@@ -124265,7 +124778,7 @@ const tableActionsOptions = [
124265
124778
  }
124266
124779
  },
124267
124780
  {
124268
- label: TEXTS.transparentBorders,
124781
+ label: TEXTS.removeBorders,
124269
124782
  command: "deleteCellAndTableBorders",
124270
124783
  icon: ICONS.deleteBorders,
124271
124784
  bottomBorder: true,