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