@harbour-enterprises/superdoc 1.0.0-next.10 → 1.0.0-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-CZG4udaT.es.js → PdfViewer-DmfOe_Pf.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-B9LcTIm2.cjs → PdfViewer-w6pLbkxf.cjs} +1 -1
  3. package/dist/chunks/{index-4FiyZ-0E.cjs → index-DCu_3jpz.cjs} +3 -3
  4. package/dist/chunks/{index-1n6qegaQ.es.js → index-DSLlUITa.es.js} +3 -3
  5. package/dist/chunks/{index-DdTDm9oI-Duiy8M_G.cjs → index-lMJbwm6b-B4MxvqkR.cjs} +1 -1
  6. package/dist/chunks/{index-DdTDm9oI-BXzE00pk.es.js → index-lMJbwm6b-l7bjUagi.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-BQQuazyp.cjs → super-editor.es-CYIzx8D9.cjs} +589 -122
  8. package/dist/chunks/{super-editor.es-DKr759cY.es.js → super-editor.es-ajKYblrs.es.js} +589 -122
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-BavE2jnW.js → converter-Bf6IlS43.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-CY4M19qa.js → docx-zipper-16dfai0y.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-Cslr04KI.js → editor-DJbi9-qr.js} +619 -123
  13. package/dist/super-editor/chunks/{index-DdTDm9oI.js → index-lMJbwm6b.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-Zdgn--Js.js → toolbar-DpmycQmV.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +591 -124
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42428,7 +42428,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42428
42428
  static getStoredSuperdocVersion(docx) {
42429
42429
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42430
42430
  }
42431
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-next.10") {
42431
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-next.12") {
42432
42432
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42433
42433
  }
42434
42434
  /**
@@ -53597,7 +53597,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53597
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);
53598
53598
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53599
53599
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
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, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _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, _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, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _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, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_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, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _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, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_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, _currentEpoch, _mapsByFromEpoch, _maxEpochsToKeep, _EpochPositionMapper_instances, pruneByCurrentEpoch_fn, _entries, _windowRoot, _getPainterHost, _onRebuild, _observer, _rebuildScheduled, _rebuildRafId, _docEpoch, _layoutEpoch, _layoutUpdating, _pending, _scheduled, _rafHandle, _scheduler, _SelectionSyncCoordinator_instances, isSafeToRender_fn, maybeSchedule_fn, cancelScheduledRender_fn, _windowRoot2, _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, _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, _selectionSync, _remoteCursorUpdateScheduled, _epochMapper, _layoutEpoch2, _domPositionIndex, _domIndexObserverManager, _debugLastPointer, _debugLastHit, _pendingMarginClick, _rafHandle2, _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, _a11ySelectionAnnounceTimeout, _a11yLastAnnouncedSelectionKey, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _dragAnchorPageIndex, _isDragging, _dragExtensionMode, _dragLastPointer, _dragLastRawHit, _dragUsedPageNotMountedFallback, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, wrapHiddenEditorFocus_fn, collectCommentPositions_fn, updateSelectionDebugHud_fn, computePendingMarginClick_fn, aggregateLayoutBounds_fn, rebuildDomPositionIndex_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_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, _handlePointerMove, _handlePointerLeave, _handleVisibleHostFocusIn, _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, syncHiddenEditorA11yAttributes_fn, scheduleA11ySelectionAnnouncement_fn, announceSelectionNow_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, isSelectionAwareVirtualizationEnabled_fn, updateSelectionVirtualizationPins_fn, finalizeDragSelectionWithDom_fn, scrollPageIntoView_fn, waitForPageMount_fn, getEffectivePageGap_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderCellSelectionOverlay_fn, renderHoverRegion_fn, clearHoverRegion_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, applyZoom_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeSelectionRectsFromDom_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_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;
53601
53601
  var GOOD_LEAF_SIZE = 200;
53602
53602
  var RopeSequence = function RopeSequence2() {
53603
53603
  };
@@ -65842,7 +65842,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65842
65842
  const onlyInputTypeMeta = ["inputType", "uiEvent", "paste", "pointer"];
65843
65843
  const notAllowedMeta = ["historyUndo", "historyRedo", "acceptReject"];
65844
65844
  const isProgrammaticInput = tr.getMeta("inputType") === "programmatic";
65845
- if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta2) => onlyInputTypeMeta.includes(meta2)) && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
65845
+ const ySyncMeta = tr.getMeta(ySyncPluginKey);
65846
+ const allowedMeta = /* @__PURE__ */ new Set([...onlyInputTypeMeta, ySyncPluginKey.key]);
65847
+ const hasDisallowedMeta = tr.meta && Object.keys(tr.meta).some((meta2) => !allowedMeta.has(meta2));
65848
+ if (ySyncMeta?.isChangeOrigin || // Skip Yjs-origin transactions (remote/rehydration).
65849
+ !tr.steps.length || hasDisallowedMeta && !isProgrammaticInput || notAllowedMeta.includes(tr.getMeta("inputType")) || tr.getMeta(CommentsPluginKey)) {
65846
65850
  return tr;
65847
65851
  }
65848
65852
  const newTr = state2.tr;
@@ -67511,7 +67515,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67511
67515
  const shouldSkipNodeView = (editor) => {
67512
67516
  return isHeadless(editor);
67513
67517
  };
67514
- const summaryVersion = "1.0.0-next.10";
67518
+ const summaryVersion = "1.0.0-next.12";
67515
67519
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67516
67520
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67517
67521
  function mapAttributes(attrs) {
@@ -68300,7 +68304,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68300
68304
  { default: remarkStringify2 },
68301
68305
  { default: remarkGfm2 }
68302
68306
  ] = await Promise.all([
68303
- Promise.resolve().then(() => indexDdTDm9oI),
68307
+ Promise.resolve().then(() => indexLMJbwm6b),
68304
68308
  Promise.resolve().then(() => indexDRCvimau),
68305
68309
  Promise.resolve().then(() => indexC_x_N6Uh),
68306
68310
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68505,7 +68509,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68505
68509
  * Process collaboration migrations
68506
68510
  */
68507
68511
  processCollaborationMigrations() {
68508
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.10");
68512
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-next.12");
68509
68513
  if (!this.options.ydoc) return;
68510
68514
  const metaMap = this.options.ydoc.getMap("meta");
68511
68515
  let docVersion = metaMap.get("version");
@@ -79504,6 +79508,86 @@ ${l}
79504
79508
  }
79505
79509
  };
79506
79510
  };
79511
+ const DEFAULT_CONFIG = {
79512
+ logLevel: "off",
79513
+ hud: false,
79514
+ dumpRects: false,
79515
+ disableRectDedupe: false
79516
+ };
79517
+ const levelOrder = {
79518
+ error: 0,
79519
+ warn: 1,
79520
+ info: 2,
79521
+ verbose: 3
79522
+ };
79523
+ function getSelectionDebugConfig() {
79524
+ var _a2;
79525
+ if (typeof window === "undefined") {
79526
+ return DEFAULT_CONFIG;
79527
+ }
79528
+ window.superdocDebug ?? (window.superdocDebug = {});
79529
+ (_a2 = window.superdocDebug).selection ?? (_a2.selection = {});
79530
+ const cfg = window.superdocDebug.selection;
79531
+ return {
79532
+ logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
79533
+ hud: cfg.hud ?? DEFAULT_CONFIG.hud,
79534
+ dumpRects: cfg.dumpRects ?? DEFAULT_CONFIG.dumpRects,
79535
+ disableRectDedupe: cfg.disableRectDedupe ?? DEFAULT_CONFIG.disableRectDedupe
79536
+ };
79537
+ }
79538
+ function debugLog(level, message, data) {
79539
+ const cfg = getSelectionDebugConfig();
79540
+ if (cfg.logLevel === "off") return;
79541
+ if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
79542
+ const prefix2 = "[Selection]";
79543
+ if (data) {
79544
+ console.log(prefix2, message, data);
79545
+ } else {
79546
+ console.log(prefix2, message);
79547
+ }
79548
+ }
79549
+ const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
79550
+ function updateSelectionDebugHud(host, state2) {
79551
+ const cfg = getSelectionDebugConfig();
79552
+ const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
79553
+ if (!doc2) return;
79554
+ const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
79555
+ if (!cfg.hud) {
79556
+ existing?.remove();
79557
+ return;
79558
+ }
79559
+ const hud = existing ?? doc2.createElement("div");
79560
+ hud.setAttribute(HUD_DATA_ATTR, "true");
79561
+ hud.style.position = "absolute";
79562
+ hud.style.top = "8px";
79563
+ hud.style.left = "8px";
79564
+ hud.style.zIndex = "9999";
79565
+ hud.style.maxWidth = "420px";
79566
+ hud.style.padding = "6px 8px";
79567
+ hud.style.borderRadius = "6px";
79568
+ hud.style.background = "rgba(0, 0, 0, 0.72)";
79569
+ hud.style.color = "white";
79570
+ hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
79571
+ hud.style.fontSize = "12px";
79572
+ hud.style.lineHeight = "1.3";
79573
+ hud.style.pointerEvents = "none";
79574
+ hud.style.whiteSpace = "pre";
79575
+ const behind = Math.max(0, state2.docEpoch - state2.layoutEpoch);
79576
+ const selectionText = state2.selection ? `${state2.selection.from}..${state2.selection.to}` : "null";
79577
+ const pointerText = state2.lastPointer ? `${state2.lastPointer.clientX},${state2.lastPointer.clientY} -> ${Math.round(state2.lastPointer.x)},${Math.round(
79578
+ state2.lastPointer.y
79579
+ )}` : "null";
79580
+ const hitText = state2.lastHit ? `${state2.lastHit.source} pos=${state2.lastHit.pos ?? "null"} epoch=${state2.lastHit.layoutEpoch ?? "null"} mapped=${state2.lastHit.mappedPos ?? "null"}` : "null";
79581
+ hud.textContent = [
79582
+ `docEpoch=${state2.docEpoch} layoutEpoch=${state2.layoutEpoch} behind=${behind}`,
79583
+ `selection=${selectionText}`,
79584
+ `pointer=${pointerText}`,
79585
+ `hit=${hitText}`
79586
+ ].join("\n");
79587
+ if (!existing) {
79588
+ host.appendChild(hud);
79589
+ }
79590
+ }
79507
79591
  class DomPositionIndex {
79508
79592
  constructor() {
79509
79593
  __privateAdd$1(this, _entries, []);
@@ -79560,6 +79644,7 @@ ${l}
79560
79644
  }
79561
79645
  for (const node2 of pmNodes) {
79562
79646
  if (node2.classList.contains(DOM_CLASS_NAMES.INLINE_SDT_WRAPPER)) continue;
79647
+ if (node2.closest(".superdoc-page-header, .superdoc-page-footer")) continue;
79563
79648
  if (leafOnly && nonLeaf.has(node2)) continue;
79564
79649
  const pmStart = Number(node2.dataset.pmStart ?? "NaN");
79565
79650
  const pmEnd = Number(node2.dataset.pmEnd ?? "NaN");
@@ -79569,6 +79654,60 @@ ${l}
79569
79654
  }
79570
79655
  entries.sort((a2, b2) => a2.pmStart - b2.pmStart !== 0 ? a2.pmStart - b2.pmStart : a2.pmEnd - b2.pmEnd);
79571
79656
  __privateSet(this, _entries, entries);
79657
+ const isVerbose = getSelectionDebugConfig().logLevel === "verbose";
79658
+ if (isVerbose) {
79659
+ const counts = { total: entries.length, body: 0, header: 0, footer: 0 };
79660
+ const bodySamples = [];
79661
+ const headerSamples = [];
79662
+ const footerSamples = [];
79663
+ for (const entry of entries) {
79664
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
79665
+ const pageIndex = pageEl?.dataset.pageIndex ?? null;
79666
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
79667
+ if (section === "header") {
79668
+ counts.header += 1;
79669
+ if (headerSamples.length < 10) {
79670
+ headerSamples.push({
79671
+ pmStart: entry.pmStart,
79672
+ pmEnd: entry.pmEnd,
79673
+ pageIndex,
79674
+ text: (entry.el.textContent ?? "").slice(0, 40)
79675
+ });
79676
+ }
79677
+ continue;
79678
+ }
79679
+ if (section === "footer") {
79680
+ counts.footer += 1;
79681
+ if (footerSamples.length < 10) {
79682
+ footerSamples.push({
79683
+ pmStart: entry.pmStart,
79684
+ pmEnd: entry.pmEnd,
79685
+ pageIndex,
79686
+ text: (entry.el.textContent ?? "").slice(0, 40)
79687
+ });
79688
+ }
79689
+ continue;
79690
+ }
79691
+ counts.body += 1;
79692
+ if (bodySamples.length < 10) {
79693
+ bodySamples.push({
79694
+ pmStart: entry.pmStart,
79695
+ pmEnd: entry.pmEnd,
79696
+ pageIndex,
79697
+ text: (entry.el.textContent ?? "").slice(0, 40)
79698
+ });
79699
+ }
79700
+ }
79701
+ debugLog(
79702
+ "verbose",
79703
+ `DomPositionIndex: rebuild summary ${JSON.stringify({
79704
+ counts,
79705
+ bodySamples,
79706
+ headerSamples,
79707
+ footerSamples
79708
+ })}`
79709
+ );
79710
+ }
79572
79711
  }
79573
79712
  /**
79574
79713
  * Finds the index entry whose position range contains the given position.
@@ -79818,82 +79957,6 @@ ${l}
79818
79957
  _observer = /* @__PURE__ */ new WeakMap();
79819
79958
  _rebuildScheduled = /* @__PURE__ */ new WeakMap();
79820
79959
  _rebuildRafId = /* @__PURE__ */ new WeakMap();
79821
- const DEFAULT_CONFIG = {
79822
- logLevel: "off",
79823
- hud: false
79824
- };
79825
- const levelOrder = {
79826
- error: 0,
79827
- warn: 1,
79828
- info: 2,
79829
- verbose: 3
79830
- };
79831
- function getSelectionDebugConfig() {
79832
- var _a2;
79833
- if (typeof window === "undefined") {
79834
- return DEFAULT_CONFIG;
79835
- }
79836
- window.superdocDebug ?? (window.superdocDebug = {});
79837
- (_a2 = window.superdocDebug).selection ?? (_a2.selection = {});
79838
- const cfg = window.superdocDebug.selection;
79839
- return {
79840
- logLevel: cfg.logLevel ?? DEFAULT_CONFIG.logLevel,
79841
- hud: cfg.hud ?? DEFAULT_CONFIG.hud
79842
- };
79843
- }
79844
- function debugLog(level, message, data) {
79845
- const cfg = getSelectionDebugConfig();
79846
- if (cfg.logLevel === "off") return;
79847
- if (levelOrder[level] > levelOrder[cfg.logLevel]) return;
79848
- const prefix2 = "[Selection]";
79849
- if (data) {
79850
- console.log(prefix2, message, data);
79851
- } else {
79852
- console.log(prefix2, message);
79853
- }
79854
- }
79855
- const HUD_DATA_ATTR = "data-superdoc-selection-debug-hud";
79856
- function updateSelectionDebugHud(host, state2) {
79857
- const cfg = getSelectionDebugConfig();
79858
- const doc2 = host.ownerDocument ?? (typeof document !== "undefined" ? document : null);
79859
- if (!doc2) return;
79860
- const existing = host.querySelector(`[${HUD_DATA_ATTR}="true"]`);
79861
- if (!cfg.hud) {
79862
- existing?.remove();
79863
- return;
79864
- }
79865
- const hud = existing ?? doc2.createElement("div");
79866
- hud.setAttribute(HUD_DATA_ATTR, "true");
79867
- hud.style.position = "absolute";
79868
- hud.style.top = "8px";
79869
- hud.style.left = "8px";
79870
- hud.style.zIndex = "9999";
79871
- hud.style.maxWidth = "420px";
79872
- hud.style.padding = "6px 8px";
79873
- hud.style.borderRadius = "6px";
79874
- hud.style.background = "rgba(0, 0, 0, 0.72)";
79875
- hud.style.color = "white";
79876
- hud.style.fontFamily = 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
79877
- hud.style.fontSize = "12px";
79878
- hud.style.lineHeight = "1.3";
79879
- hud.style.pointerEvents = "none";
79880
- hud.style.whiteSpace = "pre";
79881
- const behind = Math.max(0, state2.docEpoch - state2.layoutEpoch);
79882
- const selectionText = state2.selection ? `${state2.selection.from}..${state2.selection.to}` : "null";
79883
- const pointerText = state2.lastPointer ? `${state2.lastPointer.clientX},${state2.lastPointer.clientY} -> ${Math.round(state2.lastPointer.x)},${Math.round(
79884
- state2.lastPointer.y
79885
- )}` : "null";
79886
- const hitText = state2.lastHit ? `${state2.lastHit.source} pos=${state2.lastHit.pos ?? "null"} epoch=${state2.lastHit.layoutEpoch ?? "null"} mapped=${state2.lastHit.mappedPos ?? "null"}` : "null";
79887
- hud.textContent = [
79888
- `docEpoch=${state2.docEpoch} layoutEpoch=${state2.layoutEpoch} behind=${behind}`,
79889
- `selection=${selectionText}`,
79890
- `pointer=${pointerText}`,
79891
- `hit=${hitText}`
79892
- ].join("\n");
79893
- if (!existing) {
79894
- host.appendChild(hud);
79895
- }
79896
- }
79897
79960
  function computeSelectionRectsFromDom(options, from2, to) {
79898
79961
  const painterHost = options.painterHost;
79899
79962
  if (!painterHost) return null;
@@ -79914,6 +79977,34 @@ ${l}
79914
79977
  );
79915
79978
  const out = [];
79916
79979
  let rebuiltOnce = false;
79980
+ const debugConfig = getSelectionDebugConfig();
79981
+ const isVerbose = debugConfig.logLevel === "verbose";
79982
+ const dumpRects = isVerbose && debugConfig.dumpRects;
79983
+ const disableRectDedupe = debugConfig.disableRectDedupe;
79984
+ const entryDebugInfo = (entry) => {
79985
+ const pageEl = entry.el.closest(`.${DOM_CLASS_NAMES.PAGE}`);
79986
+ const section = entry.el.closest(".superdoc-page-header") ? "header" : entry.el.closest(".superdoc-page-footer") ? "footer" : "body";
79987
+ return {
79988
+ pmStart: entry.pmStart,
79989
+ pmEnd: entry.pmEnd,
79990
+ pageIndex: pageEl?.dataset.pageIndex ?? null,
79991
+ section,
79992
+ connected: entry.el.isConnected,
79993
+ layoutEpoch: entry.el.dataset.layoutEpoch ?? null,
79994
+ pageEpoch: pageEl?.dataset.layoutEpoch ?? null,
79995
+ text: (entry.el.textContent ?? "").slice(0, 80)
79996
+ };
79997
+ };
79998
+ const rectDebugInfo = (rect) => ({
79999
+ x: rect.x,
80000
+ y: rect.y,
80001
+ width: rect.width,
80002
+ height: rect.height,
80003
+ top: rect.top,
80004
+ left: rect.left,
80005
+ right: rect.right,
80006
+ bottom: rect.bottom
80007
+ });
79917
80008
  for (const pageEl of pageEls) {
79918
80009
  const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
79919
80010
  if (!Number.isFinite(pageIndex)) continue;
@@ -79937,9 +80028,47 @@ ${l}
79937
80028
  if (sliceEntries.length === 0) {
79938
80029
  continue;
79939
80030
  }
80031
+ if (isVerbose) {
80032
+ debugLog(
80033
+ "verbose",
80034
+ `DOM selection rects: slice entries ${JSON.stringify({
80035
+ pageIndex,
80036
+ sliceFrom,
80037
+ sliceTo,
80038
+ entriesCount: sliceEntries.length,
80039
+ entriesPreview: sliceEntries.slice(0, 20).map(entryDebugInfo)
80040
+ })}`
80041
+ );
80042
+ }
79940
80043
  let startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
79941
80044
  let endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
79942
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
80045
+ if (isVerbose) {
80046
+ debugLog(
80047
+ "verbose",
80048
+ `DOM selection rects: boundaries ${JSON.stringify({
80049
+ pageIndex,
80050
+ sliceFrom,
80051
+ sliceTo,
80052
+ start: entryDebugInfo(startEntry),
80053
+ end: entryDebugInfo(endEntry)
80054
+ })}`
80055
+ );
80056
+ }
80057
+ let startContained = pageEl.contains(startEntry.el);
80058
+ let endContained = pageEl.contains(endEntry.el);
80059
+ if (!startContained || !endContained) {
80060
+ if (isVerbose) {
80061
+ debugLog(
80062
+ "verbose",
80063
+ `DOM selection rects: boundary containment ${JSON.stringify({
80064
+ pageIndex,
80065
+ sliceFrom,
80066
+ sliceTo,
80067
+ startContained,
80068
+ endContained
80069
+ })}`
80070
+ );
80071
+ }
79943
80072
  if (!rebuiltOnce) {
79944
80073
  options.rebuildDomPositionIndex();
79945
80074
  rebuiltOnce = true;
@@ -79947,9 +80076,34 @@ ${l}
79947
80076
  if (sliceEntries.length === 0) continue;
79948
80077
  startEntry = options.domPositionIndex.findEntryAtPosition(sliceFrom) ?? sliceEntries[0];
79949
80078
  endEntry = options.domPositionIndex.findEntryAtPosition(sliceTo) ?? sliceEntries[sliceEntries.length - 1];
80079
+ startContained = pageEl.contains(startEntry.el);
80080
+ endContained = pageEl.contains(endEntry.el);
80081
+ if (isVerbose) {
80082
+ debugLog(
80083
+ "verbose",
80084
+ `DOM selection rects: boundary containment after rebuild ${JSON.stringify({
80085
+ pageIndex,
80086
+ sliceFrom,
80087
+ sliceTo,
80088
+ startContained,
80089
+ endContained,
80090
+ start: entryDebugInfo(startEntry),
80091
+ end: entryDebugInfo(endEntry)
80092
+ })}`
80093
+ );
80094
+ }
79950
80095
  }
79951
- if (!pageEl.contains(startEntry.el) || !pageEl.contains(endEntry.el)) {
79952
- debugLog("warn", "DOM selection rects: stale index after rebuild", { pageIndex, sliceFrom, sliceTo });
80096
+ if (!startContained || !endContained) {
80097
+ debugLog(
80098
+ "warn",
80099
+ `DOM selection rects: stale index after rebuild ${JSON.stringify({
80100
+ pageIndex,
80101
+ sliceFrom,
80102
+ sliceTo,
80103
+ start: entryDebugInfo(startEntry),
80104
+ end: entryDebugInfo(endEntry)
80105
+ })}`
80106
+ );
79953
80107
  return null;
79954
80108
  }
79955
80109
  }
@@ -79964,8 +80118,83 @@ ${l}
79964
80118
  }
79965
80119
  let clientRects = [];
79966
80120
  try {
79967
- const rawRects = Array.from(range2.getClientRects());
79968
- clientRects = deduplicateOverlappingRects(rawRects);
80121
+ let rawRects = Array.from(range2.getClientRects());
80122
+ if (dumpRects) {
80123
+ debugLog(
80124
+ "verbose",
80125
+ `DOM selection rects: raw rects ${JSON.stringify({
80126
+ pageIndex,
80127
+ sliceFrom,
80128
+ sliceTo,
80129
+ rects: rawRects.map(rectDebugInfo)
80130
+ })}`
80131
+ );
80132
+ }
80133
+ let missingEntries = null;
80134
+ if (typeof range2.intersectsNode === "function") {
80135
+ for (const entry of sliceEntries) {
80136
+ try {
80137
+ if (!range2.intersectsNode(entry.el)) {
80138
+ missingEntries ?? (missingEntries = []);
80139
+ missingEntries.push(entry);
80140
+ }
80141
+ } catch {
80142
+ }
80143
+ }
80144
+ }
80145
+ if (missingEntries && missingEntries.length > 0) {
80146
+ if (isVerbose) {
80147
+ debugLog(
80148
+ "verbose",
80149
+ `DOM selection rects: range missing entries ${JSON.stringify({
80150
+ pageIndex,
80151
+ sliceFrom,
80152
+ sliceTo,
80153
+ missingCount: missingEntries.length,
80154
+ missingPreview: missingEntries.slice(0, 20).map(entryDebugInfo)
80155
+ })}`
80156
+ );
80157
+ }
80158
+ rawRects = collectClientRectsByLine(doc2, sliceEntries, sliceFrom, sliceTo);
80159
+ if (dumpRects) {
80160
+ debugLog(
80161
+ "verbose",
80162
+ `DOM selection rects: fallback raw rects ${JSON.stringify({
80163
+ pageIndex,
80164
+ sliceFrom,
80165
+ sliceTo,
80166
+ rects: rawRects.map(rectDebugInfo)
80167
+ })}`
80168
+ );
80169
+ }
80170
+ }
80171
+ clientRects = disableRectDedupe ? rawRects : deduplicateOverlappingRects(rawRects);
80172
+ if (dumpRects) {
80173
+ debugLog(
80174
+ "verbose",
80175
+ `DOM selection rects: final rects ${JSON.stringify({
80176
+ pageIndex,
80177
+ sliceFrom,
80178
+ sliceTo,
80179
+ dedupeDisabled: disableRectDedupe,
80180
+ rects: clientRects.map(rectDebugInfo)
80181
+ })}`
80182
+ );
80183
+ const nonPositive = clientRects.filter(
80184
+ (rect) => !Number.isFinite(rect.width) || !Number.isFinite(rect.height) || rect.width <= 0 || rect.height <= 0
80185
+ );
80186
+ if (nonPositive.length > 0) {
80187
+ debugLog(
80188
+ "verbose",
80189
+ `DOM selection rects: non-positive rects ${JSON.stringify({
80190
+ pageIndex,
80191
+ sliceFrom,
80192
+ sliceTo,
80193
+ rects: nonPositive.map(rectDebugInfo)
80194
+ })}`
80195
+ );
80196
+ }
80197
+ }
79969
80198
  } catch (error) {
79970
80199
  debugLog("warn", "DOM selection rects: getClientRects failed", { error: String(error) });
79971
80200
  return null;
@@ -79989,6 +80218,57 @@ ${l}
79989
80218
  }
79990
80219
  return out;
79991
80220
  }
80221
+ function collectClientRectsByLine(doc2, entries, sliceFrom, sliceTo) {
80222
+ const rects = [];
80223
+ const lineMap = /* @__PURE__ */ new Map();
80224
+ const looseEntries = [];
80225
+ for (const entry of entries) {
80226
+ const lineEl = entry.el.closest(".superdoc-line");
80227
+ if (!lineEl) {
80228
+ looseEntries.push(entry);
80229
+ continue;
80230
+ }
80231
+ const list2 = lineMap.get(lineEl);
80232
+ if (list2) {
80233
+ list2.push(entry);
80234
+ } else {
80235
+ lineMap.set(lineEl, [entry]);
80236
+ }
80237
+ }
80238
+ for (const [, lineEntries] of lineMap) {
80239
+ lineEntries.sort((a2, b2) => a2.pmStart - b2.pmStart !== 0 ? a2.pmStart - b2.pmStart : a2.pmEnd - b2.pmEnd);
80240
+ const linePmStart = lineEntries[0]?.pmStart ?? Infinity;
80241
+ const linePmEnd = lineEntries[lineEntries.length - 1]?.pmEnd ?? -Infinity;
80242
+ if (!Number.isFinite(linePmStart) || !Number.isFinite(linePmEnd) || linePmEnd <= linePmStart) continue;
80243
+ const lineFrom = Math.max(sliceFrom, linePmStart);
80244
+ const lineTo = Math.min(sliceTo, linePmEnd);
80245
+ if (lineFrom >= lineTo) continue;
80246
+ const startEntry = lineEntries.find((entry) => lineFrom >= entry.pmStart && lineFrom <= entry.pmEnd) ?? lineEntries[0];
80247
+ const endEntry = lineEntries.find((entry) => lineTo >= entry.pmStart && lineTo <= entry.pmEnd) ?? lineEntries[lineEntries.length - 1];
80248
+ const range2 = doc2.createRange();
80249
+ try {
80250
+ if (!setDomRangeStart(range2, startEntry, lineFrom)) continue;
80251
+ if (!setDomRangeEnd(range2, endEntry, lineTo)) continue;
80252
+ } catch {
80253
+ continue;
80254
+ }
80255
+ rects.push(...Array.from(range2.getClientRects()));
80256
+ }
80257
+ for (const entry of looseEntries) {
80258
+ const entryFrom = Math.max(sliceFrom, entry.pmStart);
80259
+ const entryTo = Math.min(sliceTo, entry.pmEnd);
80260
+ if (entryFrom >= entryTo) continue;
80261
+ const range2 = doc2.createRange();
80262
+ try {
80263
+ if (!setDomRangeStart(range2, entry, entryFrom)) continue;
80264
+ if (!setDomRangeEnd(range2, entry, entryTo)) continue;
80265
+ } catch {
80266
+ continue;
80267
+ }
80268
+ rects.push(...Array.from(range2.getClientRects()));
80269
+ }
80270
+ return rects;
80271
+ }
79992
80272
  function setDomRangeStart(range2, entry, pos) {
79993
80273
  const el = entry.el;
79994
80274
  const pmStart = entry.pmStart;
@@ -80098,31 +80378,69 @@ ${l}
80098
80378
  return a2.x - b2.x;
80099
80379
  });
80100
80380
  const result = [];
80101
- let i2 = 0;
80102
- while (i2 < sorted.length) {
80103
- const current = sorted[i2];
80104
- let best = current;
80105
- let j2 = i2 + 1;
80106
- while (j2 < sorted.length) {
80107
- const next2 = sorted[j2];
80108
- const yOverlap = Math.abs(next2.y - current.y) < Y_SAME_LINE_THRESHOLD_PX;
80109
- const xOverlapStart = Math.max(current.x, next2.x);
80110
- const xOverlapEnd = Math.min(current.x + current.width, next2.x + next2.width);
80111
- const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
80112
- const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
80113
- const minWidth = Math.min(current.width, next2.width);
80114
- const significantOverlap = minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
80115
- if (yOverlap && hasHorizontalOverlap && significantOverlap) {
80116
- if (next2.height < best.height) {
80117
- best = next2;
80118
- }
80119
- j2++;
80120
- } else {
80121
- break;
80381
+ const groups = [];
80382
+ let currentGroup = [];
80383
+ for (const rect of sorted) {
80384
+ if (currentGroup.length === 0) {
80385
+ currentGroup.push(rect);
80386
+ continue;
80387
+ }
80388
+ const groupY = currentGroup[0].y;
80389
+ if (Math.abs(rect.y - groupY) <= Y_SAME_LINE_THRESHOLD_PX) {
80390
+ currentGroup.push(rect);
80391
+ } else {
80392
+ groups.push(currentGroup);
80393
+ currentGroup = [rect];
80394
+ }
80395
+ }
80396
+ if (currentGroup.length > 0) {
80397
+ groups.push(currentGroup);
80398
+ }
80399
+ const SIZE_EPS_PX = 0.5;
80400
+ const X_DUPLICATE_EPS_PX = 1;
80401
+ const hasSignificantOverlap = (a2, b2) => {
80402
+ const xOverlapStart = Math.max(a2.x, b2.x);
80403
+ const xOverlapEnd = Math.min(a2.x + a2.width, b2.x + b2.width);
80404
+ const hasHorizontalOverlap = xOverlapEnd > xOverlapStart;
80405
+ if (!hasHorizontalOverlap) return false;
80406
+ const overlapWidth = Math.max(0, xOverlapEnd - xOverlapStart);
80407
+ const minWidth = Math.min(a2.width, b2.width);
80408
+ return minWidth > 0 && overlapWidth / minWidth > HORIZONTAL_OVERLAP_THRESHOLD;
80409
+ };
80410
+ const isLargerRect = (a2, b2) => {
80411
+ return a2.width > b2.width + SIZE_EPS_PX || a2.height > b2.height + SIZE_EPS_PX;
80412
+ };
80413
+ for (const group of groups) {
80414
+ const unique2 = [];
80415
+ for (const rect of group) {
80416
+ const isDuplicate = unique2.some((existing) => {
80417
+ const xClose = Math.abs(existing.x - rect.x) <= X_DUPLICATE_EPS_PX;
80418
+ const yClose = Math.abs(existing.y - rect.y) <= Y_SAME_LINE_THRESHOLD_PX;
80419
+ const widthClose = Math.abs(existing.width - rect.width) <= SIZE_EPS_PX;
80420
+ const heightClose = Math.abs(existing.height - rect.height) <= SIZE_EPS_PX;
80421
+ return xClose && yClose && widthClose && heightClose;
80422
+ });
80423
+ if (!isDuplicate) {
80424
+ unique2.push(rect);
80122
80425
  }
80123
80426
  }
80124
- result.push(best);
80125
- i2 = j2;
80427
+ if (unique2.length <= 1) {
80428
+ result.push(...unique2);
80429
+ continue;
80430
+ }
80431
+ const containers = /* @__PURE__ */ new Set();
80432
+ for (const rect of unique2) {
80433
+ for (const other of unique2) {
80434
+ if (rect === other) continue;
80435
+ if (!hasSignificantOverlap(rect, other)) continue;
80436
+ if (isLargerRect(rect, other)) {
80437
+ containers.add(rect);
80438
+ break;
80439
+ }
80440
+ }
80441
+ }
80442
+ const filtered = unique2.filter((rect) => !containers.has(rect));
80443
+ result.push(...filtered.length > 0 ? filtered : unique2);
80126
80444
  }
80127
80445
  return result;
80128
80446
  }
@@ -80246,10 +80564,11 @@ ${l}
80246
80564
  function createHiddenHost(doc2, widthPx) {
80247
80565
  const host = doc2.createElement("div");
80248
80566
  host.className = "presentation-editor__hidden-host";
80249
- host.style.position = "absolute";
80567
+ host.style.position = "fixed";
80250
80568
  host.style.left = "-9999px";
80251
80569
  host.style.top = "0";
80252
80570
  host.style.width = `${widthPx}px`;
80571
+ host.style.setProperty("overflow-anchor", "none");
80253
80572
  host.style.pointerEvents = "none";
80254
80573
  host.style.opacity = "0";
80255
80574
  host.style.zIndex = "-1";
@@ -80723,7 +81042,8 @@ ${l}
80723
81042
  });
80724
81043
  let hitChain = [];
80725
81044
  const doc2 = document;
80726
- if (typeof doc2.elementsFromPoint === "function") {
81045
+ const hasElementsFromPoint = typeof doc2.elementsFromPoint === "function";
81046
+ if (hasElementsFromPoint) {
80727
81047
  try {
80728
81048
  hitChain = doc2.elementsFromPoint(viewX, viewY) ?? [];
80729
81049
  } catch {
@@ -80769,11 +81089,14 @@ ${l}
80769
81089
  log("All fragments on page:", JSON.stringify(fragmentData, null, 2));
80770
81090
  const fragmentEl = hitChain.find((el) => el.classList?.contains?.(CLASS_NAMES.fragment));
80771
81091
  if (!fragmentEl) {
81092
+ if (hasElementsFromPoint) {
81093
+ return null;
81094
+ }
80772
81095
  const fallbackFragment = pageEl.querySelector(`.${CLASS_NAMES.fragment}`);
80773
81096
  if (!fallbackFragment) {
80774
81097
  return null;
80775
81098
  }
80776
- log("Using fallback fragment:", {
81099
+ log("Using fallback fragment (no elementsFromPoint):", {
80777
81100
  blockId: fallbackFragment.dataset.blockId,
80778
81101
  pmStart: fallbackFragment.dataset.pmStart,
80779
81102
  pmEnd: fallbackFragment.dataset.pmEnd
@@ -99580,7 +99903,7 @@ ${l}
99580
99903
  }
99581
99904
  }
99582
99905
  }
99583
- editorDom2.focus({ preventScroll: true });
99906
+ editorDom2.focus();
99584
99907
  __privateGet$1(this, _editor3).view?.focus();
99585
99908
  __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
99586
99909
  return;
@@ -99647,7 +99970,7 @@ ${l}
99647
99970
  }
99648
99971
  }
99649
99972
  }
99650
- editorDom2.focus({ preventScroll: true });
99973
+ editorDom2.focus();
99651
99974
  __privateGet$1(this, _editor3).view?.focus();
99652
99975
  __privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
99653
99976
  }
@@ -99770,7 +100093,7 @@ ${l}
99770
100093
  }
99771
100094
  const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
99772
100095
  if (editorDom2) {
99773
- editorDom2.focus({ preventScroll: true });
100096
+ editorDom2.focus();
99774
100097
  __privateGet$1(this, _editor3).view?.focus();
99775
100098
  }
99776
100099
  return;
@@ -99803,6 +100126,25 @@ ${l}
99803
100126
  } else {
99804
100127
  __privateSet(this, _dragExtensionMode, "char");
99805
100128
  }
100129
+ debugLog(
100130
+ "verbose",
100131
+ `Drag selection start ${JSON.stringify({
100132
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: x2, y: y2 },
100133
+ clickDepth,
100134
+ extensionMode: __privateGet$1(this, _dragExtensionMode),
100135
+ anchor: __privateGet$1(this, _dragAnchor),
100136
+ anchorPageIndex: __privateGet$1(this, _dragAnchorPageIndex),
100137
+ rawHit: rawHit ? {
100138
+ pos: rawHit.pos,
100139
+ pageIndex: rawHit.pageIndex,
100140
+ blockId: rawHit.blockId,
100141
+ lineIndex: rawHit.lineIndex,
100142
+ layoutEpoch: rawHit.layoutEpoch
100143
+ } : null,
100144
+ mapped: mapped ? mapped.ok ? { ok: true, pos: mapped.pos, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : { ok: false, reason: mapped.reason, fromEpoch: mapped.fromEpoch, toEpoch: mapped.toEpoch } : null,
100145
+ hit: hit ? { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch } : null
100146
+ })}`
100147
+ );
99806
100148
  if (typeof __privateGet$1(this, _viewportHost).setPointerCapture === "function") {
99807
100149
  __privateGet$1(this, _viewportHost).setPointerCapture(event.pointerId);
99808
100150
  }
@@ -99830,7 +100172,7 @@ ${l}
99830
100172
  if (!editorDom) {
99831
100173
  return;
99832
100174
  }
99833
- editorDom.focus({ preventScroll: true });
100175
+ editorDom.focus();
99834
100176
  __privateGet$1(this, _editor3).view?.focus();
99835
100177
  });
99836
100178
  __privateAdd$1(this, _handlePointerMove, (event) => {
@@ -99839,6 +100181,8 @@ ${l}
99839
100181
  if (!normalized) return;
99840
100182
  if (__privateGet$1(this, _isDragging) && __privateGet$1(this, _dragAnchor) !== null && event.buttons & 1) {
99841
100183
  __privateSet(this, _pendingMarginClick, null);
100184
+ const prevPointer = __privateGet$1(this, _dragLastPointer);
100185
+ const prevRawHit = __privateGet$1(this, _dragLastRawHit);
99842
100186
  __privateSet(this, _dragLastPointer, { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y });
99843
100187
  const rawHit = clickToPosition(
99844
100188
  __privateGet$1(this, _layoutState).layout,
@@ -99850,7 +100194,17 @@ ${l}
99850
100194
  event.clientY,
99851
100195
  __privateGet$1(this, _pageGeometryHelper) ?? void 0
99852
100196
  );
99853
- if (!rawHit) return;
100197
+ if (!rawHit) {
100198
+ debugLog(
100199
+ "verbose",
100200
+ `Drag selection update (no hit) ${JSON.stringify({
100201
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
100202
+ prevPointer,
100203
+ anchor: __privateGet$1(this, _dragAnchor)
100204
+ })}`
100205
+ );
100206
+ return;
100207
+ }
99854
100208
  const doc22 = __privateGet$1(this, _editor3).state?.doc;
99855
100209
  if (!doc22) return;
99856
100210
  __privateSet(this, _dragLastRawHit, rawHit);
@@ -99863,6 +100217,27 @@ ${l}
99863
100217
  const mappedHead = __privateGet$1(this, _epochMapper).mapPosFromLayoutToCurrentDetailed(rawHit.pos, rawHit.layoutEpoch, 1);
99864
100218
  if (!mappedHead.ok) {
99865
100219
  debugLog("warn", "drag mapping failed", mappedHead);
100220
+ debugLog(
100221
+ "verbose",
100222
+ `Drag selection update (map failed) ${JSON.stringify({
100223
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
100224
+ prevPointer,
100225
+ anchor: __privateGet$1(this, _dragAnchor),
100226
+ rawHit: {
100227
+ pos: rawHit.pos,
100228
+ pageIndex: rawHit.pageIndex,
100229
+ blockId: rawHit.blockId,
100230
+ lineIndex: rawHit.lineIndex,
100231
+ layoutEpoch: rawHit.layoutEpoch
100232
+ },
100233
+ mapped: {
100234
+ ok: false,
100235
+ reason: mappedHead.reason,
100236
+ fromEpoch: mappedHead.fromEpoch,
100237
+ toEpoch: mappedHead.toEpoch
100238
+ }
100239
+ })}`
100240
+ );
99866
100241
  return;
99867
100242
  }
99868
100243
  const hit = {
@@ -99877,6 +100252,41 @@ ${l}
99877
100252
  mappedPos: hit.pos
99878
100253
  });
99879
100254
  __privateMethod$1(this, _PresentationEditor_instances, updateSelectionDebugHud_fn).call(this);
100255
+ const anchor = __privateGet$1(this, _dragAnchor);
100256
+ const head = hit.pos;
100257
+ const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
100258
+ debugLog(
100259
+ "verbose",
100260
+ `Drag selection update ${JSON.stringify({
100261
+ pointer: { clientX: event.clientX, clientY: event.clientY, x: normalized.x, y: normalized.y },
100262
+ prevPointer,
100263
+ rawHit: {
100264
+ pos: rawHit.pos,
100265
+ pageIndex: rawHit.pageIndex,
100266
+ blockId: rawHit.blockId,
100267
+ lineIndex: rawHit.lineIndex,
100268
+ layoutEpoch: rawHit.layoutEpoch
100269
+ },
100270
+ prevRawHit: prevRawHit ? {
100271
+ pos: prevRawHit.pos,
100272
+ pageIndex: prevRawHit.pageIndex,
100273
+ blockId: prevRawHit.blockId,
100274
+ lineIndex: prevRawHit.lineIndex,
100275
+ layoutEpoch: prevRawHit.layoutEpoch
100276
+ } : null,
100277
+ mappedHead: { pos: mappedHead.pos, fromEpoch: mappedHead.fromEpoch, toEpoch: mappedHead.toEpoch },
100278
+ hit: { pos: hit.pos, pageIndex: hit.pageIndex, layoutEpoch: hit.layoutEpoch },
100279
+ anchor,
100280
+ head,
100281
+ selAnchor,
100282
+ selHead,
100283
+ direction: head >= anchor ? "down" : "up",
100284
+ selectionDirection: selHead >= selAnchor ? "down" : "up",
100285
+ extensionMode: __privateGet$1(this, _dragExtensionMode),
100286
+ hitSource: pageMounted ? "dom" : "geometry",
100287
+ pageMounted
100288
+ })}`
100289
+ );
99880
100290
  const currentTableHit = __privateMethod$1(this, _PresentationEditor_instances, hitTestTable_fn).call(this, normalized.x, normalized.y);
99881
100291
  const shouldUseCellSel = __privateMethod$1(this, _PresentationEditor_instances, shouldUseCellSelection_fn).call(this, currentTableHit);
99882
100292
  if (shouldUseCellSel && __privateGet$1(this, _cellAnchor)) {
@@ -99911,9 +100321,6 @@ ${l}
99911
100321
  return;
99912
100322
  }
99913
100323
  }
99914
- const anchor = __privateGet$1(this, _dragAnchor);
99915
- const head = hit.pos;
99916
- const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
99917
100324
  try {
99918
100325
  const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, selAnchor, selHead));
99919
100326
  __privateGet$1(this, _editor3).view?.dispatch(tr);
@@ -100308,6 +100715,7 @@ ${l}
100308
100715
  editorProps: normalizedEditorProps,
100309
100716
  documentMode: __privateGet$1(this, _documentMode)
100310
100717
  }));
100718
+ __privateMethod$1(this, _PresentationEditor_instances, wrapHiddenEditorFocus_fn).call(this);
100311
100719
  __privateGet$1(this, _editor3).presentationEditor = this;
100312
100720
  __privateGet$1(this, _editor3)._presentationEditor = this;
100313
100721
  __privateMethod$1(this, _PresentationEditor_instances, syncHiddenEditorA11yAttributes_fn).call(this);
@@ -101507,6 +101915,65 @@ ${l}
101507
101915
  _lastRemoteCursorRenderTime = /* @__PURE__ */ new WeakMap();
101508
101916
  _remoteCursorThrottleTimeout = /* @__PURE__ */ new WeakMap();
101509
101917
  _PresentationEditor_instances = /* @__PURE__ */ new WeakSet();
101918
+ wrapHiddenEditorFocus_fn = function() {
101919
+ const view = __privateGet$1(this, _editor3)?.view;
101920
+ if (!view || !view.dom || typeof view.focus !== "function") {
101921
+ return;
101922
+ }
101923
+ const viewWithFlag = view;
101924
+ if (viewWithFlag.__sdPreventScrollFocus) {
101925
+ return;
101926
+ }
101927
+ const focusFn = view.focus;
101928
+ if (focusFn.mock) {
101929
+ return;
101930
+ }
101931
+ viewWithFlag.__sdPreventScrollFocus = true;
101932
+ const originalFocus = view.focus.bind(view);
101933
+ view.focus = () => {
101934
+ const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView;
101935
+ if (!win) {
101936
+ originalFocus();
101937
+ return;
101938
+ }
101939
+ const beforeX = win.scrollX;
101940
+ const beforeY = win.scrollY;
101941
+ let focused = false;
101942
+ try {
101943
+ view.dom.focus({ preventScroll: true });
101944
+ focused = true;
101945
+ } catch (error) {
101946
+ debugLog("warn", "Hidden editor focus: preventScroll failed", {
101947
+ error: String(error),
101948
+ strategy: "preventScroll"
101949
+ });
101950
+ }
101951
+ if (!focused) {
101952
+ try {
101953
+ view.dom.focus();
101954
+ focused = true;
101955
+ } catch (error) {
101956
+ debugLog("warn", "Hidden editor focus: standard focus failed", {
101957
+ error: String(error),
101958
+ strategy: "standard"
101959
+ });
101960
+ }
101961
+ }
101962
+ if (!focused) {
101963
+ try {
101964
+ originalFocus();
101965
+ } catch (error) {
101966
+ debugLog("error", "Hidden editor focus: all strategies failed", {
101967
+ error: String(error),
101968
+ strategy: "original"
101969
+ });
101970
+ }
101971
+ }
101972
+ if (win.scrollX !== beforeX || win.scrollY !== beforeY) {
101973
+ win.scrollTo(beforeX, beforeY);
101974
+ }
101975
+ };
101976
+ };
101510
101977
  collectCommentPositions_fn = function() {
101511
101978
  return collectCommentPositions(__privateGet$1(this, _editor3)?.state?.doc ?? null, {
101512
101979
  commentMarkName: CommentMarkName,
@@ -101908,7 +102375,7 @@ ${l}
101908
102375
  }
101909
102376
  const editorDom = __privateGet$1(this, _editor3).view?.dom;
101910
102377
  if (editorDom) {
101911
- editorDom.focus({ preventScroll: true });
102378
+ editorDom.focus();
101912
102379
  __privateGet$1(this, _editor3).view?.focus();
101913
102380
  }
101914
102381
  };
@@ -155898,7 +156365,7 @@ ${style2}
155898
156365
  this.config.colors = shuffleArray(this.config.colors);
155899
156366
  this.userColorMap = /* @__PURE__ */ new Map();
155900
156367
  this.colorIndex = 0;
155901
- this.version = "1.0.0-next.10";
156368
+ this.version = "1.0.0-next.12";
155902
156369
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
155903
156370
  this.superdocId = config2.superdocId || v4();
155904
156371
  this.colors = this.config.colors;
@@ -158371,7 +158838,7 @@ ${style2}
158371
158838
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
158372
158839
  );
158373
158840
  }
158374
- const indexDdTDm9oI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
158841
+ const indexLMJbwm6b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
158375
158842
  __proto__: null,
158376
158843
  unified
158377
158844
  }, Symbol.toStringTag, { value: "Module" }));