@dxos/react-ui-editor 0.6.9 → 0.6.10-main.bbdfaa4
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 +36 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/InputMode.stories.d.ts +1 -1
- package/dist/types/src/InputMode.stories.d.ts.map +1 -1
- package/dist/types/src/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/styles/tokens.d.ts +1 -2
- package/dist/types/src/styles/tokens.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/InputMode.stories.tsx +1 -1
- package/src/TextEditor.stories.tsx +3 -3
- package/src/extensions/automerge/automerge.stories.tsx +1 -1
- package/src/extensions/factories.ts +4 -4
- package/src/extensions/markdown/bundle.ts +3 -0
- package/src/extensions/markdown/decorate.ts +31 -25
- package/src/extensions/markdown/parser.test.ts +29 -0
- package/src/styles/tokens.ts +3 -5
|
@@ -60,8 +60,7 @@ var theme = {
|
|
|
60
60
|
|
|
61
61
|
// packages/ui/react-ui-editor/src/styles/tokens.ts
|
|
62
62
|
import get from "lodash.get";
|
|
63
|
-
import {
|
|
64
|
-
var tokens = tailwindConfig({}).theme;
|
|
63
|
+
import { tokens } from "@dxos/react-ui-theme";
|
|
65
64
|
var getToken = (path, defaultValue) => {
|
|
66
65
|
const value = get(tokens, path, defaultValue);
|
|
67
66
|
return value?.toString() ?? "";
|
|
@@ -2295,7 +2294,7 @@ var dropFile = (options = {}) => {
|
|
|
2295
2294
|
|
|
2296
2295
|
// packages/ui/react-ui-editor/src/extensions/factories.ts
|
|
2297
2296
|
import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
|
|
2298
|
-
import { defaultKeymap, history, historyKeymap, standardKeymap } from "@codemirror/commands";
|
|
2297
|
+
import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap } from "@codemirror/commands";
|
|
2299
2298
|
import { bracketMatching } from "@codemirror/language";
|
|
2300
2299
|
import { searchKeymap } from "@codemirror/search";
|
|
2301
2300
|
import { EditorState } from "@codemirror/state";
|
|
@@ -2340,7 +2339,9 @@ var createBasicExtensions = (_props) => {
|
|
|
2340
2339
|
props.bracketMatching && bracketMatching(),
|
|
2341
2340
|
props.closeBrackets && closeBrackets(),
|
|
2342
2341
|
props.dropCursor && dropCursor2(),
|
|
2343
|
-
props.drawSelection && drawSelection(
|
|
2342
|
+
props.drawSelection && drawSelection({
|
|
2343
|
+
cursorBlinkRate: 1200
|
|
2344
|
+
}),
|
|
2344
2345
|
props.highlightActiveLine && highlightActiveLine(),
|
|
2345
2346
|
props.history && history(),
|
|
2346
2347
|
props.lineNumbers && lineNumbers(),
|
|
@@ -2355,9 +2356,11 @@ var createBasicExtensions = (_props) => {
|
|
|
2355
2356
|
// https://codemirror.net/docs/ref/#view.KeyBinding
|
|
2356
2357
|
keymap5.of([
|
|
2357
2358
|
...(props.keymap && keymaps[props.keymap]) ?? [],
|
|
2358
|
-
// NOTE:
|
|
2359
|
+
// NOTE: Tabs are also configured by markdown extension.
|
|
2359
2360
|
// https://codemirror.net/docs/ref/#commands.indentWithTab
|
|
2360
|
-
|
|
2361
|
+
...props.indentWithTab ? [
|
|
2362
|
+
indentWithTab
|
|
2363
|
+
] : [],
|
|
2361
2364
|
// https://codemirror.net/docs/ref/#autocomplete.closeBracketsKeymap
|
|
2362
2365
|
...props.closeBrackets ? closeBracketsKeymap : [],
|
|
2363
2366
|
// https://codemirror.net/docs/ref/#commands.historyKeymap
|
|
@@ -2443,7 +2446,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
|
2443
2446
|
|
|
2444
2447
|
// packages/ui/react-ui-editor/src/extensions/markdown/formatting.ts
|
|
2445
2448
|
import { snippet } from "@codemirror/autocomplete";
|
|
2446
|
-
import { indentWithTab } from "@codemirror/commands";
|
|
2449
|
+
import { indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
|
2447
2450
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
2448
2451
|
import { EditorSelection } from "@codemirror/state";
|
|
2449
2452
|
import { EditorView as EditorView11, keymap as keymap6 } from "@codemirror/view";
|
|
@@ -3604,7 +3607,7 @@ var processAction = (view, action) => {
|
|
|
3604
3607
|
|
|
3605
3608
|
// packages/ui/react-ui-editor/src/extensions/markdown/bundle.ts
|
|
3606
3609
|
import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
|
|
3607
|
-
import { defaultKeymap as defaultKeymap2, indentWithTab as
|
|
3610
|
+
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab3 } from "@codemirror/commands";
|
|
3608
3611
|
import { markdownLanguage as markdownLanguage3, markdown } from "@codemirror/lang-markdown";
|
|
3609
3612
|
import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
3610
3613
|
import { languages } from "@codemirror/language-data";
|
|
@@ -3812,6 +3815,8 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
|
|
|
3812
3815
|
base: markdownLanguage3,
|
|
3813
3816
|
// Languages for syntax highlighting fenced code blocks.
|
|
3814
3817
|
codeLanguages: languages,
|
|
3818
|
+
// Don't complete HTML tags.
|
|
3819
|
+
completeHTMLTags: false,
|
|
3815
3820
|
// Parser extensions.
|
|
3816
3821
|
extensions: [
|
|
3817
3822
|
// GFM provided by default.
|
|
@@ -3825,7 +3830,7 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
|
|
|
3825
3830
|
keymap7.of([
|
|
3826
3831
|
// TODO(burdon): Indent by 4 if in task list.
|
|
3827
3832
|
// https://codemirror.net/docs/ref/#commands.indentWithTab
|
|
3828
|
-
|
|
3833
|
+
indentWithTab3,
|
|
3829
3834
|
// https://codemirror.net/docs/ref/#commands.defaultKeymap
|
|
3830
3835
|
...defaultKeymap2,
|
|
3831
3836
|
...completionKeymap2,
|
|
@@ -4235,7 +4240,7 @@ var autoHideTags = /* @__PURE__ */ new Set([
|
|
|
4235
4240
|
"SuperscriptMark"
|
|
4236
4241
|
]);
|
|
4237
4242
|
var bulletListIndentationWidth = 24;
|
|
4238
|
-
var orderedListIndentationWidth =
|
|
4243
|
+
var orderedListIndentationWidth = 36;
|
|
4239
4244
|
var buildDecorations2 = (view, options, focus) => {
|
|
4240
4245
|
const deco = new RangeSetBuilder3();
|
|
4241
4246
|
const atomicDeco = new RangeSetBuilder3();
|
|
@@ -4336,31 +4341,36 @@ var buildDecorations2 = (view, options, focus) => {
|
|
|
4336
4341
|
const list = getCurrentList();
|
|
4337
4342
|
const width = list.type === "OrderedList" ? orderedListIndentationWidth : bulletListIndentationWidth;
|
|
4338
4343
|
const offset = ((list.level ?? 0) + 1) * width;
|
|
4339
|
-
const
|
|
4340
|
-
|
|
4344
|
+
const line = state2.doc.lineAt(node.from);
|
|
4345
|
+
if (node.from === line.to - 1) {
|
|
4346
|
+
return false;
|
|
4347
|
+
}
|
|
4348
|
+
deco.add(line.from, line.from, Decoration7.line({
|
|
4341
4349
|
class: "cm-list-item",
|
|
4342
4350
|
attributes: {
|
|
4343
|
-
|
|
4344
|
-
// Note: This makes the cursor appear to be left of the margin.
|
|
4345
|
-
style: `padding-left: ${offset}px; text-indent: calc(-${width}px - 0.25em);`
|
|
4351
|
+
style: `padding-left: ${offset}px; text-indent: -${width}px;`
|
|
4346
4352
|
}
|
|
4347
4353
|
}));
|
|
4348
|
-
const
|
|
4349
|
-
const whitespace =
|
|
4354
|
+
const text = state2.doc.sliceString(line.from, node.to);
|
|
4355
|
+
const whitespace = text.match(/^ */)?.[0].length ?? 0;
|
|
4350
4356
|
if (whitespace) {
|
|
4351
|
-
atomicDeco.add(
|
|
4357
|
+
atomicDeco.add(line.from, line.from + whitespace, hide);
|
|
4352
4358
|
}
|
|
4353
4359
|
break;
|
|
4354
4360
|
}
|
|
4355
4361
|
case "ListMark": {
|
|
4356
|
-
const
|
|
4357
|
-
if (
|
|
4358
|
-
atomicDeco.add(node.from, node.to, hide);
|
|
4362
|
+
const next = tree.resolve(node.to + 1, 1);
|
|
4363
|
+
if (next?.name === "TaskMarker") {
|
|
4364
|
+
atomicDeco.add(node.from, node.to + 1, hide);
|
|
4359
4365
|
break;
|
|
4360
4366
|
}
|
|
4361
4367
|
const list = getCurrentList();
|
|
4362
|
-
const
|
|
4363
|
-
|
|
4368
|
+
const text = state2.doc.sliceString(node.from, node.to + 1);
|
|
4369
|
+
if (list.type === "BulletList" && text[1] !== " ") {
|
|
4370
|
+
return false;
|
|
4371
|
+
}
|
|
4372
|
+
const label = list.type === "OrderedList" ? `${++list.number}.` : "\u2022";
|
|
4373
|
+
atomicDeco.add(node.from, node.to + 1, Decoration7.replace({
|
|
4364
4374
|
widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
|
|
4365
4375
|
}));
|
|
4366
4376
|
break;
|
|
@@ -4368,10 +4378,7 @@ var buildDecorations2 = (view, options, focus) => {
|
|
|
4368
4378
|
case "TaskMarker": {
|
|
4369
4379
|
if (!editingRange(state2, node, focus)) {
|
|
4370
4380
|
const checked = state2.doc.sliceString(node.from + 1, node.to - 1) === "x";
|
|
4371
|
-
atomicDeco.add(node.from
|
|
4372
|
-
class: "cm-task-checkbox"
|
|
4373
|
-
}));
|
|
4374
|
-
atomicDeco.add(node.from, node.to, checked ? checkedTask : uncheckedTask);
|
|
4381
|
+
atomicDeco.add(node.from, node.to + 1, checked ? checkedTask : uncheckedTask);
|
|
4375
4382
|
}
|
|
4376
4383
|
break;
|
|
4377
4384
|
}
|
|
@@ -4570,7 +4577,7 @@ var formattingStyles = EditorView14.baseTheme({
|
|
|
4570
4577
|
},
|
|
4571
4578
|
"& .cm-task": {
|
|
4572
4579
|
display: "inline-block",
|
|
4573
|
-
width:
|
|
4580
|
+
width: `${bulletListIndentationWidth}px`,
|
|
4574
4581
|
color: getToken("extend.colors.blue.500")
|
|
4575
4582
|
},
|
|
4576
4583
|
"& .cm-task-checkbox": {
|
|
@@ -4582,6 +4589,7 @@ var formattingStyles = EditorView14.baseTheme({
|
|
|
4582
4589
|
"& .cm-list-mark": {
|
|
4583
4590
|
display: "inline-block",
|
|
4584
4591
|
textAlign: "right",
|
|
4592
|
+
paddingRight: "0.5em",
|
|
4585
4593
|
fontVariant: "tabular-nums"
|
|
4586
4594
|
},
|
|
4587
4595
|
"& .cm-list-mark-bullet": {
|