@dxos/ui-editor 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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 +493 -418
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +493 -418
- 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/automerge/automerge.d.ts.map +1 -1
- 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/preview/preview.d.ts +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 +32 -32
- 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/automerge/automerge.ts +6 -5
- 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 +8 -8
- package/src/extensions/scroller.ts +232 -0
- package/src/extensions/selection.ts +1 -1
- 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 -29
- 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
|
@@ -14,17 +14,17 @@ import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
|
|
14
14
|
|
|
15
15
|
// src/defaults.ts
|
|
16
16
|
import { mx } from "@dxos/ui-theme";
|
|
17
|
-
var editorWidth = "!
|
|
17
|
+
var editorWidth = "!mx-auto w-full max-w-[min(50rem,100%-4rem)]";
|
|
18
18
|
var editorSlots = {
|
|
19
19
|
scroll: {
|
|
20
|
-
className: "
|
|
20
|
+
className: "pt-2"
|
|
21
21
|
},
|
|
22
22
|
content: {
|
|
23
23
|
className: editorWidth
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
|
|
27
|
-
var stackItemContentEditorClassNames = (role) => mx("p-0.5 dx-focus-ring-inset
|
|
27
|
+
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");
|
|
28
28
|
|
|
29
29
|
// src/extensions/annotations.ts
|
|
30
30
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -59,7 +59,7 @@ var annotations = ({ match } = {}) => {
|
|
|
59
59
|
".cm-annotation": {
|
|
60
60
|
textDecoration: "underline",
|
|
61
61
|
textDecorationStyle: "wavy",
|
|
62
|
-
textDecorationColor: "var(--
|
|
62
|
+
textDecorationColor: "var(--color-error-text)"
|
|
63
63
|
}
|
|
64
64
|
})
|
|
65
65
|
];
|
|
@@ -502,192 +502,210 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
502
502
|
];
|
|
503
503
|
};
|
|
504
504
|
|
|
505
|
-
// src/extensions/
|
|
506
|
-
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
505
|
+
// src/extensions/auto-scroll.ts
|
|
507
506
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
508
|
-
import {
|
|
507
|
+
import { addEventListener, combine, throttle } from "@dxos/async";
|
|
509
508
|
import { Domino } from "@dxos/ui";
|
|
510
509
|
|
|
511
|
-
// src/extensions/
|
|
510
|
+
// src/extensions/scroller.ts
|
|
512
511
|
import { StateEffect } from "@codemirror/state";
|
|
513
512
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
514
|
-
|
|
515
|
-
var
|
|
516
|
-
|
|
513
|
+
import { log as log2 } from "@dxos/log";
|
|
514
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
515
|
+
var scrollerLineEffect = StateEffect.define();
|
|
516
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
517
|
+
var scrollToLine = (view, options) => {
|
|
518
|
+
view.dispatch({
|
|
519
|
+
effects: scrollerLineEffect.of(options)
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
523
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
517
524
|
view;
|
|
525
|
+
crawler;
|
|
518
526
|
constructor(view) {
|
|
519
527
|
this.view = view;
|
|
528
|
+
this.crawler = createCrawler(this.view);
|
|
520
529
|
}
|
|
521
530
|
// No-op.
|
|
522
531
|
destroy() {
|
|
532
|
+
this.crawler.cancel();
|
|
523
533
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const scroller = this.view.scrollDOM;
|
|
531
|
-
const targetLine = Math.max(0, lineNumber - 1);
|
|
532
|
-
if (behavior === "instant") {
|
|
533
|
-
requestAnimationFrame(() => {
|
|
534
|
-
this.view.dispatch({
|
|
535
|
-
selection: {
|
|
536
|
-
anchor: doc.line(targetLine + 1).from
|
|
537
|
-
},
|
|
538
|
-
scrollIntoView: true
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
if (targetLine >= doc.lines) {
|
|
544
|
-
const targetScrollTop2 = scroller.scrollHeight - scroller.clientHeight + (animOffset || 0);
|
|
545
|
-
this.animateScroll(scroller, targetScrollTop2);
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
const lineStart = doc.line(targetLine + 1).from;
|
|
549
|
-
const coords = this.view.coordsAtPos(lineStart);
|
|
550
|
-
if (!coords) {
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
const currentScrollTop = scroller.scrollTop;
|
|
554
|
-
const scrollerRect = scroller.getBoundingClientRect();
|
|
555
|
-
const maxScrollTop = scroller.scrollHeight - scroller.clientHeight;
|
|
556
|
-
let targetScrollTop;
|
|
557
|
-
if (animPosition === "end") {
|
|
558
|
-
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + animOffset;
|
|
534
|
+
cancel() {
|
|
535
|
+
this.crawler.cancel();
|
|
536
|
+
}
|
|
537
|
+
crawl(start = false) {
|
|
538
|
+
if (start) {
|
|
539
|
+
this.crawler.scroll();
|
|
559
540
|
} else {
|
|
560
|
-
|
|
541
|
+
this.crawler.cancel();
|
|
561
542
|
}
|
|
562
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
563
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
564
543
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
544
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
545
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
546
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
547
|
+
const doc = this.view.state.doc;
|
|
548
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
549
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
550
|
+
const lineStart = doc.line(line + 1).from;
|
|
551
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
552
|
+
if (coords) {
|
|
553
|
+
const currentScrollTop = scrollTop;
|
|
554
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
555
|
+
if (position === "end") {
|
|
556
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
557
|
+
} else {
|
|
558
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
559
|
+
}
|
|
560
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
561
|
+
}
|
|
571
562
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
563
|
+
requestAnimationFrame(() => {
|
|
564
|
+
this.view.scrollDOM.scrollTo({
|
|
565
|
+
top: targetScrollTop,
|
|
566
|
+
behavior
|
|
567
|
+
});
|
|
575
568
|
});
|
|
576
569
|
}
|
|
577
570
|
});
|
|
578
571
|
return [
|
|
579
572
|
scrollPlugin,
|
|
580
|
-
//
|
|
573
|
+
// Listen for effect.s
|
|
581
574
|
EditorView4.updateListener.of((update2) => {
|
|
582
575
|
update2.transactions.forEach((transaction) => {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
});
|
|
576
|
+
try {
|
|
577
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
578
|
+
if (plugin) {
|
|
579
|
+
for (const effect of transaction.effects) {
|
|
580
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
581
|
+
plugin.crawl(effect.value);
|
|
582
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
583
|
+
plugin.scroll(effect.value);
|
|
584
|
+
}
|
|
593
585
|
}
|
|
594
586
|
}
|
|
587
|
+
} catch (err) {
|
|
588
|
+
log2.catch(err, void 0, {
|
|
589
|
+
F: __dxlog_file2,
|
|
590
|
+
L: 145,
|
|
591
|
+
S: void 0,
|
|
592
|
+
C: (f, a) => f(...a)
|
|
593
|
+
});
|
|
595
594
|
}
|
|
596
595
|
});
|
|
596
|
+
}),
|
|
597
|
+
// Styles.
|
|
598
|
+
EditorView4.theme({
|
|
599
|
+
".cm-content": {
|
|
600
|
+
paddingBottom: `${overScroll}px`
|
|
601
|
+
},
|
|
602
|
+
".cm-scroller": {
|
|
603
|
+
overflowAnchor: "none",
|
|
604
|
+
paddingBottom: "0"
|
|
605
|
+
},
|
|
606
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
607
|
+
display: "none"
|
|
608
|
+
},
|
|
609
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
610
|
+
background: "transparent",
|
|
611
|
+
transition: "background 0.15s"
|
|
612
|
+
},
|
|
613
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
614
|
+
background: "var(--color-scrollbar-thumb)"
|
|
615
|
+
},
|
|
616
|
+
".cm-scroll-button": {
|
|
617
|
+
position: "absolute",
|
|
618
|
+
bottom: "0.5rem",
|
|
619
|
+
right: "1rem"
|
|
620
|
+
}
|
|
597
621
|
})
|
|
598
622
|
];
|
|
599
623
|
};
|
|
600
|
-
|
|
601
|
-
view.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
624
|
+
function createCrawler(view, k = 0.3, maxStep = 2, targetDelta = 0.5) {
|
|
625
|
+
const el = view.scrollDOM;
|
|
626
|
+
let currentTop = 0;
|
|
627
|
+
let rafId = null;
|
|
628
|
+
function frame() {
|
|
629
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
630
|
+
const delta = targetTop - currentTop;
|
|
631
|
+
const absDelta = Math.abs(delta);
|
|
632
|
+
if (absDelta < targetDelta) {
|
|
633
|
+
el.scrollTop = targetTop;
|
|
634
|
+
currentTop = targetTop;
|
|
635
|
+
rafId = null;
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const step = Math.sign(delta) * Math.min(absDelta, Math.max(1, Math.min(absDelta * k, maxStep)));
|
|
639
|
+
currentTop += step;
|
|
640
|
+
el.scrollTop = currentTop;
|
|
641
|
+
rafId = requestAnimationFrame(frame);
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
scroll: () => {
|
|
645
|
+
if (rafId === null) {
|
|
646
|
+
currentTop = el.scrollTop;
|
|
647
|
+
rafId = requestAnimationFrame(frame);
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
cancel: () => {
|
|
651
|
+
if (rafId !== null) {
|
|
652
|
+
cancelAnimationFrame(rafId);
|
|
653
|
+
rafId = null;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
608
658
|
|
|
609
|
-
// src/extensions/
|
|
610
|
-
var
|
|
611
|
-
var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDelay = 1e3, onAutoScroll } = {}) => {
|
|
659
|
+
// src/extensions/auto-scroll.ts
|
|
660
|
+
var autoScroll = (_ = {}) => {
|
|
612
661
|
let buttonContainer;
|
|
613
|
-
let hideTimeout;
|
|
614
|
-
let lastScrollTop = 0;
|
|
615
662
|
let isPinned = true;
|
|
616
|
-
const setPinned = (
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
};
|
|
620
|
-
const hideScrollbar = (view) => {
|
|
621
|
-
view.scrollDOM.classList.add("cm-hide-scrollbar");
|
|
622
|
-
clearTimeout(hideTimeout);
|
|
623
|
-
hideTimeout = setTimeout(() => {
|
|
624
|
-
view.scrollDOM.classList.remove("cm-hide-scrollbar");
|
|
625
|
-
}, 1e3);
|
|
626
|
-
};
|
|
627
|
-
const scrollToBottom = (view, behavior) => {
|
|
628
|
-
setPinned(true);
|
|
629
|
-
hideScrollbar(view);
|
|
630
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
631
|
-
view.dispatch({
|
|
632
|
-
selection: {
|
|
633
|
-
anchor: line.to,
|
|
634
|
-
head: line.to
|
|
635
|
-
},
|
|
636
|
-
effects: scrollToLineEffect.of({
|
|
637
|
-
line: line.number,
|
|
638
|
-
options: {
|
|
639
|
-
position: "end",
|
|
640
|
-
offset: threshold,
|
|
641
|
-
behavior
|
|
642
|
-
}
|
|
643
|
-
})
|
|
644
|
-
});
|
|
663
|
+
const setPinned = (pinned) => {
|
|
664
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
665
|
+
isPinned = pinned;
|
|
645
666
|
};
|
|
646
|
-
const checkDistance = debounce((view) => {
|
|
647
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
648
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
649
|
-
const distanceFromBottom = coords ? coords.bottom - scrollerRect.bottom : 0;
|
|
650
|
-
setPinned(distanceFromBottom < 0);
|
|
651
|
-
}, 1e3);
|
|
652
|
-
const triggerUpdate = debounce((view) => scrollToBottom(view), throttleDelay);
|
|
653
667
|
return [
|
|
654
668
|
// Update listener for logging when scrolling is needed.
|
|
655
|
-
EditorView5.updateListener.of(({ view,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
669
|
+
EditorView5.updateListener.of(({ view, heightChanged, state }) => {
|
|
670
|
+
if (heightChanged) {
|
|
671
|
+
if (isPinned) {
|
|
672
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
673
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
674
|
+
if (delta > 0 && scrollTop > 0) {
|
|
675
|
+
setPinned(true);
|
|
676
|
+
view.dispatch({
|
|
677
|
+
effects: scrollerCrawlEffect.of(true)
|
|
678
|
+
});
|
|
679
|
+
} else if (delta < 0) {
|
|
680
|
+
setPinned(false);
|
|
660
681
|
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
665
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
666
|
-
const distanceFromBottom = coords ? scrollerRect.bottom - coords.bottom : 0;
|
|
667
|
-
if (autoScroll2 && distanceFromBottom < threshold) {
|
|
668
|
-
const shouldScroll = onAutoScroll?.({
|
|
669
|
-
view,
|
|
670
|
-
distanceFromBottom
|
|
671
|
-
}) ?? true;
|
|
672
|
-
if (shouldScroll) {
|
|
673
|
-
triggerUpdate(view);
|
|
682
|
+
} else {
|
|
683
|
+
if (state.doc.length === 0) {
|
|
684
|
+
setPinned(true);
|
|
674
685
|
}
|
|
675
|
-
} else if (distanceFromBottom < 0) {
|
|
676
|
-
setPinned(false);
|
|
677
686
|
}
|
|
678
687
|
}
|
|
679
688
|
}),
|
|
680
|
-
// Detect user scroll.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
690
|
+
ViewPlugin6.fromClass(class {
|
|
691
|
+
cleanup;
|
|
692
|
+
constructor(view) {
|
|
693
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
694
|
+
requestAnimationFrame(() => {
|
|
695
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
696
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
697
|
+
const pinned = delta === 0;
|
|
698
|
+
setPinned(pinned);
|
|
699
|
+
if (!pinned) {
|
|
700
|
+
view.dispatch({
|
|
701
|
+
effects: scrollerCrawlEffect.of(false)
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
}, 500));
|
|
706
|
+
}
|
|
707
|
+
destroy() {
|
|
708
|
+
this.cleanup();
|
|
691
709
|
}
|
|
692
710
|
}),
|
|
693
711
|
// Scroll button.
|
|
@@ -696,34 +714,33 @@ var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDel
|
|
|
696
714
|
const icon = Domino.of("dx-icon").attributes({
|
|
697
715
|
icon: "ph--arrow-down--regular"
|
|
698
716
|
});
|
|
699
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
717
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
700
718
|
"data-density": "fine"
|
|
701
719
|
}).children(icon).on("click", () => {
|
|
702
|
-
|
|
720
|
+
setPinned(true);
|
|
721
|
+
view.dispatch({
|
|
722
|
+
effects: scrollerLineEffect.of({
|
|
723
|
+
line: -1,
|
|
724
|
+
position: "end",
|
|
725
|
+
behavior: "smooth"
|
|
726
|
+
})
|
|
727
|
+
});
|
|
703
728
|
});
|
|
704
729
|
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").children(button).root;
|
|
705
730
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
706
731
|
}
|
|
707
|
-
}),
|
|
708
|
-
// Styles.
|
|
709
|
-
EditorView5.theme({
|
|
710
|
-
".cm-scroller": {
|
|
711
|
-
scrollbarWidth: "thin"
|
|
712
|
-
},
|
|
713
|
-
".cm-scroller.cm-hide-scrollbar": {
|
|
714
|
-
scrollbarWidth: "none"
|
|
715
|
-
},
|
|
716
|
-
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
717
|
-
display: "none"
|
|
718
|
-
},
|
|
719
|
-
".cm-scroll-button": {
|
|
720
|
-
position: "absolute",
|
|
721
|
-
bottom: "0.5rem",
|
|
722
|
-
right: "1rem"
|
|
723
|
-
}
|
|
724
732
|
})
|
|
725
733
|
];
|
|
726
734
|
};
|
|
735
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
736
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
737
|
+
passive: true
|
|
738
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
739
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
740
|
+
onUserScroll();
|
|
741
|
+
}
|
|
742
|
+
}));
|
|
743
|
+
}
|
|
727
744
|
|
|
728
745
|
// src/extensions/automerge/automerge.ts
|
|
729
746
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -737,15 +754,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
737
754
|
|
|
738
755
|
// src/extensions/automerge/cursor.ts
|
|
739
756
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
740
|
-
import { log as
|
|
741
|
-
var
|
|
757
|
+
import { log as log3 } from "@dxos/log";
|
|
758
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
742
759
|
var cursorConverter = (accessor) => ({
|
|
743
760
|
toCursor: (pos, assoc) => {
|
|
744
761
|
try {
|
|
745
762
|
return toCursor(accessor, pos, assoc);
|
|
746
763
|
} catch (err) {
|
|
747
|
-
|
|
748
|
-
F:
|
|
764
|
+
log3.catch(err, void 0, {
|
|
765
|
+
F: __dxlog_file3,
|
|
749
766
|
L: 15,
|
|
750
767
|
S: void 0,
|
|
751
768
|
C: (f, a) => f(...a)
|
|
@@ -757,8 +774,8 @@ var cursorConverter = (accessor) => ({
|
|
|
757
774
|
try {
|
|
758
775
|
return fromCursor(accessor, cursor2);
|
|
759
776
|
} catch (err) {
|
|
760
|
-
|
|
761
|
-
F:
|
|
777
|
+
log3.catch(err, void 0, {
|
|
778
|
+
F: __dxlog_file3,
|
|
762
779
|
L: 24,
|
|
763
780
|
S: void 0,
|
|
764
781
|
C: (f, a) => f(...a)
|
|
@@ -769,10 +786,10 @@ var cursorConverter = (accessor) => ({
|
|
|
769
786
|
});
|
|
770
787
|
|
|
771
788
|
// src/extensions/automerge/defs.ts
|
|
772
|
-
import { Annotation, StateEffect as
|
|
789
|
+
import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
|
|
773
790
|
var getPath = (state, field) => state.field(field).path;
|
|
774
791
|
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
775
|
-
var updateHeadsEffect =
|
|
792
|
+
var updateHeadsEffect = StateEffect2.define({});
|
|
776
793
|
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
|
777
794
|
newHeads
|
|
778
795
|
});
|
|
@@ -783,7 +800,7 @@ var isReconcile = (tr) => {
|
|
|
783
800
|
|
|
784
801
|
// src/extensions/automerge/sync.ts
|
|
785
802
|
import { next as A2 } from "@automerge/automerge";
|
|
786
|
-
import { log as
|
|
803
|
+
import { log as log4 } from "@dxos/log";
|
|
787
804
|
|
|
788
805
|
// src/extensions/automerge/update-automerge.ts
|
|
789
806
|
import { next as A } from "@automerge/automerge";
|
|
@@ -924,7 +941,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
924
941
|
};
|
|
925
942
|
|
|
926
943
|
// src/extensions/automerge/sync.ts
|
|
927
|
-
var
|
|
944
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
928
945
|
var Syncer = class {
|
|
929
946
|
_handle;
|
|
930
947
|
_state;
|
|
@@ -947,8 +964,8 @@ var Syncer = class {
|
|
|
947
964
|
this._pending = false;
|
|
948
965
|
}
|
|
949
966
|
onEditorChange(view) {
|
|
950
|
-
|
|
951
|
-
F:
|
|
967
|
+
log4("onEditorChange", void 0, {
|
|
968
|
+
F: __dxlog_file4,
|
|
952
969
|
L: 45,
|
|
953
970
|
S: this,
|
|
954
971
|
C: (f, a) => f(...a)
|
|
@@ -963,8 +980,8 @@ var Syncer = class {
|
|
|
963
980
|
}
|
|
964
981
|
}
|
|
965
982
|
onAutomergeChange(view) {
|
|
966
|
-
|
|
967
|
-
F:
|
|
983
|
+
log4("onAutomergeChange", void 0, {
|
|
984
|
+
F: __dxlog_file4,
|
|
968
985
|
L: 60,
|
|
969
986
|
S: this,
|
|
970
987
|
C: (f, a) => f(...a)
|
|
@@ -1030,6 +1047,15 @@ var automerge = (accessor) => {
|
|
|
1030
1047
|
const value = DocAccessor.getValue(accessor);
|
|
1031
1048
|
const current = this._view.state.doc.toString();
|
|
1032
1049
|
if (value !== current) {
|
|
1050
|
+
console.warn("ENABLING INITIAL SYNC -- THIS MAY BE A REGRESSION");
|
|
1051
|
+
this._view.dispatch({
|
|
1052
|
+
changes: {
|
|
1053
|
+
from: 0,
|
|
1054
|
+
to: this._view.state.doc.length,
|
|
1055
|
+
insert: value
|
|
1056
|
+
},
|
|
1057
|
+
annotations: initialSync
|
|
1058
|
+
});
|
|
1033
1059
|
}
|
|
1034
1060
|
});
|
|
1035
1061
|
}
|
|
@@ -1057,7 +1083,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1057
1083
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1058
1084
|
import { Event } from "@dxos/async";
|
|
1059
1085
|
import { Context } from "@dxos/context";
|
|
1060
|
-
var
|
|
1086
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1061
1087
|
var dummyProvider = {
|
|
1062
1088
|
remoteStateChange: new Event(),
|
|
1063
1089
|
open: () => {
|
|
@@ -1081,7 +1107,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1081
1107
|
};
|
|
1082
1108
|
var RemoteSelectionsDecorator = class {
|
|
1083
1109
|
_ctx = new Context(void 0, {
|
|
1084
|
-
F:
|
|
1110
|
+
F: __dxlog_file5,
|
|
1085
1111
|
L: 80
|
|
1086
1112
|
});
|
|
1087
1113
|
_cursorConverter;
|
|
@@ -1294,8 +1320,8 @@ var styles = EditorView7.theme({
|
|
|
1294
1320
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1295
1321
|
import { Context as Context2 } from "@dxos/context";
|
|
1296
1322
|
import { invariant } from "@dxos/invariant";
|
|
1297
|
-
import { log as
|
|
1298
|
-
var
|
|
1323
|
+
import { log as log5 } from "@dxos/log";
|
|
1324
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1299
1325
|
var DEBOUNCE_INTERVAL = 100;
|
|
1300
1326
|
var SpaceAwarenessProvider = class {
|
|
1301
1327
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1315,7 +1341,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1315
1341
|
}
|
|
1316
1342
|
open() {
|
|
1317
1343
|
this._ctx = new Context2(void 0, {
|
|
1318
|
-
F:
|
|
1344
|
+
F: __dxlog_file6,
|
|
1319
1345
|
L: 57
|
|
1320
1346
|
});
|
|
1321
1347
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1342,10 +1368,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1342
1368
|
void this._messenger.postMessage(this._channel, {
|
|
1343
1369
|
kind: "query"
|
|
1344
1370
|
}).catch((err) => {
|
|
1345
|
-
|
|
1371
|
+
log5.debug("failed to query awareness", {
|
|
1346
1372
|
err
|
|
1347
1373
|
}, {
|
|
1348
|
-
F:
|
|
1374
|
+
F: __dxlog_file6,
|
|
1349
1375
|
L: 91,
|
|
1350
1376
|
S: this,
|
|
1351
1377
|
C: (f, a) => f(...a)
|
|
@@ -1362,7 +1388,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1362
1388
|
}
|
|
1363
1389
|
update(position) {
|
|
1364
1390
|
invariant(this._postTask, void 0, {
|
|
1365
|
-
F:
|
|
1391
|
+
F: __dxlog_file6,
|
|
1366
1392
|
L: 106,
|
|
1367
1393
|
S: this,
|
|
1368
1394
|
A: [
|
|
@@ -1379,7 +1405,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1379
1405
|
}
|
|
1380
1406
|
_handleQueryMessage() {
|
|
1381
1407
|
invariant(this._postTask, void 0, {
|
|
1382
|
-
F:
|
|
1408
|
+
F: __dxlog_file6,
|
|
1383
1409
|
L: 117,
|
|
1384
1410
|
S: this,
|
|
1385
1411
|
A: [
|
|
@@ -1391,7 +1417,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1391
1417
|
}
|
|
1392
1418
|
_handlePostMessage(message) {
|
|
1393
1419
|
invariant(message.kind === "post", void 0, {
|
|
1394
|
-
F:
|
|
1420
|
+
F: __dxlog_file6,
|
|
1395
1421
|
L: 122,
|
|
1396
1422
|
S: this,
|
|
1397
1423
|
A: [
|
|
@@ -1407,9 +1433,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1407
1433
|
// src/extensions/blast.ts
|
|
1408
1434
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1409
1435
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1410
|
-
import { throttle } from "@dxos/async";
|
|
1436
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1411
1437
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1412
|
-
var
|
|
1438
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1413
1439
|
var defaultOptions = {
|
|
1414
1440
|
effect: 2,
|
|
1415
1441
|
maxParticles: 200,
|
|
@@ -1528,7 +1554,7 @@ var Blaster = class {
|
|
|
1528
1554
|
}
|
|
1529
1555
|
initialize() {
|
|
1530
1556
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1531
|
-
F:
|
|
1557
|
+
F: __dxlog_file7,
|
|
1532
1558
|
L: 142,
|
|
1533
1559
|
S: this,
|
|
1534
1560
|
A: [
|
|
@@ -1565,7 +1591,7 @@ var Blaster = class {
|
|
|
1565
1591
|
}
|
|
1566
1592
|
start() {
|
|
1567
1593
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1568
|
-
F:
|
|
1594
|
+
F: __dxlog_file7,
|
|
1569
1595
|
L: 181,
|
|
1570
1596
|
S: this,
|
|
1571
1597
|
A: [
|
|
@@ -1599,11 +1625,11 @@ var Blaster = class {
|
|
|
1599
1625
|
this.drawParticles();
|
|
1600
1626
|
requestAnimationFrame(this.loop.bind(this));
|
|
1601
1627
|
}
|
|
1602
|
-
shake =
|
|
1628
|
+
shake = throttle2(({ time }) => {
|
|
1603
1629
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1604
1630
|
this._shakeTimeMax = time;
|
|
1605
1631
|
}, 100);
|
|
1606
|
-
spawn =
|
|
1632
|
+
spawn = throttle2(({ element, point }) => {
|
|
1607
1633
|
const color = getRGBComponents(element, this._options.color);
|
|
1608
1634
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1609
1635
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1777,11 +1803,11 @@ var blocks = () => [
|
|
|
1777
1803
|
".cm-line.block-line": {
|
|
1778
1804
|
paddingLeft: "0.75rem",
|
|
1779
1805
|
paddingRight: "0.75rem",
|
|
1780
|
-
borderLeft: "1px solid var(--
|
|
1781
|
-
borderRight: "1px solid var(--
|
|
1806
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1807
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1782
1808
|
},
|
|
1783
1809
|
".cm-line.block-single": {
|
|
1784
|
-
border: "1px solid var(--
|
|
1810
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1785
1811
|
borderRadius: "6px",
|
|
1786
1812
|
paddingTop: "0.5rem",
|
|
1787
1813
|
paddingBottom: "0.5rem",
|
|
@@ -1789,7 +1815,7 @@ var blocks = () => [
|
|
|
1789
1815
|
marginBottom: "0.5rem"
|
|
1790
1816
|
},
|
|
1791
1817
|
".cm-line.block-first": {
|
|
1792
|
-
borderTop: "1px solid var(--
|
|
1818
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1793
1819
|
borderTopLeftRadius: "6px",
|
|
1794
1820
|
borderTopRightRadius: "6px",
|
|
1795
1821
|
paddingTop: "0.5rem",
|
|
@@ -1797,7 +1823,7 @@ var blocks = () => [
|
|
|
1797
1823
|
},
|
|
1798
1824
|
".cm-line.block-middle": {},
|
|
1799
1825
|
".cm-line.block-last": {
|
|
1800
|
-
borderBottom: "1px solid var(--
|
|
1826
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1801
1827
|
borderBottomLeftRadius: "6px",
|
|
1802
1828
|
borderBottomRightRadius: "6px",
|
|
1803
1829
|
paddingBottom: "0.5rem",
|
|
@@ -1807,13 +1833,13 @@ var blocks = () => [
|
|
|
1807
1833
|
];
|
|
1808
1834
|
|
|
1809
1835
|
// src/extensions/bookmarks.ts
|
|
1810
|
-
import { Prec as Prec3, StateEffect as
|
|
1836
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1811
1837
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1812
|
-
import { log as
|
|
1813
|
-
var
|
|
1814
|
-
var addBookmark =
|
|
1815
|
-
var removeBookmark =
|
|
1816
|
-
var clearBookmarks =
|
|
1838
|
+
import { log as log6 } from "@dxos/log";
|
|
1839
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1840
|
+
var addBookmark = StateEffect3.define();
|
|
1841
|
+
var removeBookmark = StateEffect3.define();
|
|
1842
|
+
var clearBookmarks = StateEffect3.define();
|
|
1817
1843
|
var bookmarks = () => {
|
|
1818
1844
|
return [
|
|
1819
1845
|
bookmarksField,
|
|
@@ -1822,8 +1848,8 @@ var bookmarks = () => {
|
|
|
1822
1848
|
key: "Mod-ArrowUp",
|
|
1823
1849
|
run: (view) => {
|
|
1824
1850
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1825
|
-
|
|
1826
|
-
F:
|
|
1851
|
+
log6("up", bookmarks2, {
|
|
1852
|
+
F: __dxlog_file8,
|
|
1827
1853
|
L: 29,
|
|
1828
1854
|
S: void 0,
|
|
1829
1855
|
C: (f, a) => f(...a)
|
|
@@ -1835,8 +1861,8 @@ var bookmarks = () => {
|
|
|
1835
1861
|
key: "Mod-ArrowDown",
|
|
1836
1862
|
run: (view) => {
|
|
1837
1863
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1838
|
-
|
|
1839
|
-
F:
|
|
1864
|
+
log6("down", bookmarks2, {
|
|
1865
|
+
F: __dxlog_file8,
|
|
1840
1866
|
L: 37,
|
|
1841
1867
|
S: void 0,
|
|
1842
1868
|
C: (f, a) => f(...a)
|
|
@@ -1877,22 +1903,22 @@ var bookmarksField = StateField2.define({
|
|
|
1877
1903
|
|
|
1878
1904
|
// src/extensions/comments.ts
|
|
1879
1905
|
import { invertedEffects } from "@codemirror/commands";
|
|
1880
|
-
import { StateEffect as
|
|
1906
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1881
1907
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1882
1908
|
import sortBy from "lodash.sortby";
|
|
1883
|
-
import { debounce as
|
|
1884
|
-
import { log as
|
|
1909
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1910
|
+
import { log as log7 } from "@dxos/log";
|
|
1885
1911
|
import { isNonNullable } from "@dxos/util";
|
|
1886
1912
|
|
|
1887
1913
|
// src/extensions/selection.ts
|
|
1888
1914
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1889
1915
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1890
|
-
import { debounce
|
|
1916
|
+
import { debounce } from "@dxos/async";
|
|
1891
1917
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1892
1918
|
import { isTruthy } from "@dxos/util";
|
|
1893
|
-
var
|
|
1919
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1894
1920
|
var documentId = singleValueFacet();
|
|
1895
|
-
var stateRestoreAnnotation = "dxos.
|
|
1921
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1896
1922
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1897
1923
|
return {
|
|
1898
1924
|
selection,
|
|
@@ -1906,7 +1932,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1906
1932
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1907
1933
|
getState: (id) => {
|
|
1908
1934
|
invariant3(id, void 0, {
|
|
1909
|
-
F:
|
|
1935
|
+
F: __dxlog_file9,
|
|
1910
1936
|
L: 47,
|
|
1911
1937
|
S: void 0,
|
|
1912
1938
|
A: [
|
|
@@ -1919,7 +1945,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1919
1945
|
},
|
|
1920
1946
|
setState: (id, state) => {
|
|
1921
1947
|
invariant3(id, void 0, {
|
|
1922
|
-
F:
|
|
1948
|
+
F: __dxlog_file9,
|
|
1923
1949
|
L: 53,
|
|
1924
1950
|
S: void 0,
|
|
1925
1951
|
A: [
|
|
@@ -1931,7 +1957,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1931
1957
|
}
|
|
1932
1958
|
});
|
|
1933
1959
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1934
|
-
const setStateDebounced =
|
|
1960
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1935
1961
|
return [
|
|
1936
1962
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1937
1963
|
// EditorView.domEventHandlers({
|
|
@@ -1978,10 +2004,10 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1978
2004
|
};
|
|
1979
2005
|
|
|
1980
2006
|
// src/extensions/comments.ts
|
|
1981
|
-
var
|
|
1982
|
-
var setComments =
|
|
1983
|
-
var setSelection =
|
|
1984
|
-
var setCommentState =
|
|
2007
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
2008
|
+
var setComments = StateEffect4.define();
|
|
2009
|
+
var setSelection = StateEffect4.define();
|
|
2010
|
+
var setCommentState = StateEffect4.define();
|
|
1985
2011
|
var commentsState = StateField3.define({
|
|
1986
2012
|
create: (state) => ({
|
|
1987
2013
|
id: state.facet(documentId),
|
|
@@ -2023,14 +2049,14 @@ var commentsState = StateField3.define({
|
|
|
2023
2049
|
var styles2 = EditorView11.theme({
|
|
2024
2050
|
".cm-comment, .cm-comment-current": {
|
|
2025
2051
|
padding: "3px 0",
|
|
2026
|
-
color: "var(--
|
|
2027
|
-
backgroundColor: "var(--
|
|
2052
|
+
color: "var(--color-cm-comment-text)",
|
|
2053
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2028
2054
|
},
|
|
2029
2055
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2030
2056
|
boxDecorationBreak: "clone",
|
|
2031
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2032
|
-
backgroundColor: "var(--
|
|
2033
|
-
color: "var(--
|
|
2057
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2058
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2059
|
+
color: "var(--color-cm-comment-text)",
|
|
2034
2060
|
cursor: "pointer"
|
|
2035
2061
|
}
|
|
2036
2062
|
});
|
|
@@ -2048,8 +2074,8 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2048
2074
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2049
2075
|
const range = comment.range;
|
|
2050
2076
|
if (!range) {
|
|
2051
|
-
|
|
2052
|
-
F:
|
|
2077
|
+
log7.warn("Invalid range:", range, {
|
|
2078
|
+
F: __dxlog_file10,
|
|
2053
2079
|
L: 140,
|
|
2054
2080
|
S: void 0,
|
|
2055
2081
|
C: (f, a) => f(...a)
|
|
@@ -2063,7 +2089,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2063
2089
|
}).filter(isNonNullable);
|
|
2064
2090
|
return Decoration7.set(decorations2);
|
|
2065
2091
|
});
|
|
2066
|
-
var commentClickedEffect =
|
|
2092
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2067
2093
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2068
2094
|
click: (event, view) => {
|
|
2069
2095
|
let target = event.target;
|
|
@@ -2181,7 +2207,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2181
2207
|
from: changes.mapPos(comment.from, 1),
|
|
2182
2208
|
to: changes.mapPos(comment.to, 1)
|
|
2183
2209
|
});
|
|
2184
|
-
var restoreCommentEffect =
|
|
2210
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2185
2211
|
map: mapTrackedComment
|
|
2186
2212
|
});
|
|
2187
2213
|
var createComment = (view) => {
|
|
@@ -2215,7 +2241,7 @@ var createComment = (view) => {
|
|
|
2215
2241
|
var optionsFacet = singleValueFacet();
|
|
2216
2242
|
var comments = (options = {}) => {
|
|
2217
2243
|
const { key: shortcut = "meta-'" } = options;
|
|
2218
|
-
const handleSelect =
|
|
2244
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2219
2245
|
return [
|
|
2220
2246
|
optionsFacet.of(options),
|
|
2221
2247
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2393,9 +2419,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2393
2419
|
// src/extensions/debug.ts
|
|
2394
2420
|
import { syntaxTree } from "@codemirror/language";
|
|
2395
2421
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2396
|
-
var debugNodeLogger = (
|
|
2422
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2397
2423
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2398
|
-
enter: (node) =>
|
|
2424
|
+
enter: (node) => log12(node.type)
|
|
2399
2425
|
});
|
|
2400
2426
|
return StateField4.define({
|
|
2401
2427
|
create: (state) => logTokens(state),
|
|
@@ -2430,8 +2456,8 @@ var dropFile = (options = {}) => {
|
|
|
2430
2456
|
};
|
|
2431
2457
|
var styles3 = EditorView12.theme({
|
|
2432
2458
|
".cm-dropCursor": {
|
|
2433
|
-
borderLeft: "2px solid var(--
|
|
2434
|
-
color: "var(--
|
|
2459
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2460
|
+
color: "var(--color-accent-text)",
|
|
2435
2461
|
padding: "0 4px"
|
|
2436
2462
|
},
|
|
2437
2463
|
".cm-dropCursor:after": {
|
|
@@ -2449,43 +2475,62 @@ import { EditorView as EditorView15, ViewPlugin as ViewPlugin11, drawSelection,
|
|
|
2449
2475
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2450
2476
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2451
2477
|
import { generateName } from "@dxos/display-name";
|
|
2452
|
-
import { log as
|
|
2478
|
+
import { log as log8 } from "@dxos/log";
|
|
2453
2479
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2454
2480
|
|
|
2455
|
-
// src/styles/
|
|
2481
|
+
// src/styles/theme.ts
|
|
2482
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2456
2483
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2457
2484
|
var headings = {
|
|
2458
|
-
1:
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2485
|
+
1: {
|
|
2486
|
+
className: "text-4xl",
|
|
2487
|
+
fontSize: "var(--text-4xl)",
|
|
2488
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2489
|
+
},
|
|
2490
|
+
2: {
|
|
2491
|
+
className: "text-3xl",
|
|
2492
|
+
fontSize: "var(--text-3xl)",
|
|
2493
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2494
|
+
},
|
|
2495
|
+
3: {
|
|
2496
|
+
className: "text-2xl",
|
|
2497
|
+
fontSize: "var(--text-2xl)",
|
|
2498
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2499
|
+
},
|
|
2500
|
+
4: {
|
|
2501
|
+
className: "text-xl",
|
|
2502
|
+
fontSize: "var(--text-xl)",
|
|
2503
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2504
|
+
},
|
|
2505
|
+
5: {
|
|
2506
|
+
className: "text-lg",
|
|
2507
|
+
fontSize: "var(--text-lg)",
|
|
2508
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2509
|
+
},
|
|
2510
|
+
6: {
|
|
2511
|
+
className: "text-base",
|
|
2512
|
+
fontSize: "var(--text-base)",
|
|
2513
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2514
|
+
}
|
|
2464
2515
|
};
|
|
2465
2516
|
var markdownTheme = {
|
|
2466
|
-
code: "font-mono
|
|
2467
|
-
codeMark: "font-mono text-
|
|
2517
|
+
code: "font-mono no-underline! text-cm-code",
|
|
2518
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
2468
2519
|
mark: "opacity-50",
|
|
2469
|
-
heading: (level) => {
|
|
2470
|
-
|
|
2471
|
-
|
|
2520
|
+
heading: (level) => ({
|
|
2521
|
+
className: mx3(headings[level].className, "font-light text-cm-heading"),
|
|
2522
|
+
color: "var(--color-cm-heading) !important",
|
|
2523
|
+
lineHeight: headings[level].lineHeight,
|
|
2524
|
+
fontSize: headings[level].fontSize,
|
|
2525
|
+
fontWeight: "100 !important"
|
|
2526
|
+
})
|
|
2472
2527
|
};
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2476
|
-
|
|
2477
|
-
// src/styles/tokens.ts
|
|
2478
|
-
import { tokens } from "@dxos/ui-theme";
|
|
2479
|
-
import { get } from "@dxos/util";
|
|
2480
|
-
var getToken = (path, defaultValue) => {
|
|
2481
|
-
const value = get(tokens, path, defaultValue);
|
|
2482
|
-
return value?.toString() ?? "";
|
|
2483
|
-
};
|
|
2484
|
-
var fontBody = getToken("fontFamily.body");
|
|
2485
|
-
var fontMono = getToken("fontFamily.mono");
|
|
2486
|
-
|
|
2487
|
-
// src/styles/theme.ts
|
|
2528
|
+
var fontBody = "Inter Variable, ui-sans-serif, system-ui, sans-serif";
|
|
2529
|
+
var fontMono = "JetBrains Mono Variable, ui-monospace, Cascadia Code, Source Code Pro, monospace";
|
|
2488
2530
|
var baseTheme = EditorView13.baseTheme({
|
|
2531
|
+
/**
|
|
2532
|
+
* Outer frame.
|
|
2533
|
+
*/
|
|
2489
2534
|
"&": {},
|
|
2490
2535
|
"&.cm-focused": {
|
|
2491
2536
|
outline: "none"
|
|
@@ -2494,7 +2539,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2494
2539
|
* Scroller
|
|
2495
2540
|
*/
|
|
2496
2541
|
".cm-scroller": {
|
|
2497
|
-
|
|
2542
|
+
overflowAnchor: "none"
|
|
2543
|
+
},
|
|
2544
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2545
|
+
width: "8px"
|
|
2546
|
+
},
|
|
2547
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2548
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2549
|
+
background: "transparent",
|
|
2550
|
+
transition: "background 0.15s"
|
|
2551
|
+
},
|
|
2552
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2553
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2498
2554
|
},
|
|
2499
2555
|
/**
|
|
2500
2556
|
* Content
|
|
@@ -2516,8 +2572,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2516
2572
|
".cm-gutter": {},
|
|
2517
2573
|
".cm-gutter.cm-lineNumbers": {
|
|
2518
2574
|
paddingRight: "4px",
|
|
2519
|
-
borderRight: "1px solid var(--
|
|
2520
|
-
color: "var(--
|
|
2575
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2576
|
+
color: "var(--color-subdued)"
|
|
2521
2577
|
},
|
|
2522
2578
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2523
2579
|
minWidth: "40px"
|
|
@@ -2537,25 +2593,25 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2537
2593
|
paddingInline: 0
|
|
2538
2594
|
},
|
|
2539
2595
|
".cm-activeLine": {
|
|
2540
|
-
background: "var(--
|
|
2596
|
+
background: "var(--color-cm-active-line)"
|
|
2541
2597
|
},
|
|
2542
2598
|
/**
|
|
2543
2599
|
* Cursor (layer).
|
|
2544
2600
|
*/
|
|
2545
2601
|
".cm-cursor, .cm-dropCursor": {
|
|
2546
|
-
borderLeft: "2px solid var(--
|
|
2602
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2547
2603
|
},
|
|
2548
2604
|
".cm-placeholder": {
|
|
2549
|
-
color: "var(--
|
|
2605
|
+
color: "var(--color-placeholder)"
|
|
2550
2606
|
},
|
|
2551
2607
|
/**
|
|
2552
2608
|
* Selection (layer).
|
|
2553
2609
|
*/
|
|
2554
2610
|
".cm-selectionBackground": {
|
|
2555
|
-
background: "var(--
|
|
2611
|
+
background: "var(--color-cm-selection)"
|
|
2556
2612
|
},
|
|
2557
2613
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2558
|
-
background: "var(--
|
|
2614
|
+
background: "var(--color-cm-focused-selection)"
|
|
2559
2615
|
},
|
|
2560
2616
|
/**
|
|
2561
2617
|
* Search.
|
|
@@ -2565,8 +2621,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2565
2621
|
margin: "0 -3px",
|
|
2566
2622
|
padding: "3px",
|
|
2567
2623
|
borderRadius: "3px",
|
|
2568
|
-
background: "var(--
|
|
2569
|
-
color: "var(--
|
|
2624
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2625
|
+
color: "var(--color-cm-highlight)"
|
|
2570
2626
|
},
|
|
2571
2627
|
".cm-searchMatch-selected": {
|
|
2572
2628
|
textDecoration: "underline"
|
|
@@ -2577,20 +2633,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2577
2633
|
".cm-link": {
|
|
2578
2634
|
textDecorationLine: "underline",
|
|
2579
2635
|
textDecorationThickness: "1px",
|
|
2580
|
-
textDecorationColor: "var(--
|
|
2636
|
+
textDecorationColor: "var(--color-separator)",
|
|
2581
2637
|
textUnderlineOffset: "2px",
|
|
2582
2638
|
borderRadius: ".125rem"
|
|
2583
2639
|
},
|
|
2584
2640
|
".cm-link > span": {
|
|
2585
|
-
color: "var(--
|
|
2641
|
+
color: "var(--color-accent-text)"
|
|
2642
|
+
},
|
|
2643
|
+
".cm-link > span:hover": {
|
|
2644
|
+
color: "var(--color-accent-text-hover)"
|
|
2586
2645
|
},
|
|
2587
2646
|
/**
|
|
2588
2647
|
* Tooltip.
|
|
2589
2648
|
*/
|
|
2590
2649
|
".cm-tooltip": {
|
|
2591
|
-
background: "var(--
|
|
2650
|
+
background: "var(--color-modal-surface)"
|
|
2592
2651
|
},
|
|
2593
2652
|
".cm-tooltip-below": {},
|
|
2653
|
+
".cm-tooltip-hover": {
|
|
2654
|
+
background: "var(--color-modal-surface)",
|
|
2655
|
+
border: "1px solid var(--color-separator)",
|
|
2656
|
+
borderRadius: "4px",
|
|
2657
|
+
overflow: "hidden"
|
|
2658
|
+
},
|
|
2594
2659
|
/**
|
|
2595
2660
|
* Autocomplete.
|
|
2596
2661
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2598,7 +2663,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2598
2663
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2599
2664
|
marginTop: "6px",
|
|
2600
2665
|
marginLeft: "-10px",
|
|
2601
|
-
border: "2px solid var(--
|
|
2666
|
+
border: "2px solid var(--color-separator)",
|
|
2602
2667
|
borderRadius: "4px"
|
|
2603
2668
|
},
|
|
2604
2669
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2608,12 +2673,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2608
2673
|
padding: "4px"
|
|
2609
2674
|
},
|
|
2610
2675
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2611
|
-
background: "var(--
|
|
2612
|
-
color: "var(--
|
|
2676
|
+
background: "var(--color-active-surface)",
|
|
2677
|
+
color: "var(--color-base-surface-text)"
|
|
2613
2678
|
},
|
|
2614
2679
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2615
2680
|
paddingLeft: "4px !important",
|
|
2616
|
-
color: "var(--
|
|
2681
|
+
color: "var(--color-base-surface-text)"
|
|
2617
2682
|
},
|
|
2618
2683
|
/**
|
|
2619
2684
|
* Completion info.
|
|
@@ -2622,17 +2687,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2622
2687
|
width: "360px !important",
|
|
2623
2688
|
margin: "-10px 1px 0 1px",
|
|
2624
2689
|
padding: "8px !important",
|
|
2625
|
-
borderColor: "var(--
|
|
2690
|
+
borderColor: "var(--color-separator)"
|
|
2626
2691
|
},
|
|
2627
2692
|
".cm-completionIcon": {
|
|
2628
2693
|
display: "none"
|
|
2629
2694
|
},
|
|
2630
2695
|
".cm-completionLabel": {
|
|
2631
|
-
color: "var(--
|
|
2696
|
+
color: "var(--color-description)",
|
|
2632
2697
|
padding: "0 4px"
|
|
2633
2698
|
},
|
|
2634
2699
|
".cm-completionMatchedText": {
|
|
2635
|
-
color: "var(--
|
|
2700
|
+
color: "var(--color-base-surface-text)",
|
|
2636
2701
|
textDecoration: "none !important"
|
|
2637
2702
|
},
|
|
2638
2703
|
/**
|
|
@@ -2656,7 +2721,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2656
2721
|
backgroundColor: "var(--surface-bg)"
|
|
2657
2722
|
},
|
|
2658
2723
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2659
|
-
color: "var(--
|
|
2724
|
+
color: "var(--color-subdued)",
|
|
2660
2725
|
fontSize: "14px",
|
|
2661
2726
|
all: "unset",
|
|
2662
2727
|
margin: "3px !important",
|
|
@@ -2664,10 +2729,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2664
2729
|
outline: "1px solid transparent"
|
|
2665
2730
|
},
|
|
2666
2731
|
".cm-panel input, .cm-panel button": {
|
|
2667
|
-
backgroundColor: "var(--
|
|
2732
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2668
2733
|
},
|
|
2669
2734
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2670
|
-
outline: "1px solid var(--
|
|
2735
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2671
2736
|
},
|
|
2672
2737
|
".cm-panel label": {
|
|
2673
2738
|
display: "inline-flex",
|
|
@@ -2680,25 +2745,26 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2680
2745
|
height: "8px",
|
|
2681
2746
|
marginRight: "6px !important",
|
|
2682
2747
|
padding: "2px !important",
|
|
2683
|
-
color: "var(--
|
|
2748
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2684
2749
|
},
|
|
2685
2750
|
".cm-panel button": {
|
|
2686
2751
|
"&:hover": {
|
|
2687
|
-
|
|
2752
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2753
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2688
2754
|
},
|
|
2689
2755
|
"&:active": {
|
|
2690
|
-
backgroundColor: "var(--
|
|
2756
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2691
2757
|
}
|
|
2692
2758
|
},
|
|
2693
2759
|
".cm-panel.cm-search": {
|
|
2694
2760
|
padding: "4px",
|
|
2695
|
-
borderTop: "1px solid var(--
|
|
2761
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2696
2762
|
}
|
|
2697
2763
|
});
|
|
2698
2764
|
var editorGutter = EditorView13.theme({
|
|
2699
2765
|
".cm-gutters": {
|
|
2700
2766
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2701
|
-
background: "var(--
|
|
2767
|
+
background: "var(--color-base-surface) !important",
|
|
2702
2768
|
paddingRight: "1rem"
|
|
2703
2769
|
}
|
|
2704
2770
|
});
|
|
@@ -2716,9 +2782,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2716
2782
|
});
|
|
2717
2783
|
|
|
2718
2784
|
// src/extensions/focus.ts
|
|
2719
|
-
import { StateEffect as
|
|
2785
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2720
2786
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2721
|
-
var focusEffect =
|
|
2787
|
+
var focusEffect = StateEffect5.define();
|
|
2722
2788
|
var focusField = StateField5.define({
|
|
2723
2789
|
create: () => false,
|
|
2724
2790
|
update: (value, tr) => {
|
|
@@ -2747,7 +2813,7 @@ var focus = [
|
|
|
2747
2813
|
];
|
|
2748
2814
|
|
|
2749
2815
|
// src/extensions/factories.ts
|
|
2750
|
-
var
|
|
2816
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2751
2817
|
var tabbable = EditorView15.contentAttributes.of({
|
|
2752
2818
|
tabindex: "0"
|
|
2753
2819
|
});
|
|
@@ -2802,9 +2868,9 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2802
2868
|
return [
|
|
2803
2869
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2804
2870
|
EditorView15.exceptionSink.of((err) => {
|
|
2805
|
-
|
|
2806
|
-
F:
|
|
2807
|
-
L:
|
|
2871
|
+
log8.catch(err, void 0, {
|
|
2872
|
+
F: __dxlog_file11,
|
|
2873
|
+
L: 131,
|
|
2808
2874
|
S: void 0,
|
|
2809
2875
|
C: (f, a) => f(...a)
|
|
2810
2876
|
});
|
|
@@ -2856,12 +2922,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2856
2922
|
};
|
|
2857
2923
|
var grow = {
|
|
2858
2924
|
editor: {
|
|
2859
|
-
className: "
|
|
2925
|
+
className: "h-full w-full"
|
|
2860
2926
|
}
|
|
2861
2927
|
};
|
|
2862
2928
|
var fullWidth = {
|
|
2863
2929
|
editor: {
|
|
2864
|
-
className: "
|
|
2930
|
+
className: "w-full"
|
|
2865
2931
|
}
|
|
2866
2932
|
};
|
|
2867
2933
|
var defaultThemeSlots = grow;
|
|
@@ -2904,8 +2970,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2904
2970
|
channel: `awareness.${id}`,
|
|
2905
2971
|
peerId: identity.identityKey.toHex(),
|
|
2906
2972
|
info: {
|
|
2907
|
-
darkColor: `var(--
|
|
2908
|
-
lightColor: `var(--
|
|
2973
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
2974
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2909
2975
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2910
2976
|
}
|
|
2911
2977
|
})));
|
|
@@ -2924,7 +2990,7 @@ var folding = () => {
|
|
|
2924
2990
|
}),
|
|
2925
2991
|
foldGutter({
|
|
2926
2992
|
markerDOM: (open) => {
|
|
2927
|
-
return Domino2.of("div").classNames("flex
|
|
2993
|
+
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
2994
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2929
2995
|
}))).root;
|
|
2930
2996
|
}
|
|
@@ -4220,6 +4286,11 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
|
4220
4286
|
import { HighlightStyle as HighlightStyle2 } from "@codemirror/language";
|
|
4221
4287
|
import { Tag, styleTags, tags } from "@lezer/highlight";
|
|
4222
4288
|
import { Table } from "@lezer/markdown";
|
|
4289
|
+
var styles4 = {
|
|
4290
|
+
code: "font-mono no-underline! text-cm-code",
|
|
4291
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
4292
|
+
mark: "opacity-50"
|
|
4293
|
+
};
|
|
4223
4294
|
var markdownTags = {
|
|
4224
4295
|
Blockquote: Tag.define(),
|
|
4225
4296
|
CodeMark: Tag.define(),
|
|
@@ -4301,7 +4372,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4301
4372
|
markdownTags.LinkReference,
|
|
4302
4373
|
markdownTags.ListMark
|
|
4303
4374
|
],
|
|
4304
|
-
class:
|
|
4375
|
+
class: styles4.mark
|
|
4305
4376
|
},
|
|
4306
4377
|
// Markdown marks.
|
|
4307
4378
|
{
|
|
@@ -4312,7 +4383,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4312
4383
|
markdownTags.QuoteMark,
|
|
4313
4384
|
markdownTags.EmphasisMark
|
|
4314
4385
|
],
|
|
4315
|
-
class:
|
|
4386
|
+
class: styles4.mark
|
|
4316
4387
|
},
|
|
4317
4388
|
// E.g., code block language (after ```).
|
|
4318
4389
|
{
|
|
@@ -4321,7 +4392,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4321
4392
|
tags.function(tags.variableName),
|
|
4322
4393
|
tags.labelName
|
|
4323
4394
|
],
|
|
4324
|
-
class:
|
|
4395
|
+
class: styles4.codeMark
|
|
4325
4396
|
},
|
|
4326
4397
|
// Fonts.
|
|
4327
4398
|
{
|
|
@@ -4331,30 +4402,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4331
4402
|
],
|
|
4332
4403
|
class: "font-mono"
|
|
4333
4404
|
},
|
|
4334
|
-
// Headings
|
|
4405
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4406
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4407
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4408
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4409
|
+
{
|
|
4410
|
+
tag: tags.heading,
|
|
4411
|
+
color: "var(--color-cm-heading) !important",
|
|
4412
|
+
fontWeight: "300"
|
|
4413
|
+
},
|
|
4335
4414
|
{
|
|
4336
4415
|
tag: tags.heading1,
|
|
4337
|
-
|
|
4416
|
+
...markdownTheme.heading(1)
|
|
4338
4417
|
},
|
|
4339
4418
|
{
|
|
4340
4419
|
tag: tags.heading2,
|
|
4341
|
-
|
|
4420
|
+
...markdownTheme.heading(2)
|
|
4342
4421
|
},
|
|
4343
4422
|
{
|
|
4344
4423
|
tag: tags.heading3,
|
|
4345
|
-
|
|
4424
|
+
...markdownTheme.heading(3)
|
|
4346
4425
|
},
|
|
4347
4426
|
{
|
|
4348
4427
|
tag: tags.heading4,
|
|
4349
|
-
|
|
4428
|
+
...markdownTheme.heading(4)
|
|
4350
4429
|
},
|
|
4351
4430
|
{
|
|
4352
4431
|
tag: tags.heading5,
|
|
4353
|
-
|
|
4432
|
+
...markdownTheme.heading(5)
|
|
4354
4433
|
},
|
|
4355
4434
|
{
|
|
4356
4435
|
tag: tags.heading6,
|
|
4357
|
-
|
|
4436
|
+
...markdownTheme.heading(6)
|
|
4358
4437
|
},
|
|
4359
4438
|
// Emphasis.
|
|
4360
4439
|
{
|
|
@@ -4379,7 +4458,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4379
4458
|
markdownTags.CodeText,
|
|
4380
4459
|
markdownTags.InlineCode
|
|
4381
4460
|
],
|
|
4382
|
-
class:
|
|
4461
|
+
class: styles4.code
|
|
4383
4462
|
},
|
|
4384
4463
|
{
|
|
4385
4464
|
tag: [
|
|
@@ -4484,7 +4563,7 @@ var convertTreeToJson = (state) => {
|
|
|
4484
4563
|
|
|
4485
4564
|
// src/extensions/markdown/decorate.ts
|
|
4486
4565
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4487
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4566
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4488
4567
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4489
4568
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4490
4569
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
@@ -4736,7 +4815,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4736
4815
|
width: "100%",
|
|
4737
4816
|
height: "0",
|
|
4738
4817
|
verticalAlign: "middle",
|
|
4739
|
-
borderTop: "1px solid var(--
|
|
4818
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4740
4819
|
opacity: 0.5
|
|
4741
4820
|
},
|
|
4742
4821
|
/**
|
|
@@ -4759,8 +4838,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4759
4838
|
* Blockquote.
|
|
4760
4839
|
*/
|
|
4761
4840
|
"& .cm-blockquote": {
|
|
4762
|
-
background: "var(--
|
|
4763
|
-
borderLeft: "2px solid var(--
|
|
4841
|
+
background: "var(--color-cm-codeblock)",
|
|
4842
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4764
4843
|
paddingLeft: "1rem",
|
|
4765
4844
|
margin: "0"
|
|
4766
4845
|
},
|
|
@@ -4771,7 +4850,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4771
4850
|
fontFamily: fontMono
|
|
4772
4851
|
},
|
|
4773
4852
|
"& .cm-codeblock-line": {
|
|
4774
|
-
background: "var(--
|
|
4853
|
+
background: "var(--color-cm-codeblock)",
|
|
4775
4854
|
paddingInline: "1rem !important"
|
|
4776
4855
|
},
|
|
4777
4856
|
"& .cm-codeblock-start": {
|
|
@@ -4805,8 +4884,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4805
4884
|
".cm-table-head": {
|
|
4806
4885
|
padding: "2px 16px 2px 0px",
|
|
4807
4886
|
textAlign: "left",
|
|
4808
|
-
borderBottom: "1px solid var(--
|
|
4809
|
-
color: "var(--
|
|
4887
|
+
borderBottom: "1px solid var(--color-cm-separator)",
|
|
4888
|
+
color: "var(--color-subdued)"
|
|
4810
4889
|
},
|
|
4811
4890
|
".cm-table-cell": {
|
|
4812
4891
|
padding: "2px 16px 2px 0px"
|
|
@@ -4946,7 +5025,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4946
5025
|
};
|
|
4947
5026
|
|
|
4948
5027
|
// src/extensions/markdown/decorate.ts
|
|
4949
|
-
var
|
|
5028
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4950
5029
|
var Unicode = {
|
|
4951
5030
|
emDash: "\u2014",
|
|
4952
5031
|
bullet: "\u2022",
|
|
@@ -4969,7 +5048,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4969
5048
|
eq(other) {
|
|
4970
5049
|
return this.url === other.url;
|
|
4971
5050
|
}
|
|
4972
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4973
5051
|
toDOM(view) {
|
|
4974
5052
|
const el = document.createElement("span");
|
|
4975
5053
|
this.render(el, {
|
|
@@ -5082,8 +5160,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5082
5160
|
const headerLevels = [];
|
|
5083
5161
|
const getHeaderLevels = (node, level) => {
|
|
5084
5162
|
invariant4(level > 0, void 0, {
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5163
|
+
F: __dxlog_file12,
|
|
5164
|
+
L: 179,
|
|
5087
5165
|
S: void 0,
|
|
5088
5166
|
A: [
|
|
5089
5167
|
"level > 0",
|
|
@@ -5121,8 +5199,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5121
5199
|
};
|
|
5122
5200
|
const getCurrentListLevel = () => {
|
|
5123
5201
|
invariant4(listLevels.length, void 0, {
|
|
5124
|
-
F:
|
|
5125
|
-
L:
|
|
5202
|
+
F: __dxlog_file12,
|
|
5203
|
+
L: 201,
|
|
5126
5204
|
S: void 0,
|
|
5127
5205
|
A: [
|
|
5128
5206
|
"listLevels.length",
|
|
@@ -5172,7 +5250,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5172
5250
|
from: mark.from,
|
|
5173
5251
|
to: mark.from + len,
|
|
5174
5252
|
deco: Decoration11.replace({
|
|
5175
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5253
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5176
5254
|
})
|
|
5177
5255
|
});
|
|
5178
5256
|
}
|
|
@@ -5439,7 +5517,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5439
5517
|
atomicDeco: atomicDeco.finish()
|
|
5440
5518
|
};
|
|
5441
5519
|
};
|
|
5442
|
-
var forceUpdate =
|
|
5520
|
+
var forceUpdate = StateEffect6.define();
|
|
5443
5521
|
var decorateMarkdown = (options = {}) => {
|
|
5444
5522
|
return [
|
|
5445
5523
|
ViewPlugin14.fromClass(class {
|
|
@@ -5511,8 +5589,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5511
5589
|
return {
|
|
5512
5590
|
pos: link.from,
|
|
5513
5591
|
end: link.to,
|
|
5514
|
-
|
|
5515
|
-
// above: true,
|
|
5592
|
+
above: true,
|
|
5516
5593
|
create: () => {
|
|
5517
5594
|
const el = document.createElement("div");
|
|
5518
5595
|
el.className = tooltipContent({});
|
|
@@ -5528,16 +5605,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5528
5605
|
};
|
|
5529
5606
|
}
|
|
5530
5607
|
};
|
|
5531
|
-
}, {
|
|
5532
|
-
// NOTE: 0 = default of 300ms.
|
|
5533
|
-
hoverTime: 1
|
|
5534
5608
|
});
|
|
5535
5609
|
};
|
|
5536
5610
|
|
|
5537
5611
|
// src/extensions/mention.ts
|
|
5538
5612
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5539
|
-
import { log as
|
|
5540
|
-
var
|
|
5613
|
+
import { log as log9 } from "@dxos/log";
|
|
5614
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5541
5615
|
var mention = ({ debug, onSearch }) => {
|
|
5542
5616
|
return autocompletion({
|
|
5543
5617
|
// TODO(burdon): Not working.
|
|
@@ -5549,10 +5623,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5549
5623
|
icons: false,
|
|
5550
5624
|
override: [
|
|
5551
5625
|
(context) => {
|
|
5552
|
-
|
|
5626
|
+
log9.info("completion context", {
|
|
5553
5627
|
context
|
|
5554
5628
|
}, {
|
|
5555
|
-
F:
|
|
5629
|
+
F: __dxlog_file13,
|
|
5556
5630
|
L: 27,
|
|
5557
5631
|
S: void 0,
|
|
5558
5632
|
C: (f, a) => f(...a)
|
|
@@ -5573,8 +5647,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5573
5647
|
};
|
|
5574
5648
|
|
|
5575
5649
|
// src/extensions/modal.ts
|
|
5576
|
-
import { StateEffect as
|
|
5577
|
-
var modalStateEffect =
|
|
5650
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5651
|
+
var modalStateEffect = StateEffect7.define();
|
|
5578
5652
|
var modalStateField = StateField9.define({
|
|
5579
5653
|
create: () => false,
|
|
5580
5654
|
update: (value, tr) => {
|
|
@@ -5635,7 +5709,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5635
5709
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5636
5710
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5637
5711
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5638
|
-
var
|
|
5712
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5639
5713
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5640
5714
|
return {
|
|
5641
5715
|
type,
|
|
@@ -5790,7 +5864,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5790
5864
|
}
|
|
5791
5865
|
case "BulletList": {
|
|
5792
5866
|
invariant5(current, void 0, {
|
|
5793
|
-
F:
|
|
5867
|
+
F: __dxlog_file14,
|
|
5794
5868
|
L: 219,
|
|
5795
5869
|
S: void 0,
|
|
5796
5870
|
A: [
|
|
@@ -5807,7 +5881,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5807
5881
|
}
|
|
5808
5882
|
case "ListItem": {
|
|
5809
5883
|
invariant5(parent, void 0, {
|
|
5810
|
-
F:
|
|
5884
|
+
F: __dxlog_file14,
|
|
5811
5885
|
L: 228,
|
|
5812
5886
|
S: void 0,
|
|
5813
5887
|
A: [
|
|
@@ -5849,7 +5923,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5849
5923
|
}
|
|
5850
5924
|
case "ListMark": {
|
|
5851
5925
|
invariant5(current, void 0, {
|
|
5852
|
-
F:
|
|
5926
|
+
F: __dxlog_file14,
|
|
5853
5927
|
L: 272,
|
|
5854
5928
|
S: void 0,
|
|
5855
5929
|
A: [
|
|
@@ -5863,7 +5937,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5863
5937
|
}
|
|
5864
5938
|
case "Task": {
|
|
5865
5939
|
invariant5(current, void 0, {
|
|
5866
|
-
F:
|
|
5940
|
+
F: __dxlog_file14,
|
|
5867
5941
|
L: 278,
|
|
5868
5942
|
S: void 0,
|
|
5869
5943
|
A: [
|
|
@@ -5876,7 +5950,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5876
5950
|
}
|
|
5877
5951
|
case "TaskMarker": {
|
|
5878
5952
|
invariant5(current, void 0, {
|
|
5879
|
-
F:
|
|
5953
|
+
F: __dxlog_file14,
|
|
5880
5954
|
L: 283,
|
|
5881
5955
|
S: void 0,
|
|
5882
5956
|
A: [
|
|
@@ -5892,7 +5966,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5892
5966
|
leave: (node) => {
|
|
5893
5967
|
if (node.name === "BulletList") {
|
|
5894
5968
|
invariant5(parent, void 0, {
|
|
5895
|
-
F:
|
|
5969
|
+
F: __dxlog_file14,
|
|
5896
5970
|
L: 291,
|
|
5897
5971
|
S: void 0,
|
|
5898
5972
|
A: [
|
|
@@ -5906,7 +5980,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5906
5980
|
}
|
|
5907
5981
|
});
|
|
5908
5982
|
invariant5(tree, void 0, {
|
|
5909
|
-
F:
|
|
5983
|
+
F: __dxlog_file14,
|
|
5910
5984
|
L: 298,
|
|
5911
5985
|
S: void 0,
|
|
5912
5986
|
A: [
|
|
@@ -6204,8 +6278,8 @@ import { mx as mx7 } from "@dxos/ui-theme";
|
|
|
6204
6278
|
// src/extensions/outliner/editor.ts
|
|
6205
6279
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6206
6280
|
import { ViewPlugin as ViewPlugin15 } from "@codemirror/view";
|
|
6207
|
-
import { log as
|
|
6208
|
-
var
|
|
6281
|
+
import { log as log10 } from "@dxos/log";
|
|
6282
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6209
6283
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6210
6284
|
var initialize = () => {
|
|
6211
6285
|
return ViewPlugin15.fromClass(class {
|
|
@@ -6337,7 +6411,7 @@ var editor = () => [
|
|
|
6337
6411
|
cancel = true;
|
|
6338
6412
|
return;
|
|
6339
6413
|
}
|
|
6340
|
-
|
|
6414
|
+
log10("change", {
|
|
6341
6415
|
item,
|
|
6342
6416
|
line: {
|
|
6343
6417
|
from: line.from,
|
|
@@ -6356,7 +6430,7 @@ var editor = () => [
|
|
|
6356
6430
|
length: insert.length
|
|
6357
6431
|
}
|
|
6358
6432
|
}, {
|
|
6359
|
-
F:
|
|
6433
|
+
F: __dxlog_file15,
|
|
6360
6434
|
L: 164,
|
|
6361
6435
|
S: void 0,
|
|
6362
6436
|
C: (f, a) => f(...a)
|
|
@@ -6364,10 +6438,10 @@ var editor = () => [
|
|
|
6364
6438
|
}
|
|
6365
6439
|
});
|
|
6366
6440
|
if (changes.length > 0) {
|
|
6367
|
-
|
|
6441
|
+
log10("modified,", {
|
|
6368
6442
|
changes
|
|
6369
6443
|
}, {
|
|
6370
|
-
F:
|
|
6444
|
+
F: __dxlog_file15,
|
|
6371
6445
|
L: 175,
|
|
6372
6446
|
S: void 0,
|
|
6373
6447
|
C: (f, a) => f(...a)
|
|
@@ -6378,8 +6452,8 @@ var editor = () => [
|
|
|
6378
6452
|
}
|
|
6379
6453
|
];
|
|
6380
6454
|
} else if (cancel) {
|
|
6381
|
-
|
|
6382
|
-
F:
|
|
6455
|
+
log10("cancel", void 0, {
|
|
6456
|
+
F: __dxlog_file15,
|
|
6383
6457
|
L: 178,
|
|
6384
6458
|
S: void 0,
|
|
6385
6459
|
C: (f, a) => f(...a)
|
|
@@ -6392,7 +6466,7 @@ var editor = () => [
|
|
|
6392
6466
|
|
|
6393
6467
|
// src/extensions/outliner/menu.ts
|
|
6394
6468
|
import { EditorView as EditorView24, ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6395
|
-
import { addEventListener } from "@dxos/async";
|
|
6469
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6396
6470
|
var menu = (options = {}) => [
|
|
6397
6471
|
ViewPlugin16.fromClass(class {
|
|
6398
6472
|
view;
|
|
@@ -6414,7 +6488,7 @@ var menu = (options = {}) => [
|
|
|
6414
6488
|
}
|
|
6415
6489
|
container.appendChild(this.tag);
|
|
6416
6490
|
const handler = () => this.scheduleUpdate();
|
|
6417
|
-
this.cleanup =
|
|
6491
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6418
6492
|
this.scheduleUpdate();
|
|
6419
6493
|
}
|
|
6420
6494
|
destroy() {
|
|
@@ -6493,7 +6567,7 @@ var outliner = (_options = {}) => [
|
|
|
6493
6567
|
}),
|
|
6494
6568
|
// Researve space for menu.
|
|
6495
6569
|
EditorView25.contentAttributes.of({
|
|
6496
|
-
class: "
|
|
6570
|
+
class: "w-full !mr-[3rem]"
|
|
6497
6571
|
})
|
|
6498
6572
|
];
|
|
6499
6573
|
var decorations = () => [
|
|
@@ -6557,10 +6631,10 @@ var decorations = () => [
|
|
|
6557
6631
|
marginBottom: "2px"
|
|
6558
6632
|
},
|
|
6559
6633
|
".cm-list-item-focused": {
|
|
6560
|
-
borderColor: "var(--
|
|
6634
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6561
6635
|
},
|
|
6562
6636
|
"&:focus-within .cm-list-item-selected": {
|
|
6563
|
-
borderColor: "var(--
|
|
6637
|
+
borderColor: "var(--color-separator)"
|
|
6564
6638
|
}
|
|
6565
6639
|
}))
|
|
6566
6640
|
];
|
|
@@ -6632,13 +6706,13 @@ var getLinkRef = (state, node) => {
|
|
|
6632
6706
|
const mark = node.getChildren("LinkMark");
|
|
6633
6707
|
const urlNode = node.getChild("URL");
|
|
6634
6708
|
if (mark && urlNode) {
|
|
6635
|
-
const
|
|
6636
|
-
if (
|
|
6709
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6710
|
+
if (dxn.startsWith("dxn:")) {
|
|
6637
6711
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6638
6712
|
return {
|
|
6639
6713
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6640
6714
|
label,
|
|
6641
|
-
|
|
6715
|
+
dxn
|
|
6642
6716
|
};
|
|
6643
6717
|
}
|
|
6644
6718
|
}
|
|
@@ -6653,13 +6727,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6653
6727
|
// return false;
|
|
6654
6728
|
// }
|
|
6655
6729
|
eq(other) {
|
|
6656
|
-
return this._link.
|
|
6730
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6657
6731
|
}
|
|
6658
6732
|
toDOM(_view) {
|
|
6659
6733
|
const root = document.createElement("dx-anchor");
|
|
6660
6734
|
root.classList.add("dx-tag--anchor");
|
|
6661
6735
|
root.textContent = this._link.label;
|
|
6662
|
-
root.setAttribute("
|
|
6736
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6663
6737
|
return root;
|
|
6664
6738
|
}
|
|
6665
6739
|
};
|
|
@@ -6673,11 +6747,11 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6673
6747
|
// return true;
|
|
6674
6748
|
// }
|
|
6675
6749
|
eq(other) {
|
|
6676
|
-
return this._link.
|
|
6750
|
+
return this._link.dxn === other._link.dxn;
|
|
6677
6751
|
}
|
|
6678
6752
|
toDOM(_view) {
|
|
6679
6753
|
const root = document.createElement("div");
|
|
6680
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6754
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6681
6755
|
this._options.addBlockContainer?.({
|
|
6682
6756
|
link: this._link,
|
|
6683
6757
|
el: root
|
|
@@ -6892,7 +6966,7 @@ var mixedParser = (registry) => {
|
|
|
6892
6966
|
};
|
|
6893
6967
|
|
|
6894
6968
|
// src/extensions/tags/streamer.ts
|
|
6895
|
-
import { StateEffect as
|
|
6969
|
+
import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
|
|
6896
6970
|
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6897
6971
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6898
6972
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
@@ -6904,7 +6978,7 @@ var streamer = (options = {}) => {
|
|
|
6904
6978
|
].filter(isTruthy4);
|
|
6905
6979
|
};
|
|
6906
6980
|
var cursor = () => {
|
|
6907
|
-
const hideCursor =
|
|
6981
|
+
const hideCursor = StateEffect8.define();
|
|
6908
6982
|
const showCursor = StateField12.define({
|
|
6909
6983
|
create: () => true,
|
|
6910
6984
|
update: (value, tr) => {
|
|
@@ -6974,9 +7048,9 @@ var CursorWidget = class extends WidgetType9 {
|
|
|
6974
7048
|
};
|
|
6975
7049
|
var fadeIn = (options = {}) => {
|
|
6976
7050
|
const FADE_IN_DURATION = 1e3;
|
|
6977
|
-
const DEFAULT_REMOVAL_DELAY =
|
|
7051
|
+
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
6978
7052
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6979
|
-
const removeDecoration =
|
|
7053
|
+
const removeDecoration = StateEffect8.define();
|
|
6980
7054
|
const fadeField = StateField12.define({
|
|
6981
7055
|
create: () => Decoration14.none,
|
|
6982
7056
|
update: (decorations2, tr) => {
|
|
@@ -7086,17 +7160,17 @@ var fadeIn = (options = {}) => {
|
|
|
7086
7160
|
|
|
7087
7161
|
// src/extensions/tags/xml-tags.ts
|
|
7088
7162
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7089
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7163
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
|
|
7090
7164
|
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin19, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7091
7165
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7092
|
-
import { log as
|
|
7166
|
+
import { log as log11 } from "@dxos/log";
|
|
7093
7167
|
|
|
7094
7168
|
// src/extensions/tags/xml-util.ts
|
|
7095
7169
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7096
|
-
var
|
|
7170
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7097
7171
|
var nodeToJson = (state, node) => {
|
|
7098
7172
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7099
|
-
F:
|
|
7173
|
+
F: __dxlog_file16,
|
|
7100
7174
|
L: 18,
|
|
7101
7175
|
S: void 0,
|
|
7102
7176
|
A: [
|
|
@@ -7160,16 +7234,16 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7234
|
};
|
|
7161
7235
|
|
|
7162
7236
|
// src/extensions/tags/xml-tags.ts
|
|
7163
|
-
var
|
|
7164
|
-
var navigatePreviousEffect =
|
|
7165
|
-
var navigateNextEffect =
|
|
7237
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7238
|
+
var navigatePreviousEffect = StateEffect9.define();
|
|
7239
|
+
var navigateNextEffect = StateEffect9.define();
|
|
7166
7240
|
var getXmlTextChild = (children) => {
|
|
7167
7241
|
const child = children?.[0];
|
|
7168
7242
|
return typeof child === "string" ? child : null;
|
|
7169
7243
|
};
|
|
7170
|
-
var xmlTagContextEffect =
|
|
7171
|
-
var xmlTagResetEffect =
|
|
7172
|
-
var xmlTagUpdateEffect =
|
|
7244
|
+
var xmlTagContextEffect = StateEffect9.define();
|
|
7245
|
+
var xmlTagResetEffect = StateEffect9.define();
|
|
7246
|
+
var xmlTagUpdateEffect = StateEffect9.define();
|
|
7173
7247
|
var widgetContextStateField = StateField13.define({
|
|
7174
7248
|
create: () => void 0,
|
|
7175
7249
|
update: (value, tr) => {
|
|
@@ -7190,11 +7264,11 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7190
7264
|
}
|
|
7191
7265
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7192
7266
|
const { id, value } = effect.value;
|
|
7193
|
-
|
|
7267
|
+
log11("widget updated", {
|
|
7194
7268
|
id,
|
|
7195
7269
|
value
|
|
7196
7270
|
}, {
|
|
7197
|
-
F:
|
|
7271
|
+
F: __dxlog_file17,
|
|
7198
7272
|
L: 153,
|
|
7199
7273
|
S: void 0,
|
|
7200
7274
|
C: (f, a) => f(...a)
|
|
@@ -7225,11 +7299,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7225
7299
|
const widgets = /* @__PURE__ */ new Map();
|
|
7226
7300
|
const notifier = {
|
|
7227
7301
|
mounted: (state) => {
|
|
7228
|
-
|
|
7302
|
+
log11("widget mounted", {
|
|
7229
7303
|
id: state.id,
|
|
7230
7304
|
tag: state.props._tag
|
|
7231
7305
|
}, {
|
|
7232
|
-
F:
|
|
7306
|
+
F: __dxlog_file17,
|
|
7233
7307
|
L: 206,
|
|
7234
7308
|
S: void 0,
|
|
7235
7309
|
C: (f, a) => f(...a)
|
|
@@ -7241,11 +7315,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7241
7315
|
},
|
|
7242
7316
|
unmounted: (id) => {
|
|
7243
7317
|
const state = widgets.get(id);
|
|
7244
|
-
|
|
7318
|
+
log11("widget unmounted", {
|
|
7245
7319
|
id,
|
|
7246
7320
|
tag: state?.props._tag
|
|
7247
7321
|
}, {
|
|
7248
|
-
F:
|
|
7322
|
+
F: __dxlog_file17,
|
|
7249
7323
|
L: 212,
|
|
7250
7324
|
S: void 0,
|
|
7251
7325
|
C: (f, a) => f(...a)
|
|
@@ -7307,11 +7381,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7307
7381
|
anchor: line.from,
|
|
7308
7382
|
head: line.from
|
|
7309
7383
|
},
|
|
7310
|
-
effects:
|
|
7311
|
-
line: line.number,
|
|
7312
|
-
|
|
7313
|
-
offset: -16
|
|
7314
|
-
}
|
|
7384
|
+
effects: scrollerLineEffect.of({
|
|
7385
|
+
line: line.number - 1,
|
|
7386
|
+
offset: -16
|
|
7315
7387
|
})
|
|
7316
7388
|
});
|
|
7317
7389
|
continue;
|
|
@@ -7342,11 +7414,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7342
7414
|
anchor: line.to,
|
|
7343
7415
|
head: line.to
|
|
7344
7416
|
},
|
|
7345
|
-
effects:
|
|
7346
|
-
line: line.number,
|
|
7347
|
-
|
|
7348
|
-
offset: -16
|
|
7349
|
-
}
|
|
7417
|
+
effects: scrollerLineEffect.of({
|
|
7418
|
+
line: line.number - 1,
|
|
7419
|
+
offset: -16
|
|
7350
7420
|
})
|
|
7351
7421
|
});
|
|
7352
7422
|
} else {
|
|
@@ -7356,11 +7426,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7356
7426
|
anchor: line.to,
|
|
7357
7427
|
head: line.to
|
|
7358
7428
|
},
|
|
7359
|
-
effects:
|
|
7360
|
-
line: line.number,
|
|
7361
|
-
|
|
7362
|
-
position: "end"
|
|
7363
|
-
}
|
|
7429
|
+
effects: scrollerLineEffect.of({
|
|
7430
|
+
line: line.number - 1,
|
|
7431
|
+
position: "end"
|
|
7364
7432
|
})
|
|
7365
7433
|
});
|
|
7366
7434
|
}
|
|
@@ -7407,6 +7475,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7407
7475
|
update: ({ from, decorations: decorations2 }, tr) => {
|
|
7408
7476
|
for (const effect of tr.effects) {
|
|
7409
7477
|
if (effect.is(xmlTagResetEffect)) {
|
|
7478
|
+
if (tr.docChanged) {
|
|
7479
|
+
return buildDecorations4(tr.state, {
|
|
7480
|
+
from: 0,
|
|
7481
|
+
to: tr.state.doc.length
|
|
7482
|
+
}, registry, notifier);
|
|
7483
|
+
}
|
|
7410
7484
|
return {
|
|
7411
7485
|
from: 0,
|
|
7412
7486
|
decorations: Decoration15.none
|
|
@@ -7417,12 +7491,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7417
7491
|
const { state } = tr;
|
|
7418
7492
|
const reset = tr.changes.touchesRange(0, from);
|
|
7419
7493
|
if (reset) {
|
|
7420
|
-
|
|
7494
|
+
log11("document reset", {
|
|
7421
7495
|
from,
|
|
7422
7496
|
to: state.doc.length
|
|
7423
7497
|
}, {
|
|
7424
|
-
F:
|
|
7425
|
-
L:
|
|
7498
|
+
F: __dxlog_file17,
|
|
7499
|
+
L: 374,
|
|
7426
7500
|
S: void 0,
|
|
7427
7501
|
C: (f, a) => f(...a)
|
|
7428
7502
|
});
|
|
@@ -7503,9 +7577,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7503
7577
|
}
|
|
7504
7578
|
}
|
|
7505
7579
|
} catch (err) {
|
|
7506
|
-
|
|
7507
|
-
F:
|
|
7508
|
-
L:
|
|
7580
|
+
log11.catch(err, void 0, {
|
|
7581
|
+
F: __dxlog_file17,
|
|
7582
|
+
L: 459,
|
|
7509
7583
|
S: void 0,
|
|
7510
7584
|
C: (f, a) => f(...a)
|
|
7511
7585
|
});
|
|
@@ -7529,8 +7603,8 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7529
7603
|
constructor(id, Component, props, notifier) {
|
|
7530
7604
|
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier;
|
|
7531
7605
|
invariant7(id, void 0, {
|
|
7532
|
-
F:
|
|
7533
|
-
L:
|
|
7606
|
+
F: __dxlog_file17,
|
|
7607
|
+
L: 485,
|
|
7534
7608
|
S: this,
|
|
7535
7609
|
A: [
|
|
7536
7610
|
"id",
|
|
@@ -7659,6 +7733,7 @@ export {
|
|
|
7659
7733
|
convertTreeToJson,
|
|
7660
7734
|
createBasicExtensions,
|
|
7661
7735
|
createComment,
|
|
7736
|
+
createCrawler,
|
|
7662
7737
|
createDataExtensions,
|
|
7663
7738
|
createEditorStateStore,
|
|
7664
7739
|
createEditorStateTransaction,
|
|
@@ -7739,9 +7814,10 @@ export {
|
|
|
7739
7814
|
removeStyle,
|
|
7740
7815
|
replacer,
|
|
7741
7816
|
scrollThreadIntoView,
|
|
7742
|
-
scrollToBottomEffect,
|
|
7743
7817
|
scrollToLine,
|
|
7744
|
-
|
|
7818
|
+
scroller,
|
|
7819
|
+
scrollerCrawlEffect,
|
|
7820
|
+
scrollerLineEffect,
|
|
7745
7821
|
selectionState,
|
|
7746
7822
|
setBlockquote,
|
|
7747
7823
|
setComments,
|
|
@@ -7749,7 +7825,6 @@ export {
|
|
|
7749
7825
|
setSelection,
|
|
7750
7826
|
setStyle,
|
|
7751
7827
|
singleValueFacet,
|
|
7752
|
-
smoothScroll,
|
|
7753
7828
|
stackItemContentEditorClassNames,
|
|
7754
7829
|
staticCompletion,
|
|
7755
7830
|
streamer,
|