@dxos/react-ui-editor 0.8.3-staging.0fa589b → 0.8.4-main.3a94e84

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 (87) hide show
  1. package/dist/lib/browser/chunk-22UMM3QJ.mjs +22 -0
  2. package/dist/lib/browser/chunk-22UMM3QJ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +570 -530
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/browser/types/index.mjs +13 -0
  8. package/dist/lib/browser/types/index.mjs.map +7 -0
  9. package/dist/lib/node-esm/chunk-YXYQPV6R.mjs +24 -0
  10. package/dist/lib/node-esm/chunk-YXYQPV6R.mjs.map +7 -0
  11. package/dist/lib/node-esm/index.mjs +570 -531
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/testing/index.mjs +1 -1
  15. package/dist/lib/node-esm/types/index.mjs +14 -0
  16. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  17. package/dist/types/src/components/Editor/Editor.d.ts +19 -0
  18. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -0
  19. package/dist/types/src/components/Editor/index.d.ts +2 -0
  20. package/dist/types/src/components/Editor/index.d.ts.map +1 -0
  21. package/dist/types/src/components/EditorToolbar/util.d.ts +4 -3
  22. package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
  23. package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
  24. package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
  25. package/dist/types/src/components/Popover/RefDropdownMenu.d.ts.map +1 -1
  26. package/dist/types/src/components/index.d.ts +1 -0
  27. package/dist/types/src/components/index.d.ts.map +1 -1
  28. package/dist/types/src/extensions/automerge/automerge.stories.d.ts +28 -28
  29. package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
  30. package/dist/types/src/extensions/blast.d.ts.map +1 -1
  31. package/dist/types/src/extensions/command/index.d.ts +1 -1
  32. package/dist/types/src/extensions/command/index.d.ts.map +1 -1
  33. package/dist/types/src/extensions/command/typeahead.d.ts +7 -2
  34. package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
  35. package/dist/types/src/extensions/factories.d.ts +19 -0
  36. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  37. package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
  38. package/dist/types/src/extensions/modes.d.ts +0 -7
  39. package/dist/types/src/extensions/modes.d.ts.map +1 -1
  40. package/dist/types/src/index.d.ts +1 -1
  41. package/dist/types/src/index.d.ts.map +1 -1
  42. package/dist/types/src/stories/CommandMenu.stories.d.ts +1 -1
  43. package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
  44. package/dist/types/src/stories/EditorToolbar.stories.d.ts +1 -1
  45. package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
  46. package/dist/types/src/stories/components/EditorStory.d.ts +2 -2
  47. package/dist/types/src/styles/theme.d.ts.map +1 -1
  48. package/dist/types/src/translations.d.ts +28 -29
  49. package/dist/types/src/translations.d.ts.map +1 -1
  50. package/dist/types/src/types/index.d.ts +2 -0
  51. package/dist/types/src/types/index.d.ts.map +1 -0
  52. package/dist/types/src/types/types.d.ts +21 -0
  53. package/dist/types/src/types/types.d.ts.map +1 -0
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +44 -41
  56. package/src/components/Editor/Editor.tsx +39 -0
  57. package/src/components/Editor/index.ts +5 -0
  58. package/src/components/EditorToolbar/blocks.ts +1 -1
  59. package/src/components/EditorToolbar/util.ts +5 -4
  60. package/src/components/EditorToolbar/view-mode.ts +1 -1
  61. package/src/components/Popover/RefDropdownMenu.tsx +9 -3
  62. package/src/components/index.ts +1 -0
  63. package/src/extensions/automerge/automerge.stories.tsx +4 -2
  64. package/src/extensions/blast.ts +3 -16
  65. package/src/extensions/command/index.ts +1 -1
  66. package/src/extensions/command/typeahead.ts +26 -13
  67. package/src/extensions/factories.ts +24 -5
  68. package/src/extensions/markdown/formatting.test.ts +1 -1
  69. package/src/extensions/markdown/formatting.ts +14 -12
  70. package/src/extensions/modes.ts +0 -9
  71. package/src/index.ts +1 -1
  72. package/src/stories/CommandMenu.stories.tsx +2 -2
  73. package/src/stories/EditorToolbar.stories.tsx +3 -4
  74. package/src/stories/Preview.stories.tsx +4 -4
  75. package/src/stories/TextEditor.stories.tsx +1 -1
  76. package/src/styles/theme.ts +4 -5
  77. package/src/translations.ts +4 -2
  78. package/src/types/index.ts +5 -0
  79. package/src/types/types.ts +32 -0
  80. package/dist/lib/node/index.cjs +0 -7754
  81. package/dist/lib/node/index.cjs.map +0 -7
  82. package/dist/lib/node/meta.json +0 -1
  83. package/dist/lib/node/testing/index.cjs +0 -29
  84. package/dist/lib/node/testing/index.cjs.map +0 -7
  85. package/dist/types/src/types.d.ts +0 -14
  86. package/dist/types/src/types.d.ts.map +0 -1
  87. package/src/types.ts +0 -23
@@ -1,6 +1,13 @@
1
- // packages/ui/react-ui-editor/src/translations.ts
1
+ import {
2
+ EditorInputMode,
3
+ EditorInputModes,
4
+ EditorViewMode,
5
+ EditorViewModes
6
+ } from "./chunk-22UMM3QJ.mjs";
7
+
8
+ // src/translations.ts
2
9
  var translationKey = "react-ui-editor";
3
- var translations_default = [
10
+ var translations = [
4
11
  {
5
12
  "en-US": {
6
13
  [translationKey]: {
@@ -33,46 +40,27 @@ var translations_default = [
33
40
  }
34
41
  ];
35
42
 
36
- // packages/ui/react-ui-editor/src/index.ts
43
+ // src/index.ts
37
44
  import { EditorState as EditorState4 } from "@codemirror/state";
38
45
  import { EditorView as EditorView27, keymap as keymap14 } from "@codemirror/view";
39
46
  import { tags as tags2 } from "@lezer/highlight";
40
47
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
41
48
 
42
- // packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
49
+ // src/components/Editor/Editor.tsx
43
50
  import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
44
- import { Rx } from "@effect-rx/rx-react";
45
- import React3, { memo, useMemo as useMemo4 } from "react";
46
- import { rxFromSignal } from "@dxos/app-graph";
47
- import { ElevationProvider } from "@dxos/react-ui";
48
- import { MenuProvider, ToolbarMenu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
51
+ import React3, { forwardRef, useImperativeHandle } from "react";
52
+ import { useThemeContext } from "@dxos/react-ui";
53
+ import { mx as mx6 } from "@dxos/react-ui-theme";
49
54
 
50
- // packages/ui/react-ui-editor/src/components/EditorToolbar/util.ts
51
- import { useMemo } from "react";
52
- import { live } from "@dxos/live-object";
53
- import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
54
- var useEditorToolbarState = (initialState = {}) => {
55
- return useMemo(() => live(initialState), []);
56
- };
57
- var createEditorAction = (id, invoke, properties) => {
58
- const { label = [
59
- `${id} label`,
60
- {
61
- ns: translationKey
62
- }
63
- ], ...rest } = properties;
64
- return createMenuAction(id, invoke, {
65
- label,
66
- ...rest
67
- });
68
- };
69
- var createEditorActionGroup = (id, props, icon) => createMenuItemGroup(id, {
70
- icon,
71
- iconOnly: true,
72
- ...props
73
- });
55
+ // src/hooks/useTextEditor.ts
56
+ import { EditorState as EditorState3 } from "@codemirror/state";
57
+ import { EditorView as EditorView26 } from "@codemirror/view";
58
+ import { useFocusableGroup } from "@fluentui/react-tabster";
59
+ import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState2 } from "react";
60
+ import { log as log8 } from "@dxos/log";
61
+ import { getProviderValue, isNotFalsy as isNotFalsy4 } from "@dxos/util";
74
62
 
75
- // packages/ui/react-ui-editor/src/extensions/annotations.ts
63
+ // src/extensions/annotations.ts
76
64
  import { RangeSetBuilder } from "@codemirror/state";
77
65
  import { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
78
66
  var annotationMark = Decoration.mark({
@@ -113,7 +101,7 @@ var annotations = ({ match } = {}) => {
113
101
  ];
114
102
  };
115
103
 
116
- // packages/ui/react-ui-editor/src/extensions/autocomplete.ts
104
+ // src/extensions/autocomplete.ts
117
105
  import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
118
106
  import { markdownLanguage } from "@codemirror/lang-markdown";
119
107
  import { keymap } from "@codemirror/view";
@@ -150,15 +138,15 @@ var autocomplete = ({ activateOnTyping, override, onSearch } = {}) => {
150
138
  return extensions;
151
139
  };
152
140
 
153
- // packages/ui/react-ui-editor/src/extensions/automerge/automerge.ts
141
+ // src/extensions/automerge/automerge.ts
154
142
  import { next as A3 } from "@automerge/automerge";
155
143
  import { StateField } from "@codemirror/state";
156
144
  import { EditorView as EditorView2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
157
145
 
158
- // packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts
146
+ // src/extensions/automerge/cursor.ts
159
147
  import { log } from "@dxos/log";
160
148
  import { fromCursor, toCursor } from "@dxos/react-client/echo";
161
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
149
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
162
150
  var cursorConverter = (accessor) => ({
163
151
  toCursor: (pos, assoc) => {
164
152
  try {
@@ -188,7 +176,7 @@ var cursorConverter = (accessor) => ({
188
176
  }
189
177
  });
190
178
 
191
- // packages/ui/react-ui-editor/src/extensions/automerge/defs.ts
179
+ // src/extensions/automerge/defs.ts
192
180
  import { Annotation, StateEffect } from "@codemirror/state";
193
181
  var getPath = (state, field) => state.field(field).path;
194
182
  var getLastHeads = (state, field) => state.field(field).lastHeads;
@@ -201,10 +189,10 @@ var isReconcile = (tr) => {
201
189
  return !!tr.annotation(reconcileAnnotation);
202
190
  };
203
191
 
204
- // packages/ui/react-ui-editor/src/extensions/automerge/sync.ts
192
+ // src/extensions/automerge/sync.ts
205
193
  import { next as A2 } from "@automerge/automerge";
206
194
 
207
- // packages/ui/react-ui-editor/src/extensions/automerge/update-automerge.ts
195
+ // src/extensions/automerge/update-automerge.ts
208
196
  import { next as A } from "@automerge/automerge";
209
197
  var updateAutomerge = (field, handle, transactions, state) => {
210
198
  const { lastHeads, path } = state.field(field);
@@ -235,7 +223,7 @@ var updateAutomerge = (field, handle, transactions, state) => {
235
223
  return newHeads ?? void 0;
236
224
  };
237
225
 
238
- // packages/ui/react-ui-editor/src/extensions/automerge/update-codemirror.ts
226
+ // src/extensions/automerge/update-codemirror.ts
239
227
  import { ChangeSet } from "@codemirror/state";
240
228
  var updateCodeMirror = (view, selection, target, patches) => {
241
229
  for (const patch of patches) {
@@ -342,7 +330,7 @@ var charPath = (textPath, candidatePath) => {
342
330
  return null;
343
331
  };
344
332
 
345
- // packages/ui/react-ui-editor/src/extensions/automerge/sync.ts
333
+ // src/extensions/automerge/sync.ts
346
334
  var Syncer = class {
347
335
  // prettier-ignore
348
336
  constructor(_handle, _state) {
@@ -386,7 +374,7 @@ var Syncer = class {
386
374
  }
387
375
  };
388
376
 
389
- // packages/ui/react-ui-editor/src/util/facet.ts
377
+ // src/util/facet.ts
390
378
  import { Facet } from "@codemirror/state";
391
379
  var singleValueFacet = (defaultValue) => Facet.define({
392
380
  // Called immediately.
@@ -395,7 +383,7 @@ var singleValueFacet = (defaultValue) => Facet.define({
395
383
  }
396
384
  });
397
385
 
398
- // packages/ui/react-ui-editor/src/util/cursor.ts
386
+ // src/util/cursor.ts
399
387
  var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
400
388
  var defaultCursorConverter = {
401
389
  toCursor: (position) => position.toString(),
@@ -430,9 +418,9 @@ var Cursor = class _Cursor {
430
418
  }
431
419
  };
432
420
 
433
- // packages/ui/react-ui-editor/src/util/debug.ts
421
+ // src/util/debug.ts
434
422
  import { log as log2 } from "@dxos/log";
435
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
423
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
436
424
  var wrapWithCatch = (fn) => {
437
425
  return (...args) => {
438
426
  try {
@@ -490,7 +478,7 @@ var logChanges = (trs) => {
490
478
  }
491
479
  };
492
480
 
493
- // packages/ui/react-ui-editor/src/util/dom.ts
481
+ // src/util/dom.ts
494
482
  var flattenRect = (rect, left) => {
495
483
  const x = left ? rect.left : rect.right;
496
484
  return {
@@ -532,7 +520,7 @@ var createElement = (tag, options, children) => {
532
520
  return el;
533
521
  };
534
522
 
535
- // packages/ui/react-ui-editor/src/util/react.tsx
523
+ // src/util/react.tsx
536
524
  import React from "react";
537
525
  import { createRoot } from "react-dom/client";
538
526
  import { ThemeProvider, Tooltip } from "@dxos/react-ui";
@@ -549,7 +537,7 @@ var createRenderer = (Component) => (el, props) => {
549
537
  }, /* @__PURE__ */ React.createElement(Tooltip.Provider, null, /* @__PURE__ */ React.createElement(Component, props))));
550
538
  };
551
539
 
552
- // packages/ui/react-ui-editor/src/extensions/automerge/automerge.ts
540
+ // src/extensions/automerge/automerge.ts
553
541
  var automerge = (accessor) => {
554
542
  const syncState = StateField.define({
555
543
  create: () => ({
@@ -607,12 +595,12 @@ var automerge = (accessor) => {
607
595
  ];
608
596
  };
609
597
 
610
- // packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts
598
+ // src/extensions/awareness/awareness.ts
611
599
  import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
612
600
  import { Decoration as Decoration2, EditorView as EditorView3, ViewPlugin as ViewPlugin3, WidgetType } from "@codemirror/view";
613
601
  import { Event } from "@dxos/async";
614
602
  import { Context } from "@dxos/context";
615
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
603
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
616
604
  var dummyProvider = {
617
605
  remoteStateChange: new Event(),
618
606
  open: () => {
@@ -839,12 +827,12 @@ var styles = EditorView3.theme({
839
827
  }
840
828
  });
841
829
 
842
- // packages/ui/react-ui-editor/src/extensions/awareness/awareness-provider.ts
830
+ // src/extensions/awareness/awareness-provider.ts
843
831
  import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
844
832
  import { Context as Context2 } from "@dxos/context";
845
833
  import { invariant } from "@dxos/invariant";
846
834
  import { log as log3 } from "@dxos/log";
847
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness-provider.ts";
835
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness-provider.ts";
848
836
  var DEBOUNCE_INTERVAL = 100;
849
837
  var SpaceAwarenessProvider = class {
850
838
  constructor(params) {
@@ -946,11 +934,12 @@ var SpaceAwarenessProvider = class {
946
934
  }
947
935
  };
948
936
 
949
- // packages/ui/react-ui-editor/src/extensions/blast.ts
937
+ // src/extensions/blast.ts
950
938
  import { EditorView as EditorView4, keymap as keymap2 } from "@codemirror/view";
951
939
  import defaultsDeep from "lodash.defaultsdeep";
940
+ import { throttle } from "@dxos/async";
952
941
  import { invariant as invariant2 } from "@dxos/invariant";
953
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
942
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
954
943
  var defaultOptions = {
955
944
  effect: 2,
956
945
  maxParticles: 200,
@@ -1078,7 +1067,7 @@ var Blaster = class {
1078
1067
  initialize() {
1079
1068
  invariant2(!this._canvas && !this._ctx, void 0, {
1080
1069
  F: __dxlog_file5,
1081
- L: 141,
1070
+ L: 142,
1082
1071
  S: this,
1083
1072
  A: [
1084
1073
  "!this._canvas && !this._ctx",
@@ -1115,7 +1104,7 @@ var Blaster = class {
1115
1104
  start() {
1116
1105
  invariant2(this._canvas && this._ctx, void 0, {
1117
1106
  F: __dxlog_file5,
1118
- L: 180,
1107
+ L: 181,
1119
1108
  S: this,
1120
1109
  A: [
1121
1110
  "this._canvas && this._ctx",
@@ -1219,18 +1208,6 @@ var Effect2 = class extends Effect {
1219
1208
  ctx.fill();
1220
1209
  }
1221
1210
  };
1222
- function throttle(callback, limit) {
1223
- let wait = false;
1224
- return function(...args) {
1225
- if (!wait) {
1226
- callback.apply(this, args);
1227
- wait = true;
1228
- setTimeout(() => {
1229
- wait = false;
1230
- }, limit);
1231
- }
1232
- };
1233
- }
1234
1211
  var getRGBComponents = (node, color) => {
1235
1212
  if (typeof color === "function") {
1236
1213
  return color();
@@ -1256,10 +1233,10 @@ var random = (min, max) => {
1256
1233
  return min + ~~(Math.random() * (max - min + 1));
1257
1234
  };
1258
1235
 
1259
- // packages/ui/react-ui-editor/src/extensions/command/action.ts
1236
+ // src/extensions/command/action.ts
1260
1237
  import { StateEffect as StateEffect2 } from "@codemirror/state";
1261
1238
 
1262
- // packages/ui/react-ui-editor/src/extensions/command/state.ts
1239
+ // src/extensions/command/state.ts
1263
1240
  import { StateField as StateField2 } from "@codemirror/state";
1264
1241
  import { showTooltip } from "@codemirror/view";
1265
1242
  var commandConfig = singleValueFacet();
@@ -1272,7 +1249,7 @@ var commandState = StateField2.define({
1272
1249
  }
1273
1250
  const { renderDialog } = tr.state.facet(commandConfig);
1274
1251
  if (effect.is(openEffect) && renderDialog) {
1275
- const { pos, fullWidth } = effect.value;
1252
+ const { pos, fullWidth: fullWidth2 } = effect.value;
1276
1253
  const tooltip = {
1277
1254
  pos,
1278
1255
  above: false,
@@ -1283,7 +1260,7 @@ var commandState = StateField2.define({
1283
1260
  const tooltipView = {
1284
1261
  dom: root,
1285
1262
  mount: (view2) => {
1286
- if (fullWidth) {
1263
+ if (fullWidth2) {
1287
1264
  const parent = root.parentElement;
1288
1265
  const { paddingLeft, paddingRight } = window.getComputedStyle(parent);
1289
1266
  const widthWithoutPadding = parent.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
@@ -1329,7 +1306,7 @@ var commandState = StateField2.define({
1329
1306
  ]
1330
1307
  });
1331
1308
 
1332
- // packages/ui/react-ui-editor/src/extensions/command/action.ts
1309
+ // src/extensions/command/action.ts
1333
1310
  var openEffect = StateEffect2.define();
1334
1311
  var closeEffect = StateEffect2.define();
1335
1312
  var openCommand = (view) => {
@@ -1369,12 +1346,12 @@ var commandKeyBindings = [
1369
1346
  }
1370
1347
  ];
1371
1348
 
1372
- // packages/ui/react-ui-editor/src/extensions/command/command.ts
1349
+ // src/extensions/command/command.ts
1373
1350
  import { Prec } from "@codemirror/state";
1374
1351
  import { EditorView as EditorView6, keymap as keymap3 } from "@codemirror/view";
1375
1352
  import { isNonNullable } from "@dxos/util";
1376
1353
 
1377
- // packages/ui/react-ui-editor/src/extensions/command/hint.ts
1354
+ // src/extensions/command/hint.ts
1378
1355
  import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
1379
1356
  import { Decoration as Decoration3, EditorView as EditorView5, ViewPlugin as ViewPlugin4, WidgetType as WidgetType2 } from "@codemirror/view";
1380
1357
  var hint = ({ delay = 3e3, onHint }) => {
@@ -1458,7 +1435,7 @@ var Hint = class extends WidgetType2 {
1458
1435
  }
1459
1436
  };
1460
1437
 
1461
- // packages/ui/react-ui-editor/src/extensions/command/command.ts
1438
+ // src/extensions/command/command.ts
1462
1439
  var command = (options = {}) => {
1463
1440
  return [
1464
1441
  Prec.highest(keymap3.of(commandKeyBindings)),
@@ -1474,11 +1451,11 @@ var command = (options = {}) => {
1474
1451
  ].filter(isNonNullable);
1475
1452
  };
1476
1453
 
1477
- // packages/ui/react-ui-editor/src/extensions/command/command-menu.ts
1454
+ // src/extensions/command/command-menu.ts
1478
1455
  import { RangeSetBuilder as RangeSetBuilder3, StateField as StateField3, StateEffect as StateEffect3, Prec as Prec2 } from "@codemirror/state";
1479
1456
  import { EditorView as EditorView8, ViewPlugin as ViewPlugin6, Decoration as Decoration5, keymap as keymap4 } from "@codemirror/view";
1480
1457
 
1481
- // packages/ui/react-ui-editor/src/extensions/command/placeholder.ts
1458
+ // src/extensions/command/placeholder.ts
1482
1459
  import { Decoration as Decoration4, EditorView as EditorView7, WidgetType as WidgetType3, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
1483
1460
  var placeholder = ({ delay = 3e3, content }) => {
1484
1461
  const plugin = ViewPlugin5.fromClass(class {
@@ -1560,7 +1537,7 @@ var Placeholder = class extends WidgetType3 {
1560
1537
  }
1561
1538
  };
1562
1539
 
1563
- // packages/ui/react-ui-editor/src/extensions/command/command-menu.ts
1540
+ // src/extensions/command/command-menu.ts
1564
1541
  var commandMenu = (options) => {
1565
1542
  const commandMenuPlugin = ViewPlugin6.fromClass(class {
1566
1543
  constructor(view) {
@@ -1717,7 +1694,7 @@ var commandMenuState = StateField3.define({
1717
1694
  }
1718
1695
  });
1719
1696
 
1720
- // packages/ui/react-ui-editor/src/extensions/command/floating-menu.ts
1697
+ // src/extensions/command/floating-menu.ts
1721
1698
  import { EditorView as EditorView9, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
1722
1699
  import { addEventListener } from "@dxos/async";
1723
1700
  var floatingMenu = (options = {}) => [
@@ -1806,8 +1783,93 @@ var floatingMenu = (options = {}) => [
1806
1783
  })
1807
1784
  ];
1808
1785
 
1809
- // packages/ui/react-ui-editor/src/extensions/command/useCommandMenu.ts
1810
- import { useCallback, useMemo as useMemo2, useRef, useState } from "react";
1786
+ // src/extensions/command/typeahead.ts
1787
+ import { EditorSelection, Prec as Prec3, RangeSetBuilder as RangeSetBuilder4 } from "@codemirror/state";
1788
+ import { Decoration as Decoration6, keymap as keymap5, ViewPlugin as ViewPlugin8 } from "@codemirror/view";
1789
+ var typeahead = ({ onComplete } = {}) => {
1790
+ let hint2;
1791
+ const complete = (view) => {
1792
+ if (!hint2) {
1793
+ return false;
1794
+ }
1795
+ const selection = view.state.selection.main;
1796
+ view.dispatch({
1797
+ changes: [
1798
+ {
1799
+ from: selection.from,
1800
+ to: selection.to,
1801
+ insert: hint2
1802
+ }
1803
+ ],
1804
+ selection: EditorSelection.cursor(selection.from + hint2.length)
1805
+ });
1806
+ return true;
1807
+ };
1808
+ return [
1809
+ ViewPlugin8.fromClass(class {
1810
+ constructor() {
1811
+ this.decorations = Decoration6.none;
1812
+ }
1813
+ update(update2) {
1814
+ const builder = new RangeSetBuilder4();
1815
+ const selection = update2.view.state.selection.main;
1816
+ const line = update2.view.state.doc.lineAt(selection.from);
1817
+ if (selection.from === selection.to && selection.from === line.to) {
1818
+ const str = update2.state.sliceDoc(line.from, selection.from);
1819
+ hint2 = onComplete?.({
1820
+ line: str
1821
+ });
1822
+ if (hint2) {
1823
+ builder.add(selection.from, selection.to, Decoration6.widget({
1824
+ widget: new Hint(hint2)
1825
+ }));
1826
+ }
1827
+ }
1828
+ this.decorations = builder.finish();
1829
+ }
1830
+ }, {
1831
+ decorations: (v) => v.decorations
1832
+ }),
1833
+ // Keys.
1834
+ Prec3.highest(keymap5.of([
1835
+ {
1836
+ key: "Tab",
1837
+ preventDefault: true,
1838
+ run: complete
1839
+ },
1840
+ {
1841
+ key: "ArrowRight",
1842
+ preventDefault: true,
1843
+ run: complete
1844
+ }
1845
+ ]))
1846
+ ];
1847
+ };
1848
+ var staticCompletion = (completions, options = {}) => ({ line }) => {
1849
+ if (line.length === 0 && options.default) {
1850
+ return options.default;
1851
+ }
1852
+ const parts = line.split(/\s+/).filter(Boolean);
1853
+ if (parts.length) {
1854
+ const str = parts.at(-1);
1855
+ if (str.length >= (options.minLength ?? 0)) {
1856
+ for (const completion of completions) {
1857
+ const match = matchCompletion(completion, str);
1858
+ if (match) {
1859
+ return match;
1860
+ }
1861
+ }
1862
+ }
1863
+ }
1864
+ };
1865
+ var matchCompletion = (completion, str, minLength = 0) => {
1866
+ if (str.length >= minLength && completion.length > str.length && completion.startsWith(str)) {
1867
+ return completion.slice(str.length);
1868
+ }
1869
+ };
1870
+
1871
+ // src/extensions/command/useCommandMenu.ts
1872
+ import { useCallback, useMemo, useRef, useState } from "react";
1811
1873
  var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu }) => {
1812
1874
  const triggerRef = useRef(null);
1813
1875
  const currentRef = useRef(null);
@@ -1855,7 +1917,7 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1855
1917
  void item.onSelect?.(view, selection.head);
1856
1918
  }, []);
1857
1919
  const serializedTrigger = Array.isArray(trigger) ? trigger.join(",") : trigger;
1858
- const _commandMenu = useMemo2(() => {
1920
+ const _commandMenu = useMemo(() => {
1859
1921
  return commandMenu({
1860
1922
  trigger,
1861
1923
  placeholder: placeholder3,
@@ -1907,90 +1969,7 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1907
1969
  };
1908
1970
  };
1909
1971
 
1910
- // packages/ui/react-ui-editor/src/extensions/command/typeahead.ts
1911
- import { EditorSelection, Prec as Prec3, RangeSetBuilder as RangeSetBuilder4 } from "@codemirror/state";
1912
- import { Decoration as Decoration6, keymap as keymap5, ViewPlugin as ViewPlugin8 } from "@codemirror/view";
1913
- var typeahead = ({ onComplete } = {}) => {
1914
- let hint2;
1915
- const complete = (view) => {
1916
- if (!hint2) {
1917
- return false;
1918
- }
1919
- const selection = view.state.selection.main;
1920
- view.dispatch({
1921
- changes: [
1922
- {
1923
- from: selection.from,
1924
- to: selection.to,
1925
- insert: hint2
1926
- }
1927
- ],
1928
- selection: EditorSelection.cursor(selection.from + hint2.length)
1929
- });
1930
- return true;
1931
- };
1932
- return [
1933
- ViewPlugin8.fromClass(class {
1934
- constructor() {
1935
- this.decorations = Decoration6.none;
1936
- }
1937
- update(update2) {
1938
- const builder = new RangeSetBuilder4();
1939
- const selection = update2.view.state.selection.main;
1940
- const line = update2.view.state.doc.lineAt(selection.from);
1941
- if (selection.from === selection.to && selection.from === line.to) {
1942
- const str = update2.state.sliceDoc(line.from, selection.from);
1943
- hint2 = onComplete?.({
1944
- line: str
1945
- });
1946
- if (hint2) {
1947
- builder.add(selection.from, selection.to, Decoration6.widget({
1948
- widget: new Hint(hint2)
1949
- }));
1950
- }
1951
- }
1952
- this.decorations = builder.finish();
1953
- }
1954
- }, {
1955
- decorations: (v) => v.decorations
1956
- }),
1957
- // Keys.
1958
- Prec3.highest(keymap5.of([
1959
- {
1960
- key: "Tab",
1961
- preventDefault: true,
1962
- run: complete
1963
- },
1964
- {
1965
- key: "ArrowRight",
1966
- preventDefault: true,
1967
- run: complete
1968
- }
1969
- ]))
1970
- ];
1971
- };
1972
- var staticCompletion = (completions, defaultCompletion) => ({ line }) => {
1973
- if (line.length === 0 && defaultCompletion) {
1974
- return defaultCompletion;
1975
- }
1976
- const words = line.split(/\s+/).filter(Boolean);
1977
- if (words.length) {
1978
- const word = words.at(-1);
1979
- for (const completion of completions) {
1980
- const match = matchCompletion(completion, word);
1981
- if (match) {
1982
- return match;
1983
- }
1984
- }
1985
- }
1986
- };
1987
- var matchCompletion = (completion, word) => {
1988
- if (completion.length > word.length && completion.startsWith(word)) {
1989
- return completion.slice(word.length);
1990
- }
1991
- };
1992
-
1993
- // packages/ui/react-ui-editor/src/extensions/comments.ts
1972
+ // src/extensions/comments.ts
1994
1973
  import { invertedEffects } from "@codemirror/commands";
1995
1974
  import { StateEffect as StateEffect4, StateField as StateField4 } from "@codemirror/state";
1996
1975
  import { hoverTooltip, keymap as keymap7, Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin9 } from "@codemirror/view";
@@ -2000,13 +1979,13 @@ import { debounce as debounce2 } from "@dxos/async";
2000
1979
  import { log as log4 } from "@dxos/log";
2001
1980
  import { isNonNullable as isNonNullable2 } from "@dxos/util";
2002
1981
 
2003
- // packages/ui/react-ui-editor/src/extensions/selection.ts
1982
+ // src/extensions/selection.ts
2004
1983
  import { Transaction } from "@codemirror/state";
2005
1984
  import { EditorView as EditorView10, keymap as keymap6 } from "@codemirror/view";
2006
1985
  import { debounce } from "@dxos/async";
2007
1986
  import { invariant as invariant3 } from "@dxos/invariant";
2008
1987
  import { isNotFalsy } from "@dxos/util";
2009
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/selection.ts";
1988
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/selection.ts";
2010
1989
  var documentId = singleValueFacet();
2011
1990
  var stateRestoreAnnotation = "dxos.org/cm/state-restore";
2012
1991
  var createEditorStateTransaction = ({ scrollTo, selection }) => {
@@ -2093,8 +2072,8 @@ var selectionState = ({ getState, setState } = {}) => {
2093
2072
  ].filter(isNotFalsy);
2094
2073
  };
2095
2074
 
2096
- // packages/ui/react-ui-editor/src/extensions/comments.ts
2097
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/comments.ts";
2075
+ // src/extensions/comments.ts
2076
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/comments.ts";
2098
2077
  var setComments = StateEffect4.define();
2099
2078
  var setSelection = StateEffect4.define();
2100
2079
  var setCommentState = StateEffect4.define();
@@ -2518,7 +2497,7 @@ var useComments = (view, id, comments2) => {
2518
2497
  });
2519
2498
  };
2520
2499
 
2521
- // packages/ui/react-ui-editor/src/extensions/debug.ts
2500
+ // src/extensions/debug.ts
2522
2501
  import { syntaxTree } from "@codemirror/language";
2523
2502
  import { StateField as StateField5 } from "@codemirror/state";
2524
2503
  var debugNodeLogger = (log9 = console.log) => {
@@ -2531,7 +2510,7 @@ var debugNodeLogger = (log9 = console.log) => {
2531
2510
  });
2532
2511
  };
2533
2512
 
2534
- // packages/ui/react-ui-editor/src/extensions/dnd.ts
2513
+ // src/extensions/dnd.ts
2535
2514
  import { dropCursor, EditorView as EditorView12 } from "@codemirror/view";
2536
2515
  var styles3 = EditorView12.theme({
2537
2516
  ".cm-dropCursor": {
@@ -2567,7 +2546,7 @@ var dropFile = (options = {}) => {
2567
2546
  ];
2568
2547
  };
2569
2548
 
2570
- // packages/ui/react-ui-editor/src/extensions/factories.ts
2549
+ // src/extensions/factories.ts
2571
2550
  import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
2572
2551
  import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap } from "@codemirror/commands";
2573
2552
  import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
@@ -2581,7 +2560,7 @@ import { generateName } from "@dxos/display-name";
2581
2560
  import { log as log5 } from "@dxos/log";
2582
2561
  import { hexToHue, isNotFalsy as isNotFalsy2 } from "@dxos/util";
2583
2562
 
2584
- // packages/ui/react-ui-editor/src/extensions/focus.ts
2563
+ // src/extensions/focus.ts
2585
2564
  import { StateEffect as StateEffect5, StateField as StateField6 } from "@codemirror/state";
2586
2565
  import { EditorView as EditorView13 } from "@codemirror/view";
2587
2566
  var focusEffect = StateEffect5.define();
@@ -2612,11 +2591,11 @@ var focus = [
2612
2591
  })
2613
2592
  ];
2614
2593
 
2615
- // packages/ui/react-ui-editor/src/defaults.ts
2594
+ // src/defaults.ts
2616
2595
  import { EditorView as EditorView14 } from "@codemirror/view";
2617
2596
  import { mx as mx2 } from "@dxos/react-ui-theme";
2618
2597
 
2619
- // packages/ui/react-ui-editor/src/styles/markdown.ts
2598
+ // src/styles/markdown.ts
2620
2599
  import { mx } from "@dxos/react-ui-theme";
2621
2600
  var headings = {
2622
2601
  1: "text-4xl",
@@ -2635,7 +2614,7 @@ var theme = {
2635
2614
  }
2636
2615
  };
2637
2616
 
2638
- // packages/ui/react-ui-editor/src/styles/tokens.ts
2617
+ // src/styles/tokens.ts
2639
2618
  import { tokens } from "@dxos/react-ui-theme";
2640
2619
  import { get } from "@dxos/util";
2641
2620
  var getToken = (path, defaultValue) => {
@@ -2645,7 +2624,7 @@ var getToken = (path, defaultValue) => {
2645
2624
  var fontBody = getToken("fontFamily.body");
2646
2625
  var fontMono = getToken("fontFamily.mono");
2647
2626
 
2648
- // packages/ui/react-ui-editor/src/styles/theme.ts
2627
+ // src/styles/theme.ts
2649
2628
  var defaultTheme = {
2650
2629
  "&": {},
2651
2630
  "&.cm-focused": {
@@ -2680,18 +2659,17 @@ var defaultTheme = {
2680
2659
  ".cm-gutter": {},
2681
2660
  ".cm-gutter.cm-lineNumbers": {
2682
2661
  paddingRight: "4px",
2683
- borderRight: "1px solid var(--dx-separator)"
2662
+ borderRight: "1px solid var(--dx-subduedSeparator)"
2684
2663
  },
2685
2664
  ".cm-gutter.cm-lineNumbers .cm-gutterElement": {
2686
- minWidth: "40px",
2687
- alignContent: "center"
2665
+ minWidth: "40px"
2688
2666
  },
2689
2667
  /**
2690
- * Height is set to match the corresponding line.
2668
+ * Height is set to match the corresponding line (which may have wrapped).
2691
2669
  */
2692
2670
  ".cm-gutterElement": {
2693
- alignItems: "center",
2694
- fontSize: "12px"
2671
+ fontSize: "12px",
2672
+ lineHeight: "24px"
2695
2673
  },
2696
2674
  /**
2697
2675
  * Line.
@@ -2709,7 +2687,7 @@ var defaultTheme = {
2709
2687
  borderLeft: "2px solid var(--dx-cmCursor)"
2710
2688
  },
2711
2689
  ".cm-placeholder": {
2712
- color: "var(--dx-subdued)"
2690
+ color: "var(--dx-placeholder)"
2713
2691
  },
2714
2692
  /**
2715
2693
  * Selection (layer).
@@ -2857,7 +2835,7 @@ var defaultTheme = {
2857
2835
  }
2858
2836
  };
2859
2837
 
2860
- // packages/ui/react-ui-editor/src/defaults.ts
2838
+ // src/defaults.ts
2861
2839
  var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
2862
2840
  var editorSlots = {
2863
2841
  scroll: {
@@ -2881,8 +2859,8 @@ var editorMonospace = EditorView14.theme({
2881
2859
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
2882
2860
  var stackItemContentEditorClassNames = (role) => mx2("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
2883
2861
 
2884
- // packages/ui/react-ui-editor/src/extensions/factories.ts
2885
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
2862
+ // src/extensions/factories.ts
2863
+ var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
2886
2864
  var preventNewline = EditorState.transactionFilter.of((tr) => tr.newDoc.lines > 1 ? [] : tr);
2887
2865
  var defaultBasicOptions = {
2888
2866
  allowMultipleSelections: true,
@@ -2958,11 +2936,17 @@ var createBasicExtensions = (_props) => {
2958
2936
  ].filter(isNotFalsy2))
2959
2937
  ].filter(isNotFalsy2);
2960
2938
  };
2961
- var defaultThemeSlots = {
2939
+ var grow = {
2940
+ editor: {
2941
+ className: "is-full bs-full"
2942
+ }
2943
+ };
2944
+ var fullWidth = {
2962
2945
  editor: {
2963
- className: "w-full bs-full"
2946
+ className: "is-full"
2964
2947
  }
2965
2948
  };
2949
+ var defaultThemeSlots = grow;
2966
2950
  var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
2967
2951
  const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
2968
2952
  return [
@@ -2980,6 +2964,11 @@ var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _
2980
2964
  constructor(view) {
2981
2965
  view.scrollDOM.classList.add(slots.scroll.className);
2982
2966
  }
2967
+ }),
2968
+ slots.scroller?.className && ViewPlugin10.fromClass(class {
2969
+ constructor(view) {
2970
+ view.dom.querySelector(".cm-scroller")?.classList.add(...slots.scroller.className.split(" "));
2971
+ }
2983
2972
  })
2984
2973
  ].filter(isNotFalsy2);
2985
2974
  };
@@ -3005,7 +2994,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
3005
2994
  return extensions;
3006
2995
  };
3007
2996
 
3008
- // packages/ui/react-ui-editor/src/extensions/folding.tsx
2997
+ // src/extensions/folding.tsx
3009
2998
  import { codeFolding, foldGutter } from "@codemirror/language";
3010
2999
  import { EditorView as EditorView16 } from "@codemirror/view";
3011
3000
  import React2 from "react";
@@ -3043,7 +3032,7 @@ var folding = (_props = {}) => [
3043
3032
  })
3044
3033
  ];
3045
3034
 
3046
- // packages/ui/react-ui-editor/src/extensions/hashtag.tsx
3035
+ // src/extensions/hashtag.tsx
3047
3036
  import { Decoration as Decoration8, EditorView as EditorView17, MatchDecorator, ViewPlugin as ViewPlugin11, WidgetType as WidgetType4 } from "@codemirror/view";
3048
3037
  import { getHashColor, mx as mx3 } from "@dxos/react-ui-theme";
3049
3038
  var TagWidget = class extends WidgetType4 {
@@ -3086,7 +3075,7 @@ var hashtag = () => [
3086
3075
  })
3087
3076
  ];
3088
3077
 
3089
- // packages/ui/react-ui-editor/src/extensions/json.ts
3078
+ // src/extensions/json.ts
3090
3079
  import { json, jsonParseLinter } from "@codemirror/lang-json";
3091
3080
  import { linter } from "@codemirror/lint";
3092
3081
  import Ajv from "ajv";
@@ -3131,7 +3120,7 @@ var schemaLinter = (validate) => (view) => {
3131
3120
  }
3132
3121
  };
3133
3122
 
3134
- // packages/ui/react-ui-editor/src/extensions/listener.ts
3123
+ // src/extensions/listener.ts
3135
3124
  import { EditorView as EditorView18 } from "@codemirror/view";
3136
3125
  var listener = ({ onFocus, onChange }) => {
3137
3126
  const extensions = [];
@@ -3145,12 +3134,13 @@ var listener = ({ onFocus, onChange }) => {
3145
3134
  return extensions;
3146
3135
  };
3147
3136
 
3148
- // packages/ui/react-ui-editor/src/extensions/markdown/formatting.ts
3137
+ // src/extensions/markdown/formatting.ts
3149
3138
  import { snippet } from "@codemirror/autocomplete";
3150
3139
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
3151
3140
  import { EditorSelection as EditorSelection2 } from "@codemirror/state";
3152
3141
  import { EditorView as EditorView19, keymap as keymap9 } from "@codemirror/view";
3153
- import { useMemo as useMemo3 } from "react";
3142
+ import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
3143
+ import { debounceAndThrottle } from "@dxos/async";
3154
3144
  var formattingEquals = (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;
3155
3145
  var Inline = /* @__PURE__ */ function(Inline2) {
3156
3146
  Inline2[Inline2["Strong"] = 0] = "Strong";
@@ -4238,16 +4228,21 @@ var getFormatting = (state) => {
4238
4228
  };
4239
4229
  };
4240
4230
  var useFormattingState = (state) => {
4241
- return useMemo3(() => EditorView19.updateListener.of((update2) => {
4231
+ const handleUpdate = useCallback2(debounceAndThrottle((update2) => {
4242
4232
  if (update2.docChanged || update2.selectionSet) {
4243
4233
  Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
4244
4234
  state[key] = active;
4245
4235
  });
4246
4236
  }
4247
- }), []);
4237
+ }, 100), [
4238
+ state
4239
+ ]);
4240
+ return useMemo2(() => EditorView19.updateListener.of(handleUpdate), [
4241
+ handleUpdate
4242
+ ]);
4248
4243
  };
4249
4244
 
4250
- // packages/ui/react-ui-editor/src/extensions/markdown/action.ts
4245
+ // src/extensions/markdown/action.ts
4251
4246
  var processEditorPayload = (view, { type, data }) => {
4252
4247
  let inlineType, listType;
4253
4248
  switch (type) {
@@ -4296,7 +4291,7 @@ var processEditorPayload = (view, { type, data }) => {
4296
4291
  });
4297
4292
  };
4298
4293
 
4299
- // packages/ui/react-ui-editor/src/extensions/markdown/bundle.ts
4294
+ // src/extensions/markdown/bundle.ts
4300
4295
  import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
4301
4296
  import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
4302
4297
  import { markdownLanguage as markdownLanguage3, markdown } from "@codemirror/lang-markdown";
@@ -4305,7 +4300,7 @@ import { languages } from "@codemirror/language-data";
4305
4300
  import { keymap as keymap10 } from "@codemirror/view";
4306
4301
  import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
4307
4302
 
4308
- // packages/ui/react-ui-editor/src/extensions/markdown/highlight.ts
4303
+ // src/extensions/markdown/highlight.ts
4309
4304
  import { markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
4310
4305
  import { HighlightStyle } from "@codemirror/language";
4311
4306
  import { tags, styleTags, Tag } from "@lezer/highlight";
@@ -4484,7 +4479,7 @@ var markdownHighlightStyle = (_options = {}) => {
4484
4479
  });
4485
4480
  };
4486
4481
 
4487
- // packages/ui/react-ui-editor/src/extensions/markdown/bundle.ts
4482
+ // src/extensions/markdown/bundle.ts
4488
4483
  var createMarkdownExtensions = (options = {}) => {
4489
4484
  return [
4490
4485
  // Main extension.
@@ -4519,7 +4514,7 @@ var createMarkdownExtensions = (options = {}) => {
4519
4514
  ];
4520
4515
  };
4521
4516
 
4522
- // packages/ui/react-ui-editor/src/extensions/markdown/debug.ts
4517
+ // src/extensions/markdown/debug.ts
4523
4518
  import { syntaxTree as syntaxTree3 } from "@codemirror/language";
4524
4519
  import { StateField as StateField7 } from "@codemirror/state";
4525
4520
  var debugTree = (cb) => StateField7.define({
@@ -4546,14 +4541,14 @@ var convertTreeToJson = (state) => {
4546
4541
  return treeToJson(syntaxTree3(state).cursor());
4547
4542
  };
4548
4543
 
4549
- // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
4544
+ // src/extensions/markdown/decorate.ts
4550
4545
  import { syntaxTree as syntaxTree7 } from "@codemirror/language";
4551
4546
  import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect6 } from "@codemirror/state";
4552
4547
  import { EditorView as EditorView23, Decoration as Decoration11, WidgetType as WidgetType7, ViewPlugin as ViewPlugin13 } from "@codemirror/view";
4553
4548
  import { invariant as invariant4 } from "@dxos/invariant";
4554
4549
  import { mx as mx4 } from "@dxos/react-ui-theme";
4555
4550
 
4556
- // packages/ui/react-ui-editor/src/extensions/markdown/changes.ts
4551
+ // src/extensions/markdown/changes.ts
4557
4552
  import { syntaxTree as syntaxTree4 } from "@codemirror/language";
4558
4553
  import { Transaction as Transaction2 } from "@codemirror/state";
4559
4554
  import { ViewPlugin as ViewPlugin12 } from "@codemirror/view";
@@ -4697,7 +4692,7 @@ var getValidUrl = (str) => {
4697
4692
  }
4698
4693
  };
4699
4694
 
4700
- // packages/ui/react-ui-editor/src/extensions/markdown/image.ts
4695
+ // src/extensions/markdown/image.ts
4701
4696
  import { syntaxTree as syntaxTree5 } from "@codemirror/language";
4702
4697
  import { StateField as StateField8 } from "@codemirror/state";
4703
4698
  import { Decoration as Decoration9, EditorView as EditorView20, WidgetType as WidgetType5 } from "@codemirror/view";
@@ -4786,7 +4781,7 @@ var ImageWidget = class extends WidgetType5 {
4786
4781
  }
4787
4782
  };
4788
4783
 
4789
- // packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
4784
+ // src/extensions/markdown/styles.ts
4790
4785
  import { EditorView as EditorView21 } from "@codemirror/view";
4791
4786
  var bulletListIndentationWidth = 24;
4792
4787
  var orderedListIndentationWidth = 36;
@@ -4909,7 +4904,7 @@ var formattingStyles = EditorView21.theme({
4909
4904
  }
4910
4905
  });
4911
4906
 
4912
- // packages/ui/react-ui-editor/src/extensions/markdown/table.ts
4907
+ // src/extensions/markdown/table.ts
4913
4908
  import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4914
4909
  import { RangeSetBuilder as RangeSetBuilder5, StateField as StateField9 } from "@codemirror/state";
4915
4910
  import { Decoration as Decoration10, EditorView as EditorView22, WidgetType as WidgetType6 } from "@codemirror/view";
@@ -5007,8 +5002,8 @@ var TableWidget = class extends WidgetType6 {
5007
5002
  }
5008
5003
  };
5009
5004
 
5010
- // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
5011
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts";
5005
+ // src/extensions/markdown/decorate.ts
5006
+ var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts";
5012
5007
  var Unicode = {
5013
5008
  emDash: "\u2014",
5014
5009
  bullet: "\u2022",
@@ -5462,7 +5457,7 @@ var decorateMarkdown = (options = {}) => {
5462
5457
  ];
5463
5458
  };
5464
5459
 
5465
- // packages/ui/react-ui-editor/src/extensions/markdown/link.ts
5460
+ // src/extensions/markdown/link.ts
5466
5461
  import { syntaxTree as syntaxTree8 } from "@codemirror/language";
5467
5462
  import { hoverTooltip as hoverTooltip2 } from "@codemirror/view";
5468
5463
  import { tooltipContent } from "@dxos/react-ui-theme";
@@ -5504,10 +5499,10 @@ var linkTooltip = (renderTooltip) => {
5504
5499
  });
5505
5500
  };
5506
5501
 
5507
- // packages/ui/react-ui-editor/src/extensions/mention.ts
5502
+ // src/extensions/mention.ts
5508
5503
  import { autocompletion as autocompletion2 } from "@codemirror/autocomplete";
5509
5504
  import { log as log6 } from "@dxos/log";
5510
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/mention.ts";
5505
+ var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/mention.ts";
5511
5506
  var mention = ({ debug, onSearch }) => {
5512
5507
  return autocompletion2({
5513
5508
  // TODO(burdon): Not working.
@@ -5542,23 +5537,10 @@ var mention = ({ debug, onSearch }) => {
5542
5537
  });
5543
5538
  };
5544
5539
 
5545
- // packages/ui/react-ui-editor/src/extensions/modes.ts
5540
+ // src/extensions/modes.ts
5546
5541
  import { keymap as keymap11 } from "@codemirror/view";
5547
5542
  import { vim } from "@replit/codemirror-vim";
5548
5543
  import { vscodeKeymap } from "@replit/codemirror-vscode-keymap";
5549
- import { Schema } from "effect";
5550
- var EditorViewModes = [
5551
- "preview",
5552
- "readonly",
5553
- "source"
5554
- ];
5555
- var EditorViewMode = Schema.Union(...EditorViewModes.map((mode) => Schema.Literal(mode)));
5556
- var EditorInputModes = [
5557
- "default",
5558
- "vim",
5559
- "vscode"
5560
- ];
5561
- var EditorInputMode = Schema.Union(...EditorInputModes.map((mode) => Schema.Literal(mode)));
5562
5544
  var editorInputMode = singleValueFacet({});
5563
5545
  var InputModeExtensions = {
5564
5546
  default: [],
@@ -5588,21 +5570,21 @@ var InputModeExtensions = {
5588
5570
  ]
5589
5571
  };
5590
5572
 
5591
- // packages/ui/react-ui-editor/src/extensions/outliner/commands.ts
5573
+ // src/extensions/outliner/commands.ts
5592
5574
  import { indentMore } from "@codemirror/commands";
5593
5575
  import { getIndentUnit } from "@codemirror/language";
5594
5576
  import { EditorSelection as EditorSelection3 } from "@codemirror/state";
5595
5577
  import { keymap as keymap12 } from "@codemirror/view";
5596
5578
 
5597
- // packages/ui/react-ui-editor/src/extensions/outliner/selection.ts
5579
+ // src/extensions/outliner/selection.ts
5598
5580
  import { Compartment, Facet as Facet3 } from "@codemirror/state";
5599
5581
 
5600
- // packages/ui/react-ui-editor/src/extensions/outliner/tree.ts
5582
+ // src/extensions/outliner/tree.ts
5601
5583
  import { syntaxTree as syntaxTree9 } from "@codemirror/language";
5602
5584
  import { StateField as StateField10 } from "@codemirror/state";
5603
5585
  import { Facet as Facet2 } from "@codemirror/state";
5604
5586
  import { invariant as invariant5 } from "@dxos/invariant";
5605
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/tree.ts";
5587
+ var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/tree.ts";
5606
5588
  var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
5607
5589
  return {
5608
5590
  type,
@@ -5896,7 +5878,7 @@ var outlinerTree = (options = {}) => {
5896
5878
  ];
5897
5879
  };
5898
5880
 
5899
- // packages/ui/react-ui-editor/src/extensions/outliner/selection.ts
5881
+ // src/extensions/outliner/selection.ts
5900
5882
  var getSelection = (state) => state.selection.main;
5901
5883
  var selectionEquals = (a, b) => a.length === b.length && a.every((i) => b.includes(i));
5902
5884
  var selectionFacet = Facet3.define({
@@ -5926,7 +5908,7 @@ var selectDown = (view) => {
5926
5908
  return true;
5927
5909
  };
5928
5910
 
5929
- // packages/ui/react-ui-editor/src/extensions/outliner/commands.ts
5911
+ // src/extensions/outliner/commands.ts
5930
5912
  var indentItemMore = (view) => {
5931
5913
  const pos = getSelection(view.state).from;
5932
5914
  const tree = view.state.facet(treeFacet);
@@ -6160,16 +6142,16 @@ var commands = () => keymap12.of([
6160
6142
  }
6161
6143
  ]);
6162
6144
 
6163
- // packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
6145
+ // src/extensions/outliner/outliner.ts
6164
6146
  import { Prec as Prec4 } from "@codemirror/state";
6165
6147
  import { Decoration as Decoration12, EditorView as EditorView24, ViewPlugin as ViewPlugin15 } from "@codemirror/view";
6166
6148
  import { mx as mx5 } from "@dxos/react-ui-theme";
6167
6149
 
6168
- // packages/ui/react-ui-editor/src/extensions/outliner/editor.ts
6150
+ // src/extensions/outliner/editor.ts
6169
6151
  import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
6170
6152
  import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
6171
6153
  import { log as log7 } from "@dxos/log";
6172
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
6154
+ var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
6173
6155
  var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
6174
6156
  var initialize = () => {
6175
6157
  return ViewPlugin14.fromClass(class {
@@ -6354,7 +6336,7 @@ var editor = () => [
6354
6336
  })
6355
6337
  ];
6356
6338
 
6357
- // packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
6339
+ // src/extensions/outliner/outliner.ts
6358
6340
  var outliner = (options = {}) => [
6359
6341
  // Commands.
6360
6342
  Prec4.highest(commands()),
@@ -6446,7 +6428,7 @@ var decorations = () => [
6446
6428
  }))
6447
6429
  ];
6448
6430
 
6449
- // packages/ui/react-ui-editor/src/extensions/preview/preview.ts
6431
+ // src/extensions/preview/preview.ts
6450
6432
  import "@dxos/lit-ui/dx-ref-tag.pcss";
6451
6433
  import { syntaxTree as syntaxTree10 } from "@codemirror/language";
6452
6434
  import { RangeSetBuilder as RangeSetBuilder7, StateField as StateField11 } from "@codemirror/state";
@@ -6554,7 +6536,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
6554
6536
  }
6555
6537
  };
6556
6538
 
6557
- // packages/ui/react-ui-editor/src/extensions/typewriter.ts
6539
+ // src/extensions/typewriter.ts
6558
6540
  import { keymap as keymap13 } from "@codemirror/view";
6559
6541
  var defaultItems = [
6560
6542
  "hello world!",
@@ -6611,75 +6593,282 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
6611
6593
  ];
6612
6594
  };
6613
6595
 
6614
- // packages/ui/react-ui-editor/src/components/EditorToolbar/blocks.ts
6615
- var createBlockGroupAction = (value) => createEditorActionGroup("block", {
6616
- variant: "toggleGroup",
6617
- selectCardinality: "single",
6618
- value
6619
- });
6620
- var createBlockActions = (value, getView, blankLine) => Object.entries({
6621
- blockquote: "ph--quotes--regular",
6622
- codeblock: "ph--code-block--regular",
6623
- table: "ph--table--regular"
6624
- }).map(([type, icon]) => {
6625
- const checked = type === value;
6626
- return createEditorAction(type, () => {
6627
- const view = getView();
6628
- if (!view) {
6629
- return;
6630
- }
6631
- switch (type) {
6632
- case "blockquote":
6633
- checked ? removeBlockquote(view) : addBlockquote(view);
6634
- break;
6635
- case "codeblock":
6636
- checked ? removeCodeblock(view) : addCodeblock(view);
6637
- break;
6638
- case "table":
6639
- insertTable(view);
6640
- break;
6641
- }
6642
- }, {
6643
- checked,
6644
- ...type === "table" && {
6645
- disabled: !!blankLine
6646
- },
6647
- icon
6648
- });
6649
- });
6650
- var createBlocks = (state, getView) => {
6651
- const value = state?.blockQuote ? "blockquote" : state.blockType ?? "";
6652
- const blockGroupAction = createBlockGroupAction(value);
6653
- const blockActions = createBlockActions(value, getView, state.blankLine);
6654
- return {
6655
- nodes: [
6656
- blockGroupAction,
6657
- ...blockActions
6658
- ],
6659
- edges: [
6660
- {
6661
- source: "root",
6662
- target: "block"
6663
- },
6664
- ...blockActions.map(({ id }) => ({
6665
- source: blockGroupAction.id,
6666
- target: id
6667
- }))
6668
- ]
6669
- };
6670
- };
6671
-
6672
- // packages/ui/react-ui-editor/src/components/EditorToolbar/formatting.ts
6673
- var formats = {
6674
- strong: "ph--text-b--regular",
6675
- emphasis: "ph--text-italic--regular",
6676
- strikethrough: "ph--text-strikethrough--regular",
6677
- code: "ph--code--regular",
6678
- link: "ph--link--regular"
6679
- };
6680
- var createFormattingGroup = (formatting) => createEditorActionGroup("formatting", {
6681
- variant: "toggleGroup",
6682
- selectCardinality: "multiple",
6596
+ // src/hooks/useTextEditor.ts
6597
+ var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
6598
+ var instanceCount = 0;
6599
+ var useTextEditor = (props = {}, deps = []) => {
6600
+ const { id, doc, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = useMemo3(() => getProviderValue(props), deps ?? []);
6601
+ const [instanceId] = useState2(() => `text-editor-${++instanceCount}`);
6602
+ const [view, setView] = useState2();
6603
+ const parentRef = useRef2(null);
6604
+ useEffect2(() => {
6605
+ let view2;
6606
+ if (parentRef.current) {
6607
+ log8("create", {
6608
+ id,
6609
+ instanceId,
6610
+ doc: initialValue?.length ?? 0
6611
+ }, {
6612
+ F: __dxlog_file13,
6613
+ L: 75,
6614
+ S: void 0,
6615
+ C: (f, a) => f(...a)
6616
+ });
6617
+ let initialSelection;
6618
+ if (selection?.anchor && initialValue?.length) {
6619
+ if (selection.anchor <= initialValue.length && (selection?.head ?? 0) <= initialValue.length) {
6620
+ initialSelection = selection;
6621
+ }
6622
+ } else if (moveToEndOfLine && selection === void 0) {
6623
+ const index = initialValue?.indexOf("\n");
6624
+ const anchor = !index || index === -1 ? 0 : index;
6625
+ initialSelection = {
6626
+ anchor
6627
+ };
6628
+ }
6629
+ const state = EditorState3.create({
6630
+ doc: doc ?? initialValue,
6631
+ // selection: initialSelection,
6632
+ extensions: [
6633
+ id && documentId.of(id),
6634
+ extensions,
6635
+ // NOTE: This doesn't catch errors in keymap functions.
6636
+ EditorView26.exceptionSink.of((err) => {
6637
+ log8.catch(err, void 0, {
6638
+ F: __dxlog_file13,
6639
+ L: 97,
6640
+ S: void 0,
6641
+ C: (f, a) => f(...a)
6642
+ });
6643
+ })
6644
+ ].filter(isNotFalsy4)
6645
+ });
6646
+ view2 = new EditorView26({
6647
+ parent: parentRef.current,
6648
+ state,
6649
+ scrollTo: scrollTo ? EditorView26.scrollIntoView(scrollTo, {
6650
+ yMargin: 96
6651
+ }) : void 0,
6652
+ dispatchTransactions: debug ? debugDispatcher : void 0
6653
+ });
6654
+ if (moveToEndOfLine && !initialSelection) {
6655
+ const { to } = view2.state.doc.lineAt(0);
6656
+ if (to) {
6657
+ view2.dispatch({
6658
+ selection: {
6659
+ anchor: to
6660
+ }
6661
+ });
6662
+ }
6663
+ }
6664
+ setView(view2);
6665
+ }
6666
+ return () => {
6667
+ log8("destroy", {
6668
+ id
6669
+ }, {
6670
+ F: __dxlog_file13,
6671
+ L: 134,
6672
+ S: void 0,
6673
+ C: (f, a) => f(...a)
6674
+ });
6675
+ view2?.destroy();
6676
+ };
6677
+ }, deps);
6678
+ useEffect2(() => {
6679
+ if (view) {
6680
+ if (scrollTo || selection) {
6681
+ if (selection && selection.anchor > view.state.doc.length) {
6682
+ log8.warn("invalid selection", {
6683
+ length: view.state.doc.length,
6684
+ scrollTo,
6685
+ selection
6686
+ }, {
6687
+ F: __dxlog_file13,
6688
+ L: 143,
6689
+ S: void 0,
6690
+ C: (f, a) => f(...a)
6691
+ });
6692
+ return;
6693
+ }
6694
+ view.dispatch(createEditorStateTransaction({
6695
+ scrollTo,
6696
+ selection
6697
+ }));
6698
+ }
6699
+ }
6700
+ }, [
6701
+ view,
6702
+ scrollTo,
6703
+ selection
6704
+ ]);
6705
+ useEffect2(() => {
6706
+ if (view && autoFocus) {
6707
+ view.focus();
6708
+ }
6709
+ }, [
6710
+ autoFocus,
6711
+ view
6712
+ ]);
6713
+ const focusableGroupAttrs = useFocusableGroup({
6714
+ tabBehavior: "limited",
6715
+ ignoreDefaultKeydown: {
6716
+ Escape: view?.state.facet(editorInputMode).noTabster
6717
+ }
6718
+ });
6719
+ const handleKeyUp = useCallback3((event) => {
6720
+ const { key, target, currentTarget } = event;
6721
+ if (target === currentTarget) {
6722
+ switch (key) {
6723
+ case "Enter": {
6724
+ view?.focus();
6725
+ break;
6726
+ }
6727
+ }
6728
+ }
6729
+ }, [
6730
+ view
6731
+ ]);
6732
+ return {
6733
+ parentRef,
6734
+ view,
6735
+ focusAttributes: {
6736
+ tabIndex: 0,
6737
+ ...focusableGroupAttrs,
6738
+ onKeyUp: handleKeyUp
6739
+ }
6740
+ };
6741
+ };
6742
+
6743
+ // src/components/Editor/Editor.tsx
6744
+ var Editor = /* @__PURE__ */ forwardRef(({ classNames, id, text, ...props }, forwardedRef) => {
6745
+ var _effect = _useSignals();
6746
+ try {
6747
+ const { themeMode } = useThemeContext();
6748
+ const { parentRef, focusAttributes, view } = useTextEditor(() => ({
6749
+ id,
6750
+ initialValue: text.content,
6751
+ ...props
6752
+ }), [
6753
+ id,
6754
+ text,
6755
+ themeMode
6756
+ ]);
6757
+ useImperativeHandle(forwardedRef, () => view, [
6758
+ view
6759
+ ]);
6760
+ return /* @__PURE__ */ React3.createElement("div", {
6761
+ ref: parentRef,
6762
+ className: mx6(classNames),
6763
+ ...focusAttributes
6764
+ });
6765
+ } finally {
6766
+ _effect.f();
6767
+ }
6768
+ });
6769
+
6770
+ // src/components/EditorToolbar/EditorToolbar.tsx
6771
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
6772
+ import { Rx } from "@effect-rx/rx-react";
6773
+ import React4, { memo, useMemo as useMemo5 } from "react";
6774
+ import { rxFromSignal } from "@dxos/app-graph";
6775
+ import { ElevationProvider } from "@dxos/react-ui";
6776
+ import { MenuProvider, ToolbarMenu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
6777
+
6778
+ // src/components/EditorToolbar/util.ts
6779
+ import { useMemo as useMemo4 } from "react";
6780
+ import { live } from "@dxos/live-object";
6781
+ import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
6782
+ var useEditorToolbarState = (initialState = {}) => {
6783
+ return useMemo4(() => live(initialState), []);
6784
+ };
6785
+ var createEditorAction = (id, invoke, properties) => {
6786
+ const { label = [
6787
+ `${id} label`,
6788
+ {
6789
+ ns: translationKey
6790
+ }
6791
+ ], ...rest } = properties;
6792
+ return createMenuAction(id, invoke, {
6793
+ label,
6794
+ ...rest
6795
+ });
6796
+ };
6797
+ var createEditorActionGroup = (id, props, icon) => createMenuItemGroup(id, {
6798
+ icon,
6799
+ iconOnly: true,
6800
+ ...props
6801
+ });
6802
+
6803
+ // src/components/EditorToolbar/blocks.ts
6804
+ var createBlockGroupAction = (value) => createEditorActionGroup("block", {
6805
+ variant: "toggleGroup",
6806
+ selectCardinality: "single",
6807
+ value
6808
+ });
6809
+ var createBlockActions = (value, getView, blankLine) => Object.entries({
6810
+ blockquote: "ph--quotes--regular",
6811
+ codeblock: "ph--code-block--regular",
6812
+ table: "ph--table--regular"
6813
+ }).map(([type, icon]) => {
6814
+ const checked = type === value;
6815
+ return createEditorAction(type, () => {
6816
+ const view = getView();
6817
+ if (!view) {
6818
+ return;
6819
+ }
6820
+ switch (type) {
6821
+ case "blockquote":
6822
+ checked ? removeBlockquote(view) : addBlockquote(view);
6823
+ break;
6824
+ case "codeblock":
6825
+ checked ? removeCodeblock(view) : addCodeblock(view);
6826
+ break;
6827
+ case "table":
6828
+ insertTable(view);
6829
+ break;
6830
+ }
6831
+ }, {
6832
+ checked,
6833
+ ...type === "table" && {
6834
+ disabled: !!blankLine
6835
+ },
6836
+ icon
6837
+ });
6838
+ });
6839
+ var createBlocks = (state, getView) => {
6840
+ const value = state?.blockQuote ? "blockquote" : state.blockType ?? "";
6841
+ const blockGroupAction = createBlockGroupAction(value);
6842
+ const blockActions = createBlockActions(value, getView, state.blankLine);
6843
+ return {
6844
+ nodes: [
6845
+ blockGroupAction,
6846
+ ...blockActions
6847
+ ],
6848
+ edges: [
6849
+ {
6850
+ source: "root",
6851
+ target: "block"
6852
+ },
6853
+ ...blockActions.map(({ id }) => ({
6854
+ source: blockGroupAction.id,
6855
+ target: id
6856
+ }))
6857
+ ]
6858
+ };
6859
+ };
6860
+
6861
+ // src/components/EditorToolbar/formatting.ts
6862
+ var formats = {
6863
+ strong: "ph--text-b--regular",
6864
+ emphasis: "ph--text-italic--regular",
6865
+ strikethrough: "ph--text-strikethrough--regular",
6866
+ code: "ph--code--regular",
6867
+ link: "ph--link--regular"
6868
+ };
6869
+ var createFormattingGroup = (formatting) => createEditorActionGroup("formatting", {
6870
+ variant: "toggleGroup",
6871
+ selectCardinality: "multiple",
6683
6872
  value: Object.keys(formats).filter((key) => !!formatting[key])
6684
6873
  });
6685
6874
  var createFormattingActions = (formatting, getView) => Object.entries(formats).map(([type, icon]) => {
@@ -6721,7 +6910,7 @@ var createFormatting = (state, getView) => {
6721
6910
  };
6722
6911
  };
6723
6912
 
6724
- // packages/ui/react-ui-editor/src/components/EditorToolbar/headings.ts
6913
+ // src/components/EditorToolbar/headings.ts
6725
6914
  var createHeadingGroupAction = (value) => createEditorActionGroup("heading", {
6726
6915
  variant: "dropdownMenu",
6727
6916
  applyActive: true,
@@ -6776,7 +6965,7 @@ var createHeadings = (state, getView) => {
6776
6965
  };
6777
6966
  };
6778
6967
 
6779
- // packages/ui/react-ui-editor/src/components/EditorToolbar/image.ts
6968
+ // src/components/EditorToolbar/image.ts
6780
6969
  var createImageUploadAction = (onImageUpload) => createEditorAction("image", onImageUpload, {
6781
6970
  testId: "editor.toolbar.image",
6782
6971
  icon: "ph--image-square--regular"
@@ -6793,7 +6982,7 @@ var createImageUpload = (onImageUpload) => ({
6793
6982
  ]
6794
6983
  });
6795
6984
 
6796
- // packages/ui/react-ui-editor/src/components/EditorToolbar/lists.ts
6985
+ // src/components/EditorToolbar/lists.ts
6797
6986
  var listStyles = {
6798
6987
  bullet: "ph--list-bullets--regular",
6799
6988
  ordered: "ph--list-numbers--regular",
@@ -6844,7 +7033,7 @@ var createLists = (state, getView) => {
6844
7033
  };
6845
7034
  };
6846
7035
 
6847
- // packages/ui/react-ui-editor/src/components/EditorToolbar/search.ts
7036
+ // src/components/EditorToolbar/search.ts
6848
7037
  import { openSearchPanel } from "@codemirror/search";
6849
7038
  var createSearchAction = (getView) => createEditorAction("search", () => openSearchPanel(getView()), {
6850
7039
  testId: "editor.toolbar.search",
@@ -6862,7 +7051,7 @@ var createSearch = (getView) => ({
6862
7051
  ]
6863
7052
  });
6864
7053
 
6865
- // packages/ui/react-ui-editor/src/components/EditorToolbar/view-mode.ts
7054
+ // src/components/EditorToolbar/view-mode.ts
6866
7055
  var createViewModeGroupAction = (value) => createEditorActionGroup("viewMode", {
6867
7056
  variant: "dropdownMenu",
6868
7057
  applyActive: true,
@@ -6908,7 +7097,7 @@ var createViewMode = (state, onViewModeChange) => {
6908
7097
  };
6909
7098
  };
6910
7099
 
6911
- // packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
7100
+ // src/components/EditorToolbar/EditorToolbar.tsx
6912
7101
  var createToolbar = ({ getView, state, customActions, ...features }) => {
6913
7102
  return Rx.make((get2) => {
6914
7103
  const nodes = [];
@@ -6963,7 +7152,7 @@ var createToolbar = ({ getView, state, customActions, ...features }) => {
6963
7152
  });
6964
7153
  };
6965
7154
  var useEditorToolbarActionGraph = (props) => {
6966
- const menuCreator = useMemo4(() => createToolbar({
7155
+ const menuCreator = useMemo5(() => createToolbar({
6967
7156
  getView: props.getView,
6968
7157
  state: props.state,
6969
7158
  customActions: props.customActions,
@@ -6989,15 +7178,15 @@ var useEditorToolbarActionGraph = (props) => {
6989
7178
  return useMenuActions(menuCreator);
6990
7179
  };
6991
7180
  var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...props }) => {
6992
- var _effect = _useSignals();
7181
+ var _effect = _useSignals2();
6993
7182
  try {
6994
7183
  const menuProps = useEditorToolbarActionGraph(props);
6995
- return /* @__PURE__ */ React3.createElement(ElevationProvider, {
7184
+ return /* @__PURE__ */ React4.createElement(ElevationProvider, {
6996
7185
  elevation: role === "section" ? "positioned" : "base"
6997
- }, /* @__PURE__ */ React3.createElement(MenuProvider, {
7186
+ }, /* @__PURE__ */ React4.createElement(MenuProvider, {
6998
7187
  ...menuProps,
6999
7188
  attendableId
7000
- }, /* @__PURE__ */ React3.createElement(ToolbarMenu, {
7189
+ }, /* @__PURE__ */ React4.createElement(ToolbarMenu, {
7001
7190
  classNames,
7002
7191
  textBlockWidth: true
7003
7192
  })));
@@ -7006,16 +7195,16 @@ var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...p
7006
7195
  }
7007
7196
  });
7008
7197
 
7009
- // packages/ui/react-ui-editor/src/components/Popover/CommandMenu.tsx
7010
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
7011
- import React4, { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2 } from "react";
7012
- import { Icon as Icon2, Popover, toLocalizedString, useThemeContext, useTranslation } from "@dxos/react-ui";
7198
+ // src/components/Popover/CommandMenu.tsx
7199
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
7200
+ import React5, { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3 } from "react";
7201
+ import { Icon as Icon2, Popover, toLocalizedString, useThemeContext as useThemeContext2, useTranslation } from "@dxos/react-ui";
7013
7202
  var CommandMenu = ({ groups, currentItem, onSelect }) => {
7014
- var _effect = _useSignals2();
7203
+ var _effect = _useSignals3();
7015
7204
  try {
7016
- const { tx } = useThemeContext();
7205
+ const { tx } = useThemeContext2();
7017
7206
  const groupsWithItems = groups.filter((group) => group.items.length > 0);
7018
- return /* @__PURE__ */ React4.createElement(Popover.Portal, null, /* @__PURE__ */ React4.createElement(Popover.Content, {
7207
+ return /* @__PURE__ */ React5.createElement(Popover.Portal, null, /* @__PURE__ */ React5.createElement(Popover.Content, {
7019
7208
  align: "start",
7020
7209
  onOpenAutoFocus: (event) => event.preventDefault(),
7021
7210
  classNames: tx("menu.content", "menu--exotic-unfocusable", {
@@ -7023,15 +7212,15 @@ var CommandMenu = ({ groups, currentItem, onSelect }) => {
7023
7212
  }, [
7024
7213
  "max-h-[300px] overflow-y-auto"
7025
7214
  ])
7026
- }, /* @__PURE__ */ React4.createElement(Popover.Viewport, {
7215
+ }, /* @__PURE__ */ React5.createElement(Popover.Viewport, {
7027
7216
  classNames: tx("menu.viewport", "menu__viewport--exotic-unfocusable", {})
7028
- }, /* @__PURE__ */ React4.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React4.createElement(React4.Fragment, {
7217
+ }, /* @__PURE__ */ React5.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React5.createElement(React5.Fragment, {
7029
7218
  key: group.id
7030
- }, /* @__PURE__ */ React4.createElement(CommandGroup, {
7219
+ }, /* @__PURE__ */ React5.createElement(CommandGroup, {
7031
7220
  group,
7032
7221
  currentItem,
7033
7222
  onSelect
7034
- }), index < groupsWithItems.length - 1 && /* @__PURE__ */ React4.createElement("div", {
7223
+ }), index < groupsWithItems.length - 1 && /* @__PURE__ */ React5.createElement("div", {
7035
7224
  className: tx("menu.separator", "menu__item", {})
7036
7225
  })))))));
7037
7226
  } finally {
@@ -7039,13 +7228,13 @@ var CommandMenu = ({ groups, currentItem, onSelect }) => {
7039
7228
  }
7040
7229
  };
7041
7230
  var CommandGroup = ({ group, currentItem, onSelect }) => {
7042
- var _effect = _useSignals2();
7231
+ var _effect = _useSignals3();
7043
7232
  try {
7044
- const { tx } = useThemeContext();
7233
+ const { tx } = useThemeContext2();
7045
7234
  const { t } = useTranslation();
7046
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, group.label && /* @__PURE__ */ React4.createElement("div", {
7235
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, group.label && /* @__PURE__ */ React5.createElement("div", {
7047
7236
  className: tx("menu.groupLabel", "menu__group__label", {})
7048
- }, /* @__PURE__ */ React4.createElement("span", null, toLocalizedString(group.label, t))), group.items.map((item) => /* @__PURE__ */ React4.createElement(CommandItem, {
7237
+ }, /* @__PURE__ */ React5.createElement("span", null, toLocalizedString(group.label, t))), group.items.map((item) => /* @__PURE__ */ React5.createElement(CommandItem, {
7049
7238
  key: item.id,
7050
7239
  item,
7051
7240
  current: currentItem === item.id,
@@ -7056,16 +7245,16 @@ var CommandGroup = ({ group, currentItem, onSelect }) => {
7056
7245
  }
7057
7246
  };
7058
7247
  var CommandItem = ({ item, current, onSelect }) => {
7059
- var _effect = _useSignals2();
7248
+ var _effect = _useSignals3();
7060
7249
  try {
7061
- const ref = useRef2(null);
7062
- const { tx } = useThemeContext();
7250
+ const ref = useRef3(null);
7251
+ const { tx } = useThemeContext2();
7063
7252
  const { t } = useTranslation();
7064
- const handleSelect = useCallback2(() => onSelect(item), [
7253
+ const handleSelect = useCallback4(() => onSelect(item), [
7065
7254
  item,
7066
7255
  onSelect
7067
7256
  ]);
7068
- useEffect2(() => {
7257
+ useEffect3(() => {
7069
7258
  if (current && ref.current) {
7070
7259
  ref.current.scrollIntoView({
7071
7260
  behavior: "smooth",
@@ -7075,16 +7264,16 @@ var CommandItem = ({ item, current, onSelect }) => {
7075
7264
  }, [
7076
7265
  current
7077
7266
  ]);
7078
- return /* @__PURE__ */ React4.createElement("li", {
7267
+ return /* @__PURE__ */ React5.createElement("li", {
7079
7268
  ref,
7080
7269
  className: tx("menu.item", "menu__item--exotic-unfocusable", {}, [
7081
7270
  current && "bg-hoverSurface"
7082
7271
  ]),
7083
7272
  onClick: handleSelect
7084
- }, item.icon && /* @__PURE__ */ React4.createElement(Icon2, {
7273
+ }, item.icon && /* @__PURE__ */ React5.createElement(Icon2, {
7085
7274
  icon: item.icon,
7086
7275
  size: 5
7087
- }), /* @__PURE__ */ React4.createElement("span", {
7276
+ }), /* @__PURE__ */ React5.createElement("span", {
7088
7277
  className: "grow truncate"
7089
7278
  }, toLocalizedString(item.label, t)));
7090
7279
  } finally {
@@ -7271,21 +7460,21 @@ var linkSlashCommands = {
7271
7460
  ]
7272
7461
  };
7273
7462
 
7274
- // packages/ui/react-ui-editor/src/components/Popover/RefPopover.tsx
7275
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
7463
+ // src/components/Popover/RefPopover.tsx
7464
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
7276
7465
  import { createContext } from "@radix-ui/react-context";
7277
- import React5, { useRef as useRef3, useState as useState2, useEffect as useEffect3, useCallback as useCallback3, forwardRef } from "react";
7466
+ import React6, { useRef as useRef4, useState as useState3, useEffect as useEffect4, useCallback as useCallback5, forwardRef as forwardRef2 } from "react";
7278
7467
  import { addEventListener as addEventListener2 } from "@dxos/async";
7279
7468
  import { Popover as Popover2 } from "@dxos/react-ui";
7280
7469
  var customEventOptions = {
7281
7470
  capture: true,
7282
7471
  passive: false
7283
7472
  };
7284
- var RefPopover = /* @__PURE__ */ forwardRef(({ children, open, onOpenChange, modal, onActivate }, ref) => {
7285
- var _effect = _useSignals3();
7473
+ var RefPopover = /* @__PURE__ */ forwardRef2(({ children, open, onOpenChange, modal, onActivate }, ref) => {
7474
+ var _effect = _useSignals4();
7286
7475
  try {
7287
- const [rootRef, setRootRef] = useState2(null);
7288
- useEffect3(() => {
7476
+ const [rootRef, setRootRef] = useState3(null);
7477
+ useEffect4(() => {
7289
7478
  if (!rootRef || !onActivate) {
7290
7479
  return;
7291
7480
  }
@@ -7294,13 +7483,13 @@ var RefPopover = /* @__PURE__ */ forwardRef(({ children, open, onOpenChange, mod
7294
7483
  rootRef,
7295
7484
  onActivate
7296
7485
  ]);
7297
- return /* @__PURE__ */ React5.createElement(Popover2.Root, {
7486
+ return /* @__PURE__ */ React6.createElement(Popover2.Root, {
7298
7487
  open,
7299
7488
  onOpenChange,
7300
7489
  modal
7301
- }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
7490
+ }, /* @__PURE__ */ React6.createElement(Popover2.VirtualTrigger, {
7302
7491
  virtualRef: ref
7303
- }), /* @__PURE__ */ React5.createElement("div", {
7492
+ }), /* @__PURE__ */ React6.createElement("div", {
7304
7493
  role: "none",
7305
7494
  className: "contents",
7306
7495
  ref: setRootRef
@@ -7312,12 +7501,12 @@ var RefPopover = /* @__PURE__ */ forwardRef(({ children, open, onOpenChange, mod
7312
7501
  var REF_POPOVER = "RefPopover";
7313
7502
  var [RefPopoverContextProvider, useRefPopover] = createContext(REF_POPOVER, {});
7314
7503
  var PreviewProvider = ({ children, onLookup }) => {
7315
- var _effect = _useSignals3();
7504
+ var _effect = _useSignals4();
7316
7505
  try {
7317
- const trigger = useRef3(null);
7318
- const [value, setValue] = useState2({});
7319
- const [open, setOpen] = useState2(false);
7320
- const handleDxRefTagActivate = useCallback3((event) => {
7506
+ const trigger = useRef4(null);
7507
+ const [value, setValue] = useState3({});
7508
+ const [open, setOpen] = useState3(false);
7509
+ const handleDxRefTagActivate = useCallback5((event) => {
7321
7510
  const { refId, label, trigger: dxTrigger } = event;
7322
7511
  setValue((value2) => ({
7323
7512
  ...value2,
@@ -7340,11 +7529,11 @@ var PreviewProvider = ({ children, onLookup }) => {
7340
7529
  }, [
7341
7530
  onLookup
7342
7531
  ]);
7343
- return /* @__PURE__ */ React5.createElement(RefPopoverContextProvider, {
7532
+ return /* @__PURE__ */ React6.createElement(RefPopoverContextProvider, {
7344
7533
  pending: value.pending,
7345
7534
  link: value.link,
7346
7535
  target: value.target
7347
- }, /* @__PURE__ */ React5.createElement(RefPopover, {
7536
+ }, /* @__PURE__ */ React6.createElement(RefPopover, {
7348
7537
  ref: trigger,
7349
7538
  open,
7350
7539
  onOpenChange: setOpen,
@@ -7355,10 +7544,10 @@ var PreviewProvider = ({ children, onLookup }) => {
7355
7544
  }
7356
7545
  };
7357
7546
 
7358
- // packages/ui/react-ui-editor/src/components/Popover/RefDropdownMenu.tsx
7359
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
7547
+ // src/components/Popover/RefDropdownMenu.tsx
7548
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
7360
7549
  import { createContext as createContext2 } from "@radix-ui/react-context";
7361
- import React6, { useRef as useRef4, useState as useState3, useEffect as useEffect4, useCallback as useCallback4 } from "react";
7550
+ import React7, { useRef as useRef5, useState as useState4, useEffect as useEffect5, useCallback as useCallback6 } from "react";
7362
7551
  import { addEventListener as addEventListener3 } from "@dxos/async";
7363
7552
  import { DropdownMenu } from "@dxos/react-ui";
7364
7553
  var customEventOptions2 = {
@@ -7368,13 +7557,13 @@ var customEventOptions2 = {
7368
7557
  var REF_DROPDOWN_MENU = "RefDropdownMenu";
7369
7558
  var [RefDropdownMenuContextProvider, useRefDropdownMenu] = createContext2(REF_DROPDOWN_MENU, {});
7370
7559
  var RefDropdownMenuProvider = ({ children, onLookup }) => {
7371
- var _effect = _useSignals4();
7560
+ var _effect = _useSignals5();
7372
7561
  try {
7373
- const trigger = useRef4(null);
7374
- const [value, setValue] = useState3({});
7375
- const [rootRef, setRootRef] = useState3(null);
7376
- const [open, setOpen] = useState3(false);
7377
- const handleDxRefTagActivate = useCallback4((event) => {
7562
+ const trigger = useRef5(null);
7563
+ const [value, setValue] = useState4({});
7564
+ const [rootRef, setRootRef] = useState4(null);
7565
+ const [open, setOpen] = useState4(false);
7566
+ const handleDxRefTagActivate = useCallback6((event) => {
7378
7567
  const { refId, label, trigger: dxTrigger } = event;
7379
7568
  setValue((value2) => ({
7380
7569
  ...value2,
@@ -7397,7 +7586,7 @@ var RefDropdownMenuProvider = ({ children, onLookup }) => {
7397
7586
  }, [
7398
7587
  onLookup
7399
7588
  ]);
7400
- useEffect4(() => {
7589
+ useEffect5(() => {
7401
7590
  if (!rootRef) {
7402
7591
  return;
7403
7592
  }
@@ -7405,16 +7594,16 @@ var RefDropdownMenuProvider = ({ children, onLookup }) => {
7405
7594
  }, [
7406
7595
  rootRef
7407
7596
  ]);
7408
- return /* @__PURE__ */ React6.createElement(RefDropdownMenuContextProvider, {
7597
+ return /* @__PURE__ */ React7.createElement(RefDropdownMenuContextProvider, {
7409
7598
  pending: value.pending,
7410
7599
  link: value.link,
7411
7600
  target: value.target
7412
- }, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
7601
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
7413
7602
  open,
7414
7603
  onOpenChange: setOpen
7415
- }, /* @__PURE__ */ React6.createElement(DropdownMenu.VirtualTrigger, {
7604
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.VirtualTrigger, {
7416
7605
  virtualRef: trigger
7417
- }), /* @__PURE__ */ React6.createElement("div", {
7606
+ }), /* @__PURE__ */ React7.createElement("div", {
7418
7607
  role: "none",
7419
7608
  className: "contents",
7420
7609
  ref: setRootRef
@@ -7426,162 +7615,10 @@ var RefDropdownMenuProvider = ({ children, onLookup }) => {
7426
7615
  var RefDropdownMenu = {
7427
7616
  Provider: RefDropdownMenuProvider
7428
7617
  };
7429
-
7430
- // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
7431
- import { EditorState as EditorState3 } from "@codemirror/state";
7432
- import { EditorView as EditorView26 } from "@codemirror/view";
7433
- import { useFocusableGroup } from "@fluentui/react-tabster";
7434
- import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef5, useState as useState4 } from "react";
7435
- import { log as log8 } from "@dxos/log";
7436
- import { getProviderValue, isNotFalsy as isNotFalsy4 } from "@dxos/util";
7437
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
7438
- var instanceCount = 0;
7439
- var useTextEditor = (props = {}, deps = []) => {
7440
- const { id, doc, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = useMemo5(() => getProviderValue(props), deps ?? []);
7441
- const [instanceId] = useState4(() => `text-editor-${++instanceCount}`);
7442
- const [view, setView] = useState4();
7443
- const parentRef = useRef5(null);
7444
- useEffect5(() => {
7445
- let view2;
7446
- if (parentRef.current) {
7447
- log8("create", {
7448
- id,
7449
- instanceId,
7450
- doc: initialValue?.length ?? 0
7451
- }, {
7452
- F: __dxlog_file13,
7453
- L: 75,
7454
- S: void 0,
7455
- C: (f, a) => f(...a)
7456
- });
7457
- let initialSelection;
7458
- if (selection?.anchor && initialValue?.length) {
7459
- if (selection.anchor <= initialValue.length && (selection?.head ?? 0) <= initialValue.length) {
7460
- initialSelection = selection;
7461
- }
7462
- } else if (moveToEndOfLine && selection === void 0) {
7463
- const index = initialValue?.indexOf("\n");
7464
- const anchor = !index || index === -1 ? 0 : index;
7465
- initialSelection = {
7466
- anchor
7467
- };
7468
- }
7469
- const state = EditorState3.create({
7470
- doc: doc ?? initialValue,
7471
- // selection: initialSelection,
7472
- extensions: [
7473
- id && documentId.of(id),
7474
- extensions,
7475
- // NOTE: This doesn't catch errors in keymap functions.
7476
- EditorView26.exceptionSink.of((err) => {
7477
- log8.catch(err, void 0, {
7478
- F: __dxlog_file13,
7479
- L: 97,
7480
- S: void 0,
7481
- C: (f, a) => f(...a)
7482
- });
7483
- })
7484
- ].filter(isNotFalsy4)
7485
- });
7486
- view2 = new EditorView26({
7487
- parent: parentRef.current,
7488
- state,
7489
- scrollTo: scrollTo ? EditorView26.scrollIntoView(scrollTo, {
7490
- yMargin: 96
7491
- }) : void 0,
7492
- dispatchTransactions: debug ? debugDispatcher : void 0
7493
- });
7494
- if (moveToEndOfLine && !initialSelection) {
7495
- const { to } = view2.state.doc.lineAt(0);
7496
- if (to) {
7497
- view2.dispatch({
7498
- selection: {
7499
- anchor: to
7500
- }
7501
- });
7502
- }
7503
- }
7504
- setView(view2);
7505
- }
7506
- return () => {
7507
- log8("destroy", {
7508
- id
7509
- }, {
7510
- F: __dxlog_file13,
7511
- L: 134,
7512
- S: void 0,
7513
- C: (f, a) => f(...a)
7514
- });
7515
- view2?.destroy();
7516
- };
7517
- }, deps);
7518
- useEffect5(() => {
7519
- if (view) {
7520
- if (scrollTo || selection) {
7521
- if (selection && selection.anchor > view.state.doc.length) {
7522
- log8.warn("invalid selection", {
7523
- length: view.state.doc.length,
7524
- scrollTo,
7525
- selection
7526
- }, {
7527
- F: __dxlog_file13,
7528
- L: 143,
7529
- S: void 0,
7530
- C: (f, a) => f(...a)
7531
- });
7532
- return;
7533
- }
7534
- view.dispatch(createEditorStateTransaction({
7535
- scrollTo,
7536
- selection
7537
- }));
7538
- }
7539
- }
7540
- }, [
7541
- view,
7542
- scrollTo,
7543
- selection
7544
- ]);
7545
- useEffect5(() => {
7546
- if (view && autoFocus) {
7547
- view.focus();
7548
- }
7549
- }, [
7550
- autoFocus,
7551
- view
7552
- ]);
7553
- const focusableGroupAttrs = useFocusableGroup({
7554
- tabBehavior: "limited",
7555
- ignoreDefaultKeydown: {
7556
- Escape: view?.state.facet(editorInputMode).noTabster
7557
- }
7558
- });
7559
- const handleKeyUp = useCallback5((event) => {
7560
- const { key, target, currentTarget } = event;
7561
- if (target === currentTarget) {
7562
- switch (key) {
7563
- case "Enter": {
7564
- view?.focus();
7565
- break;
7566
- }
7567
- }
7568
- }
7569
- }, [
7570
- view
7571
- ]);
7572
- return {
7573
- parentRef,
7574
- view,
7575
- focusAttributes: {
7576
- tabIndex: 0,
7577
- ...focusableGroupAttrs,
7578
- onKeyUp: handleKeyUp
7579
- }
7580
- };
7581
- };
7582
7618
  export {
7583
7619
  CommandMenu,
7584
7620
  Cursor,
7621
+ Editor,
7585
7622
  EditorInputMode,
7586
7623
  EditorInputModes,
7587
7624
  EditorState4 as EditorState,
@@ -7642,6 +7679,7 @@ export {
7642
7679
  debugTree,
7643
7680
  decorateMarkdown,
7644
7681
  defaultOptions,
7682
+ defaultThemeSlots,
7645
7683
  deleteItem,
7646
7684
  documentId,
7647
7685
  dropFile,
@@ -7659,6 +7697,7 @@ export {
7659
7697
  folding,
7660
7698
  formattingEquals,
7661
7699
  formattingKeymap,
7700
+ fullWidth,
7662
7701
  getFormatting,
7663
7702
  getItem,
7664
7703
  getLinkRef,
@@ -7666,6 +7705,7 @@ export {
7666
7705
  getNextItem,
7667
7706
  getPreviousItem,
7668
7707
  getRange,
7708
+ grow,
7669
7709
  hashtag,
7670
7710
  image,
7671
7711
  indentItemLess,
@@ -7723,7 +7763,7 @@ export {
7723
7763
  toggleStrong,
7724
7764
  toggleStyle,
7725
7765
  toggleTask,
7726
- translations_default as translations,
7766
+ translations,
7727
7767
  traverse,
7728
7768
  treeFacet,
7729
7769
  typeahead,