@dxos/react-ui-editor 0.4.7-main.dca306f → 0.4.7-main.e5c4f14

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 (42) hide show
  1. package/dist/lib/browser/index.mjs +347 -149
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +6 -0
  5. package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
  6. package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
  7. package/dist/types/src/extensions/command/command.d.ts +10 -0
  8. package/dist/types/src/extensions/command/command.d.ts.map +1 -0
  9. package/dist/types/src/extensions/command/hint.d.ts +7 -0
  10. package/dist/types/src/extensions/command/hint.d.ts.map +1 -0
  11. package/dist/types/src/extensions/command/index.d.ts +2 -0
  12. package/dist/types/src/extensions/command/index.d.ts.map +1 -0
  13. package/dist/types/src/extensions/command/state.d.ts +18 -0
  14. package/dist/types/src/extensions/command/state.d.ts.map +1 -0
  15. package/dist/types/src/extensions/dnd.d.ts +3 -0
  16. package/dist/types/src/extensions/dnd.d.ts.map +1 -0
  17. package/dist/types/src/extensions/index.d.ts +2 -0
  18. package/dist/types/src/extensions/index.d.ts.map +1 -1
  19. package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
  20. package/dist/types/src/extensions/util/dom.d.ts +15 -0
  21. package/dist/types/src/extensions/util/dom.d.ts.map +1 -0
  22. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
  23. package/dist/types/src/styles/index.d.ts +0 -1
  24. package/dist/types/src/styles/index.d.ts.map +1 -1
  25. package/package.json +25 -25
  26. package/src/components/TextEditor/MarkdownEditor.stories.tsx +72 -4
  27. package/src/components/TextEditor/TextEditor.tsx +2 -0
  28. package/src/extensions/awareness.ts +3 -3
  29. package/src/extensions/command/command.ts +38 -0
  30. package/src/extensions/command/hint.ts +75 -0
  31. package/src/extensions/command/index.ts +5 -0
  32. package/src/extensions/command/state.ts +106 -0
  33. package/src/extensions/dnd.ts +15 -0
  34. package/src/extensions/index.ts +2 -0
  35. package/src/extensions/markdown/bundle.ts +0 -1
  36. package/src/extensions/markdown/decorate.ts +1 -1
  37. package/src/extensions/util/dom.ts +36 -0
  38. package/src/hooks/useTextModel.ts +12 -5
  39. package/src/styles/index.ts +0 -1
  40. package/dist/types/src/styles/cursors.d.ts +0 -5
  41. package/dist/types/src/styles/cursors.d.ts.map +0 -1
  42. package/src/styles/cursors.ts +0 -21
@@ -23,7 +23,7 @@ var translations_default = [
23
23
  ];
24
24
 
25
25
  // packages/ui/react-ui-editor/src/index.ts
26
- import { keymap as keymap8 } from "@codemirror/view";
26
+ import { keymap as keymap9 } from "@codemirror/view";
27
27
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
28
28
  import { Doc, YText, YXmlFragment } from "@dxos/text-model";
29
29
 
@@ -32,7 +32,7 @@ import { tags as tags2 } from "@lezer/highlight";
32
32
 
33
33
  // packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
34
34
  import { EditorState as EditorState2 } from "@codemirror/state";
35
- import { EditorView as EditorView14, scrollPastEnd } from "@codemirror/view";
35
+ import { EditorView as EditorView17, scrollPastEnd } from "@codemirror/view";
36
36
  import { useFocusableGroup } from "@fluentui/react-tabster";
37
37
  import defaultsDeep2 from "lodash.defaultsdeep";
38
38
  import React, { forwardRef, useCallback, useEffect as useEffect2, useImperativeHandle, useRef, useState as useState2, useMemo as useMemo2 } from "react";
@@ -596,7 +596,7 @@ var RemoteSelectionsDecorator = class {
596
596
  to: startLine.from + startLine.length,
597
597
  value: Decoration2.mark({
598
598
  attributes: {
599
- style: `background-color: ${color}`
599
+ style: `background-color: ${lightColor}`
600
600
  },
601
601
  class: "cm-collab-selection"
602
602
  })
@@ -606,7 +606,7 @@ var RemoteSelectionsDecorator = class {
606
606
  to: end,
607
607
  value: Decoration2.mark({
608
608
  attributes: {
609
- style: `background-color: ${color}`
609
+ style: `background-color: ${lightColor}`
610
610
  },
611
611
  class: "cm-collab-selection"
612
612
  })
@@ -618,7 +618,7 @@ var RemoteSelectionsDecorator = class {
618
618
  to: linePos,
619
619
  value: Decoration2.line({
620
620
  attributes: {
621
- style: `background-color: ${color}`,
621
+ style: `background-color: ${lightColor}`,
622
622
  class: "cm-collab-selectionLine"
623
623
  }
624
624
  })
@@ -1063,52 +1063,232 @@ var random = (min, max) => {
1063
1063
  return min + ~~(Math.random() * (max - min + 1));
1064
1064
  };
1065
1065
 
1066
- // packages/ui/react-ui-editor/src/extensions/comments.ts
1067
- import { invertedEffects } from "@codemirror/commands";
1068
- import { Facet as Facet3, StateEffect as StateEffect2, StateField as StateField3 } from "@codemirror/state";
1069
- import { hoverTooltip, keymap as keymap3, Decoration as Decoration3, EditorView as EditorView6 } from "@codemirror/view";
1070
- import sortBy from "lodash.sortby";
1071
- import { useEffect } from "react";
1072
- import { debounce } from "@dxos/async";
1073
- import { nonNullable } from "@dxos/util";
1066
+ // packages/ui/react-ui-editor/src/extensions/command/command.ts
1067
+ import { EditorView as EditorView7, keymap as keymap3 } from "@codemirror/view";
1074
1068
 
1075
- // packages/ui/react-ui-editor/src/styles/cursors.ts
1076
- import * as random2 from "lib0/random";
1077
- var cursorColors = [
1078
- {
1079
- color: "#30bced",
1080
- light: "#30bced33"
1081
- },
1082
- {
1083
- color: "#6eeb83",
1084
- light: "#6eeb8333"
1085
- },
1086
- {
1087
- color: "#ffbc42",
1088
- light: "#ffbc4233"
1089
- },
1090
- {
1091
- color: "#ecd444",
1092
- light: "#ecd44433"
1093
- },
1094
- {
1095
- color: "#ee6352",
1096
- light: "#ee635233"
1097
- },
1098
- {
1099
- color: "#9ac2c9",
1100
- light: "#9ac2c933"
1069
+ // packages/ui/react-ui-editor/src/extensions/command/hint.ts
1070
+ import { RangeSetBuilder } from "@codemirror/state";
1071
+ import { Decoration as Decoration3, EditorView as EditorView6, ViewPlugin as ViewPlugin3, WidgetType as WidgetType2 } from "@codemirror/view";
1072
+
1073
+ // packages/ui/react-ui-editor/src/extensions/command/state.ts
1074
+ import { Facet as Facet3, StateEffect as StateEffect2, StateField as StateField3 } from "@codemirror/state";
1075
+ import { showTooltip } from "@codemirror/view";
1076
+ var commandConfig = Facet3.define({
1077
+ combine: (providers) => providers[0]
1078
+ });
1079
+ var commandState = StateField3.define({
1080
+ create: () => ({}),
1081
+ update: (state, tr) => {
1082
+ for (const effect of tr.effects) {
1083
+ if (effect.is(closeEffect)) {
1084
+ return {};
1085
+ }
1086
+ if (effect.is(openEffect)) {
1087
+ const options = tr.state.facet(commandConfig);
1088
+ const { pos, fullWidth } = effect.value;
1089
+ const tooltip = {
1090
+ pos,
1091
+ above: false,
1092
+ arrow: false,
1093
+ strictSide: true,
1094
+ create: (view) => {
1095
+ const dom = document.createElement("div");
1096
+ const tooltipView = {
1097
+ dom,
1098
+ mount: (view2) => {
1099
+ if (fullWidth) {
1100
+ const parent = dom.parentElement;
1101
+ const { paddingLeft, paddingRight } = window.getComputedStyle(parent);
1102
+ const widthWithoutPadding = parent.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
1103
+ dom.style.width = `${widthWithoutPadding}px`;
1104
+ }
1105
+ options.onRender(dom, (action) => {
1106
+ view2.dispatch({
1107
+ effects: closeEffect.of(null)
1108
+ });
1109
+ if (action?.insert?.length) {
1110
+ view2.dispatch({
1111
+ changes: {
1112
+ from: pos,
1113
+ insert: action.insert
1114
+ },
1115
+ selection: {
1116
+ anchor: pos + action.insert.length
1117
+ }
1118
+ });
1119
+ }
1120
+ setTimeout(() => view2.focus());
1121
+ });
1122
+ }
1123
+ };
1124
+ return tooltipView;
1125
+ }
1126
+ };
1127
+ return {
1128
+ tooltip
1129
+ };
1130
+ }
1131
+ }
1132
+ return state;
1101
1133
  },
1134
+ provide: (f) => [
1135
+ showTooltip.from(f, (value) => value.tooltip ?? null)
1136
+ ]
1137
+ });
1138
+ var openEffect = StateEffect2.define();
1139
+ var closeEffect = StateEffect2.define();
1140
+ var openCommand = (view) => {
1141
+ if (view.state.field(commandState, false)) {
1142
+ const selection = view.state.selection.main;
1143
+ const line = view.state.doc.lineAt(selection.from);
1144
+ if (line.from === selection.from && line.from === line.to) {
1145
+ view.dispatch({
1146
+ effects: openEffect.of({
1147
+ pos: selection.anchor,
1148
+ fullWidth: true
1149
+ })
1150
+ });
1151
+ return true;
1152
+ }
1153
+ }
1154
+ return false;
1155
+ };
1156
+ var closeCommand = (view) => {
1157
+ if (view.state.field(commandState, false)) {
1158
+ view.dispatch({
1159
+ effects: closeEffect.of(null)
1160
+ });
1161
+ return true;
1162
+ }
1163
+ return false;
1164
+ };
1165
+ var commandKeymap = [
1102
1166
  {
1103
- color: "#8acb88",
1104
- light: "#8acb8833"
1167
+ key: "/",
1168
+ run: openCommand
1105
1169
  },
1106
1170
  {
1107
- color: "#1be7ff",
1108
- light: "#1be7ff33"
1171
+ key: "Escape",
1172
+ run: closeCommand
1109
1173
  }
1110
1174
  ];
1111
- var cursorColor = cursorColors[random2.uint32() % cursorColors.length];
1175
+
1176
+ // packages/ui/react-ui-editor/src/extensions/util/dom.ts
1177
+ var flattenRect = (rect, left) => {
1178
+ const x = left ? rect.left : rect.right;
1179
+ return {
1180
+ left: x,
1181
+ right: x,
1182
+ top: rect.top,
1183
+ bottom: rect.bottom
1184
+ };
1185
+ };
1186
+ var scratchRange;
1187
+ var textRange = (node, from, to = from) => {
1188
+ const range = scratchRange || (scratchRange = document.createRange());
1189
+ range.setEnd(node, to);
1190
+ range.setStart(node, from);
1191
+ return range;
1192
+ };
1193
+ var clientRectsFor = (dom) => {
1194
+ if (dom.nodeType === 3) {
1195
+ return textRange(dom, 0, dom.nodeValue.length).getClientRects();
1196
+ } else if (dom.nodeType === 1) {
1197
+ return dom.getClientRects();
1198
+ } else {
1199
+ return [];
1200
+ }
1201
+ };
1202
+
1203
+ // packages/ui/react-ui-editor/src/extensions/command/hint.ts
1204
+ var CommandHint = class extends WidgetType2 {
1205
+ constructor(content) {
1206
+ super();
1207
+ this.content = content;
1208
+ }
1209
+ toDOM() {
1210
+ const wrap = document.createElement("span");
1211
+ wrap.className = "cm-placeholder";
1212
+ wrap.style.pointerEvents = "none";
1213
+ wrap.appendChild(typeof this.content === "string" ? document.createTextNode(this.content) : this.content);
1214
+ if (typeof this.content === "string") {
1215
+ wrap.setAttribute("aria-label", "placeholder " + this.content);
1216
+ } else {
1217
+ wrap.setAttribute("aria-hidden", "true");
1218
+ }
1219
+ return wrap;
1220
+ }
1221
+ coordsAt(dom) {
1222
+ const rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];
1223
+ if (!rects.length) {
1224
+ return null;
1225
+ }
1226
+ const style = window.getComputedStyle(dom.parentNode);
1227
+ const rect = flattenRect(rects[0], style.direction !== "rtl");
1228
+ const lineHeight = parseInt(style.lineHeight);
1229
+ if (rect.bottom - rect.top > lineHeight * 1.5) {
1230
+ return {
1231
+ left: rect.left,
1232
+ right: rect.right,
1233
+ top: rect.top,
1234
+ bottom: rect.top + lineHeight
1235
+ };
1236
+ }
1237
+ return rect;
1238
+ }
1239
+ ignoreEvent() {
1240
+ return false;
1241
+ }
1242
+ };
1243
+ var hintViewPlugin = ({ onHint }) => ViewPlugin3.fromClass(class {
1244
+ constructor() {
1245
+ this.deco = Decoration3.none;
1246
+ }
1247
+ update(update2) {
1248
+ const builder = new RangeSetBuilder();
1249
+ const cState = update2.view.state.field(commandState, false);
1250
+ if (!cState?.tooltip) {
1251
+ const selection = update2.view.state.selection.main;
1252
+ const line = update2.view.state.doc.lineAt(selection.from);
1253
+ if (selection.from === selection.to && line.from === line.to) {
1254
+ const hint = onHint();
1255
+ if (hint) {
1256
+ builder.add(selection.from, selection.to, Decoration3.widget({
1257
+ widget: new CommandHint(hint)
1258
+ }));
1259
+ }
1260
+ }
1261
+ }
1262
+ this.deco = builder.finish();
1263
+ }
1264
+ }, {
1265
+ provide: (plugin) => [
1266
+ EditorView6.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration3.none)
1267
+ ]
1268
+ });
1269
+
1270
+ // packages/ui/react-ui-editor/src/extensions/command/command.ts
1271
+ var command = (options) => {
1272
+ return [
1273
+ commandState,
1274
+ keymap3.of(commandKeymap),
1275
+ hintViewPlugin(options),
1276
+ // Close tooltip on focus change.
1277
+ EditorView7.focusChangeEffect.of((_, focusing) => {
1278
+ return focusing ? closeEffect.of(null) : null;
1279
+ }),
1280
+ commandConfig.of(options)
1281
+ ];
1282
+ };
1283
+
1284
+ // packages/ui/react-ui-editor/src/extensions/comments.ts
1285
+ import { invertedEffects } from "@codemirror/commands";
1286
+ import { Facet as Facet4, StateEffect as StateEffect3, StateField as StateField4 } from "@codemirror/state";
1287
+ import { hoverTooltip, keymap as keymap4, Decoration as Decoration4, EditorView as EditorView8 } from "@codemirror/view";
1288
+ import sortBy from "lodash.sortby";
1289
+ import { useEffect } from "react";
1290
+ import { debounce } from "@dxos/async";
1291
+ import { nonNullable } from "@dxos/util";
1112
1292
 
1113
1293
  // packages/ui/react-ui-editor/src/styles/markdown.ts
1114
1294
  import { mx } from "@dxos/react-ui-theme";
@@ -1180,13 +1360,13 @@ var logChanges = (trs) => {
1180
1360
  };
1181
1361
 
1182
1362
  // packages/ui/react-ui-editor/src/extensions/comments.ts
1183
- var documentId = Facet3.define({
1363
+ var documentId = Facet4.define({
1184
1364
  combine: (values) => values[0]
1185
1365
  });
1186
- var setComments = StateEffect2.define();
1187
- var setSelection = StateEffect2.define();
1188
- var setCommentState = StateEffect2.define();
1189
- var commentsState = StateField3.define({
1366
+ var setComments = StateEffect3.define();
1367
+ var setSelection = StateEffect3.define();
1368
+ var setCommentState = StateEffect3.define();
1369
+ var commentsState = StateField4.define({
1190
1370
  create: (state) => ({
1191
1371
  id: state.facet(documentId),
1192
1372
  comments: [],
@@ -1224,7 +1404,7 @@ var commentsState = StateField3.define({
1224
1404
  return value;
1225
1405
  }
1226
1406
  });
1227
- var styles3 = EditorView6.baseTheme({
1407
+ var styles3 = EditorView8.baseTheme({
1228
1408
  "&light .cm-comment, &light .cm-comment-current": {
1229
1409
  mixBlendMode: "darken"
1230
1410
  },
@@ -1246,19 +1426,19 @@ var styles3 = EditorView6.baseTheme({
1246
1426
  backgroundColor: getToken("extend.colors.yellow.950")
1247
1427
  }
1248
1428
  });
1249
- var commentMark = Decoration3.mark({
1429
+ var commentMark = Decoration4.mark({
1250
1430
  class: "cm-comment",
1251
1431
  attributes: {
1252
1432
  "data-testid": "cm-comment"
1253
1433
  }
1254
1434
  });
1255
- var commentCurrentMark = Decoration3.mark({
1435
+ var commentCurrentMark = Decoration4.mark({
1256
1436
  class: "cm-comment-current",
1257
1437
  attributes: {
1258
1438
  "data-testid": "cm-comment"
1259
1439
  }
1260
1440
  });
1261
- var commentsDecorations = EditorView6.decorations.compute([
1441
+ var commentsDecorations = EditorView8.decorations.compute([
1262
1442
  commentsState
1263
1443
  ], (state) => {
1264
1444
  const { selection: { current }, comments: comments2 } = state.field(commentsState);
@@ -1274,7 +1454,7 @@ var commentsDecorations = EditorView6.decorations.compute([
1274
1454
  return commentMark.range(range.from, range.to);
1275
1455
  }
1276
1456
  }).filter(nonNullable);
1277
- return Decoration3.set(decorations);
1457
+ return Decoration4.set(decorations);
1278
1458
  });
1279
1459
  var trackPastedComments = (onUpdate) => {
1280
1460
  let tracked = null;
@@ -1296,7 +1476,7 @@ var trackPastedComments = (onUpdate) => {
1296
1476
  }
1297
1477
  };
1298
1478
  return [
1299
- EditorView6.domEventHandlers({
1479
+ EditorView8.domEventHandlers({
1300
1480
  cut: handleTrack,
1301
1481
  copy: handleTrack
1302
1482
  }),
@@ -1318,7 +1498,7 @@ var trackPastedComments = (onUpdate) => {
1318
1498
  return effects;
1319
1499
  }),
1320
1500
  // Handle paste or the undo of comment deletion.
1321
- EditorView6.updateListener.of((update2) => {
1501
+ EditorView8.updateListener.of((update2) => {
1322
1502
  const restore = [];
1323
1503
  for (let i = 0; i < update2.transactions.length; i++) {
1324
1504
  const tr = update2.transactions[i];
@@ -1374,7 +1554,7 @@ var mapTrackedComment = (comment, changes) => ({
1374
1554
  from: changes.mapPos(comment.from, 1),
1375
1555
  to: changes.mapPos(comment.to, 1)
1376
1556
  });
1377
- var restoreCommentEffect = StateEffect2.define({
1557
+ var restoreCommentEffect = StateEffect3.define({
1378
1558
  map: mapTrackedComment
1379
1559
  });
1380
1560
  var createComment = (view) => {
@@ -1415,7 +1595,7 @@ var createComment = (view) => {
1415
1595
  }
1416
1596
  return false;
1417
1597
  };
1418
- var optionsFacet = Facet3.define({
1598
+ var optionsFacet = Facet4.define({
1419
1599
  combine: (providers) => providers[0]
1420
1600
  });
1421
1601
  var comments = (options = {}) => {
@@ -1430,7 +1610,7 @@ var comments = (options = {}) => {
1430
1610
  //
1431
1611
  // Keymap.
1432
1612
  //
1433
- options.onCreate ? keymap3.of([
1613
+ options.onCreate ? keymap4.of([
1434
1614
  {
1435
1615
  key: shortcut,
1436
1616
  run: callbackWrapper(createComment)
@@ -1469,7 +1649,7 @@ var comments = (options = {}) => {
1469
1649
  //
1470
1650
  // Track deleted ranges and update ranges for decorations.
1471
1651
  //
1472
- EditorView6.updateListener.of(({ view, state, changes }) => {
1652
+ EditorView8.updateListener.of(({ view, state, changes }) => {
1473
1653
  let mod = false;
1474
1654
  const { comments: comments2, ...value } = state.field(commentsState);
1475
1655
  changes.iterChanges((from, to, from2, to2) => {
@@ -1501,7 +1681,7 @@ var comments = (options = {}) => {
1501
1681
  //
1502
1682
  // Track selection/proximity.
1503
1683
  //
1504
- EditorView6.updateListener.of(({ view, state }) => {
1684
+ EditorView8.updateListener.of(({ view, state }) => {
1505
1685
  let min = Infinity;
1506
1686
  const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
1507
1687
  const { head } = state.selection.main;
@@ -1550,7 +1730,7 @@ var focusComment = (view, id, center = true) => {
1550
1730
  },
1551
1731
  effects: [
1552
1732
  //
1553
- EditorView6.scrollIntoView(range.from, center ? {
1733
+ EditorView8.scrollIntoView(range.from, center ? {
1554
1734
  y: "center"
1555
1735
  } : void 0),
1556
1736
  setSelection.of({
@@ -1578,14 +1758,14 @@ var useComments = (view, id, comments2 = []) => {
1578
1758
  };
1579
1759
 
1580
1760
  // packages/ui/react-ui-editor/src/extensions/cursor-line-margin.ts
1581
- import { Facet as Facet4, Transaction } from "@codemirror/state";
1582
- import { EditorView as EditorView7 } from "@codemirror/view";
1583
- var cursorLineMarginFacet = Facet4.define({
1761
+ import { Facet as Facet5, Transaction } from "@codemirror/state";
1762
+ import { EditorView as EditorView9 } from "@codemirror/view";
1763
+ var cursorLineMarginFacet = Facet5.define({
1584
1764
  combine: (input) => input[0] ?? 3
1585
1765
  });
1586
1766
  var annotation = "cursorLineMargin";
1587
1767
  var lineAtPos = (s, pos) => s.doc.lineAt(pos).number;
1588
- var cursorLineMargin = EditorView7.updateListener.of(({ transactions, state, selectionSet, startState, view }) => {
1768
+ var cursorLineMargin = EditorView9.updateListener.of(({ transactions, state, selectionSet, startState, view }) => {
1589
1769
  if (transactions.length < 1 || transactions.some((tr) => tr.isUserEvent(annotation))) {
1590
1770
  return;
1591
1771
  }
@@ -1621,22 +1801,32 @@ var cursorLineMargin = EditorView7.updateListener.of(({ transactions, state, sel
1621
1801
  }
1622
1802
  view.dispatch({
1623
1803
  annotations: Transaction.userEvent.of(annotation),
1624
- effects: EditorView7.scrollIntoView(s.selection.main.head, {
1804
+ effects: EditorView9.scrollIntoView(s.selection.main.head, {
1625
1805
  y: needsScrollTop ? "start" : "end",
1626
1806
  yMargin: view.defaultLineHeight * cursorLineMargin2
1627
1807
  })
1628
1808
  });
1629
1809
  });
1630
1810
 
1811
+ // packages/ui/react-ui-editor/src/extensions/dnd.ts
1812
+ import { EditorView as EditorView10 } from "@codemirror/view";
1813
+ var dnd = () => {
1814
+ return EditorView10.domEventHandlers({
1815
+ drop: (event, view) => {
1816
+ console.log(event);
1817
+ }
1818
+ });
1819
+ };
1820
+
1631
1821
  // packages/ui/react-ui-editor/src/extensions/listener.ts
1632
- import { EditorView as EditorView8 } from "@codemirror/view";
1822
+ import { EditorView as EditorView11 } from "@codemirror/view";
1633
1823
  var listener = ({ onFocus, onChange }) => {
1634
1824
  const extensions = [];
1635
- onFocus && extensions.push(EditorView8.focusChangeEffect.of((_, focused) => {
1825
+ onFocus && extensions.push(EditorView11.focusChangeEffect.of((_, focused) => {
1636
1826
  onFocus(focused);
1637
1827
  return null;
1638
1828
  }));
1639
- onChange && extensions.push(EditorView8.updateListener.of((update2) => {
1829
+ onChange && extensions.push(EditorView11.updateListener.of((update2) => {
1640
1830
  onChange(update2.state.doc.toString());
1641
1831
  }));
1642
1832
  return extensions;
@@ -1651,7 +1841,7 @@ import { languages } from "@codemirror/language-data";
1651
1841
  import { searchKeymap } from "@codemirror/search";
1652
1842
  import { EditorState } from "@codemirror/state";
1653
1843
  import { oneDarkHighlightStyle as oneDarkHighlightStyle2 } from "@codemirror/theme-one-dark";
1654
- import { crosshairCursor, drawSelection as drawSelection2, dropCursor, EditorView as EditorView9, highlightActiveLine as highlightActiveLine2, keymap as keymap4, placeholder as placeholder2 } from "@codemirror/view";
1844
+ import { crosshairCursor, drawSelection as drawSelection2, dropCursor, EditorView as EditorView12, highlightActiveLine as highlightActiveLine2, keymap as keymap5, placeholder as placeholder2 } from "@codemirror/view";
1655
1845
  import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
1656
1846
 
1657
1847
  // packages/ui/react-ui-editor/src/extensions/markdown/highlight.ts
@@ -1845,7 +2035,7 @@ var markdownHighlightStyle = (readonly) => {
1845
2035
  // packages/ui/react-ui-editor/src/extensions/markdown/bundle.ts
1846
2036
  var createMarkdownExtensions = ({ themeMode, placeholder: _placeholder, lineWrapping = true } = {}) => {
1847
2037
  return [
1848
- lineWrapping && EditorView9.lineWrapping,
2038
+ lineWrapping && EditorView12.lineWrapping,
1849
2039
  EditorState.allowMultipleSelections.of(true),
1850
2040
  EditorState.tabSize.of(2),
1851
2041
  // https://github.com/codemirror/basic-setup
@@ -1880,7 +2070,7 @@ var createMarkdownExtensions = ({ themeMode, placeholder: _placeholder, lineWrap
1880
2070
  themeMode === "dark" ? syntaxHighlighting2(oneDarkHighlightStyle2) : syntaxHighlighting2(defaultHighlightStyle2),
1881
2071
  // Custom styles.
1882
2072
  syntaxHighlighting2(markdownHighlightStyle()),
1883
- keymap4.of([
2073
+ keymap5.of([
1884
2074
  // https://codemirror.net/docs/ref/#commands.indentWithTab
1885
2075
  indentWithTab,
1886
2076
  // https://codemirror.net/docs/ref/#autocomplete.closeBracketsKeymap
@@ -1897,17 +2087,17 @@ var createMarkdownExtensions = ({ themeMode, placeholder: _placeholder, lineWrap
1897
2087
 
1898
2088
  // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
1899
2089
  import { syntaxTree } from "@codemirror/language";
1900
- import { RangeSetBuilder, StateEffect as StateEffect3 } from "@codemirror/state";
1901
- import { EditorView as EditorView10, Decoration as Decoration4, WidgetType as WidgetType2, ViewPlugin as ViewPlugin3 } from "@codemirror/view";
2090
+ import { RangeSetBuilder as RangeSetBuilder2, StateEffect as StateEffect4 } from "@codemirror/state";
2091
+ import { EditorView as EditorView13, Decoration as Decoration5, WidgetType as WidgetType3, ViewPlugin as ViewPlugin4 } from "@codemirror/view";
1902
2092
  import { mx as mx2 } from "@dxos/react-ui-theme";
1903
- var HorizontalRuleWidget = class extends WidgetType2 {
2093
+ var HorizontalRuleWidget = class extends WidgetType3 {
1904
2094
  toDOM() {
1905
2095
  const el = document.createElement("span");
1906
2096
  el.className = "cm-hr";
1907
2097
  return el;
1908
2098
  }
1909
2099
  };
1910
- var LinkButton = class extends WidgetType2 {
2100
+ var LinkButton = class extends WidgetType3 {
1911
2101
  constructor(url, render) {
1912
2102
  super();
1913
2103
  this.url = url;
@@ -1922,7 +2112,7 @@ var LinkButton = class extends WidgetType2 {
1922
2112
  return el;
1923
2113
  }
1924
2114
  };
1925
- var CheckboxWidget = class extends WidgetType2 {
2115
+ var CheckboxWidget = class extends WidgetType3 {
1926
2116
  constructor(_checked) {
1927
2117
  super();
1928
2118
  this._checked = _checked;
@@ -1959,28 +2149,28 @@ var CheckboxWidget = class extends WidgetType2 {
1959
2149
  return false;
1960
2150
  }
1961
2151
  };
1962
- var hide = Decoration4.replace({});
1963
- var fencedCodeLine = Decoration4.line({
2152
+ var hide = Decoration5.replace({});
2153
+ var fencedCodeLine = Decoration5.line({
1964
2154
  class: mx2("cm-code cm-codeblock-line")
1965
2155
  });
1966
- var fencedCodeLineFirst = Decoration4.line({
2156
+ var fencedCodeLineFirst = Decoration5.line({
1967
2157
  class: mx2("cm-code cm-codeblock-line", "cm-codeblock-first")
1968
2158
  });
1969
- var fencedCodeLineLast = Decoration4.line({
2159
+ var fencedCodeLineLast = Decoration5.line({
1970
2160
  class: mx2("cm-code cm-codeblock-line", "cm-codeblock-last")
1971
2161
  });
1972
- var horizontalRule = Decoration4.replace({
2162
+ var horizontalRule = Decoration5.replace({
1973
2163
  widget: new HorizontalRuleWidget()
1974
2164
  });
1975
- var checkedTask = Decoration4.replace({
2165
+ var checkedTask = Decoration5.replace({
1976
2166
  widget: new CheckboxWidget(true)
1977
2167
  });
1978
- var uncheckedTask = Decoration4.replace({
2168
+ var uncheckedTask = Decoration5.replace({
1979
2169
  widget: new CheckboxWidget(false)
1980
2170
  });
1981
2171
  var editingRange = (state, range, focus) => {
1982
2172
  const { readOnly, selection: { main: { head } } } = state;
1983
- return focus && !readOnly && head >= range.from && head <= range.to;
2173
+ return focus && !readOnly && head >= range.from && head < range.to;
1984
2174
  };
1985
2175
  var MarksByParent = /* @__PURE__ */ new Set([
1986
2176
  "CodeMark",
@@ -1990,8 +2180,8 @@ var MarksByParent = /* @__PURE__ */ new Set([
1990
2180
  "SuperscriptMark"
1991
2181
  ]);
1992
2182
  var buildDecorations = (view, options, focus) => {
1993
- const deco = new RangeSetBuilder();
1994
- const atomicDeco = new RangeSetBuilder();
2183
+ const deco = new RangeSetBuilder2();
2184
+ const atomicDeco = new RangeSetBuilder2();
1995
2185
  const { state } = view;
1996
2186
  for (const { from, to } of view.visibleRanges) {
1997
2187
  syntaxTree(state).iterate({
@@ -2024,7 +2214,7 @@ var buildDecorations = (view, options, focus) => {
2024
2214
  if (!editing) {
2025
2215
  atomicDeco.add(node.from, marks[0].to, hide);
2026
2216
  }
2027
- deco.add(marks[0].to, marks[1].from, Decoration4.mark({
2217
+ deco.add(marks[0].to, marks[1].from, Decoration5.mark({
2028
2218
  tagName: "a",
2029
2219
  attributes: {
2030
2220
  class: "cm-link",
@@ -2034,7 +2224,7 @@ var buildDecorations = (view, options, focus) => {
2034
2224
  }
2035
2225
  }));
2036
2226
  if (!editing) {
2037
- atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration4.replace({
2227
+ atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration5.replace({
2038
2228
  widget: new LinkButton(url, options.renderLinkButton)
2039
2229
  }) : hide);
2040
2230
  }
@@ -2052,7 +2242,7 @@ var buildDecorations = (view, options, focus) => {
2052
2242
  } else if (node.name === "TaskMarker") {
2053
2243
  if (!editingRange(state, node, focus)) {
2054
2244
  const checked = state.doc.sliceString(node.from + 1, node.to - 1) === "x";
2055
- atomicDeco.add(node.from - 2, node.from - 1, Decoration4.mark({
2245
+ atomicDeco.add(node.from - 2, node.from - 1, Decoration5.mark({
2056
2246
  class: "cm-task"
2057
2247
  }));
2058
2248
  atomicDeco.add(node.from, node.to, checked ? checkedTask : uncheckedTask);
@@ -2070,10 +2260,10 @@ var buildDecorations = (view, options, focus) => {
2070
2260
  atomicDeco: atomicDeco.finish()
2071
2261
  };
2072
2262
  };
2073
- var forceUpdate = StateEffect3.define();
2263
+ var forceUpdate = StateEffect4.define();
2074
2264
  var decorateMarkdown = (options = {}) => {
2075
2265
  return [
2076
- ViewPlugin3.fromClass(class {
2266
+ ViewPlugin4.fromClass(class {
2077
2267
  constructor(view) {
2078
2268
  this.pendingUpdate = -1;
2079
2269
  ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations(view, options, view.hasFocus));
@@ -2105,15 +2295,15 @@ var decorateMarkdown = (options = {}) => {
2105
2295
  }
2106
2296
  }, {
2107
2297
  provide: (plugin) => [
2108
- EditorView10.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration4.none),
2109
- EditorView10.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration4.none),
2110
- EditorView10.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration4.none)
2298
+ EditorView13.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration5.none),
2299
+ EditorView13.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration5.none),
2300
+ EditorView13.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration5.none)
2111
2301
  ]
2112
2302
  }),
2113
2303
  formattingStyles
2114
2304
  ];
2115
2305
  };
2116
- var formattingStyles = EditorView10.baseTheme({
2306
+ var formattingStyles = EditorView13.baseTheme({
2117
2307
  "& .cm-code": {
2118
2308
  fontFamily: getToken("fontFamily.mono", []).join(",")
2119
2309
  },
@@ -2166,7 +2356,7 @@ var formattingStyles = EditorView10.baseTheme({
2166
2356
  import { snippet } from "@codemirror/autocomplete";
2167
2357
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
2168
2358
  import { EditorSelection } from "@codemirror/state";
2169
- import { EditorView as EditorView11, keymap as keymap5 } from "@codemirror/view";
2359
+ import { EditorView as EditorView14, keymap as keymap6 } from "@codemirror/view";
2170
2360
  import { useState, useMemo } from "react";
2171
2361
  var compareFormatting = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
2172
2362
  var Inline;
@@ -3038,7 +3228,7 @@ var toggleCodeblock = (target) => {
3038
3228
  };
3039
3229
  var formatting = (options = {}) => {
3040
3230
  return [
3041
- keymap5.of([
3231
+ keymap6.of([
3042
3232
  {
3043
3233
  key: "meta-b",
3044
3234
  run: toggleStrong
@@ -3236,7 +3426,7 @@ var getFormatting = (state) => {
3236
3426
  };
3237
3427
  var useFormattingState = () => {
3238
3428
  const [state, setState] = useState(null);
3239
- const observer = useMemo(() => EditorView11.updateListener.of((update2) => {
3429
+ const observer = useMemo(() => EditorView14.updateListener.of((update2) => {
3240
3430
  if (update2.docChanged || update2.selectionSet) {
3241
3431
  const newState = getFormatting(update2.state);
3242
3432
  if (!state || !compareFormatting(state, newState)) {
@@ -3252,12 +3442,12 @@ var useFormattingState = () => {
3252
3442
 
3253
3443
  // packages/ui/react-ui-editor/src/extensions/markdown/image.ts
3254
3444
  import { syntaxTree as syntaxTree3 } from "@codemirror/language";
3255
- import { StateField as StateField4 } from "@codemirror/state";
3256
- import { Decoration as Decoration5, EditorView as EditorView12, WidgetType as WidgetType3 } from "@codemirror/view";
3445
+ import { StateField as StateField5 } from "@codemirror/state";
3446
+ import { Decoration as Decoration6, EditorView as EditorView15, WidgetType as WidgetType4 } from "@codemirror/view";
3257
3447
  var image = (options = {}) => {
3258
- return StateField4.define({
3448
+ return StateField5.define({
3259
3449
  create: (state) => {
3260
- return Decoration5.set(buildDecorations2(0, state.doc.length, state));
3450
+ return Decoration6.set(buildDecorations2(0, state.doc.length, state));
3261
3451
  },
3262
3452
  update: (value, tr) => {
3263
3453
  if (!tr.docChanged && !tr.selection) {
@@ -3280,7 +3470,7 @@ var image = (options = {}) => {
3280
3470
  add: buildDecorations2(from, to, tr.state)
3281
3471
  });
3282
3472
  },
3283
- provide: (field) => EditorView12.decorations.from(field)
3473
+ provide: (field) => EditorView15.decorations.from(field)
3284
3474
  });
3285
3475
  };
3286
3476
  var preloaded = /* @__PURE__ */ new Set();
@@ -3302,7 +3492,7 @@ var buildDecorations2 = (from, to, state) => {
3302
3492
  const hide2 = state.readOnly || cursor < node.from || cursor > node.to;
3303
3493
  const url = state.sliceDoc(urlNode.from, urlNode.to);
3304
3494
  preloadImage(url);
3305
- decorations.push(Decoration5.replace({
3495
+ decorations.push(Decoration6.replace({
3306
3496
  block: true,
3307
3497
  widget: new ImageWidget(url)
3308
3498
  }).range(hide2 ? node.from : node.to, node.to));
@@ -3314,7 +3504,7 @@ var buildDecorations2 = (from, to, state) => {
3314
3504
  });
3315
3505
  return decorations;
3316
3506
  };
3317
- var ImageWidget = class extends WidgetType3 {
3507
+ var ImageWidget = class extends WidgetType4 {
3318
3508
  constructor(_url) {
3319
3509
  super();
3320
3510
  this._url = _url;
@@ -3367,17 +3557,17 @@ var linkTooltip = (render) => hoverTooltip2((view, pos, side) => {
3367
3557
 
3368
3558
  // packages/ui/react-ui-editor/src/extensions/markdown/table.ts
3369
3559
  import { syntaxTree as syntaxTree5 } from "@codemirror/language";
3370
- import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField5 } from "@codemirror/state";
3371
- import { Decoration as Decoration6, EditorView as EditorView13, WidgetType as WidgetType4 } from "@codemirror/view";
3560
+ import { RangeSetBuilder as RangeSetBuilder3, StateField as StateField6 } from "@codemirror/state";
3561
+ import { Decoration as Decoration7, EditorView as EditorView16, WidgetType as WidgetType5 } from "@codemirror/view";
3372
3562
  var table = (options = {}) => {
3373
- return StateField5.define({
3563
+ return StateField6.define({
3374
3564
  create: (state) => update(state, options),
3375
3565
  update: (_, tr) => update(tr.state, options),
3376
- provide: (field) => EditorView13.decorations.from(field)
3566
+ provide: (field) => EditorView16.decorations.from(field)
3377
3567
  });
3378
3568
  };
3379
3569
  var update = (state, options) => {
3380
- const builder = new RangeSetBuilder2();
3570
+ const builder = new RangeSetBuilder3();
3381
3571
  const cursor = state.selection.main.head;
3382
3572
  const tables = [];
3383
3573
  const getTable = () => tables[tables.length - 1];
@@ -3417,16 +3607,16 @@ var update = (state, options) => {
3417
3607
  });
3418
3608
  tables.forEach((table2) => {
3419
3609
  const hide2 = state.readOnly || cursor < table2.from || cursor > table2.to;
3420
- hide2 && builder.add(table2.from, table2.to, Decoration6.replace({
3610
+ hide2 && builder.add(table2.from, table2.to, Decoration7.replace({
3421
3611
  widget: new TableWidget(table2)
3422
3612
  }));
3423
- builder.add(table2.from, table2.to, Decoration6.mark({
3613
+ builder.add(table2.from, table2.to, Decoration7.mark({
3424
3614
  class: "cm-table"
3425
3615
  }));
3426
3616
  });
3427
3617
  return builder.finish();
3428
3618
  };
3429
- var TableWidget = class extends WidgetType4 {
3619
+ var TableWidget = class extends WidgetType5 {
3430
3620
  constructor(_table) {
3431
3621
  super();
3432
3622
  this._table = _table;
@@ -3493,10 +3683,10 @@ var mention = ({ onSearch }) => {
3493
3683
  };
3494
3684
 
3495
3685
  // packages/ui/react-ui-editor/src/extensions/modes.ts
3496
- import { Facet as Facet5 } from "@codemirror/state";
3497
- import { keymap as keymap6 } from "@codemirror/view";
3686
+ import { Facet as Facet6 } from "@codemirror/state";
3687
+ import { keymap as keymap7 } from "@codemirror/view";
3498
3688
  import { vim } from "@replit/codemirror-vim";
3499
- var editorMode = Facet5.define({
3689
+ var editorMode = Facet6.define({
3500
3690
  combine: (modes) => modes[0] ?? {}
3501
3691
  });
3502
3692
  var EditorModes = {
@@ -3507,7 +3697,7 @@ var EditorModes = {
3507
3697
  type: "vim",
3508
3698
  noTabster: true
3509
3699
  }),
3510
- keymap6.of([
3700
+ keymap7.of([
3511
3701
  {
3512
3702
  key: "Alt-Escape",
3513
3703
  run: (view) => {
@@ -3527,7 +3717,7 @@ var outliner = (options = {}) => {
3527
3717
  };
3528
3718
 
3529
3719
  // packages/ui/react-ui-editor/src/extensions/typewriter.ts
3530
- import { keymap as keymap7 } from "@codemirror/view";
3720
+ import { keymap as keymap8 } from "@codemirror/view";
3531
3721
  var defaultItems = [
3532
3722
  "hello world!",
3533
3723
  "this is a test.",
@@ -3537,7 +3727,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
3537
3727
  let t;
3538
3728
  let idx = 0;
3539
3729
  return [
3540
- keymap7.of([
3730
+ keymap8.of([
3541
3731
  {
3542
3732
  // Reset.
3543
3733
  key: "alt-meta-'",
@@ -3835,7 +4025,7 @@ var codeTheme = {
3835
4025
 
3836
4026
  // packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx
3837
4027
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/components/TextEditor/TextEditor.tsx";
3838
- var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, scrollTo = EditorView14.scrollIntoView(0), moveToEndOfLine, selection, theme, slots = defaultSlots, extensions = [], scrollPastEnd: _scrollPastEnd, debug }, forwardedRef) => {
4028
+ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, scrollTo = EditorView17.scrollIntoView(0), moveToEndOfLine, selection, theme, slots = defaultSlots, extensions = [], scrollPastEnd: _scrollPastEnd, debug }, forwardedRef) => {
3839
4029
  const tabsterDOMAttribute = useFocusableGroup({
3840
4030
  tabBehavior: "limited"
3841
4031
  });
@@ -3862,7 +4052,7 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
3862
4052
  selection,
3863
4053
  extensions: [
3864
4054
  // TODO(burdon): Doesn't catch errors in keymap functions.
3865
- EditorView14.exceptionSink.of((err) => {
4055
+ EditorView17.exceptionSink.of((err) => {
3866
4056
  log3.catch(err, void 0, {
3867
4057
  F: __dxlog_file4,
3868
4058
  L: 122,
@@ -3872,19 +4062,19 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
3872
4062
  }),
3873
4063
  // Theme.
3874
4064
  // TODO(burdon): Make base theme configurable.
3875
- EditorView14.baseTheme(defaultTheme),
3876
- theme && EditorView14.theme(theme),
3877
- EditorView14.darkTheme.of(themeMode === "dark"),
3878
- slots.editor?.className && EditorView14.editorAttributes.of({
4065
+ EditorView17.baseTheme(defaultTheme),
4066
+ theme && EditorView17.theme(theme),
4067
+ EditorView17.darkTheme.of(themeMode === "dark"),
4068
+ slots.editor?.className && EditorView17.editorAttributes.of({
3879
4069
  class: slots.editor.className
3880
4070
  }),
3881
- slots.content?.className && EditorView14.contentAttributes.of({
4071
+ slots.content?.className && EditorView17.contentAttributes.of({
3882
4072
  class: slots.content.className
3883
4073
  }),
3884
4074
  // NOTE: Assumes default line height.
3885
4075
  _scrollPastEnd && scrollPastEnd(),
3886
4076
  // Focus.
3887
- EditorView14.updateListener.of((update2) => {
4077
+ EditorView17.updateListener.of((update2) => {
3888
4078
  update2.transactions.forEach((transaction) => {
3889
4079
  if (transaction.isUserEvent("focus.container")) {
3890
4080
  rootRef.current?.focus();
@@ -3892,7 +4082,7 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
3892
4082
  });
3893
4083
  }),
3894
4084
  // State.
3895
- EditorView14.editable.of(!readonly),
4085
+ EditorView17.editable.of(!readonly),
3896
4086
  EditorState2.readOnly.of(!!readonly),
3897
4087
  // Storage and replication.
3898
4088
  // NOTE: This must come before user extensions.
@@ -3901,7 +4091,7 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, readonly, autoFocus, s
3901
4091
  ...extensions
3902
4092
  ].filter(isNotFalsy4)
3903
4093
  });
3904
- const view2 = new EditorView14({
4094
+ const view2 = new EditorView17({
3905
4095
  state,
3906
4096
  parent: rootRef.current,
3907
4097
  scrollTo,
@@ -4393,8 +4583,8 @@ var SpaceAwarenessProvider = class {
4393
4583
  };
4394
4584
 
4395
4585
  // packages/ui/react-ui-editor/src/hooks/defs.ts
4396
- import { StateField as StateField6 } from "@codemirror/state";
4397
- var modelState = StateField6.define({
4586
+ import { StateField as StateField7 } from "@codemirror/state";
4587
+ var modelState = StateField7.define({
4398
4588
  create: () => void 0,
4399
4589
  update: (model) => model
4400
4590
  });
@@ -4469,7 +4659,7 @@ var useEditorView = (id) => {
4469
4659
 
4470
4660
  // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
4471
4661
  import { EditorSelection as EditorSelection2, EditorState as EditorState3 } from "@codemirror/state";
4472
- import { EditorView as EditorView15 } from "@codemirror/view";
4662
+ import { EditorView as EditorView18 } from "@codemirror/view";
4473
4663
  import { useEffect as useEffect3, useRef as useRef4, useState as useState5 } from "react";
4474
4664
  import { log as log5 } from "@dxos/log";
4475
4665
  import { isNotFalsy as isNotFalsy5 } from "@dxos/util";
@@ -4486,7 +4676,7 @@ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions }
4486
4676
  selection,
4487
4677
  extensions: [
4488
4678
  // TODO(burdon): Doesn't catch errors in keymap functions.
4489
- EditorView15.exceptionSink.of((err) => {
4679
+ EditorView18.exceptionSink.of((err) => {
4490
4680
  log5.catch(err, void 0, {
4491
4681
  F: __dxlog_file6,
4492
4682
  L: 57,
@@ -4495,12 +4685,12 @@ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions }
4495
4685
  });
4496
4686
  }),
4497
4687
  extensions,
4498
- EditorView15.updateListener.of(() => {
4688
+ EditorView18.updateListener.of(() => {
4499
4689
  onUpdate.current?.();
4500
4690
  })
4501
4691
  ].filter(isNotFalsy5)
4502
4692
  });
4503
- view2 = new EditorView15({
4693
+ view2 = new EditorView18({
4504
4694
  parent: parentRef.current,
4505
4695
  scrollTo,
4506
4696
  state,
@@ -4555,19 +4745,19 @@ var createDataExtensions = ({ readonly = false } = {}) => {
4555
4745
  return [
4556
4746
  //
4557
4747
  EditorState3.readOnly.of(readonly),
4558
- EditorView15.editable.of(!readonly)
4748
+ EditorView18.editable.of(!readonly)
4559
4749
  ];
4560
4750
  };
4561
4751
  var createThemeExtensions = ({ theme, themeMode, slots } = {}) => {
4562
4752
  return [
4563
4753
  //
4564
- EditorView15.baseTheme(defaultTheme),
4565
- theme && EditorView15.theme(theme),
4566
- EditorView15.darkTheme.of(themeMode === "dark"),
4567
- EditorView15.editorAttributes.of({
4754
+ EditorView18.baseTheme(defaultTheme),
4755
+ theme && EditorView18.theme(theme),
4756
+ EditorView18.darkTheme.of(themeMode === "dark"),
4757
+ EditorView18.editorAttributes.of({
4568
4758
  class: slots?.editor?.className ?? ""
4569
4759
  }),
4570
- EditorView15.contentAttributes.of({
4760
+ EditorView18.contentAttributes.of({
4571
4761
  class: slots?.content?.className ?? ""
4572
4762
  })
4573
4763
  ].filter(isNotFalsy5);
@@ -4580,11 +4770,15 @@ import { generateName } from "@dxos/display-name";
4580
4770
  import { getRawDoc } from "@dxos/echo-schema";
4581
4771
  import { invariant as invariant3 } from "@dxos/invariant";
4582
4772
  import { isAutomergeObject } from "@dxos/react-client/echo";
4773
+ import { hueTokens } from "@dxos/react-ui-theme";
4774
+ import { hexToHue } from "@dxos/util";
4583
4775
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextModel.ts";
4584
4776
  var useTextExtensions = ({ id, text, space, identity }) => {
4585
4777
  const extensions = [
4586
4778
  automerge(text)
4587
4779
  ];
4780
+ const peerId = identity?.identityKey.toHex();
4781
+ const { cursorLightValue, cursorDarkValue } = hueTokens[hexToHue(peerId ?? "0")];
4588
4782
  if (space && identity) {
4589
4783
  const awarenessProvider2 = new SpaceAwarenessProvider({
4590
4784
  space,
@@ -4592,8 +4786,8 @@ var useTextExtensions = ({ id, text, space, identity }) => {
4592
4786
  peerId: identity.identityKey.toHex(),
4593
4787
  info: {
4594
4788
  displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
4595
- color: cursorColor.color,
4596
- lightColor: cursorColor.light
4789
+ color: cursorDarkValue,
4790
+ lightColor: cursorLightValue
4597
4791
  }
4598
4792
  });
4599
4793
  extensions.push(awareness(awarenessProvider2));
@@ -4616,7 +4810,7 @@ var createModel = ({ space, identity, text }) => {
4616
4810
  }
4617
4811
  invariant3(isAutomergeObject(text), void 0, {
4618
4812
  F: __dxlog_file7,
4619
- L: 83,
4813
+ L: 87,
4620
4814
  S: void 0,
4621
4815
  A: [
4622
4816
  "isAutomergeObject(text)",
@@ -4627,13 +4821,15 @@ var createModel = ({ space, identity, text }) => {
4627
4821
  const doc = getRawDoc(obj, [
4628
4822
  obj.field
4629
4823
  ]);
4824
+ const peerId = identity?.identityKey.toHex();
4825
+ const { cursorLightValue, cursorDarkValue } = hueTokens[hexToHue(peerId ?? "0")];
4630
4826
  const awarenessProvider2 = space && new SpaceAwarenessProvider({
4631
4827
  space,
4632
4828
  channel: `automerge.awareness.${obj.id}`,
4633
4829
  info: {
4634
4830
  displayName: identity ? identity.profile?.displayName ?? generateName(identity.identityKey.toHex()) : void 0,
4635
- color: cursorColor.color,
4636
- lightColor: cursorColor.light
4831
+ color: cursorLightValue,
4832
+ lightColor: cursorDarkValue
4637
4833
  },
4638
4834
  peerId: identity?.identityKey.toHex() ?? "Anonymous"
4639
4835
  });
@@ -4687,6 +4883,7 @@ export {
4687
4883
  blast,
4688
4884
  callbackWrapper,
4689
4885
  codeTheme,
4886
+ command,
4690
4887
  comments,
4691
4888
  compareFormatting,
4692
4889
  createBasicBundle,
@@ -4702,6 +4899,7 @@ export {
4702
4899
  defaultSlots,
4703
4900
  defaultTextSlots,
4704
4901
  defaultTheme,
4902
+ dnd,
4705
4903
  editorFillLayoutEditor,
4706
4904
  editorFillLayoutRoot,
4707
4905
  editorMode,
@@ -4712,7 +4910,7 @@ export {
4712
4910
  getToken,
4713
4911
  image,
4714
4912
  insertTable,
4715
- keymap8 as keymap,
4913
+ keymap9 as keymap,
4716
4914
  linkTooltip,
4717
4915
  listener,
4718
4916
  logChanges,