@dxos/ui-editor 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 +711 -521
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +711 -521
- 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 +3 -10
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts +6 -0
- package/dist/types/src/extensions/auto-scroll.d.ts.map +1 -0
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/folding.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +3 -2
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts +3 -0
- package/dist/types/src/extensions/markdown/bundle.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/markdown/styles.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +3 -1
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/scroll-past-end.d.ts +3 -0
- package/dist/types/src/extensions/scroll-past-end.d.ts.map +1 -0
- package/dist/types/src/extensions/scroller.d.ts +66 -0
- package/dist/types/src/extensions/scroller.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/streamer.d.ts +1 -1
- package/dist/types/src/styles/index.d.ts +0 -2
- package/dist/types/src/styles/index.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts +15 -0
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/util/cursor.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -32
- package/src/defaults.ts +19 -21
- package/src/extensions/annotations.ts +1 -1
- package/src/extensions/auto-scroll.ts +129 -0
- package/src/extensions/automerge/automerge.test.tsx +2 -2
- package/src/extensions/automerge/automerge.ts +6 -5
- package/src/extensions/blocks.ts +5 -5
- package/src/extensions/comments.ts +5 -5
- package/src/extensions/dnd.ts +2 -2
- package/src/extensions/factories.ts +7 -8
- package/src/extensions/folding.ts +3 -20
- package/src/extensions/index.ts +3 -2
- package/src/extensions/markdown/bundle.ts +23 -9
- package/src/extensions/markdown/decorate.ts +15 -11
- package/src/extensions/markdown/highlight.ts +15 -7
- package/src/extensions/markdown/link.ts +27 -33
- package/src/extensions/markdown/parser.test.ts +0 -1
- package/src/extensions/markdown/styles.ts +36 -9
- package/src/extensions/markdown/table.ts +24 -2
- package/src/extensions/outliner/outliner.ts +3 -3
- package/src/extensions/preview/preview.ts +62 -15
- package/src/extensions/scroll-past-end.ts +32 -0
- package/src/extensions/scroller.ts +233 -0
- package/src/extensions/selection.ts +1 -1
- package/src/extensions/tags/streamer.ts +2 -2
- package/src/extensions/tags/xml-tags.ts +7 -4
- package/src/styles/index.ts +0 -2
- package/src/styles/theme.ts +116 -34
- 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
|
@@ -8,23 +8,29 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
import { EditorState as EditorState3 } from "@codemirror/state";
|
|
11
|
-
import { EditorView as
|
|
11
|
+
import { EditorView as EditorView31, keymap as keymap15 } from "@codemirror/view";
|
|
12
12
|
import { tags as tags2 } from "@lezer/highlight";
|
|
13
13
|
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
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var editorClassNames = (role) => mx("dx-attention-surface p-0.5 data-[toolbar=disabled]:pt-2 dx-focus-ring-inset", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-h-24" : "dx-container overflow-hidden");
|
|
18
|
+
var documentSlots = {
|
|
19
|
+
content: {
|
|
20
|
+
/**
|
|
21
|
+
* CodeMirror content width.
|
|
22
|
+
* 40rem = 640px. Corresponds to initial plank width (Google docs, Stashpad, etc.)
|
|
23
|
+
* 50rem = 800px. Maximum content width for solo mode.
|
|
24
|
+
* NOTE: Max width - 4rem = 2rem left/right margin (or 2rem gutter plus 1rem left/right margin).
|
|
25
|
+
*/
|
|
26
|
+
className: "mx-auto! w-full pointer-fine:max-w-[min(50rem,100%-4rem)] pointer-coarse:max-w-[min(50rem,100%-2rem)]"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var compactSlots = {
|
|
22
30
|
content: {
|
|
23
|
-
className:
|
|
31
|
+
className: "mx-2! w-full"
|
|
24
32
|
}
|
|
25
33
|
};
|
|
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 attention-surface data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
|
|
28
34
|
|
|
29
35
|
// src/extensions/annotations.ts
|
|
30
36
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -59,7 +65,7 @@ var annotations = ({ match } = {}) => {
|
|
|
59
65
|
".cm-annotation": {
|
|
60
66
|
textDecoration: "underline",
|
|
61
67
|
textDecorationStyle: "wavy",
|
|
62
|
-
textDecorationColor: "var(--
|
|
68
|
+
textDecorationColor: "var(--color-error-text)"
|
|
63
69
|
}
|
|
64
70
|
})
|
|
65
71
|
];
|
|
@@ -502,228 +508,245 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
502
508
|
];
|
|
503
509
|
};
|
|
504
510
|
|
|
505
|
-
// src/extensions/
|
|
506
|
-
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
511
|
+
// src/extensions/auto-scroll.ts
|
|
507
512
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
508
|
-
import {
|
|
513
|
+
import { addEventListener, combine, throttle } from "@dxos/async";
|
|
509
514
|
import { Domino } from "@dxos/ui";
|
|
510
515
|
|
|
511
|
-
// src/extensions/
|
|
516
|
+
// src/extensions/scroller.ts
|
|
512
517
|
import { StateEffect } from "@codemirror/state";
|
|
513
518
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
514
|
-
|
|
515
|
-
var
|
|
516
|
-
|
|
519
|
+
import { log as log2 } from "@dxos/log";
|
|
520
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
521
|
+
var scrollerLineEffect = StateEffect.define();
|
|
522
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
523
|
+
var scrollToLine = (view, options) => {
|
|
524
|
+
view.dispatch({
|
|
525
|
+
effects: scrollerLineEffect.of(options)
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
529
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
517
530
|
view;
|
|
531
|
+
crawler;
|
|
518
532
|
constructor(view) {
|
|
519
533
|
this.view = view;
|
|
534
|
+
this.crawler = createCrawler(this.view);
|
|
520
535
|
}
|
|
521
536
|
// No-op.
|
|
522
537
|
destroy() {
|
|
538
|
+
this.crawler.cancel();
|
|
523
539
|
}
|
|
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;
|
|
540
|
+
cancel() {
|
|
541
|
+
this.crawler.cancel();
|
|
542
|
+
}
|
|
543
|
+
crawl(start = false) {
|
|
544
|
+
if (start) {
|
|
545
|
+
this.crawler.scroll();
|
|
559
546
|
} else {
|
|
560
|
-
|
|
547
|
+
this.crawler.cancel();
|
|
561
548
|
}
|
|
562
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
563
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
564
549
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
550
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
551
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
552
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
553
|
+
const doc = this.view.state.doc;
|
|
554
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
555
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
556
|
+
const lineStart = doc.line(line + 1).from;
|
|
557
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
558
|
+
if (coords) {
|
|
559
|
+
const currentScrollTop = scrollTop;
|
|
560
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
561
|
+
if (position === "end") {
|
|
562
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
563
|
+
} else {
|
|
564
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
565
|
+
}
|
|
566
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
567
|
+
}
|
|
571
568
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
569
|
+
requestAnimationFrame(() => {
|
|
570
|
+
this.view.scrollDOM.scrollTo({
|
|
571
|
+
top: targetScrollTop
|
|
572
|
+
});
|
|
575
573
|
});
|
|
576
574
|
}
|
|
577
575
|
});
|
|
578
576
|
return [
|
|
579
577
|
scrollPlugin,
|
|
580
|
-
//
|
|
578
|
+
// Listen for effect.s
|
|
581
579
|
EditorView4.updateListener.of((update2) => {
|
|
582
580
|
update2.transactions.forEach((transaction) => {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
});
|
|
581
|
+
try {
|
|
582
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
583
|
+
if (plugin) {
|
|
584
|
+
for (const effect of transaction.effects) {
|
|
585
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
586
|
+
plugin.crawl(effect.value);
|
|
587
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
588
|
+
plugin.scroll(effect.value);
|
|
589
|
+
}
|
|
593
590
|
}
|
|
594
591
|
}
|
|
592
|
+
} catch (err) {
|
|
593
|
+
log2.catch(err, void 0, {
|
|
594
|
+
F: __dxlog_file2,
|
|
595
|
+
L: 146,
|
|
596
|
+
S: void 0,
|
|
597
|
+
C: (f, a) => f(...a)
|
|
598
|
+
});
|
|
595
599
|
}
|
|
596
600
|
});
|
|
601
|
+
}),
|
|
602
|
+
// Styles.
|
|
603
|
+
EditorView4.theme({
|
|
604
|
+
".cm-content": {
|
|
605
|
+
paddingBottom: `${overScroll}px`
|
|
606
|
+
},
|
|
607
|
+
".cm-scroller": {
|
|
608
|
+
overflowAnchor: "none",
|
|
609
|
+
paddingBottom: "0"
|
|
610
|
+
},
|
|
611
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
612
|
+
display: "none"
|
|
613
|
+
},
|
|
614
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
615
|
+
background: "transparent",
|
|
616
|
+
transition: "background 0.15s"
|
|
617
|
+
},
|
|
618
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
619
|
+
background: "var(--color-scrollbar-thumb)"
|
|
620
|
+
},
|
|
621
|
+
".cm-scroll-button": {
|
|
622
|
+
position: "absolute",
|
|
623
|
+
bottom: "0.5rem",
|
|
624
|
+
right: "1rem"
|
|
625
|
+
}
|
|
597
626
|
})
|
|
598
627
|
];
|
|
599
628
|
};
|
|
600
|
-
|
|
601
|
-
view.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
629
|
+
function createCrawler(view, k = 0.3, maxStep = 2, targetDelta = 0.5) {
|
|
630
|
+
const el = view.scrollDOM;
|
|
631
|
+
let currentTop = 0;
|
|
632
|
+
let rafId = null;
|
|
633
|
+
function frame() {
|
|
634
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
635
|
+
const delta = targetTop - currentTop;
|
|
636
|
+
const absDelta = Math.abs(delta);
|
|
637
|
+
if (absDelta < targetDelta) {
|
|
638
|
+
el.scrollTop = targetTop;
|
|
639
|
+
currentTop = targetTop;
|
|
640
|
+
rafId = null;
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const step = Math.sign(delta) * Math.min(absDelta, Math.max(1, Math.min(absDelta * k, maxStep)));
|
|
644
|
+
currentTop += step;
|
|
645
|
+
el.scrollTop = currentTop;
|
|
646
|
+
rafId = requestAnimationFrame(frame);
|
|
647
|
+
}
|
|
648
|
+
return {
|
|
649
|
+
scroll: () => {
|
|
650
|
+
if (rafId === null) {
|
|
651
|
+
currentTop = el.scrollTop;
|
|
652
|
+
rafId = requestAnimationFrame(frame);
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
cancel: () => {
|
|
656
|
+
if (rafId !== null) {
|
|
657
|
+
cancelAnimationFrame(rafId);
|
|
658
|
+
rafId = null;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
608
663
|
|
|
609
|
-
// src/extensions/
|
|
610
|
-
|
|
611
|
-
var autoScroll = (
|
|
664
|
+
// src/extensions/auto-scroll.ts
|
|
665
|
+
import { getSize } from "@dxos/ui-theme";
|
|
666
|
+
var autoScroll = (_ = {}) => {
|
|
612
667
|
let buttonContainer;
|
|
613
|
-
let hideTimeout;
|
|
614
|
-
let lastScrollTop = 0;
|
|
615
668
|
let isPinned = true;
|
|
616
|
-
const setPinned = (
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
};
|
|
620
|
-
const hideScrollbar = (view) => {
|
|
621
|
-
view.scrollDOM.classList.add("cm-hide-scrollbar");
|
|
622
|
-
clearTimeout(hideTimeout);
|
|
623
|
-
hideTimeout = setTimeout(() => {
|
|
624
|
-
view.scrollDOM.classList.remove("cm-hide-scrollbar");
|
|
625
|
-
}, 1e3);
|
|
626
|
-
};
|
|
627
|
-
const scrollToBottom = (view, behavior) => {
|
|
628
|
-
setPinned(true);
|
|
629
|
-
hideScrollbar(view);
|
|
630
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
631
|
-
view.dispatch({
|
|
632
|
-
selection: {
|
|
633
|
-
anchor: line.to,
|
|
634
|
-
head: line.to
|
|
635
|
-
},
|
|
636
|
-
effects: scrollToLineEffect.of({
|
|
637
|
-
line: line.number,
|
|
638
|
-
options: {
|
|
639
|
-
position: "end",
|
|
640
|
-
offset: threshold,
|
|
641
|
-
behavior
|
|
642
|
-
}
|
|
643
|
-
})
|
|
644
|
-
});
|
|
669
|
+
const setPinned = (pinned) => {
|
|
670
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
671
|
+
isPinned = pinned;
|
|
645
672
|
};
|
|
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
673
|
return [
|
|
654
674
|
// Update listener for logging when scrolling is needed.
|
|
655
|
-
EditorView5.updateListener.of(({ view,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
675
|
+
EditorView5.updateListener.of(({ view, heightChanged, state }) => {
|
|
676
|
+
if (heightChanged) {
|
|
677
|
+
if (isPinned) {
|
|
678
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
679
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
680
|
+
if (delta > 0 && scrollTop > 0) {
|
|
681
|
+
setPinned(true);
|
|
682
|
+
view.dispatch({
|
|
683
|
+
effects: scrollerCrawlEffect.of(true)
|
|
684
|
+
});
|
|
685
|
+
} else if (delta < 0) {
|
|
686
|
+
setPinned(false);
|
|
660
687
|
}
|
|
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);
|
|
688
|
+
} else {
|
|
689
|
+
if (state.doc.length === 0) {
|
|
690
|
+
setPinned(true);
|
|
674
691
|
}
|
|
675
|
-
} else if (distanceFromBottom < 0) {
|
|
676
|
-
setPinned(false);
|
|
677
692
|
}
|
|
678
693
|
}
|
|
679
694
|
}),
|
|
680
|
-
// Detect user scroll.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
695
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
696
|
+
ViewPlugin6.fromClass(class {
|
|
697
|
+
cleanup;
|
|
698
|
+
constructor(view) {
|
|
699
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
700
|
+
requestAnimationFrame(() => {
|
|
701
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
702
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
703
|
+
const pinned = delta === 0;
|
|
704
|
+
setPinned(pinned);
|
|
705
|
+
if (!pinned) {
|
|
706
|
+
view.dispatch({
|
|
707
|
+
effects: scrollerCrawlEffect.of(false)
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}, 500));
|
|
712
|
+
}
|
|
713
|
+
destroy() {
|
|
714
|
+
this.cleanup();
|
|
691
715
|
}
|
|
692
716
|
}),
|
|
693
717
|
// Scroll button.
|
|
694
718
|
ViewPlugin6.fromClass(class {
|
|
695
719
|
constructor(view) {
|
|
696
|
-
const icon = Domino.of("dx-icon").attributes({
|
|
720
|
+
const icon = Domino.of("dx-icon").classNames(getSize(4)).attributes({
|
|
697
721
|
icon: "ph--arrow-down--regular"
|
|
698
722
|
});
|
|
699
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
723
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
700
724
|
"data-density": "fine"
|
|
701
725
|
}).children(icon).on("click", () => {
|
|
702
|
-
|
|
726
|
+
setPinned(true);
|
|
727
|
+
view.dispatch({
|
|
728
|
+
effects: scrollerLineEffect.of({
|
|
729
|
+
line: -1,
|
|
730
|
+
position: "end",
|
|
731
|
+
behavior: "smooth"
|
|
732
|
+
})
|
|
733
|
+
});
|
|
703
734
|
});
|
|
704
735
|
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").children(button).root;
|
|
705
736
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
706
737
|
}
|
|
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
738
|
})
|
|
725
739
|
];
|
|
726
740
|
};
|
|
741
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
742
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
743
|
+
passive: true
|
|
744
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
745
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
746
|
+
onUserScroll();
|
|
747
|
+
}
|
|
748
|
+
}));
|
|
749
|
+
}
|
|
727
750
|
|
|
728
751
|
// src/extensions/automerge/automerge.ts
|
|
729
752
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -737,15 +760,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
737
760
|
|
|
738
761
|
// src/extensions/automerge/cursor.ts
|
|
739
762
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
740
|
-
import { log as
|
|
741
|
-
var
|
|
763
|
+
import { log as log3 } from "@dxos/log";
|
|
764
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
742
765
|
var cursorConverter = (accessor) => ({
|
|
743
766
|
toCursor: (pos, assoc) => {
|
|
744
767
|
try {
|
|
745
768
|
return toCursor(accessor, pos, assoc);
|
|
746
769
|
} catch (err) {
|
|
747
|
-
|
|
748
|
-
F:
|
|
770
|
+
log3.catch(err, void 0, {
|
|
771
|
+
F: __dxlog_file3,
|
|
749
772
|
L: 15,
|
|
750
773
|
S: void 0,
|
|
751
774
|
C: (f, a) => f(...a)
|
|
@@ -757,8 +780,8 @@ var cursorConverter = (accessor) => ({
|
|
|
757
780
|
try {
|
|
758
781
|
return fromCursor(accessor, cursor2);
|
|
759
782
|
} catch (err) {
|
|
760
|
-
|
|
761
|
-
F:
|
|
783
|
+
log3.catch(err, void 0, {
|
|
784
|
+
F: __dxlog_file3,
|
|
762
785
|
L: 24,
|
|
763
786
|
S: void 0,
|
|
764
787
|
C: (f, a) => f(...a)
|
|
@@ -769,10 +792,10 @@ var cursorConverter = (accessor) => ({
|
|
|
769
792
|
});
|
|
770
793
|
|
|
771
794
|
// src/extensions/automerge/defs.ts
|
|
772
|
-
import { Annotation, StateEffect as
|
|
795
|
+
import { Annotation, StateEffect as StateEffect2 } from "@codemirror/state";
|
|
773
796
|
var getPath = (state, field) => state.field(field).path;
|
|
774
797
|
var getLastHeads = (state, field) => state.field(field).lastHeads;
|
|
775
|
-
var updateHeadsEffect =
|
|
798
|
+
var updateHeadsEffect = StateEffect2.define({});
|
|
776
799
|
var updateHeads = (newHeads) => updateHeadsEffect.of({
|
|
777
800
|
newHeads
|
|
778
801
|
});
|
|
@@ -783,7 +806,7 @@ var isReconcile = (tr) => {
|
|
|
783
806
|
|
|
784
807
|
// src/extensions/automerge/sync.ts
|
|
785
808
|
import { next as A2 } from "@automerge/automerge";
|
|
786
|
-
import { log as
|
|
809
|
+
import { log as log4 } from "@dxos/log";
|
|
787
810
|
|
|
788
811
|
// src/extensions/automerge/update-automerge.ts
|
|
789
812
|
import { next as A } from "@automerge/automerge";
|
|
@@ -924,7 +947,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
924
947
|
};
|
|
925
948
|
|
|
926
949
|
// src/extensions/automerge/sync.ts
|
|
927
|
-
var
|
|
950
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
928
951
|
var Syncer = class {
|
|
929
952
|
_handle;
|
|
930
953
|
_state;
|
|
@@ -947,8 +970,8 @@ var Syncer = class {
|
|
|
947
970
|
this._pending = false;
|
|
948
971
|
}
|
|
949
972
|
onEditorChange(view) {
|
|
950
|
-
|
|
951
|
-
F:
|
|
973
|
+
log4("onEditorChange", void 0, {
|
|
974
|
+
F: __dxlog_file4,
|
|
952
975
|
L: 45,
|
|
953
976
|
S: this,
|
|
954
977
|
C: (f, a) => f(...a)
|
|
@@ -963,8 +986,8 @@ var Syncer = class {
|
|
|
963
986
|
}
|
|
964
987
|
}
|
|
965
988
|
onAutomergeChange(view) {
|
|
966
|
-
|
|
967
|
-
F:
|
|
989
|
+
log4("onAutomergeChange", void 0, {
|
|
990
|
+
F: __dxlog_file4,
|
|
968
991
|
L: 60,
|
|
969
992
|
S: this,
|
|
970
993
|
C: (f, a) => f(...a)
|
|
@@ -1030,6 +1053,15 @@ var automerge = (accessor) => {
|
|
|
1030
1053
|
const value = DocAccessor.getValue(accessor);
|
|
1031
1054
|
const current = this._view.state.doc.toString();
|
|
1032
1055
|
if (value !== current) {
|
|
1056
|
+
console.warn("ENABLING INITIAL SYNC -- THIS MAY BE A REGRESSION");
|
|
1057
|
+
this._view.dispatch({
|
|
1058
|
+
changes: {
|
|
1059
|
+
from: 0,
|
|
1060
|
+
to: this._view.state.doc.length,
|
|
1061
|
+
insert: value
|
|
1062
|
+
},
|
|
1063
|
+
annotations: initialSync
|
|
1064
|
+
});
|
|
1033
1065
|
}
|
|
1034
1066
|
});
|
|
1035
1067
|
}
|
|
@@ -1057,7 +1089,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1057
1089
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1058
1090
|
import { Event } from "@dxos/async";
|
|
1059
1091
|
import { Context } from "@dxos/context";
|
|
1060
|
-
var
|
|
1092
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1061
1093
|
var dummyProvider = {
|
|
1062
1094
|
remoteStateChange: new Event(),
|
|
1063
1095
|
open: () => {
|
|
@@ -1081,7 +1113,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1081
1113
|
};
|
|
1082
1114
|
var RemoteSelectionsDecorator = class {
|
|
1083
1115
|
_ctx = new Context(void 0, {
|
|
1084
|
-
F:
|
|
1116
|
+
F: __dxlog_file5,
|
|
1085
1117
|
L: 80
|
|
1086
1118
|
});
|
|
1087
1119
|
_cursorConverter;
|
|
@@ -1294,8 +1326,8 @@ var styles = EditorView7.theme({
|
|
|
1294
1326
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1295
1327
|
import { Context as Context2 } from "@dxos/context";
|
|
1296
1328
|
import { invariant } from "@dxos/invariant";
|
|
1297
|
-
import { log as
|
|
1298
|
-
var
|
|
1329
|
+
import { log as log5 } from "@dxos/log";
|
|
1330
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1299
1331
|
var DEBOUNCE_INTERVAL = 100;
|
|
1300
1332
|
var SpaceAwarenessProvider = class {
|
|
1301
1333
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1315,7 +1347,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1315
1347
|
}
|
|
1316
1348
|
open() {
|
|
1317
1349
|
this._ctx = new Context2(void 0, {
|
|
1318
|
-
F:
|
|
1350
|
+
F: __dxlog_file6,
|
|
1319
1351
|
L: 57
|
|
1320
1352
|
});
|
|
1321
1353
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1342,10 +1374,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1342
1374
|
void this._messenger.postMessage(this._channel, {
|
|
1343
1375
|
kind: "query"
|
|
1344
1376
|
}).catch((err) => {
|
|
1345
|
-
|
|
1377
|
+
log5.debug("failed to query awareness", {
|
|
1346
1378
|
err
|
|
1347
1379
|
}, {
|
|
1348
|
-
F:
|
|
1380
|
+
F: __dxlog_file6,
|
|
1349
1381
|
L: 91,
|
|
1350
1382
|
S: this,
|
|
1351
1383
|
C: (f, a) => f(...a)
|
|
@@ -1362,7 +1394,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1362
1394
|
}
|
|
1363
1395
|
update(position) {
|
|
1364
1396
|
invariant(this._postTask, void 0, {
|
|
1365
|
-
F:
|
|
1397
|
+
F: __dxlog_file6,
|
|
1366
1398
|
L: 106,
|
|
1367
1399
|
S: this,
|
|
1368
1400
|
A: [
|
|
@@ -1379,7 +1411,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1379
1411
|
}
|
|
1380
1412
|
_handleQueryMessage() {
|
|
1381
1413
|
invariant(this._postTask, void 0, {
|
|
1382
|
-
F:
|
|
1414
|
+
F: __dxlog_file6,
|
|
1383
1415
|
L: 117,
|
|
1384
1416
|
S: this,
|
|
1385
1417
|
A: [
|
|
@@ -1391,7 +1423,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1391
1423
|
}
|
|
1392
1424
|
_handlePostMessage(message) {
|
|
1393
1425
|
invariant(message.kind === "post", void 0, {
|
|
1394
|
-
F:
|
|
1426
|
+
F: __dxlog_file6,
|
|
1395
1427
|
L: 122,
|
|
1396
1428
|
S: this,
|
|
1397
1429
|
A: [
|
|
@@ -1407,9 +1439,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1407
1439
|
// src/extensions/blast.ts
|
|
1408
1440
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1409
1441
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1410
|
-
import { throttle } from "@dxos/async";
|
|
1442
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1411
1443
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1412
|
-
var
|
|
1444
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1413
1445
|
var defaultOptions = {
|
|
1414
1446
|
effect: 2,
|
|
1415
1447
|
maxParticles: 200,
|
|
@@ -1528,7 +1560,7 @@ var Blaster = class {
|
|
|
1528
1560
|
}
|
|
1529
1561
|
initialize() {
|
|
1530
1562
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1531
|
-
F:
|
|
1563
|
+
F: __dxlog_file7,
|
|
1532
1564
|
L: 142,
|
|
1533
1565
|
S: this,
|
|
1534
1566
|
A: [
|
|
@@ -1565,7 +1597,7 @@ var Blaster = class {
|
|
|
1565
1597
|
}
|
|
1566
1598
|
start() {
|
|
1567
1599
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1568
|
-
F:
|
|
1600
|
+
F: __dxlog_file7,
|
|
1569
1601
|
L: 181,
|
|
1570
1602
|
S: this,
|
|
1571
1603
|
A: [
|
|
@@ -1599,11 +1631,11 @@ var Blaster = class {
|
|
|
1599
1631
|
this.drawParticles();
|
|
1600
1632
|
requestAnimationFrame(this.loop.bind(this));
|
|
1601
1633
|
}
|
|
1602
|
-
shake =
|
|
1634
|
+
shake = throttle2(({ time }) => {
|
|
1603
1635
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1604
1636
|
this._shakeTimeMax = time;
|
|
1605
1637
|
}, 100);
|
|
1606
|
-
spawn =
|
|
1638
|
+
spawn = throttle2(({ element, point }) => {
|
|
1607
1639
|
const color = getRGBComponents(element, this._options.color);
|
|
1608
1640
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1609
1641
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1777,11 +1809,11 @@ var blocks = () => [
|
|
|
1777
1809
|
".cm-line.block-line": {
|
|
1778
1810
|
paddingLeft: "0.75rem",
|
|
1779
1811
|
paddingRight: "0.75rem",
|
|
1780
|
-
borderLeft: "1px solid var(--
|
|
1781
|
-
borderRight: "1px solid var(--
|
|
1812
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1813
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1782
1814
|
},
|
|
1783
1815
|
".cm-line.block-single": {
|
|
1784
|
-
border: "1px solid var(--
|
|
1816
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1785
1817
|
borderRadius: "6px",
|
|
1786
1818
|
paddingTop: "0.5rem",
|
|
1787
1819
|
paddingBottom: "0.5rem",
|
|
@@ -1789,7 +1821,7 @@ var blocks = () => [
|
|
|
1789
1821
|
marginBottom: "0.5rem"
|
|
1790
1822
|
},
|
|
1791
1823
|
".cm-line.block-first": {
|
|
1792
|
-
borderTop: "1px solid var(--
|
|
1824
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1793
1825
|
borderTopLeftRadius: "6px",
|
|
1794
1826
|
borderTopRightRadius: "6px",
|
|
1795
1827
|
paddingTop: "0.5rem",
|
|
@@ -1797,7 +1829,7 @@ var blocks = () => [
|
|
|
1797
1829
|
},
|
|
1798
1830
|
".cm-line.block-middle": {},
|
|
1799
1831
|
".cm-line.block-last": {
|
|
1800
|
-
borderBottom: "1px solid var(--
|
|
1832
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1801
1833
|
borderBottomLeftRadius: "6px",
|
|
1802
1834
|
borderBottomRightRadius: "6px",
|
|
1803
1835
|
paddingBottom: "0.5rem",
|
|
@@ -1807,13 +1839,13 @@ var blocks = () => [
|
|
|
1807
1839
|
];
|
|
1808
1840
|
|
|
1809
1841
|
// src/extensions/bookmarks.ts
|
|
1810
|
-
import { Prec as Prec3, StateEffect as
|
|
1842
|
+
import { Prec as Prec3, StateEffect as StateEffect3, StateField as StateField2 } from "@codemirror/state";
|
|
1811
1843
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1812
|
-
import { log as
|
|
1813
|
-
var
|
|
1814
|
-
var addBookmark =
|
|
1815
|
-
var removeBookmark =
|
|
1816
|
-
var clearBookmarks =
|
|
1844
|
+
import { log as log6 } from "@dxos/log";
|
|
1845
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1846
|
+
var addBookmark = StateEffect3.define();
|
|
1847
|
+
var removeBookmark = StateEffect3.define();
|
|
1848
|
+
var clearBookmarks = StateEffect3.define();
|
|
1817
1849
|
var bookmarks = () => {
|
|
1818
1850
|
return [
|
|
1819
1851
|
bookmarksField,
|
|
@@ -1822,8 +1854,8 @@ var bookmarks = () => {
|
|
|
1822
1854
|
key: "Mod-ArrowUp",
|
|
1823
1855
|
run: (view) => {
|
|
1824
1856
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1825
|
-
|
|
1826
|
-
F:
|
|
1857
|
+
log6("up", bookmarks2, {
|
|
1858
|
+
F: __dxlog_file8,
|
|
1827
1859
|
L: 29,
|
|
1828
1860
|
S: void 0,
|
|
1829
1861
|
C: (f, a) => f(...a)
|
|
@@ -1835,8 +1867,8 @@ var bookmarks = () => {
|
|
|
1835
1867
|
key: "Mod-ArrowDown",
|
|
1836
1868
|
run: (view) => {
|
|
1837
1869
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1838
|
-
|
|
1839
|
-
F:
|
|
1870
|
+
log6("down", bookmarks2, {
|
|
1871
|
+
F: __dxlog_file8,
|
|
1840
1872
|
L: 37,
|
|
1841
1873
|
S: void 0,
|
|
1842
1874
|
C: (f, a) => f(...a)
|
|
@@ -1877,22 +1909,22 @@ var bookmarksField = StateField2.define({
|
|
|
1877
1909
|
|
|
1878
1910
|
// src/extensions/comments.ts
|
|
1879
1911
|
import { invertedEffects } from "@codemirror/commands";
|
|
1880
|
-
import { StateEffect as
|
|
1912
|
+
import { StateEffect as StateEffect4, StateField as StateField3 } from "@codemirror/state";
|
|
1881
1913
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1882
1914
|
import sortBy from "lodash.sortby";
|
|
1883
|
-
import { debounce as
|
|
1884
|
-
import { log as
|
|
1915
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1916
|
+
import { log as log7 } from "@dxos/log";
|
|
1885
1917
|
import { isNonNullable } from "@dxos/util";
|
|
1886
1918
|
|
|
1887
1919
|
// src/extensions/selection.ts
|
|
1888
1920
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1889
1921
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1890
|
-
import { debounce
|
|
1922
|
+
import { debounce } from "@dxos/async";
|
|
1891
1923
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1892
1924
|
import { isTruthy } from "@dxos/util";
|
|
1893
|
-
var
|
|
1925
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1894
1926
|
var documentId = singleValueFacet();
|
|
1895
|
-
var stateRestoreAnnotation = "dxos.
|
|
1927
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1896
1928
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1897
1929
|
return {
|
|
1898
1930
|
selection,
|
|
@@ -1906,7 +1938,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1906
1938
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1907
1939
|
getState: (id) => {
|
|
1908
1940
|
invariant3(id, void 0, {
|
|
1909
|
-
F:
|
|
1941
|
+
F: __dxlog_file9,
|
|
1910
1942
|
L: 47,
|
|
1911
1943
|
S: void 0,
|
|
1912
1944
|
A: [
|
|
@@ -1919,7 +1951,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1919
1951
|
},
|
|
1920
1952
|
setState: (id, state) => {
|
|
1921
1953
|
invariant3(id, void 0, {
|
|
1922
|
-
F:
|
|
1954
|
+
F: __dxlog_file9,
|
|
1923
1955
|
L: 53,
|
|
1924
1956
|
S: void 0,
|
|
1925
1957
|
A: [
|
|
@@ -1931,7 +1963,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1931
1963
|
}
|
|
1932
1964
|
});
|
|
1933
1965
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1934
|
-
const setStateDebounced =
|
|
1966
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1935
1967
|
return [
|
|
1936
1968
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1937
1969
|
// EditorView.domEventHandlers({
|
|
@@ -1978,10 +2010,10 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1978
2010
|
};
|
|
1979
2011
|
|
|
1980
2012
|
// src/extensions/comments.ts
|
|
1981
|
-
var
|
|
1982
|
-
var setComments =
|
|
1983
|
-
var setSelection =
|
|
1984
|
-
var setCommentState =
|
|
2013
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
2014
|
+
var setComments = StateEffect4.define();
|
|
2015
|
+
var setSelection = StateEffect4.define();
|
|
2016
|
+
var setCommentState = StateEffect4.define();
|
|
1985
2017
|
var commentsState = StateField3.define({
|
|
1986
2018
|
create: (state) => ({
|
|
1987
2019
|
id: state.facet(documentId),
|
|
@@ -2023,14 +2055,14 @@ var commentsState = StateField3.define({
|
|
|
2023
2055
|
var styles2 = EditorView11.theme({
|
|
2024
2056
|
".cm-comment, .cm-comment-current": {
|
|
2025
2057
|
padding: "3px 0",
|
|
2026
|
-
color: "var(--
|
|
2027
|
-
backgroundColor: "var(--
|
|
2058
|
+
color: "var(--color-cm-comment-text)",
|
|
2059
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2028
2060
|
},
|
|
2029
2061
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2030
2062
|
boxDecorationBreak: "clone",
|
|
2031
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2032
|
-
backgroundColor: "var(--
|
|
2033
|
-
color: "var(--
|
|
2063
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2064
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2065
|
+
color: "var(--color-cm-comment-text)",
|
|
2034
2066
|
cursor: "pointer"
|
|
2035
2067
|
}
|
|
2036
2068
|
});
|
|
@@ -2048,8 +2080,8 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2048
2080
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2049
2081
|
const range = comment.range;
|
|
2050
2082
|
if (!range) {
|
|
2051
|
-
|
|
2052
|
-
F:
|
|
2083
|
+
log7.warn("Invalid range:", range, {
|
|
2084
|
+
F: __dxlog_file10,
|
|
2053
2085
|
L: 140,
|
|
2054
2086
|
S: void 0,
|
|
2055
2087
|
C: (f, a) => f(...a)
|
|
@@ -2063,7 +2095,7 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2063
2095
|
}).filter(isNonNullable);
|
|
2064
2096
|
return Decoration7.set(decorations2);
|
|
2065
2097
|
});
|
|
2066
|
-
var commentClickedEffect =
|
|
2098
|
+
var commentClickedEffect = StateEffect4.define();
|
|
2067
2099
|
var handleCommentClick = EditorView11.domEventHandlers({
|
|
2068
2100
|
click: (event, view) => {
|
|
2069
2101
|
let target = event.target;
|
|
@@ -2181,7 +2213,7 @@ var mapTrackedComment = (comment, changes) => ({
|
|
|
2181
2213
|
from: changes.mapPos(comment.from, 1),
|
|
2182
2214
|
to: changes.mapPos(comment.to, 1)
|
|
2183
2215
|
});
|
|
2184
|
-
var restoreCommentEffect =
|
|
2216
|
+
var restoreCommentEffect = StateEffect4.define({
|
|
2185
2217
|
map: mapTrackedComment
|
|
2186
2218
|
});
|
|
2187
2219
|
var createComment = (view) => {
|
|
@@ -2215,7 +2247,7 @@ var createComment = (view) => {
|
|
|
2215
2247
|
var optionsFacet = singleValueFacet();
|
|
2216
2248
|
var comments = (options = {}) => {
|
|
2217
2249
|
const { key: shortcut = "meta-'" } = options;
|
|
2218
|
-
const handleSelect =
|
|
2250
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2219
2251
|
return [
|
|
2220
2252
|
optionsFacet.of(options),
|
|
2221
2253
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2393,9 +2425,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2393
2425
|
// src/extensions/debug.ts
|
|
2394
2426
|
import { syntaxTree } from "@codemirror/language";
|
|
2395
2427
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2396
|
-
var debugNodeLogger = (
|
|
2428
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2397
2429
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2398
|
-
enter: (node) =>
|
|
2430
|
+
enter: (node) => log12(node.type)
|
|
2399
2431
|
});
|
|
2400
2432
|
return StateField4.define({
|
|
2401
2433
|
create: (state) => logTokens(state),
|
|
@@ -2430,8 +2462,8 @@ var dropFile = (options = {}) => {
|
|
|
2430
2462
|
};
|
|
2431
2463
|
var styles3 = EditorView12.theme({
|
|
2432
2464
|
".cm-dropCursor": {
|
|
2433
|
-
borderLeft: "2px solid var(--
|
|
2434
|
-
color: "var(--
|
|
2465
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2466
|
+
color: "var(--color-accent-text)",
|
|
2435
2467
|
padding: "0 4px"
|
|
2436
2468
|
},
|
|
2437
2469
|
".cm-dropCursor:after": {
|
|
@@ -2445,47 +2477,66 @@ import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap }
|
|
|
2445
2477
|
import { HighlightStyle, bracketMatching, syntaxHighlighting } from "@codemirror/language";
|
|
2446
2478
|
import { searchKeymap } from "@codemirror/search";
|
|
2447
2479
|
import { EditorState } from "@codemirror/state";
|
|
2448
|
-
import { EditorView as
|
|
2480
|
+
import { EditorView as EditorView16, ViewPlugin as ViewPlugin12, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap7, lineNumbers, placeholder as placeholder2 } from "@codemirror/view";
|
|
2449
2481
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2450
2482
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2451
2483
|
import { generateName } from "@dxos/display-name";
|
|
2452
|
-
import { log as
|
|
2484
|
+
import { log as log8 } from "@dxos/log";
|
|
2453
2485
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2454
2486
|
|
|
2455
|
-
// src/styles/
|
|
2487
|
+
// src/styles/theme.ts
|
|
2488
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2456
2489
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2457
2490
|
var headings = {
|
|
2458
|
-
1:
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2491
|
+
1: {
|
|
2492
|
+
className: "text-3xl",
|
|
2493
|
+
fontSize: "var(--text-3xl)",
|
|
2494
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2495
|
+
},
|
|
2496
|
+
2: {
|
|
2497
|
+
className: "text-2xl",
|
|
2498
|
+
fontSize: "var(--text-2xl)",
|
|
2499
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2500
|
+
},
|
|
2501
|
+
3: {
|
|
2502
|
+
className: "text-xl",
|
|
2503
|
+
fontSize: "var(--text-xl)",
|
|
2504
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2505
|
+
},
|
|
2506
|
+
4: {
|
|
2507
|
+
className: "text-lg",
|
|
2508
|
+
fontSize: "var(--text-lg)",
|
|
2509
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2510
|
+
},
|
|
2511
|
+
5: {
|
|
2512
|
+
className: "text-base",
|
|
2513
|
+
fontSize: "var(--text-base)",
|
|
2514
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2515
|
+
},
|
|
2516
|
+
6: {
|
|
2517
|
+
className: "text-base",
|
|
2518
|
+
fontSize: "var(--text-base)",
|
|
2519
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2520
|
+
}
|
|
2464
2521
|
};
|
|
2522
|
+
var fontBody = '"Inter Variable", ui-sans-serif, system-ui, sans-serif';
|
|
2523
|
+
var fontMono = '"JetBrains Mono Variable", ui-monospace, "Cascadia Code", "Source Code Pro", monospace';
|
|
2465
2524
|
var markdownTheme = {
|
|
2466
|
-
code: "font-mono
|
|
2467
|
-
codeMark: "font-mono
|
|
2468
|
-
mark: "
|
|
2469
|
-
heading: (level) => {
|
|
2470
|
-
|
|
2471
|
-
|
|
2525
|
+
code: "font-mono! cm-code-inline",
|
|
2526
|
+
codeMark: "font-mono! cm-code-mark",
|
|
2527
|
+
mark: "font-mono!",
|
|
2528
|
+
heading: (level) => ({
|
|
2529
|
+
className: mx3(headings[level].className, "font-light text-(--color-cm-heading-number)"),
|
|
2530
|
+
color: "var(--color-cm-heading) !important",
|
|
2531
|
+
lineHeight: headings[level].lineHeight,
|
|
2532
|
+
fontSize: headings[level].fontSize,
|
|
2533
|
+
fontWeight: "100 !important"
|
|
2534
|
+
})
|
|
2472
2535
|
};
|
|
2473
|
-
|
|
2474
|
-
// src/styles/theme.ts
|
|
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
|
|
2488
2536
|
var baseTheme = EditorView13.baseTheme({
|
|
2537
|
+
/**
|
|
2538
|
+
* Outer frame.
|
|
2539
|
+
*/
|
|
2489
2540
|
"&": {},
|
|
2490
2541
|
"&.cm-focused": {
|
|
2491
2542
|
outline: "none"
|
|
@@ -2494,7 +2545,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2494
2545
|
* Scroller
|
|
2495
2546
|
*/
|
|
2496
2547
|
".cm-scroller": {
|
|
2497
|
-
|
|
2548
|
+
overflowAnchor: "none"
|
|
2549
|
+
},
|
|
2550
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2551
|
+
width: "8px"
|
|
2552
|
+
},
|
|
2553
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2554
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2555
|
+
background: "transparent",
|
|
2556
|
+
transition: "background 0.15s"
|
|
2557
|
+
},
|
|
2558
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2559
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2498
2560
|
},
|
|
2499
2561
|
/**
|
|
2500
2562
|
* Content
|
|
@@ -2502,7 +2564,6 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2502
2564
|
*/
|
|
2503
2565
|
".cm-content": {
|
|
2504
2566
|
padding: "unset",
|
|
2505
|
-
lineHeight: "24px",
|
|
2506
2567
|
color: "unset"
|
|
2507
2568
|
},
|
|
2508
2569
|
/**
|
|
@@ -2516,8 +2577,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2516
2577
|
".cm-gutter": {},
|
|
2517
2578
|
".cm-gutter.cm-lineNumbers": {
|
|
2518
2579
|
paddingRight: "4px",
|
|
2519
|
-
borderRight: "1px solid var(--
|
|
2520
|
-
color: "var(--
|
|
2580
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2581
|
+
color: "var(--color-subdued)"
|
|
2521
2582
|
},
|
|
2522
2583
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2523
2584
|
minWidth: "40px"
|
|
@@ -2526,36 +2587,43 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2526
2587
|
* Height is set to match the corresponding line (which may have wrapped).
|
|
2527
2588
|
*/
|
|
2528
2589
|
".cm-gutterElement": {
|
|
2529
|
-
lineHeight:
|
|
2590
|
+
lineHeight: 1.5,
|
|
2530
2591
|
fontSize: "12px"
|
|
2531
2592
|
},
|
|
2532
2593
|
/**
|
|
2533
2594
|
* Line.
|
|
2534
2595
|
*/
|
|
2535
2596
|
".cm-line": {
|
|
2536
|
-
lineHeight:
|
|
2597
|
+
lineHeight: 1.5,
|
|
2537
2598
|
paddingInline: 0
|
|
2538
2599
|
},
|
|
2600
|
+
/**
|
|
2601
|
+
* Force all inline children to inherit line-height to prevent monospace font metrics
|
|
2602
|
+
* (JetBrains Mono ascent/descent) from inflating the line box beyond 24px.
|
|
2603
|
+
*/
|
|
2604
|
+
".cm-line *": {
|
|
2605
|
+
lineHeight: "inherit"
|
|
2606
|
+
},
|
|
2539
2607
|
".cm-activeLine": {
|
|
2540
|
-
background: "var(--
|
|
2608
|
+
background: "var(--color-cm-active-line)"
|
|
2541
2609
|
},
|
|
2542
2610
|
/**
|
|
2543
2611
|
* Cursor (layer).
|
|
2544
2612
|
*/
|
|
2545
2613
|
".cm-cursor, .cm-dropCursor": {
|
|
2546
|
-
borderLeft: "2px solid var(--
|
|
2614
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2547
2615
|
},
|
|
2548
2616
|
".cm-placeholder": {
|
|
2549
|
-
color: "var(--
|
|
2617
|
+
color: "var(--color-placeholder)"
|
|
2550
2618
|
},
|
|
2551
2619
|
/**
|
|
2552
2620
|
* Selection (layer).
|
|
2553
2621
|
*/
|
|
2554
2622
|
".cm-selectionBackground": {
|
|
2555
|
-
background: "var(--
|
|
2623
|
+
background: "var(--color-cm-selection)"
|
|
2556
2624
|
},
|
|
2557
2625
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2558
|
-
background: "var(--
|
|
2626
|
+
background: "var(--color-cm-focused-selection)"
|
|
2559
2627
|
},
|
|
2560
2628
|
/**
|
|
2561
2629
|
* Search.
|
|
@@ -2565,8 +2633,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2565
2633
|
margin: "0 -3px",
|
|
2566
2634
|
padding: "3px",
|
|
2567
2635
|
borderRadius: "3px",
|
|
2568
|
-
background: "var(--
|
|
2569
|
-
color: "var(--
|
|
2636
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2637
|
+
color: "var(--color-cm-highlight)"
|
|
2570
2638
|
},
|
|
2571
2639
|
".cm-searchMatch-selected": {
|
|
2572
2640
|
textDecoration: "underline"
|
|
@@ -2577,20 +2645,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2577
2645
|
".cm-link": {
|
|
2578
2646
|
textDecorationLine: "underline",
|
|
2579
2647
|
textDecorationThickness: "1px",
|
|
2580
|
-
textDecorationColor: "var(--
|
|
2648
|
+
textDecorationColor: "var(--color-separator)",
|
|
2581
2649
|
textUnderlineOffset: "2px",
|
|
2582
2650
|
borderRadius: ".125rem"
|
|
2583
2651
|
},
|
|
2584
2652
|
".cm-link > span": {
|
|
2585
|
-
color: "var(--
|
|
2653
|
+
color: "var(--color-accent-text)"
|
|
2654
|
+
},
|
|
2655
|
+
".cm-link > span:hover": {
|
|
2656
|
+
color: "var(--color-accent-text-hover)"
|
|
2586
2657
|
},
|
|
2587
2658
|
/**
|
|
2588
2659
|
* Tooltip.
|
|
2589
2660
|
*/
|
|
2590
2661
|
".cm-tooltip": {
|
|
2591
|
-
background: "var(--
|
|
2662
|
+
background: "var(--color-modal-surface)"
|
|
2592
2663
|
},
|
|
2593
2664
|
".cm-tooltip-below": {},
|
|
2665
|
+
".cm-tooltip-hover": {
|
|
2666
|
+
background: "var(--color-modal-surface)",
|
|
2667
|
+
border: "1px solid var(--color-separator)",
|
|
2668
|
+
borderRadius: "4px",
|
|
2669
|
+
overflow: "hidden"
|
|
2670
|
+
},
|
|
2594
2671
|
/**
|
|
2595
2672
|
* Autocomplete.
|
|
2596
2673
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2598,7 +2675,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2598
2675
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2599
2676
|
marginTop: "6px",
|
|
2600
2677
|
marginLeft: "-10px",
|
|
2601
|
-
border: "2px solid var(--
|
|
2678
|
+
border: "2px solid var(--color-separator)",
|
|
2602
2679
|
borderRadius: "4px"
|
|
2603
2680
|
},
|
|
2604
2681
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2608,12 +2685,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2608
2685
|
padding: "4px"
|
|
2609
2686
|
},
|
|
2610
2687
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2611
|
-
background: "var(--
|
|
2612
|
-
color: "var(--
|
|
2688
|
+
background: "var(--color-active-surface)",
|
|
2689
|
+
color: "var(--color-base-surface-text)"
|
|
2613
2690
|
},
|
|
2614
2691
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2615
2692
|
paddingLeft: "4px !important",
|
|
2616
|
-
color: "var(--
|
|
2693
|
+
color: "var(--color-base-surface-text)"
|
|
2617
2694
|
},
|
|
2618
2695
|
/**
|
|
2619
2696
|
* Completion info.
|
|
@@ -2622,17 +2699,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2622
2699
|
width: "360px !important",
|
|
2623
2700
|
margin: "-10px 1px 0 1px",
|
|
2624
2701
|
padding: "8px !important",
|
|
2625
|
-
borderColor: "var(--
|
|
2702
|
+
borderColor: "var(--color-separator)"
|
|
2626
2703
|
},
|
|
2627
2704
|
".cm-completionIcon": {
|
|
2628
2705
|
display: "none"
|
|
2629
2706
|
},
|
|
2630
2707
|
".cm-completionLabel": {
|
|
2631
|
-
color: "var(--
|
|
2708
|
+
color: "var(--color-description)",
|
|
2632
2709
|
padding: "0 4px"
|
|
2633
2710
|
},
|
|
2634
2711
|
".cm-completionMatchedText": {
|
|
2635
|
-
color: "var(--
|
|
2712
|
+
color: "var(--color-base-surface-text)",
|
|
2636
2713
|
textDecoration: "none !important"
|
|
2637
2714
|
},
|
|
2638
2715
|
/**
|
|
@@ -2656,7 +2733,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2656
2733
|
backgroundColor: "var(--surface-bg)"
|
|
2657
2734
|
},
|
|
2658
2735
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2659
|
-
color: "var(--
|
|
2736
|
+
color: "var(--color-subdued)",
|
|
2660
2737
|
fontSize: "14px",
|
|
2661
2738
|
all: "unset",
|
|
2662
2739
|
margin: "3px !important",
|
|
@@ -2664,10 +2741,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2664
2741
|
outline: "1px solid transparent"
|
|
2665
2742
|
},
|
|
2666
2743
|
".cm-panel input, .cm-panel button": {
|
|
2667
|
-
backgroundColor: "var(--
|
|
2744
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2668
2745
|
},
|
|
2669
2746
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2670
|
-
outline: "1px solid var(--
|
|
2747
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2671
2748
|
},
|
|
2672
2749
|
".cm-panel label": {
|
|
2673
2750
|
display: "inline-flex",
|
|
@@ -2680,33 +2757,33 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2680
2757
|
height: "8px",
|
|
2681
2758
|
marginRight: "6px !important",
|
|
2682
2759
|
padding: "2px !important",
|
|
2683
|
-
color: "var(--
|
|
2760
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2684
2761
|
},
|
|
2685
2762
|
".cm-panel button": {
|
|
2686
2763
|
"&:hover": {
|
|
2687
|
-
|
|
2764
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2765
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2688
2766
|
},
|
|
2689
2767
|
"&:active": {
|
|
2690
|
-
backgroundColor: "var(--
|
|
2768
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2691
2769
|
}
|
|
2692
2770
|
},
|
|
2693
2771
|
".cm-panel.cm-search": {
|
|
2694
2772
|
padding: "4px",
|
|
2695
|
-
borderTop: "1px solid var(--
|
|
2773
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2696
2774
|
}
|
|
2697
2775
|
});
|
|
2698
2776
|
var editorGutter = EditorView13.theme({
|
|
2699
2777
|
".cm-gutters": {
|
|
2700
2778
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2701
|
-
background: "var(--
|
|
2779
|
+
background: "var(--color-base-surface) !important",
|
|
2702
2780
|
paddingRight: "1rem"
|
|
2703
2781
|
}
|
|
2704
2782
|
});
|
|
2705
2783
|
var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
2706
|
-
//
|
|
2784
|
+
// Main content.
|
|
2707
2785
|
".cm-scroller": {
|
|
2708
|
-
fontFamily: monospace ? fontMono : fontBody
|
|
2709
|
-
fontSize: "16px"
|
|
2786
|
+
fontFamily: monospace ? fontMono : fontBody
|
|
2710
2787
|
},
|
|
2711
2788
|
// Maintain defaults for UI components.
|
|
2712
2789
|
".cm-content, .cm-gutters, .cm-panel": {
|
|
@@ -2716,9 +2793,9 @@ var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
|
2716
2793
|
});
|
|
2717
2794
|
|
|
2718
2795
|
// src/extensions/focus.ts
|
|
2719
|
-
import { StateEffect as
|
|
2796
|
+
import { StateEffect as StateEffect5, StateField as StateField5 } from "@codemirror/state";
|
|
2720
2797
|
import { EditorView as EditorView14 } from "@codemirror/view";
|
|
2721
|
-
var focusEffect =
|
|
2798
|
+
var focusEffect = StateEffect5.define();
|
|
2722
2799
|
var focusField = StateField5.define({
|
|
2723
2800
|
create: () => false,
|
|
2724
2801
|
update: (value, tr) => {
|
|
@@ -2746,9 +2823,32 @@ var focus = [
|
|
|
2746
2823
|
})
|
|
2747
2824
|
];
|
|
2748
2825
|
|
|
2826
|
+
// src/extensions/scroll-past-end.ts
|
|
2827
|
+
import { EditorView as EditorView15, ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
|
2828
|
+
var scrollPastEndPlugin = ViewPlugin11.fromClass(class {
|
|
2829
|
+
height = 1e3;
|
|
2830
|
+
attrs = {
|
|
2831
|
+
style: "padding-bottom: 1000px"
|
|
2832
|
+
};
|
|
2833
|
+
update({ view }) {
|
|
2834
|
+
const lastLineBlock = view.lineBlockAt(view.state.doc.length);
|
|
2835
|
+
const height = view.dom.clientHeight - lastLineBlock.height - view.documentPadding.top - 0.5;
|
|
2836
|
+
if (height >= 0 && height !== this.height) {
|
|
2837
|
+
this.height = height;
|
|
2838
|
+
this.attrs = {
|
|
2839
|
+
style: `padding-bottom: ${height}px`
|
|
2840
|
+
};
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2844
|
+
var scrollPastEnd = () => [
|
|
2845
|
+
scrollPastEndPlugin,
|
|
2846
|
+
EditorView15.contentAttributes.of((view) => view.plugin(scrollPastEndPlugin)?.attrs ?? null)
|
|
2847
|
+
];
|
|
2848
|
+
|
|
2749
2849
|
// src/extensions/factories.ts
|
|
2750
|
-
var
|
|
2751
|
-
var tabbable =
|
|
2850
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2851
|
+
var tabbable = EditorView16.contentAttributes.of({
|
|
2752
2852
|
tabindex: "0"
|
|
2753
2853
|
});
|
|
2754
2854
|
var filterChars = (chars) => {
|
|
@@ -2801,10 +2901,10 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2801
2901
|
const props = defaultsDeep2({}, propsProp, defaultBasicOptions);
|
|
2802
2902
|
return [
|
|
2803
2903
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
F:
|
|
2807
|
-
L:
|
|
2904
|
+
EditorView16.exceptionSink.of((err) => {
|
|
2905
|
+
log8.catch(err, void 0, {
|
|
2906
|
+
F: __dxlog_file11,
|
|
2907
|
+
L: 131,
|
|
2808
2908
|
S: void 0,
|
|
2809
2909
|
C: (f, a) => f(...a)
|
|
2810
2910
|
});
|
|
@@ -2816,7 +2916,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2816
2916
|
props.drawSelection && drawSelection({
|
|
2817
2917
|
cursorBlinkRate: 1200
|
|
2818
2918
|
}),
|
|
2819
|
-
props.editable !== void 0 &&
|
|
2919
|
+
props.editable !== void 0 && EditorView16.editable.of(props.editable),
|
|
2820
2920
|
props.focus && focus,
|
|
2821
2921
|
props.highlightActiveLine && highlightActiveLine(),
|
|
2822
2922
|
props.history && history(),
|
|
@@ -2824,7 +2924,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2824
2924
|
lineNumbers(),
|
|
2825
2925
|
editorGutter
|
|
2826
2926
|
],
|
|
2827
|
-
props.lineWrapping &&
|
|
2927
|
+
props.lineWrapping && EditorView16.lineWrapping,
|
|
2828
2928
|
props.placeholder && placeholder2(props.placeholder),
|
|
2829
2929
|
props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
|
|
2830
2930
|
props.scrollPastEnd && scrollPastEnd(),
|
|
@@ -2856,12 +2956,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2856
2956
|
};
|
|
2857
2957
|
var grow = {
|
|
2858
2958
|
editor: {
|
|
2859
|
-
className: "
|
|
2959
|
+
className: "h-full w-full"
|
|
2860
2960
|
}
|
|
2861
2961
|
};
|
|
2862
2962
|
var fullWidth = {
|
|
2863
2963
|
editor: {
|
|
2864
|
-
className: "
|
|
2964
|
+
className: "w-full"
|
|
2865
2965
|
}
|
|
2866
2966
|
};
|
|
2867
2967
|
var defaultThemeSlots = grow;
|
|
@@ -2873,18 +2973,18 @@ var createThemeExtensions = ({ monospace, themeMode, slots: slotsProp, syntaxHig
|
|
|
2873
2973
|
const slots = defaultsDeep2({}, slotsProp, defaultThemeSlots);
|
|
2874
2974
|
return [
|
|
2875
2975
|
baseTheme,
|
|
2876
|
-
|
|
2976
|
+
EditorView16.darkTheme.of(themeMode === "dark"),
|
|
2877
2977
|
createFontTheme({
|
|
2878
2978
|
monospace
|
|
2879
2979
|
}),
|
|
2880
2980
|
syntaxHighlightingProp && syntaxHighlighting(HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light)),
|
|
2881
|
-
slots.editor?.className &&
|
|
2981
|
+
slots.editor?.className && EditorView16.editorAttributes.of({
|
|
2882
2982
|
class: slots.editor.className
|
|
2883
2983
|
}),
|
|
2884
|
-
slots.content?.className &&
|
|
2984
|
+
slots.content?.className && EditorView16.contentAttributes.of({
|
|
2885
2985
|
class: slots.content.className
|
|
2886
2986
|
}),
|
|
2887
|
-
slots.scroll?.className &&
|
|
2987
|
+
slots.scroll?.className && ViewPlugin12.fromClass(class {
|
|
2888
2988
|
constructor(view) {
|
|
2889
2989
|
view.scrollDOM.classList.add(...slots.scroll.className.split(/\s+/));
|
|
2890
2990
|
}
|
|
@@ -2904,8 +3004,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2904
3004
|
channel: `awareness.${id}`,
|
|
2905
3005
|
peerId: identity.identityKey.toHex(),
|
|
2906
3006
|
info: {
|
|
2907
|
-
darkColor: `var(--
|
|
2908
|
-
lightColor: `var(--
|
|
3007
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
3008
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2909
3009
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2910
3010
|
}
|
|
2911
3011
|
})));
|
|
@@ -2915,7 +3015,7 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2915
3015
|
|
|
2916
3016
|
// src/extensions/folding.ts
|
|
2917
3017
|
import { codeFolding, foldGutter } from "@codemirror/language";
|
|
2918
|
-
import { EditorView as
|
|
3018
|
+
import { EditorView as EditorView17 } from "@codemirror/view";
|
|
2919
3019
|
import { Domino as Domino2, mx as mx4 } from "@dxos/ui";
|
|
2920
3020
|
var folding = () => {
|
|
2921
3021
|
return [
|
|
@@ -2923,13 +3023,14 @@ var folding = () => {
|
|
|
2923
3023
|
placeholderDOM: () => Domino2.of("span").root
|
|
2924
3024
|
}),
|
|
2925
3025
|
foldGutter({
|
|
3026
|
+
// NOTE: We can't animate since the element is remounted on state change.
|
|
2926
3027
|
markerDOM: (open) => {
|
|
2927
|
-
return Domino2.of("div").classNames("flex
|
|
3028
|
+
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
3029
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2929
3030
|
}))).root;
|
|
2930
3031
|
}
|
|
2931
3032
|
}),
|
|
2932
|
-
|
|
3033
|
+
EditorView17.theme({
|
|
2933
3034
|
".cm-foldGutter": {
|
|
2934
3035
|
opacity: 0.3,
|
|
2935
3036
|
transition: "opacity 0.3s",
|
|
@@ -2943,7 +3044,7 @@ var folding = () => {
|
|
|
2943
3044
|
};
|
|
2944
3045
|
|
|
2945
3046
|
// src/extensions/hashtag.ts
|
|
2946
|
-
import { Decoration as Decoration8, EditorView as
|
|
3047
|
+
import { Decoration as Decoration8, EditorView as EditorView18, MatchDecorator, ViewPlugin as ViewPlugin13, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
2947
3048
|
import { getHashStyles, mx as mx5 } from "@dxos/ui-theme";
|
|
2948
3049
|
var TagWidget = class extends WidgetType4 {
|
|
2949
3050
|
_text;
|
|
@@ -2964,7 +3065,7 @@ var tagMatcher = new MatchDecorator({
|
|
|
2964
3065
|
})
|
|
2965
3066
|
});
|
|
2966
3067
|
var hashtag = () => [
|
|
2967
|
-
|
|
3068
|
+
ViewPlugin13.fromClass(class {
|
|
2968
3069
|
tags;
|
|
2969
3070
|
constructor(view) {
|
|
2970
3071
|
this.tags = tagMatcher.createDeco(view);
|
|
@@ -2974,11 +3075,11 @@ var hashtag = () => [
|
|
|
2974
3075
|
}
|
|
2975
3076
|
}, {
|
|
2976
3077
|
decorations: (instance) => instance.tags,
|
|
2977
|
-
provide: (plugin) =>
|
|
3078
|
+
provide: (plugin) => EditorView18.atomicRanges.of((view) => {
|
|
2978
3079
|
return view.plugin(plugin)?.tags || Decoration8.none;
|
|
2979
3080
|
})
|
|
2980
3081
|
}),
|
|
2981
|
-
|
|
3082
|
+
EditorView18.theme({
|
|
2982
3083
|
".cm-tag": {
|
|
2983
3084
|
borderRadius: "4px",
|
|
2984
3085
|
marginRight: "6px",
|
|
@@ -3033,18 +3134,18 @@ var schemaLinter = (validate) => (view) => {
|
|
|
3033
3134
|
};
|
|
3034
3135
|
|
|
3035
3136
|
// src/extensions/listener.ts
|
|
3036
|
-
import { EditorView as
|
|
3137
|
+
import { EditorView as EditorView19 } from "@codemirror/view";
|
|
3037
3138
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
3038
3139
|
var listener = ({ onFocus, onChange }) => {
|
|
3039
3140
|
return [
|
|
3040
|
-
onFocus &&
|
|
3141
|
+
onFocus && EditorView19.focusChangeEffect.of((state, focusing) => {
|
|
3041
3142
|
onFocus({
|
|
3042
3143
|
id: state.facet(documentId),
|
|
3043
3144
|
focusing
|
|
3044
3145
|
});
|
|
3045
3146
|
return null;
|
|
3046
3147
|
}),
|
|
3047
|
-
onChange &&
|
|
3148
|
+
onChange && EditorView19.updateListener.of(({ state, docChanged }) => {
|
|
3048
3149
|
if (docChanged) {
|
|
3049
3150
|
onChange({
|
|
3050
3151
|
id: state.facet(documentId),
|
|
@@ -3059,7 +3160,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
|
3059
3160
|
import { snippet } from "@codemirror/autocomplete";
|
|
3060
3161
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
3061
3162
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
|
3062
|
-
import { EditorView as
|
|
3163
|
+
import { EditorView as EditorView20, keymap as keymap8 } from "@codemirror/view";
|
|
3063
3164
|
import { debounceAndThrottle } from "@dxos/async";
|
|
3064
3165
|
var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
|
|
3065
3166
|
var Inline = /* @__PURE__ */ (function(Inline2) {
|
|
@@ -4148,7 +4249,7 @@ var getFormatting = (state) => {
|
|
|
4148
4249
|
};
|
|
4149
4250
|
};
|
|
4150
4251
|
var formattingListener = (onStateChange, delay = 100) => {
|
|
4151
|
-
return
|
|
4252
|
+
return EditorView20.updateListener.of(debounceAndThrottle((update2) => {
|
|
4152
4253
|
if (update2.docChanged || update2.selectionSet) {
|
|
4153
4254
|
onStateChange(getFormatting(update2.state));
|
|
4154
4255
|
}
|
|
@@ -4209,8 +4310,7 @@ import { completionKeymap } from "@codemirror/autocomplete";
|
|
|
4209
4310
|
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
|
4210
4311
|
import { jsonLanguage } from "@codemirror/lang-json";
|
|
4211
4312
|
import { markdown, markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
|
|
4212
|
-
import {
|
|
4213
|
-
import { LanguageDescription, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4313
|
+
import { foldNodeProp, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4214
4314
|
import { languages } from "@codemirror/language-data";
|
|
4215
4315
|
import { keymap as keymap9 } from "@codemirror/view";
|
|
4216
4316
|
import { isTruthy as isTruthy3 } from "@dxos/util";
|
|
@@ -4331,30 +4431,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4331
4431
|
],
|
|
4332
4432
|
class: "font-mono"
|
|
4333
4433
|
},
|
|
4334
|
-
// Headings
|
|
4434
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4435
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4436
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4437
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4438
|
+
{
|
|
4439
|
+
tag: tags.heading,
|
|
4440
|
+
color: "var(--color-cm-heading) !important",
|
|
4441
|
+
fontWeight: "300"
|
|
4442
|
+
},
|
|
4335
4443
|
{
|
|
4336
4444
|
tag: tags.heading1,
|
|
4337
|
-
|
|
4445
|
+
...markdownTheme.heading(1)
|
|
4338
4446
|
},
|
|
4339
4447
|
{
|
|
4340
4448
|
tag: tags.heading2,
|
|
4341
|
-
|
|
4449
|
+
...markdownTheme.heading(2)
|
|
4342
4450
|
},
|
|
4343
4451
|
{
|
|
4344
4452
|
tag: tags.heading3,
|
|
4345
|
-
|
|
4453
|
+
...markdownTheme.heading(3)
|
|
4346
4454
|
},
|
|
4347
4455
|
{
|
|
4348
4456
|
tag: tags.heading4,
|
|
4349
|
-
|
|
4457
|
+
...markdownTheme.heading(4)
|
|
4350
4458
|
},
|
|
4351
4459
|
{
|
|
4352
4460
|
tag: tags.heading5,
|
|
4353
|
-
|
|
4461
|
+
...markdownTheme.heading(5)
|
|
4354
4462
|
},
|
|
4355
4463
|
{
|
|
4356
4464
|
tag: tags.heading6,
|
|
4357
|
-
|
|
4465
|
+
...markdownTheme.heading(6)
|
|
4358
4466
|
},
|
|
4359
4467
|
// Emphasis.
|
|
4360
4468
|
{
|
|
@@ -4409,15 +4517,23 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4409
4517
|
// https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown
|
|
4410
4518
|
base: markdownLanguage2,
|
|
4411
4519
|
// Languages for syntax highlighting fenced code blocks.
|
|
4520
|
+
// Caller-supplied languages are checked first so they can override defaults.
|
|
4412
4521
|
defaultCodeLanguage: jsonLanguage,
|
|
4413
|
-
codeLanguages:
|
|
4522
|
+
codeLanguages: [
|
|
4523
|
+
...options.codeLanguages ?? [],
|
|
4524
|
+
...languages
|
|
4525
|
+
],
|
|
4414
4526
|
// Don't complete HTML tags.
|
|
4415
4527
|
completeHTMLTags: false,
|
|
4416
4528
|
// Parser extensions.
|
|
4417
4529
|
extensions: [
|
|
4418
4530
|
// GFM provided by default.
|
|
4419
4531
|
markdownTagsExtensions,
|
|
4420
|
-
...options.extensions ?? defaultExtensions()
|
|
4532
|
+
...options.extensions ?? defaultExtensions(),
|
|
4533
|
+
// Disable folding for fenced code blocks by overriding foldNodeProp.
|
|
4534
|
+
// Note: returning null from foldService does not prevent syntaxFolding fallback,
|
|
4535
|
+
// so we must override the node prop directly on the FencedCode node type.
|
|
4536
|
+
noFencedCodeFolding
|
|
4421
4537
|
]
|
|
4422
4538
|
}),
|
|
4423
4539
|
// Custom styles.
|
|
@@ -4432,18 +4548,13 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4432
4548
|
].filter(isTruthy3))
|
|
4433
4549
|
];
|
|
4434
4550
|
};
|
|
4435
|
-
var
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
]
|
|
4441
|
-
|
|
4442
|
-
"xml",
|
|
4443
|
-
"xhtml"
|
|
4444
|
-
],
|
|
4445
|
-
load: async () => xml()
|
|
4446
|
-
});
|
|
4551
|
+
var noFencedCodeFolding = {
|
|
4552
|
+
props: [
|
|
4553
|
+
foldNodeProp.add({
|
|
4554
|
+
FencedCode: () => null
|
|
4555
|
+
})
|
|
4556
|
+
]
|
|
4557
|
+
};
|
|
4447
4558
|
var defaultExtensions = () => [
|
|
4448
4559
|
noSetExtHeading,
|
|
4449
4560
|
noHtml
|
|
@@ -4484,17 +4595,16 @@ var convertTreeToJson = (state) => {
|
|
|
4484
4595
|
|
|
4485
4596
|
// src/extensions/markdown/decorate.ts
|
|
4486
4597
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4487
|
-
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as
|
|
4488
|
-
import { Decoration as Decoration11, EditorView as
|
|
4598
|
+
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4599
|
+
import { Decoration as Decoration11, EditorView as EditorView24, ViewPlugin as ViewPlugin15, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4489
4600
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4490
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
4491
4601
|
|
|
4492
4602
|
// src/extensions/markdown/changes.ts
|
|
4493
4603
|
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
|
4494
4604
|
import { Transaction as Transaction4 } from "@codemirror/state";
|
|
4495
|
-
import { ViewPlugin as
|
|
4605
|
+
import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
|
|
4496
4606
|
var adjustChanges = () => {
|
|
4497
|
-
return
|
|
4607
|
+
return ViewPlugin14.fromClass(class {
|
|
4498
4608
|
update(update2) {
|
|
4499
4609
|
const tree = syntaxTree4(update2.state);
|
|
4500
4610
|
const adjustments = [];
|
|
@@ -4636,7 +4746,7 @@ var getValidUrl = (str) => {
|
|
|
4636
4746
|
// src/extensions/markdown/image.ts
|
|
4637
4747
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
|
4638
4748
|
import { StateField as StateField7 } from "@codemirror/state";
|
|
4639
|
-
import { Decoration as Decoration9, EditorView as
|
|
4749
|
+
import { Decoration as Decoration9, EditorView as EditorView21, WidgetType as WidgetType5 } from "@codemirror/view";
|
|
4640
4750
|
var image = (_options = {}) => {
|
|
4641
4751
|
return [
|
|
4642
4752
|
StateField7.define({
|
|
@@ -4664,7 +4774,7 @@ var image = (_options = {}) => {
|
|
|
4664
4774
|
add: buildDecorations(tr.state, from, to)
|
|
4665
4775
|
});
|
|
4666
4776
|
},
|
|
4667
|
-
provide: (field) =>
|
|
4777
|
+
provide: (field) => EditorView21.decorations.from(field)
|
|
4668
4778
|
})
|
|
4669
4779
|
];
|
|
4670
4780
|
};
|
|
@@ -4724,10 +4834,10 @@ var ImageWidget = class extends WidgetType5 {
|
|
|
4724
4834
|
};
|
|
4725
4835
|
|
|
4726
4836
|
// src/extensions/markdown/styles.ts
|
|
4727
|
-
import { EditorView as
|
|
4837
|
+
import { EditorView as EditorView22 } from "@codemirror/view";
|
|
4728
4838
|
var bulletListIndentationWidth = 24;
|
|
4729
4839
|
var orderedListIndentationWidth = 36;
|
|
4730
|
-
var formattingStyles =
|
|
4840
|
+
var formattingStyles = EditorView22.theme({
|
|
4731
4841
|
/**
|
|
4732
4842
|
* Horizontal rule.
|
|
4733
4843
|
*/
|
|
@@ -4736,7 +4846,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4736
4846
|
width: "100%",
|
|
4737
4847
|
height: "0",
|
|
4738
4848
|
verticalAlign: "middle",
|
|
4739
|
-
borderTop: "1px solid var(--
|
|
4849
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4740
4850
|
opacity: 0.5
|
|
4741
4851
|
},
|
|
4742
4852
|
/**
|
|
@@ -4759,19 +4869,44 @@ var formattingStyles = EditorView21.theme({
|
|
|
4759
4869
|
* Blockquote.
|
|
4760
4870
|
*/
|
|
4761
4871
|
"& .cm-blockquote": {
|
|
4762
|
-
background: "var(--
|
|
4763
|
-
borderLeft: "2px solid var(--
|
|
4872
|
+
background: "var(--color-cm-codeblock)",
|
|
4873
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4764
4874
|
paddingLeft: "1rem",
|
|
4765
|
-
margin:
|
|
4875
|
+
margin: 0
|
|
4766
4876
|
},
|
|
4767
4877
|
/**
|
|
4768
4878
|
* Code and codeblocks.
|
|
4769
4879
|
*/
|
|
4880
|
+
"& code": {
|
|
4881
|
+
fontFamily: fontMono,
|
|
4882
|
+
whiteSpace: "nowrap",
|
|
4883
|
+
color: "var(--color-cm-code)"
|
|
4884
|
+
},
|
|
4770
4885
|
"& .cm-code": {
|
|
4771
|
-
fontFamily: fontMono
|
|
4886
|
+
fontFamily: fontMono,
|
|
4887
|
+
whiteSpace: "nowrap",
|
|
4888
|
+
color: "var(--color-cm-code)"
|
|
4889
|
+
},
|
|
4890
|
+
// Inline code spans (triggered by backticks) use `cm-code-inline` + `font-mono`.
|
|
4891
|
+
// Different monospace font metrics can slightly overflow the fixed CodeMirror line box,
|
|
4892
|
+
// so constrain them to the target 24px height.
|
|
4893
|
+
"& .cm-code-inline": {
|
|
4894
|
+
fontFamily: fontMono,
|
|
4895
|
+
height: "24px",
|
|
4896
|
+
display: "inline-flex",
|
|
4897
|
+
alignItems: "center",
|
|
4898
|
+
overflow: "hidden",
|
|
4899
|
+
color: "var(--color-cm-code)"
|
|
4900
|
+
},
|
|
4901
|
+
"& .cm-code-mark": {
|
|
4902
|
+
fontFamily: fontMono,
|
|
4903
|
+
height: "24px",
|
|
4904
|
+
display: "inline-flex",
|
|
4905
|
+
alignItems: "center",
|
|
4906
|
+
overflow: "hidden"
|
|
4772
4907
|
},
|
|
4773
4908
|
"& .cm-codeblock-line": {
|
|
4774
|
-
background: "var(--
|
|
4909
|
+
background: "var(--color-cm-codeblock)",
|
|
4775
4910
|
paddingInline: "1rem !important"
|
|
4776
4911
|
},
|
|
4777
4912
|
"& .cm-codeblock-start": {
|
|
@@ -4800,16 +4935,18 @@ var formattingStyles = EditorView21.theme({
|
|
|
4800
4935
|
*/
|
|
4801
4936
|
".cm-table *": {
|
|
4802
4937
|
fontFamily: fontMono,
|
|
4938
|
+
lineHeight: 1.5,
|
|
4803
4939
|
textDecoration: "none !important"
|
|
4804
4940
|
},
|
|
4805
4941
|
".cm-table-head": {
|
|
4806
4942
|
padding: "2px 16px 2px 0px",
|
|
4807
4943
|
textAlign: "left",
|
|
4808
|
-
borderBottom: "1px solid var(--
|
|
4809
|
-
color: "var(--
|
|
4944
|
+
borderBottom: "1px solid var(--color-cm-separator)",
|
|
4945
|
+
color: "var(--color-subdued)"
|
|
4810
4946
|
},
|
|
4811
4947
|
".cm-table-cell": {
|
|
4812
|
-
padding: "2px 16px 2px 0px"
|
|
4948
|
+
padding: "2px 16px 2px 0px",
|
|
4949
|
+
verticalAlign: "top"
|
|
4813
4950
|
},
|
|
4814
4951
|
/**
|
|
4815
4952
|
* Image.
|
|
@@ -4825,12 +4962,12 @@ var formattingStyles = EditorView21.theme({
|
|
|
4825
4962
|
},
|
|
4826
4963
|
".cm-image-with-loader": {
|
|
4827
4964
|
display: "block",
|
|
4828
|
-
opacity:
|
|
4965
|
+
opacity: 0,
|
|
4829
4966
|
transitionDuration: "350ms",
|
|
4830
4967
|
transitionProperty: "opacity"
|
|
4831
4968
|
},
|
|
4832
4969
|
".cm-image-with-loader.cm-loaded-image": {
|
|
4833
|
-
opacity:
|
|
4970
|
+
opacity: 1
|
|
4834
4971
|
},
|
|
4835
4972
|
".cm-image-wrapper": {
|
|
4836
4973
|
"grid-template-columns": "1fr",
|
|
@@ -4849,12 +4986,12 @@ var formattingStyles = EditorView21.theme({
|
|
|
4849
4986
|
// src/extensions/markdown/table.ts
|
|
4850
4987
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
|
4851
4988
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
|
4852
|
-
import { Decoration as Decoration10, EditorView as
|
|
4989
|
+
import { Decoration as Decoration10, EditorView as EditorView23, WidgetType as WidgetType6 } from "@codemirror/view";
|
|
4853
4990
|
var table = (options = {}) => {
|
|
4854
4991
|
return StateField8.define({
|
|
4855
4992
|
create: (state) => update(state, options),
|
|
4856
4993
|
update: (_, tr) => update(tr.state, options),
|
|
4857
|
-
provide: (field) =>
|
|
4994
|
+
provide: (field) => EditorView23.decorations.from(field)
|
|
4858
4995
|
});
|
|
4859
4996
|
};
|
|
4860
4997
|
var update = (state, _options) => {
|
|
@@ -4911,6 +5048,26 @@ var update = (state, _options) => {
|
|
|
4911
5048
|
});
|
|
4912
5049
|
return builder.finish();
|
|
4913
5050
|
};
|
|
5051
|
+
var renderCellContent = (el, text) => {
|
|
5052
|
+
const parts = text.split(/(`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_)/);
|
|
5053
|
+
for (const part of parts) {
|
|
5054
|
+
if (part.length > 2 && part.startsWith("`") && part.endsWith("`")) {
|
|
5055
|
+
const code = document.createElement("code");
|
|
5056
|
+
code.textContent = part.slice(1, -1);
|
|
5057
|
+
el.appendChild(code);
|
|
5058
|
+
} else if (part.startsWith("**") && part.endsWith("**") || part.startsWith("__") && part.endsWith("__")) {
|
|
5059
|
+
const strong = document.createElement("strong");
|
|
5060
|
+
strong.textContent = part.slice(2, -2);
|
|
5061
|
+
el.appendChild(strong);
|
|
5062
|
+
} else if (part.startsWith("*") && part.endsWith("*") || part.startsWith("_") && part.endsWith("_")) {
|
|
5063
|
+
const em = document.createElement("em");
|
|
5064
|
+
em.textContent = part.slice(1, -1);
|
|
5065
|
+
el.appendChild(em);
|
|
5066
|
+
} else {
|
|
5067
|
+
el.appendChild(document.createTextNode(part));
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
};
|
|
4914
5071
|
var TableWidget = class extends WidgetType6 {
|
|
4915
5072
|
_table;
|
|
4916
5073
|
constructor(_table) {
|
|
@@ -4930,7 +5087,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4930
5087
|
this._table.header?.forEach((cell) => {
|
|
4931
5088
|
const th = document.createElement("th");
|
|
4932
5089
|
th.setAttribute("class", "cm-table-head");
|
|
4933
|
-
tr.appendChild(th)
|
|
5090
|
+
renderCellContent(tr.appendChild(th), cell);
|
|
4934
5091
|
});
|
|
4935
5092
|
const body = table2.appendChild(document.createElement("tbody"));
|
|
4936
5093
|
this._table.rows?.forEach((row) => {
|
|
@@ -4938,7 +5095,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4938
5095
|
row.forEach((cell) => {
|
|
4939
5096
|
const td = document.createElement("td");
|
|
4940
5097
|
td.setAttribute("class", "cm-table-cell");
|
|
4941
|
-
tr2.appendChild(td)
|
|
5098
|
+
renderCellContent(tr2.appendChild(td), cell);
|
|
4942
5099
|
});
|
|
4943
5100
|
});
|
|
4944
5101
|
return div;
|
|
@@ -4946,7 +5103,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4946
5103
|
};
|
|
4947
5104
|
|
|
4948
5105
|
// src/extensions/markdown/decorate.ts
|
|
4949
|
-
var
|
|
5106
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4950
5107
|
var Unicode = {
|
|
4951
5108
|
emDash: "\u2014",
|
|
4952
5109
|
bullet: "\u2022",
|
|
@@ -4969,7 +5126,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4969
5126
|
eq(other) {
|
|
4970
5127
|
return this.url === other.url;
|
|
4971
5128
|
}
|
|
4972
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4973
5129
|
toDOM(view) {
|
|
4974
5130
|
const el = document.createElement("span");
|
|
4975
5131
|
this.render(el, {
|
|
@@ -5046,10 +5202,10 @@ var fencedCodeLine = Decoration11.line({
|
|
|
5046
5202
|
class: "cm-code cm-codeblock-line"
|
|
5047
5203
|
});
|
|
5048
5204
|
var fencedCodeLineFirst = Decoration11.line({
|
|
5049
|
-
class:
|
|
5205
|
+
class: "cm-code cm-codeblock-line cm-codeblock-start"
|
|
5050
5206
|
});
|
|
5051
5207
|
var fencedCodeLineLast = Decoration11.line({
|
|
5052
|
-
class:
|
|
5208
|
+
class: "cm-code cm-codeblock-line cm-codeblock-end"
|
|
5053
5209
|
});
|
|
5054
5210
|
var commentBlockLine = fencedCodeLine;
|
|
5055
5211
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
|
@@ -5082,8 +5238,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5082
5238
|
const headerLevels = [];
|
|
5083
5239
|
const getHeaderLevels = (node, level) => {
|
|
5084
5240
|
invariant4(level > 0, void 0, {
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5241
|
+
F: __dxlog_file12,
|
|
5242
|
+
L: 178,
|
|
5087
5243
|
S: void 0,
|
|
5088
5244
|
A: [
|
|
5089
5245
|
"level > 0",
|
|
@@ -5121,8 +5277,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5121
5277
|
};
|
|
5122
5278
|
const getCurrentListLevel = () => {
|
|
5123
5279
|
invariant4(listLevels.length, void 0, {
|
|
5124
|
-
F:
|
|
5125
|
-
L:
|
|
5280
|
+
F: __dxlog_file12,
|
|
5281
|
+
L: 200,
|
|
5126
5282
|
S: void 0,
|
|
5127
5283
|
A: [
|
|
5128
5284
|
"listLevels.length",
|
|
@@ -5166,13 +5322,13 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5166
5322
|
deco: hide
|
|
5167
5323
|
});
|
|
5168
5324
|
} else {
|
|
5169
|
-
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
|
5325
|
+
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + "). ";
|
|
5170
5326
|
if (num.length) {
|
|
5171
5327
|
atomicDecoRanges.push({
|
|
5172
5328
|
from: mark.from,
|
|
5173
5329
|
to: mark.from + len,
|
|
5174
5330
|
deco: Decoration11.replace({
|
|
5175
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5331
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5176
5332
|
})
|
|
5177
5333
|
});
|
|
5178
5334
|
}
|
|
@@ -5349,11 +5505,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5349
5505
|
}
|
|
5350
5506
|
decoRanges.push({
|
|
5351
5507
|
from: marks[0].to,
|
|
5352
|
-
to: marks[1].from,
|
|
5508
|
+
to: !editing && options.renderLinkButton ? node.to : marks[1].from,
|
|
5353
5509
|
deco: Decoration11.mark({
|
|
5354
5510
|
tagName: "a",
|
|
5355
5511
|
attributes: {
|
|
5356
|
-
class: "cm-link",
|
|
5512
|
+
class: options.renderLinkButton ? "cm-link cm-link-with-button" : "cm-link",
|
|
5357
5513
|
href: url,
|
|
5358
5514
|
rel: "noreferrer",
|
|
5359
5515
|
target: "_blank"
|
|
@@ -5431,18 +5587,21 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5431
5587
|
deco.add(from, to, d);
|
|
5432
5588
|
}
|
|
5433
5589
|
const atomicDeco = new RangeSetBuilder5();
|
|
5434
|
-
for (const { from, to, deco:
|
|
5435
|
-
|
|
5590
|
+
for (const { from, to, deco: deco2 } of atomicDecoRanges) {
|
|
5591
|
+
if (from < to && state.doc.lineAt(from).number !== state.doc.lineAt(to).number) {
|
|
5592
|
+
continue;
|
|
5593
|
+
}
|
|
5594
|
+
atomicDeco.add(from, to, deco2);
|
|
5436
5595
|
}
|
|
5437
5596
|
return {
|
|
5438
5597
|
deco: deco.finish(),
|
|
5439
5598
|
atomicDeco: atomicDeco.finish()
|
|
5440
5599
|
};
|
|
5441
5600
|
};
|
|
5442
|
-
var forceUpdate =
|
|
5601
|
+
var forceUpdate = StateEffect6.define();
|
|
5443
5602
|
var decorateMarkdown = (options = {}) => {
|
|
5444
5603
|
return [
|
|
5445
|
-
|
|
5604
|
+
ViewPlugin15.fromClass(class {
|
|
5446
5605
|
deco;
|
|
5447
5606
|
atomicDeco;
|
|
5448
5607
|
pendingUpdate;
|
|
@@ -5477,9 +5636,9 @@ var decorateMarkdown = (options = {}) => {
|
|
|
5477
5636
|
}
|
|
5478
5637
|
}, {
|
|
5479
5638
|
provide: (plugin) => [
|
|
5480
|
-
Prec4.low(
|
|
5481
|
-
|
|
5482
|
-
|
|
5639
|
+
Prec4.low(EditorView24.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration11.none)),
|
|
5640
|
+
EditorView24.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
|
|
5641
|
+
EditorView24.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none)
|
|
5483
5642
|
]
|
|
5484
5643
|
}),
|
|
5485
5644
|
image(),
|
|
@@ -5511,8 +5670,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5511
5670
|
return {
|
|
5512
5671
|
pos: link.from,
|
|
5513
5672
|
end: link.to,
|
|
5514
|
-
|
|
5515
|
-
// above: true,
|
|
5673
|
+
above: true,
|
|
5516
5674
|
create: () => {
|
|
5517
5675
|
const el = document.createElement("div");
|
|
5518
5676
|
el.className = tooltipContent({});
|
|
@@ -5528,16 +5686,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5528
5686
|
};
|
|
5529
5687
|
}
|
|
5530
5688
|
};
|
|
5531
|
-
}, {
|
|
5532
|
-
// NOTE: 0 = default of 300ms.
|
|
5533
|
-
hoverTime: 1
|
|
5534
5689
|
});
|
|
5535
5690
|
};
|
|
5536
5691
|
|
|
5537
5692
|
// src/extensions/mention.ts
|
|
5538
5693
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5539
|
-
import { log as
|
|
5540
|
-
var
|
|
5694
|
+
import { log as log9 } from "@dxos/log";
|
|
5695
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5541
5696
|
var mention = ({ debug, onSearch }) => {
|
|
5542
5697
|
return autocompletion({
|
|
5543
5698
|
// TODO(burdon): Not working.
|
|
@@ -5549,10 +5704,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5549
5704
|
icons: false,
|
|
5550
5705
|
override: [
|
|
5551
5706
|
(context) => {
|
|
5552
|
-
|
|
5707
|
+
log9.info("completion context", {
|
|
5553
5708
|
context
|
|
5554
5709
|
}, {
|
|
5555
|
-
F:
|
|
5710
|
+
F: __dxlog_file13,
|
|
5556
5711
|
L: 27,
|
|
5557
5712
|
S: void 0,
|
|
5558
5713
|
C: (f, a) => f(...a)
|
|
@@ -5573,8 +5728,8 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5573
5728
|
};
|
|
5574
5729
|
|
|
5575
5730
|
// src/extensions/modal.ts
|
|
5576
|
-
import { StateEffect as
|
|
5577
|
-
var modalStateEffect =
|
|
5731
|
+
import { StateEffect as StateEffect7, StateField as StateField9 } from "@codemirror/state";
|
|
5732
|
+
var modalStateEffect = StateEffect7.define();
|
|
5578
5733
|
var modalStateField = StateField9.define({
|
|
5579
5734
|
create: () => false,
|
|
5580
5735
|
update: (value, tr) => {
|
|
@@ -5635,7 +5790,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5635
5790
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5636
5791
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5637
5792
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5638
|
-
var
|
|
5793
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5639
5794
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5640
5795
|
return {
|
|
5641
5796
|
type,
|
|
@@ -5790,7 +5945,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5790
5945
|
}
|
|
5791
5946
|
case "BulletList": {
|
|
5792
5947
|
invariant5(current, void 0, {
|
|
5793
|
-
F:
|
|
5948
|
+
F: __dxlog_file14,
|
|
5794
5949
|
L: 219,
|
|
5795
5950
|
S: void 0,
|
|
5796
5951
|
A: [
|
|
@@ -5807,7 +5962,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5807
5962
|
}
|
|
5808
5963
|
case "ListItem": {
|
|
5809
5964
|
invariant5(parent, void 0, {
|
|
5810
|
-
F:
|
|
5965
|
+
F: __dxlog_file14,
|
|
5811
5966
|
L: 228,
|
|
5812
5967
|
S: void 0,
|
|
5813
5968
|
A: [
|
|
@@ -5849,7 +6004,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5849
6004
|
}
|
|
5850
6005
|
case "ListMark": {
|
|
5851
6006
|
invariant5(current, void 0, {
|
|
5852
|
-
F:
|
|
6007
|
+
F: __dxlog_file14,
|
|
5853
6008
|
L: 272,
|
|
5854
6009
|
S: void 0,
|
|
5855
6010
|
A: [
|
|
@@ -5863,7 +6018,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5863
6018
|
}
|
|
5864
6019
|
case "Task": {
|
|
5865
6020
|
invariant5(current, void 0, {
|
|
5866
|
-
F:
|
|
6021
|
+
F: __dxlog_file14,
|
|
5867
6022
|
L: 278,
|
|
5868
6023
|
S: void 0,
|
|
5869
6024
|
A: [
|
|
@@ -5876,7 +6031,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5876
6031
|
}
|
|
5877
6032
|
case "TaskMarker": {
|
|
5878
6033
|
invariant5(current, void 0, {
|
|
5879
|
-
F:
|
|
6034
|
+
F: __dxlog_file14,
|
|
5880
6035
|
L: 283,
|
|
5881
6036
|
S: void 0,
|
|
5882
6037
|
A: [
|
|
@@ -5892,7 +6047,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5892
6047
|
leave: (node) => {
|
|
5893
6048
|
if (node.name === "BulletList") {
|
|
5894
6049
|
invariant5(parent, void 0, {
|
|
5895
|
-
F:
|
|
6050
|
+
F: __dxlog_file14,
|
|
5896
6051
|
L: 291,
|
|
5897
6052
|
S: void 0,
|
|
5898
6053
|
A: [
|
|
@@ -5906,7 +6061,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5906
6061
|
}
|
|
5907
6062
|
});
|
|
5908
6063
|
invariant5(tree, void 0, {
|
|
5909
|
-
F:
|
|
6064
|
+
F: __dxlog_file14,
|
|
5910
6065
|
L: 298,
|
|
5911
6066
|
S: void 0,
|
|
5912
6067
|
A: [
|
|
@@ -6198,17 +6353,17 @@ var commands = () => keymap11.of([
|
|
|
6198
6353
|
|
|
6199
6354
|
// src/extensions/outliner/outliner.ts
|
|
6200
6355
|
import { Prec as Prec5 } from "@codemirror/state";
|
|
6201
|
-
import { Decoration as Decoration12, EditorView as
|
|
6202
|
-
import { mx as
|
|
6356
|
+
import { Decoration as Decoration12, EditorView as EditorView26, ViewPlugin as ViewPlugin18 } from "@codemirror/view";
|
|
6357
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
6203
6358
|
|
|
6204
6359
|
// src/extensions/outliner/editor.ts
|
|
6205
6360
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6206
|
-
import { ViewPlugin as
|
|
6207
|
-
import { log as
|
|
6208
|
-
var
|
|
6361
|
+
import { ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6362
|
+
import { log as log10 } from "@dxos/log";
|
|
6363
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6209
6364
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6210
6365
|
var initialize = () => {
|
|
6211
|
-
return
|
|
6366
|
+
return ViewPlugin16.fromClass(class {
|
|
6212
6367
|
constructor(view) {
|
|
6213
6368
|
const first = view.state.doc.lineAt(0);
|
|
6214
6369
|
const text = view.state.sliceDoc(first.from, first.to);
|
|
@@ -6337,7 +6492,7 @@ var editor = () => [
|
|
|
6337
6492
|
cancel = true;
|
|
6338
6493
|
return;
|
|
6339
6494
|
}
|
|
6340
|
-
|
|
6495
|
+
log10("change", {
|
|
6341
6496
|
item,
|
|
6342
6497
|
line: {
|
|
6343
6498
|
from: line.from,
|
|
@@ -6356,7 +6511,7 @@ var editor = () => [
|
|
|
6356
6511
|
length: insert.length
|
|
6357
6512
|
}
|
|
6358
6513
|
}, {
|
|
6359
|
-
F:
|
|
6514
|
+
F: __dxlog_file15,
|
|
6360
6515
|
L: 164,
|
|
6361
6516
|
S: void 0,
|
|
6362
6517
|
C: (f, a) => f(...a)
|
|
@@ -6364,10 +6519,10 @@ var editor = () => [
|
|
|
6364
6519
|
}
|
|
6365
6520
|
});
|
|
6366
6521
|
if (changes.length > 0) {
|
|
6367
|
-
|
|
6522
|
+
log10("modified,", {
|
|
6368
6523
|
changes
|
|
6369
6524
|
}, {
|
|
6370
|
-
F:
|
|
6525
|
+
F: __dxlog_file15,
|
|
6371
6526
|
L: 175,
|
|
6372
6527
|
S: void 0,
|
|
6373
6528
|
C: (f, a) => f(...a)
|
|
@@ -6378,8 +6533,8 @@ var editor = () => [
|
|
|
6378
6533
|
}
|
|
6379
6534
|
];
|
|
6380
6535
|
} else if (cancel) {
|
|
6381
|
-
|
|
6382
|
-
F:
|
|
6536
|
+
log10("cancel", void 0, {
|
|
6537
|
+
F: __dxlog_file15,
|
|
6383
6538
|
L: 178,
|
|
6384
6539
|
S: void 0,
|
|
6385
6540
|
C: (f, a) => f(...a)
|
|
@@ -6391,10 +6546,10 @@ var editor = () => [
|
|
|
6391
6546
|
];
|
|
6392
6547
|
|
|
6393
6548
|
// src/extensions/outliner/menu.ts
|
|
6394
|
-
import { EditorView as
|
|
6395
|
-
import { addEventListener } from "@dxos/async";
|
|
6549
|
+
import { EditorView as EditorView25, ViewPlugin as ViewPlugin17 } from "@codemirror/view";
|
|
6550
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6396
6551
|
var menu = (options = {}) => [
|
|
6397
|
-
|
|
6552
|
+
ViewPlugin17.fromClass(class {
|
|
6398
6553
|
view;
|
|
6399
6554
|
tag;
|
|
6400
6555
|
rafId;
|
|
@@ -6414,7 +6569,7 @@ var menu = (options = {}) => [
|
|
|
6414
6569
|
}
|
|
6415
6570
|
container.appendChild(this.tag);
|
|
6416
6571
|
const handler = () => this.scheduleUpdate();
|
|
6417
|
-
this.cleanup =
|
|
6572
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6418
6573
|
this.scheduleUpdate();
|
|
6419
6574
|
}
|
|
6420
6575
|
destroy() {
|
|
@@ -6456,7 +6611,7 @@ var menu = (options = {}) => [
|
|
|
6456
6611
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
|
6457
6612
|
}
|
|
6458
6613
|
}),
|
|
6459
|
-
|
|
6614
|
+
EditorView25.theme({
|
|
6460
6615
|
".cm-popover-trigger": {
|
|
6461
6616
|
position: "fixed",
|
|
6462
6617
|
padding: "0",
|
|
@@ -6492,12 +6647,12 @@ var outliner = (_options = {}) => [
|
|
|
6492
6647
|
listPaddingLeft: 8
|
|
6493
6648
|
}),
|
|
6494
6649
|
// Researve space for menu.
|
|
6495
|
-
|
|
6496
|
-
class: "
|
|
6650
|
+
EditorView26.contentAttributes.of({
|
|
6651
|
+
class: "w-full !mr-[3rem]"
|
|
6497
6652
|
})
|
|
6498
6653
|
];
|
|
6499
6654
|
var decorations = () => [
|
|
6500
|
-
|
|
6655
|
+
ViewPlugin18.fromClass(class {
|
|
6501
6656
|
decorations = Decoration12.none;
|
|
6502
6657
|
constructor(view) {
|
|
6503
6658
|
this.updateDecorations(view.state, view);
|
|
@@ -6522,7 +6677,7 @@ var decorations = () => [
|
|
|
6522
6677
|
const lineTo = doc.lineAt(item.contentRange.to);
|
|
6523
6678
|
const isSelected = selection.includes(item.index) || item === current;
|
|
6524
6679
|
decorations2.push(Decoration12.line({
|
|
6525
|
-
class:
|
|
6680
|
+
class: mx6("cm-list-item", lineFrom.number === line.number && "cm-list-item-start", lineTo.number === line.number && "cm-list-item-end", isSelected && (hasFocus ? "cm-list-item-focused" : "cm-list-item-selected"))
|
|
6526
6681
|
}).range(line.from, line.from));
|
|
6527
6682
|
}
|
|
6528
6683
|
}
|
|
@@ -6532,7 +6687,7 @@ var decorations = () => [
|
|
|
6532
6687
|
decorations: (v) => v.decorations
|
|
6533
6688
|
}),
|
|
6534
6689
|
// Theme.
|
|
6535
|
-
|
|
6690
|
+
EditorView26.theme(Object.assign({
|
|
6536
6691
|
".cm-list-item": {
|
|
6537
6692
|
borderLeftWidth: "1px",
|
|
6538
6693
|
borderRightWidth: "1px",
|
|
@@ -6557,38 +6712,67 @@ var decorations = () => [
|
|
|
6557
6712
|
marginBottom: "2px"
|
|
6558
6713
|
},
|
|
6559
6714
|
".cm-list-item-focused": {
|
|
6560
|
-
borderColor: "var(--
|
|
6715
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6561
6716
|
},
|
|
6562
6717
|
"&:focus-within .cm-list-item-selected": {
|
|
6563
|
-
borderColor: "var(--
|
|
6718
|
+
borderColor: "var(--color-separator)"
|
|
6564
6719
|
}
|
|
6565
6720
|
}))
|
|
6566
6721
|
];
|
|
6567
6722
|
|
|
6568
6723
|
// src/extensions/preview/preview.ts
|
|
6569
6724
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
|
6570
|
-
import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField11 } from "@codemirror/state";
|
|
6571
|
-
import { Decoration as Decoration13, EditorView as
|
|
6725
|
+
import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect8, StateField as StateField11 } from "@codemirror/state";
|
|
6726
|
+
import { Decoration as Decoration13, EditorView as EditorView27, ViewPlugin as ViewPlugin19, WidgetType as WidgetType8 } from "@codemirror/view";
|
|
6727
|
+
import { DXN, Entity } from "@dxos/echo";
|
|
6728
|
+
var labelResolvedEffect = StateEffect8.define();
|
|
6572
6729
|
var preview = (options = {}) => {
|
|
6730
|
+
const viewRef = {
|
|
6731
|
+
current: void 0
|
|
6732
|
+
};
|
|
6573
6733
|
return [
|
|
6574
6734
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
|
6575
6735
|
// "Block decorations may not be specified via plugins".
|
|
6576
6736
|
StateField11.define({
|
|
6577
|
-
create: (state) => buildDecorations3(state, options),
|
|
6737
|
+
create: (state) => buildDecorations3(state, options, viewRef),
|
|
6578
6738
|
update: (decorations2, tr) => {
|
|
6579
|
-
if (tr.docChanged) {
|
|
6580
|
-
return buildDecorations3(tr.state, options);
|
|
6739
|
+
if (tr.docChanged || tr.effects.some((effect) => effect.is(labelResolvedEffect))) {
|
|
6740
|
+
return buildDecorations3(tr.state, options, viewRef);
|
|
6581
6741
|
}
|
|
6582
6742
|
return decorations2.map(tr.changes);
|
|
6583
6743
|
},
|
|
6584
6744
|
provide: (field) => [
|
|
6585
|
-
|
|
6586
|
-
|
|
6745
|
+
EditorView27.decorations.from(field),
|
|
6746
|
+
EditorView27.atomicRanges.of((view) => view.state.field(field))
|
|
6587
6747
|
]
|
|
6748
|
+
}),
|
|
6749
|
+
ViewPlugin19.define((view) => {
|
|
6750
|
+
viewRef.current = view;
|
|
6751
|
+
return {
|
|
6752
|
+
destroy() {
|
|
6753
|
+
viewRef.current = void 0;
|
|
6754
|
+
}
|
|
6755
|
+
};
|
|
6588
6756
|
})
|
|
6589
6757
|
];
|
|
6590
6758
|
};
|
|
6591
|
-
var
|
|
6759
|
+
var resolveLabel = (db, dxnStr, viewRef) => {
|
|
6760
|
+
const dxn = DXN.tryParse(dxnStr);
|
|
6761
|
+
if (!dxn) {
|
|
6762
|
+
return;
|
|
6763
|
+
}
|
|
6764
|
+
const ref = db.makeRef(dxn);
|
|
6765
|
+
const target = ref.target;
|
|
6766
|
+
if (target) {
|
|
6767
|
+
return Entity.getLabel(target);
|
|
6768
|
+
}
|
|
6769
|
+
void ref.tryLoad().then(() => {
|
|
6770
|
+
viewRef.current?.dispatch({
|
|
6771
|
+
effects: labelResolvedEffect.of(void 0)
|
|
6772
|
+
});
|
|
6773
|
+
});
|
|
6774
|
+
};
|
|
6775
|
+
var buildDecorations3 = (state, options, viewRef) => {
|
|
6592
6776
|
const builder = new RangeSetBuilder6();
|
|
6593
6777
|
syntaxTree10(state).iterate({
|
|
6594
6778
|
enter: (node) => {
|
|
@@ -6600,8 +6784,13 @@ var buildDecorations3 = (state, options) => {
|
|
|
6600
6784
|
case "Link": {
|
|
6601
6785
|
const link = getLinkRef(state, node.node);
|
|
6602
6786
|
if (link) {
|
|
6787
|
+
const resolved = options.db ? resolveLabel(options.db, link.dxn, viewRef) : void 0;
|
|
6788
|
+
const displayLink = resolved ? {
|
|
6789
|
+
...link,
|
|
6790
|
+
label: resolved
|
|
6791
|
+
} : link;
|
|
6603
6792
|
builder.add(node.from, node.to, Decoration13.replace({
|
|
6604
|
-
widget: new PreviewInlineWidget(options,
|
|
6793
|
+
widget: new PreviewInlineWidget(options, displayLink),
|
|
6605
6794
|
side: 1
|
|
6606
6795
|
}));
|
|
6607
6796
|
}
|
|
@@ -6632,13 +6821,13 @@ var getLinkRef = (state, node) => {
|
|
|
6632
6821
|
const mark = node.getChildren("LinkMark");
|
|
6633
6822
|
const urlNode = node.getChild("URL");
|
|
6634
6823
|
if (mark && urlNode) {
|
|
6635
|
-
const
|
|
6636
|
-
if (
|
|
6824
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6825
|
+
if (dxn.startsWith("dxn:")) {
|
|
6637
6826
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6638
6827
|
return {
|
|
6639
6828
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6640
6829
|
label,
|
|
6641
|
-
|
|
6830
|
+
dxn
|
|
6642
6831
|
};
|
|
6643
6832
|
}
|
|
6644
6833
|
}
|
|
@@ -6653,13 +6842,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6653
6842
|
// return false;
|
|
6654
6843
|
// }
|
|
6655
6844
|
eq(other) {
|
|
6656
|
-
return this._link.
|
|
6845
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6657
6846
|
}
|
|
6658
6847
|
toDOM(_view) {
|
|
6659
6848
|
const root = document.createElement("dx-anchor");
|
|
6660
6849
|
root.classList.add("dx-tag--anchor");
|
|
6661
6850
|
root.textContent = this._link.label;
|
|
6662
|
-
root.setAttribute("
|
|
6851
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6663
6852
|
return root;
|
|
6664
6853
|
}
|
|
6665
6854
|
};
|
|
@@ -6673,11 +6862,11 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6673
6862
|
// return true;
|
|
6674
6863
|
// }
|
|
6675
6864
|
eq(other) {
|
|
6676
|
-
return this._link.
|
|
6865
|
+
return this._link.dxn === other._link.dxn;
|
|
6677
6866
|
}
|
|
6678
6867
|
toDOM(_view) {
|
|
6679
6868
|
const root = document.createElement("div");
|
|
6680
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6869
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6681
6870
|
this._options.addBlockContainer?.({
|
|
6682
6871
|
link: this._link,
|
|
6683
6872
|
el: root
|
|
@@ -6693,7 +6882,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6693
6882
|
};
|
|
6694
6883
|
|
|
6695
6884
|
// src/extensions/replacer.ts
|
|
6696
|
-
import { EditorView as
|
|
6885
|
+
import { EditorView as EditorView28 } from "@codemirror/view";
|
|
6697
6886
|
var defaultReplacements = [
|
|
6698
6887
|
{
|
|
6699
6888
|
input: "--",
|
|
@@ -6756,7 +6945,7 @@ var replacer = ({ replacements = defaultReplacements } = {}) => {
|
|
|
6756
6945
|
const sortedReplacements = [
|
|
6757
6946
|
...replacements
|
|
6758
6947
|
].sort((a, b) => b.input.length - a.input.length);
|
|
6759
|
-
return
|
|
6948
|
+
return EditorView28.inputHandler.of((view, from, to, insert) => {
|
|
6760
6949
|
if (insert.length !== 1) {
|
|
6761
6950
|
return false;
|
|
6762
6951
|
}
|
|
@@ -6893,7 +7082,7 @@ var mixedParser = (registry) => {
|
|
|
6893
7082
|
|
|
6894
7083
|
// src/extensions/tags/streamer.ts
|
|
6895
7084
|
import { StateEffect as StateEffect9, StateField as StateField12 } from "@codemirror/state";
|
|
6896
|
-
import { Decoration as Decoration14, EditorView as
|
|
7085
|
+
import { Decoration as Decoration14, EditorView as EditorView29, ViewPlugin as ViewPlugin20, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6897
7086
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6898
7087
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
6899
7088
|
var BLINK_RATE = 2e3;
|
|
@@ -6919,7 +7108,7 @@ var cursor = () => {
|
|
|
6919
7108
|
return value;
|
|
6920
7109
|
}
|
|
6921
7110
|
});
|
|
6922
|
-
const timerPlugin =
|
|
7111
|
+
const timerPlugin = ViewPlugin20.fromClass(class {
|
|
6923
7112
|
view;
|
|
6924
7113
|
timer;
|
|
6925
7114
|
constructor(view) {
|
|
@@ -6954,7 +7143,7 @@ var cursor = () => {
|
|
|
6954
7143
|
}).range(endPos)
|
|
6955
7144
|
]);
|
|
6956
7145
|
},
|
|
6957
|
-
provide: (f) =>
|
|
7146
|
+
provide: (f) => EditorView29.decorations.from(f)
|
|
6958
7147
|
});
|
|
6959
7148
|
return [
|
|
6960
7149
|
showCursor,
|
|
@@ -6974,7 +7163,7 @@ var CursorWidget = class extends WidgetType9 {
|
|
|
6974
7163
|
};
|
|
6975
7164
|
var fadeIn = (options = {}) => {
|
|
6976
7165
|
const FADE_IN_DURATION = 1e3;
|
|
6977
|
-
const DEFAULT_REMOVAL_DELAY =
|
|
7166
|
+
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
6978
7167
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
6979
7168
|
const removeDecoration = StateEffect9.define();
|
|
6980
7169
|
const fadeField = StateField12.define({
|
|
@@ -7018,9 +7207,9 @@ var fadeIn = (options = {}) => {
|
|
|
7018
7207
|
add
|
|
7019
7208
|
});
|
|
7020
7209
|
},
|
|
7021
|
-
provide: (f) =>
|
|
7210
|
+
provide: (f) => EditorView29.decorations.from(f)
|
|
7022
7211
|
});
|
|
7023
|
-
const timerPlugin =
|
|
7212
|
+
const timerPlugin = ViewPlugin20.fromClass(class {
|
|
7024
7213
|
view;
|
|
7025
7214
|
// Map a simple key "from-to" to timer id.
|
|
7026
7215
|
_timers = /* @__PURE__ */ new Map();
|
|
@@ -7062,7 +7251,7 @@ var fadeIn = (options = {}) => {
|
|
|
7062
7251
|
return [
|
|
7063
7252
|
fadeField,
|
|
7064
7253
|
timerPlugin,
|
|
7065
|
-
|
|
7254
|
+
EditorView29.theme({
|
|
7066
7255
|
".cm-line > span": {
|
|
7067
7256
|
opacity: "0.8"
|
|
7068
7257
|
},
|
|
@@ -7087,16 +7276,16 @@ var fadeIn = (options = {}) => {
|
|
|
7087
7276
|
// src/extensions/tags/xml-tags.ts
|
|
7088
7277
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7089
7278
|
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect10, StateField as StateField13 } from "@codemirror/state";
|
|
7090
|
-
import { Decoration as Decoration15, EditorView as
|
|
7279
|
+
import { Decoration as Decoration15, EditorView as EditorView30, ViewPlugin as ViewPlugin21, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7091
7280
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7092
|
-
import { log as
|
|
7281
|
+
import { log as log11 } from "@dxos/log";
|
|
7093
7282
|
|
|
7094
7283
|
// src/extensions/tags/xml-util.ts
|
|
7095
7284
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7096
|
-
var
|
|
7285
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7097
7286
|
var nodeToJson = (state, node) => {
|
|
7098
7287
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7099
|
-
F:
|
|
7288
|
+
F: __dxlog_file16,
|
|
7100
7289
|
L: 18,
|
|
7101
7290
|
S: void 0,
|
|
7102
7291
|
A: [
|
|
@@ -7160,7 +7349,7 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7349
|
};
|
|
7161
7350
|
|
|
7162
7351
|
// src/extensions/tags/xml-tags.ts
|
|
7163
|
-
var
|
|
7352
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7164
7353
|
var navigatePreviousEffect = StateEffect10.define();
|
|
7165
7354
|
var navigateNextEffect = StateEffect10.define();
|
|
7166
7355
|
var getXmlTextChild = (children) => {
|
|
@@ -7190,11 +7379,11 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7190
7379
|
}
|
|
7191
7380
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7192
7381
|
const { id, value } = effect.value;
|
|
7193
|
-
|
|
7382
|
+
log11("widget updated", {
|
|
7194
7383
|
id,
|
|
7195
7384
|
value
|
|
7196
7385
|
}, {
|
|
7197
|
-
F:
|
|
7386
|
+
F: __dxlog_file17,
|
|
7198
7387
|
L: 153,
|
|
7199
7388
|
S: void 0,
|
|
7200
7389
|
C: (f, a) => f(...a)
|
|
@@ -7225,11 +7414,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7225
7414
|
const widgets = /* @__PURE__ */ new Map();
|
|
7226
7415
|
const notifier = {
|
|
7227
7416
|
mounted: (state) => {
|
|
7228
|
-
|
|
7417
|
+
log11("widget mounted", {
|
|
7229
7418
|
id: state.id,
|
|
7230
7419
|
tag: state.props._tag
|
|
7231
7420
|
}, {
|
|
7232
|
-
F:
|
|
7421
|
+
F: __dxlog_file17,
|
|
7233
7422
|
L: 206,
|
|
7234
7423
|
S: void 0,
|
|
7235
7424
|
C: (f, a) => f(...a)
|
|
@@ -7241,11 +7430,11 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7241
7430
|
},
|
|
7242
7431
|
unmounted: (id) => {
|
|
7243
7432
|
const state = widgets.get(id);
|
|
7244
|
-
|
|
7433
|
+
log11("widget unmounted", {
|
|
7245
7434
|
id,
|
|
7246
7435
|
tag: state?.props._tag
|
|
7247
7436
|
}, {
|
|
7248
|
-
F:
|
|
7437
|
+
F: __dxlog_file17,
|
|
7249
7438
|
L: 212,
|
|
7250
7439
|
S: void 0,
|
|
7251
7440
|
C: (f, a) => f(...a)
|
|
@@ -7279,7 +7468,7 @@ var keyHandlers = keymap13.of([
|
|
|
7279
7468
|
}
|
|
7280
7469
|
]);
|
|
7281
7470
|
var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
7282
|
-
return
|
|
7471
|
+
return EditorView30.updateListener.of((update2) => {
|
|
7283
7472
|
update2.transactions.forEach((transaction) => {
|
|
7284
7473
|
for (const effect of transaction.effects) {
|
|
7285
7474
|
if (effect.is(navigatePreviousEffect)) {
|
|
@@ -7307,11 +7496,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7307
7496
|
anchor: line.from,
|
|
7308
7497
|
head: line.from
|
|
7309
7498
|
},
|
|
7310
|
-
effects:
|
|
7311
|
-
line: line.number,
|
|
7312
|
-
|
|
7313
|
-
offset: -16
|
|
7314
|
-
}
|
|
7499
|
+
effects: scrollerLineEffect.of({
|
|
7500
|
+
line: line.number - 1,
|
|
7501
|
+
offset: -16
|
|
7315
7502
|
})
|
|
7316
7503
|
});
|
|
7317
7504
|
continue;
|
|
@@ -7342,11 +7529,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7342
7529
|
anchor: line.to,
|
|
7343
7530
|
head: line.to
|
|
7344
7531
|
},
|
|
7345
|
-
effects:
|
|
7346
|
-
line: line.number,
|
|
7347
|
-
|
|
7348
|
-
offset: -16
|
|
7349
|
-
}
|
|
7532
|
+
effects: scrollerLineEffect.of({
|
|
7533
|
+
line: line.number - 1,
|
|
7534
|
+
offset: -16
|
|
7350
7535
|
})
|
|
7351
7536
|
});
|
|
7352
7537
|
} else {
|
|
@@ -7356,11 +7541,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7356
7541
|
anchor: line.to,
|
|
7357
7542
|
head: line.to
|
|
7358
7543
|
},
|
|
7359
|
-
effects:
|
|
7360
|
-
line: line.number,
|
|
7361
|
-
|
|
7362
|
-
position: "end"
|
|
7363
|
-
}
|
|
7544
|
+
effects: scrollerLineEffect.of({
|
|
7545
|
+
line: line.number - 1,
|
|
7546
|
+
position: "end"
|
|
7364
7547
|
})
|
|
7365
7548
|
});
|
|
7366
7549
|
}
|
|
@@ -7370,7 +7553,7 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7370
7553
|
});
|
|
7371
7554
|
});
|
|
7372
7555
|
};
|
|
7373
|
-
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) =>
|
|
7556
|
+
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin21.fromClass(class {
|
|
7374
7557
|
update(update2) {
|
|
7375
7558
|
const widgetStateMap = update2.state.field(widgetStateMapStateField);
|
|
7376
7559
|
const { decorations: decorations2 } = update2.state.field(widgetDecorationsField);
|
|
@@ -7407,6 +7590,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7407
7590
|
update: ({ from, decorations: decorations2 }, tr) => {
|
|
7408
7591
|
for (const effect of tr.effects) {
|
|
7409
7592
|
if (effect.is(xmlTagResetEffect)) {
|
|
7593
|
+
if (tr.docChanged) {
|
|
7594
|
+
return buildDecorations4(tr.state, {
|
|
7595
|
+
from: 0,
|
|
7596
|
+
to: tr.state.doc.length
|
|
7597
|
+
}, registry, notifier);
|
|
7598
|
+
}
|
|
7410
7599
|
return {
|
|
7411
7600
|
from: 0,
|
|
7412
7601
|
decorations: Decoration15.none
|
|
@@ -7417,12 +7606,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7417
7606
|
const { state } = tr;
|
|
7418
7607
|
const reset = tr.changes.touchesRange(0, from);
|
|
7419
7608
|
if (reset) {
|
|
7420
|
-
|
|
7609
|
+
log11("document reset", {
|
|
7421
7610
|
from,
|
|
7422
7611
|
to: state.doc.length
|
|
7423
7612
|
}, {
|
|
7424
|
-
F:
|
|
7425
|
-
L:
|
|
7613
|
+
F: __dxlog_file17,
|
|
7614
|
+
L: 374,
|
|
7426
7615
|
S: void 0,
|
|
7427
7616
|
C: (f, a) => f(...a)
|
|
7428
7617
|
});
|
|
@@ -7449,8 +7638,8 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7449
7638
|
};
|
|
7450
7639
|
},
|
|
7451
7640
|
provide: (field) => [
|
|
7452
|
-
|
|
7453
|
-
|
|
7641
|
+
EditorView30.decorations.from(field, (v) => v.decorations),
|
|
7642
|
+
EditorView30.atomicRanges.of((view) => view.state.field(field).decorations || Decoration15.none)
|
|
7454
7643
|
]
|
|
7455
7644
|
});
|
|
7456
7645
|
var buildDecorations4 = (state, range, registry, notifier) => {
|
|
@@ -7503,9 +7692,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7503
7692
|
}
|
|
7504
7693
|
}
|
|
7505
7694
|
} catch (err) {
|
|
7506
|
-
|
|
7507
|
-
F:
|
|
7508
|
-
L:
|
|
7695
|
+
log11.catch(err, void 0, {
|
|
7696
|
+
F: __dxlog_file17,
|
|
7697
|
+
L: 459,
|
|
7509
7698
|
S: void 0,
|
|
7510
7699
|
C: (f, a) => f(...a)
|
|
7511
7700
|
});
|
|
@@ -7529,8 +7718,8 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7529
7718
|
constructor(id, Component, props, notifier) {
|
|
7530
7719
|
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier;
|
|
7531
7720
|
invariant7(id, void 0, {
|
|
7532
|
-
F:
|
|
7533
|
-
L:
|
|
7721
|
+
F: __dxlog_file17,
|
|
7722
|
+
L: 485,
|
|
7534
7723
|
S: this,
|
|
7535
7724
|
A: [
|
|
7536
7725
|
"id",
|
|
@@ -7624,7 +7813,7 @@ export {
|
|
|
7624
7813
|
EditorInputMode,
|
|
7625
7814
|
EditorInputModes,
|
|
7626
7815
|
EditorState3 as EditorState,
|
|
7627
|
-
|
|
7816
|
+
EditorView31 as EditorView,
|
|
7628
7817
|
EditorViewMode,
|
|
7629
7818
|
EditorViewModes,
|
|
7630
7819
|
Inline,
|
|
@@ -7656,9 +7845,11 @@ export {
|
|
|
7656
7845
|
commentClickedEffect,
|
|
7657
7846
|
comments,
|
|
7658
7847
|
commentsState,
|
|
7848
|
+
compactSlots,
|
|
7659
7849
|
convertTreeToJson,
|
|
7660
7850
|
createBasicExtensions,
|
|
7661
7851
|
createComment,
|
|
7852
|
+
createCrawler,
|
|
7662
7853
|
createDataExtensions,
|
|
7663
7854
|
createEditorStateStore,
|
|
7664
7855
|
createEditorStateTransaction,
|
|
@@ -7678,11 +7869,10 @@ export {
|
|
|
7678
7869
|
defaultThemeSlots,
|
|
7679
7870
|
deleteItem,
|
|
7680
7871
|
documentId,
|
|
7872
|
+
documentSlots,
|
|
7681
7873
|
dropFile,
|
|
7874
|
+
editorClassNames,
|
|
7682
7875
|
editorInputMode,
|
|
7683
|
-
editorSlots,
|
|
7684
|
-
editorWidth,
|
|
7685
|
-
editorWithToolbarLayout,
|
|
7686
7876
|
extendedMarkdown,
|
|
7687
7877
|
filterChars,
|
|
7688
7878
|
flattenRect,
|
|
@@ -7738,10 +7928,12 @@ export {
|
|
|
7738
7928
|
removeList,
|
|
7739
7929
|
removeStyle,
|
|
7740
7930
|
replacer,
|
|
7931
|
+
scrollPastEnd,
|
|
7741
7932
|
scrollThreadIntoView,
|
|
7742
|
-
scrollToBottomEffect,
|
|
7743
7933
|
scrollToLine,
|
|
7744
|
-
|
|
7934
|
+
scroller,
|
|
7935
|
+
scrollerCrawlEffect,
|
|
7936
|
+
scrollerLineEffect,
|
|
7745
7937
|
selectionState,
|
|
7746
7938
|
setBlockquote,
|
|
7747
7939
|
setComments,
|
|
@@ -7749,8 +7941,6 @@ export {
|
|
|
7749
7941
|
setSelection,
|
|
7750
7942
|
setStyle,
|
|
7751
7943
|
singleValueFacet,
|
|
7752
|
-
smoothScroll,
|
|
7753
|
-
stackItemContentEditorClassNames,
|
|
7754
7944
|
staticCompletion,
|
|
7755
7945
|
streamer,
|
|
7756
7946
|
submit,
|