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
@@ -39792,7 +39792,7 @@ function importCommentData({ docx, editor, converter }) {
39792
39792
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
39793
39793
  const date = new Date(createdDate);
39794
39794
  const unixTimestampMs = date.getTime();
39795
- const parsedComment = nodeListHandler.handler({
39795
+ const parsedElements = nodeListHandler.handler({
39796
39796
  nodes: el.elements,
39797
39797
  nodeListHandler,
39798
39798
  docx,
@@ -39800,7 +39800,7 @@ function importCommentData({ docx, editor, converter }) {
39800
39800
  converter,
39801
39801
  path: [el]
39802
39802
  });
39803
- const { attrs } = parsedComment[0];
39803
+ const { attrs } = parsedElements[0];
39804
39804
  const paraId = attrs["w14:paraId"];
39805
39805
  return {
39806
39806
  commentId: internalId || v4(),
@@ -39808,7 +39808,8 @@ function importCommentData({ docx, editor, converter }) {
39808
39808
  creatorName: authorName,
39809
39809
  creatorEmail: authorEmail,
39810
39810
  createdTime: unixTimestampMs,
39811
- textJson: parsedComment[0],
39811
+ textJson: parsedElements[0],
39812
+ elements: parsedElements,
39812
39813
  initials,
39813
39814
  paraId,
39814
39815
  trackedChange,
@@ -39834,7 +39835,12 @@ const generateCommentsWithExtendedData = ({ docx, comments }) => {
39834
39835
  const { elements = [] } = initialElements[0] ?? {};
39835
39836
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
39836
39837
  return comments.map((comment) => {
39837
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment.paraId);
39838
+ const extendedDef = commentEx.find((ce2) => {
39839
+ const isIncludedInCommentElements = comment.elements?.some(
39840
+ (el) => el.attrs?.["w14:paraId"] === ce2.attributes["w15:paraId"]
39841
+ );
39842
+ return isIncludedInCommentElements;
39843
+ });
39838
39844
  if (!extendedDef) return { ...comment, isDone: comment.isDone ?? false };
39839
39845
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
39840
39846
  let parentComment;
@@ -41955,7 +41961,7 @@ const updateCommentsIdsAndExtensible = (comments = [], commentsIds, extensible)
41955
41961
  name: "w16cex:commentExtensible",
41956
41962
  attributes: {
41957
41963
  "w16cex:durableId": newDurableId,
41958
- "w16cex:dateUtc": toIsoNoFractional()
41964
+ "w16cex:dateUtc": toIsoNoFractional(comment.createdTime)
41959
41965
  }
41960
41966
  };
41961
41967
  extensibleUpdated.elements[0].elements.push(newExtensible);
@@ -42421,7 +42427,7 @@ const _SuperConverter = class _SuperConverter2 {
42421
42427
  static getStoredSuperdocVersion(docx) {
42422
42428
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42423
42429
  }
42424
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.100") {
42430
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.102") {
42425
42431
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42426
42432
  }
42427
42433
  /**
@@ -45733,7 +45739,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45733
45739
  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);
45734
45740
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45735
45741
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45736
- 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;
45742
+ 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;
45737
45743
  var GOOD_LEAF_SIZE = 200;
45738
45744
  var RopeSequence = function RopeSequence2() {
45739
45745
  };
@@ -54817,6 +54823,14 @@ const toggleNode = (typeOrName, toggleTypeOrName, attrs = {}) => ({ state: state
54817
54823
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
54818
54824
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
54819
54825
  const { from: from2, to, empty: empty2 } = state2.selection;
54826
+ if (typeof document !== "undefined" && document.getSelection) {
54827
+ const currentDomSelection = document.getSelection();
54828
+ const selectedLength = currentDomSelection?.toString?.().length;
54829
+ const isCollapsed = currentDomSelection?.isCollapsed;
54830
+ if (!isCollapsed && selectedLength === 1) {
54831
+ return false;
54832
+ }
54833
+ }
54820
54834
  if (empty2) {
54821
54835
  return deleteSelection$1(state2, dispatch);
54822
54836
  }
@@ -57116,12 +57130,14 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
57116
57130
  importedId: node.attrs["w:id"]
57117
57131
  });
57118
57132
  if (type2.name === "commentRangeStart") {
57119
- toMark.push({
57120
- commentId: resolvedCommentId,
57121
- importedId,
57122
- internal,
57123
- start: pos
57124
- });
57133
+ if (!matchingImportedComment?.isDone) {
57134
+ toMark.push({
57135
+ commentId: resolvedCommentId,
57136
+ importedId,
57137
+ internal,
57138
+ start: pos
57139
+ });
57140
+ }
57125
57141
  ensureFallbackComment({
57126
57142
  converter,
57127
57143
  matchingImportedComment,
@@ -59639,7 +59655,7 @@ const isHeadless = (editor) => {
59639
59655
  const shouldSkipNodeView = (editor) => {
59640
59656
  return isHeadless(editor);
59641
59657
  };
59642
- const summaryVersion = "1.0.0-beta.100";
59658
+ const summaryVersion = "1.0.0-beta.102";
59643
59659
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59644
59660
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59645
59661
  function mapAttributes(attrs) {
@@ -60428,7 +60444,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60428
60444
  { default: remarkStringify },
60429
60445
  { default: remarkGfm }
60430
60446
  ] = await Promise.all([
60431
- Promise.resolve().then(() => require("./index-Bd5TMBeR-D31VShf3.cjs")),
60447
+ Promise.resolve().then(() => require("./index-nVrA3URL-BssoM7VE.cjs")),
60432
60448
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60433
60449
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60434
60450
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60633,7 +60649,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60633
60649
  * Process collaboration migrations
60634
60650
  */
60635
60651
  processCollaborationMigrations() {
60636
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.100");
60652
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.102");
60637
60653
  if (!this.options.ydoc) return;
60638
60654
  const metaMap = this.options.ydoc.getMap("meta");
60639
60655
  let docVersion = metaMap.get("version");
@@ -72716,7 +72732,7 @@ const containerStyles = {
72716
72732
  alignItems: "center",
72717
72733
  background: "transparent",
72718
72734
  padding: "0",
72719
- gap: "24px",
72735
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
72720
72736
  overflowY: "auto"
72721
72737
  };
72722
72738
  const containerStylesHorizontal = {
@@ -72726,7 +72742,7 @@ const containerStylesHorizontal = {
72726
72742
  justifyContent: "safe center",
72727
72743
  background: "transparent",
72728
72744
  padding: "0",
72729
- gap: "20px",
72745
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
72730
72746
  overflowX: "auto",
72731
72747
  minHeight: "100%"
72732
72748
  };
@@ -74529,6 +74545,7 @@ function isMinimalWordLayout(value) {
74529
74545
  const LIST_MARKER_GAP$1 = 8;
74530
74546
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
74531
74547
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
74548
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
74532
74549
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
74533
74550
  const COMMENT_INTERNAL_COLOR = "#078383";
74534
74551
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -74658,10 +74675,11 @@ const _DomPainter = class _DomPainter2 {
74658
74675
  this.totalPages = 0;
74659
74676
  this.linkIdCounter = 0;
74660
74677
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
74678
+ this.pageGap = 24;
74661
74679
  this.virtualEnabled = false;
74662
74680
  this.virtualWindow = 5;
74663
74681
  this.virtualOverscan = 0;
74664
- this.virtualGap = 72;
74682
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
74665
74683
  this.virtualPaddingTop = null;
74666
74684
  this.topSpacerEl = null;
74667
74685
  this.bottomSpacerEl = null;
@@ -74680,13 +74698,14 @@ const _DomPainter = class _DomPainter2 {
74680
74698
  this.blockLookup = this.buildBlockLookup(blocks, measures);
74681
74699
  this.headerProvider = options.headerProvider;
74682
74700
  this.footerProvider = options.footerProvider;
74701
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
74702
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
74683
74703
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
74684
74704
  this.virtualEnabled = true;
74685
74705
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
74686
74706
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
74687
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
74688
- this.virtualGap = Math.max(0, options.virtualization.gap);
74689
- }
74707
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
74708
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
74690
74709
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
74691
74710
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
74692
74711
  }
@@ -74787,6 +74806,7 @@ const _DomPainter = class _DomPainter2 {
74787
74806
  const mode = this.layoutMode;
74788
74807
  if (mode === "horizontal") {
74789
74808
  applyStyles$2(mount2, containerStylesHorizontal);
74809
+ mount2.style.gap = `${this.pageGap}px`;
74790
74810
  this.renderHorizontal(layout, mount2);
74791
74811
  this.currentLayout = layout;
74792
74812
  this.pageStates = [];
@@ -74809,6 +74829,7 @@ const _DomPainter = class _DomPainter2 {
74809
74829
  this.changedBlocks.clear();
74810
74830
  return;
74811
74831
  }
74832
+ mount2.style.gap = `${this.pageGap}px`;
74812
74833
  if (!this.currentLayout || this.pageStates.length === 0) {
74813
74834
  this.fullRender(layout);
74814
74835
  } else {
@@ -78028,6 +78049,7 @@ const createDomPainter = (options) => {
78028
78049
  const painter = new DomPainter(options.blocks, options.measures, {
78029
78050
  pageStyles: options.pageStyles,
78030
78051
  layoutMode: options.layoutMode,
78052
+ pageGap: options.pageGap,
78031
78053
  headerProvider: options.headerProvider,
78032
78054
  footerProvider: options.footerProvider,
78033
78055
  virtualization: options.virtualization,
@@ -83325,6 +83347,285 @@ async function remeasureAffectedBlocks(blocks, measures, affectedBlockIds, const
83325
83347
  }
83326
83348
  return updatedMeasures;
83327
83349
  }
83350
+ class PageGeometryHelper {
83351
+ /**
83352
+ * Creates a new PageGeometryHelper instance.
83353
+ *
83354
+ * @param config - Page geometry configuration
83355
+ */
83356
+ constructor(config2) {
83357
+ this.cache = null;
83358
+ this.config = config2;
83359
+ }
83360
+ /**
83361
+ * Updates the layout and invalidates the cache.
83362
+ *
83363
+ * Call this whenever the layout changes (new pages, different heights, etc.)
83364
+ *
83365
+ * @param layout - New layout data
83366
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
83367
+ */
83368
+ updateLayout(layout, pageGap) {
83369
+ this.config.layout = layout;
83370
+ if (pageGap !== void 0) {
83371
+ this.config.pageGap = pageGap;
83372
+ }
83373
+ this.cache = null;
83374
+ }
83375
+ /**
83376
+ * Updates the page gap and invalidates the cache.
83377
+ *
83378
+ * @param pageGap - New gap between pages in pixels
83379
+ */
83380
+ updatePageGap(pageGap) {
83381
+ if (this.config.pageGap !== pageGap) {
83382
+ this.config.pageGap = pageGap;
83383
+ this.cache = null;
83384
+ }
83385
+ }
83386
+ /**
83387
+ * Gets the cumulative Y position (top edge) of a page in container space.
83388
+ *
83389
+ * The returned value is the distance from the top of the container to the
83390
+ * top of the specified page, accounting for all previous pages and gaps.
83391
+ *
83392
+ * @param pageIndex - Zero-based page index
83393
+ * @returns Y position in pixels, or 0 if page index is invalid
83394
+ *
83395
+ * @example
83396
+ * ```typescript
83397
+ * // Get Y position of page 0 (first page)
83398
+ * const y0 = helper.getPageTop(0); // Returns 0
83399
+ *
83400
+ * // Get Y position of page 2 (third page)
83401
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
83402
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
83403
+ * ```
83404
+ */
83405
+ getPageTop(pageIndex) {
83406
+ this.ensureCache();
83407
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
83408
+ return 0;
83409
+ }
83410
+ return this.cache.cumulativeY[pageIndex];
83411
+ }
83412
+ /**
83413
+ * Gets the height of a specific page.
83414
+ *
83415
+ * Uses per-page height if available (from layout.pages[i].size?.h),
83416
+ * otherwise falls back to layout.pageSize.h.
83417
+ *
83418
+ * @param pageIndex - Zero-based page index
83419
+ * @returns Page height in pixels, or 0 if page index is invalid
83420
+ *
83421
+ * @example
83422
+ * ```typescript
83423
+ * const height = helper.getPageHeight(0); // Returns page-specific height
83424
+ * ```
83425
+ */
83426
+ getPageHeight(pageIndex) {
83427
+ this.ensureCache();
83428
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
83429
+ return 0;
83430
+ }
83431
+ return this.cache.pageHeights[pageIndex];
83432
+ }
83433
+ /**
83434
+ * Gets the gap between pages.
83435
+ *
83436
+ * @returns Gap in pixels
83437
+ *
83438
+ * @example
83439
+ * ```typescript
83440
+ * const gap = helper.getPageGap(); // Returns 24
83441
+ * ```
83442
+ */
83443
+ getPageGap() {
83444
+ this.ensureCache();
83445
+ return this.cache.pageGap;
83446
+ }
83447
+ /**
83448
+ * Gets the total height of all pages including gaps.
83449
+ *
83450
+ * Total height = sum of all page heights + (pageCount - 1) * gap
83451
+ *
83452
+ * @returns Total height in pixels
83453
+ *
83454
+ * @example
83455
+ * ```typescript
83456
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
83457
+ * const total = helper.getTotalHeight();
83458
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
83459
+ * ```
83460
+ */
83461
+ getTotalHeight() {
83462
+ this.ensureCache();
83463
+ return this.cache.totalHeight;
83464
+ }
83465
+ /**
83466
+ * Gets the number of pages in the layout.
83467
+ *
83468
+ * @returns Page count
83469
+ */
83470
+ getPageCount() {
83471
+ return this.config.layout.pages.length;
83472
+ }
83473
+ /**
83474
+ * Finds the page index containing a given Y coordinate.
83475
+ *
83476
+ * This performs a linear search through cached cumulative positions.
83477
+ * For large documents, consider adding binary search optimization.
83478
+ *
83479
+ * @param containerY - Y coordinate in container space
83480
+ * @returns Page index, or null if Y is outside all pages
83481
+ *
83482
+ * @example
83483
+ * ```typescript
83484
+ * // Find which page contains Y = 1500
83485
+ * const pageIndex = helper.getPageIndexAtY(1500);
83486
+ * // Returns 1 (second page) if first page ends at Y=1024
83487
+ * ```
83488
+ */
83489
+ getPageIndexAtY(containerY) {
83490
+ this.ensureCache();
83491
+ const cache2 = this.cache;
83492
+ for (let i = 0; i < cache2.cumulativeY.length; i++) {
83493
+ const pageTop = cache2.cumulativeY[i];
83494
+ const pageBottom = pageTop + cache2.pageHeights[i];
83495
+ if (containerY >= pageTop && containerY < pageBottom) {
83496
+ return i;
83497
+ }
83498
+ }
83499
+ return null;
83500
+ }
83501
+ /**
83502
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
83503
+ *
83504
+ * Returns the page containing Y when inside a page; otherwise returns the
83505
+ * closest page based on distance to page center. Useful for dragging through
83506
+ * page gaps where getPageIndexAtY would return null.
83507
+ *
83508
+ * @param containerY - Y coordinate in container space
83509
+ * @returns Nearest page index, or null if there are no pages
83510
+ */
83511
+ getNearestPageIndex(containerY) {
83512
+ this.ensureCache();
83513
+ const cache2 = this.cache;
83514
+ const pageCount = cache2.pageHeights.length;
83515
+ if (pageCount === 0) return null;
83516
+ const direct = this.getPageIndexAtY(containerY);
83517
+ if (direct !== null) return direct;
83518
+ let nearestIndex = 0;
83519
+ let nearestDistance = Infinity;
83520
+ for (let i = 0; i < pageCount; i++) {
83521
+ const top2 = cache2.cumulativeY[i];
83522
+ const height = cache2.pageHeights[i];
83523
+ const center = top2 + height / 2;
83524
+ const distance = Math.abs(containerY - center);
83525
+ if (distance < nearestDistance) {
83526
+ nearestDistance = distance;
83527
+ nearestIndex = i;
83528
+ }
83529
+ }
83530
+ return nearestIndex;
83531
+ }
83532
+ /**
83533
+ * Ensures the cache is built and up-to-date.
83534
+ * Validates cache state and rebuilds if needed.
83535
+ * @private
83536
+ * @throws Never throws - handles errors gracefully with fallback values
83537
+ */
83538
+ ensureCache() {
83539
+ if (this.cache !== null) {
83540
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
83541
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
83542
+ this.cache = null;
83543
+ } else {
83544
+ return;
83545
+ }
83546
+ }
83547
+ this.buildCache();
83548
+ }
83549
+ /**
83550
+ * Builds the geometry cache from current layout data.
83551
+ * Handles errors gracefully by providing fallback values.
83552
+ * @private
83553
+ * @throws Never throws - catches all errors and provides safe defaults
83554
+ */
83555
+ buildCache() {
83556
+ try {
83557
+ const layout = this.config.layout;
83558
+ if (!layout || !Array.isArray(layout.pages)) {
83559
+ throw new Error("Invalid layout: missing or invalid pages array");
83560
+ }
83561
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
83562
+ const pageCount = layout.pages.length;
83563
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
83564
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
83565
+ }
83566
+ const cumulativeY = new Array(pageCount);
83567
+ const pageHeights = new Array(pageCount);
83568
+ let currentY = 0;
83569
+ for (let i = 0; i < pageCount; i++) {
83570
+ const page = layout.pages[i];
83571
+ if (!page) {
83572
+ throw new Error(`Invalid page at index ${i}: page is null or undefined`);
83573
+ }
83574
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
83575
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
83576
+ throw new Error(`Invalid page height at index ${i}: ${pageHeight} (must be non-negative finite number)`);
83577
+ }
83578
+ cumulativeY[i] = currentY;
83579
+ pageHeights[i] = pageHeight;
83580
+ currentY += pageHeight;
83581
+ if (i < pageCount - 1) {
83582
+ currentY += pageGap;
83583
+ }
83584
+ }
83585
+ const totalHeight = currentY;
83586
+ this.cache = {
83587
+ cumulativeY,
83588
+ pageHeights,
83589
+ pageGap,
83590
+ totalHeight,
83591
+ layoutVersion: 0
83592
+ // Placeholder for future version tracking
83593
+ };
83594
+ } catch (error) {
83595
+ const errorMessage = error instanceof Error ? error.message : String(error);
83596
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
83597
+ this.cache = {
83598
+ cumulativeY: [],
83599
+ pageHeights: [],
83600
+ pageGap: 0,
83601
+ totalHeight: 0,
83602
+ layoutVersion: 0
83603
+ };
83604
+ }
83605
+ }
83606
+ /**
83607
+ * Clears the cache, forcing recalculation on next access.
83608
+ * Useful for testing or manual cache invalidation.
83609
+ */
83610
+ clearCache() {
83611
+ this.cache = null;
83612
+ }
83613
+ /**
83614
+ * Gets debug information about the current cache state.
83615
+ * @internal
83616
+ */
83617
+ getDebugInfo() {
83618
+ this.ensureCache();
83619
+ return {
83620
+ isCached: this.cache !== null,
83621
+ pageCount: this.config.layout.pages.length,
83622
+ pageGap: this.cache.pageGap,
83623
+ totalHeight: this.cache.totalHeight,
83624
+ cumulativeY: [...this.cache.cumulativeY],
83625
+ pageHeights: [...this.cache.pageHeights]
83626
+ };
83627
+ }
83628
+ }
83328
83629
  var Priority = /* @__PURE__ */ ((Priority2) => {
83329
83630
  Priority2[Priority2["P0"] = 0] = "P0";
83330
83631
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -83618,18 +83919,41 @@ const rangesOverlap = (startA, endA, startB, endB) => {
83618
83919
  const effectiveEndA = endA ?? startA + 1;
83619
83920
  return effectiveEndA > startB && startA < endB;
83620
83921
  };
83621
- function hitTestPage(layout, point) {
83922
+ function hitTestPage(layout, point, geometryHelper) {
83923
+ if (geometryHelper) {
83924
+ const pageIndex = geometryHelper.getPageIndexAtY(point.y);
83925
+ if (pageIndex !== null) {
83926
+ return { pageIndex, page: layout.pages[pageIndex] };
83927
+ }
83928
+ const nearest = geometryHelper.getNearestPageIndex(point.y);
83929
+ if (nearest !== null) {
83930
+ return { pageIndex: nearest, page: layout.pages[nearest] };
83931
+ }
83932
+ return null;
83933
+ }
83622
83934
  const pageGap = layout.pageGap ?? 0;
83623
83935
  let cursorY = 0;
83936
+ let nearestIndex = null;
83937
+ let nearestDistance = Infinity;
83624
83938
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
83625
83939
  const page = layout.pages[pageIndex];
83940
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
83626
83941
  const top2 = cursorY;
83627
- const bottom2 = top2 + layout.pageSize.h;
83942
+ const bottom2 = top2 + pageHeight;
83628
83943
  if (point.y >= top2 && point.y < bottom2) {
83629
83944
  return { pageIndex, page };
83630
83945
  }
83946
+ const center = top2 + pageHeight / 2;
83947
+ const distance = Math.abs(point.y - center);
83948
+ if (distance < nearestDistance) {
83949
+ nearestDistance = distance;
83950
+ nearestIndex = pageIndex;
83951
+ }
83631
83952
  cursorY = bottom2 + pageGap;
83632
83953
  }
83954
+ if (nearestIndex !== null) {
83955
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
83956
+ }
83633
83957
  return null;
83634
83958
  }
83635
83959
  function hitTestFragment(layout, pageHit, blocks, measures, point) {
@@ -83790,7 +84114,7 @@ const hitTestTableFragment = (pageHit, blocks, measures, point) => {
83790
84114
  }
83791
84115
  return null;
83792
84116
  };
83793
- function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY) {
84117
+ function clickToPosition(layout, blocks, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
83794
84118
  logClickStage("log", "entry", {
83795
84119
  pages: layout.pages.length
83796
84120
  });
@@ -83833,75 +84157,132 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
83833
84157
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
83834
84158
  }
83835
84159
  }
83836
- const pageHit = hitTestPage(layout, containerPoint);
84160
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
83837
84161
  if (!pageHit) {
83838
84162
  return null;
83839
84163
  }
83840
- const pageGap = layout.pageGap ?? 0;
84164
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
83841
84165
  const pageRelativePoint = {
83842
84166
  x: containerPoint.x,
83843
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
84167
+ y: containerPoint.y - pageTopY
83844
84168
  };
83845
84169
  logClickStage("log", "page-hit", {
83846
84170
  pageIndex: pageHit.pageIndex
83847
84171
  });
83848
- const fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
84172
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks, measures, pageRelativePoint);
84173
+ if (!fragmentHit) {
84174
+ const page = pageHit.page;
84175
+ const fragments = page.fragments.filter(
84176
+ (f2) => f2 != null && typeof f2 === "object"
84177
+ );
84178
+ if (fragments.length > 0) {
84179
+ let nearest = null;
84180
+ let nearestDist = Infinity;
84181
+ for (const frag of fragments) {
84182
+ const top2 = frag.y;
84183
+ const bottom2 = frag.y + frag.height;
84184
+ let dist2;
84185
+ if (pageRelativePoint.y < top2) {
84186
+ dist2 = top2 - pageRelativePoint.y;
84187
+ } else if (pageRelativePoint.y > bottom2) {
84188
+ dist2 = pageRelativePoint.y - bottom2;
84189
+ } else {
84190
+ dist2 = 0;
84191
+ }
84192
+ if (dist2 < nearestDist) {
84193
+ nearestDist = dist2;
84194
+ nearest = frag;
84195
+ }
84196
+ }
84197
+ if (nearest) {
84198
+ const blockIndex = findBlockIndexByFragmentId(blocks, nearest.blockId);
84199
+ if (blockIndex !== -1) {
84200
+ const block = blocks[blockIndex];
84201
+ const measure = measures[blockIndex];
84202
+ if (block && measure) {
84203
+ fragmentHit = {
84204
+ fragment: nearest,
84205
+ block,
84206
+ measure,
84207
+ pageIndex: pageHit.pageIndex,
84208
+ pageY: 0
84209
+ };
84210
+ }
84211
+ }
84212
+ }
84213
+ }
84214
+ }
83849
84215
  if (fragmentHit) {
83850
84216
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
83851
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
83852
- logClickStage("warn", "fragment-type-mismatch", {
83853
- fragmentKind: fragment.kind,
83854
- measureKind: measure.kind,
83855
- blockKind: block.kind
84217
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
84218
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
84219
+ if (lineIndex == null) {
84220
+ logClickStage("warn", "no-line", {
84221
+ blockId: fragment.blockId
84222
+ });
84223
+ return null;
84224
+ }
84225
+ const line = measure.lines[lineIndex];
84226
+ const isRTL = isRtlBlock(block);
84227
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
84228
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
84229
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
84230
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
84231
+ const totalIndent = paraIndentLeft + paraIndentRight;
84232
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
84233
+ if (totalIndent > fragment.width) {
84234
+ console.warn(
84235
+ `[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.`
84236
+ );
84237
+ }
84238
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
84239
+ const isListItem3 = markerWidth > 0;
84240
+ const alignmentOverride = isListItem3 ? "left" : void 0;
84241
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
84242
+ if (pos == null) {
84243
+ logClickStage("warn", "no-position", {
84244
+ blockId: fragment.blockId
84245
+ });
84246
+ return null;
84247
+ }
84248
+ const column = determineColumn(layout, fragment.x);
84249
+ logPositionDebug({
84250
+ blockId: fragment.blockId,
84251
+ x: pageRelativePoint.x - fragment.x
83856
84252
  });
83857
- return null;
83858
- }
83859
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
83860
- if (lineIndex == null) {
83861
- logClickStage("warn", "no-line", {
84253
+ logClickStage("log", "success", {
83862
84254
  blockId: fragment.blockId
83863
84255
  });
83864
- return null;
83865
- }
83866
- const line = measure.lines[lineIndex];
83867
- const isRTL = isRtlBlock(block);
83868
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
83869
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
83870
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
83871
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
83872
- const totalIndent = paraIndentLeft + paraIndentRight;
83873
- const availableWidth = Math.max(0, fragment.width - totalIndent);
83874
- if (totalIndent > fragment.width) {
83875
- console.warn(
83876
- `[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.`
83877
- );
84256
+ return {
84257
+ pos,
84258
+ blockId: fragment.blockId,
84259
+ pageIndex,
84260
+ column,
84261
+ lineIndex
84262
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
84263
+ };
83878
84264
  }
83879
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
83880
- const isListItem3 = markerWidth > 0;
83881
- const alignmentOverride = isListItem3 ? "left" : void 0;
83882
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
83883
- if (pos == null) {
83884
- logClickStage("warn", "no-position", {
83885
- blockId: fragment.blockId
84265
+ if (isAtomicFragment(fragment)) {
84266
+ const pmRange = getAtomicPmRange(fragment, block);
84267
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
84268
+ if (pos == null) {
84269
+ logClickStage("warn", "atomic-without-range", {
84270
+ fragmentId: fragment.blockId
84271
+ });
84272
+ return null;
84273
+ }
84274
+ logClickStage("log", "success", {
84275
+ blockId: fragment.blockId,
84276
+ column: determineColumn(layout, fragment.x)
83886
84277
  });
83887
- return null;
84278
+ return {
84279
+ pos,
84280
+ blockId: fragment.blockId,
84281
+ pageIndex,
84282
+ column: determineColumn(layout, fragment.x),
84283
+ lineIndex: -1
84284
+ };
83888
84285
  }
83889
- const column = determineColumn(layout, fragment.x);
83890
- logPositionDebug({
83891
- blockId: fragment.blockId,
83892
- x: pageRelativePoint.x - fragment.x
83893
- });
83894
- logClickStage("log", "success", {
83895
- blockId: fragment.blockId
83896
- });
83897
- return {
83898
- pos,
83899
- blockId: fragment.blockId,
83900
- pageIndex,
83901
- column,
83902
- lineIndex
83903
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
83904
- };
83905
84286
  }
83906
84287
  const tableHit = hitTestTableFragment(pageHit, blocks, measures, pageRelativePoint);
83907
84288
  if (tableHit) {
@@ -84051,12 +84432,22 @@ const sumLineHeights = (measure, fromLine, toLine) => {
84051
84432
  }
84052
84433
  return height;
84053
84434
  };
84054
- function selectionToRects(layout, blocks, measures, from2, to) {
84435
+ const calculatePageTopFallback = (layout, pageIndex) => {
84436
+ const pageGap = layout.pageGap ?? 0;
84437
+ let y2 = 0;
84438
+ for (let i = 0; i < pageIndex; i++) {
84439
+ const pageHeight = layout.pages[i]?.size?.h ?? layout.pageSize.h;
84440
+ y2 += pageHeight + pageGap;
84441
+ }
84442
+ return y2;
84443
+ };
84444
+ function selectionToRects(layout, blocks, measures, from2, to, geometryHelper) {
84055
84445
  if (from2 === to) {
84056
84446
  return [];
84057
84447
  }
84058
84448
  const rects = [];
84059
84449
  layout.pages.forEach((page, pageIndex) => {
84450
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
84060
84451
  page.fragments.forEach((fragment) => {
84061
84452
  if (fragment.kind === "para") {
84062
84453
  const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
@@ -84098,12 +84489,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84098
84489
  wordLayout
84099
84490
  });
84100
84491
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
84101
- const rectWidth = Math.max(1, Math.abs(endX - startX));
84492
+ const rectWidth = Math.max(
84493
+ 1,
84494
+ Math.min(Math.abs(endX - startX), line.width)
84495
+ // clamp to line width to prevent runaway widths
84496
+ );
84102
84497
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
84103
84498
  const rectY = fragment.y + lineOffset;
84104
84499
  rects.push({
84105
84500
  x: rectX,
84106
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84501
+ y: rectY + pageTopY,
84107
84502
  width: rectWidth,
84108
84503
  height: line.lineHeight,
84109
84504
  pageIndex
@@ -84231,12 +84626,16 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84231
84626
  wordLayout: cellWordLayout
84232
84627
  });
84233
84628
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
84234
- const rectWidth = Math.max(1, Math.abs(endX - startX));
84629
+ const rectWidth = Math.max(
84630
+ 1,
84631
+ Math.min(Math.abs(endX - startX), line.width)
84632
+ // clamp to line width to prevent runaway widths
84633
+ );
84235
84634
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
84236
84635
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
84237
84636
  rects.push({
84238
84637
  x: rectX,
84239
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84638
+ y: rectY + pageTopY,
84240
84639
  width: rectWidth,
84241
84640
  height: line.lineHeight,
84242
84641
  pageIndex
@@ -84265,7 +84664,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
84265
84664
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
84266
84665
  rects.push({
84267
84666
  x: fragment.x,
84268
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
84667
+ y: fragment.y + pageTopY,
84269
84668
  width: fragment.width,
84270
84669
  height: fragment.height,
84271
84670
  pageIndex
@@ -87506,6 +87905,7 @@ const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
87506
87905
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
87507
87906
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
87508
87907
  const DEFAULT_PAGE_GAP = 24;
87908
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
87509
87909
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
87510
87910
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
87511
87911
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -87529,6 +87929,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87529
87929
  __privateAdd$1(this, _layoutOptions);
87530
87930
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
87531
87931
  __privateAdd$1(this, _domPainter, null);
87932
+ __privateAdd$1(this, _pageGeometryHelper, null);
87532
87933
  __privateAdd$1(this, _dragHandlerCleanup, null);
87533
87934
  __privateAdd$1(this, _layoutError, null);
87534
87935
  __privateAdd$1(this, _layoutErrorState, "healthy");
@@ -87681,7 +88082,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87681
88082
  { x: x2, y: y2 },
87682
88083
  __privateGet$1(this, _viewportHost),
87683
88084
  event.clientX,
87684
- event.clientY
88085
+ event.clientY,
88086
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
87685
88087
  );
87686
88088
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
87687
88089
  const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
@@ -87880,7 +88282,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
87880
88282
  { x: normalized.x, y: normalized.y },
87881
88283
  __privateGet$1(this, _viewportHost),
87882
88284
  event.clientX,
87883
- event.clientY
88285
+ event.clientY,
88286
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
87884
88287
  );
87885
88288
  if (!hit) return;
87886
88289
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -88727,7 +89130,14 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
88727
89130
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
88728
89131
  }
88729
89132
  if (!__privateGet$1(this, _layoutState).layout) return [];
88730
- const rects = selectionToRects(__privateGet$1(this, _layoutState).layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, start2, end2) ?? [];
89133
+ const rects = selectionToRects(
89134
+ __privateGet$1(this, _layoutState).layout,
89135
+ __privateGet$1(this, _layoutState).blocks,
89136
+ __privateGet$1(this, _layoutState).measures,
89137
+ start2,
89138
+ end2,
89139
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89140
+ ) ?? [];
88731
89141
  return rects;
88732
89142
  };
88733
89143
  const rawRects = layoutRectSource();
@@ -88992,6 +89402,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
88992
89402
  };
88993
89403
  }
88994
89404
  __privateSet(this, _domPainter, null);
89405
+ __privateSet(this, _pageGeometryHelper, null);
88995
89406
  __privateSet(this, _pendingDocChange, true);
88996
89407
  __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
88997
89408
  }
@@ -89024,7 +89435,16 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89024
89435
  x: localX,
89025
89436
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
89026
89437
  };
89027
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
89438
+ const hit2 = clickToPosition(
89439
+ context.layout,
89440
+ context.blocks,
89441
+ context.measures,
89442
+ headerPoint,
89443
+ void 0,
89444
+ void 0,
89445
+ void 0,
89446
+ void 0
89447
+ ) ?? null;
89028
89448
  return hit2;
89029
89449
  }
89030
89450
  if (!__privateGet$1(this, _layoutState).layout) {
@@ -89037,7 +89457,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89037
89457
  normalized,
89038
89458
  __privateGet$1(this, _viewportHost),
89039
89459
  clientX,
89040
- clientY
89460
+ clientY,
89461
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89041
89462
  ) ?? null;
89042
89463
  return hit;
89043
89464
  }
@@ -89260,6 +89681,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89260
89681
  __privateSet(this, _session, { mode: "body" });
89261
89682
  __privateSet(this, _activeHeaderFooterEditor, null);
89262
89683
  __privateSet(this, _domPainter, null);
89684
+ __privateSet(this, _pageGeometryHelper, null);
89263
89685
  (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
89264
89686
  __privateSet(this, _dragHandlerCleanup, null);
89265
89687
  __privateGet$1(this, _selectionOverlay2)?.remove();
@@ -89313,7 +89735,14 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
89313
89735
  if (!normalized) return false;
89314
89736
  const pmPos = __privateGet$1(this, _layoutState).bookmarks.get(normalized);
89315
89737
  if (pmPos == null) return false;
89316
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
89738
+ const rects = selectionToRects(
89739
+ layout,
89740
+ __privateGet$1(this, _layoutState).blocks,
89741
+ __privateGet$1(this, _layoutState).measures,
89742
+ pmPos,
89743
+ pmPos + 1,
89744
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
89745
+ ) ?? [];
89317
89746
  const rect = rects[0];
89318
89747
  let pageIndex = rect?.pageIndex ?? null;
89319
89748
  if (pageIndex == null) {
@@ -89377,6 +89806,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
89377
89806
  _layoutOptions = /* @__PURE__ */ new WeakMap();
89378
89807
  _layoutState = /* @__PURE__ */ new WeakMap();
89379
89808
  _domPainter = /* @__PURE__ */ new WeakMap();
89809
+ _pageGeometryHelper = /* @__PURE__ */ new WeakMap();
89380
89810
  _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
89381
89811
  _layoutError = /* @__PURE__ */ new WeakMap();
89382
89812
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
@@ -89835,7 +90265,7 @@ renderRemoteSelection_fn = function(cursor) {
89835
90265
  if (!layout || !blocks || !measures) return;
89836
90266
  const start2 = Math.min(cursor.anchor, cursor.head);
89837
90267
  const end2 = Math.max(cursor.anchor, cursor.head);
89838
- const rects = selectionToRects(layout, blocks, measures, start2, end2) ?? [];
90268
+ const rects = selectionToRects(layout, blocks, measures, start2, end2, __privateGet$1(this, _pageGeometryHelper) ?? void 0) ?? [];
89839
90269
  const color = __privateMethod$1(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
89840
90270
  const opacity = __privateGet$1(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
89841
90271
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -90195,15 +90625,25 @@ hitTestTable_fn = function(normalizedX, normalizedY) {
90195
90625
  const configuredPageSize = __privateGet$1(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
90196
90626
  let pageY = 0;
90197
90627
  let pageHit = null;
90198
- for (let i = 0; i < layout.pages.length; i++) {
90199
- const page = layout.pages[i];
90200
- const pageHeight = page.size?.h ?? configuredPageSize.h;
90201
- const gap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
90202
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
90203
- pageHit = { pageIndex: i, page };
90204
- break;
90628
+ const geometryHelper = __privateGet$1(this, _pageGeometryHelper);
90629
+ if (geometryHelper) {
90630
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
90631
+ if (idx != null && layout.pages[idx]) {
90632
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
90633
+ pageY = geometryHelper.getPageTop(idx);
90634
+ }
90635
+ }
90636
+ if (!pageHit) {
90637
+ const gap = layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90638
+ for (let i = 0; i < layout.pages.length; i++) {
90639
+ const page = layout.pages[i];
90640
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
90641
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
90642
+ pageHit = { pageIndex: i, page };
90643
+ break;
90644
+ }
90645
+ pageY += pageHeight + gap;
90205
90646
  }
90206
- pageY += pageHeight + gap;
90207
90647
  }
90208
90648
  if (!pageHit) {
90209
90649
  return null;
@@ -90455,12 +90895,7 @@ rerender_fn = async function() {
90455
90895
  return;
90456
90896
  }
90457
90897
  ({ layout, measures } = result);
90458
- if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
90459
- const gap = __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
90460
- layout.pageGap = Math.max(0, gap);
90461
- } else {
90462
- layout.pageGap = DEFAULT_PAGE_GAP;
90463
- }
90898
+ layout.pageGap = __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90464
90899
  headerLayouts = result.headers;
90465
90900
  footerLayouts = result.footers;
90466
90901
  } catch (error) {
@@ -90477,6 +90912,17 @@ rerender_fn = async function() {
90477
90912
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
90478
90913
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
90479
90914
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
90915
+ if (__privateGet$1(this, _layoutState).layout) {
90916
+ const pageGap = __privateGet$1(this, _layoutState).layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
90917
+ if (!__privateGet$1(this, _pageGeometryHelper)) {
90918
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
90919
+ layout: __privateGet$1(this, _layoutState).layout,
90920
+ pageGap
90921
+ }));
90922
+ } else {
90923
+ __privateGet$1(this, _pageGeometryHelper).updateLayout(__privateGet$1(this, _layoutState).layout, pageGap);
90924
+ }
90925
+ }
90480
90926
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
90481
90927
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
90482
90928
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -90546,7 +90992,8 @@ ensurePainter_fn = function(blocks, measures) {
90546
90992
  pageStyles: __privateGet$1(this, _layoutOptions).pageStyles,
90547
90993
  headerProvider: __privateGet$1(this, _headerDecorationProvider),
90548
90994
  footerProvider: __privateGet$1(this, _footerDecorationProvider),
90549
- ruler: __privateGet$1(this, _layoutOptions).ruler
90995
+ ruler: __privateGet$1(this, _layoutOptions).ruler,
90996
+ pageGap: __privateGet$1(this, _layoutState).layout?.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
90550
90997
  }));
90551
90998
  }
90552
90999
  return __privateGet$1(this, _domPainter);
@@ -90634,7 +91081,14 @@ updateSelection_fn = function() {
90634
91081
  }
90635
91082
  return;
90636
91083
  }
90637
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
91084
+ const rects = selectionToRects(
91085
+ layout,
91086
+ __privateGet$1(this, _layoutState).blocks,
91087
+ __privateGet$1(this, _layoutState).measures,
91088
+ from2,
91089
+ to,
91090
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
91091
+ ) ?? [];
90638
91092
  let domStart = null;
90639
91093
  let domEnd = null;
90640
91094
  try {
@@ -90648,7 +91102,9 @@ updateSelection_fn = function() {
90648
91102
  const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
90649
91103
  try {
90650
91104
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
90651
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
91105
+ if (correctedRects.length > 0) {
91106
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
91107
+ }
90652
91108
  } catch (error) {
90653
91109
  if (process$1$1.env.NODE_ENV === "development") {
90654
91110
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -91436,6 +91892,15 @@ waitForPageMount_fn = async function(pageIndex, options = {}) {
91436
91892
  checkPage();
91437
91893
  });
91438
91894
  };
91895
+ getEffectivePageGap_fn = function() {
91896
+ if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
91897
+ return Math.max(0, __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
91898
+ }
91899
+ if (__privateGet$1(this, _layoutOptions).layoutMode === "horizontal") {
91900
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
91901
+ }
91902
+ return DEFAULT_PAGE_GAP;
91903
+ };
91439
91904
  getBodyPageHeight_fn = function() {
91440
91905
  return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
91441
91906
  };
@@ -91459,7 +91924,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91459
91924
  dy: domStart.y - layoutY
91460
91925
  };
91461
91926
  }
91462
- return rects.map((rect, idx) => {
91927
+ const corrected = rects.map((rect, idx) => {
91463
91928
  const delta = pageDelta[rect.pageIndex];
91464
91929
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
91465
91930
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -91474,6 +91939,7 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91474
91939
  }
91475
91940
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
91476
91941
  const endX = domEnd.x;
91942
+ adjustedX = Math.min(adjustedX, endX);
91477
91943
  adjustedWidth = Math.max(1, endX - adjustedX);
91478
91944
  }
91479
91945
  return {
@@ -91483,6 +91949,29 @@ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
91483
91949
  width: adjustedWidth
91484
91950
  };
91485
91951
  });
91952
+ const MAX_DELTA_PX = 12;
91953
+ let invalid = false;
91954
+ if (domStart && corrected[0]) {
91955
+ const dx = Math.abs(corrected[0].x - domStart.x);
91956
+ const dy = Math.abs(corrected[0].y - domStart.y);
91957
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
91958
+ }
91959
+ if (domEnd && corrected[corrected.length - 1]) {
91960
+ const last = corrected[corrected.length - 1];
91961
+ const dx = Math.abs(last.x + last.width - domEnd.x);
91962
+ const dy = Math.abs(last.y - domEnd.y);
91963
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid = true;
91964
+ }
91965
+ if (invalid) {
91966
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
91967
+ domStart,
91968
+ domEnd,
91969
+ rectStart: corrected[0],
91970
+ rectEnd: corrected[corrected.length - 1]
91971
+ });
91972
+ return [];
91973
+ }
91974
+ return corrected;
91486
91975
  };
91487
91976
  renderCellSelectionOverlay_fn = function(selection, layout) {
91488
91977
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
@@ -91766,7 +92255,7 @@ computeHeaderFooterSelectionRects_fn = function(from2, to) {
91766
92255
  return [];
91767
92256
  }
91768
92257
  if (!bodyLayout) return [];
91769
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
92258
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
91770
92259
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
91771
92260
  const bodyPageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
91772
92261
  return rects.map((rect) => {
@@ -92233,7 +92722,14 @@ getCurrentPageIndex_fn = function() {
92233
92722
  if (!layout || !selection) {
92234
92723
  return 0;
92235
92724
  }
92236
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
92725
+ const rects = selectionToRects(
92726
+ layout,
92727
+ __privateGet$1(this, _layoutState).blocks,
92728
+ __privateGet$1(this, _layoutState).measures,
92729
+ selection.from,
92730
+ selection.to,
92731
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
92732
+ ) ?? [];
92237
92733
  if (rects.length > 0) {
92238
92734
  return rects[0]?.pageIndex ?? 0;
92239
92735
  }
@@ -97665,14 +98161,19 @@ const createCell = (cellType, cellContent = null) => {
97665
98161
  }
97666
98162
  return cellType.createAndFill();
97667
98163
  };
97668
- const createTableBorders = ({ size: size2 = 0.66665, color = "#000000" } = {}) => {
98164
+ const createTableBorders = (borderSpec = {}) => {
98165
+ borderSpec = {
98166
+ size: 0.66665,
98167
+ color: "#000000",
98168
+ ...borderSpec
98169
+ };
97669
98170
  return {
97670
- top: { size: size2, color },
97671
- left: { size: size2, color },
97672
- bottom: { size: size2, color },
97673
- right: { size: size2, color },
97674
- insideH: { size: size2, color },
97675
- insideV: { size: size2, color }
98171
+ top: borderSpec,
98172
+ left: borderSpec,
98173
+ bottom: borderSpec,
98174
+ right: borderSpec,
98175
+ insideH: borderSpec,
98176
+ insideV: borderSpec
97676
98177
  };
97677
98178
  };
97678
98179
  const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent = null) => {
@@ -97800,12 +98301,17 @@ const deleteTableWhenSelected = ({ editor }) => {
97800
98301
  editor.commands.deleteTable();
97801
98302
  return true;
97802
98303
  };
97803
- const createCellBorders = ({ size: size2 = 0.66665, color = "#000000" } = {}) => {
98304
+ const createCellBorders = (borderSpec = {}) => {
98305
+ borderSpec = {
98306
+ size: 0.66665,
98307
+ color: "#000000",
98308
+ ...borderSpec
98309
+ };
97804
98310
  return {
97805
- top: { size: size2, color },
97806
- left: { size: size2, color },
97807
- bottom: { size: size2, color },
97808
- right: { size: size2, color }
98311
+ top: borderSpec,
98312
+ left: borderSpec,
98313
+ bottom: borderSpec,
98314
+ right: borderSpec
97809
98315
  };
97810
98316
  };
97811
98317
  function cellAround($pos) {
@@ -98572,13 +99078,20 @@ const Table = Node$1.create({
98572
99078
  if (["tableCell", "tableHeader"].includes(node.type.name)) {
98573
99079
  tr.setNodeMarkup(pos, void 0, {
98574
99080
  ...node.attrs,
98575
- borders: createCellBorders({ size: 0 })
99081
+ borders: createCellBorders({ size: 0, space: 0, val: "none", color: "auto" })
98576
99082
  });
98577
99083
  }
98578
99084
  });
98579
99085
  tr.setNodeMarkup(table.pos, void 0, {
98580
99086
  ...table.node.attrs,
98581
- borders: createTableBorders({ size: 0 })
99087
+ borders: createTableBorders({ size: 0 }),
99088
+ // TODO: This works around the issue that table borders are duplicated between
99089
+ // the attributes of the table and the tableProperties attribute.
99090
+ // This can be removed when the redundancy is eliminated.
99091
+ tableProperties: {
99092
+ ...table.node.attrs.tableProperties,
99093
+ borders: createTableBorders({ size: 0, space: 0, val: "none", color: "auto" })
99094
+ }
98582
99095
  });
98583
99096
  return true;
98584
99097
  }
@@ -122580,7 +123093,7 @@ const makeDefaultItems = ({
122580
123093
  }
122581
123094
  },
122582
123095
  {
122583
- label: toolbarTexts2.transparentBorders,
123096
+ label: toolbarTexts2.removeBorders,
122584
123097
  command: "deleteCellAndTableBorders",
122585
123098
  icon: toolbarIcons2.deleteBorders,
122586
123099
  bottomBorder: true,
@@ -123161,7 +123674,7 @@ const toolbarTexts = {
123161
123674
  deleteRow: "Delete row",
123162
123675
  deleteColumn: "Delete column",
123163
123676
  deleteTable: "Delete table",
123164
- transparentBorders: "Transparent borders",
123677
+ removeBorders: "Remove borders",
123165
123678
  mergeCells: "Merge cells",
123166
123679
  splitCell: "Split cell",
123167
123680
  fixTables: "Fix tables",
@@ -124199,7 +124712,7 @@ const TEXTS = {
124199
124712
  deleteRow: "Delete row",
124200
124713
  deleteColumn: "Delete column",
124201
124714
  deleteTable: "Delete table",
124202
- transparentBorders: "Transparent borders",
124715
+ removeBorders: "Remove borders",
124203
124716
  mergeCells: "Merge cells",
124204
124717
  splitCell: "Split cell",
124205
124718
  fixTables: "Fix tables",
@@ -124282,7 +124795,7 @@ const tableActionsOptions = [
124282
124795
  }
124283
124796
  },
124284
124797
  {
124285
- label: TEXTS.transparentBorders,
124798
+ label: TEXTS.removeBorders,
124286
124799
  command: "deleteCellAndTableBorders",
124287
124800
  icon: ICONS.deleteBorders,
124288
124801
  bottomBorder: true,