@dxos/ui-editor 0.8.4-main.3eb6e50203 → 0.8.4-main.4a85c3132b
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 +477 -412
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +477 -412
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/defaults.d.ts +1 -1
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts +6 -0
- package/dist/types/src/extensions/auto-scroll.d.ts.map +1 -0
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- 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/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/link.d.ts.map +1 -1
- package/dist/types/src/extensions/scroller.d.ts +66 -0
- package/dist/types/src/extensions/scroller.d.ts.map +1 -0
- package/dist/types/src/styles/index.d.ts +0 -2
- package/dist/types/src/styles/index.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts +15 -0
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/util/cursor.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -28
- package/src/defaults.ts +4 -4
- package/src/extensions/annotations.ts +1 -1
- package/src/extensions/auto-scroll.ts +126 -0
- package/src/extensions/automerge/automerge.test.tsx +2 -2
- package/src/extensions/blocks.ts +5 -5
- package/src/extensions/comments.ts +5 -5
- package/src/extensions/dnd.ts +2 -2
- package/src/extensions/factories.ts +6 -7
- package/src/extensions/folding.ts +2 -2
- package/src/extensions/index.ts +2 -2
- package/src/extensions/markdown/decorate.ts +4 -3
- package/src/extensions/markdown/highlight.ts +25 -11
- package/src/extensions/markdown/link.ts +27 -33
- package/src/extensions/markdown/styles.ts +6 -6
- package/src/extensions/outliner/outliner.ts +3 -3
- package/src/extensions/preview/preview.ts +1 -1
- package/src/extensions/scroller.ts +232 -0
- package/src/extensions/tags/streamer.ts +1 -1
- package/src/extensions/tags/xml-tags.ts +7 -4
- package/src/styles/index.ts +0 -2
- package/src/styles/theme.ts +106 -30
- package/src/util/cursor.ts +1 -1
- package/dist/types/src/extensions/autoscroll.d.ts +0 -20
- package/dist/types/src/extensions/autoscroll.d.ts.map +0 -1
- package/dist/types/src/extensions/scrolling.d.ts +0 -78
- package/dist/types/src/extensions/scrolling.d.ts.map +0 -1
- package/dist/types/src/styles/markdown.d.ts +0 -8
- package/dist/types/src/styles/markdown.d.ts.map +0 -1
- package/dist/types/src/styles/tokens.d.ts +0 -3
- package/dist/types/src/styles/tokens.d.ts.map +0 -1
- package/src/extensions/autoscroll.ts +0 -165
- package/src/extensions/scrolling.ts +0 -189
- package/src/styles/markdown.ts +0 -26
- package/src/styles/tokens.ts +0 -17
|
@@ -13,17 +13,17 @@ import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
|
|
13
13
|
|
|
14
14
|
// src/defaults.ts
|
|
15
15
|
import { mx } from "@dxos/ui-theme";
|
|
16
|
-
var editorWidth = "!
|
|
16
|
+
var editorWidth = "!mx-auto w-full max-w-[min(50rem,100%-4rem)]";
|
|
17
17
|
var editorSlots = {
|
|
18
18
|
scroll: {
|
|
19
|
-
className: "
|
|
19
|
+
className: "pt-2"
|
|
20
20
|
},
|
|
21
21
|
content: {
|
|
22
22
|
className: editorWidth
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
|
|
26
|
-
var stackItemContentEditorClassNames = (role) => mx("p-0.5 dx-focus-ring-inset
|
|
26
|
+
var stackItemContentEditorClassNames = (role) => mx("dx-attention-surface p-0.5 dx-focus-ring-inset data-[toolbar=disabled]:pt-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-h-24" : "dx-container overflow-hidden");
|
|
27
27
|
|
|
28
28
|
// src/extensions/annotations.ts
|
|
29
29
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -58,7 +58,7 @@ var annotations = ({ match } = {}) => {
|
|
|
58
58
|
".cm-annotation": {
|
|
59
59
|
textDecoration: "underline",
|
|
60
60
|
textDecorationStyle: "wavy",
|
|
61
|
-
textDecorationColor: "var(--
|
|
61
|
+
textDecorationColor: "var(--color-error-text)"
|
|
62
62
|
}
|
|
63
63
|
})
|
|
64
64
|
];
|
|
@@ -501,192 +501,210 @@ 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, throttle } from "@dxos/async";
|
|
508
507
|
import { Domino } from "@dxos/ui";
|
|
509
508
|
|
|
510
|
-
// src/extensions/
|
|
509
|
+
// src/extensions/scroller.ts
|
|
511
510
|
import { StateEffect } from "@codemirror/state";
|
|
512
511
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
513
|
-
|
|
514
|
-
var
|
|
515
|
-
|
|
512
|
+
import { log as log2 } from "@dxos/log";
|
|
513
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
514
|
+
var scrollerLineEffect = StateEffect.define();
|
|
515
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
516
|
+
var scrollToLine = (view, options) => {
|
|
517
|
+
view.dispatch({
|
|
518
|
+
effects: scrollerLineEffect.of(options)
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
522
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
516
523
|
view;
|
|
524
|
+
crawler;
|
|
517
525
|
constructor(view) {
|
|
518
526
|
this.view = view;
|
|
527
|
+
this.crawler = createCrawler(this.view);
|
|
519
528
|
}
|
|
520
529
|
// No-op.
|
|
521
530
|
destroy() {
|
|
531
|
+
this.crawler.cancel();
|
|
522
532
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const scroller = this.view.scrollDOM;
|
|
530
|
-
const targetLine = Math.max(0, lineNumber - 1);
|
|
531
|
-
if (behavior === "instant") {
|
|
532
|
-
requestAnimationFrame(() => {
|
|
533
|
-
this.view.dispatch({
|
|
534
|
-
selection: {
|
|
535
|
-
anchor: doc.line(targetLine + 1).from
|
|
536
|
-
},
|
|
537
|
-
scrollIntoView: true
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
if (targetLine >= doc.lines) {
|
|
543
|
-
const targetScrollTop2 = scroller.scrollHeight - scroller.clientHeight + (animOffset || 0);
|
|
544
|
-
this.animateScroll(scroller, targetScrollTop2);
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
const lineStart = doc.line(targetLine + 1).from;
|
|
548
|
-
const coords = this.view.coordsAtPos(lineStart);
|
|
549
|
-
if (!coords) {
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
const currentScrollTop = scroller.scrollTop;
|
|
553
|
-
const scrollerRect = scroller.getBoundingClientRect();
|
|
554
|
-
const maxScrollTop = scroller.scrollHeight - scroller.clientHeight;
|
|
555
|
-
let targetScrollTop;
|
|
556
|
-
if (animPosition === "end") {
|
|
557
|
-
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + animOffset;
|
|
533
|
+
cancel() {
|
|
534
|
+
this.crawler.cancel();
|
|
535
|
+
}
|
|
536
|
+
crawl(start = false) {
|
|
537
|
+
if (start) {
|
|
538
|
+
this.crawler.scroll();
|
|
558
539
|
} else {
|
|
559
|
-
|
|
540
|
+
this.crawler.cancel();
|
|
560
541
|
}
|
|
561
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
562
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
563
542
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
543
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
544
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
545
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
546
|
+
const doc = this.view.state.doc;
|
|
547
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
548
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
549
|
+
const lineStart = doc.line(line + 1).from;
|
|
550
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
551
|
+
if (coords) {
|
|
552
|
+
const currentScrollTop = scrollTop;
|
|
553
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
554
|
+
if (position === "end") {
|
|
555
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
556
|
+
} else {
|
|
557
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
558
|
+
}
|
|
559
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
560
|
+
}
|
|
570
561
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
562
|
+
requestAnimationFrame(() => {
|
|
563
|
+
this.view.scrollDOM.scrollTo({
|
|
564
|
+
top: targetScrollTop,
|
|
565
|
+
behavior
|
|
566
|
+
});
|
|
574
567
|
});
|
|
575
568
|
}
|
|
576
569
|
});
|
|
577
570
|
return [
|
|
578
571
|
scrollPlugin,
|
|
579
|
-
//
|
|
572
|
+
// Listen for effect.s
|
|
580
573
|
EditorView4.updateListener.of((update2) => {
|
|
581
574
|
update2.transactions.forEach((transaction) => {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
});
|
|
575
|
+
try {
|
|
576
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
577
|
+
if (plugin) {
|
|
578
|
+
for (const effect of transaction.effects) {
|
|
579
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
580
|
+
plugin.crawl(effect.value);
|
|
581
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
582
|
+
plugin.scroll(effect.value);
|
|
583
|
+
}
|
|
592
584
|
}
|
|
593
585
|
}
|
|
586
|
+
} catch (err) {
|
|
587
|
+
log2.catch(err, void 0, {
|
|
588
|
+
F: __dxlog_file2,
|
|
589
|
+
L: 145,
|
|
590
|
+
S: void 0,
|
|
591
|
+
C: (f, a) => f(...a)
|
|
592
|
+
});
|
|
594
593
|
}
|
|
595
594
|
});
|
|
595
|
+
}),
|
|
596
|
+
// Styles.
|
|
597
|
+
EditorView4.theme({
|
|
598
|
+
".cm-content": {
|
|
599
|
+
paddingBottom: `${overScroll}px`
|
|
600
|
+
},
|
|
601
|
+
".cm-scroller": {
|
|
602
|
+
overflowAnchor: "none",
|
|
603
|
+
paddingBottom: "0"
|
|
604
|
+
},
|
|
605
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
606
|
+
display: "none"
|
|
607
|
+
},
|
|
608
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
609
|
+
background: "transparent",
|
|
610
|
+
transition: "background 0.15s"
|
|
611
|
+
},
|
|
612
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
613
|
+
background: "var(--color-scrollbar-thumb)"
|
|
614
|
+
},
|
|
615
|
+
".cm-scroll-button": {
|
|
616
|
+
position: "absolute",
|
|
617
|
+
bottom: "0.5rem",
|
|
618
|
+
right: "1rem"
|
|
619
|
+
}
|
|
596
620
|
})
|
|
597
621
|
];
|
|
598
622
|
};
|
|
599
|
-
|
|
600
|
-
view.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
623
|
+
function createCrawler(view, k = 0.3, maxStep = 2, targetDelta = 0.5) {
|
|
624
|
+
const el = view.scrollDOM;
|
|
625
|
+
let currentTop = 0;
|
|
626
|
+
let rafId = null;
|
|
627
|
+
function frame() {
|
|
628
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
629
|
+
const delta = targetTop - currentTop;
|
|
630
|
+
const absDelta = Math.abs(delta);
|
|
631
|
+
if (absDelta < targetDelta) {
|
|
632
|
+
el.scrollTop = targetTop;
|
|
633
|
+
currentTop = targetTop;
|
|
634
|
+
rafId = null;
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const step = Math.sign(delta) * Math.min(absDelta, Math.max(1, Math.min(absDelta * k, maxStep)));
|
|
638
|
+
currentTop += step;
|
|
639
|
+
el.scrollTop = currentTop;
|
|
640
|
+
rafId = requestAnimationFrame(frame);
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
scroll: () => {
|
|
644
|
+
if (rafId === null) {
|
|
645
|
+
currentTop = el.scrollTop;
|
|
646
|
+
rafId = requestAnimationFrame(frame);
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
cancel: () => {
|
|
650
|
+
if (rafId !== null) {
|
|
651
|
+
cancelAnimationFrame(rafId);
|
|
652
|
+
rafId = null;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
607
657
|
|
|
608
|
-
// src/extensions/
|
|
609
|
-
var
|
|
610
|
-
var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDelay = 1e3, onAutoScroll } = {}) => {
|
|
658
|
+
// src/extensions/auto-scroll.ts
|
|
659
|
+
var autoScroll = (_ = {}) => {
|
|
611
660
|
let buttonContainer;
|
|
612
|
-
let hideTimeout;
|
|
613
|
-
let lastScrollTop = 0;
|
|
614
661
|
let isPinned = true;
|
|
615
|
-
const setPinned = (
|
|
616
|
-
|
|
617
|
-
|
|
662
|
+
const setPinned = (pinned) => {
|
|
663
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
664
|
+
isPinned = pinned;
|
|
618
665
|
};
|
|
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);
|
|
625
|
-
};
|
|
626
|
-
const scrollToBottom = (view, behavior) => {
|
|
627
|
-
setPinned(true);
|
|
628
|
-
hideScrollbar(view);
|
|
629
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
630
|
-
view.dispatch({
|
|
631
|
-
selection: {
|
|
632
|
-
anchor: line.to,
|
|
633
|
-
head: line.to
|
|
634
|
-
},
|
|
635
|
-
effects: scrollToLineEffect.of({
|
|
636
|
-
line: line.number,
|
|
637
|
-
options: {
|
|
638
|
-
position: "end",
|
|
639
|
-
offset: threshold,
|
|
640
|
-
behavior
|
|
641
|
-
}
|
|
642
|
-
})
|
|
643
|
-
});
|
|
644
|
-
};
|
|
645
|
-
const checkDistance = debounce((view) => {
|
|
646
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
647
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
648
|
-
const distanceFromBottom = coords ? coords.bottom - scrollerRect.bottom : 0;
|
|
649
|
-
setPinned(distanceFromBottom < 0);
|
|
650
|
-
}, 1e3);
|
|
651
|
-
const triggerUpdate = debounce((view) => scrollToBottom(view), throttleDelay);
|
|
652
666
|
return [
|
|
653
667
|
// Update listener for logging when scrolling is needed.
|
|
654
|
-
EditorView5.updateListener.of(({ view,
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
668
|
+
EditorView5.updateListener.of(({ view, heightChanged, state }) => {
|
|
669
|
+
if (heightChanged) {
|
|
670
|
+
if (isPinned) {
|
|
671
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
672
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
673
|
+
if (delta > 0 && scrollTop > 0) {
|
|
674
|
+
setPinned(true);
|
|
675
|
+
view.dispatch({
|
|
676
|
+
effects: scrollerCrawlEffect.of(true)
|
|
677
|
+
});
|
|
678
|
+
} else if (delta < 0) {
|
|
679
|
+
setPinned(false);
|
|
659
680
|
}
|
|
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);
|
|
681
|
+
} else {
|
|
682
|
+
if (state.doc.length === 0) {
|
|
683
|
+
setPinned(true);
|
|
673
684
|
}
|
|
674
|
-
} else if (distanceFromBottom < 0) {
|
|
675
|
-
setPinned(false);
|
|
676
685
|
}
|
|
677
686
|
}
|
|
678
687
|
}),
|
|
679
|
-
// Detect user scroll.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
689
|
+
ViewPlugin6.fromClass(class {
|
|
690
|
+
cleanup;
|
|
691
|
+
constructor(view) {
|
|
692
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
693
|
+
requestAnimationFrame(() => {
|
|
694
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
695
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
696
|
+
const pinned = delta === 0;
|
|
697
|
+
setPinned(pinned);
|
|
698
|
+
if (!pinned) {
|
|
699
|
+
view.dispatch({
|
|
700
|
+
effects: scrollerCrawlEffect.of(false)
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}, 500));
|
|
705
|
+
}
|
|
706
|
+
destroy() {
|
|
707
|
+
this.cleanup();
|
|
690
708
|
}
|
|
691
709
|
}),
|
|
692
710
|
// Scroll button.
|
|
@@ -695,34 +713,33 @@ var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDel
|
|
|
695
713
|
const icon = Domino.of("dx-icon").attributes({
|
|
696
714
|
icon: "ph--arrow-down--regular"
|
|
697
715
|
});
|
|
698
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
716
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
699
717
|
"data-density": "fine"
|
|
700
718
|
}).children(icon).on("click", () => {
|
|
701
|
-
|
|
719
|
+
setPinned(true);
|
|
720
|
+
view.dispatch({
|
|
721
|
+
effects: scrollerLineEffect.of({
|
|
722
|
+
line: -1,
|
|
723
|
+
position: "end",
|
|
724
|
+
behavior: "smooth"
|
|
725
|
+
})
|
|
726
|
+
});
|
|
702
727
|
});
|
|
703
728
|
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").children(button).root;
|
|
704
729
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
705
730
|
}
|
|
706
|
-
}),
|
|
707
|
-
// Styles.
|
|
708
|
-
EditorView5.theme({
|
|
709
|
-
".cm-scroller": {
|
|
710
|
-
scrollbarWidth: "thin"
|
|
711
|
-
},
|
|
712
|
-
".cm-scroller.cm-hide-scrollbar": {
|
|
713
|
-
scrollbarWidth: "none"
|
|
714
|
-
},
|
|
715
|
-
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
716
|
-
display: "none"
|
|
717
|
-
},
|
|
718
|
-
".cm-scroll-button": {
|
|
719
|
-
position: "absolute",
|
|
720
|
-
bottom: "0.5rem",
|
|
721
|
-
right: "1rem"
|
|
722
|
-
}
|
|
723
731
|
})
|
|
724
732
|
];
|
|
725
733
|
};
|
|
734
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
735
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
736
|
+
passive: true
|
|
737
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
738
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
739
|
+
onUserScroll();
|
|
740
|
+
}
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
726
743
|
|
|
727
744
|
// src/extensions/automerge/automerge.ts
|
|
728
745
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -736,15 +753,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
736
753
|
|
|
737
754
|
// src/extensions/automerge/cursor.ts
|
|
738
755
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
739
|
-
import { log as
|
|
740
|
-
var
|
|
756
|
+
import { log as log3 } from "@dxos/log";
|
|
757
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
741
758
|
var cursorConverter = (accessor) => ({
|
|
742
759
|
toCursor: (pos, assoc) => {
|
|
743
760
|
try {
|
|
744
761
|
return toCursor(accessor, pos, assoc);
|
|
745
762
|
} catch (err) {
|
|
746
|
-
|
|
747
|
-
F:
|
|
763
|
+
log3.catch(err, void 0, {
|
|
764
|
+
F: __dxlog_file3,
|
|
748
765
|
L: 15,
|
|
749
766
|
S: void 0,
|
|
750
767
|
C: (f, a) => f(...a)
|
|
@@ -756,8 +773,8 @@ var cursorConverter = (accessor) => ({
|
|
|
756
773
|
try {
|
|
757
774
|
return fromCursor(accessor, cursor2);
|
|
758
775
|
} catch (err) {
|
|
759
|
-
|
|
760
|
-
F:
|
|
776
|
+
log3.catch(err, void 0, {
|
|
777
|
+
F: __dxlog_file3,
|
|
761
778
|
L: 24,
|
|
762
779
|
S: void 0,
|
|
763
780
|
C: (f, a) => f(...a)
|
|
@@ -768,10 +785,10 @@ var cursorConverter = (accessor) => ({
|
|
|
768
785
|
});
|
|
769
786
|
|
|
770
787
|
// src/extensions/automerge/defs.ts
|
|
771
|
-
import { Annotation, StateEffect as
|
|
788
|
+
import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
|
|
772
789
|
var getPath = (state, field) => state.field(field).path;
|
|
773
790
|
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
774
|
-
var updateHeadsEffect =
|
|
791
|
+
var updateHeadsEffect = StateEffect2.define({});
|
|
775
792
|
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
|
776
793
|
newHeads
|
|
777
794
|
});
|
|
@@ -782,7 +799,7 @@ var isReconcile = (tr) => {
|
|
|
782
799
|
|
|
783
800
|
// src/extensions/automerge/sync.ts
|
|
784
801
|
import { next as A2 } from "@automerge/automerge";
|
|
785
|
-
import { log as
|
|
802
|
+
import { log as log4 } from "@dxos/log";
|
|
786
803
|
|
|
787
804
|
// src/extensions/automerge/update-automerge.ts
|
|
788
805
|
import { next as A } from "@automerge/automerge";
|
|
@@ -923,7 +940,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
923
940
|
};
|
|
924
941
|
|
|
925
942
|
// src/extensions/automerge/sync.ts
|
|
926
|
-
var
|
|
943
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
927
944
|
var Syncer = class {
|
|
928
945
|
_handle;
|
|
929
946
|
_state;
|
|
@@ -946,8 +963,8 @@ var Syncer = class {
|
|
|
946
963
|
this._pending = false;
|
|
947
964
|
}
|
|
948
965
|
onEditorChange(view) {
|
|
949
|
-
|
|
950
|
-
F:
|
|
966
|
+
log4("onEditorChange", void 0, {
|
|
967
|
+
F: __dxlog_file4,
|
|
951
968
|
L: 45,
|
|
952
969
|
S: this,
|
|
953
970
|
C: (f, a) => f(...a)
|
|
@@ -962,8 +979,8 @@ var Syncer = class {
|
|
|
962
979
|
}
|
|
963
980
|
}
|
|
964
981
|
onAutomergeChange(view) {
|
|
965
|
-
|
|
966
|
-
F:
|
|
982
|
+
log4("onAutomergeChange", void 0, {
|
|
983
|
+
F: __dxlog_file4,
|
|
967
984
|
L: 60,
|
|
968
985
|
S: this,
|
|
969
986
|
C: (f, a) => f(...a)
|
|
@@ -1056,7 +1073,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1056
1073
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1057
1074
|
import { Event } from "@dxos/async";
|
|
1058
1075
|
import { Context } from "@dxos/context";
|
|
1059
|
-
var
|
|
1076
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1060
1077
|
var dummyProvider = {
|
|
1061
1078
|
remoteStateChange: new Event(),
|
|
1062
1079
|
open: () => {
|
|
@@ -1080,7 +1097,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1080
1097
|
};
|
|
1081
1098
|
var RemoteSelectionsDecorator = class {
|
|
1082
1099
|
_ctx = new Context(void 0, {
|
|
1083
|
-
F:
|
|
1100
|
+
F: __dxlog_file5,
|
|
1084
1101
|
L: 80
|
|
1085
1102
|
});
|
|
1086
1103
|
_cursorConverter;
|
|
@@ -1293,8 +1310,8 @@ var styles = EditorView7.theme({
|
|
|
1293
1310
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1294
1311
|
import { Context as Context2 } from "@dxos/context";
|
|
1295
1312
|
import { invariant } from "@dxos/invariant";
|
|
1296
|
-
import { log as
|
|
1297
|
-
var
|
|
1313
|
+
import { log as log5 } from "@dxos/log";
|
|
1314
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1298
1315
|
var DEBOUNCE_INTERVAL = 100;
|
|
1299
1316
|
var SpaceAwarenessProvider = class {
|
|
1300
1317
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1314,7 +1331,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1314
1331
|
}
|
|
1315
1332
|
open() {
|
|
1316
1333
|
this._ctx = new Context2(void 0, {
|
|
1317
|
-
F:
|
|
1334
|
+
F: __dxlog_file6,
|
|
1318
1335
|
L: 57
|
|
1319
1336
|
});
|
|
1320
1337
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1341,10 +1358,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1341
1358
|
void this._messenger.postMessage(this._channel, {
|
|
1342
1359
|
kind: "query"
|
|
1343
1360
|
}).catch((err) => {
|
|
1344
|
-
|
|
1361
|
+
log5.debug("failed to query awareness", {
|
|
1345
1362
|
err
|
|
1346
1363
|
}, {
|
|
1347
|
-
F:
|
|
1364
|
+
F: __dxlog_file6,
|
|
1348
1365
|
L: 91,
|
|
1349
1366
|
S: this,
|
|
1350
1367
|
C: (f, a) => f(...a)
|
|
@@ -1361,7 +1378,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1361
1378
|
}
|
|
1362
1379
|
update(position) {
|
|
1363
1380
|
invariant(this._postTask, void 0, {
|
|
1364
|
-
F:
|
|
1381
|
+
F: __dxlog_file6,
|
|
1365
1382
|
L: 106,
|
|
1366
1383
|
S: this,
|
|
1367
1384
|
A: [
|
|
@@ -1378,7 +1395,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1378
1395
|
}
|
|
1379
1396
|
_handleQueryMessage() {
|
|
1380
1397
|
invariant(this._postTask, void 0, {
|
|
1381
|
-
F:
|
|
1398
|
+
F: __dxlog_file6,
|
|
1382
1399
|
L: 117,
|
|
1383
1400
|
S: this,
|
|
1384
1401
|
A: [
|
|
@@ -1390,7 +1407,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1390
1407
|
}
|
|
1391
1408
|
_handlePostMessage(message) {
|
|
1392
1409
|
invariant(message.kind === "post", void 0, {
|
|
1393
|
-
F:
|
|
1410
|
+
F: __dxlog_file6,
|
|
1394
1411
|
L: 122,
|
|
1395
1412
|
S: this,
|
|
1396
1413
|
A: [
|
|
@@ -1406,9 +1423,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1406
1423
|
// src/extensions/blast.ts
|
|
1407
1424
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1408
1425
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1409
|
-
import { throttle } from "@dxos/async";
|
|
1426
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1410
1427
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1411
|
-
var
|
|
1428
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1412
1429
|
var defaultOptions = {
|
|
1413
1430
|
effect: 2,
|
|
1414
1431
|
maxParticles: 200,
|
|
@@ -1527,7 +1544,7 @@ var Blaster = class {
|
|
|
1527
1544
|
}
|
|
1528
1545
|
initialize() {
|
|
1529
1546
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1530
|
-
F:
|
|
1547
|
+
F: __dxlog_file7,
|
|
1531
1548
|
L: 142,
|
|
1532
1549
|
S: this,
|
|
1533
1550
|
A: [
|
|
@@ -1564,7 +1581,7 @@ var Blaster = class {
|
|
|
1564
1581
|
}
|
|
1565
1582
|
start() {
|
|
1566
1583
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1567
|
-
F:
|
|
1584
|
+
F: __dxlog_file7,
|
|
1568
1585
|
L: 181,
|
|
1569
1586
|
S: this,
|
|
1570
1587
|
A: [
|
|
@@ -1598,11 +1615,11 @@ var Blaster = class {
|
|
|
1598
1615
|
this.drawParticles();
|
|
1599
1616
|
requestAnimationFrame(this.loop.bind(this));
|
|
1600
1617
|
}
|
|
1601
|
-
shake =
|
|
1618
|
+
shake = throttle2(({ time }) => {
|
|
1602
1619
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1603
1620
|
this._shakeTimeMax = time;
|
|
1604
1621
|
}, 100);
|
|
1605
|
-
spawn =
|
|
1622
|
+
spawn = throttle2(({ element, point }) => {
|
|
1606
1623
|
const color = getRGBComponents(element, this._options.color);
|
|
1607
1624
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1608
1625
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1776,11 +1793,11 @@ var blocks = () => [
|
|
|
1776
1793
|
".cm-line.block-line": {
|
|
1777
1794
|
paddingLeft: "0.75rem",
|
|
1778
1795
|
paddingRight: "0.75rem",
|
|
1779
|
-
borderLeft: "1px solid var(--
|
|
1780
|
-
borderRight: "1px solid var(--
|
|
1796
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1797
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1781
1798
|
},
|
|
1782
1799
|
".cm-line.block-single": {
|
|
1783
|
-
border: "1px solid var(--
|
|
1800
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1784
1801
|
borderRadius: "6px",
|
|
1785
1802
|
paddingTop: "0.5rem",
|
|
1786
1803
|
paddingBottom: "0.5rem",
|
|
@@ -1788,7 +1805,7 @@ var blocks = () => [
|
|
|
1788
1805
|
marginBottom: "0.5rem"
|
|
1789
1806
|
},
|
|
1790
1807
|
".cm-line.block-first": {
|
|
1791
|
-
borderTop: "1px solid var(--
|
|
1808
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1792
1809
|
borderTopLeftRadius: "6px",
|
|
1793
1810
|
borderTopRightRadius: "6px",
|
|
1794
1811
|
paddingTop: "0.5rem",
|
|
@@ -1796,7 +1813,7 @@ var blocks = () => [
|
|
|
1796
1813
|
},
|
|
1797
1814
|
".cm-line.block-middle": {},
|
|
1798
1815
|
".cm-line.block-last": {
|
|
1799
|
-
borderBottom: "1px solid var(--
|
|
1816
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1800
1817
|
borderBottomLeftRadius: "6px",
|
|
1801
1818
|
borderBottomRightRadius: "6px",
|
|
1802
1819
|
paddingBottom: "0.5rem",
|
|
@@ -1806,13 +1823,13 @@ var blocks = () => [
|
|
|
1806
1823
|
];
|
|
1807
1824
|
|
|
1808
1825
|
// src/extensions/bookmarks.ts
|
|
1809
|
-
import { Prec as Prec3, StateEffect as
|
|
1826
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1810
1827
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1811
|
-
import { log as
|
|
1812
|
-
var
|
|
1813
|
-
var addBookmark =
|
|
1814
|
-
var removeBookmark =
|
|
1815
|
-
var clearBookmarks =
|
|
1828
|
+
import { log as log6 } from "@dxos/log";
|
|
1829
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1830
|
+
var addBookmark = StateEffect3.define();
|
|
1831
|
+
var removeBookmark = StateEffect3.define();
|
|
1832
|
+
var clearBookmarks = StateEffect3.define();
|
|
1816
1833
|
var bookmarks = () => {
|
|
1817
1834
|
return [
|
|
1818
1835
|
bookmarksField,
|
|
@@ -1821,8 +1838,8 @@ var bookmarks = () => {
|
|
|
1821
1838
|
key: "Mod-ArrowUp",
|
|
1822
1839
|
run: (view) => {
|
|
1823
1840
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1824
|
-
|
|
1825
|
-
F:
|
|
1841
|
+
log6("up", bookmarks2, {
|
|
1842
|
+
F: __dxlog_file8,
|
|
1826
1843
|
L: 29,
|
|
1827
1844
|
S: void 0,
|
|
1828
1845
|
C: (f, a) => f(...a)
|
|
@@ -1834,8 +1851,8 @@ var bookmarks = () => {
|
|
|
1834
1851
|
key: "Mod-ArrowDown",
|
|
1835
1852
|
run: (view) => {
|
|
1836
1853
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1837
|
-
|
|
1838
|
-
F:
|
|
1854
|
+
log6("down", bookmarks2, {
|
|
1855
|
+
F: __dxlog_file8,
|
|
1839
1856
|
L: 37,
|
|
1840
1857
|
S: void 0,
|
|
1841
1858
|
C: (f, a) => f(...a)
|
|
@@ -1876,20 +1893,20 @@ var bookmarksField = StateField2.define({
|
|
|
1876
1893
|
|
|
1877
1894
|
// src/extensions/comments.ts
|
|
1878
1895
|
import { invertedEffects } from "@codemirror/commands";
|
|
1879
|
-
import { StateEffect as
|
|
1896
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1880
1897
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1881
1898
|
import sortBy from "lodash.sortby";
|
|
1882
|
-
import { debounce as
|
|
1883
|
-
import { log as
|
|
1899
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1900
|
+
import { log as log7 } from "@dxos/log";
|
|
1884
1901
|
import { isNonNullable } from "@dxos/util";
|
|
1885
1902
|
|
|
1886
1903
|
// src/extensions/selection.ts
|
|
1887
1904
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1888
1905
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1889
|
-
import { debounce
|
|
1906
|
+
import { debounce } from "@dxos/async";
|
|
1890
1907
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1891
1908
|
import { isTruthy } from "@dxos/util";
|
|
1892
|
-
var
|
|
1909
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1893
1910
|
var documentId = singleValueFacet();
|
|
1894
1911
|
var stateRestoreAnnotation = "dxos.org/cm/state-restore";
|
|
1895
1912
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
@@ -1905,7 +1922,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1905
1922
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1906
1923
|
getState: (id) => {
|
|
1907
1924
|
invariant3(id, void 0, {
|
|
1908
|
-
F:
|
|
1925
|
+
F: __dxlog_file9,
|
|
1909
1926
|
L: 47,
|
|
1910
1927
|
S: void 0,
|
|
1911
1928
|
A: [
|
|
@@ -1918,7 +1935,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1918
1935
|
},
|
|
1919
1936
|
setState: (id, state) => {
|
|
1920
1937
|
invariant3(id, void 0, {
|
|
1921
|
-
F:
|
|
1938
|
+
F: __dxlog_file9,
|
|
1922
1939
|
L: 53,
|
|
1923
1940
|
S: void 0,
|
|
1924
1941
|
A: [
|
|
@@ -1930,7 +1947,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1930
1947
|
}
|
|
1931
1948
|
});
|
|
1932
1949
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1933
|
-
const setStateDebounced =
|
|
1950
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1934
1951
|
return [
|
|
1935
1952
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1936
1953
|
// EditorView.domEventHandlers({
|
|
@@ -1977,10 +1994,10 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1977
1994
|
};
|
|
1978
1995
|
|
|
1979
1996
|
// src/extensions/comments.ts
|
|
1980
|
-
var
|
|
1981
|
-
var setComments =
|
|
1982
|
-
var setSelection =
|
|
1983
|
-
var setCommentState =
|
|
1997
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
1998
|
+
var setComments = StateEffect4.define();
|
|
1999
|
+
var setSelection = StateEffect4.define();
|
|
2000
|
+
var setCommentState = StateEffect4.define();
|
|
1984
2001
|
var commentsState = StateField3.define({
|
|
1985
2002
|
create: (state) => ({
|
|
1986
2003
|
id: state.facet(documentId),
|
|
@@ -2022,14 +2039,14 @@ var commentsState = StateField3.define({
|
|
|
2022
2039
|
var styles2 = EditorView11.theme({
|
|
2023
2040
|
".cm-comment, .cm-comment-current": {
|
|
2024
2041
|
padding: "3px 0",
|
|
2025
|
-
color: "var(--
|
|
2026
|
-
backgroundColor: "var(--
|
|
2042
|
+
color: "var(--color-cm-comment-text)",
|
|
2043
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2027
2044
|
},
|
|
2028
2045
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2029
2046
|
boxDecorationBreak: "clone",
|
|
2030
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2031
|
-
backgroundColor: "var(--
|
|
2032
|
-
color: "var(--
|
|
2047
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2048
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2049
|
+
color: "var(--color-cm-comment-text)",
|
|
2033
2050
|
cursor: "pointer"
|
|
2034
2051
|
}
|
|
2035
2052
|
});
|
|
@@ -2047,8 +2064,8 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2047
2064
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2048
2065
|
const range = comment.range;
|
|
2049
2066
|
if (!range) {
|
|
2050
|
-
|
|
2051
|
-
F:
|
|
2067
|
+
log7.warn("Invalid range:", range, {
|
|
2068
|
+
F: __dxlog_file10,
|
|
2052
2069
|
L: 140,
|
|
2053
2070
|
S: void 0,
|
|
2054
2071
|
C: (f, a) => f(...a)
|
|
@@ -2062,7 +2079,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2062
2079
|
}).filter(isNonNullable);
|
|
2063
2080
|
return Decoration7.set(decorations2);
|
|
2064
2081
|
});
|
|
2065
|
-
var commentClickedEffect =
|
|
2082
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2066
2083
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2067
2084
|
click: (event, view) => {
|
|
2068
2085
|
let target = event.target;
|
|
@@ -2180,7 +2197,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2180
2197
|
from: changes.mapPos(comment.from, 1),
|
|
2181
2198
|
to: changes.mapPos(comment.to, 1)
|
|
2182
2199
|
});
|
|
2183
|
-
var restoreCommentEffect =
|
|
2200
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2184
2201
|
map: mapTrackedComment
|
|
2185
2202
|
});
|
|
2186
2203
|
var createComment = (view) => {
|
|
@@ -2214,7 +2231,7 @@ var createComment = (view) => {
|
|
|
2214
2231
|
var optionsFacet = singleValueFacet();
|
|
2215
2232
|
var comments = (options = {}) => {
|
|
2216
2233
|
const { key: shortcut = "meta-'" } = options;
|
|
2217
|
-
const handleSelect =
|
|
2234
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2218
2235
|
return [
|
|
2219
2236
|
optionsFacet.of(options),
|
|
2220
2237
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2392,9 +2409,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2392
2409
|
// src/extensions/debug.ts
|
|
2393
2410
|
import { syntaxTree } from "@codemirror/language";
|
|
2394
2411
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2395
|
-
var debugNodeLogger = (
|
|
2412
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2396
2413
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2397
|
-
enter: (node) =>
|
|
2414
|
+
enter: (node) => log12(node.type)
|
|
2398
2415
|
});
|
|
2399
2416
|
return StateField4.define({
|
|
2400
2417
|
create: (state) => logTokens(state),
|
|
@@ -2429,8 +2446,8 @@ var dropFile = (options = {}) => {
|
|
|
2429
2446
|
};
|
|
2430
2447
|
var styles3 = EditorView12.theme({
|
|
2431
2448
|
".cm-dropCursor": {
|
|
2432
|
-
borderLeft: "2px solid var(--
|
|
2433
|
-
color: "var(--
|
|
2449
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2450
|
+
color: "var(--color-accent-text)",
|
|
2434
2451
|
padding: "0 4px"
|
|
2435
2452
|
},
|
|
2436
2453
|
".cm-dropCursor:after": {
|
|
@@ -2448,43 +2465,62 @@ import { EditorView as EditorView15, ViewPlugin as ViewPlugin11, drawSelection,
|
|
|
2448
2465
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2449
2466
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2450
2467
|
import { generateName } from "@dxos/display-name";
|
|
2451
|
-
import { log as
|
|
2468
|
+
import { log as log8 } from "@dxos/log";
|
|
2452
2469
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2453
2470
|
|
|
2454
|
-
// src/styles/
|
|
2471
|
+
// src/styles/theme.ts
|
|
2472
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2455
2473
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2456
2474
|
var headings = {
|
|
2457
|
-
1:
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2475
|
+
1: {
|
|
2476
|
+
className: "text-4xl",
|
|
2477
|
+
fontSize: "var(--text-4xl)",
|
|
2478
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2479
|
+
},
|
|
2480
|
+
2: {
|
|
2481
|
+
className: "text-3xl",
|
|
2482
|
+
fontSize: "var(--text-3xl)",
|
|
2483
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2484
|
+
},
|
|
2485
|
+
3: {
|
|
2486
|
+
className: "text-2xl",
|
|
2487
|
+
fontSize: "var(--text-2xl)",
|
|
2488
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2489
|
+
},
|
|
2490
|
+
4: {
|
|
2491
|
+
className: "text-xl",
|
|
2492
|
+
fontSize: "var(--text-xl)",
|
|
2493
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2494
|
+
},
|
|
2495
|
+
5: {
|
|
2496
|
+
className: "text-lg",
|
|
2497
|
+
fontSize: "var(--text-lg)",
|
|
2498
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2499
|
+
},
|
|
2500
|
+
6: {
|
|
2501
|
+
className: "text-base",
|
|
2502
|
+
fontSize: "var(--text-base)",
|
|
2503
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2504
|
+
}
|
|
2463
2505
|
};
|
|
2464
2506
|
var markdownTheme = {
|
|
2465
|
-
code: "font-mono
|
|
2466
|
-
codeMark: "font-mono text-
|
|
2507
|
+
code: "font-mono no-underline! text-cm-code",
|
|
2508
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
2467
2509
|
mark: "opacity-50",
|
|
2468
|
-
heading: (level) => {
|
|
2469
|
-
|
|
2470
|
-
|
|
2510
|
+
heading: (level) => ({
|
|
2511
|
+
className: mx3(headings[level].className, "font-light text-cm-heading"),
|
|
2512
|
+
color: "var(--color-cm-heading) !important",
|
|
2513
|
+
lineHeight: headings[level].lineHeight,
|
|
2514
|
+
fontSize: headings[level].fontSize,
|
|
2515
|
+
fontWeight: "100 !important"
|
|
2516
|
+
})
|
|
2471
2517
|
};
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2475
|
-
|
|
2476
|
-
// src/styles/tokens.ts
|
|
2477
|
-
import { tokens } from "@dxos/ui-theme";
|
|
2478
|
-
import { get } from "@dxos/util";
|
|
2479
|
-
var getToken = (path, defaultValue) => {
|
|
2480
|
-
const value = get(tokens, path, defaultValue);
|
|
2481
|
-
return value?.toString() ?? "";
|
|
2482
|
-
};
|
|
2483
|
-
var fontBody = getToken("fontFamily.body");
|
|
2484
|
-
var fontMono = getToken("fontFamily.mono");
|
|
2485
|
-
|
|
2486
|
-
// src/styles/theme.ts
|
|
2518
|
+
var fontBody = "Inter Variable, ui-sans-serif, system-ui, sans-serif";
|
|
2519
|
+
var fontMono = "JetBrains Mono Variable, ui-monospace, Cascadia Code, Source Code Pro, monospace";
|
|
2487
2520
|
var baseTheme = EditorView13.baseTheme({
|
|
2521
|
+
/**
|
|
2522
|
+
* Outer frame.
|
|
2523
|
+
*/
|
|
2488
2524
|
"&": {},
|
|
2489
2525
|
"&.cm-focused": {
|
|
2490
2526
|
outline: "none"
|
|
@@ -2493,7 +2529,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2493
2529
|
* Scroller
|
|
2494
2530
|
*/
|
|
2495
2531
|
".cm-scroller": {
|
|
2496
|
-
|
|
2532
|
+
overflowAnchor: "none"
|
|
2533
|
+
},
|
|
2534
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2535
|
+
width: "8px"
|
|
2536
|
+
},
|
|
2537
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2538
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2539
|
+
background: "transparent",
|
|
2540
|
+
transition: "background 0.15s"
|
|
2541
|
+
},
|
|
2542
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2543
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2497
2544
|
},
|
|
2498
2545
|
/**
|
|
2499
2546
|
* Content
|
|
@@ -2515,8 +2562,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2515
2562
|
".cm-gutter": {},
|
|
2516
2563
|
".cm-gutter.cm-lineNumbers": {
|
|
2517
2564
|
paddingRight: "4px",
|
|
2518
|
-
borderRight: "1px solid var(--
|
|
2519
|
-
color: "var(--
|
|
2565
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2566
|
+
color: "var(--color-subdued)"
|
|
2520
2567
|
},
|
|
2521
2568
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2522
2569
|
minWidth: "40px"
|
|
@@ -2536,25 +2583,25 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2536
2583
|
paddingInline: 0
|
|
2537
2584
|
},
|
|
2538
2585
|
".cm-activeLine": {
|
|
2539
|
-
background: "var(--
|
|
2586
|
+
background: "var(--color-cm-active-line)"
|
|
2540
2587
|
},
|
|
2541
2588
|
/**
|
|
2542
2589
|
* Cursor (layer).
|
|
2543
2590
|
*/
|
|
2544
2591
|
".cm-cursor, .cm-dropCursor": {
|
|
2545
|
-
borderLeft: "2px solid var(--
|
|
2592
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2546
2593
|
},
|
|
2547
2594
|
".cm-placeholder": {
|
|
2548
|
-
color: "var(--
|
|
2595
|
+
color: "var(--color-placeholder)"
|
|
2549
2596
|
},
|
|
2550
2597
|
/**
|
|
2551
2598
|
* Selection (layer).
|
|
2552
2599
|
*/
|
|
2553
2600
|
".cm-selectionBackground": {
|
|
2554
|
-
background: "var(--
|
|
2601
|
+
background: "var(--color-cm-selection)"
|
|
2555
2602
|
},
|
|
2556
2603
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2557
|
-
background: "var(--
|
|
2604
|
+
background: "var(--color-cm-focused-selection)"
|
|
2558
2605
|
},
|
|
2559
2606
|
/**
|
|
2560
2607
|
* Search.
|
|
@@ -2564,8 +2611,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2564
2611
|
margin: "0 -3px",
|
|
2565
2612
|
padding: "3px",
|
|
2566
2613
|
borderRadius: "3px",
|
|
2567
|
-
background: "var(--
|
|
2568
|
-
color: "var(--
|
|
2614
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2615
|
+
color: "var(--color-cm-highlight)"
|
|
2569
2616
|
},
|
|
2570
2617
|
".cm-searchMatch-selected": {
|
|
2571
2618
|
textDecoration: "underline"
|
|
@@ -2576,20 +2623,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2576
2623
|
".cm-link": {
|
|
2577
2624
|
textDecorationLine: "underline",
|
|
2578
2625
|
textDecorationThickness: "1px",
|
|
2579
|
-
textDecorationColor: "var(--
|
|
2626
|
+
textDecorationColor: "var(--color-separator)",
|
|
2580
2627
|
textUnderlineOffset: "2px",
|
|
2581
2628
|
borderRadius: ".125rem"
|
|
2582
2629
|
},
|
|
2583
2630
|
".cm-link > span": {
|
|
2584
|
-
color: "var(--
|
|
2631
|
+
color: "var(--color-accent-text)"
|
|
2632
|
+
},
|
|
2633
|
+
".cm-link > span:hover": {
|
|
2634
|
+
color: "var(--color-accent-text-hover)"
|
|
2585
2635
|
},
|
|
2586
2636
|
/**
|
|
2587
2637
|
* Tooltip.
|
|
2588
2638
|
*/
|
|
2589
2639
|
".cm-tooltip": {
|
|
2590
|
-
background: "var(--
|
|
2640
|
+
background: "var(--color-modal-surface)"
|
|
2591
2641
|
},
|
|
2592
2642
|
".cm-tooltip-below": {},
|
|
2643
|
+
".cm-tooltip-hover": {
|
|
2644
|
+
background: "var(--color-modal-surface)",
|
|
2645
|
+
border: "1px solid var(--color-separator)",
|
|
2646
|
+
borderRadius: "4px",
|
|
2647
|
+
overflow: "hidden"
|
|
2648
|
+
},
|
|
2593
2649
|
/**
|
|
2594
2650
|
* Autocomplete.
|
|
2595
2651
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2597,7 +2653,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2597
2653
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2598
2654
|
marginTop: "6px",
|
|
2599
2655
|
marginLeft: "-10px",
|
|
2600
|
-
border: "2px solid var(--
|
|
2656
|
+
border: "2px solid var(--color-separator)",
|
|
2601
2657
|
borderRadius: "4px"
|
|
2602
2658
|
},
|
|
2603
2659
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2607,12 +2663,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2607
2663
|
padding: "4px"
|
|
2608
2664
|
},
|
|
2609
2665
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2610
|
-
background: "var(--
|
|
2611
|
-
color: "var(--
|
|
2666
|
+
background: "var(--color-active-surface)",
|
|
2667
|
+
color: "var(--color-base-surface-text)"
|
|
2612
2668
|
},
|
|
2613
2669
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2614
2670
|
paddingLeft: "4px !important",
|
|
2615
|
-
color: "var(--
|
|
2671
|
+
color: "var(--color-base-surface-text)"
|
|
2616
2672
|
},
|
|
2617
2673
|
/**
|
|
2618
2674
|
* Completion info.
|
|
@@ -2621,17 +2677,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2621
2677
|
width: "360px !important",
|
|
2622
2678
|
margin: "-10px 1px 0 1px",
|
|
2623
2679
|
padding: "8px !important",
|
|
2624
|
-
borderColor: "var(--
|
|
2680
|
+
borderColor: "var(--color-separator)"
|
|
2625
2681
|
},
|
|
2626
2682
|
".cm-completionIcon": {
|
|
2627
2683
|
display: "none"
|
|
2628
2684
|
},
|
|
2629
2685
|
".cm-completionLabel": {
|
|
2630
|
-
color: "var(--
|
|
2686
|
+
color: "var(--color-description)",
|
|
2631
2687
|
padding: "0 4px"
|
|
2632
2688
|
},
|
|
2633
2689
|
".cm-completionMatchedText": {
|
|
2634
|
-
color: "var(--
|
|
2690
|
+
color: "var(--color-base-surface-text)",
|
|
2635
2691
|
textDecoration: "none !important"
|
|
2636
2692
|
},
|
|
2637
2693
|
/**
|
|
@@ -2655,7 +2711,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2655
2711
|
backgroundColor: "var(--surface-bg)"
|
|
2656
2712
|
},
|
|
2657
2713
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2658
|
-
color: "var(--
|
|
2714
|
+
color: "var(--color-subdued)",
|
|
2659
2715
|
fontSize: "14px",
|
|
2660
2716
|
all: "unset",
|
|
2661
2717
|
margin: "3px !important",
|
|
@@ -2663,10 +2719,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2663
2719
|
outline: "1px solid transparent"
|
|
2664
2720
|
},
|
|
2665
2721
|
".cm-panel input, .cm-panel button": {
|
|
2666
|
-
backgroundColor: "var(--
|
|
2722
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2667
2723
|
},
|
|
2668
2724
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2669
|
-
outline: "1px solid var(--
|
|
2725
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2670
2726
|
},
|
|
2671
2727
|
".cm-panel label": {
|
|
2672
2728
|
display: "inline-flex",
|
|
@@ -2679,26 +2735,26 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2679
2735
|
height: "8px",
|
|
2680
2736
|
marginRight: "6px !important",
|
|
2681
2737
|
padding: "2px !important",
|
|
2682
|
-
color: "var(--
|
|
2738
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2683
2739
|
},
|
|
2684
2740
|
".cm-panel button": {
|
|
2685
2741
|
"&:hover": {
|
|
2686
|
-
// TODO(burdon): Replace with layer and @apply bg-
|
|
2687
|
-
backgroundColor: "var(--
|
|
2742
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2743
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2688
2744
|
},
|
|
2689
2745
|
"&:active": {
|
|
2690
|
-
backgroundColor: "var(--
|
|
2746
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2691
2747
|
}
|
|
2692
2748
|
},
|
|
2693
2749
|
".cm-panel.cm-search": {
|
|
2694
2750
|
padding: "4px",
|
|
2695
|
-
borderTop: "1px solid var(--
|
|
2751
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2696
2752
|
}
|
|
2697
2753
|
});
|
|
2698
2754
|
var editorGutter = EditorView13.theme({
|
|
2699
2755
|
".cm-gutters": {
|
|
2700
2756
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2701
|
-
background: "var(--
|
|
2757
|
+
background: "var(--color-base-surface) !important",
|
|
2702
2758
|
paddingRight: "1rem"
|
|
2703
2759
|
}
|
|
2704
2760
|
});
|
|
@@ -2716,9 +2772,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2716
2772
|
});
|
|
2717
2773
|
|
|
2718
2774
|
// src/extensions/focus.ts
|
|
2719
|
-
import { StateEffect as
|
|
2775
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2720
2776
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2721
|
-
var focusEffect =
|
|
2777
|
+
var focusEffect = StateEffect5.define();
|
|
2722
2778
|
var focusField = StateField5.define({
|
|
2723
2779
|
create: () => false,
|
|
2724
2780
|
update: (value, tr) => {
|
|
@@ -2747,7 +2803,7 @@ var focus = [
|
|
|
2747
2803
|
];
|
|
2748
2804
|
|
|
2749
2805
|
// src/extensions/factories.ts
|
|
2750
|
-
var
|
|
2806
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2751
2807
|
var tabbable = EditorView15.contentAttributes.of({
|
|
2752
2808
|
tabindex: "0"
|
|
2753
2809
|
});
|
|
@@ -2802,9 +2858,9 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2802
2858
|
return [
|
|
2803
2859
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2804
2860
|
EditorView15.exceptionSink.of((err) => {
|
|
2805
|
-
|
|
2806
|
-
F:
|
|
2807
|
-
L:
|
|
2861
|
+
log8.catch(err, void 0, {
|
|
2862
|
+
F: __dxlog_file11,
|
|
2863
|
+
L: 131,
|
|
2808
2864
|
S: void 0,
|
|
2809
2865
|
C: (f, a) => f(...a)
|
|
2810
2866
|
});
|
|
@@ -2856,12 +2912,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2856
2912
|
};
|
|
2857
2913
|
var grow = {
|
|
2858
2914
|
editor: {
|
|
2859
|
-
className: "
|
|
2915
|
+
className: "h-full w-full"
|
|
2860
2916
|
}
|
|
2861
2917
|
};
|
|
2862
2918
|
var fullWidth = {
|
|
2863
2919
|
editor: {
|
|
2864
|
-
className: "
|
|
2920
|
+
className: "w-full"
|
|
2865
2921
|
}
|
|
2866
2922
|
};
|
|
2867
2923
|
var defaultThemeSlots = grow;
|
|
@@ -2904,8 +2960,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2904
2960
|
channel: `awareness.${id}`,
|
|
2905
2961
|
peerId: identity.identityKey.toHex(),
|
|
2906
2962
|
info: {
|
|
2907
|
-
darkColor: `var(--
|
|
2908
|
-
lightColor: `var(--
|
|
2963
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
2964
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2909
2965
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2910
2966
|
}
|
|
2911
2967
|
})));
|
|
@@ -2924,7 +2980,7 @@ var folding = () => {
|
|
|
2924
2980
|
}),
|
|
2925
2981
|
foldGutter({
|
|
2926
2982
|
markerDOM: (open) => {
|
|
2927
|
-
return Domino2.of("div").classNames("flex
|
|
2983
|
+
return Domino2.of("div").classNames("flex h-full justify-center items-center").children(Domino2.of("svg", Domino2.SVG).classNames(mx4("w-4 h-4 cursor-pointer", open && "rotate-90")).children(Domino2.of("use", Domino2.SVG).attributes({
|
|
2928
2984
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2929
2985
|
}))).root;
|
|
2930
2986
|
}
|
|
@@ -4220,6 +4276,11 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
|
4220
4276
|
import { HighlightStyle as HighlightStyle2 } from "@codemirror/language";
|
|
4221
4277
|
import { Tag, styleTags, tags } from "@lezer/highlight";
|
|
4222
4278
|
import { Table } from "@lezer/markdown";
|
|
4279
|
+
var styles4 = {
|
|
4280
|
+
code: "font-mono no-underline! text-cm-code",
|
|
4281
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
4282
|
+
mark: "opacity-50"
|
|
4283
|
+
};
|
|
4223
4284
|
var markdownTags = {
|
|
4224
4285
|
Blockquote: Tag.define(),
|
|
4225
4286
|
CodeMark: Tag.define(),
|
|
@@ -4301,7 +4362,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4301
4362
|
markdownTags.LinkReference,
|
|
4302
4363
|
markdownTags.ListMark
|
|
4303
4364
|
],
|
|
4304
|
-
class:
|
|
4365
|
+
class: styles4.mark
|
|
4305
4366
|
},
|
|
4306
4367
|
// Markdown marks.
|
|
4307
4368
|
{
|
|
@@ -4312,7 +4373,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4312
4373
|
markdownTags.QuoteMark,
|
|
4313
4374
|
markdownTags.EmphasisMark
|
|
4314
4375
|
],
|
|
4315
|
-
class:
|
|
4376
|
+
class: styles4.mark
|
|
4316
4377
|
},
|
|
4317
4378
|
// E.g., code block language (after ```).
|
|
4318
4379
|
{
|
|
@@ -4321,7 +4382,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4321
4382
|
tags.function(tags.variableName),
|
|
4322
4383
|
tags.labelName
|
|
4323
4384
|
],
|
|
4324
|
-
class:
|
|
4385
|
+
class: styles4.codeMark
|
|
4325
4386
|
},
|
|
4326
4387
|
// Fonts.
|
|
4327
4388
|
{
|
|
@@ -4331,30 +4392,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4331
4392
|
],
|
|
4332
4393
|
class: "font-mono"
|
|
4333
4394
|
},
|
|
4334
|
-
// Headings
|
|
4395
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4396
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4397
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4398
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4399
|
+
{
|
|
4400
|
+
tag: tags.heading,
|
|
4401
|
+
color: "var(--color-cm-heading) !important",
|
|
4402
|
+
fontWeight: "300"
|
|
4403
|
+
},
|
|
4335
4404
|
{
|
|
4336
4405
|
tag: tags.heading1,
|
|
4337
|
-
|
|
4406
|
+
...markdownTheme.heading(1)
|
|
4338
4407
|
},
|
|
4339
4408
|
{
|
|
4340
4409
|
tag: tags.heading2,
|
|
4341
|
-
|
|
4410
|
+
...markdownTheme.heading(2)
|
|
4342
4411
|
},
|
|
4343
4412
|
{
|
|
4344
4413
|
tag: tags.heading3,
|
|
4345
|
-
|
|
4414
|
+
...markdownTheme.heading(3)
|
|
4346
4415
|
},
|
|
4347
4416
|
{
|
|
4348
4417
|
tag: tags.heading4,
|
|
4349
|
-
|
|
4418
|
+
...markdownTheme.heading(4)
|
|
4350
4419
|
},
|
|
4351
4420
|
{
|
|
4352
4421
|
tag: tags.heading5,
|
|
4353
|
-
|
|
4422
|
+
...markdownTheme.heading(5)
|
|
4354
4423
|
},
|
|
4355
4424
|
{
|
|
4356
4425
|
tag: tags.heading6,
|
|
4357
|
-
|
|
4426
|
+
...markdownTheme.heading(6)
|
|
4358
4427
|
},
|
|
4359
4428
|
// Emphasis.
|
|
4360
4429
|
{
|
|
@@ -4379,7 +4448,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4379
4448
|
markdownTags.CodeText,
|
|
4380
4449
|
markdownTags.InlineCode
|
|
4381
4450
|
],
|
|
4382
|
-
class:
|
|
4451
|
+
class: styles4.code
|
|
4383
4452
|
},
|
|
4384
4453
|
{
|
|
4385
4454
|
tag: [
|
|
@@ -4484,7 +4553,7 @@ var convertTreeToJson = (state) => {
|
|
|
4484
4553
|
|
|
4485
4554
|
// src/extensions/markdown/decorate.ts
|
|
4486
4555
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4487
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4556
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4488
4557
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4489
4558
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4490
4559
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
@@ -4736,7 +4805,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4736
4805
|
width: "100%",
|
|
4737
4806
|
height: "0",
|
|
4738
4807
|
verticalAlign: "middle",
|
|
4739
|
-
borderTop: "1px solid var(--
|
|
4808
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4740
4809
|
opacity: 0.5
|
|
4741
4810
|
},
|
|
4742
4811
|
/**
|
|
@@ -4759,8 +4828,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4759
4828
|
* Blockquote.
|
|
4760
4829
|
*/
|
|
4761
4830
|
"& .cm-blockquote": {
|
|
4762
|
-
background: "var(--
|
|
4763
|
-
borderLeft: "2px solid var(--
|
|
4831
|
+
background: "var(--color-cm-codeblock)",
|
|
4832
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4764
4833
|
paddingLeft: "1rem",
|
|
4765
4834
|
margin: "0"
|
|
4766
4835
|
},
|
|
@@ -4771,7 +4840,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4771
4840
|
fontFamily: fontMono
|
|
4772
4841
|
},
|
|
4773
4842
|
"& .cm-codeblock-line": {
|
|
4774
|
-
background: "var(--
|
|
4843
|
+
background: "var(--color-cm-codeblock)",
|
|
4775
4844
|
paddingInline: "1rem !important"
|
|
4776
4845
|
},
|
|
4777
4846
|
"& .cm-codeblock-start": {
|
|
@@ -4805,8 +4874,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4805
4874
|
".cm-table-head": {
|
|
4806
4875
|
padding: "2px 16px 2px 0px",
|
|
4807
4876
|
textAlign: "left",
|
|
4808
|
-
borderBottom: "1px solid var(--
|
|
4809
|
-
color: "var(--
|
|
4877
|
+
borderBottom: "1px solid var(--color-cm-separator)",
|
|
4878
|
+
color: "var(--color-subdued)"
|
|
4810
4879
|
},
|
|
4811
4880
|
".cm-table-cell": {
|
|
4812
4881
|
padding: "2px 16px 2px 0px"
|
|
@@ -4946,7 +5015,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4946
5015
|
};
|
|
4947
5016
|
|
|
4948
5017
|
// src/extensions/markdown/decorate.ts
|
|
4949
|
-
var
|
|
5018
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4950
5019
|
var Unicode = {
|
|
4951
5020
|
emDash: "\u2014",
|
|
4952
5021
|
bullet: "\u2022",
|
|
@@ -4969,7 +5038,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4969
5038
|
eq(other) {
|
|
4970
5039
|
return this.url === other.url;
|
|
4971
5040
|
}
|
|
4972
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4973
5041
|
toDOM(view) {
|
|
4974
5042
|
const el = document.createElement("span");
|
|
4975
5043
|
this.render(el, {
|
|
@@ -5082,8 +5150,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5082
5150
|
const headerLevels = [];
|
|
5083
5151
|
const getHeaderLevels = (node, level) => {
|
|
5084
5152
|
invariant4(level > 0, void 0, {
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5153
|
+
F: __dxlog_file12,
|
|
5154
|
+
L: 179,
|
|
5087
5155
|
S: void 0,
|
|
5088
5156
|
A: [
|
|
5089
5157
|
"level > 0",
|
|
@@ -5121,8 +5189,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5121
5189
|
};
|
|
5122
5190
|
const getCurrentListLevel = () => {
|
|
5123
5191
|
invariant4(listLevels.length, void 0, {
|
|
5124
|
-
F:
|
|
5125
|
-
L:
|
|
5192
|
+
F: __dxlog_file12,
|
|
5193
|
+
L: 201,
|
|
5126
5194
|
S: void 0,
|
|
5127
5195
|
A: [
|
|
5128
5196
|
"listLevels.length",
|
|
@@ -5172,7 +5240,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5172
5240
|
from: mark.from,
|
|
5173
5241
|
to: mark.from + len,
|
|
5174
5242
|
deco: Decoration11.replace({
|
|
5175
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5243
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5176
5244
|
})
|
|
5177
5245
|
});
|
|
5178
5246
|
}
|
|
@@ -5439,7 +5507,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5439
5507
|
atomicDeco: atomicDeco.finish()
|
|
5440
5508
|
};
|
|
5441
5509
|
};
|
|
5442
|
-
var forceUpdate =
|
|
5510
|
+
var forceUpdate = StateEffect6.define();
|
|
5443
5511
|
var decorateMarkdown = (options = {}) => {
|
|
5444
5512
|
return [
|
|
5445
5513
|
ViewPlugin14.fromClass(class {
|
|
@@ -5511,8 +5579,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5511
5579
|
return {
|
|
5512
5580
|
pos: link.from,
|
|
5513
5581
|
end: link.to,
|
|
5514
|
-
|
|
5515
|
-
// above: true,
|
|
5582
|
+
above: true,
|
|
5516
5583
|
create: () => {
|
|
5517
5584
|
const el = document.createElement("div");
|
|
5518
5585
|
el.className = tooltipContent({});
|
|
@@ -5528,16 +5595,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5528
5595
|
};
|
|
5529
5596
|
}
|
|
5530
5597
|
};
|
|
5531
|
-
}, {
|
|
5532
|
-
// NOTE: 0 = default of 300ms.
|
|
5533
|
-
hoverTime: 1
|
|
5534
5598
|
});
|
|
5535
5599
|
};
|
|
5536
5600
|
|
|
5537
5601
|
// src/extensions/mention.ts
|
|
5538
5602
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5539
|
-
import { log as
|
|
5540
|
-
var
|
|
5603
|
+
import { log as log9 } from "@dxos/log";
|
|
5604
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5541
5605
|
var mention = ({ debug, onSearch }) => {
|
|
5542
5606
|
return autocompletion({
|
|
5543
5607
|
// TODO(burdon): Not working.
|
|
@@ -5549,10 +5613,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5549
5613
|
icons: false,
|
|
5550
5614
|
override: [
|
|
5551
5615
|
(context) => {
|
|
5552
|
-
|
|
5616
|
+
log9.info("completion context", {
|
|
5553
5617
|
context
|
|
5554
5618
|
}, {
|
|
5555
|
-
F:
|
|
5619
|
+
F: __dxlog_file13,
|
|
5556
5620
|
L: 27,
|
|
5557
5621
|
S: void 0,
|
|
5558
5622
|
C: (f, a) => f(...a)
|
|
@@ -5573,8 +5637,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5573
5637
|
};
|
|
5574
5638
|
|
|
5575
5639
|
// src/extensions/modal.ts
|
|
5576
|
-
import { StateEffect as
|
|
5577
|
-
var modalStateEffect =
|
|
5640
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5641
|
+
var modalStateEffect = StateEffect7.define();
|
|
5578
5642
|
var modalStateField = StateField9.define({
|
|
5579
5643
|
create: () => false,
|
|
5580
5644
|
update: (value, tr) => {
|
|
@@ -5635,7 +5699,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5635
5699
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5636
5700
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5637
5701
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5638
|
-
var
|
|
5702
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5639
5703
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5640
5704
|
return {
|
|
5641
5705
|
type,
|
|
@@ -5790,7 +5854,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5790
5854
|
}
|
|
5791
5855
|
case "BulletList": {
|
|
5792
5856
|
invariant5(current, void 0, {
|
|
5793
|
-
F:
|
|
5857
|
+
F: __dxlog_file14,
|
|
5794
5858
|
L: 219,
|
|
5795
5859
|
S: void 0,
|
|
5796
5860
|
A: [
|
|
@@ -5807,7 +5871,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5807
5871
|
}
|
|
5808
5872
|
case "ListItem": {
|
|
5809
5873
|
invariant5(parent, void 0, {
|
|
5810
|
-
F:
|
|
5874
|
+
F: __dxlog_file14,
|
|
5811
5875
|
L: 228,
|
|
5812
5876
|
S: void 0,
|
|
5813
5877
|
A: [
|
|
@@ -5849,7 +5913,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5849
5913
|
}
|
|
5850
5914
|
case "ListMark": {
|
|
5851
5915
|
invariant5(current, void 0, {
|
|
5852
|
-
F:
|
|
5916
|
+
F: __dxlog_file14,
|
|
5853
5917
|
L: 272,
|
|
5854
5918
|
S: void 0,
|
|
5855
5919
|
A: [
|
|
@@ -5863,7 +5927,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5863
5927
|
}
|
|
5864
5928
|
case "Task": {
|
|
5865
5929
|
invariant5(current, void 0, {
|
|
5866
|
-
F:
|
|
5930
|
+
F: __dxlog_file14,
|
|
5867
5931
|
L: 278,
|
|
5868
5932
|
S: void 0,
|
|
5869
5933
|
A: [
|
|
@@ -5876,7 +5940,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5876
5940
|
}
|
|
5877
5941
|
case "TaskMarker": {
|
|
5878
5942
|
invariant5(current, void 0, {
|
|
5879
|
-
F:
|
|
5943
|
+
F: __dxlog_file14,
|
|
5880
5944
|
L: 283,
|
|
5881
5945
|
S: void 0,
|
|
5882
5946
|
A: [
|
|
@@ -5892,7 +5956,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5892
5956
|
leave: (node) => {
|
|
5893
5957
|
if (node.name === "BulletList") {
|
|
5894
5958
|
invariant5(parent, void 0, {
|
|
5895
|
-
F:
|
|
5959
|
+
F: __dxlog_file14,
|
|
5896
5960
|
L: 291,
|
|
5897
5961
|
S: void 0,
|
|
5898
5962
|
A: [
|
|
@@ -5906,7 +5970,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5906
5970
|
}
|
|
5907
5971
|
});
|
|
5908
5972
|
invariant5(tree, void 0, {
|
|
5909
|
-
F:
|
|
5973
|
+
F: __dxlog_file14,
|
|
5910
5974
|
L: 298,
|
|
5911
5975
|
S: void 0,
|
|
5912
5976
|
A: [
|
|
@@ -6204,8 +6268,8 @@ import { mx as mx7 } from "@dxos/ui-theme";
|
|
|
6204
6268
|
// src/extensions/outliner/editor.ts
|
|
6205
6269
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6206
6270
|
import { ViewPlugin as ViewPlugin15 } from "@codemirror/view";
|
|
6207
|
-
import { log as
|
|
6208
|
-
var
|
|
6271
|
+
import { log as log10 } from "@dxos/log";
|
|
6272
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6209
6273
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6210
6274
|
var initialize = () => {
|
|
6211
6275
|
return ViewPlugin15.fromClass(class {
|
|
@@ -6337,7 +6401,7 @@ var editor = () => [
|
|
|
6337
6401
|
cancel = true;
|
|
6338
6402
|
return;
|
|
6339
6403
|
}
|
|
6340
|
-
|
|
6404
|
+
log10("change", {
|
|
6341
6405
|
item,
|
|
6342
6406
|
line: {
|
|
6343
6407
|
from: line.from,
|
|
@@ -6356,7 +6420,7 @@ var editor = () => [
|
|
|
6356
6420
|
length: insert.length
|
|
6357
6421
|
}
|
|
6358
6422
|
}, {
|
|
6359
|
-
F:
|
|
6423
|
+
F: __dxlog_file15,
|
|
6360
6424
|
L: 164,
|
|
6361
6425
|
S: void 0,
|
|
6362
6426
|
C: (f, a) => f(...a)
|
|
@@ -6364,10 +6428,10 @@ var editor = () => [
|
|
|
6364
6428
|
}
|
|
6365
6429
|
});
|
|
6366
6430
|
if (changes.length > 0) {
|
|
6367
|
-
|
|
6431
|
+
log10("modified,", {
|
|
6368
6432
|
changes
|
|
6369
6433
|
}, {
|
|
6370
|
-
F:
|
|
6434
|
+
F: __dxlog_file15,
|
|
6371
6435
|
L: 175,
|
|
6372
6436
|
S: void 0,
|
|
6373
6437
|
C: (f, a) => f(...a)
|
|
@@ -6378,8 +6442,8 @@ var editor = () => [
|
|
|
6378
6442
|
}
|
|
6379
6443
|
];
|
|
6380
6444
|
} else if (cancel) {
|
|
6381
|
-
|
|
6382
|
-
F:
|
|
6445
|
+
log10("cancel", void 0, {
|
|
6446
|
+
F: __dxlog_file15,
|
|
6383
6447
|
L: 178,
|
|
6384
6448
|
S: void 0,
|
|
6385
6449
|
C: (f, a) => f(...a)
|
|
@@ -6392,7 +6456,7 @@ var editor = () => [
|
|
|
6392
6456
|
|
|
6393
6457
|
// src/extensions/outliner/menu.ts
|
|
6394
6458
|
import { EditorView as EditorView24, ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6395
|
-
import { addEventListener } from "@dxos/async";
|
|
6459
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6396
6460
|
var menu = (options = {}) => [
|
|
6397
6461
|
ViewPlugin16.fromClass(class {
|
|
6398
6462
|
view;
|
|
@@ -6414,7 +6478,7 @@ var menu = (options = {}) => [
|
|
|
6414
6478
|
}
|
|
6415
6479
|
container.appendChild(this.tag);
|
|
6416
6480
|
const handler = () => this.scheduleUpdate();
|
|
6417
|
-
this.cleanup =
|
|
6481
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6418
6482
|
this.scheduleUpdate();
|
|
6419
6483
|
}
|
|
6420
6484
|
destroy() {
|
|
@@ -6493,7 +6557,7 @@ var outliner = (_options = {}) => [
|
|
|
6493
6557
|
}),
|
|
6494
6558
|
// Researve space for menu.
|
|
6495
6559
|
EditorView25.contentAttributes.of({
|
|
6496
|
-
class: "
|
|
6560
|
+
class: "w-full !mr-[3rem]"
|
|
6497
6561
|
})
|
|
6498
6562
|
];
|
|
6499
6563
|
var decorations = () => [
|
|
@@ -6557,10 +6621,10 @@ var decorations = () => [
|
|
|
6557
6621
|
marginBottom: "2px"
|
|
6558
6622
|
},
|
|
6559
6623
|
".cm-list-item-focused": {
|
|
6560
|
-
borderColor: "var(--
|
|
6624
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6561
6625
|
},
|
|
6562
6626
|
"&:focus-within .cm-list-item-selected": {
|
|
6563
|
-
borderColor: "var(--
|
|
6627
|
+
borderColor: "var(--color-separator)"
|
|
6564
6628
|
}
|
|
6565
6629
|
}))
|
|
6566
6630
|
];
|
|
@@ -6677,7 +6741,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6677
6741
|
}
|
|
6678
6742
|
toDOM(_view) {
|
|
6679
6743
|
const root = document.createElement("div");
|
|
6680
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6744
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6681
6745
|
this._options.addBlockContainer?.({
|
|
6682
6746
|
link: this._link,
|
|
6683
6747
|
el: root
|
|
@@ -6892,7 +6956,7 @@ var mixedParser = (registry) => {
|
|
|
6892
6956
|
};
|
|
6893
6957
|
|
|
6894
6958
|
// src/extensions/tags/streamer.ts
|
|
6895
|
-
import { StateEffect as
|
|
6959
|
+
import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
|
|
6896
6960
|
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6897
6961
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6898
6962
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
@@ -6904,7 +6968,7 @@ var streamer = (options = {}) => {
|
|
|
6904
6968
|
].filter(isTruthy4);
|
|
6905
6969
|
};
|
|
6906
6970
|
var cursor = () => {
|
|
6907
|
-
const hideCursor =
|
|
6971
|
+
const hideCursor = StateEffect8.define();
|
|
6908
6972
|
const showCursor = StateField12.define({
|
|
6909
6973
|
create: () => true,
|
|
6910
6974
|
update: (value, tr) => {
|
|
@@ -6974,9 +7038,9 @@ var CursorWidget = class extends WidgetType9 {
|
|
|
6974
7038
|
};
|
|
6975
7039
|
var fadeIn = (options = {}) => {
|
|
6976
7040
|
const FADE_IN_DURATION = 1e3;
|
|
6977
|
-
const DEFAULT_REMOVAL_DELAY =
|
|
7041
|
+
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
6978
7042
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6979
|
-
const removeDecoration =
|
|
7043
|
+
const removeDecoration = StateEffect8.define();
|
|
6980
7044
|
const fadeField = StateField12.define({
|
|
6981
7045
|
create: () => Decoration14.none,
|
|
6982
7046
|
update: (decorations2, tr) => {
|
|
@@ -7086,17 +7150,17 @@ var fadeIn = (options = {}) => {
|
|
|
7086
7150
|
|
|
7087
7151
|
// src/extensions/tags/xml-tags.ts
|
|
7088
7152
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7089
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7153
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
|
|
7090
7154
|
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin19, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7091
7155
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7092
|
-
import { log as
|
|
7156
|
+
import { log as log11 } from "@dxos/log";
|
|
7093
7157
|
|
|
7094
7158
|
// src/extensions/tags/xml-util.ts
|
|
7095
7159
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7096
|
-
var
|
|
7160
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7097
7161
|
var nodeToJson = (state, node) => {
|
|
7098
7162
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7099
|
-
F:
|
|
7163
|
+
F: __dxlog_file16,
|
|
7100
7164
|
L: 18,
|
|
7101
7165
|
S: void 0,
|
|
7102
7166
|
A: [
|
|
@@ -7160,16 +7224,16 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7224
|
};
|
|
7161
7225
|
|
|
7162
7226
|
// src/extensions/tags/xml-tags.ts
|
|
7163
|
-
var
|
|
7164
|
-
var navigatePreviousEffect =
|
|
7165
|
-
var navigateNextEffect =
|
|
7227
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7228
|
+
var navigatePreviousEffect = StateEffect9.define();
|
|
7229
|
+
var navigateNextEffect = StateEffect9.define();
|
|
7166
7230
|
var getXmlTextChild = (children) => {
|
|
7167
7231
|
const child = children?.[0];
|
|
7168
7232
|
return typeof child === "string" ? child : null;
|
|
7169
7233
|
};
|
|
7170
|
-
var xmlTagContextEffect =
|
|
7171
|
-
var xmlTagResetEffect =
|
|
7172
|
-
var xmlTagUpdateEffect =
|
|
7234
|
+
var xmlTagContextEffect = StateEffect9.define();
|
|
7235
|
+
var xmlTagResetEffect = StateEffect9.define();
|
|
7236
|
+
var xmlTagUpdateEffect = StateEffect9.define();
|
|
7173
7237
|
var widgetContextStateField = StateField13.define({
|
|
7174
7238
|
create: () => void 0,
|
|
7175
7239
|
update: (value, tr) => {
|
|
@@ -7190,11 +7254,11 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7190
7254
|
}
|
|
7191
7255
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7192
7256
|
const { id, value } = effect.value;
|
|
7193
|
-
|
|
7257
|
+
log11("widget updated", {
|
|
7194
7258
|
id,
|
|
7195
7259
|
value
|
|
7196
7260
|
}, {
|
|
7197
|
-
F:
|
|
7261
|
+
F: __dxlog_file17,
|
|
7198
7262
|
L: 153,
|
|
7199
7263
|
S: void 0,
|
|
7200
7264
|
C: (f, a) => f(...a)
|
|
@@ -7225,11 +7289,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7225
7289
|
const widgets = /* @__PURE__ */ new Map();
|
|
7226
7290
|
const notifier = {
|
|
7227
7291
|
mounted: (state) => {
|
|
7228
|
-
|
|
7292
|
+
log11("widget mounted", {
|
|
7229
7293
|
id: state.id,
|
|
7230
7294
|
tag: state.props._tag
|
|
7231
7295
|
}, {
|
|
7232
|
-
F:
|
|
7296
|
+
F: __dxlog_file17,
|
|
7233
7297
|
L: 206,
|
|
7234
7298
|
S: void 0,
|
|
7235
7299
|
C: (f, a) => f(...a)
|
|
@@ -7241,11 +7305,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7241
7305
|
},
|
|
7242
7306
|
unmounted: (id) => {
|
|
7243
7307
|
const state = widgets.get(id);
|
|
7244
|
-
|
|
7308
|
+
log11("widget unmounted", {
|
|
7245
7309
|
id,
|
|
7246
7310
|
tag: state?.props._tag
|
|
7247
7311
|
}, {
|
|
7248
|
-
F:
|
|
7312
|
+
F: __dxlog_file17,
|
|
7249
7313
|
L: 212,
|
|
7250
7314
|
S: void 0,
|
|
7251
7315
|
C: (f, a) => f(...a)
|
|
@@ -7307,11 +7371,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7307
7371
|
anchor: line.from,
|
|
7308
7372
|
head: line.from
|
|
7309
7373
|
},
|
|
7310
|
-
effects:
|
|
7311
|
-
line: line.number,
|
|
7312
|
-
|
|
7313
|
-
offset: -16
|
|
7314
|
-
}
|
|
7374
|
+
effects: scrollerLineEffect.of({
|
|
7375
|
+
line: line.number - 1,
|
|
7376
|
+
offset: -16
|
|
7315
7377
|
})
|
|
7316
7378
|
});
|
|
7317
7379
|
continue;
|
|
@@ -7342,11 +7404,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7342
7404
|
anchor: line.to,
|
|
7343
7405
|
head: line.to
|
|
7344
7406
|
},
|
|
7345
|
-
effects:
|
|
7346
|
-
line: line.number,
|
|
7347
|
-
|
|
7348
|
-
offset: -16
|
|
7349
|
-
}
|
|
7407
|
+
effects: scrollerLineEffect.of({
|
|
7408
|
+
line: line.number - 1,
|
|
7409
|
+
offset: -16
|
|
7350
7410
|
})
|
|
7351
7411
|
});
|
|
7352
7412
|
} else {
|
|
@@ -7356,11 +7416,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7356
7416
|
anchor: line.to,
|
|
7357
7417
|
head: line.to
|
|
7358
7418
|
},
|
|
7359
|
-
effects:
|
|
7360
|
-
line: line.number,
|
|
7361
|
-
|
|
7362
|
-
position: "end"
|
|
7363
|
-
}
|
|
7419
|
+
effects: scrollerLineEffect.of({
|
|
7420
|
+
line: line.number - 1,
|
|
7421
|
+
position: "end"
|
|
7364
7422
|
})
|
|
7365
7423
|
});
|
|
7366
7424
|
}
|
|
@@ -7407,6 +7465,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7407
7465
|
update: ({ from, decorations: decorations2 }, tr) => {
|
|
7408
7466
|
for (const effect of tr.effects) {
|
|
7409
7467
|
if (effect.is(xmlTagResetEffect)) {
|
|
7468
|
+
if (tr.docChanged) {
|
|
7469
|
+
return buildDecorations4(tr.state, {
|
|
7470
|
+
from: 0,
|
|
7471
|
+
to: tr.state.doc.length
|
|
7472
|
+
}, registry, notifier);
|
|
7473
|
+
}
|
|
7410
7474
|
return {
|
|
7411
7475
|
from: 0,
|
|
7412
7476
|
decorations: Decoration15.none
|
|
@@ -7417,12 +7481,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7417
7481
|
const { state } = tr;
|
|
7418
7482
|
const reset = tr.changes.touchesRange(0, from);
|
|
7419
7483
|
if (reset) {
|
|
7420
|
-
|
|
7484
|
+
log11("document reset", {
|
|
7421
7485
|
from,
|
|
7422
7486
|
to: state.doc.length
|
|
7423
7487
|
}, {
|
|
7424
|
-
F:
|
|
7425
|
-
L:
|
|
7488
|
+
F: __dxlog_file17,
|
|
7489
|
+
L: 374,
|
|
7426
7490
|
S: void 0,
|
|
7427
7491
|
C: (f, a) => f(...a)
|
|
7428
7492
|
});
|
|
@@ -7503,9 +7567,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7503
7567
|
}
|
|
7504
7568
|
}
|
|
7505
7569
|
} catch (err) {
|
|
7506
|
-
|
|
7507
|
-
F:
|
|
7508
|
-
L:
|
|
7570
|
+
log11.catch(err, void 0, {
|
|
7571
|
+
F: __dxlog_file17,
|
|
7572
|
+
L: 459,
|
|
7509
7573
|
S: void 0,
|
|
7510
7574
|
C: (f, a) => f(...a)
|
|
7511
7575
|
});
|
|
@@ -7529,8 +7593,8 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7529
7593
|
constructor(id, Component, props, notifier) {
|
|
7530
7594
|
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier;
|
|
7531
7595
|
invariant7(id, void 0, {
|
|
7532
|
-
F:
|
|
7533
|
-
L:
|
|
7596
|
+
F: __dxlog_file17,
|
|
7597
|
+
L: 485,
|
|
7534
7598
|
S: this,
|
|
7535
7599
|
A: [
|
|
7536
7600
|
"id",
|
|
@@ -7659,6 +7723,7 @@ export {
|
|
|
7659
7723
|
convertTreeToJson,
|
|
7660
7724
|
createBasicExtensions,
|
|
7661
7725
|
createComment,
|
|
7726
|
+
createCrawler,
|
|
7662
7727
|
createDataExtensions,
|
|
7663
7728
|
createEditorStateStore,
|
|
7664
7729
|
createEditorStateTransaction,
|
|
@@ -7739,9 +7804,10 @@ export {
|
|
|
7739
7804
|
removeStyle,
|
|
7740
7805
|
replacer,
|
|
7741
7806
|
scrollThreadIntoView,
|
|
7742
|
-
scrollToBottomEffect,
|
|
7743
7807
|
scrollToLine,
|
|
7744
|
-
|
|
7808
|
+
scroller,
|
|
7809
|
+
scrollerCrawlEffect,
|
|
7810
|
+
scrollerLineEffect,
|
|
7745
7811
|
selectionState,
|
|
7746
7812
|
setBlockquote,
|
|
7747
7813
|
setComments,
|
|
@@ -7749,7 +7815,6 @@ export {
|
|
|
7749
7815
|
setSelection,
|
|
7750
7816
|
setStyle,
|
|
7751
7817
|
singleValueFacet,
|
|
7752
|
-
smoothScroll,
|
|
7753
7818
|
stackItemContentEditorClassNames,
|
|
7754
7819
|
staticCompletion,
|
|
7755
7820
|
streamer,
|