superdoc 1.0.0-beta.64 → 1.0.0-beta.66

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-eDXBBm0A.es.js → PdfViewer-BgQnzisJ.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DQuv5TC5.cjs → PdfViewer-CpRzjNks.cjs} +1 -1
  3. package/dist/chunks/{index-uKyvUOIq-BcsSifhl.cjs → index-Bjv0_slj-CIZ6x5_a.cjs} +1 -1
  4. package/dist/chunks/{index-uKyvUOIq-wrjX8LH1.es.js → index-Bjv0_slj-aY5T6UA7.es.js} +1 -1
  5. package/dist/chunks/{index-GODMYLW8.cjs → index-Bw7VVDLD.cjs} +3 -3
  6. package/dist/chunks/{index-LZWibrrm.es.js → index-k63Akk_i.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-BhtY_fQ8.cjs → super-editor.es-CLrhh2DY.cjs} +291 -158
  8. package/dist/chunks/{super-editor.es-CnZWn7ul.es.js → super-editor.es-PQo0jrvJ.es.js} +291 -158
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-BcvDxwm_.js → converter-Ybdn8aYC.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-CNK_ACKk.js → docx-zipper-DkmZTQAw.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-iZ4LJ7th.js → editor-pqbWS9yU.js} +346 -96
  13. package/dist/super-editor/chunks/{index-uKyvUOIq.js → index-Bjv0_slj.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-CopRzMJ_.js → toolbar-CSzCVKWZ.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 +293 -160
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42327,7 +42327,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42327
42327
  static getStoredSuperdocVersion(docx) {
42328
42328
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42329
42329
  }
42330
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.64") {
42330
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.66") {
42331
42331
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42332
42332
  }
42333
42333
  /**
@@ -53496,7 +53496,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
53496
53496
  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);
53497
53497
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
53498
53498
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
53499
- 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;
53499
+ 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, 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;
53500
53500
  var GOOD_LEAF_SIZE = 200;
53501
53501
  var RopeSequence = function RopeSequence2() {
53502
53502
  };
@@ -67373,7 +67373,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67373
67373
  const shouldSkipNodeView = (editor) => {
67374
67374
  return isHeadless(editor);
67375
67375
  };
67376
- const summaryVersion = "1.0.0-beta.64";
67376
+ const summaryVersion = "1.0.0-beta.66";
67377
67377
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67378
67378
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67379
67379
  function mapAttributes(attrs) {
@@ -68162,7 +68162,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68162
68162
  { default: remarkStringify2 },
68163
68163
  { default: remarkGfm2 }
68164
68164
  ] = await Promise.all([
68165
- Promise.resolve().then(() => indexUKyvUOIq),
68165
+ Promise.resolve().then(() => indexBjv0_slj),
68166
68166
  Promise.resolve().then(() => indexDRCvimau),
68167
68167
  Promise.resolve().then(() => indexC_x_N6Uh),
68168
68168
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68367,7 +68367,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68367
68367
  * Process collaboration migrations
68368
68368
  */
68369
68369
  processCollaborationMigrations() {
68370
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.64");
68370
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.66");
68371
68371
  if (!this.options.ydoc) return;
68372
68372
  const metaMap = this.options.ydoc.getMap("meta");
68373
68373
  let docVersion = metaMap.get("version");
@@ -75872,6 +75872,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75872
75872
  let measurementCanvas = null;
75873
75873
  let measurementCtx = null;
75874
75874
  const TAB_CHAR_LENGTH = 1;
75875
+ const SPACE_CHARS = /* @__PURE__ */ new Set([" ", " "]);
75875
75876
  const isTabRun$1 = (run2) => run2?.kind === "tab";
75876
75877
  function getMeasurementContext() {
75877
75878
  if (measurementCtx) return measurementCtx;
@@ -75888,6 +75889,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75888
75889
  }
75889
75890
  return measurementCtx;
75890
75891
  }
75892
+ const countSpaces = (text2) => {
75893
+ let spaces = 0;
75894
+ for (let i2 = 0; i2 < text2.length; i2 += 1) {
75895
+ if (SPACE_CHARS.has(text2[i2])) {
75896
+ spaces += 1;
75897
+ }
75898
+ }
75899
+ return spaces;
75900
+ };
75901
+ const getJustifyAdjustment = (block, line, availableWidthOverride) => {
75902
+ if (block.kind !== "paragraph") {
75903
+ return { extraPerSpace: 0, totalSpaces: 0 };
75904
+ }
75905
+ const alignment2 = block.attrs?.alignment;
75906
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
75907
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
75908
+ const slack = Math.max(0, availableWidth - line.width);
75909
+ if (alignment2 !== "justify" || hasExplicitPositioning || slack <= 0) {
75910
+ return { extraPerSpace: 0, totalSpaces: 0 };
75911
+ }
75912
+ const runs2 = sliceRunsForLine$1(block, line);
75913
+ const totalSpaces = runs2.reduce((sum, run2) => {
75914
+ if (isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
75915
+ return sum;
75916
+ }
75917
+ return sum + countSpaces(run2.text ?? "");
75918
+ }, 0);
75919
+ if (totalSpaces <= 0) {
75920
+ return { extraPerSpace: 0, totalSpaces: 0 };
75921
+ }
75922
+ return {
75923
+ extraPerSpace: slack / totalSpaces,
75924
+ totalSpaces
75925
+ };
75926
+ };
75891
75927
  function getRunFontString(run2) {
75892
75928
  if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
75893
75929
  return "normal normal 16px Arial";
@@ -75945,9 +75981,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75945
75981
  }
75946
75982
  return result;
75947
75983
  }
75948
- function measureCharacterX(block, line, charOffset) {
75984
+ function measureCharacterX(block, line, charOffset, availableWidthOverride) {
75949
75985
  const ctx2 = getMeasurementContext();
75986
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: if no maxWidth, approximate available width as line width (no slack)
75987
+ line.width;
75988
+ const justify = getJustifyAdjustment(block, line, availableWidth);
75989
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
75990
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
75950
75991
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
75992
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
75951
75993
  if (hasExplicitPositioning && line.segments && ctx2) {
75952
75994
  return measureCharacterXSegmentBased(block, line, charOffset, ctx2);
75953
75995
  }
@@ -75962,11 +76004,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75962
76004
  return sum + (run2.text ?? "").length;
75963
76005
  }, 0)
75964
76006
  );
75965
- return charOffset / charsInLine * line.width;
76007
+ return charOffset / charsInLine * renderedLineWidth;
75966
76008
  }
75967
76009
  const runs2 = sliceRunsForLine$1(block, line);
75968
76010
  let currentX = 0;
75969
76011
  let currentCharOffset = 0;
76012
+ let spaceTally = 0;
75970
76013
  for (const run2 of runs2) {
75971
76014
  if (isTabRun$1(run2)) {
75972
76015
  const runLength2 = TAB_CHAR_LENGTH;
@@ -75987,14 +76030,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75987
76030
  const textUpToTarget = text2.slice(0, offsetInRun);
75988
76031
  const measured2 = ctx2.measureText(textUpToTarget);
75989
76032
  const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
75990
- return currentX + measured2.width + spacingWidth;
76033
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToTarget) : 0;
76034
+ return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
75991
76035
  }
75992
76036
  ctx2.font = getRunFontString(run2);
75993
76037
  const measured = ctx2.measureText(text2);
75994
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
76038
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
76039
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text2) : 0;
76040
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
76041
+ spaceTally += spacesInRun;
75995
76042
  currentCharOffset += runLength;
75996
76043
  }
75997
- return currentX;
76044
+ return alignmentOffset + currentX;
75998
76045
  }
75999
76046
  function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
76000
76047
  if (block.kind !== "paragraph" || !line.segments) return 0;
@@ -76069,8 +76116,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
76069
76116
  }
76070
76117
  return lastPm;
76071
76118
  }
76072
- function findCharacterAtX(block, line, x2, pmStart) {
76119
+ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride) {
76073
76120
  const ctx2 = getMeasurementContext();
76121
+ const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: approximate with line width when no maxWidth is present
76122
+ line.width;
76123
+ const justify = getJustifyAdjustment(block, line, availableWidth);
76124
+ const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
76125
+ const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
76126
+ const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
76127
+ const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
76074
76128
  if (!ctx2) {
76075
76129
  const runs22 = sliceRunsForLine$1(block, line);
76076
76130
  const charsInLine = Math.max(
@@ -76082,7 +76136,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
76082
76136
  return sum + (run2.text ?? "").length;
76083
76137
  }, 0)
76084
76138
  );
76085
- const ratio = Math.max(0, Math.min(1, x2 / line.width));
76139
+ const ratio = Math.max(0, Math.min(1, (x2 - alignmentOffset) / renderedLineWidth));
76086
76140
  const charOffset = Math.round(ratio * charsInLine);
76087
76141
  const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
76088
76142
  return {
@@ -76091,9 +76145,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
76091
76145
  };
76092
76146
  }
76093
76147
  const runs2 = sliceRunsForLine$1(block, line);
76094
- const safeX = Math.max(0, Math.min(line.width, x2));
76148
+ const safeX = Math.max(0, Math.min(renderedLineWidth, x2 - alignmentOffset));
76095
76149
  let currentX = 0;
76096
76150
  let currentCharOffset = 0;
76151
+ let spaceTally = 0;
76097
76152
  for (const run2 of runs2) {
76098
76153
  if (isTabRun$1(run2)) {
76099
76154
  const tabWidth = run2.width ?? 0;
@@ -76120,7 +76175,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
76120
76175
  for (let i2 = 0; i2 <= runLength; i2++) {
76121
76176
  const textUpToChar = text2.slice(0, i2);
76122
76177
  const measured2 = ctx2.measureText(textUpToChar);
76123
- const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i2, runLength);
76178
+ const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToChar) : 0;
76179
+ const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i2, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
76124
76180
  if (charX >= safeX) {
76125
76181
  if (i2 === 0) {
76126
76182
  const pmPosition3 = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -76143,7 +76199,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
76143
76199
  }
76144
76200
  }
76145
76201
  const measured = ctx2.measureText(text2);
76146
- currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
76202
+ const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
76203
+ const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text2) : 0;
76204
+ currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
76205
+ spaceTally += spacesInRun;
76147
76206
  currentCharOffset += runLength;
76148
76207
  }
76149
76208
  const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
@@ -87632,7 +87691,7 @@ ${l}
87632
87691
  for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
87633
87692
  const runA = a2.runs[i2];
87634
87693
  const runB = b2.runs[i2];
87635
- if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
87694
+ if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || ("fontSize" in runA ? runA.fontSize : void 0) !== ("fontSize" in runB ? runB.fontSize : void 0) || ("fontFamily" in runA ? runA.fontFamily : void 0) !== ("fontFamily" in runB ? runB.fontFamily : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
87636
87695
  return false;
87637
87696
  }
87638
87697
  }
@@ -88760,7 +88819,10 @@ ${l}
88760
88819
  }
88761
88820
  const line = measure.lines[lineIndex];
88762
88821
  const isRTL = isRtlBlock(block);
88763
- const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL);
88822
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
88823
+ const paraIndentRight = block.attrs?.indent?.right ?? 0;
88824
+ const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
88825
+ const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth);
88764
88826
  if (pos == null) {
88765
88827
  logClickStage("warn", "no-position", {
88766
88828
  blockId: fragment.blockId
@@ -88791,7 +88853,10 @@ ${l}
88791
88853
  if (lineIndex != null) {
88792
88854
  const line = cellMeasure.lines[lineIndex];
88793
88855
  const isRTL = isRtlBlock(cellBlock);
88794
- const pos = mapPointToPm(cellBlock, line, localX, isRTL);
88856
+ const paraIndentLeft = cellBlock.attrs?.indent?.left ?? 0;
88857
+ const paraIndentRight = cellBlock.attrs?.indent?.right ?? 0;
88858
+ const availableWidth = Math.max(0, tableHit.fragment.width - (paraIndentLeft + paraIndentRight));
88859
+ const pos = mapPointToPm(cellBlock, line, localX, isRTL, availableWidth);
88795
88860
  if (pos != null) {
88796
88861
  logClickStage("log", "success", {
88797
88862
  blockId: tableHit.fragment.blockId,
@@ -88950,7 +89015,15 @@ ${l}
88950
89015
  const startX = mapPmToX(block, line, charOffsetFrom, fragment.width);
88951
89016
  const endX = mapPmToX(block, line, charOffsetTo, fragment.width);
88952
89017
  const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
88953
- const rectX = fragment.x + markerWidth + Math.min(startX, endX);
89018
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
89019
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
89020
+ const isFirstLine = index2 === fragment.fromLine;
89021
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
89022
+ let indentAdjust = 0;
89023
+ if (!isListFirstLine) {
89024
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
89025
+ }
89026
+ const rectX = fragment.x + markerWidth + indentAdjust + Math.min(startX, endX);
88954
89027
  const rectWidth = Math.max(1, Math.abs(endX - startX));
88955
89028
  const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
88956
89029
  const rectY = fragment.y + lineOffset;
@@ -89326,11 +89399,11 @@ ${l}
89326
89399
  }
89327
89400
  return height;
89328
89401
  };
89329
- const mapPointToPm = (block, line, x2, isRTL) => {
89402
+ const mapPointToPm = (block, line, x2, isRTL, availableWidthOverride) => {
89330
89403
  if (block.kind !== "paragraph") return null;
89331
89404
  const range2 = computeLinePmRange(block, line);
89332
89405
  if (range2.pmStart == null || range2.pmEnd == null) return null;
89333
- const result = findCharacterAtX(block, line, x2, range2.pmStart);
89406
+ const result = findCharacterAtX(block, line, x2, range2.pmStart, availableWidthOverride);
89334
89407
  if (isRTL) {
89335
89408
  const charOffset = result.charOffset;
89336
89409
  const charsInLine = Math.max(1, line.toChar - line.fromChar);
@@ -89341,7 +89414,10 @@ ${l}
89341
89414
  };
89342
89415
  const mapPmToX = (block, line, offset2, fragmentWidth) => {
89343
89416
  if (fragmentWidth <= 0 || line.width <= 0) return 0;
89344
- return measureCharacterX(block, line, offset2);
89417
+ const paraIndentLeft = block.kind === "paragraph" ? block.attrs?.indent?.left ?? 0 : 0;
89418
+ const paraIndentRight = block.kind === "paragraph" ? block.attrs?.indent?.right ?? 0 : 0;
89419
+ const availableWidth = Math.max(0, fragmentWidth - (paraIndentLeft + paraIndentRight));
89420
+ return measureCharacterX(block, line, offset2, availableWidth);
89345
89421
  };
89346
89422
  const isRtlBlock = (block) => {
89347
89423
  if (block.kind !== "paragraph") return false;
@@ -92006,29 +92082,16 @@ ${l}
92006
92082
  }
92007
92083
  return editorHost;
92008
92084
  };
92009
- positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom) {
92085
+ positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
92010
92086
  const pageElement = editorHost.parentElement;
92011
92087
  if (!pageElement) {
92012
92088
  console.error("[EditorOverlayManager] Editor host has no parent element");
92013
92089
  return;
92014
92090
  }
92015
- let top2;
92016
- let left2;
92017
- let width;
92018
- let height;
92019
- if (decorationContainer) {
92020
- const decorationRect = decorationContainer.getBoundingClientRect();
92021
- const pageRect = pageElement.getBoundingClientRect();
92022
- top2 = decorationRect.top - pageRect.top;
92023
- left2 = decorationRect.left - pageRect.left;
92024
- width = decorationRect.width;
92025
- height = decorationRect.height;
92026
- } else {
92027
- top2 = region.localY * zoom;
92028
- left2 = region.localX * zoom;
92029
- width = region.width * zoom;
92030
- height = region.height * zoom;
92031
- }
92091
+ const top2 = decorationContainer?.offsetTop ?? region.localY;
92092
+ const left2 = decorationContainer?.offsetLeft ?? region.localX;
92093
+ const width = decorationContainer?.offsetWidth ?? region.width;
92094
+ const height = decorationContainer?.offsetHeight ?? region.height;
92032
92095
  Object.assign(editorHost.style, {
92033
92096
  top: `${top2}px`,
92034
92097
  left: `${left2}px`,
@@ -92043,19 +92106,14 @@ ${l}
92043
92106
  }
92044
92107
  }
92045
92108
  };
92046
- showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, zoom) {
92109
+ showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, _zoom) {
92047
92110
  __privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
92048
92111
  __privateSet(this, _borderLine, document.createElement("div"));
92049
92112
  __privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
92050
- let topPosition;
92051
92113
  const isHeader = region.kind === "header";
92052
- if (decorationContainer) {
92053
- const decorationRect = decorationContainer.getBoundingClientRect();
92054
- const pageRect = pageElement.getBoundingClientRect();
92055
- topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
92056
- } else {
92057
- topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
92058
- }
92114
+ const decorationTop = decorationContainer?.offsetTop;
92115
+ const decorationHeight = decorationContainer?.offsetHeight;
92116
+ const topPosition = isHeader ? decorationTop != null && decorationHeight != null ? decorationTop + decorationHeight : region.localY + region.height : decorationTop ?? region.localY;
92059
92117
  Object.assign(__privateGet$1(this, _borderLine).style, {
92060
92118
  position: "absolute",
92061
92119
  left: "0",
@@ -93168,8 +93226,10 @@ ${l}
93168
93226
  const start2 = Math.min(from2, to);
93169
93227
  const end2 = Math.max(from2, to);
93170
93228
  const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
93171
- const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
93172
93229
  const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
93230
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
93231
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
93232
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
93173
93233
  const layoutRectSource = () => {
93174
93234
  if (__privateGet$1(this, _session).mode !== "body") {
93175
93235
  return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
@@ -93180,14 +93240,38 @@ ${l}
93180
93240
  };
93181
93241
  const rawRects = layoutRectSource();
93182
93242
  if (!rawRects.length) return [];
93243
+ const domCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, start2);
93244
+ const domCaretEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, end2);
93245
+ const layoutCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, start2, false);
93246
+ __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, end2, false);
93247
+ const pageDelta = {};
93248
+ if (domCaretStart && layoutCaretStart && domCaretStart.pageIndex === layoutCaretStart.pageIndex) {
93249
+ pageDelta[domCaretStart.pageIndex] = {
93250
+ dx: domCaretStart.x - layoutCaretStart.x,
93251
+ dy: domCaretStart.y - layoutCaretStart.y
93252
+ };
93253
+ }
93183
93254
  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);
93184
93255
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
93185
- return rawRects.map((rect) => {
93186
- const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
93187
- const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
93256
+ const finalRects = rawRects.map((rect, idx, allRects) => {
93257
+ const delta = pageDelta[rect.pageIndex];
93258
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
93259
+ const adjustedY = delta ? rect.y + delta.dy : rect.y;
93260
+ const isFirstRect = idx === 0;
93261
+ const isLastRect = idx === allRects.length - 1;
93262
+ if (isFirstRect && domCaretStart && rect.pageIndex === domCaretStart.pageIndex) {
93263
+ adjustedX = domCaretStart.x;
93264
+ }
93265
+ if (isLastRect && domCaretEnd && rect.pageIndex === domCaretEnd.pageIndex) {
93266
+ const endX = domCaretEnd.x;
93267
+ const newWidth = Math.max(1, endX - adjustedX);
93268
+ rect = { ...rect, width: newWidth };
93269
+ }
93270
+ const pageLocalY = adjustedY - rect.pageIndex * (pageHeight + pageGap);
93271
+ const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, adjustedX, pageLocalY);
93188
93272
  if (!coords) return null;
93189
- const absLeft = coords.x * zoom + overlayRect.left;
93190
- const absTop = coords.y * zoom + overlayRect.top;
93273
+ const absLeft = coords.x * zoom - scrollLeft + containerRect.left;
93274
+ const absTop = coords.y * zoom - scrollTop + containerRect.top;
93191
93275
  const left2 = relativeRect ? absLeft - relativeRect.left : absLeft;
93192
93276
  const top2 = relativeRect ? absTop - relativeRect.top : absTop;
93193
93277
  const width = Math.max(1, rect.width * zoom);
@@ -93202,6 +93286,7 @@ ${l}
93202
93286
  height
93203
93287
  };
93204
93288
  }).filter((rect) => Boolean(rect));
93289
+ return finalRects;
93205
93290
  }
93206
93291
  /**
93207
93292
  * Get selection bounds for a document range with aggregated bounding box.
@@ -93430,24 +93515,22 @@ ${l}
93430
93515
  return null;
93431
93516
  }
93432
93517
  const rect2 = rects2[0];
93433
- const overlayRect = __privateGet$1(this, _selectionOverlay2)?.getBoundingClientRect();
93434
- if (!overlayRect) {
93435
- return null;
93436
- }
93518
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
93519
+ const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
93520
+ const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
93521
+ const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
93437
93522
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
93438
93523
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
93439
93524
  const pageLocalY = rect2.y - rect2.pageIndex * (pageHeight + pageGap);
93440
93525
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect2.pageIndex, rect2.x, pageLocalY);
93441
- if (!coords) {
93442
- return null;
93443
- }
93526
+ if (!coords) return null;
93444
93527
  return {
93445
- top: coords.y + overlayRect.top,
93446
- bottom: coords.y + overlayRect.top + rect2.height,
93447
- left: coords.x + overlayRect.left,
93448
- right: coords.x + overlayRect.left + rect2.width,
93449
- width: rect2.width,
93450
- height: rect2.height
93528
+ top: coords.y * zoom - scrollTop + containerRect.top,
93529
+ bottom: coords.y * zoom - scrollTop + containerRect.top + rect2.height * zoom,
93530
+ left: coords.x * zoom - scrollLeft + containerRect.left,
93531
+ right: coords.x * zoom - scrollLeft + containerRect.left + rect2.width * zoom,
93532
+ width: rect2.width * zoom,
93533
+ height: rect2.height * zoom
93451
93534
  };
93452
93535
  }
93453
93536
  const rects = this.getRangeRects(pos, pos);
@@ -94813,7 +94896,7 @@ ${l}
94813
94896
  }
94814
94897
  try {
94815
94898
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
94816
- __privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout);
94899
+ __privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout, from2);
94817
94900
  } catch (error) {
94818
94901
  if (process$1$1.env.NODE_ENV === "development") {
94819
94902
  console.warn("[PresentationEditor] Failed to render caret overlay:", error);
@@ -94822,9 +94905,12 @@ ${l}
94822
94905
  return;
94823
94906
  }
94824
94907
  const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
94908
+ const domStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, from2);
94909
+ const domEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, to);
94910
+ const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
94825
94911
  try {
94826
94912
  __privateGet$1(this, _localSelectionLayer).innerHTML = "";
94827
- __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, rects);
94913
+ __privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
94828
94914
  } catch (error) {
94829
94915
  if (process$1$1.env.NODE_ENV === "development") {
94830
94916
  console.warn("[PresentationEditor] Failed to render selection rects:", error);
@@ -95599,6 +95685,43 @@ ${l}
95599
95685
  }
95600
95686
  return context.layout.pageSize?.h ?? context.region.height ?? 1;
95601
95687
  };
95688
+ applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
95689
+ if (rects.length === 0) return rects;
95690
+ const pageDelta = {};
95691
+ if (domStart && rects[0] && domStart.pageIndex === rects[0].pageIndex) {
95692
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
95693
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
95694
+ const layoutY = rects[0].y - rects[0].pageIndex * (pageHeight + pageGap);
95695
+ pageDelta[domStart.pageIndex] = {
95696
+ dx: domStart.x - rects[0].x,
95697
+ dy: domStart.y - layoutY
95698
+ };
95699
+ }
95700
+ return rects.map((rect, idx) => {
95701
+ const delta = pageDelta[rect.pageIndex];
95702
+ let adjustedX = delta ? rect.x + delta.dx : rect.x;
95703
+ let adjustedY = delta ? rect.y + delta.dy : rect.y;
95704
+ let adjustedWidth = rect.width;
95705
+ const isFirstRect = idx === 0;
95706
+ const isLastRect = idx === rects.length - 1;
95707
+ if (isFirstRect && domStart && rect.pageIndex === domStart.pageIndex) {
95708
+ const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
95709
+ const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
95710
+ adjustedX = domStart.x;
95711
+ adjustedY = domStart.y + rect.pageIndex * (pageHeight + pageGap);
95712
+ }
95713
+ if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
95714
+ const endX = domEnd.x;
95715
+ adjustedWidth = Math.max(1, endX - adjustedX);
95716
+ }
95717
+ return {
95718
+ ...rect,
95719
+ x: adjustedX,
95720
+ y: adjustedY,
95721
+ width: adjustedWidth
95722
+ };
95723
+ });
95724
+ };
95602
95725
  renderSelectionRects_fn = function(rects) {
95603
95726
  const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
95604
95727
  if (!localSelectionLayer) {
@@ -95606,7 +95729,7 @@ ${l}
95606
95729
  }
95607
95730
  const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
95608
95731
  const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
95609
- rects.forEach((rect, _index) => {
95732
+ rects.forEach((rect) => {
95610
95733
  const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
95611
95734
  const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
95612
95735
  if (!coords) {
@@ -95659,7 +95782,7 @@ ${l}
95659
95782
  __privateGet$1(this, _hoverTooltip).style.display = "none";
95660
95783
  }
95661
95784
  };
95662
- renderCaretOverlay_fn = function(caretLayout) {
95785
+ renderCaretOverlay_fn = function(caretLayout, pos) {
95663
95786
  if (!__privateGet$1(this, _localSelectionLayer)) {
95664
95787
  return;
95665
95788
  }
@@ -95871,6 +95994,46 @@ ${l}
95871
95994
  y: pageIndex * (pageHeight + pageGap) + pageLocalY
95872
95995
  };
95873
95996
  };
95997
+ computeDomCaretPageLocal_fn = function(pos) {
95998
+ __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page span[data-pm-start][data-pm-end]`) ? __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page`) : null;
95999
+ const spans = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll("span[data-pm-start][data-pm-end]"));
96000
+ let targetSpan = null;
96001
+ for (const span of spans) {
96002
+ const pmStart2 = Number(span.dataset.pmStart ?? "NaN");
96003
+ const pmEnd = Number(span.dataset.pmEnd ?? "NaN");
96004
+ if (!Number.isFinite(pmStart2) || !Number.isFinite(pmEnd)) continue;
96005
+ if (pos < pmStart2 || pos > pmEnd) continue;
96006
+ targetSpan = span;
96007
+ break;
96008
+ }
96009
+ if (!targetSpan) return null;
96010
+ const page = targetSpan.closest(".superdoc-page");
96011
+ if (!page) return null;
96012
+ const pageRect = page.getBoundingClientRect();
96013
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
96014
+ const textNode = targetSpan.firstChild;
96015
+ if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
96016
+ const spanRect = targetSpan.getBoundingClientRect();
96017
+ return {
96018
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
96019
+ x: (spanRect.left - pageRect.left) / zoom,
96020
+ y: (spanRect.top - pageRect.top) / zoom
96021
+ };
96022
+ }
96023
+ const pmStart = Number(targetSpan.dataset.pmStart ?? "NaN");
96024
+ const charIndex = Math.min(pos - pmStart, textNode.length);
96025
+ const range2 = document.createRange();
96026
+ range2.setStart(textNode, Math.max(0, charIndex));
96027
+ range2.setEnd(textNode, Math.max(0, charIndex));
96028
+ const rangeRect = range2.getBoundingClientRect();
96029
+ const lineEl = targetSpan.closest(".superdoc-line");
96030
+ const lineRect = lineEl?.getBoundingClientRect() ?? rangeRect;
96031
+ return {
96032
+ pageIndex: Number(page.dataset.pageIndex ?? "0"),
96033
+ x: (rangeRect.left - pageRect.left) / zoom,
96034
+ y: (lineRect.top - pageRect.top) / zoom
96035
+ };
96036
+ };
95874
96037
  normalizeClientPoint_fn = function(clientX, clientY) {
95875
96038
  if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
95876
96039
  return null;
@@ -95884,13 +96047,9 @@ ${l}
95884
96047
  y: (clientY - rect.top + scrollTop) / zoom
95885
96048
  };
95886
96049
  };
95887
- computeCaretLayoutRect_fn = function(pos) {
96050
+ computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
95888
96051
  const layout = __privateGet$1(this, _layoutState).layout;
95889
96052
  if (!layout) return null;
95890
- const domResult = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectFromDOM_fn).call(this, pos);
95891
- if (domResult) {
95892
- return domResult;
95893
- }
95894
96053
  const hit = getFragmentAtPosition(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pos);
95895
96054
  if (!hit) {
95896
96055
  return null;
@@ -95912,101 +96071,75 @@ ${l}
95912
96071
  const { line, index: index2 } = lineInfo;
95913
96072
  const range2 = computeLinePmRange(block, line);
95914
96073
  if (range2.pmStart == null || range2.pmEnd == null) return null;
95915
- const pmCharsInLine = Math.max(1, range2.pmEnd - range2.pmStart);
95916
- const pmOffset = Math.max(0, Math.min(pmCharsInLine, pos - range2.pmStart));
95917
- const localX = fragment.x + measureCharacterX(block, line, pmOffset);
96074
+ const pmOffset = pmPosToCharOffset(block, line, pos);
96075
+ const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
96076
+ const paraIndentLeft = block.attrs?.indent?.left ?? 0;
96077
+ const paraIndentRight = block.attrs?.indent?.right ?? 0;
96078
+ const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
96079
+ const charX = measureCharacterX(block, line, pmOffset, availableWidth);
96080
+ const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
96081
+ const isFirstLine = index2 === fragment.fromLine;
96082
+ const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
96083
+ let indentAdjust = 0;
96084
+ if (!isListFirstLine) {
96085
+ indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
96086
+ }
96087
+ const localX = fragment.x + markerWidth + indentAdjust + charX;
95918
96088
  const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
95919
96089
  const localY = fragment.y + lineOffset;
95920
- return {
96090
+ const result = {
95921
96091
  pageIndex: hit.pageIndex,
95922
96092
  x: localX,
95923
96093
  y: localY,
95924
96094
  height: line.lineHeight
95925
96095
  };
95926
- };
95927
- computeCaretLayoutRectFromDOM_fn = function(pos) {
95928
- const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
95929
- let targetPageEl = null;
95930
- if (__privateGet$1(this, _layoutState).layout && __privateGet$1(this, _layoutState).blocks && __privateGet$1(this, _layoutState).measures) {
95931
- const fragmentHit = getFragmentAtPosition(
95932
- __privateGet$1(this, _layoutState).layout,
95933
- __privateGet$1(this, _layoutState).blocks,
95934
- __privateGet$1(this, _layoutState).measures,
95935
- pos
95936
- );
95937
- if (fragmentHit) {
95938
- const pageEl = __privateGet$1(this, _viewportHost).querySelector(
95939
- `.superdoc-page[data-page-index="${fragmentHit.pageIndex}"]`
95940
- );
95941
- if (pageEl) {
95942
- targetPageEl = pageEl;
95943
- }
95944
- }
95945
- }
95946
- const spanEls = Array.from(
95947
- targetPageEl ? targetPageEl.querySelectorAll(`span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`) : __privateGet$1(this, _viewportHost).querySelectorAll(
95948
- `span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`
95949
- )
96096
+ const pageEl = __privateGet$1(this, _painterHost)?.querySelector(
96097
+ `.superdoc-page[data-page-index="${hit.pageIndex}"]`
95950
96098
  );
96099
+ const pageRect = pageEl?.getBoundingClientRect();
96100
+ const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
96101
+ let domCaretX = null;
96102
+ let domCaretY = null;
96103
+ const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
95951
96104
  for (const spanEl of spanEls) {
95952
- const pmStart = Number(spanEl.dataset.pmStart ?? "NaN");
95953
- const pmEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
95954
- if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd)) continue;
95955
- if (pos < pmStart || pos > pmEnd) continue;
95956
- const pageEl = spanEl.closest(".superdoc-page");
95957
- if (!pageEl) continue;
95958
- const pageIndex = Number(pageEl.dataset.pageIndex ?? "0");
95959
- const pageRect = pageEl.getBoundingClientRect();
95960
- const textNode = spanEl.firstChild;
95961
- if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
95962
- const spanRect2 = spanEl.getBoundingClientRect();
95963
- return {
95964
- pageIndex,
95965
- x: (spanRect2.left - pageRect.left) / zoom,
95966
- y: (spanRect2.top - pageRect.top) / zoom,
95967
- height: spanRect2.height / zoom
95968
- };
95969
- }
95970
- const text2 = textNode.textContent ?? "";
95971
- const charOffset = Math.max(0, Math.min(text2.length, pos - pmStart));
95972
- const range2 = document.createRange();
95973
- try {
95974
- range2.setStart(textNode, charOffset);
95975
- range2.setEnd(textNode, charOffset);
95976
- } catch (error) {
95977
- if (process$1$1.env.NODE_ENV === "development") {
95978
- console.warn("[PresentationEditor] Range.setStart/setEnd failed:", {
95979
- error: error instanceof Error ? error.message : String(error),
95980
- charOffset,
95981
- textLength: text2.length,
95982
- pos,
95983
- pmStart,
95984
- pmEnd
95985
- });
96105
+ const pmStart = Number(spanEl.dataset.pmStart);
96106
+ const pmEnd = Number(spanEl.dataset.pmEnd);
96107
+ if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
96108
+ const textNode = spanEl.firstChild;
96109
+ const charIndex = Math.min(pos - pmStart, textNode.length);
96110
+ const rangeObj = document.createRange();
96111
+ rangeObj.setStart(textNode, charIndex);
96112
+ rangeObj.setEnd(textNode, charIndex);
96113
+ const rangeRect = rangeObj.getBoundingClientRect();
96114
+ if (pageRect) {
96115
+ domCaretX = (rangeRect.left - pageRect.left) / zoom;
96116
+ domCaretY = (rangeRect.top - pageRect.top) / zoom;
95986
96117
  }
95987
- const spanRect2 = spanEl.getBoundingClientRect();
95988
- return {
95989
- pageIndex,
95990
- x: (spanRect2.left - pageRect.left) / zoom,
95991
- y: (spanRect2.top - pageRect.top) / zoom,
95992
- height: spanRect2.height / zoom
95993
- };
96118
+ break;
95994
96119
  }
95995
- const rangeRect = range2.getBoundingClientRect();
95996
- const spanRect = spanEl.getBoundingClientRect();
95997
- const lineEl = spanEl.closest(".superdoc-line");
95998
- const lineRect = lineEl ? lineEl.getBoundingClientRect() : spanRect;
95999
- const caretHeight = spanRect.height;
96000
- const verticalOffset = (lineRect.height - caretHeight) / 2;
96001
- const caretY = lineRect.top + verticalOffset;
96120
+ }
96121
+ if (includeDomFallback && domCaretX != null && domCaretY != null) {
96002
96122
  return {
96003
- pageIndex,
96004
- x: (rangeRect.left - pageRect.left) / zoom,
96005
- y: (caretY - pageRect.top) / zoom,
96006
- height: caretHeight / zoom
96123
+ pageIndex: hit.pageIndex,
96124
+ x: domCaretX,
96125
+ y: domCaretY,
96126
+ height: line.lineHeight
96007
96127
  };
96008
96128
  }
96009
- return null;
96129
+ return result;
96130
+ };
96131
+ computeCaretLayoutRect_fn = function(pos) {
96132
+ const geometry = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, pos, true);
96133
+ const dom = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, pos);
96134
+ if (dom && geometry) {
96135
+ return {
96136
+ pageIndex: dom.pageIndex,
96137
+ x: dom.x,
96138
+ y: dom.y,
96139
+ height: geometry.height
96140
+ };
96141
+ }
96142
+ return geometry;
96010
96143
  };
96011
96144
  computeTableCaretLayoutRect_fn = function(pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
96012
96145
  const lineEls = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll(".superdoc-line"));
@@ -149881,7 +150014,7 @@ ${style2}
149881
150014
  this.config.colors = shuffleArray(this.config.colors);
149882
150015
  this.userColorMap = /* @__PURE__ */ new Map();
149883
150016
  this.colorIndex = 0;
149884
- this.version = "1.0.0-beta.64";
150017
+ this.version = "1.0.0-beta.66";
149885
150018
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
149886
150019
  this.superdocId = config2.superdocId || v4();
149887
150020
  this.colors = this.config.colors;
@@ -152353,7 +152486,7 @@ ${style2}
152353
152486
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
152354
152487
  );
152355
152488
  }
152356
- const indexUKyvUOIq = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152489
+ const indexBjv0_slj = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152357
152490
  __proto__: null,
152358
152491
  unified
152359
152492
  }, Symbol.toStringTag, { value: "Module" }));