@dxos/ui-editor 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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 +491 -420
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +491 -420
- 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/extensions/tags/streamer.d.ts +1 -1
- 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 +3 -6
- 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 +233 -0
- package/src/extensions/selection.ts +1 -1
- package/src/extensions/tags/streamer.ts +2 -2
- 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,14 @@ 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
|
-
scroll: {
|
|
19
|
-
className: "pbs-2"
|
|
20
|
-
},
|
|
21
18
|
content: {
|
|
22
19
|
className: editorWidth
|
|
23
20
|
}
|
|
24
21
|
};
|
|
25
22
|
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
|
|
23
|
+
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
24
|
|
|
28
25
|
// src/extensions/annotations.ts
|
|
29
26
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -58,7 +55,7 @@ var annotations = ({ match } = {}) => {
|
|
|
58
55
|
".cm-annotation": {
|
|
59
56
|
textDecoration: "underline",
|
|
60
57
|
textDecorationStyle: "wavy",
|
|
61
|
-
textDecorationColor: "var(--
|
|
58
|
+
textDecorationColor: "var(--color-error-text)"
|
|
62
59
|
}
|
|
63
60
|
})
|
|
64
61
|
];
|
|
@@ -501,192 +498,209 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
501
498
|
];
|
|
502
499
|
};
|
|
503
500
|
|
|
504
|
-
// src/extensions/
|
|
505
|
-
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
501
|
+
// src/extensions/auto-scroll.ts
|
|
506
502
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
507
|
-
import {
|
|
503
|
+
import { addEventListener, combine, throttle } from "@dxos/async";
|
|
508
504
|
import { Domino } from "@dxos/ui";
|
|
509
505
|
|
|
510
|
-
// src/extensions/
|
|
506
|
+
// src/extensions/scroller.ts
|
|
511
507
|
import { StateEffect } from "@codemirror/state";
|
|
512
508
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
513
|
-
|
|
514
|
-
var
|
|
515
|
-
|
|
509
|
+
import { log as log2 } from "@dxos/log";
|
|
510
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
511
|
+
var scrollerLineEffect = StateEffect.define();
|
|
512
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
513
|
+
var scrollToLine = (view, options) => {
|
|
514
|
+
view.dispatch({
|
|
515
|
+
effects: scrollerLineEffect.of(options)
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
519
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
516
520
|
view;
|
|
521
|
+
crawler;
|
|
517
522
|
constructor(view) {
|
|
518
523
|
this.view = view;
|
|
524
|
+
this.crawler = createCrawler(this.view);
|
|
519
525
|
}
|
|
520
526
|
// No-op.
|
|
521
527
|
destroy() {
|
|
528
|
+
this.crawler.cancel();
|
|
522
529
|
}
|
|
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;
|
|
530
|
+
cancel() {
|
|
531
|
+
this.crawler.cancel();
|
|
532
|
+
}
|
|
533
|
+
crawl(start = false) {
|
|
534
|
+
if (start) {
|
|
535
|
+
this.crawler.scroll();
|
|
558
536
|
} else {
|
|
559
|
-
|
|
537
|
+
this.crawler.cancel();
|
|
560
538
|
}
|
|
561
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
562
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
563
539
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
540
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
541
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
542
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
543
|
+
const doc = this.view.state.doc;
|
|
544
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
545
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
546
|
+
const lineStart = doc.line(line + 1).from;
|
|
547
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
548
|
+
if (coords) {
|
|
549
|
+
const currentScrollTop = scrollTop;
|
|
550
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
551
|
+
if (position === "end") {
|
|
552
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
553
|
+
} else {
|
|
554
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
555
|
+
}
|
|
556
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
557
|
+
}
|
|
570
558
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
559
|
+
requestAnimationFrame(() => {
|
|
560
|
+
this.view.scrollDOM.scrollTo({
|
|
561
|
+
top: targetScrollTop
|
|
562
|
+
});
|
|
574
563
|
});
|
|
575
564
|
}
|
|
576
565
|
});
|
|
577
566
|
return [
|
|
578
567
|
scrollPlugin,
|
|
579
|
-
//
|
|
568
|
+
// Listen for effect.s
|
|
580
569
|
EditorView4.updateListener.of((update2) => {
|
|
581
570
|
update2.transactions.forEach((transaction) => {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
});
|
|
571
|
+
try {
|
|
572
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
573
|
+
if (plugin) {
|
|
574
|
+
for (const effect of transaction.effects) {
|
|
575
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
576
|
+
plugin.crawl(effect.value);
|
|
577
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
578
|
+
plugin.scroll(effect.value);
|
|
579
|
+
}
|
|
592
580
|
}
|
|
593
581
|
}
|
|
582
|
+
} catch (err) {
|
|
583
|
+
log2.catch(err, void 0, {
|
|
584
|
+
F: __dxlog_file2,
|
|
585
|
+
L: 146,
|
|
586
|
+
S: void 0,
|
|
587
|
+
C: (f, a) => f(...a)
|
|
588
|
+
});
|
|
594
589
|
}
|
|
595
590
|
});
|
|
591
|
+
}),
|
|
592
|
+
// Styles.
|
|
593
|
+
EditorView4.theme({
|
|
594
|
+
".cm-content": {
|
|
595
|
+
paddingBottom: `${overScroll}px`
|
|
596
|
+
},
|
|
597
|
+
".cm-scroller": {
|
|
598
|
+
overflowAnchor: "none",
|
|
599
|
+
paddingBottom: "0"
|
|
600
|
+
},
|
|
601
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
602
|
+
display: "none"
|
|
603
|
+
},
|
|
604
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
605
|
+
background: "transparent",
|
|
606
|
+
transition: "background 0.15s"
|
|
607
|
+
},
|
|
608
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
609
|
+
background: "var(--color-scrollbar-thumb)"
|
|
610
|
+
},
|
|
611
|
+
".cm-scroll-button": {
|
|
612
|
+
position: "absolute",
|
|
613
|
+
bottom: "0.5rem",
|
|
614
|
+
right: "1rem"
|
|
615
|
+
}
|
|
596
616
|
})
|
|
597
617
|
];
|
|
598
618
|
};
|
|
599
|
-
|
|
600
|
-
view.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
619
|
+
function createCrawler(view, k = 0.3, maxStep = 2, targetDelta = 0.5) {
|
|
620
|
+
const el = view.scrollDOM;
|
|
621
|
+
let currentTop = 0;
|
|
622
|
+
let rafId = null;
|
|
623
|
+
function frame() {
|
|
624
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
625
|
+
const delta = targetTop - currentTop;
|
|
626
|
+
const absDelta = Math.abs(delta);
|
|
627
|
+
if (absDelta < targetDelta) {
|
|
628
|
+
el.scrollTop = targetTop;
|
|
629
|
+
currentTop = targetTop;
|
|
630
|
+
rafId = null;
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
const step = Math.sign(delta) * Math.min(absDelta, Math.max(1, Math.min(absDelta * k, maxStep)));
|
|
634
|
+
currentTop += step;
|
|
635
|
+
el.scrollTop = currentTop;
|
|
636
|
+
rafId = requestAnimationFrame(frame);
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
scroll: () => {
|
|
640
|
+
if (rafId === null) {
|
|
641
|
+
currentTop = el.scrollTop;
|
|
642
|
+
rafId = requestAnimationFrame(frame);
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
cancel: () => {
|
|
646
|
+
if (rafId !== null) {
|
|
647
|
+
cancelAnimationFrame(rafId);
|
|
648
|
+
rafId = null;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
607
653
|
|
|
608
|
-
// src/extensions/
|
|
609
|
-
var
|
|
610
|
-
var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDelay = 1e3, onAutoScroll } = {}) => {
|
|
654
|
+
// src/extensions/auto-scroll.ts
|
|
655
|
+
var autoScroll = (_ = {}) => {
|
|
611
656
|
let buttonContainer;
|
|
612
|
-
let hideTimeout;
|
|
613
|
-
let lastScrollTop = 0;
|
|
614
657
|
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);
|
|
658
|
+
const setPinned = (pinned) => {
|
|
659
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
660
|
+
isPinned = pinned;
|
|
625
661
|
};
|
|
626
|
-
const scrollToBottom = (view, behavior) => {
|
|
627
|
-
setPinned(true);
|
|
628
|
-
hideScrollbar(view);
|
|
629
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
630
|
-
view.dispatch({
|
|
631
|
-
selection: {
|
|
632
|
-
anchor: line.to,
|
|
633
|
-
head: line.to
|
|
634
|
-
},
|
|
635
|
-
effects: scrollToLineEffect.of({
|
|
636
|
-
line: line.number,
|
|
637
|
-
options: {
|
|
638
|
-
position: "end",
|
|
639
|
-
offset: threshold,
|
|
640
|
-
behavior
|
|
641
|
-
}
|
|
642
|
-
})
|
|
643
|
-
});
|
|
644
|
-
};
|
|
645
|
-
const checkDistance = debounce((view) => {
|
|
646
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
647
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
648
|
-
const distanceFromBottom = coords ? coords.bottom - scrollerRect.bottom : 0;
|
|
649
|
-
setPinned(distanceFromBottom < 0);
|
|
650
|
-
}, 1e3);
|
|
651
|
-
const triggerUpdate = debounce((view) => scrollToBottom(view), throttleDelay);
|
|
652
662
|
return [
|
|
653
663
|
// Update listener for logging when scrolling is needed.
|
|
654
|
-
EditorView5.updateListener.of(({ view,
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
664
|
+
EditorView5.updateListener.of(({ view, heightChanged, state }) => {
|
|
665
|
+
if (heightChanged) {
|
|
666
|
+
if (isPinned) {
|
|
667
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
668
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
669
|
+
if (delta > 0 && scrollTop > 0) {
|
|
670
|
+
setPinned(true);
|
|
671
|
+
view.dispatch({
|
|
672
|
+
effects: scrollerCrawlEffect.of(true)
|
|
673
|
+
});
|
|
674
|
+
} else if (delta < 0) {
|
|
675
|
+
setPinned(false);
|
|
659
676
|
}
|
|
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);
|
|
677
|
+
} else {
|
|
678
|
+
if (state.doc.length === 0) {
|
|
679
|
+
setPinned(true);
|
|
673
680
|
}
|
|
674
|
-
} else if (distanceFromBottom < 0) {
|
|
675
|
-
setPinned(false);
|
|
676
681
|
}
|
|
677
682
|
}
|
|
678
683
|
}),
|
|
679
|
-
// Detect user scroll.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
684
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
685
|
+
ViewPlugin6.fromClass(class {
|
|
686
|
+
cleanup;
|
|
687
|
+
constructor(view) {
|
|
688
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
689
|
+
requestAnimationFrame(() => {
|
|
690
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
691
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
692
|
+
const pinned = delta === 0;
|
|
693
|
+
setPinned(pinned);
|
|
694
|
+
if (!pinned) {
|
|
695
|
+
view.dispatch({
|
|
696
|
+
effects: scrollerCrawlEffect.of(false)
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}, 500));
|
|
701
|
+
}
|
|
702
|
+
destroy() {
|
|
703
|
+
this.cleanup();
|
|
690
704
|
}
|
|
691
705
|
}),
|
|
692
706
|
// Scroll button.
|
|
@@ -695,34 +709,33 @@ var autoScroll = ({ autoScroll: autoScroll2 = true, threshold = 100, throttleDel
|
|
|
695
709
|
const icon = Domino.of("dx-icon").attributes({
|
|
696
710
|
icon: "ph--arrow-down--regular"
|
|
697
711
|
});
|
|
698
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
712
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
699
713
|
"data-density": "fine"
|
|
700
714
|
}).children(icon).on("click", () => {
|
|
701
|
-
|
|
715
|
+
setPinned(true);
|
|
716
|
+
view.dispatch({
|
|
717
|
+
effects: scrollerLineEffect.of({
|
|
718
|
+
line: -1,
|
|
719
|
+
position: "end",
|
|
720
|
+
behavior: "smooth"
|
|
721
|
+
})
|
|
722
|
+
});
|
|
702
723
|
});
|
|
703
724
|
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").children(button).root;
|
|
704
725
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
705
726
|
}
|
|
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
727
|
})
|
|
724
728
|
];
|
|
725
729
|
};
|
|
730
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
731
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
732
|
+
passive: true
|
|
733
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
734
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
735
|
+
onUserScroll();
|
|
736
|
+
}
|
|
737
|
+
}));
|
|
738
|
+
}
|
|
726
739
|
|
|
727
740
|
// src/extensions/automerge/automerge.ts
|
|
728
741
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -736,15 +749,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
736
749
|
|
|
737
750
|
// src/extensions/automerge/cursor.ts
|
|
738
751
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
739
|
-
import { log as
|
|
740
|
-
var
|
|
752
|
+
import { log as log3 } from "@dxos/log";
|
|
753
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
741
754
|
var cursorConverter = (accessor) => ({
|
|
742
755
|
toCursor: (pos, assoc) => {
|
|
743
756
|
try {
|
|
744
757
|
return toCursor(accessor, pos, assoc);
|
|
745
758
|
} catch (err) {
|
|
746
|
-
|
|
747
|
-
F:
|
|
759
|
+
log3.catch(err, void 0, {
|
|
760
|
+
F: __dxlog_file3,
|
|
748
761
|
L: 15,
|
|
749
762
|
S: void 0,
|
|
750
763
|
C: (f, a) => f(...a)
|
|
@@ -756,8 +769,8 @@ var cursorConverter = (accessor) => ({
|
|
|
756
769
|
try {
|
|
757
770
|
return fromCursor(accessor, cursor2);
|
|
758
771
|
} catch (err) {
|
|
759
|
-
|
|
760
|
-
F:
|
|
772
|
+
log3.catch(err, void 0, {
|
|
773
|
+
F: __dxlog_file3,
|
|
761
774
|
L: 24,
|
|
762
775
|
S: void 0,
|
|
763
776
|
C: (f, a) => f(...a)
|
|
@@ -768,10 +781,10 @@ var cursorConverter = (accessor) => ({
|
|
|
768
781
|
});
|
|
769
782
|
|
|
770
783
|
// src/extensions/automerge/defs.ts
|
|
771
|
-
import { Annotation, StateEffect as
|
|
784
|
+
import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
|
|
772
785
|
var getPath = (state, field) => state.field(field).path;
|
|
773
786
|
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
774
|
-
var updateHeadsEffect =
|
|
787
|
+
var updateHeadsEffect = StateEffect2.define({});
|
|
775
788
|
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
|
776
789
|
newHeads
|
|
777
790
|
});
|
|
@@ -782,7 +795,7 @@ var isReconcile = (tr) => {
|
|
|
782
795
|
|
|
783
796
|
// src/extensions/automerge/sync.ts
|
|
784
797
|
import { next as A2 } from "@automerge/automerge";
|
|
785
|
-
import { log as
|
|
798
|
+
import { log as log4 } from "@dxos/log";
|
|
786
799
|
|
|
787
800
|
// src/extensions/automerge/update-automerge.ts
|
|
788
801
|
import { next as A } from "@automerge/automerge";
|
|
@@ -923,7 +936,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
923
936
|
};
|
|
924
937
|
|
|
925
938
|
// src/extensions/automerge/sync.ts
|
|
926
|
-
var
|
|
939
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
927
940
|
var Syncer = class {
|
|
928
941
|
_handle;
|
|
929
942
|
_state;
|
|
@@ -946,8 +959,8 @@ var Syncer = class {
|
|
|
946
959
|
this._pending = false;
|
|
947
960
|
}
|
|
948
961
|
onEditorChange(view) {
|
|
949
|
-
|
|
950
|
-
F:
|
|
962
|
+
log4("onEditorChange", void 0, {
|
|
963
|
+
F: __dxlog_file4,
|
|
951
964
|
L: 45,
|
|
952
965
|
S: this,
|
|
953
966
|
C: (f, a) => f(...a)
|
|
@@ -962,8 +975,8 @@ var Syncer = class {
|
|
|
962
975
|
}
|
|
963
976
|
}
|
|
964
977
|
onAutomergeChange(view) {
|
|
965
|
-
|
|
966
|
-
F:
|
|
978
|
+
log4("onAutomergeChange", void 0, {
|
|
979
|
+
F: __dxlog_file4,
|
|
967
980
|
L: 60,
|
|
968
981
|
S: this,
|
|
969
982
|
C: (f, a) => f(...a)
|
|
@@ -1029,6 +1042,15 @@ var automerge = (accessor) => {
|
|
|
1029
1042
|
const value = DocAccessor.getValue(accessor);
|
|
1030
1043
|
const current = this._view.state.doc.toString();
|
|
1031
1044
|
if (value !== current) {
|
|
1045
|
+
console.warn("ENABLING INITIAL SYNC -- THIS MAY BE A REGRESSION");
|
|
1046
|
+
this._view.dispatch({
|
|
1047
|
+
changes: {
|
|
1048
|
+
from: 0,
|
|
1049
|
+
to: this._view.state.doc.length,
|
|
1050
|
+
insert: value
|
|
1051
|
+
},
|
|
1052
|
+
annotations: initialSync
|
|
1053
|
+
});
|
|
1032
1054
|
}
|
|
1033
1055
|
});
|
|
1034
1056
|
}
|
|
@@ -1056,7 +1078,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1056
1078
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1057
1079
|
import { Event } from "@dxos/async";
|
|
1058
1080
|
import { Context } from "@dxos/context";
|
|
1059
|
-
var
|
|
1081
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1060
1082
|
var dummyProvider = {
|
|
1061
1083
|
remoteStateChange: new Event(),
|
|
1062
1084
|
open: () => {
|
|
@@ -1080,7 +1102,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1080
1102
|
};
|
|
1081
1103
|
var RemoteSelectionsDecorator = class {
|
|
1082
1104
|
_ctx = new Context(void 0, {
|
|
1083
|
-
F:
|
|
1105
|
+
F: __dxlog_file5,
|
|
1084
1106
|
L: 80
|
|
1085
1107
|
});
|
|
1086
1108
|
_cursorConverter;
|
|
@@ -1293,8 +1315,8 @@ var styles = EditorView7.theme({
|
|
|
1293
1315
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1294
1316
|
import { Context as Context2 } from "@dxos/context";
|
|
1295
1317
|
import { invariant } from "@dxos/invariant";
|
|
1296
|
-
import { log as
|
|
1297
|
-
var
|
|
1318
|
+
import { log as log5 } from "@dxos/log";
|
|
1319
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1298
1320
|
var DEBOUNCE_INTERVAL = 100;
|
|
1299
1321
|
var SpaceAwarenessProvider = class {
|
|
1300
1322
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1314,7 +1336,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1314
1336
|
}
|
|
1315
1337
|
open() {
|
|
1316
1338
|
this._ctx = new Context2(void 0, {
|
|
1317
|
-
F:
|
|
1339
|
+
F: __dxlog_file6,
|
|
1318
1340
|
L: 57
|
|
1319
1341
|
});
|
|
1320
1342
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1341,10 +1363,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1341
1363
|
void this._messenger.postMessage(this._channel, {
|
|
1342
1364
|
kind: "query"
|
|
1343
1365
|
}).catch((err) => {
|
|
1344
|
-
|
|
1366
|
+
log5.debug("failed to query awareness", {
|
|
1345
1367
|
err
|
|
1346
1368
|
}, {
|
|
1347
|
-
F:
|
|
1369
|
+
F: __dxlog_file6,
|
|
1348
1370
|
L: 91,
|
|
1349
1371
|
S: this,
|
|
1350
1372
|
C: (f, a) => f(...a)
|
|
@@ -1361,7 +1383,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1361
1383
|
}
|
|
1362
1384
|
update(position) {
|
|
1363
1385
|
invariant(this._postTask, void 0, {
|
|
1364
|
-
F:
|
|
1386
|
+
F: __dxlog_file6,
|
|
1365
1387
|
L: 106,
|
|
1366
1388
|
S: this,
|
|
1367
1389
|
A: [
|
|
@@ -1378,7 +1400,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1378
1400
|
}
|
|
1379
1401
|
_handleQueryMessage() {
|
|
1380
1402
|
invariant(this._postTask, void 0, {
|
|
1381
|
-
F:
|
|
1403
|
+
F: __dxlog_file6,
|
|
1382
1404
|
L: 117,
|
|
1383
1405
|
S: this,
|
|
1384
1406
|
A: [
|
|
@@ -1390,7 +1412,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1390
1412
|
}
|
|
1391
1413
|
_handlePostMessage(message) {
|
|
1392
1414
|
invariant(message.kind === "post", void 0, {
|
|
1393
|
-
F:
|
|
1415
|
+
F: __dxlog_file6,
|
|
1394
1416
|
L: 122,
|
|
1395
1417
|
S: this,
|
|
1396
1418
|
A: [
|
|
@@ -1406,9 +1428,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1406
1428
|
// src/extensions/blast.ts
|
|
1407
1429
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1408
1430
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1409
|
-
import { throttle } from "@dxos/async";
|
|
1431
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1410
1432
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1411
|
-
var
|
|
1433
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1412
1434
|
var defaultOptions = {
|
|
1413
1435
|
effect: 2,
|
|
1414
1436
|
maxParticles: 200,
|
|
@@ -1527,7 +1549,7 @@ var Blaster = class {
|
|
|
1527
1549
|
}
|
|
1528
1550
|
initialize() {
|
|
1529
1551
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1530
|
-
F:
|
|
1552
|
+
F: __dxlog_file7,
|
|
1531
1553
|
L: 142,
|
|
1532
1554
|
S: this,
|
|
1533
1555
|
A: [
|
|
@@ -1564,7 +1586,7 @@ var Blaster = class {
|
|
|
1564
1586
|
}
|
|
1565
1587
|
start() {
|
|
1566
1588
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1567
|
-
F:
|
|
1589
|
+
F: __dxlog_file7,
|
|
1568
1590
|
L: 181,
|
|
1569
1591
|
S: this,
|
|
1570
1592
|
A: [
|
|
@@ -1598,11 +1620,11 @@ var Blaster = class {
|
|
|
1598
1620
|
this.drawParticles();
|
|
1599
1621
|
requestAnimationFrame(this.loop.bind(this));
|
|
1600
1622
|
}
|
|
1601
|
-
shake =
|
|
1623
|
+
shake = throttle2(({ time }) => {
|
|
1602
1624
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1603
1625
|
this._shakeTimeMax = time;
|
|
1604
1626
|
}, 100);
|
|
1605
|
-
spawn =
|
|
1627
|
+
spawn = throttle2(({ element, point }) => {
|
|
1606
1628
|
const color = getRGBComponents(element, this._options.color);
|
|
1607
1629
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1608
1630
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1776,11 +1798,11 @@ var blocks = () => [
|
|
|
1776
1798
|
".cm-line.block-line": {
|
|
1777
1799
|
paddingLeft: "0.75rem",
|
|
1778
1800
|
paddingRight: "0.75rem",
|
|
1779
|
-
borderLeft: "1px solid var(--
|
|
1780
|
-
borderRight: "1px solid var(--
|
|
1801
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1802
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1781
1803
|
},
|
|
1782
1804
|
".cm-line.block-single": {
|
|
1783
|
-
border: "1px solid var(--
|
|
1805
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1784
1806
|
borderRadius: "6px",
|
|
1785
1807
|
paddingTop: "0.5rem",
|
|
1786
1808
|
paddingBottom: "0.5rem",
|
|
@@ -1788,7 +1810,7 @@ var blocks = () => [
|
|
|
1788
1810
|
marginBottom: "0.5rem"
|
|
1789
1811
|
},
|
|
1790
1812
|
".cm-line.block-first": {
|
|
1791
|
-
borderTop: "1px solid var(--
|
|
1813
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1792
1814
|
borderTopLeftRadius: "6px",
|
|
1793
1815
|
borderTopRightRadius: "6px",
|
|
1794
1816
|
paddingTop: "0.5rem",
|
|
@@ -1796,7 +1818,7 @@ var blocks = () => [
|
|
|
1796
1818
|
},
|
|
1797
1819
|
".cm-line.block-middle": {},
|
|
1798
1820
|
".cm-line.block-last": {
|
|
1799
|
-
borderBottom: "1px solid var(--
|
|
1821
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1800
1822
|
borderBottomLeftRadius: "6px",
|
|
1801
1823
|
borderBottomRightRadius: "6px",
|
|
1802
1824
|
paddingBottom: "0.5rem",
|
|
@@ -1806,13 +1828,13 @@ var blocks = () => [
|
|
|
1806
1828
|
];
|
|
1807
1829
|
|
|
1808
1830
|
// src/extensions/bookmarks.ts
|
|
1809
|
-
import { Prec as Prec3, StateEffect as
|
|
1831
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1810
1832
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1811
|
-
import { log as
|
|
1812
|
-
var
|
|
1813
|
-
var addBookmark =
|
|
1814
|
-
var removeBookmark =
|
|
1815
|
-
var clearBookmarks =
|
|
1833
|
+
import { log as log6 } from "@dxos/log";
|
|
1834
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1835
|
+
var addBookmark = StateEffect3.define();
|
|
1836
|
+
var removeBookmark = StateEffect3.define();
|
|
1837
|
+
var clearBookmarks = StateEffect3.define();
|
|
1816
1838
|
var bookmarks = () => {
|
|
1817
1839
|
return [
|
|
1818
1840
|
bookmarksField,
|
|
@@ -1821,8 +1843,8 @@ var bookmarks = () => {
|
|
|
1821
1843
|
key: "Mod-ArrowUp",
|
|
1822
1844
|
run: (view) => {
|
|
1823
1845
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1824
|
-
|
|
1825
|
-
F:
|
|
1846
|
+
log6("up", bookmarks2, {
|
|
1847
|
+
F: __dxlog_file8,
|
|
1826
1848
|
L: 29,
|
|
1827
1849
|
S: void 0,
|
|
1828
1850
|
C: (f, a) => f(...a)
|
|
@@ -1834,8 +1856,8 @@ var bookmarks = () => {
|
|
|
1834
1856
|
key: "Mod-ArrowDown",
|
|
1835
1857
|
run: (view) => {
|
|
1836
1858
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1837
|
-
|
|
1838
|
-
F:
|
|
1859
|
+
log6("down", bookmarks2, {
|
|
1860
|
+
F: __dxlog_file8,
|
|
1839
1861
|
L: 37,
|
|
1840
1862
|
S: void 0,
|
|
1841
1863
|
C: (f, a) => f(...a)
|
|
@@ -1876,22 +1898,22 @@ var bookmarksField = StateField2.define({
|
|
|
1876
1898
|
|
|
1877
1899
|
// src/extensions/comments.ts
|
|
1878
1900
|
import { invertedEffects } from "@codemirror/commands";
|
|
1879
|
-
import { StateEffect as
|
|
1901
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1880
1902
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1881
1903
|
import sortBy from "lodash.sortby";
|
|
1882
|
-
import { debounce as
|
|
1883
|
-
import { log as
|
|
1904
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1905
|
+
import { log as log7 } from "@dxos/log";
|
|
1884
1906
|
import { isNonNullable } from "@dxos/util";
|
|
1885
1907
|
|
|
1886
1908
|
// src/extensions/selection.ts
|
|
1887
1909
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1888
1910
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1889
|
-
import { debounce
|
|
1911
|
+
import { debounce } from "@dxos/async";
|
|
1890
1912
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1891
1913
|
import { isTruthy } from "@dxos/util";
|
|
1892
|
-
var
|
|
1914
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1893
1915
|
var documentId = singleValueFacet();
|
|
1894
|
-
var stateRestoreAnnotation = "dxos.
|
|
1916
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1895
1917
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1896
1918
|
return {
|
|
1897
1919
|
selection,
|
|
@@ -1905,7 +1927,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1905
1927
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1906
1928
|
getState: (id) => {
|
|
1907
1929
|
invariant3(id, void 0, {
|
|
1908
|
-
F:
|
|
1930
|
+
F: __dxlog_file9,
|
|
1909
1931
|
L: 47,
|
|
1910
1932
|
S: void 0,
|
|
1911
1933
|
A: [
|
|
@@ -1918,7 +1940,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1918
1940
|
},
|
|
1919
1941
|
setState: (id, state) => {
|
|
1920
1942
|
invariant3(id, void 0, {
|
|
1921
|
-
F:
|
|
1943
|
+
F: __dxlog_file9,
|
|
1922
1944
|
L: 53,
|
|
1923
1945
|
S: void 0,
|
|
1924
1946
|
A: [
|
|
@@ -1930,7 +1952,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1930
1952
|
}
|
|
1931
1953
|
});
|
|
1932
1954
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1933
|
-
const setStateDebounced =
|
|
1955
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1934
1956
|
return [
|
|
1935
1957
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1936
1958
|
// EditorView.domEventHandlers({
|
|
@@ -1977,10 +1999,10 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1977
1999
|
};
|
|
1978
2000
|
|
|
1979
2001
|
// src/extensions/comments.ts
|
|
1980
|
-
var
|
|
1981
|
-
var setComments =
|
|
1982
|
-
var setSelection =
|
|
1983
|
-
var setCommentState =
|
|
2002
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
2003
|
+
var setComments = StateEffect4.define();
|
|
2004
|
+
var setSelection = StateEffect4.define();
|
|
2005
|
+
var setCommentState = StateEffect4.define();
|
|
1984
2006
|
var commentsState = StateField3.define({
|
|
1985
2007
|
create: (state) => ({
|
|
1986
2008
|
id: state.facet(documentId),
|
|
@@ -2022,14 +2044,14 @@ var commentsState = StateField3.define({
|
|
|
2022
2044
|
var styles2 = EditorView11.theme({
|
|
2023
2045
|
".cm-comment, .cm-comment-current": {
|
|
2024
2046
|
padding: "3px 0",
|
|
2025
|
-
color: "var(--
|
|
2026
|
-
backgroundColor: "var(--
|
|
2047
|
+
color: "var(--color-cm-comment-text)",
|
|
2048
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2027
2049
|
},
|
|
2028
2050
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2029
2051
|
boxDecorationBreak: "clone",
|
|
2030
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2031
|
-
backgroundColor: "var(--
|
|
2032
|
-
color: "var(--
|
|
2052
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2053
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2054
|
+
color: "var(--color-cm-comment-text)",
|
|
2033
2055
|
cursor: "pointer"
|
|
2034
2056
|
}
|
|
2035
2057
|
});
|
|
@@ -2047,8 +2069,8 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2047
2069
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2048
2070
|
const range = comment.range;
|
|
2049
2071
|
if (!range) {
|
|
2050
|
-
|
|
2051
|
-
F:
|
|
2072
|
+
log7.warn("Invalid range:", range, {
|
|
2073
|
+
F: __dxlog_file10,
|
|
2052
2074
|
L: 140,
|
|
2053
2075
|
S: void 0,
|
|
2054
2076
|
C: (f, a) => f(...a)
|
|
@@ -2062,7 +2084,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2062
2084
|
}).filter(isNonNullable);
|
|
2063
2085
|
return Decoration7.set(decorations2);
|
|
2064
2086
|
});
|
|
2065
|
-
var commentClickedEffect =
|
|
2087
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2066
2088
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2067
2089
|
click: (event, view) => {
|
|
2068
2090
|
let target = event.target;
|
|
@@ -2180,7 +2202,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2180
2202
|
from: changes.mapPos(comment.from, 1),
|
|
2181
2203
|
to: changes.mapPos(comment.to, 1)
|
|
2182
2204
|
});
|
|
2183
|
-
var restoreCommentEffect =
|
|
2205
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2184
2206
|
map: mapTrackedComment
|
|
2185
2207
|
});
|
|
2186
2208
|
var createComment = (view) => {
|
|
@@ -2214,7 +2236,7 @@ var createComment = (view) => {
|
|
|
2214
2236
|
var optionsFacet = singleValueFacet();
|
|
2215
2237
|
var comments = (options = {}) => {
|
|
2216
2238
|
const { key: shortcut = "meta-'" } = options;
|
|
2217
|
-
const handleSelect =
|
|
2239
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2218
2240
|
return [
|
|
2219
2241
|
optionsFacet.of(options),
|
|
2220
2242
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2392,9 +2414,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2392
2414
|
// src/extensions/debug.ts
|
|
2393
2415
|
import { syntaxTree } from "@codemirror/language";
|
|
2394
2416
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2395
|
-
var debugNodeLogger = (
|
|
2417
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2396
2418
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2397
|
-
enter: (node) =>
|
|
2419
|
+
enter: (node) => log12(node.type)
|
|
2398
2420
|
});
|
|
2399
2421
|
return StateField4.define({
|
|
2400
2422
|
create: (state) => logTokens(state),
|
|
@@ -2429,8 +2451,8 @@ var dropFile = (options = {}) => {
|
|
|
2429
2451
|
};
|
|
2430
2452
|
var styles3 = EditorView12.theme({
|
|
2431
2453
|
".cm-dropCursor": {
|
|
2432
|
-
borderLeft: "2px solid var(--
|
|
2433
|
-
color: "var(--
|
|
2454
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2455
|
+
color: "var(--color-accent-text)",
|
|
2434
2456
|
padding: "0 4px"
|
|
2435
2457
|
},
|
|
2436
2458
|
".cm-dropCursor:after": {
|
|
@@ -2448,43 +2470,62 @@ import { EditorView as EditorView15, ViewPlugin as ViewPlugin11, drawSelection,
|
|
|
2448
2470
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2449
2471
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2450
2472
|
import { generateName } from "@dxos/display-name";
|
|
2451
|
-
import { log as
|
|
2473
|
+
import { log as log8 } from "@dxos/log";
|
|
2452
2474
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2453
2475
|
|
|
2454
|
-
// src/styles/
|
|
2476
|
+
// src/styles/theme.ts
|
|
2477
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2455
2478
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2456
2479
|
var headings = {
|
|
2457
|
-
1:
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2480
|
+
1: {
|
|
2481
|
+
className: "text-4xl",
|
|
2482
|
+
fontSize: "var(--text-4xl)",
|
|
2483
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2484
|
+
},
|
|
2485
|
+
2: {
|
|
2486
|
+
className: "text-3xl",
|
|
2487
|
+
fontSize: "var(--text-3xl)",
|
|
2488
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2489
|
+
},
|
|
2490
|
+
3: {
|
|
2491
|
+
className: "text-2xl",
|
|
2492
|
+
fontSize: "var(--text-2xl)",
|
|
2493
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2494
|
+
},
|
|
2495
|
+
4: {
|
|
2496
|
+
className: "text-xl",
|
|
2497
|
+
fontSize: "var(--text-xl)",
|
|
2498
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2499
|
+
},
|
|
2500
|
+
5: {
|
|
2501
|
+
className: "text-lg",
|
|
2502
|
+
fontSize: "var(--text-lg)",
|
|
2503
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2504
|
+
},
|
|
2505
|
+
6: {
|
|
2506
|
+
className: "text-base",
|
|
2507
|
+
fontSize: "var(--text-base)",
|
|
2508
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2509
|
+
}
|
|
2463
2510
|
};
|
|
2464
2511
|
var markdownTheme = {
|
|
2465
|
-
code: "font-mono
|
|
2466
|
-
codeMark: "font-mono text-
|
|
2512
|
+
code: "font-mono no-underline! text-cm-code",
|
|
2513
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
2467
2514
|
mark: "opacity-50",
|
|
2468
|
-
heading: (level) => {
|
|
2469
|
-
|
|
2470
|
-
|
|
2515
|
+
heading: (level) => ({
|
|
2516
|
+
className: mx3(headings[level].className, "font-light text-cm-heading"),
|
|
2517
|
+
color: "var(--color-cm-heading) !important",
|
|
2518
|
+
lineHeight: headings[level].lineHeight,
|
|
2519
|
+
fontSize: headings[level].fontSize,
|
|
2520
|
+
fontWeight: "100 !important"
|
|
2521
|
+
})
|
|
2471
2522
|
};
|
|
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
|
|
2523
|
+
var fontBody = "Inter Variable, ui-sans-serif, system-ui, sans-serif";
|
|
2524
|
+
var fontMono = "JetBrains Mono Variable, ui-monospace, Cascadia Code, Source Code Pro, monospace";
|
|
2487
2525
|
var baseTheme = EditorView13.baseTheme({
|
|
2526
|
+
/**
|
|
2527
|
+
* Outer frame.
|
|
2528
|
+
*/
|
|
2488
2529
|
"&": {},
|
|
2489
2530
|
"&.cm-focused": {
|
|
2490
2531
|
outline: "none"
|
|
@@ -2493,7 +2534,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2493
2534
|
* Scroller
|
|
2494
2535
|
*/
|
|
2495
2536
|
".cm-scroller": {
|
|
2496
|
-
|
|
2537
|
+
overflowAnchor: "none"
|
|
2538
|
+
},
|
|
2539
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2540
|
+
width: "8px"
|
|
2541
|
+
},
|
|
2542
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2543
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2544
|
+
background: "transparent",
|
|
2545
|
+
transition: "background 0.15s"
|
|
2546
|
+
},
|
|
2547
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2548
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2497
2549
|
},
|
|
2498
2550
|
/**
|
|
2499
2551
|
* Content
|
|
@@ -2515,8 +2567,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2515
2567
|
".cm-gutter": {},
|
|
2516
2568
|
".cm-gutter.cm-lineNumbers": {
|
|
2517
2569
|
paddingRight: "4px",
|
|
2518
|
-
borderRight: "1px solid var(--
|
|
2519
|
-
color: "var(--
|
|
2570
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2571
|
+
color: "var(--color-subdued)"
|
|
2520
2572
|
},
|
|
2521
2573
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2522
2574
|
minWidth: "40px"
|
|
@@ -2536,25 +2588,25 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2536
2588
|
paddingInline: 0
|
|
2537
2589
|
},
|
|
2538
2590
|
".cm-activeLine": {
|
|
2539
|
-
background: "var(--
|
|
2591
|
+
background: "var(--color-cm-active-line)"
|
|
2540
2592
|
},
|
|
2541
2593
|
/**
|
|
2542
2594
|
* Cursor (layer).
|
|
2543
2595
|
*/
|
|
2544
2596
|
".cm-cursor, .cm-dropCursor": {
|
|
2545
|
-
borderLeft: "2px solid var(--
|
|
2597
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2546
2598
|
},
|
|
2547
2599
|
".cm-placeholder": {
|
|
2548
|
-
color: "var(--
|
|
2600
|
+
color: "var(--color-placeholder)"
|
|
2549
2601
|
},
|
|
2550
2602
|
/**
|
|
2551
2603
|
* Selection (layer).
|
|
2552
2604
|
*/
|
|
2553
2605
|
".cm-selectionBackground": {
|
|
2554
|
-
background: "var(--
|
|
2606
|
+
background: "var(--color-cm-selection)"
|
|
2555
2607
|
},
|
|
2556
2608
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2557
|
-
background: "var(--
|
|
2609
|
+
background: "var(--color-cm-focused-selection)"
|
|
2558
2610
|
},
|
|
2559
2611
|
/**
|
|
2560
2612
|
* Search.
|
|
@@ -2564,8 +2616,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2564
2616
|
margin: "0 -3px",
|
|
2565
2617
|
padding: "3px",
|
|
2566
2618
|
borderRadius: "3px",
|
|
2567
|
-
background: "var(--
|
|
2568
|
-
color: "var(--
|
|
2619
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2620
|
+
color: "var(--color-cm-highlight)"
|
|
2569
2621
|
},
|
|
2570
2622
|
".cm-searchMatch-selected": {
|
|
2571
2623
|
textDecoration: "underline"
|
|
@@ -2576,20 +2628,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2576
2628
|
".cm-link": {
|
|
2577
2629
|
textDecorationLine: "underline",
|
|
2578
2630
|
textDecorationThickness: "1px",
|
|
2579
|
-
textDecorationColor: "var(--
|
|
2631
|
+
textDecorationColor: "var(--color-separator)",
|
|
2580
2632
|
textUnderlineOffset: "2px",
|
|
2581
2633
|
borderRadius: ".125rem"
|
|
2582
2634
|
},
|
|
2583
2635
|
".cm-link > span": {
|
|
2584
|
-
color: "var(--
|
|
2636
|
+
color: "var(--color-accent-text)"
|
|
2637
|
+
},
|
|
2638
|
+
".cm-link > span:hover": {
|
|
2639
|
+
color: "var(--color-accent-text-hover)"
|
|
2585
2640
|
},
|
|
2586
2641
|
/**
|
|
2587
2642
|
* Tooltip.
|
|
2588
2643
|
*/
|
|
2589
2644
|
".cm-tooltip": {
|
|
2590
|
-
background: "var(--
|
|
2645
|
+
background: "var(--color-modal-surface)"
|
|
2591
2646
|
},
|
|
2592
2647
|
".cm-tooltip-below": {},
|
|
2648
|
+
".cm-tooltip-hover": {
|
|
2649
|
+
background: "var(--color-modal-surface)",
|
|
2650
|
+
border: "1px solid var(--color-separator)",
|
|
2651
|
+
borderRadius: "4px",
|
|
2652
|
+
overflow: "hidden"
|
|
2653
|
+
},
|
|
2593
2654
|
/**
|
|
2594
2655
|
* Autocomplete.
|
|
2595
2656
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2597,7 +2658,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2597
2658
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2598
2659
|
marginTop: "6px",
|
|
2599
2660
|
marginLeft: "-10px",
|
|
2600
|
-
border: "2px solid var(--
|
|
2661
|
+
border: "2px solid var(--color-separator)",
|
|
2601
2662
|
borderRadius: "4px"
|
|
2602
2663
|
},
|
|
2603
2664
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2607,12 +2668,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2607
2668
|
padding: "4px"
|
|
2608
2669
|
},
|
|
2609
2670
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2610
|
-
background: "var(--
|
|
2611
|
-
color: "var(--
|
|
2671
|
+
background: "var(--color-active-surface)",
|
|
2672
|
+
color: "var(--color-base-surface-text)"
|
|
2612
2673
|
},
|
|
2613
2674
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2614
2675
|
paddingLeft: "4px !important",
|
|
2615
|
-
color: "var(--
|
|
2676
|
+
color: "var(--color-base-surface-text)"
|
|
2616
2677
|
},
|
|
2617
2678
|
/**
|
|
2618
2679
|
* Completion info.
|
|
@@ -2621,17 +2682,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2621
2682
|
width: "360px !important",
|
|
2622
2683
|
margin: "-10px 1px 0 1px",
|
|
2623
2684
|
padding: "8px !important",
|
|
2624
|
-
borderColor: "var(--
|
|
2685
|
+
borderColor: "var(--color-separator)"
|
|
2625
2686
|
},
|
|
2626
2687
|
".cm-completionIcon": {
|
|
2627
2688
|
display: "none"
|
|
2628
2689
|
},
|
|
2629
2690
|
".cm-completionLabel": {
|
|
2630
|
-
color: "var(--
|
|
2691
|
+
color: "var(--color-description)",
|
|
2631
2692
|
padding: "0 4px"
|
|
2632
2693
|
},
|
|
2633
2694
|
".cm-completionMatchedText": {
|
|
2634
|
-
color: "var(--
|
|
2695
|
+
color: "var(--color-base-surface-text)",
|
|
2635
2696
|
textDecoration: "none !important"
|
|
2636
2697
|
},
|
|
2637
2698
|
/**
|
|
@@ -2655,7 +2716,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2655
2716
|
backgroundColor: "var(--surface-bg)"
|
|
2656
2717
|
},
|
|
2657
2718
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2658
|
-
color: "var(--
|
|
2719
|
+
color: "var(--color-subdued)",
|
|
2659
2720
|
fontSize: "14px",
|
|
2660
2721
|
all: "unset",
|
|
2661
2722
|
margin: "3px !important",
|
|
@@ -2663,10 +2724,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2663
2724
|
outline: "1px solid transparent"
|
|
2664
2725
|
},
|
|
2665
2726
|
".cm-panel input, .cm-panel button": {
|
|
2666
|
-
backgroundColor: "var(--
|
|
2727
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2667
2728
|
},
|
|
2668
2729
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2669
|
-
outline: "1px solid var(--
|
|
2730
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2670
2731
|
},
|
|
2671
2732
|
".cm-panel label": {
|
|
2672
2733
|
display: "inline-flex",
|
|
@@ -2679,25 +2740,26 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2679
2740
|
height: "8px",
|
|
2680
2741
|
marginRight: "6px !important",
|
|
2681
2742
|
padding: "2px !important",
|
|
2682
|
-
color: "var(--
|
|
2743
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2683
2744
|
},
|
|
2684
2745
|
".cm-panel button": {
|
|
2685
2746
|
"&:hover": {
|
|
2686
|
-
|
|
2747
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2748
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2687
2749
|
},
|
|
2688
2750
|
"&:active": {
|
|
2689
|
-
backgroundColor: "var(--
|
|
2751
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2690
2752
|
}
|
|
2691
2753
|
},
|
|
2692
2754
|
".cm-panel.cm-search": {
|
|
2693
2755
|
padding: "4px",
|
|
2694
|
-
borderTop: "1px solid var(--
|
|
2756
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2695
2757
|
}
|
|
2696
2758
|
});
|
|
2697
2759
|
var editorGutter = EditorView13.theme({
|
|
2698
2760
|
".cm-gutters": {
|
|
2699
2761
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2700
|
-
background: "var(--
|
|
2762
|
+
background: "var(--color-base-surface) !important",
|
|
2701
2763
|
paddingRight: "1rem"
|
|
2702
2764
|
}
|
|
2703
2765
|
});
|
|
@@ -2715,9 +2777,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2715
2777
|
});
|
|
2716
2778
|
|
|
2717
2779
|
// src/extensions/focus.ts
|
|
2718
|
-
import { StateEffect as
|
|
2780
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2719
2781
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2720
|
-
var focusEffect =
|
|
2782
|
+
var focusEffect = StateEffect5.define();
|
|
2721
2783
|
var focusField = StateField5.define({
|
|
2722
2784
|
create: () => false,
|
|
2723
2785
|
update: (value, tr) => {
|
|
@@ -2746,7 +2808,7 @@ var focus = [
|
|
|
2746
2808
|
];
|
|
2747
2809
|
|
|
2748
2810
|
// src/extensions/factories.ts
|
|
2749
|
-
var
|
|
2811
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2750
2812
|
var tabbable = EditorView15.contentAttributes.of({
|
|
2751
2813
|
tabindex: "0"
|
|
2752
2814
|
});
|
|
@@ -2801,9 +2863,9 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2801
2863
|
return [
|
|
2802
2864
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2803
2865
|
EditorView15.exceptionSink.of((err) => {
|
|
2804
|
-
|
|
2805
|
-
F:
|
|
2806
|
-
L:
|
|
2866
|
+
log8.catch(err, void 0, {
|
|
2867
|
+
F: __dxlog_file11,
|
|
2868
|
+
L: 131,
|
|
2807
2869
|
S: void 0,
|
|
2808
2870
|
C: (f, a) => f(...a)
|
|
2809
2871
|
});
|
|
@@ -2855,12 +2917,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2855
2917
|
};
|
|
2856
2918
|
var grow = {
|
|
2857
2919
|
editor: {
|
|
2858
|
-
className: "
|
|
2920
|
+
className: "h-full w-full"
|
|
2859
2921
|
}
|
|
2860
2922
|
};
|
|
2861
2923
|
var fullWidth = {
|
|
2862
2924
|
editor: {
|
|
2863
|
-
className: "
|
|
2925
|
+
className: "w-full"
|
|
2864
2926
|
}
|
|
2865
2927
|
};
|
|
2866
2928
|
var defaultThemeSlots = grow;
|
|
@@ -2903,8 +2965,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2903
2965
|
channel: `awareness.${id}`,
|
|
2904
2966
|
peerId: identity.identityKey.toHex(),
|
|
2905
2967
|
info: {
|
|
2906
|
-
darkColor: `var(--
|
|
2907
|
-
lightColor: `var(--
|
|
2968
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
2969
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2908
2970
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2909
2971
|
}
|
|
2910
2972
|
})));
|
|
@@ -2923,7 +2985,7 @@ var folding = () => {
|
|
|
2923
2985
|
}),
|
|
2924
2986
|
foldGutter({
|
|
2925
2987
|
markerDOM: (open) => {
|
|
2926
|
-
return Domino2.of("div").classNames("flex
|
|
2988
|
+
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
2989
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2928
2990
|
}))).root;
|
|
2929
2991
|
}
|
|
@@ -4219,6 +4281,11 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
|
4219
4281
|
import { HighlightStyle as HighlightStyle2 } from "@codemirror/language";
|
|
4220
4282
|
import { Tag, styleTags, tags } from "@lezer/highlight";
|
|
4221
4283
|
import { Table } from "@lezer/markdown";
|
|
4284
|
+
var styles4 = {
|
|
4285
|
+
code: "font-mono no-underline! text-cm-code",
|
|
4286
|
+
codeMark: "font-mono text-cm-code-mark",
|
|
4287
|
+
mark: "opacity-50"
|
|
4288
|
+
};
|
|
4222
4289
|
var markdownTags = {
|
|
4223
4290
|
Blockquote: Tag.define(),
|
|
4224
4291
|
CodeMark: Tag.define(),
|
|
@@ -4300,7 +4367,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4300
4367
|
markdownTags.LinkReference,
|
|
4301
4368
|
markdownTags.ListMark
|
|
4302
4369
|
],
|
|
4303
|
-
class:
|
|
4370
|
+
class: styles4.mark
|
|
4304
4371
|
},
|
|
4305
4372
|
// Markdown marks.
|
|
4306
4373
|
{
|
|
@@ -4311,7 +4378,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4311
4378
|
markdownTags.QuoteMark,
|
|
4312
4379
|
markdownTags.EmphasisMark
|
|
4313
4380
|
],
|
|
4314
|
-
class:
|
|
4381
|
+
class: styles4.mark
|
|
4315
4382
|
},
|
|
4316
4383
|
// E.g., code block language (after ```).
|
|
4317
4384
|
{
|
|
@@ -4320,7 +4387,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4320
4387
|
tags.function(tags.variableName),
|
|
4321
4388
|
tags.labelName
|
|
4322
4389
|
],
|
|
4323
|
-
class:
|
|
4390
|
+
class: styles4.codeMark
|
|
4324
4391
|
},
|
|
4325
4392
|
// Fonts.
|
|
4326
4393
|
{
|
|
@@ -4330,30 +4397,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4330
4397
|
],
|
|
4331
4398
|
class: "font-mono"
|
|
4332
4399
|
},
|
|
4333
|
-
// Headings
|
|
4400
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4401
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4402
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4403
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4404
|
+
{
|
|
4405
|
+
tag: tags.heading,
|
|
4406
|
+
color: "var(--color-cm-heading) !important",
|
|
4407
|
+
fontWeight: "300"
|
|
4408
|
+
},
|
|
4334
4409
|
{
|
|
4335
4410
|
tag: tags.heading1,
|
|
4336
|
-
|
|
4411
|
+
...markdownTheme.heading(1)
|
|
4337
4412
|
},
|
|
4338
4413
|
{
|
|
4339
4414
|
tag: tags.heading2,
|
|
4340
|
-
|
|
4415
|
+
...markdownTheme.heading(2)
|
|
4341
4416
|
},
|
|
4342
4417
|
{
|
|
4343
4418
|
tag: tags.heading3,
|
|
4344
|
-
|
|
4419
|
+
...markdownTheme.heading(3)
|
|
4345
4420
|
},
|
|
4346
4421
|
{
|
|
4347
4422
|
tag: tags.heading4,
|
|
4348
|
-
|
|
4423
|
+
...markdownTheme.heading(4)
|
|
4349
4424
|
},
|
|
4350
4425
|
{
|
|
4351
4426
|
tag: tags.heading5,
|
|
4352
|
-
|
|
4427
|
+
...markdownTheme.heading(5)
|
|
4353
4428
|
},
|
|
4354
4429
|
{
|
|
4355
4430
|
tag: tags.heading6,
|
|
4356
|
-
|
|
4431
|
+
...markdownTheme.heading(6)
|
|
4357
4432
|
},
|
|
4358
4433
|
// Emphasis.
|
|
4359
4434
|
{
|
|
@@ -4378,7 +4453,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4378
4453
|
markdownTags.CodeText,
|
|
4379
4454
|
markdownTags.InlineCode
|
|
4380
4455
|
],
|
|
4381
|
-
class:
|
|
4456
|
+
class: styles4.code
|
|
4382
4457
|
},
|
|
4383
4458
|
{
|
|
4384
4459
|
tag: [
|
|
@@ -4483,7 +4558,7 @@ var convertTreeToJson = (state) => {
|
|
|
4483
4558
|
|
|
4484
4559
|
// src/extensions/markdown/decorate.ts
|
|
4485
4560
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4486
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4561
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4487
4562
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4488
4563
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4489
4564
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
@@ -4735,7 +4810,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4735
4810
|
width: "100%",
|
|
4736
4811
|
height: "0",
|
|
4737
4812
|
verticalAlign: "middle",
|
|
4738
|
-
borderTop: "1px solid var(--
|
|
4813
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4739
4814
|
opacity: 0.5
|
|
4740
4815
|
},
|
|
4741
4816
|
/**
|
|
@@ -4758,8 +4833,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4758
4833
|
* Blockquote.
|
|
4759
4834
|
*/
|
|
4760
4835
|
"& .cm-blockquote": {
|
|
4761
|
-
background: "var(--
|
|
4762
|
-
borderLeft: "2px solid var(--
|
|
4836
|
+
background: "var(--color-cm-codeblock)",
|
|
4837
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4763
4838
|
paddingLeft: "1rem",
|
|
4764
4839
|
margin: "0"
|
|
4765
4840
|
},
|
|
@@ -4770,7 +4845,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4770
4845
|
fontFamily: fontMono
|
|
4771
4846
|
},
|
|
4772
4847
|
"& .cm-codeblock-line": {
|
|
4773
|
-
background: "var(--
|
|
4848
|
+
background: "var(--color-cm-codeblock)",
|
|
4774
4849
|
paddingInline: "1rem !important"
|
|
4775
4850
|
},
|
|
4776
4851
|
"& .cm-codeblock-start": {
|
|
@@ -4804,8 +4879,8 @@ var formattingStyles = EditorView21.theme({
|
|
|
4804
4879
|
".cm-table-head": {
|
|
4805
4880
|
padding: "2px 16px 2px 0px",
|
|
4806
4881
|
textAlign: "left",
|
|
4807
|
-
borderBottom: "1px solid var(--
|
|
4808
|
-
color: "var(--
|
|
4882
|
+
borderBottom: "1px solid var(--color-cm-separator)",
|
|
4883
|
+
color: "var(--color-subdued)"
|
|
4809
4884
|
},
|
|
4810
4885
|
".cm-table-cell": {
|
|
4811
4886
|
padding: "2px 16px 2px 0px"
|
|
@@ -4945,7 +5020,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4945
5020
|
};
|
|
4946
5021
|
|
|
4947
5022
|
// src/extensions/markdown/decorate.ts
|
|
4948
|
-
var
|
|
5023
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4949
5024
|
var Unicode = {
|
|
4950
5025
|
emDash: "\u2014",
|
|
4951
5026
|
bullet: "\u2022",
|
|
@@ -4968,7 +5043,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4968
5043
|
eq(other) {
|
|
4969
5044
|
return this.url === other.url;
|
|
4970
5045
|
}
|
|
4971
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4972
5046
|
toDOM(view) {
|
|
4973
5047
|
const el = document.createElement("span");
|
|
4974
5048
|
this.render(el, {
|
|
@@ -5081,8 +5155,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5081
5155
|
const headerLevels = [];
|
|
5082
5156
|
const getHeaderLevels = (node, level) => {
|
|
5083
5157
|
invariant4(level > 0, void 0, {
|
|
5084
|
-
F:
|
|
5085
|
-
L:
|
|
5158
|
+
F: __dxlog_file12,
|
|
5159
|
+
L: 179,
|
|
5086
5160
|
S: void 0,
|
|
5087
5161
|
A: [
|
|
5088
5162
|
"level > 0",
|
|
@@ -5120,8 +5194,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5120
5194
|
};
|
|
5121
5195
|
const getCurrentListLevel = () => {
|
|
5122
5196
|
invariant4(listLevels.length, void 0, {
|
|
5123
|
-
F:
|
|
5124
|
-
L:
|
|
5197
|
+
F: __dxlog_file12,
|
|
5198
|
+
L: 201,
|
|
5125
5199
|
S: void 0,
|
|
5126
5200
|
A: [
|
|
5127
5201
|
"listLevels.length",
|
|
@@ -5171,7 +5245,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5171
5245
|
from: mark.from,
|
|
5172
5246
|
to: mark.from + len,
|
|
5173
5247
|
deco: Decoration11.replace({
|
|
5174
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5248
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5175
5249
|
})
|
|
5176
5250
|
});
|
|
5177
5251
|
}
|
|
@@ -5438,7 +5512,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5438
5512
|
atomicDeco: atomicDeco.finish()
|
|
5439
5513
|
};
|
|
5440
5514
|
};
|
|
5441
|
-
var forceUpdate =
|
|
5515
|
+
var forceUpdate = StateEffect6.define();
|
|
5442
5516
|
var decorateMarkdown = (options = {}) => {
|
|
5443
5517
|
return [
|
|
5444
5518
|
ViewPlugin14.fromClass(class {
|
|
@@ -5510,8 +5584,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5510
5584
|
return {
|
|
5511
5585
|
pos: link.from,
|
|
5512
5586
|
end: link.to,
|
|
5513
|
-
|
|
5514
|
-
// above: true,
|
|
5587
|
+
above: true,
|
|
5515
5588
|
create: () => {
|
|
5516
5589
|
const el = document.createElement("div");
|
|
5517
5590
|
el.className = tooltipContent({});
|
|
@@ -5527,16 +5600,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5527
5600
|
};
|
|
5528
5601
|
}
|
|
5529
5602
|
};
|
|
5530
|
-
}, {
|
|
5531
|
-
// NOTE: 0 = default of 300ms.
|
|
5532
|
-
hoverTime: 1
|
|
5533
5603
|
});
|
|
5534
5604
|
};
|
|
5535
5605
|
|
|
5536
5606
|
// src/extensions/mention.ts
|
|
5537
5607
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5538
|
-
import { log as
|
|
5539
|
-
var
|
|
5608
|
+
import { log as log9 } from "@dxos/log";
|
|
5609
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5540
5610
|
var mention = ({ debug, onSearch }) => {
|
|
5541
5611
|
return autocompletion({
|
|
5542
5612
|
// TODO(burdon): Not working.
|
|
@@ -5548,10 +5618,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5548
5618
|
icons: false,
|
|
5549
5619
|
override: [
|
|
5550
5620
|
(context) => {
|
|
5551
|
-
|
|
5621
|
+
log9.info("completion context", {
|
|
5552
5622
|
context
|
|
5553
5623
|
}, {
|
|
5554
|
-
F:
|
|
5624
|
+
F: __dxlog_file13,
|
|
5555
5625
|
L: 27,
|
|
5556
5626
|
S: void 0,
|
|
5557
5627
|
C: (f, a) => f(...a)
|
|
@@ -5572,8 +5642,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5572
5642
|
};
|
|
5573
5643
|
|
|
5574
5644
|
// src/extensions/modal.ts
|
|
5575
|
-
import { StateEffect as
|
|
5576
|
-
var modalStateEffect =
|
|
5645
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5646
|
+
var modalStateEffect = StateEffect7.define();
|
|
5577
5647
|
var modalStateField = StateField9.define({
|
|
5578
5648
|
create: () => false,
|
|
5579
5649
|
update: (value, tr) => {
|
|
@@ -5634,7 +5704,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5634
5704
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5635
5705
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5636
5706
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5637
|
-
var
|
|
5707
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5638
5708
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5639
5709
|
return {
|
|
5640
5710
|
type,
|
|
@@ -5789,7 +5859,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5789
5859
|
}
|
|
5790
5860
|
case "BulletList": {
|
|
5791
5861
|
invariant5(current, void 0, {
|
|
5792
|
-
F:
|
|
5862
|
+
F: __dxlog_file14,
|
|
5793
5863
|
L: 219,
|
|
5794
5864
|
S: void 0,
|
|
5795
5865
|
A: [
|
|
@@ -5806,7 +5876,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5806
5876
|
}
|
|
5807
5877
|
case "ListItem": {
|
|
5808
5878
|
invariant5(parent, void 0, {
|
|
5809
|
-
F:
|
|
5879
|
+
F: __dxlog_file14,
|
|
5810
5880
|
L: 228,
|
|
5811
5881
|
S: void 0,
|
|
5812
5882
|
A: [
|
|
@@ -5848,7 +5918,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5848
5918
|
}
|
|
5849
5919
|
case "ListMark": {
|
|
5850
5920
|
invariant5(current, void 0, {
|
|
5851
|
-
F:
|
|
5921
|
+
F: __dxlog_file14,
|
|
5852
5922
|
L: 272,
|
|
5853
5923
|
S: void 0,
|
|
5854
5924
|
A: [
|
|
@@ -5862,7 +5932,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5862
5932
|
}
|
|
5863
5933
|
case "Task": {
|
|
5864
5934
|
invariant5(current, void 0, {
|
|
5865
|
-
F:
|
|
5935
|
+
F: __dxlog_file14,
|
|
5866
5936
|
L: 278,
|
|
5867
5937
|
S: void 0,
|
|
5868
5938
|
A: [
|
|
@@ -5875,7 +5945,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5875
5945
|
}
|
|
5876
5946
|
case "TaskMarker": {
|
|
5877
5947
|
invariant5(current, void 0, {
|
|
5878
|
-
F:
|
|
5948
|
+
F: __dxlog_file14,
|
|
5879
5949
|
L: 283,
|
|
5880
5950
|
S: void 0,
|
|
5881
5951
|
A: [
|
|
@@ -5891,7 +5961,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5891
5961
|
leave: (node) => {
|
|
5892
5962
|
if (node.name === "BulletList") {
|
|
5893
5963
|
invariant5(parent, void 0, {
|
|
5894
|
-
F:
|
|
5964
|
+
F: __dxlog_file14,
|
|
5895
5965
|
L: 291,
|
|
5896
5966
|
S: void 0,
|
|
5897
5967
|
A: [
|
|
@@ -5905,7 +5975,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5905
5975
|
}
|
|
5906
5976
|
});
|
|
5907
5977
|
invariant5(tree, void 0, {
|
|
5908
|
-
F:
|
|
5978
|
+
F: __dxlog_file14,
|
|
5909
5979
|
L: 298,
|
|
5910
5980
|
S: void 0,
|
|
5911
5981
|
A: [
|
|
@@ -6203,8 +6273,8 @@ import { mx as mx7 } from "@dxos/ui-theme";
|
|
|
6203
6273
|
// src/extensions/outliner/editor.ts
|
|
6204
6274
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6205
6275
|
import { ViewPlugin as ViewPlugin15 } from "@codemirror/view";
|
|
6206
|
-
import { log as
|
|
6207
|
-
var
|
|
6276
|
+
import { log as log10 } from "@dxos/log";
|
|
6277
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6208
6278
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6209
6279
|
var initialize = () => {
|
|
6210
6280
|
return ViewPlugin15.fromClass(class {
|
|
@@ -6336,7 +6406,7 @@ var editor = () => [
|
|
|
6336
6406
|
cancel = true;
|
|
6337
6407
|
return;
|
|
6338
6408
|
}
|
|
6339
|
-
|
|
6409
|
+
log10("change", {
|
|
6340
6410
|
item,
|
|
6341
6411
|
line: {
|
|
6342
6412
|
from: line.from,
|
|
@@ -6355,7 +6425,7 @@ var editor = () => [
|
|
|
6355
6425
|
length: insert.length
|
|
6356
6426
|
}
|
|
6357
6427
|
}, {
|
|
6358
|
-
F:
|
|
6428
|
+
F: __dxlog_file15,
|
|
6359
6429
|
L: 164,
|
|
6360
6430
|
S: void 0,
|
|
6361
6431
|
C: (f, a) => f(...a)
|
|
@@ -6363,10 +6433,10 @@ var editor = () => [
|
|
|
6363
6433
|
}
|
|
6364
6434
|
});
|
|
6365
6435
|
if (changes.length > 0) {
|
|
6366
|
-
|
|
6436
|
+
log10("modified,", {
|
|
6367
6437
|
changes
|
|
6368
6438
|
}, {
|
|
6369
|
-
F:
|
|
6439
|
+
F: __dxlog_file15,
|
|
6370
6440
|
L: 175,
|
|
6371
6441
|
S: void 0,
|
|
6372
6442
|
C: (f, a) => f(...a)
|
|
@@ -6377,8 +6447,8 @@ var editor = () => [
|
|
|
6377
6447
|
}
|
|
6378
6448
|
];
|
|
6379
6449
|
} else if (cancel) {
|
|
6380
|
-
|
|
6381
|
-
F:
|
|
6450
|
+
log10("cancel", void 0, {
|
|
6451
|
+
F: __dxlog_file15,
|
|
6382
6452
|
L: 178,
|
|
6383
6453
|
S: void 0,
|
|
6384
6454
|
C: (f, a) => f(...a)
|
|
@@ -6391,7 +6461,7 @@ var editor = () => [
|
|
|
6391
6461
|
|
|
6392
6462
|
// src/extensions/outliner/menu.ts
|
|
6393
6463
|
import { EditorView as EditorView24, ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6394
|
-
import { addEventListener } from "@dxos/async";
|
|
6464
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6395
6465
|
var menu = (options = {}) => [
|
|
6396
6466
|
ViewPlugin16.fromClass(class {
|
|
6397
6467
|
view;
|
|
@@ -6413,7 +6483,7 @@ var menu = (options = {}) => [
|
|
|
6413
6483
|
}
|
|
6414
6484
|
container.appendChild(this.tag);
|
|
6415
6485
|
const handler = () => this.scheduleUpdate();
|
|
6416
|
-
this.cleanup =
|
|
6486
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6417
6487
|
this.scheduleUpdate();
|
|
6418
6488
|
}
|
|
6419
6489
|
destroy() {
|
|
@@ -6492,7 +6562,7 @@ var outliner = (_options = {}) => [
|
|
|
6492
6562
|
}),
|
|
6493
6563
|
// Researve space for menu.
|
|
6494
6564
|
EditorView25.contentAttributes.of({
|
|
6495
|
-
class: "
|
|
6565
|
+
class: "w-full !mr-[3rem]"
|
|
6496
6566
|
})
|
|
6497
6567
|
];
|
|
6498
6568
|
var decorations = () => [
|
|
@@ -6556,10 +6626,10 @@ var decorations = () => [
|
|
|
6556
6626
|
marginBottom: "2px"
|
|
6557
6627
|
},
|
|
6558
6628
|
".cm-list-item-focused": {
|
|
6559
|
-
borderColor: "var(--
|
|
6629
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6560
6630
|
},
|
|
6561
6631
|
"&:focus-within .cm-list-item-selected": {
|
|
6562
|
-
borderColor: "var(--
|
|
6632
|
+
borderColor: "var(--color-separator)"
|
|
6563
6633
|
}
|
|
6564
6634
|
}))
|
|
6565
6635
|
];
|
|
@@ -6631,13 +6701,13 @@ var getLinkRef = (state, node) => {
|
|
|
6631
6701
|
const mark = node.getChildren("LinkMark");
|
|
6632
6702
|
const urlNode = node.getChild("URL");
|
|
6633
6703
|
if (mark && urlNode) {
|
|
6634
|
-
const
|
|
6635
|
-
if (
|
|
6704
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6705
|
+
if (dxn.startsWith("dxn:")) {
|
|
6636
6706
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6637
6707
|
return {
|
|
6638
6708
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6639
6709
|
label,
|
|
6640
|
-
|
|
6710
|
+
dxn
|
|
6641
6711
|
};
|
|
6642
6712
|
}
|
|
6643
6713
|
}
|
|
@@ -6652,13 +6722,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6652
6722
|
// return false;
|
|
6653
6723
|
// }
|
|
6654
6724
|
eq(other) {
|
|
6655
|
-
return this._link.
|
|
6725
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6656
6726
|
}
|
|
6657
6727
|
toDOM(_view) {
|
|
6658
6728
|
const root = document.createElement("dx-anchor");
|
|
6659
6729
|
root.classList.add("dx-tag--anchor");
|
|
6660
6730
|
root.textContent = this._link.label;
|
|
6661
|
-
root.setAttribute("
|
|
6731
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6662
6732
|
return root;
|
|
6663
6733
|
}
|
|
6664
6734
|
};
|
|
@@ -6672,11 +6742,11 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6672
6742
|
// return true;
|
|
6673
6743
|
// }
|
|
6674
6744
|
eq(other) {
|
|
6675
|
-
return this._link.
|
|
6745
|
+
return this._link.dxn === other._link.dxn;
|
|
6676
6746
|
}
|
|
6677
6747
|
toDOM(_view) {
|
|
6678
6748
|
const root = document.createElement("div");
|
|
6679
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6749
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6680
6750
|
this._options.addBlockContainer?.({
|
|
6681
6751
|
link: this._link,
|
|
6682
6752
|
el: root
|
|
@@ -6891,7 +6961,7 @@ var mixedParser = (registry) => {
|
|
|
6891
6961
|
};
|
|
6892
6962
|
|
|
6893
6963
|
// src/extensions/tags/streamer.ts
|
|
6894
|
-
import { StateEffect as
|
|
6964
|
+
import { StateEffect as StateEffect8, StateField as StateField12 } from "@codemirror/state";
|
|
6895
6965
|
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin18, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6896
6966
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6897
6967
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
@@ -6903,7 +6973,7 @@ var streamer = (options = {}) => {
|
|
|
6903
6973
|
].filter(isTruthy4);
|
|
6904
6974
|
};
|
|
6905
6975
|
var cursor = () => {
|
|
6906
|
-
const hideCursor =
|
|
6976
|
+
const hideCursor = StateEffect8.define();
|
|
6907
6977
|
const showCursor = StateField12.define({
|
|
6908
6978
|
create: () => true,
|
|
6909
6979
|
update: (value, tr) => {
|
|
@@ -6973,9 +7043,9 @@ var CursorWidget = class extends WidgetType9 {
|
|
|
6973
7043
|
};
|
|
6974
7044
|
var fadeIn = (options = {}) => {
|
|
6975
7045
|
const FADE_IN_DURATION = 1e3;
|
|
6976
|
-
const DEFAULT_REMOVAL_DELAY =
|
|
7046
|
+
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
6977
7047
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6978
|
-
const removeDecoration =
|
|
7048
|
+
const removeDecoration = StateEffect8.define();
|
|
6979
7049
|
const fadeField = StateField12.define({
|
|
6980
7050
|
create: () => Decoration14.none,
|
|
6981
7051
|
update: (decorations2, tr) => {
|
|
@@ -7085,17 +7155,17 @@ var fadeIn = (options = {}) => {
|
|
|
7085
7155
|
|
|
7086
7156
|
// src/extensions/tags/xml-tags.ts
|
|
7087
7157
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7088
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7158
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect9, StateField as StateField13 } from "@codemirror/state";
|
|
7089
7159
|
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin19, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7090
7160
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7091
|
-
import { log as
|
|
7161
|
+
import { log as log11 } from "@dxos/log";
|
|
7092
7162
|
|
|
7093
7163
|
// src/extensions/tags/xml-util.ts
|
|
7094
7164
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7095
|
-
var
|
|
7165
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7096
7166
|
var nodeToJson = (state, node) => {
|
|
7097
7167
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7098
|
-
F:
|
|
7168
|
+
F: __dxlog_file16,
|
|
7099
7169
|
L: 18,
|
|
7100
7170
|
S: void 0,
|
|
7101
7171
|
A: [
|
|
@@ -7159,16 +7229,16 @@ var nodeToJson = (state, node) => {
|
|
|
7159
7229
|
};
|
|
7160
7230
|
|
|
7161
7231
|
// src/extensions/tags/xml-tags.ts
|
|
7162
|
-
var
|
|
7163
|
-
var navigatePreviousEffect =
|
|
7164
|
-
var navigateNextEffect =
|
|
7232
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7233
|
+
var navigatePreviousEffect = StateEffect9.define();
|
|
7234
|
+
var navigateNextEffect = StateEffect9.define();
|
|
7165
7235
|
var getXmlTextChild = (children) => {
|
|
7166
7236
|
const child = children?.[0];
|
|
7167
7237
|
return typeof child === "string" ? child : null;
|
|
7168
7238
|
};
|
|
7169
|
-
var xmlTagContextEffect =
|
|
7170
|
-
var xmlTagResetEffect =
|
|
7171
|
-
var xmlTagUpdateEffect =
|
|
7239
|
+
var xmlTagContextEffect = StateEffect9.define();
|
|
7240
|
+
var xmlTagResetEffect = StateEffect9.define();
|
|
7241
|
+
var xmlTagUpdateEffect = StateEffect9.define();
|
|
7172
7242
|
var widgetContextStateField = StateField13.define({
|
|
7173
7243
|
create: () => void 0,
|
|
7174
7244
|
update: (value, tr) => {
|
|
@@ -7189,11 +7259,11 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7189
7259
|
}
|
|
7190
7260
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7191
7261
|
const { id, value } = effect.value;
|
|
7192
|
-
|
|
7262
|
+
log11("widget updated", {
|
|
7193
7263
|
id,
|
|
7194
7264
|
value
|
|
7195
7265
|
}, {
|
|
7196
|
-
F:
|
|
7266
|
+
F: __dxlog_file17,
|
|
7197
7267
|
L: 153,
|
|
7198
7268
|
S: void 0,
|
|
7199
7269
|
C: (f, a) => f(...a)
|
|
@@ -7224,11 +7294,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7224
7294
|
const widgets = /* @__PURE__ */ new Map();
|
|
7225
7295
|
const notifier = {
|
|
7226
7296
|
mounted: (state) => {
|
|
7227
|
-
|
|
7297
|
+
log11("widget mounted", {
|
|
7228
7298
|
id: state.id,
|
|
7229
7299
|
tag: state.props._tag
|
|
7230
7300
|
}, {
|
|
7231
|
-
F:
|
|
7301
|
+
F: __dxlog_file17,
|
|
7232
7302
|
L: 206,
|
|
7233
7303
|
S: void 0,
|
|
7234
7304
|
C: (f, a) => f(...a)
|
|
@@ -7240,11 +7310,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7240
7310
|
},
|
|
7241
7311
|
unmounted: (id) => {
|
|
7242
7312
|
const state = widgets.get(id);
|
|
7243
|
-
|
|
7313
|
+
log11("widget unmounted", {
|
|
7244
7314
|
id,
|
|
7245
7315
|
tag: state?.props._tag
|
|
7246
7316
|
}, {
|
|
7247
|
-
F:
|
|
7317
|
+
F: __dxlog_file17,
|
|
7248
7318
|
L: 212,
|
|
7249
7319
|
S: void 0,
|
|
7250
7320
|
C: (f, a) => f(...a)
|
|
@@ -7306,11 +7376,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7306
7376
|
anchor: line.from,
|
|
7307
7377
|
head: line.from
|
|
7308
7378
|
},
|
|
7309
|
-
effects:
|
|
7310
|
-
line: line.number,
|
|
7311
|
-
|
|
7312
|
-
offset: -16
|
|
7313
|
-
}
|
|
7379
|
+
effects: scrollerLineEffect.of({
|
|
7380
|
+
line: line.number - 1,
|
|
7381
|
+
offset: -16
|
|
7314
7382
|
})
|
|
7315
7383
|
});
|
|
7316
7384
|
continue;
|
|
@@ -7341,11 +7409,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7341
7409
|
anchor: line.to,
|
|
7342
7410
|
head: line.to
|
|
7343
7411
|
},
|
|
7344
|
-
effects:
|
|
7345
|
-
line: line.number,
|
|
7346
|
-
|
|
7347
|
-
offset: -16
|
|
7348
|
-
}
|
|
7412
|
+
effects: scrollerLineEffect.of({
|
|
7413
|
+
line: line.number - 1,
|
|
7414
|
+
offset: -16
|
|
7349
7415
|
})
|
|
7350
7416
|
});
|
|
7351
7417
|
} else {
|
|
@@ -7355,11 +7421,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7355
7421
|
anchor: line.to,
|
|
7356
7422
|
head: line.to
|
|
7357
7423
|
},
|
|
7358
|
-
effects:
|
|
7359
|
-
line: line.number,
|
|
7360
|
-
|
|
7361
|
-
position: "end"
|
|
7362
|
-
}
|
|
7424
|
+
effects: scrollerLineEffect.of({
|
|
7425
|
+
line: line.number - 1,
|
|
7426
|
+
position: "end"
|
|
7363
7427
|
})
|
|
7364
7428
|
});
|
|
7365
7429
|
}
|
|
@@ -7406,6 +7470,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7406
7470
|
update: ({ from, decorations: decorations2 }, tr) => {
|
|
7407
7471
|
for (const effect of tr.effects) {
|
|
7408
7472
|
if (effect.is(xmlTagResetEffect)) {
|
|
7473
|
+
if (tr.docChanged) {
|
|
7474
|
+
return buildDecorations4(tr.state, {
|
|
7475
|
+
from: 0,
|
|
7476
|
+
to: tr.state.doc.length
|
|
7477
|
+
}, registry, notifier);
|
|
7478
|
+
}
|
|
7409
7479
|
return {
|
|
7410
7480
|
from: 0,
|
|
7411
7481
|
decorations: Decoration15.none
|
|
@@ -7416,12 +7486,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7416
7486
|
const { state } = tr;
|
|
7417
7487
|
const reset = tr.changes.touchesRange(0, from);
|
|
7418
7488
|
if (reset) {
|
|
7419
|
-
|
|
7489
|
+
log11("document reset", {
|
|
7420
7490
|
from,
|
|
7421
7491
|
to: state.doc.length
|
|
7422
7492
|
}, {
|
|
7423
|
-
F:
|
|
7424
|
-
L:
|
|
7493
|
+
F: __dxlog_file17,
|
|
7494
|
+
L: 374,
|
|
7425
7495
|
S: void 0,
|
|
7426
7496
|
C: (f, a) => f(...a)
|
|
7427
7497
|
});
|
|
@@ -7502,9 +7572,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7502
7572
|
}
|
|
7503
7573
|
}
|
|
7504
7574
|
} catch (err) {
|
|
7505
|
-
|
|
7506
|
-
F:
|
|
7507
|
-
L:
|
|
7575
|
+
log11.catch(err, void 0, {
|
|
7576
|
+
F: __dxlog_file17,
|
|
7577
|
+
L: 459,
|
|
7508
7578
|
S: void 0,
|
|
7509
7579
|
C: (f, a) => f(...a)
|
|
7510
7580
|
});
|
|
@@ -7528,8 +7598,8 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7528
7598
|
constructor(id, Component, props, notifier) {
|
|
7529
7599
|
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier;
|
|
7530
7600
|
invariant7(id, void 0, {
|
|
7531
|
-
F:
|
|
7532
|
-
L:
|
|
7601
|
+
F: __dxlog_file17,
|
|
7602
|
+
L: 485,
|
|
7533
7603
|
S: this,
|
|
7534
7604
|
A: [
|
|
7535
7605
|
"id",
|
|
@@ -7658,6 +7728,7 @@ export {
|
|
|
7658
7728
|
convertTreeToJson,
|
|
7659
7729
|
createBasicExtensions,
|
|
7660
7730
|
createComment,
|
|
7731
|
+
createCrawler,
|
|
7661
7732
|
createDataExtensions,
|
|
7662
7733
|
createEditorStateStore,
|
|
7663
7734
|
createEditorStateTransaction,
|
|
@@ -7738,9 +7809,10 @@ export {
|
|
|
7738
7809
|
removeStyle,
|
|
7739
7810
|
replacer,
|
|
7740
7811
|
scrollThreadIntoView,
|
|
7741
|
-
scrollToBottomEffect,
|
|
7742
7812
|
scrollToLine,
|
|
7743
|
-
|
|
7813
|
+
scroller,
|
|
7814
|
+
scrollerCrawlEffect,
|
|
7815
|
+
scrollerLineEffect,
|
|
7744
7816
|
selectionState,
|
|
7745
7817
|
setBlockquote,
|
|
7746
7818
|
setComments,
|
|
@@ -7748,7 +7820,6 @@ export {
|
|
|
7748
7820
|
setSelection,
|
|
7749
7821
|
setStyle,
|
|
7750
7822
|
singleValueFacet,
|
|
7751
|
-
smoothScroll,
|
|
7752
7823
|
stackItemContentEditorClassNames,
|
|
7753
7824
|
staticCompletion,
|
|
7754
7825
|
streamer,
|