@dxos/ui-editor 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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 +155 -117
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +155 -117
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/extensions/{autoscroll.d.ts → auto-scroll.d.ts} +4 -5
- package/dist/types/src/extensions/auto-scroll.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -2
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +1 -1
- package/dist/types/src/extensions/{scrolling.d.ts → smooth-scroll.d.ts} +1 -1
- package/dist/types/src/extensions/smooth-scroll.d.ts.map +1 -0
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -29
- package/src/extensions/auto-scroll.ts +205 -0
- package/src/extensions/index.ts +2 -2
- package/src/extensions/preview/preview.ts +7 -7
- package/src/extensions/{scrolling.ts → smooth-scroll.ts} +12 -6
- package/src/extensions/tags/xml-tags.ts +1 -1
- package/src/styles/theme.ts +15 -2
- package/dist/types/src/extensions/autoscroll.d.ts.map +0 -1
- package/dist/types/src/extensions/scrolling.d.ts.map +0 -1
- package/src/extensions/autoscroll.ts +0 -165
|
@@ -501,13 +501,12 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
501
501
|
];
|
|
502
502
|
};
|
|
503
503
|
|
|
504
|
-
// src/extensions/
|
|
505
|
-
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
504
|
+
// src/extensions/auto-scroll.ts
|
|
506
505
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
507
|
-
import {
|
|
506
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
508
507
|
import { Domino } from "@dxos/ui";
|
|
509
508
|
|
|
510
|
-
// src/extensions/
|
|
509
|
+
// src/extensions/smooth-scroll.ts
|
|
511
510
|
import { StateEffect } from "@codemirror/state";
|
|
512
511
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
513
512
|
var scrollToLineEffect = StateEffect.define();
|
|
@@ -525,8 +524,8 @@ var smoothScroll = ({ offset = 0, position = "start" } = {}) => {
|
|
|
525
524
|
*/
|
|
526
525
|
scrollToLine(lineNumber, options) {
|
|
527
526
|
const { offset: animOffset = 0, position: animPosition, behavior } = options;
|
|
528
|
-
const doc = this.view.state.doc;
|
|
529
527
|
const scroller = this.view.scrollDOM;
|
|
528
|
+
const doc = this.view.state.doc;
|
|
530
529
|
const targetLine = Math.max(0, lineNumber - 1);
|
|
531
530
|
if (behavior === "instant") {
|
|
532
531
|
requestAnimationFrame(() => {
|
|
@@ -539,6 +538,10 @@ var smoothScroll = ({ offset = 0, position = "start" } = {}) => {
|
|
|
539
538
|
});
|
|
540
539
|
return;
|
|
541
540
|
}
|
|
541
|
+
if (lineNumber === -1) {
|
|
542
|
+
this.animateScroll(scroller, scroller.scrollHeight - scroller.clientHeight);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
542
545
|
if (targetLine >= doc.lines) {
|
|
543
546
|
const targetScrollTop2 = scroller.scrollHeight - scroller.clientHeight + (animOffset || 0);
|
|
544
547
|
this.animateScroll(scroller, targetScrollTop2);
|
|
@@ -568,10 +571,12 @@ var smoothScroll = ({ offset = 0, position = "start" } = {}) => {
|
|
|
568
571
|
if (Math.abs(targetScrollTop - element.scrollTop) < 1) {
|
|
569
572
|
return;
|
|
570
573
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
574
|
+
setTimeout(() => {
|
|
575
|
+
element.scrollTo({
|
|
576
|
+
top: targetScrollTop,
|
|
577
|
+
behavior: "smooth"
|
|
578
|
+
});
|
|
579
|
+
}, 100);
|
|
575
580
|
}
|
|
576
581
|
});
|
|
577
582
|
return [
|
|
@@ -605,88 +610,71 @@ var scrollToLine = (view, line, options) => {
|
|
|
605
610
|
});
|
|
606
611
|
};
|
|
607
612
|
|
|
608
|
-
// src/extensions/
|
|
609
|
-
var
|
|
610
|
-
var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDelay = 1e3, onAutoScroll } = {}) => {
|
|
613
|
+
// src/extensions/auto-scroll.ts
|
|
614
|
+
var autoScroll = ({ pinned = true, threshold = 100, throttleDelay = 500, onAutoScroll } = {}) => {
|
|
611
615
|
let buttonContainer;
|
|
612
|
-
let
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
isPinned = pin;
|
|
617
|
-
buttonContainer?.classList.toggle("opacity-0", pin);
|
|
618
|
-
};
|
|
619
|
-
const hideScrollbar = (view) => {
|
|
620
|
-
view.scrollDOM.classList.add("cm-hide-scrollbar");
|
|
621
|
-
clearTimeout(hideTimeout);
|
|
622
|
-
hideTimeout = setTimeout(() => {
|
|
623
|
-
view.scrollDOM.classList.remove("cm-hide-scrollbar");
|
|
624
|
-
}, 1e3);
|
|
616
|
+
let isPinned = pinned;
|
|
617
|
+
const setPinned = (pinned2) => {
|
|
618
|
+
buttonContainer?.classList.toggle("opacity-0", pinned2);
|
|
619
|
+
isPinned = pinned2;
|
|
625
620
|
};
|
|
626
621
|
const scrollToBottom = (view, behavior) => {
|
|
627
622
|
setPinned(true);
|
|
628
|
-
hideScrollbar(view);
|
|
629
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
630
623
|
view.dispatch({
|
|
631
|
-
selection: {
|
|
632
|
-
anchor: line.to,
|
|
633
|
-
head: line.to
|
|
634
|
-
},
|
|
635
624
|
effects: scrollToLineEffect.of({
|
|
636
|
-
line:
|
|
625
|
+
line: -1,
|
|
637
626
|
options: {
|
|
638
627
|
position: "end",
|
|
639
|
-
offset: threshold,
|
|
640
628
|
behavior
|
|
641
629
|
}
|
|
642
630
|
})
|
|
643
631
|
});
|
|
644
632
|
};
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}, 1e3);
|
|
651
|
-
const triggerUpdate = debounce((view) => scrollToBottom(view), throttleDelay);
|
|
633
|
+
const triggerUpdate = intervalUntilQuiet((view) => {
|
|
634
|
+
if (isPinned) {
|
|
635
|
+
scrollToBottom(view);
|
|
636
|
+
}
|
|
637
|
+
}, throttleDelay);
|
|
652
638
|
return [
|
|
653
639
|
// Update listener for logging when scrolling is needed.
|
|
654
|
-
EditorView5.updateListener.of(({ view,
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
640
|
+
EditorView5.updateListener.of(({ view, heightChanged, state }) => {
|
|
641
|
+
if (heightChanged) {
|
|
642
|
+
if (isPinned) {
|
|
643
|
+
const coords = view.coordsAtPos(view.state.doc.length);
|
|
644
|
+
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
645
|
+
const distanceFromBottom = coords ? scrollerRect.bottom - coords.bottom : 0;
|
|
646
|
+
if (distanceFromBottom < threshold) {
|
|
647
|
+
const shouldScroll = onAutoScroll?.({
|
|
648
|
+
view,
|
|
649
|
+
distanceFromBottom
|
|
650
|
+
}) ?? true;
|
|
651
|
+
if (shouldScroll) {
|
|
652
|
+
triggerUpdate(view);
|
|
653
|
+
}
|
|
654
|
+
} else if (distanceFromBottom < 0) {
|
|
655
|
+
setPinned(false);
|
|
659
656
|
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
664
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
665
|
-
const distanceFromBottom = coords ? scrollerRect.bottom - coords.bottom : 0;
|
|
666
|
-
if (autoScroll2 && distanceFromBottom < threshold) {
|
|
667
|
-
const shouldScroll = onAutoScroll?.({
|
|
668
|
-
view,
|
|
669
|
-
distanceFromBottom
|
|
670
|
-
}) ?? true;
|
|
671
|
-
if (shouldScroll) {
|
|
672
|
-
triggerUpdate(view);
|
|
657
|
+
} else {
|
|
658
|
+
if (state.doc.length === 0) {
|
|
659
|
+
setPinned(true);
|
|
673
660
|
}
|
|
674
|
-
} else if (distanceFromBottom < 0) {
|
|
675
|
-
setPinned(false);
|
|
676
661
|
}
|
|
677
662
|
}
|
|
678
663
|
}),
|
|
679
|
-
// Detect user scroll.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
664
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
665
|
+
ViewPlugin6.fromClass(class {
|
|
666
|
+
cleanup;
|
|
667
|
+
constructor(view) {
|
|
668
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, () => {
|
|
669
|
+
requestAnimationFrame(() => {
|
|
670
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
671
|
+
const atBottom = scrollHeight - scrollTop - clientHeight < threshold;
|
|
672
|
+
setPinned(atBottom);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
destroy() {
|
|
677
|
+
this.cleanup();
|
|
690
678
|
}
|
|
691
679
|
}),
|
|
692
680
|
// Scroll button.
|
|
@@ -706,15 +694,22 @@ var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDel
|
|
|
706
694
|
}),
|
|
707
695
|
// Styles.
|
|
708
696
|
EditorView5.theme({
|
|
709
|
-
".cm-
|
|
710
|
-
|
|
697
|
+
".cm-content": {
|
|
698
|
+
paddingBottom: `${threshold}px`
|
|
711
699
|
},
|
|
712
|
-
".cm-scroller
|
|
713
|
-
|
|
700
|
+
".cm-scroller": {
|
|
701
|
+
paddingBottom: "0"
|
|
714
702
|
},
|
|
715
703
|
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
716
704
|
display: "none"
|
|
717
705
|
},
|
|
706
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
707
|
+
background: "transparent",
|
|
708
|
+
transition: "background 0.15s"
|
|
709
|
+
},
|
|
710
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
711
|
+
background: "var(--dx-scrollbarThumb)"
|
|
712
|
+
},
|
|
718
713
|
".cm-scroll-button": {
|
|
719
714
|
position: "absolute",
|
|
720
715
|
bottom: "0.5rem",
|
|
@@ -723,6 +718,37 @@ var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDel
|
|
|
723
718
|
})
|
|
724
719
|
];
|
|
725
720
|
};
|
|
721
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
722
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
723
|
+
passive: true
|
|
724
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
725
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
726
|
+
onUserScroll();
|
|
727
|
+
}
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
function intervalUntilQuiet(fn, interval) {
|
|
731
|
+
let timer = null;
|
|
732
|
+
let quietTimer = null;
|
|
733
|
+
let latestArgs;
|
|
734
|
+
return (...args) => {
|
|
735
|
+
latestArgs = args;
|
|
736
|
+
if (quietTimer) {
|
|
737
|
+
clearTimeout(quietTimer);
|
|
738
|
+
}
|
|
739
|
+
quietTimer = setTimeout(() => {
|
|
740
|
+
if (timer) {
|
|
741
|
+
clearInterval(timer);
|
|
742
|
+
timer = null;
|
|
743
|
+
}
|
|
744
|
+
quietTimer = null;
|
|
745
|
+
}, interval);
|
|
746
|
+
if (!timer) {
|
|
747
|
+
fn(...latestArgs);
|
|
748
|
+
timer = setInterval(() => fn(...latestArgs), interval);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
726
752
|
|
|
727
753
|
// src/extensions/automerge/automerge.ts
|
|
728
754
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -768,10 +794,10 @@ var cursorConverter = (accessor) => ({
|
|
|
768
794
|
});
|
|
769
795
|
|
|
770
796
|
// src/extensions/automerge/defs.ts
|
|
771
|
-
import { Annotation, StateEffect as
|
|
797
|
+
import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
|
|
772
798
|
var getPath = (state, field) => state.field(field).path;
|
|
773
799
|
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
774
|
-
var updateHeadsEffect =
|
|
800
|
+
var updateHeadsEffect = StateEffect2.define({});
|
|
775
801
|
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
|
776
802
|
newHeads
|
|
777
803
|
});
|
|
@@ -1806,13 +1832,13 @@ var blocks = () => [
|
|
|
1806
1832
|
];
|
|
1807
1833
|
|
|
1808
1834
|
// src/extensions/bookmarks.ts
|
|
1809
|
-
import { Prec as Prec3, StateEffect as
|
|
1835
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1810
1836
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1811
1837
|
import { log as log5 } from "@dxos/log";
|
|
1812
1838
|
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1813
|
-
var addBookmark =
|
|
1814
|
-
var removeBookmark =
|
|
1815
|
-
var clearBookmarks =
|
|
1839
|
+
var addBookmark = StateEffect3.define();
|
|
1840
|
+
var removeBookmark = StateEffect3.define();
|
|
1841
|
+
var clearBookmarks = StateEffect3.define();
|
|
1816
1842
|
var bookmarks = () => {
|
|
1817
1843
|
return [
|
|
1818
1844
|
bookmarksField,
|
|
@@ -1876,17 +1902,17 @@ var bookmarksField = StateField2.define({
|
|
|
1876
1902
|
|
|
1877
1903
|
// src/extensions/comments.ts
|
|
1878
1904
|
import { invertedEffects } from "@codemirror/commands";
|
|
1879
|
-
import { StateEffect as
|
|
1905
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1880
1906
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1881
1907
|
import sortBy from "lodash.sortby";
|
|
1882
|
-
import { debounce as
|
|
1908
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1883
1909
|
import { log as log6 } from "@dxos/log";
|
|
1884
1910
|
import { isNonNullable } from "@dxos/util";
|
|
1885
1911
|
|
|
1886
1912
|
// src/extensions/selection.ts
|
|
1887
1913
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1888
1914
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1889
|
-
import { debounce
|
|
1915
|
+
import { debounce } from "@dxos/async";
|
|
1890
1916
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1891
1917
|
import { isTruthy } from "@dxos/util";
|
|
1892
1918
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
@@ -1930,7 +1956,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1930
1956
|
}
|
|
1931
1957
|
});
|
|
1932
1958
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1933
|
-
const setStateDebounced =
|
|
1959
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1934
1960
|
return [
|
|
1935
1961
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1936
1962
|
// EditorView.domEventHandlers({
|
|
@@ -1978,9 +2004,9 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1978
2004
|
|
|
1979
2005
|
// src/extensions/comments.ts
|
|
1980
2006
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
1981
|
-
var setComments =
|
|
1982
|
-
var setSelection =
|
|
1983
|
-
var setCommentState =
|
|
2007
|
+
var setComments = StateEffect4.define();
|
|
2008
|
+
var setSelection = StateEffect4.define();
|
|
2009
|
+
var setCommentState = StateEffect4.define();
|
|
1984
2010
|
var commentsState = StateField3.define({
|
|
1985
2011
|
create: (state) => ({
|
|
1986
2012
|
id: state.facet(documentId),
|
|
@@ -2062,7 +2088,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2062
2088
|
}).filter(isNonNullable);
|
|
2063
2089
|
return Decoration7.set(decorations2);
|
|
2064
2090
|
});
|
|
2065
|
-
var commentClickedEffect =
|
|
2091
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2066
2092
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2067
2093
|
click: (event, view) => {
|
|
2068
2094
|
let target = event.target;
|
|
@@ -2180,7 +2206,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2180
2206
|
from: changes.mapPos(comment.from, 1),
|
|
2181
2207
|
to: changes.mapPos(comment.to, 1)
|
|
2182
2208
|
});
|
|
2183
|
-
var restoreCommentEffect =
|
|
2209
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2184
2210
|
map: mapTrackedComment
|
|
2185
2211
|
});
|
|
2186
2212
|
var createComment = (view) => {
|
|
@@ -2214,7 +2240,7 @@ var createComment = (view) => {
|
|
|
2214
2240
|
var optionsFacet = singleValueFacet();
|
|
2215
2241
|
var comments = (options = {}) => {
|
|
2216
2242
|
const { key: shortcut = "meta-'" } = options;
|
|
2217
|
-
const handleSelect =
|
|
2243
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2218
2244
|
return [
|
|
2219
2245
|
optionsFacet.of(options),
|
|
2220
2246
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2485,6 +2511,9 @@ var fontMono = getToken("fontFamily.mono");
|
|
|
2485
2511
|
|
|
2486
2512
|
// src/styles/theme.ts
|
|
2487
2513
|
var baseTheme = EditorView13.baseTheme({
|
|
2514
|
+
/**
|
|
2515
|
+
* Outer frame.
|
|
2516
|
+
*/
|
|
2488
2517
|
"&": {},
|
|
2489
2518
|
"&.cm-focused": {
|
|
2490
2519
|
outline: "none"
|
|
@@ -2492,8 +2521,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2492
2521
|
/**
|
|
2493
2522
|
* Scroller
|
|
2494
2523
|
*/
|
|
2495
|
-
".cm-scroller": {
|
|
2496
|
-
|
|
2524
|
+
".cm-scroller": {},
|
|
2525
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2526
|
+
width: "8px"
|
|
2527
|
+
},
|
|
2528
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2529
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2530
|
+
background: "transparent",
|
|
2531
|
+
transition: "background 0.15s"
|
|
2532
|
+
},
|
|
2533
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2534
|
+
background: "var(--dx-scrollbarThumb)"
|
|
2497
2535
|
},
|
|
2498
2536
|
/**
|
|
2499
2537
|
* Content
|
|
@@ -2683,6 +2721,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2683
2721
|
},
|
|
2684
2722
|
".cm-panel button": {
|
|
2685
2723
|
"&:hover": {
|
|
2724
|
+
// TODO(burdon): Replace with layer and @apply bg-accentSurfaceHover
|
|
2686
2725
|
backgroundColor: "var(--dx-accentSurfaceHover) !important"
|
|
2687
2726
|
},
|
|
2688
2727
|
"&:active": {
|
|
@@ -2715,9 +2754,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2715
2754
|
});
|
|
2716
2755
|
|
|
2717
2756
|
// src/extensions/focus.ts
|
|
2718
|
-
import { StateEffect as
|
|
2757
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2719
2758
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2720
|
-
var focusEffect =
|
|
2759
|
+
var focusEffect = StateEffect5.define();
|
|
2721
2760
|
var focusField = StateField5.define({
|
|
2722
2761
|
create: () => false,
|
|
2723
2762
|
update: (value, tr) => {
|
|
@@ -4483,7 +4522,7 @@ var convertTreeToJson = (state) => {
|
|
|
4483
4522
|
|
|
4484
4523
|
// src/extensions/markdown/decorate.ts
|
|
4485
4524
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4486
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4525
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4487
4526
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4488
4527
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4489
4528
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
@@ -5438,7 +5477,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5438
5477
|
atomicDeco: atomicDeco.finish()
|
|
5439
5478
|
};
|
|
5440
5479
|
};
|
|
5441
|
-
var forceUpdate =
|
|
5480
|
+
var forceUpdate = StateEffect6.define();
|
|
5442
5481
|
var decorateMarkdown = (options = {}) => {
|
|
5443
5482
|
return [
|
|
5444
5483
|
ViewPlugin14.fromClass(class {
|
|
@@ -5572,8 +5611,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5572
5611
|
};
|
|
5573
5612
|
|
|
5574
5613
|
// src/extensions/modal.ts
|
|
5575
|
-
import { StateEffect as
|
|
5576
|
-
var modalStateEffect =
|
|
5614
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5615
|
+
var modalStateEffect = StateEffect7.define();
|
|
5577
5616
|
var modalStateField = StateField9.define({
|
|
5578
5617
|
create: () => false,
|
|
5579
5618
|
update: (value, tr) => {
|
|
@@ -6391,7 +6430,7 @@ var editor = () => [
|
|
|
6391
6430
|
|
|
6392
6431
|
// src/extensions/outliner/menu.ts
|
|
6393
6432
|
import { EditorView as EditorView24, ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6394
|
-
import { addEventListener } from "@dxos/async";
|
|
6433
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6395
6434
|
var menu = (options = {}) => [
|
|
6396
6435
|
ViewPlugin16.fromClass(class {
|
|
6397
6436
|
view;
|
|
@@ -6413,7 +6452,7 @@ var menu = (options = {}) => [
|
|
|
6413
6452
|
}
|
|
6414
6453
|
container.appendChild(this.tag);
|
|
6415
6454
|
const handler = () => this.scheduleUpdate();
|
|
6416
|
-
this.cleanup =
|
|
6455
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6417
6456
|
this.scheduleUpdate();
|
|
6418
6457
|
}
|
|
6419
6458
|
destroy() {
|
|
@@ -6631,13 +6670,13 @@ var getLinkRef = (state, node) => {
|
|
|
6631
6670
|
const mark = node.getChildren("LinkMark");
|
|
6632
6671
|
const urlNode = node.getChild("URL");
|
|
6633
6672
|
if (mark && urlNode) {
|
|
6634
|
-
const
|
|
6635
|
-
if (
|
|
6673
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6674
|
+
if (dxn.startsWith("dxn:")) {
|
|
6636
6675
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6637
6676
|
return {
|
|
6638
6677
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6639
6678
|
label,
|
|
6640
|
-
|
|
6679
|
+
dxn
|
|
6641
6680
|
};
|
|
6642
6681
|
}
|
|
6643
6682
|
}
|
|
@@ -6652,13 +6691,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6652
6691
|
// return false;
|
|
6653
6692
|
// }
|
|
6654
6693
|
eq(other) {
|
|
6655
|
-
return this._link.
|
|
6694
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6656
6695
|
}
|
|
6657
6696
|
toDOM(_view) {
|
|
6658
6697
|
const root = document.createElement("dx-anchor");
|
|
6659
6698
|
root.classList.add("dx-tag--anchor");
|
|
6660
6699
|
root.textContent = this._link.label;
|
|
6661
|
-
root.setAttribute("
|
|
6700
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6662
6701
|
return root;
|
|
6663
6702
|
}
|
|
6664
6703
|
};
|
|
@@ -6672,7 +6711,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6672
6711
|
// return true;
|
|
6673
6712
|
// }
|
|
6674
6713
|
eq(other) {
|
|
6675
|
-
return this._link.
|
|
6714
|
+
return this._link.dxn === other._link.dxn;
|
|
6676
6715
|
}
|
|
6677
6716
|
toDOM(_view) {
|
|
6678
6717
|
const root = document.createElement("div");
|
|
@@ -6891,7 +6930,7 @@ var mixedParser = (registry) => {
|
|
|
6891
6930
|
};
|
|
6892
6931
|
|
|
6893
6932
|
// src/extensions/tags/streamer.ts
|
|
6894
|
-
import { StateEffect as
|
|
6933
|
+
import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
|
|
6895
6934
|
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6896
6935
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6897
6936
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
@@ -6903,7 +6942,7 @@ var streamer = (options = {}) => {
|
|
|
6903
6942
|
].filter(isTruthy4);
|
|
6904
6943
|
};
|
|
6905
6944
|
var cursor = () => {
|
|
6906
|
-
const hideCursor =
|
|
6945
|
+
const hideCursor = StateEffect8.define();
|
|
6907
6946
|
const showCursor = StateField12.define({
|
|
6908
6947
|
create: () => true,
|
|
6909
6948
|
update: (value, tr) => {
|
|
@@ -6975,7 +7014,7 @@ var fadeIn = (options = {}) => {
|
|
|
6975
7014
|
const FADE_IN_DURATION = 1e3;
|
|
6976
7015
|
const DEFAULT_REMOVAL_DELAY = 5e3;
|
|
6977
7016
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6978
|
-
const removeDecoration =
|
|
7017
|
+
const removeDecoration = StateEffect8.define();
|
|
6979
7018
|
const fadeField = StateField12.define({
|
|
6980
7019
|
create: () => Decoration14.none,
|
|
6981
7020
|
update: (decorations2, tr) => {
|
|
@@ -7085,7 +7124,7 @@ var fadeIn = (options = {}) => {
|
|
|
7085
7124
|
|
|
7086
7125
|
// src/extensions/tags/xml-tags.ts
|
|
7087
7126
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7088
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7127
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
|
|
7089
7128
|
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin19, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7090
7129
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7091
7130
|
import { log as log10 } from "@dxos/log";
|
|
@@ -7160,15 +7199,15 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7199
|
|
|
7161
7200
|
// src/extensions/tags/xml-tags.ts
|
|
7162
7201
|
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7163
|
-
var navigatePreviousEffect =
|
|
7164
|
-
var navigateNextEffect =
|
|
7202
|
+
var navigatePreviousEffect = StateEffect9.define();
|
|
7203
|
+
var navigateNextEffect = StateEffect9.define();
|
|
7165
7204
|
var getXmlTextChild = (children) => {
|
|
7166
7205
|
const child = children?.[0];
|
|
7167
7206
|
return typeof child === "string" ? child : null;
|
|
7168
7207
|
};
|
|
7169
|
-
var xmlTagContextEffect =
|
|
7170
|
-
var xmlTagResetEffect =
|
|
7171
|
-
var xmlTagUpdateEffect =
|
|
7208
|
+
var xmlTagContextEffect = StateEffect9.define();
|
|
7209
|
+
var xmlTagResetEffect = StateEffect9.define();
|
|
7210
|
+
var xmlTagUpdateEffect = StateEffect9.define();
|
|
7172
7211
|
var widgetContextStateField = StateField13.define({
|
|
7173
7212
|
create: () => void 0,
|
|
7174
7213
|
update: (value, tr) => {
|
|
@@ -7738,7 +7777,6 @@ export {
|
|
|
7738
7777
|
removeStyle,
|
|
7739
7778
|
replacer,
|
|
7740
7779
|
scrollThreadIntoView,
|
|
7741
|
-
scrollToBottomEffect,
|
|
7742
7780
|
scrollToLine,
|
|
7743
7781
|
scrollToLineEffect,
|
|
7744
7782
|
selectionState,
|