@dxos/react-ui-editor 0.8.4-main.5acf9ea → 0.8.4-main.5ea62a8
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.
- package/dist/lib/browser/index.mjs +768 -452
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +768 -452
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Editor/Editor.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/blocks.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/formatting.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/headings.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/image.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/lists.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/search.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/util.d.ts +2 -2
- package/dist/types/src/components/EditorToolbar/util.d.ts.map +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts +1 -1
- package/dist/types/src/components/EditorToolbar/view-mode.d.ts.map +1 -1
- package/dist/types/src/components/Popover/CommandMenu.d.ts.map +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +9 -18
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/command/action.d.ts +1 -1
- package/dist/types/src/extensions/command/action.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts +1 -1
- package/dist/types/src/extensions/command/command-menu.d.ts.map +1 -1
- package/dist/types/src/extensions/command/command.d.ts.map +1 -1
- package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
- package/dist/types/src/extensions/command/state.d.ts +1 -1
- package/dist/types/src/extensions/command/state.d.ts.map +1 -1
- package/dist/types/src/extensions/command/typeahead.d.ts.map +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts +1 -1
- package/dist/types/src/extensions/command/useCommandMenu.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +2 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.test.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts +12 -4
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/CommandMenu.stories.d.ts +10 -3
- package/dist/types/src/stories/CommandMenu.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +21 -9
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/EditorToolbar.stories.d.ts +39 -2
- package/dist/types/src/stories/EditorToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +22 -12
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +32 -42
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts +15 -20
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +21 -6
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +38 -51
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +3 -6
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +1 -0
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -44
- package/src/components/Editor/Editor.tsx +1 -1
- package/src/components/EditorToolbar/EditorToolbar.tsx +40 -30
- package/src/components/EditorToolbar/blocks.ts +21 -24
- package/src/components/EditorToolbar/formatting.ts +22 -25
- package/src/components/EditorToolbar/headings.ts +10 -5
- package/src/components/EditorToolbar/image.ts +8 -4
- package/src/components/EditorToolbar/lists.ts +16 -19
- package/src/components/EditorToolbar/search.ts +8 -4
- package/src/components/EditorToolbar/util.ts +16 -5
- package/src/components/EditorToolbar/view-mode.ts +11 -6
- package/src/components/Popover/CommandMenu.tsx +3 -3
- package/src/components/Popover/RefDropdownMenu.tsx +1 -1
- package/src/components/Popover/RefPopover.tsx +4 -4
- package/src/defaults.ts +5 -2
- package/src/extensions/autocomplete.ts +3 -3
- package/src/extensions/automerge/automerge.stories.tsx +25 -18
- package/src/extensions/automerge/automerge.ts +4 -3
- package/src/extensions/automerge/defs.ts +1 -1
- package/src/extensions/automerge/sync.ts +1 -1
- package/src/extensions/automerge/update-automerge.ts +1 -1
- package/src/extensions/awareness/awareness.ts +2 -2
- package/src/extensions/command/action.ts +1 -1
- package/src/extensions/command/command-menu.ts +4 -3
- package/src/extensions/command/command.ts +3 -3
- package/src/extensions/command/hint.ts +2 -1
- package/src/extensions/command/placeholder.ts +1 -1
- package/src/extensions/command/state.ts +4 -3
- package/src/extensions/command/typeahead.ts +2 -2
- package/src/extensions/command/useCommandMenu.ts +2 -1
- package/src/extensions/comments.ts +13 -12
- package/src/extensions/dnd.ts +1 -1
- package/src/extensions/factories.ts +4 -3
- package/src/extensions/markdown/action.ts +2 -1
- package/src/extensions/markdown/bundle.ts +4 -1
- package/src/extensions/markdown/changes.ts +1 -1
- package/src/extensions/markdown/decorate.ts +7 -6
- package/src/extensions/markdown/formatting.test.ts +6 -6
- package/src/extensions/markdown/formatting.ts +3 -3
- package/src/extensions/markdown/highlight.ts +1 -1
- package/src/extensions/mention.ts +1 -1
- package/src/extensions/outliner/outliner.test.ts +3 -2
- package/src/extensions/outliner/outliner.ts +4 -3
- package/src/extensions/outliner/selection.ts +1 -1
- package/src/extensions/outliner/tree.test.ts +2 -1
- package/src/extensions/outliner/tree.ts +1 -1
- package/src/hooks/useTextEditor.ts +3 -3
- package/src/stories/Command.stories.tsx +12 -8
- package/src/stories/CommandMenu.stories.tsx +16 -14
- package/src/stories/Comments.stories.tsx +10 -6
- package/src/stories/EditorToolbar.stories.tsx +7 -7
- package/src/stories/Experimental.stories.tsx +12 -8
- package/src/stories/Markdown.stories.tsx +21 -17
- package/src/stories/Outliner.stories.tsx +14 -10
- package/src/stories/Preview.stories.tsx +27 -25
- package/src/stories/TextEditor.stories.tsx +36 -32
- package/src/stories/components/EditorStory.tsx +8 -9
- package/src/styles/theme.ts +8 -6
- package/src/testing/util.ts +2 -0
- package/src/translations.ts +1 -1
- package/src/util/cursor.ts +2 -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}}",
|
@@ -64,15 +64,25 @@ import { getProviderValue, isNotFalsy as isNotFalsy4 } from "@dxos/util";
|
|
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
|
}),
|
@@ -144,17 +157,187 @@ import { next as A3 } from "@automerge/automerge";
|
|
144
157
|
import { StateField } from "@codemirror/state";
|
145
158
|
import { EditorView as EditorView2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
|
146
159
|
|
147
|
-
// src/
|
160
|
+
// src/util/facet.ts
|
161
|
+
import { Facet } from "@codemirror/state";
|
162
|
+
var singleValueFacet = (defaultValue) => Facet.define({
|
163
|
+
// Called immediately.
|
164
|
+
combine: (providers) => {
|
165
|
+
return providers[0] ?? defaultValue;
|
166
|
+
}
|
167
|
+
});
|
168
|
+
|
169
|
+
// src/util/cursor.ts
|
170
|
+
function _define_property2(obj, key, value) {
|
171
|
+
if (key in obj) {
|
172
|
+
Object.defineProperty(obj, key, {
|
173
|
+
value,
|
174
|
+
enumerable: true,
|
175
|
+
configurable: true,
|
176
|
+
writable: true
|
177
|
+
});
|
178
|
+
} else {
|
179
|
+
obj[key] = value;
|
180
|
+
}
|
181
|
+
return obj;
|
182
|
+
}
|
183
|
+
var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
|
184
|
+
var defaultCursorConverter = {
|
185
|
+
toCursor: (position) => position.toString(),
|
186
|
+
fromCursor: (cursor) => parseInt(cursor)
|
187
|
+
};
|
188
|
+
var Cursor = class {
|
189
|
+
};
|
190
|
+
_define_property2(Cursor, "converter", singleValueFacet(defaultCursorConverter));
|
191
|
+
_define_property2(Cursor, "getCursorFromRange", (state, range) => {
|
192
|
+
const cursorConverter2 = state.facet(Cursor.converter);
|
193
|
+
const from = cursorConverter2.toCursor(range.from);
|
194
|
+
const to = cursorConverter2.toCursor(range.to, -1);
|
195
|
+
return [
|
196
|
+
from,
|
197
|
+
to
|
198
|
+
].join(":");
|
199
|
+
});
|
200
|
+
_define_property2(Cursor, "getRangeFromCursor", (state, cursor) => {
|
201
|
+
const cursorConverter2 = state.facet(Cursor.converter);
|
202
|
+
const parts = cursor.split(":");
|
203
|
+
const from = cursorConverter2.fromCursor(parts[0]);
|
204
|
+
const to = cursorConverter2.fromCursor(parts[1]);
|
205
|
+
return from !== void 0 && to !== void 0 ? {
|
206
|
+
from,
|
207
|
+
to
|
208
|
+
} : void 0;
|
209
|
+
});
|
210
|
+
|
211
|
+
// src/util/debug.ts
|
148
212
|
import { log } from "@dxos/log";
|
213
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/util/debug.ts";
|
214
|
+
var wrapWithCatch = (fn) => {
|
215
|
+
return (...args) => {
|
216
|
+
try {
|
217
|
+
return fn(...args);
|
218
|
+
} catch (err) {
|
219
|
+
log.catch(err, void 0, {
|
220
|
+
F: __dxlog_file,
|
221
|
+
L: 15,
|
222
|
+
S: void 0,
|
223
|
+
C: (f, a) => f(...a)
|
224
|
+
});
|
225
|
+
}
|
226
|
+
};
|
227
|
+
};
|
228
|
+
var callbackWrapper = (fn) => (...args) => {
|
229
|
+
try {
|
230
|
+
return fn(...args);
|
231
|
+
} catch (err) {
|
232
|
+
log.catch(err, void 0, {
|
233
|
+
F: __dxlog_file,
|
234
|
+
L: 29,
|
235
|
+
S: void 0,
|
236
|
+
C: (f, a) => f(...a)
|
237
|
+
});
|
238
|
+
}
|
239
|
+
};
|
240
|
+
var debugDispatcher = (trs, view) => {
|
241
|
+
logChanges(trs);
|
242
|
+
view.update(trs);
|
243
|
+
};
|
244
|
+
var logChanges = (trs) => {
|
245
|
+
const changes = trs.flatMap((tr) => {
|
246
|
+
if (tr.changes.empty) {
|
247
|
+
return void 0;
|
248
|
+
}
|
249
|
+
const changes2 = [];
|
250
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => changes2.push(JSON.stringify({
|
251
|
+
fromA,
|
252
|
+
toA,
|
253
|
+
fromB,
|
254
|
+
toB,
|
255
|
+
inserted: inserted.toString()
|
256
|
+
})));
|
257
|
+
return changes2;
|
258
|
+
}).filter(Boolean);
|
259
|
+
if (changes.length) {
|
260
|
+
log("changes", {
|
261
|
+
changes
|
262
|
+
}, {
|
263
|
+
F: __dxlog_file,
|
264
|
+
L: 62,
|
265
|
+
S: void 0,
|
266
|
+
C: (f, a) => f(...a)
|
267
|
+
});
|
268
|
+
}
|
269
|
+
};
|
270
|
+
|
271
|
+
// src/util/dom.ts
|
272
|
+
var flattenRect = (rect, left) => {
|
273
|
+
const x = left ? rect.left : rect.right;
|
274
|
+
return {
|
275
|
+
left: x,
|
276
|
+
right: x,
|
277
|
+
top: rect.top,
|
278
|
+
bottom: rect.bottom
|
279
|
+
};
|
280
|
+
};
|
281
|
+
var scratchRange;
|
282
|
+
var textRange = (node, from, to = from) => {
|
283
|
+
const range = scratchRange || (scratchRange = document.createRange());
|
284
|
+
range.setEnd(node, to);
|
285
|
+
range.setStart(node, from);
|
286
|
+
return range;
|
287
|
+
};
|
288
|
+
var clientRectsFor = (dom) => {
|
289
|
+
if (dom.nodeType === 3) {
|
290
|
+
return textRange(dom, 0, dom.nodeValue.length).getClientRects();
|
291
|
+
} else if (dom.nodeType === 1) {
|
292
|
+
return dom.getClientRects();
|
293
|
+
} else {
|
294
|
+
return [];
|
295
|
+
}
|
296
|
+
};
|
297
|
+
var createElement = (tag, options, children) => {
|
298
|
+
const el = document.createElement(tag);
|
299
|
+
if (options?.className) {
|
300
|
+
el.className = options.className;
|
301
|
+
}
|
302
|
+
if (options?.text) {
|
303
|
+
el.textContent = options.text;
|
304
|
+
}
|
305
|
+
if (children) {
|
306
|
+
el.append(...Array.isArray(children) ? children : [
|
307
|
+
children
|
308
|
+
]);
|
309
|
+
}
|
310
|
+
return el;
|
311
|
+
};
|
312
|
+
|
313
|
+
// src/util/react.tsx
|
314
|
+
import React from "react";
|
315
|
+
import { createRoot } from "react-dom/client";
|
316
|
+
import { ThemeProvider, Tooltip } from "@dxos/react-ui";
|
317
|
+
import { defaultTx } from "@dxos/react-ui-theme";
|
318
|
+
var renderRoot = (root, node) => {
|
319
|
+
createRoot(root).render(/* @__PURE__ */ React.createElement(ThemeProvider, {
|
320
|
+
tx: defaultTx
|
321
|
+
}, node));
|
322
|
+
return root;
|
323
|
+
};
|
324
|
+
var createRenderer = (Component) => (el, props) => {
|
325
|
+
renderRoot(el, /* @__PURE__ */ React.createElement(ThemeProvider, {
|
326
|
+
tx: defaultTx
|
327
|
+
}, /* @__PURE__ */ React.createElement(Tooltip.Provider, null, /* @__PURE__ */ React.createElement(Component, props))));
|
328
|
+
};
|
329
|
+
|
330
|
+
// src/extensions/automerge/cursor.ts
|
331
|
+
import { log as log2 } from "@dxos/log";
|
149
332
|
import { fromCursor, toCursor } from "@dxos/react-client/echo";
|
150
|
-
var
|
333
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/automerge/cursor.ts";
|
151
334
|
var cursorConverter = (accessor) => ({
|
152
335
|
toCursor: (pos, assoc) => {
|
153
336
|
try {
|
154
337
|
return toCursor(accessor, pos, assoc);
|
155
338
|
} catch (err) {
|
156
|
-
|
157
|
-
F:
|
339
|
+
log2.catch(err, void 0, {
|
340
|
+
F: __dxlog_file2,
|
158
341
|
L: 15,
|
159
342
|
S: void 0,
|
160
343
|
C: (f, a) => f(...a)
|
@@ -166,8 +349,8 @@ var cursorConverter = (accessor) => ({
|
|
166
349
|
try {
|
167
350
|
return fromCursor(accessor, cursor);
|
168
351
|
} catch (err) {
|
169
|
-
|
170
|
-
F:
|
352
|
+
log2.catch(err, void 0, {
|
353
|
+
F: __dxlog_file2,
|
171
354
|
L: 24,
|
172
355
|
S: void 0,
|
173
356
|
C: (f, a) => f(...a)
|
@@ -332,13 +515,20 @@ var charPath = (textPath, candidatePath) => {
|
|
332
515
|
};
|
333
516
|
|
334
517
|
// src/extensions/automerge/sync.ts
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
518
|
+
function _define_property3(obj, key, value) {
|
519
|
+
if (key in obj) {
|
520
|
+
Object.defineProperty(obj, key, {
|
521
|
+
value,
|
522
|
+
enumerable: true,
|
523
|
+
configurable: true,
|
524
|
+
writable: true
|
525
|
+
});
|
526
|
+
} else {
|
527
|
+
obj[key] = value;
|
341
528
|
}
|
529
|
+
return obj;
|
530
|
+
}
|
531
|
+
var Syncer = class {
|
342
532
|
reconcile(view, editor2) {
|
343
533
|
if (this._pending) {
|
344
534
|
return;
|
@@ -373,172 +563,31 @@ var Syncer = class {
|
|
373
563
|
annotations: reconcileAnnotation.of(false)
|
374
564
|
});
|
375
565
|
}
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
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
|
-
};
|
566
|
+
// prettier-ignore
|
567
|
+
constructor(_handle, _state) {
|
568
|
+
_define_property3(this, "_handle", void 0);
|
569
|
+
_define_property3(this, "_state", void 0);
|
570
|
+
_define_property3(this, "_pending", void 0);
|
571
|
+
this._handle = _handle;
|
572
|
+
this._state = _state;
|
573
|
+
this._pending = false;
|
419
574
|
}
|
420
575
|
};
|
421
576
|
|
422
|
-
// src/
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
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)
|
577
|
+
// src/extensions/automerge/automerge.ts
|
578
|
+
function _define_property4(obj, key, value) {
|
579
|
+
if (key in obj) {
|
580
|
+
Object.defineProperty(obj, key, {
|
581
|
+
value,
|
582
|
+
enumerable: true,
|
583
|
+
configurable: true,
|
584
|
+
writable: true
|
478
585
|
});
|
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
586
|
} else {
|
505
|
-
|
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;
|
587
|
+
obj[key] = value;
|
515
588
|
}
|
516
|
-
|
517
|
-
|
518
|
-
children
|
519
|
-
]);
|
520
|
-
}
|
521
|
-
return el;
|
522
|
-
};
|
523
|
-
|
524
|
-
// src/util/react.tsx
|
525
|
-
import React from "react";
|
526
|
-
import { createRoot } from "react-dom/client";
|
527
|
-
import { ThemeProvider, Tooltip } from "@dxos/react-ui";
|
528
|
-
import { defaultTx } from "@dxos/react-ui-theme";
|
529
|
-
var renderRoot = (root, node) => {
|
530
|
-
createRoot(root).render(/* @__PURE__ */ React.createElement(ThemeProvider, {
|
531
|
-
tx: defaultTx
|
532
|
-
}, node));
|
533
|
-
return root;
|
534
|
-
};
|
535
|
-
var createRenderer = (Component) => (el, props) => {
|
536
|
-
renderRoot(el, /* @__PURE__ */ React.createElement(ThemeProvider, {
|
537
|
-
tx: defaultTx
|
538
|
-
}, /* @__PURE__ */ React.createElement(Tooltip.Provider, null, /* @__PURE__ */ React.createElement(Component, props))));
|
539
|
-
};
|
540
|
-
|
541
|
-
// src/extensions/automerge/automerge.ts
|
589
|
+
return obj;
|
590
|
+
}
|
542
591
|
var automerge = (accessor) => {
|
543
592
|
const syncState = StateField.define({
|
544
593
|
create: () => ({
|
@@ -576,16 +625,18 @@ var automerge = (accessor) => {
|
|
576
625
|
syncState,
|
577
626
|
// Reconcile external updates.
|
578
627
|
ViewPlugin2.fromClass(class {
|
628
|
+
destroy() {
|
629
|
+
accessor.handle.removeListener("change", this._handleChange);
|
630
|
+
}
|
579
631
|
constructor(_view) {
|
632
|
+
_define_property4(this, "_view", void 0);
|
633
|
+
_define_property4(this, "_handleChange", void 0);
|
580
634
|
this._view = _view;
|
581
635
|
this._handleChange = () => {
|
582
636
|
syncer.reconcile(this._view, false);
|
583
637
|
};
|
584
638
|
accessor.handle.addListener("change", this._handleChange);
|
585
639
|
}
|
586
|
-
destroy() {
|
587
|
-
accessor.handle.removeListener("change", this._handleChange);
|
588
|
-
}
|
589
640
|
}),
|
590
641
|
// Reconcile local updates.
|
591
642
|
EditorView2.updateListener.of(({ view, changes }) => {
|
@@ -601,6 +652,19 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
601
652
|
import { Decoration as Decoration2, EditorView as EditorView3, ViewPlugin as ViewPlugin3, WidgetType } from "@codemirror/view";
|
602
653
|
import { Event } from "@dxos/async";
|
603
654
|
import { Context } from "@dxos/context";
|
655
|
+
function _define_property5(obj, key, value) {
|
656
|
+
if (key in obj) {
|
657
|
+
Object.defineProperty(obj, key, {
|
658
|
+
value,
|
659
|
+
enumerable: true,
|
660
|
+
configurable: true,
|
661
|
+
writable: true
|
662
|
+
});
|
663
|
+
} else {
|
664
|
+
obj[key] = value;
|
665
|
+
}
|
666
|
+
return obj;
|
667
|
+
}
|
604
668
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness.ts";
|
605
669
|
var dummyProvider = {
|
606
670
|
remoteStateChange: new Event(),
|
@@ -624,23 +688,6 @@ var awareness = (provider = dummyProvider) => {
|
|
624
688
|
];
|
625
689
|
};
|
626
690
|
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
691
|
destroy() {
|
645
692
|
void this._ctx.dispose();
|
646
693
|
this._provider.close();
|
@@ -735,11 +782,29 @@ var RemoteSelectionsDecorator = class {
|
|
735
782
|
}
|
736
783
|
this.decorations = Decoration2.set(decorations2, true);
|
737
784
|
}
|
785
|
+
constructor(view) {
|
786
|
+
_define_property5(this, "_ctx", new Context(void 0, {
|
787
|
+
F: __dxlog_file3,
|
788
|
+
L: 80
|
789
|
+
}));
|
790
|
+
_define_property5(this, "_cursorConverter", void 0);
|
791
|
+
_define_property5(this, "_provider", void 0);
|
792
|
+
_define_property5(this, "_lastAnchor", void 0);
|
793
|
+
_define_property5(this, "_lastHead", void 0);
|
794
|
+
_define_property5(this, "decorations", RangeSet.of([]));
|
795
|
+
this._cursorConverter = view.state.facet(Cursor.converter);
|
796
|
+
this._provider = view.state.facet(awarenessProvider);
|
797
|
+
this._provider.open();
|
798
|
+
this._provider.remoteStateChange.on(this._ctx, () => {
|
799
|
+
view.dispatch({
|
800
|
+
annotations: [
|
801
|
+
RemoteSelectionChangedAnnotation.of([])
|
802
|
+
]
|
803
|
+
});
|
804
|
+
});
|
805
|
+
}
|
738
806
|
};
|
739
807
|
var RemoteCaretWidget = class extends WidgetType {
|
740
|
-
constructor(_name, _color) {
|
741
|
-
super(), this._name = _name, this._color = _color;
|
742
|
-
}
|
743
808
|
toDOM() {
|
744
809
|
const span = document.createElement("span");
|
745
810
|
span.className = "cm-collab-selectionCaret";
|
@@ -769,6 +834,9 @@ var RemoteCaretWidget = class extends WidgetType {
|
|
769
834
|
ignoreEvent() {
|
770
835
|
return true;
|
771
836
|
}
|
837
|
+
constructor(_name, _color) {
|
838
|
+
super(), _define_property5(this, "_name", void 0), _define_property5(this, "_color", void 0), this._name = _name, this._color = _color;
|
839
|
+
}
|
772
840
|
};
|
773
841
|
var styles = EditorView3.theme({
|
774
842
|
".cm-collab-selection": {},
|
@@ -833,17 +901,22 @@ import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
833
901
|
import { Context as Context2 } from "@dxos/context";
|
834
902
|
import { invariant } from "@dxos/invariant";
|
835
903
|
import { log as log3 } from "@dxos/log";
|
904
|
+
function _define_property6(obj, key, value) {
|
905
|
+
if (key in obj) {
|
906
|
+
Object.defineProperty(obj, key, {
|
907
|
+
value,
|
908
|
+
enumerable: true,
|
909
|
+
configurable: true,
|
910
|
+
writable: true
|
911
|
+
});
|
912
|
+
} else {
|
913
|
+
obj[key] = value;
|
914
|
+
}
|
915
|
+
return obj;
|
916
|
+
}
|
836
917
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/awareness/awareness-provider.ts";
|
837
918
|
var DEBOUNCE_INTERVAL = 100;
|
838
919
|
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
920
|
open() {
|
848
921
|
this._ctx = new Context2(void 0, {
|
849
922
|
F: __dxlog_file4,
|
@@ -933,6 +1006,21 @@ var SpaceAwarenessProvider = class {
|
|
933
1006
|
this._remoteStates.set(message.state.peerId, message.state);
|
934
1007
|
this.remoteStateChange.emit();
|
935
1008
|
}
|
1009
|
+
constructor(params) {
|
1010
|
+
_define_property6(this, "_remoteStates", /* @__PURE__ */ new Map());
|
1011
|
+
_define_property6(this, "_space", void 0);
|
1012
|
+
_define_property6(this, "_channel", void 0);
|
1013
|
+
_define_property6(this, "_peerId", void 0);
|
1014
|
+
_define_property6(this, "_info", void 0);
|
1015
|
+
_define_property6(this, "_ctx", void 0);
|
1016
|
+
_define_property6(this, "_postTask", void 0);
|
1017
|
+
_define_property6(this, "_localState", void 0);
|
1018
|
+
_define_property6(this, "remoteStateChange", new Event2());
|
1019
|
+
this._space = params.space;
|
1020
|
+
this._channel = params.channel;
|
1021
|
+
this._peerId = params.peerId;
|
1022
|
+
this._info = params.info;
|
1023
|
+
}
|
936
1024
|
};
|
937
1025
|
|
938
1026
|
// src/extensions/blast.ts
|
@@ -940,6 +1028,19 @@ import { EditorView as EditorView4, keymap as keymap2 } from "@codemirror/view";
|
|
940
1028
|
import defaultsDeep from "lodash.defaultsdeep";
|
941
1029
|
import { throttle } from "@dxos/async";
|
942
1030
|
import { invariant as invariant2 } from "@dxos/invariant";
|
1031
|
+
function _define_property7(obj, key, value) {
|
1032
|
+
if (key in obj) {
|
1033
|
+
Object.defineProperty(obj, key, {
|
1034
|
+
value,
|
1035
|
+
enumerable: true,
|
1036
|
+
configurable: true,
|
1037
|
+
writable: true
|
1038
|
+
});
|
1039
|
+
} else {
|
1040
|
+
obj[key] = value;
|
1041
|
+
}
|
1042
|
+
return obj;
|
1043
|
+
}
|
943
1044
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/blast.ts";
|
944
1045
|
var defaultOptions = {
|
945
1046
|
effect: 2,
|
@@ -1034,34 +1135,6 @@ var blast = (options = defaultOptions) => {
|
|
1034
1135
|
];
|
1035
1136
|
};
|
1036
1137
|
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
1138
|
get node() {
|
1066
1139
|
return this._node;
|
1067
1140
|
}
|
@@ -1125,7 +1198,7 @@ var Blaster = class {
|
|
1125
1198
|
}
|
1126
1199
|
this._ctx.clearRect(0, 0, this._canvas.width ?? 0, this._canvas.height ?? 0);
|
1127
1200
|
const now = (/* @__PURE__ */ new Date()).getTime();
|
1128
|
-
this._lastTime
|
1201
|
+
this._lastTime ?? (this._lastTime = now);
|
1129
1202
|
const dt = (now - this._lastTime) / 1e3;
|
1130
1203
|
this._lastTime = now;
|
1131
1204
|
if (this._shakeTime > 0) {
|
@@ -1150,9 +1223,52 @@ var Blaster = class {
|
|
1150
1223
|
this._effect.update(this._ctx, particle);
|
1151
1224
|
}
|
1152
1225
|
}
|
1226
|
+
constructor(_node, _options) {
|
1227
|
+
_define_property7(this, "_node", void 0);
|
1228
|
+
_define_property7(this, "_options", void 0);
|
1229
|
+
_define_property7(this, "_effect", void 0);
|
1230
|
+
_define_property7(this, "_canvas", void 0);
|
1231
|
+
_define_property7(this, "_ctx", void 0);
|
1232
|
+
_define_property7(this, "_running", void 0);
|
1233
|
+
_define_property7(this, "_lastTime", void 0);
|
1234
|
+
_define_property7(this, "_shakeTime", void 0);
|
1235
|
+
_define_property7(this, "_shakeTimeMax", void 0);
|
1236
|
+
_define_property7(this, "_particles", void 0);
|
1237
|
+
_define_property7(this, "_particlePointer", void 0);
|
1238
|
+
_define_property7(this, "_lastPoint", void 0);
|
1239
|
+
_define_property7(this, "shake", void 0);
|
1240
|
+
_define_property7(this, "spawn", void 0);
|
1241
|
+
this._node = _node;
|
1242
|
+
this._options = _options;
|
1243
|
+
this._running = false;
|
1244
|
+
this._shakeTime = 0;
|
1245
|
+
this._shakeTimeMax = 0;
|
1246
|
+
this._particles = [];
|
1247
|
+
this._particlePointer = 0;
|
1248
|
+
this._lastPoint = {
|
1249
|
+
x: 0,
|
1250
|
+
y: 0
|
1251
|
+
};
|
1252
|
+
this.shake = throttle(({ time }) => {
|
1253
|
+
this._shakeTime = this._shakeTimeMax || time;
|
1254
|
+
this._shakeTimeMax = time;
|
1255
|
+
}, 100);
|
1256
|
+
this.spawn = throttle(({ element, point }) => {
|
1257
|
+
const color = getRGBComponents(element, this._options.color);
|
1258
|
+
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
1259
|
+
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
1260
|
+
this._lastPoint = point;
|
1261
|
+
for (let i = numParticles; i--; i > 0) {
|
1262
|
+
this._particles[this._particlePointer] = this._effect.create(point.x - dir * 16, point.y, color);
|
1263
|
+
this._particlePointer = (this._particlePointer + 1) % this._options.maxParticles;
|
1264
|
+
}
|
1265
|
+
}, 100);
|
1266
|
+
this._effect = this._options.effect === 1 ? new Effect1(_options) : new Effect2(_options);
|
1267
|
+
}
|
1153
1268
|
};
|
1154
1269
|
var Effect = class {
|
1155
1270
|
constructor(_options) {
|
1271
|
+
_define_property7(this, "_options", void 0);
|
1156
1272
|
this._options = _options;
|
1157
1273
|
}
|
1158
1274
|
};
|
@@ -1355,11 +1471,21 @@ import { isNonNullable } from "@dxos/util";
|
|
1355
1471
|
// src/extensions/command/hint.ts
|
1356
1472
|
import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
|
1357
1473
|
import { Decoration as Decoration3, EditorView as EditorView5, ViewPlugin as ViewPlugin4, WidgetType as WidgetType2 } from "@codemirror/view";
|
1474
|
+
function _define_property8(obj, key, value) {
|
1475
|
+
if (key in obj) {
|
1476
|
+
Object.defineProperty(obj, key, {
|
1477
|
+
value,
|
1478
|
+
enumerable: true,
|
1479
|
+
configurable: true,
|
1480
|
+
writable: true
|
1481
|
+
});
|
1482
|
+
} else {
|
1483
|
+
obj[key] = value;
|
1484
|
+
}
|
1485
|
+
return obj;
|
1486
|
+
}
|
1358
1487
|
var hint = ({ delay = 3e3, onHint }) => {
|
1359
1488
|
return ViewPlugin4.fromClass(class {
|
1360
|
-
constructor() {
|
1361
|
-
this.decorations = Decoration3.none;
|
1362
|
-
}
|
1363
1489
|
update(update2) {
|
1364
1490
|
if (this.timeout) {
|
1365
1491
|
clearTimeout(this.timeout);
|
@@ -1391,6 +1517,10 @@ var hint = ({ delay = 3e3, onHint }) => {
|
|
1391
1517
|
clearTimeout(this.timeout);
|
1392
1518
|
}
|
1393
1519
|
}
|
1520
|
+
constructor() {
|
1521
|
+
_define_property8(this, "decorations", Decoration3.none);
|
1522
|
+
_define_property8(this, "timeout", void 0);
|
1523
|
+
}
|
1394
1524
|
}, {
|
1395
1525
|
provide: (plugin) => [
|
1396
1526
|
EditorView5.decorations.of((view) => view.plugin(plugin)?.decorations ?? Decoration3.none)
|
@@ -1398,9 +1528,6 @@ var hint = ({ delay = 3e3, onHint }) => {
|
|
1398
1528
|
});
|
1399
1529
|
};
|
1400
1530
|
var Hint = class extends WidgetType2 {
|
1401
|
-
constructor(content) {
|
1402
|
-
super(), this.content = content;
|
1403
|
-
}
|
1404
1531
|
toDOM() {
|
1405
1532
|
const wrap = document.createElement("span");
|
1406
1533
|
wrap.className = "cm-placeholder";
|
@@ -1434,6 +1561,9 @@ var Hint = class extends WidgetType2 {
|
|
1434
1561
|
ignoreEvent() {
|
1435
1562
|
return false;
|
1436
1563
|
}
|
1564
|
+
constructor(content) {
|
1565
|
+
super(), _define_property8(this, "content", void 0), this.content = content;
|
1566
|
+
}
|
1437
1567
|
};
|
1438
1568
|
|
1439
1569
|
// src/extensions/command/command.ts
|
@@ -1453,16 +1583,26 @@ var command = (options = {}) => {
|
|
1453
1583
|
};
|
1454
1584
|
|
1455
1585
|
// src/extensions/command/command-menu.ts
|
1456
|
-
import {
|
1457
|
-
import {
|
1586
|
+
import { Prec as Prec2, RangeSetBuilder as RangeSetBuilder3, StateEffect as StateEffect3, StateField as StateField3 } from "@codemirror/state";
|
1587
|
+
import { Decoration as Decoration5, EditorView as EditorView8, ViewPlugin as ViewPlugin6, keymap as keymap4 } from "@codemirror/view";
|
1458
1588
|
|
1459
1589
|
// src/extensions/command/placeholder.ts
|
1460
|
-
import { Decoration as Decoration4, EditorView as EditorView7,
|
1590
|
+
import { Decoration as Decoration4, EditorView as EditorView7, ViewPlugin as ViewPlugin5, WidgetType as WidgetType3 } from "@codemirror/view";
|
1591
|
+
function _define_property9(obj, key, value) {
|
1592
|
+
if (key in obj) {
|
1593
|
+
Object.defineProperty(obj, key, {
|
1594
|
+
value,
|
1595
|
+
enumerable: true,
|
1596
|
+
configurable: true,
|
1597
|
+
writable: true
|
1598
|
+
});
|
1599
|
+
} else {
|
1600
|
+
obj[key] = value;
|
1601
|
+
}
|
1602
|
+
return obj;
|
1603
|
+
}
|
1461
1604
|
var placeholder = ({ delay = 3e3, content }) => {
|
1462
1605
|
const plugin = ViewPlugin5.fromClass(class {
|
1463
|
-
constructor() {
|
1464
|
-
this.decorations = Decoration4.none;
|
1465
|
-
}
|
1466
1606
|
update(update2) {
|
1467
1607
|
if (this.timeout) {
|
1468
1608
|
window.clearTimeout(this.timeout);
|
@@ -1489,6 +1629,10 @@ var placeholder = ({ delay = 3e3, content }) => {
|
|
1489
1629
|
clearTimeout(this.timeout);
|
1490
1630
|
}
|
1491
1631
|
}
|
1632
|
+
constructor() {
|
1633
|
+
_define_property9(this, "decorations", Decoration4.none);
|
1634
|
+
_define_property9(this, "timeout", void 0);
|
1635
|
+
}
|
1492
1636
|
}, {
|
1493
1637
|
provide: (plugin2) => {
|
1494
1638
|
return [
|
@@ -1504,9 +1648,6 @@ var placeholder = ({ delay = 3e3, content }) => {
|
|
1504
1648
|
] : plugin;
|
1505
1649
|
};
|
1506
1650
|
var Placeholder = class extends WidgetType3 {
|
1507
|
-
constructor(content) {
|
1508
|
-
super(), this.content = content;
|
1509
|
-
}
|
1510
1651
|
toDOM(view) {
|
1511
1652
|
const wrap = document.createElement("span");
|
1512
1653
|
wrap.className = "cm-placeholder";
|
@@ -1536,15 +1677,27 @@ var Placeholder = class extends WidgetType3 {
|
|
1536
1677
|
ignoreEvent() {
|
1537
1678
|
return false;
|
1538
1679
|
}
|
1680
|
+
constructor(content) {
|
1681
|
+
super(), _define_property9(this, "content", void 0), this.content = content;
|
1682
|
+
}
|
1539
1683
|
};
|
1540
1684
|
|
1541
1685
|
// src/extensions/command/command-menu.ts
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1686
|
+
function _define_property10(obj, key, value) {
|
1687
|
+
if (key in obj) {
|
1688
|
+
Object.defineProperty(obj, key, {
|
1689
|
+
value,
|
1690
|
+
enumerable: true,
|
1691
|
+
configurable: true,
|
1692
|
+
writable: true
|
1693
|
+
});
|
1694
|
+
} else {
|
1695
|
+
obj[key] = value;
|
1696
|
+
}
|
1697
|
+
return obj;
|
1698
|
+
}
|
1699
|
+
var commandMenu = (options) => {
|
1700
|
+
const commandMenuPlugin = ViewPlugin6.fromClass(class {
|
1548
1701
|
// TODO(wittjosiah): The decorations are repainted on every update, this occasionally causes menu to flicker.
|
1549
1702
|
update(update2) {
|
1550
1703
|
const builder = new RangeSetBuilder3();
|
@@ -1568,6 +1721,12 @@ var commandMenu = (options) => {
|
|
1568
1721
|
}
|
1569
1722
|
this.decorations = builder.finish();
|
1570
1723
|
}
|
1724
|
+
constructor(view) {
|
1725
|
+
_define_property10(this, "view", void 0);
|
1726
|
+
_define_property10(this, "decorations", void 0);
|
1727
|
+
this.view = view;
|
1728
|
+
this.decorations = Decoration5.none;
|
1729
|
+
}
|
1571
1730
|
}, {
|
1572
1731
|
decorations: (v) => v.decorations
|
1573
1732
|
});
|
@@ -1698,28 +1857,21 @@ var commandMenuState = StateField3.define({
|
|
1698
1857
|
// src/extensions/command/floating-menu.ts
|
1699
1858
|
import { EditorView as EditorView9, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
|
1700
1859
|
import { addEventListener } from "@dxos/async";
|
1860
|
+
function _define_property11(obj, key, value) {
|
1861
|
+
if (key in obj) {
|
1862
|
+
Object.defineProperty(obj, key, {
|
1863
|
+
value,
|
1864
|
+
enumerable: true,
|
1865
|
+
configurable: true,
|
1866
|
+
writable: true
|
1867
|
+
});
|
1868
|
+
} else {
|
1869
|
+
obj[key] = value;
|
1870
|
+
}
|
1871
|
+
return obj;
|
1872
|
+
}
|
1701
1873
|
var floatingMenu = (options = {}) => [
|
1702
1874
|
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
|
-
}
|
1723
1875
|
destroy() {
|
1724
1876
|
this.cleanup?.();
|
1725
1877
|
this.tag.remove();
|
@@ -1763,6 +1915,30 @@ var floatingMenu = (options = {}) => [
|
|
1763
1915
|
}
|
1764
1916
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
1765
1917
|
}
|
1918
|
+
constructor(view) {
|
1919
|
+
_define_property11(this, "view", void 0);
|
1920
|
+
_define_property11(this, "tag", void 0);
|
1921
|
+
_define_property11(this, "rafId", void 0);
|
1922
|
+
_define_property11(this, "cleanup", void 0);
|
1923
|
+
this.view = view;
|
1924
|
+
const container = view.scrollDOM;
|
1925
|
+
if (getComputedStyle(container).position === "static") {
|
1926
|
+
container.style.position = "relative";
|
1927
|
+
}
|
1928
|
+
{
|
1929
|
+
const icon = document.createElement("dx-icon");
|
1930
|
+
icon.setAttribute("icon", options.icon ?? "ph--dots-three-vertical--regular");
|
1931
|
+
const button = document.createElement("button");
|
1932
|
+
button.appendChild(icon);
|
1933
|
+
this.tag = document.createElement("dx-ref-tag");
|
1934
|
+
this.tag.classList.add("cm-ref-tag");
|
1935
|
+
this.tag.appendChild(button);
|
1936
|
+
}
|
1937
|
+
container.appendChild(this.tag);
|
1938
|
+
const handler = () => this.scheduleUpdate();
|
1939
|
+
this.cleanup = addEventListener(container, "scroll", handler);
|
1940
|
+
this.scheduleUpdate();
|
1941
|
+
}
|
1766
1942
|
}),
|
1767
1943
|
EditorView9.theme({
|
1768
1944
|
".cm-ref-tag": {
|
@@ -1786,7 +1962,20 @@ var floatingMenu = (options = {}) => [
|
|
1786
1962
|
|
1787
1963
|
// src/extensions/command/typeahead.ts
|
1788
1964
|
import { EditorSelection, Prec as Prec3, RangeSetBuilder as RangeSetBuilder4 } from "@codemirror/state";
|
1789
|
-
import { Decoration as Decoration6,
|
1965
|
+
import { Decoration as Decoration6, ViewPlugin as ViewPlugin8, keymap as keymap5 } from "@codemirror/view";
|
1966
|
+
function _define_property12(obj, key, value) {
|
1967
|
+
if (key in obj) {
|
1968
|
+
Object.defineProperty(obj, key, {
|
1969
|
+
value,
|
1970
|
+
enumerable: true,
|
1971
|
+
configurable: true,
|
1972
|
+
writable: true
|
1973
|
+
});
|
1974
|
+
} else {
|
1975
|
+
obj[key] = value;
|
1976
|
+
}
|
1977
|
+
return obj;
|
1978
|
+
}
|
1790
1979
|
var typeahead = ({ onComplete } = {}) => {
|
1791
1980
|
let hint2;
|
1792
1981
|
const complete = (view) => {
|
@@ -1808,9 +1997,6 @@ var typeahead = ({ onComplete } = {}) => {
|
|
1808
1997
|
};
|
1809
1998
|
return [
|
1810
1999
|
ViewPlugin8.fromClass(class {
|
1811
|
-
constructor() {
|
1812
|
-
this.decorations = Decoration6.none;
|
1813
|
-
}
|
1814
2000
|
update(update2) {
|
1815
2001
|
const builder = new RangeSetBuilder4();
|
1816
2002
|
const selection = update2.view.state.selection.main;
|
@@ -1828,6 +2014,9 @@ var typeahead = ({ onComplete } = {}) => {
|
|
1828
2014
|
}
|
1829
2015
|
this.decorations = builder.finish();
|
1830
2016
|
}
|
2017
|
+
constructor() {
|
2018
|
+
_define_property12(this, "decorations", Decoration6.none);
|
2019
|
+
}
|
1831
2020
|
}, {
|
1832
2021
|
decorations: (v) => v.decorations
|
1833
2022
|
}),
|
@@ -1973,7 +2162,7 @@ var useCommandMenu = ({ viewRef, trigger, placeholder: placeholder3, getMenu })
|
|
1973
2162
|
// src/extensions/comments.ts
|
1974
2163
|
import { invertedEffects } from "@codemirror/commands";
|
1975
2164
|
import { StateEffect as StateEffect4, StateField as StateField4 } from "@codemirror/state";
|
1976
|
-
import {
|
2165
|
+
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin9, hoverTooltip, keymap as keymap7 } from "@codemirror/view";
|
1977
2166
|
import sortBy from "lodash.sortby";
|
1978
2167
|
import { useEffect } from "react";
|
1979
2168
|
import { debounce as debounce2 } from "@dxos/async";
|
@@ -2074,6 +2263,19 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
2074
2263
|
};
|
2075
2264
|
|
2076
2265
|
// src/extensions/comments.ts
|
2266
|
+
function _define_property13(obj, key, value) {
|
2267
|
+
if (key in obj) {
|
2268
|
+
Object.defineProperty(obj, key, {
|
2269
|
+
value,
|
2270
|
+
enumerable: true,
|
2271
|
+
configurable: true,
|
2272
|
+
writable: true
|
2273
|
+
});
|
2274
|
+
} else {
|
2275
|
+
obj[key] = value;
|
2276
|
+
}
|
2277
|
+
return obj;
|
2278
|
+
}
|
2077
2279
|
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/comments.ts";
|
2078
2280
|
var setComments = StateEffect4.define();
|
2079
2281
|
var setSelection = StateEffect4.define();
|
@@ -2118,15 +2320,15 @@ var commentsState = StateField4.define({
|
|
2118
2320
|
});
|
2119
2321
|
var styles2 = EditorView11.theme({
|
2120
2322
|
".cm-comment, .cm-comment-current": {
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2323
|
+
padding: "3px 0",
|
2324
|
+
backgroundColor: "var(--dx-cmCommentSurface)"
|
2325
|
+
},
|
2326
|
+
".cm-comment > span, .cm-comment-current > span": {
|
2327
|
+
boxDecorationBreak: "clone",
|
2328
|
+
boxShadow: "0 0 1px 3px var(--dx-cmCommentSurface)",
|
2124
2329
|
backgroundColor: "var(--dx-cmCommentSurface)",
|
2125
2330
|
color: "var(--dx-cmComment)",
|
2126
2331
|
cursor: "pointer"
|
2127
|
-
},
|
2128
|
-
".cm-comment:hover, .cm-comment-current": {
|
2129
|
-
textDecoration: "underline"
|
2130
2332
|
}
|
2131
2333
|
});
|
2132
2334
|
var createCommentMark = (id, isCurrent) => Decoration7.mark({
|
@@ -2145,7 +2347,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
2145
2347
|
if (!range) {
|
2146
2348
|
log4.warn("Invalid range:", range, {
|
2147
2349
|
F: __dxlog_file7,
|
2148
|
-
L:
|
2350
|
+
L: 136,
|
2149
2351
|
S: void 0,
|
2150
2352
|
C: (f, a) => f(...a)
|
2151
2353
|
});
|
@@ -2461,9 +2663,10 @@ var scrollThreadIntoView = (view, id, center = true) => {
|
|
2461
2663
|
};
|
2462
2664
|
var ExternalCommentSync = class {
|
2463
2665
|
constructor(view, id, subscribe, getComments) {
|
2464
|
-
this
|
2666
|
+
_define_property13(this, "unsubscribe", void 0);
|
2667
|
+
_define_property13(this, "destroy", () => {
|
2465
2668
|
this.unsubscribe();
|
2466
|
-
};
|
2669
|
+
});
|
2467
2670
|
const updateComments = () => {
|
2468
2671
|
const comments2 = getComments();
|
2469
2672
|
if (id === view.state.facet(documentId)) {
|
@@ -2512,7 +2715,7 @@ var debugNodeLogger = (log9 = console.log) => {
|
|
2512
2715
|
};
|
2513
2716
|
|
2514
2717
|
// src/extensions/dnd.ts
|
2515
|
-
import {
|
2718
|
+
import { EditorView as EditorView12, dropCursor } from "@codemirror/view";
|
2516
2719
|
var styles3 = EditorView12.theme({
|
2517
2720
|
".cm-dropCursor": {
|
2518
2721
|
borderLeft: "2px solid var(--dx-accentText)",
|
@@ -2561,39 +2764,8 @@ import { generateName } from "@dxos/display-name";
|
|
2561
2764
|
import { log as log5 } from "@dxos/log";
|
2562
2765
|
import { hexToHue, isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
2563
2766
|
|
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
2767
|
// src/defaults.ts
|
2596
|
-
import { EditorView as
|
2768
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
2597
2769
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
2598
2770
|
|
2599
2771
|
// src/styles/markdown.ts
|
@@ -2646,7 +2818,7 @@ var defaultTheme = {
|
|
2646
2818
|
fontFamily: fontBody,
|
2647
2819
|
// NOTE: Base font size (otherwise defined by HTML tag, which might be different for storybook).
|
2648
2820
|
fontSize: "16px",
|
2649
|
-
lineHeight:
|
2821
|
+
lineHeight: "24px",
|
2650
2822
|
color: "unset"
|
2651
2823
|
},
|
2652
2824
|
/**
|
@@ -2654,8 +2826,7 @@ var defaultTheme = {
|
|
2654
2826
|
* NOTE: Gutters should have the same top margin as the content.
|
2655
2827
|
*/
|
2656
2828
|
".cm-gutters": {
|
2657
|
-
borderRight: "none"
|
2658
|
-
background: "transparent"
|
2829
|
+
borderRight: "none"
|
2659
2830
|
},
|
2660
2831
|
".cm-gutter": {},
|
2661
2832
|
".cm-gutter.cm-lineNumbers": {
|
@@ -2669,13 +2840,14 @@ var defaultTheme = {
|
|
2669
2840
|
* Height is set to match the corresponding line (which may have wrapped).
|
2670
2841
|
*/
|
2671
2842
|
".cm-gutterElement": {
|
2672
|
-
|
2673
|
-
|
2843
|
+
lineHeight: "24px",
|
2844
|
+
fontSize: "12px"
|
2674
2845
|
},
|
2675
2846
|
/**
|
2676
2847
|
* Line.
|
2677
2848
|
*/
|
2678
2849
|
".cm-line": {
|
2850
|
+
lineHeight: "24px",
|
2679
2851
|
paddingInline: 0
|
2680
2852
|
},
|
2681
2853
|
".cm-activeLine": {
|
@@ -2730,7 +2902,7 @@ var defaultTheme = {
|
|
2730
2902
|
* Tooltip.
|
2731
2903
|
*/
|
2732
2904
|
".cm-tooltip": {
|
2733
|
-
background: "var(--dx-
|
2905
|
+
background: "var(--dx-modalSurface)"
|
2734
2906
|
},
|
2735
2907
|
".cm-tooltip-below": {},
|
2736
2908
|
/**
|
@@ -2750,7 +2922,8 @@ var defaultTheme = {
|
|
2750
2922
|
padding: "4px"
|
2751
2923
|
},
|
2752
2924
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
2753
|
-
background: "var(--dx-
|
2925
|
+
background: "var(--dx-accentSurface)",
|
2926
|
+
color: "var(--dx-accentSurfaceText)"
|
2754
2927
|
},
|
2755
2928
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
2756
2929
|
paddingLeft: "4px !important",
|
@@ -2804,7 +2977,7 @@ var defaultTheme = {
|
|
2804
2977
|
outline: "1px solid transparent"
|
2805
2978
|
},
|
2806
2979
|
".cm-panel input, .cm-panel button": {
|
2807
|
-
backgroundColor: "var(--dx-
|
2980
|
+
backgroundColor: "var(--dx-inputSurface)"
|
2808
2981
|
},
|
2809
2982
|
".cm-panel input:focus, .cm-panel button:focus": {
|
2810
2983
|
outline: "1px solid var(--dx-neutralFocusIndicator)"
|
@@ -2846,19 +3019,52 @@ var editorSlots = {
|
|
2846
3019
|
className: editorWidth
|
2847
3020
|
}
|
2848
3021
|
};
|
2849
|
-
var editorGutter =
|
3022
|
+
var editorGutter = EditorView13.theme({
|
2850
3023
|
".cm-gutters": {
|
2851
|
-
|
3024
|
+
// NOTE: Color required to cover content if scrolling horizontally.
|
3025
|
+
// TODO(burdon): Non-transparent background clips the focus ring.
|
3026
|
+
background: "var(--dx-baseSurface) !important",
|
2852
3027
|
paddingRight: "1rem"
|
2853
3028
|
}
|
2854
3029
|
});
|
2855
|
-
var editorMonospace =
|
3030
|
+
var editorMonospace = EditorView13.theme({
|
2856
3031
|
".cm-content": {
|
2857
3032
|
fontFamily: fontMono
|
2858
3033
|
}
|
2859
3034
|
});
|
2860
3035
|
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("
|
3036
|
+
var stackItemContentEditorClassNames = (role) => mx2("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");
|
3037
|
+
|
3038
|
+
// src/extensions/focus.ts
|
3039
|
+
import { StateEffect as StateEffect5, StateField as StateField6 } from "@codemirror/state";
|
3040
|
+
import { EditorView as EditorView14 } from "@codemirror/view";
|
3041
|
+
var focusEffect = StateEffect5.define();
|
3042
|
+
var focusField = StateField6.define({
|
3043
|
+
create: () => false,
|
3044
|
+
update: (value, tr) => {
|
3045
|
+
for (const effect of tr.effects) {
|
3046
|
+
if (effect.is(focusEffect)) {
|
3047
|
+
return effect.value;
|
3048
|
+
}
|
3049
|
+
}
|
3050
|
+
return value;
|
3051
|
+
}
|
3052
|
+
});
|
3053
|
+
var focus = [
|
3054
|
+
focusField,
|
3055
|
+
EditorView14.domEventHandlers({
|
3056
|
+
focus: (event, view) => {
|
3057
|
+
setTimeout(() => view.dispatch({
|
3058
|
+
effects: focusEffect.of(true)
|
3059
|
+
}));
|
3060
|
+
},
|
3061
|
+
blur: (event, view) => {
|
3062
|
+
setTimeout(() => view.dispatch({
|
3063
|
+
effects: focusEffect.of(false)
|
3064
|
+
}));
|
3065
|
+
}
|
3066
|
+
})
|
3067
|
+
];
|
2862
3068
|
|
2863
3069
|
// src/extensions/factories.ts
|
2864
3070
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
|
@@ -2872,7 +3078,7 @@ var defaultBasicOptions = {
|
|
2872
3078
|
history: true,
|
2873
3079
|
keymap: "standard",
|
2874
3080
|
lineWrapping: true,
|
2875
|
-
search:
|
3081
|
+
search: false
|
2876
3082
|
};
|
2877
3083
|
var keymaps = {
|
2878
3084
|
// https://codemirror.net/docs/ref/#commands.standardKeymap
|
@@ -2887,7 +3093,7 @@ var createBasicExtensions = (_props) => {
|
|
2887
3093
|
EditorView15.exceptionSink.of((err) => {
|
2888
3094
|
log5.catch(err, void 0, {
|
2889
3095
|
F: __dxlog_file8,
|
2890
|
-
L:
|
3096
|
+
L: 101,
|
2891
3097
|
S: void 0,
|
2892
3098
|
C: (f, a) => f(...a)
|
2893
3099
|
});
|
@@ -3036,16 +3242,29 @@ var folding = (_props = {}) => [
|
|
3036
3242
|
// src/extensions/hashtag.tsx
|
3037
3243
|
import { Decoration as Decoration8, EditorView as EditorView17, MatchDecorator, ViewPlugin as ViewPlugin11, WidgetType as WidgetType4 } from "@codemirror/view";
|
3038
3244
|
import { getHashColor, mx as mx3 } from "@dxos/react-ui-theme";
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3245
|
+
function _define_property14(obj, key, value) {
|
3246
|
+
if (key in obj) {
|
3247
|
+
Object.defineProperty(obj, key, {
|
3248
|
+
value,
|
3249
|
+
enumerable: true,
|
3250
|
+
configurable: true,
|
3251
|
+
writable: true
|
3252
|
+
});
|
3253
|
+
} else {
|
3254
|
+
obj[key] = value;
|
3042
3255
|
}
|
3256
|
+
return obj;
|
3257
|
+
}
|
3258
|
+
var TagWidget = class extends WidgetType4 {
|
3043
3259
|
toDOM() {
|
3044
3260
|
const span = document.createElement("span");
|
3045
3261
|
span.className = mx3("cm-tag", getHashColor(this._text).tag);
|
3046
3262
|
span.textContent = this._text;
|
3047
3263
|
return span;
|
3048
3264
|
}
|
3265
|
+
constructor(_text) {
|
3266
|
+
super(), _define_property14(this, "_text", void 0), this._text = _text;
|
3267
|
+
}
|
3049
3268
|
};
|
3050
3269
|
var tagMatcher = new MatchDecorator({
|
3051
3270
|
regexp: /#(\w+)\W/g,
|
@@ -3055,12 +3274,13 @@ var tagMatcher = new MatchDecorator({
|
|
3055
3274
|
});
|
3056
3275
|
var hashtag = () => [
|
3057
3276
|
ViewPlugin11.fromClass(class {
|
3058
|
-
constructor(view) {
|
3059
|
-
this.tags = tagMatcher.createDeco(view);
|
3060
|
-
}
|
3061
3277
|
update(update2) {
|
3062
3278
|
this.tags = tagMatcher.updateDeco(update2, this.tags);
|
3063
3279
|
}
|
3280
|
+
constructor(view) {
|
3281
|
+
_define_property14(this, "tags", void 0);
|
3282
|
+
this.tags = tagMatcher.createDeco(view);
|
3283
|
+
}
|
3064
3284
|
}, {
|
3065
3285
|
decorations: (instance) => instance.tags,
|
3066
3286
|
provide: (plugin) => EditorView17.atomicRanges.of((view) => {
|
@@ -4295,7 +4515,7 @@ var processEditorPayload = (view, { type, data }) => {
|
|
4295
4515
|
// src/extensions/markdown/bundle.ts
|
4296
4516
|
import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
|
4297
4517
|
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
4298
|
-
import { markdownLanguage as markdownLanguage3
|
4518
|
+
import { markdown, markdownLanguage as markdownLanguage3 } from "@codemirror/lang-markdown";
|
4299
4519
|
import { syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
4300
4520
|
import { languages } from "@codemirror/language-data";
|
4301
4521
|
import { keymap as keymap10 } from "@codemirror/view";
|
@@ -4304,7 +4524,7 @@ import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
|
|
4304
4524
|
// src/extensions/markdown/highlight.ts
|
4305
4525
|
import { markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
|
4306
4526
|
import { HighlightStyle } from "@codemirror/language";
|
4307
|
-
import {
|
4527
|
+
import { Tag, styleTags, tags } from "@lezer/highlight";
|
4308
4528
|
import { Table } from "@lezer/markdown";
|
4309
4529
|
var markdownTags = {
|
4310
4530
|
Blockquote: Tag.define(),
|
@@ -4500,7 +4720,8 @@ var createMarkdownExtensions = (options = {}) => {
|
|
4500
4720
|
// Parser extensions.
|
4501
4721
|
extensions: [
|
4502
4722
|
// GFM provided by default.
|
4503
|
-
markdownTagsExtensions
|
4723
|
+
markdownTagsExtensions,
|
4724
|
+
...options.extensions ?? []
|
4504
4725
|
]
|
4505
4726
|
}),
|
4506
4727
|
// Custom styles.
|
@@ -4545,7 +4766,7 @@ var convertTreeToJson = (state) => {
|
|
4545
4766
|
// src/extensions/markdown/decorate.ts
|
4546
4767
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
4547
4768
|
import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect6 } from "@codemirror/state";
|
4548
|
-
import {
|
4769
|
+
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin13, WidgetType as WidgetType7 } from "@codemirror/view";
|
4549
4770
|
import { invariant as invariant4 } from "@dxos/invariant";
|
4550
4771
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
4551
4772
|
|
@@ -4697,6 +4918,19 @@ var getValidUrl = (str) => {
|
|
4697
4918
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
4698
4919
|
import { StateField as StateField8 } from "@codemirror/state";
|
4699
4920
|
import { Decoration as Decoration9, EditorView as EditorView20, WidgetType as WidgetType5 } from "@codemirror/view";
|
4921
|
+
function _define_property15(obj, key, value) {
|
4922
|
+
if (key in obj) {
|
4923
|
+
Object.defineProperty(obj, key, {
|
4924
|
+
value,
|
4925
|
+
enumerable: true,
|
4926
|
+
configurable: true,
|
4927
|
+
writable: true
|
4928
|
+
});
|
4929
|
+
} else {
|
4930
|
+
obj[key] = value;
|
4931
|
+
}
|
4932
|
+
return obj;
|
4933
|
+
}
|
4700
4934
|
var image = (_options = {}) => {
|
4701
4935
|
return [
|
4702
4936
|
StateField8.define({
|
@@ -4763,9 +4997,6 @@ var preloadImage = (url) => {
|
|
4763
4997
|
}
|
4764
4998
|
};
|
4765
4999
|
var ImageWidget = class extends WidgetType5 {
|
4766
|
-
constructor(_url) {
|
4767
|
-
super(), this._url = _url;
|
4768
|
-
}
|
4769
5000
|
eq(other) {
|
4770
5001
|
return this._url === other._url;
|
4771
5002
|
}
|
@@ -4780,6 +5011,9 @@ var ImageWidget = class extends WidgetType5 {
|
|
4780
5011
|
}
|
4781
5012
|
return img;
|
4782
5013
|
}
|
5014
|
+
constructor(_url) {
|
5015
|
+
super(), _define_property15(this, "_url", void 0), this._url = _url;
|
5016
|
+
}
|
4783
5017
|
};
|
4784
5018
|
|
4785
5019
|
// src/extensions/markdown/styles.ts
|
@@ -4909,6 +5143,19 @@ var formattingStyles = EditorView21.theme({
|
|
4909
5143
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
4910
5144
|
import { RangeSetBuilder as RangeSetBuilder5, StateField as StateField9 } from "@codemirror/state";
|
4911
5145
|
import { Decoration as Decoration10, EditorView as EditorView22, WidgetType as WidgetType6 } from "@codemirror/view";
|
5146
|
+
function _define_property16(obj, key, value) {
|
5147
|
+
if (key in obj) {
|
5148
|
+
Object.defineProperty(obj, key, {
|
5149
|
+
value,
|
5150
|
+
enumerable: true,
|
5151
|
+
configurable: true,
|
5152
|
+
writable: true
|
5153
|
+
});
|
5154
|
+
} else {
|
5155
|
+
obj[key] = value;
|
5156
|
+
}
|
5157
|
+
return obj;
|
5158
|
+
}
|
4912
5159
|
var table = (options = {}) => {
|
4913
5160
|
return StateField9.define({
|
4914
5161
|
create: (state) => update(state, options),
|
@@ -4940,7 +5187,8 @@ var update = (state, _options) => {
|
|
4940
5187
|
break;
|
4941
5188
|
}
|
4942
5189
|
case "TableRow": {
|
4943
|
-
|
5190
|
+
var _getTable;
|
5191
|
+
((_getTable = getTable()).rows ?? (_getTable.rows = [])).push([]);
|
4944
5192
|
break;
|
4945
5193
|
}
|
4946
5194
|
case "TableCell": {
|
@@ -4971,9 +5219,6 @@ var update = (state, _options) => {
|
|
4971
5219
|
return builder.finish();
|
4972
5220
|
};
|
4973
5221
|
var TableWidget = class extends WidgetType6 {
|
4974
|
-
constructor(_table) {
|
4975
|
-
super(), this._table = _table;
|
4976
|
-
}
|
4977
5222
|
eq(other) {
|
4978
5223
|
return this._table.header?.join() === other._table.header?.join() && this._table.rows?.join() === other._table.rows?.join();
|
4979
5224
|
}
|
@@ -5001,9 +5246,25 @@ var TableWidget = class extends WidgetType6 {
|
|
5001
5246
|
ignoreEvent(e) {
|
5002
5247
|
return !/^mouse/.test(e.type);
|
5003
5248
|
}
|
5249
|
+
constructor(_table) {
|
5250
|
+
super(), _define_property16(this, "_table", void 0), this._table = _table;
|
5251
|
+
}
|
5004
5252
|
};
|
5005
5253
|
|
5006
5254
|
// src/extensions/markdown/decorate.ts
|
5255
|
+
function _define_property17(obj, key, value) {
|
5256
|
+
if (key in obj) {
|
5257
|
+
Object.defineProperty(obj, key, {
|
5258
|
+
value,
|
5259
|
+
enumerable: true,
|
5260
|
+
configurable: true,
|
5261
|
+
writable: true
|
5262
|
+
});
|
5263
|
+
} else {
|
5264
|
+
obj[key] = value;
|
5265
|
+
}
|
5266
|
+
return obj;
|
5267
|
+
}
|
5007
5268
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts";
|
5008
5269
|
var Unicode = {
|
5009
5270
|
emDash: "\u2014",
|
@@ -5019,9 +5280,6 @@ var HorizontalRuleWidget = class extends WidgetType7 {
|
|
5019
5280
|
}
|
5020
5281
|
};
|
5021
5282
|
var LinkButton = class extends WidgetType7 {
|
5022
|
-
constructor(url, render) {
|
5023
|
-
super(), this.url = url, this.render = render;
|
5024
|
-
}
|
5025
5283
|
eq(other) {
|
5026
5284
|
return this.url === other.url;
|
5027
5285
|
}
|
@@ -5033,11 +5291,11 @@ var LinkButton = class extends WidgetType7 {
|
|
5033
5291
|
}, view);
|
5034
5292
|
return el;
|
5035
5293
|
}
|
5294
|
+
constructor(url, render) {
|
5295
|
+
super(), _define_property17(this, "url", void 0), _define_property17(this, "render", void 0), this.url = url, this.render = render;
|
5296
|
+
}
|
5036
5297
|
};
|
5037
5298
|
var CheckboxWidget = class extends WidgetType7 {
|
5038
|
-
constructor(_checked) {
|
5039
|
-
super(), this._checked = _checked;
|
5040
|
-
}
|
5041
5299
|
eq(other) {
|
5042
5300
|
return this._checked === other._checked;
|
5043
5301
|
}
|
@@ -5077,11 +5335,11 @@ var CheckboxWidget = class extends WidgetType7 {
|
|
5077
5335
|
ignoreEvent() {
|
5078
5336
|
return false;
|
5079
5337
|
}
|
5338
|
+
constructor(_checked) {
|
5339
|
+
super(), _define_property17(this, "_checked", void 0), this._checked = _checked;
|
5340
|
+
}
|
5080
5341
|
};
|
5081
5342
|
var TextWidget = class extends WidgetType7 {
|
5082
|
-
constructor(text, className) {
|
5083
|
-
super(), this.text = text, this.className = className;
|
5084
|
-
}
|
5085
5343
|
toDOM() {
|
5086
5344
|
const el = document.createElement("span");
|
5087
5345
|
if (this.className) {
|
@@ -5090,6 +5348,9 @@ var TextWidget = class extends WidgetType7 {
|
|
5090
5348
|
el.innerText = this.text;
|
5091
5349
|
return el;
|
5092
5350
|
}
|
5351
|
+
constructor(text, className) {
|
5352
|
+
super(), _define_property17(this, "text", void 0), _define_property17(this, "className", void 0), this.text = text, this.className = className;
|
5353
|
+
}
|
5093
5354
|
};
|
5094
5355
|
var hide = Decoration11.replace({});
|
5095
5356
|
var blockQuote = Decoration11.line({
|
@@ -5136,7 +5397,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
5136
5397
|
const getHeaderLevels = (node, level) => {
|
5137
5398
|
invariant4(level > 0, void 0, {
|
5138
5399
|
F: __dxlog_file9,
|
5139
|
-
L:
|
5400
|
+
L: 180,
|
5140
5401
|
S: void 0,
|
5141
5402
|
A: [
|
5142
5403
|
"level > 0",
|
@@ -5175,7 +5436,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
5175
5436
|
const getCurrentListLevel = () => {
|
5176
5437
|
invariant4(listLevels.length, void 0, {
|
5177
5438
|
F: __dxlog_file9,
|
5178
|
-
L:
|
5439
|
+
L: 202,
|
5179
5440
|
S: void 0,
|
5180
5441
|
A: [
|
5181
5442
|
"listLevels.length",
|
@@ -5415,9 +5676,6 @@ var forceUpdate = StateEffect6.define();
|
|
5415
5676
|
var decorateMarkdown = (options = {}) => {
|
5416
5677
|
return [
|
5417
5678
|
ViewPlugin13.fromClass(class {
|
5418
|
-
constructor(view) {
|
5419
|
-
({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
|
5420
|
-
}
|
5421
5679
|
update(update2) {
|
5422
5680
|
if (update2.docChanged || update2.viewportChanged || update2.focusChanged || update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(forceUpdate))) || update2.selectionSet && !options.selectionChangeDelay) {
|
5423
5681
|
({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(update2.view, options, update2.view.hasFocus));
|
@@ -5444,6 +5702,12 @@ var decorateMarkdown = (options = {}) => {
|
|
5444
5702
|
destroy() {
|
5445
5703
|
this.clearUpdate();
|
5446
5704
|
}
|
5705
|
+
constructor(view) {
|
5706
|
+
_define_property17(this, "deco", void 0);
|
5707
|
+
_define_property17(this, "atomicDeco", void 0);
|
5708
|
+
_define_property17(this, "pendingUpdate", void 0);
|
5709
|
+
({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
|
5710
|
+
}
|
5447
5711
|
}, {
|
5448
5712
|
provide: (plugin) => [
|
5449
5713
|
EditorView23.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
|
@@ -5585,6 +5849,19 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
5585
5849
|
import { StateField as StateField10 } from "@codemirror/state";
|
5586
5850
|
import { Facet as Facet2 } from "@codemirror/state";
|
5587
5851
|
import { invariant as invariant5 } from "@dxos/invariant";
|
5852
|
+
function _define_property18(obj, key, value) {
|
5853
|
+
if (key in obj) {
|
5854
|
+
Object.defineProperty(obj, key, {
|
5855
|
+
value,
|
5856
|
+
enumerable: true,
|
5857
|
+
configurable: true,
|
5858
|
+
writable: true
|
5859
|
+
});
|
5860
|
+
} else {
|
5861
|
+
obj[key] = value;
|
5862
|
+
}
|
5863
|
+
return obj;
|
5864
|
+
}
|
5588
5865
|
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/tree.ts";
|
5589
5866
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
5590
5867
|
return {
|
@@ -5597,18 +5874,6 @@ var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) =>
|
|
5597
5874
|
};
|
5598
5875
|
};
|
5599
5876
|
var Tree = class {
|
5600
|
-
constructor(node) {
|
5601
|
-
this.type = "root";
|
5602
|
-
this.index = -1;
|
5603
|
-
this.level = -1;
|
5604
|
-
this.children = [];
|
5605
|
-
this.node = node;
|
5606
|
-
this.lineRange = {
|
5607
|
-
from: node.from,
|
5608
|
-
to: node.to
|
5609
|
-
};
|
5610
|
-
this.contentRange = this.lineRange;
|
5611
|
-
}
|
5612
5877
|
toJSON() {
|
5613
5878
|
return itemToJSON(this);
|
5614
5879
|
}
|
@@ -5658,6 +5923,21 @@ var Tree = class {
|
|
5658
5923
|
lastDescendant(item) {
|
5659
5924
|
return item.children.length > 0 ? this.lastDescendant(item.children.at(-1)) : item;
|
5660
5925
|
}
|
5926
|
+
constructor(node) {
|
5927
|
+
_define_property18(this, "type", "root");
|
5928
|
+
_define_property18(this, "index", -1);
|
5929
|
+
_define_property18(this, "level", -1);
|
5930
|
+
_define_property18(this, "node", void 0);
|
5931
|
+
_define_property18(this, "lineRange", void 0);
|
5932
|
+
_define_property18(this, "contentRange", void 0);
|
5933
|
+
_define_property18(this, "children", []);
|
5934
|
+
this.node = node;
|
5935
|
+
this.lineRange = {
|
5936
|
+
from: node.from,
|
5937
|
+
to: node.to
|
5938
|
+
};
|
5939
|
+
this.contentRange = this.lineRange;
|
5940
|
+
}
|
5661
5941
|
};
|
5662
5942
|
var getRange = (tree, item) => {
|
5663
5943
|
const lastDescendant = tree.lastDescendant(item);
|
@@ -6338,6 +6618,19 @@ var editor = () => [
|
|
6338
6618
|
];
|
6339
6619
|
|
6340
6620
|
// src/extensions/outliner/outliner.ts
|
6621
|
+
function _define_property19(obj, key, value) {
|
6622
|
+
if (key in obj) {
|
6623
|
+
Object.defineProperty(obj, key, {
|
6624
|
+
value,
|
6625
|
+
enumerable: true,
|
6626
|
+
configurable: true,
|
6627
|
+
writable: true
|
6628
|
+
});
|
6629
|
+
} else {
|
6630
|
+
obj[key] = value;
|
6631
|
+
}
|
6632
|
+
return obj;
|
6633
|
+
}
|
6341
6634
|
var outliner = (options = {}) => [
|
6342
6635
|
// Commands.
|
6343
6636
|
Prec4.highest(commands()),
|
@@ -6362,10 +6655,6 @@ var outliner = (options = {}) => [
|
|
6362
6655
|
];
|
6363
6656
|
var decorations = () => [
|
6364
6657
|
ViewPlugin15.fromClass(class {
|
6365
|
-
constructor(view) {
|
6366
|
-
this.decorations = Decoration12.none;
|
6367
|
-
this.updateDecorations(view.state, view);
|
6368
|
-
}
|
6369
6658
|
update(update2) {
|
6370
6659
|
const selectionChanged = !selectionEquals(update2.state.facet(selectionFacet), update2.startState.facet(selectionFacet));
|
6371
6660
|
if (update2.focusChanged || update2.docChanged || update2.viewportChanged || update2.selectionSet || selectionChanged) {
|
@@ -6392,6 +6681,10 @@ var decorations = () => [
|
|
6392
6681
|
}
|
6393
6682
|
this.decorations = Decoration12.set(decorations2);
|
6394
6683
|
}
|
6684
|
+
constructor(view) {
|
6685
|
+
_define_property19(this, "decorations", Decoration12.none);
|
6686
|
+
this.updateDecorations(view.state, view);
|
6687
|
+
}
|
6395
6688
|
}, {
|
6396
6689
|
decorations: (v) => v.decorations
|
6397
6690
|
}),
|
@@ -6434,6 +6727,19 @@ import "@dxos/lit-ui/dx-ref-tag.pcss";
|
|
6434
6727
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
6435
6728
|
import { RangeSetBuilder as RangeSetBuilder7, StateField as StateField11 } from "@codemirror/state";
|
6436
6729
|
import { Decoration as Decoration13, EditorView as EditorView25, WidgetType as WidgetType8 } from "@codemirror/view";
|
6730
|
+
function _define_property20(obj, key, value) {
|
6731
|
+
if (key in obj) {
|
6732
|
+
Object.defineProperty(obj, key, {
|
6733
|
+
value,
|
6734
|
+
enumerable: true,
|
6735
|
+
configurable: true,
|
6736
|
+
writable: true
|
6737
|
+
});
|
6738
|
+
} else {
|
6739
|
+
obj[key] = value;
|
6740
|
+
}
|
6741
|
+
return obj;
|
6742
|
+
}
|
6437
6743
|
var preview = (options = {}) => {
|
6438
6744
|
return [
|
6439
6745
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
@@ -6500,9 +6806,6 @@ var buildDecorations3 = (state, options) => {
|
|
6500
6806
|
return builder.finish();
|
6501
6807
|
};
|
6502
6808
|
var PreviewInlineWidget = class extends WidgetType8 {
|
6503
|
-
constructor(_options, _link) {
|
6504
|
-
super(), this._options = _options, this._link = _link;
|
6505
|
-
}
|
6506
6809
|
// override ignoreEvent() {
|
6507
6810
|
// return false;
|
6508
6811
|
// }
|
@@ -6515,11 +6818,11 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
6515
6818
|
root.setAttribute("refId", this._link.ref);
|
6516
6819
|
return root;
|
6517
6820
|
}
|
6518
|
-
};
|
6519
|
-
var PreviewBlockWidget = class extends WidgetType8 {
|
6520
6821
|
constructor(_options, _link) {
|
6521
|
-
super(), this._options = _options, this._link = _link;
|
6822
|
+
super(), _define_property20(this, "_options", void 0), _define_property20(this, "_link", void 0), this._options = _options, this._link = _link;
|
6522
6823
|
}
|
6824
|
+
};
|
6825
|
+
var PreviewBlockWidget = class extends WidgetType8 {
|
6523
6826
|
// override ignoreEvent() {
|
6524
6827
|
// return true;
|
6525
6828
|
// }
|
@@ -6535,6 +6838,9 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
6535
6838
|
destroy() {
|
6536
6839
|
this._options.removeBlockContainer?.(this._link);
|
6537
6840
|
}
|
6841
|
+
constructor(_options, _link) {
|
6842
|
+
super(), _define_property20(this, "_options", void 0), _define_property20(this, "_link", void 0), this._options = _options, this._link = _link;
|
6843
|
+
}
|
6538
6844
|
};
|
6539
6845
|
|
6540
6846
|
// src/extensions/typewriter.ts
|
@@ -6783,23 +7089,32 @@ import { createMenuAction, createMenuItemGroup } from "@dxos/react-ui-menu";
|
|
6783
7089
|
var useEditorToolbarState = (initialState = {}) => {
|
6784
7090
|
return useMemo4(() => live(initialState), []);
|
6785
7091
|
};
|
6786
|
-
var createEditorAction = (id,
|
7092
|
+
var createEditorAction = (id, props, invoke) => {
|
6787
7093
|
const { label = [
|
6788
7094
|
`${id} label`,
|
6789
7095
|
{
|
6790
7096
|
ns: translationKey
|
6791
7097
|
}
|
6792
|
-
], ...rest } =
|
7098
|
+
], ...rest } = props;
|
6793
7099
|
return createMenuAction(id, invoke, {
|
6794
7100
|
label,
|
6795
7101
|
...rest
|
6796
7102
|
});
|
6797
7103
|
};
|
6798
|
-
var createEditorActionGroup = (id, props, icon) =>
|
6799
|
-
|
6800
|
-
|
6801
|
-
|
6802
|
-
|
7104
|
+
var createEditorActionGroup = (id, props, icon) => {
|
7105
|
+
const { label = [
|
7106
|
+
`${id} label`,
|
7107
|
+
{
|
7108
|
+
ns: translationKey
|
7109
|
+
}
|
7110
|
+
], ...rest } = props;
|
7111
|
+
return createMenuItemGroup(id, {
|
7112
|
+
label,
|
7113
|
+
icon,
|
7114
|
+
iconOnly: true,
|
7115
|
+
...rest
|
7116
|
+
});
|
7117
|
+
};
|
6803
7118
|
|
6804
7119
|
// src/components/EditorToolbar/blocks.ts
|
6805
7120
|
var createBlockGroupAction = (value) => createEditorActionGroup("block", {
|
@@ -6813,7 +7128,13 @@ var createBlockActions = (value, getView, blankLine) => Object.entries({
|
|
6813
7128
|
table: "ph--table--regular"
|
6814
7129
|
}).map(([type, icon]) => {
|
6815
7130
|
const checked = type === value;
|
6816
|
-
return createEditorAction(type,
|
7131
|
+
return createEditorAction(type, {
|
7132
|
+
checked,
|
7133
|
+
...type === "table" && {
|
7134
|
+
disabled: !!blankLine
|
7135
|
+
},
|
7136
|
+
icon
|
7137
|
+
}, () => {
|
6817
7138
|
const view = getView();
|
6818
7139
|
if (!view) {
|
6819
7140
|
return;
|
@@ -6829,12 +7150,6 @@ var createBlockActions = (value, getView, blankLine) => Object.entries({
|
|
6829
7150
|
insertTable(view);
|
6830
7151
|
break;
|
6831
7152
|
}
|
6832
|
-
}, {
|
6833
|
-
checked,
|
6834
|
-
...type === "table" && {
|
6835
|
-
disabled: !!blankLine
|
6836
|
-
},
|
6837
|
-
icon
|
6838
7153
|
});
|
6839
7154
|
});
|
6840
7155
|
var createBlocks = (state, getView) => {
|
@@ -6874,7 +7189,10 @@ var createFormattingGroup = (formatting) => createEditorActionGroup("formatting"
|
|
6874
7189
|
});
|
6875
7190
|
var createFormattingActions = (formatting, getView) => Object.entries(formats).map(([type, icon]) => {
|
6876
7191
|
const checked = !!formatting[type];
|
6877
|
-
return createEditorAction(type,
|
7192
|
+
return createEditorAction(type, {
|
7193
|
+
checked,
|
7194
|
+
icon
|
7195
|
+
}, () => {
|
6878
7196
|
const view = getView();
|
6879
7197
|
if (!view) {
|
6880
7198
|
return;
|
@@ -6885,9 +7203,6 @@ var createFormattingActions = (formatting, getView) => Object.entries(formats).m
|
|
6885
7203
|
}
|
6886
7204
|
const inlineType = type === "strong" ? Inline.Strong : type === "emphasis" ? Inline.Emphasis : type === "strikethrough" ? Inline.Strikethrough : Inline.Code;
|
6887
7205
|
setStyle(inlineType, !checked)(view);
|
6888
|
-
}, {
|
6889
|
-
checked,
|
6890
|
-
icon
|
6891
7206
|
});
|
6892
7207
|
});
|
6893
7208
|
var createFormatting = (state, getView) => {
|
@@ -6928,7 +7243,7 @@ var createHeadingActions = (getView) => Object.entries({
|
|
6928
7243
|
"6": "ph--text-h-six--regular"
|
6929
7244
|
}).map(([levelStr, icon]) => {
|
6930
7245
|
const level = parseInt(levelStr);
|
6931
|
-
return createEditorAction(`heading--${levelStr}`,
|
7246
|
+
return createEditorAction(`heading--${levelStr}`, {
|
6932
7247
|
label: [
|
6933
7248
|
"heading level label",
|
6934
7249
|
{
|
@@ -6937,7 +7252,7 @@ var createHeadingActions = (getView) => Object.entries({
|
|
6937
7252
|
}
|
6938
7253
|
],
|
6939
7254
|
icon
|
6940
|
-
});
|
7255
|
+
}, () => setHeading(level)(getView()));
|
6941
7256
|
});
|
6942
7257
|
var computeHeadingValue = (state) => {
|
6943
7258
|
const blockType = state ? state.blockType : "paragraph";
|
@@ -6967,10 +7282,10 @@ var createHeadings = (state, getView) => {
|
|
6967
7282
|
};
|
6968
7283
|
|
6969
7284
|
// src/components/EditorToolbar/image.ts
|
6970
|
-
var createImageUploadAction = (onImageUpload) => createEditorAction("image",
|
7285
|
+
var createImageUploadAction = (onImageUpload) => createEditorAction("image", {
|
6971
7286
|
testId: "editor.toolbar.image",
|
6972
7287
|
icon: "ph--image-square--regular"
|
6973
|
-
});
|
7288
|
+
}, onImageUpload);
|
6974
7289
|
var createImageUpload = (onImageUpload) => ({
|
6975
7290
|
nodes: [
|
6976
7291
|
createImageUploadAction(onImageUpload)
|
@@ -6996,7 +7311,10 @@ var createListGroupAction = (value) => createEditorActionGroup("list", {
|
|
6996
7311
|
});
|
6997
7312
|
var createListActions = (value, getView) => Object.entries(listStyles).map(([listStyle, icon]) => {
|
6998
7313
|
const checked = value === listStyle;
|
6999
|
-
return createEditorAction(`list-${listStyle}`,
|
7314
|
+
return createEditorAction(`list-${listStyle}`, {
|
7315
|
+
checked,
|
7316
|
+
icon
|
7317
|
+
}, () => {
|
7000
7318
|
const view = getView();
|
7001
7319
|
if (!view) {
|
7002
7320
|
return;
|
@@ -7007,9 +7325,6 @@ var createListActions = (value, getView) => Object.entries(listStyles).map(([lis
|
|
7007
7325
|
} else {
|
7008
7326
|
addList(listType)(view);
|
7009
7327
|
}
|
7010
|
-
}, {
|
7011
|
-
checked,
|
7012
|
-
icon
|
7013
7328
|
});
|
7014
7329
|
});
|
7015
7330
|
var createLists = (state, getView) => {
|
@@ -7036,10 +7351,10 @@ var createLists = (state, getView) => {
|
|
7036
7351
|
|
7037
7352
|
// src/components/EditorToolbar/search.ts
|
7038
7353
|
import { openSearchPanel } from "@codemirror/search";
|
7039
|
-
var createSearchAction = (getView) => createEditorAction("search",
|
7354
|
+
var createSearchAction = (getView) => createEditorAction("search", {
|
7040
7355
|
testId: "editor.toolbar.search",
|
7041
7356
|
icon: "ph--magnifying-glass--regular"
|
7042
|
-
});
|
7357
|
+
}, () => openSearchPanel(getView()));
|
7043
7358
|
var createSearch = (getView) => ({
|
7044
7359
|
nodes: [
|
7045
7360
|
createSearchAction(getView)
|
@@ -7065,7 +7380,7 @@ var createViewModeActions = (value, onViewModeChange) => Object.entries({
|
|
7065
7380
|
readonly: "ph--pencil-slash--regular"
|
7066
7381
|
}).map(([viewMode, icon]) => {
|
7067
7382
|
const checked = viewMode === value;
|
7068
|
-
return createEditorAction(`view-mode--${viewMode}`,
|
7383
|
+
return createEditorAction(`view-mode--${viewMode}`, {
|
7069
7384
|
label: [
|
7070
7385
|
`${viewMode} mode label`,
|
7071
7386
|
{
|
@@ -7074,7 +7389,7 @@ var createViewModeActions = (value, onViewModeChange) => Object.entries({
|
|
7074
7389
|
],
|
7075
7390
|
checked,
|
7076
7391
|
icon
|
7077
|
-
});
|
7392
|
+
}, () => onViewModeChange(viewMode));
|
7078
7393
|
});
|
7079
7394
|
var createViewMode = (state, onViewModeChange) => {
|
7080
7395
|
const value = state.viewMode ?? "source";
|
@@ -7099,61 +7414,62 @@ var createViewMode = (state, onViewModeChange) => {
|
|
7099
7414
|
};
|
7100
7415
|
|
7101
7416
|
// src/components/EditorToolbar/EditorToolbar.tsx
|
7102
|
-
var
|
7417
|
+
var createToolbarActions = ({ getView, state, customActions, ...features }) => {
|
7103
7418
|
return Rx.make((get2) => {
|
7104
|
-
const
|
7105
|
-
|
7419
|
+
const graph = {
|
7420
|
+
nodes: [],
|
7421
|
+
edges: []
|
7422
|
+
};
|
7106
7423
|
if (features.headings ?? true) {
|
7107
7424
|
const headings2 = get2(rxFromSignal(() => createHeadings(state, getView)));
|
7108
|
-
nodes.push(...headings2.nodes);
|
7109
|
-
edges.push(...headings2.edges);
|
7425
|
+
graph.nodes.push(...headings2.nodes);
|
7426
|
+
graph.edges.push(...headings2.edges);
|
7110
7427
|
}
|
7111
7428
|
if (features.formatting ?? true) {
|
7112
7429
|
const formatting = get2(rxFromSignal(() => createFormatting(state, getView)));
|
7113
|
-
nodes.push(...formatting.nodes);
|
7114
|
-
edges.push(...formatting.edges);
|
7430
|
+
graph.nodes.push(...formatting.nodes);
|
7431
|
+
graph.edges.push(...formatting.edges);
|
7115
7432
|
}
|
7116
7433
|
if (features.lists ?? true) {
|
7117
7434
|
const lists = get2(rxFromSignal(() => createLists(state, getView)));
|
7118
|
-
nodes.push(...lists.nodes);
|
7119
|
-
edges.push(...lists.edges);
|
7435
|
+
graph.nodes.push(...lists.nodes);
|
7436
|
+
graph.edges.push(...lists.edges);
|
7120
7437
|
}
|
7121
7438
|
if (features.blocks ?? true) {
|
7122
7439
|
const blocks = get2(rxFromSignal(() => createBlocks(state, getView)));
|
7123
|
-
nodes.push(...blocks.nodes);
|
7124
|
-
edges.push(...blocks.edges);
|
7440
|
+
graph.nodes.push(...blocks.nodes);
|
7441
|
+
graph.edges.push(...blocks.edges);
|
7125
7442
|
}
|
7126
7443
|
if (features.image) {
|
7127
7444
|
const image2 = get2(rxFromSignal(() => createImageUpload(features.image)));
|
7128
|
-
nodes.push(...image2.nodes);
|
7129
|
-
edges.push(...image2.edges);
|
7445
|
+
graph.nodes.push(...image2.nodes);
|
7446
|
+
graph.edges.push(...image2.edges);
|
7447
|
+
}
|
7448
|
+
{
|
7449
|
+
const gap = createGapSeparator();
|
7450
|
+
graph.nodes.push(...gap.nodes);
|
7451
|
+
graph.edges.push(...gap.edges);
|
7130
7452
|
}
|
7131
|
-
const editorToolbarGap = createGapSeparator();
|
7132
|
-
nodes.push(...editorToolbarGap.nodes);
|
7133
|
-
edges.push(...editorToolbarGap.edges);
|
7134
7453
|
if (customActions) {
|
7135
7454
|
const custom = get2(customActions);
|
7136
|
-
nodes.push(...custom.nodes);
|
7137
|
-
edges.push(...custom.edges);
|
7455
|
+
graph.nodes.push(...custom.nodes);
|
7456
|
+
graph.edges.push(...custom.edges);
|
7138
7457
|
}
|
7139
7458
|
if (features.search ?? true) {
|
7140
7459
|
const search = get2(rxFromSignal(() => createSearch(getView)));
|
7141
|
-
nodes.push(...search.nodes);
|
7142
|
-
edges.push(...search.edges);
|
7460
|
+
graph.nodes.push(...search.nodes);
|
7461
|
+
graph.edges.push(...search.edges);
|
7143
7462
|
}
|
7144
7463
|
if (features.viewMode) {
|
7145
7464
|
const viewMode = get2(rxFromSignal(() => createViewMode(state, features.viewMode)));
|
7146
|
-
nodes.push(...viewMode.nodes);
|
7147
|
-
edges.push(...viewMode.edges);
|
7465
|
+
graph.nodes.push(...viewMode.nodes);
|
7466
|
+
graph.edges.push(...viewMode.edges);
|
7148
7467
|
}
|
7149
|
-
return
|
7150
|
-
nodes,
|
7151
|
-
edges
|
7152
|
-
};
|
7468
|
+
return graph;
|
7153
7469
|
});
|
7154
7470
|
};
|
7155
7471
|
var useEditorToolbarActionGraph = (props) => {
|
7156
|
-
const menuCreator = useMemo5(() =>
|
7472
|
+
const menuCreator = useMemo5(() => createToolbarActions({
|
7157
7473
|
getView: props.getView,
|
7158
7474
|
state: props.state,
|
7159
7475
|
customActions: props.customActions,
|
@@ -7198,7 +7514,7 @@ var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...p
|
|
7198
7514
|
|
7199
7515
|
// src/components/Popover/CommandMenu.tsx
|
7200
7516
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
7201
|
-
import React5, { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3 } from "react";
|
7517
|
+
import React5, { Fragment, useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3 } from "react";
|
7202
7518
|
import { Icon as Icon2, Popover, toLocalizedString, useThemeContext as useThemeContext2, useTranslation } from "@dxos/react-ui";
|
7203
7519
|
var CommandMenu = ({ groups, currentItem, onSelect }) => {
|
7204
7520
|
var _effect = _useSignals3();
|
@@ -7215,7 +7531,7 @@ var CommandMenu = ({ groups, currentItem, onSelect }) => {
|
|
7215
7531
|
])
|
7216
7532
|
}, /* @__PURE__ */ React5.createElement(Popover.Viewport, {
|
7217
7533
|
classNames: tx("menu.viewport", "menu__viewport--exotic-unfocusable", {})
|
7218
|
-
}, /* @__PURE__ */ React5.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React5.createElement(
|
7534
|
+
}, /* @__PURE__ */ React5.createElement("ul", null, groupsWithItems.map((group, index) => /* @__PURE__ */ React5.createElement(Fragment, {
|
7219
7535
|
key: group.id
|
7220
7536
|
}, /* @__PURE__ */ React5.createElement(CommandGroup, {
|
7221
7537
|
group,
|
@@ -7464,7 +7780,7 @@ var linkSlashCommands = {
|
|
7464
7780
|
// src/components/Popover/RefPopover.tsx
|
7465
7781
|
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
7466
7782
|
import { createContext } from "@radix-ui/react-context";
|
7467
|
-
import React6, {
|
7783
|
+
import React6, { forwardRef as forwardRef2, useCallback as useCallback5, useEffect as useEffect4, useRef as useRef4, useState as useState3 } from "react";
|
7468
7784
|
import { addEventListener as addEventListener2 } from "@dxos/async";
|
7469
7785
|
import { Popover as Popover2 } from "@dxos/react-ui";
|
7470
7786
|
var customEventOptions = {
|
@@ -7548,7 +7864,7 @@ var PreviewProvider = ({ children, onLookup }) => {
|
|
7548
7864
|
// src/components/Popover/RefDropdownMenu.tsx
|
7549
7865
|
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
7550
7866
|
import { createContext as createContext2 } from "@radix-ui/react-context";
|
7551
|
-
import React7, {
|
7867
|
+
import React7, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef5, useState as useState4 } from "react";
|
7552
7868
|
import { addEventListener as addEventListener3 } from "@dxos/async";
|
7553
7869
|
import { DropdownMenu } from "@dxos/react-ui";
|
7554
7870
|
var customEventOptions2 = {
|