@dxos/react-ui-editor 0.8.4-main.b97322e → 0.8.4-main.dedc0f3

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