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