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
@@ -42326,7 +42326,7 @@ const _SuperConverter = class _SuperConverter2 {
42326
42326
  static getStoredSuperdocVersion(docx) {
42327
42327
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42328
42328
  }
42329
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.65") {
42329
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.67") {
42330
42330
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42331
42331
  }
42332
42332
  /**
@@ -45638,7 +45638,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
45638
45638
  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);
45639
45639
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
45640
45640
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
45641
- 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;
45641
+ 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;
45642
45642
  var GOOD_LEAF_SIZE = 200;
45643
45643
  var RopeSequence = function RopeSequence2() {
45644
45644
  };
@@ -59515,7 +59515,7 @@ const isHeadless = (editor) => {
59515
59515
  const shouldSkipNodeView = (editor) => {
59516
59516
  return isHeadless(editor);
59517
59517
  };
59518
- const summaryVersion = "1.0.0-beta.65";
59518
+ const summaryVersion = "1.0.0-beta.67";
59519
59519
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59520
59520
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59521
59521
  function mapAttributes(attrs) {
@@ -60304,7 +60304,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60304
60304
  { default: remarkStringify },
60305
60305
  { default: remarkGfm }
60306
60306
  ] = await Promise.all([
60307
- Promise.resolve().then(() => require("./index-YSWS94Jr-C7xFStTB.cjs")),
60307
+ Promise.resolve().then(() => require("./index-Cixgd5bX-ByqITVZq.cjs")),
60308
60308
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60309
60309
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60310
60310
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60509,7 +60509,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60509
60509
  * Process collaboration migrations
60510
60510
  */
60511
60511
  processCollaborationMigrations() {
60512
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.65");
60512
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.67");
60513
60513
  if (!this.options.ydoc) return;
60514
60514
  const metaMap = this.options.ydoc.getMap("meta");
60515
60515
  let docVersion = metaMap.get("version");
@@ -68014,6 +68014,7 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
68014
68014
  let measurementCanvas = null;
68015
68015
  let measurementCtx = null;
68016
68016
  const TAB_CHAR_LENGTH = 1;
68017
+ const SPACE_CHARS = /* @__PURE__ */ new Set([" ", " "]);
68017
68018
  const isTabRun$1 = (run2) => run2?.kind === "tab";
68018
68019
  function getMeasurementContext() {
68019
68020
  if (measurementCtx) return measurementCtx;
@@ -68030,6 +68031,41 @@ function getMeasurementContext() {
68030
68031
  }
68031
68032
  return measurementCtx;
68032
68033
  }
68034
+ const countSpaces = (text) => {
68035
+ let spaces = 0;
68036
+ for (let i = 0; i < text.length; i += 1) {
68037
+ if (SPACE_CHARS.has(text[i])) {
68038
+ spaces += 1;
68039
+ }
68040
+ }
68041
+ return spaces;
68042
+ };
68043
+ const getJustifyAdjustment = (block, line, availableWidthOverride) => {
68044
+ if (block.kind !== "paragraph") {
68045
+ return { extraPerSpace: 0, totalSpaces: 0 };
68046
+ }
68047
+ const alignment2 = block.attrs?.alignment;
68048
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68049
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
68050
+ const slack = Math.max(0, availableWidth - line.width);
68051
+ if (alignment2 !== "justify" || hasExplicitPositioning || slack <= 0) {
68052
+ return { extraPerSpace: 0, totalSpaces: 0 };
68053
+ }
68054
+ const runs = sliceRunsForLine$1(block, line);
68055
+ const totalSpaces = runs.reduce((sum, run2) => {
68056
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
68057
+ return sum;
68058
+ }
68059
+ return sum + countSpaces(run2.text ?? "");
68060
+ }, 0);
68061
+ if (totalSpaces <= 0) {
68062
+ return { extraPerSpace: 0, totalSpaces: 0 };
68063
+ }
68064
+ return {
68065
+ extraPerSpace: slack / totalSpaces,
68066
+ totalSpaces
68067
+ };
68068
+ };
68033
68069
  function getRunFontString(run2) {
68034
68070
  if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
68035
68071
  return "normal normal 16px Arial";
@@ -68087,9 +68123,15 @@ function sliceRunsForLine$1(block, line) {
68087
68123
  }
68088
68124
  return result;
68089
68125
  }
68090
- function measureCharacterX(block, line, charOffset) {
68126
+ function measureCharacterX(block, line, charOffset, availableWidthOverride) {
68091
68127
  const ctx2 = getMeasurementContext();
68128
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: if no maxWidth, approximate available width as line width (no slack)
68129
+ line.width;
68130
+ const justify = getJustifyAdjustment(block, line, availableWidth);
68131
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
68132
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
68092
68133
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68134
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
68093
68135
  if (hasExplicitPositioning && line.segments && ctx2) {
68094
68136
  return measureCharacterXSegmentBased(block, line, charOffset, ctx2);
68095
68137
  }
@@ -68104,11 +68146,12 @@ function measureCharacterX(block, line, charOffset) {
68104
68146
  return sum + (run2.text ?? "").length;
68105
68147
  }, 0)
68106
68148
  );
68107
- return charOffset / charsInLine * line.width;
68149
+ return charOffset / charsInLine * renderedLineWidth;
68108
68150
  }
68109
68151
  const runs = sliceRunsForLine$1(block, line);
68110
68152
  let currentX = 0;
68111
68153
  let currentCharOffset = 0;
68154
+ let spaceTally = 0;
68112
68155
  for (const run2 of runs) {
68113
68156
  if (isTabRun$1(run2)) {
68114
68157
  const runLength2 = TAB_CHAR_LENGTH;
@@ -68129,14 +68172,18 @@ function measureCharacterX(block, line, charOffset) {
68129
68172
  const textUpToTarget = text.slice(0, offsetInRun);
68130
68173
  const measured2 = ctx2.measureText(textUpToTarget);
68131
68174
  const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
68132
- return currentX + measured2.width + spacingWidth;
68175
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToTarget) : 0;
68176
+ return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
68133
68177
  }
68134
68178
  ctx2.font = getRunFontString(run2);
68135
68179
  const measured = ctx2.measureText(text);
68136
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
68180
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
68181
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
68182
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
68183
+ spaceTally += spacesInRun;
68137
68184
  currentCharOffset += runLength;
68138
68185
  }
68139
- return currentX;
68186
+ return alignmentOffset + currentX;
68140
68187
  }
68141
68188
  function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
68142
68189
  if (block.kind !== "paragraph" || !line.segments) return 0;
@@ -68211,8 +68258,15 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
68211
68258
  }
68212
68259
  return lastPm;
68213
68260
  }
68214
- function findCharacterAtX(block, line, x2, pmStart) {
68261
+ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride) {
68215
68262
  const ctx2 = getMeasurementContext();
68263
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: approximate with line width when no maxWidth is present
68264
+ line.width;
68265
+ const justify = getJustifyAdjustment(block, line, availableWidth);
68266
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
68267
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
68268
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
68269
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
68216
68270
  if (!ctx2) {
68217
68271
  const runs2 = sliceRunsForLine$1(block, line);
68218
68272
  const charsInLine = Math.max(
@@ -68224,7 +68278,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
68224
68278
  return sum + (run2.text ?? "").length;
68225
68279
  }, 0)
68226
68280
  );
68227
- const ratio = Math.max(0, Math.min(1, x2 / line.width));
68281
+ const ratio = Math.max(0, Math.min(1, (x2 - alignmentOffset) / renderedLineWidth));
68228
68282
  const charOffset = Math.round(ratio * charsInLine);
68229
68283
  const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
68230
68284
  return {
@@ -68233,9 +68287,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
68233
68287
  };
68234
68288
  }
68235
68289
  const runs = sliceRunsForLine$1(block, line);
68236
- const safeX = Math.max(0, Math.min(line.width, x2));
68290
+ const safeX = Math.max(0, Math.min(renderedLineWidth, x2 - alignmentOffset));
68237
68291
  let currentX = 0;
68238
68292
  let currentCharOffset = 0;
68293
+ let spaceTally = 0;
68239
68294
  for (const run2 of runs) {
68240
68295
  if (isTabRun$1(run2)) {
68241
68296
  const tabWidth = run2.width ?? 0;
@@ -68262,7 +68317,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
68262
68317
  for (let i = 0; i <= runLength; i++) {
68263
68318
  const textUpToChar = text.slice(0, i);
68264
68319
  const measured2 = ctx2.measureText(textUpToChar);
68265
- const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength);
68320
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToChar) : 0;
68321
+ const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
68266
68322
  if (charX >= safeX) {
68267
68323
  if (i === 0) {
68268
68324
  const pmPosition3 = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -68285,7 +68341,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
68285
68341
  }
68286
68342
  }
68287
68343
  const measured = ctx2.measureText(text);
68288
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
68344
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
68345
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
68346
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
68347
+ spaceTally += spacesInRun;
68289
68348
  currentCharOffset += runLength;
68290
68349
  }
68291
68350
  const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -80902,7 +80961,18 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
80902
80961
  }
80903
80962
  const line = measure.lines[lineIndex];
80904
80963
  const isRTL = isRtlBlock(block);
80905
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL);
80964
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
80965
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
80966
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
80967
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
80968
+ const totalIndent = paraIndentLeft + paraIndentRight;
80969
+ const availableWidth = Math.max(0, fragment.width - totalIndent);
80970
+ if (totalIndent > fragment.width) {
80971
+ console.warn(
80972
+ `[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.`
80973
+ );
80974
+ }
80975
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth);
80906
80976
  if (pos == null) {
80907
80977
  logClickStage("warn", "no-position", {
80908
80978
  blockId: fragment.blockId
@@ -80933,7 +81003,18 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
80933
81003
  if (lineIndex != null) {
80934
81004
  const line = cellMeasure.lines[lineIndex];
80935
81005
  const isRTL = isRtlBlock(cellBlock);
80936
- const pos = mapPointToPm(cellBlock, line, localX, isRTL);
81006
+ const indentLeft = typeof cellBlock.attrs?.indent?.left === "number" ? cellBlock.attrs.indent.left : 0;
81007
+ const indentRight = typeof cellBlock.attrs?.indent?.right === "number" ? cellBlock.attrs.indent.right : 0;
81008
+ const paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
81009
+ const paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
81010
+ const totalIndent = paraIndentLeft + paraIndentRight;
81011
+ const availableWidth = Math.max(0, tableHit.fragment.width - totalIndent);
81012
+ if (totalIndent > tableHit.fragment.width) {
81013
+ console.warn(
81014
+ `[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.`
81015
+ );
81016
+ }
81017
+ const pos = mapPointToPm(cellBlock, line, localX, isRTL, availableWidth);
80937
81018
  if (pos != null) {
80938
81019
  logClickStage("log", "success", {
80939
81020
  blockId: tableHit.fragment.blockId,
@@ -81092,7 +81173,15 @@ function selectionToRects(layout, blocks, measures, from2, to) {
81092
81173
  const startX = mapPmToX(block, line, charOffsetFrom, fragment.width);
81093
81174
  const endX = mapPmToX(block, line, charOffsetTo, fragment.width);
81094
81175
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
81095
- const rectX = fragment.x + markerWidth + Math.min(startX, endX);
81176
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
81177
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
81178
+ const isFirstLine = index2 === fragment.fromLine;
81179
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
81180
+ let indentAdjust = 0;
81181
+ if (!isListFirstLine) {
81182
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
81183
+ }
81184
+ const rectX = fragment.x + markerWidth + indentAdjust + Math.min(startX, endX);
81096
81185
  const rectWidth = Math.max(1, Math.abs(endX - startX));
81097
81186
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
81098
81187
  const rectY = fragment.y + lineOffset;
@@ -81468,11 +81557,11 @@ const lineHeightBeforeIndex = (measure, absoluteLineIndex) => {
81468
81557
  }
81469
81558
  return height;
81470
81559
  };
81471
- const mapPointToPm = (block, line, x2, isRTL) => {
81560
+ const mapPointToPm = (block, line, x2, isRTL, availableWidthOverride) => {
81472
81561
  if (block.kind !== "paragraph") return null;
81473
81562
  const range2 = computeLinePmRange(block, line);
81474
81563
  if (range2.pmStart == null || range2.pmEnd == null) return null;
81475
- const result = findCharacterAtX(block, line, x2, range2.pmStart);
81564
+ const result = findCharacterAtX(block, line, x2, range2.pmStart, availableWidthOverride);
81476
81565
  if (isRTL) {
81477
81566
  const charOffset = result.charOffset;
81478
81567
  const charsInLine = Math.max(1, line.toChar - line.fromChar);
@@ -81483,7 +81572,22 @@ const mapPointToPm = (block, line, x2, isRTL) => {
81483
81572
  };
81484
81573
  const mapPmToX = (block, line, offset2, fragmentWidth) => {
81485
81574
  if (fragmentWidth <= 0 || line.width <= 0) return 0;
81486
- return measureCharacterX(block, line, offset2);
81575
+ let paraIndentLeft = 0;
81576
+ let paraIndentRight = 0;
81577
+ if (block.kind === "paragraph") {
81578
+ const indentLeft = typeof block.attrs?.indent?.left === "number" ? block.attrs.indent.left : 0;
81579
+ const indentRight = typeof block.attrs?.indent?.right === "number" ? block.attrs.indent.right : 0;
81580
+ paraIndentLeft = Number.isFinite(indentLeft) ? indentLeft : 0;
81581
+ paraIndentRight = Number.isFinite(indentRight) ? indentRight : 0;
81582
+ }
81583
+ const totalIndent = paraIndentLeft + paraIndentRight;
81584
+ const availableWidth = Math.max(0, fragmentWidth - totalIndent);
81585
+ if (totalIndent > fragmentWidth) {
81586
+ console.warn(
81587
+ `[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.`
81588
+ );
81589
+ }
81590
+ return measureCharacterX(block, line, offset2, availableWidth);
81487
81591
  };
81488
81592
  const isRtlBlock = (block) => {
81489
81593
  if (block.kind !== "paragraph") return false;
@@ -84148,29 +84252,16 @@ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
84148
84252
  }
84149
84253
  return editorHost;
84150
84254
  };
84151
- positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
84255
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
84152
84256
  const pageElement = editorHost.parentElement;
84153
84257
  if (!pageElement) {
84154
84258
  console.error("[EditorOverlayManager] Editor host has no parent element");
84155
84259
  return;
84156
84260
  }
84157
- let top2;
84158
- let left2;
84159
- let width;
84160
- let height;
84161
- if (decorationContainer) {
84162
- const decorationRect = decorationContainer.getBoundingClientRect();
84163
- const pageRect = pageElement.getBoundingClientRect();
84164
- top2 = decorationRect.top - pageRect.top;
84165
- left2 = decorationRect.left - pageRect.left;
84166
- width = decorationRect.width;
84167
- height = decorationRect.height;
84168
- } else {
84169
- top2 = region.localY * zoom;
84170
- left2 = region.localX * zoom;
84171
- width = region.width * zoom;
84172
- height = region.height * zoom;
84173
- }
84261
+ const top2 = decorationContainer?.offsetTop ?? region.localY;
84262
+ const left2 = decorationContainer?.offsetLeft ?? region.localX;
84263
+ const width = decorationContainer?.offsetWidth ?? region.width;
84264
+ const height = decorationContainer?.offsetHeight ?? region.height;
84174
84265
  Object.assign(editorHost.style, {
84175
84266
  top: `${top2}px`,
84176
84267
  left: `${left2}px`,
@@ -84185,19 +84276,14 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom)
84185
84276
  }
84186
84277
  }
84187
84278
  };
84188
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
84279
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, _zoom) {
84189
84280
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
84190
84281
  __privateSet(this, _borderLine, document.createElement("div"));
84191
84282
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
84192
- let topPosition;
84193
84283
  const isHeader = region.kind === "header";
84194
- if (decorationContainer) {
84195
- const decorationRect = decorationContainer.getBoundingClientRect();
84196
- const pageRect = pageElement.getBoundingClientRect();
84197
- topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
84198
- } else {
84199
- topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
84200
- }
84284
+ const decorationTop = decorationContainer?.offsetTop;
84285
+ const decorationHeight = decorationContainer?.offsetHeight;
84286
+ const topPosition = isHeader ? decorationTop != null && decorationHeight != null ? decorationTop + decorationHeight : region.localY + region.height : decorationTop ?? region.localY;
84201
84287
  Object.assign(__privateGet$1(this, _borderLine).style, {
84202
84288
  position: "absolute",
84203
84289
  left: "0",
@@ -85310,8 +85396,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85310
85396
  const start2 = Math.min(from2, to);
85311
85397
  const end2 = Math.max(from2, to);
85312
85398
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
85313
- const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
85314
85399
  const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
85400
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
85401
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
85402
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
85315
85403
  const layoutRectSource = () => {
85316
85404
  if (__privateGet$1(this, _session).mode !== "body") {
85317
85405
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
@@ -85322,14 +85410,46 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85322
85410
  };
85323
85411
  const rawRects = layoutRectSource();
85324
85412
  if (!rawRects.length) return [];
85413
+ let domCaretStart = null;
85414
+ let domCaretEnd = null;
85415
+ try {
85416
+ domCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, start2);
85417
+ domCaretEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, end2);
85418
+ } catch (error) {
85419
+ if (process$1$1.env.NODE_ENV === "development") {
85420
+ console.warn("[PresentationEditor] DOM caret computation failed in getRectsForRange:", error);
85421
+ }
85422
+ }
85423
+ const layoutCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, start2, false);
85424
+ __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, end2, false);
85425
+ const pageDelta = {};
85426
+ if (domCaretStart && layoutCaretStart && domCaretStart.pageIndex === layoutCaretStart.pageIndex) {
85427
+ pageDelta[domCaretStart.pageIndex] = {
85428
+ dx: domCaretStart.x - layoutCaretStart.x,
85429
+ dy: domCaretStart.y - layoutCaretStart.y
85430
+ };
85431
+ }
85325
85432
  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);
85326
85433
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
85327
- return rawRects.map((rect) => {
85328
- const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
85329
- const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
85434
+ const finalRects = rawRects.map((rect, idx, allRects) => {
85435
+ const delta = pageDelta[rect.pageIndex];
85436
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
85437
+ const adjustedY = delta ? rect.y + delta.dy : rect.y;
85438
+ const isFirstRect = idx === 0;
85439
+ const isLastRect = idx === allRects.length - 1;
85440
+ if (isFirstRect && domCaretStart && rect.pageIndex === domCaretStart.pageIndex) {
85441
+ adjustedX = domCaretStart.x;
85442
+ }
85443
+ if (isLastRect && domCaretEnd && rect.pageIndex === domCaretEnd.pageIndex) {
85444
+ const endX = domCaretEnd.x;
85445
+ const newWidth = Math.max(1, endX - adjustedX);
85446
+ rect = { ...rect, width: newWidth };
85447
+ }
85448
+ const pageLocalY = adjustedY - rect.pageIndex * (pageHeight + pageGap);
85449
+ const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, adjustedX, pageLocalY);
85330
85450
  if (!coords) return null;
85331
- const absLeft = coords.x * zoom + overlayRect.left;
85332
- const absTop = coords.y * zoom + overlayRect.top;
85451
+ const absLeft = coords.x * zoom - scrollLeft + containerRect.left;
85452
+ const absTop = coords.y * zoom - scrollTop + containerRect.top;
85333
85453
  const left2 = relativeRect ? absLeft - relativeRect.left : absLeft;
85334
85454
  const top2 = relativeRect ? absTop - relativeRect.top : absTop;
85335
85455
  const width = Math.max(1, rect.width * zoom);
@@ -85344,6 +85464,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85344
85464
  height
85345
85465
  };
85346
85466
  }).filter((rect) => Boolean(rect));
85467
+ return finalRects;
85347
85468
  }
85348
85469
  /**
85349
85470
  * Get selection bounds for a document range with aggregated bounding box.
@@ -85572,24 +85693,22 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
85572
85693
  return null;
85573
85694
  }
85574
85695
  const rect2 = rects2[0];
85575
- const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
85576
- if (!overlayRect) {
85577
- return null;
85578
- }
85696
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
85697
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
85698
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
85699
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
85579
85700
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
85580
85701
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
85581
85702
  const pageLocalY = rect2.y - rect2.pageIndex * (pageHeight + pageGap);
85582
85703
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect2.pageIndex, rect2.x, pageLocalY);
85583
- if (!coords) {
85584
- return null;
85585
- }
85704
+ if (!coords) return null;
85586
85705
  return {
85587
- top: coords.y + overlayRect.top,
85588
- bottom: coords.y + overlayRect.top + rect2.height,
85589
- left: coords.x + overlayRect.left,
85590
- right: coords.x + overlayRect.left + rect2.width,
85591
- width: rect2.width,
85592
- height: rect2.height
85706
+ top: coords.y * zoom - scrollTop + containerRect.top,
85707
+ bottom: coords.y * zoom - scrollTop + containerRect.top + rect2.height * zoom,
85708
+ left: coords.x * zoom - scrollLeft + containerRect.left,
85709
+ right: coords.x * zoom - scrollLeft + containerRect.left + rect2.width * zoom,
85710
+ width: rect2.width * zoom,
85711
+ height: rect2.height * zoom
85593
85712
  };
85594
85713
  }
85595
85714
  const rects = this.getRangeRects(pos, pos);
@@ -86815,6 +86934,19 @@ rerender_fn = async function() {
86815
86934
  __privateSet(this, _layoutState, { blocks, measures, layout, bookmarks, anchorMap });
86816
86935
  __privateSet(this, _headerLayoutResults, headerLayouts ?? null);
86817
86936
  __privateSet(this, _footerLayoutResults, footerLayouts ?? null);
86937
+ const pageWidth = layout.pageSize?.w ?? __privateGet$1(this, _layoutOptions).pageSize?.w ?? DEFAULT_PAGE_SIZE.w;
86938
+ if (__privateGet$1(this, _painterHost)) {
86939
+ __privateGet$1(this, _painterHost).style.width = `${pageWidth}px`;
86940
+ __privateGet$1(this, _painterHost).style.marginLeft = "0";
86941
+ __privateGet$1(this, _painterHost).style.marginRight = "0";
86942
+ }
86943
+ if (__privateGet$1(this, _selectionOverlay2)) {
86944
+ __privateGet$1(this, _selectionOverlay2).style.width = `${pageWidth}px`;
86945
+ __privateGet$1(this, _selectionOverlay2).style.left = "0";
86946
+ __privateGet$1(this, _selectionOverlay2).style.right = "";
86947
+ __privateGet$1(this, _selectionOverlay2).style.marginLeft = "0";
86948
+ __privateGet$1(this, _selectionOverlay2).style.marginRight = "0";
86949
+ }
86818
86950
  await __privateMethod$1(this, _PresentationEditor_instances, layoutPerRIdHeaderFooters_fn).call(this, headerFooterInput, layout, sectionMetadata);
86819
86951
  __privateMethod$1(this, _PresentationEditor_instances, updateDecorationProviders_fn).call(this, layout);
86820
86952
  const painter = __privateMethod$1(this, _PresentationEditor_instances, ensurePainter_fn).call(this, blocks, measures);
@@ -86964,9 +87096,20 @@ updateSelection_fn = function() {
86964
87096
  return;
86965
87097
  }
86966
87098
  const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
87099
+ let domStart = null;
87100
+ let domEnd = null;
87101
+ try {
87102
+ domStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, from2);
87103
+ domEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, to);
87104
+ } catch (error) {
87105
+ if (process$1$1.env.NODE_ENV === "development") {
87106
+ console.warn("[PresentationEditor] DOM caret computation failed in #renderLocalSelection:", error);
87107
+ }
87108
+ }
87109
+ const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
86967
87110
  try {
86968
87111
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
86969
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects);
87112
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
86970
87113
  } catch (error) {
86971
87114
  if (process$1$1.env.NODE_ENV === "development") {
86972
87115
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -87741,6 +87884,43 @@ getHeaderFooterPageHeight_fn = function() {
87741
87884
  }
87742
87885
  return context.layout.pageSize?.h ?? context.region.height ?? 1;
87743
87886
  };
87887
+ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
87888
+ if (rects.length === 0) return rects;
87889
+ const pageDelta = {};
87890
+ if (domStart && rects[0] && domStart.pageIndex === rects[0].pageIndex) {
87891
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87892
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87893
+ const layoutY = rects[0].y - rects[0].pageIndex * (pageHeight + pageGap);
87894
+ pageDelta[domStart.pageIndex] = {
87895
+ dx: domStart.x - rects[0].x,
87896
+ dy: domStart.y - layoutY
87897
+ };
87898
+ }
87899
+ return rects.map((rect, idx) => {
87900
+ const delta = pageDelta[rect.pageIndex];
87901
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
87902
+ let adjustedY = delta ? rect.y + delta.dy : rect.y;
87903
+ let adjustedWidth = rect.width;
87904
+ const isFirstRect = idx === 0;
87905
+ const isLastRect = idx === rects.length - 1;
87906
+ if (isFirstRect && domStart && rect.pageIndex === domStart.pageIndex) {
87907
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87908
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87909
+ adjustedX = domStart.x;
87910
+ adjustedY = domStart.y + rect.pageIndex * (pageHeight + pageGap);
87911
+ }
87912
+ if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
87913
+ const endX = domEnd.x;
87914
+ adjustedWidth = Math.max(1, endX - adjustedX);
87915
+ }
87916
+ return {
87917
+ ...rect,
87918
+ x: adjustedX,
87919
+ y: adjustedY,
87920
+ width: adjustedWidth
87921
+ };
87922
+ });
87923
+ };
87744
87924
  renderSelectionRects_fn = function(rects) {
87745
87925
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
87746
87926
  if (!localSelectionLayer) {
@@ -87748,7 +87928,7 @@ renderSelectionRects_fn = function(rects) {
87748
87928
  }
87749
87929
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
87750
87930
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
87751
- rects.forEach((rect, _index) => {
87931
+ rects.forEach((rect) => {
87752
87932
  const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
87753
87933
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
87754
87934
  if (!coords) {
@@ -87987,6 +88167,20 @@ createLayoutMetrics_fn = function(perf, startMark, layout, blocks) {
87987
88167
  pageCount: layout.pages?.length ?? 0
87988
88168
  };
87989
88169
  };
88170
+ getPageOffsetX_fn = function(pageIndex) {
88171
+ if (!__privateGet$1(this, _painterHost) || !__privateGet$1(this, _viewportHost)) {
88172
+ return null;
88173
+ }
88174
+ const pageEl = __privateGet$1(this, _painterHost).querySelector(
88175
+ `.superdoc-page[data-page-index="${pageIndex}"]`
88176
+ );
88177
+ if (!pageEl) return null;
88178
+ const pageRect = pageEl.getBoundingClientRect();
88179
+ const viewportRect = __privateGet$1(this, _viewportHost).getBoundingClientRect();
88180
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88181
+ const offsetX = (pageRect.left - viewportRect.left) / zoom;
88182
+ return offsetX;
88183
+ };
87990
88184
  convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY) {
87991
88185
  if (!Number.isFinite(pageIndex) || pageIndex < 0) {
87992
88186
  console.warn(
@@ -88008,10 +88202,52 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
88008
88202
  }
88009
88203
  const pageHeight = __privateGet$1(this, _layoutOptions).pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
88010
88204
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
88011
- return {
88012
- x: pageLocalX,
88205
+ const pageOffsetX = __privateMethod$1(this, _PresentationEditor_instances, getPageOffsetX_fn).call(this, pageIndex) ?? 0;
88206
+ const coords = {
88207
+ x: pageOffsetX + pageLocalX,
88013
88208
  y: pageIndex * (pageHeight + pageGap) + pageLocalY
88014
88209
  };
88210
+ return coords;
88211
+ };
88212
+ computeDomCaretPageLocal_fn = function(pos) {
88213
+ __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page span[data-pm-start][data-pm-end]`) ? __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page`) : null;
88214
+ const spans = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll("span[data-pm-start][data-pm-end]"));
88215
+ let targetSpan = null;
88216
+ for (const span of spans) {
88217
+ const pmStart2 = Number(span.dataset.pmStart ?? "NaN");
88218
+ const pmEnd = Number(span.dataset.pmEnd ?? "NaN");
88219
+ if (!Number.isFinite(pmStart2) || !Number.isFinite(pmEnd)) continue;
88220
+ if (pos < pmStart2 || pos > pmEnd) continue;
88221
+ targetSpan = span;
88222
+ break;
88223
+ }
88224
+ if (!targetSpan) return null;
88225
+ const page = targetSpan.closest(".superdoc-page");
88226
+ if (!page) return null;
88227
+ const pageRect = page.getBoundingClientRect();
88228
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88229
+ const textNode = targetSpan.firstChild;
88230
+ if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
88231
+ const spanRect = targetSpan.getBoundingClientRect();
88232
+ return {
88233
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
88234
+ x: (spanRect.left - pageRect.left) / zoom,
88235
+ y: (spanRect.top - pageRect.top) / zoom
88236
+ };
88237
+ }
88238
+ const pmStart = Number(targetSpan.dataset.pmStart ?? "NaN");
88239
+ const charIndex = Math.min(pos - pmStart, textNode.length);
88240
+ const range2 = document.createRange();
88241
+ range2.setStart(textNode, Math.max(0, charIndex));
88242
+ range2.setEnd(textNode, Math.max(0, charIndex));
88243
+ const rangeRect = range2.getBoundingClientRect();
88244
+ const lineEl = targetSpan.closest(".superdoc-line");
88245
+ const lineRect = lineEl?.getBoundingClientRect() ?? rangeRect;
88246
+ return {
88247
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
88248
+ x: (rangeRect.left - pageRect.left) / zoom,
88249
+ y: (lineRect.top - pageRect.top) / zoom
88250
+ };
88015
88251
  };
88016
88252
  normalizeClientPoint_fn = function(clientX, clientY) {
88017
88253
  if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
@@ -88021,18 +88257,29 @@ normalizeClientPoint_fn = function(clientX, clientY) {
88021
88257
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88022
88258
  const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
88023
88259
  const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
88260
+ const baseX = (clientX - rect.left + scrollLeft) / zoom;
88261
+ const baseY = (clientY - rect.top + scrollTop) / zoom;
88262
+ let adjustedX = baseX;
88263
+ const doc2 = __privateGet$1(this, _visibleHost).ownerDocument ?? document;
88264
+ const hitChain = typeof doc2.elementsFromPoint === "function" ? doc2.elementsFromPoint(clientX, clientY) : [];
88265
+ const pageEl = Array.isArray(hitChain) ? hitChain.find((el) => el?.classList?.contains("superdoc-page")) : null;
88266
+ if (pageEl) {
88267
+ const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
88268
+ if (Number.isFinite(pageIndex)) {
88269
+ const pageOffsetX = __privateMethod$1(this, _PresentationEditor_instances, getPageOffsetX_fn).call(this, pageIndex);
88270
+ if (pageOffsetX != null) {
88271
+ adjustedX = baseX - pageOffsetX;
88272
+ }
88273
+ }
88274
+ }
88024
88275
  return {
88025
- x: (clientX - rect.left + scrollLeft) / zoom,
88026
- y: (clientY - rect.top + scrollTop) / zoom
88276
+ x: adjustedX,
88277
+ y: baseY
88027
88278
  };
88028
88279
  };
88029
- computeCaretLayoutRect_fn = function(pos) {
88280
+ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
88030
88281
  const layout = __privateGet$1(this, _layoutState).layout;
88031
88282
  if (!layout) return null;
88032
- const domResult = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectFromDOM_fn).call(this, pos);
88033
- if (domResult) {
88034
- return domResult;
88035
- }
88036
88283
  const hit = getFragmentAtPosition(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pos);
88037
88284
  if (!hit) {
88038
88285
  return null;
@@ -88054,101 +88301,82 @@ computeCaretLayoutRect_fn = function(pos) {
88054
88301
  const { line, index: index2 } = lineInfo;
88055
88302
  const range2 = computeLinePmRange(block, line);
88056
88303
  if (range2.pmStart == null || range2.pmEnd == null) return null;
88057
- const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
88058
- const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
88059
- const localX = fragment.x + measureCharacterX(block, line, pmOffset);
88304
+ const pmOffset = pmPosToCharOffset(block, line, pos);
88305
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
88306
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
88307
+ const paraIndentRight = block.attrs?.indent?.right ?? 0;
88308
+ const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
88309
+ const charX = measureCharacterX(block, line, pmOffset, availableWidth);
88310
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
88311
+ const isFirstLine = index2 === fragment.fromLine;
88312
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
88313
+ let indentAdjust = 0;
88314
+ if (!isListFirstLine) {
88315
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
88316
+ }
88317
+ const localX = fragment.x + markerWidth + indentAdjust + charX;
88060
88318
  const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
88061
88319
  const localY = fragment.y + lineOffset;
88062
- return {
88320
+ const result = {
88063
88321
  pageIndex: hit.pageIndex,
88064
88322
  x: localX,
88065
88323
  y: localY,
88066
88324
  height: line.lineHeight
88067
88325
  };
88068
- };
88069
- computeCaretLayoutRectFromDOM_fn = function(pos) {
88326
+ const pageEl = __privateGet$1(this, _painterHost)?.querySelector(
88327
+ `.superdoc-page[data-page-index="${hit.pageIndex}"]`
88328
+ );
88329
+ const pageRect = pageEl?.getBoundingClientRect();
88070
88330
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
88071
- let targetPageEl = null;
88072
- if (__privateGet$1(this, _layoutState).layout && __privateGet$1(this, _layoutState).blocks && __privateGet$1(this, _layoutState).measures) {
88073
- const fragmentHit = getFragmentAtPosition(
88074
- __privateGet$1(this, _layoutState).layout,
88075
- __privateGet$1(this, _layoutState).blocks,
88076
- __privateGet$1(this, _layoutState).measures,
88077
- pos
88078
- );
88079
- if (fragmentHit) {
88080
- const pageEl = __privateGet$1(this, _viewportHost).querySelector(
88081
- `.superdoc-page[data-page-index="${fragmentHit.pageIndex}"]`
88082
- );
88083
- if (pageEl) {
88084
- targetPageEl = pageEl;
88331
+ let domCaretX = null;
88332
+ let domCaretY = null;
88333
+ const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
88334
+ for (const spanEl of spanEls) {
88335
+ const pmStart = Number(spanEl.dataset.pmStart);
88336
+ const pmEnd = Number(spanEl.dataset.pmEnd);
88337
+ if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
88338
+ const textNode = spanEl.firstChild;
88339
+ const charIndex = Math.min(pos - pmStart, textNode.length);
88340
+ const rangeObj = document.createRange();
88341
+ rangeObj.setStart(textNode, charIndex);
88342
+ rangeObj.setEnd(textNode, charIndex);
88343
+ const rangeRect = rangeObj.getBoundingClientRect();
88344
+ if (pageRect) {
88345
+ domCaretX = (rangeRect.left - pageRect.left) / zoom;
88346
+ domCaretY = (rangeRect.top - pageRect.top) / zoom;
88085
88347
  }
88348
+ break;
88086
88349
  }
88087
88350
  }
88088
- const spanEls = Array.from(
88089
- targetPageEl ? targetPageEl.querySelectorAll(`span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`) : __privateGet$1(this, _viewportHost).querySelectorAll(
88090
- `span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`
88091
- )
88092
- );
88093
- for (const spanEl of spanEls) {
88094
- const pmStart = Number(spanEl.dataset.pmStart ?? "NaN");
88095
- const pmEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
88096
- if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd)) continue;
88097
- if (pos < pmStart || pos > pmEnd) continue;
88098
- const pageEl = spanEl.closest(".superdoc-page");
88099
- if (!pageEl) continue;
88100
- const pageIndex = Number(pageEl.dataset.pageIndex ?? "0");
88101
- const pageRect = pageEl.getBoundingClientRect();
88102
- const textNode = spanEl.firstChild;
88103
- if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
88104
- const spanRect2 = spanEl.getBoundingClientRect();
88105
- return {
88106
- pageIndex,
88107
- x: (spanRect2.left - pageRect.left) / zoom,
88108
- y: (spanRect2.top - pageRect.top) / zoom,
88109
- height: spanRect2.height / zoom
88110
- };
88111
- }
88112
- const text = textNode.textContent ?? "";
88113
- const charOffset = Math.max(0, Math.min(text.length, pos - pmStart));
88114
- const range2 = document.createRange();
88115
- try {
88116
- range2.setStart(textNode, charOffset);
88117
- range2.setEnd(textNode, charOffset);
88118
- } catch (error) {
88119
- if (process$1$1.env.NODE_ENV === "development") {
88120
- console.warn("[PresentationEditor] Range.setStart/setEnd failed:", {
88121
- error: error instanceof Error ? error.message : String(error),
88122
- charOffset,
88123
- textLength: text.length,
88124
- pos,
88125
- pmStart,
88126
- pmEnd
88127
- });
88128
- }
88129
- const spanRect2 = spanEl.getBoundingClientRect();
88130
- return {
88131
- pageIndex,
88132
- x: (spanRect2.left - pageRect.left) / zoom,
88133
- y: (spanRect2.top - pageRect.top) / zoom,
88134
- height: spanRect2.height / zoom
88135
- };
88351
+ if (includeDomFallback && domCaretX != null && domCaretY != null) {
88352
+ return {
88353
+ pageIndex: hit.pageIndex,
88354
+ x: domCaretX,
88355
+ y: domCaretY,
88356
+ height: line.lineHeight
88357
+ };
88358
+ }
88359
+ return result;
88360
+ };
88361
+ computeCaretLayoutRect_fn = function(pos) {
88362
+ const geometry = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, pos, true);
88363
+ let dom = null;
88364
+ try {
88365
+ dom = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, pos);
88366
+ } catch (error) {
88367
+ if (process$1$1.env.NODE_ENV === "development") {
88368
+ console.warn("[PresentationEditor] DOM caret computation failed in #computeCaretLayoutRect:", error);
88136
88369
  }
88137
- const rangeRect = range2.getBoundingClientRect();
88138
- const spanRect = spanEl.getBoundingClientRect();
88139
- const lineEl = spanEl.closest(".superdoc-line");
88140
- const lineRect = lineEl ? lineEl.getBoundingClientRect() : spanRect;
88141
- const caretHeight = spanRect.height;
88142
- const verticalOffset = (lineRect.height - caretHeight) / 2;
88143
- const caretY = lineRect.top + verticalOffset;
88370
+ }
88371
+ if (dom && geometry) {
88144
88372
  return {
88145
- pageIndex,
88146
- x: (rangeRect.left - pageRect.left) / zoom,
88147
- y: (caretY - pageRect.top) / zoom,
88148
- height: caretHeight / zoom
88373
+ pageIndex: dom.pageIndex,
88374
+ x: dom.x,
88375
+ y: dom.y,
88376
+ height: geometry.height
88149
88377
  };
88150
88378
  }
88151
- return null;
88379
+ return geometry;
88152
88380
  };
88153
88381
  computeTableCaretLayoutRect_fn = function(pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
88154
88382
  const lineEls = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll(".superdoc-line"));