@dxos/react-ui-editor 0.3.11-main.42059c4 → 0.3.11-main.4d95695
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 +24 -27
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/code.d.ts.map +1 -1
- 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/tasklist.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/components/TextEditor/TextEditor.tsx +2 -2
- package/src/extensions/automerge/automerge.ts +0 -2
- package/src/extensions/awareness.ts +2 -1
- package/src/extensions/code.ts +15 -17
- package/src/extensions/comments.ts +10 -4
- package/src/extensions/hr.ts +6 -7
- package/src/extensions/link.ts +3 -3
- package/src/extensions/tasklist.ts +1 -0
|
@@ -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
|
}, {
|
|
@@ -1172,7 +1170,7 @@ var commentsStateField = StateField2.define({
|
|
|
1172
1170
|
...effect.value
|
|
1173
1171
|
};
|
|
1174
1172
|
}
|
|
1175
|
-
if (effect.is(setCommentRange)
|
|
1173
|
+
if (effect.is(setCommentRange)) {
|
|
1176
1174
|
const { comments: comments2 } = effect.value;
|
|
1177
1175
|
const ranges = comments2.map((comment) => {
|
|
1178
1176
|
const range = Cursor.getRangeFromCursor(cursorConverter3, comment.cursor);
|
|
@@ -1279,7 +1277,7 @@ var comments = (options = {}) => {
|
|
|
1279
1277
|
const cursorConverter3 = view.state.facet(Cursor.converter);
|
|
1280
1278
|
invariant2(options.onCreate, void 0, {
|
|
1281
1279
|
F: __dxlog_file3,
|
|
1282
|
-
L:
|
|
1280
|
+
L: 264,
|
|
1283
1281
|
S: void 0,
|
|
1284
1282
|
A: [
|
|
1285
1283
|
"options.onCreate",
|
|
@@ -1336,7 +1334,7 @@ var comments = (options = {}) => {
|
|
|
1336
1334
|
above: true,
|
|
1337
1335
|
create: () => {
|
|
1338
1336
|
const el = document.createElement("div");
|
|
1339
|
-
options.onHover
|
|
1337
|
+
options.onHover(el, shortcut);
|
|
1340
1338
|
return {
|
|
1341
1339
|
dom: el,
|
|
1342
1340
|
offset: {
|
|
@@ -1349,7 +1347,8 @@ var comments = (options = {}) => {
|
|
|
1349
1347
|
}
|
|
1350
1348
|
return null;
|
|
1351
1349
|
}, {
|
|
1352
|
-
|
|
1350
|
+
// TODO(burdon): Hide on change triggered immediately?
|
|
1351
|
+
// hideOnChange: true,
|
|
1353
1352
|
hoverTime: 1e3
|
|
1354
1353
|
}) : [],
|
|
1355
1354
|
//
|
|
@@ -1445,7 +1444,8 @@ var HorizontalRuleWidget = class extends WidgetType2 {
|
|
|
1445
1444
|
}
|
|
1446
1445
|
};
|
|
1447
1446
|
var placeholderMatcher = new MatchDecorator({
|
|
1448
|
-
regexp:
|
|
1447
|
+
// regexp: /(?<=\n\n)---/gs,
|
|
1448
|
+
regexp: /^---$/gs,
|
|
1449
1449
|
decoration: (match, view, pos) => Decoration4.replace({
|
|
1450
1450
|
widget: new HorizontalRuleWidget(pos)
|
|
1451
1451
|
})
|
|
@@ -1460,11 +1460,7 @@ var hr = () => [
|
|
|
1460
1460
|
this.rules = placeholderMatcher.updateDeco(update2, this.rules);
|
|
1461
1461
|
}
|
|
1462
1462
|
}, {
|
|
1463
|
-
decorations: (instance) => instance.rules
|
|
1464
|
-
// TODO(burdon): Is this really atomic (cursor can move into ---).
|
|
1465
|
-
provide: (plugin) => EditorView6.atomicRanges.of((view) => {
|
|
1466
|
-
return view.plugin(plugin)?.rules || Decoration4.none;
|
|
1467
|
-
})
|
|
1463
|
+
decorations: (instance) => instance.rules
|
|
1468
1464
|
})
|
|
1469
1465
|
];
|
|
1470
1466
|
|
|
@@ -1543,7 +1539,7 @@ var ImageWidget = class extends WidgetType3 {
|
|
|
1543
1539
|
// packages/ui/react-ui-editor/src/extensions/link.ts
|
|
1544
1540
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
1545
1541
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
1546
|
-
import {
|
|
1542
|
+
import { hoverTooltip as hoverTooltip2, Decoration as Decoration6, ViewPlugin as ViewPlugin5, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
1547
1543
|
import { tooltipContent } from "@dxos/react-ui-theme";
|
|
1548
1544
|
var link = (options = {}) => {
|
|
1549
1545
|
const extensions = [
|
|
@@ -2122,6 +2118,7 @@ var tasklist = (options = {}) => {
|
|
|
2122
2118
|
}
|
|
2123
2119
|
}, {
|
|
2124
2120
|
decorations: (v) => v.decorations,
|
|
2121
|
+
// TODO(burdon): Is this still required?
|
|
2125
2122
|
provide: (plugin) => EditorView11.atomicRanges.of((view) => {
|
|
2126
2123
|
return view.plugin(plugin)?.decorations || Decoration8.none;
|
|
2127
2124
|
})
|