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
@@ -39793,7 +39793,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39793
39793
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
39794
39794
  const date = new Date(createdDate);
39795
39795
  const unixTimestampMs = date.getTime();
39796
- const parsedComment = nodeListHandler.handler({
39796
+ const parsedElements = nodeListHandler.handler({
39797
39797
  nodes: el.elements,
39798
39798
  nodeListHandler,
39799
39799
  docx,
@@ -39801,7 +39801,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39801
39801
  converter,
39802
39802
  path: [el]
39803
39803
  });
39804
- const { attrs } = parsedComment[0];
39804
+ const { attrs } = parsedElements[0];
39805
39805
  const paraId = attrs["w14:paraId"];
39806
39806
  return {
39807
39807
  commentId: internalId || v4$1(),
@@ -39809,7 +39809,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39809
39809
  creatorName: authorName,
39810
39810
  creatorEmail: authorEmail,
39811
39811
  createdTime: unixTimestampMs,
39812
- textJson: parsedComment[0],
39812
+ textJson: parsedElements[0],
39813
+ elements: parsedElements,
39813
39814
  initials,
39814
39815
  paraId,
39815
39816
  trackedChange,
@@ -39835,7 +39836,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39835
39836
  const { elements = [] } = initialElements[0] ?? {};
39836
39837
  const commentEx = elements.filter((el) => el.name === "w15:commentEx");
39837
39838
  return comments.map((comment2) => {
39838
- const extendedDef = commentEx.find((ce2) => ce2.attributes["w15:paraId"] === comment2.paraId);
39839
+ const extendedDef = commentEx.find((ce2) => {
39840
+ const isIncludedInCommentElements = comment2.elements?.some(
39841
+ (el) => el.attrs?.["w14:paraId"] === ce2.attributes["w15:paraId"]
39842
+ );
39843
+ return isIncludedInCommentElements;
39844
+ });
39839
39845
  if (!extendedDef) return { ...comment2, isDone: comment2.isDone ?? false };
39840
39846
  const { isDone, paraIdParent } = getExtendedDetails(extendedDef);
39841
39847
  let parentComment;
@@ -41956,7 +41962,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41956
41962
  name: "w16cex:commentExtensible",
41957
41963
  attributes: {
41958
41964
  "w16cex:durableId": newDurableId,
41959
- "w16cex:dateUtc": toIsoNoFractional()
41965
+ "w16cex:dateUtc": toIsoNoFractional(comment2.createdTime)
41960
41966
  }
41961
41967
  };
41962
41968
  extensibleUpdated.elements[0].elements.push(newExtensible);
@@ -42422,7 +42428,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42422
42428
  static getStoredSuperdocVersion(docx) {
42423
42429
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42424
42430
  }
42425
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.100") {
42431
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.102") {
42426
42432
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42427
42433
  }
42428
42434
  /**
@@ -53591,7 +53597,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53591
53597
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53592
53598
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53593
53599
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53594
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53600
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _pageGeometryHelper, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
53595
53601
  var GOOD_LEAF_SIZE = 200;
53596
53602
  var RopeSequence = function RopeSequence2() {
53597
53603
  };
@@ -62675,6 +62681,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62675
62681
  const selectAll = () => ({ state: state2, dispatch }) => selectAll$1(state2, dispatch);
62676
62682
  const deleteSelection = () => ({ state: state2, tr, dispatch }) => {
62677
62683
  const { from: from2, to, empty: empty2 } = state2.selection;
62684
+ if (typeof document !== "undefined" && document.getSelection) {
62685
+ const currentDomSelection = document.getSelection();
62686
+ const selectedLength = currentDomSelection?.toString?.().length;
62687
+ const isCollapsed = currentDomSelection?.isCollapsed;
62688
+ if (!isCollapsed && selectedLength === 1) {
62689
+ return false;
62690
+ }
62691
+ }
62678
62692
  if (empty2) {
62679
62693
  return deleteSelection$1(state2, dispatch);
62680
62694
  }
@@ -64974,12 +64988,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64974
64988
  importedId: node2.attrs["w:id"]
64975
64989
  });
64976
64990
  if (type2.name === "commentRangeStart") {
64977
- toMark.push({
64978
- commentId: resolvedCommentId,
64979
- importedId,
64980
- internal,
64981
- start: pos
64982
- });
64991
+ if (!matchingImportedComment?.isDone) {
64992
+ toMark.push({
64993
+ commentId: resolvedCommentId,
64994
+ importedId,
64995
+ internal,
64996
+ start: pos
64997
+ });
64998
+ }
64983
64999
  ensureFallbackComment({
64984
65000
  converter,
64985
65001
  matchingImportedComment,
@@ -67497,7 +67513,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67497
67513
  const shouldSkipNodeView = (editor) => {
67498
67514
  return isHeadless(editor);
67499
67515
  };
67500
- const summaryVersion = "1.0.0-beta.100";
67516
+ const summaryVersion = "1.0.0-beta.102";
67501
67517
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67502
67518
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67503
67519
  function mapAttributes(attrs) {
@@ -68286,7 +68302,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68286
68302
  { default: remarkStringify2 },
68287
68303
  { default: remarkGfm2 }
68288
68304
  ] = await Promise.all([
68289
- Promise.resolve().then(() => indexBd5TMBeR),
68305
+ Promise.resolve().then(() => indexNVrA3URL),
68290
68306
  Promise.resolve().then(() => indexDRCvimau),
68291
68307
  Promise.resolve().then(() => indexC_x_N6Uh),
68292
68308
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68491,7 +68507,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68491
68507
  * Process collaboration migrations
68492
68508
  */
68493
68509
  processCollaborationMigrations() {
68494
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.100");
68510
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.102");
68495
68511
  if (!this.options.ydoc) return;
68496
68512
  const metaMap = this.options.ydoc.getMap("meta");
68497
68513
  let docVersion = metaMap.get("version");
@@ -80574,7 +80590,7 @@ ${l}
80574
80590
  alignItems: "center",
80575
80591
  background: "transparent",
80576
80592
  padding: "0",
80577
- gap: "24px",
80593
+ // gap is set dynamically by renderer based on pageGap option (default: 24px)
80578
80594
  overflowY: "auto"
80579
80595
  };
80580
80596
  const containerStylesHorizontal = {
@@ -80584,7 +80600,7 @@ ${l}
80584
80600
  justifyContent: "safe center",
80585
80601
  background: "transparent",
80586
80602
  padding: "0",
80587
- gap: "20px",
80603
+ // gap is set dynamically by renderer based on pageGap option (default: 20px for horizontal)
80588
80604
  overflowX: "auto",
80589
80605
  minHeight: "100%"
80590
80606
  };
@@ -82387,6 +82403,7 @@ ${l}
82387
82403
  const LIST_MARKER_GAP$1 = 8;
82388
82404
  const DEFAULT_TAB_INTERVAL_PX$1 = 48;
82389
82405
  const DEFAULT_PAGE_HEIGHT_PX = 1056;
82406
+ const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
82390
82407
  const COMMENT_EXTERNAL_COLOR = "#B1124B";
82391
82408
  const COMMENT_INTERNAL_COLOR = "#078383";
82392
82409
  const COMMENT_INACTIVE_ALPHA = "22";
@@ -82516,10 +82533,11 @@ ${l}
82516
82533
  this.totalPages = 0;
82517
82534
  this.linkIdCounter = 0;
82518
82535
  this.pendingTooltips = /* @__PURE__ */ new WeakMap();
82536
+ this.pageGap = 24;
82519
82537
  this.virtualEnabled = false;
82520
82538
  this.virtualWindow = 5;
82521
82539
  this.virtualOverscan = 0;
82522
- this.virtualGap = 72;
82540
+ this.virtualGap = DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82523
82541
  this.virtualPaddingTop = null;
82524
82542
  this.topSpacerEl = null;
82525
82543
  this.bottomSpacerEl = null;
@@ -82538,13 +82556,14 @@ ${l}
82538
82556
  this.blockLookup = this.buildBlockLookup(blocks2, measures);
82539
82557
  this.headerProvider = options.headerProvider;
82540
82558
  this.footerProvider = options.footerProvider;
82559
+ const defaultGap = this.layoutMode === "horizontal" ? 20 : 24;
82560
+ this.pageGap = typeof options.pageGap === "number" && Number.isFinite(options.pageGap) ? Math.max(0, options.pageGap) : defaultGap;
82541
82561
  if (this.layoutMode === "vertical" && options.virtualization?.enabled) {
82542
82562
  this.virtualEnabled = true;
82543
82563
  this.virtualWindow = Math.max(1, options.virtualization.window ?? 5);
82544
82564
  this.virtualOverscan = Math.max(0, options.virtualization.overscan ?? 0);
82545
- if (typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap)) {
82546
- this.virtualGap = Math.max(0, options.virtualization.gap);
82547
- }
82565
+ const hasExplicitVirtualGap = typeof options.virtualization.gap === "number" && Number.isFinite(options.virtualization.gap);
82566
+ this.virtualGap = hasExplicitVirtualGap ? Math.max(0, options.virtualization.gap) : DEFAULT_VIRTUALIZED_PAGE_GAP$1;
82548
82567
  if (typeof options.virtualization.paddingTop === "number" && Number.isFinite(options.virtualization.paddingTop)) {
82549
82568
  this.virtualPaddingTop = Math.max(0, options.virtualization.paddingTop);
82550
82569
  }
@@ -82645,6 +82664,7 @@ ${l}
82645
82664
  const mode = this.layoutMode;
82646
82665
  if (mode === "horizontal") {
82647
82666
  applyStyles$2(mount2, containerStylesHorizontal);
82667
+ mount2.style.gap = `${this.pageGap}px`;
82648
82668
  this.renderHorizontal(layout, mount2);
82649
82669
  this.currentLayout = layout;
82650
82670
  this.pageStates = [];
@@ -82667,6 +82687,7 @@ ${l}
82667
82687
  this.changedBlocks.clear();
82668
82688
  return;
82669
82689
  }
82690
+ mount2.style.gap = `${this.pageGap}px`;
82670
82691
  if (!this.currentLayout || this.pageStates.length === 0) {
82671
82692
  this.fullRender(layout);
82672
82693
  } else {
@@ -85886,6 +85907,7 @@ ${l}
85886
85907
  const painter = new DomPainter(options.blocks, options.measures, {
85887
85908
  pageStyles: options.pageStyles,
85888
85909
  layoutMode: options.layoutMode,
85910
+ pageGap: options.pageGap,
85889
85911
  headerProvider: options.headerProvider,
85890
85912
  footerProvider: options.footerProvider,
85891
85913
  virtualization: options.virtualization,
@@ -91183,6 +91205,285 @@ ${l}
91183
91205
  }
91184
91206
  return updatedMeasures;
91185
91207
  }
91208
+ class PageGeometryHelper {
91209
+ /**
91210
+ * Creates a new PageGeometryHelper instance.
91211
+ *
91212
+ * @param config - Page geometry configuration
91213
+ */
91214
+ constructor(config2) {
91215
+ this.cache = null;
91216
+ this.config = config2;
91217
+ }
91218
+ /**
91219
+ * Updates the layout and invalidates the cache.
91220
+ *
91221
+ * Call this whenever the layout changes (new pages, different heights, etc.)
91222
+ *
91223
+ * @param layout - New layout data
91224
+ * @param pageGap - Optional new page gap (if not provided, uses current gap)
91225
+ */
91226
+ updateLayout(layout, pageGap) {
91227
+ this.config.layout = layout;
91228
+ if (pageGap !== void 0) {
91229
+ this.config.pageGap = pageGap;
91230
+ }
91231
+ this.cache = null;
91232
+ }
91233
+ /**
91234
+ * Updates the page gap and invalidates the cache.
91235
+ *
91236
+ * @param pageGap - New gap between pages in pixels
91237
+ */
91238
+ updatePageGap(pageGap) {
91239
+ if (this.config.pageGap !== pageGap) {
91240
+ this.config.pageGap = pageGap;
91241
+ this.cache = null;
91242
+ }
91243
+ }
91244
+ /**
91245
+ * Gets the cumulative Y position (top edge) of a page in container space.
91246
+ *
91247
+ * The returned value is the distance from the top of the container to the
91248
+ * top of the specified page, accounting for all previous pages and gaps.
91249
+ *
91250
+ * @param pageIndex - Zero-based page index
91251
+ * @returns Y position in pixels, or 0 if page index is invalid
91252
+ *
91253
+ * @example
91254
+ * ```typescript
91255
+ * // Get Y position of page 0 (first page)
91256
+ * const y0 = helper.getPageTop(0); // Returns 0
91257
+ *
91258
+ * // Get Y position of page 2 (third page)
91259
+ * // Assumes page 0 height = 1000, page 1 height = 1200, gap = 24
91260
+ * const y2 = helper.getPageTop(2); // Returns 1000 + 24 + 1200 + 24 = 2248
91261
+ * ```
91262
+ */
91263
+ getPageTop(pageIndex) {
91264
+ this.ensureCache();
91265
+ if (pageIndex < 0 || pageIndex >= this.cache.cumulativeY.length) {
91266
+ return 0;
91267
+ }
91268
+ return this.cache.cumulativeY[pageIndex];
91269
+ }
91270
+ /**
91271
+ * Gets the height of a specific page.
91272
+ *
91273
+ * Uses per-page height if available (from layout.pages[i].size?.h),
91274
+ * otherwise falls back to layout.pageSize.h.
91275
+ *
91276
+ * @param pageIndex - Zero-based page index
91277
+ * @returns Page height in pixels, or 0 if page index is invalid
91278
+ *
91279
+ * @example
91280
+ * ```typescript
91281
+ * const height = helper.getPageHeight(0); // Returns page-specific height
91282
+ * ```
91283
+ */
91284
+ getPageHeight(pageIndex) {
91285
+ this.ensureCache();
91286
+ if (pageIndex < 0 || pageIndex >= this.cache.pageHeights.length) {
91287
+ return 0;
91288
+ }
91289
+ return this.cache.pageHeights[pageIndex];
91290
+ }
91291
+ /**
91292
+ * Gets the gap between pages.
91293
+ *
91294
+ * @returns Gap in pixels
91295
+ *
91296
+ * @example
91297
+ * ```typescript
91298
+ * const gap = helper.getPageGap(); // Returns 24
91299
+ * ```
91300
+ */
91301
+ getPageGap() {
91302
+ this.ensureCache();
91303
+ return this.cache.pageGap;
91304
+ }
91305
+ /**
91306
+ * Gets the total height of all pages including gaps.
91307
+ *
91308
+ * Total height = sum of all page heights + (pageCount - 1) * gap
91309
+ *
91310
+ * @returns Total height in pixels
91311
+ *
91312
+ * @example
91313
+ * ```typescript
91314
+ * // 3 pages: heights [1000, 1200, 1000], gap = 24
91315
+ * const total = helper.getTotalHeight();
91316
+ * // Returns 1000 + 24 + 1200 + 24 + 1000 = 3248
91317
+ * ```
91318
+ */
91319
+ getTotalHeight() {
91320
+ this.ensureCache();
91321
+ return this.cache.totalHeight;
91322
+ }
91323
+ /**
91324
+ * Gets the number of pages in the layout.
91325
+ *
91326
+ * @returns Page count
91327
+ */
91328
+ getPageCount() {
91329
+ return this.config.layout.pages.length;
91330
+ }
91331
+ /**
91332
+ * Finds the page index containing a given Y coordinate.
91333
+ *
91334
+ * This performs a linear search through cached cumulative positions.
91335
+ * For large documents, consider adding binary search optimization.
91336
+ *
91337
+ * @param containerY - Y coordinate in container space
91338
+ * @returns Page index, or null if Y is outside all pages
91339
+ *
91340
+ * @example
91341
+ * ```typescript
91342
+ * // Find which page contains Y = 1500
91343
+ * const pageIndex = helper.getPageIndexAtY(1500);
91344
+ * // Returns 1 (second page) if first page ends at Y=1024
91345
+ * ```
91346
+ */
91347
+ getPageIndexAtY(containerY) {
91348
+ this.ensureCache();
91349
+ const cache2 = this.cache;
91350
+ for (let i2 = 0; i2 < cache2.cumulativeY.length; i2++) {
91351
+ const pageTop = cache2.cumulativeY[i2];
91352
+ const pageBottom = pageTop + cache2.pageHeights[i2];
91353
+ if (containerY >= pageTop && containerY < pageBottom) {
91354
+ return i2;
91355
+ }
91356
+ }
91357
+ return null;
91358
+ }
91359
+ /**
91360
+ * Finds the nearest page index to a given Y coordinate (snap-to-nearest).
91361
+ *
91362
+ * Returns the page containing Y when inside a page; otherwise returns the
91363
+ * closest page based on distance to page center. Useful for dragging through
91364
+ * page gaps where getPageIndexAtY would return null.
91365
+ *
91366
+ * @param containerY - Y coordinate in container space
91367
+ * @returns Nearest page index, or null if there are no pages
91368
+ */
91369
+ getNearestPageIndex(containerY) {
91370
+ this.ensureCache();
91371
+ const cache2 = this.cache;
91372
+ const pageCount = cache2.pageHeights.length;
91373
+ if (pageCount === 0) return null;
91374
+ const direct = this.getPageIndexAtY(containerY);
91375
+ if (direct !== null) return direct;
91376
+ let nearestIndex = 0;
91377
+ let nearestDistance = Infinity;
91378
+ for (let i2 = 0; i2 < pageCount; i2++) {
91379
+ const top2 = cache2.cumulativeY[i2];
91380
+ const height = cache2.pageHeights[i2];
91381
+ const center = top2 + height / 2;
91382
+ const distance = Math.abs(containerY - center);
91383
+ if (distance < nearestDistance) {
91384
+ nearestDistance = distance;
91385
+ nearestIndex = i2;
91386
+ }
91387
+ }
91388
+ return nearestIndex;
91389
+ }
91390
+ /**
91391
+ * Ensures the cache is built and up-to-date.
91392
+ * Validates cache state and rebuilds if needed.
91393
+ * @private
91394
+ * @throws Never throws - handles errors gracefully with fallback values
91395
+ */
91396
+ ensureCache() {
91397
+ if (this.cache !== null) {
91398
+ if (!Array.isArray(this.cache.cumulativeY) || !Array.isArray(this.cache.pageHeights)) {
91399
+ console.warn("[PageGeometryHelper] Cache corruption detected, rebuilding cache");
91400
+ this.cache = null;
91401
+ } else {
91402
+ return;
91403
+ }
91404
+ }
91405
+ this.buildCache();
91406
+ }
91407
+ /**
91408
+ * Builds the geometry cache from current layout data.
91409
+ * Handles errors gracefully by providing fallback values.
91410
+ * @private
91411
+ * @throws Never throws - catches all errors and provides safe defaults
91412
+ */
91413
+ buildCache() {
91414
+ try {
91415
+ const layout = this.config.layout;
91416
+ if (!layout || !Array.isArray(layout.pages)) {
91417
+ throw new Error("Invalid layout: missing or invalid pages array");
91418
+ }
91419
+ const pageGap = this.config.pageGap ?? layout.pageGap ?? 0;
91420
+ const pageCount = layout.pages.length;
91421
+ if (!Number.isFinite(pageGap) || pageGap < 0) {
91422
+ throw new Error(`Invalid pageGap: ${pageGap} (must be non-negative finite number)`);
91423
+ }
91424
+ const cumulativeY = new Array(pageCount);
91425
+ const pageHeights = new Array(pageCount);
91426
+ let currentY = 0;
91427
+ for (let i2 = 0; i2 < pageCount; i2++) {
91428
+ const page = layout.pages[i2];
91429
+ if (!page) {
91430
+ throw new Error(`Invalid page at index ${i2}: page is null or undefined`);
91431
+ }
91432
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91433
+ if (!Number.isFinite(pageHeight) || pageHeight < 0) {
91434
+ throw new Error(`Invalid page height at index ${i2}: ${pageHeight} (must be non-negative finite number)`);
91435
+ }
91436
+ cumulativeY[i2] = currentY;
91437
+ pageHeights[i2] = pageHeight;
91438
+ currentY += pageHeight;
91439
+ if (i2 < pageCount - 1) {
91440
+ currentY += pageGap;
91441
+ }
91442
+ }
91443
+ const totalHeight = currentY;
91444
+ this.cache = {
91445
+ cumulativeY,
91446
+ pageHeights,
91447
+ pageGap,
91448
+ totalHeight,
91449
+ layoutVersion: 0
91450
+ // Placeholder for future version tracking
91451
+ };
91452
+ } catch (error) {
91453
+ const errorMessage = error instanceof Error ? error.message : String(error);
91454
+ console.error(`[PageGeometryHelper] Cache build failed: ${errorMessage}. Using fallback empty cache.`);
91455
+ this.cache = {
91456
+ cumulativeY: [],
91457
+ pageHeights: [],
91458
+ pageGap: 0,
91459
+ totalHeight: 0,
91460
+ layoutVersion: 0
91461
+ };
91462
+ }
91463
+ }
91464
+ /**
91465
+ * Clears the cache, forcing recalculation on next access.
91466
+ * Useful for testing or manual cache invalidation.
91467
+ */
91468
+ clearCache() {
91469
+ this.cache = null;
91470
+ }
91471
+ /**
91472
+ * Gets debug information about the current cache state.
91473
+ * @internal
91474
+ */
91475
+ getDebugInfo() {
91476
+ this.ensureCache();
91477
+ return {
91478
+ isCached: this.cache !== null,
91479
+ pageCount: this.config.layout.pages.length,
91480
+ pageGap: this.cache.pageGap,
91481
+ totalHeight: this.cache.totalHeight,
91482
+ cumulativeY: [...this.cache.cumulativeY],
91483
+ pageHeights: [...this.cache.pageHeights]
91484
+ };
91485
+ }
91486
+ }
91186
91487
  var Priority = /* @__PURE__ */ ((Priority2) => {
91187
91488
  Priority2[Priority2["P0"] = 0] = "P0";
91188
91489
  Priority2[Priority2["P1"] = 1] = "P1";
@@ -91476,18 +91777,41 @@ ${l}
91476
91777
  const effectiveEndA = endA ?? startA + 1;
91477
91778
  return effectiveEndA > startB && startA < endB;
91478
91779
  };
91479
- function hitTestPage(layout, point2) {
91780
+ function hitTestPage(layout, point2, geometryHelper) {
91781
+ if (geometryHelper) {
91782
+ const pageIndex = geometryHelper.getPageIndexAtY(point2.y);
91783
+ if (pageIndex !== null) {
91784
+ return { pageIndex, page: layout.pages[pageIndex] };
91785
+ }
91786
+ const nearest = geometryHelper.getNearestPageIndex(point2.y);
91787
+ if (nearest !== null) {
91788
+ return { pageIndex: nearest, page: layout.pages[nearest] };
91789
+ }
91790
+ return null;
91791
+ }
91480
91792
  const pageGap = layout.pageGap ?? 0;
91481
91793
  let cursorY = 0;
91794
+ let nearestIndex = null;
91795
+ let nearestDistance = Infinity;
91482
91796
  for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
91483
91797
  const page = layout.pages[pageIndex];
91798
+ const pageHeight = page.size?.h ?? layout.pageSize.h;
91484
91799
  const top2 = cursorY;
91485
- const bottom2 = top2 + layout.pageSize.h;
91800
+ const bottom2 = top2 + pageHeight;
91486
91801
  if (point2.y >= top2 && point2.y < bottom2) {
91487
91802
  return { pageIndex, page };
91488
91803
  }
91804
+ const center = top2 + pageHeight / 2;
91805
+ const distance = Math.abs(point2.y - center);
91806
+ if (distance < nearestDistance) {
91807
+ nearestDistance = distance;
91808
+ nearestIndex = pageIndex;
91809
+ }
91489
91810
  cursorY = bottom2 + pageGap;
91490
91811
  }
91812
+ if (nearestIndex !== null) {
91813
+ return { pageIndex: nearestIndex, page: layout.pages[nearestIndex] };
91814
+ }
91491
91815
  return null;
91492
91816
  }
91493
91817
  function hitTestFragment(layout, pageHit, blocks2, measures, point2) {
@@ -91648,7 +91972,7 @@ ${l}
91648
91972
  }
91649
91973
  return null;
91650
91974
  };
91651
- function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY) {
91975
+ function clickToPosition(layout, blocks2, measures, containerPoint, domContainer, clientX, clientY, geometryHelper) {
91652
91976
  logClickStage("log", "entry", {
91653
91977
  pages: layout.pages.length
91654
91978
  });
@@ -91691,75 +92015,132 @@ ${l}
91691
92015
  return { pos: domPos, blockId: "", pageIndex: 0, column: 0, lineIndex: -1 };
91692
92016
  }
91693
92017
  }
91694
- const pageHit = hitTestPage(layout, containerPoint);
92018
+ const pageHit = hitTestPage(layout, containerPoint, geometryHelper);
91695
92019
  if (!pageHit) {
91696
92020
  return null;
91697
92021
  }
91698
- const pageGap = layout.pageGap ?? 0;
92022
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageHit.pageIndex) : calculatePageTopFallback(layout, pageHit.pageIndex);
91699
92023
  const pageRelativePoint = {
91700
92024
  x: containerPoint.x,
91701
- y: containerPoint.y - pageHit.pageIndex * (layout.pageSize.h + pageGap)
92025
+ y: containerPoint.y - pageTopY
91702
92026
  };
91703
92027
  logClickStage("log", "page-hit", {
91704
92028
  pageIndex: pageHit.pageIndex
91705
92029
  });
91706
- const fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92030
+ let fragmentHit = hitTestFragment(layout, pageHit, blocks2, measures, pageRelativePoint);
92031
+ if (!fragmentHit) {
92032
+ const page = pageHit.page;
92033
+ const fragments = page.fragments.filter(
92034
+ (f2) => f2 != null && typeof f2 === "object"
92035
+ );
92036
+ if (fragments.length > 0) {
92037
+ let nearest = null;
92038
+ let nearestDist = Infinity;
92039
+ for (const frag of fragments) {
92040
+ const top2 = frag.y;
92041
+ const bottom2 = frag.y + frag.height;
92042
+ let dist2;
92043
+ if (pageRelativePoint.y < top2) {
92044
+ dist2 = top2 - pageRelativePoint.y;
92045
+ } else if (pageRelativePoint.y > bottom2) {
92046
+ dist2 = pageRelativePoint.y - bottom2;
92047
+ } else {
92048
+ dist2 = 0;
92049
+ }
92050
+ if (dist2 < nearestDist) {
92051
+ nearestDist = dist2;
92052
+ nearest = frag;
92053
+ }
92054
+ }
92055
+ if (nearest) {
92056
+ const blockIndex = findBlockIndexByFragmentId(blocks2, nearest.blockId);
92057
+ if (blockIndex !== -1) {
92058
+ const block = blocks2[blockIndex];
92059
+ const measure = measures[blockIndex];
92060
+ if (block && measure) {
92061
+ fragmentHit = {
92062
+ fragment: nearest,
92063
+ block,
92064
+ measure,
92065
+ pageIndex: pageHit.pageIndex,
92066
+ pageY: 0
92067
+ };
92068
+ }
92069
+ }
92070
+ }
92071
+ }
92072
+ }
91707
92073
  if (fragmentHit) {
91708
92074
  const { fragment, block, measure, pageIndex, pageY } = fragmentHit;
91709
- if (fragment.kind !== "para" || measure.kind !== "paragraph" || block.kind !== "paragraph") {
91710
- logClickStage("warn", "fragment-type-mismatch", {
91711
- fragmentKind: fragment.kind,
91712
- measureKind: measure.kind,
91713
- blockKind: block.kind
92075
+ if (fragment.kind === "para" && measure.kind === "paragraph" && block.kind === "paragraph") {
92076
+ const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
92077
+ if (lineIndex == null) {
92078
+ logClickStage("warn", "no-line", {
92079
+ blockId: fragment.blockId
92080
+ });
92081
+ return null;
92082
+ }
92083
+ const line = measure.lines[lineIndex];
92084
+ const isRTL = isRtlBlock(block);
92085
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
92086
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
92087
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
92088
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
92089
+ const totalIndent = paraIndentLeft + paraIndentRight;
92090
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
92091
+ if (totalIndent > fragment.width) {
92092
+ console.warn(
92093
+ `[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.`
92094
+ );
92095
+ }
92096
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
92097
+ const isListItem3 = markerWidth > 0;
92098
+ const alignmentOverride = isListItem3 ? "left" : void 0;
92099
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
92100
+ if (pos == null) {
92101
+ logClickStage("warn", "no-position", {
92102
+ blockId: fragment.blockId
92103
+ });
92104
+ return null;
92105
+ }
92106
+ const column = determineColumn(layout, fragment.x);
92107
+ logPositionDebug({
92108
+ blockId: fragment.blockId,
92109
+ x: pageRelativePoint.x - fragment.x
91714
92110
  });
91715
- return null;
91716
- }
91717
- const lineIndex = findLineIndexAtY(measure, pageY, fragment.fromLine, fragment.toLine);
91718
- if (lineIndex == null) {
91719
- logClickStage("warn", "no-line", {
92111
+ logClickStage("log", "success", {
91720
92112
  blockId: fragment.blockId
91721
92113
  });
91722
- return null;
91723
- }
91724
- const line = measure.lines[lineIndex];
91725
- const isRTL = isRtlBlock(block);
91726
- const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
91727
- const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
91728
- const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
91729
- const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
91730
- const totalIndent = paraIndentLeft + paraIndentRight;
91731
- const availableWidth = Math.max(0, fragment.width - totalIndent);
91732
- if (totalIndent > fragment.width) {
91733
- console.warn(
91734
- `[clickToPosition] Paragraph indents (${totalIndent}px) exceed fragment width (${fragment.width}px) for block ${fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
91735
- );
92114
+ return {
92115
+ pos,
92116
+ blockId: fragment.blockId,
92117
+ pageIndex,
92118
+ column,
92119
+ lineIndex
92120
+ // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
92121
+ };
91736
92122
  }
91737
- const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
91738
- const isListItem3 = markerWidth > 0;
91739
- const alignmentOverride = isListItem3 ? "left" : void 0;
91740
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth, alignmentOverride);
91741
- if (pos == null) {
91742
- logClickStage("warn", "no-position", {
91743
- blockId: fragment.blockId
92123
+ if (isAtomicFragment(fragment)) {
92124
+ const pmRange = getAtomicPmRange(fragment, block);
92125
+ const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
92126
+ if (pos == null) {
92127
+ logClickStage("warn", "atomic-without-range", {
92128
+ fragmentId: fragment.blockId
92129
+ });
92130
+ return null;
92131
+ }
92132
+ logClickStage("log", "success", {
92133
+ blockId: fragment.blockId,
92134
+ column: determineColumn(layout, fragment.x)
91744
92135
  });
91745
- return null;
92136
+ return {
92137
+ pos,
92138
+ blockId: fragment.blockId,
92139
+ pageIndex,
92140
+ column: determineColumn(layout, fragment.x),
92141
+ lineIndex: -1
92142
+ };
91746
92143
  }
91747
- const column = determineColumn(layout, fragment.x);
91748
- logPositionDebug({
91749
- blockId: fragment.blockId,
91750
- x: pageRelativePoint.x - fragment.x
91751
- });
91752
- logClickStage("log", "success", {
91753
- blockId: fragment.blockId
91754
- });
91755
- return {
91756
- pos,
91757
- blockId: fragment.blockId,
91758
- pageIndex,
91759
- column,
91760
- lineIndex
91761
- // lineIndex is now already absolute (within measure.lines), no need to add fragment.fromLine
91762
- };
91763
92144
  }
91764
92145
  const tableHit = hitTestTableFragment(pageHit, blocks2, measures, pageRelativePoint);
91765
92146
  if (tableHit) {
@@ -91909,12 +92290,22 @@ ${l}
91909
92290
  }
91910
92291
  return height;
91911
92292
  };
91912
- function selectionToRects(layout, blocks2, measures, from2, to) {
92293
+ const calculatePageTopFallback = (layout, pageIndex) => {
92294
+ const pageGap = layout.pageGap ?? 0;
92295
+ let y2 = 0;
92296
+ for (let i2 = 0; i2 < pageIndex; i2++) {
92297
+ const pageHeight = layout.pages[i2]?.size?.h ?? layout.pageSize.h;
92298
+ y2 += pageHeight + pageGap;
92299
+ }
92300
+ return y2;
92301
+ };
92302
+ function selectionToRects(layout, blocks2, measures, from2, to, geometryHelper) {
91913
92303
  if (from2 === to) {
91914
92304
  return [];
91915
92305
  }
91916
92306
  const rects = [];
91917
92307
  layout.pages.forEach((page, pageIndex) => {
92308
+ const pageTopY = geometryHelper ? geometryHelper.getPageTop(pageIndex) : calculatePageTopFallback(layout, pageIndex);
91918
92309
  page.fragments.forEach((fragment) => {
91919
92310
  if (fragment.kind === "para") {
91920
92311
  const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId, { from: from2, to });
@@ -91956,12 +92347,16 @@ ${l}
91956
92347
  wordLayout
91957
92348
  });
91958
92349
  const rectX = fragment.x + indentAdjust + Math.min(startX, endX);
91959
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92350
+ const rectWidth = Math.max(
92351
+ 1,
92352
+ Math.min(Math.abs(endX - startX), line.width)
92353
+ // clamp to line width to prevent runaway widths
92354
+ );
91960
92355
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
91961
92356
  const rectY = fragment.y + lineOffset;
91962
92357
  rects.push({
91963
92358
  x: rectX,
91964
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92359
+ y: rectY + pageTopY,
91965
92360
  width: rectWidth,
91966
92361
  height: line.lineHeight,
91967
92362
  pageIndex
@@ -92089,12 +92484,16 @@ ${l}
92089
92484
  wordLayout: cellWordLayout
92090
92485
  });
92091
92486
  const rectX = fragment.x + cellX + padding.left + textIndentAdjust + Math.min(startX, endX);
92092
- const rectWidth = Math.max(1, Math.abs(endX - startX));
92487
+ const rectWidth = Math.max(
92488
+ 1,
92489
+ Math.min(Math.abs(endX - startX), line.width)
92490
+ // clamp to line width to prevent runaway widths
92491
+ );
92093
92492
  const lineOffset = lineHeightBeforeIndex(info.measure, index2) - lineHeightBeforeIndex(info.measure, info.startLine);
92094
92493
  const rectY = fragment.y + rowOffset + blockTopCursor + lineOffset;
92095
92494
  rects.push({
92096
92495
  x: rectX,
92097
- y: rectY + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92496
+ y: rectY + pageTopY,
92098
92497
  width: rectWidth,
92099
92498
  height: line.lineHeight,
92100
92499
  pageIndex
@@ -92123,7 +92522,7 @@ ${l}
92123
92522
  if (!rangesOverlap(pmRange.pmStart, pmRange.pmEnd, from2, to)) return;
92124
92523
  rects.push({
92125
92524
  x: fragment.x,
92126
- y: fragment.y + pageIndex * (layout.pageSize.h + (layout.pageGap ?? 0)),
92525
+ y: fragment.y + pageTopY,
92127
92526
  width: fragment.width,
92128
92527
  height: fragment.height,
92129
92528
  pageIndex
@@ -95364,6 +95763,7 @@ ${l}
95364
95763
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
95365
95764
  const DEFAULT_VIRTUALIZED_PAGE_GAP = 72;
95366
95765
  const DEFAULT_PAGE_GAP = 24;
95766
+ const DEFAULT_HORIZONTAL_PAGE_GAP = 20;
95367
95767
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
95368
95768
  const MULTI_CLICK_TIME_THRESHOLD_MS = 400;
95369
95769
  const MULTI_CLICK_DISTANCE_THRESHOLD_PX = 5;
@@ -95387,6 +95787,7 @@ ${l}
95387
95787
  __privateAdd$1(this, _layoutOptions);
95388
95788
  __privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() });
95389
95789
  __privateAdd$1(this, _domPainter, null);
95790
+ __privateAdd$1(this, _pageGeometryHelper, null);
95390
95791
  __privateAdd$1(this, _dragHandlerCleanup, null);
95391
95792
  __privateAdd$1(this, _layoutError, null);
95392
95793
  __privateAdd$1(this, _layoutErrorState, "healthy");
@@ -95539,7 +95940,8 @@ ${l}
95539
95940
  { x: x2, y: y2 },
95540
95941
  __privateGet$1(this, _viewportHost),
95541
95942
  event.clientX,
95542
- event.clientY
95943
+ event.clientY,
95944
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95543
95945
  );
95544
95946
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
95545
95947
  const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
@@ -95738,7 +96140,8 @@ ${l}
95738
96140
  { x: normalized.x, y: normalized.y },
95739
96141
  __privateGet$1(this, _viewportHost),
95740
96142
  event.clientX,
95741
- event.clientY
96143
+ event.clientY,
96144
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
95742
96145
  );
95743
96146
  if (!hit) return;
95744
96147
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
@@ -96585,7 +96988,14 @@ ${l}
96585
96988
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
96586
96989
  }
96587
96990
  if (!__privateGet$1(this, _layoutState).layout) return [];
96588
- const rects = selectionToRects(__privateGet$1(this, _layoutState).layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, start2, end2) ?? [];
96991
+ const rects = selectionToRects(
96992
+ __privateGet$1(this, _layoutState).layout,
96993
+ __privateGet$1(this, _layoutState).blocks,
96994
+ __privateGet$1(this, _layoutState).measures,
96995
+ start2,
96996
+ end2,
96997
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
96998
+ ) ?? [];
96589
96999
  return rects;
96590
97000
  };
96591
97001
  const rawRects = layoutRectSource();
@@ -96850,6 +97260,7 @@ ${l}
96850
97260
  };
96851
97261
  }
96852
97262
  __privateSet(this, _domPainter, null);
97263
+ __privateSet(this, _pageGeometryHelper, null);
96853
97264
  __privateSet(this, _pendingDocChange, true);
96854
97265
  __privateMethod$1(this, _PresentationEditor_instances, scheduleRerender_fn).call(this);
96855
97266
  }
@@ -96882,7 +97293,16 @@ ${l}
96882
97293
  x: localX,
96883
97294
  y: headerPageIndex * headerPageHeight + (localY - headerPageIndex * headerPageHeight)
96884
97295
  };
96885
- const hit2 = clickToPosition(context.layout, context.blocks, context.measures, headerPoint) ?? null;
97296
+ const hit2 = clickToPosition(
97297
+ context.layout,
97298
+ context.blocks,
97299
+ context.measures,
97300
+ headerPoint,
97301
+ void 0,
97302
+ void 0,
97303
+ void 0,
97304
+ void 0
97305
+ ) ?? null;
96886
97306
  return hit2;
96887
97307
  }
96888
97308
  if (!__privateGet$1(this, _layoutState).layout) {
@@ -96895,7 +97315,8 @@ ${l}
96895
97315
  normalized,
96896
97316
  __privateGet$1(this, _viewportHost),
96897
97317
  clientX,
96898
- clientY
97318
+ clientY,
97319
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
96899
97320
  ) ?? null;
96900
97321
  return hit;
96901
97322
  }
@@ -97118,6 +97539,7 @@ ${l}
97118
97539
  __privateSet(this, _session, { mode: "body" });
97119
97540
  __privateSet(this, _activeHeaderFooterEditor, null);
97120
97541
  __privateSet(this, _domPainter, null);
97542
+ __privateSet(this, _pageGeometryHelper, null);
97121
97543
  (_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
97122
97544
  __privateSet(this, _dragHandlerCleanup, null);
97123
97545
  __privateGet$1(this, _selectionOverlay2)?.remove();
@@ -97171,7 +97593,14 @@ ${l}
97171
97593
  if (!normalized) return false;
97172
97594
  const pmPos = __privateGet$1(this, _layoutState).bookmarks.get(normalized);
97173
97595
  if (pmPos == null) return false;
97174
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pmPos, pmPos + 1) ?? [];
97596
+ const rects = selectionToRects(
97597
+ layout,
97598
+ __privateGet$1(this, _layoutState).blocks,
97599
+ __privateGet$1(this, _layoutState).measures,
97600
+ pmPos,
97601
+ pmPos + 1,
97602
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
97603
+ ) ?? [];
97175
97604
  const rect = rects[0];
97176
97605
  let pageIndex = rect?.pageIndex ?? null;
97177
97606
  if (pageIndex == null) {
@@ -97235,6 +97664,7 @@ ${l}
97235
97664
  _layoutOptions = /* @__PURE__ */ new WeakMap();
97236
97665
  _layoutState = /* @__PURE__ */ new WeakMap();
97237
97666
  _domPainter = /* @__PURE__ */ new WeakMap();
97667
+ _pageGeometryHelper = /* @__PURE__ */ new WeakMap();
97238
97668
  _dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
97239
97669
  _layoutError = /* @__PURE__ */ new WeakMap();
97240
97670
  _layoutErrorState = /* @__PURE__ */ new WeakMap();
@@ -97693,7 +98123,7 @@ ${l}
97693
98123
  if (!layout || !blocks2 || !measures) return;
97694
98124
  const start2 = Math.min(cursor.anchor, cursor.head);
97695
98125
  const end2 = Math.max(cursor.anchor, cursor.head);
97696
- const rects = selectionToRects(layout, blocks2, measures, start2, end2) ?? [];
98126
+ const rects = selectionToRects(layout, blocks2, measures, start2, end2, __privateGet$1(this, _pageGeometryHelper) ?? void 0) ?? [];
97697
98127
  const color2 = __privateMethod$1(this, _PresentationEditor_instances, getValidatedColor_fn).call(this, cursor);
97698
98128
  const opacity = __privateGet$1(this, _layoutOptions).presence?.highlightOpacity ?? 0.35;
97699
98129
  const pageHeight = layout.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
@@ -98053,15 +98483,25 @@ ${l}
98053
98483
  const configuredPageSize = __privateGet$1(this, _layoutOptions).pageSize ?? DEFAULT_PAGE_SIZE;
98054
98484
  let pageY = 0;
98055
98485
  let pageHit = null;
98056
- for (let i2 = 0; i2 < layout.pages.length; i2++) {
98057
- const page = layout.pages[i2];
98058
- const pageHeight = page.size?.h ?? configuredPageSize.h;
98059
- const gap = __privateGet$1(this, _layoutOptions).virtualization?.gap ?? DEFAULT_PAGE_GAP;
98060
- if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
98061
- pageHit = { pageIndex: i2, page };
98062
- break;
98486
+ const geometryHelper = __privateGet$1(this, _pageGeometryHelper);
98487
+ if (geometryHelper) {
98488
+ const idx = geometryHelper.getPageIndexAtY(normalizedY) ?? geometryHelper.getNearestPageIndex(normalizedY);
98489
+ if (idx != null && layout.pages[idx]) {
98490
+ pageHit = { pageIndex: idx, page: layout.pages[idx] };
98491
+ pageY = geometryHelper.getPageTop(idx);
98492
+ }
98493
+ }
98494
+ if (!pageHit) {
98495
+ const gap = layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98496
+ for (let i2 = 0; i2 < layout.pages.length; i2++) {
98497
+ const page = layout.pages[i2];
98498
+ const pageHeight = page.size?.h ?? configuredPageSize.h;
98499
+ if (normalizedY >= pageY && normalizedY < pageY + pageHeight) {
98500
+ pageHit = { pageIndex: i2, page };
98501
+ break;
98502
+ }
98503
+ pageY += pageHeight + gap;
98063
98504
  }
98064
- pageY += pageHeight + gap;
98065
98505
  }
98066
98506
  if (!pageHit) {
98067
98507
  return null;
@@ -98313,12 +98753,7 @@ ${l}
98313
98753
  return;
98314
98754
  }
98315
98755
  ({ layout, measures } = result);
98316
- if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
98317
- const gap = __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP;
98318
- layout.pageGap = Math.max(0, gap);
98319
- } else {
98320
- layout.pageGap = DEFAULT_PAGE_GAP;
98321
- }
98756
+ layout.pageGap = __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98322
98757
  headerLayouts = result.headers;
98323
98758
  footerLayouts = result.footers;
98324
98759
  } catch (error) {
@@ -98335,6 +98770,17 @@ ${l}
98335
98770
  __privateSet(this, _layoutState, { blocks: blocks2, measures, layout, bookmarks, anchorMap });
98336
98771
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
98337
98772
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
98773
+ if (__privateGet$1(this, _layoutState).layout) {
98774
+ const pageGap = __privateGet$1(this, _layoutState).layout.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this);
98775
+ if (!__privateGet$1(this, _pageGeometryHelper)) {
98776
+ __privateSet(this, _pageGeometryHelper, new PageGeometryHelper({
98777
+ layout: __privateGet$1(this, _layoutState).layout,
98778
+ pageGap
98779
+ }));
98780
+ } else {
98781
+ __privateGet$1(this, _pageGeometryHelper).updateLayout(__privateGet$1(this, _layoutState).layout, pageGap);
98782
+ }
98783
+ }
98338
98784
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
98339
98785
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
98340
98786
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks2, measures);
@@ -98404,7 +98850,8 @@ ${l}
98404
98850
  pageStyles: __privateGet$1(this, _layoutOptions).pageStyles,
98405
98851
  headerProvider: __privateGet$1(this, _headerDecorationProvider),
98406
98852
  footerProvider: __privateGet$1(this, _footerDecorationProvider),
98407
- ruler: __privateGet$1(this, _layoutOptions).ruler
98853
+ ruler: __privateGet$1(this, _layoutOptions).ruler,
98854
+ pageGap: __privateGet$1(this, _layoutState).layout?.pageGap ?? __privateMethod$1(this, _PresentationEditor_instances, getEffectivePageGap_fn).call(this)
98408
98855
  }));
98409
98856
  }
98410
98857
  return __privateGet$1(this, _domPainter);
@@ -98492,7 +98939,14 @@ ${l}
98492
98939
  }
98493
98940
  return;
98494
98941
  }
98495
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
98942
+ const rects = selectionToRects(
98943
+ layout,
98944
+ __privateGet$1(this, _layoutState).blocks,
98945
+ __privateGet$1(this, _layoutState).measures,
98946
+ from2,
98947
+ to,
98948
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
98949
+ ) ?? [];
98496
98950
  let domStart = null;
98497
98951
  let domEnd = null;
98498
98952
  try {
@@ -98506,7 +98960,9 @@ ${l}
98506
98960
  const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
98507
98961
  try {
98508
98962
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
98509
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
98963
+ if (correctedRects.length > 0) {
98964
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
98965
+ }
98510
98966
  } catch (error) {
98511
98967
  if (process$1$1.env.NODE_ENV === "development") {
98512
98968
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -99294,6 +99750,15 @@ ${l}
99294
99750
  checkPage();
99295
99751
  });
99296
99752
  };
99753
+ getEffectivePageGap_fn = function() {
99754
+ if (__privateGet$1(this, _layoutOptions).virtualization?.enabled) {
99755
+ return Math.max(0, __privateGet$1(this, _layoutOptions).virtualization.gap ?? DEFAULT_VIRTUALIZED_PAGE_GAP);
99756
+ }
99757
+ if (__privateGet$1(this, _layoutOptions).layoutMode === "horizontal") {
99758
+ return DEFAULT_HORIZONTAL_PAGE_GAP;
99759
+ }
99760
+ return DEFAULT_PAGE_GAP;
99761
+ };
99297
99762
  getBodyPageHeight_fn = function() {
99298
99763
  return __privateGet$1(this, _layoutState).layout?.pageSize?.h ?? __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
99299
99764
  };
@@ -99317,7 +99782,7 @@ ${l}
99317
99782
  dy: domStart.y - layoutY
99318
99783
  };
99319
99784
  }
99320
- return rects.map((rect, idx) => {
99785
+ const corrected = rects.map((rect, idx) => {
99321
99786
  const delta = pageDelta[rect.pageIndex];
99322
99787
  let adjustedX = delta ? rect.x + delta.dx : rect.x;
99323
99788
  let adjustedY = delta ? rect.y + delta.dy : rect.y;
@@ -99332,6 +99797,7 @@ ${l}
99332
99797
  }
99333
99798
  if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
99334
99799
  const endX = domEnd.x;
99800
+ adjustedX = Math.min(adjustedX, endX);
99335
99801
  adjustedWidth = Math.max(1, endX - adjustedX);
99336
99802
  }
99337
99803
  return {
@@ -99341,6 +99807,29 @@ ${l}
99341
99807
  width: adjustedWidth
99342
99808
  };
99343
99809
  });
99810
+ const MAX_DELTA_PX = 12;
99811
+ let invalid2 = false;
99812
+ if (domStart && corrected[0]) {
99813
+ const dx = Math.abs(corrected[0].x - domStart.x);
99814
+ const dy = Math.abs(corrected[0].y - domStart.y);
99815
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99816
+ }
99817
+ if (domEnd && corrected[corrected.length - 1]) {
99818
+ const last = corrected[corrected.length - 1];
99819
+ const dx = Math.abs(last.x + last.width - domEnd.x);
99820
+ const dy = Math.abs(last.y - domEnd.y);
99821
+ if (dx > MAX_DELTA_PX || dy > MAX_DELTA_PX) invalid2 = true;
99822
+ }
99823
+ if (invalid2) {
99824
+ console.warn("[SelectionOverlay] Suppressing selection render due to large DOM/Layout mismatch", {
99825
+ domStart,
99826
+ domEnd,
99827
+ rectStart: corrected[0],
99828
+ rectEnd: corrected[corrected.length - 1]
99829
+ });
99830
+ return [];
99831
+ }
99832
+ return corrected;
99344
99833
  };
99345
99834
  renderCellSelectionOverlay_fn = function(selection, layout) {
99346
99835
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
@@ -99624,7 +100113,7 @@ ${l}
99624
100113
  return [];
99625
100114
  }
99626
100115
  if (!bodyLayout) return [];
99627
- const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to) ?? [];
100116
+ const rects = selectionToRects(context.layout, context.blocks, context.measures, from2, to, void 0) ?? [];
99628
100117
  const headerPageHeight = context.layout.pageSize?.h ?? context.region.height ?? 1;
99629
100118
  const bodyPageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
99630
100119
  return rects.map((rect) => {
@@ -100091,7 +100580,14 @@ ${l}
100091
100580
  if (!layout || !selection) {
100092
100581
  return 0;
100093
100582
  }
100094
- const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, selection.from, selection.to) ?? [];
100583
+ const rects = selectionToRects(
100584
+ layout,
100585
+ __privateGet$1(this, _layoutState).blocks,
100586
+ __privateGet$1(this, _layoutState).measures,
100587
+ selection.from,
100588
+ selection.to,
100589
+ __privateGet$1(this, _pageGeometryHelper) ?? void 0
100590
+ ) ?? [];
100095
100591
  if (rects.length > 0) {
100096
100592
  return rects[0]?.pageIndex ?? 0;
100097
100593
  }
@@ -105523,14 +106019,19 @@ ${l}
105523
106019
  }
105524
106020
  return cellType.createAndFill();
105525
106021
  };
105526
- const createTableBorders = ({ size: size2 = 0.66665, color: color2 = "#000000" } = {}) => {
106022
+ const createTableBorders = (borderSpec = {}) => {
106023
+ borderSpec = {
106024
+ size: 0.66665,
106025
+ color: "#000000",
106026
+ ...borderSpec
106027
+ };
105527
106028
  return {
105528
- top: { size: size2, color: color2 },
105529
- left: { size: size2, color: color2 },
105530
- bottom: { size: size2, color: color2 },
105531
- right: { size: size2, color: color2 },
105532
- insideH: { size: size2, color: color2 },
105533
- insideV: { size: size2, color: color2 }
106029
+ top: borderSpec,
106030
+ left: borderSpec,
106031
+ bottom: borderSpec,
106032
+ right: borderSpec,
106033
+ insideH: borderSpec,
106034
+ insideV: borderSpec
105534
106035
  };
105535
106036
  };
105536
106037
  const createTable = (schema, rowsCount, colsCount, withHeaderRow, cellContent = null) => {
@@ -105658,12 +106159,17 @@ ${l}
105658
106159
  editor.commands.deleteTable();
105659
106160
  return true;
105660
106161
  };
105661
- const createCellBorders = ({ size: size2 = 0.66665, color: color2 = "#000000" } = {}) => {
106162
+ const createCellBorders = (borderSpec = {}) => {
106163
+ borderSpec = {
106164
+ size: 0.66665,
106165
+ color: "#000000",
106166
+ ...borderSpec
106167
+ };
105662
106168
  return {
105663
- top: { size: size2, color: color2 },
105664
- left: { size: size2, color: color2 },
105665
- bottom: { size: size2, color: color2 },
105666
- right: { size: size2, color: color2 }
106169
+ top: borderSpec,
106170
+ left: borderSpec,
106171
+ bottom: borderSpec,
106172
+ right: borderSpec
105667
106173
  };
105668
106174
  };
105669
106175
  function cellAround($pos) {
@@ -106430,13 +106936,20 @@ ${l}
106430
106936
  if (["tableCell", "tableHeader"].includes(node2.type.name)) {
106431
106937
  tr.setNodeMarkup(pos, void 0, {
106432
106938
  ...node2.attrs,
106433
- borders: createCellBorders({ size: 0 })
106939
+ borders: createCellBorders({ size: 0, space: 0, val: "none", color: "auto" })
106434
106940
  });
106435
106941
  }
106436
106942
  });
106437
106943
  tr.setNodeMarkup(table2.pos, void 0, {
106438
106944
  ...table2.node.attrs,
106439
- borders: createTableBorders({ size: 0 })
106945
+ borders: createTableBorders({ size: 0 }),
106946
+ // TODO: This works around the issue that table borders are duplicated between
106947
+ // the attributes of the table and the tableProperties attribute.
106948
+ // This can be removed when the redundancy is eliminated.
106949
+ tableProperties: {
106950
+ ...table2.node.attrs.tableProperties,
106951
+ borders: createTableBorders({ size: 0, space: 0, val: "none", color: "auto" })
106952
+ }
106440
106953
  });
106441
106954
  return true;
106442
106955
  }
@@ -130438,7 +130951,7 @@ ${style2}
130438
130951
  }
130439
130952
  },
130440
130953
  {
130441
- label: toolbarTexts2.transparentBorders,
130954
+ label: toolbarTexts2.removeBorders,
130442
130955
  command: "deleteCellAndTableBorders",
130443
130956
  icon: toolbarIcons2.deleteBorders,
130444
130957
  bottomBorder: true,
@@ -131019,7 +131532,7 @@ ${style2}
131019
131532
  deleteRow: "Delete row",
131020
131533
  deleteColumn: "Delete column",
131021
131534
  deleteTable: "Delete table",
131022
- transparentBorders: "Transparent borders",
131535
+ removeBorders: "Remove borders",
131023
131536
  mergeCells: "Merge cells",
131024
131537
  splitCell: "Split cell",
131025
131538
  fixTables: "Fix tables",
@@ -132057,7 +132570,7 @@ ${style2}
132057
132570
  deleteRow: "Delete row",
132058
132571
  deleteColumn: "Delete column",
132059
132572
  deleteTable: "Delete table",
132060
- transparentBorders: "Transparent borders",
132573
+ removeBorders: "Remove borders",
132061
132574
  mergeCells: "Merge cells",
132062
132575
  splitCell: "Split cell",
132063
132576
  fixTables: "Fix tables",
@@ -132140,7 +132653,7 @@ ${style2}
132140
132653
  }
132141
132654
  },
132142
132655
  {
132143
- label: TEXTS.transparentBorders,
132656
+ label: TEXTS.removeBorders,
132144
132657
  command: "deleteCellAndTableBorders",
132145
132658
  icon: ICONS.deleteBorders,
132146
132659
  bottomBorder: true,
@@ -152285,7 +152798,7 @@ ${style2}
152285
152798
  this.config.colors = shuffleArray(this.config.colors);
152286
152799
  this.userColorMap = /* @__PURE__ */ new Map();
152287
152800
  this.colorIndex = 0;
152288
- this.version = "1.0.0-beta.100";
152801
+ this.version = "1.0.0-beta.102";
152289
152802
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
152290
152803
  this.superdocId = config2.superdocId || v4();
152291
152804
  this.colors = this.config.colors;
@@ -154757,7 +155270,7 @@ ${style2}
154757
155270
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
154758
155271
  );
154759
155272
  }
154760
- const indexBd5TMBeR = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
155273
+ const indexNVrA3URL = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154761
155274
  __proto__: null,
154762
155275
  unified
154763
155276
  }, Symbol.toStringTag, { value: "Module" }));