@dxos/react-ui-editor 0.3.11-main.c86e105 → 0.3.11-main.cd64fe0
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 +84 -96
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +3 -0
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +2 -2
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/comments.stories.d.ts +1 -1
- package/dist/types/src/components/TextEditor/comments.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts +4 -4
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/semaphore.d.ts +4 -9
- package/dist/types/src/extensions/automerge/semaphore.d.ts.map +1 -1
- package/dist/types/src/extensions/code.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +9 -4
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/hr.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +1 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner.d.ts +4 -0
- package/dist/types/src/extensions/outliner.d.ts.map +1 -0
- package/dist/types/src/extensions/tasklist.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +16 -14
- package/src/components/TextEditor/TextEditor.tsx +12 -12
- package/src/components/TextEditor/comments.stories.tsx +74 -48
- package/src/extensions/automerge/automerge.ts +10 -12
- package/src/extensions/automerge/defs.ts +13 -9
- package/src/extensions/automerge/semaphore.ts +10 -12
- package/src/extensions/awareness.ts +2 -1
- package/src/extensions/code.ts +15 -17
- package/src/extensions/comments.ts +68 -50
- package/src/extensions/hr.ts +6 -7
- package/src/extensions/index.ts +1 -0
- package/src/extensions/link.ts +3 -3
- package/src/extensions/outliner.ts +12 -0
- package/src/extensions/tasklist.ts +1 -0
- package/src/hooks/index.ts +2 -1
|
@@ -51,7 +51,7 @@ var autocomplete = ({ onSearch }) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// packages/ui/react-ui-editor/src/extensions/automerge/automerge.ts
|
|
54
|
-
import {
|
|
54
|
+
import { StateField } from "@codemirror/state";
|
|
55
55
|
import { ViewPlugin } from "@codemirror/view";
|
|
56
56
|
import { next as A } from "@dxos/automerge/automerge";
|
|
57
57
|
|
|
@@ -92,7 +92,7 @@ var cursorConverter = (handle, path) => ({
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
// packages/ui/react-ui-editor/src/extensions/automerge/defs.ts
|
|
95
|
-
import { Annotation, StateEffect } from "@codemirror/state";
|
|
95
|
+
import { Annotation, StateEffect, Facet } from "@codemirror/state";
|
|
96
96
|
var effectType = StateEffect.define({});
|
|
97
97
|
var updateHeads = (newHeads) => effectType.of({
|
|
98
98
|
newHeads
|
|
@@ -101,6 +101,9 @@ var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
|
101
101
|
var getPath = (state, field) => state.field(field).path;
|
|
102
102
|
var reconcileAnnotationType = Annotation.define();
|
|
103
103
|
var isReconcileTx = (tr) => !!tr.annotation(reconcileAnnotationType);
|
|
104
|
+
var semaphoreFacet = Facet.define({
|
|
105
|
+
combine: (values) => values.at(-1)
|
|
106
|
+
});
|
|
104
107
|
|
|
105
108
|
// packages/ui/react-ui-editor/src/extensions/automerge/semaphore.ts
|
|
106
109
|
import { next as automerge2 } from "@dxos/automerge/automerge";
|
|
@@ -237,11 +240,11 @@ var charPath = (textPath, candidatePath) => {
|
|
|
237
240
|
|
|
238
241
|
// packages/ui/react-ui-editor/src/extensions/automerge/semaphore.ts
|
|
239
242
|
var PatchSemaphore = class {
|
|
240
|
-
constructor(_field) {
|
|
243
|
+
constructor(_handle, _field) {
|
|
244
|
+
this._handle = _handle;
|
|
241
245
|
this._field = _field;
|
|
242
246
|
this._inReconcile = false;
|
|
243
|
-
this.
|
|
244
|
-
this.reconcile = (handle, view) => {
|
|
247
|
+
this.reconcile = (view) => {
|
|
245
248
|
if (this._inReconcile) {
|
|
246
249
|
return;
|
|
247
250
|
}
|
|
@@ -259,11 +262,11 @@ var PatchSemaphore = class {
|
|
|
259
262
|
annotations: reconcileAnnotationType.of(true)
|
|
260
263
|
});
|
|
261
264
|
}
|
|
262
|
-
let newHeads = updateAutomerge(this._field,
|
|
265
|
+
let newHeads = updateAutomerge(this._field, this._handle, transactions, view.state);
|
|
263
266
|
if (newHeads === null || newHeads === void 0) {
|
|
264
|
-
newHeads = automerge2.getHeads(
|
|
267
|
+
newHeads = automerge2.getHeads(this._handle.docSync());
|
|
265
268
|
}
|
|
266
|
-
const diff = automerge2.equals(oldHeads, newHeads) ? [] : automerge2.diff(
|
|
269
|
+
const diff = automerge2.equals(oldHeads, newHeads) ? [] : automerge2.diff(this._handle.docSync(), oldHeads, newHeads);
|
|
267
270
|
updateCodeMirror(view, selection, path, diff);
|
|
268
271
|
view.dispatch({
|
|
269
272
|
effects: updateHeads(newHeads),
|
|
@@ -275,14 +278,14 @@ var PatchSemaphore = class {
|
|
|
275
278
|
};
|
|
276
279
|
|
|
277
280
|
// packages/ui/react-ui-editor/src/extensions/cursor.ts
|
|
278
|
-
import { Facet } from "@codemirror/state";
|
|
281
|
+
import { Facet as Facet2 } from "@codemirror/state";
|
|
279
282
|
var defaultCursorConverter = {
|
|
280
283
|
toCursor: (position) => position.toString(),
|
|
281
284
|
fromCursor: (cursor) => parseInt(cursor)
|
|
282
285
|
};
|
|
283
286
|
var Cursor = class {
|
|
284
287
|
static {
|
|
285
|
-
this.converter =
|
|
288
|
+
this.converter = Facet2.define({
|
|
286
289
|
combine: (providers) => providers[0] ?? defaultCursorConverter
|
|
287
290
|
});
|
|
288
291
|
}
|
|
@@ -310,9 +313,6 @@ var Cursor = class {
|
|
|
310
313
|
};
|
|
311
314
|
|
|
312
315
|
// packages/ui/react-ui-editor/src/extensions/automerge/automerge.ts
|
|
313
|
-
var semaphoreFacet = Facet2.define({
|
|
314
|
-
combine: (values) => values.at(-1)
|
|
315
|
-
});
|
|
316
316
|
var automerge3 = ({ handle, path }) => {
|
|
317
317
|
const stateField = StateField.define({
|
|
318
318
|
create: () => ({
|
|
@@ -343,19 +343,19 @@ var automerge3 = ({ handle, path }) => {
|
|
|
343
343
|
return result;
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
|
-
const semaphore = new PatchSemaphore(stateField);
|
|
347
|
-
const viewPlugin = ViewPlugin.fromClass(class
|
|
346
|
+
const semaphore = new PatchSemaphore(handle, stateField);
|
|
347
|
+
const viewPlugin = ViewPlugin.fromClass(class AutomergeViewPlugin {
|
|
348
348
|
constructor(_view) {
|
|
349
349
|
this._view = _view;
|
|
350
350
|
this._handleChange = () => {
|
|
351
|
-
this._view.state.facet(semaphoreFacet).reconcile(
|
|
351
|
+
this._view.state.facet(semaphoreFacet).reconcile(this._view);
|
|
352
352
|
};
|
|
353
353
|
handle.addListener("change", this._handleChange);
|
|
354
354
|
}
|
|
355
355
|
update(update2) {
|
|
356
356
|
if (update2.transactions.length > 0 && update2.transactions.some((tr) => !isReconcileTx(tr))) {
|
|
357
357
|
queueMicrotask(() => {
|
|
358
|
-
this._view.state.facet(semaphoreFacet).reconcile(
|
|
358
|
+
this._view.state.facet(semaphoreFacet).reconcile(this._view);
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
}
|
|
@@ -595,7 +595,7 @@ var styles = EditorView.baseTheme({
|
|
|
595
595
|
zIndex: 101,
|
|
596
596
|
transition: "opacity .3s ease-in-out",
|
|
597
597
|
backgroundColor: "inherit",
|
|
598
|
-
//
|
|
598
|
+
// These should be separate.
|
|
599
599
|
opacity: 0,
|
|
600
600
|
transitionDelay: "0s",
|
|
601
601
|
whiteSpace: "nowrap"
|
|
@@ -1059,20 +1059,18 @@ var getLineRange = (lines, from, to) => {
|
|
|
1059
1059
|
];
|
|
1060
1060
|
};
|
|
1061
1061
|
var code2 = () => {
|
|
1062
|
-
const
|
|
1062
|
+
const buildDecorations4 = (view) => {
|
|
1063
1063
|
const decorations = [];
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
}).range(block.from));
|
|
1075
|
-
}
|
|
1064
|
+
const text = view.state.doc.sliceString(0);
|
|
1065
|
+
const matches = text.matchAll(CODE_REGEX);
|
|
1066
|
+
const blocks = view.viewportLineBlocks;
|
|
1067
|
+
for (const match of matches) {
|
|
1068
|
+
const range = getLineRange(blocks, match.index, match.index + match[0].length);
|
|
1069
|
+
for (let i = range[0]; i <= range[1]; i++) {
|
|
1070
|
+
const block = blocks[i];
|
|
1071
|
+
decorations.push(Decoration2.line({
|
|
1072
|
+
class: mx2("cm-codeblock", i === range[0] && "cm-codeblock-first", i === range[1] && "cm-codeblock-last")
|
|
1073
|
+
}).range(block.from));
|
|
1076
1074
|
}
|
|
1077
1075
|
}
|
|
1078
1076
|
return Decoration2.set(decorations);
|
|
@@ -1081,7 +1079,7 @@ var code2 = () => {
|
|
|
1081
1079
|
ViewPlugin3.fromClass(class {
|
|
1082
1080
|
constructor(view) {
|
|
1083
1081
|
this.hasFocus = false;
|
|
1084
|
-
this.decorations =
|
|
1082
|
+
this.decorations = buildDecorations4(view);
|
|
1085
1083
|
}
|
|
1086
1084
|
update(update2) {
|
|
1087
1085
|
if (
|
|
@@ -1089,7 +1087,7 @@ var code2 = () => {
|
|
|
1089
1087
|
this.hasFocus !== update2.view.hasFocus || update2.startState.readOnly !== update2.view.state.readOnly || update2.docChanged || update2.viewportChanged
|
|
1090
1088
|
) {
|
|
1091
1089
|
this.hasFocus = update2.view.hasFocus;
|
|
1092
|
-
this.decorations =
|
|
1090
|
+
this.decorations = buildDecorations4(update2.view);
|
|
1093
1091
|
}
|
|
1094
1092
|
}
|
|
1095
1093
|
}, {
|
|
@@ -1105,7 +1103,6 @@ import { hoverTooltip, keymap as keymap3, Decoration as Decoration3, EditorView
|
|
|
1105
1103
|
import sortBy from "lodash.sortby";
|
|
1106
1104
|
import { debounce } from "@dxos/async";
|
|
1107
1105
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1108
|
-
import { log as log2 } from "@dxos/log";
|
|
1109
1106
|
import { nonNullable } from "@dxos/util";
|
|
1110
1107
|
|
|
1111
1108
|
// packages/ui/react-ui-editor/src/util.ts
|
|
@@ -1214,51 +1211,56 @@ var highlightDecorations = EditorView5.decorations.compute([
|
|
|
1214
1211
|
}).filter(nonNullable) ?? [];
|
|
1215
1212
|
return Decoration3.set(decorations);
|
|
1216
1213
|
});
|
|
1217
|
-
var trackPastedComments = (
|
|
1214
|
+
var trackPastedComments = (onUpdate) => {
|
|
1218
1215
|
let tracked = null;
|
|
1219
|
-
const
|
|
1216
|
+
const handleTrack = (event, view) => {
|
|
1220
1217
|
const comments2 = view.state.field(commentsStateField);
|
|
1221
1218
|
const { main } = view.state.selection;
|
|
1222
|
-
const
|
|
1223
|
-
if (!
|
|
1219
|
+
const selectedRanges = comments2.ranges.filter((range) => range.from >= main.from && range.to <= main.to && range.from < range.to);
|
|
1220
|
+
if (!selectedRanges.length) {
|
|
1224
1221
|
tracked = null;
|
|
1225
1222
|
} else {
|
|
1226
1223
|
tracked = {
|
|
1227
1224
|
text: view.state.doc.slice(main.from, main.to),
|
|
1228
|
-
comments:
|
|
1225
|
+
comments: selectedRanges.map((range) => ({
|
|
1226
|
+
id: range.id,
|
|
1229
1227
|
from: range.from - main.from,
|
|
1230
|
-
to: range.to - main.from
|
|
1231
|
-
id: range.id
|
|
1228
|
+
to: range.to - main.from
|
|
1232
1229
|
}))
|
|
1233
1230
|
};
|
|
1234
1231
|
}
|
|
1235
1232
|
};
|
|
1236
1233
|
return [
|
|
1237
1234
|
EditorView5.domEventHandlers({
|
|
1238
|
-
cut:
|
|
1239
|
-
copy:
|
|
1235
|
+
cut: handleTrack,
|
|
1236
|
+
copy: handleTrack
|
|
1240
1237
|
}),
|
|
1241
|
-
|
|
1238
|
+
// Handle paste.
|
|
1239
|
+
EditorView5.updateListener.of(({ view, state, transactions }) => {
|
|
1242
1240
|
if (tracked) {
|
|
1243
|
-
const paste =
|
|
1241
|
+
const paste = transactions.find((tr) => tr.isUserEvent("input.paste"));
|
|
1244
1242
|
if (paste) {
|
|
1245
1243
|
let found = -1;
|
|
1246
1244
|
paste.changes.iterChanges((fromA, toA, fromB, toB, text) => {
|
|
1247
1245
|
if (text.eq(tracked.text)) {
|
|
1248
|
-
for (let i =
|
|
1249
|
-
fromB =
|
|
1246
|
+
for (let i = transactions.indexOf(paste) + 1; i < transactions.length; i++) {
|
|
1247
|
+
fromB = transactions[i].changes.mapPos(fromB);
|
|
1250
1248
|
}
|
|
1251
1249
|
found = fromB;
|
|
1252
1250
|
}
|
|
1253
1251
|
});
|
|
1254
1252
|
if (found > -1) {
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1253
|
+
const comments2 = tracked.comments;
|
|
1254
|
+
view.state.facet(semaphoreFacet).reconcile(view);
|
|
1255
|
+
const active = state.field(commentsStateField).ranges;
|
|
1256
|
+
for (const moved of comments2) {
|
|
1257
1257
|
if (active.some((range) => range.id === moved.id && range.from === range.to)) {
|
|
1258
|
-
|
|
1258
|
+
const range = {
|
|
1259
1259
|
from: found + moved.from,
|
|
1260
1260
|
to: found + moved.to
|
|
1261
|
-
}
|
|
1261
|
+
};
|
|
1262
|
+
const cursor = Cursor.getCursorFromRange(state.facet(Cursor.converter), range);
|
|
1263
|
+
onUpdate(moved.id, cursor);
|
|
1262
1264
|
}
|
|
1263
1265
|
}
|
|
1264
1266
|
}
|
|
@@ -1275,14 +1277,14 @@ var comments = (options = {}) => {
|
|
|
1275
1277
|
const cursorConverter3 = view.state.facet(Cursor.converter);
|
|
1276
1278
|
invariant2(options.onCreate, void 0, {
|
|
1277
1279
|
F: __dxlog_file3,
|
|
1278
|
-
L:
|
|
1280
|
+
L: 264,
|
|
1279
1281
|
S: void 0,
|
|
1280
1282
|
A: [
|
|
1281
1283
|
"options.onCreate",
|
|
1282
1284
|
""
|
|
1283
1285
|
]
|
|
1284
1286
|
});
|
|
1285
|
-
const {
|
|
1287
|
+
const { from, to } = view.state.selection.main;
|
|
1286
1288
|
if (from === to) {
|
|
1287
1289
|
return false;
|
|
1288
1290
|
}
|
|
@@ -1301,18 +1303,6 @@ var comments = (options = {}) => {
|
|
|
1301
1303
|
anchor: from
|
|
1302
1304
|
}
|
|
1303
1305
|
});
|
|
1304
|
-
if (options.footnote) {
|
|
1305
|
-
const tag = `[^${id}]`;
|
|
1306
|
-
view.dispatch({
|
|
1307
|
-
changes: {
|
|
1308
|
-
from: head,
|
|
1309
|
-
insert: tag
|
|
1310
|
-
},
|
|
1311
|
-
selection: {
|
|
1312
|
-
anchor: head + tag.length
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
1306
|
return true;
|
|
1317
1307
|
}
|
|
1318
1308
|
}
|
|
@@ -1344,7 +1334,7 @@ var comments = (options = {}) => {
|
|
|
1344
1334
|
above: true,
|
|
1345
1335
|
create: () => {
|
|
1346
1336
|
const el = document.createElement("div");
|
|
1347
|
-
options.onHover
|
|
1337
|
+
options.onHover(el, shortcut);
|
|
1348
1338
|
return {
|
|
1349
1339
|
dom: el,
|
|
1350
1340
|
offset: {
|
|
@@ -1357,7 +1347,8 @@ var comments = (options = {}) => {
|
|
|
1357
1347
|
}
|
|
1358
1348
|
return null;
|
|
1359
1349
|
}, {
|
|
1360
|
-
|
|
1350
|
+
// TODO(burdon): Hide on change triggered immediately?
|
|
1351
|
+
// hideOnChange: true,
|
|
1361
1352
|
hoverTime: 1e3
|
|
1362
1353
|
}) : [],
|
|
1363
1354
|
//
|
|
@@ -1374,14 +1365,7 @@ var comments = (options = {}) => {
|
|
|
1374
1365
|
if (from2 === to2) {
|
|
1375
1366
|
const newRange = Cursor.getRangeFromCursor(cursorConverter3, range.cursor);
|
|
1376
1367
|
if (!newRange || newRange.to - newRange.from === 0) {
|
|
1377
|
-
|
|
1378
|
-
thread: range.id
|
|
1379
|
-
}, {
|
|
1380
|
-
F: __dxlog_file3,
|
|
1381
|
-
L: 337,
|
|
1382
|
-
S: void 0,
|
|
1383
|
-
C: (f, a) => f(...a)
|
|
1384
|
-
});
|
|
1368
|
+
options.onDelete?.(range.id);
|
|
1385
1369
|
}
|
|
1386
1370
|
}
|
|
1387
1371
|
if (from <= range.to) {
|
|
@@ -1432,7 +1416,7 @@ var comments = (options = {}) => {
|
|
|
1432
1416
|
}
|
|
1433
1417
|
}
|
|
1434
1418
|
}),
|
|
1435
|
-
options.
|
|
1419
|
+
options.onUpdate ? trackPastedComments(options.onUpdate) : []
|
|
1436
1420
|
];
|
|
1437
1421
|
};
|
|
1438
1422
|
|
|
@@ -1460,7 +1444,8 @@ var HorizontalRuleWidget = class extends WidgetType2 {
|
|
|
1460
1444
|
}
|
|
1461
1445
|
};
|
|
1462
1446
|
var placeholderMatcher = new MatchDecorator({
|
|
1463
|
-
regexp:
|
|
1447
|
+
// regexp: /(?<=\n\n)---/gs,
|
|
1448
|
+
regexp: /^---$/gs,
|
|
1464
1449
|
decoration: (match, view, pos) => Decoration4.replace({
|
|
1465
1450
|
widget: new HorizontalRuleWidget(pos)
|
|
1466
1451
|
})
|
|
@@ -1475,11 +1460,7 @@ var hr = () => [
|
|
|
1475
1460
|
this.rules = placeholderMatcher.updateDeco(update2, this.rules);
|
|
1476
1461
|
}
|
|
1477
1462
|
}, {
|
|
1478
|
-
decorations: (instance) => instance.rules
|
|
1479
|
-
// TODO(burdon): Is this really atomic (cursor can move into ---).
|
|
1480
|
-
provide: (plugin) => EditorView6.atomicRanges.of((view) => {
|
|
1481
|
-
return view.plugin(plugin)?.rules || Decoration4.none;
|
|
1482
|
-
})
|
|
1463
|
+
decorations: (instance) => instance.rules
|
|
1483
1464
|
})
|
|
1484
1465
|
];
|
|
1485
1466
|
|
|
@@ -1558,7 +1539,7 @@ var ImageWidget = class extends WidgetType3 {
|
|
|
1558
1539
|
// packages/ui/react-ui-editor/src/extensions/link.ts
|
|
1559
1540
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
1560
1541
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
1561
|
-
import {
|
|
1542
|
+
import { hoverTooltip as hoverTooltip2, Decoration as Decoration6, ViewPlugin as ViewPlugin5, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
1562
1543
|
import { tooltipContent } from "@dxos/react-ui-theme";
|
|
1563
1544
|
var link = (options = {}) => {
|
|
1564
1545
|
const extensions = [
|
|
@@ -1981,6 +1962,11 @@ var mention = ({ onSearch }) => {
|
|
|
1981
1962
|
});
|
|
1982
1963
|
};
|
|
1983
1964
|
|
|
1965
|
+
// packages/ui/react-ui-editor/src/extensions/outliner.ts
|
|
1966
|
+
var outliner = (options = {}) => {
|
|
1967
|
+
return [];
|
|
1968
|
+
};
|
|
1969
|
+
|
|
1984
1970
|
// packages/ui/react-ui-editor/src/extensions/table.ts
|
|
1985
1971
|
import { syntaxTree as syntaxTree3 } from "@codemirror/language";
|
|
1986
1972
|
import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField4 } from "@codemirror/state";
|
|
@@ -2137,6 +2123,7 @@ var tasklist = (options = {}) => {
|
|
|
2137
2123
|
}
|
|
2138
2124
|
}, {
|
|
2139
2125
|
decorations: (v) => v.decorations,
|
|
2126
|
+
// TODO(burdon): Is this still required?
|
|
2140
2127
|
provide: (plugin) => EditorView11.atomicRanges.of((view) => {
|
|
2141
2128
|
return view.plugin(plugin)?.decorations || Decoration8.none;
|
|
2142
2129
|
})
|
|
@@ -2480,7 +2467,7 @@ var EditorModes = [
|
|
|
2480
2467
|
"default",
|
|
2481
2468
|
"vim"
|
|
2482
2469
|
];
|
|
2483
|
-
var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model,
|
|
2470
|
+
var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, autofocus, readonly, selection, comments: comments2, extensions = [], editorMode, theme, slots = defaultSlots }, forwardedRef) => {
|
|
2484
2471
|
const tabsterDOMAttribute = useFocusableGroup({
|
|
2485
2472
|
tabBehavior: "limited"
|
|
2486
2473
|
});
|
|
@@ -2491,12 +2478,12 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, focus, selection, read
|
|
|
2491
2478
|
view
|
|
2492
2479
|
]);
|
|
2493
2480
|
useEffect(() => {
|
|
2494
|
-
if (
|
|
2495
|
-
view
|
|
2481
|
+
if (autofocus) {
|
|
2482
|
+
view?.focus();
|
|
2496
2483
|
}
|
|
2497
2484
|
}, [
|
|
2498
|
-
|
|
2499
|
-
|
|
2485
|
+
autofocus,
|
|
2486
|
+
view
|
|
2500
2487
|
]);
|
|
2501
2488
|
const { awareness: awareness2, peer } = model;
|
|
2502
2489
|
useEffect(() => {
|
|
@@ -2587,11 +2574,11 @@ var BaseTextEditor = /* @__PURE__ */ forwardRef(({ model, focus, selection, read
|
|
|
2587
2574
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2588
2575
|
key: model.id,
|
|
2589
2576
|
role: "none",
|
|
2590
|
-
ref: rootRef,
|
|
2591
2577
|
tabIndex: 0,
|
|
2592
2578
|
onKeyUp: handleKeyUp,
|
|
2593
2579
|
...slots.root,
|
|
2594
|
-
...editorMode !== "vim" && tabsterDOMAttribute
|
|
2580
|
+
...editorMode !== "vim" && tabsterDOMAttribute,
|
|
2581
|
+
ref: rootRef
|
|
2595
2582
|
});
|
|
2596
2583
|
});
|
|
2597
2584
|
var TextEditor = /* @__PURE__ */ forwardRef(({ readonly, placeholder: placeholder3, extensions = [], theme = textTheme, slots, ...props }, forwardedRef) => {
|
|
@@ -2634,7 +2621,7 @@ var MarkdownEditor = /* @__PURE__ */ forwardRef(({ readonly, placeholder: placeh
|
|
|
2634
2621
|
});
|
|
2635
2622
|
var defaultSlots = {
|
|
2636
2623
|
root: {
|
|
2637
|
-
className: mx3("p-2 overflow-y-auto", inputSurface)
|
|
2624
|
+
className: mx3("w-full p-2 overflow-y-auto", inputSurface)
|
|
2638
2625
|
}
|
|
2639
2626
|
};
|
|
2640
2627
|
var defaultTextSlots = {
|
|
@@ -2653,7 +2640,7 @@ import { isNotNullOrUndefined } from "@dxos/util";
|
|
|
2653
2640
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
2654
2641
|
import { Context as Context2 } from "@dxos/context";
|
|
2655
2642
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2656
|
-
import { log as
|
|
2643
|
+
import { log as log2 } from "@dxos/log";
|
|
2657
2644
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/awareness-provider.ts";
|
|
2658
2645
|
var DEBOUNCE_INTERVAL = 100;
|
|
2659
2646
|
var SpaceAwarenessProvider = class {
|
|
@@ -2692,7 +2679,7 @@ var SpaceAwarenessProvider = class {
|
|
|
2692
2679
|
void this._space.postMessage(this._channel, {
|
|
2693
2680
|
kind: "query"
|
|
2694
2681
|
}).catch((err) => {
|
|
2695
|
-
|
|
2682
|
+
log2.debug("failed to query awareness", {
|
|
2696
2683
|
err
|
|
2697
2684
|
}, {
|
|
2698
2685
|
F: __dxlog_file4,
|
|
@@ -2765,7 +2752,7 @@ import * as encoding from "lib0/encoding";
|
|
|
2765
2752
|
import { Observable } from "lib0/observable";
|
|
2766
2753
|
import * as YP from "y-protocols/awareness";
|
|
2767
2754
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
2768
|
-
import { log as
|
|
2755
|
+
import { log as log3 } from "@dxos/log";
|
|
2769
2756
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/hooks/yjs.ts";
|
|
2770
2757
|
var createYjsModel = ({ identity, space, text }) => {
|
|
2771
2758
|
invariant4(text?.doc && text?.content, void 0, {
|
|
@@ -2828,7 +2815,7 @@ var YAwarenessProvider = class extends Observable {
|
|
|
2828
2815
|
return this._awareness;
|
|
2829
2816
|
}
|
|
2830
2817
|
_handleAwarenessUpdate({ added, updated, removed }, origin) {
|
|
2831
|
-
|
|
2818
|
+
log3("awareness update", {
|
|
2832
2819
|
added,
|
|
2833
2820
|
updated,
|
|
2834
2821
|
removed,
|
|
@@ -2846,7 +2833,7 @@ var YAwarenessProvider = class extends Observable {
|
|
|
2846
2833
|
void this._space.postMessage(this._channel, encoding.toUint8Array(encoderAwareness));
|
|
2847
2834
|
}
|
|
2848
2835
|
_handleSpaceMessage({ payload }) {
|
|
2849
|
-
|
|
2836
|
+
log3("space message", payload, {
|
|
2850
2837
|
F: __dxlog_file5,
|
|
2851
2838
|
L: 109,
|
|
2852
2839
|
S: this,
|
|
@@ -2996,6 +2983,7 @@ export {
|
|
|
2996
2983
|
markdownTheme,
|
|
2997
2984
|
mention,
|
|
2998
2985
|
modelState,
|
|
2986
|
+
outliner,
|
|
2999
2987
|
setCommentRange,
|
|
3000
2988
|
setFocus,
|
|
3001
2989
|
setSelection,
|