@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
@@ -35,7 +35,7 @@ var translations_default = [
|
|
35
35
|
|
36
36
|
// packages/ui/react-ui-editor/src/index.ts
|
37
37
|
import { EditorState as EditorState4 } from "@codemirror/state";
|
38
|
-
import { EditorView as
|
38
|
+
import { EditorView as EditorView24, keymap as keymap13 } from "@codemirror/view";
|
39
39
|
import { tags as tags2 } from "@lezer/highlight";
|
40
40
|
import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
41
41
|
|
@@ -1458,7 +1458,7 @@ var command = (options = {}) => {
|
|
1458
1458
|
};
|
1459
1459
|
|
1460
1460
|
// packages/ui/react-ui-editor/src/extensions/command/menu.ts
|
1461
|
-
import { ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
1461
|
+
import { EditorView as EditorView7, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
1462
1462
|
var floatingMenu = (options = {}) => [
|
1463
1463
|
ViewPlugin5.fromClass(class {
|
1464
1464
|
constructor(view) {
|
@@ -1472,20 +1472,24 @@ var floatingMenu = (options = {}) => [
|
|
1472
1472
|
icon.setAttribute("icon", options.icon ?? "ph--dots-three-outline--regular");
|
1473
1473
|
const button = document.createElement("button");
|
1474
1474
|
button.appendChild(icon);
|
1475
|
-
button.classList.add("grid", "items-center", "justify-center", "w-8", "h-8");
|
1476
1475
|
this.tag = document.createElement("dx-ref-tag");
|
1477
|
-
this.tag.classList.add("
|
1476
|
+
this.tag.classList.add("cm-ref-tag");
|
1478
1477
|
this.tag.appendChild(button);
|
1479
1478
|
container.appendChild(this.tag);
|
1480
1479
|
container.addEventListener("scroll", this.scheduleUpdate.bind(this));
|
1481
1480
|
this.scheduleUpdate();
|
1482
1481
|
}
|
1483
1482
|
update(update2) {
|
1483
|
+
this.tag.dataset.focused = update2.view.hasFocus ? "true" : "false";
|
1484
|
+
if (!update2.view.hasFocus) {
|
1485
|
+
return;
|
1486
|
+
}
|
1484
1487
|
if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(openEffect)))) {
|
1485
1488
|
this.tag.style.display = "none";
|
1489
|
+
this.tag.classList.add("opacity-10");
|
1486
1490
|
} else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
|
1487
1491
|
this.tag.style.display = "block";
|
1488
|
-
} else if (update2.
|
1492
|
+
} else if (update2.docChanged || update2.focusChanged || update2.geometryChanged || update2.selectionSet || update2.viewportChanged) {
|
1489
1493
|
this.scheduleUpdate();
|
1490
1494
|
}
|
1491
1495
|
}
|
@@ -1517,6 +1521,25 @@ var floatingMenu = (options = {}) => [
|
|
1517
1521
|
cancelAnimationFrame(this.rafId);
|
1518
1522
|
}
|
1519
1523
|
}
|
1524
|
+
}),
|
1525
|
+
EditorView7.theme({
|
1526
|
+
".cm-ref-tag": {
|
1527
|
+
position: "fixed",
|
1528
|
+
padding: "0",
|
1529
|
+
border: "none",
|
1530
|
+
transition: "opacity 0.3s ease-in-out",
|
1531
|
+
opacity: 0.1
|
1532
|
+
},
|
1533
|
+
".cm-ref-tag button": {
|
1534
|
+
display: "grid",
|
1535
|
+
alignItems: "center",
|
1536
|
+
justifyContent: "center",
|
1537
|
+
width: "2rem",
|
1538
|
+
height: "2rem"
|
1539
|
+
},
|
1540
|
+
'.cm-ref-tag[data-focused="true"]': {
|
1541
|
+
opacity: 1
|
1542
|
+
}
|
1520
1543
|
})
|
1521
1544
|
];
|
1522
1545
|
|
@@ -1606,7 +1629,7 @@ var matchCompletion = (completion, word) => {
|
|
1606
1629
|
// packages/ui/react-ui-editor/src/extensions/comments.ts
|
1607
1630
|
import { invertedEffects } from "@codemirror/commands";
|
1608
1631
|
import { StateEffect as StateEffect3, StateField as StateField3 } from "@codemirror/state";
|
1609
|
-
import { hoverTooltip, keymap as keymap6, Decoration as Decoration5, EditorView as
|
1632
|
+
import { hoverTooltip, keymap as keymap6, Decoration as Decoration5, EditorView as EditorView9, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
|
1610
1633
|
import sortBy from "lodash.sortby";
|
1611
1634
|
import { useEffect } from "react";
|
1612
1635
|
import { debounce as debounce2 } from "@dxos/async";
|
@@ -1615,7 +1638,7 @@ import { isNonNullable } from "@dxos/util";
|
|
1615
1638
|
|
1616
1639
|
// packages/ui/react-ui-editor/src/extensions/selection.ts
|
1617
1640
|
import { Transaction } from "@codemirror/state";
|
1618
|
-
import { EditorView as
|
1641
|
+
import { EditorView as EditorView8, keymap as keymap5 } from "@codemirror/view";
|
1619
1642
|
import { debounce } from "@dxos/async";
|
1620
1643
|
import { invariant as invariant3 } from "@dxos/invariant";
|
1621
1644
|
import { isNotFalsy } from "@dxos/util";
|
@@ -1626,7 +1649,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1626
1649
|
return {
|
1627
1650
|
selection,
|
1628
1651
|
scrollIntoView: !scrollTo,
|
1629
|
-
effects: scrollTo ?
|
1652
|
+
effects: scrollTo ? EditorView8.scrollIntoView(scrollTo, {
|
1630
1653
|
yMargin: 96
|
1631
1654
|
}) : void 0,
|
1632
1655
|
annotations: Transaction.userEvent.of(stateRestoreAnnotation)
|
@@ -1668,7 +1691,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
1668
1691
|
// setStateDebounced(id, {});
|
1669
1692
|
// },
|
1670
1693
|
// }),
|
1671
|
-
|
1694
|
+
EditorView8.updateListener.of(({ view, transactions }) => {
|
1672
1695
|
const id = view.state.facet(documentId);
|
1673
1696
|
if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
|
1674
1697
|
return;
|
@@ -1749,7 +1772,7 @@ var commentsState = StateField3.define({
|
|
1749
1772
|
return value;
|
1750
1773
|
}
|
1751
1774
|
});
|
1752
|
-
var styles2 =
|
1775
|
+
var styles2 = EditorView9.theme({
|
1753
1776
|
".cm-comment, .cm-comment-current": {
|
1754
1777
|
margin: "0 -3px",
|
1755
1778
|
padding: "3px",
|
@@ -1769,7 +1792,7 @@ var createCommentMark = (id, isCurrent) => Decoration5.mark({
|
|
1769
1792
|
"data-comment-id": id
|
1770
1793
|
}
|
1771
1794
|
});
|
1772
|
-
var commentsDecorations =
|
1795
|
+
var commentsDecorations = EditorView9.decorations.compute([
|
1773
1796
|
commentsState
|
1774
1797
|
], (state) => {
|
1775
1798
|
const { selection: { current }, comments: comments2 } = state.field(commentsState);
|
@@ -1792,7 +1815,7 @@ var commentsDecorations = EditorView8.decorations.compute([
|
|
1792
1815
|
return Decoration5.set(decorations2);
|
1793
1816
|
});
|
1794
1817
|
var commentClickedEffect = StateEffect3.define();
|
1795
|
-
var handleCommentClick =
|
1818
|
+
var handleCommentClick = EditorView9.domEventHandlers({
|
1796
1819
|
click: (event, view) => {
|
1797
1820
|
let target = event.target;
|
1798
1821
|
const editorRoot = view.dom;
|
@@ -1831,7 +1854,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1831
1854
|
}
|
1832
1855
|
};
|
1833
1856
|
return [
|
1834
|
-
|
1857
|
+
EditorView9.domEventHandlers({
|
1835
1858
|
cut: handleTrack,
|
1836
1859
|
copy: handleTrack
|
1837
1860
|
}),
|
@@ -1853,7 +1876,7 @@ var trackPastedComments = (onUpdate) => {
|
|
1853
1876
|
return effects;
|
1854
1877
|
}),
|
1855
1878
|
// Handle paste or the undo of comment deletion.
|
1856
|
-
|
1879
|
+
EditorView9.updateListener.of((update2) => {
|
1857
1880
|
const restore = [];
|
1858
1881
|
for (let i = 0; i < update2.transactions.length; i++) {
|
1859
1882
|
const tr = update2.transactions[i];
|
@@ -1995,7 +2018,7 @@ var comments = (options = {}) => {
|
|
1995
2018
|
//
|
1996
2019
|
// Track deleted ranges and update ranges for decorations.
|
1997
2020
|
//
|
1998
|
-
|
2021
|
+
EditorView9.updateListener.of(({ view, state, changes }) => {
|
1999
2022
|
let mod = false;
|
2000
2023
|
const { comments: comments2, ...value } = state.field(commentsState);
|
2001
2024
|
changes.iterChanges((from, to, from2, to2) => {
|
@@ -2027,7 +2050,7 @@ var comments = (options = {}) => {
|
|
2027
2050
|
//
|
2028
2051
|
// Track selection/proximity.
|
2029
2052
|
//
|
2030
|
-
|
2053
|
+
EditorView9.updateListener.of(({ view, state }) => {
|
2031
2054
|
let min = Infinity;
|
2032
2055
|
const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
|
2033
2056
|
const { head } = state.selection.main;
|
@@ -2081,7 +2104,7 @@ var scrollThreadIntoView = (view, id, center = true) => {
|
|
2081
2104
|
anchor: range.from
|
2082
2105
|
} : void 0,
|
2083
2106
|
effects: [
|
2084
|
-
needsScroll ?
|
2107
|
+
needsScroll ? EditorView9.scrollIntoView(range.from, center ? {
|
2085
2108
|
y: "center"
|
2086
2109
|
} : void 0) : [],
|
2087
2110
|
needsSelectionUpdate ? setSelection.of({
|
@@ -2145,8 +2168,8 @@ var debugNodeLogger = (log9 = console.log) => {
|
|
2145
2168
|
};
|
2146
2169
|
|
2147
2170
|
// packages/ui/react-ui-editor/src/extensions/dnd.ts
|
2148
|
-
import { dropCursor, EditorView as
|
2149
|
-
var styles3 =
|
2171
|
+
import { dropCursor, EditorView as EditorView10 } from "@codemirror/view";
|
2172
|
+
var styles3 = EditorView10.theme({
|
2150
2173
|
".cm-dropCursor": {
|
2151
2174
|
borderLeft: "2px solid var(--dx-accentText)",
|
2152
2175
|
color: "var(--dx-accentText)",
|
@@ -2160,7 +2183,7 @@ var dropFile = (options = {}) => {
|
|
2160
2183
|
return [
|
2161
2184
|
styles3,
|
2162
2185
|
dropCursor(),
|
2163
|
-
|
2186
|
+
EditorView10.domEventHandlers({
|
2164
2187
|
drop: (event, view) => {
|
2165
2188
|
event.preventDefault();
|
2166
2189
|
const files = event.dataTransfer?.files;
|
@@ -2187,7 +2210,7 @@ import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@cod
|
|
2187
2210
|
import { searchKeymap } from "@codemirror/search";
|
2188
2211
|
import { EditorState } from "@codemirror/state";
|
2189
2212
|
import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
|
2190
|
-
import { EditorView as
|
2213
|
+
import { EditorView as EditorView12, ViewPlugin as ViewPlugin8, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap7, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
|
2191
2214
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
2192
2215
|
import merge from "lodash.merge";
|
2193
2216
|
import { generateName } from "@dxos/display-name";
|
@@ -2196,7 +2219,7 @@ import { hexToHue, isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
2196
2219
|
|
2197
2220
|
// packages/ui/react-ui-editor/src/extensions/focus.ts
|
2198
2221
|
import { StateEffect as StateEffect4, StateField as StateField5 } from "@codemirror/state";
|
2199
|
-
import { EditorView as
|
2222
|
+
import { EditorView as EditorView11 } from "@codemirror/view";
|
2200
2223
|
var focusEffect = StateEffect4.define();
|
2201
2224
|
var focusField = StateField5.define({
|
2202
2225
|
create: () => false,
|
@@ -2211,7 +2234,7 @@ var focusField = StateField5.define({
|
|
2211
2234
|
});
|
2212
2235
|
var focus = [
|
2213
2236
|
focusField,
|
2214
|
-
|
2237
|
+
EditorView11.domEventHandlers({
|
2215
2238
|
focus: (event, view) => {
|
2216
2239
|
setTimeout(() => view.dispatch({
|
2217
2240
|
effects: focusEffect.of(true)
|
@@ -2490,7 +2513,7 @@ var createBasicExtensions = (_props) => {
|
|
2490
2513
|
const props = defaultsDeep2({}, _props, defaultBasicOptions);
|
2491
2514
|
return [
|
2492
2515
|
// NOTE: Doesn't catch errors in keymap functions.
|
2493
|
-
|
2516
|
+
EditorView12.exceptionSink.of((err) => {
|
2494
2517
|
log5.catch(err, void 0, {
|
2495
2518
|
F: __dxlog_file8,
|
2496
2519
|
L: 98,
|
@@ -2505,12 +2528,12 @@ var createBasicExtensions = (_props) => {
|
|
2505
2528
|
props.drawSelection && drawSelection({
|
2506
2529
|
cursorBlinkRate: 1200
|
2507
2530
|
}),
|
2508
|
-
props.editable !== void 0 &&
|
2531
|
+
props.editable !== void 0 && EditorView12.editable.of(props.editable),
|
2509
2532
|
props.focus && focus,
|
2510
2533
|
props.highlightActiveLine && highlightActiveLine(),
|
2511
2534
|
props.history && history(),
|
2512
2535
|
props.lineNumbers && lineNumbers(),
|
2513
|
-
props.lineWrapping &&
|
2536
|
+
props.lineWrapping && EditorView12.lineWrapping,
|
2514
2537
|
props.placeholder && placeholder(props.placeholder),
|
2515
2538
|
props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
|
2516
2539
|
props.scrollPastEnd && scrollPastEnd(),
|
@@ -2547,14 +2570,14 @@ var defaultThemeSlots = {
|
|
2547
2570
|
var createThemeExtensions = ({ themeMode, styles: styles4, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
|
2548
2571
|
const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
|
2549
2572
|
return [
|
2550
|
-
|
2551
|
-
|
2573
|
+
EditorView12.darkTheme.of(themeMode === "dark"),
|
2574
|
+
EditorView12.baseTheme(styles4 ? merge({}, defaultTheme, styles4) : defaultTheme),
|
2552
2575
|
// https://github.com/codemirror/theme-one-dark
|
2553
2576
|
_syntaxHighlighting && (themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle)),
|
2554
|
-
slots.editor?.className &&
|
2577
|
+
slots.editor?.className && EditorView12.editorAttributes.of({
|
2555
2578
|
class: slots.editor.className
|
2556
2579
|
}),
|
2557
|
-
slots.content?.className &&
|
2580
|
+
slots.content?.className && EditorView12.contentAttributes.of({
|
2558
2581
|
class: slots.content.className
|
2559
2582
|
}),
|
2560
2583
|
slots.scroll?.className && ViewPlugin8.fromClass(class {
|
@@ -2588,7 +2611,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
|
|
2588
2611
|
|
2589
2612
|
// packages/ui/react-ui-editor/src/extensions/folding.tsx
|
2590
2613
|
import { codeFolding, foldGutter } from "@codemirror/language";
|
2591
|
-
import { EditorView as
|
2614
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
2592
2615
|
import React2 from "react";
|
2593
2616
|
import { Icon } from "@dxos/react-ui";
|
2594
2617
|
var folding = (_props = {}) => [
|
@@ -2612,7 +2635,7 @@ var folding = (_props = {}) => [
|
|
2612
2635
|
}));
|
2613
2636
|
}
|
2614
2637
|
}),
|
2615
|
-
|
2638
|
+
EditorView13.theme({
|
2616
2639
|
".cm-foldGutter": {
|
2617
2640
|
opacity: 0.3,
|
2618
2641
|
transition: "opacity 0.3s",
|
@@ -2669,14 +2692,14 @@ var schemaLinter = (validate) => (view) => {
|
|
2669
2692
|
};
|
2670
2693
|
|
2671
2694
|
// packages/ui/react-ui-editor/src/extensions/listener.ts
|
2672
|
-
import { EditorView as
|
2695
|
+
import { EditorView as EditorView14 } from "@codemirror/view";
|
2673
2696
|
var listener = ({ onFocus, onChange }) => {
|
2674
2697
|
const extensions = [];
|
2675
|
-
onFocus && extensions.push(
|
2698
|
+
onFocus && extensions.push(EditorView14.focusChangeEffect.of((_, focusing) => {
|
2676
2699
|
onFocus(focusing);
|
2677
2700
|
return null;
|
2678
2701
|
}));
|
2679
|
-
onChange && extensions.push(
|
2702
|
+
onChange && extensions.push(EditorView14.updateListener.of((update2) => {
|
2680
2703
|
onChange(update2.state.doc.toString(), update2.state.facet(documentId));
|
2681
2704
|
}));
|
2682
2705
|
return extensions;
|
@@ -2686,7 +2709,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
2686
2709
|
import { snippet } from "@codemirror/autocomplete";
|
2687
2710
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
2688
2711
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
2689
|
-
import { EditorView as
|
2712
|
+
import { EditorView as EditorView15, keymap as keymap8 } from "@codemirror/view";
|
2690
2713
|
import { useMemo as useMemo2 } from "react";
|
2691
2714
|
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;
|
2692
2715
|
var Inline = /* @__PURE__ */ function(Inline2) {
|
@@ -3775,7 +3798,7 @@ var getFormatting = (state) => {
|
|
3775
3798
|
};
|
3776
3799
|
};
|
3777
3800
|
var useFormattingState = (state) => {
|
3778
|
-
return useMemo2(() =>
|
3801
|
+
return useMemo2(() => EditorView15.updateListener.of((update2) => {
|
3779
3802
|
if (update2.docChanged || update2.selectionSet) {
|
3780
3803
|
Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
|
3781
3804
|
state[key] = active;
|
@@ -4088,7 +4111,7 @@ var convertTreeToJson = (state) => {
|
|
4088
4111
|
// packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
|
4089
4112
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
4090
4113
|
import { RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect5 } from "@codemirror/state";
|
4091
|
-
import { EditorView as
|
4114
|
+
import { EditorView as EditorView19, Decoration as Decoration8, WidgetType as WidgetType5, ViewPlugin as ViewPlugin10 } from "@codemirror/view";
|
4092
4115
|
import { invariant as invariant4 } from "@dxos/invariant";
|
4093
4116
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
4094
4117
|
|
@@ -4239,7 +4262,7 @@ var getValidUrl = (str) => {
|
|
4239
4262
|
// packages/ui/react-ui-editor/src/extensions/markdown/image.ts
|
4240
4263
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
4241
4264
|
import { StateField as StateField7 } from "@codemirror/state";
|
4242
|
-
import { Decoration as Decoration6, EditorView as
|
4265
|
+
import { Decoration as Decoration6, EditorView as EditorView16, WidgetType as WidgetType3 } from "@codemirror/view";
|
4243
4266
|
var image = (_options = {}) => {
|
4244
4267
|
return [
|
4245
4268
|
StateField7.define({
|
@@ -4267,7 +4290,7 @@ var image = (_options = {}) => {
|
|
4267
4290
|
add: buildDecorations(from, to, tr.state)
|
4268
4291
|
});
|
4269
4292
|
},
|
4270
|
-
provide: (field) =>
|
4293
|
+
provide: (field) => EditorView16.decorations.from(field)
|
4271
4294
|
})
|
4272
4295
|
];
|
4273
4296
|
};
|
@@ -4326,10 +4349,10 @@ var ImageWidget = class extends WidgetType3 {
|
|
4326
4349
|
};
|
4327
4350
|
|
4328
4351
|
// packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
|
4329
|
-
import { EditorView as
|
4352
|
+
import { EditorView as EditorView17 } from "@codemirror/view";
|
4330
4353
|
var bulletListIndentationWidth = 24;
|
4331
4354
|
var orderedListIndentationWidth = 36;
|
4332
|
-
var formattingStyles =
|
4355
|
+
var formattingStyles = EditorView17.theme({
|
4333
4356
|
/**
|
4334
4357
|
* Horizontal rule.
|
4335
4358
|
*/
|
@@ -4451,12 +4474,12 @@ var formattingStyles = EditorView16.theme({
|
|
4451
4474
|
// packages/ui/react-ui-editor/src/extensions/markdown/table.ts
|
4452
4475
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
4453
4476
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
4454
|
-
import { Decoration as Decoration7, EditorView as
|
4477
|
+
import { Decoration as Decoration7, EditorView as EditorView18, WidgetType as WidgetType4 } from "@codemirror/view";
|
4455
4478
|
var table = (options = {}) => {
|
4456
4479
|
return StateField8.define({
|
4457
4480
|
create: (state) => update(state, options),
|
4458
4481
|
update: (_, tr) => update(tr.state, options),
|
4459
|
-
provide: (field) =>
|
4482
|
+
provide: (field) => EditorView18.decorations.from(field)
|
4460
4483
|
});
|
4461
4484
|
};
|
4462
4485
|
var update = (state, _options) => {
|
@@ -4989,9 +5012,9 @@ var decorateMarkdown = (options = {}) => {
|
|
4989
5012
|
}
|
4990
5013
|
}, {
|
4991
5014
|
provide: (plugin) => [
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
5015
|
+
EditorView19.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
|
5016
|
+
EditorView19.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
|
5017
|
+
EditorView19.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration8.none)
|
4995
5018
|
]
|
4996
5019
|
}),
|
4997
5020
|
image(),
|
@@ -5127,11 +5150,6 @@ var InputModeExtensions = {
|
|
5127
5150
|
]
|
5128
5151
|
};
|
5129
5152
|
|
5130
|
-
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5131
|
-
import { Prec as Prec2 } from "@codemirror/state";
|
5132
|
-
import { Decoration as Decoration9, EditorView as EditorView19, ViewPlugin as ViewPlugin12 } from "@codemirror/view";
|
5133
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
5134
|
-
|
5135
5153
|
// packages/ui/react-ui-editor/src/extensions/outliner/commands.ts
|
5136
5154
|
import { indentMore } from "@codemirror/commands";
|
5137
5155
|
import { getIndentUnit } from "@codemirror/language";
|
@@ -5562,9 +5580,26 @@ var moveItemUp = (view) => {
|
|
5562
5580
|
}
|
5563
5581
|
return true;
|
5564
5582
|
};
|
5583
|
+
var deleteItem = (view) => {
|
5584
|
+
const tree = view.state.facet(treeFacet);
|
5585
|
+
const pos = getSelection(view.state).from;
|
5586
|
+
const current = tree.find(pos);
|
5587
|
+
if (current) {
|
5588
|
+
view.dispatch({
|
5589
|
+
selection: EditorSelection3.cursor(current.lineRange.from),
|
5590
|
+
changes: [
|
5591
|
+
{
|
5592
|
+
from: current.lineRange.from,
|
5593
|
+
to: Math.min(current.lineRange.to + 1, view.state.doc.length)
|
5594
|
+
}
|
5595
|
+
]
|
5596
|
+
});
|
5597
|
+
}
|
5598
|
+
return true;
|
5599
|
+
};
|
5565
5600
|
var toggleTask = (view) => {
|
5566
|
-
const pos = getSelection(view.state)?.from;
|
5567
5601
|
const tree = view.state.facet(treeFacet);
|
5602
|
+
const pos = getSelection(view.state)?.from;
|
5568
5603
|
const current = tree.find(pos);
|
5569
5604
|
if (current) {
|
5570
5605
|
const type = current.type === "task" ? "bullet" : "task";
|
@@ -5669,14 +5704,28 @@ var commands = () => keymap11.of([
|
|
5669
5704
|
run: moveItemUp
|
5670
5705
|
},
|
5671
5706
|
//
|
5707
|
+
// Delete.
|
5708
|
+
//
|
5709
|
+
{
|
5710
|
+
key: "Mod-Backspace",
|
5711
|
+
preventDefault: true,
|
5712
|
+
run: deleteItem
|
5713
|
+
},
|
5714
|
+
//
|
5672
5715
|
// Misc.
|
5673
5716
|
//
|
5674
5717
|
{
|
5675
5718
|
key: "Alt-t",
|
5719
|
+
preventDefault: true,
|
5676
5720
|
run: toggleTask
|
5677
5721
|
}
|
5678
5722
|
]);
|
5679
5723
|
|
5724
|
+
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5725
|
+
import { Prec as Prec2 } from "@codemirror/state";
|
5726
|
+
import { Decoration as Decoration9, EditorView as EditorView20, ViewPlugin as ViewPlugin12 } from "@codemirror/view";
|
5727
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
5728
|
+
|
5680
5729
|
// packages/ui/react-ui-editor/src/extensions/outliner/editor.ts
|
5681
5730
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
5682
5731
|
import { ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
@@ -5770,6 +5819,12 @@ var editor = () => [
|
|
5770
5819
|
const line = tr.startState.doc.lineAt(fromA);
|
5771
5820
|
const match = line.text.match(LIST_ITEM_REGEX);
|
5772
5821
|
if (match) {
|
5822
|
+
const startTree = tr.startState.facet(treeFacet);
|
5823
|
+
const startItem = startTree.find(tr.startState.selection.main.from);
|
5824
|
+
const deleteLine = fromA === startItem?.lineRange.from && toA === startItem?.lineRange.to + 1;
|
5825
|
+
if (deleteLine) {
|
5826
|
+
return;
|
5827
|
+
}
|
5773
5828
|
const currentItem = tree.find(tr.state.selection.main.from);
|
5774
5829
|
if (!currentItem?.contentRange) {
|
5775
5830
|
cancel = true;
|
@@ -5827,7 +5882,7 @@ var editor = () => [
|
|
5827
5882
|
}
|
5828
5883
|
}, {
|
5829
5884
|
F: __dxlog_file12,
|
5830
|
-
L:
|
5885
|
+
L: 164,
|
5831
5886
|
S: void 0,
|
5832
5887
|
C: (f, a) => f(...a)
|
5833
5888
|
});
|
@@ -5838,7 +5893,7 @@ var editor = () => [
|
|
5838
5893
|
changes
|
5839
5894
|
}, {
|
5840
5895
|
F: __dxlog_file12,
|
5841
|
-
L:
|
5896
|
+
L: 175,
|
5842
5897
|
S: void 0,
|
5843
5898
|
C: (f, a) => f(...a)
|
5844
5899
|
});
|
@@ -5850,7 +5905,7 @@ var editor = () => [
|
|
5850
5905
|
} else if (cancel) {
|
5851
5906
|
log7("cancel", void 0, {
|
5852
5907
|
F: __dxlog_file12,
|
5853
|
-
L:
|
5908
|
+
L: 178,
|
5854
5909
|
S: void 0,
|
5855
5910
|
C: (f, a) => f(...a)
|
5856
5911
|
});
|
@@ -5861,7 +5916,7 @@ var editor = () => [
|
|
5861
5916
|
];
|
5862
5917
|
|
5863
5918
|
// packages/ui/react-ui-editor/src/extensions/outliner/outliner.ts
|
5864
|
-
var outliner = () => [
|
5919
|
+
var outliner = (options = {}) => [
|
5865
5920
|
// Commands.
|
5866
5921
|
Prec2.highest(commands()),
|
5867
5922
|
// Selection.
|
@@ -5873,17 +5928,17 @@ var outliner = () => [
|
|
5873
5928
|
// Floating menu.
|
5874
5929
|
floatingMenu(),
|
5875
5930
|
// Line decorations.
|
5876
|
-
decorations(),
|
5931
|
+
decorations(options),
|
5877
5932
|
// Default markdown decorations.
|
5878
5933
|
decorateMarkdown({
|
5879
5934
|
listPaddingLeft: 8
|
5880
5935
|
}),
|
5881
5936
|
// Researve space for menu.
|
5882
|
-
|
5937
|
+
EditorView20.contentAttributes.of({
|
5883
5938
|
class: "is-full !mr-[3rem]"
|
5884
5939
|
})
|
5885
5940
|
];
|
5886
|
-
var decorations = () => [
|
5941
|
+
var decorations = (options) => [
|
5887
5942
|
ViewPlugin12.fromClass(class {
|
5888
5943
|
constructor(view) {
|
5889
5944
|
this.decorations = Decoration9.none;
|
@@ -5919,7 +5974,7 @@ var decorations = () => [
|
|
5919
5974
|
decorations: (v) => v.decorations
|
5920
5975
|
}),
|
5921
5976
|
// Theme.
|
5922
|
-
|
5977
|
+
EditorView20.theme(Object.assign({
|
5923
5978
|
".cm-list-item": {
|
5924
5979
|
borderLeftWidth: "1px",
|
5925
5980
|
borderRightWidth: "1px",
|
@@ -5934,29 +5989,29 @@ var decorations = () => [
|
|
5934
5989
|
borderTopLeftRadius: "4px",
|
5935
5990
|
borderTopRightRadius: "4px",
|
5936
5991
|
paddingTop: "4px",
|
5937
|
-
marginTop: "
|
5992
|
+
marginTop: "2px"
|
5938
5993
|
},
|
5939
5994
|
".cm-list-item-end": {
|
5940
5995
|
borderBottomWidth: "1px",
|
5941
5996
|
borderBottomLeftRadius: "4px",
|
5942
5997
|
borderBottomRightRadius: "4px",
|
5943
5998
|
paddingBottom: "4px",
|
5944
|
-
marginBottom: "
|
5999
|
+
marginBottom: "2px"
|
5945
6000
|
},
|
5946
6001
|
".cm-list-item-selected": {
|
5947
|
-
borderColor: "var(--dx-separator)"
|
6002
|
+
borderColor: options.showSelected ? "var(--dx-separator)" : void 0
|
5948
6003
|
},
|
5949
6004
|
".cm-list-item-focused": {
|
5950
6005
|
borderColor: "var(--dx-accentFocusIndicator)"
|
5951
6006
|
}
|
5952
|
-
})
|
6007
|
+
}))
|
5953
6008
|
];
|
5954
6009
|
|
5955
6010
|
// packages/ui/react-ui-editor/src/extensions/preview/preview.ts
|
5956
6011
|
import "@dxos/lit-ui/dx-ref-tag.pcss";
|
5957
6012
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
5958
6013
|
import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField10 } from "@codemirror/state";
|
5959
|
-
import { Decoration as Decoration10, EditorView as
|
6014
|
+
import { Decoration as Decoration10, EditorView as EditorView21, WidgetType as WidgetType6 } from "@codemirror/view";
|
5960
6015
|
var preview = (options = {}) => {
|
5961
6016
|
return [
|
5962
6017
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
@@ -5965,11 +6020,11 @@ var preview = (options = {}) => {
|
|
5965
6020
|
create: (state) => buildDecorations3(state, options),
|
5966
6021
|
update: (_, tr) => buildDecorations3(tr.state, options),
|
5967
6022
|
provide: (field) => [
|
5968
|
-
|
5969
|
-
|
6023
|
+
EditorView21.decorations.from(field),
|
6024
|
+
EditorView21.atomicRanges.of((view) => view.state.field(field))
|
5970
6025
|
]
|
5971
6026
|
}),
|
5972
|
-
|
6027
|
+
EditorView21.theme({
|
5973
6028
|
".cm-preview-block": {
|
5974
6029
|
marginLeft: "-1rem",
|
5975
6030
|
marginRight: "-1rem",
|
@@ -6462,7 +6517,7 @@ var createViewMode = (state, onViewModeChange) => {
|
|
6462
6517
|
};
|
6463
6518
|
|
6464
6519
|
// packages/ui/react-ui-editor/src/defaults.ts
|
6465
|
-
import { EditorView as
|
6520
|
+
import { EditorView as EditorView22 } from "@codemirror/view";
|
6466
6521
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
6467
6522
|
var editorWidth = "!mli-auto is-full max-is-[min(50rem,100%-4rem)]";
|
6468
6523
|
var editorSlots = {
|
@@ -6473,12 +6528,12 @@ var editorSlots = {
|
|
6473
6528
|
className: editorWidth
|
6474
6529
|
}
|
6475
6530
|
};
|
6476
|
-
var editorGutter =
|
6531
|
+
var editorGutter = EditorView22.theme({
|
6477
6532
|
".cm-gutters": {
|
6478
6533
|
paddingRight: "1rem"
|
6479
6534
|
}
|
6480
6535
|
});
|
6481
|
-
var editorMonospace =
|
6536
|
+
var editorMonospace = EditorView22.theme({
|
6482
6537
|
".cm-content": {
|
6483
6538
|
fontFamily: fontMono
|
6484
6539
|
}
|
@@ -6730,7 +6785,7 @@ var RefDropdownMenu = {
|
|
6730
6785
|
|
6731
6786
|
// packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
|
6732
6787
|
import { EditorState as EditorState3 } from "@codemirror/state";
|
6733
|
-
import { EditorView as
|
6788
|
+
import { EditorView as EditorView23 } from "@codemirror/view";
|
6734
6789
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
6735
6790
|
import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef3, useState as useState3 } from "react";
|
6736
6791
|
import { log as log8 } from "@dxos/log";
|
@@ -6774,7 +6829,7 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6774
6829
|
id && documentId.of(id),
|
6775
6830
|
extensions,
|
6776
6831
|
// NOTE: This doesn't catch errors in keymap functions.
|
6777
|
-
|
6832
|
+
EditorView23.exceptionSink.of((err) => {
|
6778
6833
|
log8.catch(err, void 0, {
|
6779
6834
|
F: __dxlog_file13,
|
6780
6835
|
L: 98,
|
@@ -6784,10 +6839,10 @@ var useTextEditor = (props = {}, deps = []) => {
|
|
6784
6839
|
})
|
6785
6840
|
].filter(isNotFalsy4)
|
6786
6841
|
});
|
6787
|
-
view2 = new
|
6842
|
+
view2 = new EditorView23({
|
6788
6843
|
parent: parentRef.current,
|
6789
6844
|
state,
|
6790
|
-
scrollTo: scrollTo ?
|
6845
|
+
scrollTo: scrollTo ? EditorView23.scrollIntoView(scrollTo, {
|
6791
6846
|
yMargin: 96
|
6792
6847
|
}) : void 0,
|
6793
6848
|
dispatchTransactions: debug ? debugDispatcher : void 0
|
@@ -6886,7 +6941,7 @@ export {
|
|
6886
6941
|
EditorInputModes,
|
6887
6942
|
EditorState4 as EditorState,
|
6888
6943
|
EditorToolbar,
|
6889
|
-
|
6944
|
+
EditorView24 as EditorView,
|
6890
6945
|
EditorViewMode,
|
6891
6946
|
EditorViewModes,
|
6892
6947
|
Inline,
|
@@ -6915,6 +6970,7 @@ export {
|
|
6915
6970
|
closeEffect,
|
6916
6971
|
command,
|
6917
6972
|
commandKeyBindings,
|
6973
|
+
commands,
|
6918
6974
|
commentClickedEffect,
|
6919
6975
|
comments,
|
6920
6976
|
commentsState,
|
@@ -6937,6 +6993,7 @@ export {
|
|
6937
6993
|
debugTree,
|
6938
6994
|
decorateMarkdown,
|
6939
6995
|
defaultOptions,
|
6996
|
+
deleteItem,
|
6940
6997
|
documentId,
|
6941
6998
|
dropFile,
|
6942
6999
|
editorGutter,
|
@@ -6956,6 +7013,8 @@ export {
|
|
6956
7013
|
getListItemContent,
|
6957
7014
|
getRange,
|
6958
7015
|
image,
|
7016
|
+
indentItemLess,
|
7017
|
+
indentItemMore,
|
6959
7018
|
insertTable,
|
6960
7019
|
itemToJSON,
|
6961
7020
|
keymap13 as keymap,
|
@@ -6968,6 +7027,8 @@ export {
|
|
6968
7027
|
markdownTagsExtensions,
|
6969
7028
|
matchCompletion,
|
6970
7029
|
mention,
|
7030
|
+
moveItemDown,
|
7031
|
+
moveItemUp,
|
6971
7032
|
openCommand,
|
6972
7033
|
openEffect,
|
6973
7034
|
outliner,
|
@@ -7004,6 +7065,7 @@ export {
|
|
7004
7065
|
toggleStrikethrough,
|
7005
7066
|
toggleStrong,
|
7006
7067
|
toggleStyle,
|
7068
|
+
toggleTask,
|
7007
7069
|
translations_default as translations,
|
7008
7070
|
traverse,
|
7009
7071
|
treeFacet,
|