@dxos/react-ui-editor 0.8.2 → 0.8.3-main.672df60
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 +159 -105
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +172 -119
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +159 -105
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/extensions/command/menu.d.ts.map +1 -1
- package/dist/types/src/extensions/hashtag.d.ts +3 -0
- package/dist/types/src/extensions/hashtag.d.ts.map +1 -0
- 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/json.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/debug.d.ts +2 -2
- package/dist/types/src/extensions/markdown/debug.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts +1 -3
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts +1 -1
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +43 -0
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +3 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/{util.d.ts → components/util.d.ts} +3 -18
- package/dist/types/src/stories/components/util.d.ts.map +1 -0
- package/package.json +28 -27
- package/src/extensions/command/menu.ts +31 -22
- package/src/extensions/hashtag.tsx +68 -0
- package/src/extensions/index.ts +1 -0
- package/src/extensions/json.ts +2 -1
- package/src/extensions/markdown/debug.ts +2 -2
- package/src/extensions/outliner/outliner.ts +9 -8
- package/src/stories/Command.stories.tsx +1 -1
- package/src/stories/Comments.stories.tsx +2 -2
- package/src/stories/Experimental.stories.tsx +2 -2
- package/src/stories/Markdown.stories.tsx +2 -2
- package/src/stories/Outliner.stories.tsx +19 -7
- package/src/stories/Preview.stories.tsx +2 -2
- package/src/stories/TextEditor.stories.tsx +3 -3
- package/src/stories/components/EditorStory.tsx +135 -0
- package/src/stories/components/index.ts +6 -0
- package/src/stories/{util.tsx → components/util.tsx} +5 -100
- package/dist/types/src/stories/util.d.ts.map +0 -1
@@ -37,7 +37,7 @@ var translations_default = [
|
|
37
37
|
|
38
38
|
// packages/ui/react-ui-editor/src/index.ts
|
39
39
|
import { EditorState as EditorState4 } from "@codemirror/state";
|
40
|
-
import { EditorView as
|
40
|
+
import { EditorView as EditorView25, keymap as keymap13 } from "@codemirror/view";
|
41
41
|
import { tags as tags2 } from "@lezer/highlight";
|
42
42
|
import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
43
43
|
|
@@ -1461,26 +1461,36 @@ var command = (options = {}) => {
|
|
1461
1461
|
|
1462
1462
|
// packages/ui/react-ui-editor/src/extensions/command/menu.ts
|
1463
1463
|
import { EditorView as EditorView7, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
1464
|
+
import { addEventListener } from "@dxos/async";
|
1464
1465
|
var floatingMenu = (options = {}) => [
|
1465
1466
|
ViewPlugin5.fromClass(class {
|
1466
1467
|
constructor(view) {
|
1467
|
-
this.rafId = null;
|
1468
1468
|
this.view = view;
|
1469
1469
|
const container = view.scrollDOM;
|
1470
1470
|
if (getComputedStyle(container).position === "static") {
|
1471
1471
|
container.style.position = "relative";
|
1472
1472
|
}
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1473
|
+
{
|
1474
|
+
const icon = document.createElement("dx-icon");
|
1475
|
+
icon.setAttribute("icon", options.icon ?? "ph--dots-three-vertical--regular");
|
1476
|
+
const button = document.createElement("button");
|
1477
|
+
button.appendChild(icon);
|
1478
|
+
this.tag = document.createElement("dx-ref-tag");
|
1479
|
+
this.tag.classList.add("cm-ref-tag");
|
1480
|
+
this.tag.appendChild(button);
|
1481
|
+
}
|
1480
1482
|
container.appendChild(this.tag);
|
1481
|
-
|
1483
|
+
const handler = () => this.scheduleUpdate();
|
1484
|
+
this.cleanup = addEventListener(container, "scroll", handler);
|
1482
1485
|
this.scheduleUpdate();
|
1483
1486
|
}
|
1487
|
+
destroy() {
|
1488
|
+
this.cleanup?.();
|
1489
|
+
this.tag.remove();
|
1490
|
+
if (this.rafId != null) {
|
1491
|
+
cancelAnimationFrame(this.rafId);
|
1492
|
+
}
|
1493
|
+
}
|
1484
1494
|
update(update2) {
|
1485
1495
|
this.tag.dataset.focused = update2.view.hasFocus ? "true" : "false";
|
1486
1496
|
if (!update2.view.hasFocus) {
|
@@ -1517,20 +1527,19 @@ var floatingMenu = (options = {}) => [
|
|
1517
1527
|
}
|
1518
1528
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
1519
1529
|
}
|
1520
|
-
destroy() {
|
1521
|
-
this.tag.remove();
|
1522
|
-
if (this.rafId != null) {
|
1523
|
-
cancelAnimationFrame(this.rafId);
|
1524
|
-
}
|
1525
|
-
}
|
1526
1530
|
}),
|
1527
1531
|
EditorView7.theme({
|
1528
1532
|
".cm-ref-tag": {
|
1529
1533
|
position: "fixed",
|
1530
1534
|
padding: "0",
|
1531
1535
|
border: "none",
|
1532
|
-
|
1533
|
-
|
1536
|
+
opacity: "0"
|
1537
|
+
},
|
1538
|
+
"[data-has-focus] & .cm-ref-tag": {
|
1539
|
+
opacity: "1"
|
1540
|
+
},
|
1541
|
+
"[data-is-attention-source] & .cm-ref-tag": {
|
1542
|
+
opacity: "1"
|
1534
1543
|
},
|
1535
1544
|
".cm-ref-tag button": {
|
1536
1545
|
display: "grid",
|
@@ -1538,9 +1547,6 @@ var floatingMenu = (options = {}) => [
|
|
1538
1547
|
justifyContent: "center",
|
1539
1548
|
width: "2rem",
|
1540
1549
|
height: "2rem"
|
1541
|
-
},
|
1542
|
-
'.cm-ref-tag[data-focused="true"]': {
|
1543
|
-
opacity: 1
|
1544
1550
|
}
|
1545
1551
|
})
|
1546
1552
|
];
|
@@ -2649,6 +2655,49 @@ var folding = (_props = {}) => [
|
|
2649
2655
|
})
|
2650
2656
|
];
|
2651
2657
|
|
2658
|
+
// packages/ui/react-ui-editor/src/extensions/hashtag.tsx
|
2659
|
+
import { Decoration as Decoration6, EditorView as EditorView14, MatchDecorator, ViewPlugin as ViewPlugin9, WidgetType as WidgetType3 } from "@codemirror/view";
|
2660
|
+
import { getHashColor, mx as mx2 } from "@dxos/react-ui-theme";
|
2661
|
+
var TagWidget = class extends WidgetType3 {
|
2662
|
+
constructor(_text) {
|
2663
|
+
super(), this._text = _text;
|
2664
|
+
}
|
2665
|
+
toDOM() {
|
2666
|
+
const span = document.createElement("span");
|
2667
|
+
span.className = mx2("cm-tag", getHashColor(this._text).tag);
|
2668
|
+
span.textContent = this._text;
|
2669
|
+
return span;
|
2670
|
+
}
|
2671
|
+
};
|
2672
|
+
var tagMatcher = new MatchDecorator({
|
2673
|
+
regexp: /#(\w+)\W/g,
|
2674
|
+
decoration: (match) => Decoration6.replace({
|
2675
|
+
widget: new TagWidget(match[1])
|
2676
|
+
})
|
2677
|
+
});
|
2678
|
+
var hashtag = () => [
|
2679
|
+
ViewPlugin9.fromClass(class {
|
2680
|
+
constructor(view) {
|
2681
|
+
this.tags = tagMatcher.createDeco(view);
|
2682
|
+
}
|
2683
|
+
update(update2) {
|
2684
|
+
this.tags = tagMatcher.updateDeco(update2, this.tags);
|
2685
|
+
}
|
2686
|
+
}, {
|
2687
|
+
decorations: (instance) => instance.tags,
|
2688
|
+
provide: (plugin) => EditorView14.atomicRanges.of((view) => {
|
2689
|
+
return view.plugin(plugin)?.tags || Decoration6.none;
|
2690
|
+
})
|
2691
|
+
}),
|
2692
|
+
EditorView14.theme({
|
2693
|
+
".cm-tag": {
|
2694
|
+
borderRadius: "4px",
|
2695
|
+
marginRight: "6px",
|
2696
|
+
padding: "2px 6px"
|
2697
|
+
}
|
2698
|
+
})
|
2699
|
+
];
|
2700
|
+
|
2652
2701
|
// packages/ui/react-ui-editor/src/extensions/json.ts
|
2653
2702
|
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
2654
2703
|
import { linter } from "@codemirror/lint";
|
@@ -2657,7 +2706,8 @@ var createJsonExtensions = ({ schema } = {}) => {
|
|
2657
2706
|
let lintSource = jsonParseLinter();
|
2658
2707
|
if (schema) {
|
2659
2708
|
const ajv = new Ajv({
|
2660
|
-
allErrors: false
|
2709
|
+
allErrors: false,
|
2710
|
+
strict: false
|
2661
2711
|
});
|
2662
2712
|
const validate = ajv.compile(schema);
|
2663
2713
|
lintSource = schemaLinter(validate);
|
@@ -2694,14 +2744,14 @@ var schemaLinter = (validate) => (view) => {
|
|
2694
2744
|
};
|
2695
2745
|
|
2696
2746
|
// packages/ui/react-ui-editor/src/extensions/listener.ts
|
2697
|
-
import { EditorView as
|
2747
|
+
import { EditorView as EditorView15 } from "@codemirror/view";
|
2698
2748
|
var listener = ({ onFocus, onChange }) => {
|
2699
2749
|
const extensions = [];
|
2700
|
-
onFocus && extensions.push(
|
2750
|
+
onFocus && extensions.push(EditorView15.focusChangeEffect.of((_, focusing) => {
|
2701
2751
|
onFocus(focusing);
|
2702
2752
|
return null;
|
2703
2753
|
}));
|
2704
|
-
onChange && extensions.push(
|
2754
|
+
onChange && extensions.push(EditorView15.updateListener.of((update2) => {
|
2705
2755
|
onChange(update2.state.doc.toString(), update2.state.facet(documentId));
|
2706
2756
|
}));
|
2707
2757
|
return extensions;
|
@@ -2711,7 +2761,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
2711
2761
|
import { snippet } from "@codemirror/autocomplete";
|
2712
2762
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
2713
2763
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
2714
|
-
import { EditorView as
|
2764
|
+
import { EditorView as EditorView16, keymap as keymap8 } from "@codemirror/view";
|
2715
2765
|
import { useMemo as useMemo2 } from "react";
|
2716
2766
|
var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
|
2717
2767
|
var Inline = /* @__PURE__ */ function(Inline2) {
|
@@ -3800,7 +3850,7 @@ var getFormatting = (state) => {
|
|
3800
3850
|
};
|
3801
3851
|
};
|
3802
3852
|
var useFormattingState = (state) => {
|
3803
|
-
return useMemo2(() =>
|
3853
|
+
return useMemo2(() => EditorView16.updateListener.of((update2) => {
|
3804
3854
|
if (update2.docChanged || update2.selectionSet) {
|
3805
3855
|
Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
|
3806
3856
|
state[key] = active;
|
@@ -4113,16 +4163,16 @@ var convertTreeToJson = (state) => {
|
|
4113
4163
|
// packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
|
4114
4164
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
4115
4165
|
import { RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect5 } from "@codemirror/state";
|
4116
|
-
import { EditorView as
|
4166
|
+
import { EditorView as EditorView20, Decoration as Decoration9, WidgetType as WidgetType6, ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
4117
4167
|
import { invariant as invariant4 } from "@dxos/invariant";
|
4118
|
-
import { mx as
|
4168
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
4119
4169
|
|
4120
4170
|
// packages/ui/react-ui-editor/src/extensions/markdown/changes.ts
|
4121
4171
|
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
4122
4172
|
import { Transaction as Transaction2 } from "@codemirror/state";
|
4123
|
-
import { ViewPlugin as
|
4173
|
+
import { ViewPlugin as ViewPlugin10 } from "@codemirror/view";
|
4124
4174
|
var adjustChanges = () => {
|
4125
|
-
return
|
4175
|
+
return ViewPlugin10.fromClass(class {
|
4126
4176
|
update(update2) {
|
4127
4177
|
const tree = syntaxTree4(update2.state);
|
4128
4178
|
const adjustments = [];
|
@@ -4264,12 +4314,12 @@ var getValidUrl = (str) => {
|
|
4264
4314
|
// packages/ui/react-ui-editor/src/extensions/markdown/image.ts
|
4265
4315
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
4266
4316
|
import { StateField as StateField7 } from "@codemirror/state";
|
4267
|
-
import { Decoration as
|
4317
|
+
import { Decoration as Decoration7, EditorView as EditorView17, WidgetType as WidgetType4 } from "@codemirror/view";
|
4268
4318
|
var image = (_options = {}) => {
|
4269
4319
|
return [
|
4270
4320
|
StateField7.define({
|
4271
4321
|
create: (state) => {
|
4272
|
-
return
|
4322
|
+
return Decoration7.set(buildDecorations(0, state.doc.length, state));
|
4273
4323
|
},
|
4274
4324
|
update: (value, tr) => {
|
4275
4325
|
if (!tr.docChanged && !tr.selection) {
|
@@ -4292,7 +4342,7 @@ var image = (_options = {}) => {
|
|
4292
4342
|
add: buildDecorations(from, to, tr.state)
|
4293
4343
|
});
|
4294
4344
|
},
|
4295
|
-
provide: (field) =>
|
4345
|
+
provide: (field) => EditorView17.decorations.from(field)
|
4296
4346
|
})
|
4297
4347
|
];
|
4298
4348
|
};
|
@@ -4310,7 +4360,7 @@ var buildDecorations = (from, to, state) => {
|
|
4310
4360
|
return;
|
4311
4361
|
}
|
4312
4362
|
preloadImage(url);
|
4313
|
-
decorations2.push(
|
4363
|
+
decorations2.push(Decoration7.replace({
|
4314
4364
|
block: true,
|
4315
4365
|
widget: new ImageWidget(url)
|
4316
4366
|
}).range(hide2 ? node.from : node.to, node.to));
|
@@ -4330,7 +4380,7 @@ var preloadImage = (url) => {
|
|
4330
4380
|
preloaded.add(url);
|
4331
4381
|
}
|
4332
4382
|
};
|
4333
|
-
var ImageWidget = class extends
|
4383
|
+
var ImageWidget = class extends WidgetType4 {
|
4334
4384
|
constructor(_url) {
|
4335
4385
|
super(), this._url = _url;
|
4336
4386
|
}
|
@@ -4351,10 +4401,10 @@ var ImageWidget = class extends WidgetType3 {
|
|
4351
4401
|
};
|
4352
4402
|
|
4353
4403
|
// packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
|
4354
|
-
import { EditorView as
|
4404
|
+
import { EditorView as EditorView18 } from "@codemirror/view";
|
4355
4405
|
var bulletListIndentationWidth = 24;
|
4356
4406
|
var orderedListIndentationWidth = 36;
|
4357
|
-
var formattingStyles =
|
4407
|
+
var formattingStyles = EditorView18.theme({
|
4358
4408
|
/**
|
4359
4409
|
* Horizontal rule.
|
4360
4410
|
*/
|
@@ -4476,12 +4526,12 @@ var formattingStyles = EditorView17.theme({
|
|
4476
4526
|
// packages/ui/react-ui-editor/src/extensions/markdown/table.ts
|
4477
4527
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
4478
4528
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
4479
|
-
import { Decoration as
|
4529
|
+
import { Decoration as Decoration8, EditorView as EditorView19, WidgetType as WidgetType5 } from "@codemirror/view";
|
4480
4530
|
var table = (options = {}) => {
|
4481
4531
|
return StateField8.define({
|
4482
4532
|
create: (state) => update(state, options),
|
4483
4533
|
update: (_, tr) => update(tr.state, options),
|
4484
|
-
provide: (field) =>
|
4534
|
+
provide: (field) => EditorView19.decorations.from(field)
|
4485
4535
|
});
|
4486
4536
|
};
|
4487
4537
|
var update = (state, _options) => {
|
@@ -4526,19 +4576,19 @@ var update = (state, _options) => {
|
|
4526
4576
|
tables.forEach((table2) => {
|
4527
4577
|
const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
|
4528
4578
|
if (replace) {
|
4529
|
-
builder.add(table2.from, table2.to,
|
4579
|
+
builder.add(table2.from, table2.to, Decoration8.replace({
|
4530
4580
|
block: true,
|
4531
4581
|
widget: new TableWidget(table2)
|
4532
4582
|
}));
|
4533
4583
|
} else {
|
4534
|
-
builder.add(table2.from, table2.to,
|
4584
|
+
builder.add(table2.from, table2.to, Decoration8.mark({
|
4535
4585
|
class: "cm-table"
|
4536
4586
|
}));
|
4537
4587
|
}
|
4538
4588
|
});
|
4539
4589
|
return builder.finish();
|
4540
4590
|
};
|
4541
|
-
var TableWidget = class extends
|
4591
|
+
var TableWidget = class extends WidgetType5 {
|
4542
4592
|
constructor(_table) {
|
4543
4593
|
super(), this._table = _table;
|
4544
4594
|
}
|
@@ -4579,14 +4629,14 @@ var Unicode = {
|
|
4579
4629
|
bulletSmall: "\u2219",
|
4580
4630
|
bulletSquare: "\u2B1D"
|
4581
4631
|
};
|
4582
|
-
var HorizontalRuleWidget = class extends
|
4632
|
+
var HorizontalRuleWidget = class extends WidgetType6 {
|
4583
4633
|
toDOM() {
|
4584
4634
|
const el = document.createElement("span");
|
4585
4635
|
el.className = "cm-hr";
|
4586
4636
|
return el;
|
4587
4637
|
}
|
4588
4638
|
};
|
4589
|
-
var LinkButton = class extends
|
4639
|
+
var LinkButton = class extends WidgetType6 {
|
4590
4640
|
constructor(url, render) {
|
4591
4641
|
super(), this.url = url, this.render = render;
|
4592
4642
|
}
|
@@ -4602,7 +4652,7 @@ var LinkButton = class extends WidgetType5 {
|
|
4602
4652
|
return el;
|
4603
4653
|
}
|
4604
4654
|
};
|
4605
|
-
var CheckboxWidget = class extends
|
4655
|
+
var CheckboxWidget = class extends WidgetType6 {
|
4606
4656
|
constructor(_checked) {
|
4607
4657
|
super(), this._checked = _checked;
|
4608
4658
|
}
|
@@ -4646,7 +4696,7 @@ var CheckboxWidget = class extends WidgetType5 {
|
|
4646
4696
|
return false;
|
4647
4697
|
}
|
4648
4698
|
};
|
4649
|
-
var TextWidget = class extends
|
4699
|
+
var TextWidget = class extends WidgetType6 {
|
4650
4700
|
constructor(text, className) {
|
4651
4701
|
super(), this.text = text, this.className = className;
|
4652
4702
|
}
|
@@ -4659,29 +4709,29 @@ var TextWidget = class extends WidgetType5 {
|
|
4659
4709
|
return el;
|
4660
4710
|
}
|
4661
4711
|
};
|
4662
|
-
var hide =
|
4663
|
-
var blockQuote =
|
4712
|
+
var hide = Decoration9.replace({});
|
4713
|
+
var blockQuote = Decoration9.line({
|
4664
4714
|
class: "cm-blockquote"
|
4665
4715
|
});
|
4666
|
-
var fencedCodeLine =
|
4716
|
+
var fencedCodeLine = Decoration9.line({
|
4667
4717
|
class: "cm-code cm-codeblock-line"
|
4668
4718
|
});
|
4669
|
-
var fencedCodeLineFirst =
|
4670
|
-
class:
|
4719
|
+
var fencedCodeLineFirst = Decoration9.line({
|
4720
|
+
class: mx3("cm-code cm-codeblock-line", "cm-codeblock-start")
|
4671
4721
|
});
|
4672
|
-
var fencedCodeLineLast =
|
4673
|
-
class:
|
4722
|
+
var fencedCodeLineLast = Decoration9.line({
|
4723
|
+
class: mx3("cm-code cm-codeblock-line", "cm-codeblock-end")
|
4674
4724
|
});
|
4675
4725
|
var commentBlockLine = fencedCodeLine;
|
4676
4726
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
4677
4727
|
var commentBlockLineLast = fencedCodeLineLast;
|
4678
|
-
var horizontalRule =
|
4728
|
+
var horizontalRule = Decoration9.replace({
|
4679
4729
|
widget: new HorizontalRuleWidget()
|
4680
4730
|
});
|
4681
|
-
var checkedTask =
|
4731
|
+
var checkedTask = Decoration9.replace({
|
4682
4732
|
widget: new CheckboxWidget(true)
|
4683
4733
|
});
|
4684
|
-
var uncheckedTask =
|
4734
|
+
var uncheckedTask = Decoration9.replace({
|
4685
4735
|
widget: new CheckboxWidget(false)
|
4686
4736
|
});
|
4687
4737
|
var editingRange = (state, range, focus2) => {
|
@@ -4785,7 +4835,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4785
4835
|
} else {
|
4786
4836
|
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
4787
4837
|
if (num.length) {
|
4788
|
-
atomicDeco.add(mark.from, mark.from + len,
|
4838
|
+
atomicDeco.add(mark.from, mark.from + len, Decoration9.replace({
|
4789
4839
|
widget: new TextWidget(num, theme.heading(level))
|
4790
4840
|
}));
|
4791
4841
|
}
|
@@ -4810,7 +4860,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4810
4860
|
if (node.from === line.to - 1) {
|
4811
4861
|
return false;
|
4812
4862
|
}
|
4813
|
-
deco.add(line.from, line.from,
|
4863
|
+
deco.add(line.from, line.from, Decoration9.line({
|
4814
4864
|
class: "cm-list-item",
|
4815
4865
|
attributes: {
|
4816
4866
|
style: `padding-left: ${offset}px; text-indent: -${width}px;`
|
@@ -4827,7 +4877,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4827
4877
|
const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
|
4828
4878
|
const line = state.doc.lineAt(node.from);
|
4829
4879
|
const to = state.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
|
4830
|
-
atomicDeco.add(line.from, to,
|
4880
|
+
atomicDeco.add(line.from, to, Decoration9.replace({
|
4831
4881
|
widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
|
4832
4882
|
}));
|
4833
4883
|
break;
|
@@ -4914,7 +4964,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4914
4964
|
if (!editing) {
|
4915
4965
|
atomicDeco.add(node.from, marks[0].to, hide);
|
4916
4966
|
}
|
4917
|
-
deco.add(marks[0].to, marks[1].from,
|
4967
|
+
deco.add(marks[0].to, marks[1].from, Decoration9.mark({
|
4918
4968
|
tagName: "a",
|
4919
4969
|
attributes: {
|
4920
4970
|
class: "cm-link",
|
@@ -4924,7 +4974,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4924
4974
|
}
|
4925
4975
|
}));
|
4926
4976
|
if (!editing) {
|
4927
|
-
atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ?
|
4977
|
+
atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration9.replace({
|
4928
4978
|
widget: new LinkButton(url, options.renderLinkButton)
|
4929
4979
|
}) : hide);
|
4930
4980
|
}
|
@@ -4982,7 +5032,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
4982
5032
|
var forceUpdate = StateEffect5.define();
|
4983
5033
|
var decorateMarkdown = (options = {}) => {
|
4984
5034
|
return [
|
4985
|
-
|
5035
|
+
ViewPlugin11.fromClass(class {
|
4986
5036
|
constructor(view) {
|
4987
5037
|
({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
|
4988
5038
|
}
|
@@ -5014,9 +5064,9 @@ var decorateMarkdown = (options = {}) => {
|
|
5014
5064
|
}
|
5015
5065
|
}, {
|
5016
5066
|
provide: (plugin) => [
|
5017
|
-
|
5018
|
-
|
5019
|
-
|
5067
|
+
EditorView20.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration9.none),
|
5068
|
+
EditorView20.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration9.none),
|
5069
|
+
EditorView20.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration9.none)
|
5020
5070
|
]
|
5021
5071
|
}),
|
5022
5072
|
image(),
|
@@ -5725,17 +5775,17 @@ var commands = () => keymap11.of([
|
|
5725
5775
|
|
5726
5776
|
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5727
5777
|
import { Prec as Prec2 } from "@codemirror/state";
|
5728
|
-
import { Decoration as
|
5729
|
-
import { mx as
|
5778
|
+
import { Decoration as Decoration10, EditorView as EditorView21, ViewPlugin as ViewPlugin13 } from "@codemirror/view";
|
5779
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
5730
5780
|
|
5731
5781
|
// packages/ui/react-ui-editor/src/extensions/outliner/editor.ts
|
5732
5782
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
5733
|
-
import { ViewPlugin as
|
5783
|
+
import { ViewPlugin as ViewPlugin12 } from "@codemirror/view";
|
5734
5784
|
import { log as log7 } from "@dxos/log";
|
5735
5785
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/outliner/editor.ts";
|
5736
5786
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
5737
5787
|
var initialize = () => {
|
5738
|
-
return
|
5788
|
+
return ViewPlugin12.fromClass(class {
|
5739
5789
|
constructor(view) {
|
5740
5790
|
const first = view.state.doc.lineAt(0);
|
5741
5791
|
const text = view.state.sliceDoc(first.from, first.to);
|
@@ -5930,20 +5980,20 @@ var outliner = (options = {}) => [
|
|
5930
5980
|
// Floating menu.
|
5931
5981
|
floatingMenu(),
|
5932
5982
|
// Line decorations.
|
5933
|
-
decorations(
|
5983
|
+
decorations(),
|
5934
5984
|
// Default markdown decorations.
|
5935
5985
|
decorateMarkdown({
|
5936
5986
|
listPaddingLeft: 8
|
5937
5987
|
}),
|
5938
5988
|
// Researve space for menu.
|
5939
|
-
|
5989
|
+
EditorView21.contentAttributes.of({
|
5940
5990
|
class: "is-full !mr-[3rem]"
|
5941
5991
|
})
|
5942
5992
|
];
|
5943
|
-
var decorations = (
|
5944
|
-
|
5993
|
+
var decorations = () => [
|
5994
|
+
ViewPlugin13.fromClass(class {
|
5945
5995
|
constructor(view) {
|
5946
|
-
this.decorations =
|
5996
|
+
this.decorations = Decoration10.none;
|
5947
5997
|
this.updateDecorations(view.state, view);
|
5948
5998
|
}
|
5949
5999
|
update(update2) {
|
@@ -5965,18 +6015,18 @@ var decorations = (options) => [
|
|
5965
6015
|
const lineFrom = doc.lineAt(item.contentRange.from);
|
5966
6016
|
const lineTo = doc.lineAt(item.contentRange.to);
|
5967
6017
|
const isSelected = selection.includes(item.index) || item === current;
|
5968
|
-
decorations2.push(
|
5969
|
-
class:
|
6018
|
+
decorations2.push(Decoration10.line({
|
6019
|
+
class: mx4("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
|
5970
6020
|
}).range(line.from, line.from));
|
5971
6021
|
}
|
5972
6022
|
}
|
5973
|
-
this.decorations =
|
6023
|
+
this.decorations = Decoration10.set(decorations2);
|
5974
6024
|
}
|
5975
6025
|
}, {
|
5976
6026
|
decorations: (v) => v.decorations
|
5977
6027
|
}),
|
5978
6028
|
// Theme.
|
5979
|
-
|
6029
|
+
EditorView21.theme(Object.assign({
|
5980
6030
|
".cm-list-item": {
|
5981
6031
|
borderLeftWidth: "1px",
|
5982
6032
|
borderRightWidth: "1px",
|
@@ -6000,11 +6050,14 @@ var decorations = (options) => [
|
|
6000
6050
|
paddingBottom: "4px",
|
6001
6051
|
marginBottom: "2px"
|
6002
6052
|
},
|
6003
|
-
".cm-list-item-selected": {
|
6004
|
-
borderColor: options.showSelected ? "var(--dx-separator)" : void 0
|
6005
|
-
},
|
6006
6053
|
".cm-list-item-focused": {
|
6007
6054
|
borderColor: "var(--dx-accentFocusIndicator)"
|
6055
|
+
},
|
6056
|
+
"[data-has-focus] & .cm-list-item-selected": {
|
6057
|
+
borderColor: "var(--dx-separator)"
|
6058
|
+
},
|
6059
|
+
"[data-is-attention-source] & .cm-list-item-selected": {
|
6060
|
+
borderColor: "var(--dx-separator)"
|
6008
6061
|
}
|
6009
6062
|
}))
|
6010
6063
|
];
|
@@ -6013,7 +6066,7 @@ var decorations = (options) => [
|
|
6013
6066
|
import "@dxos/lit-ui/dx-ref-tag.pcss";
|
6014
6067
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
6015
6068
|
import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField10 } from "@codemirror/state";
|
6016
|
-
import { Decoration as
|
6069
|
+
import { Decoration as Decoration11, EditorView as EditorView22, WidgetType as WidgetType7 } from "@codemirror/view";
|
6017
6070
|
var preview = (options = {}) => {
|
6018
6071
|
return [
|
6019
6072
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
@@ -6022,11 +6075,11 @@ var preview = (options = {}) => {
|
|
6022
6075
|
create: (state) => buildDecorations3(state, options),
|
6023
6076
|
update: (_, tr) => buildDecorations3(tr.state, options),
|
6024
6077
|
provide: (field) => [
|
6025
|
-
|
6026
|
-
|
6078
|
+
EditorView22.decorations.from(field),
|
6079
|
+
EditorView22.atomicRanges.of((view) => view.state.field(field))
|
6027
6080
|
]
|
6028
6081
|
}),
|
6029
|
-
|
6082
|
+
EditorView22.theme({
|
6030
6083
|
".cm-preview-block": {
|
6031
6084
|
marginLeft: "-1rem",
|
6032
6085
|
marginRight: "-1rem",
|
@@ -6063,7 +6116,7 @@ var buildDecorations3 = (state, options) => {
|
|
6063
6116
|
case "Link": {
|
6064
6117
|
const link = getLinkRef(state, node.node);
|
6065
6118
|
if (link) {
|
6066
|
-
builder.add(node.from, node.to,
|
6119
|
+
builder.add(node.from, node.to, Decoration11.replace({
|
6067
6120
|
widget: new PreviewInlineWidget(options, link)
|
6068
6121
|
}));
|
6069
6122
|
}
|
@@ -6076,7 +6129,7 @@ var buildDecorations3 = (state, options) => {
|
|
6076
6129
|
case "Image": {
|
6077
6130
|
const link = getLinkRef(state, node.node);
|
6078
6131
|
if (options.renderBlock && link) {
|
6079
|
-
builder.add(node.from, node.to,
|
6132
|
+
builder.add(node.from, node.to, Decoration11.replace({
|
6080
6133
|
block: true,
|
6081
6134
|
// atomic: true,
|
6082
6135
|
widget: new PreviewBlockWidget(options, link)
|
@@ -6089,7 +6142,7 @@ var buildDecorations3 = (state, options) => {
|
|
6089
6142
|
});
|
6090
6143
|
return builder.finish();
|
6091
6144
|
};
|
6092
|
-
var PreviewInlineWidget = class extends
|
6145
|
+
var PreviewInlineWidget = class extends WidgetType7 {
|
6093
6146
|
constructor(_options, _link) {
|
6094
6147
|
super(), this._options = _options, this._link = _link;
|
6095
6148
|
}
|
@@ -6106,7 +6159,7 @@ var PreviewInlineWidget = class extends WidgetType6 {
|
|
6106
6159
|
return root;
|
6107
6160
|
}
|
6108
6161
|
};
|
6109
|
-
var PreviewBlockWidget = class extends
|
6162
|
+
var PreviewBlockWidget = class extends WidgetType7 {
|
6110
6163
|
constructor(_options, _link) {
|
6111
6164
|
super(), this._options = _options, this._link = _link;
|
6112
6165
|
}
|
@@ -6519,8 +6572,8 @@ var createViewMode = (state, onViewModeChange) => {
|
|
6519
6572
|
};
|
6520
6573
|
|
6521
6574
|
// packages/ui/react-ui-editor/src/defaults.ts
|
6522
|
-
import { EditorView as
|
6523
|
-
import { mx as
|
6575
|
+
import { EditorView as EditorView23 } from "@codemirror/view";
|
6576
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
6524
6577
|
var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
|
6525
6578
|
var editorSlots = {
|
6526
6579
|
scroll: {
|
@@ -6530,19 +6583,19 @@ var editorSlots = {
|
|
6530
6583
|
className: editorWidth
|
6531
6584
|
}
|
6532
6585
|
};
|
6533
|
-
var editorGutter =
|
6586
|
+
var editorGutter = EditorView23.theme({
|
6534
6587
|
".cm-gutters": {
|
6535
6588
|
paddingRight: "1rem"
|
6536
6589
|
}
|
6537
6590
|
});
|
6538
|
-
var editorMonospace =
|
6591
|
+
var editorMonospace = EditorView23.theme({
|
6539
6592
|
".cm-content": {
|
6540
6593
|
fontFamily: fontMono
|
6541
6594
|
}
|
6542
6595
|
});
|
6543
6596
|
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
|
6544
|
-
var stackItemContentEditorClassNames = (role) =>
|
6545
|
-
var stackItemContentToolbarClassNames = (role) =>
|
6597
|
+
var stackItemContentEditorClassNames = (role) => mx5("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
|
6598
|
+
var stackItemContentToolbarClassNames = (role) => mx5("relative z-[1] flex is-full bg-toolbarSurface border-be border-subduedSeparator", role === "section" && "sticky block-start-0 -mbe-px min-is-0");
|
6546
6599
|
|
6547
6600
|
// packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
|
6548
6601
|
var createToolbar = ({ getView, state, customActions, ...features }) => {
|
@@ -6651,7 +6704,7 @@ var EditorToolbar = /* @__PURE__ */ memo(({ classNames, attendableId, role, ...p
|
|
6651
6704
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
6652
6705
|
import { createContext } from "@radix-ui/react-context";
|
6653
6706
|
import React4, { useRef, useState, useEffect as useEffect2, useCallback } from "react";
|
6654
|
-
import { addEventListener } from "@dxos/async";
|
6707
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
6655
6708
|
import { Popover } from "@dxos/react-ui";
|
6656
6709
|
var customEventOptions = {
|
6657
6710
|
capture: true,
|
@@ -6690,7 +6743,7 @@ var RefPopoverProvider = ({ children, onLookup }) => {
|
|
6690
6743
|
onLookup
|
6691
6744
|
]);
|
6692
6745
|
useEffect2(() => {
|
6693
|
-
return rootRef ?
|
6746
|
+
return rootRef ? addEventListener2(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions) : void 0;
|
6694
6747
|
}, [
|
6695
6748
|
rootRef
|
6696
6749
|
]);
|
@@ -6720,7 +6773,7 @@ var RefPopover = {
|
|
6720
6773
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
6721
6774
|
import { createContext as createContext2 } from "@radix-ui/react-context";
|
6722
6775
|
import React5, { useRef as useRef2, useState as useState2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
|
6723
|
-
import { addEventListener as
|
6776
|
+
import { addEventListener as addEventListener3 } from "@dxos/async";
|
6724
6777
|
import { DropdownMenu } from "@dxos/react-ui";
|
6725
6778
|
var customEventOptions2 = {
|
6726
6779
|
capture: true,
|
@@ -6759,7 +6812,7 @@ var RefDropdownMenuProvider = ({ children, onLookup }) => {
|
|
6759
6812
|
onLookup
|
6760
6813
|
]);
|
6761
6814
|
useEffect3(() => {
|
6762
|
-
return rootRef ?
|
6815
|
+
return rootRef ? addEventListener3(rootRef, "dx-ref-tag-activate", handleDxRefTagActivate, customEventOptions2) : void 0;
|
6763
6816
|
}, [
|
6764
6817
|
rootRef
|
6765
6818
|
]);
|
@@ -6787,7 +6840,7 @@ var RefDropdownMenu = {
|
|
6787
6840
|
|
6788
6841
|
// packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
|
6789
6842
|
import { EditorState as EditorState3 } from "@codemirror/state";
|
6790
|
-
import { EditorView as
|
6843
|
+
import { EditorView as EditorView24 } from "@codemirror/view";
|
6791
6844
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
6792
6845
|
import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
|
6793
6846
|
import { log as log8 } from "@dxos/log";
|
@@ -6831,7 +6884,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6831
6884
|
id && documentId.of(id),
|
6832
6885
|
extensions,
|
6833
6886
|
// NOTE: This doesn't catch errors in keymap functions.
|
6834
|
-
|
6887
|
+
EditorView24.exceptionSink.of((err) => {
|
6835
6888
|
log8.catch(err, void 0, {
|
6836
6889
|
F: __dxlog_file13,
|
6837
6890
|
L: 98,
|
@@ -6841,10 +6894,10 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6841
6894
|
})
|
6842
6895
|
].filter(isNotFalsy4)
|
6843
6896
|
});
|
6844
|
-
view2 = new
|
6897
|
+
view2 = new EditorView24({
|
6845
6898
|
parent: parentRef.current,
|
6846
6899
|
state,
|
6847
|
-
scrollTo: scrollTo ?
|
6900
|
+
scrollTo: scrollTo ? EditorView24.scrollIntoView(scrollTo, {
|
6848
6901
|
yMargin: 96
|
6849
6902
|
}) : void 0,
|
6850
6903
|
dispatchTransactions: debug ? debugDispatcher : void 0
|
@@ -6943,7 +6996,7 @@ export {
|
|
6943
6996
|
EditorInputModes,
|
6944
6997
|
EditorState4 as EditorState,
|
6945
6998
|
EditorToolbar,
|
6946
|
-
|
6999
|
+
EditorView25 as EditorView,
|
6947
7000
|
EditorViewMode,
|
6948
7001
|
EditorViewModes,
|
6949
7002
|
Inline,
|
@@ -7014,6 +7067,7 @@ export {
|
|
7014
7067
|
getFormatting,
|
7015
7068
|
getListItemContent,
|
7016
7069
|
getRange,
|
7070
|
+
hashtag,
|
7017
7071
|
image,
|
7018
7072
|
indentItemLess,
|
7019
7073
|
indentItemMore,
|