@dxos/ui-editor 0.8.4-main.ef1bc66f44 → 0.8.4-main.fcfe5033a5
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/chunk-D724USEC.mjs +34 -0
- package/dist/lib/browser/chunk-D724USEC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1488 -716
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/chunk-JRVJWKQF.mjs +36 -0
- package/dist/lib/node-esm/chunk-JRVJWKQF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1488 -716
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/defaults.d.ts +4 -10
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts +8 -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/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +2 -2
- 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/action.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/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +2 -0
- 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 +63 -0
- package/dist/types/src/extensions/scroller.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/extended-markdown.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/fader.d.ts +12 -0
- package/dist/types/src/extensions/tags/fader.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/index.d.ts +2 -1
- package/dist/types/src/extensions/tags/index.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/wire.d.ts +23 -0
- package/dist/types/src/extensions/tags/wire.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/wire.test.d.ts +2 -0
- package/dist/types/src/extensions/tags/wire.test.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts +36 -9
- package/dist/types/src/extensions/tags/xml-tags.d.ts.map +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/types/types.d.ts +2 -2
- package/dist/types/src/types/types.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 +30 -30
- package/src/defaults.ts +30 -20
- package/src/extensions/annotations.ts +1 -1
- package/src/extensions/auto-scroll.ts +179 -0
- package/src/extensions/automerge/automerge.test.tsx +2 -2
- package/src/extensions/automerge/automerge.ts +5 -7
- package/src/extensions/blocks.ts +5 -5
- package/src/extensions/comments.ts +5 -6
- package/src/extensions/dnd.ts +2 -2
- package/src/extensions/factories.ts +13 -14
- package/src/extensions/folding.ts +5 -22
- package/src/extensions/index.ts +3 -2
- package/src/extensions/markdown/action.ts +0 -1
- package/src/extensions/markdown/bundle.ts +23 -9
- package/src/extensions/markdown/decorate.ts +15 -12
- 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 +42 -9
- package/src/extensions/markdown/table.ts +24 -2
- package/src/extensions/outliner/outliner.test.ts +0 -1
- package/src/extensions/outliner/outliner.ts +3 -4
- package/src/extensions/outliner/tree.test.ts +0 -1
- package/src/extensions/preview/preview.ts +55 -8
- package/src/extensions/scroll-past-end.ts +32 -0
- package/src/extensions/scroller.ts +245 -0
- package/src/extensions/selection.ts +1 -1
- package/src/extensions/tags/extended-markdown.test.ts +120 -2
- package/src/extensions/tags/extended-markdown.ts +80 -1
- package/src/extensions/tags/fader.ts +195 -0
- package/src/extensions/tags/index.ts +2 -1
- package/src/extensions/tags/wire.test.ts +65 -0
- package/src/extensions/tags/wire.ts +459 -0
- package/src/extensions/tags/xml-tags.ts +211 -34
- package/src/extensions/tags/xml-util.test.ts +111 -23
- package/src/styles/index.ts +0 -2
- package/src/styles/theme.ts +116 -34
- package/src/types/types.ts +10 -2
- package/src/util/cursor.ts +1 -2
- package/dist/lib/browser/chunk-HL3YF6WC.mjs +0 -22
- package/dist/lib/browser/chunk-HL3YF6WC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YJZGD3LY.mjs +0 -24
- package/dist/lib/node-esm/chunk-YJZGD3LY.mjs.map +0 -7
- 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/extensions/tags/streamer.d.ts +0 -12
- package/dist/types/src/extensions/tags/streamer.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/extensions/tags/streamer.ts +0 -243
- package/src/styles/markdown.ts +0 -26
- package/src/styles/tokens.ts +0 -17
|
@@ -4,27 +4,44 @@ import {
|
|
|
4
4
|
EditorInputModes,
|
|
5
5
|
EditorViewMode,
|
|
6
6
|
EditorViewModes
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JRVJWKQF.mjs";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
|
-
import { EditorState as
|
|
11
|
-
import { EditorView as
|
|
10
|
+
import { EditorState as EditorState4 } from "@codemirror/state";
|
|
11
|
+
import { EditorView as EditorView32, 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(
|
|
27
|
+
// NOTE: Container for widget sizing (must have `max-w-[100cqi]`).
|
|
28
|
+
"dx-size-container",
|
|
29
|
+
// Wider margin for web (vs. mobile).
|
|
30
|
+
"pointer-fine:max-w-[min(50rem,100%-4rem)] pointer-coarse:max-w-[min(50rem,100%-2rem)]",
|
|
31
|
+
"mx-auto! w-full"
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var compactSlots = {
|
|
36
|
+
content: {
|
|
37
|
+
className: "mx-2!"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var mobileSlots = {
|
|
22
41
|
content: {
|
|
23
|
-
className:
|
|
42
|
+
className: "mx-2!"
|
|
24
43
|
}
|
|
25
44
|
};
|
|
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
45
|
|
|
29
46
|
// src/extensions/annotations.ts
|
|
30
47
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -59,7 +76,7 @@ var annotations = ({ match } = {}) => {
|
|
|
59
76
|
".cm-annotation": {
|
|
60
77
|
textDecoration: "underline",
|
|
61
78
|
textDecorationStyle: "wavy",
|
|
62
|
-
textDecorationColor: "var(--
|
|
79
|
+
textDecorationColor: "var(--color-error-text)"
|
|
63
80
|
}
|
|
64
81
|
})
|
|
65
82
|
];
|
|
@@ -208,7 +225,7 @@ var singleValueFacet = (defaultValue) => Facet.define({
|
|
|
208
225
|
var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
|
|
209
226
|
var defaultCursorConverter = {
|
|
210
227
|
toCursor: (position) => position.toString(),
|
|
211
|
-
fromCursor: (
|
|
228
|
+
fromCursor: (cursor) => parseInt(cursor)
|
|
212
229
|
};
|
|
213
230
|
var Cursor = class _Cursor {
|
|
214
231
|
static converter = singleValueFacet(defaultCursorConverter);
|
|
@@ -221,9 +238,9 @@ var Cursor = class _Cursor {
|
|
|
221
238
|
to
|
|
222
239
|
].join(":");
|
|
223
240
|
};
|
|
224
|
-
static getRangeFromCursor = (state,
|
|
241
|
+
static getRangeFromCursor = (state, cursor) => {
|
|
225
242
|
const cursorConverter2 = state.facet(_Cursor.converter);
|
|
226
|
-
const parts =
|
|
243
|
+
const parts = cursor.split(":");
|
|
227
244
|
const from = cursorConverter2.fromCursor(parts[0]);
|
|
228
245
|
const to = cursorConverter2.fromCursor(parts[1]);
|
|
229
246
|
return from !== void 0 && to !== void 0 ? {
|
|
@@ -502,228 +519,295 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
502
519
|
];
|
|
503
520
|
};
|
|
504
521
|
|
|
505
|
-
// src/extensions/
|
|
522
|
+
// src/extensions/auto-scroll.ts
|
|
506
523
|
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
507
524
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
508
|
-
import {
|
|
525
|
+
import { addEventListener, combine, throttle } from "@dxos/async";
|
|
509
526
|
import { Domino } from "@dxos/ui";
|
|
527
|
+
import { getSize } from "@dxos/ui-theme";
|
|
510
528
|
|
|
511
|
-
// src/extensions/
|
|
529
|
+
// src/extensions/scroller.ts
|
|
512
530
|
import { StateEffect } from "@codemirror/state";
|
|
513
531
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
514
|
-
|
|
515
|
-
var
|
|
516
|
-
|
|
532
|
+
import { log as log2 } from "@dxos/log";
|
|
533
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
534
|
+
var scrollerLineEffect = StateEffect.define();
|
|
535
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
536
|
+
var scrollToLine = (view, options) => {
|
|
537
|
+
view.dispatch({
|
|
538
|
+
effects: scrollerLineEffect.of(options)
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
542
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
517
543
|
view;
|
|
544
|
+
crawler;
|
|
518
545
|
constructor(view) {
|
|
519
546
|
this.view = view;
|
|
547
|
+
this.crawler = createCrawler(this.view);
|
|
520
548
|
}
|
|
521
549
|
// No-op.
|
|
522
550
|
destroy() {
|
|
551
|
+
this.crawler.cancel();
|
|
523
552
|
}
|
|
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;
|
|
553
|
+
cancel() {
|
|
554
|
+
this.crawler.cancel();
|
|
555
|
+
}
|
|
556
|
+
crawl(start = false) {
|
|
557
|
+
if (start) {
|
|
558
|
+
this.crawler.scroll();
|
|
559
559
|
} else {
|
|
560
|
-
|
|
560
|
+
this.crawler.cancel();
|
|
561
561
|
}
|
|
562
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
563
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
564
562
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
563
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
564
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
565
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
566
|
+
const doc = this.view.state.doc;
|
|
567
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
568
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
569
|
+
const lineStart = doc.line(line + 1).from;
|
|
570
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
571
|
+
if (coords) {
|
|
572
|
+
const currentScrollTop = scrollTop;
|
|
573
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
574
|
+
if (position === "end") {
|
|
575
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
576
|
+
} else {
|
|
577
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
578
|
+
}
|
|
579
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
580
|
+
}
|
|
571
581
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
582
|
+
requestAnimationFrame(() => {
|
|
583
|
+
this.view.scrollDOM.scrollTo({
|
|
584
|
+
top: targetScrollTop
|
|
585
|
+
});
|
|
575
586
|
});
|
|
576
587
|
}
|
|
577
588
|
});
|
|
578
589
|
return [
|
|
579
590
|
scrollPlugin,
|
|
580
|
-
//
|
|
591
|
+
// Listen for effect.s
|
|
581
592
|
EditorView4.updateListener.of((update2) => {
|
|
582
593
|
update2.transactions.forEach((transaction) => {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
});
|
|
594
|
+
try {
|
|
595
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
596
|
+
if (plugin) {
|
|
597
|
+
for (const effect of transaction.effects) {
|
|
598
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
599
|
+
plugin.crawl(effect.value);
|
|
600
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
601
|
+
plugin.scroll(effect.value);
|
|
602
|
+
}
|
|
593
603
|
}
|
|
594
604
|
}
|
|
605
|
+
} catch (err) {
|
|
606
|
+
log2.catch(err, void 0, {
|
|
607
|
+
F: __dxlog_file2,
|
|
608
|
+
L: 146,
|
|
609
|
+
S: void 0,
|
|
610
|
+
C: (f, a) => f(...a)
|
|
611
|
+
});
|
|
595
612
|
}
|
|
596
613
|
});
|
|
614
|
+
}),
|
|
615
|
+
// Styles.
|
|
616
|
+
EditorView4.theme({
|
|
617
|
+
".cm-content": {
|
|
618
|
+
paddingBottom: `${overScroll}px`
|
|
619
|
+
},
|
|
620
|
+
".cm-scroller": {
|
|
621
|
+
overflowY: "scroll",
|
|
622
|
+
overflowAnchor: "none",
|
|
623
|
+
paddingBottom: "0"
|
|
624
|
+
},
|
|
625
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
626
|
+
display: "none"
|
|
627
|
+
},
|
|
628
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
629
|
+
background: "transparent",
|
|
630
|
+
transition: "background 0.15s"
|
|
631
|
+
},
|
|
632
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
633
|
+
background: "var(--color-scrollbar-thumb)"
|
|
634
|
+
},
|
|
635
|
+
".cm-scroll-button": {
|
|
636
|
+
position: "absolute",
|
|
637
|
+
bottom: "0.5rem",
|
|
638
|
+
right: "1rem"
|
|
639
|
+
}
|
|
597
640
|
})
|
|
598
641
|
];
|
|
599
642
|
};
|
|
600
|
-
|
|
601
|
-
view.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
643
|
+
function createCrawler(view, accel = 0.15, maxVelocity = 1, snapThreshold = 0.5) {
|
|
644
|
+
const el = view.scrollDOM;
|
|
645
|
+
let currentTop = 0;
|
|
646
|
+
let velocity = 0;
|
|
647
|
+
let rafId = null;
|
|
648
|
+
function frame() {
|
|
649
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
650
|
+
const delta = targetTop - currentTop;
|
|
651
|
+
const absDelta = Math.abs(delta);
|
|
652
|
+
if (absDelta < snapThreshold && Math.abs(velocity) < snapThreshold) {
|
|
653
|
+
el.scrollTop = targetTop;
|
|
654
|
+
currentTop = targetTop;
|
|
655
|
+
velocity = 0;
|
|
656
|
+
rafId = null;
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
const stoppingDistance = velocity * velocity / (2 * accel);
|
|
660
|
+
const direction = Math.sign(delta);
|
|
661
|
+
if (velocity !== 0 && (absDelta <= stoppingDistance || direction !== Math.sign(velocity))) {
|
|
662
|
+
velocity -= Math.sign(velocity) * Math.min(accel, Math.abs(velocity));
|
|
663
|
+
} else {
|
|
664
|
+
velocity += direction * accel;
|
|
665
|
+
velocity = Math.sign(velocity) * Math.min(Math.abs(velocity), maxVelocity);
|
|
666
|
+
}
|
|
667
|
+
currentTop += velocity;
|
|
668
|
+
el.scrollTop = currentTop;
|
|
669
|
+
rafId = requestAnimationFrame(frame);
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
scroll: () => {
|
|
673
|
+
if (rafId === null) {
|
|
674
|
+
currentTop = el.scrollTop;
|
|
675
|
+
rafId = requestAnimationFrame(frame);
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
cancel: () => {
|
|
679
|
+
if (rafId !== null) {
|
|
680
|
+
cancelAnimationFrame(rafId);
|
|
681
|
+
rafId = null;
|
|
682
|
+
velocity = 0;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
}
|
|
608
687
|
|
|
609
|
-
// src/extensions/
|
|
610
|
-
var
|
|
611
|
-
var autoScroll = (
|
|
688
|
+
// src/extensions/auto-scroll.ts
|
|
689
|
+
var autoScrollEffect = StateEffect2.define();
|
|
690
|
+
var autoScroll = (_ = {}) => {
|
|
612
691
|
let buttonContainer;
|
|
613
|
-
let hideTimeout;
|
|
614
|
-
let lastScrollTop = 0;
|
|
615
692
|
let isPinned = true;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
-
});
|
|
693
|
+
let jumpPending = false;
|
|
694
|
+
let enabled = true;
|
|
695
|
+
let firstUpdate = true;
|
|
696
|
+
const setPinned = (pinned) => {
|
|
697
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
698
|
+
isPinned = pinned;
|
|
645
699
|
};
|
|
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
700
|
return [
|
|
654
|
-
// Update listener for
|
|
655
|
-
EditorView5.updateListener.of((
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
701
|
+
// Update listener for scrolling when content changes.
|
|
702
|
+
EditorView5.updateListener.of((update2) => {
|
|
703
|
+
const { view, heightChanged, state, startState } = update2;
|
|
704
|
+
for (const tr of update2.transactions) {
|
|
705
|
+
for (const effect of tr.effects) {
|
|
706
|
+
if (effect.is(autoScrollEffect)) {
|
|
707
|
+
enabled = effect.value;
|
|
708
|
+
if (enabled) {
|
|
709
|
+
setPinned(true);
|
|
710
|
+
view.dispatch({
|
|
711
|
+
effects: scrollerCrawlEffect.of(true)
|
|
712
|
+
});
|
|
713
|
+
} else {
|
|
714
|
+
view.dispatch({
|
|
715
|
+
effects: scrollerCrawlEffect.of(false)
|
|
716
|
+
});
|
|
717
|
+
}
|
|
660
718
|
}
|
|
661
719
|
}
|
|
662
|
-
}
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
720
|
+
}
|
|
721
|
+
if (!enabled) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
if (isPinned && (firstUpdate || startState.doc.length === 0) && state.doc.length > 0) {
|
|
725
|
+
firstUpdate = false;
|
|
726
|
+
jumpPending = true;
|
|
727
|
+
requestAnimationFrame(() => {
|
|
728
|
+
view.scrollDOM.scrollTop = view.scrollDOM.scrollHeight;
|
|
729
|
+
jumpPending = false;
|
|
730
|
+
});
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
firstUpdate = false;
|
|
734
|
+
if (jumpPending) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (heightChanged) {
|
|
738
|
+
if (isPinned) {
|
|
739
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
740
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
741
|
+
if (delta > 0) {
|
|
742
|
+
setPinned(true);
|
|
743
|
+
view.dispatch({
|
|
744
|
+
effects: scrollerCrawlEffect.of(true)
|
|
745
|
+
});
|
|
746
|
+
} else if (delta < -1) {
|
|
747
|
+
setPinned(false);
|
|
748
|
+
}
|
|
749
|
+
} else {
|
|
750
|
+
if (state.doc.length === 0) {
|
|
751
|
+
setPinned(true);
|
|
674
752
|
}
|
|
675
|
-
} else if (distanceFromBottom < 0) {
|
|
676
|
-
setPinned(false);
|
|
677
753
|
}
|
|
678
754
|
}
|
|
679
755
|
}),
|
|
680
|
-
// Detect user scroll.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
756
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
757
|
+
ViewPlugin6.fromClass(class {
|
|
758
|
+
cleanup;
|
|
759
|
+
constructor(view) {
|
|
760
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
761
|
+
requestAnimationFrame(() => {
|
|
762
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
763
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
764
|
+
const pinned = delta === 0;
|
|
765
|
+
setPinned(pinned);
|
|
766
|
+
if (!pinned) {
|
|
767
|
+
view.dispatch({
|
|
768
|
+
effects: scrollerCrawlEffect.of(false)
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}, 500));
|
|
773
|
+
}
|
|
774
|
+
destroy() {
|
|
775
|
+
this.cleanup();
|
|
691
776
|
}
|
|
692
777
|
}),
|
|
693
778
|
// Scroll button.
|
|
694
779
|
ViewPlugin6.fromClass(class {
|
|
695
780
|
constructor(view) {
|
|
696
|
-
const icon = Domino.of("dx-icon").attributes({
|
|
781
|
+
const icon = Domino.of("dx-icon").classNames(getSize(4)).attributes({
|
|
697
782
|
icon: "ph--arrow-down--regular"
|
|
698
783
|
});
|
|
699
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
784
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
700
785
|
"data-density": "fine"
|
|
701
|
-
}).
|
|
702
|
-
|
|
786
|
+
}).append(icon).on("click", () => {
|
|
787
|
+
setPinned(true);
|
|
788
|
+
view.dispatch({
|
|
789
|
+
effects: scrollerLineEffect.of({
|
|
790
|
+
line: -1,
|
|
791
|
+
position: "end",
|
|
792
|
+
behavior: "smooth"
|
|
793
|
+
})
|
|
794
|
+
});
|
|
703
795
|
});
|
|
704
|
-
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").
|
|
796
|
+
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").append(button).root;
|
|
705
797
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
706
798
|
}
|
|
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
799
|
})
|
|
725
800
|
];
|
|
726
801
|
};
|
|
802
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
803
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
804
|
+
passive: true
|
|
805
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
806
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
807
|
+
onUserScroll();
|
|
808
|
+
}
|
|
809
|
+
}));
|
|
810
|
+
}
|
|
727
811
|
|
|
728
812
|
// src/extensions/automerge/automerge.ts
|
|
729
813
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -737,15 +821,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
737
821
|
|
|
738
822
|
// src/extensions/automerge/cursor.ts
|
|
739
823
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
740
|
-
import { log as
|
|
741
|
-
var
|
|
824
|
+
import { log as log3 } from "@dxos/log";
|
|
825
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
742
826
|
var cursorConverter = (accessor) => ({
|
|
743
827
|
toCursor: (pos, assoc) => {
|
|
744
828
|
try {
|
|
745
829
|
return toCursor(accessor, pos, assoc);
|
|
746
830
|
} catch (err) {
|
|
747
|
-
|
|
748
|
-
F:
|
|
831
|
+
log3.catch(err, void 0, {
|
|
832
|
+
F: __dxlog_file3,
|
|
749
833
|
L: 15,
|
|
750
834
|
S: void 0,
|
|
751
835
|
C: (f, a) => f(...a)
|
|
@@ -753,12 +837,12 @@ var cursorConverter = (accessor) => ({
|
|
|
753
837
|
return "";
|
|
754
838
|
}
|
|
755
839
|
},
|
|
756
|
-
fromCursor: (
|
|
840
|
+
fromCursor: (cursor) => {
|
|
757
841
|
try {
|
|
758
|
-
return fromCursor(accessor,
|
|
842
|
+
return fromCursor(accessor, cursor);
|
|
759
843
|
} catch (err) {
|
|
760
|
-
|
|
761
|
-
F:
|
|
844
|
+
log3.catch(err, void 0, {
|
|
845
|
+
F: __dxlog_file3,
|
|
762
846
|
L: 24,
|
|
763
847
|
S: void 0,
|
|
764
848
|
C: (f, a) => f(...a)
|
|
@@ -783,7 +867,7 @@ var isReconcile = (tr) => {
|
|
|
783
867
|
|
|
784
868
|
// src/extensions/automerge/sync.ts
|
|
785
869
|
import { next as A2 } from "@automerge/automerge";
|
|
786
|
-
import { log as
|
|
870
|
+
import { log as log4 } from "@dxos/log";
|
|
787
871
|
|
|
788
872
|
// src/extensions/automerge/update-automerge.ts
|
|
789
873
|
import { next as A } from "@automerge/automerge";
|
|
@@ -924,7 +1008,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
924
1008
|
};
|
|
925
1009
|
|
|
926
1010
|
// src/extensions/automerge/sync.ts
|
|
927
|
-
var
|
|
1011
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
928
1012
|
var Syncer = class {
|
|
929
1013
|
_handle;
|
|
930
1014
|
_state;
|
|
@@ -947,8 +1031,8 @@ var Syncer = class {
|
|
|
947
1031
|
this._pending = false;
|
|
948
1032
|
}
|
|
949
1033
|
onEditorChange(view) {
|
|
950
|
-
|
|
951
|
-
F:
|
|
1034
|
+
log4("onEditorChange", void 0, {
|
|
1035
|
+
F: __dxlog_file4,
|
|
952
1036
|
L: 45,
|
|
953
1037
|
S: this,
|
|
954
1038
|
C: (f, a) => f(...a)
|
|
@@ -963,8 +1047,8 @@ var Syncer = class {
|
|
|
963
1047
|
}
|
|
964
1048
|
}
|
|
965
1049
|
onAutomergeChange(view) {
|
|
966
|
-
|
|
967
|
-
F:
|
|
1050
|
+
log4("onAutomergeChange", void 0, {
|
|
1051
|
+
F: __dxlog_file4,
|
|
968
1052
|
L: 60,
|
|
969
1053
|
S: this,
|
|
970
1054
|
C: (f, a) => f(...a)
|
|
@@ -1030,6 +1114,17 @@ var automerge = (accessor) => {
|
|
|
1030
1114
|
const value = DocAccessor.getValue(accessor);
|
|
1031
1115
|
const current = this._view.state.doc.toString();
|
|
1032
1116
|
if (value !== current) {
|
|
1117
|
+
this._view.dispatch({
|
|
1118
|
+
changes: {
|
|
1119
|
+
from: 0,
|
|
1120
|
+
to: this._view.state.doc.length,
|
|
1121
|
+
insert: value
|
|
1122
|
+
},
|
|
1123
|
+
annotations: [
|
|
1124
|
+
initialSync,
|
|
1125
|
+
reconcileAnnotation.of(true)
|
|
1126
|
+
]
|
|
1127
|
+
});
|
|
1033
1128
|
}
|
|
1034
1129
|
});
|
|
1035
1130
|
}
|
|
@@ -1057,7 +1152,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1057
1152
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1058
1153
|
import { Event } from "@dxos/async";
|
|
1059
1154
|
import { Context } from "@dxos/context";
|
|
1060
|
-
var
|
|
1155
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1061
1156
|
var dummyProvider = {
|
|
1062
1157
|
remoteStateChange: new Event(),
|
|
1063
1158
|
open: () => {
|
|
@@ -1081,7 +1176,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1081
1176
|
};
|
|
1082
1177
|
var RemoteSelectionsDecorator = class {
|
|
1083
1178
|
_ctx = new Context(void 0, {
|
|
1084
|
-
F:
|
|
1179
|
+
F: __dxlog_file5,
|
|
1085
1180
|
L: 80
|
|
1086
1181
|
});
|
|
1087
1182
|
_cursorConverter;
|
|
@@ -1294,8 +1389,8 @@ var styles = EditorView7.theme({
|
|
|
1294
1389
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1295
1390
|
import { Context as Context2 } from "@dxos/context";
|
|
1296
1391
|
import { invariant } from "@dxos/invariant";
|
|
1297
|
-
import { log as
|
|
1298
|
-
var
|
|
1392
|
+
import { log as log5 } from "@dxos/log";
|
|
1393
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1299
1394
|
var DEBOUNCE_INTERVAL = 100;
|
|
1300
1395
|
var SpaceAwarenessProvider = class {
|
|
1301
1396
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1315,7 +1410,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1315
1410
|
}
|
|
1316
1411
|
open() {
|
|
1317
1412
|
this._ctx = new Context2(void 0, {
|
|
1318
|
-
F:
|
|
1413
|
+
F: __dxlog_file6,
|
|
1319
1414
|
L: 57
|
|
1320
1415
|
});
|
|
1321
1416
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1342,10 +1437,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1342
1437
|
void this._messenger.postMessage(this._channel, {
|
|
1343
1438
|
kind: "query"
|
|
1344
1439
|
}).catch((err) => {
|
|
1345
|
-
|
|
1440
|
+
log5.debug("failed to query awareness", {
|
|
1346
1441
|
err
|
|
1347
1442
|
}, {
|
|
1348
|
-
F:
|
|
1443
|
+
F: __dxlog_file6,
|
|
1349
1444
|
L: 91,
|
|
1350
1445
|
S: this,
|
|
1351
1446
|
C: (f, a) => f(...a)
|
|
@@ -1362,7 +1457,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1362
1457
|
}
|
|
1363
1458
|
update(position) {
|
|
1364
1459
|
invariant(this._postTask, void 0, {
|
|
1365
|
-
F:
|
|
1460
|
+
F: __dxlog_file6,
|
|
1366
1461
|
L: 106,
|
|
1367
1462
|
S: this,
|
|
1368
1463
|
A: [
|
|
@@ -1379,7 +1474,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1379
1474
|
}
|
|
1380
1475
|
_handleQueryMessage() {
|
|
1381
1476
|
invariant(this._postTask, void 0, {
|
|
1382
|
-
F:
|
|
1477
|
+
F: __dxlog_file6,
|
|
1383
1478
|
L: 117,
|
|
1384
1479
|
S: this,
|
|
1385
1480
|
A: [
|
|
@@ -1391,7 +1486,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1391
1486
|
}
|
|
1392
1487
|
_handlePostMessage(message) {
|
|
1393
1488
|
invariant(message.kind === "post", void 0, {
|
|
1394
|
-
F:
|
|
1489
|
+
F: __dxlog_file6,
|
|
1395
1490
|
L: 122,
|
|
1396
1491
|
S: this,
|
|
1397
1492
|
A: [
|
|
@@ -1407,9 +1502,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1407
1502
|
// src/extensions/blast.ts
|
|
1408
1503
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1409
1504
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1410
|
-
import { throttle } from "@dxos/async";
|
|
1505
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1411
1506
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1412
|
-
var
|
|
1507
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1413
1508
|
var defaultOptions = {
|
|
1414
1509
|
effect: 2,
|
|
1415
1510
|
maxParticles: 200,
|
|
@@ -1528,7 +1623,7 @@ var Blaster = class {
|
|
|
1528
1623
|
}
|
|
1529
1624
|
initialize() {
|
|
1530
1625
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1531
|
-
F:
|
|
1626
|
+
F: __dxlog_file7,
|
|
1532
1627
|
L: 142,
|
|
1533
1628
|
S: this,
|
|
1534
1629
|
A: [
|
|
@@ -1565,7 +1660,7 @@ var Blaster = class {
|
|
|
1565
1660
|
}
|
|
1566
1661
|
start() {
|
|
1567
1662
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1568
|
-
F:
|
|
1663
|
+
F: __dxlog_file7,
|
|
1569
1664
|
L: 181,
|
|
1570
1665
|
S: this,
|
|
1571
1666
|
A: [
|
|
@@ -1599,11 +1694,11 @@ var Blaster = class {
|
|
|
1599
1694
|
this.drawParticles();
|
|
1600
1695
|
requestAnimationFrame(this.loop.bind(this));
|
|
1601
1696
|
}
|
|
1602
|
-
shake =
|
|
1697
|
+
shake = throttle2(({ time }) => {
|
|
1603
1698
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1604
1699
|
this._shakeTimeMax = time;
|
|
1605
1700
|
}, 100);
|
|
1606
|
-
spawn =
|
|
1701
|
+
spawn = throttle2(({ element, point }) => {
|
|
1607
1702
|
const color = getRGBComponents(element, this._options.color);
|
|
1608
1703
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1609
1704
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1777,11 +1872,11 @@ var blocks = () => [
|
|
|
1777
1872
|
".cm-line.block-line": {
|
|
1778
1873
|
paddingLeft: "0.75rem",
|
|
1779
1874
|
paddingRight: "0.75rem",
|
|
1780
|
-
borderLeft: "1px solid var(--
|
|
1781
|
-
borderRight: "1px solid var(--
|
|
1875
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1876
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1782
1877
|
},
|
|
1783
1878
|
".cm-line.block-single": {
|
|
1784
|
-
border: "1px solid var(--
|
|
1879
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1785
1880
|
borderRadius: "6px",
|
|
1786
1881
|
paddingTop: "0.5rem",
|
|
1787
1882
|
paddingBottom: "0.5rem",
|
|
@@ -1789,7 +1884,7 @@ var blocks = () => [
|
|
|
1789
1884
|
marginBottom: "0.5rem"
|
|
1790
1885
|
},
|
|
1791
1886
|
".cm-line.block-first": {
|
|
1792
|
-
borderTop: "1px solid var(--
|
|
1887
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1793
1888
|
borderTopLeftRadius: "6px",
|
|
1794
1889
|
borderTopRightRadius: "6px",
|
|
1795
1890
|
paddingTop: "0.5rem",
|
|
@@ -1797,7 +1892,7 @@ var blocks = () => [
|
|
|
1797
1892
|
},
|
|
1798
1893
|
".cm-line.block-middle": {},
|
|
1799
1894
|
".cm-line.block-last": {
|
|
1800
|
-
borderBottom: "1px solid var(--
|
|
1895
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1801
1896
|
borderBottomLeftRadius: "6px",
|
|
1802
1897
|
borderBottomRightRadius: "6px",
|
|
1803
1898
|
paddingBottom: "0.5rem",
|
|
@@ -1809,8 +1904,8 @@ var blocks = () => [
|
|
|
1809
1904
|
// src/extensions/bookmarks.ts
|
|
1810
1905
|
import { Prec as Prec3, StateEffect as StateEffect4, StateField as StateField2 } from "@codemirror/state";
|
|
1811
1906
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1812
|
-
import { log as
|
|
1813
|
-
var
|
|
1907
|
+
import { log as log6 } from "@dxos/log";
|
|
1908
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1814
1909
|
var addBookmark = StateEffect4.define();
|
|
1815
1910
|
var removeBookmark = StateEffect4.define();
|
|
1816
1911
|
var clearBookmarks = StateEffect4.define();
|
|
@@ -1822,8 +1917,8 @@ var bookmarks = () => {
|
|
|
1822
1917
|
key: "Mod-ArrowUp",
|
|
1823
1918
|
run: (view) => {
|
|
1824
1919
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1825
|
-
|
|
1826
|
-
F:
|
|
1920
|
+
log6("up", bookmarks2, {
|
|
1921
|
+
F: __dxlog_file8,
|
|
1827
1922
|
L: 29,
|
|
1828
1923
|
S: void 0,
|
|
1829
1924
|
C: (f, a) => f(...a)
|
|
@@ -1835,8 +1930,8 @@ var bookmarks = () => {
|
|
|
1835
1930
|
key: "Mod-ArrowDown",
|
|
1836
1931
|
run: (view) => {
|
|
1837
1932
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1838
|
-
|
|
1839
|
-
F:
|
|
1933
|
+
log6("down", bookmarks2, {
|
|
1934
|
+
F: __dxlog_file8,
|
|
1840
1935
|
L: 37,
|
|
1841
1936
|
S: void 0,
|
|
1842
1937
|
C: (f, a) => f(...a)
|
|
@@ -1880,19 +1975,19 @@ import { invertedEffects } from "@codemirror/commands";
|
|
|
1880
1975
|
import { StateEffect as StateEffect5, StateField as StateField3 } from "@codemirror/state";
|
|
1881
1976
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1882
1977
|
import sortBy from "lodash.sortby";
|
|
1883
|
-
import { debounce as
|
|
1884
|
-
import { log as
|
|
1978
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1979
|
+
import { log as log7 } from "@dxos/log";
|
|
1885
1980
|
import { isNonNullable } from "@dxos/util";
|
|
1886
1981
|
|
|
1887
1982
|
// src/extensions/selection.ts
|
|
1888
1983
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1889
1984
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1890
|
-
import { debounce
|
|
1985
|
+
import { debounce } from "@dxos/async";
|
|
1891
1986
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1892
1987
|
import { isTruthy } from "@dxos/util";
|
|
1893
|
-
var
|
|
1988
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1894
1989
|
var documentId = singleValueFacet();
|
|
1895
|
-
var stateRestoreAnnotation = "dxos.
|
|
1990
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1896
1991
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1897
1992
|
return {
|
|
1898
1993
|
selection,
|
|
@@ -1906,7 +2001,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1906
2001
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1907
2002
|
getState: (id) => {
|
|
1908
2003
|
invariant3(id, void 0, {
|
|
1909
|
-
F:
|
|
2004
|
+
F: __dxlog_file9,
|
|
1910
2005
|
L: 47,
|
|
1911
2006
|
S: void 0,
|
|
1912
2007
|
A: [
|
|
@@ -1919,7 +2014,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1919
2014
|
},
|
|
1920
2015
|
setState: (id, state) => {
|
|
1921
2016
|
invariant3(id, void 0, {
|
|
1922
|
-
F:
|
|
2017
|
+
F: __dxlog_file9,
|
|
1923
2018
|
L: 53,
|
|
1924
2019
|
S: void 0,
|
|
1925
2020
|
A: [
|
|
@@ -1931,7 +2026,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1931
2026
|
}
|
|
1932
2027
|
});
|
|
1933
2028
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1934
|
-
const setStateDebounced =
|
|
2029
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1935
2030
|
return [
|
|
1936
2031
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1937
2032
|
// EditorView.domEventHandlers({
|
|
@@ -1978,7 +2073,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1978
2073
|
};
|
|
1979
2074
|
|
|
1980
2075
|
// src/extensions/comments.ts
|
|
1981
|
-
var
|
|
2076
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
1982
2077
|
var setComments = StateEffect5.define();
|
|
1983
2078
|
var setSelection = StateEffect5.define();
|
|
1984
2079
|
var setCommentState = StateEffect5.define();
|
|
@@ -2023,14 +2118,14 @@ var commentsState = StateField3.define({
|
|
|
2023
2118
|
var styles2 = EditorView11.theme({
|
|
2024
2119
|
".cm-comment, .cm-comment-current": {
|
|
2025
2120
|
padding: "3px 0",
|
|
2026
|
-
color: "var(--
|
|
2027
|
-
backgroundColor: "var(--
|
|
2121
|
+
color: "var(--color-cm-comment-text)",
|
|
2122
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2028
2123
|
},
|
|
2029
2124
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2030
2125
|
boxDecorationBreak: "clone",
|
|
2031
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2032
|
-
backgroundColor: "var(--
|
|
2033
|
-
color: "var(--
|
|
2126
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2127
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2128
|
+
color: "var(--color-cm-comment-text)",
|
|
2034
2129
|
cursor: "pointer"
|
|
2035
2130
|
}
|
|
2036
2131
|
});
|
|
@@ -2048,9 +2143,9 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2048
2143
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2049
2144
|
const range = comment.range;
|
|
2050
2145
|
if (!range) {
|
|
2051
|
-
|
|
2052
|
-
F:
|
|
2053
|
-
L:
|
|
2146
|
+
log7.warn("Invalid range:", range, {
|
|
2147
|
+
F: __dxlog_file10,
|
|
2148
|
+
L: 139,
|
|
2054
2149
|
S: void 0,
|
|
2055
2150
|
C: (f, a) => f(...a)
|
|
2056
2151
|
});
|
|
@@ -2166,10 +2261,10 @@ var trackPastedComments = (onUpdate) => {
|
|
|
2166
2261
|
const { comments: comments2 } = update2.startState.field(commentsState);
|
|
2167
2262
|
const exists = comments2.some((c) => c.comment.id === comment.id && c.range.from < c.range.to);
|
|
2168
2263
|
if (!exists) {
|
|
2169
|
-
const
|
|
2264
|
+
const cursor = Cursor.getCursorFromRange(update2.state, comment);
|
|
2170
2265
|
onUpdate({
|
|
2171
2266
|
id: comment.id,
|
|
2172
|
-
cursor
|
|
2267
|
+
cursor
|
|
2173
2268
|
});
|
|
2174
2269
|
}
|
|
2175
2270
|
}
|
|
@@ -2198,13 +2293,13 @@ var createComment = (view) => {
|
|
|
2198
2293
|
}
|
|
2199
2294
|
});
|
|
2200
2295
|
}
|
|
2201
|
-
const
|
|
2296
|
+
const cursor = Cursor.getCursorFromRange(view.state, {
|
|
2202
2297
|
from,
|
|
2203
2298
|
to
|
|
2204
2299
|
});
|
|
2205
|
-
if (
|
|
2300
|
+
if (cursor) {
|
|
2206
2301
|
options.onCreate?.({
|
|
2207
|
-
cursor
|
|
2302
|
+
cursor,
|
|
2208
2303
|
from,
|
|
2209
2304
|
location: view.coordsAtPos(from)
|
|
2210
2305
|
});
|
|
@@ -2215,7 +2310,7 @@ var createComment = (view) => {
|
|
|
2215
2310
|
var optionsFacet = singleValueFacet();
|
|
2216
2311
|
var comments = (options = {}) => {
|
|
2217
2312
|
const { key: shortcut = "meta-'" } = options;
|
|
2218
|
-
const handleSelect =
|
|
2313
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2219
2314
|
return [
|
|
2220
2315
|
optionsFacet.of(options),
|
|
2221
2316
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2393,9 +2488,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2393
2488
|
// src/extensions/debug.ts
|
|
2394
2489
|
import { syntaxTree } from "@codemirror/language";
|
|
2395
2490
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2396
|
-
var debugNodeLogger = (
|
|
2491
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2397
2492
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2398
|
-
enter: (node) =>
|
|
2493
|
+
enter: (node) => log12(node.type)
|
|
2399
2494
|
});
|
|
2400
2495
|
return StateField4.define({
|
|
2401
2496
|
create: (state) => logTokens(state),
|
|
@@ -2430,8 +2525,8 @@ var dropFile = (options = {}) => {
|
|
|
2430
2525
|
};
|
|
2431
2526
|
var styles3 = EditorView12.theme({
|
|
2432
2527
|
".cm-dropCursor": {
|
|
2433
|
-
borderLeft: "2px solid var(--
|
|
2434
|
-
color: "var(--
|
|
2528
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2529
|
+
color: "var(--color-accent-text)",
|
|
2435
2530
|
padding: "0 4px"
|
|
2436
2531
|
},
|
|
2437
2532
|
".cm-dropCursor:after": {
|
|
@@ -2445,47 +2540,66 @@ import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap }
|
|
|
2445
2540
|
import { HighlightStyle, bracketMatching, syntaxHighlighting } from "@codemirror/language";
|
|
2446
2541
|
import { searchKeymap } from "@codemirror/search";
|
|
2447
2542
|
import { EditorState } from "@codemirror/state";
|
|
2448
|
-
import { EditorView as
|
|
2543
|
+
import { EditorView as EditorView16, ViewPlugin as ViewPlugin12, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap7, lineNumbers, placeholder as placeholder2 } from "@codemirror/view";
|
|
2449
2544
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2450
2545
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2451
2546
|
import { generateName } from "@dxos/display-name";
|
|
2452
|
-
import { log as
|
|
2547
|
+
import { log as log8 } from "@dxos/log";
|
|
2453
2548
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2454
2549
|
|
|
2455
|
-
// src/styles/
|
|
2550
|
+
// src/styles/theme.ts
|
|
2551
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2456
2552
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2457
2553
|
var headings = {
|
|
2458
|
-
1:
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2554
|
+
1: {
|
|
2555
|
+
className: "text-3xl",
|
|
2556
|
+
fontSize: "var(--text-3xl)",
|
|
2557
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2558
|
+
},
|
|
2559
|
+
2: {
|
|
2560
|
+
className: "text-2xl",
|
|
2561
|
+
fontSize: "var(--text-2xl)",
|
|
2562
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2563
|
+
},
|
|
2564
|
+
3: {
|
|
2565
|
+
className: "text-xl",
|
|
2566
|
+
fontSize: "var(--text-xl)",
|
|
2567
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2568
|
+
},
|
|
2569
|
+
4: {
|
|
2570
|
+
className: "text-lg",
|
|
2571
|
+
fontSize: "var(--text-lg)",
|
|
2572
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2573
|
+
},
|
|
2574
|
+
5: {
|
|
2575
|
+
className: "text-base",
|
|
2576
|
+
fontSize: "var(--text-base)",
|
|
2577
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2578
|
+
},
|
|
2579
|
+
6: {
|
|
2580
|
+
className: "text-base",
|
|
2581
|
+
fontSize: "var(--text-base)",
|
|
2582
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2583
|
+
}
|
|
2464
2584
|
};
|
|
2585
|
+
var fontBody = '"Inter Variable", ui-sans-serif, system-ui, sans-serif';
|
|
2586
|
+
var fontMono = '"JetBrains Mono Variable", ui-monospace, "Cascadia Code", "Source Code Pro", monospace';
|
|
2465
2587
|
var markdownTheme = {
|
|
2466
|
-
code: "font-mono
|
|
2467
|
-
codeMark: "font-mono
|
|
2468
|
-
mark: "
|
|
2469
|
-
heading: (level) => {
|
|
2470
|
-
|
|
2471
|
-
|
|
2588
|
+
code: "font-mono! cm-code-inline",
|
|
2589
|
+
codeMark: "font-mono! cm-code-mark",
|
|
2590
|
+
mark: "font-mono!",
|
|
2591
|
+
heading: (level) => ({
|
|
2592
|
+
className: mx3(headings[level].className, "font-light text-(--color-cm-heading-number)"),
|
|
2593
|
+
color: "var(--color-cm-heading) !important",
|
|
2594
|
+
lineHeight: headings[level].lineHeight,
|
|
2595
|
+
fontSize: headings[level].fontSize,
|
|
2596
|
+
fontWeight: "100 !important"
|
|
2597
|
+
})
|
|
2472
2598
|
};
|
|
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
2599
|
var baseTheme = EditorView13.baseTheme({
|
|
2600
|
+
/**
|
|
2601
|
+
* Outer frame.
|
|
2602
|
+
*/
|
|
2489
2603
|
"&": {},
|
|
2490
2604
|
"&.cm-focused": {
|
|
2491
2605
|
outline: "none"
|
|
@@ -2494,7 +2608,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2494
2608
|
* Scroller
|
|
2495
2609
|
*/
|
|
2496
2610
|
".cm-scroller": {
|
|
2497
|
-
|
|
2611
|
+
overflowAnchor: "none"
|
|
2612
|
+
},
|
|
2613
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2614
|
+
width: "8px"
|
|
2615
|
+
},
|
|
2616
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2617
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2618
|
+
background: "transparent",
|
|
2619
|
+
transition: "background 0.15s"
|
|
2620
|
+
},
|
|
2621
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2622
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2498
2623
|
},
|
|
2499
2624
|
/**
|
|
2500
2625
|
* Content
|
|
@@ -2502,7 +2627,6 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2502
2627
|
*/
|
|
2503
2628
|
".cm-content": {
|
|
2504
2629
|
padding: "unset",
|
|
2505
|
-
lineHeight: "24px",
|
|
2506
2630
|
color: "unset"
|
|
2507
2631
|
},
|
|
2508
2632
|
/**
|
|
@@ -2516,8 +2640,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2516
2640
|
".cm-gutter": {},
|
|
2517
2641
|
".cm-gutter.cm-lineNumbers": {
|
|
2518
2642
|
paddingRight: "4px",
|
|
2519
|
-
borderRight: "1px solid var(--
|
|
2520
|
-
color: "var(--
|
|
2643
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2644
|
+
color: "var(--color-subdued)"
|
|
2521
2645
|
},
|
|
2522
2646
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2523
2647
|
minWidth: "40px"
|
|
@@ -2526,36 +2650,43 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2526
2650
|
* Height is set to match the corresponding line (which may have wrapped).
|
|
2527
2651
|
*/
|
|
2528
2652
|
".cm-gutterElement": {
|
|
2529
|
-
lineHeight:
|
|
2653
|
+
lineHeight: 1.5,
|
|
2530
2654
|
fontSize: "12px"
|
|
2531
2655
|
},
|
|
2532
2656
|
/**
|
|
2533
2657
|
* Line.
|
|
2534
2658
|
*/
|
|
2535
2659
|
".cm-line": {
|
|
2536
|
-
lineHeight:
|
|
2660
|
+
lineHeight: 1.5,
|
|
2537
2661
|
paddingInline: 0
|
|
2538
2662
|
},
|
|
2663
|
+
/**
|
|
2664
|
+
* Force all inline children to inherit line-height to prevent monospace font metrics
|
|
2665
|
+
* (JetBrains Mono ascent/descent) from inflating the line box beyond 24px.
|
|
2666
|
+
*/
|
|
2667
|
+
".cm-line *": {
|
|
2668
|
+
lineHeight: "inherit"
|
|
2669
|
+
},
|
|
2539
2670
|
".cm-activeLine": {
|
|
2540
|
-
background: "var(--
|
|
2671
|
+
background: "var(--color-cm-active-line)"
|
|
2541
2672
|
},
|
|
2542
2673
|
/**
|
|
2543
2674
|
* Cursor (layer).
|
|
2544
2675
|
*/
|
|
2545
2676
|
".cm-cursor, .cm-dropCursor": {
|
|
2546
|
-
borderLeft: "2px solid var(--
|
|
2677
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2547
2678
|
},
|
|
2548
2679
|
".cm-placeholder": {
|
|
2549
|
-
color: "var(--
|
|
2680
|
+
color: "var(--color-placeholder)"
|
|
2550
2681
|
},
|
|
2551
2682
|
/**
|
|
2552
2683
|
* Selection (layer).
|
|
2553
2684
|
*/
|
|
2554
2685
|
".cm-selectionBackground": {
|
|
2555
|
-
background: "var(--
|
|
2686
|
+
background: "var(--color-cm-selection)"
|
|
2556
2687
|
},
|
|
2557
2688
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2558
|
-
background: "var(--
|
|
2689
|
+
background: "var(--color-cm-focused-selection)"
|
|
2559
2690
|
},
|
|
2560
2691
|
/**
|
|
2561
2692
|
* Search.
|
|
@@ -2565,8 +2696,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2565
2696
|
margin: "0 -3px",
|
|
2566
2697
|
padding: "3px",
|
|
2567
2698
|
borderRadius: "3px",
|
|
2568
|
-
background: "var(--
|
|
2569
|
-
color: "var(--
|
|
2699
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2700
|
+
color: "var(--color-cm-highlight)"
|
|
2570
2701
|
},
|
|
2571
2702
|
".cm-searchMatch-selected": {
|
|
2572
2703
|
textDecoration: "underline"
|
|
@@ -2577,20 +2708,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2577
2708
|
".cm-link": {
|
|
2578
2709
|
textDecorationLine: "underline",
|
|
2579
2710
|
textDecorationThickness: "1px",
|
|
2580
|
-
textDecorationColor: "var(--
|
|
2711
|
+
textDecorationColor: "var(--color-separator)",
|
|
2581
2712
|
textUnderlineOffset: "2px",
|
|
2582
2713
|
borderRadius: ".125rem"
|
|
2583
2714
|
},
|
|
2584
2715
|
".cm-link > span": {
|
|
2585
|
-
color: "var(--
|
|
2716
|
+
color: "var(--color-accent-text)"
|
|
2717
|
+
},
|
|
2718
|
+
".cm-link > span:hover": {
|
|
2719
|
+
color: "var(--color-accent-text-hover)"
|
|
2586
2720
|
},
|
|
2587
2721
|
/**
|
|
2588
2722
|
* Tooltip.
|
|
2589
2723
|
*/
|
|
2590
2724
|
".cm-tooltip": {
|
|
2591
|
-
background: "var(--
|
|
2725
|
+
background: "var(--color-modal-surface)"
|
|
2592
2726
|
},
|
|
2593
2727
|
".cm-tooltip-below": {},
|
|
2728
|
+
".cm-tooltip-hover": {
|
|
2729
|
+
background: "var(--color-modal-surface)",
|
|
2730
|
+
border: "1px solid var(--color-separator)",
|
|
2731
|
+
borderRadius: "4px",
|
|
2732
|
+
overflow: "hidden"
|
|
2733
|
+
},
|
|
2594
2734
|
/**
|
|
2595
2735
|
* Autocomplete.
|
|
2596
2736
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2598,7 +2738,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2598
2738
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2599
2739
|
marginTop: "6px",
|
|
2600
2740
|
marginLeft: "-10px",
|
|
2601
|
-
border: "2px solid var(--
|
|
2741
|
+
border: "2px solid var(--color-separator)",
|
|
2602
2742
|
borderRadius: "4px"
|
|
2603
2743
|
},
|
|
2604
2744
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2608,12 +2748,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2608
2748
|
padding: "4px"
|
|
2609
2749
|
},
|
|
2610
2750
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2611
|
-
background: "var(--
|
|
2612
|
-
color: "var(--
|
|
2751
|
+
background: "var(--color-active-surface)",
|
|
2752
|
+
color: "var(--color-base-surface-text)"
|
|
2613
2753
|
},
|
|
2614
2754
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2615
2755
|
paddingLeft: "4px !important",
|
|
2616
|
-
color: "var(--
|
|
2756
|
+
color: "var(--color-base-surface-text)"
|
|
2617
2757
|
},
|
|
2618
2758
|
/**
|
|
2619
2759
|
* Completion info.
|
|
@@ -2622,17 +2762,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2622
2762
|
width: "360px !important",
|
|
2623
2763
|
margin: "-10px 1px 0 1px",
|
|
2624
2764
|
padding: "8px !important",
|
|
2625
|
-
borderColor: "var(--
|
|
2765
|
+
borderColor: "var(--color-separator)"
|
|
2626
2766
|
},
|
|
2627
2767
|
".cm-completionIcon": {
|
|
2628
2768
|
display: "none"
|
|
2629
2769
|
},
|
|
2630
2770
|
".cm-completionLabel": {
|
|
2631
|
-
color: "var(--
|
|
2771
|
+
color: "var(--color-description)",
|
|
2632
2772
|
padding: "0 4px"
|
|
2633
2773
|
},
|
|
2634
2774
|
".cm-completionMatchedText": {
|
|
2635
|
-
color: "var(--
|
|
2775
|
+
color: "var(--color-base-surface-text)",
|
|
2636
2776
|
textDecoration: "none !important"
|
|
2637
2777
|
},
|
|
2638
2778
|
/**
|
|
@@ -2656,7 +2796,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2656
2796
|
backgroundColor: "var(--surface-bg)"
|
|
2657
2797
|
},
|
|
2658
2798
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2659
|
-
color: "var(--
|
|
2799
|
+
color: "var(--color-subdued)",
|
|
2660
2800
|
fontSize: "14px",
|
|
2661
2801
|
all: "unset",
|
|
2662
2802
|
margin: "3px !important",
|
|
@@ -2664,10 +2804,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2664
2804
|
outline: "1px solid transparent"
|
|
2665
2805
|
},
|
|
2666
2806
|
".cm-panel input, .cm-panel button": {
|
|
2667
|
-
backgroundColor: "var(--
|
|
2807
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2668
2808
|
},
|
|
2669
2809
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2670
|
-
outline: "1px solid var(--
|
|
2810
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2671
2811
|
},
|
|
2672
2812
|
".cm-panel label": {
|
|
2673
2813
|
display: "inline-flex",
|
|
@@ -2680,33 +2820,33 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2680
2820
|
height: "8px",
|
|
2681
2821
|
marginRight: "6px !important",
|
|
2682
2822
|
padding: "2px !important",
|
|
2683
|
-
color: "var(--
|
|
2823
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2684
2824
|
},
|
|
2685
2825
|
".cm-panel button": {
|
|
2686
2826
|
"&:hover": {
|
|
2687
|
-
|
|
2827
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2828
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2688
2829
|
},
|
|
2689
2830
|
"&:active": {
|
|
2690
|
-
backgroundColor: "var(--
|
|
2831
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2691
2832
|
}
|
|
2692
2833
|
},
|
|
2693
2834
|
".cm-panel.cm-search": {
|
|
2694
2835
|
padding: "4px",
|
|
2695
|
-
borderTop: "1px solid var(--
|
|
2836
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2696
2837
|
}
|
|
2697
2838
|
});
|
|
2698
2839
|
var editorGutter = EditorView13.theme({
|
|
2699
2840
|
".cm-gutters": {
|
|
2700
2841
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2701
|
-
background: "var(--
|
|
2842
|
+
background: "var(--color-base-surface) !important",
|
|
2702
2843
|
paddingRight: "1rem"
|
|
2703
2844
|
}
|
|
2704
2845
|
});
|
|
2705
2846
|
var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
2706
|
-
//
|
|
2847
|
+
// Main content.
|
|
2707
2848
|
".cm-scroller": {
|
|
2708
|
-
fontFamily: monospace ? fontMono : fontBody
|
|
2709
|
-
fontSize: "16px"
|
|
2849
|
+
fontFamily: monospace ? fontMono : fontBody
|
|
2710
2850
|
},
|
|
2711
2851
|
// Maintain defaults for UI components.
|
|
2712
2852
|
".cm-content, .cm-gutters, .cm-panel": {
|
|
@@ -2746,9 +2886,32 @@ var focus = [
|
|
|
2746
2886
|
})
|
|
2747
2887
|
];
|
|
2748
2888
|
|
|
2889
|
+
// src/extensions/scroll-past-end.ts
|
|
2890
|
+
import { EditorView as EditorView15, ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
|
2891
|
+
var scrollPastEndPlugin = ViewPlugin11.fromClass(class {
|
|
2892
|
+
height = 1e3;
|
|
2893
|
+
attrs = {
|
|
2894
|
+
style: "padding-bottom: 1000px"
|
|
2895
|
+
};
|
|
2896
|
+
update({ view }) {
|
|
2897
|
+
const lastLineBlock = view.lineBlockAt(view.state.doc.length);
|
|
2898
|
+
const height = view.dom.clientHeight - lastLineBlock.height - view.documentPadding.top - 0.5;
|
|
2899
|
+
if (height >= 0 && height !== this.height) {
|
|
2900
|
+
this.height = height;
|
|
2901
|
+
this.attrs = {
|
|
2902
|
+
style: `padding-bottom: ${height}px`
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
});
|
|
2907
|
+
var scrollPastEnd = () => [
|
|
2908
|
+
scrollPastEndPlugin,
|
|
2909
|
+
EditorView15.contentAttributes.of((view) => view.plugin(scrollPastEndPlugin)?.attrs ?? null)
|
|
2910
|
+
];
|
|
2911
|
+
|
|
2749
2912
|
// src/extensions/factories.ts
|
|
2750
|
-
var
|
|
2751
|
-
var tabbable =
|
|
2913
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2914
|
+
var tabbable = EditorView16.contentAttributes.of({
|
|
2752
2915
|
tabindex: "0"
|
|
2753
2916
|
});
|
|
2754
2917
|
var filterChars = (chars) => {
|
|
@@ -2801,10 +2964,10 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2801
2964
|
const props = defaultsDeep2({}, propsProp, defaultBasicOptions);
|
|
2802
2965
|
return [
|
|
2803
2966
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
F:
|
|
2807
|
-
L:
|
|
2967
|
+
EditorView16.exceptionSink.of((err) => {
|
|
2968
|
+
log8.catch(err, void 0, {
|
|
2969
|
+
F: __dxlog_file11,
|
|
2970
|
+
L: 130,
|
|
2808
2971
|
S: void 0,
|
|
2809
2972
|
C: (f, a) => f(...a)
|
|
2810
2973
|
});
|
|
@@ -2816,7 +2979,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2816
2979
|
props.drawSelection && drawSelection({
|
|
2817
2980
|
cursorBlinkRate: 1200
|
|
2818
2981
|
}),
|
|
2819
|
-
props.editable !== void 0 &&
|
|
2982
|
+
props.editable !== void 0 && EditorView16.editable.of(props.editable),
|
|
2820
2983
|
props.focus && focus,
|
|
2821
2984
|
props.highlightActiveLine && highlightActiveLine(),
|
|
2822
2985
|
props.history && history(),
|
|
@@ -2824,7 +2987,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2824
2987
|
lineNumbers(),
|
|
2825
2988
|
editorGutter
|
|
2826
2989
|
],
|
|
2827
|
-
props.lineWrapping &&
|
|
2990
|
+
props.lineWrapping && EditorView16.lineWrapping,
|
|
2828
2991
|
props.placeholder && placeholder2(props.placeholder),
|
|
2829
2992
|
props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
|
|
2830
2993
|
props.scrollPastEnd && scrollPastEnd(),
|
|
@@ -2856,12 +3019,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2856
3019
|
};
|
|
2857
3020
|
var grow = {
|
|
2858
3021
|
editor: {
|
|
2859
|
-
className: "
|
|
3022
|
+
className: "h-full w-full"
|
|
2860
3023
|
}
|
|
2861
3024
|
};
|
|
2862
3025
|
var fullWidth = {
|
|
2863
3026
|
editor: {
|
|
2864
|
-
className: "
|
|
3027
|
+
className: "w-full"
|
|
2865
3028
|
}
|
|
2866
3029
|
};
|
|
2867
3030
|
var defaultThemeSlots = grow;
|
|
@@ -2873,20 +3036,22 @@ var createThemeExtensions = ({ monospace, themeMode, slots: slotsProp, syntaxHig
|
|
|
2873
3036
|
const slots = defaultsDeep2({}, slotsProp, defaultThemeSlots);
|
|
2874
3037
|
return [
|
|
2875
3038
|
baseTheme,
|
|
2876
|
-
|
|
3039
|
+
EditorView16.darkTheme.of(themeMode === "dark"),
|
|
2877
3040
|
createFontTheme({
|
|
2878
3041
|
monospace
|
|
2879
3042
|
}),
|
|
2880
3043
|
syntaxHighlightingProp && syntaxHighlighting(HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light)),
|
|
2881
|
-
slots.editor?.className &&
|
|
3044
|
+
slots.editor?.className && EditorView16.editorAttributes.of({
|
|
2882
3045
|
class: slots.editor.className
|
|
2883
3046
|
}),
|
|
2884
|
-
slots.content?.className &&
|
|
3047
|
+
slots.content?.className && EditorView16.contentAttributes.of({
|
|
2885
3048
|
class: slots.content.className
|
|
2886
3049
|
}),
|
|
2887
|
-
slots.
|
|
3050
|
+
slots.scroller?.className && ViewPlugin12.fromClass(class {
|
|
2888
3051
|
constructor(view) {
|
|
2889
|
-
|
|
3052
|
+
if (slots.scroller?.className) {
|
|
3053
|
+
view.scrollDOM.classList.add(...slots.scroller.className.split(/\s+/));
|
|
3054
|
+
}
|
|
2890
3055
|
}
|
|
2891
3056
|
})
|
|
2892
3057
|
].filter(isTruthy2);
|
|
@@ -2904,8 +3069,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2904
3069
|
channel: `awareness.${id}`,
|
|
2905
3070
|
peerId: identity.identityKey.toHex(),
|
|
2906
3071
|
info: {
|
|
2907
|
-
darkColor: `var(--
|
|
2908
|
-
lightColor: `var(--
|
|
3072
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
3073
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2909
3074
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2910
3075
|
}
|
|
2911
3076
|
})));
|
|
@@ -2915,7 +3080,7 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2915
3080
|
|
|
2916
3081
|
// src/extensions/folding.ts
|
|
2917
3082
|
import { codeFolding, foldGutter } from "@codemirror/language";
|
|
2918
|
-
import { EditorView as
|
|
3083
|
+
import { EditorView as EditorView17 } from "@codemirror/view";
|
|
2919
3084
|
import { Domino as Domino2, mx as mx4 } from "@dxos/ui";
|
|
2920
3085
|
var folding = () => {
|
|
2921
3086
|
return [
|
|
@@ -2923,13 +3088,14 @@ var folding = () => {
|
|
|
2923
3088
|
placeholderDOM: () => Domino2.of("span").root
|
|
2924
3089
|
}),
|
|
2925
3090
|
foldGutter({
|
|
3091
|
+
// NOTE: We can't animate since the element is remounted on state change.
|
|
2926
3092
|
markerDOM: (open) => {
|
|
2927
|
-
return Domino2.of("div").classNames("flex
|
|
3093
|
+
return Domino2.of("div").classNames("flex h-full justify-center items-center").append(Domino2.of("svg", Domino2.SVG).classNames(mx4("w-4 h-4 cursor-pointer", open && "rotate-90")).append(Domino2.of("use", Domino2.SVG).attributes({
|
|
2928
3094
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2929
3095
|
}))).root;
|
|
2930
3096
|
}
|
|
2931
3097
|
}),
|
|
2932
|
-
|
|
3098
|
+
EditorView17.theme({
|
|
2933
3099
|
".cm-foldGutter": {
|
|
2934
3100
|
opacity: 0.3,
|
|
2935
3101
|
transition: "opacity 0.3s",
|
|
@@ -2943,7 +3109,7 @@ var folding = () => {
|
|
|
2943
3109
|
};
|
|
2944
3110
|
|
|
2945
3111
|
// src/extensions/hashtag.ts
|
|
2946
|
-
import { Decoration as Decoration8, EditorView as
|
|
3112
|
+
import { Decoration as Decoration8, EditorView as EditorView18, MatchDecorator, ViewPlugin as ViewPlugin13, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
2947
3113
|
import { getHashStyles, mx as mx5 } from "@dxos/ui-theme";
|
|
2948
3114
|
var TagWidget = class extends WidgetType4 {
|
|
2949
3115
|
_text;
|
|
@@ -2964,7 +3130,7 @@ var tagMatcher = new MatchDecorator({
|
|
|
2964
3130
|
})
|
|
2965
3131
|
});
|
|
2966
3132
|
var hashtag = () => [
|
|
2967
|
-
|
|
3133
|
+
ViewPlugin13.fromClass(class {
|
|
2968
3134
|
tags;
|
|
2969
3135
|
constructor(view) {
|
|
2970
3136
|
this.tags = tagMatcher.createDeco(view);
|
|
@@ -2974,11 +3140,11 @@ var hashtag = () => [
|
|
|
2974
3140
|
}
|
|
2975
3141
|
}, {
|
|
2976
3142
|
decorations: (instance) => instance.tags,
|
|
2977
|
-
provide: (plugin) =>
|
|
3143
|
+
provide: (plugin) => EditorView18.atomicRanges.of((view) => {
|
|
2978
3144
|
return view.plugin(plugin)?.tags || Decoration8.none;
|
|
2979
3145
|
})
|
|
2980
3146
|
}),
|
|
2981
|
-
|
|
3147
|
+
EditorView18.theme({
|
|
2982
3148
|
".cm-tag": {
|
|
2983
3149
|
borderRadius: "4px",
|
|
2984
3150
|
marginRight: "6px",
|
|
@@ -3033,18 +3199,18 @@ var schemaLinter = (validate) => (view) => {
|
|
|
3033
3199
|
};
|
|
3034
3200
|
|
|
3035
3201
|
// src/extensions/listener.ts
|
|
3036
|
-
import { EditorView as
|
|
3202
|
+
import { EditorView as EditorView19 } from "@codemirror/view";
|
|
3037
3203
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
3038
3204
|
var listener = ({ onFocus, onChange }) => {
|
|
3039
3205
|
return [
|
|
3040
|
-
onFocus &&
|
|
3206
|
+
onFocus && EditorView19.focusChangeEffect.of((state, focusing) => {
|
|
3041
3207
|
onFocus({
|
|
3042
3208
|
id: state.facet(documentId),
|
|
3043
3209
|
focusing
|
|
3044
3210
|
});
|
|
3045
3211
|
return null;
|
|
3046
3212
|
}),
|
|
3047
|
-
onChange &&
|
|
3213
|
+
onChange && EditorView19.updateListener.of(({ state, docChanged }) => {
|
|
3048
3214
|
if (docChanged) {
|
|
3049
3215
|
onChange({
|
|
3050
3216
|
id: state.facet(documentId),
|
|
@@ -3059,7 +3225,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
|
3059
3225
|
import { snippet } from "@codemirror/autocomplete";
|
|
3060
3226
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
3061
3227
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
|
3062
|
-
import { EditorView as
|
|
3228
|
+
import { EditorView as EditorView20, keymap as keymap8 } from "@codemirror/view";
|
|
3063
3229
|
import { debounceAndThrottle } from "@dxos/async";
|
|
3064
3230
|
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
3231
|
var Inline = /* @__PURE__ */ (function(Inline2) {
|
|
@@ -4148,7 +4314,7 @@ var getFormatting = (state) => {
|
|
|
4148
4314
|
};
|
|
4149
4315
|
};
|
|
4150
4316
|
var formattingListener = (onStateChange, delay = 100) => {
|
|
4151
|
-
return
|
|
4317
|
+
return EditorView20.updateListener.of(debounceAndThrottle((update2) => {
|
|
4152
4318
|
if (update2.docChanged || update2.selectionSet) {
|
|
4153
4319
|
onStateChange(getFormatting(update2.state));
|
|
4154
4320
|
}
|
|
@@ -4209,8 +4375,7 @@ import { completionKeymap } from "@codemirror/autocomplete";
|
|
|
4209
4375
|
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
|
4210
4376
|
import { jsonLanguage } from "@codemirror/lang-json";
|
|
4211
4377
|
import { markdown, markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
|
|
4212
|
-
import {
|
|
4213
|
-
import { LanguageDescription, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4378
|
+
import { foldNodeProp, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4214
4379
|
import { languages } from "@codemirror/language-data";
|
|
4215
4380
|
import { keymap as keymap9 } from "@codemirror/view";
|
|
4216
4381
|
import { isTruthy as isTruthy3 } from "@dxos/util";
|
|
@@ -4331,30 +4496,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4331
4496
|
],
|
|
4332
4497
|
class: "font-mono"
|
|
4333
4498
|
},
|
|
4334
|
-
// Headings
|
|
4499
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4500
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4501
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4502
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4503
|
+
{
|
|
4504
|
+
tag: tags.heading,
|
|
4505
|
+
color: "var(--color-cm-heading) !important",
|
|
4506
|
+
fontWeight: "300"
|
|
4507
|
+
},
|
|
4335
4508
|
{
|
|
4336
4509
|
tag: tags.heading1,
|
|
4337
|
-
|
|
4510
|
+
...markdownTheme.heading(1)
|
|
4338
4511
|
},
|
|
4339
4512
|
{
|
|
4340
4513
|
tag: tags.heading2,
|
|
4341
|
-
|
|
4514
|
+
...markdownTheme.heading(2)
|
|
4342
4515
|
},
|
|
4343
4516
|
{
|
|
4344
4517
|
tag: tags.heading3,
|
|
4345
|
-
|
|
4518
|
+
...markdownTheme.heading(3)
|
|
4346
4519
|
},
|
|
4347
4520
|
{
|
|
4348
4521
|
tag: tags.heading4,
|
|
4349
|
-
|
|
4522
|
+
...markdownTheme.heading(4)
|
|
4350
4523
|
},
|
|
4351
4524
|
{
|
|
4352
4525
|
tag: tags.heading5,
|
|
4353
|
-
|
|
4526
|
+
...markdownTheme.heading(5)
|
|
4354
4527
|
},
|
|
4355
4528
|
{
|
|
4356
4529
|
tag: tags.heading6,
|
|
4357
|
-
|
|
4530
|
+
...markdownTheme.heading(6)
|
|
4358
4531
|
},
|
|
4359
4532
|
// Emphasis.
|
|
4360
4533
|
{
|
|
@@ -4409,15 +4582,23 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4409
4582
|
// https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown
|
|
4410
4583
|
base: markdownLanguage2,
|
|
4411
4584
|
// Languages for syntax highlighting fenced code blocks.
|
|
4585
|
+
// Caller-supplied languages are checked first so they can override defaults.
|
|
4412
4586
|
defaultCodeLanguage: jsonLanguage,
|
|
4413
|
-
codeLanguages:
|
|
4587
|
+
codeLanguages: [
|
|
4588
|
+
...options.codeLanguages ?? [],
|
|
4589
|
+
...languages
|
|
4590
|
+
],
|
|
4414
4591
|
// Don't complete HTML tags.
|
|
4415
4592
|
completeHTMLTags: false,
|
|
4416
4593
|
// Parser extensions.
|
|
4417
4594
|
extensions: [
|
|
4418
4595
|
// GFM provided by default.
|
|
4419
4596
|
markdownTagsExtensions,
|
|
4420
|
-
...options.extensions ?? defaultExtensions()
|
|
4597
|
+
...options.extensions ?? defaultExtensions(),
|
|
4598
|
+
// Disable folding for fenced code blocks by overriding foldNodeProp.
|
|
4599
|
+
// Note: returning null from foldService does not prevent syntaxFolding fallback,
|
|
4600
|
+
// so we must override the node prop directly on the FencedCode node type.
|
|
4601
|
+
noFencedCodeFolding
|
|
4421
4602
|
]
|
|
4422
4603
|
}),
|
|
4423
4604
|
// Custom styles.
|
|
@@ -4432,18 +4613,13 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4432
4613
|
].filter(isTruthy3))
|
|
4433
4614
|
];
|
|
4434
4615
|
};
|
|
4435
|
-
var
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
]
|
|
4441
|
-
|
|
4442
|
-
"xml",
|
|
4443
|
-
"xhtml"
|
|
4444
|
-
],
|
|
4445
|
-
load: async () => xml()
|
|
4446
|
-
});
|
|
4616
|
+
var noFencedCodeFolding = {
|
|
4617
|
+
props: [
|
|
4618
|
+
foldNodeProp.add({
|
|
4619
|
+
FencedCode: () => null
|
|
4620
|
+
})
|
|
4621
|
+
]
|
|
4622
|
+
};
|
|
4447
4623
|
var defaultExtensions = () => [
|
|
4448
4624
|
noSetExtHeading,
|
|
4449
4625
|
noHtml
|
|
@@ -4463,19 +4639,19 @@ var debugTree = (cb) => StateField6.define({
|
|
|
4463
4639
|
update: (value, tr) => cb(convertTreeToJson(tr.state))
|
|
4464
4640
|
});
|
|
4465
4641
|
var convertTreeToJson = (state) => {
|
|
4466
|
-
const treeToJson = (
|
|
4642
|
+
const treeToJson = (cursor) => {
|
|
4467
4643
|
const node = {
|
|
4468
|
-
type:
|
|
4469
|
-
from:
|
|
4470
|
-
to:
|
|
4471
|
-
text: state.doc.slice(
|
|
4644
|
+
type: cursor.type.name,
|
|
4645
|
+
from: cursor.from,
|
|
4646
|
+
to: cursor.to,
|
|
4647
|
+
text: state.doc.slice(cursor.from, cursor.to).toString(),
|
|
4472
4648
|
children: []
|
|
4473
4649
|
};
|
|
4474
|
-
if (
|
|
4650
|
+
if (cursor.firstChild()) {
|
|
4475
4651
|
do {
|
|
4476
|
-
node.children.push(treeToJson(
|
|
4477
|
-
} while (
|
|
4478
|
-
|
|
4652
|
+
node.children.push(treeToJson(cursor));
|
|
4653
|
+
} while (cursor.nextSibling());
|
|
4654
|
+
cursor.parent();
|
|
4479
4655
|
}
|
|
4480
4656
|
return node;
|
|
4481
4657
|
};
|
|
@@ -4485,16 +4661,15 @@ var convertTreeToJson = (state) => {
|
|
|
4485
4661
|
// src/extensions/markdown/decorate.ts
|
|
4486
4662
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4487
4663
|
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect7 } from "@codemirror/state";
|
|
4488
|
-
import { Decoration as Decoration11, EditorView as
|
|
4664
|
+
import { Decoration as Decoration11, EditorView as EditorView24, ViewPlugin as ViewPlugin15, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4489
4665
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4490
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
4491
4666
|
|
|
4492
4667
|
// src/extensions/markdown/changes.ts
|
|
4493
4668
|
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
|
4494
4669
|
import { Transaction as Transaction4 } from "@codemirror/state";
|
|
4495
|
-
import { ViewPlugin as
|
|
4670
|
+
import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
|
|
4496
4671
|
var adjustChanges = () => {
|
|
4497
|
-
return
|
|
4672
|
+
return ViewPlugin14.fromClass(class {
|
|
4498
4673
|
update(update2) {
|
|
4499
4674
|
const tree = syntaxTree4(update2.state);
|
|
4500
4675
|
const adjustments = [];
|
|
@@ -4636,7 +4811,7 @@ var getValidUrl = (str) => {
|
|
|
4636
4811
|
// src/extensions/markdown/image.ts
|
|
4637
4812
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
|
4638
4813
|
import { StateField as StateField7 } from "@codemirror/state";
|
|
4639
|
-
import { Decoration as Decoration9, EditorView as
|
|
4814
|
+
import { Decoration as Decoration9, EditorView as EditorView21, WidgetType as WidgetType5 } from "@codemirror/view";
|
|
4640
4815
|
var image = (_options = {}) => {
|
|
4641
4816
|
return [
|
|
4642
4817
|
StateField7.define({
|
|
@@ -4647,10 +4822,10 @@ var image = (_options = {}) => {
|
|
|
4647
4822
|
if (!tr.docChanged && !tr.selection) {
|
|
4648
4823
|
return value;
|
|
4649
4824
|
}
|
|
4650
|
-
const
|
|
4825
|
+
const cursor = tr.state.selection.main.head;
|
|
4651
4826
|
const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);
|
|
4652
|
-
let from = Math.min(
|
|
4653
|
-
let to = Math.max(
|
|
4827
|
+
let from = Math.min(cursor, oldCursor);
|
|
4828
|
+
let to = Math.max(cursor, oldCursor);
|
|
4654
4829
|
tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {
|
|
4655
4830
|
from = Math.min(from, fromB);
|
|
4656
4831
|
to = Math.max(to, toB);
|
|
@@ -4664,19 +4839,19 @@ var image = (_options = {}) => {
|
|
|
4664
4839
|
add: buildDecorations(tr.state, from, to)
|
|
4665
4840
|
});
|
|
4666
4841
|
},
|
|
4667
|
-
provide: (field) =>
|
|
4842
|
+
provide: (field) => EditorView21.decorations.from(field)
|
|
4668
4843
|
})
|
|
4669
4844
|
];
|
|
4670
4845
|
};
|
|
4671
4846
|
var buildDecorations = (state, from, to) => {
|
|
4672
4847
|
const decorations2 = [];
|
|
4673
|
-
const
|
|
4848
|
+
const cursor = state.selection.main.head;
|
|
4674
4849
|
syntaxTree5(state).iterate({
|
|
4675
4850
|
enter: (node) => {
|
|
4676
4851
|
if (node.name === "Image") {
|
|
4677
4852
|
const urlNode = node.node.getChild("URL");
|
|
4678
4853
|
if (urlNode) {
|
|
4679
|
-
const hide2 = state.readOnly ||
|
|
4854
|
+
const hide2 = state.readOnly || cursor < node.from || cursor > node.to || !state.field(focusField);
|
|
4680
4855
|
const url = state.sliceDoc(urlNode.from, urlNode.to);
|
|
4681
4856
|
if (url.match(/^https?:\/\//) === null && url.match(/^file?:\/\//) === null) {
|
|
4682
4857
|
return;
|
|
@@ -4724,10 +4899,10 @@ var ImageWidget = class extends WidgetType5 {
|
|
|
4724
4899
|
};
|
|
4725
4900
|
|
|
4726
4901
|
// src/extensions/markdown/styles.ts
|
|
4727
|
-
import { EditorView as
|
|
4902
|
+
import { EditorView as EditorView22 } from "@codemirror/view";
|
|
4728
4903
|
var bulletListIndentationWidth = 24;
|
|
4729
4904
|
var orderedListIndentationWidth = 36;
|
|
4730
|
-
var formattingStyles =
|
|
4905
|
+
var formattingStyles = EditorView22.theme({
|
|
4731
4906
|
/**
|
|
4732
4907
|
* Horizontal rule.
|
|
4733
4908
|
*/
|
|
@@ -4736,7 +4911,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4736
4911
|
width: "100%",
|
|
4737
4912
|
height: "0",
|
|
4738
4913
|
verticalAlign: "middle",
|
|
4739
|
-
borderTop: "1px solid var(--
|
|
4914
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4740
4915
|
opacity: 0.5
|
|
4741
4916
|
},
|
|
4742
4917
|
/**
|
|
@@ -4759,19 +4934,44 @@ var formattingStyles = EditorView21.theme({
|
|
|
4759
4934
|
* Blockquote.
|
|
4760
4935
|
*/
|
|
4761
4936
|
"& .cm-blockquote": {
|
|
4762
|
-
background: "var(--
|
|
4763
|
-
borderLeft: "2px solid var(--
|
|
4937
|
+
background: "var(--color-cm-codeblock)",
|
|
4938
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4764
4939
|
paddingLeft: "1rem",
|
|
4765
|
-
margin:
|
|
4940
|
+
margin: 0
|
|
4766
4941
|
},
|
|
4767
4942
|
/**
|
|
4768
4943
|
* Code and codeblocks.
|
|
4769
4944
|
*/
|
|
4945
|
+
"& code": {
|
|
4946
|
+
fontFamily: fontMono,
|
|
4947
|
+
color: "var(--color-cm-code)",
|
|
4948
|
+
whiteSpace: "nowrap"
|
|
4949
|
+
},
|
|
4770
4950
|
"& .cm-code": {
|
|
4771
|
-
fontFamily: fontMono
|
|
4951
|
+
fontFamily: fontMono,
|
|
4952
|
+
color: "var(--color-cm-code)"
|
|
4953
|
+
},
|
|
4954
|
+
// Inline code spans (triggered by backticks) use `cm-code-inline` + `font-mono`.
|
|
4955
|
+
// Different monospace font metrics can slightly overflow the fixed CodeMirror line box,
|
|
4956
|
+
// so constrain them to the target 24px height.
|
|
4957
|
+
"& .cm-code-inline": {
|
|
4958
|
+
fontFamily: fontMono,
|
|
4959
|
+
height: "24px",
|
|
4960
|
+
// display: 'inline-flex',
|
|
4961
|
+
alignItems: "center",
|
|
4962
|
+
overflow: "hidden",
|
|
4963
|
+
whiteSpace: "nowrap",
|
|
4964
|
+
color: "var(--color-cm-code-inline)"
|
|
4965
|
+
},
|
|
4966
|
+
"& .cm-code-mark": {
|
|
4967
|
+
fontFamily: fontMono,
|
|
4968
|
+
height: "24px",
|
|
4969
|
+
display: "inline-flex",
|
|
4970
|
+
alignItems: "center",
|
|
4971
|
+
overflow: "hidden"
|
|
4772
4972
|
},
|
|
4773
4973
|
"& .cm-codeblock-line": {
|
|
4774
|
-
background: "var(--
|
|
4974
|
+
background: "var(--color-cm-codeblock)",
|
|
4775
4975
|
paddingInline: "1rem !important"
|
|
4776
4976
|
},
|
|
4777
4977
|
"& .cm-codeblock-start": {
|
|
@@ -4800,16 +5000,24 @@ var formattingStyles = EditorView21.theme({
|
|
|
4800
5000
|
*/
|
|
4801
5001
|
".cm-table *": {
|
|
4802
5002
|
fontFamily: fontMono,
|
|
5003
|
+
lineHeight: 1.5,
|
|
4803
5004
|
textDecoration: "none !important"
|
|
4804
5005
|
},
|
|
4805
5006
|
".cm-table-head": {
|
|
4806
5007
|
padding: "2px 16px 2px 0px",
|
|
5008
|
+
overflowWrap: "break-word",
|
|
5009
|
+
whiteSpace: "pre-wrap",
|
|
5010
|
+
wordBreak: "keep-all",
|
|
4807
5011
|
textAlign: "left",
|
|
4808
|
-
|
|
4809
|
-
|
|
5012
|
+
color: "var(--color-subdued)",
|
|
5013
|
+
borderBottom: "1px solid var(--color-cm-separator)"
|
|
4810
5014
|
},
|
|
4811
5015
|
".cm-table-cell": {
|
|
4812
|
-
padding: "2px 16px 2px 0px"
|
|
5016
|
+
padding: "2px 16px 2px 0px",
|
|
5017
|
+
overflowWrap: "break-word",
|
|
5018
|
+
whiteSpace: "pre-wrap",
|
|
5019
|
+
wordBreak: "keep-all",
|
|
5020
|
+
verticalAlign: "top"
|
|
4813
5021
|
},
|
|
4814
5022
|
/**
|
|
4815
5023
|
* Image.
|
|
@@ -4825,12 +5033,12 @@ var formattingStyles = EditorView21.theme({
|
|
|
4825
5033
|
},
|
|
4826
5034
|
".cm-image-with-loader": {
|
|
4827
5035
|
display: "block",
|
|
4828
|
-
opacity:
|
|
5036
|
+
opacity: 0,
|
|
4829
5037
|
transitionDuration: "350ms",
|
|
4830
5038
|
transitionProperty: "opacity"
|
|
4831
5039
|
},
|
|
4832
5040
|
".cm-image-with-loader.cm-loaded-image": {
|
|
4833
|
-
opacity:
|
|
5041
|
+
opacity: 1
|
|
4834
5042
|
},
|
|
4835
5043
|
".cm-image-wrapper": {
|
|
4836
5044
|
"grid-template-columns": "1fr",
|
|
@@ -4849,17 +5057,17 @@ var formattingStyles = EditorView21.theme({
|
|
|
4849
5057
|
// src/extensions/markdown/table.ts
|
|
4850
5058
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
|
4851
5059
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
|
4852
|
-
import { Decoration as Decoration10, EditorView as
|
|
5060
|
+
import { Decoration as Decoration10, EditorView as EditorView23, WidgetType as WidgetType6 } from "@codemirror/view";
|
|
4853
5061
|
var table = (options = {}) => {
|
|
4854
5062
|
return StateField8.define({
|
|
4855
5063
|
create: (state) => update(state, options),
|
|
4856
5064
|
update: (_, tr) => update(tr.state, options),
|
|
4857
|
-
provide: (field) =>
|
|
5065
|
+
provide: (field) => EditorView23.decorations.from(field)
|
|
4858
5066
|
});
|
|
4859
5067
|
};
|
|
4860
5068
|
var update = (state, _options) => {
|
|
4861
5069
|
const builder = new RangeSetBuilder4();
|
|
4862
|
-
const
|
|
5070
|
+
const cursor = state.selection.main.head;
|
|
4863
5071
|
const tables = [];
|
|
4864
5072
|
const getTable = () => tables[tables.length - 1];
|
|
4865
5073
|
const getRow = () => {
|
|
@@ -4897,7 +5105,7 @@ var update = (state, _options) => {
|
|
|
4897
5105
|
}
|
|
4898
5106
|
});
|
|
4899
5107
|
tables.forEach((table2) => {
|
|
4900
|
-
const replace = state.readOnly ||
|
|
5108
|
+
const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
|
|
4901
5109
|
if (replace) {
|
|
4902
5110
|
builder.add(table2.from, table2.to, Decoration10.replace({
|
|
4903
5111
|
block: true,
|
|
@@ -4911,6 +5119,26 @@ var update = (state, _options) => {
|
|
|
4911
5119
|
});
|
|
4912
5120
|
return builder.finish();
|
|
4913
5121
|
};
|
|
5122
|
+
var renderCellContent = (el, text) => {
|
|
5123
|
+
const parts = text.split(/(`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_)/);
|
|
5124
|
+
for (const part of parts) {
|
|
5125
|
+
if (part.length > 2 && part.startsWith("`") && part.endsWith("`")) {
|
|
5126
|
+
const code = document.createElement("code");
|
|
5127
|
+
code.textContent = part.slice(1, -1);
|
|
5128
|
+
el.appendChild(code);
|
|
5129
|
+
} else if (part.startsWith("**") && part.endsWith("**") || part.startsWith("__") && part.endsWith("__")) {
|
|
5130
|
+
const strong = document.createElement("strong");
|
|
5131
|
+
strong.textContent = part.slice(2, -2);
|
|
5132
|
+
el.appendChild(strong);
|
|
5133
|
+
} else if (part.startsWith("*") && part.endsWith("*") || part.startsWith("_") && part.endsWith("_")) {
|
|
5134
|
+
const em = document.createElement("em");
|
|
5135
|
+
em.textContent = part.slice(1, -1);
|
|
5136
|
+
el.appendChild(em);
|
|
5137
|
+
} else {
|
|
5138
|
+
el.appendChild(document.createTextNode(part));
|
|
5139
|
+
}
|
|
5140
|
+
}
|
|
5141
|
+
};
|
|
4914
5142
|
var TableWidget = class extends WidgetType6 {
|
|
4915
5143
|
_table;
|
|
4916
5144
|
constructor(_table) {
|
|
@@ -4930,7 +5158,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4930
5158
|
this._table.header?.forEach((cell) => {
|
|
4931
5159
|
const th = document.createElement("th");
|
|
4932
5160
|
th.setAttribute("class", "cm-table-head");
|
|
4933
|
-
tr.appendChild(th)
|
|
5161
|
+
renderCellContent(tr.appendChild(th), cell);
|
|
4934
5162
|
});
|
|
4935
5163
|
const body = table2.appendChild(document.createElement("tbody"));
|
|
4936
5164
|
this._table.rows?.forEach((row) => {
|
|
@@ -4938,7 +5166,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4938
5166
|
row.forEach((cell) => {
|
|
4939
5167
|
const td = document.createElement("td");
|
|
4940
5168
|
td.setAttribute("class", "cm-table-cell");
|
|
4941
|
-
tr2.appendChild(td)
|
|
5169
|
+
renderCellContent(tr2.appendChild(td), cell);
|
|
4942
5170
|
});
|
|
4943
5171
|
});
|
|
4944
5172
|
return div;
|
|
@@ -4946,7 +5174,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4946
5174
|
};
|
|
4947
5175
|
|
|
4948
5176
|
// src/extensions/markdown/decorate.ts
|
|
4949
|
-
var
|
|
5177
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4950
5178
|
var Unicode = {
|
|
4951
5179
|
emDash: "\u2014",
|
|
4952
5180
|
bullet: "\u2022",
|
|
@@ -4969,7 +5197,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4969
5197
|
eq(other) {
|
|
4970
5198
|
return this.url === other.url;
|
|
4971
5199
|
}
|
|
4972
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4973
5200
|
toDOM(view) {
|
|
4974
5201
|
const el = document.createElement("span");
|
|
4975
5202
|
this.render(el, {
|
|
@@ -5046,10 +5273,10 @@ var fencedCodeLine = Decoration11.line({
|
|
|
5046
5273
|
class: "cm-code cm-codeblock-line"
|
|
5047
5274
|
});
|
|
5048
5275
|
var fencedCodeLineFirst = Decoration11.line({
|
|
5049
|
-
class:
|
|
5276
|
+
class: "cm-code cm-codeblock-line cm-codeblock-start"
|
|
5050
5277
|
});
|
|
5051
5278
|
var fencedCodeLineLast = Decoration11.line({
|
|
5052
|
-
class:
|
|
5279
|
+
class: "cm-code cm-codeblock-line cm-codeblock-end"
|
|
5053
5280
|
});
|
|
5054
5281
|
var commentBlockLine = fencedCodeLine;
|
|
5055
5282
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
|
@@ -5082,8 +5309,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5082
5309
|
const headerLevels = [];
|
|
5083
5310
|
const getHeaderLevels = (node, level) => {
|
|
5084
5311
|
invariant4(level > 0, void 0, {
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5312
|
+
F: __dxlog_file12,
|
|
5313
|
+
L: 177,
|
|
5087
5314
|
S: void 0,
|
|
5088
5315
|
A: [
|
|
5089
5316
|
"level > 0",
|
|
@@ -5121,8 +5348,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5121
5348
|
};
|
|
5122
5349
|
const getCurrentListLevel = () => {
|
|
5123
5350
|
invariant4(listLevels.length, void 0, {
|
|
5124
|
-
F:
|
|
5125
|
-
L:
|
|
5351
|
+
F: __dxlog_file12,
|
|
5352
|
+
L: 199,
|
|
5126
5353
|
S: void 0,
|
|
5127
5354
|
A: [
|
|
5128
5355
|
"listLevels.length",
|
|
@@ -5166,13 +5393,13 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5166
5393
|
deco: hide
|
|
5167
5394
|
});
|
|
5168
5395
|
} else {
|
|
5169
|
-
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
|
5396
|
+
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + "). ";
|
|
5170
5397
|
if (num.length) {
|
|
5171
5398
|
atomicDecoRanges.push({
|
|
5172
5399
|
from: mark.from,
|
|
5173
5400
|
to: mark.from + len,
|
|
5174
5401
|
deco: Decoration11.replace({
|
|
5175
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5402
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5176
5403
|
})
|
|
5177
5404
|
});
|
|
5178
5405
|
}
|
|
@@ -5349,11 +5576,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5349
5576
|
}
|
|
5350
5577
|
decoRanges.push({
|
|
5351
5578
|
from: marks[0].to,
|
|
5352
|
-
to: marks[1].from,
|
|
5579
|
+
to: !editing && options.renderLinkButton ? node.to : marks[1].from,
|
|
5353
5580
|
deco: Decoration11.mark({
|
|
5354
5581
|
tagName: "a",
|
|
5355
5582
|
attributes: {
|
|
5356
|
-
class: "cm-link",
|
|
5583
|
+
class: options.renderLinkButton ? "cm-link cm-link-with-button" : "cm-link",
|
|
5357
5584
|
href: url,
|
|
5358
5585
|
rel: "noreferrer",
|
|
5359
5586
|
target: "_blank"
|
|
@@ -5431,8 +5658,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5431
5658
|
deco.add(from, to, d);
|
|
5432
5659
|
}
|
|
5433
5660
|
const atomicDeco = new RangeSetBuilder5();
|
|
5434
|
-
for (const { from, to, deco:
|
|
5435
|
-
|
|
5661
|
+
for (const { from, to, deco: deco2 } of atomicDecoRanges) {
|
|
5662
|
+
if (from < to && state.doc.lineAt(from).number !== state.doc.lineAt(to).number) {
|
|
5663
|
+
continue;
|
|
5664
|
+
}
|
|
5665
|
+
atomicDeco.add(from, to, deco2);
|
|
5436
5666
|
}
|
|
5437
5667
|
return {
|
|
5438
5668
|
deco: deco.finish(),
|
|
@@ -5442,7 +5672,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5442
5672
|
var forceUpdate = StateEffect7.define();
|
|
5443
5673
|
var decorateMarkdown = (options = {}) => {
|
|
5444
5674
|
return [
|
|
5445
|
-
|
|
5675
|
+
ViewPlugin15.fromClass(class {
|
|
5446
5676
|
deco;
|
|
5447
5677
|
atomicDeco;
|
|
5448
5678
|
pendingUpdate;
|
|
@@ -5477,9 +5707,9 @@ var decorateMarkdown = (options = {}) => {
|
|
|
5477
5707
|
}
|
|
5478
5708
|
}, {
|
|
5479
5709
|
provide: (plugin) => [
|
|
5480
|
-
Prec4.low(
|
|
5481
|
-
|
|
5482
|
-
|
|
5710
|
+
Prec4.low(EditorView24.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration11.none)),
|
|
5711
|
+
EditorView24.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
|
|
5712
|
+
EditorView24.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none)
|
|
5483
5713
|
]
|
|
5484
5714
|
}),
|
|
5485
5715
|
image(),
|
|
@@ -5511,8 +5741,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5511
5741
|
return {
|
|
5512
5742
|
pos: link.from,
|
|
5513
5743
|
end: link.to,
|
|
5514
|
-
|
|
5515
|
-
// above: true,
|
|
5744
|
+
above: true,
|
|
5516
5745
|
create: () => {
|
|
5517
5746
|
const el = document.createElement("div");
|
|
5518
5747
|
el.className = tooltipContent({});
|
|
@@ -5528,16 +5757,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5528
5757
|
};
|
|
5529
5758
|
}
|
|
5530
5759
|
};
|
|
5531
|
-
}, {
|
|
5532
|
-
// NOTE: 0 = default of 300ms.
|
|
5533
|
-
hoverTime: 1
|
|
5534
5760
|
});
|
|
5535
5761
|
};
|
|
5536
5762
|
|
|
5537
5763
|
// src/extensions/mention.ts
|
|
5538
5764
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5539
|
-
import { log as
|
|
5540
|
-
var
|
|
5765
|
+
import { log as log9 } from "@dxos/log";
|
|
5766
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5541
5767
|
var mention = ({ debug, onSearch }) => {
|
|
5542
5768
|
return autocompletion({
|
|
5543
5769
|
// TODO(burdon): Not working.
|
|
@@ -5549,10 +5775,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5549
5775
|
icons: false,
|
|
5550
5776
|
override: [
|
|
5551
5777
|
(context) => {
|
|
5552
|
-
|
|
5778
|
+
log9.info("completion context", {
|
|
5553
5779
|
context
|
|
5554
5780
|
}, {
|
|
5555
|
-
F:
|
|
5781
|
+
F: __dxlog_file13,
|
|
5556
5782
|
L: 27,
|
|
5557
5783
|
S: void 0,
|
|
5558
5784
|
C: (f, a) => f(...a)
|
|
@@ -5635,7 +5861,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5635
5861
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5636
5862
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5637
5863
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5638
|
-
var
|
|
5864
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5639
5865
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5640
5866
|
return {
|
|
5641
5867
|
type,
|
|
@@ -5790,7 +6016,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5790
6016
|
}
|
|
5791
6017
|
case "BulletList": {
|
|
5792
6018
|
invariant5(current, void 0, {
|
|
5793
|
-
F:
|
|
6019
|
+
F: __dxlog_file14,
|
|
5794
6020
|
L: 219,
|
|
5795
6021
|
S: void 0,
|
|
5796
6022
|
A: [
|
|
@@ -5807,7 +6033,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5807
6033
|
}
|
|
5808
6034
|
case "ListItem": {
|
|
5809
6035
|
invariant5(parent, void 0, {
|
|
5810
|
-
F:
|
|
6036
|
+
F: __dxlog_file14,
|
|
5811
6037
|
L: 228,
|
|
5812
6038
|
S: void 0,
|
|
5813
6039
|
A: [
|
|
@@ -5849,7 +6075,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5849
6075
|
}
|
|
5850
6076
|
case "ListMark": {
|
|
5851
6077
|
invariant5(current, void 0, {
|
|
5852
|
-
F:
|
|
6078
|
+
F: __dxlog_file14,
|
|
5853
6079
|
L: 272,
|
|
5854
6080
|
S: void 0,
|
|
5855
6081
|
A: [
|
|
@@ -5863,7 +6089,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5863
6089
|
}
|
|
5864
6090
|
case "Task": {
|
|
5865
6091
|
invariant5(current, void 0, {
|
|
5866
|
-
F:
|
|
6092
|
+
F: __dxlog_file14,
|
|
5867
6093
|
L: 278,
|
|
5868
6094
|
S: void 0,
|
|
5869
6095
|
A: [
|
|
@@ -5876,7 +6102,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5876
6102
|
}
|
|
5877
6103
|
case "TaskMarker": {
|
|
5878
6104
|
invariant5(current, void 0, {
|
|
5879
|
-
F:
|
|
6105
|
+
F: __dxlog_file14,
|
|
5880
6106
|
L: 283,
|
|
5881
6107
|
S: void 0,
|
|
5882
6108
|
A: [
|
|
@@ -5892,7 +6118,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5892
6118
|
leave: (node) => {
|
|
5893
6119
|
if (node.name === "BulletList") {
|
|
5894
6120
|
invariant5(parent, void 0, {
|
|
5895
|
-
F:
|
|
6121
|
+
F: __dxlog_file14,
|
|
5896
6122
|
L: 291,
|
|
5897
6123
|
S: void 0,
|
|
5898
6124
|
A: [
|
|
@@ -5906,7 +6132,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5906
6132
|
}
|
|
5907
6133
|
});
|
|
5908
6134
|
invariant5(tree, void 0, {
|
|
5909
|
-
F:
|
|
6135
|
+
F: __dxlog_file14,
|
|
5910
6136
|
L: 298,
|
|
5911
6137
|
S: void 0,
|
|
5912
6138
|
A: [
|
|
@@ -6198,17 +6424,17 @@ var commands = () => keymap11.of([
|
|
|
6198
6424
|
|
|
6199
6425
|
// src/extensions/outliner/outliner.ts
|
|
6200
6426
|
import { Prec as Prec5 } from "@codemirror/state";
|
|
6201
|
-
import { Decoration as Decoration12, EditorView as
|
|
6202
|
-
import { mx as
|
|
6427
|
+
import { Decoration as Decoration12, EditorView as EditorView26, ViewPlugin as ViewPlugin18 } from "@codemirror/view";
|
|
6428
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
6203
6429
|
|
|
6204
6430
|
// src/extensions/outliner/editor.ts
|
|
6205
6431
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6206
|
-
import { ViewPlugin as
|
|
6207
|
-
import { log as
|
|
6208
|
-
var
|
|
6432
|
+
import { ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6433
|
+
import { log as log10 } from "@dxos/log";
|
|
6434
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6209
6435
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6210
6436
|
var initialize = () => {
|
|
6211
|
-
return
|
|
6437
|
+
return ViewPlugin16.fromClass(class {
|
|
6212
6438
|
constructor(view) {
|
|
6213
6439
|
const first = view.state.doc.lineAt(0);
|
|
6214
6440
|
const text = view.state.sliceDoc(first.from, first.to);
|
|
@@ -6337,7 +6563,7 @@ var editor = () => [
|
|
|
6337
6563
|
cancel = true;
|
|
6338
6564
|
return;
|
|
6339
6565
|
}
|
|
6340
|
-
|
|
6566
|
+
log10("change", {
|
|
6341
6567
|
item,
|
|
6342
6568
|
line: {
|
|
6343
6569
|
from: line.from,
|
|
@@ -6356,7 +6582,7 @@ var editor = () => [
|
|
|
6356
6582
|
length: insert.length
|
|
6357
6583
|
}
|
|
6358
6584
|
}, {
|
|
6359
|
-
F:
|
|
6585
|
+
F: __dxlog_file15,
|
|
6360
6586
|
L: 164,
|
|
6361
6587
|
S: void 0,
|
|
6362
6588
|
C: (f, a) => f(...a)
|
|
@@ -6364,10 +6590,10 @@ var editor = () => [
|
|
|
6364
6590
|
}
|
|
6365
6591
|
});
|
|
6366
6592
|
if (changes.length > 0) {
|
|
6367
|
-
|
|
6593
|
+
log10("modified,", {
|
|
6368
6594
|
changes
|
|
6369
6595
|
}, {
|
|
6370
|
-
F:
|
|
6596
|
+
F: __dxlog_file15,
|
|
6371
6597
|
L: 175,
|
|
6372
6598
|
S: void 0,
|
|
6373
6599
|
C: (f, a) => f(...a)
|
|
@@ -6378,8 +6604,8 @@ var editor = () => [
|
|
|
6378
6604
|
}
|
|
6379
6605
|
];
|
|
6380
6606
|
} else if (cancel) {
|
|
6381
|
-
|
|
6382
|
-
F:
|
|
6607
|
+
log10("cancel", void 0, {
|
|
6608
|
+
F: __dxlog_file15,
|
|
6383
6609
|
L: 178,
|
|
6384
6610
|
S: void 0,
|
|
6385
6611
|
C: (f, a) => f(...a)
|
|
@@ -6391,10 +6617,10 @@ var editor = () => [
|
|
|
6391
6617
|
];
|
|
6392
6618
|
|
|
6393
6619
|
// src/extensions/outliner/menu.ts
|
|
6394
|
-
import { EditorView as
|
|
6395
|
-
import { addEventListener } from "@dxos/async";
|
|
6620
|
+
import { EditorView as EditorView25, ViewPlugin as ViewPlugin17 } from "@codemirror/view";
|
|
6621
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6396
6622
|
var menu = (options = {}) => [
|
|
6397
|
-
|
|
6623
|
+
ViewPlugin17.fromClass(class {
|
|
6398
6624
|
view;
|
|
6399
6625
|
tag;
|
|
6400
6626
|
rafId;
|
|
@@ -6414,7 +6640,7 @@ var menu = (options = {}) => [
|
|
|
6414
6640
|
}
|
|
6415
6641
|
container.appendChild(this.tag);
|
|
6416
6642
|
const handler = () => this.scheduleUpdate();
|
|
6417
|
-
this.cleanup =
|
|
6643
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6418
6644
|
this.scheduleUpdate();
|
|
6419
6645
|
}
|
|
6420
6646
|
destroy() {
|
|
@@ -6456,7 +6682,7 @@ var menu = (options = {}) => [
|
|
|
6456
6682
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
|
6457
6683
|
}
|
|
6458
6684
|
}),
|
|
6459
|
-
|
|
6685
|
+
EditorView25.theme({
|
|
6460
6686
|
".cm-popover-trigger": {
|
|
6461
6687
|
position: "fixed",
|
|
6462
6688
|
padding: "0",
|
|
@@ -6492,12 +6718,12 @@ var outliner = (_options = {}) => [
|
|
|
6492
6718
|
listPaddingLeft: 8
|
|
6493
6719
|
}),
|
|
6494
6720
|
// Researve space for menu.
|
|
6495
|
-
|
|
6496
|
-
class: "
|
|
6721
|
+
EditorView26.contentAttributes.of({
|
|
6722
|
+
class: "w-full !mr-[3rem]"
|
|
6497
6723
|
})
|
|
6498
6724
|
];
|
|
6499
6725
|
var decorations = () => [
|
|
6500
|
-
|
|
6726
|
+
ViewPlugin18.fromClass(class {
|
|
6501
6727
|
decorations = Decoration12.none;
|
|
6502
6728
|
constructor(view) {
|
|
6503
6729
|
this.updateDecorations(view.state, view);
|
|
@@ -6522,7 +6748,7 @@ var decorations = () => [
|
|
|
6522
6748
|
const lineTo = doc.lineAt(item.contentRange.to);
|
|
6523
6749
|
const isSelected = selection.includes(item.index) || item === current;
|
|
6524
6750
|
decorations2.push(Decoration12.line({
|
|
6525
|
-
class:
|
|
6751
|
+
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
6752
|
}).range(line.from, line.from));
|
|
6527
6753
|
}
|
|
6528
6754
|
}
|
|
@@ -6532,7 +6758,7 @@ var decorations = () => [
|
|
|
6532
6758
|
decorations: (v) => v.decorations
|
|
6533
6759
|
}),
|
|
6534
6760
|
// Theme.
|
|
6535
|
-
|
|
6761
|
+
EditorView26.theme(Object.assign({
|
|
6536
6762
|
".cm-list-item": {
|
|
6537
6763
|
borderLeftWidth: "1px",
|
|
6538
6764
|
borderRightWidth: "1px",
|
|
@@ -6557,38 +6783,67 @@ var decorations = () => [
|
|
|
6557
6783
|
marginBottom: "2px"
|
|
6558
6784
|
},
|
|
6559
6785
|
".cm-list-item-focused": {
|
|
6560
|
-
borderColor: "var(--
|
|
6786
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6561
6787
|
},
|
|
6562
6788
|
"&:focus-within .cm-list-item-selected": {
|
|
6563
|
-
borderColor: "var(--
|
|
6789
|
+
borderColor: "var(--color-separator)"
|
|
6564
6790
|
}
|
|
6565
6791
|
}))
|
|
6566
6792
|
];
|
|
6567
6793
|
|
|
6568
6794
|
// src/extensions/preview/preview.ts
|
|
6569
6795
|
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
|
|
6796
|
+
import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect9, StateField as StateField11 } from "@codemirror/state";
|
|
6797
|
+
import { Decoration as Decoration13, EditorView as EditorView27, ViewPlugin as ViewPlugin19, WidgetType as WidgetType8 } from "@codemirror/view";
|
|
6798
|
+
import { DXN, Entity } from "@dxos/echo";
|
|
6799
|
+
var labelResolvedEffect = StateEffect9.define();
|
|
6572
6800
|
var preview = (options = {}) => {
|
|
6801
|
+
const viewRef = {
|
|
6802
|
+
current: void 0
|
|
6803
|
+
};
|
|
6573
6804
|
return [
|
|
6574
6805
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
|
6575
6806
|
// "Block decorations may not be specified via plugins".
|
|
6576
6807
|
StateField11.define({
|
|
6577
|
-
create: (state) => buildDecorations3(state, options),
|
|
6808
|
+
create: (state) => buildDecorations3(state, options, viewRef),
|
|
6578
6809
|
update: (decorations2, tr) => {
|
|
6579
|
-
if (tr.docChanged) {
|
|
6580
|
-
return buildDecorations3(tr.state, options);
|
|
6810
|
+
if (tr.docChanged || tr.effects.some((effect) => effect.is(labelResolvedEffect))) {
|
|
6811
|
+
return buildDecorations3(tr.state, options, viewRef);
|
|
6581
6812
|
}
|
|
6582
6813
|
return decorations2.map(tr.changes);
|
|
6583
6814
|
},
|
|
6584
6815
|
provide: (field) => [
|
|
6585
|
-
|
|
6586
|
-
|
|
6816
|
+
EditorView27.decorations.from(field),
|
|
6817
|
+
EditorView27.atomicRanges.of((view) => view.state.field(field))
|
|
6587
6818
|
]
|
|
6819
|
+
}),
|
|
6820
|
+
ViewPlugin19.define((view) => {
|
|
6821
|
+
viewRef.current = view;
|
|
6822
|
+
return {
|
|
6823
|
+
destroy() {
|
|
6824
|
+
viewRef.current = void 0;
|
|
6825
|
+
}
|
|
6826
|
+
};
|
|
6588
6827
|
})
|
|
6589
6828
|
];
|
|
6590
6829
|
};
|
|
6591
|
-
var
|
|
6830
|
+
var resolveLabel = (db, dxnStr, viewRef) => {
|
|
6831
|
+
const dxn = DXN.tryParse(dxnStr);
|
|
6832
|
+
if (!dxn) {
|
|
6833
|
+
return;
|
|
6834
|
+
}
|
|
6835
|
+
const ref = db.makeRef(dxn);
|
|
6836
|
+
const target = ref.target;
|
|
6837
|
+
if (target) {
|
|
6838
|
+
return Entity.getLabel(target);
|
|
6839
|
+
}
|
|
6840
|
+
void ref.tryLoad().then(() => {
|
|
6841
|
+
viewRef.current?.dispatch({
|
|
6842
|
+
effects: labelResolvedEffect.of(void 0)
|
|
6843
|
+
});
|
|
6844
|
+
});
|
|
6845
|
+
};
|
|
6846
|
+
var buildDecorations3 = (state, options, viewRef) => {
|
|
6592
6847
|
const builder = new RangeSetBuilder6();
|
|
6593
6848
|
syntaxTree10(state).iterate({
|
|
6594
6849
|
enter: (node) => {
|
|
@@ -6600,8 +6855,13 @@ var buildDecorations3 = (state, options) => {
|
|
|
6600
6855
|
case "Link": {
|
|
6601
6856
|
const link = getLinkRef(state, node.node);
|
|
6602
6857
|
if (link) {
|
|
6858
|
+
const resolved = options.db ? resolveLabel(options.db, link.dxn, viewRef) : void 0;
|
|
6859
|
+
const displayLink = resolved ? {
|
|
6860
|
+
...link,
|
|
6861
|
+
label: resolved
|
|
6862
|
+
} : link;
|
|
6603
6863
|
builder.add(node.from, node.to, Decoration13.replace({
|
|
6604
|
-
widget: new PreviewInlineWidget(options,
|
|
6864
|
+
widget: new PreviewInlineWidget(options, displayLink),
|
|
6605
6865
|
side: 1
|
|
6606
6866
|
}));
|
|
6607
6867
|
}
|
|
@@ -6677,7 +6937,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6677
6937
|
}
|
|
6678
6938
|
toDOM(_view) {
|
|
6679
6939
|
const root = document.createElement("div");
|
|
6680
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6940
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6681
6941
|
this._options.addBlockContainer?.({
|
|
6682
6942
|
link: this._link,
|
|
6683
6943
|
el: root
|
|
@@ -6693,7 +6953,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6693
6953
|
};
|
|
6694
6954
|
|
|
6695
6955
|
// src/extensions/replacer.ts
|
|
6696
|
-
import { EditorView as
|
|
6956
|
+
import { EditorView as EditorView28 } from "@codemirror/view";
|
|
6697
6957
|
var defaultReplacements = [
|
|
6698
6958
|
{
|
|
6699
6959
|
input: "--",
|
|
@@ -6756,7 +7016,7 @@ var replacer = ({ replacements = defaultReplacements } = {}) => {
|
|
|
6756
7016
|
const sortedReplacements = [
|
|
6757
7017
|
...replacements
|
|
6758
7018
|
].sort((a, b) => b.input.length - a.input.length);
|
|
6759
|
-
return
|
|
7019
|
+
return EditorView28.inputHandler.of((view, from, to, insert) => {
|
|
6760
7020
|
if (insert.length !== 1) {
|
|
6761
7021
|
return false;
|
|
6762
7022
|
}
|
|
@@ -6840,6 +7100,7 @@ var submit = ({ fireIfEmpty = false, onSubmit } = {}) => {
|
|
|
6840
7100
|
// src/extensions/tags/extended-markdown.ts
|
|
6841
7101
|
import { xmlLanguage } from "@codemirror/lang-xml";
|
|
6842
7102
|
import { parseMixed } from "@lezer/common";
|
|
7103
|
+
var escapeRegExpSource = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6843
7104
|
var extendedMarkdown = ({ registry } = {}) => {
|
|
6844
7105
|
return [
|
|
6845
7106
|
createMarkdownExtensions({
|
|
@@ -6851,25 +7112,77 @@ var extendedMarkdown = ({ registry } = {}) => {
|
|
|
6851
7112
|
{
|
|
6852
7113
|
name: "SetextHeading",
|
|
6853
7114
|
parse: () => false
|
|
6854
|
-
}
|
|
7115
|
+
},
|
|
7116
|
+
// Custom XML block parser that keeps registered tags as a single HTMLBlock
|
|
7117
|
+
// even when their content contains blank lines.
|
|
7118
|
+
...xmlBlockParsers(registry)
|
|
6855
7119
|
]
|
|
6856
7120
|
}
|
|
6857
7121
|
]
|
|
6858
7122
|
})
|
|
6859
7123
|
];
|
|
6860
7124
|
};
|
|
6861
|
-
var
|
|
7125
|
+
var xmlBlockParsers = (registry) => {
|
|
6862
7126
|
const customTags = Object.keys(registry ?? {});
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
7127
|
+
if (customTags.length === 0) {
|
|
7128
|
+
return [];
|
|
7129
|
+
}
|
|
7130
|
+
const tagPattern = customTags.map(escapeRegExpSource).join("|");
|
|
7131
|
+
const selfClosePattern = new RegExp(`^\\s*<(${tagPattern})(\\s[^>]*)?\\/>\\s*$`);
|
|
7132
|
+
const openPattern = new RegExp(`^\\s*<(${tagPattern})(\\s[^>]*)?\\/?>`);
|
|
7133
|
+
return [
|
|
7134
|
+
{
|
|
7135
|
+
name: "XMLBlock",
|
|
7136
|
+
before: "HTMLBlock",
|
|
7137
|
+
parse: (cx, line) => {
|
|
7138
|
+
const match = openPattern.exec(line.text);
|
|
7139
|
+
if (!match) {
|
|
7140
|
+
return false;
|
|
7141
|
+
}
|
|
7142
|
+
if (selfClosePattern.test(line.text)) {
|
|
7143
|
+
const end2 = cx.lineStart + line.text.length;
|
|
7144
|
+
cx.addElement(cx.elt("HTMLBlock", cx.lineStart, end2));
|
|
7145
|
+
cx.nextLine();
|
|
7146
|
+
return true;
|
|
7147
|
+
}
|
|
7148
|
+
if (match[0].trimEnd().endsWith("/>")) {
|
|
7149
|
+
return false;
|
|
7150
|
+
}
|
|
7151
|
+
const tagName = match[1];
|
|
7152
|
+
const closeTag = `</${tagName}>`;
|
|
7153
|
+
const start = cx.lineStart;
|
|
7154
|
+
if (line.text.includes(closeTag)) {
|
|
7155
|
+
cx.addElement(cx.elt("HTMLBlock", start, start + line.text.length));
|
|
7156
|
+
cx.nextLine();
|
|
7157
|
+
return true;
|
|
7158
|
+
}
|
|
7159
|
+
let end = cx.lineStart + line.text.length;
|
|
7160
|
+
while (cx.nextLine()) {
|
|
7161
|
+
end = cx.lineStart + line.text.length;
|
|
7162
|
+
if (line.text.includes(closeTag)) {
|
|
7163
|
+
cx.addElement(cx.elt("HTMLBlock", start, end));
|
|
7164
|
+
cx.nextLine();
|
|
7165
|
+
return true;
|
|
7166
|
+
}
|
|
7167
|
+
}
|
|
7168
|
+
cx.addElement(cx.elt("HTMLBlock", start, end));
|
|
7169
|
+
return true;
|
|
7170
|
+
}
|
|
7171
|
+
}
|
|
7172
|
+
];
|
|
7173
|
+
};
|
|
7174
|
+
var mixedParser = (registry) => {
|
|
7175
|
+
const customTags = Object.keys(registry ?? {});
|
|
7176
|
+
const tagPattern = new RegExp(`<(${customTags.join("|")})`);
|
|
7177
|
+
return parseMixed((node, input) => {
|
|
7178
|
+
switch (node.name) {
|
|
7179
|
+
// Ignore XML inside of fenced and inline code.
|
|
7180
|
+
case "FencedCode":
|
|
7181
|
+
case "InlineCode": {
|
|
7182
|
+
return null;
|
|
7183
|
+
}
|
|
7184
|
+
// Parse multi-line HTML blocks.
|
|
7185
|
+
// case 'XMLBlock':
|
|
6873
7186
|
case "HTMLBlock": {
|
|
6874
7187
|
return {
|
|
6875
7188
|
parser: xmlLanguage.parser
|
|
@@ -6891,212 +7204,560 @@ var mixedParser = (registry) => {
|
|
|
6891
7204
|
});
|
|
6892
7205
|
};
|
|
6893
7206
|
|
|
6894
|
-
// src/extensions/tags/
|
|
6895
|
-
import { StateEffect as
|
|
6896
|
-
import { Decoration as Decoration14, EditorView as
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
var
|
|
6900
|
-
var
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
7207
|
+
// src/extensions/tags/fader.ts
|
|
7208
|
+
import { StateEffect as StateEffect10, StateField as StateField12 } from "@codemirror/state";
|
|
7209
|
+
import { Decoration as Decoration14, EditorView as EditorView29, ViewPlugin as ViewPlugin20 } from "@codemirror/view";
|
|
7210
|
+
var DEFAULT_REMOVAL_DELAY = 5e3;
|
|
7211
|
+
var DEFAULT_COALESCE_WINDOW = 100;
|
|
7212
|
+
var CLEANUP_INTERVAL = 1e3;
|
|
7213
|
+
var fader = (options = {}) => {
|
|
7214
|
+
const removalDelay = DEFAULT_REMOVAL_DELAY;
|
|
7215
|
+
const coalesceWindow = options.coalesce ?? DEFAULT_COALESCE_WINDOW;
|
|
7216
|
+
let lastCount = -1;
|
|
7217
|
+
const log12 = (expiries) => {
|
|
7218
|
+
if (expiries.length !== lastCount) {
|
|
7219
|
+
lastCount = expiries.length;
|
|
7220
|
+
}
|
|
7221
|
+
};
|
|
7222
|
+
const dequeue = StateEffect10.define();
|
|
7223
|
+
const fadeField = StateField12.define({
|
|
7224
|
+
create: () => ({
|
|
7225
|
+
decorations: Decoration14.none,
|
|
7226
|
+
expiries: [],
|
|
7227
|
+
batchStart: 0
|
|
7228
|
+
}),
|
|
7229
|
+
update: ({ decorations: decorations2, expiries, batchStart }, tr) => {
|
|
6911
7230
|
for (const effect of tr.effects) {
|
|
6912
|
-
if (effect.is(
|
|
6913
|
-
|
|
7231
|
+
if (effect.is(dequeue)) {
|
|
7232
|
+
const now2 = effect.value;
|
|
7233
|
+
let removeCount = 0;
|
|
7234
|
+
while (removeCount < expiries.length && expiries[removeCount] <= now2) {
|
|
7235
|
+
removeCount++;
|
|
7236
|
+
}
|
|
7237
|
+
if (removeCount > 0) {
|
|
7238
|
+
expiries = expiries.slice(removeCount);
|
|
7239
|
+
let skipped = 0;
|
|
7240
|
+
decorations2 = decorations2.update({
|
|
7241
|
+
filter: () => {
|
|
7242
|
+
if (skipped < removeCount) {
|
|
7243
|
+
skipped++;
|
|
7244
|
+
return false;
|
|
7245
|
+
}
|
|
7246
|
+
return true;
|
|
7247
|
+
}
|
|
7248
|
+
});
|
|
7249
|
+
}
|
|
6914
7250
|
}
|
|
6915
7251
|
}
|
|
6916
|
-
if (tr.docChanged) {
|
|
6917
|
-
|
|
7252
|
+
if (!tr.docChanged) {
|
|
7253
|
+
log12(expiries);
|
|
7254
|
+
return {
|
|
7255
|
+
decorations: decorations2,
|
|
7256
|
+
expiries,
|
|
7257
|
+
batchStart
|
|
7258
|
+
};
|
|
6918
7259
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
7260
|
+
let isReset = tr.state.doc.length === 0;
|
|
7261
|
+
if (!isReset && tr.startState.doc.length > 0) {
|
|
7262
|
+
tr.changes.iterChanges((fromA, toA) => {
|
|
7263
|
+
if (fromA === 0 && toA === tr.startState.doc.length) {
|
|
7264
|
+
isReset = true;
|
|
7265
|
+
}
|
|
7266
|
+
});
|
|
7267
|
+
}
|
|
7268
|
+
if (isReset) {
|
|
7269
|
+
log12([]);
|
|
7270
|
+
return {
|
|
7271
|
+
decorations: Decoration14.none,
|
|
7272
|
+
expiries: [],
|
|
7273
|
+
batchStart: 0
|
|
7274
|
+
};
|
|
7275
|
+
}
|
|
7276
|
+
const now = Date.now();
|
|
7277
|
+
const add = [];
|
|
7278
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
|
|
7279
|
+
if (toA === tr.startState.doc.length && inserted.length > 0) {
|
|
7280
|
+
add.push({
|
|
7281
|
+
from: fromB,
|
|
7282
|
+
to: toB
|
|
7283
|
+
});
|
|
7284
|
+
}
|
|
7285
|
+
});
|
|
7286
|
+
if (add.length > 0) {
|
|
7287
|
+
const canCoalesce = expiries.length > 0 && batchStart > 0 && now - batchStart < coalesceWindow;
|
|
7288
|
+
if (canCoalesce) {
|
|
7289
|
+
let lastFrom = -1;
|
|
7290
|
+
let lastTo = -1;
|
|
7291
|
+
decorations2.between(0, tr.state.doc.length, (from, to) => {
|
|
7292
|
+
lastFrom = from;
|
|
7293
|
+
lastTo = to;
|
|
7294
|
+
});
|
|
7295
|
+
if (lastFrom >= 0) {
|
|
7296
|
+
decorations2 = decorations2.update({
|
|
7297
|
+
filter: (from, to) => !(from === lastFrom && to === lastTo)
|
|
7298
|
+
});
|
|
7299
|
+
const mergedFrom = Math.min(lastFrom, add[0].from);
|
|
7300
|
+
const mergedTo = add[add.length - 1].to;
|
|
7301
|
+
decorations2 = decorations2.update({
|
|
7302
|
+
add: [
|
|
7303
|
+
Decoration14.mark({
|
|
7304
|
+
class: "cm-fader"
|
|
7305
|
+
}).range(mergedFrom, mergedTo)
|
|
7306
|
+
]
|
|
7307
|
+
});
|
|
7308
|
+
expiries = [
|
|
7309
|
+
...expiries.slice(0, -1),
|
|
7310
|
+
now + removalDelay
|
|
7311
|
+
];
|
|
7312
|
+
}
|
|
7313
|
+
} else {
|
|
7314
|
+
batchStart = now;
|
|
7315
|
+
expiries = [
|
|
7316
|
+
...expiries,
|
|
7317
|
+
now + removalDelay
|
|
7318
|
+
];
|
|
7319
|
+
decorations2 = decorations2.update({
|
|
7320
|
+
add: add.map(({ from, to }) => Decoration14.mark({
|
|
7321
|
+
class: "cm-fader"
|
|
7322
|
+
}).range(from, to))
|
|
7323
|
+
});
|
|
7324
|
+
}
|
|
7325
|
+
}
|
|
7326
|
+
log12(expiries);
|
|
7327
|
+
return {
|
|
7328
|
+
decorations: decorations2,
|
|
7329
|
+
expiries,
|
|
7330
|
+
batchStart
|
|
7331
|
+
};
|
|
7332
|
+
},
|
|
7333
|
+
provide: (f) => EditorView29.decorations.from(f, (value) => value.decorations)
|
|
6921
7334
|
});
|
|
6922
|
-
const
|
|
7335
|
+
const cleanup = ViewPlugin20.fromClass(class {
|
|
6923
7336
|
view;
|
|
6924
|
-
timer;
|
|
7337
|
+
#timer;
|
|
6925
7338
|
constructor(view) {
|
|
6926
7339
|
this.view = view;
|
|
7340
|
+
this.#schedule();
|
|
6927
7341
|
}
|
|
6928
|
-
update(
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
7342
|
+
update() {
|
|
7343
|
+
this.#schedule();
|
|
7344
|
+
}
|
|
7345
|
+
#schedule() {
|
|
7346
|
+
const { expiries } = this.view.state.field(fadeField);
|
|
7347
|
+
if (expiries.length === 0) {
|
|
7348
|
+
clearTimeout(this.#timer);
|
|
7349
|
+
this.#timer = void 0;
|
|
7350
|
+
return;
|
|
6936
7351
|
}
|
|
7352
|
+
if (this.#timer !== void 0) {
|
|
7353
|
+
return;
|
|
7354
|
+
}
|
|
7355
|
+
const delay = Math.max(CLEANUP_INTERVAL, expiries[0] - Date.now());
|
|
7356
|
+
this.#timer = setTimeout(() => {
|
|
7357
|
+
this.#timer = void 0;
|
|
7358
|
+
this.view.dispatch({
|
|
7359
|
+
effects: dequeue.of(Date.now())
|
|
7360
|
+
});
|
|
7361
|
+
}, delay);
|
|
6937
7362
|
}
|
|
6938
7363
|
destroy() {
|
|
6939
|
-
clearTimeout(this
|
|
7364
|
+
clearTimeout(this.#timer);
|
|
6940
7365
|
}
|
|
6941
7366
|
});
|
|
6942
|
-
const cursorDecoration = StateField12.define({
|
|
6943
|
-
create: () => Decoration14.none,
|
|
6944
|
-
update: (_decorations, tr) => {
|
|
6945
|
-
const show = tr.state.field(showCursor);
|
|
6946
|
-
if (!show) {
|
|
6947
|
-
return Decoration14.none;
|
|
6948
|
-
}
|
|
6949
|
-
const endPos = tr.state.doc.length;
|
|
6950
|
-
return Decoration14.set([
|
|
6951
|
-
Decoration14.widget({
|
|
6952
|
-
widget: new CursorWidget(),
|
|
6953
|
-
side: 1
|
|
6954
|
-
}).range(endPos)
|
|
6955
|
-
]);
|
|
6956
|
-
},
|
|
6957
|
-
provide: (f) => EditorView28.decorations.from(f)
|
|
6958
|
-
});
|
|
6959
7367
|
return [
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
7368
|
+
fadeField,
|
|
7369
|
+
cleanup,
|
|
7370
|
+
EditorView29.theme({
|
|
7371
|
+
".cm-fader": {
|
|
7372
|
+
animation: "fader 1s ease-out forwards"
|
|
7373
|
+
},
|
|
7374
|
+
"@keyframes fader": {
|
|
7375
|
+
"0%": {
|
|
7376
|
+
textShadow: "0 0 16px rgba(100, 200, 255, 1), 0 0 32px rgba(100, 200, 255, 0.6)"
|
|
7377
|
+
},
|
|
7378
|
+
"100%": {}
|
|
7379
|
+
}
|
|
7380
|
+
})
|
|
6963
7381
|
];
|
|
6964
7382
|
};
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
const
|
|
6977
|
-
const
|
|
6978
|
-
const
|
|
6979
|
-
const
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
7383
|
+
|
|
7384
|
+
// src/extensions/tags/wire.ts
|
|
7385
|
+
import { Annotation as Annotation3, ChangeSet as ChangeSet2, EditorState as EditorState3, StateEffect as StateEffect11, StateField as StateField13 } from "@codemirror/state";
|
|
7386
|
+
import { Decoration as Decoration15, EditorView as EditorView30, ViewPlugin as ViewPlugin21, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
7387
|
+
import { Domino as Domino3 } from "@dxos/ui";
|
|
7388
|
+
var wireBypass = Annotation3.define();
|
|
7389
|
+
var DEFAULT_RATE = 200;
|
|
7390
|
+
var CURSOR_LINGER = 3e3;
|
|
7391
|
+
var wire = (options = {}) => {
|
|
7392
|
+
const rate = options.rate ?? DEFAULT_RATE;
|
|
7393
|
+
const interval = 1e3 / rate;
|
|
7394
|
+
const streamingTags = options.streamingTags ?? /* @__PURE__ */ new Set();
|
|
7395
|
+
const suppressAppend = StateEffect11.define();
|
|
7396
|
+
const insertChunk = StateEffect11.define();
|
|
7397
|
+
const bufferField = StateField13.define({
|
|
7398
|
+
create: () => ({
|
|
7399
|
+
text: "",
|
|
7400
|
+
insertAt: 0
|
|
7401
|
+
}),
|
|
7402
|
+
update: (value, tr) => {
|
|
7403
|
+
let { text, insertAt } = value;
|
|
6984
7404
|
for (const effect of tr.effects) {
|
|
6985
|
-
if (effect.is(
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
7405
|
+
if (effect.is(suppressAppend)) {
|
|
7406
|
+
text += effect.value.text;
|
|
7407
|
+
if (text.length === effect.value.text.length) {
|
|
7408
|
+
insertAt = effect.value.from;
|
|
7409
|
+
}
|
|
7410
|
+
}
|
|
7411
|
+
if (effect.is(insertChunk)) {
|
|
7412
|
+
text = text.slice(effect.value.text.length);
|
|
7413
|
+
insertAt = effect.value.from + effect.value.text.length;
|
|
7414
|
+
}
|
|
7415
|
+
}
|
|
7416
|
+
if (tr.docChanged) {
|
|
7417
|
+
let isReset = tr.state.doc.length === 0;
|
|
7418
|
+
if (!isReset && tr.startState.doc.length > 0) {
|
|
7419
|
+
tr.changes.iterChanges((fromA, toA) => {
|
|
7420
|
+
if (fromA === 0 && toA === tr.startState.doc.length) {
|
|
7421
|
+
isReset = true;
|
|
7422
|
+
}
|
|
6989
7423
|
});
|
|
6990
7424
|
}
|
|
7425
|
+
if (isReset) {
|
|
7426
|
+
return {
|
|
7427
|
+
text: "",
|
|
7428
|
+
insertAt: 0
|
|
7429
|
+
};
|
|
7430
|
+
}
|
|
7431
|
+
if (!tr.effects.some((effect) => effect.is(insertChunk))) {
|
|
7432
|
+
insertAt = tr.changes.mapPos(Math.min(insertAt, tr.startState.doc.length));
|
|
7433
|
+
}
|
|
6991
7434
|
}
|
|
6992
|
-
|
|
6993
|
-
|
|
7435
|
+
return {
|
|
7436
|
+
text,
|
|
7437
|
+
insertAt
|
|
7438
|
+
};
|
|
7439
|
+
}
|
|
7440
|
+
});
|
|
7441
|
+
const filter = EditorState3.transactionFilter.of((tr) => {
|
|
7442
|
+
if (!tr.docChanged) {
|
|
7443
|
+
return tr;
|
|
7444
|
+
}
|
|
7445
|
+
if (tr.annotation(wireBypass) || tr.effects.some((effect) => effect.is(insertChunk))) {
|
|
7446
|
+
return tr;
|
|
7447
|
+
}
|
|
7448
|
+
let appendedText = "";
|
|
7449
|
+
let appendFrom = -1;
|
|
7450
|
+
let isAppendOnly = true;
|
|
7451
|
+
tr.changes.iterChanges((fromA, toA, _fromB, _toB, inserted) => {
|
|
7452
|
+
if (toA === tr.startState.doc.length && fromA === toA && inserted.length > 0) {
|
|
7453
|
+
appendedText += inserted.sliceString(0);
|
|
7454
|
+
if (appendFrom === -1) {
|
|
7455
|
+
appendFrom = fromA;
|
|
7456
|
+
}
|
|
7457
|
+
} else {
|
|
7458
|
+
isAppendOnly = false;
|
|
6994
7459
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7460
|
+
});
|
|
7461
|
+
if (!isAppendOnly || appendedText.length === 0) {
|
|
7462
|
+
return tr;
|
|
7463
|
+
}
|
|
7464
|
+
return {
|
|
7465
|
+
changes: ChangeSet2.empty(tr.startState.doc.length),
|
|
7466
|
+
effects: suppressAppend.of({
|
|
7467
|
+
from: appendFrom,
|
|
7468
|
+
text: appendedText
|
|
7469
|
+
})
|
|
7470
|
+
};
|
|
7471
|
+
});
|
|
7472
|
+
const drainPlugin = ViewPlugin21.fromClass(class {
|
|
7473
|
+
view;
|
|
7474
|
+
#timer;
|
|
7475
|
+
#activeStreamTag = null;
|
|
7476
|
+
constructor(view) {
|
|
7477
|
+
this.view = view;
|
|
7478
|
+
this.#start();
|
|
7479
|
+
}
|
|
7480
|
+
update(update2) {
|
|
7481
|
+
const buffer = update2.state.field(bufferField);
|
|
7482
|
+
if (buffer.text.length === 0) {
|
|
7483
|
+
this.#activeStreamTag = null;
|
|
7002
7484
|
}
|
|
7003
|
-
if (
|
|
7004
|
-
|
|
7485
|
+
if (buffer.text.length > 0 && this.#timer === void 0) {
|
|
7486
|
+
this.#start();
|
|
7005
7487
|
}
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7488
|
+
}
|
|
7489
|
+
#start() {
|
|
7490
|
+
this.#timer = setInterval(() => {
|
|
7491
|
+
const { text, insertAt } = this.view.state.field(bufferField);
|
|
7492
|
+
if (text.length === 0) {
|
|
7493
|
+
clearInterval(this.#timer);
|
|
7494
|
+
this.#timer = void 0;
|
|
7009
7495
|
return;
|
|
7010
7496
|
}
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
}).range(fromB, toB));
|
|
7497
|
+
const result = flushable(text, streamingTags, this.#activeStreamTag);
|
|
7498
|
+
if (result.count === 0) {
|
|
7499
|
+
return;
|
|
7015
7500
|
}
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7501
|
+
if (result.enterTag) {
|
|
7502
|
+
this.#activeStreamTag = result.enterTag;
|
|
7503
|
+
}
|
|
7504
|
+
if (result.exitTag) {
|
|
7505
|
+
this.#activeStreamTag = null;
|
|
7506
|
+
}
|
|
7507
|
+
const chunk = text.slice(0, result.count);
|
|
7508
|
+
this.view.dispatch({
|
|
7509
|
+
changes: {
|
|
7510
|
+
from: insertAt,
|
|
7511
|
+
insert: chunk
|
|
7512
|
+
},
|
|
7513
|
+
effects: insertChunk.of({
|
|
7514
|
+
from: insertAt,
|
|
7515
|
+
text: chunk
|
|
7516
|
+
})
|
|
7517
|
+
});
|
|
7518
|
+
}, interval);
|
|
7519
|
+
}
|
|
7520
|
+
destroy() {
|
|
7521
|
+
clearInterval(this.#timer);
|
|
7522
|
+
}
|
|
7523
|
+
});
|
|
7524
|
+
return [
|
|
7525
|
+
bufferField,
|
|
7526
|
+
filter,
|
|
7527
|
+
drainPlugin,
|
|
7528
|
+
options.cursor && wireCursor(bufferField)
|
|
7529
|
+
].filter(Boolean);
|
|
7530
|
+
};
|
|
7531
|
+
var wireCursor = (bufferField) => {
|
|
7532
|
+
const hideCursor = StateEffect11.define();
|
|
7533
|
+
const visibilityField = StateField13.define({
|
|
7534
|
+
create: () => ({
|
|
7535
|
+
visible: false,
|
|
7536
|
+
insertAt: 0,
|
|
7537
|
+
lastNonWsAt: 0
|
|
7538
|
+
}),
|
|
7539
|
+
update: (value, tr) => {
|
|
7540
|
+
const { text, insertAt } = tr.state.field(bufferField);
|
|
7541
|
+
if (text.length > 0) {
|
|
7542
|
+
let lastNonWsAt = tr.changes.mapPos(Math.min(value.lastNonWsAt, tr.startState.doc.length));
|
|
7543
|
+
if (tr.docChanged) {
|
|
7544
|
+
tr.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => {
|
|
7545
|
+
const chunk = inserted.sliceString(0);
|
|
7546
|
+
if (chunk.trim().length > 0) {
|
|
7547
|
+
lastNonWsAt = _fromB + chunk.length;
|
|
7548
|
+
}
|
|
7549
|
+
});
|
|
7550
|
+
}
|
|
7551
|
+
return {
|
|
7552
|
+
visible: true,
|
|
7553
|
+
insertAt,
|
|
7554
|
+
lastNonWsAt
|
|
7555
|
+
};
|
|
7556
|
+
}
|
|
7557
|
+
for (const effect of tr.effects) {
|
|
7558
|
+
if (effect.is(hideCursor)) {
|
|
7559
|
+
return {
|
|
7560
|
+
...value,
|
|
7561
|
+
visible: false
|
|
7562
|
+
};
|
|
7563
|
+
}
|
|
7564
|
+
}
|
|
7565
|
+
return value;
|
|
7566
|
+
}
|
|
7567
|
+
});
|
|
7568
|
+
const decorationField = StateField13.define({
|
|
7569
|
+
create: () => Decoration15.none,
|
|
7570
|
+
update: (_decorations, tr) => {
|
|
7571
|
+
const { visible, insertAt, lastNonWsAt } = tr.state.field(visibilityField);
|
|
7572
|
+
if (!visible) {
|
|
7573
|
+
return Decoration15.none;
|
|
7574
|
+
}
|
|
7575
|
+
const { text } = tr.state.field(bufferField);
|
|
7576
|
+
const cursorAt = text.length > 0 ? insertAt : lastNonWsAt;
|
|
7577
|
+
const pos = Math.min(cursorAt, tr.state.doc.length);
|
|
7578
|
+
return Decoration15.set([
|
|
7579
|
+
Decoration15.widget({
|
|
7580
|
+
widget: new CursorWidget(),
|
|
7581
|
+
side: 1
|
|
7582
|
+
}).range(pos)
|
|
7583
|
+
]);
|
|
7020
7584
|
},
|
|
7021
|
-
provide: (
|
|
7585
|
+
provide: (field) => EditorView30.decorations.from(field)
|
|
7022
7586
|
});
|
|
7023
|
-
const timerPlugin =
|
|
7587
|
+
const timerPlugin = ViewPlugin21.fromClass(class {
|
|
7024
7588
|
view;
|
|
7025
|
-
|
|
7026
|
-
_timers = /* @__PURE__ */ new Map();
|
|
7589
|
+
#timer;
|
|
7027
7590
|
constructor(view) {
|
|
7028
7591
|
this.view = view;
|
|
7029
7592
|
}
|
|
7030
7593
|
update(update2) {
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
const key = `${fromB}-${toB}`;
|
|
7039
|
-
if (this._timers.has(key)) {
|
|
7040
|
-
clearTimeout(this._timers.get(key));
|
|
7041
|
-
}
|
|
7042
|
-
const totalDelay = FADE_IN_DURATION + removalDelay;
|
|
7043
|
-
const id = setTimeout(() => {
|
|
7594
|
+
const { text } = update2.state.field(bufferField);
|
|
7595
|
+
const { visible } = update2.state.field(visibilityField);
|
|
7596
|
+
if (text.length > 0) {
|
|
7597
|
+
clearTimeout(this.#timer);
|
|
7598
|
+
this.#timer = void 0;
|
|
7599
|
+
} else if (visible && this.#timer === void 0) {
|
|
7600
|
+
this.#timer = setTimeout(() => {
|
|
7044
7601
|
this.view.dispatch({
|
|
7045
|
-
effects:
|
|
7046
|
-
from: fromB,
|
|
7047
|
-
to: toB
|
|
7048
|
-
})
|
|
7602
|
+
effects: hideCursor.of(null)
|
|
7049
7603
|
});
|
|
7050
|
-
this
|
|
7051
|
-
},
|
|
7052
|
-
|
|
7053
|
-
});
|
|
7604
|
+
this.#timer = void 0;
|
|
7605
|
+
}, CURSOR_LINGER);
|
|
7606
|
+
}
|
|
7054
7607
|
}
|
|
7055
7608
|
destroy() {
|
|
7056
|
-
|
|
7057
|
-
clearTimeout(id);
|
|
7058
|
-
}
|
|
7059
|
-
this._timers.clear();
|
|
7609
|
+
clearTimeout(this.#timer);
|
|
7060
7610
|
}
|
|
7061
7611
|
});
|
|
7062
7612
|
return [
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
".cm-line > span": {
|
|
7067
|
-
opacity: "0.8"
|
|
7068
|
-
},
|
|
7069
|
-
".cm-fade-in": {
|
|
7070
|
-
animation: "fade-in 3s ease-out forwards"
|
|
7071
|
-
},
|
|
7072
|
-
"@keyframes fade-in": {
|
|
7073
|
-
"0%": {
|
|
7074
|
-
opacity: "0"
|
|
7075
|
-
},
|
|
7076
|
-
"80%": {
|
|
7077
|
-
opacity: "1"
|
|
7078
|
-
},
|
|
7079
|
-
"100%": {
|
|
7080
|
-
opacity: "0.8"
|
|
7081
|
-
}
|
|
7082
|
-
}
|
|
7083
|
-
})
|
|
7613
|
+
visibilityField,
|
|
7614
|
+
decorationField,
|
|
7615
|
+
timerPlugin
|
|
7084
7616
|
];
|
|
7085
7617
|
};
|
|
7618
|
+
var CursorWidget = class extends WidgetType9 {
|
|
7619
|
+
toDOM() {
|
|
7620
|
+
const inner = Domino3.of("span").text("\u2217").style({
|
|
7621
|
+
animation: "blink 1s infinite",
|
|
7622
|
+
animationDelay: "250ms"
|
|
7623
|
+
});
|
|
7624
|
+
return Domino3.of("span").style({
|
|
7625
|
+
opacity: "0.8"
|
|
7626
|
+
}).append(inner).root;
|
|
7627
|
+
}
|
|
7628
|
+
};
|
|
7629
|
+
var OPENING_TAG_NAME = /^<([a-zA-Z][\w-]*)/;
|
|
7630
|
+
var escapeRegExpSource2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7631
|
+
var flushable = (buffer, streamingTags, activeStreamTag) => {
|
|
7632
|
+
if (buffer.length === 0) {
|
|
7633
|
+
return {
|
|
7634
|
+
count: 0
|
|
7635
|
+
};
|
|
7636
|
+
}
|
|
7637
|
+
if (activeStreamTag) {
|
|
7638
|
+
const closeTag = `</${activeStreamTag}>`;
|
|
7639
|
+
if (buffer.startsWith(closeTag)) {
|
|
7640
|
+
return {
|
|
7641
|
+
count: closeTag.length,
|
|
7642
|
+
exitTag: true
|
|
7643
|
+
};
|
|
7644
|
+
}
|
|
7645
|
+
if (buffer[0] === "<") {
|
|
7646
|
+
return {
|
|
7647
|
+
count: xmlElementLength(buffer)
|
|
7648
|
+
};
|
|
7649
|
+
}
|
|
7650
|
+
return {
|
|
7651
|
+
count: 1
|
|
7652
|
+
};
|
|
7653
|
+
}
|
|
7654
|
+
const ch = buffer[0];
|
|
7655
|
+
if (ch === "<") {
|
|
7656
|
+
const nameMatch = buffer.match(OPENING_TAG_NAME);
|
|
7657
|
+
if (nameMatch && streamingTags.has(nameMatch[1])) {
|
|
7658
|
+
const close = buffer.indexOf(">");
|
|
7659
|
+
if (close === -1) {
|
|
7660
|
+
return {
|
|
7661
|
+
count: 0
|
|
7662
|
+
};
|
|
7663
|
+
}
|
|
7664
|
+
if (buffer[close - 1] === "/") {
|
|
7665
|
+
return {
|
|
7666
|
+
count: close + 1
|
|
7667
|
+
};
|
|
7668
|
+
}
|
|
7669
|
+
return {
|
|
7670
|
+
count: close + 1,
|
|
7671
|
+
enterTag: nameMatch[1]
|
|
7672
|
+
};
|
|
7673
|
+
}
|
|
7674
|
+
return {
|
|
7675
|
+
count: xmlElementLength(buffer)
|
|
7676
|
+
};
|
|
7677
|
+
}
|
|
7678
|
+
if (ch === "!" && buffer.length > 1 && buffer[1] === "[") {
|
|
7679
|
+
return {
|
|
7680
|
+
count: linkLength(buffer, 1)
|
|
7681
|
+
};
|
|
7682
|
+
}
|
|
7683
|
+
if (ch === "[") {
|
|
7684
|
+
return {
|
|
7685
|
+
count: linkLength(buffer, 0)
|
|
7686
|
+
};
|
|
7687
|
+
}
|
|
7688
|
+
return {
|
|
7689
|
+
count: 1
|
|
7690
|
+
};
|
|
7691
|
+
};
|
|
7692
|
+
var xmlElementLength = (buffer) => {
|
|
7693
|
+
const close = buffer.indexOf(">");
|
|
7694
|
+
if (close === -1) {
|
|
7695
|
+
return 0;
|
|
7696
|
+
}
|
|
7697
|
+
if (buffer[close - 1] === "/") {
|
|
7698
|
+
return close + 1;
|
|
7699
|
+
}
|
|
7700
|
+
if (buffer[1] === "/") {
|
|
7701
|
+
return close + 1;
|
|
7702
|
+
}
|
|
7703
|
+
const nameMatch = buffer.match(OPENING_TAG_NAME);
|
|
7704
|
+
if (!nameMatch) {
|
|
7705
|
+
return 1;
|
|
7706
|
+
}
|
|
7707
|
+
const tagName = nameMatch[1];
|
|
7708
|
+
let depth = 0;
|
|
7709
|
+
const tagPattern = new RegExp(`<(/?)${escapeRegExpSource2(tagName)}(\\s[^>]*)?>`, "g");
|
|
7710
|
+
let match;
|
|
7711
|
+
while ((match = tagPattern.exec(buffer)) !== null) {
|
|
7712
|
+
const isSelfClosing = match[0].endsWith("/>");
|
|
7713
|
+
const isClosing = match[1] === "/";
|
|
7714
|
+
if (isSelfClosing) {
|
|
7715
|
+
if (depth === 0) {
|
|
7716
|
+
return match.index + match[0].length;
|
|
7717
|
+
}
|
|
7718
|
+
} else if (isClosing) {
|
|
7719
|
+
depth--;
|
|
7720
|
+
if (depth === 0) {
|
|
7721
|
+
return match.index + match[0].length;
|
|
7722
|
+
}
|
|
7723
|
+
} else {
|
|
7724
|
+
depth++;
|
|
7725
|
+
}
|
|
7726
|
+
}
|
|
7727
|
+
return 0;
|
|
7728
|
+
};
|
|
7729
|
+
var linkLength = (buffer, offset) => {
|
|
7730
|
+
const bracketClose = buffer.indexOf("]", offset + 1);
|
|
7731
|
+
if (bracketClose === -1) {
|
|
7732
|
+
return 0;
|
|
7733
|
+
}
|
|
7734
|
+
if (bracketClose + 1 >= buffer.length) {
|
|
7735
|
+
return 0;
|
|
7736
|
+
}
|
|
7737
|
+
if (buffer[bracketClose + 1] !== "(") {
|
|
7738
|
+
return 1;
|
|
7739
|
+
}
|
|
7740
|
+
const parenClose = buffer.indexOf(")", bracketClose + 2);
|
|
7741
|
+
if (parenClose === -1) {
|
|
7742
|
+
return 0;
|
|
7743
|
+
}
|
|
7744
|
+
return parenClose + 1;
|
|
7745
|
+
};
|
|
7086
7746
|
|
|
7087
7747
|
// src/extensions/tags/xml-tags.ts
|
|
7088
7748
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7089
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7090
|
-
import { Decoration as
|
|
7749
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect12, StateField as StateField14 } from "@codemirror/state";
|
|
7750
|
+
import { Decoration as Decoration16, EditorView as EditorView31, ViewPlugin as ViewPlugin22, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7091
7751
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7092
|
-
import { log as
|
|
7752
|
+
import { log as log11 } from "@dxos/log";
|
|
7753
|
+
import { Domino as Domino4 } from "@dxos/ui";
|
|
7093
7754
|
|
|
7094
7755
|
// src/extensions/tags/xml-util.ts
|
|
7095
7756
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7096
|
-
var
|
|
7757
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7097
7758
|
var nodeToJson = (state, node) => {
|
|
7098
7759
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7099
|
-
F:
|
|
7760
|
+
F: __dxlog_file16,
|
|
7100
7761
|
L: 18,
|
|
7101
7762
|
S: void 0,
|
|
7102
7763
|
A: [
|
|
@@ -7160,17 +7821,19 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7821
|
};
|
|
7161
7822
|
|
|
7162
7823
|
// src/extensions/tags/xml-tags.ts
|
|
7163
|
-
var
|
|
7164
|
-
var navigatePreviousEffect =
|
|
7165
|
-
var navigateNextEffect =
|
|
7824
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7825
|
+
var navigatePreviousEffect = StateEffect12.define();
|
|
7826
|
+
var navigateNextEffect = StateEffect12.define();
|
|
7166
7827
|
var getXmlTextChild = (children) => {
|
|
7167
7828
|
const child = children?.[0];
|
|
7168
7829
|
return typeof child === "string" ? child : null;
|
|
7169
7830
|
};
|
|
7170
|
-
var
|
|
7171
|
-
var
|
|
7172
|
-
var
|
|
7173
|
-
var
|
|
7831
|
+
var xmlWidgetId = (explicit, fallback) => typeof explicit === "string" && explicit.length > 0 ? explicit : fallback;
|
|
7832
|
+
var escapeRegExpSource3 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7833
|
+
var xmlTagContextEffect = StateEffect12.define();
|
|
7834
|
+
var xmlTagResetEffect = StateEffect12.define();
|
|
7835
|
+
var xmlTagUpdateEffect = StateEffect12.define();
|
|
7836
|
+
var widgetContextStateField = StateField14.define({
|
|
7174
7837
|
create: () => void 0,
|
|
7175
7838
|
update: (value, tr) => {
|
|
7176
7839
|
for (const effect of tr.effects) {
|
|
@@ -7181,7 +7844,7 @@ var widgetContextStateField = StateField13.define({
|
|
|
7181
7844
|
return value;
|
|
7182
7845
|
}
|
|
7183
7846
|
});
|
|
7184
|
-
var widgetStateMapStateField =
|
|
7847
|
+
var widgetStateMapStateField = StateField14.define({
|
|
7185
7848
|
create: () => ({}),
|
|
7186
7849
|
update: (map, tr) => {
|
|
7187
7850
|
for (const effect of tr.effects) {
|
|
@@ -7190,12 +7853,12 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7190
7853
|
}
|
|
7191
7854
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7192
7855
|
const { id, value } = effect.value;
|
|
7193
|
-
|
|
7856
|
+
log11("widget updated", {
|
|
7194
7857
|
id,
|
|
7195
7858
|
value
|
|
7196
7859
|
}, {
|
|
7197
|
-
F:
|
|
7198
|
-
L:
|
|
7860
|
+
F: __dxlog_file17,
|
|
7861
|
+
L: 184,
|
|
7199
7862
|
S: void 0,
|
|
7200
7863
|
C: (f, a) => f(...a)
|
|
7201
7864
|
});
|
|
@@ -7209,28 +7872,37 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7209
7872
|
return map;
|
|
7210
7873
|
}
|
|
7211
7874
|
});
|
|
7212
|
-
var
|
|
7875
|
+
var XML_WIDGET_DATA_ATTR = "data-xml-widget";
|
|
7876
|
+
var xmlTags = ({ registry, setWidgets, bookmarks: bookmarks2, paragraphToWidgetGapRem } = {}) => {
|
|
7213
7877
|
const notifier = createWidgetMap(setWidgets);
|
|
7214
7878
|
const widgetDecorationsField = createWidgetDecorationsField(registry, notifier);
|
|
7879
|
+
const paragraphGapTheme = paragraphToWidgetGapRem != null && paragraphToWidgetGapRem > 0 ? EditorView31.baseTheme({
|
|
7880
|
+
[`& .cm-content > .cm-line:not(:has([${XML_WIDGET_DATA_ATTR}])) + .cm-line:has([${XML_WIDGET_DATA_ATTR}])`]: {
|
|
7881
|
+
marginTop: `${paragraphToWidgetGapRem}rem`
|
|
7882
|
+
}
|
|
7883
|
+
}) : null;
|
|
7215
7884
|
return [
|
|
7216
7885
|
widgetContextStateField,
|
|
7217
7886
|
widgetStateMapStateField,
|
|
7218
7887
|
widgetDecorationsField,
|
|
7219
7888
|
createWidgetUpdatePlugin(widgetDecorationsField, notifier),
|
|
7220
7889
|
createNavigationEffectPlugin(widgetDecorationsField, bookmarks2),
|
|
7221
|
-
bookmarks2?.length ? Prec7.highest(keyHandlers) : []
|
|
7890
|
+
bookmarks2?.length ? Prec7.highest(keyHandlers) : [],
|
|
7891
|
+
...paragraphGapTheme ? [
|
|
7892
|
+
paragraphGapTheme
|
|
7893
|
+
] : []
|
|
7222
7894
|
];
|
|
7223
7895
|
};
|
|
7224
7896
|
var createWidgetMap = (setWidgets) => {
|
|
7225
7897
|
const widgets = /* @__PURE__ */ new Map();
|
|
7226
7898
|
const notifier = {
|
|
7227
7899
|
mounted: (state) => {
|
|
7228
|
-
|
|
7900
|
+
log11("widget mounted", {
|
|
7229
7901
|
id: state.id,
|
|
7230
7902
|
tag: state.props._tag
|
|
7231
7903
|
}, {
|
|
7232
|
-
F:
|
|
7233
|
-
L:
|
|
7904
|
+
F: __dxlog_file17,
|
|
7905
|
+
L: 261,
|
|
7234
7906
|
S: void 0,
|
|
7235
7907
|
C: (f, a) => f(...a)
|
|
7236
7908
|
});
|
|
@@ -7241,12 +7913,12 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7241
7913
|
},
|
|
7242
7914
|
unmounted: (id) => {
|
|
7243
7915
|
const state = widgets.get(id);
|
|
7244
|
-
|
|
7916
|
+
log11("widget unmounted", {
|
|
7245
7917
|
id,
|
|
7246
7918
|
tag: state?.props._tag
|
|
7247
7919
|
}, {
|
|
7248
|
-
F:
|
|
7249
|
-
L:
|
|
7920
|
+
F: __dxlog_file17,
|
|
7921
|
+
L: 267,
|
|
7250
7922
|
S: void 0,
|
|
7251
7923
|
C: (f, a) => f(...a)
|
|
7252
7924
|
});
|
|
@@ -7279,7 +7951,7 @@ var keyHandlers = keymap13.of([
|
|
|
7279
7951
|
}
|
|
7280
7952
|
]);
|
|
7281
7953
|
var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
7282
|
-
return
|
|
7954
|
+
return EditorView31.updateListener.of((update2) => {
|
|
7283
7955
|
update2.transactions.forEach((transaction) => {
|
|
7284
7956
|
for (const effect of transaction.effects) {
|
|
7285
7957
|
if (effect.is(navigatePreviousEffect)) {
|
|
@@ -7307,11 +7979,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7307
7979
|
anchor: line.from,
|
|
7308
7980
|
head: line.from
|
|
7309
7981
|
},
|
|
7310
|
-
effects:
|
|
7311
|
-
line: line.number,
|
|
7312
|
-
|
|
7313
|
-
offset: -16
|
|
7314
|
-
}
|
|
7982
|
+
effects: scrollerLineEffect.of({
|
|
7983
|
+
line: line.number - 1,
|
|
7984
|
+
offset: -16
|
|
7315
7985
|
})
|
|
7316
7986
|
});
|
|
7317
7987
|
continue;
|
|
@@ -7342,11 +8012,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7342
8012
|
anchor: line.to,
|
|
7343
8013
|
head: line.to
|
|
7344
8014
|
},
|
|
7345
|
-
effects:
|
|
7346
|
-
line: line.number,
|
|
7347
|
-
|
|
7348
|
-
offset: -16
|
|
7349
|
-
}
|
|
8015
|
+
effects: scrollerLineEffect.of({
|
|
8016
|
+
line: line.number - 1,
|
|
8017
|
+
offset: -16
|
|
7350
8018
|
})
|
|
7351
8019
|
});
|
|
7352
8020
|
} else {
|
|
@@ -7356,11 +8024,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7356
8024
|
anchor: line.to,
|
|
7357
8025
|
head: line.to
|
|
7358
8026
|
},
|
|
7359
|
-
effects:
|
|
7360
|
-
line: line.number,
|
|
7361
|
-
|
|
7362
|
-
position: "end"
|
|
7363
|
-
}
|
|
8027
|
+
effects: scrollerLineEffect.of({
|
|
8028
|
+
line: line.number - 1,
|
|
8029
|
+
position: "end"
|
|
7364
8030
|
})
|
|
7365
8031
|
});
|
|
7366
8032
|
}
|
|
@@ -7370,7 +8036,7 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7370
8036
|
});
|
|
7371
8037
|
});
|
|
7372
8038
|
};
|
|
7373
|
-
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) =>
|
|
8039
|
+
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin22.fromClass(class {
|
|
7374
8040
|
update(update2) {
|
|
7375
8041
|
const widgetStateMap = update2.state.field(widgetStateMapStateField);
|
|
7376
8042
|
const { decorations: decorations2 } = update2.state.field(widgetDecorationsField);
|
|
@@ -7397,19 +8063,25 @@ var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin1
|
|
|
7397
8063
|
}
|
|
7398
8064
|
}
|
|
7399
8065
|
});
|
|
7400
|
-
var createWidgetDecorationsField = (registry = {}, notifier) =>
|
|
8066
|
+
var createWidgetDecorationsField = (registry = {}, notifier) => StateField14.define({
|
|
7401
8067
|
create: (state) => {
|
|
7402
8068
|
return buildDecorations4(state, {
|
|
7403
8069
|
from: 0,
|
|
7404
8070
|
to: state.doc.length
|
|
7405
8071
|
}, registry, notifier);
|
|
7406
8072
|
},
|
|
7407
|
-
update: ({ from, decorations: decorations2 }, tr) => {
|
|
8073
|
+
update: ({ from, streamingFrom, decorations: decorations2 }, tr) => {
|
|
7408
8074
|
for (const effect of tr.effects) {
|
|
7409
8075
|
if (effect.is(xmlTagResetEffect)) {
|
|
8076
|
+
if (tr.docChanged) {
|
|
8077
|
+
return buildDecorations4(tr.state, {
|
|
8078
|
+
from: 0,
|
|
8079
|
+
to: tr.state.doc.length
|
|
8080
|
+
}, registry, notifier);
|
|
8081
|
+
}
|
|
7410
8082
|
return {
|
|
7411
8083
|
from: 0,
|
|
7412
|
-
decorations:
|
|
8084
|
+
decorations: Decoration16.none
|
|
7413
8085
|
};
|
|
7414
8086
|
}
|
|
7415
8087
|
}
|
|
@@ -7417,12 +8089,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7417
8089
|
const { state } = tr;
|
|
7418
8090
|
const reset = tr.changes.touchesRange(0, from);
|
|
7419
8091
|
if (reset) {
|
|
7420
|
-
|
|
8092
|
+
log11("document reset", {
|
|
7421
8093
|
from,
|
|
7422
8094
|
to: state.doc.length
|
|
7423
8095
|
}, {
|
|
7424
|
-
F:
|
|
7425
|
-
L:
|
|
8096
|
+
F: __dxlog_file17,
|
|
8097
|
+
L: 429,
|
|
7426
8098
|
S: void 0,
|
|
7427
8099
|
C: (f, a) => f(...a)
|
|
7428
8100
|
});
|
|
@@ -7431,13 +8103,17 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7431
8103
|
to: state.doc.length
|
|
7432
8104
|
}, registry, notifier);
|
|
7433
8105
|
} else {
|
|
8106
|
+
const rebuildFrom = streamingFrom ?? from;
|
|
7434
8107
|
const result = buildDecorations4(state, {
|
|
7435
|
-
from,
|
|
8108
|
+
from: rebuildFrom,
|
|
7436
8109
|
to: state.doc.length
|
|
7437
8110
|
}, registry, notifier);
|
|
7438
8111
|
return {
|
|
7439
8112
|
from: result.from,
|
|
8113
|
+
streamingFrom: result.streamingFrom,
|
|
7440
8114
|
decorations: decorations2.update({
|
|
8115
|
+
// Remove old streaming decorations — they are rebuilt each tick.
|
|
8116
|
+
filter: (_f, _t, deco) => !deco.spec.streaming,
|
|
7441
8117
|
add: decorationSetToArray(result.decorations)
|
|
7442
8118
|
})
|
|
7443
8119
|
};
|
|
@@ -7445,12 +8121,13 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7445
8121
|
}
|
|
7446
8122
|
return {
|
|
7447
8123
|
from,
|
|
8124
|
+
streamingFrom,
|
|
7448
8125
|
decorations: decorations2
|
|
7449
8126
|
};
|
|
7450
8127
|
},
|
|
7451
8128
|
provide: (field) => [
|
|
7452
|
-
|
|
7453
|
-
|
|
8129
|
+
EditorView31.decorations.from(field, (v) => v.decorations),
|
|
8130
|
+
EditorView31.atomicRanges.of((view) => view.state.field(field).decorations || Decoration16.none)
|
|
7454
8131
|
]
|
|
7455
8132
|
});
|
|
7456
8133
|
var buildDecorations4 = (state, range, registry, notifier) => {
|
|
@@ -7461,10 +8138,11 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7461
8138
|
if (!tree || tree.type.name === "Program" && tree.length === 0) {
|
|
7462
8139
|
return {
|
|
7463
8140
|
from: range.from,
|
|
7464
|
-
decorations:
|
|
8141
|
+
decorations: Decoration16.none
|
|
7465
8142
|
};
|
|
7466
8143
|
}
|
|
7467
8144
|
let last = range.from;
|
|
8145
|
+
let streamingFrom;
|
|
7468
8146
|
tree.iterate({
|
|
7469
8147
|
from: range.from,
|
|
7470
8148
|
to: range.to,
|
|
@@ -7477,21 +8155,26 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7477
8155
|
if (args) {
|
|
7478
8156
|
const def = registry[args._tag];
|
|
7479
8157
|
if (def) {
|
|
8158
|
+
if (def.streaming && !node.node.getChild("CloseTag")) {
|
|
8159
|
+
return false;
|
|
8160
|
+
}
|
|
7480
8161
|
const { block, factory, Component } = def;
|
|
7481
|
-
const widgetState = args.id ? widgetStateMap[args.id] : void 0;
|
|
7482
8162
|
const nodeRange = {
|
|
7483
8163
|
from: node.node.from,
|
|
7484
8164
|
to: node.node.to
|
|
7485
8165
|
};
|
|
8166
|
+
const widgetId = xmlWidgetId(args.id, def.streaming ? `cm-xml-${nodeRange.from}` : `cm-xml-${nodeRange.from}-${nodeRange.to}`);
|
|
8167
|
+
const widgetState = widgetStateMap[widgetId];
|
|
7486
8168
|
const props = {
|
|
7487
|
-
|
|
8169
|
+
id: widgetId,
|
|
7488
8170
|
range: nodeRange,
|
|
8171
|
+
context,
|
|
7489
8172
|
...args,
|
|
7490
8173
|
...widgetState
|
|
7491
8174
|
};
|
|
7492
|
-
const widget = factory ? factory(props) : Component ?
|
|
8175
|
+
const widget = factory ? factory(props) ?? void 0 : Component ? new PlaceholderWidget2(widgetId, Component, props, notifier) : void 0;
|
|
7493
8176
|
if (widget) {
|
|
7494
|
-
builder.add(nodeRange.from, nodeRange.to,
|
|
8177
|
+
builder.add(nodeRange.from, nodeRange.to, Decoration16.replace({
|
|
7495
8178
|
widget,
|
|
7496
8179
|
block,
|
|
7497
8180
|
atomic: true,
|
|
@@ -7503,9 +8186,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7503
8186
|
}
|
|
7504
8187
|
}
|
|
7505
8188
|
} catch (err) {
|
|
7506
|
-
|
|
7507
|
-
F:
|
|
7508
|
-
L:
|
|
8189
|
+
log11.catch(err, void 0, {
|
|
8190
|
+
F: __dxlog_file17,
|
|
8191
|
+
L: 538,
|
|
7509
8192
|
S: void 0,
|
|
7510
8193
|
C: (f, a) => f(...a)
|
|
7511
8194
|
});
|
|
@@ -7515,8 +8198,65 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7515
8198
|
}
|
|
7516
8199
|
}
|
|
7517
8200
|
});
|
|
8201
|
+
const streamingTagNames = Object.entries(registry).filter(([, def]) => def.streaming).map(([name]) => name).sort((a, b) => b.length - a.length);
|
|
8202
|
+
if (streamingTagNames.length > 0) {
|
|
8203
|
+
const tailText = state.sliceDoc(range.from, range.to);
|
|
8204
|
+
const streamingPattern = streamingTagNames.map(escapeRegExpSource3).join("|");
|
|
8205
|
+
const tagPattern = new RegExp(`<(${streamingPattern})(\\s[^>]*)?>`, "g");
|
|
8206
|
+
let match;
|
|
8207
|
+
while ((match = tagPattern.exec(tailText)) !== null) {
|
|
8208
|
+
const tagName = match[1];
|
|
8209
|
+
const closeTag = `</${tagName}>`;
|
|
8210
|
+
const afterOpen = match.index + match[0].length;
|
|
8211
|
+
if (tailText.indexOf(closeTag, afterOpen) === -1) {
|
|
8212
|
+
const absoluteFrom = range.from + match.index;
|
|
8213
|
+
const contentFrom = range.from + afterOpen;
|
|
8214
|
+
const innerText = state.sliceDoc(contentFrom, range.to).trim();
|
|
8215
|
+
const def = registry[tagName];
|
|
8216
|
+
const props = {
|
|
8217
|
+
_tag: tagName,
|
|
8218
|
+
context,
|
|
8219
|
+
range: {
|
|
8220
|
+
from: absoluteFrom,
|
|
8221
|
+
to: range.to
|
|
8222
|
+
},
|
|
8223
|
+
children: innerText ? [
|
|
8224
|
+
innerText
|
|
8225
|
+
] : void 0
|
|
8226
|
+
};
|
|
8227
|
+
const attrPattern = /(\w+)="([^"]*)"/g;
|
|
8228
|
+
let attrMatch;
|
|
8229
|
+
while ((attrMatch = attrPattern.exec(match[0])) !== null) {
|
|
8230
|
+
props[attrMatch[1]] = attrMatch[2];
|
|
8231
|
+
}
|
|
8232
|
+
const widgetId = xmlWidgetId(props.id, `cm-xml-${absoluteFrom}`);
|
|
8233
|
+
const widgetState = widgetStateMap[widgetId];
|
|
8234
|
+
const mergedProps = {
|
|
8235
|
+
...props,
|
|
8236
|
+
id: widgetId,
|
|
8237
|
+
...widgetState
|
|
8238
|
+
};
|
|
8239
|
+
const widget = def.factory ? def.factory(mergedProps) ?? void 0 : def.Component ? new PlaceholderWidget2(widgetId, def.Component, mergedProps, notifier, true) : void 0;
|
|
8240
|
+
if (widget) {
|
|
8241
|
+
builder.add(absoluteFrom, range.to, Decoration16.replace({
|
|
8242
|
+
widget,
|
|
8243
|
+
block: def.block,
|
|
8244
|
+
atomic: true,
|
|
8245
|
+
inclusive: true,
|
|
8246
|
+
tag: tagName,
|
|
8247
|
+
streaming: true,
|
|
8248
|
+
contentFrom
|
|
8249
|
+
}));
|
|
8250
|
+
streamingFrom = absoluteFrom;
|
|
8251
|
+
last = absoluteFrom;
|
|
8252
|
+
}
|
|
8253
|
+
break;
|
|
8254
|
+
}
|
|
8255
|
+
}
|
|
8256
|
+
}
|
|
7518
8257
|
return {
|
|
7519
8258
|
from: last,
|
|
8259
|
+
streamingFrom,
|
|
7520
8260
|
decorations: builder.finish()
|
|
7521
8261
|
};
|
|
7522
8262
|
};
|
|
@@ -7525,12 +8265,14 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7525
8265
|
Component;
|
|
7526
8266
|
props;
|
|
7527
8267
|
notifier;
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
8268
|
+
streaming;
|
|
8269
|
+
#root = null;
|
|
8270
|
+
#view;
|
|
8271
|
+
constructor(id, Component, props, notifier, streaming) {
|
|
8272
|
+
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier, this.streaming = streaming;
|
|
7531
8273
|
invariant7(id, void 0, {
|
|
7532
|
-
F:
|
|
7533
|
-
L:
|
|
8274
|
+
F: __dxlog_file17,
|
|
8275
|
+
L: 641,
|
|
7534
8276
|
S: this,
|
|
7535
8277
|
A: [
|
|
7536
8278
|
"id",
|
|
@@ -7539,27 +8281,50 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7539
8281
|
});
|
|
7540
8282
|
}
|
|
7541
8283
|
get root() {
|
|
7542
|
-
return this
|
|
8284
|
+
return this.#root;
|
|
7543
8285
|
}
|
|
7544
8286
|
eq(other) {
|
|
8287
|
+
if (this.streaming) {
|
|
8288
|
+
return false;
|
|
8289
|
+
}
|
|
7545
8290
|
return this.id === other.id;
|
|
7546
8291
|
}
|
|
7547
8292
|
ignoreEvent() {
|
|
7548
8293
|
return true;
|
|
7549
8294
|
}
|
|
7550
|
-
toDOM(
|
|
7551
|
-
this
|
|
8295
|
+
toDOM(view) {
|
|
8296
|
+
this.#view = view;
|
|
8297
|
+
this.#root = Domino4.of("div").classNames("min-h-[24px]").attributes({
|
|
8298
|
+
[XML_WIDGET_DATA_ATTR]: ""
|
|
8299
|
+
}).root;
|
|
8300
|
+
const props = Object.assign({}, this.props, {
|
|
8301
|
+
view
|
|
8302
|
+
});
|
|
7552
8303
|
this.notifier.mounted({
|
|
7553
8304
|
id: this.id,
|
|
7554
|
-
root: this
|
|
7555
|
-
props
|
|
8305
|
+
root: this.#root,
|
|
8306
|
+
props,
|
|
7556
8307
|
Component: this.Component
|
|
7557
8308
|
});
|
|
7558
|
-
return this
|
|
8309
|
+
return this.#root;
|
|
8310
|
+
}
|
|
8311
|
+
updateDOM(dom) {
|
|
8312
|
+
this.#root = dom;
|
|
8313
|
+
const props = Object.assign({}, this.props, {
|
|
8314
|
+
view: this.#view
|
|
8315
|
+
});
|
|
8316
|
+
this.notifier.mounted({
|
|
8317
|
+
id: this.id,
|
|
8318
|
+
root: this.#root,
|
|
8319
|
+
props,
|
|
8320
|
+
Component: this.Component
|
|
8321
|
+
});
|
|
8322
|
+
return true;
|
|
7559
8323
|
}
|
|
7560
8324
|
destroy(_dom) {
|
|
7561
8325
|
this.notifier.unmounted(this.id);
|
|
7562
|
-
this
|
|
8326
|
+
this.#root = null;
|
|
8327
|
+
this.#view = void 0;
|
|
7563
8328
|
}
|
|
7564
8329
|
};
|
|
7565
8330
|
|
|
@@ -7623,8 +8388,8 @@ export {
|
|
|
7623
8388
|
Cursor,
|
|
7624
8389
|
EditorInputMode,
|
|
7625
8390
|
EditorInputModes,
|
|
7626
|
-
|
|
7627
|
-
|
|
8391
|
+
EditorState4 as EditorState,
|
|
8392
|
+
EditorView32 as EditorView,
|
|
7628
8393
|
EditorViewMode,
|
|
7629
8394
|
EditorViewModes,
|
|
7630
8395
|
Inline,
|
|
@@ -7635,6 +8400,7 @@ export {
|
|
|
7635
8400
|
SpaceAwarenessProvider,
|
|
7636
8401
|
TextKind,
|
|
7637
8402
|
Tree,
|
|
8403
|
+
XML_WIDGET_DATA_ATTR,
|
|
7638
8404
|
addBlockquote,
|
|
7639
8405
|
addBookmark,
|
|
7640
8406
|
addCodeblock,
|
|
@@ -7643,6 +8409,7 @@ export {
|
|
|
7643
8409
|
addStyle,
|
|
7644
8410
|
annotations,
|
|
7645
8411
|
autoScroll,
|
|
8412
|
+
autoScrollEffect,
|
|
7646
8413
|
autocomplete,
|
|
7647
8414
|
automerge,
|
|
7648
8415
|
awareness,
|
|
@@ -7656,9 +8423,11 @@ export {
|
|
|
7656
8423
|
commentClickedEffect,
|
|
7657
8424
|
comments,
|
|
7658
8425
|
commentsState,
|
|
8426
|
+
compactSlots,
|
|
7659
8427
|
convertTreeToJson,
|
|
7660
8428
|
createBasicExtensions,
|
|
7661
8429
|
createComment,
|
|
8430
|
+
createCrawler,
|
|
7662
8431
|
createDataExtensions,
|
|
7663
8432
|
createEditorStateStore,
|
|
7664
8433
|
createEditorStateTransaction,
|
|
@@ -7678,12 +8447,12 @@ export {
|
|
|
7678
8447
|
defaultThemeSlots,
|
|
7679
8448
|
deleteItem,
|
|
7680
8449
|
documentId,
|
|
8450
|
+
documentSlots,
|
|
7681
8451
|
dropFile,
|
|
8452
|
+
editorClassNames,
|
|
7682
8453
|
editorInputMode,
|
|
7683
|
-
editorSlots,
|
|
7684
|
-
editorWidth,
|
|
7685
|
-
editorWithToolbarLayout,
|
|
7686
8454
|
extendedMarkdown,
|
|
8455
|
+
fader,
|
|
7687
8456
|
filterChars,
|
|
7688
8457
|
flattenRect,
|
|
7689
8458
|
focus,
|
|
@@ -7719,6 +8488,7 @@ export {
|
|
|
7719
8488
|
markdownTagsExtensions,
|
|
7720
8489
|
matchCompletion,
|
|
7721
8490
|
mention,
|
|
8491
|
+
mobileSlots,
|
|
7722
8492
|
modalStateEffect,
|
|
7723
8493
|
modalStateField,
|
|
7724
8494
|
moveItemDown,
|
|
@@ -7738,10 +8508,12 @@ export {
|
|
|
7738
8508
|
removeList,
|
|
7739
8509
|
removeStyle,
|
|
7740
8510
|
replacer,
|
|
8511
|
+
scrollPastEnd,
|
|
7741
8512
|
scrollThreadIntoView,
|
|
7742
|
-
scrollToBottomEffect,
|
|
7743
8513
|
scrollToLine,
|
|
7744
|
-
|
|
8514
|
+
scroller,
|
|
8515
|
+
scrollerCrawlEffect,
|
|
8516
|
+
scrollerLineEffect,
|
|
7745
8517
|
selectionState,
|
|
7746
8518
|
setBlockquote,
|
|
7747
8519
|
setComments,
|
|
@@ -7749,10 +8521,7 @@ export {
|
|
|
7749
8521
|
setSelection,
|
|
7750
8522
|
setStyle,
|
|
7751
8523
|
singleValueFacet,
|
|
7752
|
-
smoothScroll,
|
|
7753
|
-
stackItemContentEditorClassNames,
|
|
7754
8524
|
staticCompletion,
|
|
7755
|
-
streamer,
|
|
7756
8525
|
submit,
|
|
7757
8526
|
tabbable,
|
|
7758
8527
|
table,
|
|
@@ -7771,7 +8540,10 @@ export {
|
|
|
7771
8540
|
treeFacet,
|
|
7772
8541
|
typeahead,
|
|
7773
8542
|
typewriter,
|
|
8543
|
+
wire,
|
|
8544
|
+
wireBypass,
|
|
7774
8545
|
wrapWithCatch,
|
|
8546
|
+
xmlElementLength,
|
|
7775
8547
|
xmlTagContextEffect,
|
|
7776
8548
|
xmlTagResetEffect,
|
|
7777
8549
|
xmlTagUpdateEffect,
|