@dxos/react-ui-editor 0.6.2-main.c53e208 → 0.6.2-main.c820d78

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.
@@ -1481,39 +1481,57 @@ var commentsState = StateField4.define({
1481
1481
  }
1482
1482
  });
1483
1483
  var styles3 = EditorView7.baseTheme({
1484
+ ".cm-comment, .cm-comment-current": {
1485
+ cursor: "pointer",
1486
+ borderWidth: "1px",
1487
+ borderStyle: "solid",
1488
+ borderRadius: "2px",
1489
+ transition: "background-color 0.1s ease"
1490
+ },
1484
1491
  "&light .cm-comment, &light .cm-comment-current": {
1485
- mixBlendMode: "darken"
1492
+ mixBlendMode: "darken",
1493
+ borderColor: getToken("extend.colors.yellow.100")
1486
1494
  },
1487
1495
  "&dark .cm-comment, &dark .cm-comment-current": {
1488
- mixBlendMode: "plus-lighter"
1496
+ mixBlendMode: "plus-lighter",
1497
+ borderColor: getToken("extend.colors.yellow.900")
1489
1498
  },
1490
1499
  "&light .cm-comment": {
1491
1500
  backgroundColor: getToken("extend.colors.yellow.50")
1492
1501
  },
1502
+ "&light .cm-comment:hover": {
1503
+ backgroundColor: getToken("extend.colors.yellow.100")
1504
+ },
1493
1505
  "&light .cm-comment-current": {
1494
1506
  backgroundColor: getToken("extend.colors.yellow.100")
1495
1507
  },
1508
+ "&light .cm-comment-current:hover": {
1509
+ backgroundColor: getToken("extend.colors.yellow.150")
1510
+ },
1496
1511
  "&dark .cm-comment": {
1497
1512
  color: getToken("extend.colors.yellow.50"),
1498
1513
  backgroundColor: getToken("extend.colors.yellow.900")
1499
1514
  },
1515
+ "&dark .cm-comment:hover": {
1516
+ backgroundColor: getToken("extend.colors.yellow.800")
1517
+ },
1500
1518
  "&dark .cm-comment-current": {
1501
1519
  color: getToken("extend.colors.yellow.100"),
1502
1520
  backgroundColor: getToken("extend.colors.yellow.950")
1521
+ },
1522
+ "&dark .cm-comment-current:hover": {
1523
+ backgroundColor: getToken("extend.colors.yellow.900")
1503
1524
  }
1504
1525
  });
1505
- var commentMark = Decoration4.mark({
1506
- class: "cm-comment",
1507
- attributes: {
1508
- "data-testid": "cm-comment"
1509
- }
1510
- });
1511
- var commentCurrentMark = Decoration4.mark({
1512
- class: "cm-comment-current",
1513
- attributes: {
1514
- "data-testid": "cm-comment"
1515
- }
1516
- });
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
+ };
1517
1535
  var commentsDecorations = EditorView7.decorations.compute([
1518
1536
  commentsState
1519
1537
  ], (state2) => {
@@ -1523,7 +1541,7 @@ var commentsDecorations = EditorView7.decorations.compute([
1523
1541
  if (!range) {
1524
1542
  log4.warn("Invalid range:", range, {
1525
1543
  F: __dxlog_file6,
1526
- L: 141,
1544
+ L: 160,
1527
1545
  S: void 0,
1528
1546
  C: (f, a) => f(...a)
1529
1547
  });
@@ -1531,14 +1549,31 @@ var commentsDecorations = EditorView7.decorations.compute([
1531
1549
  } else if (range.from === range.to) {
1532
1550
  return void 0;
1533
1551
  }
1534
- if (comment.comment.id === current) {
1535
- return commentCurrentMark.range(range.from, range.to);
1536
- } else {
1537
- return commentMark.range(range.from, range.to);
1538
- }
1552
+ const mark2 = createCommentMark(comment.comment.id, comment.comment.id === current);
1553
+ return mark2.range(range.from, range.to);
1539
1554
  }).filter(nonNullable);
1540
1555
  return Decoration4.set(decorations);
1541
1556
  });
1557
+ var commentClickedEffect = StateEffect3.define();
1558
+ var handleCommentClick = EditorView7.domEventHandlers({
1559
+ click: (event, view) => {
1560
+ let target = event.target;
1561
+ const editorRoot = view.dom;
1562
+ while (target && target !== editorRoot && !target.hasAttribute("data-comment-id")) {
1563
+ target = target.parentElement;
1564
+ }
1565
+ if (target && target !== editorRoot) {
1566
+ const commentId = target.getAttribute("data-comment-id");
1567
+ if (commentId) {
1568
+ view.dispatch({
1569
+ effects: commentClickedEffect.of(commentId)
1570
+ });
1571
+ return true;
1572
+ }
1573
+ }
1574
+ return false;
1575
+ }
1576
+ });
1542
1577
  var trackPastedComments = (onUpdate) => {
1543
1578
  let tracked = null;
1544
1579
  const handleTrack = (event, view) => {
@@ -1689,6 +1724,7 @@ var comments = (options = {}) => {
1689
1724
  documentId.of(options.id),
1690
1725
  commentsState,
1691
1726
  commentsDecorations,
1727
+ handleCommentClick,
1692
1728
  styles3,
1693
1729
  //
1694
1730
  // Keymap.
@@ -1872,6 +1908,20 @@ var useCommentState = () => {
1872
1908
  observer
1873
1909
  ];
1874
1910
  };
1911
+ var useCommentClickListener = (onCommentClick) => {
1912
+ const observer = useMemo(() => EditorView7.updateListener.of((update2) => {
1913
+ update2.transactions.forEach((transaction) => {
1914
+ transaction.effects.forEach((effect) => {
1915
+ if (effect.is(commentClickedEffect)) {
1916
+ onCommentClick(effect.value);
1917
+ }
1918
+ });
1919
+ });
1920
+ }), [
1921
+ onCommentClick
1922
+ ]);
1923
+ return observer;
1924
+ };
1875
1925
 
1876
1926
  // packages/ui/react-ui-editor/src/extensions/doc.ts
1877
1927
  import { Facet as Facet5 } from "@codemirror/state";
@@ -5193,6 +5243,7 @@ export {
5193
5243
  translations_default as translations,
5194
5244
  typewriter,
5195
5245
  useActionHandler,
5246
+ useCommentClickListener,
5196
5247
  useCommentState,
5197
5248
  useComments,
5198
5249
  useFormattingState,