@dxos/react-ui-editor 0.6.2-next.5b5129c → 0.6.2

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.
@@ -1523,15 +1523,13 @@ var styles3 = EditorView7.baseTheme({
1523
1523
  backgroundColor: getToken("extend.colors.yellow.900")
1524
1524
  }
1525
1525
  });
1526
- var createCommentMark = (id, isCurrent) => {
1527
- return Decoration4.mark({
1528
- class: isCurrent ? "cm-comment-current" : "cm-comment",
1529
- attributes: {
1530
- "data-testid": "cm-comment",
1531
- "data-comment-id": id
1532
- }
1533
- });
1534
- };
1526
+ var createCommentMark = (id, isCurrent) => Decoration4.mark({
1527
+ class: isCurrent ? "cm-comment-current" : "cm-comment",
1528
+ attributes: {
1529
+ "data-testid": "cm-comment",
1530
+ "data-comment-id": id
1531
+ }
1532
+ });
1535
1533
  var commentsDecorations = EditorView7.decorations.compute([
1536
1534
  commentsState
1537
1535
  ], (state2) => {
@@ -1541,7 +1539,7 @@ var commentsDecorations = EditorView7.decorations.compute([
1541
1539
  if (!range) {
1542
1540
  log4.warn("Invalid range:", range, {
1543
1541
  F: __dxlog_file6,
1544
- L: 160,
1542
+ L: 159,
1545
1543
  S: void 0,
1546
1544
  C: (f, a) => f(...a)
1547
1545
  });
@@ -1843,20 +1841,26 @@ var scrollThreadIntoView = (view, id, center = true) => {
1843
1841
  }
1844
1842
  const range = Cursor.getRangeFromCursor(view.state, comment.comment.cursor);
1845
1843
  if (range) {
1846
- view.dispatch({
1847
- selection: {
1848
- anchor: range.from
1849
- },
1850
- effects: [
1851
- //
1852
- EditorView7.scrollIntoView(range.from, center ? {
1853
- y: "center"
1854
- } : void 0),
1855
- setSelection.of({
1856
- current: id
1857
- })
1858
- ]
1859
- });
1844
+ const currentSelection = view.state.selection.main;
1845
+ const currentScrollPosition = view.scrollDOM.scrollTop;
1846
+ const targetScrollPosition = view.coordsAtPos(range.from)?.top;
1847
+ const needsScroll = targetScrollPosition !== void 0 && (targetScrollPosition < currentScrollPosition || targetScrollPosition > currentScrollPosition + view.scrollDOM.clientHeight);
1848
+ const needsSelectionUpdate = currentSelection.from !== range.from || currentSelection.to !== range.from;
1849
+ if (needsScroll || needsSelectionUpdate) {
1850
+ view.dispatch({
1851
+ selection: needsSelectionUpdate ? {
1852
+ anchor: range.from
1853
+ } : void 0,
1854
+ effects: [
1855
+ needsScroll ? EditorView7.scrollIntoView(range.from, center ? {
1856
+ y: "center"
1857
+ } : void 0) : [],
1858
+ needsSelectionUpdate ? setSelection.of({
1859
+ current: id
1860
+ }) : []
1861
+ ].flat()
1862
+ });
1863
+ }
1860
1864
  }
1861
1865
  };
1862
1866
  var selectionOverlapsComment = (state2) => {