@dxos/react-ui-editor 0.6.11-staging.e6894a4 → 0.6.12-main.15a606f

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 (43) hide show
  1. package/dist/lib/browser/index.mjs +127 -74
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/InputMode.stories.d.ts.map +1 -1
  5. package/dist/types/src/TextEditor.stories.d.ts +10 -2
  6. package/dist/types/src/TextEditor.stories.d.ts.map +1 -1
  7. package/dist/types/src/defaults.d.ts.map +1 -1
  8. package/dist/types/src/extensions/automerge/automerge.stories.d.ts +0 -1
  9. package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
  10. package/dist/types/src/extensions/automerge/automerge.test.d.ts.map +1 -1
  11. package/dist/types/src/extensions/factories.d.ts +5 -1
  12. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  13. package/dist/types/src/extensions/folding.d.ts.map +1 -1
  14. package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
  15. package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
  16. package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
  17. package/dist/types/src/extensions/util/react.d.ts +4 -0
  18. package/dist/types/src/extensions/util/react.d.ts.map +1 -1
  19. package/dist/types/src/hooks/useTextEditor.d.ts +2 -2
  20. package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
  21. package/dist/types/src/styles/markdown.d.ts.map +1 -1
  22. package/dist/types/src/styles/theme.d.ts.map +1 -1
  23. package/package.json +32 -27
  24. package/src/InputMode.stories.tsx +8 -10
  25. package/src/TextEditor.stories.tsx +61 -34
  26. package/src/defaults.ts +3 -3
  27. package/src/extensions/automerge/automerge.stories.tsx +5 -6
  28. package/src/extensions/automerge/{automerge.spec.tsx → automerge.test.tsx} +1 -0
  29. package/src/extensions/automerge/automerge.ts +1 -1
  30. package/src/extensions/factories.ts +15 -4
  31. package/src/extensions/folding.tsx +17 -4
  32. package/src/extensions/markdown/bundle.ts +1 -5
  33. package/src/extensions/markdown/changes.test.ts +1 -3
  34. package/src/extensions/markdown/decorate.ts +40 -23
  35. package/src/extensions/markdown/formatting.test.ts +1 -3
  36. package/src/extensions/markdown/parser.test.ts +1 -2
  37. package/src/extensions/util/react.tsx +15 -0
  38. package/src/hooks/useTextEditor.ts +3 -5
  39. package/src/styles/markdown.ts +0 -2
  40. package/src/styles/theme.ts +13 -9
  41. package/dist/types/src/extensions/automerge/automerge.spec.d.ts +0 -2
  42. package/dist/types/src/extensions/automerge/automerge.spec.d.ts.map +0 -1
  43. package/src/extensions/automerge/automerge.test.ts +0 -13
@@ -1389,6 +1389,18 @@ import React from "react";
1389
1389
  import { createRoot } from "react-dom/client";
1390
1390
  import { ThemeProvider } from "@dxos/react-ui";
1391
1391
  import { defaultTx } from "@dxos/react-ui-theme";
1392
+ var createElement = (tag, options, children) => {
1393
+ const el = document.createElement(tag);
1394
+ if (options?.className) {
1395
+ el.className = options.className;
1396
+ }
1397
+ if (children) {
1398
+ el.append(...Array.isArray(children) ? children : [
1399
+ children
1400
+ ]);
1401
+ }
1402
+ return el;
1403
+ };
1392
1404
  var renderRoot = (root, node) => {
1393
1405
  createRoot(root).render(/* @__PURE__ */ React.createElement(ThemeProvider, {
1394
1406
  tx: defaultTx
@@ -1981,9 +1993,10 @@ var dropFile = (options = {}) => {
1981
1993
  // packages/ui/react-ui-editor/src/extensions/factories.ts
1982
1994
  import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
1983
1995
  import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap } from "@codemirror/commands";
1984
- import { bracketMatching } from "@codemirror/language";
1996
+ import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
1985
1997
  import { searchKeymap } from "@codemirror/search";
1986
1998
  import { EditorState } from "@codemirror/state";
1999
+ import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
1987
2000
  import { EditorView as EditorView9, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap5, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
1988
2001
  import defaultsDeep2 from "lodash.defaultsdeep";
1989
2002
  import merge from "lodash.merge";
@@ -2052,15 +2065,19 @@ var defaultTheme = {
2052
2065
  * NOTE: Gutters should have the same top margin as the content.
2053
2066
  */
2054
2067
  ".cm-gutters": {
2055
- background: "unset"
2068
+ background: "var(--surface-bg)"
2056
2069
  },
2057
2070
  ".cm-gutter": {},
2058
- ".cm-gutterElement": {
2059
- fontSize: "16px",
2060
- lineHeight: 1.5
2071
+ ".cm-gutter.cm-lineNumbers .cm-gutterElement": {
2072
+ minWidth: "40px",
2073
+ alignContent: "center"
2061
2074
  },
2062
- ".cm-lineNumbers": {
2063
- minWidth: "36px"
2075
+ /**
2076
+ * Height is set to match the corresponding line.
2077
+ */
2078
+ ".cm-gutterElement": {
2079
+ alignItems: "center",
2080
+ fontSize: "16px"
2064
2081
  },
2065
2082
  /**
2066
2083
  * Line.
@@ -2069,7 +2086,7 @@ var defaultTheme = {
2069
2086
  paddingInline: 0
2070
2087
  },
2071
2088
  ".cm-activeLine": {
2072
- background: "var(--dx-hoverSurface)"
2089
+ background: "var(--dx-cmActiveLine)"
2073
2090
  },
2074
2091
  /**
2075
2092
  * Cursor (layer).
@@ -2168,13 +2185,14 @@ var defaultTheme = {
2168
2185
  * </div>
2169
2186
  * </div
2170
2187
  */
2171
- // TODO(burdon): Apply react-ui-theme or replace panel.
2188
+ // TODO(burdon): Implement custom panel (with icon buttons).
2172
2189
  ".cm-panels": {},
2173
2190
  ".cm-panel": {
2174
2191
  fontFamily: fontBody,
2175
- backgroundColor: "var(--dx-base)"
2192
+ backgroundColor: "var(--surface-bg)"
2176
2193
  },
2177
2194
  ".cm-panel input, .cm-panel button, .cm-panel label": {
2195
+ color: "var(--dx-subdued)",
2178
2196
  fontFamily: fontBody,
2179
2197
  fontSize: "14px",
2180
2198
  all: "unset",
@@ -2242,7 +2260,7 @@ var createBasicExtensions = (_props) => {
2242
2260
  EditorView9.exceptionSink.of((err) => {
2243
2261
  log6.catch(err, void 0, {
2244
2262
  F: __dxlog_file9,
2245
- L: 92,
2263
+ L: 93,
2246
2264
  S: void 0,
2247
2265
  C: (f, a) => f(...a)
2248
2266
  });
@@ -2287,11 +2305,13 @@ var defaultThemeSlots = {
2287
2305
  className: "w-full bs-full"
2288
2306
  }
2289
2307
  };
2290
- var createThemeExtensions = ({ themeMode, styles: styles5, slots: _slots } = {}) => {
2308
+ var createThemeExtensions = ({ themeMode, styles: styles5, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
2291
2309
  const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
2292
2310
  return [
2293
2311
  EditorView9.darkTheme.of(themeMode === "dark"),
2294
2312
  EditorView9.baseTheme(styles5 ? merge({}, defaultTheme, styles5) : defaultTheme),
2313
+ // https://github.com/codemirror/theme-one-dark
2314
+ _syntaxHighlighting && (themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle)),
2295
2315
  slots.editor?.className && EditorView9.editorAttributes.of({
2296
2316
  class: slots.editor.className
2297
2317
  }),
@@ -2324,36 +2344,50 @@ var createDataExtensions = ({ id, text, space, identity }) => {
2324
2344
 
2325
2345
  // packages/ui/react-ui-editor/src/extensions/folding.tsx
2326
2346
  import { codeFolding, foldGutter } from "@codemirror/language";
2347
+ import { EditorView as EditorView10 } from "@codemirror/view";
2327
2348
  import React2 from "react";
2328
2349
  import { Icon } from "@dxos/react-ui";
2329
2350
  import { getSize } from "@dxos/react-ui-theme";
2330
2351
  var folding = (_props = {}) => [
2331
2352
  codeFolding({
2332
- placeholderDOM: () => document.createElement("div")
2353
+ placeholderDOM: () => {
2354
+ return document.createElement("span");
2355
+ }
2333
2356
  }),
2334
2357
  foldGutter({
2335
2358
  markerDOM: (open) => {
2336
- return renderRoot(document.createElement("div"), /* @__PURE__ */ React2.createElement(Icon, {
2359
+ return renderRoot(createElement("div", {
2360
+ className: "flex h-full items-center"
2361
+ }), /* @__PURE__ */ React2.createElement(Icon, {
2337
2362
  icon: "ph--caret-right--regular",
2338
2363
  classNames: [
2339
2364
  getSize(3),
2340
- "m-2 cursor-pointer",
2365
+ "mx-3 cursor-pointer",
2341
2366
  open && "rotate-90"
2342
2367
  ]
2343
2368
  }));
2344
2369
  }
2370
+ }),
2371
+ EditorView10.theme({
2372
+ ".cm-foldGutter": {
2373
+ opacity: 0.3,
2374
+ transition: "opacity 0.3s"
2375
+ },
2376
+ ".cm-foldGutter:hover": {
2377
+ opacity: 1
2378
+ }
2345
2379
  })
2346
2380
  ];
2347
2381
 
2348
2382
  // packages/ui/react-ui-editor/src/extensions/listener.ts
2349
- import { EditorView as EditorView10 } from "@codemirror/view";
2383
+ import { EditorView as EditorView11 } from "@codemirror/view";
2350
2384
  var listener = ({ onFocus, onChange }) => {
2351
2385
  const extensions = [];
2352
- onFocus && extensions.push(EditorView10.focusChangeEffect.of((_, focusing) => {
2386
+ onFocus && extensions.push(EditorView11.focusChangeEffect.of((_, focusing) => {
2353
2387
  onFocus(focusing);
2354
2388
  return null;
2355
2389
  }));
2356
- onChange && extensions.push(EditorView10.updateListener.of((update2) => {
2390
+ onChange && extensions.push(EditorView11.updateListener.of((update2) => {
2357
2391
  onChange(update2.state.doc.toString());
2358
2392
  }));
2359
2393
  return extensions;
@@ -2363,7 +2397,7 @@ var listener = ({ onFocus, onChange }) => {
2363
2397
  import { snippet } from "@codemirror/autocomplete";
2364
2398
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
2365
2399
  import { EditorSelection } from "@codemirror/state";
2366
- import { EditorView as EditorView11, keymap as keymap6 } from "@codemirror/view";
2400
+ import { EditorView as EditorView12, keymap as keymap6 } from "@codemirror/view";
2367
2401
  import { useMemo as useMemo2, useState as useState2 } from "react";
2368
2402
  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;
2369
2403
  var Inline;
@@ -3453,7 +3487,7 @@ var getFormatting = (state2) => {
3453
3487
  };
3454
3488
  var useFormattingState = () => {
3455
3489
  const [state2, setState] = useState2();
3456
- const observer = useMemo2(() => EditorView11.updateListener.of((update2) => {
3490
+ const observer = useMemo2(() => EditorView12.updateListener.of((update2) => {
3457
3491
  if (update2.docChanged || update2.selectionSet) {
3458
3492
  setState((prevState) => {
3459
3493
  const newState = getFormatting(update2.state);
@@ -3523,10 +3557,9 @@ var processAction = (view, action) => {
3523
3557
  import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
3524
3558
  import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
3525
3559
  import { markdownLanguage as markdownLanguage3, markdown } from "@codemirror/lang-markdown";
3526
- import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
3560
+ import { syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
3527
3561
  import { languages } from "@codemirror/language-data";
3528
3562
  import { lintKeymap } from "@codemirror/lint";
3529
- import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
3530
3563
  import { keymap as keymap7 } from "@codemirror/view";
3531
3564
 
3532
3565
  // packages/ui/react-ui-editor/src/extensions/markdown/highlight.ts
@@ -3737,10 +3770,8 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
3737
3770
  markdownTagsExtensions
3738
3771
  ]
3739
3772
  }),
3740
- // https://github.com/codemirror/theme-one-dark
3741
- themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),
3742
3773
  // Custom styles.
3743
- syntaxHighlighting(markdownHighlightStyle()),
3774
+ syntaxHighlighting2(markdownHighlightStyle()),
3744
3775
  keymap7.of([
3745
3776
  // https://codemirror.net/docs/ref/#commands.indentWithTab
3746
3777
  indentWithTab2,
@@ -3782,7 +3813,7 @@ var convertTreeToJson = (state2) => {
3782
3813
  // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
3783
3814
  import { syntaxTree as syntaxTree7 } from "@codemirror/language";
3784
3815
  import { RangeSetBuilder as RangeSetBuilder3, StateEffect as StateEffect4 } from "@codemirror/state";
3785
- import { EditorView as EditorView15, Decoration as Decoration7, WidgetType as WidgetType5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
3816
+ import { EditorView as EditorView16, Decoration as Decoration7, WidgetType as WidgetType5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
3786
3817
  import { invariant as invariant4 } from "@dxos/invariant";
3787
3818
  import { mx as mx2 } from "@dxos/react-ui-theme";
3788
3819
 
@@ -3798,6 +3829,9 @@ var adjustChanges = () => {
3798
3829
  for (const tr of update2.transactions) {
3799
3830
  const event = tr.annotation(Transaction.userEvent);
3800
3831
  switch (event) {
3832
+ //
3833
+ // Enter
3834
+ //
3801
3835
  case "input": {
3802
3836
  const changes = tr.changes;
3803
3837
  if (changes.empty) {
@@ -3818,6 +3852,9 @@ var adjustChanges = () => {
3818
3852
  });
3819
3853
  break;
3820
3854
  }
3855
+ //
3856
+ // Paste
3857
+ //
3821
3858
  case "input.paste": {
3822
3859
  const changes = tr.changes;
3823
3860
  if (changes.empty) {
@@ -3927,7 +3964,7 @@ var getValidUrl = (str) => {
3927
3964
  // packages/ui/react-ui-editor/src/extensions/markdown/image.ts
3928
3965
  import { syntaxTree as syntaxTree5 } from "@codemirror/language";
3929
3966
  import { StateField as StateField7 } from "@codemirror/state";
3930
- import { Decoration as Decoration5, EditorView as EditorView12, WidgetType as WidgetType3 } from "@codemirror/view";
3967
+ import { Decoration as Decoration5, EditorView as EditorView13, WidgetType as WidgetType3 } from "@codemirror/view";
3931
3968
  var image = (_options = {}) => {
3932
3969
  return StateField7.define({
3933
3970
  create: (state2) => {
@@ -3954,7 +3991,7 @@ var image = (_options = {}) => {
3954
3991
  add: buildDecorations(from, to, tr.state)
3955
3992
  });
3956
3993
  },
3957
- provide: (field) => EditorView12.decorations.from(field)
3994
+ provide: (field) => EditorView13.decorations.from(field)
3958
3995
  });
3959
3996
  };
3960
3997
  var preloaded = /* @__PURE__ */ new Set();
@@ -4008,10 +4045,10 @@ var imageUpload = (options = {}) => {
4008
4045
  };
4009
4046
 
4010
4047
  // packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
4011
- import { EditorView as EditorView13 } from "@codemirror/view";
4048
+ import { EditorView as EditorView14 } from "@codemirror/view";
4012
4049
  var bulletListIndentationWidth = 24;
4013
4050
  var orderedListIndentationWidth = 36;
4014
- var formattingStyles = EditorView13.theme({
4051
+ var formattingStyles = EditorView14.theme({
4015
4052
  /**
4016
4053
  * Horizontal rule.
4017
4054
  */
@@ -4102,12 +4139,12 @@ var formattingStyles = EditorView13.theme({
4102
4139
  // packages/ui/react-ui-editor/src/extensions/markdown/table.ts
4103
4140
  import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4104
4141
  import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField8 } from "@codemirror/state";
4105
- import { Decoration as Decoration6, EditorView as EditorView14, WidgetType as WidgetType4 } from "@codemirror/view";
4142
+ import { Decoration as Decoration6, EditorView as EditorView15, WidgetType as WidgetType4 } from "@codemirror/view";
4106
4143
  var table = (options = {}) => {
4107
4144
  return StateField8.define({
4108
4145
  create: (state2) => update(state2, options),
4109
4146
  update: (_, tr) => update(tr.state, options),
4110
- provide: (field) => EditorView14.decorations.from(field)
4147
+ provide: (field) => EditorView15.decorations.from(field)
4111
4148
  });
4112
4149
  };
4113
4150
  var update = (state2, _options) => {
@@ -4200,6 +4237,12 @@ var TableWidget = class extends WidgetType4 {
4200
4237
 
4201
4238
  // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
4202
4239
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts";
4240
+ var Unicode = {
4241
+ emDash: "\u2014",
4242
+ bullet: "\u2022",
4243
+ bulletSmall: "\u2219",
4244
+ bulletSquare: "\u2B1D"
4245
+ };
4203
4246
  var HorizontalRuleWidget = class extends WidgetType5 {
4204
4247
  toDOM() {
4205
4248
  const el = document.createElement("span");
@@ -4240,9 +4283,13 @@ var CheckboxWidget = class extends WidgetType5 {
4240
4283
  input.setAttribute("disabled", "true");
4241
4284
  } else {
4242
4285
  input.onmousedown = (event) => {
4243
- const pos = view.posAtDOM(span);
4244
- const text = view.state.sliceDoc(pos, pos + 3);
4245
- if (text === (this._checked ? "[x]" : "[ ]")) {
4286
+ const line = view.state.doc.lineAt(view.posAtDOM(span));
4287
+ const text = view.state.sliceDoc(line.from, line.to);
4288
+ const match = text.match(/^\s*- (\[[xX ]]).*/);
4289
+ if (match) {
4290
+ const [, checked] = match;
4291
+ const pos = line.from + text.indexOf(checked);
4292
+ this._checked = checked !== "[ ]";
4246
4293
  view.dispatch({
4247
4294
  changes: {
4248
4295
  from: pos + 1,
@@ -4320,7 +4367,7 @@ var buildDecorations2 = (view, options, focus) => {
4320
4367
  const getHeaderLevels = (node, level) => {
4321
4368
  invariant4(level > 0, void 0, {
4322
4369
  F: __dxlog_file10,
4323
- L: 157,
4370
+ L: 176,
4324
4371
  S: void 0,
4325
4372
  A: [
4326
4373
  "level > 0",
@@ -4359,7 +4406,7 @@ var buildDecorations2 = (view, options, focus) => {
4359
4406
  const getCurrentListLevel = () => {
4360
4407
  invariant4(listLevels.length, void 0, {
4361
4408
  F: __dxlog_file10,
4362
- L: 179,
4409
+ L: 198,
4363
4410
  S: void 0,
4364
4411
  A: [
4365
4412
  "listLevels.length",
@@ -4370,6 +4417,9 @@ var buildDecorations2 = (view, options, focus) => {
4370
4417
  };
4371
4418
  const enterNode = (node) => {
4372
4419
  switch (node.name) {
4420
+ // ATXHeading > HeaderMark > Paragraph
4421
+ // NOTE: Numbering requires processing the entire document since otherwise only the visible range will be
4422
+ // processed and the numbering will be incorrect.
4373
4423
  case "ATXHeading1":
4374
4424
  case "ATXHeading2":
4375
4425
  case "ATXHeading3":
@@ -4403,16 +4453,20 @@ var buildDecorations2 = (view, options, focus) => {
4403
4453
  }
4404
4454
  return false;
4405
4455
  }
4456
+ //
4457
+ // Lists.
4458
+ // [BulletList | OrderedList] > (ListItem > ListMark) > (Task > TaskMarker)?
4459
+ //
4406
4460
  case "BulletList":
4407
4461
  case "OrderedList": {
4408
4462
  enterList(node);
4409
4463
  break;
4410
4464
  }
4411
4465
  case "ListItem": {
4466
+ const line = state2.doc.lineAt(node.from);
4412
4467
  const list = getCurrentListLevel();
4413
4468
  const width = list.type === "OrderedList" ? orderedListIndentationWidth : bulletListIndentationWidth;
4414
4469
  const offset = ((list.level ?? 0) + 1) * width;
4415
- const line = state2.doc.lineAt(node.from);
4416
4470
  if (node.from === line.to - 1) {
4417
4471
  return false;
4418
4472
  }
@@ -4422,33 +4476,30 @@ var buildDecorations2 = (view, options, focus) => {
4422
4476
  style: `padding-left: ${offset}px; text-indent: -${width}px;`
4423
4477
  }
4424
4478
  }));
4425
- const text = state2.doc.sliceString(line.from, node.to);
4426
- const whitespace = text.match(/^ */)?.[0].length ?? 0;
4427
- if (whitespace) {
4428
- atomicDeco.add(line.from, line.from + whitespace, hide);
4429
- }
4430
4479
  break;
4431
4480
  }
4432
4481
  case "ListMark": {
4482
+ const list = getCurrentListLevel();
4433
4483
  const next = tree.resolve(node.to + 1, 1);
4434
4484
  if (next?.name === "TaskMarker") {
4435
- atomicDeco.add(node.from, node.to + 1, hide);
4436
4485
  break;
4437
4486
  }
4438
- const list = getCurrentListLevel();
4439
- const label = list.type === "OrderedList" ? `${++list.number}.` : "\u2022";
4440
- atomicDeco.add(node.from, node.to + 1, Decoration7.replace({
4487
+ const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
4488
+ const line = state2.doc.lineAt(node.from);
4489
+ const to = state2.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
4490
+ atomicDeco.add(line.from, to, Decoration7.replace({
4441
4491
  widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
4442
4492
  }));
4443
4493
  break;
4444
4494
  }
4445
4495
  case "TaskMarker": {
4446
- if (!editingRange(state2, node, focus)) {
4447
- const checked = state2.doc.sliceString(node.from + 1, node.to - 1) === "x";
4448
- atomicDeco.add(node.from, node.to + 1, checked ? checkedTask : uncheckedTask);
4449
- }
4496
+ const checked = state2.doc.sliceString(node.from + 1, node.to - 1) === "x";
4497
+ const line = state2.doc.lineAt(node.from);
4498
+ const to = state2.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
4499
+ atomicDeco.add(line.from, to, checked ? checkedTask : uncheckedTask);
4450
4500
  break;
4451
4501
  }
4502
+ // CommentBlock
4452
4503
  case "CommentBlock": {
4453
4504
  const editing = editingRange(state2, node, focus);
4454
4505
  for (const block of view.viewportLineBlocks) {
@@ -4467,6 +4518,7 @@ var buildDecorations2 = (view, options, focus) => {
4467
4518
  }
4468
4519
  break;
4469
4520
  }
4521
+ // FencedCode > CodeMark > [CodeInfo] > CodeText > CodeMark
4470
4522
  case "FencedCode": {
4471
4523
  for (const block of view.viewportLineBlocks) {
4472
4524
  if (block.to < node.from) {
@@ -4485,6 +4537,7 @@ var buildDecorations2 = (view, options, focus) => {
4485
4537
  }
4486
4538
  return false;
4487
4539
  }
4540
+ // Link > [LinkMark, URL]
4488
4541
  case "Link": {
4489
4542
  const marks = node.node.getChildren("LinkMark");
4490
4543
  const urlNode = node.node.getChild("URL");
@@ -4511,6 +4564,7 @@ var buildDecorations2 = (view, options, focus) => {
4511
4564
  }
4512
4565
  break;
4513
4566
  }
4567
+ // HR
4514
4568
  case "HorizontalRule": {
4515
4569
  if (!editingRange(state2, node, focus)) {
4516
4570
  deco.add(node.from, node.to, horizontalRule);
@@ -4591,9 +4645,9 @@ var decorateMarkdown = (options = {}) => {
4591
4645
  }
4592
4646
  }, {
4593
4647
  provide: (plugin) => [
4594
- EditorView15.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
4595
- EditorView15.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
4596
- EditorView15.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration7.none)
4648
+ EditorView16.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
4649
+ EditorView16.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
4650
+ EditorView16.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration7.none)
4597
4651
  ]
4598
4652
  }),
4599
4653
  image(),
@@ -4726,7 +4780,7 @@ var InputModeExtensions = {
4726
4780
 
4727
4781
  // packages/ui/react-ui-editor/src/extensions/state.ts
4728
4782
  import { Transaction as Transaction2 } from "@codemirror/state";
4729
- import { EditorView as EditorView16, keymap as keymap9 } from "@codemirror/view";
4783
+ import { EditorView as EditorView17, keymap as keymap9 } from "@codemirror/view";
4730
4784
  import { debounce as debounce2 } from "@dxos/async";
4731
4785
  import { invariant as invariant5 } from "@dxos/invariant";
4732
4786
  import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
@@ -4764,7 +4818,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
4764
4818
  return {
4765
4819
  selection,
4766
4820
  scrollIntoView: !scrollTo,
4767
- effects: scrollTo ? EditorView16.scrollIntoView(scrollTo, {
4821
+ effects: scrollTo ? EditorView17.scrollIntoView(scrollTo, {
4768
4822
  yMargin: 96
4769
4823
  }) : void 0,
4770
4824
  annotations: Transaction2.userEvent.of(stateRestoreAnnotation)
@@ -4779,7 +4833,7 @@ var state = ({ getState, setState } = {}) => {
4779
4833
  // setStateDebounced(id, {});
4780
4834
  // },
4781
4835
  // }),
4782
- EditorView16.updateListener.of(({ view, transactions }) => {
4836
+ EditorView17.updateListener.of(({ view, transactions }) => {
4783
4837
  const id = view.state.facet(documentId2);
4784
4838
  if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
4785
4839
  return;
@@ -5259,19 +5313,20 @@ var Toolbar = {
5259
5313
  };
5260
5314
 
5261
5315
  // packages/ui/react-ui-editor/src/defaults.ts
5262
- import { EditorView as EditorView17 } from "@codemirror/view";
5316
+ import { EditorView as EditorView18 } from "@codemirror/view";
5263
5317
  import { mx as mx3 } from "@dxos/react-ui-theme";
5264
- var margin = "!mt-[16px]";
5318
+ var margin = "!mt-[1rem]";
5265
5319
  var editorContent = mx3(margin, "!mli-auto w-full max-w-[min(50rem,100%-2rem)]");
5266
- var editorFullWidth = mx3(margin, "!ml-[3rem]");
5320
+ var editorFullWidth = mx3(margin);
5267
5321
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
5268
- var editorGutter = EditorView17.theme({
5322
+ var editorGutter = EditorView18.theme({
5269
5323
  // Match margin from content.
5270
5324
  ".cm-gutters": {
5271
- marginTop: "16px"
5325
+ marginTop: "16px",
5326
+ paddingRight: "1rem"
5272
5327
  }
5273
5328
  });
5274
- var editorMonospace = EditorView17.theme({
5329
+ var editorMonospace = EditorView18.theme({
5275
5330
  ".cm-content": {
5276
5331
  fontFamily: fontMono
5277
5332
  }
@@ -5284,17 +5339,15 @@ var useActionHandler = (view) => {
5284
5339
 
5285
5340
  // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
5286
5341
  import { EditorState as EditorState2 } from "@codemirror/state";
5287
- import { EditorView as EditorView18 } from "@codemirror/view";
5342
+ import { EditorView as EditorView19 } from "@codemirror/view";
5288
5343
  import { useFocusableGroup } from "@fluentui/react-tabster";
5289
5344
  import { useCallback, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2, useState as useState4 } from "react";
5290
5345
  import { log as log8 } from "@dxos/log";
5291
- import { isNotFalsy as isNotFalsy4 } from "@dxos/util";
5346
+ import { getProviderValue, isNotFalsy as isNotFalsy4 } from "@dxos/util";
5292
5347
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
5293
5348
  var instanceCount = 0;
5294
5349
  var useTextEditor = (props = {}, deps = []) => {
5295
- const { id, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = useMemo3(() => {
5296
- return typeof props === "function" ? props() : props;
5297
- }, deps ?? []);
5350
+ const { id, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = useMemo3(() => getProviderValue(props), deps ?? []);
5298
5351
  const [instanceId] = useState4(() => `text-editor-${++instanceCount}`);
5299
5352
  const onUpdate = useRef2();
5300
5353
  const [view, setView] = useState4();
@@ -5308,7 +5361,7 @@ var useTextEditor = (props = {}, deps = []) => {
5308
5361
  doc: initialValue?.length ?? 0
5309
5362
  }, {
5310
5363
  F: __dxlog_file13,
5311
- L: 78,
5364
+ L: 76,
5312
5365
  S: void 0,
5313
5366
  C: (f, a) => f(...a)
5314
5367
  });
@@ -5330,23 +5383,23 @@ var useTextEditor = (props = {}, deps = []) => {
5330
5383
  extensions: [
5331
5384
  id && documentId2.of(id),
5332
5385
  // NOTE: Doesn't catch errors in keymap functions.
5333
- EditorView18.exceptionSink.of((err) => {
5386
+ EditorView19.exceptionSink.of((err) => {
5334
5387
  log8.catch(err, void 0, {
5335
5388
  F: __dxlog_file13,
5336
- L: 100,
5389
+ L: 98,
5337
5390
  S: void 0,
5338
5391
  C: (f, a) => f(...a)
5339
5392
  });
5340
5393
  }),
5341
5394
  extensions,
5342
- EditorView18.updateListener.of(() => {
5395
+ EditorView19.updateListener.of(() => {
5343
5396
  setTimeout(() => {
5344
5397
  onUpdate.current?.();
5345
5398
  });
5346
5399
  })
5347
5400
  ].filter(isNotFalsy4)
5348
5401
  });
5349
- view2 = new EditorView18({
5402
+ view2 = new EditorView19({
5350
5403
  parent: parentRef.current,
5351
5404
  selection: initialSelection,
5352
5405
  state: state2,
@@ -5374,7 +5427,7 @@ var useTextEditor = (props = {}, deps = []) => {
5374
5427
  id
5375
5428
  }, {
5376
5429
  F: __dxlog_file13,
5377
- L: 136,
5430
+ L: 134,
5378
5431
  S: void 0,
5379
5432
  C: (f, a) => f(...a)
5380
5433
  });