@dxos/react-ui-editor 0.8.4-main.c1de068 → 0.8.4-main.e098934

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 (231) hide show
  1. package/dist/lib/browser/index.mjs +2074 -996
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs +71 -1
  5. package/dist/lib/browser/testing/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/index.mjs +2074 -996
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/testing/index.mjs +71 -1
  10. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  11. package/dist/types/src/components/{Popover → CommandMenu}/CommandMenu.d.ts +10 -6
  12. package/dist/types/src/components/CommandMenu/CommandMenu.d.ts.map +1 -0
  13. package/dist/types/src/components/CommandMenu/index.d.ts +2 -0
  14. package/dist/types/src/components/CommandMenu/index.d.ts.map +1 -0
  15. package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
  16. package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
  17. package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
  18. package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
  19. package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
  20. package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
  21. package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
  22. package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
  23. package/dist/types/src/components/EditorToolbar/util.d.ts +2 -2
  24. package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
  25. package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
  26. package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
  27. package/dist/types/src/components/index.d.ts +1 -1
  28. package/dist/types/src/components/index.d.ts.map +1 -1
  29. package/dist/types/src/defaults.d.ts.map +1 -1
  30. package/dist/types/src/extensions/autocomplete.d.ts +20 -7
  31. package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
  32. package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
  33. package/dist/types/src/extensions/automerge/automerge.stories.d.ts +9 -18
  34. package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
  35. package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
  36. package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
  37. package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
  38. package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
  39. package/dist/types/src/extensions/autoscroll.d.ts +10 -0
  40. package/dist/types/src/extensions/autoscroll.d.ts.map +1 -0
  41. package/dist/types/src/extensions/command/action.d.ts +1 -1
  42. package/dist/types/src/extensions/command/action.d.ts.map +1 -1
  43. package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
  44. package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
  45. package/dist/types/src/extensions/command/command.d.ts.map +1 -1
  46. package/dist/types/src/extensions/command/floating-menu.d.ts.map +1 -1
  47. package/dist/types/src/extensions/command/hint.d.ts +2 -7
  48. package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
  49. package/dist/types/src/extensions/command/state.d.ts +1 -1
  50. package/dist/types/src/extensions/command/state.d.ts.map +1 -1
  51. package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
  52. package/dist/types/src/extensions/command/useCommandMenu.d.ts +3 -4
  53. package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
  54. package/dist/types/src/extensions/comments.d.ts +1 -1
  55. package/dist/types/src/extensions/comments.d.ts.map +1 -1
  56. package/dist/types/src/extensions/dnd.d.ts.map +1 -1
  57. package/dist/types/src/extensions/factories.d.ts +2 -7
  58. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  59. package/dist/types/src/extensions/index.d.ts +2 -0
  60. package/dist/types/src/extensions/index.d.ts.map +1 -1
  61. package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
  62. package/dist/types/src/extensions/markdown/bundle.d.ts +8 -2
  63. package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
  64. package/dist/types/src/extensions/markdown/changes.d.ts +1 -1
  65. package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
  66. package/dist/types/src/extensions/markdown/decorate.d.ts +9 -1
  67. package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
  68. package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
  69. package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
  70. package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
  71. package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
  72. package/dist/types/src/extensions/markdown/image.d.ts.map +1 -1
  73. package/dist/types/src/extensions/markdown/link.d.ts.map +1 -1
  74. package/dist/types/src/extensions/outliner/outliner.d.ts +1 -1
  75. package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
  76. package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
  77. package/dist/types/src/extensions/outliner/tree.d.ts +2 -2
  78. package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
  79. package/dist/types/src/extensions/preview/preview.d.ts +3 -6
  80. package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
  81. package/dist/types/src/extensions/tags/extended-markdown.d.ts +10 -0
  82. package/dist/types/src/extensions/tags/extended-markdown.d.ts.map +1 -0
  83. package/dist/types/src/extensions/tags/extended-markdown.test.d.ts +2 -0
  84. package/dist/types/src/extensions/tags/extended-markdown.test.d.ts.map +1 -0
  85. package/dist/types/src/extensions/tags/index.d.ts +4 -0
  86. package/dist/types/src/extensions/tags/index.d.ts.map +1 -0
  87. package/dist/types/src/extensions/tags/streamer.d.ts +12 -0
  88. package/dist/types/src/extensions/tags/streamer.d.ts.map +1 -0
  89. package/dist/types/src/extensions/tags/xml-tags.d.ts +71 -0
  90. package/dist/types/src/extensions/tags/xml-tags.d.ts.map +1 -0
  91. package/dist/types/src/extensions/tags/xml-util.d.ts +10 -0
  92. package/dist/types/src/extensions/tags/xml-util.d.ts.map +1 -0
  93. package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
  94. package/dist/types/src/stories/Command.stories.d.ts +12 -4
  95. package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
  96. package/dist/types/src/stories/CommandMenu.stories.d.ts +10 -3
  97. package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
  98. package/dist/types/src/stories/Comments.stories.d.ts +21 -9
  99. package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
  100. package/dist/types/src/stories/EditorToolbar.stories.d.ts +39 -2
  101. package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
  102. package/dist/types/src/stories/Experimental.stories.d.ts +22 -12
  103. package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
  104. package/dist/types/src/stories/Markdown.stories.d.ts +32 -42
  105. package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
  106. package/dist/types/src/stories/Outliner.stories.d.ts +15 -20
  107. package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
  108. package/dist/types/src/stories/Preview.stories.d.ts +21 -6
  109. package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
  110. package/dist/types/src/stories/Tags.stories.d.ts +17 -0
  111. package/dist/types/src/stories/Tags.stories.d.ts.map +1 -0
  112. package/dist/types/src/stories/TextEditor.stories.d.ts +38 -51
  113. package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
  114. package/dist/types/src/stories/components/EditorStory.d.ts +3 -6
  115. package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
  116. package/dist/types/src/styles/theme.d.ts.map +1 -1
  117. package/dist/types/src/testing/PreviewPopover.d.ts +20 -0
  118. package/dist/types/src/testing/PreviewPopover.d.ts.map +1 -0
  119. package/dist/types/src/testing/index.d.ts +1 -0
  120. package/dist/types/src/testing/index.d.ts.map +1 -1
  121. package/dist/types/src/testing/util.d.ts +1 -0
  122. package/dist/types/src/testing/util.d.ts.map +1 -1
  123. package/dist/types/src/translations.d.ts +1 -1
  124. package/dist/types/src/types/types.d.ts +1 -1
  125. package/dist/types/src/util/cursor.d.ts.map +1 -1
  126. package/dist/types/src/util/debug.d.ts +1 -1
  127. package/dist/types/src/util/debug.d.ts.map +1 -1
  128. package/dist/types/src/util/decorations.d.ts +4 -0
  129. package/dist/types/src/util/decorations.d.ts.map +1 -0
  130. package/dist/types/src/util/dom.d.ts +2 -12
  131. package/dist/types/src/util/dom.d.ts.map +1 -1
  132. package/dist/types/src/util/domino.d.ts +18 -0
  133. package/dist/types/src/util/domino.d.ts.map +1 -0
  134. package/dist/types/src/util/index.d.ts +2 -0
  135. package/dist/types/src/util/index.d.ts.map +1 -1
  136. package/dist/types/src/util/react.d.ts +1 -1
  137. package/dist/types/src/util/react.d.ts.map +1 -1
  138. package/dist/types/tsconfig.tsbuildinfo +1 -1
  139. package/package.json +57 -51
  140. package/src/components/{Popover → CommandMenu}/CommandMenu.tsx +93 -26
  141. package/src/components/{Popover → CommandMenu}/index.ts +0 -2
  142. package/src/components/Editor/Editor.tsx +1 -1
  143. package/src/components/EditorToolbar/EditorToolbar.tsx +40 -30
  144. package/src/components/EditorToolbar/blocks.ts +21 -24
  145. package/src/components/EditorToolbar/formatting.ts +22 -25
  146. package/src/components/EditorToolbar/headings.ts +10 -5
  147. package/src/components/EditorToolbar/image.ts +8 -4
  148. package/src/components/EditorToolbar/lists.ts +16 -19
  149. package/src/components/EditorToolbar/search.ts +8 -4
  150. package/src/components/EditorToolbar/util.ts +16 -5
  151. package/src/components/EditorToolbar/view-mode.ts +11 -6
  152. package/src/components/index.ts +1 -1
  153. package/src/defaults.ts +5 -2
  154. package/src/extensions/autocomplete.ts +204 -54
  155. package/src/extensions/automerge/automerge.stories.tsx +25 -18
  156. package/src/extensions/automerge/automerge.ts +4 -3
  157. package/src/extensions/automerge/defs.ts +1 -1
  158. package/src/extensions/automerge/sync.ts +1 -1
  159. package/src/extensions/automerge/update-automerge.ts +1 -1
  160. package/src/extensions/autoscroll.ts +157 -0
  161. package/src/extensions/awareness/awareness.ts +2 -2
  162. package/src/extensions/command/action.ts +1 -2
  163. package/src/extensions/command/command-menu.ts +7 -6
  164. package/src/extensions/command/command.ts +3 -3
  165. package/src/extensions/command/floating-menu.ts +10 -15
  166. package/src/extensions/command/hint.ts +2 -1
  167. package/src/extensions/command/placeholder.ts +1 -1
  168. package/src/extensions/command/state.ts +4 -3
  169. package/src/extensions/command/typeahead.ts +2 -2
  170. package/src/extensions/command/useCommandMenu.ts +6 -9
  171. package/src/extensions/comments.ts +18 -13
  172. package/src/extensions/dnd.ts +1 -1
  173. package/src/extensions/factories.ts +9 -21
  174. package/src/extensions/folding.tsx +2 -2
  175. package/src/extensions/index.ts +2 -0
  176. package/src/extensions/markdown/action.ts +2 -1
  177. package/src/extensions/markdown/bundle.ts +25 -3
  178. package/src/extensions/markdown/changes.ts +1 -1
  179. package/src/extensions/markdown/decorate.ts +23 -14
  180. package/src/extensions/markdown/formatting.test.ts +6 -6
  181. package/src/extensions/markdown/formatting.ts +3 -3
  182. package/src/extensions/markdown/highlight.ts +1 -1
  183. package/src/extensions/markdown/image.ts +3 -4
  184. package/src/extensions/markdown/link.ts +3 -0
  185. package/src/extensions/markdown/table.ts +7 -1
  186. package/src/extensions/mention.ts +1 -1
  187. package/src/extensions/outliner/outliner.test.ts +3 -2
  188. package/src/extensions/outliner/outliner.ts +6 -5
  189. package/src/extensions/outliner/selection.ts +1 -1
  190. package/src/extensions/outliner/tree.test.ts +2 -1
  191. package/src/extensions/outliner/tree.ts +2 -2
  192. package/src/extensions/preview/preview.ts +59 -62
  193. package/src/extensions/tags/extended-markdown.test.ts +261 -0
  194. package/src/extensions/tags/extended-markdown.ts +78 -0
  195. package/src/extensions/tags/index.ts +7 -0
  196. package/src/extensions/tags/streamer.ts +244 -0
  197. package/src/extensions/tags/xml-tags.ts +335 -0
  198. package/src/extensions/tags/xml-util.ts +94 -0
  199. package/src/hooks/useTextEditor.ts +3 -15
  200. package/src/stories/Command.stories.tsx +24 -31
  201. package/src/stories/CommandMenu.stories.tsx +28 -29
  202. package/src/stories/Comments.stories.tsx +10 -6
  203. package/src/stories/EditorToolbar.stories.tsx +8 -8
  204. package/src/stories/Experimental.stories.tsx +12 -8
  205. package/src/stories/Markdown.stories.tsx +21 -17
  206. package/src/stories/Outliner.stories.tsx +42 -30
  207. package/src/stories/Preview.stories.tsx +30 -29
  208. package/src/stories/Tags.stories.tsx +81 -0
  209. package/src/stories/TextEditor.stories.tsx +40 -34
  210. package/src/stories/components/EditorStory.tsx +9 -10
  211. package/src/styles/theme.ts +8 -6
  212. package/src/testing/PreviewPopover.tsx +78 -0
  213. package/src/testing/index.ts +1 -0
  214. package/src/testing/util.ts +2 -0
  215. package/src/translations.ts +1 -1
  216. package/src/util/cursor.ts +2 -1
  217. package/src/util/debug.ts +2 -2
  218. package/src/util/decorations.ts +21 -0
  219. package/src/util/dom.ts +5 -27
  220. package/src/util/domino.ts +51 -0
  221. package/src/util/index.ts +2 -0
  222. package/src/util/react.tsx +1 -1
  223. package/dist/types/src/components/Popover/CommandMenu.d.ts.map +0 -1
  224. package/dist/types/src/components/Popover/RefDropdownMenu.d.ts +0 -21
  225. package/dist/types/src/components/Popover/RefDropdownMenu.d.ts.map +0 -1
  226. package/dist/types/src/components/Popover/RefPopover.d.ts +0 -34
  227. package/dist/types/src/components/Popover/RefPopover.d.ts.map +0 -1
  228. package/dist/types/src/components/Popover/index.d.ts +0 -4
  229. package/dist/types/src/components/Popover/index.d.ts.map +0 -1
  230. package/src/components/Popover/RefDropdownMenu.tsx +0 -85
  231. package/src/components/Popover/RefPopover.tsx +0 -99
@@ -26,8 +26,8 @@ var translations = [
26
26
  "selection overlaps existing comment label": "Selection overlaps existing comment",
27
27
  "select text to comment label": "Select text to comment",
28
28
  "image label": "Insert image",
29
- "heading label": "Heading level",
30
29
  "table label": "Create table",
30
+ "heading label": "Heading level",
31
31
  "heading level label_zero": "Paragraph",
32
32
  "heading level label_one": "Heading level {{count}}",
33
33
  "heading level label_other": "Heading level {{count}}",
@@ -43,7 +43,7 @@ var translations = [
43
43
 
44
44
  // src/index.ts
45
45
  import { EditorState as EditorState4 } from "@codemirror/state";
46
- import { EditorView as EditorView27, keymap as keymap14 } from "@codemirror/view";
46
+ import { EditorView as EditorView31, keymap as keymap14 } from "@codemirror/view";
47
47
  import { tags as tags2 } from "@lezer/highlight";
48
48
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
49
49
 
@@ -51,28 +51,38 @@ import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
51
51
  import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
52
52
  import React3, { forwardRef, useImperativeHandle } from "react";
53
53
  import { useThemeContext } from "@dxos/react-ui";
54
- import { mx as mx6 } from "@dxos/react-ui-theme";
54
+ import { mx as mx7 } from "@dxos/react-ui-theme";
55
55
 
56
56
  // src/hooks/useTextEditor.ts
57
57
  import { EditorState as EditorState3 } from "@codemirror/state";
58
- import { EditorView as EditorView26 } from "@codemirror/view";
58
+ import { EditorView as EditorView30 } from "@codemirror/view";
59
59
  import { useFocusableGroup } from "@fluentui/react-tabster";
60
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";
61
+ import { log as log9 } from "@dxos/log";
62
+ import { getProviderValue, isNotFalsy as isNotFalsy5 } from "@dxos/util";
63
63
 
64
64
  // src/extensions/annotations.ts
65
65
  import { RangeSetBuilder } from "@codemirror/state";
66
66
  import { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
67
+ function _define_property(obj, key, value) {
68
+ if (key in obj) {
69
+ Object.defineProperty(obj, key, {
70
+ value,
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true
74
+ });
75
+ } else {
76
+ obj[key] = value;
77
+ }
78
+ return obj;
79
+ }
67
80
  var annotationMark = Decoration.mark({
68
81
  class: "cm-annotation"
69
82
  });
70
83
  var annotations = ({ match } = {}) => {
71
84
  return [
72
85
  ViewPlugin.fromClass(class {
73
- constructor() {
74
- this.decorations = Decoration.none;
75
- }
76
86
  update(update2) {
77
87
  const builder = new RangeSetBuilder();
78
88
  if (match) {
@@ -89,6 +99,9 @@ var annotations = ({ match } = {}) => {
89
99
  }
90
100
  this.decorations = builder.finish();
91
101
  }
102
+ constructor() {
103
+ _define_property(this, "decorations", Decoration.none);
104
+ }
92
105
  }, {
93
106
  decorations: (v) => v.decorations
94
107
  }),
@@ -103,58 +116,530 @@ var annotations = ({ match } = {}) => {
103
116
  };
104
117
 
105
118
  // src/extensions/autocomplete.ts
106
- import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
107
- import { markdownLanguage } from "@codemirror/lang-markdown";
108
- import { keymap } from "@codemirror/view";
109
- var autocomplete = ({ activateOnTyping, override, onSearch } = {}) => {
110
- const extensions = [
111
- // https://codemirror.net/docs/ref/#view.keymap
112
- // https://discuss.codemirror.net/t/how-can-i-replace-the-default-autocompletion-keymap-v6/3322
113
- // TODO(burdon): Set custom keymap.
114
- keymap.of(completionKeymap),
115
- // https://codemirror.net/examples/autocompletion
116
- // https://codemirror.net/docs/ref/#autocomplete.autocompletion
117
- autocompletion({
118
- override,
119
- activateOnTyping
120
- })
121
- ];
122
- if (onSearch) {
123
- extensions.push(
124
- // TODO(burdon): Optional decoration via addToOptions.
125
- markdownLanguage.data.of({
126
- autocomplete: (context) => {
127
- const match = context.matchBefore(/\w*/);
128
- if (!match || match.from === match.to && !context.explicit) {
129
- return null;
119
+ import { Prec } from "@codemirror/state";
120
+ import { Decoration as Decoration2, EditorView as EditorView2, ViewPlugin as ViewPlugin2, WidgetType, keymap } from "@codemirror/view";
121
+ function _define_property2(obj, key, value) {
122
+ if (key in obj) {
123
+ Object.defineProperty(obj, key, {
124
+ value,
125
+ enumerable: true,
126
+ configurable: true,
127
+ writable: true
128
+ });
129
+ } else {
130
+ obj[key] = value;
131
+ }
132
+ return obj;
133
+ }
134
+ var autocomplete = ({ fireIfEmpty, onSubmit, onSuggest, onCancel }) => {
135
+ const suggest = ViewPlugin2.fromClass(class {
136
+ update(update2) {
137
+ if (update2.docChanged || update2.selectionSet) {
138
+ this._decorations = this.computeDecorations(update2.view);
139
+ }
140
+ }
141
+ computeDecorations(view) {
142
+ const text = view.state.doc.toString();
143
+ const suggestions = onSuggest?.(text) ?? [];
144
+ if (!suggestions.length) {
145
+ this._currentSuggestion = null;
146
+ return Decoration2.none;
147
+ }
148
+ this._currentSuggestion = suggestions[0];
149
+ const suffix = this._currentSuggestion.slice(text.length);
150
+ if (!suffix) {
151
+ return Decoration2.none;
152
+ }
153
+ return Decoration2.set([
154
+ Decoration2.widget({
155
+ widget: new InlineSuggestionWidget(suffix),
156
+ side: 1
157
+ }).range(view.state.doc.length)
158
+ ]);
159
+ }
160
+ completeSuggestion(view) {
161
+ if (!this._currentSuggestion) {
162
+ return false;
163
+ }
164
+ const text = view.state.doc.toString();
165
+ const suffix = this._currentSuggestion.slice(text.length);
166
+ if (!suffix) {
167
+ return false;
168
+ }
169
+ view.dispatch({
170
+ changes: {
171
+ from: view.state.doc.length,
172
+ insert: suffix
173
+ },
174
+ selection: {
175
+ anchor: view.state.doc.length + suffix.length
176
+ }
177
+ });
178
+ return true;
179
+ }
180
+ constructor(view) {
181
+ _define_property2(this, "_decorations", void 0);
182
+ _define_property2(this, "_currentSuggestion", null);
183
+ this._decorations = this.computeDecorations(view);
184
+ }
185
+ }, {
186
+ decorations: (v) => v._decorations
187
+ });
188
+ return [
189
+ suggest,
190
+ EditorView2.theme({
191
+ ".cm-inline-suggestion": {
192
+ opacity: 0.4
193
+ }
194
+ }),
195
+ Prec.highest(keymap.of([
196
+ {
197
+ key: "Tab",
198
+ preventDefault: true,
199
+ run: (view) => {
200
+ const plugin = view.plugin(suggest);
201
+ return plugin?.completeSuggestion(view) ?? false;
202
+ }
203
+ },
204
+ {
205
+ key: "ArrowRight",
206
+ preventDefault: true,
207
+ run: (view) => {
208
+ if (view.state.selection.main.head !== view.state.doc.length) {
209
+ return false;
130
210
  }
131
- return {
132
- from: match.from,
133
- options: onSearch(match.text.toLowerCase())
134
- };
211
+ const plugin = view.plugin(suggest);
212
+ return plugin?.completeSuggestion(view) ?? false;
135
213
  }
136
- })
137
- );
214
+ },
215
+ {
216
+ key: "Enter",
217
+ preventDefault: true,
218
+ run: (view) => {
219
+ const text = view.state.doc.toString().trim();
220
+ if (onSubmit && (fireIfEmpty || text.length > 0)) {
221
+ const reset = onSubmit(text);
222
+ if (reset) {
223
+ view.dispatch({
224
+ changes: {
225
+ from: 0,
226
+ to: view.state.doc.length,
227
+ insert: ""
228
+ }
229
+ });
230
+ }
231
+ }
232
+ return true;
233
+ }
234
+ },
235
+ {
236
+ key: "Shift-Enter",
237
+ preventDefault: true,
238
+ run: (view) => {
239
+ view.dispatch({
240
+ changes: {
241
+ from: view.state.selection.main.head,
242
+ insert: "\n"
243
+ },
244
+ selection: {
245
+ anchor: view.state.selection.main.head + 1,
246
+ head: view.state.selection.main.head + 1
247
+ }
248
+ });
249
+ return true;
250
+ }
251
+ },
252
+ {
253
+ key: "Escape",
254
+ preventDefault: true,
255
+ run: (view) => {
256
+ view.dispatch({
257
+ changes: {
258
+ from: 0,
259
+ to: view.state.doc.length,
260
+ insert: ""
261
+ }
262
+ });
263
+ onCancel?.();
264
+ return true;
265
+ }
266
+ }
267
+ ]))
268
+ ];
269
+ };
270
+ var InlineSuggestionWidget = class extends WidgetType {
271
+ toDOM() {
272
+ const span = document.createElement("span");
273
+ span.textContent = this.suffix;
274
+ span.className = "cm-inline-suggestion";
275
+ return span;
138
276
  }
139
- return extensions;
277
+ eq(other) {
278
+ return other.suffix === this.suffix;
279
+ }
280
+ constructor(suffix) {
281
+ super(), _define_property2(this, "suffix", void 0), this.suffix = suffix;
282
+ }
283
+ };
284
+
285
+ // src/extensions/autoscroll.ts
286
+ import { StateEffect } from "@codemirror/state";
287
+ import { EditorView as EditorView3, ViewPlugin as ViewPlugin3 } from "@codemirror/view";
288
+
289
+ // src/util/facet.ts
290
+ import { Facet } from "@codemirror/state";
291
+ var singleValueFacet = (defaultValue) => Facet.define({
292
+ // Called immediately.
293
+ combine: (providers) => {
294
+ return providers[0] ?? defaultValue;
295
+ }
296
+ });
297
+
298
+ // src/util/cursor.ts
299
+ function _define_property3(obj, key, value) {
300
+ if (key in obj) {
301
+ Object.defineProperty(obj, key, {
302
+ value,
303
+ enumerable: true,
304
+ configurable: true,
305
+ writable: true
306
+ });
307
+ } else {
308
+ obj[key] = value;
309
+ }
310
+ return obj;
311
+ }
312
+ var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
313
+ var defaultCursorConverter = {
314
+ toCursor: (position) => position.toString(),
315
+ fromCursor: (cursor2) => parseInt(cursor2)
316
+ };
317
+ var Cursor = class {
318
+ };
319
+ _define_property3(Cursor, "converter", singleValueFacet(defaultCursorConverter));
320
+ _define_property3(Cursor, "getCursorFromRange", (state, range) => {
321
+ const cursorConverter2 = state.facet(Cursor.converter);
322
+ const from = cursorConverter2.toCursor(range.from);
323
+ const to = cursorConverter2.toCursor(range.to, -1);
324
+ return [
325
+ from,
326
+ to
327
+ ].join(":");
328
+ });
329
+ _define_property3(Cursor, "getRangeFromCursor", (state, cursor2) => {
330
+ const cursorConverter2 = state.facet(Cursor.converter);
331
+ const parts = cursor2.split(":");
332
+ const from = cursorConverter2.fromCursor(parts[0]);
333
+ const to = cursorConverter2.fromCursor(parts[1]);
334
+ return from !== void 0 && to !== void 0 ? {
335
+ from,
336
+ to
337
+ } : void 0;
338
+ });
339
+
340
+ // src/util/decorations.ts
341
+ var decorationSetToArray = (deco) => {
342
+ const ranges = [];
343
+ const iter = deco.iter();
344
+ while (iter.value) {
345
+ ranges.push({
346
+ from: iter.from,
347
+ to: iter.to,
348
+ value: iter.value
349
+ });
350
+ iter.next();
351
+ }
352
+ return ranges;
353
+ };
354
+
355
+ // src/util/debug.ts
356
+ import { log } from "@dxos/log";
357
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
358
+ var wrapWithCatch = (fn, label) => {
359
+ return (...args) => {
360
+ try {
361
+ return fn(...args);
362
+ } catch (err) {
363
+ log.catch(err, {
364
+ label
365
+ }, {
366
+ F: __dxlog_file,
367
+ L: 15,
368
+ S: void 0,
369
+ C: (f, a) => f(...a)
370
+ });
371
+ }
372
+ };
373
+ };
374
+ var callbackWrapper = (fn) => (...args) => {
375
+ try {
376
+ return fn(...args);
377
+ } catch (err) {
378
+ log.catch(err, void 0, {
379
+ F: __dxlog_file,
380
+ L: 29,
381
+ S: void 0,
382
+ C: (f, a) => f(...a)
383
+ });
384
+ }
385
+ };
386
+ var debugDispatcher = (trs, view) => {
387
+ logChanges(trs);
388
+ view.update(trs);
389
+ };
390
+ var logChanges = (trs) => {
391
+ const changes = trs.flatMap((tr) => {
392
+ if (tr.changes.empty) {
393
+ return void 0;
394
+ }
395
+ const changes2 = [];
396
+ tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => changes2.push(JSON.stringify({
397
+ fromA,
398
+ toA,
399
+ fromB,
400
+ toB,
401
+ inserted: inserted.toString()
402
+ })));
403
+ return changes2;
404
+ }).filter(Boolean);
405
+ if (changes.length) {
406
+ log("changes", {
407
+ changes
408
+ }, {
409
+ F: __dxlog_file,
410
+ L: 62,
411
+ S: void 0,
412
+ C: (f, a) => f(...a)
413
+ });
414
+ }
415
+ };
416
+
417
+ // src/util/dom.ts
418
+ var flattenRect = (rect, left) => {
419
+ const x = left ? rect.left : rect.right;
420
+ return {
421
+ left: x,
422
+ right: x,
423
+ top: rect.top,
424
+ bottom: rect.bottom
425
+ };
426
+ };
427
+ var scratchRange;
428
+ var textRange = (node, from, to = from) => {
429
+ const range = scratchRange || (scratchRange = document.createRange());
430
+ range.setEnd(node, to);
431
+ range.setStart(node, from);
432
+ return range;
433
+ };
434
+ var clientRectsFor = (dom) => {
435
+ if (dom.nodeType === 3) {
436
+ return textRange(dom, 0, dom.nodeValue.length).getClientRects();
437
+ } else if (dom.nodeType === 1) {
438
+ return dom.getClientRects();
439
+ } else {
440
+ return [];
441
+ }
442
+ };
443
+
444
+ // src/util/domino.ts
445
+ import { mx } from "@dxos/react-ui-theme";
446
+ function _define_property4(obj, key, value) {
447
+ if (key in obj) {
448
+ Object.defineProperty(obj, key, {
449
+ value,
450
+ enumerable: true,
451
+ configurable: true,
452
+ writable: true
453
+ });
454
+ } else {
455
+ obj[key] = value;
456
+ }
457
+ return obj;
458
+ }
459
+ var Domino = class _Domino {
460
+ static of(tag) {
461
+ return new _Domino(tag);
462
+ }
463
+ classNames(...classNames) {
464
+ this._el.className = mx(classNames);
465
+ return this;
466
+ }
467
+ text(value) {
468
+ this._el.textContent = value;
469
+ return this;
470
+ }
471
+ data(key, value) {
472
+ this._el.dataset[key] = value;
473
+ return this;
474
+ }
475
+ style(styles4) {
476
+ Object.assign(this._el.style, styles4);
477
+ return this;
478
+ }
479
+ attr(key, value) {
480
+ this._el[key] = value;
481
+ return this;
482
+ }
483
+ child(...children) {
484
+ children.forEach((child) => this._el.appendChild(child.build()));
485
+ return this;
486
+ }
487
+ on(event, handler) {
488
+ this._el.addEventListener(event, handler);
489
+ return this;
490
+ }
491
+ build() {
492
+ return this._el;
493
+ }
494
+ constructor(tag) {
495
+ _define_property4(this, "_el", void 0);
496
+ this._el = document.createElement(tag);
497
+ }
498
+ };
499
+
500
+ // src/util/react.tsx
501
+ import React from "react";
502
+ import { createRoot } from "react-dom/client";
503
+ import { ThemeProvider, Tooltip } from "@dxos/react-ui";
504
+ import { defaultTx } from "@dxos/react-ui-theme";
505
+ var renderRoot = (root, node) => {
506
+ createRoot(root).render(/* @__PURE__ */ React.createElement(ThemeProvider, {
507
+ tx: defaultTx
508
+ }, node));
509
+ return root;
510
+ };
511
+ var createRenderer = (Component) => (el, props) => {
512
+ renderRoot(el, /* @__PURE__ */ React.createElement(ThemeProvider, {
513
+ tx: defaultTx
514
+ }, /* @__PURE__ */ React.createElement(Tooltip.Provider, null, /* @__PURE__ */ React.createElement(Component, props))));
515
+ };
516
+
517
+ // src/extensions/autoscroll.ts
518
+ var lineHeight = 24;
519
+ var scrollToBottomEffect = StateEffect.define();
520
+ var autoScroll = ({ overscroll = 4 * lineHeight, throttle: throttle2 = 2e3 } = {}) => {
521
+ let isThrottled = false;
522
+ let isPinned = true;
523
+ let timeout;
524
+ let buttonContainer;
525
+ let lastScrollTop = 0;
526
+ let scrollCounter = 0;
527
+ const hideScrollbar = (view) => {
528
+ view.scrollDOM.classList.add("cm-hide-scrollbar");
529
+ clearTimeout(timeout);
530
+ timeout = setTimeout(() => {
531
+ view.scrollDOM.classList.remove("cm-hide-scrollbar");
532
+ }, 1e3);
533
+ };
534
+ const scrollToBottom = (view) => {
535
+ isPinned = true;
536
+ scrollCounter = 0;
537
+ buttonContainer?.classList.add("opacity-0");
538
+ requestAnimationFrame(() => {
539
+ hideScrollbar(view);
540
+ view.scrollDOM.scrollTo({
541
+ top: view.scrollDOM.scrollHeight,
542
+ behavior: "smooth"
543
+ });
544
+ });
545
+ };
546
+ return [
547
+ // Scroll button.
548
+ ViewPlugin3.fromClass(class {
549
+ constructor(view) {
550
+ const scroller = view.scrollDOM.parentElement;
551
+ buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").child(Domino.of("button").classNames("dx-button bg-accentSurface").data("density", "fine").child(Domino.of("dx-icon").attr("icon", "ph--arrow-down--regular")).on("click", () => {
552
+ scrollToBottom(view);
553
+ })).build();
554
+ scroller?.appendChild(buttonContainer);
555
+ }
556
+ }),
557
+ // Update listener for logging when scrolling is needed.
558
+ EditorView3.updateListener.of((update2) => {
559
+ update2.transactions.forEach((transaction) => {
560
+ for (const effect of transaction.effects) {
561
+ if (effect.is(scrollToBottomEffect)) {
562
+ scrollToBottom(update2.view);
563
+ }
564
+ }
565
+ });
566
+ if (update2.docChanged && isPinned && !isThrottled) {
567
+ const distanceFromBottom = calcDistance(update2.view.scrollDOM);
568
+ if (distanceFromBottom >= overscroll) {
569
+ isThrottled = true;
570
+ requestAnimationFrame(() => {
571
+ scrollToBottom(update2.view);
572
+ });
573
+ setTimeout(() => {
574
+ isThrottled = false;
575
+ }, throttle2);
576
+ }
577
+ }
578
+ }),
579
+ // Detect user scroll.
580
+ // NOTE: Multiple scroll events are triggered during programmatic smooth scrolling.
581
+ EditorView3.domEventHandlers({
582
+ scroll: (event, view) => {
583
+ const scroller = view.scrollDOM;
584
+ if (lastScrollTop > scroller.scrollTop) {
585
+ scrollCounter++;
586
+ }
587
+ lastScrollTop = scroller.scrollTop;
588
+ const distanceFromBottom = calcDistance(scroller);
589
+ if (distanceFromBottom === 0) {
590
+ isPinned = true;
591
+ buttonContainer?.classList.add("opacity-0");
592
+ scrollCounter = 0;
593
+ } else if (scrollCounter > 3) {
594
+ isPinned = false;
595
+ buttonContainer?.classList.remove("opacity-0");
596
+ }
597
+ }
598
+ }),
599
+ EditorView3.theme({
600
+ ".cm-scroller": {
601
+ paddingBottom: `${overscroll}px`,
602
+ scrollbarWidth: "thin"
603
+ },
604
+ ".cm-scroller.cm-hide-scrollbar": {
605
+ scrollbarWidth: "none"
606
+ },
607
+ ".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
608
+ display: "none"
609
+ },
610
+ // TODO(burdon): IconButton.
611
+ ".cm-scroll-button": {
612
+ position: "absolute",
613
+ bottom: "0.5rem",
614
+ right: "1rem"
615
+ }
616
+ })
617
+ ];
618
+ };
619
+ var calcDistance = (scroller) => {
620
+ const scrollTop = scroller.scrollTop;
621
+ const scrollHeight = scroller.scrollHeight;
622
+ const clientHeight = scroller.clientHeight;
623
+ const distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
624
+ return distanceFromBottom;
140
625
  };
141
626
 
142
627
  // src/extensions/automerge/automerge.ts
143
628
  import { next as A3 } from "@automerge/automerge";
144
629
  import { StateField } from "@codemirror/state";
145
- import { EditorView as EditorView2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
630
+ import { EditorView as EditorView4, ViewPlugin as ViewPlugin4 } from "@codemirror/view";
146
631
 
147
632
  // src/extensions/automerge/cursor.ts
148
- import { log } from "@dxos/log";
633
+ import { log as log2 } from "@dxos/log";
149
634
  import { fromCursor, toCursor } from "@dxos/react-client/echo";
150
- var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
635
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
151
636
  var cursorConverter = (accessor) => ({
152
637
  toCursor: (pos, assoc) => {
153
638
  try {
154
639
  return toCursor(accessor, pos, assoc);
155
640
  } catch (err) {
156
- log.catch(err, void 0, {
157
- F: __dxlog_file,
641
+ log2.catch(err, void 0, {
642
+ F: __dxlog_file2,
158
643
  L: 15,
159
644
  S: void 0,
160
645
  C: (f, a) => f(...a)
@@ -162,12 +647,12 @@ var cursorConverter = (accessor) => ({
162
647
  return "";
163
648
  }
164
649
  },
165
- fromCursor: (cursor) => {
650
+ fromCursor: (cursor2) => {
166
651
  try {
167
- return fromCursor(accessor, cursor);
652
+ return fromCursor(accessor, cursor2);
168
653
  } catch (err) {
169
- log.catch(err, void 0, {
170
- F: __dxlog_file,
654
+ log2.catch(err, void 0, {
655
+ F: __dxlog_file2,
171
656
  L: 24,
172
657
  S: void 0,
173
658
  C: (f, a) => f(...a)
@@ -178,10 +663,10 @@ var cursorConverter = (accessor) => ({
178
663
  });
179
664
 
180
665
  // src/extensions/automerge/defs.ts
181
- import { Annotation, StateEffect } from "@codemirror/state";
666
+ import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
182
667
  var getPath = (state, field) => state.field(field).path;
183
668
  var getLastHeads = (state, field) => state.field(field).lastHeads;
184
- var updateHeadsEffect = StateEffect.define({});
669
+ var updateHeadsEffect = StateEffect2.define({});
185
670
  var updateHeads = (newHeads) => updateHeadsEffect.of({
186
671
  newHeads
187
672
  });
@@ -332,13 +817,20 @@ var charPath = (textPath, candidatePath) => {
332
817
  };
333
818
 
334
819
  // src/extensions/automerge/sync.ts
335
- var Syncer = class {
336
- // prettier-ignore
337
- constructor(_handle, _state) {
338
- this._handle = _handle;
339
- this._state = _state;
340
- this._pending = false;
820
+ function _define_property5(obj, key, value) {
821
+ if (key in obj) {
822
+ Object.defineProperty(obj, key, {
823
+ value,
824
+ enumerable: true,
825
+ configurable: true,
826
+ writable: true
827
+ });
828
+ } else {
829
+ obj[key] = value;
341
830
  }
831
+ return obj;
832
+ }
833
+ var Syncer = class {
342
834
  reconcile(view, editor2) {
343
835
  if (this._pending) {
344
836
  return;
@@ -373,172 +865,31 @@ var Syncer = class {
373
865
  annotations: reconcileAnnotation.of(false)
374
866
  });
375
867
  }
376
- };
377
-
378
- // src/util/facet.ts
379
- import { Facet } from "@codemirror/state";
380
- var singleValueFacet = (defaultValue) => Facet.define({
381
- // Called immediately.
382
- combine: (providers) => {
383
- return providers[0] ?? defaultValue;
384
- }
385
- });
386
-
387
- // src/util/cursor.ts
388
- var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
389
- var defaultCursorConverter = {
390
- toCursor: (position) => position.toString(),
391
- fromCursor: (cursor) => parseInt(cursor)
392
- };
393
- var Cursor = class _Cursor {
394
- static {
395
- this.converter = singleValueFacet(defaultCursorConverter);
396
- }
397
- static {
398
- this.getCursorFromRange = (state, range) => {
399
- const cursorConverter2 = state.facet(_Cursor.converter);
400
- const from = cursorConverter2.toCursor(range.from);
401
- const to = cursorConverter2.toCursor(range.to, -1);
402
- return [
403
- from,
404
- to
405
- ].join(":");
406
- };
407
- }
408
- static {
409
- this.getRangeFromCursor = (state, cursor) => {
410
- const cursorConverter2 = state.facet(_Cursor.converter);
411
- const parts = cursor.split(":");
412
- const from = cursorConverter2.fromCursor(parts[0]);
413
- const to = cursorConverter2.fromCursor(parts[1]);
414
- return from !== void 0 && to !== void 0 ? {
415
- from,
416
- to
417
- } : void 0;
418
- };
868
+ // prettier-ignore
869
+ constructor(_handle, _state) {
870
+ _define_property5(this, "_handle", void 0);
871
+ _define_property5(this, "_state", void 0);
872
+ _define_property5(this, "_pending", void 0);
873
+ this._handle = _handle;
874
+ this._state = _state;
875
+ this._pending = false;
419
876
  }
420
877
  };
421
878
 
422
- // src/util/debug.ts
423
- import { log as log2 } from "@dxos/log";
424
- var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
425
- var wrapWithCatch = (fn) => {
426
- return (...args) => {
427
- try {
428
- return fn(...args);
429
- } catch (err) {
430
- log2.catch(err, void 0, {
431
- F: __dxlog_file2,
432
- L: 15,
433
- S: void 0,
434
- C: (f, a) => f(...a)
435
- });
436
- }
437
- };
438
- };
439
- var callbackWrapper = (fn) => (...args) => {
440
- try {
441
- return fn(...args);
442
- } catch (err) {
443
- log2.catch(err, void 0, {
444
- F: __dxlog_file2,
445
- L: 29,
446
- S: void 0,
447
- C: (f, a) => f(...a)
448
- });
449
- }
450
- };
451
- var debugDispatcher = (trs, view) => {
452
- logChanges(trs);
453
- view.update(trs);
454
- };
455
- var logChanges = (trs) => {
456
- const changes = trs.flatMap((tr) => {
457
- if (tr.changes.empty) {
458
- return void 0;
459
- }
460
- const changes2 = [];
461
- tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => changes2.push(JSON.stringify({
462
- fromA,
463
- toA,
464
- fromB,
465
- toB,
466
- inserted: inserted.toString()
467
- })));
468
- return changes2;
469
- }).filter(Boolean);
470
- if (changes.length) {
471
- log2("changes", {
472
- changes
473
- }, {
474
- F: __dxlog_file2,
475
- L: 62,
476
- S: void 0,
477
- C: (f, a) => f(...a)
879
+ // src/extensions/automerge/automerge.ts
880
+ function _define_property6(obj, key, value) {
881
+ if (key in obj) {
882
+ Object.defineProperty(obj, key, {
883
+ value,
884
+ enumerable: true,
885
+ configurable: true,
886
+ writable: true
478
887
  });
479
- }
480
- };
481
-
482
- // src/util/dom.ts
483
- var flattenRect = (rect, left) => {
484
- const x = left ? rect.left : rect.right;
485
- return {
486
- left: x,
487
- right: x,
488
- top: rect.top,
489
- bottom: rect.bottom
490
- };
491
- };
492
- var scratchRange;
493
- var textRange = (node, from, to = from) => {
494
- const range = scratchRange || (scratchRange = document.createRange());
495
- range.setEnd(node, to);
496
- range.setStart(node, from);
497
- return range;
498
- };
499
- var clientRectsFor = (dom) => {
500
- if (dom.nodeType === 3) {
501
- return textRange(dom, 0, dom.nodeValue.length).getClientRects();
502
- } else if (dom.nodeType === 1) {
503
- return dom.getClientRects();
504
888
  } else {
505
- return [];
506
- }
507
- };
508
- var createElement = (tag, options, children) => {
509
- const el = document.createElement(tag);
510
- if (options?.className) {
511
- el.className = options.className;
512
- }
513
- if (options?.text) {
514
- el.textContent = options.text;
889
+ obj[key] = value;
515
890
  }
516
- if (children) {
517
- el.append(...Array.isArray(children) ? children : [
518
- children
519
- ]);
520
- }
521
- return el;
522
- };
523
-
524
- // src/util/react.tsx
525
- import React from "react";
526
- import { createRoot } from "react-dom/client";
527
- import { ThemeProvider, Tooltip } from "@dxos/react-ui";
528
- import { defaultTx } from "@dxos/react-ui-theme";
529
- var renderRoot = (root, node) => {
530
- createRoot(root).render(/* @__PURE__ */ React.createElement(ThemeProvider, {
531
- tx: defaultTx
532
- }, node));
533
- return root;
534
- };
535
- var createRenderer = (Component) => (el, props) => {
536
- renderRoot(el, /* @__PURE__ */ React.createElement(ThemeProvider, {
537
- tx: defaultTx
538
- }, /* @__PURE__ */ React.createElement(Tooltip.Provider, null, /* @__PURE__ */ React.createElement(Component, props))));
539
- };
540
-
541
- // src/extensions/automerge/automerge.ts
891
+ return obj;
892
+ }
542
893
  var automerge = (accessor) => {
543
894
  const syncState = StateField.define({
544
895
  create: () => ({
@@ -575,20 +926,22 @@ var automerge = (accessor) => {
575
926
  // Track heads.
576
927
  syncState,
577
928
  // Reconcile external updates.
578
- ViewPlugin2.fromClass(class {
929
+ ViewPlugin4.fromClass(class {
930
+ destroy() {
931
+ accessor.handle.removeListener("change", this._handleChange);
932
+ }
579
933
  constructor(_view) {
934
+ _define_property6(this, "_view", void 0);
935
+ _define_property6(this, "_handleChange", void 0);
580
936
  this._view = _view;
581
937
  this._handleChange = () => {
582
938
  syncer.reconcile(this._view, false);
583
939
  };
584
940
  accessor.handle.addListener("change", this._handleChange);
585
941
  }
586
- destroy() {
587
- accessor.handle.removeListener("change", this._handleChange);
588
- }
589
942
  }),
590
943
  // Reconcile local updates.
591
- EditorView2.updateListener.of(({ view, changes }) => {
944
+ EditorView4.updateListener.of(({ view, changes }) => {
592
945
  if (!changes.empty) {
593
946
  syncer.reconcile(view, true);
594
947
  }
@@ -598,9 +951,22 @@ var automerge = (accessor) => {
598
951
 
599
952
  // src/extensions/awareness/awareness.ts
600
953
  import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
601
- import { Decoration as Decoration2, EditorView as EditorView3, ViewPlugin as ViewPlugin3, WidgetType } from "@codemirror/view";
954
+ import { Decoration as Decoration3, EditorView as EditorView5, ViewPlugin as ViewPlugin5, WidgetType as WidgetType2 } from "@codemirror/view";
602
955
  import { Event } from "@dxos/async";
603
956
  import { Context } from "@dxos/context";
957
+ function _define_property7(obj, key, value) {
958
+ if (key in obj) {
959
+ Object.defineProperty(obj, key, {
960
+ value,
961
+ enumerable: true,
962
+ configurable: true,
963
+ writable: true
964
+ });
965
+ } else {
966
+ obj[key] = value;
967
+ }
968
+ return obj;
969
+ }
604
970
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
605
971
  var dummyProvider = {
606
972
  remoteStateChange: new Event(),
@@ -617,30 +983,13 @@ var RemoteSelectionChangedAnnotation = Annotation2.define();
617
983
  var awareness = (provider = dummyProvider) => {
618
984
  return [
619
985
  awarenessProvider.of(provider),
620
- ViewPlugin3.fromClass(RemoteSelectionsDecorator, {
986
+ ViewPlugin5.fromClass(RemoteSelectionsDecorator, {
621
987
  decorations: (value) => value.decorations
622
988
  }),
623
989
  styles
624
990
  ];
625
991
  };
626
992
  var RemoteSelectionsDecorator = class {
627
- constructor(view) {
628
- this._ctx = new Context(void 0, {
629
- F: __dxlog_file3,
630
- L: 80
631
- });
632
- this.decorations = RangeSet.of([]);
633
- this._cursorConverter = view.state.facet(Cursor.converter);
634
- this._provider = view.state.facet(awarenessProvider);
635
- this._provider.open();
636
- this._provider.remoteStateChange.on(this._ctx, () => {
637
- view.dispatch({
638
- annotations: [
639
- RemoteSelectionChangedAnnotation.of([])
640
- ]
641
- });
642
- });
643
- }
644
993
  destroy() {
645
994
  void this._ctx.dispose();
646
995
  this._provider.close();
@@ -681,7 +1030,7 @@ var RemoteSelectionsDecorator = class {
681
1030
  decorations2.push({
682
1031
  from: start,
683
1032
  to: end,
684
- value: Decoration2.mark({
1033
+ value: Decoration3.mark({
685
1034
  attributes: {
686
1035
  style: `background-color: ${lightColor}`
687
1036
  },
@@ -692,7 +1041,7 @@ var RemoteSelectionsDecorator = class {
692
1041
  decorations2.push({
693
1042
  from: start,
694
1043
  to: startLine.from + startLine.length,
695
- value: Decoration2.mark({
1044
+ value: Decoration3.mark({
696
1045
  attributes: {
697
1046
  style: `background-color: ${lightColor}`
698
1047
  },
@@ -702,7 +1051,7 @@ var RemoteSelectionsDecorator = class {
702
1051
  decorations2.push({
703
1052
  from: endLine.from,
704
1053
  to: end,
705
- value: Decoration2.mark({
1054
+ value: Decoration3.mark({
706
1055
  attributes: {
707
1056
  style: `background-color: ${lightColor}`
708
1057
  },
@@ -714,7 +1063,7 @@ var RemoteSelectionsDecorator = class {
714
1063
  decorations2.push({
715
1064
  from: linePos,
716
1065
  to: linePos,
717
- value: Decoration2.line({
1066
+ value: Decoration3.line({
718
1067
  attributes: {
719
1068
  style: `background-color: ${lightColor}`,
720
1069
  class: "cm-collab-selectionLine"
@@ -726,20 +1075,38 @@ var RemoteSelectionsDecorator = class {
726
1075
  decorations2.push({
727
1076
  from: head,
728
1077
  to: head,
729
- value: Decoration2.widget({
1078
+ value: Decoration3.widget({
730
1079
  side: head - anchor > 0 ? -1 : 1,
731
1080
  block: false,
732
1081
  widget: new RemoteCaretWidget(state.info.displayName ?? "Anonymous", darkColor)
733
1082
  })
734
1083
  });
735
1084
  }
736
- this.decorations = Decoration2.set(decorations2, true);
1085
+ this.decorations = Decoration3.set(decorations2, true);
737
1086
  }
738
- };
739
- var RemoteCaretWidget = class extends WidgetType {
740
- constructor(_name, _color) {
741
- super(), this._name = _name, this._color = _color;
1087
+ constructor(view) {
1088
+ _define_property7(this, "_ctx", new Context(void 0, {
1089
+ F: __dxlog_file3,
1090
+ L: 80
1091
+ }));
1092
+ _define_property7(this, "_cursorConverter", void 0);
1093
+ _define_property7(this, "_provider", void 0);
1094
+ _define_property7(this, "_lastAnchor", void 0);
1095
+ _define_property7(this, "_lastHead", void 0);
1096
+ _define_property7(this, "decorations", RangeSet.of([]));
1097
+ this._cursorConverter = view.state.facet(Cursor.converter);
1098
+ this._provider = view.state.facet(awarenessProvider);
1099
+ this._provider.open();
1100
+ this._provider.remoteStateChange.on(this._ctx, () => {
1101
+ view.dispatch({
1102
+ annotations: [
1103
+ RemoteSelectionChangedAnnotation.of([])
1104
+ ]
1105
+ });
1106
+ });
742
1107
  }
1108
+ };
1109
+ var RemoteCaretWidget = class extends WidgetType2 {
743
1110
  toDOM() {
744
1111
  const span = document.createElement("span");
745
1112
  span.className = "cm-collab-selectionCaret";
@@ -769,8 +1136,11 @@ var RemoteCaretWidget = class extends WidgetType {
769
1136
  ignoreEvent() {
770
1137
  return true;
771
1138
  }
1139
+ constructor(_name, _color) {
1140
+ super(), _define_property7(this, "_name", void 0), _define_property7(this, "_color", void 0), this._name = _name, this._color = _color;
1141
+ }
772
1142
  };
773
- var styles = EditorView3.theme({
1143
+ var styles = EditorView5.theme({
774
1144
  ".cm-collab-selection": {},
775
1145
  ".cm-collab-selectionLine": {
776
1146
  padding: 0,
@@ -833,17 +1203,22 @@ import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
833
1203
  import { Context as Context2 } from "@dxos/context";
834
1204
  import { invariant } from "@dxos/invariant";
835
1205
  import { log as log3 } from "@dxos/log";
1206
+ function _define_property8(obj, key, value) {
1207
+ if (key in obj) {
1208
+ Object.defineProperty(obj, key, {
1209
+ value,
1210
+ enumerable: true,
1211
+ configurable: true,
1212
+ writable: true
1213
+ });
1214
+ } else {
1215
+ obj[key] = value;
1216
+ }
1217
+ return obj;
1218
+ }
836
1219
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness-provider.ts";
837
1220
  var DEBOUNCE_INTERVAL = 100;
838
1221
  var SpaceAwarenessProvider = class {
839
- constructor(params) {
840
- this._remoteStates = /* @__PURE__ */ new Map();
841
- this.remoteStateChange = new Event2();
842
- this._space = params.space;
843
- this._channel = params.channel;
844
- this._peerId = params.peerId;
845
- this._info = params.info;
846
- }
847
1222
  open() {
848
1223
  this._ctx = new Context2(void 0, {
849
1224
  F: __dxlog_file4,
@@ -933,13 +1308,41 @@ var SpaceAwarenessProvider = class {
933
1308
  this._remoteStates.set(message.state.peerId, message.state);
934
1309
  this.remoteStateChange.emit();
935
1310
  }
1311
+ constructor(params) {
1312
+ _define_property8(this, "_remoteStates", /* @__PURE__ */ new Map());
1313
+ _define_property8(this, "_space", void 0);
1314
+ _define_property8(this, "_channel", void 0);
1315
+ _define_property8(this, "_peerId", void 0);
1316
+ _define_property8(this, "_info", void 0);
1317
+ _define_property8(this, "_ctx", void 0);
1318
+ _define_property8(this, "_postTask", void 0);
1319
+ _define_property8(this, "_localState", void 0);
1320
+ _define_property8(this, "remoteStateChange", new Event2());
1321
+ this._space = params.space;
1322
+ this._channel = params.channel;
1323
+ this._peerId = params.peerId;
1324
+ this._info = params.info;
1325
+ }
936
1326
  };
937
1327
 
938
1328
  // src/extensions/blast.ts
939
- import { EditorView as EditorView4, keymap as keymap2 } from "@codemirror/view";
1329
+ import { EditorView as EditorView6, keymap as keymap2 } from "@codemirror/view";
940
1330
  import defaultsDeep from "lodash.defaultsdeep";
941
1331
  import { throttle } from "@dxos/async";
942
1332
  import { invariant as invariant2 } from "@dxos/invariant";
1333
+ function _define_property9(obj, key, value) {
1334
+ if (key in obj) {
1335
+ Object.defineProperty(obj, key, {
1336
+ value,
1337
+ enumerable: true,
1338
+ configurable: true,
1339
+ writable: true
1340
+ });
1341
+ } else {
1342
+ obj[key] = value;
1343
+ }
1344
+ return obj;
1345
+ }
943
1346
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
944
1347
  var defaultOptions = {
945
1348
  effect: 2,
@@ -985,7 +1388,7 @@ var blast = (options = defaultOptions) => {
985
1388
  };
986
1389
  return [
987
1390
  // Cursor moved.
988
- EditorView4.updateListener.of((update2) => {
1391
+ EditorView6.updateListener.of((update2) => {
989
1392
  if (blaster?.node !== update2.view.scrollDOM) {
990
1393
  if (blaster) {
991
1394
  blaster.destroy();
@@ -1034,34 +1437,6 @@ var blast = (options = defaultOptions) => {
1034
1437
  ];
1035
1438
  };
1036
1439
  var Blaster = class {
1037
- constructor(_node, _options) {
1038
- this._node = _node;
1039
- this._options = _options;
1040
- this._running = false;
1041
- this._shakeTime = 0;
1042
- this._shakeTimeMax = 0;
1043
- this._particles = [];
1044
- this._particlePointer = 0;
1045
- this._lastPoint = {
1046
- x: 0,
1047
- y: 0
1048
- };
1049
- this.shake = throttle(({ time }) => {
1050
- this._shakeTime = this._shakeTimeMax || time;
1051
- this._shakeTimeMax = time;
1052
- }, 100);
1053
- this.spawn = throttle(({ element, point }) => {
1054
- const color = getRGBComponents(element, this._options.color);
1055
- const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
1056
- const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
1057
- this._lastPoint = point;
1058
- for (let i = numParticles; i--; i > 0) {
1059
- this._particles[this._particlePointer] = this._effect.create(point.x - dir * 16, point.y, color);
1060
- this._particlePointer = (this._particlePointer + 1) % this._options.maxParticles;
1061
- }
1062
- }, 100);
1063
- this._effect = this._options.effect === 1 ? new Effect1(_options) : new Effect2(_options);
1064
- }
1065
1440
  get node() {
1066
1441
  return this._node;
1067
1442
  }
@@ -1125,7 +1500,7 @@ var Blaster = class {
1125
1500
  }
1126
1501
  this._ctx.clearRect(0, 0, this._canvas.width ?? 0, this._canvas.height ?? 0);
1127
1502
  const now = (/* @__PURE__ */ new Date()).getTime();
1128
- this._lastTime ??= now;
1503
+ this._lastTime ?? (this._lastTime = now);
1129
1504
  const dt = (now - this._lastTime) / 1e3;
1130
1505
  this._lastTime = now;
1131
1506
  if (this._shakeTime > 0) {
@@ -1150,9 +1525,52 @@ var Blaster = class {
1150
1525
  this._effect.update(this._ctx, particle);
1151
1526
  }
1152
1527
  }
1528
+ constructor(_node, _options) {
1529
+ _define_property9(this, "_node", void 0);
1530
+ _define_property9(this, "_options", void 0);
1531
+ _define_property9(this, "_effect", void 0);
1532
+ _define_property9(this, "_canvas", void 0);
1533
+ _define_property9(this, "_ctx", void 0);
1534
+ _define_property9(this, "_running", void 0);
1535
+ _define_property9(this, "_lastTime", void 0);
1536
+ _define_property9(this, "_shakeTime", void 0);
1537
+ _define_property9(this, "_shakeTimeMax", void 0);
1538
+ _define_property9(this, "_particles", void 0);
1539
+ _define_property9(this, "_particlePointer", void 0);
1540
+ _define_property9(this, "_lastPoint", void 0);
1541
+ _define_property9(this, "shake", void 0);
1542
+ _define_property9(this, "spawn", void 0);
1543
+ this._node = _node;
1544
+ this._options = _options;
1545
+ this._running = false;
1546
+ this._shakeTime = 0;
1547
+ this._shakeTimeMax = 0;
1548
+ this._particles = [];
1549
+ this._particlePointer = 0;
1550
+ this._lastPoint = {
1551
+ x: 0,
1552
+ y: 0
1553
+ };
1554
+ this.shake = throttle(({ time }) => {
1555
+ this._shakeTime = this._shakeTimeMax || time;
1556
+ this._shakeTimeMax = time;
1557
+ }, 100);
1558
+ this.spawn = throttle(({ element, point }) => {
1559
+ const color = getRGBComponents(element, this._options.color);
1560
+ const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
1561
+ const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
1562
+ this._lastPoint = point;
1563
+ for (let i = numParticles; i--; i > 0) {
1564
+ this._particles[this._particlePointer] = this._effect.create(point.x - dir * 16, point.y, color);
1565
+ this._particlePointer = (this._particlePointer + 1) % this._options.maxParticles;
1566
+ }
1567
+ }, 100);
1568
+ this._effect = this._options.effect === 1 ? new Effect1(_options) : new Effect2(_options);
1569
+ }
1153
1570
  };
1154
1571
  var Effect = class {
1155
1572
  constructor(_options) {
1573
+ _define_property9(this, "_options", void 0);
1156
1574
  this._options = _options;
1157
1575
  }
1158
1576
  };
@@ -1235,7 +1653,7 @@ var random = (min, max) => {
1235
1653
  };
1236
1654
 
1237
1655
  // src/extensions/command/action.ts
1238
- import { StateEffect as StateEffect2 } from "@codemirror/state";
1656
+ import { StateEffect as StateEffect3 } from "@codemirror/state";
1239
1657
 
1240
1658
  // src/extensions/command/state.ts
1241
1659
  import { StateField as StateField2 } from "@codemirror/state";
@@ -1308,8 +1726,8 @@ var commandState = StateField2.define({
1308
1726
  });
1309
1727
 
1310
1728
  // src/extensions/command/action.ts
1311
- var openEffect = StateEffect2.define();
1312
- var closeEffect = StateEffect2.define();
1729
+ var openEffect = StateEffect3.define();
1730
+ var closeEffect = StateEffect3.define();
1313
1731
  var openCommand = (view) => {
1314
1732
  if (view.state.field(commandState, false)) {
1315
1733
  const selection = view.state.selection.main;
@@ -1338,7 +1756,6 @@ var closeCommand = (view) => {
1338
1756
  var commandKeyBindings = [
1339
1757
  {
1340
1758
  key: "/",
1341
- preventDefault: true,
1342
1759
  run: openCommand
1343
1760
  },
1344
1761
  {
@@ -1348,18 +1765,28 @@ var commandKeyBindings = [
1348
1765
  ];
1349
1766
 
1350
1767
  // src/extensions/command/command.ts
1351
- import { Prec } from "@codemirror/state";
1352
- import { EditorView as EditorView6, keymap as keymap3 } from "@codemirror/view";
1768
+ import { Prec as Prec2 } from "@codemirror/state";
1769
+ import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
1353
1770
  import { isNonNullable } from "@dxos/util";
1354
1771
 
1355
1772
  // src/extensions/command/hint.ts
1356
1773
  import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
1357
- import { Decoration as Decoration3, EditorView as EditorView5, ViewPlugin as ViewPlugin4, WidgetType as WidgetType2 } from "@codemirror/view";
1774
+ import { Decoration as Decoration4, EditorView as EditorView7, ViewPlugin as ViewPlugin6, WidgetType as WidgetType3 } from "@codemirror/view";
1775
+ function _define_property10(obj, key, value) {
1776
+ if (key in obj) {
1777
+ Object.defineProperty(obj, key, {
1778
+ value,
1779
+ enumerable: true,
1780
+ configurable: true,
1781
+ writable: true
1782
+ });
1783
+ } else {
1784
+ obj[key] = value;
1785
+ }
1786
+ return obj;
1787
+ }
1358
1788
  var hint = ({ delay = 3e3, onHint }) => {
1359
- return ViewPlugin4.fromClass(class {
1360
- constructor() {
1361
- this.decorations = Decoration3.none;
1362
- }
1789
+ return ViewPlugin6.fromClass(class {
1363
1790
  update(update2) {
1364
1791
  if (this.timeout) {
1365
1792
  clearTimeout(this.timeout);
@@ -1375,7 +1802,7 @@ var hint = ({ delay = 3e3, onHint }) => {
1375
1802
  const hint2 = onHint?.();
1376
1803
  if (hint2) {
1377
1804
  const builder2 = new RangeSetBuilder2();
1378
- builder2.add(selection.from, selection.to, Decoration3.widget({
1805
+ builder2.add(selection.from, selection.to, Decoration4.widget({
1379
1806
  widget: new Hint(hint2)
1380
1807
  }));
1381
1808
  this.decorations = builder2.finish();
@@ -1391,16 +1818,17 @@ var hint = ({ delay = 3e3, onHint }) => {
1391
1818
  clearTimeout(this.timeout);
1392
1819
  }
1393
1820
  }
1821
+ constructor() {
1822
+ _define_property10(this, "decorations", Decoration4.none);
1823
+ _define_property10(this, "timeout", void 0);
1824
+ }
1394
1825
  }, {
1395
1826
  provide: (plugin) => [
1396
- EditorView5.decorations.of((view) => view.plugin(plugin)?.decorations ?? Decoration3.none)
1827
+ EditorView7.decorations.of((view) => view.plugin(plugin)?.decorations ?? Decoration4.none)
1397
1828
  ]
1398
1829
  });
1399
1830
  };
1400
- var Hint = class extends WidgetType2 {
1401
- constructor(content) {
1402
- super(), this.content = content;
1403
- }
1831
+ var Hint = class extends WidgetType3 {
1404
1832
  toDOM() {
1405
1833
  const wrap = document.createElement("span");
1406
1834
  wrap.className = "cm-placeholder";
@@ -1420,13 +1848,13 @@ var Hint = class extends WidgetType2 {
1420
1848
  }
1421
1849
  const style = window.getComputedStyle(dom.parentNode);
1422
1850
  const rect = flattenRect(rects[0], style.direction !== "rtl");
1423
- const lineHeight = parseInt(style.lineHeight);
1424
- if (rect.bottom - rect.top > lineHeight * 1.5) {
1851
+ const lineHeight2 = parseInt(style.lineHeight);
1852
+ if (rect.bottom - rect.top > lineHeight2 * 1.5) {
1425
1853
  return {
1426
1854
  left: rect.left,
1427
1855
  right: rect.right,
1428
1856
  top: rect.top,
1429
- bottom: rect.top + lineHeight
1857
+ bottom: rect.top + lineHeight2
1430
1858
  };
1431
1859
  }
1432
1860
  return rect;
@@ -1434,17 +1862,20 @@ var Hint = class extends WidgetType2 {
1434
1862
  ignoreEvent() {
1435
1863
  return false;
1436
1864
  }
1865
+ constructor(content) {
1866
+ super(), _define_property10(this, "content", void 0), this.content = content;
1867
+ }
1437
1868
  };
1438
1869
 
1439
1870
  // src/extensions/command/command.ts
1440
1871
  var command = (options = {}) => {
1441
1872
  return [
1442
- Prec.highest(keymap3.of(commandKeyBindings)),
1873
+ Prec2.highest(keymap3.of(commandKeyBindings)),
1443
1874
  commandConfig.of(options),
1444
1875
  commandState,
1445
1876
  options.onHint && hint(options),
1446
- EditorView6.focusChangeEffect.of((_, focusing) => focusing ? closeEffect.of(null) : null),
1447
- EditorView6.theme({
1877
+ EditorView8.focusChangeEffect.of((_, focusing) => focusing ? closeEffect.of(null) : null),
1878
+ EditorView8.theme({
1448
1879
  ".cm-tooltip": {
1449
1880
  background: "transparent"
1450
1881
  }
@@ -1453,16 +1884,26 @@ var command = (options = {}) => {
1453
1884
  };
1454
1885
 
1455
1886
  // src/extensions/command/command-menu.ts
1456
- import { RangeSetBuilder as RangeSetBuilder3, StateField as StateField3, StateEffect as StateEffect3, Prec as Prec2 } from "@codemirror/state";
1457
- import { EditorView as EditorView8, ViewPlugin as ViewPlugin6, Decoration as Decoration5, keymap as keymap4 } from "@codemirror/view";
1887
+ import { Prec as Prec3, RangeSetBuilder as RangeSetBuilder3, StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
1888
+ import { Decoration as Decoration6, EditorView as EditorView10, ViewPlugin as ViewPlugin8, keymap as keymap4 } from "@codemirror/view";
1458
1889
 
1459
1890
  // src/extensions/command/placeholder.ts
1460
- import { Decoration as Decoration4, EditorView as EditorView7, WidgetType as WidgetType3, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
1891
+ import { Decoration as Decoration5, EditorView as EditorView9, ViewPlugin as ViewPlugin7, WidgetType as WidgetType4 } from "@codemirror/view";
1892
+ function _define_property11(obj, key, value) {
1893
+ if (key in obj) {
1894
+ Object.defineProperty(obj, key, {
1895
+ value,
1896
+ enumerable: true,
1897
+ configurable: true,
1898
+ writable: true
1899
+ });
1900
+ } else {
1901
+ obj[key] = value;
1902
+ }
1903
+ return obj;
1904
+ }
1461
1905
  var placeholder = ({ delay = 3e3, content }) => {
1462
- const plugin = ViewPlugin5.fromClass(class {
1463
- constructor() {
1464
- this.decorations = Decoration4.none;
1465
- }
1906
+ const plugin = ViewPlugin7.fromClass(class {
1466
1907
  update(update2) {
1467
1908
  if (this.timeout) {
1468
1909
  window.clearTimeout(this.timeout);
@@ -1473,8 +1914,8 @@ var placeholder = ({ delay = 3e3, content }) => {
1473
1914
  if (isEmpty) {
1474
1915
  const lineStart = activeLine.from;
1475
1916
  this.timeout = setTimeout(() => {
1476
- this.decorations = Decoration4.set([
1477
- Decoration4.widget({
1917
+ this.decorations = Decoration5.set([
1918
+ Decoration5.widget({
1478
1919
  widget: new Placeholder(content),
1479
1920
  side: 1
1480
1921
  }).range(lineStart)
@@ -1482,31 +1923,32 @@ var placeholder = ({ delay = 3e3, content }) => {
1482
1923
  update2.view.update([]);
1483
1924
  }, delay);
1484
1925
  }
1485
- this.decorations = Decoration4.none;
1926
+ this.decorations = Decoration5.none;
1486
1927
  }
1487
1928
  destroy() {
1488
1929
  if (this.timeout) {
1489
1930
  clearTimeout(this.timeout);
1490
1931
  }
1491
1932
  }
1933
+ constructor() {
1934
+ _define_property11(this, "decorations", Decoration5.none);
1935
+ _define_property11(this, "timeout", void 0);
1936
+ }
1492
1937
  }, {
1493
1938
  provide: (plugin2) => {
1494
1939
  return [
1495
- EditorView7.decorations.of((view) => view.plugin(plugin2)?.decorations ?? Decoration4.none)
1940
+ EditorView9.decorations.of((view) => view.plugin(plugin2)?.decorations ?? Decoration5.none)
1496
1941
  ];
1497
1942
  }
1498
1943
  });
1499
1944
  return typeof content === "string" ? [
1500
1945
  plugin,
1501
- EditorView7.contentAttributes.of({
1946
+ EditorView9.contentAttributes.of({
1502
1947
  "aria-placeholder": content
1503
1948
  })
1504
1949
  ] : plugin;
1505
1950
  };
1506
- var Placeholder = class extends WidgetType3 {
1507
- constructor(content) {
1508
- super(), this.content = content;
1509
- }
1951
+ var Placeholder = class extends WidgetType4 {
1510
1952
  toDOM(view) {
1511
1953
  const wrap = document.createElement("span");
1512
1954
  wrap.className = "cm-placeholder";
@@ -1522,13 +1964,13 @@ var Placeholder = class extends WidgetType3 {
1522
1964
  }
1523
1965
  const style = window.getComputedStyle(dom.parentNode);
1524
1966
  const rect = flattenRect(rects[0], style.direction !== "rtl");
1525
- const lineHeight = parseInt(style.lineHeight);
1526
- if (rect.bottom - rect.top > lineHeight * 1.5) {
1967
+ const lineHeight2 = parseInt(style.lineHeight);
1968
+ if (rect.bottom - rect.top > lineHeight2 * 1.5) {
1527
1969
  return {
1528
1970
  left: rect.left,
1529
1971
  right: rect.right,
1530
1972
  top: rect.top,
1531
- bottom: rect.top + lineHeight
1973
+ bottom: rect.top + lineHeight2
1532
1974
  };
1533
1975
  }
1534
1976
  return rect;
@@ -1536,15 +1978,27 @@ var Placeholder = class extends WidgetType3 {
1536
1978
  ignoreEvent() {
1537
1979
  return false;
1538
1980
  }
1981
+ constructor(content) {
1982
+ super(), _define_property11(this, "content", void 0), this.content = content;
1983
+ }
1539
1984
  };
1540
1985
 
1541
1986
  // src/extensions/command/command-menu.ts
1987
+ function _define_property12(obj, key, value) {
1988
+ if (key in obj) {
1989
+ Object.defineProperty(obj, key, {
1990
+ value,
1991
+ enumerable: true,
1992
+ configurable: true,
1993
+ writable: true
1994
+ });
1995
+ } else {
1996
+ obj[key] = value;
1997
+ }
1998
+ return obj;
1999
+ }
1542
2000
  var commandMenu = (options) => {
1543
- const commandMenuPlugin = ViewPlugin6.fromClass(class {
1544
- constructor(view) {
1545
- this.view = view;
1546
- this.decorations = Decoration5.none;
1547
- }
2001
+ const commandMenuPlugin = ViewPlugin8.fromClass(class {
1548
2002
  // TODO(wittjosiah): The decorations are repainted on every update, this occasionally causes menu to flicker.
1549
2003
  update(update2) {
1550
2004
  const builder = new RangeSetBuilder3();
@@ -1552,9 +2006,9 @@ var commandMenu = (options) => {
1552
2006
  const { range: activeRange, trigger } = update2.view.state.field(commandMenuState) ?? {};
1553
2007
  const shouldShowWidget = activeRange && selection.head >= activeRange.from && selection.head <= activeRange.to;
1554
2008
  if (shouldShowWidget) {
1555
- builder.add(activeRange.from, activeRange.to, Decoration5.mark({
1556
- tagName: "dx-ref-tag",
1557
- class: "cm-ref-tag",
2009
+ builder.add(activeRange.from, activeRange.to, Decoration6.mark({
2010
+ tagName: "dx-anchor",
2011
+ class: "cm-floating-menu-trigger",
1558
2012
  attributes: {
1559
2013
  "data-auto-trigger": "true",
1560
2014
  "data-trigger": trigger
@@ -1568,6 +2022,12 @@ var commandMenu = (options) => {
1568
2022
  }
1569
2023
  this.decorations = builder.finish();
1570
2024
  }
2025
+ constructor(view) {
2026
+ _define_property12(this, "view", void 0);
2027
+ _define_property12(this, "decorations", void 0);
2028
+ this.view = view;
2029
+ this.decorations = Decoration6.none;
2030
+ }
1571
2031
  }, {
1572
2032
  decorations: (v) => v.decorations
1573
2033
  });
@@ -1645,7 +2105,7 @@ var commandMenu = (options) => {
1645
2105
  }
1646
2106
  }
1647
2107
  ]);
1648
- const updateListener = EditorView8.updateListener.of((update2) => {
2108
+ const updateListener = EditorView10.updateListener.of((update2) => {
1649
2109
  const { trigger, range: activeRange } = update2.view.state.field(commandMenuState) ?? {};
1650
2110
  if (!activeRange || !trigger) {
1651
2111
  return;
@@ -1672,7 +2132,7 @@ var commandMenu = (options) => {
1672
2132
  }
1673
2133
  });
1674
2134
  return [
1675
- Prec2.highest(commandKeymap),
2135
+ Prec3.highest(commandKeymap),
1676
2136
  placeholder(Object.assign({
1677
2137
  content: `Press '${Array.isArray(options.trigger) ? options.trigger[0] : options.trigger}' for commands`
1678
2138
  }, options.placeholder)),
@@ -1681,7 +2141,7 @@ var commandMenu = (options) => {
1681
2141
  commandMenuPlugin
1682
2142
  ];
1683
2143
  };
1684
- var commandRangeEffect = StateEffect3.define();
2144
+ var commandRangeEffect = StateEffect4.define();
1685
2145
  var commandMenuState = StateField3.define({
1686
2146
  create: () => null,
1687
2147
  update: (value, tr) => {
@@ -1696,30 +2156,23 @@ var commandMenuState = StateField3.define({
1696
2156
  });
1697
2157
 
1698
2158
  // src/extensions/command/floating-menu.ts
1699
- import { EditorView as EditorView9, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
2159
+ import { EditorView as EditorView11, ViewPlugin as ViewPlugin9 } from "@codemirror/view";
1700
2160
  import { addEventListener } from "@dxos/async";
2161
+ function _define_property13(obj, key, value) {
2162
+ if (key in obj) {
2163
+ Object.defineProperty(obj, key, {
2164
+ value,
2165
+ enumerable: true,
2166
+ configurable: true,
2167
+ writable: true
2168
+ });
2169
+ } else {
2170
+ obj[key] = value;
2171
+ }
2172
+ return obj;
2173
+ }
1701
2174
  var floatingMenu = (options = {}) => [
1702
- ViewPlugin7.fromClass(class {
1703
- constructor(view) {
1704
- this.view = view;
1705
- const container = view.scrollDOM;
1706
- if (getComputedStyle(container).position === "static") {
1707
- container.style.position = "relative";
1708
- }
1709
- {
1710
- const icon = document.createElement("dx-icon");
1711
- icon.setAttribute("icon", options.icon ?? "ph--dots-three-vertical--regular");
1712
- const button = document.createElement("button");
1713
- button.appendChild(icon);
1714
- this.tag = document.createElement("dx-ref-tag");
1715
- this.tag.classList.add("cm-ref-tag");
1716
- this.tag.appendChild(button);
1717
- }
1718
- container.appendChild(this.tag);
1719
- const handler = () => this.scheduleUpdate();
1720
- this.cleanup = addEventListener(container, "scroll", handler);
1721
- this.scheduleUpdate();
1722
- }
2175
+ ViewPlugin9.fromClass(class {
1723
2176
  destroy() {
1724
2177
  this.cleanup?.();
1725
2178
  this.tag.remove();
@@ -1736,7 +2189,7 @@ var floatingMenu = (options = {}) => [
1736
2189
  this.tag.style.display = "none";
1737
2190
  this.tag.classList.add("opacity-10");
1738
2191
  } else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
1739
- this.tag.style.display = "block";
2192
+ this.tag.style.display = "";
1740
2193
  } else if (update2.docChanged || update2.focusChanged || update2.geometryChanged || update2.selectionSet || update2.viewportChanged) {
1741
2194
  this.scheduleUpdate();
1742
2195
  }
@@ -1749,13 +2202,13 @@ var floatingMenu = (options = {}) => [
1749
2202
  if (!coords) {
1750
2203
  return;
1751
2204
  }
1752
- const lineHeight = coords.bottom - coords.top;
1753
- const dy = (lineHeight - (options.height ?? 32)) / 2;
2205
+ const lineHeight2 = coords.bottom - coords.top;
2206
+ const dy = (lineHeight2 - (options.height ?? 32)) / 2;
1754
2207
  const offsetTop = coords.top + dy;
1755
2208
  const offsetLeft = x + width + (options.padding ?? 8);
1756
2209
  this.tag.style.top = `${offsetTop}px`;
1757
2210
  this.tag.style.left = `${offsetLeft}px`;
1758
- this.tag.style.display = "block";
2211
+ this.tag.style.display = "";
1759
2212
  }
1760
2213
  scheduleUpdate() {
1761
2214
  if (this.rafId != null) {
@@ -1763,30 +2216,62 @@ var floatingMenu = (options = {}) => [
1763
2216
  }
1764
2217
  this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
1765
2218
  }
2219
+ constructor(view) {
2220
+ _define_property13(this, "view", void 0);
2221
+ _define_property13(this, "tag", void 0);
2222
+ _define_property13(this, "rafId", void 0);
2223
+ _define_property13(this, "cleanup", void 0);
2224
+ this.view = view;
2225
+ const container = view.scrollDOM;
2226
+ if (getComputedStyle(container).position === "static") {
2227
+ container.style.position = "relative";
2228
+ }
2229
+ {
2230
+ const icon = document.createElement("dx-icon");
2231
+ icon.setAttribute("icon", options.icon ?? "ph--dots-three-vertical--regular");
2232
+ this.tag = document.createElement("dx-anchor");
2233
+ this.tag.classList.add("cm-floating-menu-trigger");
2234
+ this.tag.appendChild(icon);
2235
+ }
2236
+ container.appendChild(this.tag);
2237
+ const handler = () => this.scheduleUpdate();
2238
+ this.cleanup = addEventListener(container, "scroll", handler);
2239
+ this.scheduleUpdate();
2240
+ }
1766
2241
  }),
1767
- EditorView9.theme({
1768
- ".cm-ref-tag": {
2242
+ EditorView11.theme({
2243
+ ".cm-floating-menu-trigger": {
1769
2244
  position: "fixed",
1770
2245
  padding: "0",
1771
2246
  border: "none",
1772
- opacity: "0"
1773
- },
1774
- "[data-has-focus] & .cm-ref-tag": {
1775
- opacity: "1"
1776
- },
1777
- ".cm-ref-tag button": {
2247
+ opacity: "0",
1778
2248
  display: "grid",
1779
- alignItems: "center",
1780
- justifyContent: "center",
2249
+ placeContent: "center",
1781
2250
  width: "2rem",
1782
2251
  height: "2rem"
2252
+ },
2253
+ "&:focus-within .cm-floating-menu-trigger": {
2254
+ opacity: "1"
1783
2255
  }
1784
2256
  })
1785
2257
  ];
1786
2258
 
1787
2259
  // 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";
2260
+ import { EditorSelection, Prec as Prec4, RangeSetBuilder as RangeSetBuilder4 } from "@codemirror/state";
2261
+ import { Decoration as Decoration7, ViewPlugin as ViewPlugin10, keymap as keymap5 } from "@codemirror/view";
2262
+ function _define_property14(obj, key, value) {
2263
+ if (key in obj) {
2264
+ Object.defineProperty(obj, key, {
2265
+ value,
2266
+ enumerable: true,
2267
+ configurable: true,
2268
+ writable: true
2269
+ });
2270
+ } else {
2271
+ obj[key] = value;
2272
+ }
2273
+ return obj;
2274
+ }
1790
2275
  var typeahead = ({ onComplete } = {}) => {
1791
2276
  let hint2;
1792
2277
  const complete = (view) => {
@@ -1807,10 +2292,7 @@ var typeahead = ({ onComplete } = {}) => {
1807
2292
  return true;
1808
2293
  };
1809
2294
  return [
1810
- ViewPlugin8.fromClass(class {
1811
- constructor() {
1812
- this.decorations = Decoration6.none;
1813
- }
2295
+ ViewPlugin10.fromClass(class {
1814
2296
  update(update2) {
1815
2297
  const builder = new RangeSetBuilder4();
1816
2298
  const selection = update2.view.state.selection.main;
@@ -1821,18 +2303,21 @@ var typeahead = ({ onComplete } = {}) => {
1821
2303
  line: str
1822
2304
  });
1823
2305
  if (hint2) {
1824
- builder.add(selection.from, selection.to, Decoration6.widget({
2306
+ builder.add(selection.from, selection.to, Decoration7.widget({
1825
2307
  widget: new Hint(hint2)
1826
2308
  }));
1827
2309
  }
1828
2310
  }
1829
2311
  this.decorations = builder.finish();
1830
2312
  }
2313
+ constructor() {
2314
+ _define_property14(this, "decorations", Decoration7.none);
2315
+ }
1831
2316
  }, {
1832
2317
  decorations: (v) => v.decorations
1833
2318
  }),
1834
2319
  // Keys.
1835
- Prec3.highest(keymap5.of([
2320
+ Prec4.highest(keymap5.of([
1836
2321
  {
1837
2322
  key: "Tab",
1838
2323
  preventDefault: true,
@@ -1872,7 +2357,6 @@ var matchCompletion = (completion, str, minLength = 0) => {
1872
2357
  // src/extensions/command/useCommandMenu.ts
1873
2358
  import { useCallback, useMemo, useRef, useState } from "react";
1874
2359
  var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu }) => {
1875
- const triggerRef = useRef(null);
1876
2360
  const currentRef = useRef(null);
1877
2361
  const groupsRef = useRef([]);
1878
2362
  const [currentItem, setCurrentItem] = useState();
@@ -1884,7 +2368,6 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1884
2368
  }
1885
2369
  setOpen(open2);
1886
2370
  if (!open2) {
1887
- triggerRef.current = null;
1888
2371
  setCurrentItem(void 0);
1889
2372
  viewRef.current?.dispatch({
1890
2373
  effects: [
@@ -1900,7 +2383,6 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1900
2383
  if (item) {
1901
2384
  currentRef.current = item;
1902
2385
  }
1903
- triggerRef.current = event.trigger;
1904
2386
  const triggerKey = event.trigger.getAttribute("data-trigger");
1905
2387
  if (!open && triggerKey) {
1906
2388
  await handleOpenChange(true, triggerKey);
@@ -1918,7 +2400,7 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1918
2400
  void item.onSelect?.(view, selection.head);
1919
2401
  }, []);
1920
2402
  const serializedTrigger = Array.isArray(trigger) ? trigger.join(",") : trigger;
1921
- const _commandMenu = useMemo(() => {
2403
+ const memoizedCommandMenu = useMemo(() => {
1922
2404
  return commandMenu({
1923
2405
  trigger,
1924
2406
  placeholder: placeholder3,
@@ -1959,10 +2441,9 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1959
2441
  placeholder3
1960
2442
  ]);
1961
2443
  return {
1962
- commandMenu: _commandMenu,
2444
+ commandMenu: memoizedCommandMenu,
1963
2445
  currentItem,
1964
2446
  groupsRef,
1965
- ref: triggerRef,
1966
2447
  open,
1967
2448
  onActivate: handleActivate,
1968
2449
  onOpenChange: setOpen,
@@ -1972,8 +2453,8 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
1972
2453
 
1973
2454
  // src/extensions/comments.ts
1974
2455
  import { invertedEffects } from "@codemirror/commands";
1975
- import { StateEffect as StateEffect4, StateField as StateField4 } from "@codemirror/state";
1976
- import { hoverTooltip, keymap as keymap7, Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin9 } from "@codemirror/view";
2456
+ import { StateEffect as StateEffect5, StateField as StateField4 } from "@codemirror/state";
2457
+ import { Decoration as Decoration8, EditorView as EditorView13, ViewPlugin as ViewPlugin11, hoverTooltip, keymap as keymap7 } from "@codemirror/view";
1977
2458
  import sortBy from "lodash.sortby";
1978
2459
  import { useEffect } from "react";
1979
2460
  import { debounce as debounce2 } from "@dxos/async";
@@ -1982,7 +2463,7 @@ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1982
2463
 
1983
2464
  // src/extensions/selection.ts
1984
2465
  import { Transaction } from "@codemirror/state";
1985
- import { EditorView as EditorView10, keymap as keymap6 } from "@codemirror/view";
2466
+ import { EditorView as EditorView12, keymap as keymap6 } from "@codemirror/view";
1986
2467
  import { debounce } from "@dxos/async";
1987
2468
  import { invariant as invariant3 } from "@dxos/invariant";
1988
2469
  import { isNotFalsy } from "@dxos/util";
@@ -1993,7 +2474,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
1993
2474
  return {
1994
2475
  selection,
1995
2476
  scrollIntoView: !scrollTo,
1996
- effects: scrollTo ? EditorView10.scrollIntoView(scrollTo, {
2477
+ effects: scrollTo ? EditorView12.scrollIntoView(scrollTo, {
1997
2478
  yMargin: 96
1998
2479
  }) : void 0,
1999
2480
  annotations: Transaction.userEvent.of(stateRestoreAnnotation)
@@ -2035,7 +2516,7 @@ var selectionState = ({ getState, setState } = {}) => {
2035
2516
  // setStateDebounced(id, {});
2036
2517
  // },
2037
2518
  // }),
2038
- EditorView10.updateListener.of(({ view, transactions }) => {
2519
+ EditorView12.updateListener.of(({ view, transactions }) => {
2039
2520
  const id = view.state.facet(documentId);
2040
2521
  if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
2041
2522
  return;
@@ -2074,10 +2555,23 @@ var selectionState = ({ getState, setState } = {}) => {
2074
2555
  };
2075
2556
 
2076
2557
  // src/extensions/comments.ts
2558
+ function _define_property15(obj, key, value) {
2559
+ if (key in obj) {
2560
+ Object.defineProperty(obj, key, {
2561
+ value,
2562
+ enumerable: true,
2563
+ configurable: true,
2564
+ writable: true
2565
+ });
2566
+ } else {
2567
+ obj[key] = value;
2568
+ }
2569
+ return obj;
2570
+ }
2077
2571
  var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/comments.ts";
2078
- var setComments = StateEffect4.define();
2079
- var setSelection = StateEffect4.define();
2080
- var setCommentState = StateEffect4.define();
2572
+ var setComments = StateEffect5.define();
2573
+ var setSelection = StateEffect5.define();
2574
+ var setCommentState = StateEffect5.define();
2081
2575
  var commentsState = StateField4.define({
2082
2576
  create: (state) => ({
2083
2577
  id: state.facet(documentId),
@@ -2116,27 +2610,27 @@ var commentsState = StateField4.define({
2116
2610
  return value;
2117
2611
  }
2118
2612
  });
2119
- var styles2 = EditorView11.theme({
2613
+ var styles2 = EditorView13.theme({
2120
2614
  ".cm-comment, .cm-comment-current": {
2121
- margin: "0 -3px",
2122
- padding: "3px",
2123
- borderRadius: "3px",
2615
+ padding: "3px 0",
2616
+ backgroundColor: "var(--dx-cmCommentSurface)"
2617
+ },
2618
+ ".cm-comment > span, .cm-comment-current > span": {
2619
+ boxDecorationBreak: "clone",
2620
+ boxShadow: "0 0 1px 3px var(--dx-cmCommentSurface)",
2124
2621
  backgroundColor: "var(--dx-cmCommentSurface)",
2125
2622
  color: "var(--dx-cmComment)",
2126
2623
  cursor: "pointer"
2127
- },
2128
- ".cm-comment:hover, .cm-comment-current": {
2129
- textDecoration: "underline"
2130
2624
  }
2131
2625
  });
2132
- var createCommentMark = (id, isCurrent) => Decoration7.mark({
2626
+ var createCommentMark = (id, isCurrent) => Decoration8.mark({
2133
2627
  class: isCurrent ? "cm-comment-current" : "cm-comment",
2134
2628
  attributes: {
2135
2629
  "data-testid": "cm-comment",
2136
2630
  "data-comment-id": id
2137
2631
  }
2138
2632
  });
2139
- var commentsDecorations = EditorView11.decorations.compute([
2633
+ var commentsDecorations = EditorView13.decorations.compute([
2140
2634
  commentsState
2141
2635
  ], (state) => {
2142
2636
  const { selection: { current }, comments: comments2 } = state.field(commentsState);
@@ -2145,7 +2639,7 @@ var commentsDecorations = EditorView11.decorations.compute([
2145
2639
  if (!range) {
2146
2640
  log4.warn("Invalid range:", range, {
2147
2641
  F: __dxlog_file7,
2148
- L: 135,
2642
+ L: 140,
2149
2643
  S: void 0,
2150
2644
  C: (f, a) => f(...a)
2151
2645
  });
@@ -2156,10 +2650,10 @@ var commentsDecorations = EditorView11.decorations.compute([
2156
2650
  const mark = createCommentMark(comment.comment.id, comment.comment.id === current);
2157
2651
  return mark.range(range.from, range.to);
2158
2652
  }).filter(isNonNullable2);
2159
- return Decoration7.set(decorations2);
2653
+ return Decoration8.set(decorations2);
2160
2654
  });
2161
- var commentClickedEffect = StateEffect4.define();
2162
- var handleCommentClick = EditorView11.domEventHandlers({
2655
+ var commentClickedEffect = StateEffect5.define();
2656
+ var handleCommentClick = EditorView13.domEventHandlers({
2163
2657
  click: (event, view) => {
2164
2658
  let target = event.target;
2165
2659
  const editorRoot = view.dom;
@@ -2198,7 +2692,7 @@ var trackPastedComments = (onUpdate) => {
2198
2692
  }
2199
2693
  };
2200
2694
  return [
2201
- EditorView11.domEventHandlers({
2695
+ EditorView13.domEventHandlers({
2202
2696
  cut: handleTrack,
2203
2697
  copy: handleTrack
2204
2698
  }),
@@ -2220,7 +2714,7 @@ var trackPastedComments = (onUpdate) => {
2220
2714
  return effects;
2221
2715
  }),
2222
2716
  // Handle paste or the undo of comment deletion.
2223
- EditorView11.updateListener.of((update2) => {
2717
+ EditorView13.updateListener.of((update2) => {
2224
2718
  const restore = [];
2225
2719
  for (let i = 0; i < update2.transactions.length; i++) {
2226
2720
  const tr = update2.transactions[i];
@@ -2261,10 +2755,10 @@ var trackPastedComments = (onUpdate) => {
2261
2755
  const { comments: comments2 } = update2.startState.field(commentsState);
2262
2756
  const exists = comments2.some((c) => c.comment.id === comment.id && c.range.from < c.range.to);
2263
2757
  if (!exists) {
2264
- const cursor = Cursor.getCursorFromRange(update2.state, comment);
2758
+ const cursor2 = Cursor.getCursorFromRange(update2.state, comment);
2265
2759
  onUpdate({
2266
2760
  id: comment.id,
2267
- cursor
2761
+ cursor: cursor2
2268
2762
  });
2269
2763
  }
2270
2764
  }
@@ -2276,7 +2770,7 @@ var mapTrackedComment = (comment, changes) => ({
2276
2770
  from: changes.mapPos(comment.from, 1),
2277
2771
  to: changes.mapPos(comment.to, 1)
2278
2772
  });
2279
- var restoreCommentEffect = StateEffect4.define({
2773
+ var restoreCommentEffect = StateEffect5.define({
2280
2774
  map: mapTrackedComment
2281
2775
  });
2282
2776
  var createComment = (view) => {
@@ -2293,13 +2787,13 @@ var createComment = (view) => {
2293
2787
  }
2294
2788
  });
2295
2789
  }
2296
- const cursor = Cursor.getCursorFromRange(view.state, {
2790
+ const cursor2 = Cursor.getCursorFromRange(view.state, {
2297
2791
  from,
2298
2792
  to
2299
2793
  });
2300
- if (cursor) {
2794
+ if (cursor2) {
2301
2795
  options.onCreate?.({
2302
- cursor,
2796
+ cursor: cursor2,
2303
2797
  from,
2304
2798
  location: view.coordsAtPos(from)
2305
2799
  });
@@ -2362,7 +2856,7 @@ var comments = (options = {}) => {
2362
2856
  //
2363
2857
  // Track deleted ranges and update ranges for decorations.
2364
2858
  //
2365
- EditorView11.updateListener.of(({ view, state, changes }) => {
2859
+ EditorView13.updateListener.of(({ view, state, changes }) => {
2366
2860
  let mod = false;
2367
2861
  const { comments: comments2, ...value } = state.field(commentsState);
2368
2862
  changes.iterChanges((from, to, from2, to2) => {
@@ -2394,7 +2888,7 @@ var comments = (options = {}) => {
2394
2888
  //
2395
2889
  // Track selection/proximity.
2396
2890
  //
2397
- EditorView11.updateListener.of(({ view, state }) => {
2891
+ EditorView13.updateListener.of(({ view, state }) => {
2398
2892
  let min = Infinity;
2399
2893
  const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
2400
2894
  const { head } = state.selection.main;
@@ -2448,7 +2942,7 @@ var scrollThreadIntoView = (view, id, center = true) => {
2448
2942
  anchor: range.from
2449
2943
  } : void 0,
2450
2944
  effects: [
2451
- needsScroll ? EditorView11.scrollIntoView(range.from, center ? {
2945
+ needsScroll ? EditorView13.scrollIntoView(range.from, center ? {
2452
2946
  y: "center"
2453
2947
  } : void 0) : [],
2454
2948
  needsSelectionUpdate ? setSelection.of({
@@ -2461,9 +2955,10 @@ var scrollThreadIntoView = (view, id, center = true) => {
2461
2955
  };
2462
2956
  var ExternalCommentSync = class {
2463
2957
  constructor(view, id, subscribe, getComments) {
2464
- this.destroy = () => {
2958
+ _define_property15(this, "unsubscribe", void 0);
2959
+ _define_property15(this, "destroy", () => {
2465
2960
  this.unsubscribe();
2466
- };
2961
+ });
2467
2962
  const updateComments = () => {
2468
2963
  const comments2 = getComments();
2469
2964
  if (id === view.state.facet(documentId)) {
@@ -2478,7 +2973,7 @@ var ExternalCommentSync = class {
2478
2973
  this.unsubscribe = subscribe(updateComments);
2479
2974
  }
2480
2975
  };
2481
- var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin9.fromClass(class {
2976
+ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin11.fromClass(class {
2482
2977
  constructor(view) {
2483
2978
  return new ExternalCommentSync(view, id, subscribe, getComments);
2484
2979
  }
@@ -2501,9 +2996,9 @@ var useComments = (view, id, comments2) => {
2501
2996
  // src/extensions/debug.ts
2502
2997
  import { syntaxTree } from "@codemirror/language";
2503
2998
  import { StateField as StateField5 } from "@codemirror/state";
2504
- var debugNodeLogger = (log9 = console.log) => {
2999
+ var debugNodeLogger = (log10 = console.log) => {
2505
3000
  const logTokens = (state) => syntaxTree(state).iterate({
2506
- enter: (node) => log9(node.type)
3001
+ enter: (node) => log10(node.type)
2507
3002
  });
2508
3003
  return StateField5.define({
2509
3004
  create: (state) => logTokens(state),
@@ -2512,8 +3007,8 @@ var debugNodeLogger = (log9 = console.log) => {
2512
3007
  };
2513
3008
 
2514
3009
  // src/extensions/dnd.ts
2515
- import { dropCursor, EditorView as EditorView12 } from "@codemirror/view";
2516
- var styles3 = EditorView12.theme({
3010
+ import { EditorView as EditorView14, dropCursor } from "@codemirror/view";
3011
+ var styles3 = EditorView14.theme({
2517
3012
  ".cm-dropCursor": {
2518
3013
  borderLeft: "2px solid var(--dx-accentText)",
2519
3014
  color: "var(--dx-accentText)",
@@ -2527,7 +3022,7 @@ var dropFile = (options = {}) => {
2527
3022
  return [
2528
3023
  styles3,
2529
3024
  dropCursor(),
2530
- EditorView12.domEventHandlers({
3025
+ EditorView14.domEventHandlers({
2531
3026
  drop: (event, view) => {
2532
3027
  event.preventDefault();
2533
3028
  const files = event.dataTransfer?.files;
@@ -2554,50 +3049,19 @@ import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@cod
2554
3049
  import { searchKeymap } from "@codemirror/search";
2555
3050
  import { EditorState } from "@codemirror/state";
2556
3051
  import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
2557
- import { EditorView as EditorView15, ViewPlugin as ViewPlugin10, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap8, lineNumbers, placeholder as placeholder2, scrollPastEnd } from "@codemirror/view";
3052
+ import { EditorView as EditorView17, ViewPlugin as ViewPlugin12, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap8, lineNumbers, placeholder as placeholder2, scrollPastEnd } from "@codemirror/view";
2558
3053
  import defaultsDeep2 from "lodash.defaultsdeep";
2559
3054
  import merge from "lodash.merge";
2560
3055
  import { generateName } from "@dxos/display-name";
2561
3056
  import { log as log5 } from "@dxos/log";
2562
3057
  import { hexToHue, isNotFalsy as isNotFalsy2 } from "@dxos/util";
2563
3058
 
2564
- // src/extensions/focus.ts
2565
- import { StateEffect as StateEffect5, StateField as StateField6 } from "@codemirror/state";
2566
- import { EditorView as EditorView13 } from "@codemirror/view";
2567
- var focusEffect = StateEffect5.define();
2568
- var focusField = StateField6.define({
2569
- create: () => false,
2570
- update: (value, tr) => {
2571
- for (const effect of tr.effects) {
2572
- if (effect.is(focusEffect)) {
2573
- return effect.value;
2574
- }
2575
- }
2576
- return value;
2577
- }
2578
- });
2579
- var focus = [
2580
- focusField,
2581
- EditorView13.domEventHandlers({
2582
- focus: (event, view) => {
2583
- setTimeout(() => view.dispatch({
2584
- effects: focusEffect.of(true)
2585
- }));
2586
- },
2587
- blur: (event, view) => {
2588
- setTimeout(() => view.dispatch({
2589
- effects: focusEffect.of(false)
2590
- }));
2591
- }
2592
- })
2593
- ];
2594
-
2595
3059
  // src/defaults.ts
2596
- import { EditorView as EditorView14 } from "@codemirror/view";
2597
- import { mx as mx2 } from "@dxos/react-ui-theme";
3060
+ import { EditorView as EditorView15 } from "@codemirror/view";
3061
+ import { mx as mx3 } from "@dxos/react-ui-theme";
2598
3062
 
2599
3063
  // src/styles/markdown.ts
2600
- import { mx } from "@dxos/react-ui-theme";
3064
+ import { mx as mx2 } from "@dxos/react-ui-theme";
2601
3065
  var headings = {
2602
3066
  1: "text-4xl",
2603
3067
  2: "text-3xl",
@@ -2611,7 +3075,7 @@ var theme = {
2611
3075
  codeMark: "font-mono text-primary-500",
2612
3076
  mark: "opacity-50",
2613
3077
  heading: (level) => {
2614
- return mx(headings[level], "dark:text-primary-400");
3078
+ return mx2(headings[level], "dark:text-primary-400");
2615
3079
  }
2616
3080
  };
2617
3081
 
@@ -2646,7 +3110,7 @@ var defaultTheme = {
2646
3110
  fontFamily: fontBody,
2647
3111
  // NOTE: Base font size (otherwise defined by HTML tag, which might be different for storybook).
2648
3112
  fontSize: "16px",
2649
- lineHeight: 1.5,
3113
+ lineHeight: "24px",
2650
3114
  color: "unset"
2651
3115
  },
2652
3116
  /**
@@ -2654,8 +3118,7 @@ var defaultTheme = {
2654
3118
  * NOTE: Gutters should have the same top margin as the content.
2655
3119
  */
2656
3120
  ".cm-gutters": {
2657
- borderRight: "none",
2658
- background: "transparent"
3121
+ borderRight: "none"
2659
3122
  },
2660
3123
  ".cm-gutter": {},
2661
3124
  ".cm-gutter.cm-lineNumbers": {
@@ -2669,13 +3132,14 @@ var defaultTheme = {
2669
3132
  * Height is set to match the corresponding line (which may have wrapped).
2670
3133
  */
2671
3134
  ".cm-gutterElement": {
2672
- fontSize: "12px",
2673
- lineHeight: "24px"
3135
+ lineHeight: "24px",
3136
+ fontSize: "12px"
2674
3137
  },
2675
3138
  /**
2676
3139
  * Line.
2677
3140
  */
2678
3141
  ".cm-line": {
3142
+ lineHeight: "24px",
2679
3143
  paddingInline: 0
2680
3144
  },
2681
3145
  ".cm-activeLine": {
@@ -2730,7 +3194,7 @@ var defaultTheme = {
2730
3194
  * Tooltip.
2731
3195
  */
2732
3196
  ".cm-tooltip": {
2733
- background: "var(--dx-baseSurface)"
3197
+ background: "var(--dx-modalSurface)"
2734
3198
  },
2735
3199
  ".cm-tooltip-below": {},
2736
3200
  /**
@@ -2750,7 +3214,8 @@ var defaultTheme = {
2750
3214
  padding: "4px"
2751
3215
  },
2752
3216
  ".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
2753
- background: "var(--dx-hoverSurface)"
3217
+ background: "var(--dx-accentSurface)",
3218
+ color: "var(--dx-accentSurfaceText)"
2754
3219
  },
2755
3220
  ".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
2756
3221
  paddingLeft: "4px !important",
@@ -2804,7 +3269,7 @@ var defaultTheme = {
2804
3269
  outline: "1px solid transparent"
2805
3270
  },
2806
3271
  ".cm-panel input, .cm-panel button": {
2807
- backgroundColor: "var(--dx-input)"
3272
+ backgroundColor: "var(--dx-inputSurface)"
2808
3273
  },
2809
3274
  ".cm-panel input:focus, .cm-panel button:focus": {
2810
3275
  outline: "1px solid var(--dx-neutralFocusIndicator)"
@@ -2846,19 +3311,52 @@ var editorSlots = {
2846
3311
  className: editorWidth
2847
3312
  }
2848
3313
  };
2849
- var editorGutter = EditorView14.theme({
3314
+ var editorGutter = EditorView15.theme({
2850
3315
  ".cm-gutters": {
2851
- background: "var(--dx-baseSurface)",
3316
+ // NOTE: Color required to cover content if scrolling horizontally.
3317
+ // TODO(burdon): Non-transparent background clips the focus ring.
3318
+ background: "var(--dx-baseSurface) !important",
2852
3319
  paddingRight: "1rem"
2853
3320
  }
2854
3321
  });
2855
- var editorMonospace = EditorView14.theme({
3322
+ var editorMonospace = EditorView15.theme({
2856
3323
  ".cm-content": {
2857
3324
  fontFamily: fontMono
2858
3325
  }
2859
3326
  });
2860
3327
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
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");
3328
+ var stackItemContentEditorClassNames = (role) => mx3("p-0.5 dx-focus-ring-inset attention-surface data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
3329
+
3330
+ // src/extensions/focus.ts
3331
+ import { StateEffect as StateEffect6, StateField as StateField6 } from "@codemirror/state";
3332
+ import { EditorView as EditorView16 } from "@codemirror/view";
3333
+ var focusEffect = StateEffect6.define();
3334
+ var focusField = StateField6.define({
3335
+ create: () => false,
3336
+ update: (value, tr) => {
3337
+ for (const effect of tr.effects) {
3338
+ if (effect.is(focusEffect)) {
3339
+ return effect.value;
3340
+ }
3341
+ }
3342
+ return value;
3343
+ }
3344
+ });
3345
+ var focus = [
3346
+ focusField,
3347
+ EditorView16.domEventHandlers({
3348
+ focus: (event, view) => {
3349
+ setTimeout(() => view.dispatch({
3350
+ effects: focusEffect.of(true)
3351
+ }));
3352
+ },
3353
+ blur: (event, view) => {
3354
+ setTimeout(() => view.dispatch({
3355
+ effects: focusEffect.of(false)
3356
+ }));
3357
+ }
3358
+ })
3359
+ ];
2862
3360
 
2863
3361
  // src/extensions/factories.ts
2864
3362
  var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
@@ -2872,7 +3370,7 @@ var defaultBasicOptions = {
2872
3370
  history: true,
2873
3371
  keymap: "standard",
2874
3372
  lineWrapping: true,
2875
- search: true
3373
+ search: false
2876
3374
  };
2877
3375
  var keymaps = {
2878
3376
  // https://codemirror.net/docs/ref/#commands.standardKeymap
@@ -2884,10 +3382,10 @@ var createBasicExtensions = (_props) => {
2884
3382
  const props = defaultsDeep2({}, _props, defaultBasicOptions);
2885
3383
  return [
2886
3384
  // NOTE: Doesn't catch errors in keymap functions.
2887
- EditorView15.exceptionSink.of((err) => {
3385
+ EditorView17.exceptionSink.of((err) => {
2888
3386
  log5.catch(err, void 0, {
2889
3387
  F: __dxlog_file8,
2890
- L: 100,
3388
+ L: 102,
2891
3389
  S: void 0,
2892
3390
  C: (f, a) => f(...a)
2893
3391
  });
@@ -2899,7 +3397,7 @@ var createBasicExtensions = (_props) => {
2899
3397
  props.drawSelection && drawSelection({
2900
3398
  cursorBlinkRate: 1200
2901
3399
  }),
2902
- props.editable !== void 0 && EditorView15.editable.of(props.editable),
3400
+ props.editable !== void 0 && EditorView17.editable.of(props.editable),
2903
3401
  props.focus && focus,
2904
3402
  props.highlightActiveLine && highlightActiveLine(),
2905
3403
  props.history && history(),
@@ -2907,7 +3405,7 @@ var createBasicExtensions = (_props) => {
2907
3405
  lineNumbers(),
2908
3406
  editorGutter
2909
3407
  ],
2910
- props.lineWrapping && EditorView15.lineWrapping,
3408
+ props.lineWrapping && EditorView17.lineWrapping,
2911
3409
  props.monospace && editorMonospace,
2912
3410
  props.placeholder && placeholder2(props.placeholder),
2913
3411
  props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
@@ -2948,27 +3446,21 @@ var fullWidth = {
2948
3446
  }
2949
3447
  };
2950
3448
  var defaultThemeSlots = grow;
2951
- var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
3449
+ var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: syntaxHighlightingProps, slots: _slots } = {}) => {
2952
3450
  const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
2953
3451
  return [
2954
- EditorView15.darkTheme.of(themeMode === "dark"),
2955
- EditorView15.baseTheme(styles4 ? merge({}, defaultTheme, styles4) : defaultTheme),
2956
- // https://github.com/codemirror/theme-one-dark
2957
- _syntaxHighlighting && (themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle)),
2958
- slots.editor?.className && EditorView15.editorAttributes.of({
3452
+ EditorView17.darkTheme.of(themeMode === "dark"),
3453
+ EditorView17.baseTheme(styles4 ? merge({}, defaultTheme, styles4) : defaultTheme),
3454
+ syntaxHighlightingProps && syntaxHighlighting(themeMode === "dark" ? oneDarkHighlightStyle : defaultHighlightStyle),
3455
+ slots.editor?.className && EditorView17.editorAttributes.of({
2959
3456
  class: slots.editor.className
2960
3457
  }),
2961
- slots.content?.className && EditorView15.contentAttributes.of({
3458
+ slots.content?.className && EditorView17.contentAttributes.of({
2962
3459
  class: slots.content.className
2963
3460
  }),
2964
- slots.scroll?.className && ViewPlugin10.fromClass(class {
2965
- constructor(view) {
2966
- view.scrollDOM.classList.add(slots.scroll.className);
2967
- }
2968
- }),
2969
- slots.scroller?.className && ViewPlugin10.fromClass(class {
3461
+ slots.scroll?.className && ViewPlugin12.fromClass(class {
2970
3462
  constructor(view) {
2971
- view.dom.querySelector(".cm-scroller")?.classList.add(...slots.scroller.className.split(" "));
3463
+ view.scrollDOM.classList.add(...slots.scroll.className.split(/\s+/));
2972
3464
  }
2973
3465
  })
2974
3466
  ].filter(isNotFalsy2);
@@ -2986,9 +3478,9 @@ var createDataExtensions = ({ id, text, space, identity }) => {
2986
3478
  channel: `awareness.${id}`,
2987
3479
  peerId: identity.identityKey.toHex(),
2988
3480
  info: {
2989
- displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex()),
2990
3481
  darkColor: `var(--dx-${hue}Cursor)`,
2991
- lightColor: `var(--dx-${hue}Cursor)`
3482
+ lightColor: `var(--dx-${hue}Cursor)`,
3483
+ displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
2992
3484
  }
2993
3485
  })));
2994
3486
  }
@@ -2997,7 +3489,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
2997
3489
 
2998
3490
  // src/extensions/folding.tsx
2999
3491
  import { codeFolding, foldGutter } from "@codemirror/language";
3000
- import { EditorView as EditorView16 } from "@codemirror/view";
3492
+ import { EditorView as EditorView18 } from "@codemirror/view";
3001
3493
  import React2 from "react";
3002
3494
  import { Icon } from "@dxos/react-ui";
3003
3495
  var folding = (_props = {}) => [
@@ -3008,9 +3500,7 @@ var folding = (_props = {}) => [
3008
3500
  }),
3009
3501
  foldGutter({
3010
3502
  markerDOM: (open) => {
3011
- const el = createElement("div", {
3012
- className: "flex h-full items-center"
3013
- });
3503
+ const el = Domino.of("div").classNames("flex h-full items-center").build();
3014
3504
  return renderRoot(el, /* @__PURE__ */ React2.createElement(Icon, {
3015
3505
  icon: "ph--caret-right--bold",
3016
3506
  size: 3,
@@ -3021,7 +3511,7 @@ var folding = (_props = {}) => [
3021
3511
  }));
3022
3512
  }
3023
3513
  }),
3024
- EditorView16.theme({
3514
+ EditorView18.theme({
3025
3515
  ".cm-foldGutter": {
3026
3516
  opacity: 0.3,
3027
3517
  transition: "opacity 0.3s",
@@ -3034,40 +3524,54 @@ var folding = (_props = {}) => [
3034
3524
  ];
3035
3525
 
3036
3526
  // src/extensions/hashtag.tsx
3037
- import { Decoration as Decoration8, EditorView as EditorView17, MatchDecorator, ViewPlugin as ViewPlugin11, WidgetType as WidgetType4 } from "@codemirror/view";
3038
- import { getHashColor, mx as mx3 } from "@dxos/react-ui-theme";
3039
- var TagWidget = class extends WidgetType4 {
3040
- constructor(_text) {
3041
- super(), this._text = _text;
3527
+ import { Decoration as Decoration9, EditorView as EditorView19, MatchDecorator, ViewPlugin as ViewPlugin13, WidgetType as WidgetType5 } from "@codemirror/view";
3528
+ import { getHashColor, mx as mx4 } from "@dxos/react-ui-theme";
3529
+ function _define_property16(obj, key, value) {
3530
+ if (key in obj) {
3531
+ Object.defineProperty(obj, key, {
3532
+ value,
3533
+ enumerable: true,
3534
+ configurable: true,
3535
+ writable: true
3536
+ });
3537
+ } else {
3538
+ obj[key] = value;
3042
3539
  }
3540
+ return obj;
3541
+ }
3542
+ var TagWidget = class extends WidgetType5 {
3043
3543
  toDOM() {
3044
3544
  const span = document.createElement("span");
3045
- span.className = mx3("cm-tag", getHashColor(this._text).tag);
3545
+ span.className = mx4("cm-tag", getHashColor(this._text).tag);
3046
3546
  span.textContent = this._text;
3047
3547
  return span;
3048
3548
  }
3549
+ constructor(_text) {
3550
+ super(), _define_property16(this, "_text", void 0), this._text = _text;
3551
+ }
3049
3552
  };
3050
3553
  var tagMatcher = new MatchDecorator({
3051
3554
  regexp: /#(\w+)\W/g,
3052
- decoration: (match) => Decoration8.replace({
3555
+ decoration: (match) => Decoration9.replace({
3053
3556
  widget: new TagWidget(match[1])
3054
3557
  })
3055
3558
  });
3056
3559
  var hashtag = () => [
3057
- ViewPlugin11.fromClass(class {
3058
- constructor(view) {
3059
- this.tags = tagMatcher.createDeco(view);
3060
- }
3560
+ ViewPlugin13.fromClass(class {
3061
3561
  update(update2) {
3062
3562
  this.tags = tagMatcher.updateDeco(update2, this.tags);
3063
3563
  }
3564
+ constructor(view) {
3565
+ _define_property16(this, "tags", void 0);
3566
+ this.tags = tagMatcher.createDeco(view);
3567
+ }
3064
3568
  }, {
3065
3569
  decorations: (instance) => instance.tags,
3066
- provide: (plugin) => EditorView17.atomicRanges.of((view) => {
3067
- return view.plugin(plugin)?.tags || Decoration8.none;
3570
+ provide: (plugin) => EditorView19.atomicRanges.of((view) => {
3571
+ return view.plugin(plugin)?.tags || Decoration9.none;
3068
3572
  })
3069
3573
  }),
3070
- EditorView17.theme({
3574
+ EditorView19.theme({
3071
3575
  ".cm-tag": {
3072
3576
  borderRadius: "4px",
3073
3577
  marginRight: "6px",
@@ -3122,14 +3626,14 @@ var schemaLinter = (validate) => (view) => {
3122
3626
  };
3123
3627
 
3124
3628
  // src/extensions/listener.ts
3125
- import { EditorView as EditorView18 } from "@codemirror/view";
3629
+ import { EditorView as EditorView20 } from "@codemirror/view";
3126
3630
  var listener = ({ onFocus, onChange }) => {
3127
3631
  const extensions = [];
3128
- onFocus && extensions.push(EditorView18.focusChangeEffect.of((_, focusing) => {
3632
+ onFocus && extensions.push(EditorView20.focusChangeEffect.of((_, focusing) => {
3129
3633
  onFocus(focusing);
3130
3634
  return null;
3131
3635
  }));
3132
- onChange && extensions.push(EditorView18.updateListener.of((update2) => {
3636
+ onChange && extensions.push(EditorView20.updateListener.of((update2) => {
3133
3637
  onChange(update2.state.doc.toString(), update2.state.facet(documentId));
3134
3638
  }));
3135
3639
  return extensions;
@@ -3139,7 +3643,7 @@ var listener = ({ onFocus, onChange }) => {
3139
3643
  import { snippet } from "@codemirror/autocomplete";
3140
3644
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
3141
3645
  import { EditorSelection as EditorSelection2 } from "@codemirror/state";
3142
- import { EditorView as EditorView19, keymap as keymap9 } from "@codemirror/view";
3646
+ import { EditorView as EditorView21, keymap as keymap9 } from "@codemirror/view";
3143
3647
  import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
3144
3648
  import { debounceAndThrottle } from "@dxos/async";
3145
3649
  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;
@@ -4238,7 +4742,7 @@ var useFormattingState = (state) => {
4238
4742
  }, 100), [
4239
4743
  state
4240
4744
  ]);
4241
- return useMemo2(() => EditorView19.updateListener.of(handleUpdate), [
4745
+ return useMemo2(() => EditorView21.updateListener.of(handleUpdate), [
4242
4746
  handleUpdate
4243
4747
  ]);
4244
4748
  };
@@ -4293,18 +4797,18 @@ var processEditorPayload = (view, { type, data }) => {
4293
4797
  };
4294
4798
 
4295
4799
  // src/extensions/markdown/bundle.ts
4296
- import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
4800
+ import { completionKeymap } from "@codemirror/autocomplete";
4297
4801
  import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
4298
- import { markdownLanguage as markdownLanguage3, markdown } from "@codemirror/lang-markdown";
4802
+ import { markdown, markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
4299
4803
  import { syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
4300
4804
  import { languages } from "@codemirror/language-data";
4301
4805
  import { keymap as keymap10 } from "@codemirror/view";
4302
4806
  import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
4303
4807
 
4304
4808
  // src/extensions/markdown/highlight.ts
4305
- import { markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
4809
+ import { markdownLanguage } from "@codemirror/lang-markdown";
4306
4810
  import { HighlightStyle } from "@codemirror/language";
4307
- import { tags, styleTags, Tag } from "@lezer/highlight";
4811
+ import { Tag, styleTags, tags } from "@lezer/highlight";
4308
4812
  import { Table } from "@lezer/markdown";
4309
4813
  var markdownTags = {
4310
4814
  Blockquote: Tag.define(),
@@ -4473,7 +4977,7 @@ var markdownHighlightStyle = (_options = {}) => {
4473
4977
  class: "font-mono"
4474
4978
  }
4475
4979
  ], {
4476
- scope: markdownLanguage2,
4980
+ scope: markdownLanguage,
4477
4981
  all: {
4478
4982
  fontFamily: fontBody
4479
4983
  }
@@ -4492,7 +4996,7 @@ var createMarkdownExtensions = (options = {}) => {
4492
4996
  // NOTE: This extends the parser; it doesn't affect rendering.
4493
4997
  // https://github.github.com/gfm
4494
4998
  // https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown
4495
- base: markdownLanguage3,
4999
+ base: markdownLanguage2,
4496
5000
  // Languages for syntax highlighting fenced code blocks.
4497
5001
  codeLanguages: languages,
4498
5002
  // Don't complete HTML tags.
@@ -4500,7 +5004,8 @@ var createMarkdownExtensions = (options = {}) => {
4500
5004
  // Parser extensions.
4501
5005
  extensions: [
4502
5006
  // GFM provided by default.
4503
- markdownTagsExtensions
5007
+ markdownTagsExtensions,
5008
+ ...options.extensions ?? defaultExtensions()
4504
5009
  ]
4505
5010
  }),
4506
5011
  // Custom styles.
@@ -4510,10 +5015,25 @@ var createMarkdownExtensions = (options = {}) => {
4510
5015
  options.indentWithTab !== false && indentWithTab2,
4511
5016
  // https://codemirror.net/docs/ref/#commands.defaultKeymap
4512
5017
  ...defaultKeymap2,
4513
- ...completionKeymap2
5018
+ ...completionKeymap
4514
5019
  ].filter(isNotFalsy3))
4515
5020
  ];
4516
5021
  };
5022
+ var defaultExtensions = () => [
5023
+ noSetExtHeading,
5024
+ noHtml
5025
+ ];
5026
+ var noSetExtHeading = {
5027
+ remove: [
5028
+ "SetextHeading"
5029
+ ]
5030
+ };
5031
+ var noHtml = {
5032
+ remove: [
5033
+ "HTMLBlock",
5034
+ "HTMLTag"
5035
+ ]
5036
+ };
4517
5037
 
4518
5038
  // src/extensions/markdown/debug.ts
4519
5039
  import { syntaxTree as syntaxTree3 } from "@codemirror/language";
@@ -4523,19 +5043,19 @@ var debugTree = (cb) => StateField7.define({
4523
5043
  update: (value, tr) => cb(convertTreeToJson(tr.state))
4524
5044
  });
4525
5045
  var convertTreeToJson = (state) => {
4526
- const treeToJson = (cursor) => {
5046
+ const treeToJson = (cursor2) => {
4527
5047
  const node = {
4528
- type: cursor.type.name,
4529
- from: cursor.from,
4530
- to: cursor.to,
4531
- text: state.doc.slice(cursor.from, cursor.to).toString(),
5048
+ type: cursor2.type.name,
5049
+ from: cursor2.from,
5050
+ to: cursor2.to,
5051
+ text: state.doc.slice(cursor2.from, cursor2.to).toString(),
4532
5052
  children: []
4533
5053
  };
4534
- if (cursor.firstChild()) {
5054
+ if (cursor2.firstChild()) {
4535
5055
  do {
4536
- node.children.push(treeToJson(cursor));
4537
- } while (cursor.nextSibling());
4538
- cursor.parent();
5056
+ node.children.push(treeToJson(cursor2));
5057
+ } while (cursor2.nextSibling());
5058
+ cursor2.parent();
4539
5059
  }
4540
5060
  return node;
4541
5061
  };
@@ -4544,17 +5064,17 @@ var convertTreeToJson = (state) => {
4544
5064
 
4545
5065
  // src/extensions/markdown/decorate.ts
4546
5066
  import { syntaxTree as syntaxTree7 } from "@codemirror/language";
4547
- import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect6 } from "@codemirror/state";
4548
- import { EditorView as EditorView23, Decoration as Decoration11, WidgetType as WidgetType7, ViewPlugin as ViewPlugin13 } from "@codemirror/view";
5067
+ import { Prec as Prec5, RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect7 } from "@codemirror/state";
5068
+ import { Decoration as Decoration12, EditorView as EditorView25, ViewPlugin as ViewPlugin15, WidgetType as WidgetType8 } from "@codemirror/view";
4549
5069
  import { invariant as invariant4 } from "@dxos/invariant";
4550
- import { mx as mx4 } from "@dxos/react-ui-theme";
5070
+ import { mx as mx5 } from "@dxos/react-ui-theme";
4551
5071
 
4552
5072
  // src/extensions/markdown/changes.ts
4553
5073
  import { syntaxTree as syntaxTree4 } from "@codemirror/language";
4554
5074
  import { Transaction as Transaction2 } from "@codemirror/state";
4555
- import { ViewPlugin as ViewPlugin12 } from "@codemirror/view";
5075
+ import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
4556
5076
  var adjustChanges = () => {
4557
- return ViewPlugin12.fromClass(class {
5077
+ return ViewPlugin14.fromClass(class {
4558
5078
  update(update2) {
4559
5079
  const tree = syntaxTree4(update2.state);
4560
5080
  const adjustments = [];
@@ -4696,21 +5216,34 @@ var getValidUrl = (str) => {
4696
5216
  // src/extensions/markdown/image.ts
4697
5217
  import { syntaxTree as syntaxTree5 } from "@codemirror/language";
4698
5218
  import { StateField as StateField8 } from "@codemirror/state";
4699
- import { Decoration as Decoration9, EditorView as EditorView20, WidgetType as WidgetType5 } from "@codemirror/view";
5219
+ import { Decoration as Decoration10, EditorView as EditorView22, WidgetType as WidgetType6 } from "@codemirror/view";
5220
+ function _define_property17(obj, key, value) {
5221
+ if (key in obj) {
5222
+ Object.defineProperty(obj, key, {
5223
+ value,
5224
+ enumerable: true,
5225
+ configurable: true,
5226
+ writable: true
5227
+ });
5228
+ } else {
5229
+ obj[key] = value;
5230
+ }
5231
+ return obj;
5232
+ }
4700
5233
  var image = (_options = {}) => {
4701
5234
  return [
4702
5235
  StateField8.define({
4703
5236
  create: (state) => {
4704
- return Decoration9.set(buildDecorations(0, state.doc.length, state));
5237
+ return Decoration10.set(buildDecorations(state, 0, state.doc.length));
4705
5238
  },
4706
5239
  update: (value, tr) => {
4707
5240
  if (!tr.docChanged && !tr.selection) {
4708
5241
  return value;
4709
5242
  }
4710
- const cursor = tr.state.selection.main.head;
5243
+ const cursor2 = tr.state.selection.main.head;
4711
5244
  const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);
4712
- let from = Math.min(cursor, oldCursor);
4713
- let to = Math.max(cursor, oldCursor);
5245
+ let from = Math.min(cursor2, oldCursor);
5246
+ let to = Math.max(cursor2, oldCursor);
4714
5247
  tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {
4715
5248
  from = Math.min(from, fromB);
4716
5249
  to = Math.max(to, toB);
@@ -4721,28 +5254,28 @@ var image = (_options = {}) => {
4721
5254
  filterFrom: from,
4722
5255
  filterTo: to,
4723
5256
  filter: () => false,
4724
- add: buildDecorations(from, to, tr.state)
5257
+ add: buildDecorations(tr.state, from, to)
4725
5258
  });
4726
5259
  },
4727
- provide: (field) => EditorView20.decorations.from(field)
5260
+ provide: (field) => EditorView22.decorations.from(field)
4728
5261
  })
4729
5262
  ];
4730
5263
  };
4731
- var buildDecorations = (from, to, state) => {
5264
+ var buildDecorations = (state, from, to) => {
4732
5265
  const decorations2 = [];
4733
- const cursor = state.selection.main.head;
5266
+ const cursor2 = state.selection.main.head;
4734
5267
  syntaxTree5(state).iterate({
4735
5268
  enter: (node) => {
4736
5269
  if (node.name === "Image") {
4737
5270
  const urlNode = node.node.getChild("URL");
4738
5271
  if (urlNode) {
4739
- const hide2 = state.readOnly || cursor < node.from || cursor > node.to || !state.field(focusField);
5272
+ const hide2 = state.readOnly || cursor2 < node.from || cursor2 > node.to || !state.field(focusField);
4740
5273
  const url = state.sliceDoc(urlNode.from, urlNode.to);
4741
5274
  if (url.match(/^https?:\/\//) === null && url.match(/^file?:\/\//) === null) {
4742
5275
  return;
4743
5276
  }
4744
5277
  preloadImage(url);
4745
- decorations2.push(Decoration9.replace({
5278
+ decorations2.push(Decoration10.replace({
4746
5279
  block: true,
4747
5280
  widget: new ImageWidget(url)
4748
5281
  }).range(hide2 ? node.from : node.to, node.to));
@@ -4762,10 +5295,7 @@ var preloadImage = (url) => {
4762
5295
  preloaded.add(url);
4763
5296
  }
4764
5297
  };
4765
- var ImageWidget = class extends WidgetType5 {
4766
- constructor(_url) {
4767
- super(), this._url = _url;
4768
- }
5298
+ var ImageWidget = class extends WidgetType6 {
4769
5299
  eq(other) {
4770
5300
  return this._url === other._url;
4771
5301
  }
@@ -4780,13 +5310,16 @@ var ImageWidget = class extends WidgetType5 {
4780
5310
  }
4781
5311
  return img;
4782
5312
  }
5313
+ constructor(_url) {
5314
+ super(), _define_property17(this, "_url", void 0), this._url = _url;
5315
+ }
4783
5316
  };
4784
5317
 
4785
5318
  // src/extensions/markdown/styles.ts
4786
- import { EditorView as EditorView21 } from "@codemirror/view";
5319
+ import { EditorView as EditorView23 } from "@codemirror/view";
4787
5320
  var bulletListIndentationWidth = 24;
4788
5321
  var orderedListIndentationWidth = 36;
4789
- var formattingStyles = EditorView21.theme({
5322
+ var formattingStyles = EditorView23.theme({
4790
5323
  /**
4791
5324
  * Horizontal rule.
4792
5325
  */
@@ -4908,17 +5441,30 @@ var formattingStyles = EditorView21.theme({
4908
5441
  // src/extensions/markdown/table.ts
4909
5442
  import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4910
5443
  import { RangeSetBuilder as RangeSetBuilder5, StateField as StateField9 } from "@codemirror/state";
4911
- import { Decoration as Decoration10, EditorView as EditorView22, WidgetType as WidgetType6 } from "@codemirror/view";
5444
+ import { Decoration as Decoration11, EditorView as EditorView24, WidgetType as WidgetType7 } from "@codemirror/view";
5445
+ function _define_property18(obj, key, value) {
5446
+ if (key in obj) {
5447
+ Object.defineProperty(obj, key, {
5448
+ value,
5449
+ enumerable: true,
5450
+ configurable: true,
5451
+ writable: true
5452
+ });
5453
+ } else {
5454
+ obj[key] = value;
5455
+ }
5456
+ return obj;
5457
+ }
4912
5458
  var table = (options = {}) => {
4913
5459
  return StateField9.define({
4914
5460
  create: (state) => update(state, options),
4915
5461
  update: (_, tr) => update(tr.state, options),
4916
- provide: (field) => EditorView22.decorations.from(field)
5462
+ provide: (field) => EditorView24.decorations.from(field)
4917
5463
  });
4918
5464
  };
4919
5465
  var update = (state, _options) => {
4920
5466
  const builder = new RangeSetBuilder5();
4921
- const cursor = state.selection.main.head;
5467
+ const cursor2 = state.selection.main.head;
4922
5468
  const tables = [];
4923
5469
  const getTable = () => tables[tables.length - 1];
4924
5470
  const getRow = () => {
@@ -4940,7 +5486,8 @@ var update = (state, _options) => {
4940
5486
  break;
4941
5487
  }
4942
5488
  case "TableRow": {
4943
- (getTable().rows ??= []).push([]);
5489
+ var _getTable;
5490
+ ((_getTable = getTable()).rows ?? (_getTable.rows = [])).push([]);
4944
5491
  break;
4945
5492
  }
4946
5493
  case "TableCell": {
@@ -4956,24 +5503,21 @@ var update = (state, _options) => {
4956
5503
  }
4957
5504
  });
4958
5505
  tables.forEach((table2) => {
4959
- const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
5506
+ const replace = state.readOnly || cursor2 < table2.from || cursor2 > table2.to;
4960
5507
  if (replace) {
4961
- builder.add(table2.from, table2.to, Decoration10.replace({
5508
+ builder.add(table2.from, table2.to, Decoration11.replace({
4962
5509
  block: true,
4963
5510
  widget: new TableWidget(table2)
4964
5511
  }));
4965
5512
  } else {
4966
- builder.add(table2.from, table2.to, Decoration10.mark({
5513
+ builder.add(table2.from, table2.to, Decoration11.mark({
4967
5514
  class: "cm-table"
4968
5515
  }));
4969
5516
  }
4970
5517
  });
4971
5518
  return builder.finish();
4972
5519
  };
4973
- var TableWidget = class extends WidgetType6 {
4974
- constructor(_table) {
4975
- super(), this._table = _table;
4976
- }
5520
+ var TableWidget = class extends WidgetType7 {
4977
5521
  eq(other) {
4978
5522
  return this._table.header?.join() === other._table.header?.join() && this._table.rows?.join() === other._table.rows?.join();
4979
5523
  }
@@ -5001,9 +5545,25 @@ var TableWidget = class extends WidgetType6 {
5001
5545
  ignoreEvent(e) {
5002
5546
  return !/^mouse/.test(e.type);
5003
5547
  }
5548
+ constructor(_table) {
5549
+ super(), _define_property18(this, "_table", void 0), this._table = _table;
5550
+ }
5004
5551
  };
5005
5552
 
5006
5553
  // src/extensions/markdown/decorate.ts
5554
+ function _define_property19(obj, key, value) {
5555
+ if (key in obj) {
5556
+ Object.defineProperty(obj, key, {
5557
+ value,
5558
+ enumerable: true,
5559
+ configurable: true,
5560
+ writable: true
5561
+ });
5562
+ } else {
5563
+ obj[key] = value;
5564
+ }
5565
+ return obj;
5566
+ }
5007
5567
  var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts";
5008
5568
  var Unicode = {
5009
5569
  emDash: "\u2014",
@@ -5011,17 +5571,14 @@ var Unicode = {
5011
5571
  bulletSmall: "\u2219",
5012
5572
  bulletSquare: "\u2B1D"
5013
5573
  };
5014
- var HorizontalRuleWidget = class extends WidgetType7 {
5574
+ var HorizontalRuleWidget = class extends WidgetType8 {
5015
5575
  toDOM() {
5016
5576
  const el = document.createElement("span");
5017
5577
  el.className = "cm-hr";
5018
5578
  return el;
5019
5579
  }
5020
5580
  };
5021
- var LinkButton = class extends WidgetType7 {
5022
- constructor(url, render) {
5023
- super(), this.url = url, this.render = render;
5024
- }
5581
+ var LinkButton = class extends WidgetType8 {
5025
5582
  eq(other) {
5026
5583
  return this.url === other.url;
5027
5584
  }
@@ -5033,11 +5590,11 @@ var LinkButton = class extends WidgetType7 {
5033
5590
  }, view);
5034
5591
  return el;
5035
5592
  }
5593
+ constructor(url, render) {
5594
+ super(), _define_property19(this, "url", void 0), _define_property19(this, "render", void 0), this.url = url, this.render = render;
5595
+ }
5036
5596
  };
5037
- var CheckboxWidget = class extends WidgetType7 {
5038
- constructor(_checked) {
5039
- super(), this._checked = _checked;
5040
- }
5597
+ var CheckboxWidget = class extends WidgetType8 {
5041
5598
  eq(other) {
5042
5599
  return this._checked === other._checked;
5043
5600
  }
@@ -5077,11 +5634,11 @@ var CheckboxWidget = class extends WidgetType7 {
5077
5634
  ignoreEvent() {
5078
5635
  return false;
5079
5636
  }
5080
- };
5081
- var TextWidget = class extends WidgetType7 {
5082
- constructor(text, className) {
5083
- super(), this.text = text, this.className = className;
5637
+ constructor(_checked) {
5638
+ super(), _define_property19(this, "_checked", void 0), this._checked = _checked;
5084
5639
  }
5640
+ };
5641
+ var TextWidget = class extends WidgetType8 {
5085
5642
  toDOM() {
5086
5643
  const el = document.createElement("span");
5087
5644
  if (this.className) {
@@ -5090,30 +5647,33 @@ var TextWidget = class extends WidgetType7 {
5090
5647
  el.innerText = this.text;
5091
5648
  return el;
5092
5649
  }
5650
+ constructor(text, className) {
5651
+ super(), _define_property19(this, "text", void 0), _define_property19(this, "className", void 0), this.text = text, this.className = className;
5652
+ }
5093
5653
  };
5094
- var hide = Decoration11.replace({});
5095
- var blockQuote = Decoration11.line({
5654
+ var hide = Decoration12.replace({});
5655
+ var blockQuote = Decoration12.line({
5096
5656
  class: "cm-blockquote"
5097
5657
  });
5098
- var fencedCodeLine = Decoration11.line({
5658
+ var fencedCodeLine = Decoration12.line({
5099
5659
  class: "cm-code cm-codeblock-line"
5100
5660
  });
5101
- var fencedCodeLineFirst = Decoration11.line({
5102
- class: mx4("cm-code cm-codeblock-line", "cm-codeblock-start")
5661
+ var fencedCodeLineFirst = Decoration12.line({
5662
+ class: mx5("cm-code cm-codeblock-line", "cm-codeblock-start")
5103
5663
  });
5104
- var fencedCodeLineLast = Decoration11.line({
5105
- class: mx4("cm-code cm-codeblock-line", "cm-codeblock-end")
5664
+ var fencedCodeLineLast = Decoration12.line({
5665
+ class: mx5("cm-code cm-codeblock-line", "cm-codeblock-end")
5106
5666
  });
5107
5667
  var commentBlockLine = fencedCodeLine;
5108
5668
  var commentBlockLineFirst = fencedCodeLineFirst;
5109
5669
  var commentBlockLineLast = fencedCodeLineLast;
5110
- var horizontalRule = Decoration11.replace({
5670
+ var horizontalRule = Decoration12.replace({
5111
5671
  widget: new HorizontalRuleWidget()
5112
5672
  });
5113
- var checkedTask = Decoration11.replace({
5673
+ var checkedTask = Decoration12.replace({
5114
5674
  widget: new CheckboxWidget(true)
5115
5675
  });
5116
- var uncheckedTask = Decoration11.replace({
5676
+ var uncheckedTask = Decoration12.replace({
5117
5677
  widget: new CheckboxWidget(false)
5118
5678
  });
5119
5679
  var editingRange = (state, range, focus2) => {
@@ -5136,7 +5696,7 @@ var buildDecorations2 = (view, options, focus2) => {
5136
5696
  const getHeaderLevels = (node, level) => {
5137
5697
  invariant4(level > 0, void 0, {
5138
5698
  F: __dxlog_file9,
5139
- L: 179,
5699
+ L: 180,
5140
5700
  S: void 0,
5141
5701
  A: [
5142
5702
  "level > 0",
@@ -5175,7 +5735,7 @@ var buildDecorations2 = (view, options, focus2) => {
5175
5735
  const getCurrentListLevel = () => {
5176
5736
  invariant4(listLevels.length, void 0, {
5177
5737
  F: __dxlog_file9,
5178
- L: 201,
5738
+ L: 202,
5179
5739
  S: void 0,
5180
5740
  A: [
5181
5741
  "listLevels.length",
@@ -5210,14 +5770,14 @@ var buildDecorations2 = (view, options, focus2) => {
5210
5770
  const mark = node.node.firstChild;
5211
5771
  if (mark?.name === "HeaderMark") {
5212
5772
  const { from, to = 6 } = options.numberedHeadings ?? {};
5213
- const text = view.state.sliceDoc(node.from, node.to);
5773
+ const text = state.sliceDoc(node.from, node.to);
5214
5774
  const len = text.match(/[#\s]+/)[0].length;
5215
5775
  if (!from || level < from || level > to) {
5216
5776
  atomicDeco.add(mark.from, mark.from + len, hide);
5217
5777
  } else {
5218
5778
  const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
5219
5779
  if (num.length) {
5220
- atomicDeco.add(mark.from, mark.from + len, Decoration11.replace({
5780
+ atomicDeco.add(mark.from, mark.from + len, Decoration12.replace({
5221
5781
  widget: new TextWidget(num, theme.heading(level))
5222
5782
  }));
5223
5783
  }
@@ -5242,7 +5802,7 @@ var buildDecorations2 = (view, options, focus2) => {
5242
5802
  if (node.from === line.to - 1) {
5243
5803
  return false;
5244
5804
  }
5245
- deco.add(line.from, line.from, Decoration11.line({
5805
+ deco.add(line.from, line.from, Decoration12.line({
5246
5806
  class: "cm-list-item",
5247
5807
  attributes: {
5248
5808
  style: `padding-left: ${offset}px; text-indent: -${width}px;`
@@ -5259,7 +5819,7 @@ var buildDecorations2 = (view, options, focus2) => {
5259
5819
  const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
5260
5820
  const line = state.doc.lineAt(node.from);
5261
5821
  const to = state.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
5262
- atomicDeco.add(line.from, to, Decoration11.replace({
5822
+ atomicDeco.add(line.from, to, Decoration12.replace({
5263
5823
  widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
5264
5824
  }));
5265
5825
  break;
@@ -5343,10 +5903,16 @@ var buildDecorations2 = (view, options, focus2) => {
5343
5903
  const editing = editingRange(state, node, focus2);
5344
5904
  if (urlNode && marks.length >= 2) {
5345
5905
  const url = state.sliceDoc(urlNode.from, urlNode.to);
5906
+ if (options.skip?.({
5907
+ name: "Link",
5908
+ url
5909
+ })) {
5910
+ break;
5911
+ }
5346
5912
  if (!editing) {
5347
5913
  atomicDeco.add(node.from, marks[0].to, hide);
5348
5914
  }
5349
- deco.add(marks[0].to, marks[1].from, Decoration11.mark({
5915
+ deco.add(marks[0].to, marks[1].from, Decoration12.mark({
5350
5916
  tagName: "a",
5351
5917
  attributes: {
5352
5918
  class: "cm-link",
@@ -5356,7 +5922,7 @@ var buildDecorations2 = (view, options, focus2) => {
5356
5922
  }
5357
5923
  }));
5358
5924
  if (!editing) {
5359
- atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration11.replace({
5925
+ atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration12.replace({
5360
5926
  widget: new LinkButton(url, options.renderLinkButton)
5361
5927
  }) : hide);
5362
5928
  }
@@ -5396,14 +5962,14 @@ var buildDecorations2 = (view, options, focus2) => {
5396
5962
  tree.iterate({
5397
5963
  from,
5398
5964
  to,
5399
- enter: wrapWithCatch(enterNode),
5400
- leave: wrapWithCatch(leaveNode)
5965
+ enter: wrapWithCatch(enterNode, "decorate.enter"),
5966
+ leave: wrapWithCatch(leaveNode, "decorate.leave")
5401
5967
  });
5402
5968
  }
5403
5969
  } else {
5404
5970
  tree.iterate({
5405
- enter: wrapWithCatch(enterNode),
5406
- leave: wrapWithCatch(leaveNode)
5971
+ enter: wrapWithCatch(enterNode, "decorate.enter"),
5972
+ leave: wrapWithCatch(leaveNode, "decorate.leave")
5407
5973
  });
5408
5974
  }
5409
5975
  return {
@@ -5411,13 +5977,10 @@ var buildDecorations2 = (view, options, focus2) => {
5411
5977
  atomicDeco: atomicDeco.finish()
5412
5978
  };
5413
5979
  };
5414
- var forceUpdate = StateEffect6.define();
5980
+ var forceUpdate = StateEffect7.define();
5415
5981
  var decorateMarkdown = (options = {}) => {
5416
5982
  return [
5417
- ViewPlugin13.fromClass(class {
5418
- constructor(view) {
5419
- ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
5420
- }
5983
+ ViewPlugin15.fromClass(class {
5421
5984
  update(update2) {
5422
5985
  if (update2.docChanged || update2.viewportChanged || update2.focusChanged || update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(forceUpdate))) || update2.selectionSet && !options.selectionChangeDelay) {
5423
5986
  ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(update2.view, options, update2.view.hasFocus));
@@ -5444,11 +6007,17 @@ var decorateMarkdown = (options = {}) => {
5444
6007
  destroy() {
5445
6008
  this.clearUpdate();
5446
6009
  }
6010
+ constructor(view) {
6011
+ _define_property19(this, "deco", void 0);
6012
+ _define_property19(this, "atomicDeco", void 0);
6013
+ _define_property19(this, "pendingUpdate", void 0);
6014
+ ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
6015
+ }
5447
6016
  }, {
5448
6017
  provide: (plugin) => [
5449
- EditorView23.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
5450
- EditorView23.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
5451
- EditorView23.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration11.none)
6018
+ Prec5.low(EditorView25.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration12.none)),
6019
+ EditorView25.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration12.none),
6020
+ EditorView25.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration12.none)
5452
6021
  ]
5453
6022
  }),
5454
6023
  image(),
@@ -5474,6 +6043,9 @@ var linkTooltip = (renderTooltip) => {
5474
6043
  return null;
5475
6044
  }
5476
6045
  const urlText = view.state.sliceDoc(url.from, url.to);
6046
+ if (urlText.startsWith("dxn")) {
6047
+ return null;
6048
+ }
5477
6049
  return {
5478
6050
  pos: link.from,
5479
6051
  end: link.to,
@@ -5501,11 +6073,11 @@ var linkTooltip = (renderTooltip) => {
5501
6073
  };
5502
6074
 
5503
6075
  // src/extensions/mention.ts
5504
- import { autocompletion as autocompletion2 } from "@codemirror/autocomplete";
6076
+ import { autocompletion } from "@codemirror/autocomplete";
5505
6077
  import { log as log6 } from "@dxos/log";
5506
6078
  var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/mention.ts";
5507
6079
  var mention = ({ debug, onSearch }) => {
5508
- return autocompletion2({
6080
+ return autocompletion({
5509
6081
  // TODO(burdon): Not working.
5510
6082
  activateOnTyping: true,
5511
6083
  // activateOnTypingDelay: 100,
@@ -5585,6 +6157,19 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
5585
6157
  import { StateField as StateField10 } from "@codemirror/state";
5586
6158
  import { Facet as Facet2 } from "@codemirror/state";
5587
6159
  import { invariant as invariant5 } from "@dxos/invariant";
6160
+ function _define_property20(obj, key, value) {
6161
+ if (key in obj) {
6162
+ Object.defineProperty(obj, key, {
6163
+ value,
6164
+ enumerable: true,
6165
+ configurable: true,
6166
+ writable: true
6167
+ });
6168
+ } else {
6169
+ obj[key] = value;
6170
+ }
6171
+ return obj;
6172
+ }
5588
6173
  var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/tree.ts";
5589
6174
  var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
5590
6175
  return {
@@ -5597,18 +6182,6 @@ var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) =>
5597
6182
  };
5598
6183
  };
5599
6184
  var Tree = class {
5600
- constructor(node) {
5601
- this.type = "root";
5602
- this.index = -1;
5603
- this.level = -1;
5604
- this.children = [];
5605
- this.node = node;
5606
- this.lineRange = {
5607
- from: node.from,
5608
- to: node.to
5609
- };
5610
- this.contentRange = this.lineRange;
5611
- }
5612
6185
  toJSON() {
5613
6186
  return itemToJSON(this);
5614
6187
  }
@@ -5658,6 +6231,21 @@ var Tree = class {
5658
6231
  lastDescendant(item) {
5659
6232
  return item.children.length > 0 ? this.lastDescendant(item.children.at(-1)) : item;
5660
6233
  }
6234
+ constructor(node) {
6235
+ _define_property20(this, "type", "root");
6236
+ _define_property20(this, "index", -1);
6237
+ _define_property20(this, "level", -1);
6238
+ _define_property20(this, "node", void 0);
6239
+ _define_property20(this, "lineRange", void 0);
6240
+ _define_property20(this, "contentRange", void 0);
6241
+ _define_property20(this, "children", []);
6242
+ this.node = node;
6243
+ this.lineRange = {
6244
+ from: node.from,
6245
+ to: node.to
6246
+ };
6247
+ this.contentRange = this.lineRange;
6248
+ }
5661
6249
  };
5662
6250
  var getRange = (tree, item) => {
5663
6251
  const lastDescendant = tree.lastDescendant(item);
@@ -5718,7 +6306,7 @@ var format = (value) => JSON.stringify(value, (key, value2) => {
5718
6306
  var treeFacet = Facet2.define({
5719
6307
  combine: (values) => values[0]
5720
6308
  });
5721
- var outlinerTree = (options = {}) => {
6309
+ var outlinerTree = (_options = {}) => {
5722
6310
  const buildTree = (state) => {
5723
6311
  let tree;
5724
6312
  let parent;
@@ -6144,18 +6732,18 @@ var commands = () => keymap12.of([
6144
6732
  ]);
6145
6733
 
6146
6734
  // src/extensions/outliner/outliner.ts
6147
- import { Prec as Prec4 } from "@codemirror/state";
6148
- import { Decoration as Decoration12, EditorView as EditorView24, ViewPlugin as ViewPlugin15 } from "@codemirror/view";
6149
- import { mx as mx5 } from "@dxos/react-ui-theme";
6735
+ import { Prec as Prec6 } from "@codemirror/state";
6736
+ import { Decoration as Decoration13, EditorView as EditorView26, ViewPlugin as ViewPlugin17 } from "@codemirror/view";
6737
+ import { mx as mx6 } from "@dxos/react-ui-theme";
6150
6738
 
6151
6739
  // src/extensions/outliner/editor.ts
6152
6740
  import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
6153
- import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
6741
+ import { ViewPlugin as ViewPlugin16 } from "@codemirror/view";
6154
6742
  import { log as log7 } from "@dxos/log";
6155
6743
  var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
6156
6744
  var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
6157
6745
  var initialize = () => {
6158
- return ViewPlugin14.fromClass(class {
6746
+ return ViewPlugin16.fromClass(class {
6159
6747
  constructor(view) {
6160
6748
  const first = view.state.doc.lineAt(0);
6161
6749
  const text = view.state.sliceDoc(first.from, first.to);
@@ -6338,9 +6926,22 @@ var editor = () => [
6338
6926
  ];
6339
6927
 
6340
6928
  // src/extensions/outliner/outliner.ts
6341
- var outliner = (options = {}) => [
6929
+ function _define_property21(obj, key, value) {
6930
+ if (key in obj) {
6931
+ Object.defineProperty(obj, key, {
6932
+ value,
6933
+ enumerable: true,
6934
+ configurable: true,
6935
+ writable: true
6936
+ });
6937
+ } else {
6938
+ obj[key] = value;
6939
+ }
6940
+ return obj;
6941
+ }
6942
+ var outliner = (_options = {}) => [
6342
6943
  // Commands.
6343
- Prec4.highest(commands()),
6944
+ Prec6.highest(commands()),
6344
6945
  // Selection.
6345
6946
  selectionCompartment.of(selectionFacet.of([])),
6346
6947
  // State.
@@ -6356,16 +6957,12 @@ var outliner = (options = {}) => [
6356
6957
  listPaddingLeft: 8
6357
6958
  }),
6358
6959
  // Researve space for menu.
6359
- EditorView24.contentAttributes.of({
6960
+ EditorView26.contentAttributes.of({
6360
6961
  class: "is-full !mr-[3rem]"
6361
6962
  })
6362
6963
  ];
6363
6964
  var decorations = () => [
6364
- ViewPlugin15.fromClass(class {
6365
- constructor(view) {
6366
- this.decorations = Decoration12.none;
6367
- this.updateDecorations(view.state, view);
6368
- }
6965
+ ViewPlugin17.fromClass(class {
6369
6966
  update(update2) {
6370
6967
  const selectionChanged = !selectionEquals(update2.state.facet(selectionFacet), update2.startState.facet(selectionFacet));
6371
6968
  if (update2.focusChanged || update2.docChanged || update2.viewportChanged || update2.selectionSet || selectionChanged) {
@@ -6385,18 +6982,22 @@ var decorations = () => [
6385
6982
  const lineFrom = doc.lineAt(item.contentRange.from);
6386
6983
  const lineTo = doc.lineAt(item.contentRange.to);
6387
6984
  const isSelected = selection.includes(item.index) || item === current;
6388
- decorations2.push(Decoration12.line({
6389
- class: mx5("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
6985
+ decorations2.push(Decoration13.line({
6986
+ class: mx6("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
6390
6987
  }).range(line.from, line.from));
6391
6988
  }
6392
6989
  }
6393
- this.decorations = Decoration12.set(decorations2);
6990
+ this.decorations = Decoration13.set(decorations2);
6991
+ }
6992
+ constructor(view) {
6993
+ _define_property21(this, "decorations", Decoration13.none);
6994
+ this.updateDecorations(view.state, view);
6394
6995
  }
6395
6996
  }, {
6396
6997
  decorations: (v) => v.decorations
6397
6998
  }),
6398
6999
  // Theme.
6399
- EditorView24.theme(Object.assign({
7000
+ EditorView26.theme(Object.assign({
6400
7001
  ".cm-list-item": {
6401
7002
  borderLeftWidth: "1px",
6402
7003
  borderRightWidth: "1px",
@@ -6413,127 +7014,701 @@ var decorations = () => [
6413
7014
  paddingTop: "4px",
6414
7015
  marginTop: "2px"
6415
7016
  },
6416
- ".cm-list-item-end": {
6417
- borderBottomWidth: "1px",
6418
- borderBottomLeftRadius: "4px",
6419
- borderBottomRightRadius: "4px",
6420
- paddingBottom: "4px",
6421
- marginBottom: "2px"
7017
+ ".cm-list-item-end": {
7018
+ borderBottomWidth: "1px",
7019
+ borderBottomLeftRadius: "4px",
7020
+ borderBottomRightRadius: "4px",
7021
+ paddingBottom: "4px",
7022
+ marginBottom: "2px"
7023
+ },
7024
+ ".cm-list-item-focused": {
7025
+ borderColor: "var(--dx-accentFocusIndicator)"
7026
+ },
7027
+ "&:focus-within .cm-list-item-selected": {
7028
+ borderColor: "var(--dx-separator)"
7029
+ }
7030
+ }))
7031
+ ];
7032
+
7033
+ // src/extensions/preview/preview.ts
7034
+ import { syntaxTree as syntaxTree10 } from "@codemirror/language";
7035
+ import { RangeSetBuilder as RangeSetBuilder7, StateField as StateField11 } from "@codemirror/state";
7036
+ import { Decoration as Decoration14, EditorView as EditorView27, WidgetType as WidgetType9 } from "@codemirror/view";
7037
+ function _define_property22(obj, key, value) {
7038
+ if (key in obj) {
7039
+ Object.defineProperty(obj, key, {
7040
+ value,
7041
+ enumerable: true,
7042
+ configurable: true,
7043
+ writable: true
7044
+ });
7045
+ } else {
7046
+ obj[key] = value;
7047
+ }
7048
+ return obj;
7049
+ }
7050
+ var preview = (options = {}) => {
7051
+ return [
7052
+ // NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
7053
+ // "Block decorations may not be specified via plugins".
7054
+ StateField11.define({
7055
+ create: (state) => buildDecorations3(state, options),
7056
+ update: (decorations2, tr) => {
7057
+ if (tr.docChanged) {
7058
+ return buildDecorations3(tr.state, options);
7059
+ }
7060
+ return decorations2.map(tr.changes);
7061
+ },
7062
+ provide: (field) => [
7063
+ EditorView27.decorations.from(field),
7064
+ EditorView27.atomicRanges.of((view) => view.state.field(field))
7065
+ ]
7066
+ })
7067
+ ];
7068
+ };
7069
+ var buildDecorations3 = (state, options) => {
7070
+ const builder = new RangeSetBuilder7();
7071
+ syntaxTree10(state).iterate({
7072
+ enter: (node) => {
7073
+ switch (node.name) {
7074
+ //
7075
+ // Inline widget.
7076
+ // [Label](dxn:echo:123)
7077
+ //
7078
+ case "Link": {
7079
+ const link = getLinkRef(state, node.node);
7080
+ if (link) {
7081
+ builder.add(node.from, node.to, Decoration14.replace({
7082
+ widget: new PreviewInlineWidget(options, link),
7083
+ side: 1
7084
+ }));
7085
+ }
7086
+ return false;
7087
+ }
7088
+ //
7089
+ // Block widget (transclusion).
7090
+ // ![Label](dxn:echo:123)
7091
+ //
7092
+ case "Image": {
7093
+ if (options.addBlockContainer && options.removeBlockContainer) {
7094
+ const link = getLinkRef(state, node.node);
7095
+ if (link) {
7096
+ builder.add(node.from, node.to, Decoration14.replace({
7097
+ block: true,
7098
+ widget: new PreviewBlockWidget(options, link)
7099
+ }));
7100
+ }
7101
+ }
7102
+ return false;
7103
+ }
7104
+ }
7105
+ }
7106
+ });
7107
+ return builder.finish();
7108
+ };
7109
+ var getLinkRef = (state, node) => {
7110
+ const mark = node.getChildren("LinkMark");
7111
+ const urlNode = node.getChild("URL");
7112
+ if (mark && urlNode) {
7113
+ const url = state.sliceDoc(urlNode.from, urlNode.to);
7114
+ if (url.startsWith("dxn:")) {
7115
+ const label = state.sliceDoc(mark[0].to, mark[1].from);
7116
+ return {
7117
+ block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
7118
+ label,
7119
+ ref: url
7120
+ };
7121
+ }
7122
+ }
7123
+ };
7124
+ var PreviewInlineWidget = class extends WidgetType9 {
7125
+ // override ignoreEvent() {
7126
+ // return false;
7127
+ // }
7128
+ eq(other) {
7129
+ return this._link.ref === other._link.ref && this._link.label === other._link.label;
7130
+ }
7131
+ toDOM(_view) {
7132
+ const root = document.createElement("dx-anchor");
7133
+ root.classList.add("dx-tag--anchor");
7134
+ root.textContent = this._link.label;
7135
+ root.setAttribute("refId", this._link.ref);
7136
+ return root;
7137
+ }
7138
+ constructor(_options, _link) {
7139
+ super(), _define_property22(this, "_options", void 0), _define_property22(this, "_link", void 0), this._options = _options, this._link = _link;
7140
+ }
7141
+ };
7142
+ var PreviewBlockWidget = class extends WidgetType9 {
7143
+ // override ignoreEvent() {
7144
+ // return true;
7145
+ // }
7146
+ eq(other) {
7147
+ return this._link.ref === other._link.ref;
7148
+ }
7149
+ toDOM(_view) {
7150
+ const root = document.createElement("div");
7151
+ root.classList.add("cm-preview-block", "density-coarse");
7152
+ this._options.addBlockContainer?.(this._link, root);
7153
+ return root;
7154
+ }
7155
+ destroy() {
7156
+ this._options.removeBlockContainer?.(this._link);
7157
+ }
7158
+ constructor(_options, _link) {
7159
+ super(), _define_property22(this, "_options", void 0), _define_property22(this, "_link", void 0), this._options = _options, this._link = _link;
7160
+ }
7161
+ };
7162
+
7163
+ // src/extensions/tags/extended-markdown.ts
7164
+ import { xmlLanguage } from "@codemirror/lang-xml";
7165
+ import { parseMixed } from "@lezer/common";
7166
+ var extendedMarkdown = ({ registry } = {}) => {
7167
+ return [
7168
+ createMarkdownExtensions({
7169
+ extensions: [
7170
+ {
7171
+ wrap: mixedParser(registry),
7172
+ parseBlock: [
7173
+ // Disable SetextHeading since it causes flickering when parsing/rendering tasks in chunks.
7174
+ {
7175
+ name: "SetextHeading",
7176
+ parse: () => false
7177
+ }
7178
+ ]
7179
+ }
7180
+ ]
7181
+ })
7182
+ ];
7183
+ };
7184
+ var mixedParser = (registry) => {
7185
+ const customTags = Object.keys(registry ?? {});
7186
+ const tagPattern = new RegExp(`<(${customTags.join("|")})`);
7187
+ return parseMixed((node, input) => {
7188
+ switch (node.name) {
7189
+ // Ignore XML inside of fenced and inline code.
7190
+ case "FencedCode":
7191
+ case "InlineCode": {
7192
+ return null;
7193
+ }
7194
+ // Parse multi-line HTML blocks.
7195
+ // case 'XMLBlock':
7196
+ case "HTMLBlock": {
7197
+ return {
7198
+ parser: xmlLanguage.parser
7199
+ };
7200
+ }
7201
+ // Parse paragraphs that contain custom XML tags.
7202
+ // TODO(burdon): Entire paragraph should be parsed as XML.
7203
+ case "Paragraph": {
7204
+ const content = input.read(node.from, node.to);
7205
+ if (tagPattern.test(content)) {
7206
+ return {
7207
+ parser: xmlLanguage.parser
7208
+ };
7209
+ }
7210
+ return null;
7211
+ }
7212
+ }
7213
+ return null;
7214
+ });
7215
+ };
7216
+
7217
+ // src/extensions/tags/streamer.ts
7218
+ import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
7219
+ import { Decoration as Decoration15, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType10 } from "@codemirror/view";
7220
+ import { isNotFalsy as isNotFalsy4 } from "@dxos/util";
7221
+ function _define_property23(obj, key, value) {
7222
+ if (key in obj) {
7223
+ Object.defineProperty(obj, key, {
7224
+ value,
7225
+ enumerable: true,
7226
+ configurable: true,
7227
+ writable: true
7228
+ });
7229
+ } else {
7230
+ obj[key] = value;
7231
+ }
7232
+ return obj;
7233
+ }
7234
+ var BLINK_RATE = 2e3;
7235
+ var streamer = (options = {}) => {
7236
+ return [
7237
+ options.cursor && cursor(),
7238
+ options.fadeIn && fadeIn(typeof options.fadeIn === "object" ? options.fadeIn : {})
7239
+ ].filter(isNotFalsy4);
7240
+ };
7241
+ var cursor = () => {
7242
+ const hideCursor = StateEffect8.define();
7243
+ const showCursor = StateField12.define({
7244
+ create: () => true,
7245
+ update: (value, tr) => {
7246
+ for (const effect of tr.effects) {
7247
+ if (effect.is(hideCursor)) {
7248
+ return false;
7249
+ }
7250
+ }
7251
+ if (tr.docChanged) {
7252
+ return true;
7253
+ }
7254
+ return value;
7255
+ }
7256
+ });
7257
+ const timerPlugin = ViewPlugin18.fromClass(class {
7258
+ update(update2) {
7259
+ if (update2.docChanged) {
7260
+ clearTimeout(this.timer);
7261
+ this.timer = setTimeout(() => {
7262
+ this.view.dispatch({
7263
+ effects: hideCursor.of(null)
7264
+ });
7265
+ }, BLINK_RATE);
7266
+ }
7267
+ }
7268
+ destroy() {
7269
+ clearTimeout(this.timer);
7270
+ }
7271
+ constructor(view) {
7272
+ _define_property23(this, "view", void 0);
7273
+ _define_property23(this, "timer", void 0);
7274
+ this.view = view;
7275
+ }
7276
+ });
7277
+ const cursorDecoration = StateField12.define({
7278
+ create: () => Decoration15.none,
7279
+ update: (_decorations, tr) => {
7280
+ const show = tr.state.field(showCursor);
7281
+ if (!show) {
7282
+ return Decoration15.none;
7283
+ }
7284
+ const endPos = tr.state.doc.length;
7285
+ return Decoration15.set([
7286
+ Decoration15.widget({
7287
+ widget: new CursorWidget(),
7288
+ side: 1
7289
+ }).range(endPos)
7290
+ ]);
7291
+ },
7292
+ provide: (f) => EditorView28.decorations.from(f)
7293
+ });
7294
+ return [
7295
+ showCursor,
7296
+ timerPlugin,
7297
+ cursorDecoration
7298
+ ];
7299
+ };
7300
+ var CursorWidget = class extends WidgetType10 {
7301
+ toDOM() {
7302
+ return Domino.of("span").style({
7303
+ opacity: "0.8"
7304
+ }).child(Domino.of("span").text("\u258F").style({
7305
+ animation: "blink 2s infinite"
7306
+ })).build();
7307
+ }
7308
+ };
7309
+ var fadeIn = (options = {}) => {
7310
+ const FADE_IN_DURATION = 1e3;
7311
+ const DEFAULT_REMOVAL_DELAY = 5e3;
7312
+ const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
7313
+ const removeDecoration = StateEffect8.define();
7314
+ const fadeField = StateField12.define({
7315
+ create: () => Decoration15.none,
7316
+ update: (decorations2, tr) => {
7317
+ let next = decorations2;
7318
+ for (const effect of tr.effects) {
7319
+ if (effect.is(removeDecoration)) {
7320
+ const target = effect.value;
7321
+ next = next.update({
7322
+ filter: (from, to) => !(from === target.from && to === target.to)
7323
+ });
7324
+ }
7325
+ }
7326
+ if (!tr.docChanged) {
7327
+ return next;
7328
+ }
7329
+ let isReset = tr.state.doc.length === 0;
7330
+ if (!isReset) {
7331
+ tr.changes.iterChanges((fromA, toA) => {
7332
+ if (fromA === 0 && toA === tr.startState.doc.length) {
7333
+ isReset = true;
7334
+ }
7335
+ });
7336
+ }
7337
+ if (isReset) {
7338
+ return Decoration15.none;
7339
+ }
7340
+ const add = [];
7341
+ tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
7342
+ if (fromB === 0 && toB === inserted.length) {
7343
+ return;
7344
+ }
7345
+ if (toA === tr.startState.doc.length && inserted.length > 0) {
7346
+ add.push(Decoration15.mark({
7347
+ class: "cm-fade-in"
7348
+ }).range(fromB, toB));
7349
+ }
7350
+ });
7351
+ return next.update({
7352
+ add
7353
+ });
7354
+ },
7355
+ provide: (f) => EditorView28.decorations.from(f)
7356
+ });
7357
+ const timerPlugin = ViewPlugin18.fromClass(class {
7358
+ update(update2) {
7359
+ if (!update2.docChanged) {
7360
+ return;
7361
+ }
7362
+ update2.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
7363
+ if (toA !== update2.startState.doc.length || inserted.length === 0) {
7364
+ return;
7365
+ }
7366
+ const key = `${fromB}-${toB}`;
7367
+ if (this._timers.has(key)) {
7368
+ clearTimeout(this._timers.get(key));
7369
+ }
7370
+ const totalDelay = FADE_IN_DURATION + removalDelay;
7371
+ const id = setTimeout(() => {
7372
+ this.view.dispatch({
7373
+ effects: removeDecoration.of({
7374
+ from: fromB,
7375
+ to: toB
7376
+ })
7377
+ });
7378
+ this._timers.delete(key);
7379
+ }, totalDelay);
7380
+ this._timers.set(key, id);
7381
+ });
7382
+ }
7383
+ destroy() {
7384
+ for (const id of this._timers.values()) {
7385
+ clearTimeout(id);
7386
+ }
7387
+ this._timers.clear();
7388
+ }
7389
+ constructor(view) {
7390
+ _define_property23(this, "view", void 0);
7391
+ _define_property23(this, "_timers", void 0);
7392
+ this.view = view;
7393
+ this._timers = /* @__PURE__ */ new Map();
7394
+ }
7395
+ });
7396
+ return [
7397
+ fadeField,
7398
+ timerPlugin,
7399
+ EditorView28.theme({
7400
+ ".cm-line > span": {
7401
+ opacity: "0.8"
7402
+ },
7403
+ ".cm-fade-in": {
7404
+ animation: "fade-in 3s ease-out forwards"
7405
+ },
7406
+ "@keyframes fade-in": {
7407
+ "0%": {
7408
+ opacity: "0"
7409
+ },
7410
+ "80%": {
7411
+ opacity: "1"
7412
+ },
7413
+ "100%": {
7414
+ opacity: "0.8"
7415
+ }
7416
+ }
7417
+ })
7418
+ ];
7419
+ };
7420
+
7421
+ // src/extensions/tags/xml-tags.ts
7422
+ import { syntaxTree as syntaxTree11 } from "@codemirror/language";
7423
+ import { RangeSetBuilder as RangeSetBuilder8, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
7424
+ import { Decoration as Decoration16, EditorView as EditorView29, WidgetType as WidgetType11 } from "@codemirror/view";
7425
+ import { invariant as invariant7 } from "@dxos/invariant";
7426
+ import { log as log8 } from "@dxos/log";
7427
+
7428
+ // src/extensions/tags/xml-util.ts
7429
+ import { invariant as invariant6 } from "@dxos/invariant";
7430
+ var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/tags/xml-util.ts";
7431
+ var nodeToJson = (state, node) => {
7432
+ invariant6(node.type.name === "Element", "Node is not an Element", {
7433
+ F: __dxlog_file13,
7434
+ L: 18,
7435
+ S: void 0,
7436
+ A: [
7437
+ "node.type.name === 'Element'",
7438
+ "'Node is not an Element'"
7439
+ ]
7440
+ });
7441
+ const openTag = node.node.getChild("OpenTag") || node.node.getChild("SelfClosingTag");
7442
+ if (openTag) {
7443
+ const tagName = openTag.getChild("TagName");
7444
+ if (!tagName) {
7445
+ return;
7446
+ }
7447
+ const tag = {
7448
+ _tag: state.doc.sliceString(tagName.from, tagName.to)
7449
+ };
7450
+ let attributeNode = openTag.getChild("Attribute");
7451
+ while (attributeNode) {
7452
+ const attrName = attributeNode.getChild("AttributeName");
7453
+ const attrValue = attributeNode.getChild("AttributeValue");
7454
+ if (attrName) {
7455
+ const attr = state.doc.sliceString(attrName.from, attrName.to);
7456
+ let value = true;
7457
+ if (attrValue) {
7458
+ const rawValue = state.doc.sliceString(attrValue.from, attrValue.to);
7459
+ if (rawValue.startsWith('"') && rawValue.endsWith('"') || rawValue.startsWith("'") && rawValue.endsWith("'")) {
7460
+ value = rawValue.slice(1, -1);
7461
+ } else {
7462
+ value = rawValue;
7463
+ }
7464
+ }
7465
+ tag[attr] = value;
7466
+ }
7467
+ attributeNode = attributeNode.nextSibling;
7468
+ }
7469
+ if (node.type.name === "Element" && openTag.type.name !== "SelfClosingTag") {
7470
+ const children = [];
7471
+ let child = node.node.firstChild;
7472
+ while (child) {
7473
+ if (child.type.name !== "OpenTag" && child.type.name !== "CloseTag") {
7474
+ if (child.type.name === "Text") {
7475
+ const text = state.doc.sliceString(child.from, child.to).trim();
7476
+ if (text) {
7477
+ children.push(text);
7478
+ }
7479
+ } else if (child.type.name === "Element") {
7480
+ const data = nodeToJson(state, child);
7481
+ if (data) {
7482
+ children.push(data);
7483
+ }
7484
+ }
7485
+ }
7486
+ child = child.nextSibling;
7487
+ }
7488
+ if (children.length > 0) {
7489
+ tag.children = children;
7490
+ }
7491
+ }
7492
+ return tag;
7493
+ }
7494
+ };
7495
+
7496
+ // src/extensions/tags/xml-tags.ts
7497
+ function _define_property24(obj, key, value) {
7498
+ if (key in obj) {
7499
+ Object.defineProperty(obj, key, {
7500
+ value,
7501
+ enumerable: true,
7502
+ configurable: true,
7503
+ writable: true
7504
+ });
7505
+ } else {
7506
+ obj[key] = value;
7507
+ }
7508
+ return obj;
7509
+ }
7510
+ var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/tags/xml-tags.ts";
7511
+ var xmlTagContextEffect = StateEffect9.define();
7512
+ var xmlTagUpdateEffect = StateEffect9.define();
7513
+ var xmlTagResetEffect = StateEffect9.define();
7514
+ var xmlTags = (options = {}) => {
7515
+ const contextState = StateField13.define({
7516
+ create: () => void 0,
7517
+ update: (value, tr) => {
7518
+ for (const effect of tr.effects) {
7519
+ if (effect.is(xmlTagContextEffect)) {
7520
+ return effect.value;
7521
+ }
7522
+ }
7523
+ return value;
7524
+ }
7525
+ });
7526
+ const widgets = /* @__PURE__ */ new Map();
7527
+ const notifier = {
7528
+ mounted: (widget) => {
7529
+ widgets.set(widget.id, widget);
7530
+ options.setWidgets?.([
7531
+ ...widgets.values()
7532
+ ]);
7533
+ },
7534
+ unmounted: (id) => {
7535
+ widgets.delete(id);
7536
+ options.setWidgets?.([
7537
+ ...widgets.values()
7538
+ ]);
7539
+ }
7540
+ };
7541
+ const decorationsState = StateField13.define({
7542
+ create: (state) => {
7543
+ return buildDecorations4(state, 0, state.doc.length, state.field(contextState), state.field(widgetState), options, notifier);
6422
7544
  },
6423
- ".cm-list-item-focused": {
6424
- borderColor: "var(--dx-accentFocusIndicator)"
7545
+ update: ({ from, decorations: decorations2 }, tr) => {
7546
+ for (const effect of tr.effects) {
7547
+ if (effect.is(xmlTagResetEffect)) {
7548
+ return {
7549
+ from: 0,
7550
+ decorations: Decoration16.none
7551
+ };
7552
+ }
7553
+ }
7554
+ if (tr.docChanged) {
7555
+ const { state } = tr;
7556
+ const reset = tr.changes.touchesRange(0, from);
7557
+ const result = buildDecorations4(state, reset ? 0 : from, state.doc.length, state.field(contextState), state.field(widgetState), options, notifier);
7558
+ return {
7559
+ from: result.from,
7560
+ decorations: decorations2.update({
7561
+ add: decorationSetToArray(result.decorations)
7562
+ })
7563
+ };
7564
+ }
7565
+ return {
7566
+ from,
7567
+ decorations: decorations2
7568
+ };
6425
7569
  },
6426
- "[data-has-focus] & .cm-list-item-selected": {
6427
- borderColor: "var(--dx-separator)"
7570
+ provide: (field) => [
7571
+ EditorView29.decorations.from(field, (v) => v.decorations),
7572
+ EditorView29.atomicRanges.of((view) => view.state.field(field).decorations || Decoration16.none)
7573
+ ]
7574
+ });
7575
+ const widgetState = StateField13.define({
7576
+ create: () => ({}),
7577
+ update: (map, tr) => {
7578
+ for (const effect of tr.effects) {
7579
+ if (effect.is(xmlTagResetEffect)) {
7580
+ return {};
7581
+ }
7582
+ if (effect.is(xmlTagUpdateEffect)) {
7583
+ const { id, value } = effect.value;
7584
+ const state = typeof value === "function" ? value(map[id]) : value;
7585
+ const { decorations: decorations2 } = tr.state.field(decorationsState);
7586
+ for (const range of decorationSetToArray(decorations2)) {
7587
+ const deco = range.value;
7588
+ const widget = deco?.spec?.widget;
7589
+ if (widget && widget instanceof PlaceholderWidget && widget.id === effect.value.id && widget.root) {
7590
+ const props = {
7591
+ ...widget.props,
7592
+ ...state
7593
+ };
7594
+ notifier.mounted({
7595
+ id: widget.id,
7596
+ props,
7597
+ root: widget.root,
7598
+ Component: widget.Component
7599
+ });
7600
+ }
7601
+ }
7602
+ return {
7603
+ ...map,
7604
+ [id]: state
7605
+ };
7606
+ }
7607
+ }
7608
+ return map;
6428
7609
  }
6429
- }))
6430
- ];
6431
-
6432
- // src/extensions/preview/preview.ts
6433
- import "@dxos/lit-ui/dx-ref-tag.pcss";
6434
- import { syntaxTree as syntaxTree10 } from "@codemirror/language";
6435
- import { RangeSetBuilder as RangeSetBuilder7, StateField as StateField11 } from "@codemirror/state";
6436
- import { Decoration as Decoration13, EditorView as EditorView25, WidgetType as WidgetType8 } from "@codemirror/view";
6437
- var preview = (options = {}) => {
7610
+ });
6438
7611
  return [
6439
- // NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
6440
- // "Block decorations may not be specified via plugins"
6441
- StateField11.define({
6442
- create: (state) => buildDecorations3(state, options),
6443
- update: (_, tr) => buildDecorations3(tr.state, options),
6444
- provide: (field) => [
6445
- EditorView25.decorations.from(field),
6446
- EditorView25.atomicRanges.of((view) => view.state.field(field))
6447
- ]
6448
- })
7612
+ contextState,
7613
+ decorationsState,
7614
+ widgetState
6449
7615
  ];
6450
7616
  };
6451
- var getLinkRef = (state, node) => {
6452
- const mark = node.getChild("LinkMark");
6453
- const label = node.getChild("LinkLabel");
6454
- if (mark && label) {
6455
- const ref = state.sliceDoc(label.from + 1, label.to - 1);
7617
+ var buildDecorations4 = (state, from, to, context, widgetState, options, notifier) => {
7618
+ const builder = new RangeSetBuilder8();
7619
+ const tree = syntaxTree11(state);
7620
+ if (!tree || tree.type.name === "Program" && tree.length === 0) {
6456
7621
  return {
6457
- suggest: ref.startsWith("?"),
6458
- block: state.sliceDoc(mark.from, mark.from + 1) === "!",
6459
- label: state.sliceDoc(mark.to, label.from - 1),
6460
- ref: ref.startsWith("?") ? ref.slice(1) : ref
7622
+ from,
7623
+ decorations: Decoration16.none
6461
7624
  };
6462
7625
  }
6463
- };
6464
- var buildDecorations3 = (state, options) => {
6465
- const builder = new RangeSetBuilder7();
6466
- syntaxTree10(state).iterate({
7626
+ tree.iterate({
7627
+ from,
7628
+ to,
6467
7629
  enter: (node) => {
6468
- switch (node.name) {
6469
- //
6470
- // Decoration.
6471
- // [Label][dxn:echo:123]
6472
- //
6473
- case "Link": {
6474
- const link = getLinkRef(state, node.node);
6475
- if (link) {
6476
- builder.add(node.from, node.to, Decoration13.replace({
6477
- widget: new PreviewInlineWidget(options, link)
6478
- }));
6479
- }
6480
- break;
6481
- }
6482
- //
6483
- // Block widget.
6484
- // ![Label][dxn:echo:123]
6485
- //
6486
- case "Image": {
6487
- const link = getLinkRef(state, node.node);
6488
- if (options.addBlockContainer && options.removeBlockContainer && link) {
6489
- builder.add(node.from, node.to, Decoration13.replace({
6490
- block: true,
6491
- // atomic: true,
6492
- widget: new PreviewBlockWidget(options, link)
6493
- }));
7630
+ switch (node.type.name) {
7631
+ // XML Element.
7632
+ case "Element": {
7633
+ try {
7634
+ if (options.registry) {
7635
+ const props = nodeToJson(state, node.node);
7636
+ if (props) {
7637
+ const def = options.registry[props._tag];
7638
+ if (def) {
7639
+ const { block, factory, Component } = def;
7640
+ const state2 = props.id ? widgetState[props.id] : void 0;
7641
+ const args = {
7642
+ context,
7643
+ ...props,
7644
+ ...state2
7645
+ };
7646
+ const widget = factory ? factory(args) : Component ? props.id && new PlaceholderWidget(props.id, Component, args, notifier) : void 0;
7647
+ if (widget) {
7648
+ from = node.node.to;
7649
+ builder.add(node.node.from, node.node.to, Decoration16.replace({
7650
+ widget,
7651
+ block,
7652
+ atomic: true,
7653
+ inclusive: true
7654
+ }));
7655
+ }
7656
+ }
7657
+ }
7658
+ }
7659
+ } catch (err) {
7660
+ log8.catch(err, void 0, {
7661
+ F: __dxlog_file14,
7662
+ L: 285,
7663
+ S: void 0,
7664
+ C: (f, a) => f(...a)
7665
+ });
6494
7666
  }
6495
- break;
7667
+ return false;
6496
7668
  }
6497
7669
  }
6498
7670
  }
6499
7671
  });
6500
- return builder.finish();
7672
+ return {
7673
+ from,
7674
+ decorations: builder.finish()
7675
+ };
6501
7676
  };
6502
- var PreviewInlineWidget = class extends WidgetType8 {
6503
- constructor(_options, _link) {
6504
- super(), this._options = _options, this._link = _link;
7677
+ var PlaceholderWidget = class _PlaceholderWidget extends WidgetType11 {
7678
+ get root() {
7679
+ return this._root;
6505
7680
  }
6506
- // override ignoreEvent() {
6507
- // return false;
6508
- // }
6509
7681
  eq(other) {
6510
- return this._link.ref === other._link.ref && this._link.label === other._link.label;
6511
- }
6512
- toDOM(view) {
6513
- const root = document.createElement("dx-ref-tag");
6514
- root.textContent = this._link.label;
6515
- root.setAttribute("refId", this._link.ref);
6516
- return root;
7682
+ return other instanceof _PlaceholderWidget && this.id === other.id;
6517
7683
  }
6518
- };
6519
- var PreviewBlockWidget = class extends WidgetType8 {
6520
- constructor(_options, _link) {
6521
- super(), this._options = _options, this._link = _link;
7684
+ ignoreEvent() {
7685
+ return true;
6522
7686
  }
6523
- // override ignoreEvent() {
6524
- // return true;
6525
- // }
6526
- eq(other) {
6527
- return this._link.ref === other._link.ref;
7687
+ toDOM(_view) {
7688
+ this._root = document.createElement("span");
7689
+ this.notifier.mounted({
7690
+ id: this.id,
7691
+ props: this.props,
7692
+ root: this._root,
7693
+ Component: this.Component
7694
+ });
7695
+ return this._root;
6528
7696
  }
6529
- toDOM(view) {
6530
- const root = document.createElement("div");
6531
- root.classList.add("cm-preview-block", "density-coarse");
6532
- this._options.addBlockContainer?.(this._link, root);
6533
- return root;
7697
+ destroy(_dom) {
7698
+ this.notifier.unmounted(this.id);
7699
+ this._root = null;
6534
7700
  }
6535
- destroy() {
6536
- this._options.removeBlockContainer?.(this._link);
7701
+ constructor(id, Component, props, notifier) {
7702
+ super(), _define_property24(this, "id", void 0), _define_property24(this, "Component", void 0), _define_property24(this, "props", void 0), _define_property24(this, "notifier", void 0), _define_property24(this, "_root", void 0), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier, this._root = null;
7703
+ invariant7(id, void 0, {
7704
+ F: __dxlog_file14,
7705
+ L: 310,
7706
+ S: this,
7707
+ A: [
7708
+ "id",
7709
+ ""
7710
+ ]
7711
+ });
6537
7712
  }
6538
7713
  };
6539
7714
 
@@ -6595,7 +7770,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
6595
7770
  };
6596
7771
 
6597
7772
  // src/hooks/useTextEditor.ts
6598
- var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
7773
+ var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/hooks/useTextEditor.ts";
6599
7774
  var instanceCount = 0;
6600
7775
  var useTextEditor = (props = {}, deps = []) => {
6601
7776
  const { id, doc, initialValue, extensions, autoFocus, scrollTo, selection, moveToEndOfLine, debug } = useMemo3(() => getProviderValue(props), deps ?? []);
@@ -6605,12 +7780,12 @@ var useTextEditor = (props = {}, deps = []) => {
6605
7780
  useEffect2(() => {
6606
7781
  let view2;
6607
7782
  if (parentRef.current) {
6608
- log8("create", {
7783
+ log9("create", {
6609
7784
  id,
6610
7785
  instanceId,
6611
7786
  doc: initialValue?.length ?? 0
6612
7787
  }, {
6613
- F: __dxlog_file13,
7788
+ F: __dxlog_file15,
6614
7789
  L: 75,
6615
7790
  S: void 0,
6616
7791
  C: (f, a) => f(...a)
@@ -6634,20 +7809,20 @@ var useTextEditor = (props = {}, deps = []) => {
6634
7809
  id && documentId.of(id),
6635
7810
  extensions,
6636
7811
  // NOTE: This doesn't catch errors in keymap functions.
6637
- EditorView26.exceptionSink.of((err) => {
6638
- log8.catch(err, void 0, {
6639
- F: __dxlog_file13,
7812
+ EditorView30.exceptionSink.of((err) => {
7813
+ log9.catch(err, void 0, {
7814
+ F: __dxlog_file15,
6640
7815
  L: 97,
6641
7816
  S: void 0,
6642
7817
  C: (f, a) => f(...a)
6643
7818
  });
6644
7819
  })
6645
- ].filter(isNotFalsy4)
7820
+ ].filter(isNotFalsy5)
6646
7821
  });
6647
- view2 = new EditorView26({
7822
+ view2 = new EditorView30({
6648
7823
  parent: parentRef.current,
6649
7824
  state,
6650
- scrollTo: scrollTo ? EditorView26.scrollIntoView(scrollTo, {
7825
+ scrollTo: scrollTo ? EditorView30.scrollIntoView(scrollTo, {
6651
7826
  yMargin: 96
6652
7827
  }) : void 0,
6653
7828
  dispatchTransactions: debug ? debugDispatcher : void 0
@@ -6665,11 +7840,11 @@ var useTextEditor = (props = {}, deps = []) => {
6665
7840
  setView(view2);
6666
7841
  }
6667
7842
  return () => {
6668
- log8("destroy", {
7843
+ log9("destroy", {
6669
7844
  id
6670
7845
  }, {
6671
- F: __dxlog_file13,
6672
- L: 134,
7846
+ F: __dxlog_file15,
7847
+ L: 122,
6673
7848
  S: void 0,
6674
7849
  C: (f, a) => f(...a)
6675
7850
  });
@@ -6680,13 +7855,13 @@ var useTextEditor = (props = {}, deps = []) => {
6680
7855
  if (view) {
6681
7856
  if (scrollTo || selection) {
6682
7857
  if (selection && selection.anchor > view.state.doc.length) {
6683
- log8.warn("invalid selection", {
7858
+ log9.warn("invalid selection", {
6684
7859
  length: view.state.doc.length,
6685
7860
  scrollTo,
6686
7861
  selection
6687
7862
  }, {
6688
- F: __dxlog_file13,
6689
- L: 143,
7863
+ F: __dxlog_file15,
7864
+ L: 131,
6690
7865
  S: void 0,
6691
7866
  C: (f, a) => f(...a)
6692
7867
  });
@@ -6760,7 +7935,7 @@ var Editor = /* @__PURE__ */ forwardRef(({ classNames, id, text, ...props }, for
6760
7935
  ]);
6761
7936
  return /* @__PURE__ */ React3.createElement("div", {
6762
7937
  ref: parentRef,
6763
- className: mx6(classNames),
7938
+ className: mx7(classNames),
6764
7939
  ...focusAttributes
6765
7940
  });
6766
7941
  } finally {
@@ -6783,23 +7958,32 @@ import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
6783
7958
  var useEditorToolbarState = (initialState = {}) => {
6784
7959
  return useMemo4(() => live(initialState), []);
6785
7960
  };
6786
- var createEditorAction = (id, invoke, properties) => {
7961
+ var createEditorAction = (id, props, invoke) => {
6787
7962
  const { label = [
6788
7963
  `${id} label`,
6789
7964
  {
6790
7965
  ns: translationKey
6791
7966
  }
6792
- ], ...rest } = properties;
7967
+ ], ...rest } = props;
6793
7968
  return createMenuAction(id, invoke, {
6794
7969
  label,
6795
7970
  ...rest
6796
7971
  });
6797
7972
  };
6798
- var createEditorActionGroup = (id, props, icon) => createMenuItemGroup(id, {
6799
- icon,
6800
- iconOnly: true,
6801
- ...props
6802
- });
7973
+ var createEditorActionGroup = (id, props, icon) => {
7974
+ const { label = [
7975
+ `${id} label`,
7976
+ {
7977
+ ns: translationKey
7978
+ }
7979
+ ], ...rest } = props;
7980
+ return createMenuItemGroup(id, {
7981
+ label,
7982
+ icon,
7983
+ iconOnly: true,
7984
+ ...rest
7985
+ });
7986
+ };
6803
7987
 
6804
7988
  // src/components/EditorToolbar/blocks.ts
6805
7989
  var createBlockGroupAction = (value) => createEditorActionGroup("block", {
@@ -6813,7 +7997,13 @@ var createBlockActions = (value, getView, blankLine) => Object.entries({
6813
7997
  table: "ph--table--regular"
6814
7998
  }).map(([type, icon]) => {
6815
7999
  const checked = type === value;
6816
- return createEditorAction(type, () => {
8000
+ return createEditorAction(type, {
8001
+ checked,
8002
+ ...type === "table" && {
8003
+ disabled: !!blankLine
8004
+ },
8005
+ icon
8006
+ }, () => {
6817
8007
  const view = getView();
6818
8008
  if (!view) {
6819
8009
  return;
@@ -6829,12 +8019,6 @@ var createBlockActions = (value, getView, blankLine) => Object.entries({
6829
8019
  insertTable(view);
6830
8020
  break;
6831
8021
  }
6832
- }, {
6833
- checked,
6834
- ...type === "table" && {
6835
- disabled: !!blankLine
6836
- },
6837
- icon
6838
8022
  });
6839
8023
  });
6840
8024
  var createBlocks = (state, getView) => {
@@ -6874,7 +8058,10 @@ var createFormattingGroup = (formatting) => createEditorActionGroup("formatting"
6874
8058
  });
6875
8059
  var createFormattingActions = (formatting, getView) => Object.entries(formats).map(([type, icon]) => {
6876
8060
  const checked = !!formatting[type];
6877
- return createEditorAction(type, () => {
8061
+ return createEditorAction(type, {
8062
+ checked,
8063
+ icon
8064
+ }, () => {
6878
8065
  const view = getView();
6879
8066
  if (!view) {
6880
8067
  return;
@@ -6885,9 +8072,6 @@ var createFormattingActions = (formatting, getView) => Object.entries(formats).m
6885
8072
  }
6886
8073
  const inlineType = type === "strong" ? Inline.Strong : type === "emphasis" ? Inline.Emphasis : type === "strikethrough" ? Inline.Strikethrough : Inline.Code;
6887
8074
  setStyle(inlineType, !checked)(view);
6888
- }, {
6889
- checked,
6890
- icon
6891
8075
  });
6892
8076
  });
6893
8077
  var createFormatting = (state, getView) => {
@@ -6928,7 +8112,7 @@ var createHeadingActions = (getView) => Object.entries({
6928
8112
  "6": "ph--text-h-six--regular"
6929
8113
  }).map(([levelStr, icon]) => {
6930
8114
  const level = parseInt(levelStr);
6931
- return createEditorAction(`heading--${levelStr}`, () => setHeading(level)(getView()), {
8115
+ return createEditorAction(`heading--${levelStr}`, {
6932
8116
  label: [
6933
8117
  "heading level label",
6934
8118
  {
@@ -6937,7 +8121,7 @@ var createHeadingActions = (getView) => Object.entries({
6937
8121
  }
6938
8122
  ],
6939
8123
  icon
6940
- });
8124
+ }, () => setHeading(level)(getView()));
6941
8125
  });
6942
8126
  var computeHeadingValue = (state) => {
6943
8127
  const blockType = state ? state.blockType : "paragraph";
@@ -6967,10 +8151,10 @@ var createHeadings = (state, getView) => {
6967
8151
  };
6968
8152
 
6969
8153
  // src/components/EditorToolbar/image.ts
6970
- var createImageUploadAction = (onImageUpload) => createEditorAction("image", onImageUpload, {
8154
+ var createImageUploadAction = (onImageUpload) => createEditorAction("image", {
6971
8155
  testId: "editor.toolbar.image",
6972
8156
  icon: "ph--image-square--regular"
6973
- });
8157
+ }, onImageUpload);
6974
8158
  var createImageUpload = (onImageUpload) => ({
6975
8159
  nodes: [
6976
8160
  createImageUploadAction(onImageUpload)
@@ -6996,7 +8180,10 @@ var createListGroupAction = (value) => createEditorActionGroup("list", {
6996
8180
  });
6997
8181
  var createListActions = (value, getView) => Object.entries(listStyles).map(([listStyle, icon]) => {
6998
8182
  const checked = value === listStyle;
6999
- return createEditorAction(`list-${listStyle}`, () => {
8183
+ return createEditorAction(`list-${listStyle}`, {
8184
+ checked,
8185
+ icon
8186
+ }, () => {
7000
8187
  const view = getView();
7001
8188
  if (!view) {
7002
8189
  return;
@@ -7007,9 +8194,6 @@ var createListActions = (value, getView) => Object.entries(listStyles).map(([lis
7007
8194
  } else {
7008
8195
  addList(listType)(view);
7009
8196
  }
7010
- }, {
7011
- checked,
7012
- icon
7013
8197
  });
7014
8198
  });
7015
8199
  var createLists = (state, getView) => {
@@ -7036,10 +8220,10 @@ var createLists = (state, getView) => {
7036
8220
 
7037
8221
  // src/components/EditorToolbar/search.ts
7038
8222
  import { openSearchPanel } from "@codemirror/search";
7039
- var createSearchAction = (getView) => createEditorAction("search", () => openSearchPanel(getView()), {
8223
+ var createSearchAction = (getView) => createEditorAction("search", {
7040
8224
  testId: "editor.toolbar.search",
7041
8225
  icon: "ph--magnifying-glass--regular"
7042
- });
8226
+ }, () => openSearchPanel(getView()));
7043
8227
  var createSearch = (getView) => ({
7044
8228
  nodes: [
7045
8229
  createSearchAction(getView)
@@ -7065,7 +8249,7 @@ var createViewModeActions = (value, onViewModeChange) => Object.entries({
7065
8249
  readonly: "ph--pencil-slash--regular"
7066
8250
  }).map(([viewMode, icon]) => {
7067
8251
  const checked = viewMode === value;
7068
- return createEditorAction(`view-mode--${viewMode}`, () => onViewModeChange(viewMode), {
8252
+ return createEditorAction(`view-mode--${viewMode}`, {
7069
8253
  label: [
7070
8254
  `${viewMode} mode label`,
7071
8255
  {
@@ -7074,7 +8258,7 @@ var createViewModeActions = (value, onViewModeChange) => Object.entries({
7074
8258
  ],
7075
8259
  checked,
7076
8260
  icon
7077
- });
8261
+ }, () => onViewModeChange(viewMode));
7078
8262
  });
7079
8263
  var createViewMode = (state, onViewModeChange) => {
7080
8264
  const value = state.viewMode ?? "source";
@@ -7099,61 +8283,62 @@ var createViewMode = (state, onViewModeChange) => {
7099
8283
  };
7100
8284
 
7101
8285
  // src/components/EditorToolbar/EditorToolbar.tsx
7102
- var createToolbar = ({ getView, state, customActions, ...features }) => {
8286
+ var createToolbarActions = ({ getView, state, customActions, ...features }) => {
7103
8287
  return Rx.make((get2) => {
7104
- const nodes = [];
7105
- const edges = [];
8288
+ const graph = {
8289
+ nodes: [],
8290
+ edges: []
8291
+ };
7106
8292
  if (features.headings ?? true) {
7107
8293
  const headings2 = get2(rxFromSignal(() => createHeadings(state, getView)));
7108
- nodes.push(...headings2.nodes);
7109
- edges.push(...headings2.edges);
8294
+ graph.nodes.push(...headings2.nodes);
8295
+ graph.edges.push(...headings2.edges);
7110
8296
  }
7111
8297
  if (features.formatting ?? true) {
7112
8298
  const formatting = get2(rxFromSignal(() => createFormatting(state, getView)));
7113
- nodes.push(...formatting.nodes);
7114
- edges.push(...formatting.edges);
8299
+ graph.nodes.push(...formatting.nodes);
8300
+ graph.edges.push(...formatting.edges);
7115
8301
  }
7116
8302
  if (features.lists ?? true) {
7117
8303
  const lists = get2(rxFromSignal(() => createLists(state, getView)));
7118
- nodes.push(...lists.nodes);
7119
- edges.push(...lists.edges);
8304
+ graph.nodes.push(...lists.nodes);
8305
+ graph.edges.push(...lists.edges);
7120
8306
  }
7121
8307
  if (features.blocks ?? true) {
7122
8308
  const blocks = get2(rxFromSignal(() => createBlocks(state, getView)));
7123
- nodes.push(...blocks.nodes);
7124
- edges.push(...blocks.edges);
8309
+ graph.nodes.push(...blocks.nodes);
8310
+ graph.edges.push(...blocks.edges);
7125
8311
  }
7126
8312
  if (features.image) {
7127
8313
  const image2 = get2(rxFromSignal(() => createImageUpload(features.image)));
7128
- nodes.push(...image2.nodes);
7129
- edges.push(...image2.edges);
8314
+ graph.nodes.push(...image2.nodes);
8315
+ graph.edges.push(...image2.edges);
8316
+ }
8317
+ {
8318
+ const gap = createGapSeparator();
8319
+ graph.nodes.push(...gap.nodes);
8320
+ graph.edges.push(...gap.edges);
7130
8321
  }
7131
- const editorToolbarGap = createGapSeparator();
7132
- nodes.push(...editorToolbarGap.nodes);
7133
- edges.push(...editorToolbarGap.edges);
7134
8322
  if (customActions) {
7135
8323
  const custom = get2(customActions);
7136
- nodes.push(...custom.nodes);
7137
- edges.push(...custom.edges);
8324
+ graph.nodes.push(...custom.nodes);
8325
+ graph.edges.push(...custom.edges);
7138
8326
  }
7139
8327
  if (features.search ?? true) {
7140
8328
  const search = get2(rxFromSignal(() => createSearch(getView)));
7141
- nodes.push(...search.nodes);
7142
- edges.push(...search.edges);
8329
+ graph.nodes.push(...search.nodes);
8330
+ graph.edges.push(...search.edges);
7143
8331
  }
7144
8332
  if (features.viewMode) {
7145
8333
  const viewMode = get2(rxFromSignal(() => createViewMode(state, features.viewMode)));
7146
- nodes.push(...viewMode.nodes);
7147
- edges.push(...viewMode.edges);
8334
+ graph.nodes.push(...viewMode.nodes);
8335
+ graph.edges.push(...viewMode.edges);
7148
8336
  }
7149
- return {
7150
- nodes,
7151
- edges
7152
- };
8337
+ return graph;
7153
8338
  });
7154
8339
  };
7155
8340
  var useEditorToolbarActionGraph = (props) => {
7156
- const menuCreator = useMemo5(() => createToolbar({
8341
+ const menuCreator = useMemo5(() => createToolbarActions({
7157
8342
  getView: props.getView,
7158
8343
  state: props.state,
7159
8344
  customActions: props.customActions,
@@ -7196,26 +8381,64 @@ var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...p
7196
8381
  }
7197
8382
  });
7198
8383
 
7199
- // src/components/Popover/CommandMenu.tsx
8384
+ // src/components/CommandMenu/CommandMenu.tsx
7200
8385
  import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
7201
- import React5, { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3 } from "react";
8386
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
8387
+ import React5, { Fragment, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
8388
+ import { addEventListener as addEventListener2 } from "@dxos/async";
7202
8389
  import { Icon as Icon2, Popover, toLocalizedString, useThemeContext as useThemeContext2, useTranslation } from "@dxos/react-ui";
7203
- var CommandMenu = ({ groups, currentItem, onSelect }) => {
8390
+ var CommandMenuProvider = ({ groups, onSelect, onActivate, currentItem, children, open: propsOpen, onOpenChange, defaultOpen }) => {
7204
8391
  var _effect = _useSignals3();
7205
8392
  try {
7206
8393
  const { tx } = useThemeContext2();
7207
8394
  const groupsWithItems = groups.filter((group) => group.items.length > 0);
7208
- return /* @__PURE__ */ React5.createElement(Popover.Portal, null, /* @__PURE__ */ React5.createElement(Popover.Content, {
8395
+ const trigger = useRef3(null);
8396
+ const [open, setOpen] = useControllableState({
8397
+ prop: propsOpen,
8398
+ onChange: onOpenChange,
8399
+ defaultProp: defaultOpen
8400
+ });
8401
+ const handleDxAnchorActivate = useCallback4((event) => {
8402
+ const { trigger: dxTrigger, refId } = event;
8403
+ if (!refId) {
8404
+ trigger.current = dxTrigger;
8405
+ if (onActivate) {
8406
+ onActivate(event);
8407
+ } else {
8408
+ queueMicrotask(() => setOpen(true));
8409
+ }
8410
+ }
8411
+ }, [
8412
+ onActivate
8413
+ ]);
8414
+ const [rootRef, setRootRef] = useState3(null);
8415
+ useEffect3(() => {
8416
+ if (!rootRef || !handleDxAnchorActivate) {
8417
+ return;
8418
+ }
8419
+ return addEventListener2(rootRef, "dx-anchor-activate", handleDxAnchorActivate, {
8420
+ capture: true,
8421
+ passive: false
8422
+ });
8423
+ }, [
8424
+ rootRef,
8425
+ handleDxAnchorActivate
8426
+ ]);
8427
+ return /* @__PURE__ */ React5.createElement(Popover.Root, {
8428
+ modal: false,
8429
+ open,
8430
+ onOpenChange: setOpen
8431
+ }, /* @__PURE__ */ React5.createElement(Popover.Portal, null, /* @__PURE__ */ React5.createElement(Popover.Content, {
7209
8432
  align: "start",
7210
8433
  onOpenAutoFocus: (event) => event.preventDefault(),
7211
8434
  classNames: tx("menu.content", "menu--exotic-unfocusable", {
7212
8435
  elevation: "positioned"
7213
8436
  }, [
7214
- "max-h-[300px] overflow-y-auto"
8437
+ "max-bs-80 overflow-y-auto"
7215
8438
  ])
7216
8439
  }, /* @__PURE__ */ React5.createElement(Popover.Viewport, {
7217
8440
  classNames: tx("menu.viewport", "menu__viewport--exotic-unfocusable", {})
7218
- }, /* @__PURE__ */ React5.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React5.createElement(React5.Fragment, {
8441
+ }, /* @__PURE__ */ React5.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React5.createElement(Fragment, {
7219
8442
  key: group.id
7220
8443
  }, /* @__PURE__ */ React5.createElement(CommandGroup, {
7221
8444
  group,
@@ -7223,7 +8446,13 @@ var CommandMenu = ({ groups, currentItem, onSelect }) => {
7223
8446
  onSelect
7224
8447
  }), index < groupsWithItems.length - 1 && /* @__PURE__ */ React5.createElement("div", {
7225
8448
  className: tx("menu.separator", "menu__item", {})
7226
- })))))));
8449
+ }))))), /* @__PURE__ */ React5.createElement(Popover.Arrow, null))), /* @__PURE__ */ React5.createElement(Popover.VirtualTrigger, {
8450
+ virtualRef: trigger
8451
+ }), /* @__PURE__ */ React5.createElement("div", {
8452
+ role: "none",
8453
+ className: "contents",
8454
+ ref: setRootRef
8455
+ }, children));
7227
8456
  } finally {
7228
8457
  _effect.f();
7229
8458
  }
@@ -7460,179 +8689,21 @@ var linkSlashCommands = {
7460
8689
  }
7461
8690
  ]
7462
8691
  };
7463
-
7464
- // src/components/Popover/RefPopover.tsx
7465
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
7466
- import { createContext } from "@radix-ui/react-context";
7467
- import React6, { useRef as useRef4, useState as useState3, useEffect as useEffect4, useCallback as useCallback5, forwardRef as forwardRef2 } from "react";
7468
- import { addEventListener as addEventListener2 } from "@dxos/async";
7469
- import { Popover as Popover2 } from "@dxos/react-ui";
7470
- var customEventOptions = {
7471
- capture: true,
7472
- passive: false
7473
- };
7474
- var RefPopover = /* @__PURE__ */ forwardRef2(({ children, open, onOpenChange, modal, onActivate }, ref) => {
7475
- var _effect = _useSignals4();
7476
- try {
7477
- const [rootRef, setRootRef] = useState3(null);
7478
- useEffect4(() => {
7479
- if (!rootRef || !onActivate) {
7480
- return;
7481
- }
7482
- return addEventListener2(rootRef, "dx-ref-tag-activate", onActivate, customEventOptions);
7483
- }, [
7484
- rootRef,
7485
- onActivate
7486
- ]);
7487
- return /* @__PURE__ */ React6.createElement(Popover2.Root, {
7488
- open,
7489
- onOpenChange,
7490
- modal
7491
- }, /* @__PURE__ */ React6.createElement(Popover2.VirtualTrigger, {
7492
- virtualRef: ref
7493
- }), /* @__PURE__ */ React6.createElement("div", {
7494
- role: "none",
7495
- className: "contents",
7496
- ref: setRootRef
7497
- }, children));
7498
- } finally {
7499
- _effect.f();
7500
- }
7501
- });
7502
- var REF_POPOVER = "RefPopover";
7503
- var [RefPopoverContextProvider, useRefPopover] = createContext(REF_POPOVER, {});
7504
- var PreviewProvider = ({ children, onLookup }) => {
7505
- var _effect = _useSignals4();
7506
- try {
7507
- const trigger = useRef4(null);
7508
- const [value, setValue] = useState3({});
7509
- const [open, setOpen] = useState3(false);
7510
- const handleDxRefTagActivate = useCallback5((event) => {
7511
- const { refId, label, trigger: dxTrigger } = event;
7512
- setValue((value2) => ({
7513
- ...value2,
7514
- link: {
7515
- label,
7516
- ref: refId
7517
- },
7518
- pending: true
7519
- }));
7520
- trigger.current = dxTrigger;
7521
- queueMicrotask(() => setOpen(true));
7522
- void onLookup?.({
7523
- label,
7524
- ref: refId
7525
- }).then((target) => setValue((value2) => ({
7526
- ...value2,
7527
- target: target ?? void 0,
7528
- pending: false
7529
- })));
7530
- }, [
7531
- onLookup
7532
- ]);
7533
- return /* @__PURE__ */ React6.createElement(RefPopoverContextProvider, {
7534
- pending: value.pending,
7535
- link: value.link,
7536
- target: value.target
7537
- }, /* @__PURE__ */ React6.createElement(RefPopover, {
7538
- ref: trigger,
7539
- open,
7540
- onOpenChange: setOpen,
7541
- onActivate: handleDxRefTagActivate
7542
- }, children));
7543
- } finally {
7544
- _effect.f();
7545
- }
7546
- };
7547
-
7548
- // src/components/Popover/RefDropdownMenu.tsx
7549
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
7550
- import { createContext as createContext2 } from "@radix-ui/react-context";
7551
- import React7, { useRef as useRef5, useState as useState4, useEffect as useEffect5, useCallback as useCallback6 } from "react";
7552
- import { addEventListener as addEventListener3 } from "@dxos/async";
7553
- import { DropdownMenu } from "@dxos/react-ui";
7554
- var customEventOptions2 = {
7555
- capture: true,
7556
- passive: false
7557
- };
7558
- var REF_DROPDOWN_MENU = "RefDropdownMenu";
7559
- var [RefDropdownMenuContextProvider, useRefDropdownMenu] = createContext2(REF_DROPDOWN_MENU, {});
7560
- var RefDropdownMenuProvider = ({ children, onLookup }) => {
7561
- var _effect = _useSignals5();
7562
- try {
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) => {
7568
- const { refId, label, trigger: dxTrigger } = event;
7569
- setValue((value2) => ({
7570
- ...value2,
7571
- link: {
7572
- label,
7573
- ref: refId
7574
- },
7575
- pending: true
7576
- }));
7577
- trigger.current = dxTrigger;
7578
- queueMicrotask(() => setOpen(true));
7579
- void onLookup?.({
7580
- label,
7581
- ref: refId
7582
- }).then((target) => setValue((value2) => ({
7583
- ...value2,
7584
- target: target ?? void 0,
7585
- pending: false
7586
- })));
7587
- }, [
7588
- onLookup
7589
- ]);
7590
- useEffect5(() => {
7591
- if (!rootRef) {
7592
- return;
7593
- }
7594
- return addEventListener3(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions2);
7595
- }, [
7596
- rootRef
7597
- ]);
7598
- return /* @__PURE__ */ React7.createElement(RefDropdownMenuContextProvider, {
7599
- pending: value.pending,
7600
- link: value.link,
7601
- target: value.target
7602
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
7603
- open,
7604
- onOpenChange: setOpen
7605
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.VirtualTrigger, {
7606
- virtualRef: trigger
7607
- }), /* @__PURE__ */ React7.createElement("div", {
7608
- role: "none",
7609
- className: "contents",
7610
- ref: setRootRef
7611
- }, children)));
7612
- } finally {
7613
- _effect.f();
7614
- }
7615
- };
7616
- var RefDropdownMenu = {
7617
- Provider: RefDropdownMenuProvider
7618
- };
7619
8692
  export {
7620
- CommandMenu,
8693
+ CommandMenuProvider,
7621
8694
  Cursor,
8695
+ Domino,
7622
8696
  Editor,
7623
8697
  EditorInputMode,
7624
8698
  EditorInputModes,
7625
8699
  EditorState4 as EditorState,
7626
8700
  EditorToolbar,
7627
- EditorView27 as EditorView,
8701
+ EditorView31 as EditorView,
7628
8702
  EditorViewMode,
7629
8703
  EditorViewModes,
7630
8704
  Inline,
7631
8705
  InputModeExtensions,
7632
8706
  List,
7633
- PreviewProvider,
7634
- RefDropdownMenu,
7635
- RefPopover,
7636
8707
  RemoteSelectionsDecorator,
7637
8708
  SpaceAwarenessProvider,
7638
8709
  TextKind,
@@ -7643,6 +8714,7 @@ export {
7643
8714
  addList,
7644
8715
  addStyle,
7645
8716
  annotations,
8717
+ autoScroll,
7646
8718
  autocomplete,
7647
8719
  automerge,
7648
8720
  awareness,
@@ -7669,7 +8741,6 @@ export {
7669
8741
  createEditorActionGroup,
7670
8742
  createEditorStateStore,
7671
8743
  createEditorStateTransaction,
7672
- createElement,
7673
8744
  createExternalCommentSync,
7674
8745
  createJsonExtensions,
7675
8746
  createMarkdownExtensions,
@@ -7679,6 +8750,8 @@ export {
7679
8750
  debugNodeLogger,
7680
8751
  debugTree,
7681
8752
  decorateMarkdown,
8753
+ decorationSetToArray,
8754
+ defaultExtensions,
7682
8755
  defaultOptions,
7683
8756
  defaultThemeSlots,
7684
8757
  deleteItem,
@@ -7690,6 +8763,7 @@ export {
7690
8763
  editorSlots,
7691
8764
  editorWidth,
7692
8765
  editorWithToolbarLayout,
8766
+ extendedMarkdown,
7693
8767
  filterItems,
7694
8768
  flattenRect,
7695
8769
  floatingMenu,
@@ -7743,6 +8817,7 @@ export {
7743
8817
  removeStyle,
7744
8818
  renderRoot,
7745
8819
  scrollThreadIntoView,
8820
+ scrollToBottomEffect,
7746
8821
  selectionState,
7747
8822
  setBlockquote,
7748
8823
  setComments,
@@ -7752,6 +8827,7 @@ export {
7752
8827
  singleValueFacet,
7753
8828
  stackItemContentEditorClassNames,
7754
8829
  staticCompletion,
8830
+ streamer,
7755
8831
  table,
7756
8832
  tags2 as tags,
7757
8833
  textRange,
@@ -7773,9 +8849,11 @@ export {
7773
8849
  useComments,
7774
8850
  useEditorToolbarState,
7775
8851
  useFormattingState,
7776
- useRefDropdownMenu,
7777
- useRefPopover,
7778
8852
  useTextEditor,
7779
- wrapWithCatch
8853
+ wrapWithCatch,
8854
+ xmlTagContextEffect,
8855
+ xmlTagResetEffect,
8856
+ xmlTagUpdateEffect,
8857
+ xmlTags
7780
8858
  };
7781
8859
  //# sourceMappingURL=index.mjs.map