@dxos/react-ui-editor 0.8.2-staging.4d6ad0f → 0.8.2
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 +139 -77
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +105 -36
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +139 -77
- 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 +1 -10
- package/dist/types/src/extensions/command/menu.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/commands.d.ts +1 -0
- package/dist/types/src/extensions/outliner/commands.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/editor.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/index.d.ts +1 -0
- package/dist/types/src/extensions/outliner/index.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts +4 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/extensions/command/menu.ts +35 -4
- package/src/extensions/outliner/commands.ts +29 -1
- package/src/extensions/outliner/editor.ts +7 -3
- package/src/extensions/outliner/index.ts +1 -0
- package/src/extensions/outliner/outliner.test.ts +2 -2
- package/src/extensions/outliner/outliner.ts +43 -37
@@ -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 EditorView24, 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
|
|
@@ -1460,7 +1460,7 @@ var command = (options = {}) => {
|
|
1460
1460
|
};
|
1461
1461
|
|
1462
1462
|
// packages/ui/react-ui-editor/src/extensions/command/menu.ts
|
1463
|
-
import { ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
1463
|
+
import { EditorView as EditorView7, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
1464
1464
|
var floatingMenu = (options = {}) => [
|
1465
1465
|
ViewPlugin5.fromClass(class {
|
1466
1466
|
constructor(view) {
|
@@ -1474,20 +1474,24 @@ var floatingMenu = (options = {}) => [
|
|
1474
1474
|
icon.setAttribute("icon", options.icon ?? "ph--dots-three-outline--regular");
|
1475
1475
|
const button = document.createElement("button");
|
1476
1476
|
button.appendChild(icon);
|
1477
|
-
button.classList.add("grid", "items-center", "justify-center", "w-8", "h-8");
|
1478
1477
|
this.tag = document.createElement("dx-ref-tag");
|
1479
|
-
this.tag.classList.add("
|
1478
|
+
this.tag.classList.add("cm-ref-tag");
|
1480
1479
|
this.tag.appendChild(button);
|
1481
1480
|
container.appendChild(this.tag);
|
1482
1481
|
container.addEventListener("scroll", this.scheduleUpdate.bind(this));
|
1483
1482
|
this.scheduleUpdate();
|
1484
1483
|
}
|
1485
1484
|
update(update2) {
|
1485
|
+
this.tag.dataset.focused = update2.view.hasFocus ? "true" : "false";
|
1486
|
+
if (!update2.view.hasFocus) {
|
1487
|
+
return;
|
1488
|
+
}
|
1486
1489
|
if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(openEffect)))) {
|
1487
1490
|
this.tag.style.display = "none";
|
1491
|
+
this.tag.classList.add("opacity-10");
|
1488
1492
|
} else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
|
1489
1493
|
this.tag.style.display = "block";
|
1490
|
-
} else if (update2.
|
1494
|
+
} else if (update2.docChanged || update2.focusChanged || update2.geometryChanged || update2.selectionSet || update2.viewportChanged) {
|
1491
1495
|
this.scheduleUpdate();
|
1492
1496
|
}
|
1493
1497
|
}
|
@@ -1519,6 +1523,25 @@ var floatingMenu = (options = {}) => [
|
|
1519
1523
|
cancelAnimationFrame(this.rafId);
|
1520
1524
|
}
|
1521
1525
|
}
|
1526
|
+
}),
|
1527
|
+
EditorView7.theme({
|
1528
|
+
".cm-ref-tag": {
|
1529
|
+
position: "fixed",
|
1530
|
+
padding: "0",
|
1531
|
+
border: "none",
|
1532
|
+
transition: "opacity 0.3s ease-in-out",
|
1533
|
+
opacity: 0.1
|
1534
|
+
},
|
1535
|
+
".cm-ref-tag button": {
|
1536
|
+
display: "grid",
|
1537
|
+
alignItems: "center",
|
1538
|
+
justifyContent: "center",
|
1539
|
+
width: "2rem",
|
1540
|
+
height: "2rem"
|
1541
|
+
},
|
1542
|
+
'.cm-ref-tag[data-focused="true"]': {
|
1543
|
+
opacity: 1
|
1544
|
+
}
|
1522
1545
|
})
|
1523
1546
|
];
|
1524
1547
|
|
@@ -1608,7 +1631,7 @@ var matchCompletion = (completion, word) => {
|
|
1608
1631
|
// packages/ui/react-ui-editor/src/extensions/comments.ts
|
1609
1632
|
import { invertedEffects } from "@codemirror/commands";
|
1610
1633
|
import { StateEffect as StateEffect3, StateField as StateField3 } from "@codemirror/state";
|
1611
|
-
import { hoverTooltip, keymap as keymap6, Decoration as Decoration5, EditorView as
|
1634
|
+
import { hoverTooltip, keymap as keymap6, Decoration as Decoration5, EditorView as EditorView9, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
|
1612
1635
|
import sortBy from "lodash.sortby";
|
1613
1636
|
import { useEffect } from "react";
|
1614
1637
|
import { debounce as debounce2 } from "@dxos/async";
|
@@ -1617,7 +1640,7 @@ import { isNonNullable } from "@dxos/util";
|
|
1617
1640
|
|
1618
1641
|
// packages/ui/react-ui-editor/src/extensions/selection.ts
|
1619
1642
|
import { Transaction } from "@codemirror/state";
|
1620
|
-
import { EditorView as
|
1643
|
+
import { EditorView as EditorView8, keymap as keymap5 } from "@codemirror/view";
|
1621
1644
|
import { debounce } from "@dxos/async";
|
1622
1645
|
import { invariant as invariant3 } from "@dxos/invariant";
|
1623
1646
|
import { isNotFalsy } from "@dxos/util";
|
@@ -1628,7 +1651,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1628
1651
|
return {
|
1629
1652
|
selection,
|
1630
1653
|
scrollIntoView: !scrollTo,
|
1631
|
-
effects: scrollTo ?
|
1654
|
+
effects: scrollTo ? EditorView8.scrollIntoView(scrollTo, {
|
1632
1655
|
yMargin: 96
|
1633
1656
|
}) : void 0,
|
1634
1657
|
annotations: Transaction.userEvent.of(stateRestoreAnnotation)
|
@@ -1670,7 +1693,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
1670
1693
|
// setStateDebounced(id, {});
|
1671
1694
|
// },
|
1672
1695
|
// }),
|
1673
|
-
|
1696
|
+
EditorView8.updateListener.of(({ view, transactions }) => {
|
1674
1697
|
const id = view.state.facet(documentId);
|
1675
1698
|
if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
|
1676
1699
|
return;
|
@@ -1751,7 +1774,7 @@ var commentsState = StateField3.define({
|
|
1751
1774
|
return value;
|
1752
1775
|
}
|
1753
1776
|
});
|
1754
|
-
var styles2 =
|
1777
|
+
var styles2 = EditorView9.theme({
|
1755
1778
|
".cm-comment, .cm-comment-current": {
|
1756
1779
|
margin: "0 -3px",
|
1757
1780
|
padding: "3px",
|
@@ -1771,7 +1794,7 @@ var createCommentMark = (id, isCurrent) => Decoration5.mark({
|
|
1771
1794
|
"data-comment-id": id
|
1772
1795
|
}
|
1773
1796
|
});
|
1774
|
-
var commentsDecorations =
|
1797
|
+
var commentsDecorations = EditorView9.decorations.compute([
|
1775
1798
|
commentsState
|
1776
1799
|
], (state) => {
|
1777
1800
|
const { selection: { current }, comments: comments2 } = state.field(commentsState);
|
@@ -1794,7 +1817,7 @@ var commentsDecorations = EditorView8.decorations.compute([
|
|
1794
1817
|
return Decoration5.set(decorations2);
|
1795
1818
|
});
|
1796
1819
|
var commentClickedEffect = StateEffect3.define();
|
1797
|
-
var handleCommentClick =
|
1820
|
+
var handleCommentClick = EditorView9.domEventHandlers({
|
1798
1821
|
click: (event, view) => {
|
1799
1822
|
let target = event.target;
|
1800
1823
|
const editorRoot = view.dom;
|
@@ -1833,7 +1856,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1833
1856
|
}
|
1834
1857
|
};
|
1835
1858
|
return [
|
1836
|
-
|
1859
|
+
EditorView9.domEventHandlers({
|
1837
1860
|
cut: handleTrack,
|
1838
1861
|
copy: handleTrack
|
1839
1862
|
}),
|
@@ -1855,7 +1878,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1855
1878
|
return effects;
|
1856
1879
|
}),
|
1857
1880
|
// Handle paste or the undo of comment deletion.
|
1858
|
-
|
1881
|
+
EditorView9.updateListener.of((update2) => {
|
1859
1882
|
const restore = [];
|
1860
1883
|
for (let i = 0; i < update2.transactions.length; i++) {
|
1861
1884
|
const tr = update2.transactions[i];
|
@@ -1997,7 +2020,7 @@ var comments = (options = {}) => {
|
|
1997
2020
|
//
|
1998
2021
|
// Track deleted ranges and update ranges for decorations.
|
1999
2022
|
//
|
2000
|
-
|
2023
|
+
EditorView9.updateListener.of(({ view, state, changes }) => {
|
2001
2024
|
let mod = false;
|
2002
2025
|
const { comments: comments2, ...value } = state.field(commentsState);
|
2003
2026
|
changes.iterChanges((from, to, from2, to2) => {
|
@@ -2029,7 +2052,7 @@ var comments = (options = {}) => {
|
|
2029
2052
|
//
|
2030
2053
|
// Track selection/proximity.
|
2031
2054
|
//
|
2032
|
-
|
2055
|
+
EditorView9.updateListener.of(({ view, state }) => {
|
2033
2056
|
let min = Infinity;
|
2034
2057
|
const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
|
2035
2058
|
const { head } = state.selection.main;
|
@@ -2083,7 +2106,7 @@ var scrollThreadIntoView = (view, id, center = true) => {
|
|
2083
2106
|
anchor: range.from
|
2084
2107
|
} : void 0,
|
2085
2108
|
effects: [
|
2086
|
-
needsScroll ?
|
2109
|
+
needsScroll ? EditorView9.scrollIntoView(range.from, center ? {
|
2087
2110
|
y: "center"
|
2088
2111
|
} : void 0) : [],
|
2089
2112
|
needsSelectionUpdate ? setSelection.of({
|
@@ -2147,8 +2170,8 @@ var debugNodeLogger = (log9 = console.log) => {
|
|
2147
2170
|
};
|
2148
2171
|
|
2149
2172
|
// packages/ui/react-ui-editor/src/extensions/dnd.ts
|
2150
|
-
import { dropCursor, EditorView as
|
2151
|
-
var styles3 =
|
2173
|
+
import { dropCursor, EditorView as EditorView10 } from "@codemirror/view";
|
2174
|
+
var styles3 = EditorView10.theme({
|
2152
2175
|
".cm-dropCursor": {
|
2153
2176
|
borderLeft: "2px solid var(--dx-accentText)",
|
2154
2177
|
color: "var(--dx-accentText)",
|
@@ -2162,7 +2185,7 @@ var dropFile = (options = {}) => {
|
|
2162
2185
|
return [
|
2163
2186
|
styles3,
|
2164
2187
|
dropCursor(),
|
2165
|
-
|
2188
|
+
EditorView10.domEventHandlers({
|
2166
2189
|
drop: (event, view) => {
|
2167
2190
|
event.preventDefault();
|
2168
2191
|
const files = event.dataTransfer?.files;
|
@@ -2189,7 +2212,7 @@ import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@cod
|
|
2189
2212
|
import { searchKeymap } from "@codemirror/search";
|
2190
2213
|
import { EditorState } from "@codemirror/state";
|
2191
2214
|
import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
|
2192
|
-
import { EditorView as
|
2215
|
+
import { EditorView as EditorView12, ViewPlugin as ViewPlugin8, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap7, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
|
2193
2216
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
2194
2217
|
import merge from "lodash.merge";
|
2195
2218
|
import { generateName } from "@dxos/display-name";
|
@@ -2198,7 +2221,7 @@ import { hexToHue, isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
2198
2221
|
|
2199
2222
|
// packages/ui/react-ui-editor/src/extensions/focus.ts
|
2200
2223
|
import { StateEffect as StateEffect4, StateField as StateField5 } from "@codemirror/state";
|
2201
|
-
import { EditorView as
|
2224
|
+
import { EditorView as EditorView11 } from "@codemirror/view";
|
2202
2225
|
var focusEffect = StateEffect4.define();
|
2203
2226
|
var focusField = StateField5.define({
|
2204
2227
|
create: () => false,
|
@@ -2213,7 +2236,7 @@ var focusField = StateField5.define({
|
|
2213
2236
|
});
|
2214
2237
|
var focus = [
|
2215
2238
|
focusField,
|
2216
|
-
|
2239
|
+
EditorView11.domEventHandlers({
|
2217
2240
|
focus: (event, view) => {
|
2218
2241
|
setTimeout(() => view.dispatch({
|
2219
2242
|
effects: focusEffect.of(true)
|
@@ -2492,7 +2515,7 @@ var createBasicExtensions = (_props) => {
|
|
2492
2515
|
const props = defaultsDeep2({}, _props, defaultBasicOptions);
|
2493
2516
|
return [
|
2494
2517
|
// NOTE: Doesn't catch errors in keymap functions.
|
2495
|
-
|
2518
|
+
EditorView12.exceptionSink.of((err) => {
|
2496
2519
|
log5.catch(err, void 0, {
|
2497
2520
|
F: __dxlog_file8,
|
2498
2521
|
L: 98,
|
@@ -2507,12 +2530,12 @@ var createBasicExtensions = (_props) => {
|
|
2507
2530
|
props.drawSelection && drawSelection({
|
2508
2531
|
cursorBlinkRate: 1200
|
2509
2532
|
}),
|
2510
|
-
props.editable !== void 0 &&
|
2533
|
+
props.editable !== void 0 && EditorView12.editable.of(props.editable),
|
2511
2534
|
props.focus && focus,
|
2512
2535
|
props.highlightActiveLine && highlightActiveLine(),
|
2513
2536
|
props.history && history(),
|
2514
2537
|
props.lineNumbers && lineNumbers(),
|
2515
|
-
props.lineWrapping &&
|
2538
|
+
props.lineWrapping && EditorView12.lineWrapping,
|
2516
2539
|
props.placeholder && placeholder(props.placeholder),
|
2517
2540
|
props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
|
2518
2541
|
props.scrollPastEnd && scrollPastEnd(),
|
@@ -2549,14 +2572,14 @@ var defaultThemeSlots = {
|
|
2549
2572
|
var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
|
2550
2573
|
const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
|
2551
2574
|
return [
|
2552
|
-
|
2553
|
-
|
2575
|
+
EditorView12.darkTheme.of(themeMode === "dark"),
|
2576
|
+
EditorView12.baseTheme(styles4 ? merge({}, defaultTheme, styles4) : defaultTheme),
|
2554
2577
|
// https://github.com/codemirror/theme-one-dark
|
2555
2578
|
_syntaxHighlighting && (themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle)),
|
2556
|
-
slots.editor?.className &&
|
2579
|
+
slots.editor?.className && EditorView12.editorAttributes.of({
|
2557
2580
|
class: slots.editor.className
|
2558
2581
|
}),
|
2559
|
-
slots.content?.className &&
|
2582
|
+
slots.content?.className && EditorView12.contentAttributes.of({
|
2560
2583
|
class: slots.content.className
|
2561
2584
|
}),
|
2562
2585
|
slots.scroll?.className && ViewPlugin8.fromClass(class {
|
@@ -2590,7 +2613,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
|
|
2590
2613
|
|
2591
2614
|
// packages/ui/react-ui-editor/src/extensions/folding.tsx
|
2592
2615
|
import { codeFolding, foldGutter } from "@codemirror/language";
|
2593
|
-
import { EditorView as
|
2616
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
2594
2617
|
import React2 from "react";
|
2595
2618
|
import { Icon } from "@dxos/react-ui";
|
2596
2619
|
var folding = (_props = {}) => [
|
@@ -2614,7 +2637,7 @@ var folding = (_props = {}) => [
|
|
2614
2637
|
}));
|
2615
2638
|
}
|
2616
2639
|
}),
|
2617
|
-
|
2640
|
+
EditorView13.theme({
|
2618
2641
|
".cm-foldGutter": {
|
2619
2642
|
opacity: 0.3,
|
2620
2643
|
transition: "opacity 0.3s",
|
@@ -2671,14 +2694,14 @@ var schemaLinter = (validate) => (view) => {
|
|
2671
2694
|
};
|
2672
2695
|
|
2673
2696
|
// packages/ui/react-ui-editor/src/extensions/listener.ts
|
2674
|
-
import { EditorView as
|
2697
|
+
import { EditorView as EditorView14 } from "@codemirror/view";
|
2675
2698
|
var listener = ({ onFocus, onChange }) => {
|
2676
2699
|
const extensions = [];
|
2677
|
-
onFocus && extensions.push(
|
2700
|
+
onFocus && extensions.push(EditorView14.focusChangeEffect.of((_, focusing) => {
|
2678
2701
|
onFocus(focusing);
|
2679
2702
|
return null;
|
2680
2703
|
}));
|
2681
|
-
onChange && extensions.push(
|
2704
|
+
onChange && extensions.push(EditorView14.updateListener.of((update2) => {
|
2682
2705
|
onChange(update2.state.doc.toString(), update2.state.facet(documentId));
|
2683
2706
|
}));
|
2684
2707
|
return extensions;
|
@@ -2688,7 +2711,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
2688
2711
|
import { snippet } from "@codemirror/autocomplete";
|
2689
2712
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
2690
2713
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
2691
|
-
import { EditorView as
|
2714
|
+
import { EditorView as EditorView15, keymap as keymap8 } from "@codemirror/view";
|
2692
2715
|
import { useMemo as useMemo2 } from "react";
|
2693
2716
|
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;
|
2694
2717
|
var Inline = /* @__PURE__ */ function(Inline2) {
|
@@ -3777,7 +3800,7 @@ var getFormatting = (state) => {
|
|
3777
3800
|
};
|
3778
3801
|
};
|
3779
3802
|
var useFormattingState = (state) => {
|
3780
|
-
return useMemo2(() =>
|
3803
|
+
return useMemo2(() => EditorView15.updateListener.of((update2) => {
|
3781
3804
|
if (update2.docChanged || update2.selectionSet) {
|
3782
3805
|
Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
|
3783
3806
|
state[key] = active;
|
@@ -4090,7 +4113,7 @@ var convertTreeToJson = (state) => {
|
|
4090
4113
|
// packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
|
4091
4114
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
4092
4115
|
import { RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect5 } from "@codemirror/state";
|
4093
|
-
import { EditorView as
|
4116
|
+
import { EditorView as EditorView19, Decoration as Decoration8, WidgetType as WidgetType5, ViewPlugin as ViewPlugin10 } from "@codemirror/view";
|
4094
4117
|
import { invariant as invariant4 } from "@dxos/invariant";
|
4095
4118
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
4096
4119
|
|
@@ -4241,7 +4264,7 @@ var getValidUrl = (str) => {
|
|
4241
4264
|
// packages/ui/react-ui-editor/src/extensions/markdown/image.ts
|
4242
4265
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
4243
4266
|
import { StateField as StateField7 } from "@codemirror/state";
|
4244
|
-
import { Decoration as Decoration6, EditorView as
|
4267
|
+
import { Decoration as Decoration6, EditorView as EditorView16, WidgetType as WidgetType3 } from "@codemirror/view";
|
4245
4268
|
var image = (_options = {}) => {
|
4246
4269
|
return [
|
4247
4270
|
StateField7.define({
|
@@ -4269,7 +4292,7 @@ var image = (_options = {}) => {
|
|
4269
4292
|
add: buildDecorations(from, to, tr.state)
|
4270
4293
|
});
|
4271
4294
|
},
|
4272
|
-
provide: (field) =>
|
4295
|
+
provide: (field) => EditorView16.decorations.from(field)
|
4273
4296
|
})
|
4274
4297
|
];
|
4275
4298
|
};
|
@@ -4328,10 +4351,10 @@ var ImageWidget = class extends WidgetType3 {
|
|
4328
4351
|
};
|
4329
4352
|
|
4330
4353
|
// packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
|
4331
|
-
import { EditorView as
|
4354
|
+
import { EditorView as EditorView17 } from "@codemirror/view";
|
4332
4355
|
var bulletListIndentationWidth = 24;
|
4333
4356
|
var orderedListIndentationWidth = 36;
|
4334
|
-
var formattingStyles =
|
4357
|
+
var formattingStyles = EditorView17.theme({
|
4335
4358
|
/**
|
4336
4359
|
* Horizontal rule.
|
4337
4360
|
*/
|
@@ -4453,12 +4476,12 @@ var formattingStyles = EditorView16.theme({
|
|
4453
4476
|
// packages/ui/react-ui-editor/src/extensions/markdown/table.ts
|
4454
4477
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
4455
4478
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
4456
|
-
import { Decoration as Decoration7, EditorView as
|
4479
|
+
import { Decoration as Decoration7, EditorView as EditorView18, WidgetType as WidgetType4 } from "@codemirror/view";
|
4457
4480
|
var table = (options = {}) => {
|
4458
4481
|
return StateField8.define({
|
4459
4482
|
create: (state) => update(state, options),
|
4460
4483
|
update: (_, tr) => update(tr.state, options),
|
4461
|
-
provide: (field) =>
|
4484
|
+
provide: (field) => EditorView18.decorations.from(field)
|
4462
4485
|
});
|
4463
4486
|
};
|
4464
4487
|
var update = (state, _options) => {
|
@@ -4991,9 +5014,9 @@ var decorateMarkdown = (options = {}) => {
|
|
4991
5014
|
}
|
4992
5015
|
}, {
|
4993
5016
|
provide: (plugin) => [
|
4994
|
-
|
4995
|
-
|
4996
|
-
|
5017
|
+
EditorView19.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
|
5018
|
+
EditorView19.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
|
5019
|
+
EditorView19.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration8.none)
|
4997
5020
|
]
|
4998
5021
|
}),
|
4999
5022
|
image(),
|
@@ -5129,11 +5152,6 @@ var InputModeExtensions = {
|
|
5129
5152
|
]
|
5130
5153
|
};
|
5131
5154
|
|
5132
|
-
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5133
|
-
import { Prec as Prec2 } from "@codemirror/state";
|
5134
|
-
import { Decoration as Decoration9, EditorView as EditorView19, ViewPlugin as ViewPlugin12 } from "@codemirror/view";
|
5135
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
5136
|
-
|
5137
5155
|
// packages/ui/react-ui-editor/src/extensions/outliner/commands.ts
|
5138
5156
|
import { indentMore } from "@codemirror/commands";
|
5139
5157
|
import { getIndentUnit } from "@codemirror/language";
|
@@ -5564,9 +5582,26 @@ var moveItemUp = (view) => {
|
|
5564
5582
|
}
|
5565
5583
|
return true;
|
5566
5584
|
};
|
5585
|
+
var deleteItem = (view) => {
|
5586
|
+
const tree = view.state.facet(treeFacet);
|
5587
|
+
const pos = getSelection(view.state).from;
|
5588
|
+
const current = tree.find(pos);
|
5589
|
+
if (current) {
|
5590
|
+
view.dispatch({
|
5591
|
+
selection: EditorSelection3.cursor(current.lineRange.from),
|
5592
|
+
changes: [
|
5593
|
+
{
|
5594
|
+
from: current.lineRange.from,
|
5595
|
+
to: Math.min(current.lineRange.to + 1, view.state.doc.length)
|
5596
|
+
}
|
5597
|
+
]
|
5598
|
+
});
|
5599
|
+
}
|
5600
|
+
return true;
|
5601
|
+
};
|
5567
5602
|
var toggleTask = (view) => {
|
5568
|
-
const pos = getSelection(view.state)?.from;
|
5569
5603
|
const tree = view.state.facet(treeFacet);
|
5604
|
+
const pos = getSelection(view.state)?.from;
|
5570
5605
|
const current = tree.find(pos);
|
5571
5606
|
if (current) {
|
5572
5607
|
const type = current.type === "task" ? "bullet" : "task";
|
@@ -5671,14 +5706,28 @@ var commands = () => keymap11.of([
|
|
5671
5706
|
run: moveItemUp
|
5672
5707
|
},
|
5673
5708
|
//
|
5709
|
+
// Delete.
|
5710
|
+
//
|
5711
|
+
{
|
5712
|
+
key: "Mod-Backspace",
|
5713
|
+
preventDefault: true,
|
5714
|
+
run: deleteItem
|
5715
|
+
},
|
5716
|
+
//
|
5674
5717
|
// Misc.
|
5675
5718
|
//
|
5676
5719
|
{
|
5677
5720
|
key: "Alt-t",
|
5721
|
+
preventDefault: true,
|
5678
5722
|
run: toggleTask
|
5679
5723
|
}
|
5680
5724
|
]);
|
5681
5725
|
|
5726
|
+
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5727
|
+
import { Prec as Prec2 } from "@codemirror/state";
|
5728
|
+
import { Decoration as Decoration9, EditorView as EditorView20, ViewPlugin as ViewPlugin12 } from "@codemirror/view";
|
5729
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
5730
|
+
|
5682
5731
|
// packages/ui/react-ui-editor/src/extensions/outliner/editor.ts
|
5683
5732
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
5684
5733
|
import { ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
@@ -5772,6 +5821,12 @@ var editor = () => [
|
|
5772
5821
|
const line = tr.startState.doc.lineAt(fromA);
|
5773
5822
|
const match = line.text.match(LIST_ITEM_REGEX);
|
5774
5823
|
if (match) {
|
5824
|
+
const startTree = tr.startState.facet(treeFacet);
|
5825
|
+
const startItem = startTree.find(tr.startState.selection.main.from);
|
5826
|
+
const deleteLine = fromA === startItem?.lineRange.from && toA === startItem?.lineRange.to + 1;
|
5827
|
+
if (deleteLine) {
|
5828
|
+
return;
|
5829
|
+
}
|
5775
5830
|
const currentItem = tree.find(tr.state.selection.main.from);
|
5776
5831
|
if (!currentItem?.contentRange) {
|
5777
5832
|
cancel = true;
|
@@ -5829,7 +5884,7 @@ var editor = () => [
|
|
5829
5884
|
}
|
5830
5885
|
}, {
|
5831
5886
|
F: __dxlog_file12,
|
5832
|
-
L:
|
5887
|
+
L: 164,
|
5833
5888
|
S: void 0,
|
5834
5889
|
C: (f, a) => f(...a)
|
5835
5890
|
});
|
@@ -5840,7 +5895,7 @@ var editor = () => [
|
|
5840
5895
|
changes
|
5841
5896
|
}, {
|
5842
5897
|
F: __dxlog_file12,
|
5843
|
-
L:
|
5898
|
+
L: 175,
|
5844
5899
|
S: void 0,
|
5845
5900
|
C: (f, a) => f(...a)
|
5846
5901
|
});
|
@@ -5852,7 +5907,7 @@ var editor = () => [
|
|
5852
5907
|
} else if (cancel) {
|
5853
5908
|
log7("cancel", void 0, {
|
5854
5909
|
F: __dxlog_file12,
|
5855
|
-
L:
|
5910
|
+
L: 178,
|
5856
5911
|
S: void 0,
|
5857
5912
|
C: (f, a) => f(...a)
|
5858
5913
|
});
|
@@ -5863,7 +5918,7 @@ var editor = () => [
|
|
5863
5918
|
];
|
5864
5919
|
|
5865
5920
|
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5866
|
-
var outliner = () => [
|
5921
|
+
var outliner = (options = {}) => [
|
5867
5922
|
// Commands.
|
5868
5923
|
Prec2.highest(commands()),
|
5869
5924
|
// Selection.
|
@@ -5875,17 +5930,17 @@ var outliner = () => [
|
|
5875
5930
|
// Floating menu.
|
5876
5931
|
floatingMenu(),
|
5877
5932
|
// Line decorations.
|
5878
|
-
decorations(),
|
5933
|
+
decorations(options),
|
5879
5934
|
// Default markdown decorations.
|
5880
5935
|
decorateMarkdown({
|
5881
5936
|
listPaddingLeft: 8
|
5882
5937
|
}),
|
5883
5938
|
// Researve space for menu.
|
5884
|
-
|
5939
|
+
EditorView20.contentAttributes.of({
|
5885
5940
|
class: "is-full !mr-[3rem]"
|
5886
5941
|
})
|
5887
5942
|
];
|
5888
|
-
var decorations = () => [
|
5943
|
+
var decorations = (options) => [
|
5889
5944
|
ViewPlugin12.fromClass(class {
|
5890
5945
|
constructor(view) {
|
5891
5946
|
this.decorations = Decoration9.none;
|
@@ -5921,7 +5976,7 @@ var decorations = () => [
|
|
5921
5976
|
decorations: (v) => v.decorations
|
5922
5977
|
}),
|
5923
5978
|
// Theme.
|
5924
|
-
|
5979
|
+
EditorView20.theme(Object.assign({
|
5925
5980
|
".cm-list-item": {
|
5926
5981
|
borderLeftWidth: "1px",
|
5927
5982
|
borderRightWidth: "1px",
|
@@ -5936,29 +5991,29 @@ var decorations = () => [
|
|
5936
5991
|
borderTopLeftRadius: "4px",
|
5937
5992
|
borderTopRightRadius: "4px",
|
5938
5993
|
paddingTop: "4px",
|
5939
|
-
marginTop: "
|
5994
|
+
marginTop: "2px"
|
5940
5995
|
},
|
5941
5996
|
".cm-list-item-end": {
|
5942
5997
|
borderBottomWidth: "1px",
|
5943
5998
|
borderBottomLeftRadius: "4px",
|
5944
5999
|
borderBottomRightRadius: "4px",
|
5945
6000
|
paddingBottom: "4px",
|
5946
|
-
marginBottom: "
|
6001
|
+
marginBottom: "2px"
|
5947
6002
|
},
|
5948
6003
|
".cm-list-item-selected": {
|
5949
|
-
borderColor: "var(--dx-separator)"
|
6004
|
+
borderColor: options.showSelected ? "var(--dx-separator)" : void 0
|
5950
6005
|
},
|
5951
6006
|
".cm-list-item-focused": {
|
5952
6007
|
borderColor: "var(--dx-accentFocusIndicator)"
|
5953
6008
|
}
|
5954
|
-
})
|
6009
|
+
}))
|
5955
6010
|
];
|
5956
6011
|
|
5957
6012
|
// packages/ui/react-ui-editor/src/extensions/preview/preview.ts
|
5958
6013
|
import "@dxos/lit-ui/dx-ref-tag.pcss";
|
5959
6014
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
5960
6015
|
import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField10 } from "@codemirror/state";
|
5961
|
-
import { Decoration as Decoration10, EditorView as
|
6016
|
+
import { Decoration as Decoration10, EditorView as EditorView21, WidgetType as WidgetType6 } from "@codemirror/view";
|
5962
6017
|
var preview = (options = {}) => {
|
5963
6018
|
return [
|
5964
6019
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
@@ -5967,11 +6022,11 @@ var preview = (options = {}) => {
|
|
5967
6022
|
create: (state) => buildDecorations3(state, options),
|
5968
6023
|
update: (_, tr) => buildDecorations3(tr.state, options),
|
5969
6024
|
provide: (field) => [
|
5970
|
-
|
5971
|
-
|
6025
|
+
EditorView21.decorations.from(field),
|
6026
|
+
EditorView21.atomicRanges.of((view) => view.state.field(field))
|
5972
6027
|
]
|
5973
6028
|
}),
|
5974
|
-
|
6029
|
+
EditorView21.theme({
|
5975
6030
|
".cm-preview-block": {
|
5976
6031
|
marginLeft: "-1rem",
|
5977
6032
|
marginRight: "-1rem",
|
@@ -6464,7 +6519,7 @@ var createViewMode = (state, onViewModeChange) => {
|
|
6464
6519
|
};
|
6465
6520
|
|
6466
6521
|
// packages/ui/react-ui-editor/src/defaults.ts
|
6467
|
-
import { EditorView as
|
6522
|
+
import { EditorView as EditorView22 } from "@codemirror/view";
|
6468
6523
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
6469
6524
|
var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
|
6470
6525
|
var editorSlots = {
|
@@ -6475,12 +6530,12 @@ var editorSlots = {
|
|
6475
6530
|
className: editorWidth
|
6476
6531
|
}
|
6477
6532
|
};
|
6478
|
-
var editorGutter =
|
6533
|
+
var editorGutter = EditorView22.theme({
|
6479
6534
|
".cm-gutters": {
|
6480
6535
|
paddingRight: "1rem"
|
6481
6536
|
}
|
6482
6537
|
});
|
6483
|
-
var editorMonospace =
|
6538
|
+
var editorMonospace = EditorView22.theme({
|
6484
6539
|
".cm-content": {
|
6485
6540
|
fontFamily: fontMono
|
6486
6541
|
}
|
@@ -6732,7 +6787,7 @@ var RefDropdownMenu = {
|
|
6732
6787
|
|
6733
6788
|
// packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
|
6734
6789
|
import { EditorState as EditorState3 } from "@codemirror/state";
|
6735
|
-
import { EditorView as
|
6790
|
+
import { EditorView as EditorView23 } from "@codemirror/view";
|
6736
6791
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
6737
6792
|
import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
|
6738
6793
|
import { log as log8 } from "@dxos/log";
|
@@ -6776,7 +6831,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6776
6831
|
id && documentId.of(id),
|
6777
6832
|
extensions,
|
6778
6833
|
// NOTE: This doesn't catch errors in keymap functions.
|
6779
|
-
|
6834
|
+
EditorView23.exceptionSink.of((err) => {
|
6780
6835
|
log8.catch(err, void 0, {
|
6781
6836
|
F: __dxlog_file13,
|
6782
6837
|
L: 98,
|
@@ -6786,10 +6841,10 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6786
6841
|
})
|
6787
6842
|
].filter(isNotFalsy4)
|
6788
6843
|
});
|
6789
|
-
view2 = new
|
6844
|
+
view2 = new EditorView23({
|
6790
6845
|
parent: parentRef.current,
|
6791
6846
|
state,
|
6792
|
-
scrollTo: scrollTo ?
|
6847
|
+
scrollTo: scrollTo ? EditorView23.scrollIntoView(scrollTo, {
|
6793
6848
|
yMargin: 96
|
6794
6849
|
}) : void 0,
|
6795
6850
|
dispatchTransactions: debug ? debugDispatcher : void 0
|
@@ -6888,7 +6943,7 @@ export {
|
|
6888
6943
|
EditorInputModes,
|
6889
6944
|
EditorState4 as EditorState,
|
6890
6945
|
EditorToolbar,
|
6891
|
-
|
6946
|
+
EditorView24 as EditorView,
|
6892
6947
|
EditorViewMode,
|
6893
6948
|
EditorViewModes,
|
6894
6949
|
Inline,
|
@@ -6917,6 +6972,7 @@ export {
|
|
6917
6972
|
closeEffect,
|
6918
6973
|
command,
|
6919
6974
|
commandKeyBindings,
|
6975
|
+
commands,
|
6920
6976
|
commentClickedEffect,
|
6921
6977
|
comments,
|
6922
6978
|
commentsState,
|
@@ -6939,6 +6995,7 @@ export {
|
|
6939
6995
|
debugTree,
|
6940
6996
|
decorateMarkdown,
|
6941
6997
|
defaultOptions,
|
6998
|
+
deleteItem,
|
6942
6999
|
documentId,
|
6943
7000
|
dropFile,
|
6944
7001
|
editorGutter,
|
@@ -6958,6 +7015,8 @@ export {
|
|
6958
7015
|
getListItemContent,
|
6959
7016
|
getRange,
|
6960
7017
|
image,
|
7018
|
+
indentItemLess,
|
7019
|
+
indentItemMore,
|
6961
7020
|
insertTable,
|
6962
7021
|
itemToJSON,
|
6963
7022
|
keymap13 as keymap,
|
@@ -6970,6 +7029,8 @@ export {
|
|
6970
7029
|
markdownTagsExtensions,
|
6971
7030
|
matchCompletion,
|
6972
7031
|
mention,
|
7032
|
+
moveItemDown,
|
7033
|
+
moveItemUp,
|
6973
7034
|
openCommand,
|
6974
7035
|
openEffect,
|
6975
7036
|
outliner,
|
@@ -7006,6 +7067,7 @@ export {
|
|
7006
7067
|
toggleStrikethrough,
|
7007
7068
|
toggleStrong,
|
7008
7069
|
toggleStyle,
|
7070
|
+
toggleTask,
|
7009
7071
|
translations_default as translations,
|
7010
7072
|
traverse,
|
7011
7073
|
treeFacet,
|