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