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