superdoc 1.0.0-beta.65 → 1.0.0-beta.67

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-CPtbSOs5.cjs → PdfViewer-DTK306FZ.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-CqHxrRM3.es.js → PdfViewer-P0cvxvjh.es.js} +1 -1
  3. package/dist/chunks/{index-DWJXw-IX.cjs → index-BNGG0zf5.cjs} +3 -3
  4. package/dist/chunks/{index-YSWS94Jr-BeHINTZ9.es.js → index-Cixgd5bX-39fIJYpL.es.js} +1 -1
  5. package/dist/chunks/{index-YSWS94Jr-C7xFStTB.cjs → index-Cixgd5bX-ByqITVZq.cjs} +1 -1
  6. package/dist/chunks/{index-BUvQNe-T.es.js → index-U-bzTPNb.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-DaC-R5gx.es.js → super-editor.es-CIPQg4rG.es.js} +386 -158
  8. package/dist/chunks/{super-editor.es-BHjskxiY.cjs → super-editor.es-DKbuo7ju.cjs} +386 -158
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DIAStmht.js → converter-BLNx019v.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-DK-wWQD9.js → docx-zipper-BfQBQQz_.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CxKPNxhs.js → editor-5RSp-DNd.js} +536 -97
  13. package/dist/super-editor/chunks/{index-YSWS94Jr.js → index-Cixgd5bX.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-D7ZHiSKZ.js → toolbar-Db_-z4Fa.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 +388 -160
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42309,7 +42309,7 @@ const _SuperConverter = class _SuperConverter2 {
42309
42309
  static getStoredSuperdocVersion(docx) {
42310
42310
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42311
42311
  }
42312
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.65") {
42312
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.67") {
42313
42313
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42314
42314
  }
42315
42315
  /**
@@ -45621,7 +45621,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45621
45621
  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);
45622
45622
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45623
45623
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45624
- 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, _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, 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, 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, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
45624
+ 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, _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, 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, 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;
45625
45625
  var GOOD_LEAF_SIZE = 200;
45626
45626
  var RopeSequence = function RopeSequence2() {
45627
45627
  };
@@ -59498,7 +59498,7 @@ const isHeadless = (editor) => {
59498
59498
  const shouldSkipNodeView = (editor) => {
59499
59499
  return isHeadless(editor);
59500
59500
  };
59501
- const summaryVersion = "1.0.0-beta.65";
59501
+ const summaryVersion = "1.0.0-beta.67";
59502
59502
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59503
59503
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59504
59504
  function mapAttributes(attrs) {
@@ -60287,7 +60287,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60287
60287
  { default: remarkStringify },
60288
60288
  { default: remarkGfm }
60289
60289
  ] = await Promise.all([
60290
- import("./index-YSWS94Jr-BeHINTZ9.es.js"),
60290
+ import("./index-Cixgd5bX-39fIJYpL.es.js"),
60291
60291
  import("./index-DRCvimau-Cw339678.es.js"),
60292
60292
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60293
60293
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60492,7 +60492,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60492
60492
  * Process collaboration migrations
60493
60493
  */
60494
60494
  processCollaborationMigrations() {
60495
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.65");
60495
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.67");
60496
60496
  if (!this.options.ydoc) return;
60497
60497
  const metaMap = this.options.ydoc.getMap("meta");
60498
60498
  let docVersion = metaMap.get("version");
@@ -67997,6 +67997,7 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
67997
67997
  let measurementCanvas = null;
67998
67998
  let measurementCtx = null;
67999
67999
  const TAB_CHAR_LENGTH = 1;
68000
+ const SPACE_CHARS = /* @__PURE__ */ new Set([" ", " "]);
68000
68001
  const isTabRun$1 = (run2) => run2?.kind === "tab";
68001
68002
  function getMeasurementContext() {
68002
68003
  if (measurementCtx) return measurementCtx;
@@ -68013,6 +68014,41 @@ function getMeasurementContext() {
68013
68014
  }
68014
68015
  return measurementCtx;
68015
68016
  }
68017
+ const countSpaces = (text) => {
68018
+ let spaces = 0;
68019
+ for (let i = 0; i < text.length; i += 1) {
68020
+ if (SPACE_CHARS.has(text[i])) {
68021
+ spaces += 1;
68022
+ }
68023
+ }
68024
+ return spaces;
68025
+ };
68026
+ const getJustifyAdjustment = (block, line, availableWidthOverride) => {
68027
+ if (block.kind !== "paragraph") {
68028
+ return { extraPerSpace: 0, totalSpaces: 0 };
68029
+ }
68030
+ const alignment2 = block.attrs?.alignment;
68031
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68032
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
68033
+ const slack = Math.max(0, availableWidth - line.width);
68034
+ if (alignment2 !== "justify" || hasExplicitPositioning || slack <= 0) {
68035
+ return { extraPerSpace: 0, totalSpaces: 0 };
68036
+ }
68037
+ const runs = sliceRunsForLine$1(block, line);
68038
+ const totalSpaces = runs.reduce((sum, run2) => {
68039
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
68040
+ return sum;
68041
+ }
68042
+ return sum + countSpaces(run2.text ?? "");
68043
+ }, 0);
68044
+ if (totalSpaces <= 0) {
68045
+ return { extraPerSpace: 0, totalSpaces: 0 };
68046
+ }
68047
+ return {
68048
+ extraPerSpace: slack / totalSpaces,
68049
+ totalSpaces
68050
+ };
68051
+ };
68016
68052
  function getRunFontString(run2) {
68017
68053
  if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
68018
68054
  return "normal normal 16px Arial";
@@ -68070,9 +68106,15 @@ function sliceRunsForLine$1(block, line) {
68070
68106
  }
68071
68107
  return result;
68072
68108
  }
68073
- function measureCharacterX(block, line, charOffset) {
68109
+ function measureCharacterX(block, line, charOffset, availableWidthOverride) {
68074
68110
  const ctx2 = getMeasurementContext();
68111
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: if no maxWidth, approximate available width as line width (no slack)
68112
+ line.width;
68113
+ const justify = getJustifyAdjustment(block, line, availableWidth);
68114
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
68115
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
68075
68116
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68117
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
68076
68118
  if (hasExplicitPositioning && line.segments && ctx2) {
68077
68119
  return measureCharacterXSegmentBased(block, line, charOffset, ctx2);
68078
68120
  }
@@ -68087,11 +68129,12 @@ function measureCharacterX(block, line, charOffset) {
68087
68129
  return sum + (run2.text ?? "").length;
68088
68130
  }, 0)
68089
68131
  );
68090
- return charOffset / charsInLine * line.width;
68132
+ return charOffset / charsInLine * renderedLineWidth;
68091
68133
  }
68092
68134
  const runs = sliceRunsForLine$1(block, line);
68093
68135
  let currentX = 0;
68094
68136
  let currentCharOffset = 0;
68137
+ let spaceTally = 0;
68095
68138
  for (const run2 of runs) {
68096
68139
  if (isTabRun$1(run2)) {
68097
68140
  const runLength2 = TAB_CHAR_LENGTH;
@@ -68112,14 +68155,18 @@ function measureCharacterX(block, line, charOffset) {
68112
68155
  const textUpToTarget = text.slice(0, offsetInRun);
68113
68156
  const measured2 = ctx2.measureText(textUpToTarget);
68114
68157
  const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
68115
- return currentX + measured2.width + spacingWidth;
68158
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToTarget) : 0;
68159
+ return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
68116
68160
  }
68117
68161
  ctx2.font = getRunFontString(run2);
68118
68162
  const measured = ctx2.measureText(text);
68119
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
68163
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
68164
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
68165
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
68166
+ spaceTally += spacesInRun;
68120
68167
  currentCharOffset += runLength;
68121
68168
  }
68122
- return currentX;
68169
+ return alignmentOffset + currentX;
68123
68170
  }
68124
68171
  function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
68125
68172
  if (block.kind !== "paragraph" || !line.segments) return 0;
@@ -68194,8 +68241,15 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
68194
68241
  }
68195
68242
  return lastPm;
68196
68243
  }
68197
- function findCharacterAtX(block, line, x2, pmStart) {
68244
+ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride) {
68198
68245
  const ctx2 = getMeasurementContext();
68246
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: approximate with line width when no maxWidth is present
68247
+ line.width;
68248
+ const justify = getJustifyAdjustment(block, line, availableWidth);
68249
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
68250
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
68251
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68252
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
68199
68253
  if (!ctx2) {
68200
68254
  const runs2 = sliceRunsForLine$1(block, line);
68201
68255
  const charsInLine = Math.max(
@@ -68207,7 +68261,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
68207
68261
  return sum + (run2.text ?? "").length;
68208
68262
  }, 0)
68209
68263
  );
68210
- const ratio = Math.max(0, Math.min(1, x2 / line.width));
68264
+ const ratio = Math.max(0, Math.min(1, (x2 - alignmentOffset) / renderedLineWidth));
68211
68265
  const charOffset = Math.round(ratio * charsInLine);
68212
68266
  const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
68213
68267
  return {
@@ -68216,9 +68270,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
68216
68270
  };
68217
68271
  }
68218
68272
  const runs = sliceRunsForLine$1(block, line);
68219
- const safeX = Math.max(0, Math.min(line.width, x2));
68273
+ const safeX = Math.max(0, Math.min(renderedLineWidth, x2 - alignmentOffset));
68220
68274
  let currentX = 0;
68221
68275
  let currentCharOffset = 0;
68276
+ let spaceTally = 0;
68222
68277
  for (const run2 of runs) {
68223
68278
  if (isTabRun$1(run2)) {
68224
68279
  const tabWidth = run2.width ?? 0;
@@ -68245,7 +68300,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
68245
68300
  for (let i = 0; i <= runLength; i++) {
68246
68301
  const textUpToChar = text.slice(0, i);
68247
68302
  const measured2 = ctx2.measureText(textUpToChar);
68248
- const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength);
68303
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToChar) : 0;
68304
+ const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
68249
68305
  if (charX >= safeX) {
68250
68306
  if (i === 0) {
68251
68307
  const pmPosition3 = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -68268,7 +68324,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
68268
68324
  }
68269
68325
  }
68270
68326
  const measured = ctx2.measureText(text);
68271
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
68327
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
68328
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
68329
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
68330
+ spaceTally += spacesInRun;
68272
68331
  currentCharOffset += runLength;
68273
68332
  }
68274
68333
  const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -80885,7 +80944,18 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
80885
80944
  }
80886
80945
  const line = measure.lines[lineIndex];
80887
80946
  const isRTL = isRtlBlock(block);
80888
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL);
80947
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
80948
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
80949
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
80950
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
80951
+ const totalIndent = paraIndentLeft + paraIndentRight;
80952
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
80953
+ if (totalIndent > fragment.width) {
80954
+ console.warn(
80955
+ `[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.`
80956
+ );
80957
+ }
80958
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth);
80889
80959
  if (pos == null) {
80890
80960
  logClickStage("warn", "no-position", {
80891
80961
  blockId: fragment.blockId
@@ -80916,7 +80986,18 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
80916
80986
  if (lineIndex != null) {
80917
80987
  const line = cellMeasure.lines[lineIndex];
80918
80988
  const isRTL = isRtlBlock(cellBlock);
80919
- const pos = mapPointToPm(cellBlock, line, localX, isRTL);
80989
+ const indentLeft = typeof cellBlock.attrs?.indent?.left === "number" ? cellBlock.attrs.indent.left : 0;
80990
+ const indentRight = typeof cellBlock.attrs?.indent?.right === "number" ? cellBlock.attrs.indent.right : 0;
80991
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
80992
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
80993
+ const totalIndent = paraIndentLeft + paraIndentRight;
80994
+ const availableWidth = Math.max(0, tableHit.fragment.width - totalIndent);
80995
+ if (totalIndent > tableHit.fragment.width) {
80996
+ console.warn(
80997
+ `[clickToPosition:table] Paragraph indents (${totalIndent}px) exceed fragment width (${tableHit.fragment.width}px) for block ${tableHit.fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`
80998
+ );
80999
+ }
81000
+ const pos = mapPointToPm(cellBlock, line, localX, isRTL, availableWidth);
80920
81001
  if (pos != null) {
80921
81002
  logClickStage("log", "success", {
80922
81003
  blockId: tableHit.fragment.blockId,
@@ -81075,7 +81156,15 @@ function selectionToRects(layout, blocks, measures, from2, to) {
81075
81156
  const startX = mapPmToX(block, line, charOffsetFrom, fragment.width);
81076
81157
  const endX = mapPmToX(block, line, charOffsetTo, fragment.width);
81077
81158
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
81078
- const rectX = fragment.x + markerWidth + Math.min(startX, endX);
81159
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
81160
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
81161
+ const isFirstLine = index2 === fragment.fromLine;
81162
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
81163
+ let indentAdjust = 0;
81164
+ if (!isListFirstLine) {
81165
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
81166
+ }
81167
+ const rectX = fragment.x + markerWidth + indentAdjust + Math.min(startX, endX);
81079
81168
  const rectWidth = Math.max(1, Math.abs(endX - startX));
81080
81169
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
81081
81170
  const rectY = fragment.y + lineOffset;
@@ -81451,11 +81540,11 @@ const lineHeightBeforeIndex = (measure, absoluteLineIndex) => {
81451
81540
  }
81452
81541
  return height;
81453
81542
  };
81454
- const mapPointToPm = (block, line, x2, isRTL) => {
81543
+ const mapPointToPm = (block, line, x2, isRTL, availableWidthOverride) => {
81455
81544
  if (block.kind !== "paragraph") return null;
81456
81545
  const range2 = computeLinePmRange(block, line);
81457
81546
  if (range2.pmStart == null || range2.pmEnd == null) return null;
81458
- const result = findCharacterAtX(block, line, x2, range2.pmStart);
81547
+ const result = findCharacterAtX(block, line, x2, range2.pmStart, availableWidthOverride);
81459
81548
  if (isRTL) {
81460
81549
  const charOffset = result.charOffset;
81461
81550
  const charsInLine = Math.max(1, line.toChar - line.fromChar);
@@ -81466,7 +81555,22 @@ const mapPointToPm = (block, line, x2, isRTL) => {
81466
81555
  };
81467
81556
  const mapPmToX = (block, line, offset2, fragmentWidth) => {
81468
81557
  if (fragmentWidth <= 0 || line.width <= 0) return 0;
81469
- return measureCharacterX(block, line, offset2);
81558
+ let paraIndentLeft = 0;
81559
+ let paraIndentRight = 0;
81560
+ if (block.kind === "paragraph") {
81561
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
81562
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
81563
+ paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
81564
+ paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
81565
+ }
81566
+ const totalIndent = paraIndentLeft + paraIndentRight;
81567
+ const availableWidth = Math.max(0, fragmentWidth - totalIndent);
81568
+ if (totalIndent > fragmentWidth) {
81569
+ console.warn(
81570
+ `[mapPmToX] Paragraph indents (${totalIndent}px) exceed fragment width (${fragmentWidth}px) for block ${block.id}. This may indicate a layout miscalculation. Available width clamped to 0.`
81571
+ );
81572
+ }
81573
+ return measureCharacterX(block, line, offset2, availableWidth);
81470
81574
  };
81471
81575
  const isRtlBlock = (block) => {
81472
81576
  if (block.kind !== "paragraph") return false;
@@ -84131,29 +84235,16 @@ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
84131
84235
  }
84132
84236
  return editorHost;
84133
84237
  };
84134
- positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
84238
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
84135
84239
  const pageElement = editorHost.parentElement;
84136
84240
  if (!pageElement) {
84137
84241
  console.error("[EditorOverlayManager] Editor host has no parent element");
84138
84242
  return;
84139
84243
  }
84140
- let top2;
84141
- let left2;
84142
- let width;
84143
- let height;
84144
- if (decorationContainer) {
84145
- const decorationRect = decorationContainer.getBoundingClientRect();
84146
- const pageRect = pageElement.getBoundingClientRect();
84147
- top2 = decorationRect.top - pageRect.top;
84148
- left2 = decorationRect.left - pageRect.left;
84149
- width = decorationRect.width;
84150
- height = decorationRect.height;
84151
- } else {
84152
- top2 = region.localY * zoom;
84153
- left2 = region.localX * zoom;
84154
- width = region.width * zoom;
84155
- height = region.height * zoom;
84156
- }
84244
+ const top2 = decorationContainer?.offsetTop ?? region.localY;
84245
+ const left2 = decorationContainer?.offsetLeft ?? region.localX;
84246
+ const width = decorationContainer?.offsetWidth ?? region.width;
84247
+ const height = decorationContainer?.offsetHeight ?? region.height;
84157
84248
  Object.assign(editorHost.style, {
84158
84249
  top: `${top2}px`,
84159
84250
  left: `${left2}px`,
@@ -84168,19 +84259,14 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom)
84168
84259
  }
84169
84260
  }
84170
84261
  };
84171
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
84262
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, _zoom) {
84172
84263
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
84173
84264
  __privateSet(this, _borderLine, document.createElement("div"));
84174
84265
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
84175
- let topPosition;
84176
84266
  const isHeader = region.kind === "header";
84177
- if (decorationContainer) {
84178
- const decorationRect = decorationContainer.getBoundingClientRect();
84179
- const pageRect = pageElement.getBoundingClientRect();
84180
- topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
84181
- } else {
84182
- topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
84183
- }
84267
+ const decorationTop = decorationContainer?.offsetTop;
84268
+ const decorationHeight = decorationContainer?.offsetHeight;
84269
+ const topPosition = isHeader ? decorationTop != null && decorationHeight != null ? decorationTop + decorationHeight : region.localY + region.height : decorationTop ?? region.localY;
84184
84270
  Object.assign(__privateGet$1(this, _borderLine).style, {
84185
84271
  position: "absolute",
84186
84272
  left: "0",
@@ -85293,8 +85379,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85293
85379
  const start2 = Math.min(from2, to);
85294
85380
  const end2 = Math.max(from2, to);
85295
85381
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
85296
- const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
85297
85382
  const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
85383
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
85384
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
85385
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
85298
85386
  const layoutRectSource = () => {
85299
85387
  if (__privateGet$1(this, _session).mode !== "body") {
85300
85388
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
@@ -85305,14 +85393,46 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85305
85393
  };
85306
85394
  const rawRects = layoutRectSource();
85307
85395
  if (!rawRects.length) return [];
85396
+ let domCaretStart = null;
85397
+ let domCaretEnd = null;
85398
+ try {
85399
+ domCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, start2);
85400
+ domCaretEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, end2);
85401
+ } catch (error) {
85402
+ if (process$1$1.env.NODE_ENV === "development") {
85403
+ console.warn("[PresentationEditor] DOM caret computation failed in getRectsForRange:", error);
85404
+ }
85405
+ }
85406
+ const layoutCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, start2, false);
85407
+ __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, end2, false);
85408
+ const pageDelta = {};
85409
+ if (domCaretStart && layoutCaretStart && domCaretStart.pageIndex === layoutCaretStart.pageIndex) {
85410
+ pageDelta[domCaretStart.pageIndex] = {
85411
+ dx: domCaretStart.x - layoutCaretStart.x,
85412
+ dy: domCaretStart.y - layoutCaretStart.y
85413
+ };
85414
+ }
85308
85415
  const pageHeight = __privateGet$1(this, _session).mode === "body" ? __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this) : __privateMethod$1(this, _PresentationEditor_instances, getHeaderFooterPageHeight_fn).call(this);
85309
85416
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
85310
- return rawRects.map((rect) => {
85311
- const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
85312
- const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
85417
+ const finalRects = rawRects.map((rect, idx, allRects) => {
85418
+ const delta = pageDelta[rect.pageIndex];
85419
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
85420
+ const adjustedY = delta ? rect.y + delta.dy : rect.y;
85421
+ const isFirstRect = idx === 0;
85422
+ const isLastRect = idx === allRects.length - 1;
85423
+ if (isFirstRect && domCaretStart && rect.pageIndex === domCaretStart.pageIndex) {
85424
+ adjustedX = domCaretStart.x;
85425
+ }
85426
+ if (isLastRect && domCaretEnd && rect.pageIndex === domCaretEnd.pageIndex) {
85427
+ const endX = domCaretEnd.x;
85428
+ const newWidth = Math.max(1, endX - adjustedX);
85429
+ rect = { ...rect, width: newWidth };
85430
+ }
85431
+ const pageLocalY = adjustedY - rect.pageIndex * (pageHeight + pageGap);
85432
+ const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, adjustedX, pageLocalY);
85313
85433
  if (!coords) return null;
85314
- const absLeft = coords.x * zoom + overlayRect.left;
85315
- const absTop = coords.y * zoom + overlayRect.top;
85434
+ const absLeft = coords.x * zoom - scrollLeft + containerRect.left;
85435
+ const absTop = coords.y * zoom - scrollTop + containerRect.top;
85316
85436
  const left2 = relativeRect ? absLeft - relativeRect.left : absLeft;
85317
85437
  const top2 = relativeRect ? absTop - relativeRect.top : absTop;
85318
85438
  const width = Math.max(1, rect.width * zoom);
@@ -85327,6 +85447,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85327
85447
  height
85328
85448
  };
85329
85449
  }).filter((rect) => Boolean(rect));
85450
+ return finalRects;
85330
85451
  }
85331
85452
  /**
85332
85453
  * Get selection bounds for a document range with aggregated bounding box.
@@ -85555,24 +85676,22 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85555
85676
  return null;
85556
85677
  }
85557
85678
  const rect2 = rects2[0];
85558
- const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
85559
- if (!overlayRect) {
85560
- return null;
85561
- }
85679
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
85680
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
85681
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
85682
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
85562
85683
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
85563
85684
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
85564
85685
  const pageLocalY = rect2.y - rect2.pageIndex * (pageHeight + pageGap);
85565
85686
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect2.pageIndex, rect2.x, pageLocalY);
85566
- if (!coords) {
85567
- return null;
85568
- }
85687
+ if (!coords) return null;
85569
85688
  return {
85570
- top: coords.y + overlayRect.top,
85571
- bottom: coords.y + overlayRect.top + rect2.height,
85572
- left: coords.x + overlayRect.left,
85573
- right: coords.x + overlayRect.left + rect2.width,
85574
- width: rect2.width,
85575
- height: rect2.height
85689
+ top: coords.y * zoom - scrollTop + containerRect.top,
85690
+ bottom: coords.y * zoom - scrollTop + containerRect.top + rect2.height * zoom,
85691
+ left: coords.x * zoom - scrollLeft + containerRect.left,
85692
+ right: coords.x * zoom - scrollLeft + containerRect.left + rect2.width * zoom,
85693
+ width: rect2.width * zoom,
85694
+ height: rect2.height * zoom
85576
85695
  };
85577
85696
  }
85578
85697
  const rects = this.getRangeRects(pos, pos);
@@ -86798,6 +86917,19 @@ rerender_fn = async function() {
86798
86917
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
86799
86918
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
86800
86919
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
86920
+ const pageWidth = layout.pageSize?.w ?? __privateGet$1(this, _layoutOptions).pageSize?.w ?? DEFAULT_PAGE_SIZE.w;
86921
+ if (__privateGet$1(this, _painterHost)) {
86922
+ __privateGet$1(this, _painterHost).style.width = `${pageWidth}px`;
86923
+ __privateGet$1(this, _painterHost).style.marginLeft = "0";
86924
+ __privateGet$1(this, _painterHost).style.marginRight = "0";
86925
+ }
86926
+ if (__privateGet$1(this, _selectionOverlay2)) {
86927
+ __privateGet$1(this, _selectionOverlay2).style.width = `${pageWidth}px`;
86928
+ __privateGet$1(this, _selectionOverlay2).style.left = "0";
86929
+ __privateGet$1(this, _selectionOverlay2).style.right = "";
86930
+ __privateGet$1(this, _selectionOverlay2).style.marginLeft = "0";
86931
+ __privateGet$1(this, _selectionOverlay2).style.marginRight = "0";
86932
+ }
86801
86933
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
86802
86934
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
86803
86935
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -86947,9 +87079,20 @@ updateSelection_fn = function() {
86947
87079
  return;
86948
87080
  }
86949
87081
  const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
87082
+ let domStart = null;
87083
+ let domEnd = null;
87084
+ try {
87085
+ domStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, from2);
87086
+ domEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, to);
87087
+ } catch (error) {
87088
+ if (process$1$1.env.NODE_ENV === "development") {
87089
+ console.warn("[PresentationEditor] DOM caret computation failed in #renderLocalSelection:", error);
87090
+ }
87091
+ }
87092
+ const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
86950
87093
  try {
86951
87094
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
86952
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects);
87095
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
86953
87096
  } catch (error) {
86954
87097
  if (process$1$1.env.NODE_ENV === "development") {
86955
87098
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -87724,6 +87867,43 @@ getHeaderFooterPageHeight_fn = function() {
87724
87867
  }
87725
87868
  return context.layout.pageSize?.h ?? context.region.height ?? 1;
87726
87869
  };
87870
+ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
87871
+ if (rects.length === 0) return rects;
87872
+ const pageDelta = {};
87873
+ if (domStart && rects[0] && domStart.pageIndex === rects[0].pageIndex) {
87874
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87875
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87876
+ const layoutY = rects[0].y - rects[0].pageIndex * (pageHeight + pageGap);
87877
+ pageDelta[domStart.pageIndex] = {
87878
+ dx: domStart.x - rects[0].x,
87879
+ dy: domStart.y - layoutY
87880
+ };
87881
+ }
87882
+ return rects.map((rect, idx) => {
87883
+ const delta = pageDelta[rect.pageIndex];
87884
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
87885
+ let adjustedY = delta ? rect.y + delta.dy : rect.y;
87886
+ let adjustedWidth = rect.width;
87887
+ const isFirstRect = idx === 0;
87888
+ const isLastRect = idx === rects.length - 1;
87889
+ if (isFirstRect && domStart && rect.pageIndex === domStart.pageIndex) {
87890
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87891
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87892
+ adjustedX = domStart.x;
87893
+ adjustedY = domStart.y + rect.pageIndex * (pageHeight + pageGap);
87894
+ }
87895
+ if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
87896
+ const endX = domEnd.x;
87897
+ adjustedWidth = Math.max(1, endX - adjustedX);
87898
+ }
87899
+ return {
87900
+ ...rect,
87901
+ x: adjustedX,
87902
+ y: adjustedY,
87903
+ width: adjustedWidth
87904
+ };
87905
+ });
87906
+ };
87727
87907
  renderSelectionRects_fn = function(rects) {
87728
87908
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
87729
87909
  if (!localSelectionLayer) {
@@ -87731,7 +87911,7 @@ renderSelectionRects_fn = function(rects) {
87731
87911
  }
87732
87912
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87733
87913
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87734
- rects.forEach((rect, _index) => {
87914
+ rects.forEach((rect) => {
87735
87915
  const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
87736
87916
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
87737
87917
  if (!coords) {
@@ -87970,6 +88150,20 @@ createLayoutMetrics_fn = function(perf, startMark, layout, blocks) {
87970
88150
  pageCount: layout.pages?.length ?? 0
87971
88151
  };
87972
88152
  };
88153
+ getPageOffsetX_fn = function(pageIndex) {
88154
+ if (!__privateGet$1(this, _painterHost) || !__privateGet$1(this, _viewportHost)) {
88155
+ return null;
88156
+ }
88157
+ const pageEl = __privateGet$1(this, _painterHost).querySelector(
88158
+ `.superdoc-page[data-page-index="${pageIndex}"]`
88159
+ );
88160
+ if (!pageEl) return null;
88161
+ const pageRect = pageEl.getBoundingClientRect();
88162
+ const viewportRect = __privateGet$1(this, _viewportHost).getBoundingClientRect();
88163
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88164
+ const offsetX = (pageRect.left - viewportRect.left) / zoom;
88165
+ return offsetX;
88166
+ };
87973
88167
  convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY) {
87974
88168
  if (!Number.isFinite(pageIndex) || pageIndex < 0) {
87975
88169
  console.warn(
@@ -87991,10 +88185,52 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
87991
88185
  }
87992
88186
  const pageHeight = __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
87993
88187
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87994
- return {
87995
- x: pageLocalX,
88188
+ const pageOffsetX = __privateMethod$1(this, _PresentationEditor_instances, getPageOffsetX_fn).call(this, pageIndex) ?? 0;
88189
+ const coords = {
88190
+ x: pageOffsetX + pageLocalX,
87996
88191
  y: pageIndex * (pageHeight + pageGap) + pageLocalY
87997
88192
  };
88193
+ return coords;
88194
+ };
88195
+ computeDomCaretPageLocal_fn = function(pos) {
88196
+ __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page span[data-pm-start][data-pm-end]`) ? __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page`) : null;
88197
+ const spans = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll("span[data-pm-start][data-pm-end]"));
88198
+ let targetSpan = null;
88199
+ for (const span of spans) {
88200
+ const pmStart2 = Number(span.dataset.pmStart ?? "NaN");
88201
+ const pmEnd = Number(span.dataset.pmEnd ?? "NaN");
88202
+ if (!Number.isFinite(pmStart2) || !Number.isFinite(pmEnd)) continue;
88203
+ if (pos < pmStart2 || pos > pmEnd) continue;
88204
+ targetSpan = span;
88205
+ break;
88206
+ }
88207
+ if (!targetSpan) return null;
88208
+ const page = targetSpan.closest(".superdoc-page");
88209
+ if (!page) return null;
88210
+ const pageRect = page.getBoundingClientRect();
88211
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88212
+ const textNode = targetSpan.firstChild;
88213
+ if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
88214
+ const spanRect = targetSpan.getBoundingClientRect();
88215
+ return {
88216
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
88217
+ x: (spanRect.left - pageRect.left) / zoom,
88218
+ y: (spanRect.top - pageRect.top) / zoom
88219
+ };
88220
+ }
88221
+ const pmStart = Number(targetSpan.dataset.pmStart ?? "NaN");
88222
+ const charIndex = Math.min(pos - pmStart, textNode.length);
88223
+ const range2 = document.createRange();
88224
+ range2.setStart(textNode, Math.max(0, charIndex));
88225
+ range2.setEnd(textNode, Math.max(0, charIndex));
88226
+ const rangeRect = range2.getBoundingClientRect();
88227
+ const lineEl = targetSpan.closest(".superdoc-line");
88228
+ const lineRect = lineEl?.getBoundingClientRect() ?? rangeRect;
88229
+ return {
88230
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
88231
+ x: (rangeRect.left - pageRect.left) / zoom,
88232
+ y: (lineRect.top - pageRect.top) / zoom
88233
+ };
87998
88234
  };
87999
88235
  normalizeClientPoint_fn = function(clientX, clientY) {
88000
88236
  if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
@@ -88004,18 +88240,29 @@ normalizeClientPoint_fn = function(clientX, clientY) {
88004
88240
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88005
88241
  const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
88006
88242
  const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
88243
+ const baseX = (clientX - rect.left + scrollLeft) / zoom;
88244
+ const baseY = (clientY - rect.top + scrollTop) / zoom;
88245
+ let adjustedX = baseX;
88246
+ const doc2 = __privateGet$1(this, _visibleHost).ownerDocument ?? document;
88247
+ const hitChain = typeof doc2.elementsFromPoint === "function" ? doc2.elementsFromPoint(clientX, clientY) : [];
88248
+ const pageEl = Array.isArray(hitChain) ? hitChain.find((el) => el?.classList?.contains("superdoc-page")) : null;
88249
+ if (pageEl) {
88250
+ const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
88251
+ if (Number.isFinite(pageIndex)) {
88252
+ const pageOffsetX = __privateMethod$1(this, _PresentationEditor_instances, getPageOffsetX_fn).call(this, pageIndex);
88253
+ if (pageOffsetX != null) {
88254
+ adjustedX = baseX - pageOffsetX;
88255
+ }
88256
+ }
88257
+ }
88007
88258
  return {
88008
- x: (clientX - rect.left + scrollLeft) / zoom,
88009
- y: (clientY - rect.top + scrollTop) / zoom
88259
+ x: adjustedX,
88260
+ y: baseY
88010
88261
  };
88011
88262
  };
88012
- computeCaretLayoutRect_fn = function(pos) {
88263
+ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
88013
88264
  const layout = __privateGet$1(this, _layoutState).layout;
88014
88265
  if (!layout) return null;
88015
- const domResult = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectFromDOM_fn).call(this, pos);
88016
- if (domResult) {
88017
- return domResult;
88018
- }
88019
88266
  const hit = getFragmentAtPosition(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pos);
88020
88267
  if (!hit) {
88021
88268
  return null;
@@ -88037,101 +88284,82 @@ computeCaretLayoutRect_fn = function(pos) {
88037
88284
  const { line, index: index2 } = lineInfo;
88038
88285
  const range2 = computeLinePmRange(block, line);
88039
88286
  if (range2.pmStart == null || range2.pmEnd == null) return null;
88040
- const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
88041
- const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
88042
- const localX = fragment.x + measureCharacterX(block, line, pmOffset);
88287
+ const pmOffset = pmPosToCharOffset(block, line, pos);
88288
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
88289
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
88290
+ const paraIndentRight = block.attrs?.indent?.right ?? 0;
88291
+ const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
88292
+ const charX = measureCharacterX(block, line, pmOffset, availableWidth);
88293
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
88294
+ const isFirstLine = index2 === fragment.fromLine;
88295
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
88296
+ let indentAdjust = 0;
88297
+ if (!isListFirstLine) {
88298
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
88299
+ }
88300
+ const localX = fragment.x + markerWidth + indentAdjust + charX;
88043
88301
  const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
88044
88302
  const localY = fragment.y + lineOffset;
88045
- return {
88303
+ const result = {
88046
88304
  pageIndex: hit.pageIndex,
88047
88305
  x: localX,
88048
88306
  y: localY,
88049
88307
  height: line.lineHeight
88050
88308
  };
88051
- };
88052
- computeCaretLayoutRectFromDOM_fn = function(pos) {
88309
+ const pageEl = __privateGet$1(this, _painterHost)?.querySelector(
88310
+ `.superdoc-page[data-page-index="${hit.pageIndex}"]`
88311
+ );
88312
+ const pageRect = pageEl?.getBoundingClientRect();
88053
88313
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88054
- let targetPageEl = null;
88055
- if (__privateGet$1(this, _layoutState).layout && __privateGet$1(this, _layoutState).blocks && __privateGet$1(this, _layoutState).measures) {
88056
- const fragmentHit = getFragmentAtPosition(
88057
- __privateGet$1(this, _layoutState).layout,
88058
- __privateGet$1(this, _layoutState).blocks,
88059
- __privateGet$1(this, _layoutState).measures,
88060
- pos
88061
- );
88062
- if (fragmentHit) {
88063
- const pageEl = __privateGet$1(this, _viewportHost).querySelector(
88064
- `.superdoc-page[data-page-index="${fragmentHit.pageIndex}"]`
88065
- );
88066
- if (pageEl) {
88067
- targetPageEl = pageEl;
88314
+ let domCaretX = null;
88315
+ let domCaretY = null;
88316
+ const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
88317
+ for (const spanEl of spanEls) {
88318
+ const pmStart = Number(spanEl.dataset.pmStart);
88319
+ const pmEnd = Number(spanEl.dataset.pmEnd);
88320
+ if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
88321
+ const textNode = spanEl.firstChild;
88322
+ const charIndex = Math.min(pos - pmStart, textNode.length);
88323
+ const rangeObj = document.createRange();
88324
+ rangeObj.setStart(textNode, charIndex);
88325
+ rangeObj.setEnd(textNode, charIndex);
88326
+ const rangeRect = rangeObj.getBoundingClientRect();
88327
+ if (pageRect) {
88328
+ domCaretX = (rangeRect.left - pageRect.left) / zoom;
88329
+ domCaretY = (rangeRect.top - pageRect.top) / zoom;
88068
88330
  }
88331
+ break;
88069
88332
  }
88070
88333
  }
88071
- const spanEls = Array.from(
88072
- targetPageEl ? targetPageEl.querySelectorAll(`span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`) : __privateGet$1(this, _viewportHost).querySelectorAll(
88073
- `span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`
88074
- )
88075
- );
88076
- for (const spanEl of spanEls) {
88077
- const pmStart = Number(spanEl.dataset.pmStart ?? "NaN");
88078
- const pmEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
88079
- if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd)) continue;
88080
- if (pos < pmStart || pos > pmEnd) continue;
88081
- const pageEl = spanEl.closest(".superdoc-page");
88082
- if (!pageEl) continue;
88083
- const pageIndex = Number(pageEl.dataset.pageIndex ?? "0");
88084
- const pageRect = pageEl.getBoundingClientRect();
88085
- const textNode = spanEl.firstChild;
88086
- if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
88087
- const spanRect2 = spanEl.getBoundingClientRect();
88088
- return {
88089
- pageIndex,
88090
- x: (spanRect2.left - pageRect.left) / zoom,
88091
- y: (spanRect2.top - pageRect.top) / zoom,
88092
- height: spanRect2.height / zoom
88093
- };
88094
- }
88095
- const text = textNode.textContent ?? "";
88096
- const charOffset = Math.max(0, Math.min(text.length, pos - pmStart));
88097
- const range2 = document.createRange();
88098
- try {
88099
- range2.setStart(textNode, charOffset);
88100
- range2.setEnd(textNode, charOffset);
88101
- } catch (error) {
88102
- if (process$1$1.env.NODE_ENV === "development") {
88103
- console.warn("[PresentationEditor] Range.setStart/setEnd failed:", {
88104
- error: error instanceof Error ? error.message : String(error),
88105
- charOffset,
88106
- textLength: text.length,
88107
- pos,
88108
- pmStart,
88109
- pmEnd
88110
- });
88111
- }
88112
- const spanRect2 = spanEl.getBoundingClientRect();
88113
- return {
88114
- pageIndex,
88115
- x: (spanRect2.left - pageRect.left) / zoom,
88116
- y: (spanRect2.top - pageRect.top) / zoom,
88117
- height: spanRect2.height / zoom
88118
- };
88334
+ if (includeDomFallback && domCaretX != null && domCaretY != null) {
88335
+ return {
88336
+ pageIndex: hit.pageIndex,
88337
+ x: domCaretX,
88338
+ y: domCaretY,
88339
+ height: line.lineHeight
88340
+ };
88341
+ }
88342
+ return result;
88343
+ };
88344
+ computeCaretLayoutRect_fn = function(pos) {
88345
+ const geometry = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, pos, true);
88346
+ let dom = null;
88347
+ try {
88348
+ dom = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, pos);
88349
+ } catch (error) {
88350
+ if (process$1$1.env.NODE_ENV === "development") {
88351
+ console.warn("[PresentationEditor] DOM caret computation failed in #computeCaretLayoutRect:", error);
88119
88352
  }
88120
- const rangeRect = range2.getBoundingClientRect();
88121
- const spanRect = spanEl.getBoundingClientRect();
88122
- const lineEl = spanEl.closest(".superdoc-line");
88123
- const lineRect = lineEl ? lineEl.getBoundingClientRect() : spanRect;
88124
- const caretHeight = spanRect.height;
88125
- const verticalOffset = (lineRect.height - caretHeight) / 2;
88126
- const caretY = lineRect.top + verticalOffset;
88353
+ }
88354
+ if (dom && geometry) {
88127
88355
  return {
88128
- pageIndex,
88129
- x: (rangeRect.left - pageRect.left) / zoom,
88130
- y: (caretY - pageRect.top) / zoom,
88131
- height: caretHeight / zoom
88356
+ pageIndex: dom.pageIndex,
88357
+ x: dom.x,
88358
+ y: dom.y,
88359
+ height: geometry.height
88132
88360
  };
88133
88361
  }
88134
- return null;
88362
+ return geometry;
88135
88363
  };
88136
88364
  computeTableCaretLayoutRect_fn = function(pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
88137
88365
  const lineEls = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll(".superdoc-line"));