@dxos/react-ui-editor 0.4.6-main.268e405 → 0.4.6-main.2c76dca

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 (33) hide show
  1. package/dist/lib/browser/index.mjs +99 -94
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/components/TextEditor/automerge.stories.d.ts +3 -5
  5. package/dist/types/src/components/TextEditor/automerge.stories.d.ts.map +1 -1
  6. package/dist/types/src/extensions/automerge/automerge.d.ts +2 -7
  7. package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
  8. package/dist/types/src/extensions/automerge/cursor.d.ts +2 -3
  9. package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
  10. package/dist/types/src/extensions/automerge/defs.d.ts +9 -2
  11. package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
  12. package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
  13. package/dist/types/src/hooks/defs.d.ts +1 -0
  14. package/dist/types/src/hooks/defs.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useEditorView.d.ts +1 -0
  16. package/dist/types/src/hooks/useEditorView.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useTextEditor.d.ts +2 -2
  18. package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
  19. package/dist/types/src/hooks/useTextModel.d.ts +12 -4
  20. package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
  21. package/dist/types/src/themes/default.d.ts.map +1 -1
  22. package/package.json +24 -24
  23. package/src/components/TextEditor/automerge.stories.tsx +15 -16
  24. package/src/extensions/automerge/automerge.ts +10 -15
  25. package/src/extensions/automerge/cursor.ts +2 -3
  26. package/src/extensions/automerge/defs.ts +15 -2
  27. package/src/extensions/markdown/decorate.ts +13 -49
  28. package/src/extensions/markdown/image.ts +11 -0
  29. package/src/hooks/defs.ts +2 -0
  30. package/src/hooks/useEditorView.ts +2 -0
  31. package/src/hooks/useTextEditor.ts +6 -10
  32. package/src/hooks/useTextModel.ts +34 -5
  33. package/src/themes/default.ts +7 -0
@@ -189,7 +189,7 @@ import get from "lodash.get";
189
189
  import { next as A } from "@dxos/automerge/automerge";
190
190
  import { log } from "@dxos/log";
191
191
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
192
- var cursorConverter = (handle, path) => ({
192
+ var cursorConverter = ({ handle, path }) => ({
193
193
  // TODO(burdon): Handle assoc to associate with a previous character.
194
194
  toCursor: (pos) => {
195
195
  const doc = handle.docSync();
@@ -205,7 +205,7 @@ var cursorConverter = (handle, path) => ({
205
205
  } catch (err) {
206
206
  log.catch(err, void 0, {
207
207
  F: __dxlog_file,
208
- L: 31,
208
+ L: 30,
209
209
  S: void 0,
210
210
  C: (f, a) => f(...a)
211
211
  });
@@ -233,7 +233,7 @@ var cursorConverter = (handle, path) => ({
233
233
  } catch (err) {
234
234
  log.catch(err, void 0, {
235
235
  F: __dxlog_file,
236
- L: 59,
236
+ L: 58,
237
237
  S: void 0,
238
238
  C: (f, a) => f(...a)
239
239
  });
@@ -244,6 +244,7 @@ var cursorConverter = (handle, path) => ({
244
244
 
245
245
  // packages/ui/react-ui-editor/src/extensions/automerge/defs.ts
246
246
  import { Annotation, StateEffect } from "@codemirror/state";
247
+ import get2 from "lodash.get";
247
248
  var getPath = (state, field) => state.field(field).path;
248
249
  var getLastHeads = (state, field) => state.field(field).lastHeads;
249
250
  var updateHeadsEffect = StateEffect.define({});
@@ -441,16 +442,16 @@ var Syncer = class {
441
442
  };
442
443
 
443
444
  // packages/ui/react-ui-editor/src/extensions/automerge/automerge.ts
444
- var automerge = ({ handle, path }) => {
445
+ var automerge = (accessor) => {
445
446
  const syncState = StateField2.define({
446
447
  create: () => ({
447
- path: path.slice(),
448
- lastHeads: A4.getHeads(handle.docSync()),
448
+ path: accessor.path.slice(),
449
+ lastHeads: A4.getHeads(accessor.handle.docSync()),
449
450
  unreconciledTransactions: []
450
451
  }),
451
452
  update: (value, tr) => {
452
453
  const result = {
453
- path: path.slice(),
454
+ path: accessor.path.slice(),
454
455
  lastHeads: value.lastHeads,
455
456
  unreconciledTransactions: value.unreconciledTransactions.slice()
456
457
  };
@@ -471,18 +472,18 @@ var automerge = ({ handle, path }) => {
471
472
  return result;
472
473
  }
473
474
  });
474
- const syncer = new Syncer(handle, syncState);
475
+ const syncer = new Syncer(accessor.handle, syncState);
475
476
  return [
476
- Cursor.converter.of(cursorConverter(handle, path)),
477
+ Cursor.converter.of(cursorConverter(accessor)),
477
478
  syncState,
478
479
  // Reconcile external updates.
479
480
  ViewPlugin.fromClass(class {
480
481
  constructor(_view) {
481
482
  this._view = _view;
482
- handle.addListener("change", this._handleChange.bind(this));
483
+ accessor.handle.addListener("change", this._handleChange.bind(this));
483
484
  }
484
485
  destroy() {
485
- handle.removeListener("change", this._handleChange.bind(this));
486
+ accessor.handle.removeListener("change", this._handleChange.bind(this));
486
487
  }
487
488
  _handleChange() {
488
489
  syncer.reconcile(this._view, false);
@@ -1133,10 +1134,10 @@ var inlineUrl = mx(code, "px-1");
1133
1134
  var blockquote = mx("pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30", light);
1134
1135
 
1135
1136
  // packages/ui/react-ui-editor/src/styles/tokens.ts
1136
- import get2 from "lodash.get";
1137
+ import get3 from "lodash.get";
1137
1138
  import { tailwindConfig } from "@dxos/react-ui-theme";
1138
1139
  var tokens = tailwindConfig({}).theme;
1139
- var getToken = (path, defaultValue = void 0) => get2(tokens, path, defaultValue);
1140
+ var getToken = (path, defaultValue = void 0) => get3(tokens, path, defaultValue);
1140
1141
 
1141
1142
  // packages/ui/react-ui-editor/src/styles/layout.ts
1142
1143
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
@@ -1899,18 +1900,6 @@ import { syntaxTree } from "@codemirror/language";
1899
1900
  import { RangeSetBuilder } from "@codemirror/state";
1900
1901
  import { EditorView as EditorView10, Decoration as Decoration4, WidgetType as WidgetType2, ViewPlugin as ViewPlugin3 } from "@codemirror/view";
1901
1902
  import { mx as mx2 } from "@dxos/react-ui-theme";
1902
- var FencedCodeBoundary = class extends WidgetType2 {
1903
- constructor(_className) {
1904
- super();
1905
- this._className = _className;
1906
- }
1907
- toDOM() {
1908
- const el = document.createElement("span");
1909
- el.innerHTML = " ";
1910
- el.className = mx2("cm-code cm-codeblock", this._className);
1911
- return el;
1912
- }
1913
- };
1914
1903
  var HorizontalRuleWidget = class extends WidgetType2 {
1915
1904
  toDOM() {
1916
1905
  const el = document.createElement("span");
@@ -1971,11 +1960,14 @@ var CheckboxWidget = class extends WidgetType2 {
1971
1960
  }
1972
1961
  };
1973
1962
  var hide = Decoration4.replace({});
1974
- var fencedCodeTop = Decoration4.replace({
1975
- widget: new FencedCodeBoundary("cm-codeblock-end cm-codeblock-first")
1963
+ var fencedCodeLine = Decoration4.line({
1964
+ class: mx2("cm-code cm-codeblock-line")
1965
+ });
1966
+ var fencedCodeLineFirst = Decoration4.line({
1967
+ class: mx2("cm-code cm-codeblock-line", "cm-codeblock-first")
1976
1968
  });
1977
- var fencedCodeBottom = Decoration4.replace({
1978
- widget: new FencedCodeBoundary("cm-codeblock-end cm-codeblock-last")
1969
+ var fencedCodeLineLast = Decoration4.line({
1970
+ class: mx2("cm-code cm-codeblock-line", "cm-codeblock-last")
1979
1971
  });
1980
1972
  var horizontalRule = Decoration4.replace({
1981
1973
  widget: new HorizontalRuleWidget()
@@ -2016,12 +2008,9 @@ var buildDecorations = (view, options) => {
2016
2008
  }
2017
2009
  const first = block.from <= node.from;
2018
2010
  const last = block.to >= node.to;
2011
+ builder.add(block.from, block.from, first ? fencedCodeLineFirst : last ? fencedCodeLineLast : fencedCodeLine);
2019
2012
  if (!editing && (first || last)) {
2020
- builder.add(block.from, block.to, first ? fencedCodeTop : fencedCodeBottom);
2021
- } else {
2022
- builder.add(block.from, block.from, Decoration4.line({
2023
- class: mx2("cm-code cm-codeblock-line", first && "cm-codeblock-first", last && "cm-codeblock-last")
2024
- }));
2013
+ builder.add(block.from, block.to, hide);
2025
2014
  }
2026
2015
  }
2027
2016
  return false;
@@ -2112,16 +2101,12 @@ var formattingStyles = EditorView10.baseTheme({
2112
2101
  }
2113
2102
  },
2114
2103
  "& .cm-codeblock-first": {
2115
- "&::after": {
2116
- borderTopLeftRadius: ".5rem",
2117
- borderTopRightRadius: ".5rem"
2118
- }
2104
+ borderTopLeftRadius: ".5rem",
2105
+ borderTopRightRadius: ".5rem"
2119
2106
  },
2120
2107
  "& .cm-codeblock-last": {
2121
- "&::after": {
2122
- borderBottomLeftRadius: ".5rem",
2123
- borderBottomRightRadius: ".5rem"
2124
- }
2108
+ borderBottomLeftRadius: ".5rem",
2109
+ borderBottomRightRadius: ".5rem"
2125
2110
  },
2126
2111
  "&light .cm-codeblock-line, &light .cm-activeLine.cm-codeblock-line": {
2127
2112
  background: getToken("extend.semanticColors.input.light"),
@@ -2131,18 +2116,6 @@ var formattingStyles = EditorView10.baseTheme({
2131
2116
  background: getToken("extend.semanticColors.input.dark"),
2132
2117
  mixBlendMode: "lighten"
2133
2118
  },
2134
- "&light .cm-codeblock-first, &light .cm-codeblock-last": {
2135
- mixBlendMode: "darken",
2136
- "&::after": {
2137
- background: getToken("extend.semanticColors.input.light")
2138
- }
2139
- },
2140
- "&dark .cm-codeblock-first, &dark .cm-codeblock-last": {
2141
- mixBlendMode: "lighten",
2142
- "&::after": {
2143
- background: getToken("extend.semanticColors.input.dark")
2144
- }
2145
- },
2146
2119
  "& .cm-hr": {
2147
2120
  display: "inline-block",
2148
2121
  width: "100%",
@@ -3280,6 +3253,14 @@ var image = (options = {}) => {
3280
3253
  provide: (field) => EditorView12.decorations.from(field)
3281
3254
  });
3282
3255
  };
3256
+ var preloaded = /* @__PURE__ */ new Set();
3257
+ var preloadImage = (url) => {
3258
+ if (!preloaded.has(url)) {
3259
+ const img = document.createElement("img");
3260
+ img.src = url;
3261
+ preloaded.add(url);
3262
+ }
3263
+ };
3283
3264
  var buildDecorations2 = (from, to, state) => {
3284
3265
  const decorations = [];
3285
3266
  const cursor = state.selection.main.head;
@@ -3290,6 +3271,7 @@ var buildDecorations2 = (from, to, state) => {
3290
3271
  if (urlNode) {
3291
3272
  const hide2 = state.readOnly || cursor < node.from || cursor > node.to;
3292
3273
  const url = state.sliceDoc(urlNode.from, urlNode.to);
3274
+ preloadImage(url);
3293
3275
  decorations.push(Decoration5.replace({
3294
3276
  block: true,
3295
3277
  widget: new ImageWidget(url)
@@ -3572,7 +3554,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
3572
3554
  };
3573
3555
 
3574
3556
  // packages/ui/react-ui-editor/src/themes/default.ts
3575
- import get3 from "lodash.get";
3557
+ import get4 from "lodash.get";
3576
3558
  var defaultTheme = {
3577
3559
  //
3578
3560
  // Main layout:
@@ -3606,7 +3588,7 @@ var defaultTheme = {
3606
3588
  // TODO(burdon): Reconcile with docs: https://codemirror.net/docs/guide
3607
3589
  // Inside of that is the scroller element. If the editor has its own scrollbar, this one should be styled with overflow: auto. But it doesn't have to—the editor also supports growing to accomodate its content, or growing up to a certain max-height and then scrolling.
3608
3590
  overflowY: "auto",
3609
- fontFamily: get3(tokens, "fontFamily.mono", []).join(","),
3591
+ fontFamily: get4(tokens, "fontFamily.mono", []).join(","),
3610
3592
  lineHeight: 1.5
3611
3593
  },
3612
3594
  ".cm-content": {
@@ -3616,11 +3598,11 @@ var defaultTheme = {
3616
3598
  fontSize: "16px"
3617
3599
  },
3618
3600
  "&light .cm-content": {
3619
- color: get3(tokens, "extend.semanticColors.base.fg.light", "black"),
3601
+ color: get4(tokens, "extend.semanticColors.base.fg.light", "black"),
3620
3602
  caretColor: "black"
3621
3603
  },
3622
3604
  "&dark .cm-content": {
3623
- color: get3(tokens, "extend.semanticColors.base.fg.dark", "white"),
3605
+ color: get4(tokens, "extend.semanticColors.base.fg.dark", "white"),
3624
3606
  caretColor: "white"
3625
3607
  },
3626
3608
  //
@@ -3633,10 +3615,10 @@ var defaultTheme = {
3633
3615
  borderLeft: "2px solid white"
3634
3616
  },
3635
3617
  "&light .cm-placeholder": {
3636
- color: get3(tokens, "extend.semanticColors.description.light", "rgba(0,0,0,.2)")
3618
+ color: get4(tokens, "extend.semanticColors.description.light", "rgba(0,0,0,.2)")
3637
3619
  },
3638
3620
  "&dark .cm-placeholder": {
3639
- color: get3(tokens, "extend.semanticColors.description.dark", "rgba(255,255,255,.2)")
3621
+ color: get4(tokens, "extend.semanticColors.description.dark", "rgba(255,255,255,.2)")
3640
3622
  },
3641
3623
  //
3642
3624
  // line
@@ -3648,39 +3630,45 @@ var defaultTheme = {
3648
3630
  background: "transparent"
3649
3631
  },
3650
3632
  //
3633
+ // gutter
3634
+ //
3635
+ ".cm-gutterElement": {
3636
+ width: "48px"
3637
+ },
3638
+ //
3651
3639
  // Selection
3652
3640
  //
3653
3641
  "&light .cm-selectionBackground": {
3654
- background: get3(tokens, "extend.colors.primary.100")
3642
+ background: get4(tokens, "extend.colors.primary.100")
3655
3643
  },
3656
3644
  "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
3657
- background: get3(tokens, "extend.colors.primary.200")
3645
+ background: get4(tokens, "extend.colors.primary.200")
3658
3646
  },
3659
3647
  "&dark .cm-selectionBackground": {
3660
- background: get3(tokens, "extend.colors.primary.700")
3648
+ background: get4(tokens, "extend.colors.primary.700")
3661
3649
  },
3662
3650
  "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
3663
- background: get3(tokens, "extend.colors.primary.600")
3651
+ background: get4(tokens, "extend.colors.primary.600")
3664
3652
  },
3665
3653
  //
3666
3654
  // Search
3667
3655
  //
3668
3656
  "&light .cm-searchMatch": {
3669
- backgroundColor: get3(tokens, "extend.colors.yellow.100")
3657
+ backgroundColor: get4(tokens, "extend.colors.yellow.100")
3670
3658
  },
3671
3659
  "&dark .cm-searchMatch": {
3672
- backgroundColor: get3(tokens, "extend.colors.yellow.700")
3660
+ backgroundColor: get4(tokens, "extend.colors.yellow.700")
3673
3661
  },
3674
3662
  //
3675
3663
  // link
3676
3664
  //
3677
3665
  ".cm-link": {
3678
- color: get3(tokens, "extend.colors.primary.500"),
3666
+ color: get4(tokens, "extend.colors.primary.500"),
3679
3667
  textDecorationLine: "underline",
3680
3668
  textDecorationThickness: "1px",
3681
3669
  textUnderlineOffset: "2px",
3682
3670
  borderRadius: ".125rem",
3683
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3671
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3684
3672
  },
3685
3673
  //
3686
3674
  // tooltip
@@ -3702,7 +3690,7 @@ var defaultTheme = {
3702
3690
  display: "none"
3703
3691
  },
3704
3692
  ".cm-completionLabel": {
3705
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3693
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3706
3694
  },
3707
3695
  ".cm-completionMatchedText": {
3708
3696
  textDecoration: "none"
@@ -3711,15 +3699,15 @@ var defaultTheme = {
3711
3699
  // table
3712
3700
  //
3713
3701
  ".cm-table *": {
3714
- fontFamily: `${get3(tokens, "fontFamily.mono", []).join(",")} !important`,
3702
+ fontFamily: `${get4(tokens, "fontFamily.mono", []).join(",")} !important`,
3715
3703
  textDecoration: "none !important"
3716
3704
  },
3717
3705
  ".cm-table-head": {
3718
3706
  padding: "2px 16px 2px 0px",
3719
- borderBottom: `1px solid ${get3(tokens, "extend.colors.neutral.500")}`,
3707
+ borderBottom: `1px solid ${get4(tokens, "extend.colors.neutral.500")}`,
3720
3708
  fontWeight: 100,
3721
3709
  textAlign: "left",
3722
- color: get3(tokens, "extend.colors.neutral.500")
3710
+ color: get4(tokens, "extend.colors.neutral.500")
3723
3711
  },
3724
3712
  ".cm-table-cell": {
3725
3713
  padding: "2px 16px 2px 0px"
@@ -3766,23 +3754,23 @@ var defaultTheme = {
3766
3754
  * </div
3767
3755
  */
3768
3756
  ".cm-panels": {
3769
- border: `1px solid ${get3(tokens, "extend.colors.neutral.200")}`
3757
+ border: `1px solid ${get4(tokens, "extend.colors.neutral.200")}`
3770
3758
  },
3771
3759
  ".cm-panel": {
3772
- background: get3(tokens, "extend.colors.neutral.50"),
3773
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3760
+ background: get4(tokens, "extend.colors.neutral.50"),
3761
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3774
3762
  },
3775
3763
  ".cm-button": {
3776
3764
  margin: "4px",
3777
- fontFamily: get3(tokens, "fontFamily.body", []).join(","),
3778
- background: get3(tokens, "extend.colors.neutral.100"),
3765
+ fontFamily: get4(tokens, "fontFamily.body", []).join(","),
3766
+ background: get4(tokens, "extend.colors.neutral.100"),
3779
3767
  backgroundImage: "none",
3780
3768
  border: "none",
3781
3769
  "&:hover": {
3782
- background: get3(tokens, "extend.colors.neutral.200")
3770
+ background: get4(tokens, "extend.colors.neutral.200")
3783
3771
  },
3784
3772
  "&:active": {
3785
- background: get3(tokens, "extend.colors.neutral.300"),
3773
+ background: get4(tokens, "extend.colors.neutral.300"),
3786
3774
  backgroundImage: "none"
3787
3775
  }
3788
3776
  },
@@ -3792,26 +3780,26 @@ var defaultTheme = {
3792
3780
  };
3793
3781
  var textTheme = {
3794
3782
  ".cm-scroller": {
3795
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3783
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3796
3784
  },
3797
3785
  ".cm-placeholder": {
3798
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3786
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3799
3787
  }
3800
3788
  };
3801
3789
  var markdownTheme = {
3802
3790
  ".cm-scroller": {
3803
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3791
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3804
3792
  },
3805
3793
  ".cm-placeholder": {
3806
- fontFamily: get3(tokens, "fontFamily.body", []).join(",")
3794
+ fontFamily: get4(tokens, "fontFamily.body", []).join(",")
3807
3795
  }
3808
3796
  };
3809
3797
  var codeTheme = {
3810
3798
  ".cm-scroller": {
3811
- fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
3799
+ fontFamily: get4(tokens, "fontFamily.mono", []).join(",")
3812
3800
  },
3813
3801
  ".cm-placeholder": {
3814
- fontFamily: get3(tokens, "fontFamily.mono", []).join(",")
3802
+ fontFamily: get4(tokens, "fontFamily.mono", []).join(",")
3815
3803
  }
3816
3804
  };
3817
3805
 
@@ -4456,7 +4444,7 @@ import { useEffect as useEffect3, useRef as useRef4, useState as useState5 } fro
4456
4444
  import { log as log5 } from "@dxos/log";
4457
4445
  import { isNotFalsy as isNotFalsy5 } from "@dxos/util";
4458
4446
  var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
4459
- var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions } = {}) => {
4447
+ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions } = {}, deps) => {
4460
4448
  const onUpdate = useRef4();
4461
4449
  const [view, setView] = useState5();
4462
4450
  const parentRef = useRef4(null);
@@ -4471,7 +4459,7 @@ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions }
4471
4459
  EditorView15.exceptionSink.of((err) => {
4472
4460
  log5.catch(err, void 0, {
4473
4461
  F: __dxlog_file6,
4474
- L: 61,
4462
+ L: 57,
4475
4463
  S: void 0,
4476
4464
  C: (f, a) => f(...a)
4477
4465
  });
@@ -4500,10 +4488,7 @@ var useTextEditor = ({ autoFocus, scrollTo, debug, doc, selection, extensions }
4500
4488
  return () => {
4501
4489
  view2?.destroy();
4502
4490
  };
4503
- }, [
4504
- doc,
4505
- extensions
4506
- ]);
4491
+ }, deps);
4507
4492
  useEffect3(() => {
4508
4493
  if (view) {
4509
4494
  if (!selection && !view.state.selection.main.anchor) {
@@ -4559,13 +4544,32 @@ var createThemeExtensions = ({ theme, themeMode, slots } = {}) => {
4559
4544
  };
4560
4545
 
4561
4546
  // packages/ui/react-ui-editor/src/hooks/useTextModel.ts
4562
- import get4 from "lodash.get";
4547
+ import get5 from "lodash.get";
4563
4548
  import { useState as useState6, useMemo as useMemo3 } from "react";
4564
4549
  import { generateName } from "@dxos/display-name";
4565
4550
  import { getRawDoc } from "@dxos/echo-schema";
4566
4551
  import { invariant as invariant3 } from "@dxos/invariant";
4567
4552
  import { isAutomergeObject } from "@dxos/react-client/echo";
4568
4553
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextModel.ts";
4554
+ var useTextExtensions = ({ id, text, space, identity }) => {
4555
+ const extensions = [
4556
+ automerge(text)
4557
+ ];
4558
+ if (space && identity) {
4559
+ const awarenessProvider2 = new SpaceAwarenessProvider({
4560
+ space,
4561
+ channel: `awareness.${id}`,
4562
+ peerId: identity.identityKey.toHex(),
4563
+ info: {
4564
+ displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
4565
+ color: cursorColor.color,
4566
+ lightColor: cursorColor.light
4567
+ }
4568
+ });
4569
+ extensions.push(awareness(awarenessProvider2));
4570
+ }
4571
+ return extensions;
4572
+ };
4569
4573
  var useTextModel = (props) => useMemo3(() => createModel(props), Object.values(props));
4570
4574
  var useInMemoryTextModel = ({ id, defaultContent }) => {
4571
4575
  const [content, setContent] = useState6(defaultContent ?? "");
@@ -4582,7 +4586,7 @@ var createModel = ({ space, identity, text }) => {
4582
4586
  }
4583
4587
  invariant3(isAutomergeObject(text), void 0, {
4584
4588
  F: __dxlog_file7,
4585
- L: 54,
4589
+ L: 83,
4586
4590
  S: void 0,
4587
4591
  A: [
4588
4592
  "isAutomergeObject(text)",
@@ -4616,7 +4620,7 @@ var createModel = ({ space, identity, text }) => {
4616
4620
  const model = {
4617
4621
  id: obj.id,
4618
4622
  content: doc,
4619
- text: () => get4(doc.handle.docSync(), doc.path),
4623
+ text: () => get5(doc.handle.docSync(), doc.path),
4620
4624
  extension: extensions,
4621
4625
  peer: identity ? {
4622
4626
  id: identity.identityKey.toHex(),
@@ -4718,6 +4722,7 @@ export {
4718
4722
  useFormattingState,
4719
4723
  useInMemoryTextModel,
4720
4724
  useTextEditor,
4725
+ useTextExtensions,
4721
4726
  useTextModel,
4722
4727
  useToolbarContext
4723
4728
  };