@dxos/ui-editor 0.8.4-main.bc674ce → 0.8.4-main.d05673bc65
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
|
@@ -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
|
-
|
|
618
|
-
};
|
|
619
|
-
const hideScrollbar = (view) => {
|
|
620
|
-
view.scrollDOM.classList.add("cm-hide-scrollbar");
|
|
621
|
-
clearTimeout(hideTimeout);
|
|
622
|
-
hideTimeout = setTimeout(() => {
|
|
623
|
-
view.scrollDOM.classList.remove("cm-hide-scrollbar");
|
|
624
|
-
}, 1e3);
|
|
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
|
-
});
|
|
662
|
+
const setPinned = (pinned) => {
|
|
663
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
664
|
+
isPinned = pinned;
|
|
644
665
|
};
|
|
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)
|
|
@@ -1029,6 +1046,15 @@ var automerge = (accessor) => {
|
|
|
1029
1046
|
const value = DocAccessor.getValue(accessor);
|
|
1030
1047
|
const current = this._view.state.doc.toString();
|
|
1031
1048
|
if (value !== current) {
|
|
1049
|
+
console.warn("ENABLING INITIAL SYNC -- THIS MAY BE A REGRESSION");
|
|
1050
|
+
this._view.dispatch({
|
|
1051
|
+
changes: {
|
|
1052
|
+
from: 0,
|
|
1053
|
+
to: this._view.state.doc.length,
|
|
1054
|
+
insert: value
|
|
1055
|
+
},
|
|
1056
|
+
annotations: initialSync
|
|
1057
|
+
});
|
|
1032
1058
|
}
|
|
1033
1059
|
});
|
|
1034
1060
|
}
|
|
@@ -1056,7 +1082,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1056
1082
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1057
1083
|
import { Event } from "@dxos/async";
|
|
1058
1084
|
import { Context } from "@dxos/context";
|
|
1059
|
-
var
|
|
1085
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1060
1086
|
var dummyProvider = {
|
|
1061
1087
|
remoteStateChange: new Event(),
|
|
1062
1088
|
open: () => {
|
|
@@ -1080,7 +1106,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1080
1106
|
};
|
|
1081
1107
|
var RemoteSelectionsDecorator = class {
|
|
1082
1108
|
_ctx = new Context(void 0, {
|
|
1083
|
-
F:
|
|
1109
|
+
F: __dxlog_file5,
|
|
1084
1110
|
L: 80
|
|
1085
1111
|
});
|
|
1086
1112
|
_cursorConverter;
|
|
@@ -1293,8 +1319,8 @@ var styles = EditorView7.theme({
|
|
|
1293
1319
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1294
1320
|
import { Context as Context2 } from "@dxos/context";
|
|
1295
1321
|
import { invariant } from "@dxos/invariant";
|
|
1296
|
-
import { log as
|
|
1297
|
-
var
|
|
1322
|
+
import { log as log5 } from "@dxos/log";
|
|
1323
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1298
1324
|
var DEBOUNCE_INTERVAL = 100;
|
|
1299
1325
|
var SpaceAwarenessProvider = class {
|
|
1300
1326
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1314,7 +1340,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1314
1340
|
}
|
|
1315
1341
|
open() {
|
|
1316
1342
|
this._ctx = new Context2(void 0, {
|
|
1317
|
-
F:
|
|
1343
|
+
F: __dxlog_file6,
|
|
1318
1344
|
L: 57
|
|
1319
1345
|
});
|
|
1320
1346
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1341,10 +1367,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1341
1367
|
void this._messenger.postMessage(this._channel, {
|
|
1342
1368
|
kind: "query"
|
|
1343
1369
|
}).catch((err) => {
|
|
1344
|
-
|
|
1370
|
+
log5.debug("failed to query awareness", {
|
|
1345
1371
|
err
|
|
1346
1372
|
}, {
|
|
1347
|
-
F:
|
|
1373
|
+
F: __dxlog_file6,
|
|
1348
1374
|
L: 91,
|
|
1349
1375
|
S: this,
|
|
1350
1376
|
C: (f, a) => f(...a)
|
|
@@ -1361,7 +1387,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1361
1387
|
}
|
|
1362
1388
|
update(position) {
|
|
1363
1389
|
invariant(this._postTask, void 0, {
|
|
1364
|
-
F:
|
|
1390
|
+
F: __dxlog_file6,
|
|
1365
1391
|
L: 106,
|
|
1366
1392
|
S: this,
|
|
1367
1393
|
A: [
|
|
@@ -1378,7 +1404,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1378
1404
|
}
|
|
1379
1405
|
_handleQueryMessage() {
|
|
1380
1406
|
invariant(this._postTask, void 0, {
|
|
1381
|
-
F:
|
|
1407
|
+
F: __dxlog_file6,
|
|
1382
1408
|
L: 117,
|
|
1383
1409
|
S: this,
|
|
1384
1410
|
A: [
|
|
@@ -1390,7 +1416,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1390
1416
|
}
|
|
1391
1417
|
_handlePostMessage(message) {
|
|
1392
1418
|
invariant(message.kind === "post", void 0, {
|
|
1393
|
-
F:
|
|
1419
|
+
F: __dxlog_file6,
|
|
1394
1420
|
L: 122,
|
|
1395
1421
|
S: this,
|
|
1396
1422
|
A: [
|
|
@@ -1406,9 +1432,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1406
1432
|
// src/extensions/blast.ts
|
|
1407
1433
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1408
1434
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1409
|
-
import { throttle } from "@dxos/async";
|
|
1435
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1410
1436
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1411
|
-
var
|
|
1437
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1412
1438
|
var defaultOptions = {
|
|
1413
1439
|
effect: 2,
|
|
1414
1440
|
maxParticles: 200,
|
|
@@ -1527,7 +1553,7 @@ var Blaster = class {
|
|
|
1527
1553
|
}
|
|
1528
1554
|
initialize() {
|
|
1529
1555
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1530
|
-
F:
|
|
1556
|
+
F: __dxlog_file7,
|
|
1531
1557
|
L: 142,
|
|
1532
1558
|
S: this,
|
|
1533
1559
|
A: [
|
|
@@ -1564,7 +1590,7 @@ var Blaster = class {
|
|
|
1564
1590
|
}
|
|
1565
1591
|
start() {
|
|
1566
1592
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1567
|
-
F:
|
|
1593
|
+
F: __dxlog_file7,
|
|
1568
1594
|
L: 181,
|
|
1569
1595
|
S: this,
|
|
1570
1596
|
A: [
|
|
@@ -1598,11 +1624,11 @@ var Blaster = class {
|
|
|
1598
1624
|
this.drawParticles();
|
|
1599
1625
|
requestAnimationFrame(this.loop.bind(this));
|
|
1600
1626
|
}
|
|
1601
|
-
shake =
|
|
1627
|
+
shake = throttle2(({ time }) => {
|
|
1602
1628
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1603
1629
|
this._shakeTimeMax = time;
|
|
1604
1630
|
}, 100);
|
|
1605
|
-
spawn =
|
|
1631
|
+
spawn = throttle2(({ element, point }) => {
|
|
1606
1632
|
const color = getRGBComponents(element, this._options.color);
|
|
1607
1633
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1608
1634
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1776,11 +1802,11 @@ var blocks = () => [
|
|
|
1776
1802
|
".cm-line.block-line": {
|
|
1777
1803
|
paddingLeft: "0.75rem",
|
|
1778
1804
|
paddingRight: "0.75rem",
|
|
1779
|
-
borderLeft: "1px solid var(--
|
|
1780
|
-
borderRight: "1px solid var(--
|
|
1805
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1806
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1781
1807
|
},
|
|
1782
1808
|
".cm-line.block-single": {
|
|
1783
|
-
border: "1px solid var(--
|
|
1809
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1784
1810
|
borderRadius: "6px",
|
|
1785
1811
|
paddingTop: "0.5rem",
|
|
1786
1812
|
paddingBottom: "0.5rem",
|
|
@@ -1788,7 +1814,7 @@ var blocks = () => [
|
|
|
1788
1814
|
marginBottom: "0.5rem"
|
|
1789
1815
|
},
|
|
1790
1816
|
".cm-line.block-first": {
|
|
1791
|
-
borderTop: "1px solid var(--
|
|
1817
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1792
1818
|
borderTopLeftRadius: "6px",
|
|
1793
1819
|
borderTopRightRadius: "6px",
|
|
1794
1820
|
paddingTop: "0.5rem",
|
|
@@ -1796,7 +1822,7 @@ var blocks = () => [
|
|
|
1796
1822
|
},
|
|
1797
1823
|
".cm-line.block-middle": {},
|
|
1798
1824
|
".cm-line.block-last": {
|
|
1799
|
-
borderBottom: "1px solid var(--
|
|
1825
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1800
1826
|
borderBottomLeftRadius: "6px",
|
|
1801
1827
|
borderBottomRightRadius: "6px",
|
|
1802
1828
|
paddingBottom: "0.5rem",
|
|
@@ -1806,13 +1832,13 @@ var blocks = () => [
|
|
|
1806
1832
|
];
|
|
1807
1833
|
|
|
1808
1834
|
// src/extensions/bookmarks.ts
|
|
1809
|
-
import { Prec as Prec3, StateEffect as
|
|
1835
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1810
1836
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1811
|
-
import { log as
|
|
1812
|
-
var
|
|
1813
|
-
var addBookmark =
|
|
1814
|
-
var removeBookmark =
|
|
1815
|
-
var clearBookmarks =
|
|
1837
|
+
import { log as log6 } from "@dxos/log";
|
|
1838
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1839
|
+
var addBookmark = StateEffect3.define();
|
|
1840
|
+
var removeBookmark = StateEffect3.define();
|
|
1841
|
+
var clearBookmarks = StateEffect3.define();
|
|
1816
1842
|
var bookmarks = () => {
|
|
1817
1843
|
return [
|
|
1818
1844
|
bookmarksField,
|
|
@@ -1821,8 +1847,8 @@ var bookmarks = () => {
|
|
|
1821
1847
|
key: "Mod-ArrowUp",
|
|
1822
1848
|
run: (view) => {
|
|
1823
1849
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1824
|
-
|
|
1825
|
-
F:
|
|
1850
|
+
log6("up", bookmarks2, {
|
|
1851
|
+
F: __dxlog_file8,
|
|
1826
1852
|
L: 29,
|
|
1827
1853
|
S: void 0,
|
|
1828
1854
|
C: (f, a) => f(...a)
|
|
@@ -1834,8 +1860,8 @@ var bookmarks = () => {
|
|
|
1834
1860
|
key: "Mod-ArrowDown",
|
|
1835
1861
|
run: (view) => {
|
|
1836
1862
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1837
|
-
|
|
1838
|
-
F:
|
|
1863
|
+
log6("down", bookmarks2, {
|
|
1864
|
+
F: __dxlog_file8,
|
|
1839
1865
|
L: 37,
|
|
1840
1866
|
S: void 0,
|
|
1841
1867
|
C: (f, a) => f(...a)
|
|
@@ -1876,22 +1902,22 @@ var bookmarksField = StateField2.define({
|
|
|
1876
1902
|
|
|
1877
1903
|
// src/extensions/comments.ts
|
|
1878
1904
|
import { invertedEffects } from "@codemirror/commands";
|
|
1879
|
-
import { StateEffect as
|
|
1905
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1880
1906
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1881
1907
|
import sortBy from "lodash.sortby";
|
|
1882
|
-
import { debounce as
|
|
1883
|
-
import { log as
|
|
1908
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1909
|
+
import { log as log7 } from "@dxos/log";
|
|
1884
1910
|
import { isNonNullable } from "@dxos/util";
|
|
1885
1911
|
|
|
1886
1912
|
// src/extensions/selection.ts
|
|
1887
1913
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1888
1914
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1889
|
-
import { debounce
|
|
1915
|
+
import { debounce } from "@dxos/async";
|
|
1890
1916
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1891
1917
|
import { isTruthy } from "@dxos/util";
|
|
1892
|
-
var
|
|
1918
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1893
1919
|
var documentId = singleValueFacet();
|
|
1894
|
-
var stateRestoreAnnotation = "dxos.
|
|
1920
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1895
1921
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1896
1922
|
return {
|
|
1897
1923
|
selection,
|
|
@@ -1905,7 +1931,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1905
1931
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1906
1932
|
getState: (id) => {
|
|
1907
1933
|
invariant3(id, void 0, {
|
|
1908
|
-
F:
|
|
1934
|
+
F: __dxlog_file9,
|
|
1909
1935
|
L: 47,
|
|
1910
1936
|
S: void 0,
|
|
1911
1937
|
A: [
|
|
@@ -1918,7 +1944,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1918
1944
|
},
|
|
1919
1945
|
setState: (id, state) => {
|
|
1920
1946
|
invariant3(id, void 0, {
|
|
1921
|
-
F:
|
|
1947
|
+
F: __dxlog_file9,
|
|
1922
1948
|
L: 53,
|
|
1923
1949
|
S: void 0,
|
|
1924
1950
|
A: [
|
|
@@ -1930,7 +1956,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1930
1956
|
}
|
|
1931
1957
|
});
|
|
1932
1958
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1933
|
-
const setStateDebounced =
|
|
1959
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1934
1960
|
return [
|
|
1935
1961
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1936
1962
|
// EditorView.domEventHandlers({
|
|
@@ -1977,10 +2003,10 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1977
2003
|
};
|
|
1978
2004
|
|
|
1979
2005
|
// src/extensions/comments.ts
|
|
1980
|
-
var
|
|
1981
|
-
var setComments =
|
|
1982
|
-
var setSelection =
|
|
1983
|
-
var setCommentState =
|
|
2006
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
2007
|
+
var setComments = StateEffect4.define();
|
|
2008
|
+
var setSelection = StateEffect4.define();
|
|
2009
|
+
var setCommentState = StateEffect4.define();
|
|
1984
2010
|
var commentsState = StateField3.define({
|
|
1985
2011
|
create: (state) => ({
|
|
1986
2012
|
id: state.facet(documentId),
|
|
@@ -2022,14 +2048,14 @@ var commentsState = StateField3.define({
|
|
|
2022
2048
|
var styles2 = EditorView11.theme({
|
|
2023
2049
|
".cm-comment, .cm-comment-current": {
|
|
2024
2050
|
padding: "3px 0",
|
|
2025
|
-
color: "var(--
|
|
2026
|
-
backgroundColor: "var(--
|
|
2051
|
+
color: "var(--color-cm-comment-text)",
|
|
2052
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2027
2053
|
},
|
|
2028
2054
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2029
2055
|
boxDecorationBreak: "clone",
|
|
2030
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2031
|
-
backgroundColor: "var(--
|
|
2032
|
-
color: "var(--
|
|
2056
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2057
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2058
|
+
color: "var(--color-cm-comment-text)",
|
|
2033
2059
|
cursor: "pointer"
|
|
2034
2060
|
}
|
|
2035
2061
|
});
|
|
@@ -2047,8 +2073,8 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2047
2073
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2048
2074
|
const range = comment.range;
|
|
2049
2075
|
if (!range) {
|
|
2050
|
-
|
|
2051
|
-
F:
|
|
2076
|
+
log7.warn("Invalid range:", range, {
|
|
2077
|
+
F: __dxlog_file10,
|
|
2052
2078
|
L: 140,
|
|
2053
2079
|
S: void 0,
|
|
2054
2080
|
C: (f, a) => f(...a)
|
|
@@ -2062,7 +2088,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2062
2088
|
}).filter(isNonNullable);
|
|
2063
2089
|
return Decoration7.set(decorations2);
|
|
2064
2090
|
});
|
|
2065
|
-
var commentClickedEffect =
|
|
2091
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2066
2092
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2067
2093
|
click: (event, view) => {
|
|
2068
2094
|
let target = event.target;
|
|
@@ -2180,7 +2206,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2180
2206
|
from: changes.mapPos(comment.from, 1),
|
|
2181
2207
|
to: changes.mapPos(comment.to, 1)
|
|
2182
2208
|
});
|
|
2183
|
-
var restoreCommentEffect =
|
|
2209
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2184
2210
|
map: mapTrackedComment
|
|
2185
2211
|
});
|
|
2186
2212
|
var createComment = (view) => {
|
|
@@ -2214,7 +2240,7 @@ var createComment = (view) => {
|
|
|
2214
2240
|
var optionsFacet = singleValueFacet();
|
|
2215
2241
|
var comments = (options = {}) => {
|
|
2216
2242
|
const { key: shortcut = "meta-'" } = options;
|
|
2217
|
-
const handleSelect =
|
|
2243
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2218
2244
|
return [
|
|
2219
2245
|
optionsFacet.of(options),
|
|
2220
2246
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2392,9 +2418,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2392
2418
|
// src/extensions/debug.ts
|
|
2393
2419
|
import { syntaxTree } from "@codemirror/language";
|
|
2394
2420
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2395
|
-
var debugNodeLogger = (
|
|
2421
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2396
2422
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2397
|
-
enter: (node) =>
|
|
2423
|
+
enter: (node) => log12(node.type)
|
|
2398
2424
|
});
|
|
2399
2425
|
return StateField4.define({
|
|
2400
2426
|
create: (state) => logTokens(state),
|
|
@@ -2429,8 +2455,8 @@ var dropFile = (options = {}) => {
|
|
|
2429
2455
|
};
|
|
2430
2456
|
var styles3 = EditorView12.theme({
|
|
2431
2457
|
".cm-dropCursor": {
|
|
2432
|
-
borderLeft: "2px solid var(--
|
|
2433
|
-
color: "var(--
|
|
2458
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2459
|
+
color: "var(--color-accent-text)",
|
|
2434
2460
|
padding: "0 4px"
|
|
2435
2461
|
},
|
|
2436
2462
|
".cm-dropCursor:after": {
|
|
@@ -2448,43 +2474,62 @@ import { EditorView as EditorView15, ViewPlugin as ViewPlugin11, drawSelection,
|
|
|
2448
2474
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2449
2475
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2450
2476
|
import { generateName } from "@dxos/display-name";
|
|
2451
|
-
import { log as
|
|
2477
|
+
import { log as log8 } from "@dxos/log";
|
|
2452
2478
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2453
2479
|
|
|
2454
|
-
// src/styles/
|
|
2480
|
+
// src/styles/theme.ts
|
|
2481
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2455
2482
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2456
2483
|
var headings = {
|
|
2457
|
-
1:
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2484
|
+
1: {
|
|
2485
|
+
className: "text-4xl",
|
|
2486
|
+
fontSize: "var(--text-4xl)",
|
|
2487
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2488
|
+
},
|
|
2489
|
+
2: {
|
|
2490
|
+
className: "text-3xl",
|
|
2491
|
+
fontSize: "var(--text-3xl)",
|
|
2492
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2493
|
+
},
|
|
2494
|
+
3: {
|
|
2495
|
+
className: "text-2xl",
|
|
2496
|
+
fontSize: "var(--text-2xl)",
|
|
2497
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2498
|
+
},
|
|
2499
|
+
4: {
|
|
2500
|
+
className: "text-xl",
|
|
2501
|
+
fontSize: "var(--text-xl)",
|
|
2502
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2503
|
+
},
|
|
2504
|
+
5: {
|
|
2505
|
+
className: "text-lg",
|
|
2506
|
+
fontSize: "var(--text-lg)",
|
|
2507
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2508
|
+
},
|
|
2509
|
+
6: {
|
|
2510
|
+
className: "text-base",
|
|
2511
|
+
fontSize: "var(--text-base)",
|
|
2512
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2513
|
+
}
|
|
2463
2514
|
};
|
|
2464
2515
|
var markdownTheme = {
|
|
2465
|
-
code: "font-mono
|
|
2466
|
-
codeMark: "font-mono text-
|
|
2516
|
+
code: "font-mono no-underline! text-cm-code",
|
|
2517
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
2467
2518
|
mark: "opacity-50",
|
|
2468
|
-
heading: (level) => {
|
|
2469
|
-
|
|
2470
|
-
|
|
2519
|
+
heading: (level) => ({
|
|
2520
|
+
className: mx3(headings[level].className, "font-light text-cm-heading"),
|
|
2521
|
+
color: "var(--color-cm-heading) !important",
|
|
2522
|
+
lineHeight: headings[level].lineHeight,
|
|
2523
|
+
fontSize: headings[level].fontSize,
|
|
2524
|
+
fontWeight: "100 !important"
|
|
2525
|
+
})
|
|
2471
2526
|
};
|
|
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
|
|
2527
|
+
var fontBody = "Inter Variable, ui-sans-serif, system-ui, sans-serif";
|
|
2528
|
+
var fontMono = "JetBrains Mono Variable, ui-monospace, Cascadia Code, Source Code Pro, monospace";
|
|
2487
2529
|
var baseTheme = EditorView13.baseTheme({
|
|
2530
|
+
/**
|
|
2531
|
+
* Outer frame.
|
|
2532
|
+
*/
|
|
2488
2533
|
"&": {},
|
|
2489
2534
|
"&.cm-focused": {
|
|
2490
2535
|
outline: "none"
|
|
@@ -2493,7 +2538,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2493
2538
|
* Scroller
|
|
2494
2539
|
*/
|
|
2495
2540
|
".cm-scroller": {
|
|
2496
|
-
|
|
2541
|
+
overflowAnchor: "none"
|
|
2542
|
+
},
|
|
2543
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2544
|
+
width: "8px"
|
|
2545
|
+
},
|
|
2546
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2547
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2548
|
+
background: "transparent",
|
|
2549
|
+
transition: "background 0.15s"
|
|
2550
|
+
},
|
|
2551
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2552
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2497
2553
|
},
|
|
2498
2554
|
/**
|
|
2499
2555
|
* Content
|
|
@@ -2515,8 +2571,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2515
2571
|
".cm-gutter": {},
|
|
2516
2572
|
".cm-gutter.cm-lineNumbers": {
|
|
2517
2573
|
paddingRight: "4px",
|
|
2518
|
-
borderRight: "1px solid var(--
|
|
2519
|
-
color: "var(--
|
|
2574
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2575
|
+
color: "var(--color-subdued)"
|
|
2520
2576
|
},
|
|
2521
2577
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2522
2578
|
minWidth: "40px"
|
|
@@ -2536,25 +2592,25 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2536
2592
|
paddingInline: 0
|
|
2537
2593
|
},
|
|
2538
2594
|
".cm-activeLine": {
|
|
2539
|
-
background: "var(--
|
|
2595
|
+
background: "var(--color-cm-active-line)"
|
|
2540
2596
|
},
|
|
2541
2597
|
/**
|
|
2542
2598
|
* Cursor (layer).
|
|
2543
2599
|
*/
|
|
2544
2600
|
".cm-cursor, .cm-dropCursor": {
|
|
2545
|
-
borderLeft: "2px solid var(--
|
|
2601
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2546
2602
|
},
|
|
2547
2603
|
".cm-placeholder": {
|
|
2548
|
-
color: "var(--
|
|
2604
|
+
color: "var(--color-placeholder)"
|
|
2549
2605
|
},
|
|
2550
2606
|
/**
|
|
2551
2607
|
* Selection (layer).
|
|
2552
2608
|
*/
|
|
2553
2609
|
".cm-selectionBackground": {
|
|
2554
|
-
background: "var(--
|
|
2610
|
+
background: "var(--color-cm-selection)"
|
|
2555
2611
|
},
|
|
2556
2612
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2557
|
-
background: "var(--
|
|
2613
|
+
background: "var(--color-cm-focused-selection)"
|
|
2558
2614
|
},
|
|
2559
2615
|
/**
|
|
2560
2616
|
* Search.
|
|
@@ -2564,8 +2620,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2564
2620
|
margin: "0 -3px",
|
|
2565
2621
|
padding: "3px",
|
|
2566
2622
|
borderRadius: "3px",
|
|
2567
|
-
background: "var(--
|
|
2568
|
-
color: "var(--
|
|
2623
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2624
|
+
color: "var(--color-cm-highlight)"
|
|
2569
2625
|
},
|
|
2570
2626
|
".cm-searchMatch-selected": {
|
|
2571
2627
|
textDecoration: "underline"
|
|
@@ -2576,20 +2632,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2576
2632
|
".cm-link": {
|
|
2577
2633
|
textDecorationLine: "underline",
|
|
2578
2634
|
textDecorationThickness: "1px",
|
|
2579
|
-
textDecorationColor: "var(--
|
|
2635
|
+
textDecorationColor: "var(--color-separator)",
|
|
2580
2636
|
textUnderlineOffset: "2px",
|
|
2581
2637
|
borderRadius: ".125rem"
|
|
2582
2638
|
},
|
|
2583
2639
|
".cm-link > span": {
|
|
2584
|
-
color: "var(--
|
|
2640
|
+
color: "var(--color-accent-text)"
|
|
2641
|
+
},
|
|
2642
|
+
".cm-link > span:hover": {
|
|
2643
|
+
color: "var(--color-accent-text-hover)"
|
|
2585
2644
|
},
|
|
2586
2645
|
/**
|
|
2587
2646
|
* Tooltip.
|
|
2588
2647
|
*/
|
|
2589
2648
|
".cm-tooltip": {
|
|
2590
|
-
background: "var(--
|
|
2649
|
+
background: "var(--color-modal-surface)"
|
|
2591
2650
|
},
|
|
2592
2651
|
".cm-tooltip-below": {},
|
|
2652
|
+
".cm-tooltip-hover": {
|
|
2653
|
+
background: "var(--color-modal-surface)",
|
|
2654
|
+
border: "1px solid var(--color-separator)",
|
|
2655
|
+
borderRadius: "4px",
|
|
2656
|
+
overflow: "hidden"
|
|
2657
|
+
},
|
|
2593
2658
|
/**
|
|
2594
2659
|
* Autocomplete.
|
|
2595
2660
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2597,7 +2662,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2597
2662
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2598
2663
|
marginTop: "6px",
|
|
2599
2664
|
marginLeft: "-10px",
|
|
2600
|
-
border: "2px solid var(--
|
|
2665
|
+
border: "2px solid var(--color-separator)",
|
|
2601
2666
|
borderRadius: "4px"
|
|
2602
2667
|
},
|
|
2603
2668
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2607,12 +2672,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2607
2672
|
padding: "4px"
|
|
2608
2673
|
},
|
|
2609
2674
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2610
|
-
background: "var(--
|
|
2611
|
-
color: "var(--
|
|
2675
|
+
background: "var(--color-active-surface)",
|
|
2676
|
+
color: "var(--color-base-surface-text)"
|
|
2612
2677
|
},
|
|
2613
2678
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2614
2679
|
paddingLeft: "4px !important",
|
|
2615
|
-
color: "var(--
|
|
2680
|
+
color: "var(--color-base-surface-text)"
|
|
2616
2681
|
},
|
|
2617
2682
|
/**
|
|
2618
2683
|
* Completion info.
|
|
@@ -2621,17 +2686,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2621
2686
|
width: "360px !important",
|
|
2622
2687
|
margin: "-10px 1px 0 1px",
|
|
2623
2688
|
padding: "8px !important",
|
|
2624
|
-
borderColor: "var(--
|
|
2689
|
+
borderColor: "var(--color-separator)"
|
|
2625
2690
|
},
|
|
2626
2691
|
".cm-completionIcon": {
|
|
2627
2692
|
display: "none"
|
|
2628
2693
|
},
|
|
2629
2694
|
".cm-completionLabel": {
|
|
2630
|
-
color: "var(--
|
|
2695
|
+
color: "var(--color-description)",
|
|
2631
2696
|
padding: "0 4px"
|
|
2632
2697
|
},
|
|
2633
2698
|
".cm-completionMatchedText": {
|
|
2634
|
-
color: "var(--
|
|
2699
|
+
color: "var(--color-base-surface-text)",
|
|
2635
2700
|
textDecoration: "none !important"
|
|
2636
2701
|
},
|
|
2637
2702
|
/**
|
|
@@ -2655,7 +2720,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2655
2720
|
backgroundColor: "var(--surface-bg)"
|
|
2656
2721
|
},
|
|
2657
2722
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2658
|
-
color: "var(--
|
|
2723
|
+
color: "var(--color-subdued)",
|
|
2659
2724
|
fontSize: "14px",
|
|
2660
2725
|
all: "unset",
|
|
2661
2726
|
margin: "3px !important",
|
|
@@ -2663,10 +2728,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2663
2728
|
outline: "1px solid transparent"
|
|
2664
2729
|
},
|
|
2665
2730
|
".cm-panel input, .cm-panel button": {
|
|
2666
|
-
backgroundColor: "var(--
|
|
2731
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2667
2732
|
},
|
|
2668
2733
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2669
|
-
outline: "1px solid var(--
|
|
2734
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2670
2735
|
},
|
|
2671
2736
|
".cm-panel label": {
|
|
2672
2737
|
display: "inline-flex",
|
|
@@ -2679,25 +2744,26 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2679
2744
|
height: "8px",
|
|
2680
2745
|
marginRight: "6px !important",
|
|
2681
2746
|
padding: "2px !important",
|
|
2682
|
-
color: "var(--
|
|
2747
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2683
2748
|
},
|
|
2684
2749
|
".cm-panel button": {
|
|
2685
2750
|
"&:hover": {
|
|
2686
|
-
|
|
2751
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2752
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2687
2753
|
},
|
|
2688
2754
|
"&:active": {
|
|
2689
|
-
backgroundColor: "var(--
|
|
2755
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2690
2756
|
}
|
|
2691
2757
|
},
|
|
2692
2758
|
".cm-panel.cm-search": {
|
|
2693
2759
|
padding: "4px",
|
|
2694
|
-
borderTop: "1px solid var(--
|
|
2760
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2695
2761
|
}
|
|
2696
2762
|
});
|
|
2697
2763
|
var editorGutter = EditorView13.theme({
|
|
2698
2764
|
".cm-gutters": {
|
|
2699
2765
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2700
|
-
background: "var(--
|
|
2766
|
+
background: "var(--color-base-surface) !important",
|
|
2701
2767
|
paddingRight: "1rem"
|
|
2702
2768
|
}
|
|
2703
2769
|
});
|
|
@@ -2715,9 +2781,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2715
2781
|
});
|
|
2716
2782
|
|
|
2717
2783
|
// src/extensions/focus.ts
|
|
2718
|
-
import { StateEffect as
|
|
2784
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2719
2785
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2720
|
-
var focusEffect =
|
|
2786
|
+
var focusEffect = StateEffect5.define();
|
|
2721
2787
|
var focusField = StateField5.define({
|
|
2722
2788
|
create: () => false,
|
|
2723
2789
|
update: (value, tr) => {
|
|
@@ -2746,7 +2812,7 @@ var focus = [
|
|
|
2746
2812
|
];
|
|
2747
2813
|
|
|
2748
2814
|
// src/extensions/factories.ts
|
|
2749
|
-
var
|
|
2815
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2750
2816
|
var tabbable = EditorView15.contentAttributes.of({
|
|
2751
2817
|
tabindex: "0"
|
|
2752
2818
|
});
|
|
@@ -2801,9 +2867,9 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2801
2867
|
return [
|
|
2802
2868
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2803
2869
|
EditorView15.exceptionSink.of((err) => {
|
|
2804
|
-
|
|
2805
|
-
F:
|
|
2806
|
-
L:
|
|
2870
|
+
log8.catch(err, void 0, {
|
|
2871
|
+
F: __dxlog_file11,
|
|
2872
|
+
L: 131,
|
|
2807
2873
|
S: void 0,
|
|
2808
2874
|
C: (f, a) => f(...a)
|
|
2809
2875
|
});
|
|
@@ -2855,12 +2921,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2855
2921
|
};
|
|
2856
2922
|
var grow = {
|
|
2857
2923
|
editor: {
|
|
2858
|
-
className: "
|
|
2924
|
+
className: "h-full w-full"
|
|
2859
2925
|
}
|
|
2860
2926
|
};
|
|
2861
2927
|
var fullWidth = {
|
|
2862
2928
|
editor: {
|
|
2863
|
-
className: "
|
|
2929
|
+
className: "w-full"
|
|
2864
2930
|
}
|
|
2865
2931
|
};
|
|
2866
2932
|
var defaultThemeSlots = grow;
|
|
@@ -2903,8 +2969,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2903
2969
|
channel: `awareness.${id}`,
|
|
2904
2970
|
peerId: identity.identityKey.toHex(),
|
|
2905
2971
|
info: {
|
|
2906
|
-
darkColor: `var(--
|
|
2907
|
-
lightColor: `var(--
|
|
2972
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
2973
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2908
2974
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2909
2975
|
}
|
|
2910
2976
|
})));
|
|
@@ -2923,7 +2989,7 @@ var folding = () => {
|
|
|
2923
2989
|
}),
|
|
2924
2990
|
foldGutter({
|
|
2925
2991
|
markerDOM: (open) => {
|
|
2926
|
-
return Domino2.of("div").classNames("flex
|
|
2992
|
+
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({
|
|
2927
2993
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2928
2994
|
}))).root;
|
|
2929
2995
|
}
|
|
@@ -4219,6 +4285,11 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
|
4219
4285
|
import { HighlightStyle as HighlightStyle2 } from "@codemirror/language";
|
|
4220
4286
|
import { Tag, styleTags, tags } from "@lezer/highlight";
|
|
4221
4287
|
import { Table } from "@lezer/markdown";
|
|
4288
|
+
var styles4 = {
|
|
4289
|
+
code: "font-mono no-underline! text-cm-code",
|
|
4290
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
4291
|
+
mark: "opacity-50"
|
|
4292
|
+
};
|
|
4222
4293
|
var markdownTags = {
|
|
4223
4294
|
Blockquote: Tag.define(),
|
|
4224
4295
|
CodeMark: Tag.define(),
|
|
@@ -4300,7 +4371,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4300
4371
|
markdownTags.LinkReference,
|
|
4301
4372
|
markdownTags.ListMark
|
|
4302
4373
|
],
|
|
4303
|
-
class:
|
|
4374
|
+
class: styles4.mark
|
|
4304
4375
|
},
|
|
4305
4376
|
// Markdown marks.
|
|
4306
4377
|
{
|
|
@@ -4311,7 +4382,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4311
4382
|
markdownTags.QuoteMark,
|
|
4312
4383
|
markdownTags.EmphasisMark
|
|
4313
4384
|
],
|
|
4314
|
-
class:
|
|
4385
|
+
class: styles4.mark
|
|
4315
4386
|
},
|
|
4316
4387
|
// E.g., code block language (after ```).
|
|
4317
4388
|
{
|
|
@@ -4320,7 +4391,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4320
4391
|
tags.function(tags.variableName),
|
|
4321
4392
|
tags.labelName
|
|
4322
4393
|
],
|
|
4323
|
-
class:
|
|
4394
|
+
class: styles4.codeMark
|
|
4324
4395
|
},
|
|
4325
4396
|
// Fonts.
|
|
4326
4397
|
{
|
|
@@ -4330,30 +4401,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4330
4401
|
],
|
|
4331
4402
|
class: "font-mono"
|
|
4332
4403
|
},
|
|
4333
|
-
// Headings
|
|
4404
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4405
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4406
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4407
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4408
|
+
{
|
|
4409
|
+
tag: tags.heading,
|
|
4410
|
+
color: "var(--color-cm-heading) !important",
|
|
4411
|
+
fontWeight: "300"
|
|
4412
|
+
},
|
|
4334
4413
|
{
|
|
4335
4414
|
tag: tags.heading1,
|
|
4336
|
-
|
|
4415
|
+
...markdownTheme.heading(1)
|
|
4337
4416
|
},
|
|
4338
4417
|
{
|
|
4339
4418
|
tag: tags.heading2,
|
|
4340
|
-
|
|
4419
|
+
...markdownTheme.heading(2)
|
|
4341
4420
|
},
|
|
4342
4421
|
{
|
|
4343
4422
|
tag: tags.heading3,
|
|
4344
|
-
|
|
4423
|
+
...markdownTheme.heading(3)
|
|
4345
4424
|
},
|
|
4346
4425
|
{
|
|
4347
4426
|
tag: tags.heading4,
|
|
4348
|
-
|
|
4427
|
+
...markdownTheme.heading(4)
|
|
4349
4428
|
},
|
|
4350
4429
|
{
|
|
4351
4430
|
tag: tags.heading5,
|
|
4352
|
-
|
|
4431
|
+
...markdownTheme.heading(5)
|
|
4353
4432
|
},
|
|
4354
4433
|
{
|
|
4355
4434
|
tag: tags.heading6,
|
|
4356
|
-
|
|
4435
|
+
...markdownTheme.heading(6)
|
|
4357
4436
|
},
|
|
4358
4437
|
// Emphasis.
|
|
4359
4438
|
{
|
|
@@ -4378,7 +4457,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4378
4457
|
markdownTags.CodeText,
|
|
4379
4458
|
markdownTags.InlineCode
|
|
4380
4459
|
],
|
|
4381
|
-
class:
|
|
4460
|
+
class: styles4.code
|
|
4382
4461
|
},
|
|
4383
4462
|
{
|
|
4384
4463
|
tag: [
|
|
@@ -4483,7 +4562,7 @@ var convertTreeToJson = (state) => {
|
|
|
4483
4562
|
|
|
4484
4563
|
// src/extensions/markdown/decorate.ts
|
|
4485
4564
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4486
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4565
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4487
4566
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4488
4567
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4489
4568
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
@@ -4735,7 +4814,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4735
4814
|
width: "100%",
|
|
4736
4815
|
height: "0",
|
|
4737
4816
|
verticalAlign: "middle",
|
|
4738
|
-
borderTop: "1px solid var(--
|
|
4817
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4739
4818
|
opacity: 0.5
|
|
4740
4819
|
},
|
|
4741
4820
|
/**
|
|
@@ -4758,8 +4837,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4758
4837
|
* Blockquote.
|
|
4759
4838
|
*/
|
|
4760
4839
|
"& .cm-blockquote": {
|
|
4761
|
-
background: "var(--
|
|
4762
|
-
borderLeft: "2px solid var(--
|
|
4840
|
+
background: "var(--color-cm-codeblock)",
|
|
4841
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4763
4842
|
paddingLeft: "1rem",
|
|
4764
4843
|
margin: "0"
|
|
4765
4844
|
},
|
|
@@ -4770,7 +4849,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4770
4849
|
fontFamily: fontMono
|
|
4771
4850
|
},
|
|
4772
4851
|
"& .cm-codeblock-line": {
|
|
4773
|
-
background: "var(--
|
|
4852
|
+
background: "var(--color-cm-codeblock)",
|
|
4774
4853
|
paddingInline: "1rem !important"
|
|
4775
4854
|
},
|
|
4776
4855
|
"& .cm-codeblock-start": {
|
|
@@ -4804,8 +4883,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4804
4883
|
".cm-table-head": {
|
|
4805
4884
|
padding: "2px 16px 2px 0px",
|
|
4806
4885
|
textAlign: "left",
|
|
4807
|
-
borderBottom: "1px solid var(--
|
|
4808
|
-
color: "var(--
|
|
4886
|
+
borderBottom: "1px solid var(--color-cm-separator)",
|
|
4887
|
+
color: "var(--color-subdued)"
|
|
4809
4888
|
},
|
|
4810
4889
|
".cm-table-cell": {
|
|
4811
4890
|
padding: "2px 16px 2px 0px"
|
|
@@ -4945,7 +5024,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4945
5024
|
};
|
|
4946
5025
|
|
|
4947
5026
|
// src/extensions/markdown/decorate.ts
|
|
4948
|
-
var
|
|
5027
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4949
5028
|
var Unicode = {
|
|
4950
5029
|
emDash: "\u2014",
|
|
4951
5030
|
bullet: "\u2022",
|
|
@@ -4968,7 +5047,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4968
5047
|
eq(other) {
|
|
4969
5048
|
return this.url === other.url;
|
|
4970
5049
|
}
|
|
4971
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4972
5050
|
toDOM(view) {
|
|
4973
5051
|
const el = document.createElement("span");
|
|
4974
5052
|
this.render(el, {
|
|
@@ -5081,8 +5159,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5081
5159
|
const headerLevels = [];
|
|
5082
5160
|
const getHeaderLevels = (node, level) => {
|
|
5083
5161
|
invariant4(level > 0, void 0, {
|
|
5084
|
-
F:
|
|
5085
|
-
L:
|
|
5162
|
+
F: __dxlog_file12,
|
|
5163
|
+
L: 179,
|
|
5086
5164
|
S: void 0,
|
|
5087
5165
|
A: [
|
|
5088
5166
|
"level > 0",
|
|
@@ -5120,8 +5198,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5120
5198
|
};
|
|
5121
5199
|
const getCurrentListLevel = () => {
|
|
5122
5200
|
invariant4(listLevels.length, void 0, {
|
|
5123
|
-
F:
|
|
5124
|
-
L:
|
|
5201
|
+
F: __dxlog_file12,
|
|
5202
|
+
L: 201,
|
|
5125
5203
|
S: void 0,
|
|
5126
5204
|
A: [
|
|
5127
5205
|
"listLevels.length",
|
|
@@ -5171,7 +5249,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5171
5249
|
from: mark.from,
|
|
5172
5250
|
to: mark.from + len,
|
|
5173
5251
|
deco: Decoration11.replace({
|
|
5174
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5252
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5175
5253
|
})
|
|
5176
5254
|
});
|
|
5177
5255
|
}
|
|
@@ -5438,7 +5516,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5438
5516
|
atomicDeco: atomicDeco.finish()
|
|
5439
5517
|
};
|
|
5440
5518
|
};
|
|
5441
|
-
var forceUpdate =
|
|
5519
|
+
var forceUpdate = StateEffect6.define();
|
|
5442
5520
|
var decorateMarkdown = (options = {}) => {
|
|
5443
5521
|
return [
|
|
5444
5522
|
ViewPlugin14.fromClass(class {
|
|
@@ -5510,8 +5588,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5510
5588
|
return {
|
|
5511
5589
|
pos: link.from,
|
|
5512
5590
|
end: link.to,
|
|
5513
|
-
|
|
5514
|
-
// above: true,
|
|
5591
|
+
above: true,
|
|
5515
5592
|
create: () => {
|
|
5516
5593
|
const el = document.createElement("div");
|
|
5517
5594
|
el.className = tooltipContent({});
|
|
@@ -5527,16 +5604,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5527
5604
|
};
|
|
5528
5605
|
}
|
|
5529
5606
|
};
|
|
5530
|
-
}, {
|
|
5531
|
-
// NOTE: 0 = default of 300ms.
|
|
5532
|
-
hoverTime: 1
|
|
5533
5607
|
});
|
|
5534
5608
|
};
|
|
5535
5609
|
|
|
5536
5610
|
// src/extensions/mention.ts
|
|
5537
5611
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5538
|
-
import { log as
|
|
5539
|
-
var
|
|
5612
|
+
import { log as log9 } from "@dxos/log";
|
|
5613
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5540
5614
|
var mention = ({ debug, onSearch }) => {
|
|
5541
5615
|
return autocompletion({
|
|
5542
5616
|
// TODO(burdon): Not working.
|
|
@@ -5548,10 +5622,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5548
5622
|
icons: false,
|
|
5549
5623
|
override: [
|
|
5550
5624
|
(context) => {
|
|
5551
|
-
|
|
5625
|
+
log9.info("completion context", {
|
|
5552
5626
|
context
|
|
5553
5627
|
}, {
|
|
5554
|
-
F:
|
|
5628
|
+
F: __dxlog_file13,
|
|
5555
5629
|
L: 27,
|
|
5556
5630
|
S: void 0,
|
|
5557
5631
|
C: (f, a) => f(...a)
|
|
@@ -5572,8 +5646,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5572
5646
|
};
|
|
5573
5647
|
|
|
5574
5648
|
// src/extensions/modal.ts
|
|
5575
|
-
import { StateEffect as
|
|
5576
|
-
var modalStateEffect =
|
|
5649
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5650
|
+
var modalStateEffect = StateEffect7.define();
|
|
5577
5651
|
var modalStateField = StateField9.define({
|
|
5578
5652
|
create: () => false,
|
|
5579
5653
|
update: (value, tr) => {
|
|
@@ -5634,7 +5708,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5634
5708
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5635
5709
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5636
5710
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5637
|
-
var
|
|
5711
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5638
5712
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5639
5713
|
return {
|
|
5640
5714
|
type,
|
|
@@ -5789,7 +5863,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5789
5863
|
}
|
|
5790
5864
|
case "BulletList": {
|
|
5791
5865
|
invariant5(current, void 0, {
|
|
5792
|
-
F:
|
|
5866
|
+
F: __dxlog_file14,
|
|
5793
5867
|
L: 219,
|
|
5794
5868
|
S: void 0,
|
|
5795
5869
|
A: [
|
|
@@ -5806,7 +5880,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5806
5880
|
}
|
|
5807
5881
|
case "ListItem": {
|
|
5808
5882
|
invariant5(parent, void 0, {
|
|
5809
|
-
F:
|
|
5883
|
+
F: __dxlog_file14,
|
|
5810
5884
|
L: 228,
|
|
5811
5885
|
S: void 0,
|
|
5812
5886
|
A: [
|
|
@@ -5848,7 +5922,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5848
5922
|
}
|
|
5849
5923
|
case "ListMark": {
|
|
5850
5924
|
invariant5(current, void 0, {
|
|
5851
|
-
F:
|
|
5925
|
+
F: __dxlog_file14,
|
|
5852
5926
|
L: 272,
|
|
5853
5927
|
S: void 0,
|
|
5854
5928
|
A: [
|
|
@@ -5862,7 +5936,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5862
5936
|
}
|
|
5863
5937
|
case "Task": {
|
|
5864
5938
|
invariant5(current, void 0, {
|
|
5865
|
-
F:
|
|
5939
|
+
F: __dxlog_file14,
|
|
5866
5940
|
L: 278,
|
|
5867
5941
|
S: void 0,
|
|
5868
5942
|
A: [
|
|
@@ -5875,7 +5949,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5875
5949
|
}
|
|
5876
5950
|
case "TaskMarker": {
|
|
5877
5951
|
invariant5(current, void 0, {
|
|
5878
|
-
F:
|
|
5952
|
+
F: __dxlog_file14,
|
|
5879
5953
|
L: 283,
|
|
5880
5954
|
S: void 0,
|
|
5881
5955
|
A: [
|
|
@@ -5891,7 +5965,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5891
5965
|
leave: (node) => {
|
|
5892
5966
|
if (node.name === "BulletList") {
|
|
5893
5967
|
invariant5(parent, void 0, {
|
|
5894
|
-
F:
|
|
5968
|
+
F: __dxlog_file14,
|
|
5895
5969
|
L: 291,
|
|
5896
5970
|
S: void 0,
|
|
5897
5971
|
A: [
|
|
@@ -5905,7 +5979,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5905
5979
|
}
|
|
5906
5980
|
});
|
|
5907
5981
|
invariant5(tree, void 0, {
|
|
5908
|
-
F:
|
|
5982
|
+
F: __dxlog_file14,
|
|
5909
5983
|
L: 298,
|
|
5910
5984
|
S: void 0,
|
|
5911
5985
|
A: [
|
|
@@ -6203,8 +6277,8 @@ import { mx as mx7 } from "@dxos/ui-theme";
|
|
|
6203
6277
|
// src/extensions/outliner/editor.ts
|
|
6204
6278
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6205
6279
|
import { ViewPlugin as ViewPlugin15 } from "@codemirror/view";
|
|
6206
|
-
import { log as
|
|
6207
|
-
var
|
|
6280
|
+
import { log as log10 } from "@dxos/log";
|
|
6281
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6208
6282
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6209
6283
|
var initialize = () => {
|
|
6210
6284
|
return ViewPlugin15.fromClass(class {
|
|
@@ -6336,7 +6410,7 @@ var editor = () => [
|
|
|
6336
6410
|
cancel = true;
|
|
6337
6411
|
return;
|
|
6338
6412
|
}
|
|
6339
|
-
|
|
6413
|
+
log10("change", {
|
|
6340
6414
|
item,
|
|
6341
6415
|
line: {
|
|
6342
6416
|
from: line.from,
|
|
@@ -6355,7 +6429,7 @@ var editor = () => [
|
|
|
6355
6429
|
length: insert.length
|
|
6356
6430
|
}
|
|
6357
6431
|
}, {
|
|
6358
|
-
F:
|
|
6432
|
+
F: __dxlog_file15,
|
|
6359
6433
|
L: 164,
|
|
6360
6434
|
S: void 0,
|
|
6361
6435
|
C: (f, a) => f(...a)
|
|
@@ -6363,10 +6437,10 @@ var editor = () => [
|
|
|
6363
6437
|
}
|
|
6364
6438
|
});
|
|
6365
6439
|
if (changes.length > 0) {
|
|
6366
|
-
|
|
6440
|
+
log10("modified,", {
|
|
6367
6441
|
changes
|
|
6368
6442
|
}, {
|
|
6369
|
-
F:
|
|
6443
|
+
F: __dxlog_file15,
|
|
6370
6444
|
L: 175,
|
|
6371
6445
|
S: void 0,
|
|
6372
6446
|
C: (f, a) => f(...a)
|
|
@@ -6377,8 +6451,8 @@ var editor = () => [
|
|
|
6377
6451
|
}
|
|
6378
6452
|
];
|
|
6379
6453
|
} else if (cancel) {
|
|
6380
|
-
|
|
6381
|
-
F:
|
|
6454
|
+
log10("cancel", void 0, {
|
|
6455
|
+
F: __dxlog_file15,
|
|
6382
6456
|
L: 178,
|
|
6383
6457
|
S: void 0,
|
|
6384
6458
|
C: (f, a) => f(...a)
|
|
@@ -6391,7 +6465,7 @@ var editor = () => [
|
|
|
6391
6465
|
|
|
6392
6466
|
// src/extensions/outliner/menu.ts
|
|
6393
6467
|
import { EditorView as EditorView24, ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6394
|
-
import { addEventListener } from "@dxos/async";
|
|
6468
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6395
6469
|
var menu = (options = {}) => [
|
|
6396
6470
|
ViewPlugin16.fromClass(class {
|
|
6397
6471
|
view;
|
|
@@ -6413,7 +6487,7 @@ var menu = (options = {}) => [
|
|
|
6413
6487
|
}
|
|
6414
6488
|
container.appendChild(this.tag);
|
|
6415
6489
|
const handler = () => this.scheduleUpdate();
|
|
6416
|
-
this.cleanup =
|
|
6490
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6417
6491
|
this.scheduleUpdate();
|
|
6418
6492
|
}
|
|
6419
6493
|
destroy() {
|
|
@@ -6492,7 +6566,7 @@ var outliner = (_options = {}) => [
|
|
|
6492
6566
|
}),
|
|
6493
6567
|
// Researve space for menu.
|
|
6494
6568
|
EditorView25.contentAttributes.of({
|
|
6495
|
-
class: "
|
|
6569
|
+
class: "w-full !mr-[3rem]"
|
|
6496
6570
|
})
|
|
6497
6571
|
];
|
|
6498
6572
|
var decorations = () => [
|
|
@@ -6556,10 +6630,10 @@ var decorations = () => [
|
|
|
6556
6630
|
marginBottom: "2px"
|
|
6557
6631
|
},
|
|
6558
6632
|
".cm-list-item-focused": {
|
|
6559
|
-
borderColor: "var(--
|
|
6633
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6560
6634
|
},
|
|
6561
6635
|
"&:focus-within .cm-list-item-selected": {
|
|
6562
|
-
borderColor: "var(--
|
|
6636
|
+
borderColor: "var(--color-separator)"
|
|
6563
6637
|
}
|
|
6564
6638
|
}))
|
|
6565
6639
|
];
|
|
@@ -6631,13 +6705,13 @@ var getLinkRef = (state, node) => {
|
|
|
6631
6705
|
const mark = node.getChildren("LinkMark");
|
|
6632
6706
|
const urlNode = node.getChild("URL");
|
|
6633
6707
|
if (mark && urlNode) {
|
|
6634
|
-
const
|
|
6635
|
-
if (
|
|
6708
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6709
|
+
if (dxn.startsWith("dxn:")) {
|
|
6636
6710
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6637
6711
|
return {
|
|
6638
6712
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6639
6713
|
label,
|
|
6640
|
-
|
|
6714
|
+
dxn
|
|
6641
6715
|
};
|
|
6642
6716
|
}
|
|
6643
6717
|
}
|
|
@@ -6652,13 +6726,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6652
6726
|
// return false;
|
|
6653
6727
|
// }
|
|
6654
6728
|
eq(other) {
|
|
6655
|
-
return this._link.
|
|
6729
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6656
6730
|
}
|
|
6657
6731
|
toDOM(_view) {
|
|
6658
6732
|
const root = document.createElement("dx-anchor");
|
|
6659
6733
|
root.classList.add("dx-tag--anchor");
|
|
6660
6734
|
root.textContent = this._link.label;
|
|
6661
|
-
root.setAttribute("
|
|
6735
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6662
6736
|
return root;
|
|
6663
6737
|
}
|
|
6664
6738
|
};
|
|
@@ -6672,11 +6746,11 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6672
6746
|
// return true;
|
|
6673
6747
|
// }
|
|
6674
6748
|
eq(other) {
|
|
6675
|
-
return this._link.
|
|
6749
|
+
return this._link.dxn === other._link.dxn;
|
|
6676
6750
|
}
|
|
6677
6751
|
toDOM(_view) {
|
|
6678
6752
|
const root = document.createElement("div");
|
|
6679
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6753
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6680
6754
|
this._options.addBlockContainer?.({
|
|
6681
6755
|
link: this._link,
|
|
6682
6756
|
el: root
|
|
@@ -6891,7 +6965,7 @@ var mixedParser = (registry) => {
|
|
|
6891
6965
|
};
|
|
6892
6966
|
|
|
6893
6967
|
// src/extensions/tags/streamer.ts
|
|
6894
|
-
import { StateEffect as
|
|
6968
|
+
import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
|
|
6895
6969
|
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6896
6970
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6897
6971
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
@@ -6903,7 +6977,7 @@ var streamer = (options = {}) => {
|
|
|
6903
6977
|
].filter(isTruthy4);
|
|
6904
6978
|
};
|
|
6905
6979
|
var cursor = () => {
|
|
6906
|
-
const hideCursor =
|
|
6980
|
+
const hideCursor = StateEffect8.define();
|
|
6907
6981
|
const showCursor = StateField12.define({
|
|
6908
6982
|
create: () => true,
|
|
6909
6983
|
update: (value, tr) => {
|
|
@@ -6973,9 +7047,9 @@ var CursorWidget = class extends WidgetType9 {
|
|
|
6973
7047
|
};
|
|
6974
7048
|
var fadeIn = (options = {}) => {
|
|
6975
7049
|
const FADE_IN_DURATION = 1e3;
|
|
6976
|
-
const DEFAULT_REMOVAL_DELAY =
|
|
7050
|
+
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
6977
7051
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6978
|
-
const removeDecoration =
|
|
7052
|
+
const removeDecoration = StateEffect8.define();
|
|
6979
7053
|
const fadeField = StateField12.define({
|
|
6980
7054
|
create: () => Decoration14.none,
|
|
6981
7055
|
update: (decorations2, tr) => {
|
|
@@ -7085,17 +7159,17 @@ var fadeIn = (options = {}) => {
|
|
|
7085
7159
|
|
|
7086
7160
|
// src/extensions/tags/xml-tags.ts
|
|
7087
7161
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7088
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7162
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
|
|
7089
7163
|
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin19, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7090
7164
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7091
|
-
import { log as
|
|
7165
|
+
import { log as log11 } from "@dxos/log";
|
|
7092
7166
|
|
|
7093
7167
|
// src/extensions/tags/xml-util.ts
|
|
7094
7168
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7095
|
-
var
|
|
7169
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7096
7170
|
var nodeToJson = (state, node) => {
|
|
7097
7171
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7098
|
-
F:
|
|
7172
|
+
F: __dxlog_file16,
|
|
7099
7173
|
L: 18,
|
|
7100
7174
|
S: void 0,
|
|
7101
7175
|
A: [
|
|
@@ -7159,16 +7233,16 @@ var nodeToJson = (state, node) => {
|
|
|
7159
7233
|
};
|
|
7160
7234
|
|
|
7161
7235
|
// src/extensions/tags/xml-tags.ts
|
|
7162
|
-
var
|
|
7163
|
-
var navigatePreviousEffect =
|
|
7164
|
-
var navigateNextEffect =
|
|
7236
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7237
|
+
var navigatePreviousEffect = StateEffect9.define();
|
|
7238
|
+
var navigateNextEffect = StateEffect9.define();
|
|
7165
7239
|
var getXmlTextChild = (children) => {
|
|
7166
7240
|
const child = children?.[0];
|
|
7167
7241
|
return typeof child === "string" ? child : null;
|
|
7168
7242
|
};
|
|
7169
|
-
var xmlTagContextEffect =
|
|
7170
|
-
var xmlTagResetEffect =
|
|
7171
|
-
var xmlTagUpdateEffect =
|
|
7243
|
+
var xmlTagContextEffect = StateEffect9.define();
|
|
7244
|
+
var xmlTagResetEffect = StateEffect9.define();
|
|
7245
|
+
var xmlTagUpdateEffect = StateEffect9.define();
|
|
7172
7246
|
var widgetContextStateField = StateField13.define({
|
|
7173
7247
|
create: () => void 0,
|
|
7174
7248
|
update: (value, tr) => {
|
|
@@ -7189,11 +7263,11 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7189
7263
|
}
|
|
7190
7264
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7191
7265
|
const { id, value } = effect.value;
|
|
7192
|
-
|
|
7266
|
+
log11("widget updated", {
|
|
7193
7267
|
id,
|
|
7194
7268
|
value
|
|
7195
7269
|
}, {
|
|
7196
|
-
F:
|
|
7270
|
+
F: __dxlog_file17,
|
|
7197
7271
|
L: 153,
|
|
7198
7272
|
S: void 0,
|
|
7199
7273
|
C: (f, a) => f(...a)
|
|
@@ -7224,11 +7298,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7224
7298
|
const widgets = /* @__PURE__ */ new Map();
|
|
7225
7299
|
const notifier = {
|
|
7226
7300
|
mounted: (state) => {
|
|
7227
|
-
|
|
7301
|
+
log11("widget mounted", {
|
|
7228
7302
|
id: state.id,
|
|
7229
7303
|
tag: state.props._tag
|
|
7230
7304
|
}, {
|
|
7231
|
-
F:
|
|
7305
|
+
F: __dxlog_file17,
|
|
7232
7306
|
L: 206,
|
|
7233
7307
|
S: void 0,
|
|
7234
7308
|
C: (f, a) => f(...a)
|
|
@@ -7240,11 +7314,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7240
7314
|
},
|
|
7241
7315
|
unmounted: (id) => {
|
|
7242
7316
|
const state = widgets.get(id);
|
|
7243
|
-
|
|
7317
|
+
log11("widget unmounted", {
|
|
7244
7318
|
id,
|
|
7245
7319
|
tag: state?.props._tag
|
|
7246
7320
|
}, {
|
|
7247
|
-
F:
|
|
7321
|
+
F: __dxlog_file17,
|
|
7248
7322
|
L: 212,
|
|
7249
7323
|
S: void 0,
|
|
7250
7324
|
C: (f, a) => f(...a)
|
|
@@ -7306,11 +7380,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7306
7380
|
anchor: line.from,
|
|
7307
7381
|
head: line.from
|
|
7308
7382
|
},
|
|
7309
|
-
effects:
|
|
7310
|
-
line: line.number,
|
|
7311
|
-
|
|
7312
|
-
offset: -16
|
|
7313
|
-
}
|
|
7383
|
+
effects: scrollerLineEffect.of({
|
|
7384
|
+
line: line.number - 1,
|
|
7385
|
+
offset: -16
|
|
7314
7386
|
})
|
|
7315
7387
|
});
|
|
7316
7388
|
continue;
|
|
@@ -7341,11 +7413,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7341
7413
|
anchor: line.to,
|
|
7342
7414
|
head: line.to
|
|
7343
7415
|
},
|
|
7344
|
-
effects:
|
|
7345
|
-
line: line.number,
|
|
7346
|
-
|
|
7347
|
-
offset: -16
|
|
7348
|
-
}
|
|
7416
|
+
effects: scrollerLineEffect.of({
|
|
7417
|
+
line: line.number - 1,
|
|
7418
|
+
offset: -16
|
|
7349
7419
|
})
|
|
7350
7420
|
});
|
|
7351
7421
|
} else {
|
|
@@ -7355,11 +7425,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7355
7425
|
anchor: line.to,
|
|
7356
7426
|
head: line.to
|
|
7357
7427
|
},
|
|
7358
|
-
effects:
|
|
7359
|
-
line: line.number,
|
|
7360
|
-
|
|
7361
|
-
position: "end"
|
|
7362
|
-
}
|
|
7428
|
+
effects: scrollerLineEffect.of({
|
|
7429
|
+
line: line.number - 1,
|
|
7430
|
+
position: "end"
|
|
7363
7431
|
})
|
|
7364
7432
|
});
|
|
7365
7433
|
}
|
|
@@ -7406,6 +7474,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7406
7474
|
update: ({ from, decorations: decorations2 }, tr) => {
|
|
7407
7475
|
for (const effect of tr.effects) {
|
|
7408
7476
|
if (effect.is(xmlTagResetEffect)) {
|
|
7477
|
+
if (tr.docChanged) {
|
|
7478
|
+
return buildDecorations4(tr.state, {
|
|
7479
|
+
from: 0,
|
|
7480
|
+
to: tr.state.doc.length
|
|
7481
|
+
}, registry, notifier);
|
|
7482
|
+
}
|
|
7409
7483
|
return {
|
|
7410
7484
|
from: 0,
|
|
7411
7485
|
decorations: Decoration15.none
|
|
@@ -7416,12 +7490,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7416
7490
|
const { state } = tr;
|
|
7417
7491
|
const reset = tr.changes.touchesRange(0, from);
|
|
7418
7492
|
if (reset) {
|
|
7419
|
-
|
|
7493
|
+
log11("document reset", {
|
|
7420
7494
|
from,
|
|
7421
7495
|
to: state.doc.length
|
|
7422
7496
|
}, {
|
|
7423
|
-
F:
|
|
7424
|
-
L:
|
|
7497
|
+
F: __dxlog_file17,
|
|
7498
|
+
L: 374,
|
|
7425
7499
|
S: void 0,
|
|
7426
7500
|
C: (f, a) => f(...a)
|
|
7427
7501
|
});
|
|
@@ -7502,9 +7576,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7502
7576
|
}
|
|
7503
7577
|
}
|
|
7504
7578
|
} catch (err) {
|
|
7505
|
-
|
|
7506
|
-
F:
|
|
7507
|
-
L:
|
|
7579
|
+
log11.catch(err, void 0, {
|
|
7580
|
+
F: __dxlog_file17,
|
|
7581
|
+
L: 459,
|
|
7508
7582
|
S: void 0,
|
|
7509
7583
|
C: (f, a) => f(...a)
|
|
7510
7584
|
});
|
|
@@ -7528,8 +7602,8 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7528
7602
|
constructor(id, Component, props, notifier) {
|
|
7529
7603
|
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier;
|
|
7530
7604
|
invariant7(id, void 0, {
|
|
7531
|
-
F:
|
|
7532
|
-
L:
|
|
7605
|
+
F: __dxlog_file17,
|
|
7606
|
+
L: 485,
|
|
7533
7607
|
S: this,
|
|
7534
7608
|
A: [
|
|
7535
7609
|
"id",
|
|
@@ -7658,6 +7732,7 @@ export {
|
|
|
7658
7732
|
convertTreeToJson,
|
|
7659
7733
|
createBasicExtensions,
|
|
7660
7734
|
createComment,
|
|
7735
|
+
createCrawler,
|
|
7661
7736
|
createDataExtensions,
|
|
7662
7737
|
createEditorStateStore,
|
|
7663
7738
|
createEditorStateTransaction,
|
|
@@ -7738,9 +7813,10 @@ export {
|
|
|
7738
7813
|
removeStyle,
|
|
7739
7814
|
replacer,
|
|
7740
7815
|
scrollThreadIntoView,
|
|
7741
|
-
scrollToBottomEffect,
|
|
7742
7816
|
scrollToLine,
|
|
7743
|
-
|
|
7817
|
+
scroller,
|
|
7818
|
+
scrollerCrawlEffect,
|
|
7819
|
+
scrollerLineEffect,
|
|
7744
7820
|
selectionState,
|
|
7745
7821
|
setBlockquote,
|
|
7746
7822
|
setComments,
|
|
@@ -7748,7 +7824,6 @@ export {
|
|
|
7748
7824
|
setSelection,
|
|
7749
7825
|
setStyle,
|
|
7750
7826
|
singleValueFacet,
|
|
7751
|
-
smoothScroll,
|
|
7752
7827
|
stackItemContentEditorClassNames,
|
|
7753
7828
|
staticCompletion,
|
|
7754
7829
|
streamer,
|