@dxos/ui-editor 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +1487 -725
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1487 -725
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/defaults.d.ts +3 -10
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts +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 +3 -1
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/scroll-past-end.d.ts +3 -0
- package/dist/types/src/extensions/scroll-past-end.d.ts.map +1 -0
- package/dist/types/src/extensions/scroller.d.ts +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/util/cursor.d.ts +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -32
- package/src/defaults.ts +25 -21
- 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 +6 -6
- 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 +8 -10
- 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 +62 -15
- 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/util/cursor.ts +1 -2
- 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
|
@@ -7,24 +7,36 @@ import {
|
|
|
7
7
|
} from "./chunk-YJZGD3LY.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 = {
|
|
22
36
|
content: {
|
|
23
|
-
className:
|
|
37
|
+
className: "mx-2! w-full"
|
|
24
38
|
}
|
|
25
39
|
};
|
|
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
40
|
|
|
29
41
|
// src/extensions/annotations.ts
|
|
30
42
|
import { RangeSetBuilder } from "@codemirror/state";
|
|
@@ -59,7 +71,7 @@ var annotations = ({ match } = {}) => {
|
|
|
59
71
|
".cm-annotation": {
|
|
60
72
|
textDecoration: "underline",
|
|
61
73
|
textDecorationStyle: "wavy",
|
|
62
|
-
textDecorationColor: "var(--
|
|
74
|
+
textDecorationColor: "var(--color-error-text)"
|
|
63
75
|
}
|
|
64
76
|
})
|
|
65
77
|
];
|
|
@@ -208,7 +220,7 @@ var singleValueFacet = (defaultValue) => Facet.define({
|
|
|
208
220
|
var overlap = (a, b) => a.from <= b.to && a.to >= b.from;
|
|
209
221
|
var defaultCursorConverter = {
|
|
210
222
|
toCursor: (position) => position.toString(),
|
|
211
|
-
fromCursor: (
|
|
223
|
+
fromCursor: (cursor) => parseInt(cursor)
|
|
212
224
|
};
|
|
213
225
|
var Cursor = class _Cursor {
|
|
214
226
|
static converter = singleValueFacet(defaultCursorConverter);
|
|
@@ -221,9 +233,9 @@ var Cursor = class _Cursor {
|
|
|
221
233
|
to
|
|
222
234
|
].join(":");
|
|
223
235
|
};
|
|
224
|
-
static getRangeFromCursor = (state,
|
|
236
|
+
static getRangeFromCursor = (state, cursor) => {
|
|
225
237
|
const cursorConverter2 = state.facet(_Cursor.converter);
|
|
226
|
-
const parts =
|
|
238
|
+
const parts = cursor.split(":");
|
|
227
239
|
const from = cursorConverter2.fromCursor(parts[0]);
|
|
228
240
|
const to = cursorConverter2.fromCursor(parts[1]);
|
|
229
241
|
return from !== void 0 && to !== void 0 ? {
|
|
@@ -502,228 +514,295 @@ var typeahead = ({ onComplete } = {}) => {
|
|
|
502
514
|
];
|
|
503
515
|
};
|
|
504
516
|
|
|
505
|
-
// src/extensions/
|
|
517
|
+
// src/extensions/auto-scroll.ts
|
|
506
518
|
import { StateEffect as StateEffect2 } from "@codemirror/state";
|
|
507
519
|
import { EditorView as EditorView5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
508
|
-
import {
|
|
520
|
+
import { addEventListener, combine, throttle } from "@dxos/async";
|
|
509
521
|
import { Domino } from "@dxos/ui";
|
|
522
|
+
import { getSize } from "@dxos/ui-theme";
|
|
510
523
|
|
|
511
|
-
// src/extensions/
|
|
524
|
+
// src/extensions/scroller.ts
|
|
512
525
|
import { StateEffect } from "@codemirror/state";
|
|
513
526
|
import { EditorView as EditorView4, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
514
|
-
|
|
515
|
-
var
|
|
516
|
-
|
|
527
|
+
import { log as log2 } from "@dxos/log";
|
|
528
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/scroller.ts";
|
|
529
|
+
var scrollerLineEffect = StateEffect.define();
|
|
530
|
+
var scrollerCrawlEffect = StateEffect.define();
|
|
531
|
+
var scrollToLine = (view, options) => {
|
|
532
|
+
view.dispatch({
|
|
533
|
+
effects: scrollerLineEffect.of(options)
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
var scroller = ({ overScroll = 0 } = {}) => {
|
|
537
|
+
const scrollPlugin = ViewPlugin5.fromClass(class ScrollerPlugin {
|
|
517
538
|
view;
|
|
539
|
+
crawler;
|
|
518
540
|
constructor(view) {
|
|
519
541
|
this.view = view;
|
|
542
|
+
this.crawler = createCrawler(this.view);
|
|
520
543
|
}
|
|
521
544
|
// No-op.
|
|
522
545
|
destroy() {
|
|
546
|
+
this.crawler.cancel();
|
|
523
547
|
}
|
|
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;
|
|
548
|
+
cancel() {
|
|
549
|
+
this.crawler.cancel();
|
|
550
|
+
}
|
|
551
|
+
crawl(start = false) {
|
|
552
|
+
if (start) {
|
|
553
|
+
this.crawler.scroll();
|
|
559
554
|
} else {
|
|
560
|
-
|
|
555
|
+
this.crawler.cancel();
|
|
561
556
|
}
|
|
562
|
-
const clampedScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
563
|
-
this.animateScroll(scroller, clampedScrollTop);
|
|
564
557
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
558
|
+
scroll({ line, offset = 0, position, behavior = "instant" }) {
|
|
559
|
+
const { scrollTop, scrollHeight, clientHeight } = this.view.scrollDOM;
|
|
560
|
+
const scrollerRect = this.view.scrollDOM.getBoundingClientRect();
|
|
561
|
+
const doc = this.view.state.doc;
|
|
562
|
+
let targetScrollTop = scrollHeight - clientHeight + offset;
|
|
563
|
+
if (line >= 0 && line <= doc.lines - 1) {
|
|
564
|
+
const lineStart = doc.line(line + 1).from;
|
|
565
|
+
const coords = this.view.coordsAtPos(lineStart);
|
|
566
|
+
if (coords) {
|
|
567
|
+
const currentScrollTop = scrollTop;
|
|
568
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
569
|
+
if (position === "end") {
|
|
570
|
+
targetScrollTop = currentScrollTop + coords.bottom - scrollerRect.bottom + offset;
|
|
571
|
+
} else {
|
|
572
|
+
targetScrollTop = currentScrollTop + coords.top - scrollerRect.top + offset;
|
|
573
|
+
}
|
|
574
|
+
targetScrollTop = Math.max(0, Math.min(targetScrollTop, maxScrollTop));
|
|
575
|
+
}
|
|
571
576
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
577
|
+
requestAnimationFrame(() => {
|
|
578
|
+
this.view.scrollDOM.scrollTo({
|
|
579
|
+
top: targetScrollTop
|
|
580
|
+
});
|
|
575
581
|
});
|
|
576
582
|
}
|
|
577
583
|
});
|
|
578
584
|
return [
|
|
579
585
|
scrollPlugin,
|
|
580
|
-
//
|
|
586
|
+
// Listen for effect.s
|
|
581
587
|
EditorView4.updateListener.of((update2) => {
|
|
582
588
|
update2.transactions.forEach((transaction) => {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
});
|
|
589
|
+
try {
|
|
590
|
+
const plugin = update2.view.plugin(scrollPlugin);
|
|
591
|
+
if (plugin) {
|
|
592
|
+
for (const effect of transaction.effects) {
|
|
593
|
+
if (effect.is(scrollerCrawlEffect)) {
|
|
594
|
+
plugin.crawl(effect.value);
|
|
595
|
+
} else if (effect.is(scrollerLineEffect)) {
|
|
596
|
+
plugin.scroll(effect.value);
|
|
597
|
+
}
|
|
593
598
|
}
|
|
594
599
|
}
|
|
600
|
+
} catch (err) {
|
|
601
|
+
log2.catch(err, void 0, {
|
|
602
|
+
F: __dxlog_file2,
|
|
603
|
+
L: 146,
|
|
604
|
+
S: void 0,
|
|
605
|
+
C: (f, a) => f(...a)
|
|
606
|
+
});
|
|
595
607
|
}
|
|
596
608
|
});
|
|
609
|
+
}),
|
|
610
|
+
// Styles.
|
|
611
|
+
EditorView4.theme({
|
|
612
|
+
".cm-content": {
|
|
613
|
+
paddingBottom: `${overScroll}px`
|
|
614
|
+
},
|
|
615
|
+
".cm-scroller": {
|
|
616
|
+
overflowY: "scroll",
|
|
617
|
+
overflowAnchor: "none",
|
|
618
|
+
paddingBottom: "0"
|
|
619
|
+
},
|
|
620
|
+
".cm-scroller.cm-hide-scrollbar::-webkit-scrollbar": {
|
|
621
|
+
display: "none"
|
|
622
|
+
},
|
|
623
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
624
|
+
background: "transparent",
|
|
625
|
+
transition: "background 0.15s"
|
|
626
|
+
},
|
|
627
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
628
|
+
background: "var(--color-scrollbar-thumb)"
|
|
629
|
+
},
|
|
630
|
+
".cm-scroll-button": {
|
|
631
|
+
position: "absolute",
|
|
632
|
+
bottom: "0.5rem",
|
|
633
|
+
right: "1rem"
|
|
634
|
+
}
|
|
597
635
|
})
|
|
598
636
|
];
|
|
599
637
|
};
|
|
600
|
-
|
|
601
|
-
view.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
638
|
+
function createCrawler(view, accel = 0.15, maxVelocity = 1, snapThreshold = 0.5) {
|
|
639
|
+
const el = view.scrollDOM;
|
|
640
|
+
let currentTop = 0;
|
|
641
|
+
let velocity = 0;
|
|
642
|
+
let rafId = null;
|
|
643
|
+
function frame() {
|
|
644
|
+
const targetTop = el.scrollHeight - el.clientHeight;
|
|
645
|
+
const delta = targetTop - currentTop;
|
|
646
|
+
const absDelta = Math.abs(delta);
|
|
647
|
+
if (absDelta < snapThreshold && Math.abs(velocity) < snapThreshold) {
|
|
648
|
+
el.scrollTop = targetTop;
|
|
649
|
+
currentTop = targetTop;
|
|
650
|
+
velocity = 0;
|
|
651
|
+
rafId = null;
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const stoppingDistance = velocity * velocity / (2 * accel);
|
|
655
|
+
const direction = Math.sign(delta);
|
|
656
|
+
if (velocity !== 0 && (absDelta <= stoppingDistance || direction !== Math.sign(velocity))) {
|
|
657
|
+
velocity -= Math.sign(velocity) * Math.min(accel, Math.abs(velocity));
|
|
658
|
+
} else {
|
|
659
|
+
velocity += direction * accel;
|
|
660
|
+
velocity = Math.sign(velocity) * Math.min(Math.abs(velocity), maxVelocity);
|
|
661
|
+
}
|
|
662
|
+
currentTop += velocity;
|
|
663
|
+
el.scrollTop = currentTop;
|
|
664
|
+
rafId = requestAnimationFrame(frame);
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
scroll: () => {
|
|
668
|
+
if (rafId === null) {
|
|
669
|
+
currentTop = el.scrollTop;
|
|
670
|
+
rafId = requestAnimationFrame(frame);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
cancel: () => {
|
|
674
|
+
if (rafId !== null) {
|
|
675
|
+
cancelAnimationFrame(rafId);
|
|
676
|
+
rafId = null;
|
|
677
|
+
velocity = 0;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
608
682
|
|
|
609
|
-
// src/extensions/
|
|
610
|
-
var
|
|
611
|
-
var autoScroll = (
|
|
683
|
+
// src/extensions/auto-scroll.ts
|
|
684
|
+
var autoScrollEffect = StateEffect2.define();
|
|
685
|
+
var autoScroll = (_ = {}) => {
|
|
612
686
|
let buttonContainer;
|
|
613
|
-
let hideTimeout;
|
|
614
|
-
let lastScrollTop = 0;
|
|
615
687
|
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);
|
|
688
|
+
let jumpPending = false;
|
|
689
|
+
let enabled = true;
|
|
690
|
+
let firstUpdate = true;
|
|
691
|
+
const setPinned = (pinned) => {
|
|
692
|
+
buttonContainer?.classList.toggle("opacity-0", pinned);
|
|
693
|
+
isPinned = pinned;
|
|
626
694
|
};
|
|
627
|
-
const scrollToBottom = (view, behavior) => {
|
|
628
|
-
setPinned(true);
|
|
629
|
-
hideScrollbar(view);
|
|
630
|
-
const line = view.state.doc.lineAt(view.state.doc.length);
|
|
631
|
-
view.dispatch({
|
|
632
|
-
selection: {
|
|
633
|
-
anchor: line.to,
|
|
634
|
-
head: line.to
|
|
635
|
-
},
|
|
636
|
-
effects: scrollToLineEffect.of({
|
|
637
|
-
line: line.number,
|
|
638
|
-
options: {
|
|
639
|
-
position: "end",
|
|
640
|
-
offset: threshold,
|
|
641
|
-
behavior
|
|
642
|
-
}
|
|
643
|
-
})
|
|
644
|
-
});
|
|
645
|
-
};
|
|
646
|
-
const checkDistance = debounce((view) => {
|
|
647
|
-
const scrollerRect = view.scrollDOM.getBoundingClientRect();
|
|
648
|
-
const coords = view.coordsAtPos(view.state.doc.length);
|
|
649
|
-
const distanceFromBottom = coords ? coords.bottom - scrollerRect.bottom : 0;
|
|
650
|
-
setPinned(distanceFromBottom < 0);
|
|
651
|
-
}, 1e3);
|
|
652
|
-
const triggerUpdate = debounce((view) => scrollToBottom(view), throttleDelay);
|
|
653
695
|
return [
|
|
654
|
-
// Update listener for
|
|
655
|
-
EditorView5.updateListener.of((
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
696
|
+
// Update listener for scrolling when content changes.
|
|
697
|
+
EditorView5.updateListener.of((update2) => {
|
|
698
|
+
const { view, heightChanged, state, startState } = update2;
|
|
699
|
+
for (const tr of update2.transactions) {
|
|
700
|
+
for (const effect of tr.effects) {
|
|
701
|
+
if (effect.is(autoScrollEffect)) {
|
|
702
|
+
enabled = effect.value;
|
|
703
|
+
if (enabled) {
|
|
704
|
+
setPinned(true);
|
|
705
|
+
view.dispatch({
|
|
706
|
+
effects: scrollerCrawlEffect.of(true)
|
|
707
|
+
});
|
|
708
|
+
} else {
|
|
709
|
+
view.dispatch({
|
|
710
|
+
effects: scrollerCrawlEffect.of(false)
|
|
711
|
+
});
|
|
712
|
+
}
|
|
660
713
|
}
|
|
661
714
|
}
|
|
662
|
-
}
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
715
|
+
}
|
|
716
|
+
if (!enabled) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
if (isPinned && (firstUpdate || startState.doc.length === 0) && state.doc.length > 0) {
|
|
720
|
+
firstUpdate = false;
|
|
721
|
+
jumpPending = true;
|
|
722
|
+
requestAnimationFrame(() => {
|
|
723
|
+
view.scrollDOM.scrollTop = view.scrollDOM.scrollHeight;
|
|
724
|
+
jumpPending = false;
|
|
725
|
+
});
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
firstUpdate = false;
|
|
729
|
+
if (jumpPending) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (heightChanged) {
|
|
733
|
+
if (isPinned) {
|
|
734
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
735
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
736
|
+
if (delta > 0) {
|
|
737
|
+
setPinned(true);
|
|
738
|
+
view.dispatch({
|
|
739
|
+
effects: scrollerCrawlEffect.of(true)
|
|
740
|
+
});
|
|
741
|
+
} else if (delta < -1) {
|
|
742
|
+
setPinned(false);
|
|
743
|
+
}
|
|
744
|
+
} else {
|
|
745
|
+
if (state.doc.length === 0) {
|
|
746
|
+
setPinned(true);
|
|
674
747
|
}
|
|
675
|
-
} else if (distanceFromBottom < 0) {
|
|
676
|
-
setPinned(false);
|
|
677
748
|
}
|
|
678
749
|
}
|
|
679
750
|
}),
|
|
680
|
-
// Detect user scroll.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
751
|
+
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
752
|
+
ViewPlugin6.fromClass(class {
|
|
753
|
+
cleanup;
|
|
754
|
+
constructor(view) {
|
|
755
|
+
this.cleanup = createUserScrollDetector(view.scrollDOM, throttle(() => {
|
|
756
|
+
requestAnimationFrame(() => {
|
|
757
|
+
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
758
|
+
const delta = scrollHeight - scrollTop - clientHeight;
|
|
759
|
+
const pinned = delta === 0;
|
|
760
|
+
setPinned(pinned);
|
|
761
|
+
if (!pinned) {
|
|
762
|
+
view.dispatch({
|
|
763
|
+
effects: scrollerCrawlEffect.of(false)
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}, 500));
|
|
768
|
+
}
|
|
769
|
+
destroy() {
|
|
770
|
+
this.cleanup();
|
|
691
771
|
}
|
|
692
772
|
}),
|
|
693
773
|
// Scroll button.
|
|
694
774
|
ViewPlugin6.fromClass(class {
|
|
695
775
|
constructor(view) {
|
|
696
|
-
const icon = Domino.of("dx-icon").attributes({
|
|
776
|
+
const icon = Domino.of("dx-icon").classNames(getSize(4)).attributes({
|
|
697
777
|
icon: "ph--arrow-down--regular"
|
|
698
778
|
});
|
|
699
|
-
const button = Domino.of("button").classNames("dx-button bg-
|
|
779
|
+
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
700
780
|
"data-density": "fine"
|
|
701
|
-
}).
|
|
702
|
-
|
|
781
|
+
}).append(icon).on("click", () => {
|
|
782
|
+
setPinned(true);
|
|
783
|
+
view.dispatch({
|
|
784
|
+
effects: scrollerLineEffect.of({
|
|
785
|
+
line: -1,
|
|
786
|
+
position: "end",
|
|
787
|
+
behavior: "smooth"
|
|
788
|
+
})
|
|
789
|
+
});
|
|
703
790
|
});
|
|
704
|
-
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").
|
|
791
|
+
buttonContainer = Domino.of("div").classNames("cm-scroll-button transition-opacity duration-300 opacity-0").append(button).root;
|
|
705
792
|
view.scrollDOM.parentElement.appendChild(buttonContainer);
|
|
706
793
|
}
|
|
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
794
|
})
|
|
725
795
|
];
|
|
726
796
|
};
|
|
797
|
+
function createUserScrollDetector(element, onUserScroll) {
|
|
798
|
+
return combine(addEventListener(element, "wheel", () => onUserScroll(), {
|
|
799
|
+
passive: true
|
|
800
|
+
}), addEventListener(element, "pointerdown", (event) => {
|
|
801
|
+
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
802
|
+
onUserScroll();
|
|
803
|
+
}
|
|
804
|
+
}));
|
|
805
|
+
}
|
|
727
806
|
|
|
728
807
|
// src/extensions/automerge/automerge.ts
|
|
729
808
|
import { next as A3 } from "@automerge/automerge";
|
|
@@ -737,15 +816,15 @@ var initialSync = Transaction.userEvent.of("initial.sync");
|
|
|
737
816
|
|
|
738
817
|
// src/extensions/automerge/cursor.ts
|
|
739
818
|
import { fromCursor, toCursor } from "@dxos/echo-db";
|
|
740
|
-
import { log as
|
|
741
|
-
var
|
|
819
|
+
import { log as log3 } from "@dxos/log";
|
|
820
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/cursor.ts";
|
|
742
821
|
var cursorConverter = (accessor) => ({
|
|
743
822
|
toCursor: (pos, assoc) => {
|
|
744
823
|
try {
|
|
745
824
|
return toCursor(accessor, pos, assoc);
|
|
746
825
|
} catch (err) {
|
|
747
|
-
|
|
748
|
-
F:
|
|
826
|
+
log3.catch(err, void 0, {
|
|
827
|
+
F: __dxlog_file3,
|
|
749
828
|
L: 15,
|
|
750
829
|
S: void 0,
|
|
751
830
|
C: (f, a) => f(...a)
|
|
@@ -753,12 +832,12 @@ var cursorConverter = (accessor) => ({
|
|
|
753
832
|
return "";
|
|
754
833
|
}
|
|
755
834
|
},
|
|
756
|
-
fromCursor: (
|
|
835
|
+
fromCursor: (cursor) => {
|
|
757
836
|
try {
|
|
758
|
-
return fromCursor(accessor,
|
|
837
|
+
return fromCursor(accessor, cursor);
|
|
759
838
|
} catch (err) {
|
|
760
|
-
|
|
761
|
-
F:
|
|
839
|
+
log3.catch(err, void 0, {
|
|
840
|
+
F: __dxlog_file3,
|
|
762
841
|
L: 24,
|
|
763
842
|
S: void 0,
|
|
764
843
|
C: (f, a) => f(...a)
|
|
@@ -783,7 +862,7 @@ var isReconcile = (tr) => {
|
|
|
783
862
|
|
|
784
863
|
// src/extensions/automerge/sync.ts
|
|
785
864
|
import { next as A2 } from "@automerge/automerge";
|
|
786
|
-
import { log as
|
|
865
|
+
import { log as log4 } from "@dxos/log";
|
|
787
866
|
|
|
788
867
|
// src/extensions/automerge/update-automerge.ts
|
|
789
868
|
import { next as A } from "@automerge/automerge";
|
|
@@ -924,7 +1003,7 @@ var charPath = (textPath, candidatePath) => {
|
|
|
924
1003
|
};
|
|
925
1004
|
|
|
926
1005
|
// src/extensions/automerge/sync.ts
|
|
927
|
-
var
|
|
1006
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/automerge/sync.ts";
|
|
928
1007
|
var Syncer = class {
|
|
929
1008
|
_handle;
|
|
930
1009
|
_state;
|
|
@@ -947,8 +1026,8 @@ var Syncer = class {
|
|
|
947
1026
|
this._pending = false;
|
|
948
1027
|
}
|
|
949
1028
|
onEditorChange(view) {
|
|
950
|
-
|
|
951
|
-
F:
|
|
1029
|
+
log4("onEditorChange", void 0, {
|
|
1030
|
+
F: __dxlog_file4,
|
|
952
1031
|
L: 45,
|
|
953
1032
|
S: this,
|
|
954
1033
|
C: (f, a) => f(...a)
|
|
@@ -963,8 +1042,8 @@ var Syncer = class {
|
|
|
963
1042
|
}
|
|
964
1043
|
}
|
|
965
1044
|
onAutomergeChange(view) {
|
|
966
|
-
|
|
967
|
-
F:
|
|
1045
|
+
log4("onAutomergeChange", void 0, {
|
|
1046
|
+
F: __dxlog_file4,
|
|
968
1047
|
L: 60,
|
|
969
1048
|
S: this,
|
|
970
1049
|
C: (f, a) => f(...a)
|
|
@@ -1030,6 +1109,15 @@ var automerge = (accessor) => {
|
|
|
1030
1109
|
const value = DocAccessor.getValue(accessor);
|
|
1031
1110
|
const current = this._view.state.doc.toString();
|
|
1032
1111
|
if (value !== current) {
|
|
1112
|
+
console.warn("ENABLING INITIAL SYNC -- THIS MAY BE A REGRESSION");
|
|
1113
|
+
this._view.dispatch({
|
|
1114
|
+
changes: {
|
|
1115
|
+
from: 0,
|
|
1116
|
+
to: this._view.state.doc.length,
|
|
1117
|
+
insert: value
|
|
1118
|
+
},
|
|
1119
|
+
annotations: initialSync
|
|
1120
|
+
});
|
|
1033
1121
|
}
|
|
1034
1122
|
});
|
|
1035
1123
|
}
|
|
@@ -1057,7 +1145,7 @@ import { Annotation as Annotation2, RangeSet } from "@codemirror/state";
|
|
|
1057
1145
|
import { Decoration as Decoration5, EditorView as EditorView7, ViewPlugin as ViewPlugin8, WidgetType as WidgetType3 } from "@codemirror/view";
|
|
1058
1146
|
import { Event } from "@dxos/async";
|
|
1059
1147
|
import { Context } from "@dxos/context";
|
|
1060
|
-
var
|
|
1148
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness.ts";
|
|
1061
1149
|
var dummyProvider = {
|
|
1062
1150
|
remoteStateChange: new Event(),
|
|
1063
1151
|
open: () => {
|
|
@@ -1081,7 +1169,7 @@ var awareness = (provider = dummyProvider) => {
|
|
|
1081
1169
|
};
|
|
1082
1170
|
var RemoteSelectionsDecorator = class {
|
|
1083
1171
|
_ctx = new Context(void 0, {
|
|
1084
|
-
F:
|
|
1172
|
+
F: __dxlog_file5,
|
|
1085
1173
|
L: 80
|
|
1086
1174
|
});
|
|
1087
1175
|
_cursorConverter;
|
|
@@ -1294,8 +1382,8 @@ var styles = EditorView7.theme({
|
|
|
1294
1382
|
import { DeferredTask, Event as Event2, sleep } from "@dxos/async";
|
|
1295
1383
|
import { Context as Context2 } from "@dxos/context";
|
|
1296
1384
|
import { invariant } from "@dxos/invariant";
|
|
1297
|
-
import { log as
|
|
1298
|
-
var
|
|
1385
|
+
import { log as log5 } from "@dxos/log";
|
|
1386
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/awareness/awareness-provider.ts";
|
|
1299
1387
|
var DEBOUNCE_INTERVAL = 100;
|
|
1300
1388
|
var SpaceAwarenessProvider = class {
|
|
1301
1389
|
_remoteStates = /* @__PURE__ */ new Map();
|
|
@@ -1315,7 +1403,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1315
1403
|
}
|
|
1316
1404
|
open() {
|
|
1317
1405
|
this._ctx = new Context2(void 0, {
|
|
1318
|
-
F:
|
|
1406
|
+
F: __dxlog_file6,
|
|
1319
1407
|
L: 57
|
|
1320
1408
|
});
|
|
1321
1409
|
this._postTask = new DeferredTask(this._ctx, async () => {
|
|
@@ -1342,10 +1430,10 @@ var SpaceAwarenessProvider = class {
|
|
|
1342
1430
|
void this._messenger.postMessage(this._channel, {
|
|
1343
1431
|
kind: "query"
|
|
1344
1432
|
}).catch((err) => {
|
|
1345
|
-
|
|
1433
|
+
log5.debug("failed to query awareness", {
|
|
1346
1434
|
err
|
|
1347
1435
|
}, {
|
|
1348
|
-
F:
|
|
1436
|
+
F: __dxlog_file6,
|
|
1349
1437
|
L: 91,
|
|
1350
1438
|
S: this,
|
|
1351
1439
|
C: (f, a) => f(...a)
|
|
@@ -1362,7 +1450,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1362
1450
|
}
|
|
1363
1451
|
update(position) {
|
|
1364
1452
|
invariant(this._postTask, void 0, {
|
|
1365
|
-
F:
|
|
1453
|
+
F: __dxlog_file6,
|
|
1366
1454
|
L: 106,
|
|
1367
1455
|
S: this,
|
|
1368
1456
|
A: [
|
|
@@ -1379,7 +1467,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1379
1467
|
}
|
|
1380
1468
|
_handleQueryMessage() {
|
|
1381
1469
|
invariant(this._postTask, void 0, {
|
|
1382
|
-
F:
|
|
1470
|
+
F: __dxlog_file6,
|
|
1383
1471
|
L: 117,
|
|
1384
1472
|
S: this,
|
|
1385
1473
|
A: [
|
|
@@ -1391,7 +1479,7 @@ var SpaceAwarenessProvider = class {
|
|
|
1391
1479
|
}
|
|
1392
1480
|
_handlePostMessage(message) {
|
|
1393
1481
|
invariant(message.kind === "post", void 0, {
|
|
1394
|
-
F:
|
|
1482
|
+
F: __dxlog_file6,
|
|
1395
1483
|
L: 122,
|
|
1396
1484
|
S: this,
|
|
1397
1485
|
A: [
|
|
@@ -1407,9 +1495,9 @@ var SpaceAwarenessProvider = class {
|
|
|
1407
1495
|
// src/extensions/blast.ts
|
|
1408
1496
|
import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
|
|
1409
1497
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
1410
|
-
import { throttle } from "@dxos/async";
|
|
1498
|
+
import { throttle as throttle2 } from "@dxos/async";
|
|
1411
1499
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1412
|
-
var
|
|
1500
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/blast.ts";
|
|
1413
1501
|
var defaultOptions = {
|
|
1414
1502
|
effect: 2,
|
|
1415
1503
|
maxParticles: 200,
|
|
@@ -1528,7 +1616,7 @@ var Blaster = class {
|
|
|
1528
1616
|
}
|
|
1529
1617
|
initialize() {
|
|
1530
1618
|
invariant2(!this._canvas && !this._ctx, void 0, {
|
|
1531
|
-
F:
|
|
1619
|
+
F: __dxlog_file7,
|
|
1532
1620
|
L: 142,
|
|
1533
1621
|
S: this,
|
|
1534
1622
|
A: [
|
|
@@ -1565,7 +1653,7 @@ var Blaster = class {
|
|
|
1565
1653
|
}
|
|
1566
1654
|
start() {
|
|
1567
1655
|
invariant2(this._canvas && this._ctx, void 0, {
|
|
1568
|
-
F:
|
|
1656
|
+
F: __dxlog_file7,
|
|
1569
1657
|
L: 181,
|
|
1570
1658
|
S: this,
|
|
1571
1659
|
A: [
|
|
@@ -1599,11 +1687,11 @@ var Blaster = class {
|
|
|
1599
1687
|
this.drawParticles();
|
|
1600
1688
|
requestAnimationFrame(this.loop.bind(this));
|
|
1601
1689
|
}
|
|
1602
|
-
shake =
|
|
1690
|
+
shake = throttle2(({ time }) => {
|
|
1603
1691
|
this._shakeTime = this._shakeTimeMax || time;
|
|
1604
1692
|
this._shakeTimeMax = time;
|
|
1605
1693
|
}, 100);
|
|
1606
|
-
spawn =
|
|
1694
|
+
spawn = throttle2(({ element, point }) => {
|
|
1607
1695
|
const color = getRGBComponents(element, this._options.color);
|
|
1608
1696
|
const numParticles = random(this._options.particleNumRange.min, this._options.particleNumRange.max);
|
|
1609
1697
|
const dir = this._lastPoint.x === point.x ? 0 : this._lastPoint.x < point.x ? 1 : -1;
|
|
@@ -1777,11 +1865,11 @@ var blocks = () => [
|
|
|
1777
1865
|
".cm-line.block-line": {
|
|
1778
1866
|
paddingLeft: "0.75rem",
|
|
1779
1867
|
paddingRight: "0.75rem",
|
|
1780
|
-
borderLeft: "1px solid var(--
|
|
1781
|
-
borderRight: "1px solid var(--
|
|
1868
|
+
borderLeft: "1px solid var(--color-subdued-separator)",
|
|
1869
|
+
borderRight: "1px solid var(--color-subdued-separator)"
|
|
1782
1870
|
},
|
|
1783
1871
|
".cm-line.block-single": {
|
|
1784
|
-
border: "1px solid var(--
|
|
1872
|
+
border: "1px solid var(--color-subdued-separator)",
|
|
1785
1873
|
borderRadius: "6px",
|
|
1786
1874
|
paddingTop: "0.5rem",
|
|
1787
1875
|
paddingBottom: "0.5rem",
|
|
@@ -1789,7 +1877,7 @@ var blocks = () => [
|
|
|
1789
1877
|
marginBottom: "0.5rem"
|
|
1790
1878
|
},
|
|
1791
1879
|
".cm-line.block-first": {
|
|
1792
|
-
borderTop: "1px solid var(--
|
|
1880
|
+
borderTop: "1px solid var(--color-subdued-separator)",
|
|
1793
1881
|
borderTopLeftRadius: "6px",
|
|
1794
1882
|
borderTopRightRadius: "6px",
|
|
1795
1883
|
paddingTop: "0.5rem",
|
|
@@ -1797,7 +1885,7 @@ var blocks = () => [
|
|
|
1797
1885
|
},
|
|
1798
1886
|
".cm-line.block-middle": {},
|
|
1799
1887
|
".cm-line.block-last": {
|
|
1800
|
-
borderBottom: "1px solid var(--
|
|
1888
|
+
borderBottom: "1px solid var(--color-subdued-separator)",
|
|
1801
1889
|
borderBottomLeftRadius: "6px",
|
|
1802
1890
|
borderBottomRightRadius: "6px",
|
|
1803
1891
|
paddingBottom: "0.5rem",
|
|
@@ -1809,8 +1897,8 @@ var blocks = () => [
|
|
|
1809
1897
|
// src/extensions/bookmarks.ts
|
|
1810
1898
|
import { Prec as Prec3, StateEffect as StateEffect4, StateField as StateField2 } from "@codemirror/state";
|
|
1811
1899
|
import { keymap as keymap4 } from "@codemirror/view";
|
|
1812
|
-
import { log as
|
|
1813
|
-
var
|
|
1900
|
+
import { log as log6 } from "@dxos/log";
|
|
1901
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/bookmarks.ts";
|
|
1814
1902
|
var addBookmark = StateEffect4.define();
|
|
1815
1903
|
var removeBookmark = StateEffect4.define();
|
|
1816
1904
|
var clearBookmarks = StateEffect4.define();
|
|
@@ -1822,8 +1910,8 @@ var bookmarks = () => {
|
|
|
1822
1910
|
key: "Mod-ArrowUp",
|
|
1823
1911
|
run: (view) => {
|
|
1824
1912
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1825
|
-
|
|
1826
|
-
F:
|
|
1913
|
+
log6("up", bookmarks2, {
|
|
1914
|
+
F: __dxlog_file8,
|
|
1827
1915
|
L: 29,
|
|
1828
1916
|
S: void 0,
|
|
1829
1917
|
C: (f, a) => f(...a)
|
|
@@ -1835,8 +1923,8 @@ var bookmarks = () => {
|
|
|
1835
1923
|
key: "Mod-ArrowDown",
|
|
1836
1924
|
run: (view) => {
|
|
1837
1925
|
const bookmarks2 = view.state.field(bookmarksField);
|
|
1838
|
-
|
|
1839
|
-
F:
|
|
1926
|
+
log6("down", bookmarks2, {
|
|
1927
|
+
F: __dxlog_file8,
|
|
1840
1928
|
L: 37,
|
|
1841
1929
|
S: void 0,
|
|
1842
1930
|
C: (f, a) => f(...a)
|
|
@@ -1880,19 +1968,19 @@ import { invertedEffects } from "@codemirror/commands";
|
|
|
1880
1968
|
import { StateEffect as StateEffect5, StateField as StateField3 } from "@codemirror/state";
|
|
1881
1969
|
import { Decoration as Decoration7, EditorView as EditorView11, ViewPlugin as ViewPlugin10, hoverTooltip, keymap as keymap6 } from "@codemirror/view";
|
|
1882
1970
|
import sortBy from "lodash.sortby";
|
|
1883
|
-
import { debounce as
|
|
1884
|
-
import { log as
|
|
1971
|
+
import { debounce as debounce2 } from "@dxos/async";
|
|
1972
|
+
import { log as log7 } from "@dxos/log";
|
|
1885
1973
|
import { isNonNullable } from "@dxos/util";
|
|
1886
1974
|
|
|
1887
1975
|
// src/extensions/selection.ts
|
|
1888
1976
|
import { Transaction as Transaction3 } from "@codemirror/state";
|
|
1889
1977
|
import { EditorView as EditorView10, keymap as keymap5 } from "@codemirror/view";
|
|
1890
|
-
import { debounce
|
|
1978
|
+
import { debounce } from "@dxos/async";
|
|
1891
1979
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1892
1980
|
import { isTruthy } from "@dxos/util";
|
|
1893
|
-
var
|
|
1981
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/selection.ts";
|
|
1894
1982
|
var documentId = singleValueFacet();
|
|
1895
|
-
var stateRestoreAnnotation = "dxos.
|
|
1983
|
+
var stateRestoreAnnotation = "org.dxos.cm.state-restore";
|
|
1896
1984
|
var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
1897
1985
|
return {
|
|
1898
1986
|
selection,
|
|
@@ -1906,7 +1994,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
|
|
|
1906
1994
|
var createEditorStateStore = (keyPrefix) => ({
|
|
1907
1995
|
getState: (id) => {
|
|
1908
1996
|
invariant3(id, void 0, {
|
|
1909
|
-
F:
|
|
1997
|
+
F: __dxlog_file9,
|
|
1910
1998
|
L: 47,
|
|
1911
1999
|
S: void 0,
|
|
1912
2000
|
A: [
|
|
@@ -1919,7 +2007,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1919
2007
|
},
|
|
1920
2008
|
setState: (id, state) => {
|
|
1921
2009
|
invariant3(id, void 0, {
|
|
1922
|
-
F:
|
|
2010
|
+
F: __dxlog_file9,
|
|
1923
2011
|
L: 53,
|
|
1924
2012
|
S: void 0,
|
|
1925
2013
|
A: [
|
|
@@ -1931,7 +2019,7 @@ var createEditorStateStore = (keyPrefix) => ({
|
|
|
1931
2019
|
}
|
|
1932
2020
|
});
|
|
1933
2021
|
var selectionState = ({ getState, setState } = {}) => {
|
|
1934
|
-
const setStateDebounced =
|
|
2022
|
+
const setStateDebounced = debounce(setState, 1e3);
|
|
1935
2023
|
return [
|
|
1936
2024
|
// TODO(burdon): Track scrolling (currently only updates when cursor moves).
|
|
1937
2025
|
// EditorView.domEventHandlers({
|
|
@@ -1978,7 +2066,7 @@ var selectionState = ({ getState, setState } = {}) => {
|
|
|
1978
2066
|
};
|
|
1979
2067
|
|
|
1980
2068
|
// src/extensions/comments.ts
|
|
1981
|
-
var
|
|
2069
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/comments.ts";
|
|
1982
2070
|
var setComments = StateEffect5.define();
|
|
1983
2071
|
var setSelection = StateEffect5.define();
|
|
1984
2072
|
var setCommentState = StateEffect5.define();
|
|
@@ -2023,14 +2111,14 @@ var commentsState = StateField3.define({
|
|
|
2023
2111
|
var styles2 = EditorView11.theme({
|
|
2024
2112
|
".cm-comment, .cm-comment-current": {
|
|
2025
2113
|
padding: "3px 0",
|
|
2026
|
-
color: "var(--
|
|
2027
|
-
backgroundColor: "var(--
|
|
2114
|
+
color: "var(--color-cm-comment-text)",
|
|
2115
|
+
backgroundColor: "var(--color-cm-comment-surface)"
|
|
2028
2116
|
},
|
|
2029
2117
|
".cm-comment > span, .cm-comment-current > span": {
|
|
2030
2118
|
boxDecorationBreak: "clone",
|
|
2031
|
-
boxShadow: "0 0 1px 3px var(--
|
|
2032
|
-
backgroundColor: "var(--
|
|
2033
|
-
color: "var(--
|
|
2119
|
+
boxShadow: "0 0 1px 3px var(--color-cm-comment-surface)",
|
|
2120
|
+
backgroundColor: "var(--color-cm-comment-surface)",
|
|
2121
|
+
color: "var(--color-cm-comment-text)",
|
|
2034
2122
|
cursor: "pointer"
|
|
2035
2123
|
}
|
|
2036
2124
|
});
|
|
@@ -2048,9 +2136,9 @@ var commentsDecorations = EditorView11.decorations.compute([
|
|
|
2048
2136
|
const decorations2 = sortBy(comments2 ?? [], (range) => range.range.from)?.flatMap((comment) => {
|
|
2049
2137
|
const range = comment.range;
|
|
2050
2138
|
if (!range) {
|
|
2051
|
-
|
|
2052
|
-
F:
|
|
2053
|
-
L:
|
|
2139
|
+
log7.warn("Invalid range:", range, {
|
|
2140
|
+
F: __dxlog_file10,
|
|
2141
|
+
L: 139,
|
|
2054
2142
|
S: void 0,
|
|
2055
2143
|
C: (f, a) => f(...a)
|
|
2056
2144
|
});
|
|
@@ -2166,10 +2254,10 @@ var trackPastedComments = (onUpdate) => {
|
|
|
2166
2254
|
const { comments: comments2 } = update2.startState.field(commentsState);
|
|
2167
2255
|
const exists = comments2.some((c) => c.comment.id === comment.id && c.range.from < c.range.to);
|
|
2168
2256
|
if (!exists) {
|
|
2169
|
-
const
|
|
2257
|
+
const cursor = Cursor.getCursorFromRange(update2.state, comment);
|
|
2170
2258
|
onUpdate({
|
|
2171
2259
|
id: comment.id,
|
|
2172
|
-
cursor
|
|
2260
|
+
cursor
|
|
2173
2261
|
});
|
|
2174
2262
|
}
|
|
2175
2263
|
}
|
|
@@ -2198,13 +2286,13 @@ var createComment = (view) => {
|
|
|
2198
2286
|
}
|
|
2199
2287
|
});
|
|
2200
2288
|
}
|
|
2201
|
-
const
|
|
2289
|
+
const cursor = Cursor.getCursorFromRange(view.state, {
|
|
2202
2290
|
from,
|
|
2203
2291
|
to
|
|
2204
2292
|
});
|
|
2205
|
-
if (
|
|
2293
|
+
if (cursor) {
|
|
2206
2294
|
options.onCreate?.({
|
|
2207
|
-
cursor
|
|
2295
|
+
cursor,
|
|
2208
2296
|
from,
|
|
2209
2297
|
location: view.coordsAtPos(from)
|
|
2210
2298
|
});
|
|
@@ -2215,7 +2303,7 @@ var createComment = (view) => {
|
|
|
2215
2303
|
var optionsFacet = singleValueFacet();
|
|
2216
2304
|
var comments = (options = {}) => {
|
|
2217
2305
|
const { key: shortcut = "meta-'" } = options;
|
|
2218
|
-
const handleSelect =
|
|
2306
|
+
const handleSelect = debounce2((state) => options.onSelect?.(state), 200);
|
|
2219
2307
|
return [
|
|
2220
2308
|
optionsFacet.of(options),
|
|
2221
2309
|
options.id ? documentId.of(options.id) : void 0,
|
|
@@ -2393,9 +2481,9 @@ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin10.fro
|
|
|
2393
2481
|
// src/extensions/debug.ts
|
|
2394
2482
|
import { syntaxTree } from "@codemirror/language";
|
|
2395
2483
|
import { StateField as StateField4 } from "@codemirror/state";
|
|
2396
|
-
var debugNodeLogger = (
|
|
2484
|
+
var debugNodeLogger = (log12 = console.log) => {
|
|
2397
2485
|
const logTokens = (state) => syntaxTree(state).iterate({
|
|
2398
|
-
enter: (node) =>
|
|
2486
|
+
enter: (node) => log12(node.type)
|
|
2399
2487
|
});
|
|
2400
2488
|
return StateField4.define({
|
|
2401
2489
|
create: (state) => logTokens(state),
|
|
@@ -2430,8 +2518,8 @@ var dropFile = (options = {}) => {
|
|
|
2430
2518
|
};
|
|
2431
2519
|
var styles3 = EditorView12.theme({
|
|
2432
2520
|
".cm-dropCursor": {
|
|
2433
|
-
borderLeft: "2px solid var(--
|
|
2434
|
-
color: "var(--
|
|
2521
|
+
borderLeft: "2px solid var(--color-accent-text)",
|
|
2522
|
+
color: "var(--color-accent-text)",
|
|
2435
2523
|
padding: "0 4px"
|
|
2436
2524
|
},
|
|
2437
2525
|
".cm-dropCursor:after": {
|
|
@@ -2445,47 +2533,66 @@ import { defaultKeymap, history, historyKeymap, indentWithTab, standardKeymap }
|
|
|
2445
2533
|
import { HighlightStyle, bracketMatching, syntaxHighlighting } from "@codemirror/language";
|
|
2446
2534
|
import { searchKeymap } from "@codemirror/search";
|
|
2447
2535
|
import { EditorState } from "@codemirror/state";
|
|
2448
|
-
import { EditorView as
|
|
2536
|
+
import { EditorView as EditorView16, ViewPlugin as ViewPlugin12, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap7, lineNumbers, placeholder as placeholder2 } from "@codemirror/view";
|
|
2449
2537
|
import { vscodeDarkStyle, vscodeLightStyle } from "@uiw/codemirror-theme-vscode";
|
|
2450
2538
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2451
2539
|
import { generateName } from "@dxos/display-name";
|
|
2452
|
-
import { log as
|
|
2540
|
+
import { log as log8 } from "@dxos/log";
|
|
2453
2541
|
import { hexToHue, isTruthy as isTruthy2 } from "@dxos/util";
|
|
2454
2542
|
|
|
2455
|
-
// src/styles/
|
|
2543
|
+
// src/styles/theme.ts
|
|
2544
|
+
import { EditorView as EditorView13 } from "@codemirror/view";
|
|
2456
2545
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2457
2546
|
var headings = {
|
|
2458
|
-
1:
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2547
|
+
1: {
|
|
2548
|
+
className: "text-3xl",
|
|
2549
|
+
fontSize: "var(--text-3xl)",
|
|
2550
|
+
lineHeight: "var(--text-4xl--line-height)"
|
|
2551
|
+
},
|
|
2552
|
+
2: {
|
|
2553
|
+
className: "text-2xl",
|
|
2554
|
+
fontSize: "var(--text-2xl)",
|
|
2555
|
+
lineHeight: "var(--text-3xl--line-height)"
|
|
2556
|
+
},
|
|
2557
|
+
3: {
|
|
2558
|
+
className: "text-xl",
|
|
2559
|
+
fontSize: "var(--text-xl)",
|
|
2560
|
+
lineHeight: "var(--text-2xl--line-height)"
|
|
2561
|
+
},
|
|
2562
|
+
4: {
|
|
2563
|
+
className: "text-lg",
|
|
2564
|
+
fontSize: "var(--text-lg)",
|
|
2565
|
+
lineHeight: "var(--text-xl--line-height)"
|
|
2566
|
+
},
|
|
2567
|
+
5: {
|
|
2568
|
+
className: "text-base",
|
|
2569
|
+
fontSize: "var(--text-base)",
|
|
2570
|
+
lineHeight: "var(--text-lg--line-height)"
|
|
2571
|
+
},
|
|
2572
|
+
6: {
|
|
2573
|
+
className: "text-base",
|
|
2574
|
+
fontSize: "var(--text-base)",
|
|
2575
|
+
lineHeight: "var(--text-base--line-height)"
|
|
2576
|
+
}
|
|
2464
2577
|
};
|
|
2578
|
+
var fontBody = '"Inter Variable", ui-sans-serif, system-ui, sans-serif';
|
|
2579
|
+
var fontMono = '"JetBrains Mono Variable", ui-monospace, "Cascadia Code", "Source Code Pro", monospace';
|
|
2465
2580
|
var markdownTheme = {
|
|
2466
|
-
code: "font-mono
|
|
2467
|
-
codeMark: "font-mono
|
|
2468
|
-
mark: "
|
|
2469
|
-
heading: (level) => {
|
|
2470
|
-
|
|
2471
|
-
|
|
2581
|
+
code: "font-mono! cm-code-inline",
|
|
2582
|
+
codeMark: "font-mono! cm-code-mark",
|
|
2583
|
+
mark: "font-mono!",
|
|
2584
|
+
heading: (level) => ({
|
|
2585
|
+
className: mx3(headings[level].className, "font-light text-(--color-cm-heading-number)"),
|
|
2586
|
+
color: "var(--color-cm-heading) !important",
|
|
2587
|
+
lineHeight: headings[level].lineHeight,
|
|
2588
|
+
fontSize: headings[level].fontSize,
|
|
2589
|
+
fontWeight: "100 !important"
|
|
2590
|
+
})
|
|
2472
2591
|
};
|
|
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
2592
|
var baseTheme = EditorView13.baseTheme({
|
|
2593
|
+
/**
|
|
2594
|
+
* Outer frame.
|
|
2595
|
+
*/
|
|
2489
2596
|
"&": {},
|
|
2490
2597
|
"&.cm-focused": {
|
|
2491
2598
|
outline: "none"
|
|
@@ -2494,7 +2601,18 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2494
2601
|
* Scroller
|
|
2495
2602
|
*/
|
|
2496
2603
|
".cm-scroller": {
|
|
2497
|
-
|
|
2604
|
+
overflowAnchor: "none"
|
|
2605
|
+
},
|
|
2606
|
+
".cm-scroller::-webkit-scrollbar": {
|
|
2607
|
+
width: "8px"
|
|
2608
|
+
},
|
|
2609
|
+
".cm-scroller::-webkit-scrollbar-track": {},
|
|
2610
|
+
".cm-scroller::-webkit-scrollbar-thumb": {
|
|
2611
|
+
background: "transparent",
|
|
2612
|
+
transition: "background 0.15s"
|
|
2613
|
+
},
|
|
2614
|
+
"&:hover .cm-scroller::-webkit-scrollbar-thumb": {
|
|
2615
|
+
background: "var(--color-scrollbar-thumb)"
|
|
2498
2616
|
},
|
|
2499
2617
|
/**
|
|
2500
2618
|
* Content
|
|
@@ -2502,7 +2620,6 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2502
2620
|
*/
|
|
2503
2621
|
".cm-content": {
|
|
2504
2622
|
padding: "unset",
|
|
2505
|
-
lineHeight: "24px",
|
|
2506
2623
|
color: "unset"
|
|
2507
2624
|
},
|
|
2508
2625
|
/**
|
|
@@ -2516,8 +2633,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2516
2633
|
".cm-gutter": {},
|
|
2517
2634
|
".cm-gutter.cm-lineNumbers": {
|
|
2518
2635
|
paddingRight: "4px",
|
|
2519
|
-
borderRight: "1px solid var(--
|
|
2520
|
-
color: "var(--
|
|
2636
|
+
borderRight: "1px solid var(--color-subdued-separator)",
|
|
2637
|
+
color: "var(--color-subdued)"
|
|
2521
2638
|
},
|
|
2522
2639
|
".cm-gutter.cm-lineNumbers .cm-gutterElement": {
|
|
2523
2640
|
minWidth: "40px"
|
|
@@ -2526,36 +2643,43 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2526
2643
|
* Height is set to match the corresponding line (which may have wrapped).
|
|
2527
2644
|
*/
|
|
2528
2645
|
".cm-gutterElement": {
|
|
2529
|
-
lineHeight:
|
|
2646
|
+
lineHeight: 1.5,
|
|
2530
2647
|
fontSize: "12px"
|
|
2531
2648
|
},
|
|
2532
2649
|
/**
|
|
2533
2650
|
* Line.
|
|
2534
2651
|
*/
|
|
2535
2652
|
".cm-line": {
|
|
2536
|
-
lineHeight:
|
|
2653
|
+
lineHeight: 1.5,
|
|
2537
2654
|
paddingInline: 0
|
|
2538
2655
|
},
|
|
2656
|
+
/**
|
|
2657
|
+
* Force all inline children to inherit line-height to prevent monospace font metrics
|
|
2658
|
+
* (JetBrains Mono ascent/descent) from inflating the line box beyond 24px.
|
|
2659
|
+
*/
|
|
2660
|
+
".cm-line *": {
|
|
2661
|
+
lineHeight: "inherit"
|
|
2662
|
+
},
|
|
2539
2663
|
".cm-activeLine": {
|
|
2540
|
-
background: "var(--
|
|
2664
|
+
background: "var(--color-cm-active-line)"
|
|
2541
2665
|
},
|
|
2542
2666
|
/**
|
|
2543
2667
|
* Cursor (layer).
|
|
2544
2668
|
*/
|
|
2545
2669
|
".cm-cursor, .cm-dropCursor": {
|
|
2546
|
-
borderLeft: "2px solid var(--
|
|
2670
|
+
borderLeft: "2px solid var(--color-cm-cursor)"
|
|
2547
2671
|
},
|
|
2548
2672
|
".cm-placeholder": {
|
|
2549
|
-
color: "var(--
|
|
2673
|
+
color: "var(--color-placeholder)"
|
|
2550
2674
|
},
|
|
2551
2675
|
/**
|
|
2552
2676
|
* Selection (layer).
|
|
2553
2677
|
*/
|
|
2554
2678
|
".cm-selectionBackground": {
|
|
2555
|
-
background: "var(--
|
|
2679
|
+
background: "var(--color-cm-selection)"
|
|
2556
2680
|
},
|
|
2557
2681
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
|
|
2558
|
-
background: "var(--
|
|
2682
|
+
background: "var(--color-cm-focused-selection)"
|
|
2559
2683
|
},
|
|
2560
2684
|
/**
|
|
2561
2685
|
* Search.
|
|
@@ -2565,8 +2689,8 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2565
2689
|
margin: "0 -3px",
|
|
2566
2690
|
padding: "3px",
|
|
2567
2691
|
borderRadius: "3px",
|
|
2568
|
-
background: "var(--
|
|
2569
|
-
color: "var(--
|
|
2692
|
+
background: "var(--color-cm-highlight-surface)",
|
|
2693
|
+
color: "var(--color-cm-highlight)"
|
|
2570
2694
|
},
|
|
2571
2695
|
".cm-searchMatch-selected": {
|
|
2572
2696
|
textDecoration: "underline"
|
|
@@ -2577,20 +2701,29 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2577
2701
|
".cm-link": {
|
|
2578
2702
|
textDecorationLine: "underline",
|
|
2579
2703
|
textDecorationThickness: "1px",
|
|
2580
|
-
textDecorationColor: "var(--
|
|
2704
|
+
textDecorationColor: "var(--color-separator)",
|
|
2581
2705
|
textUnderlineOffset: "2px",
|
|
2582
2706
|
borderRadius: ".125rem"
|
|
2583
2707
|
},
|
|
2584
2708
|
".cm-link > span": {
|
|
2585
|
-
color: "var(--
|
|
2709
|
+
color: "var(--color-accent-text)"
|
|
2710
|
+
},
|
|
2711
|
+
".cm-link > span:hover": {
|
|
2712
|
+
color: "var(--color-accent-text-hover)"
|
|
2586
2713
|
},
|
|
2587
2714
|
/**
|
|
2588
2715
|
* Tooltip.
|
|
2589
2716
|
*/
|
|
2590
2717
|
".cm-tooltip": {
|
|
2591
|
-
background: "var(--
|
|
2718
|
+
background: "var(--color-modal-surface)"
|
|
2592
2719
|
},
|
|
2593
2720
|
".cm-tooltip-below": {},
|
|
2721
|
+
".cm-tooltip-hover": {
|
|
2722
|
+
background: "var(--color-modal-surface)",
|
|
2723
|
+
border: "1px solid var(--color-separator)",
|
|
2724
|
+
borderRadius: "4px",
|
|
2725
|
+
overflow: "hidden"
|
|
2726
|
+
},
|
|
2594
2727
|
/**
|
|
2595
2728
|
* Autocomplete.
|
|
2596
2729
|
* https://github.com/codemirror/autocomplete/blob/main/src/completion.ts
|
|
@@ -2598,7 +2731,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2598
2731
|
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
2599
2732
|
marginTop: "6px",
|
|
2600
2733
|
marginLeft: "-10px",
|
|
2601
|
-
border: "2px solid var(--
|
|
2734
|
+
border: "2px solid var(--color-separator)",
|
|
2602
2735
|
borderRadius: "4px"
|
|
2603
2736
|
},
|
|
2604
2737
|
".cm-tooltip.cm-tooltip-autocomplete > ul": {
|
|
@@ -2608,12 +2741,12 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2608
2741
|
padding: "4px"
|
|
2609
2742
|
},
|
|
2610
2743
|
".cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
2611
|
-
background: "var(--
|
|
2612
|
-
color: "var(--
|
|
2744
|
+
background: "var(--color-active-surface)",
|
|
2745
|
+
color: "var(--color-base-surface-text)"
|
|
2613
2746
|
},
|
|
2614
2747
|
".cm-tooltip.cm-tooltip-autocomplete > ul > completion-section": {
|
|
2615
2748
|
paddingLeft: "4px !important",
|
|
2616
|
-
color: "var(--
|
|
2749
|
+
color: "var(--color-base-surface-text)"
|
|
2617
2750
|
},
|
|
2618
2751
|
/**
|
|
2619
2752
|
* Completion info.
|
|
@@ -2622,17 +2755,17 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2622
2755
|
width: "360px !important",
|
|
2623
2756
|
margin: "-10px 1px 0 1px",
|
|
2624
2757
|
padding: "8px !important",
|
|
2625
|
-
borderColor: "var(--
|
|
2758
|
+
borderColor: "var(--color-separator)"
|
|
2626
2759
|
},
|
|
2627
2760
|
".cm-completionIcon": {
|
|
2628
2761
|
display: "none"
|
|
2629
2762
|
},
|
|
2630
2763
|
".cm-completionLabel": {
|
|
2631
|
-
color: "var(--
|
|
2764
|
+
color: "var(--color-description)",
|
|
2632
2765
|
padding: "0 4px"
|
|
2633
2766
|
},
|
|
2634
2767
|
".cm-completionMatchedText": {
|
|
2635
|
-
color: "var(--
|
|
2768
|
+
color: "var(--color-base-surface-text)",
|
|
2636
2769
|
textDecoration: "none !important"
|
|
2637
2770
|
},
|
|
2638
2771
|
/**
|
|
@@ -2656,7 +2789,7 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2656
2789
|
backgroundColor: "var(--surface-bg)"
|
|
2657
2790
|
},
|
|
2658
2791
|
".cm-panel input, .cm-panel button, .cm-panel label": {
|
|
2659
|
-
color: "var(--
|
|
2792
|
+
color: "var(--color-subdued)",
|
|
2660
2793
|
fontSize: "14px",
|
|
2661
2794
|
all: "unset",
|
|
2662
2795
|
margin: "3px !important",
|
|
@@ -2664,10 +2797,10 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2664
2797
|
outline: "1px solid transparent"
|
|
2665
2798
|
},
|
|
2666
2799
|
".cm-panel input, .cm-panel button": {
|
|
2667
|
-
backgroundColor: "var(--
|
|
2800
|
+
backgroundColor: "var(--color-input-surface)"
|
|
2668
2801
|
},
|
|
2669
2802
|
".cm-panel input:focus, .cm-panel button:focus": {
|
|
2670
|
-
outline: "1px solid var(--
|
|
2803
|
+
outline: "1px solid var(--color-neutral-focus-indicator)"
|
|
2671
2804
|
},
|
|
2672
2805
|
".cm-panel label": {
|
|
2673
2806
|
display: "inline-flex",
|
|
@@ -2680,33 +2813,33 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2680
2813
|
height: "8px",
|
|
2681
2814
|
marginRight: "6px !important",
|
|
2682
2815
|
padding: "2px !important",
|
|
2683
|
-
color: "var(--
|
|
2816
|
+
color: "var(--color-neutral-focus-indicator)"
|
|
2684
2817
|
},
|
|
2685
2818
|
".cm-panel button": {
|
|
2686
2819
|
"&:hover": {
|
|
2687
|
-
|
|
2820
|
+
// TODO(burdon): Replace with layer and @apply bg-accent-surface-hover
|
|
2821
|
+
backgroundColor: "var(--color-accent-surface-hover) !important"
|
|
2688
2822
|
},
|
|
2689
2823
|
"&:active": {
|
|
2690
|
-
backgroundColor: "var(--
|
|
2824
|
+
backgroundColor: "var(--color-accent-surface-hover)"
|
|
2691
2825
|
}
|
|
2692
2826
|
},
|
|
2693
2827
|
".cm-panel.cm-search": {
|
|
2694
2828
|
padding: "4px",
|
|
2695
|
-
borderTop: "1px solid var(--
|
|
2829
|
+
borderTop: "1px solid var(--color-separator)"
|
|
2696
2830
|
}
|
|
2697
2831
|
});
|
|
2698
2832
|
var editorGutter = EditorView13.theme({
|
|
2699
2833
|
".cm-gutters": {
|
|
2700
2834
|
// NOTE: Non-transparent background required to cover content if scrolling horizontally.
|
|
2701
|
-
background: "var(--
|
|
2835
|
+
background: "var(--color-base-surface) !important",
|
|
2702
2836
|
paddingRight: "1rem"
|
|
2703
2837
|
}
|
|
2704
2838
|
});
|
|
2705
2839
|
var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
2706
|
-
//
|
|
2840
|
+
// Main content.
|
|
2707
2841
|
".cm-scroller": {
|
|
2708
|
-
fontFamily: monospace ? fontMono : fontBody
|
|
2709
|
-
fontSize: "16px"
|
|
2842
|
+
fontFamily: monospace ? fontMono : fontBody
|
|
2710
2843
|
},
|
|
2711
2844
|
// Maintain defaults for UI components.
|
|
2712
2845
|
".cm-content, .cm-gutters, .cm-panel": {
|
|
@@ -2746,9 +2879,32 @@ var focus = [
|
|
|
2746
2879
|
})
|
|
2747
2880
|
];
|
|
2748
2881
|
|
|
2882
|
+
// src/extensions/scroll-past-end.ts
|
|
2883
|
+
import { EditorView as EditorView15, ViewPlugin as ViewPlugin11 } from "@codemirror/view";
|
|
2884
|
+
var scrollPastEndPlugin = ViewPlugin11.fromClass(class {
|
|
2885
|
+
height = 1e3;
|
|
2886
|
+
attrs = {
|
|
2887
|
+
style: "padding-bottom: 1000px"
|
|
2888
|
+
};
|
|
2889
|
+
update({ view }) {
|
|
2890
|
+
const lastLineBlock = view.lineBlockAt(view.state.doc.length);
|
|
2891
|
+
const height = view.dom.clientHeight - lastLineBlock.height - view.documentPadding.top - 0.5;
|
|
2892
|
+
if (height >= 0 && height !== this.height) {
|
|
2893
|
+
this.height = height;
|
|
2894
|
+
this.attrs = {
|
|
2895
|
+
style: `padding-bottom: ${height}px`
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
var scrollPastEnd = () => [
|
|
2901
|
+
scrollPastEndPlugin,
|
|
2902
|
+
EditorView15.contentAttributes.of((view) => view.plugin(scrollPastEndPlugin)?.attrs ?? null)
|
|
2903
|
+
];
|
|
2904
|
+
|
|
2749
2905
|
// src/extensions/factories.ts
|
|
2750
|
-
var
|
|
2751
|
-
var tabbable =
|
|
2906
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/factories.ts";
|
|
2907
|
+
var tabbable = EditorView16.contentAttributes.of({
|
|
2752
2908
|
tabindex: "0"
|
|
2753
2909
|
});
|
|
2754
2910
|
var filterChars = (chars) => {
|
|
@@ -2801,10 +2957,10 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2801
2957
|
const props = defaultsDeep2({}, propsProp, defaultBasicOptions);
|
|
2802
2958
|
return [
|
|
2803
2959
|
// NOTE: Doesn't catch errors in keymap functions.
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
F:
|
|
2807
|
-
L:
|
|
2960
|
+
EditorView16.exceptionSink.of((err) => {
|
|
2961
|
+
log8.catch(err, void 0, {
|
|
2962
|
+
F: __dxlog_file11,
|
|
2963
|
+
L: 130,
|
|
2808
2964
|
S: void 0,
|
|
2809
2965
|
C: (f, a) => f(...a)
|
|
2810
2966
|
});
|
|
@@ -2816,7 +2972,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2816
2972
|
props.drawSelection && drawSelection({
|
|
2817
2973
|
cursorBlinkRate: 1200
|
|
2818
2974
|
}),
|
|
2819
|
-
props.editable !== void 0 &&
|
|
2975
|
+
props.editable !== void 0 && EditorView16.editable.of(props.editable),
|
|
2820
2976
|
props.focus && focus,
|
|
2821
2977
|
props.highlightActiveLine && highlightActiveLine(),
|
|
2822
2978
|
props.history && history(),
|
|
@@ -2824,7 +2980,7 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2824
2980
|
lineNumbers(),
|
|
2825
2981
|
editorGutter
|
|
2826
2982
|
],
|
|
2827
|
-
props.lineWrapping &&
|
|
2983
|
+
props.lineWrapping && EditorView16.lineWrapping,
|
|
2828
2984
|
props.placeholder && placeholder2(props.placeholder),
|
|
2829
2985
|
props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
|
|
2830
2986
|
props.scrollPastEnd && scrollPastEnd(),
|
|
@@ -2856,12 +3012,12 @@ var createBasicExtensions = (propsProp) => {
|
|
|
2856
3012
|
};
|
|
2857
3013
|
var grow = {
|
|
2858
3014
|
editor: {
|
|
2859
|
-
className: "
|
|
3015
|
+
className: "h-full w-full"
|
|
2860
3016
|
}
|
|
2861
3017
|
};
|
|
2862
3018
|
var fullWidth = {
|
|
2863
3019
|
editor: {
|
|
2864
|
-
className: "
|
|
3020
|
+
className: "w-full"
|
|
2865
3021
|
}
|
|
2866
3022
|
};
|
|
2867
3023
|
var defaultThemeSlots = grow;
|
|
@@ -2873,18 +3029,18 @@ var createThemeExtensions = ({ monospace, themeMode, slots: slotsProp, syntaxHig
|
|
|
2873
3029
|
const slots = defaultsDeep2({}, slotsProp, defaultThemeSlots);
|
|
2874
3030
|
return [
|
|
2875
3031
|
baseTheme,
|
|
2876
|
-
|
|
3032
|
+
EditorView16.darkTheme.of(themeMode === "dark"),
|
|
2877
3033
|
createFontTheme({
|
|
2878
3034
|
monospace
|
|
2879
3035
|
}),
|
|
2880
3036
|
syntaxHighlightingProp && syntaxHighlighting(HighlightStyle.define(themeMode === "dark" ? defaultStyles.dark : defaultStyles.light)),
|
|
2881
|
-
slots.editor?.className &&
|
|
3037
|
+
slots.editor?.className && EditorView16.editorAttributes.of({
|
|
2882
3038
|
class: slots.editor.className
|
|
2883
3039
|
}),
|
|
2884
|
-
slots.content?.className &&
|
|
3040
|
+
slots.content?.className && EditorView16.contentAttributes.of({
|
|
2885
3041
|
class: slots.content.className
|
|
2886
3042
|
}),
|
|
2887
|
-
slots.scroll?.className &&
|
|
3043
|
+
slots.scroll?.className && ViewPlugin12.fromClass(class {
|
|
2888
3044
|
constructor(view) {
|
|
2889
3045
|
view.scrollDOM.classList.add(...slots.scroll.className.split(/\s+/));
|
|
2890
3046
|
}
|
|
@@ -2904,8 +3060,8 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2904
3060
|
channel: `awareness.${id}`,
|
|
2905
3061
|
peerId: identity.identityKey.toHex(),
|
|
2906
3062
|
info: {
|
|
2907
|
-
darkColor: `var(--
|
|
2908
|
-
lightColor: `var(--
|
|
3063
|
+
darkColor: `var(--color-${hue}-border)`,
|
|
3064
|
+
lightColor: `var(--color-${hue}-border)`,
|
|
2909
3065
|
displayName: identity.profile?.displayName ?? generateName(identity.identityKey.toHex())
|
|
2910
3066
|
}
|
|
2911
3067
|
})));
|
|
@@ -2915,7 +3071,7 @@ var createDataExtensions = ({ id, text, messenger, identity }) => {
|
|
|
2915
3071
|
|
|
2916
3072
|
// src/extensions/folding.ts
|
|
2917
3073
|
import { codeFolding, foldGutter } from "@codemirror/language";
|
|
2918
|
-
import { EditorView as
|
|
3074
|
+
import { EditorView as EditorView17 } from "@codemirror/view";
|
|
2919
3075
|
import { Domino as Domino2, mx as mx4 } from "@dxos/ui";
|
|
2920
3076
|
var folding = () => {
|
|
2921
3077
|
return [
|
|
@@ -2923,13 +3079,14 @@ var folding = () => {
|
|
|
2923
3079
|
placeholderDOM: () => Domino2.of("span").root
|
|
2924
3080
|
}),
|
|
2925
3081
|
foldGutter({
|
|
3082
|
+
// NOTE: We can't animate since the element is remounted on state change.
|
|
2926
3083
|
markerDOM: (open) => {
|
|
2927
|
-
return Domino2.of("div").classNames("flex
|
|
3084
|
+
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
3085
|
href: Domino2.icon("ph--caret-right--regular")
|
|
2929
3086
|
}))).root;
|
|
2930
3087
|
}
|
|
2931
3088
|
}),
|
|
2932
|
-
|
|
3089
|
+
EditorView17.theme({
|
|
2933
3090
|
".cm-foldGutter": {
|
|
2934
3091
|
opacity: 0.3,
|
|
2935
3092
|
transition: "opacity 0.3s",
|
|
@@ -2943,7 +3100,7 @@ var folding = () => {
|
|
|
2943
3100
|
};
|
|
2944
3101
|
|
|
2945
3102
|
// src/extensions/hashtag.ts
|
|
2946
|
-
import { Decoration as Decoration8, EditorView as
|
|
3103
|
+
import { Decoration as Decoration8, EditorView as EditorView18, MatchDecorator, ViewPlugin as ViewPlugin13, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
2947
3104
|
import { getHashStyles, mx as mx5 } from "@dxos/ui-theme";
|
|
2948
3105
|
var TagWidget = class extends WidgetType4 {
|
|
2949
3106
|
_text;
|
|
@@ -2964,7 +3121,7 @@ var tagMatcher = new MatchDecorator({
|
|
|
2964
3121
|
})
|
|
2965
3122
|
});
|
|
2966
3123
|
var hashtag = () => [
|
|
2967
|
-
|
|
3124
|
+
ViewPlugin13.fromClass(class {
|
|
2968
3125
|
tags;
|
|
2969
3126
|
constructor(view) {
|
|
2970
3127
|
this.tags = tagMatcher.createDeco(view);
|
|
@@ -2974,11 +3131,11 @@ var hashtag = () => [
|
|
|
2974
3131
|
}
|
|
2975
3132
|
}, {
|
|
2976
3133
|
decorations: (instance) => instance.tags,
|
|
2977
|
-
provide: (plugin) =>
|
|
3134
|
+
provide: (plugin) => EditorView18.atomicRanges.of((view) => {
|
|
2978
3135
|
return view.plugin(plugin)?.tags || Decoration8.none;
|
|
2979
3136
|
})
|
|
2980
3137
|
}),
|
|
2981
|
-
|
|
3138
|
+
EditorView18.theme({
|
|
2982
3139
|
".cm-tag": {
|
|
2983
3140
|
borderRadius: "4px",
|
|
2984
3141
|
marginRight: "6px",
|
|
@@ -3033,18 +3190,18 @@ var schemaLinter = (validate) => (view) => {
|
|
|
3033
3190
|
};
|
|
3034
3191
|
|
|
3035
3192
|
// src/extensions/listener.ts
|
|
3036
|
-
import { EditorView as
|
|
3193
|
+
import { EditorView as EditorView19 } from "@codemirror/view";
|
|
3037
3194
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
3038
3195
|
var listener = ({ onFocus, onChange }) => {
|
|
3039
3196
|
return [
|
|
3040
|
-
onFocus &&
|
|
3197
|
+
onFocus && EditorView19.focusChangeEffect.of((state, focusing) => {
|
|
3041
3198
|
onFocus({
|
|
3042
3199
|
id: state.facet(documentId),
|
|
3043
3200
|
focusing
|
|
3044
3201
|
});
|
|
3045
3202
|
return null;
|
|
3046
3203
|
}),
|
|
3047
|
-
onChange &&
|
|
3204
|
+
onChange && EditorView19.updateListener.of(({ state, docChanged }) => {
|
|
3048
3205
|
if (docChanged) {
|
|
3049
3206
|
onChange({
|
|
3050
3207
|
id: state.facet(documentId),
|
|
@@ -3059,7 +3216,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
|
3059
3216
|
import { snippet } from "@codemirror/autocomplete";
|
|
3060
3217
|
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
3061
3218
|
import { EditorSelection as EditorSelection2 } from "@codemirror/state";
|
|
3062
|
-
import { EditorView as
|
|
3219
|
+
import { EditorView as EditorView20, keymap as keymap8 } from "@codemirror/view";
|
|
3063
3220
|
import { debounceAndThrottle } from "@dxos/async";
|
|
3064
3221
|
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
3222
|
var Inline = /* @__PURE__ */ (function(Inline2) {
|
|
@@ -4148,7 +4305,7 @@ var getFormatting = (state) => {
|
|
|
4148
4305
|
};
|
|
4149
4306
|
};
|
|
4150
4307
|
var formattingListener = (onStateChange, delay = 100) => {
|
|
4151
|
-
return
|
|
4308
|
+
return EditorView20.updateListener.of(debounceAndThrottle((update2) => {
|
|
4152
4309
|
if (update2.docChanged || update2.selectionSet) {
|
|
4153
4310
|
onStateChange(getFormatting(update2.state));
|
|
4154
4311
|
}
|
|
@@ -4209,8 +4366,7 @@ import { completionKeymap } from "@codemirror/autocomplete";
|
|
|
4209
4366
|
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
|
4210
4367
|
import { jsonLanguage } from "@codemirror/lang-json";
|
|
4211
4368
|
import { markdown, markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
|
|
4212
|
-
import {
|
|
4213
|
-
import { LanguageDescription, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4369
|
+
import { foldNodeProp, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4214
4370
|
import { languages } from "@codemirror/language-data";
|
|
4215
4371
|
import { keymap as keymap9 } from "@codemirror/view";
|
|
4216
4372
|
import { isTruthy as isTruthy3 } from "@dxos/util";
|
|
@@ -4331,30 +4487,38 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4331
4487
|
],
|
|
4332
4488
|
class: "font-mono"
|
|
4333
4489
|
},
|
|
4334
|
-
// Headings
|
|
4490
|
+
// Headings — use CSS properties only (no class:) so CodeMirror generates scoped CSS via
|
|
4491
|
+
// StyleModule that overrides vscodeDarkStyle's t.heading rule. When class: is present,
|
|
4492
|
+
// HighlightStyle silently ignores all other CSS properties (they're mutually exclusive).
|
|
4493
|
+
// Font sizes use Tailwind v4 CSS variables so nothing is hardcoded.
|
|
4494
|
+
{
|
|
4495
|
+
tag: tags.heading,
|
|
4496
|
+
color: "var(--color-cm-heading) !important",
|
|
4497
|
+
fontWeight: "300"
|
|
4498
|
+
},
|
|
4335
4499
|
{
|
|
4336
4500
|
tag: tags.heading1,
|
|
4337
|
-
|
|
4501
|
+
...markdownTheme.heading(1)
|
|
4338
4502
|
},
|
|
4339
4503
|
{
|
|
4340
4504
|
tag: tags.heading2,
|
|
4341
|
-
|
|
4505
|
+
...markdownTheme.heading(2)
|
|
4342
4506
|
},
|
|
4343
4507
|
{
|
|
4344
4508
|
tag: tags.heading3,
|
|
4345
|
-
|
|
4509
|
+
...markdownTheme.heading(3)
|
|
4346
4510
|
},
|
|
4347
4511
|
{
|
|
4348
4512
|
tag: tags.heading4,
|
|
4349
|
-
|
|
4513
|
+
...markdownTheme.heading(4)
|
|
4350
4514
|
},
|
|
4351
4515
|
{
|
|
4352
4516
|
tag: tags.heading5,
|
|
4353
|
-
|
|
4517
|
+
...markdownTheme.heading(5)
|
|
4354
4518
|
},
|
|
4355
4519
|
{
|
|
4356
4520
|
tag: tags.heading6,
|
|
4357
|
-
|
|
4521
|
+
...markdownTheme.heading(6)
|
|
4358
4522
|
},
|
|
4359
4523
|
// Emphasis.
|
|
4360
4524
|
{
|
|
@@ -4409,15 +4573,23 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4409
4573
|
// https://github.com/lezer-parser/markdown?tab=readme-ov-file#github-flavored-markdown
|
|
4410
4574
|
base: markdownLanguage2,
|
|
4411
4575
|
// Languages for syntax highlighting fenced code blocks.
|
|
4576
|
+
// Caller-supplied languages are checked first so they can override defaults.
|
|
4412
4577
|
defaultCodeLanguage: jsonLanguage,
|
|
4413
|
-
codeLanguages:
|
|
4578
|
+
codeLanguages: [
|
|
4579
|
+
...options.codeLanguages ?? [],
|
|
4580
|
+
...languages
|
|
4581
|
+
],
|
|
4414
4582
|
// Don't complete HTML tags.
|
|
4415
4583
|
completeHTMLTags: false,
|
|
4416
4584
|
// Parser extensions.
|
|
4417
4585
|
extensions: [
|
|
4418
4586
|
// GFM provided by default.
|
|
4419
4587
|
markdownTagsExtensions,
|
|
4420
|
-
...options.extensions ?? defaultExtensions()
|
|
4588
|
+
...options.extensions ?? defaultExtensions(),
|
|
4589
|
+
// Disable folding for fenced code blocks by overriding foldNodeProp.
|
|
4590
|
+
// Note: returning null from foldService does not prevent syntaxFolding fallback,
|
|
4591
|
+
// so we must override the node prop directly on the FencedCode node type.
|
|
4592
|
+
noFencedCodeFolding
|
|
4421
4593
|
]
|
|
4422
4594
|
}),
|
|
4423
4595
|
// Custom styles.
|
|
@@ -4432,18 +4604,13 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4432
4604
|
].filter(isTruthy3))
|
|
4433
4605
|
];
|
|
4434
4606
|
};
|
|
4435
|
-
var
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
]
|
|
4441
|
-
|
|
4442
|
-
"xml",
|
|
4443
|
-
"xhtml"
|
|
4444
|
-
],
|
|
4445
|
-
load: async () => xml()
|
|
4446
|
-
});
|
|
4607
|
+
var noFencedCodeFolding = {
|
|
4608
|
+
props: [
|
|
4609
|
+
foldNodeProp.add({
|
|
4610
|
+
FencedCode: () => null
|
|
4611
|
+
})
|
|
4612
|
+
]
|
|
4613
|
+
};
|
|
4447
4614
|
var defaultExtensions = () => [
|
|
4448
4615
|
noSetExtHeading,
|
|
4449
4616
|
noHtml
|
|
@@ -4463,19 +4630,19 @@ var debugTree = (cb) => StateField6.define({
|
|
|
4463
4630
|
update: (value, tr) => cb(convertTreeToJson(tr.state))
|
|
4464
4631
|
});
|
|
4465
4632
|
var convertTreeToJson = (state) => {
|
|
4466
|
-
const treeToJson = (
|
|
4633
|
+
const treeToJson = (cursor) => {
|
|
4467
4634
|
const node = {
|
|
4468
|
-
type:
|
|
4469
|
-
from:
|
|
4470
|
-
to:
|
|
4471
|
-
text: state.doc.slice(
|
|
4635
|
+
type: cursor.type.name,
|
|
4636
|
+
from: cursor.from,
|
|
4637
|
+
to: cursor.to,
|
|
4638
|
+
text: state.doc.slice(cursor.from, cursor.to).toString(),
|
|
4472
4639
|
children: []
|
|
4473
4640
|
};
|
|
4474
|
-
if (
|
|
4641
|
+
if (cursor.firstChild()) {
|
|
4475
4642
|
do {
|
|
4476
|
-
node.children.push(treeToJson(
|
|
4477
|
-
} while (
|
|
4478
|
-
|
|
4643
|
+
node.children.push(treeToJson(cursor));
|
|
4644
|
+
} while (cursor.nextSibling());
|
|
4645
|
+
cursor.parent();
|
|
4479
4646
|
}
|
|
4480
4647
|
return node;
|
|
4481
4648
|
};
|
|
@@ -4485,16 +4652,15 @@ var convertTreeToJson = (state) => {
|
|
|
4485
4652
|
// src/extensions/markdown/decorate.ts
|
|
4486
4653
|
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4487
4654
|
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect7 } from "@codemirror/state";
|
|
4488
|
-
import { Decoration as Decoration11, EditorView as
|
|
4655
|
+
import { Decoration as Decoration11, EditorView as EditorView24, ViewPlugin as ViewPlugin15, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4489
4656
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4490
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
4491
4657
|
|
|
4492
4658
|
// src/extensions/markdown/changes.ts
|
|
4493
4659
|
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
|
4494
4660
|
import { Transaction as Transaction4 } from "@codemirror/state";
|
|
4495
|
-
import { ViewPlugin as
|
|
4661
|
+
import { ViewPlugin as ViewPlugin14 } from "@codemirror/view";
|
|
4496
4662
|
var adjustChanges = () => {
|
|
4497
|
-
return
|
|
4663
|
+
return ViewPlugin14.fromClass(class {
|
|
4498
4664
|
update(update2) {
|
|
4499
4665
|
const tree = syntaxTree4(update2.state);
|
|
4500
4666
|
const adjustments = [];
|
|
@@ -4636,7 +4802,7 @@ var getValidUrl = (str) => {
|
|
|
4636
4802
|
// src/extensions/markdown/image.ts
|
|
4637
4803
|
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
|
4638
4804
|
import { StateField as StateField7 } from "@codemirror/state";
|
|
4639
|
-
import { Decoration as Decoration9, EditorView as
|
|
4805
|
+
import { Decoration as Decoration9, EditorView as EditorView21, WidgetType as WidgetType5 } from "@codemirror/view";
|
|
4640
4806
|
var image = (_options = {}) => {
|
|
4641
4807
|
return [
|
|
4642
4808
|
StateField7.define({
|
|
@@ -4647,10 +4813,10 @@ var image = (_options = {}) => {
|
|
|
4647
4813
|
if (!tr.docChanged && !tr.selection) {
|
|
4648
4814
|
return value;
|
|
4649
4815
|
}
|
|
4650
|
-
const
|
|
4816
|
+
const cursor = tr.state.selection.main.head;
|
|
4651
4817
|
const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);
|
|
4652
|
-
let from = Math.min(
|
|
4653
|
-
let to = Math.max(
|
|
4818
|
+
let from = Math.min(cursor, oldCursor);
|
|
4819
|
+
let to = Math.max(cursor, oldCursor);
|
|
4654
4820
|
tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {
|
|
4655
4821
|
from = Math.min(from, fromB);
|
|
4656
4822
|
to = Math.max(to, toB);
|
|
@@ -4664,19 +4830,19 @@ var image = (_options = {}) => {
|
|
|
4664
4830
|
add: buildDecorations(tr.state, from, to)
|
|
4665
4831
|
});
|
|
4666
4832
|
},
|
|
4667
|
-
provide: (field) =>
|
|
4833
|
+
provide: (field) => EditorView21.decorations.from(field)
|
|
4668
4834
|
})
|
|
4669
4835
|
];
|
|
4670
4836
|
};
|
|
4671
4837
|
var buildDecorations = (state, from, to) => {
|
|
4672
4838
|
const decorations2 = [];
|
|
4673
|
-
const
|
|
4839
|
+
const cursor = state.selection.main.head;
|
|
4674
4840
|
syntaxTree5(state).iterate({
|
|
4675
4841
|
enter: (node) => {
|
|
4676
4842
|
if (node.name === "Image") {
|
|
4677
4843
|
const urlNode = node.node.getChild("URL");
|
|
4678
4844
|
if (urlNode) {
|
|
4679
|
-
const hide2 = state.readOnly ||
|
|
4845
|
+
const hide2 = state.readOnly || cursor < node.from || cursor > node.to || !state.field(focusField);
|
|
4680
4846
|
const url = state.sliceDoc(urlNode.from, urlNode.to);
|
|
4681
4847
|
if (url.match(/^https?:\/\//) === null && url.match(/^file?:\/\//) === null) {
|
|
4682
4848
|
return;
|
|
@@ -4724,10 +4890,10 @@ var ImageWidget = class extends WidgetType5 {
|
|
|
4724
4890
|
};
|
|
4725
4891
|
|
|
4726
4892
|
// src/extensions/markdown/styles.ts
|
|
4727
|
-
import { EditorView as
|
|
4893
|
+
import { EditorView as EditorView22 } from "@codemirror/view";
|
|
4728
4894
|
var bulletListIndentationWidth = 24;
|
|
4729
4895
|
var orderedListIndentationWidth = 36;
|
|
4730
|
-
var formattingStyles =
|
|
4896
|
+
var formattingStyles = EditorView22.theme({
|
|
4731
4897
|
/**
|
|
4732
4898
|
* Horizontal rule.
|
|
4733
4899
|
*/
|
|
@@ -4736,7 +4902,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4736
4902
|
width: "100%",
|
|
4737
4903
|
height: "0",
|
|
4738
4904
|
verticalAlign: "middle",
|
|
4739
|
-
borderTop: "1px solid var(--
|
|
4905
|
+
borderTop: "1px solid var(--color-cm-separator)",
|
|
4740
4906
|
opacity: 0.5
|
|
4741
4907
|
},
|
|
4742
4908
|
/**
|
|
@@ -4759,19 +4925,44 @@ var formattingStyles = EditorView21.theme({
|
|
|
4759
4925
|
* Blockquote.
|
|
4760
4926
|
*/
|
|
4761
4927
|
"& .cm-blockquote": {
|
|
4762
|
-
background: "var(--
|
|
4763
|
-
borderLeft: "2px solid var(--
|
|
4928
|
+
background: "var(--color-cm-codeblock)",
|
|
4929
|
+
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4764
4930
|
paddingLeft: "1rem",
|
|
4765
|
-
margin:
|
|
4931
|
+
margin: 0
|
|
4766
4932
|
},
|
|
4767
4933
|
/**
|
|
4768
4934
|
* Code and codeblocks.
|
|
4769
4935
|
*/
|
|
4936
|
+
"& code": {
|
|
4937
|
+
fontFamily: fontMono,
|
|
4938
|
+
color: "var(--color-cm-code)",
|
|
4939
|
+
whiteSpace: "nowrap"
|
|
4940
|
+
},
|
|
4770
4941
|
"& .cm-code": {
|
|
4771
|
-
fontFamily: fontMono
|
|
4942
|
+
fontFamily: fontMono,
|
|
4943
|
+
color: "var(--color-cm-code)"
|
|
4944
|
+
},
|
|
4945
|
+
// Inline code spans (triggered by backticks) use `cm-code-inline` + `font-mono`.
|
|
4946
|
+
// Different monospace font metrics can slightly overflow the fixed CodeMirror line box,
|
|
4947
|
+
// so constrain them to the target 24px height.
|
|
4948
|
+
"& .cm-code-inline": {
|
|
4949
|
+
fontFamily: fontMono,
|
|
4950
|
+
height: "24px",
|
|
4951
|
+
// display: 'inline-flex',
|
|
4952
|
+
alignItems: "center",
|
|
4953
|
+
overflow: "hidden",
|
|
4954
|
+
whiteSpace: "nowrap",
|
|
4955
|
+
color: "var(--color-cm-code-inline)"
|
|
4956
|
+
},
|
|
4957
|
+
"& .cm-code-mark": {
|
|
4958
|
+
fontFamily: fontMono,
|
|
4959
|
+
height: "24px",
|
|
4960
|
+
display: "inline-flex",
|
|
4961
|
+
alignItems: "center",
|
|
4962
|
+
overflow: "hidden"
|
|
4772
4963
|
},
|
|
4773
4964
|
"& .cm-codeblock-line": {
|
|
4774
|
-
background: "var(--
|
|
4965
|
+
background: "var(--color-cm-codeblock)",
|
|
4775
4966
|
paddingInline: "1rem !important"
|
|
4776
4967
|
},
|
|
4777
4968
|
"& .cm-codeblock-start": {
|
|
@@ -4800,16 +4991,24 @@ var formattingStyles = EditorView21.theme({
|
|
|
4800
4991
|
*/
|
|
4801
4992
|
".cm-table *": {
|
|
4802
4993
|
fontFamily: fontMono,
|
|
4994
|
+
lineHeight: 1.5,
|
|
4803
4995
|
textDecoration: "none !important"
|
|
4804
4996
|
},
|
|
4805
4997
|
".cm-table-head": {
|
|
4806
4998
|
padding: "2px 16px 2px 0px",
|
|
4999
|
+
overflowWrap: "break-word",
|
|
5000
|
+
whiteSpace: "pre-wrap",
|
|
5001
|
+
wordBreak: "keep-all",
|
|
4807
5002
|
textAlign: "left",
|
|
4808
|
-
|
|
4809
|
-
|
|
5003
|
+
color: "var(--color-subdued)",
|
|
5004
|
+
borderBottom: "1px solid var(--color-cm-separator)"
|
|
4810
5005
|
},
|
|
4811
5006
|
".cm-table-cell": {
|
|
4812
|
-
padding: "2px 16px 2px 0px"
|
|
5007
|
+
padding: "2px 16px 2px 0px",
|
|
5008
|
+
overflowWrap: "break-word",
|
|
5009
|
+
whiteSpace: "pre-wrap",
|
|
5010
|
+
wordBreak: "keep-all",
|
|
5011
|
+
verticalAlign: "top"
|
|
4813
5012
|
},
|
|
4814
5013
|
/**
|
|
4815
5014
|
* Image.
|
|
@@ -4825,12 +5024,12 @@ var formattingStyles = EditorView21.theme({
|
|
|
4825
5024
|
},
|
|
4826
5025
|
".cm-image-with-loader": {
|
|
4827
5026
|
display: "block",
|
|
4828
|
-
opacity:
|
|
5027
|
+
opacity: 0,
|
|
4829
5028
|
transitionDuration: "350ms",
|
|
4830
5029
|
transitionProperty: "opacity"
|
|
4831
5030
|
},
|
|
4832
5031
|
".cm-image-with-loader.cm-loaded-image": {
|
|
4833
|
-
opacity:
|
|
5032
|
+
opacity: 1
|
|
4834
5033
|
},
|
|
4835
5034
|
".cm-image-wrapper": {
|
|
4836
5035
|
"grid-template-columns": "1fr",
|
|
@@ -4849,17 +5048,17 @@ var formattingStyles = EditorView21.theme({
|
|
|
4849
5048
|
// src/extensions/markdown/table.ts
|
|
4850
5049
|
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
|
4851
5050
|
import { RangeSetBuilder as RangeSetBuilder4, StateField as StateField8 } from "@codemirror/state";
|
|
4852
|
-
import { Decoration as Decoration10, EditorView as
|
|
5051
|
+
import { Decoration as Decoration10, EditorView as EditorView23, WidgetType as WidgetType6 } from "@codemirror/view";
|
|
4853
5052
|
var table = (options = {}) => {
|
|
4854
5053
|
return StateField8.define({
|
|
4855
5054
|
create: (state) => update(state, options),
|
|
4856
5055
|
update: (_, tr) => update(tr.state, options),
|
|
4857
|
-
provide: (field) =>
|
|
5056
|
+
provide: (field) => EditorView23.decorations.from(field)
|
|
4858
5057
|
});
|
|
4859
5058
|
};
|
|
4860
5059
|
var update = (state, _options) => {
|
|
4861
5060
|
const builder = new RangeSetBuilder4();
|
|
4862
|
-
const
|
|
5061
|
+
const cursor = state.selection.main.head;
|
|
4863
5062
|
const tables = [];
|
|
4864
5063
|
const getTable = () => tables[tables.length - 1];
|
|
4865
5064
|
const getRow = () => {
|
|
@@ -4897,7 +5096,7 @@ var update = (state, _options) => {
|
|
|
4897
5096
|
}
|
|
4898
5097
|
});
|
|
4899
5098
|
tables.forEach((table2) => {
|
|
4900
|
-
const replace = state.readOnly ||
|
|
5099
|
+
const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
|
|
4901
5100
|
if (replace) {
|
|
4902
5101
|
builder.add(table2.from, table2.to, Decoration10.replace({
|
|
4903
5102
|
block: true,
|
|
@@ -4911,6 +5110,26 @@ var update = (state, _options) => {
|
|
|
4911
5110
|
});
|
|
4912
5111
|
return builder.finish();
|
|
4913
5112
|
};
|
|
5113
|
+
var renderCellContent = (el, text) => {
|
|
5114
|
+
const parts = text.split(/(`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_)/);
|
|
5115
|
+
for (const part of parts) {
|
|
5116
|
+
if (part.length > 2 && part.startsWith("`") && part.endsWith("`")) {
|
|
5117
|
+
const code = document.createElement("code");
|
|
5118
|
+
code.textContent = part.slice(1, -1);
|
|
5119
|
+
el.appendChild(code);
|
|
5120
|
+
} else if (part.startsWith("**") && part.endsWith("**") || part.startsWith("__") && part.endsWith("__")) {
|
|
5121
|
+
const strong = document.createElement("strong");
|
|
5122
|
+
strong.textContent = part.slice(2, -2);
|
|
5123
|
+
el.appendChild(strong);
|
|
5124
|
+
} else if (part.startsWith("*") && part.endsWith("*") || part.startsWith("_") && part.endsWith("_")) {
|
|
5125
|
+
const em = document.createElement("em");
|
|
5126
|
+
em.textContent = part.slice(1, -1);
|
|
5127
|
+
el.appendChild(em);
|
|
5128
|
+
} else {
|
|
5129
|
+
el.appendChild(document.createTextNode(part));
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
};
|
|
4914
5133
|
var TableWidget = class extends WidgetType6 {
|
|
4915
5134
|
_table;
|
|
4916
5135
|
constructor(_table) {
|
|
@@ -4930,7 +5149,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4930
5149
|
this._table.header?.forEach((cell) => {
|
|
4931
5150
|
const th = document.createElement("th");
|
|
4932
5151
|
th.setAttribute("class", "cm-table-head");
|
|
4933
|
-
tr.appendChild(th)
|
|
5152
|
+
renderCellContent(tr.appendChild(th), cell);
|
|
4934
5153
|
});
|
|
4935
5154
|
const body = table2.appendChild(document.createElement("tbody"));
|
|
4936
5155
|
this._table.rows?.forEach((row) => {
|
|
@@ -4938,7 +5157,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4938
5157
|
row.forEach((cell) => {
|
|
4939
5158
|
const td = document.createElement("td");
|
|
4940
5159
|
td.setAttribute("class", "cm-table-cell");
|
|
4941
|
-
tr2.appendChild(td)
|
|
5160
|
+
renderCellContent(tr2.appendChild(td), cell);
|
|
4942
5161
|
});
|
|
4943
5162
|
});
|
|
4944
5163
|
return div;
|
|
@@ -4946,7 +5165,7 @@ var TableWidget = class extends WidgetType6 {
|
|
|
4946
5165
|
};
|
|
4947
5166
|
|
|
4948
5167
|
// src/extensions/markdown/decorate.ts
|
|
4949
|
-
var
|
|
5168
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/markdown/decorate.ts";
|
|
4950
5169
|
var Unicode = {
|
|
4951
5170
|
emDash: "\u2014",
|
|
4952
5171
|
bullet: "\u2022",
|
|
@@ -4969,7 +5188,6 @@ var LinkButton = class extends WidgetType7 {
|
|
|
4969
5188
|
eq(other) {
|
|
4970
5189
|
return this.url === other.url;
|
|
4971
5190
|
}
|
|
4972
|
-
// TODO(burdon): Create icon and link directly without react?
|
|
4973
5191
|
toDOM(view) {
|
|
4974
5192
|
const el = document.createElement("span");
|
|
4975
5193
|
this.render(el, {
|
|
@@ -5046,10 +5264,10 @@ var fencedCodeLine = Decoration11.line({
|
|
|
5046
5264
|
class: "cm-code cm-codeblock-line"
|
|
5047
5265
|
});
|
|
5048
5266
|
var fencedCodeLineFirst = Decoration11.line({
|
|
5049
|
-
class:
|
|
5267
|
+
class: "cm-code cm-codeblock-line cm-codeblock-start"
|
|
5050
5268
|
});
|
|
5051
5269
|
var fencedCodeLineLast = Decoration11.line({
|
|
5052
|
-
class:
|
|
5270
|
+
class: "cm-code cm-codeblock-line cm-codeblock-end"
|
|
5053
5271
|
});
|
|
5054
5272
|
var commentBlockLine = fencedCodeLine;
|
|
5055
5273
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
|
@@ -5082,8 +5300,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5082
5300
|
const headerLevels = [];
|
|
5083
5301
|
const getHeaderLevels = (node, level) => {
|
|
5084
5302
|
invariant4(level > 0, void 0, {
|
|
5085
|
-
F:
|
|
5086
|
-
L:
|
|
5303
|
+
F: __dxlog_file12,
|
|
5304
|
+
L: 177,
|
|
5087
5305
|
S: void 0,
|
|
5088
5306
|
A: [
|
|
5089
5307
|
"level > 0",
|
|
@@ -5121,8 +5339,8 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5121
5339
|
};
|
|
5122
5340
|
const getCurrentListLevel = () => {
|
|
5123
5341
|
invariant4(listLevels.length, void 0, {
|
|
5124
|
-
F:
|
|
5125
|
-
L:
|
|
5342
|
+
F: __dxlog_file12,
|
|
5343
|
+
L: 199,
|
|
5126
5344
|
S: void 0,
|
|
5127
5345
|
A: [
|
|
5128
5346
|
"listLevels.length",
|
|
@@ -5166,13 +5384,13 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5166
5384
|
deco: hide
|
|
5167
5385
|
});
|
|
5168
5386
|
} else {
|
|
5169
|
-
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
|
5387
|
+
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + "). ";
|
|
5170
5388
|
if (num.length) {
|
|
5171
5389
|
atomicDecoRanges.push({
|
|
5172
5390
|
from: mark.from,
|
|
5173
5391
|
to: mark.from + len,
|
|
5174
5392
|
deco: Decoration11.replace({
|
|
5175
|
-
widget: new TextWidget(num, markdownTheme.heading(level))
|
|
5393
|
+
widget: new TextWidget(num, markdownTheme.heading(level).className)
|
|
5176
5394
|
})
|
|
5177
5395
|
});
|
|
5178
5396
|
}
|
|
@@ -5349,11 +5567,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5349
5567
|
}
|
|
5350
5568
|
decoRanges.push({
|
|
5351
5569
|
from: marks[0].to,
|
|
5352
|
-
to: marks[1].from,
|
|
5570
|
+
to: !editing && options.renderLinkButton ? node.to : marks[1].from,
|
|
5353
5571
|
deco: Decoration11.mark({
|
|
5354
5572
|
tagName: "a",
|
|
5355
5573
|
attributes: {
|
|
5356
|
-
class: "cm-link",
|
|
5574
|
+
class: options.renderLinkButton ? "cm-link cm-link-with-button" : "cm-link",
|
|
5357
5575
|
href: url,
|
|
5358
5576
|
rel: "noreferrer",
|
|
5359
5577
|
target: "_blank"
|
|
@@ -5431,8 +5649,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5431
5649
|
deco.add(from, to, d);
|
|
5432
5650
|
}
|
|
5433
5651
|
const atomicDeco = new RangeSetBuilder5();
|
|
5434
|
-
for (const { from, to, deco:
|
|
5435
|
-
|
|
5652
|
+
for (const { from, to, deco: deco2 } of atomicDecoRanges) {
|
|
5653
|
+
if (from < to && state.doc.lineAt(from).number !== state.doc.lineAt(to).number) {
|
|
5654
|
+
continue;
|
|
5655
|
+
}
|
|
5656
|
+
atomicDeco.add(from, to, deco2);
|
|
5436
5657
|
}
|
|
5437
5658
|
return {
|
|
5438
5659
|
deco: deco.finish(),
|
|
@@ -5442,7 +5663,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5442
5663
|
var forceUpdate = StateEffect7.define();
|
|
5443
5664
|
var decorateMarkdown = (options = {}) => {
|
|
5444
5665
|
return [
|
|
5445
|
-
|
|
5666
|
+
ViewPlugin15.fromClass(class {
|
|
5446
5667
|
deco;
|
|
5447
5668
|
atomicDeco;
|
|
5448
5669
|
pendingUpdate;
|
|
@@ -5477,9 +5698,9 @@ var decorateMarkdown = (options = {}) => {
|
|
|
5477
5698
|
}
|
|
5478
5699
|
}, {
|
|
5479
5700
|
provide: (plugin) => [
|
|
5480
|
-
Prec4.low(
|
|
5481
|
-
|
|
5482
|
-
|
|
5701
|
+
Prec4.low(EditorView24.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration11.none)),
|
|
5702
|
+
EditorView24.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none),
|
|
5703
|
+
EditorView24.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration11.none)
|
|
5483
5704
|
]
|
|
5484
5705
|
}),
|
|
5485
5706
|
image(),
|
|
@@ -5511,8 +5732,7 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5511
5732
|
return {
|
|
5512
5733
|
pos: link.from,
|
|
5513
5734
|
end: link.to,
|
|
5514
|
-
|
|
5515
|
-
// above: true,
|
|
5735
|
+
above: true,
|
|
5516
5736
|
create: () => {
|
|
5517
5737
|
const el = document.createElement("div");
|
|
5518
5738
|
el.className = tooltipContent({});
|
|
@@ -5528,16 +5748,13 @@ var linkTooltip = (renderTooltip) => {
|
|
|
5528
5748
|
};
|
|
5529
5749
|
}
|
|
5530
5750
|
};
|
|
5531
|
-
}, {
|
|
5532
|
-
// NOTE: 0 = default of 300ms.
|
|
5533
|
-
hoverTime: 1
|
|
5534
5751
|
});
|
|
5535
5752
|
};
|
|
5536
5753
|
|
|
5537
5754
|
// src/extensions/mention.ts
|
|
5538
5755
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
5539
|
-
import { log as
|
|
5540
|
-
var
|
|
5756
|
+
import { log as log9 } from "@dxos/log";
|
|
5757
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/mention.ts";
|
|
5541
5758
|
var mention = ({ debug, onSearch }) => {
|
|
5542
5759
|
return autocompletion({
|
|
5543
5760
|
// TODO(burdon): Not working.
|
|
@@ -5549,10 +5766,10 @@ var mention = ({ debug, onSearch }) => {
|
|
|
5549
5766
|
icons: false,
|
|
5550
5767
|
override: [
|
|
5551
5768
|
(context) => {
|
|
5552
|
-
|
|
5769
|
+
log9.info("completion context", {
|
|
5553
5770
|
context
|
|
5554
5771
|
}, {
|
|
5555
|
-
F:
|
|
5772
|
+
F: __dxlog_file13,
|
|
5556
5773
|
L: 27,
|
|
5557
5774
|
S: void 0,
|
|
5558
5775
|
C: (f, a) => f(...a)
|
|
@@ -5635,7 +5852,7 @@ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
|
|
|
5635
5852
|
import { StateField as StateField10 } from "@codemirror/state";
|
|
5636
5853
|
import { Facet as Facet2 } from "@codemirror/state";
|
|
5637
5854
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
5638
|
-
var
|
|
5855
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/tree.ts";
|
|
5639
5856
|
var itemToJSON = ({ type, index, level, lineRange, contentRange, children }) => {
|
|
5640
5857
|
return {
|
|
5641
5858
|
type,
|
|
@@ -5790,7 +6007,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5790
6007
|
}
|
|
5791
6008
|
case "BulletList": {
|
|
5792
6009
|
invariant5(current, void 0, {
|
|
5793
|
-
F:
|
|
6010
|
+
F: __dxlog_file14,
|
|
5794
6011
|
L: 219,
|
|
5795
6012
|
S: void 0,
|
|
5796
6013
|
A: [
|
|
@@ -5807,7 +6024,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5807
6024
|
}
|
|
5808
6025
|
case "ListItem": {
|
|
5809
6026
|
invariant5(parent, void 0, {
|
|
5810
|
-
F:
|
|
6027
|
+
F: __dxlog_file14,
|
|
5811
6028
|
L: 228,
|
|
5812
6029
|
S: void 0,
|
|
5813
6030
|
A: [
|
|
@@ -5849,7 +6066,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5849
6066
|
}
|
|
5850
6067
|
case "ListMark": {
|
|
5851
6068
|
invariant5(current, void 0, {
|
|
5852
|
-
F:
|
|
6069
|
+
F: __dxlog_file14,
|
|
5853
6070
|
L: 272,
|
|
5854
6071
|
S: void 0,
|
|
5855
6072
|
A: [
|
|
@@ -5863,7 +6080,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5863
6080
|
}
|
|
5864
6081
|
case "Task": {
|
|
5865
6082
|
invariant5(current, void 0, {
|
|
5866
|
-
F:
|
|
6083
|
+
F: __dxlog_file14,
|
|
5867
6084
|
L: 278,
|
|
5868
6085
|
S: void 0,
|
|
5869
6086
|
A: [
|
|
@@ -5876,7 +6093,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5876
6093
|
}
|
|
5877
6094
|
case "TaskMarker": {
|
|
5878
6095
|
invariant5(current, void 0, {
|
|
5879
|
-
F:
|
|
6096
|
+
F: __dxlog_file14,
|
|
5880
6097
|
L: 283,
|
|
5881
6098
|
S: void 0,
|
|
5882
6099
|
A: [
|
|
@@ -5892,7 +6109,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5892
6109
|
leave: (node) => {
|
|
5893
6110
|
if (node.name === "BulletList") {
|
|
5894
6111
|
invariant5(parent, void 0, {
|
|
5895
|
-
F:
|
|
6112
|
+
F: __dxlog_file14,
|
|
5896
6113
|
L: 291,
|
|
5897
6114
|
S: void 0,
|
|
5898
6115
|
A: [
|
|
@@ -5906,7 +6123,7 @@ var outlinerTree = (_options = {}) => {
|
|
|
5906
6123
|
}
|
|
5907
6124
|
});
|
|
5908
6125
|
invariant5(tree, void 0, {
|
|
5909
|
-
F:
|
|
6126
|
+
F: __dxlog_file14,
|
|
5910
6127
|
L: 298,
|
|
5911
6128
|
S: void 0,
|
|
5912
6129
|
A: [
|
|
@@ -6198,17 +6415,17 @@ var commands = () => keymap11.of([
|
|
|
6198
6415
|
|
|
6199
6416
|
// src/extensions/outliner/outliner.ts
|
|
6200
6417
|
import { Prec as Prec5 } from "@codemirror/state";
|
|
6201
|
-
import { Decoration as Decoration12, EditorView as
|
|
6202
|
-
import { mx as
|
|
6418
|
+
import { Decoration as Decoration12, EditorView as EditorView26, ViewPlugin as ViewPlugin18 } from "@codemirror/view";
|
|
6419
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
6203
6420
|
|
|
6204
6421
|
// src/extensions/outliner/editor.ts
|
|
6205
6422
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
6206
|
-
import { ViewPlugin as
|
|
6207
|
-
import { log as
|
|
6208
|
-
var
|
|
6423
|
+
import { ViewPlugin as ViewPlugin16 } from "@codemirror/view";
|
|
6424
|
+
import { log as log10 } from "@dxos/log";
|
|
6425
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/outliner/editor.ts";
|
|
6209
6426
|
var LIST_ITEM_REGEX = /^\s*- (\[ \]|\[x\])? /;
|
|
6210
6427
|
var initialize = () => {
|
|
6211
|
-
return
|
|
6428
|
+
return ViewPlugin16.fromClass(class {
|
|
6212
6429
|
constructor(view) {
|
|
6213
6430
|
const first = view.state.doc.lineAt(0);
|
|
6214
6431
|
const text = view.state.sliceDoc(first.from, first.to);
|
|
@@ -6337,7 +6554,7 @@ var editor = () => [
|
|
|
6337
6554
|
cancel = true;
|
|
6338
6555
|
return;
|
|
6339
6556
|
}
|
|
6340
|
-
|
|
6557
|
+
log10("change", {
|
|
6341
6558
|
item,
|
|
6342
6559
|
line: {
|
|
6343
6560
|
from: line.from,
|
|
@@ -6356,7 +6573,7 @@ var editor = () => [
|
|
|
6356
6573
|
length: insert.length
|
|
6357
6574
|
}
|
|
6358
6575
|
}, {
|
|
6359
|
-
F:
|
|
6576
|
+
F: __dxlog_file15,
|
|
6360
6577
|
L: 164,
|
|
6361
6578
|
S: void 0,
|
|
6362
6579
|
C: (f, a) => f(...a)
|
|
@@ -6364,10 +6581,10 @@ var editor = () => [
|
|
|
6364
6581
|
}
|
|
6365
6582
|
});
|
|
6366
6583
|
if (changes.length > 0) {
|
|
6367
|
-
|
|
6584
|
+
log10("modified,", {
|
|
6368
6585
|
changes
|
|
6369
6586
|
}, {
|
|
6370
|
-
F:
|
|
6587
|
+
F: __dxlog_file15,
|
|
6371
6588
|
L: 175,
|
|
6372
6589
|
S: void 0,
|
|
6373
6590
|
C: (f, a) => f(...a)
|
|
@@ -6378,8 +6595,8 @@ var editor = () => [
|
|
|
6378
6595
|
}
|
|
6379
6596
|
];
|
|
6380
6597
|
} else if (cancel) {
|
|
6381
|
-
|
|
6382
|
-
F:
|
|
6598
|
+
log10("cancel", void 0, {
|
|
6599
|
+
F: __dxlog_file15,
|
|
6383
6600
|
L: 178,
|
|
6384
6601
|
S: void 0,
|
|
6385
6602
|
C: (f, a) => f(...a)
|
|
@@ -6391,10 +6608,10 @@ var editor = () => [
|
|
|
6391
6608
|
];
|
|
6392
6609
|
|
|
6393
6610
|
// src/extensions/outliner/menu.ts
|
|
6394
|
-
import { EditorView as
|
|
6395
|
-
import { addEventListener } from "@dxos/async";
|
|
6611
|
+
import { EditorView as EditorView25, ViewPlugin as ViewPlugin17 } from "@codemirror/view";
|
|
6612
|
+
import { addEventListener as addEventListener2 } from "@dxos/async";
|
|
6396
6613
|
var menu = (options = {}) => [
|
|
6397
|
-
|
|
6614
|
+
ViewPlugin17.fromClass(class {
|
|
6398
6615
|
view;
|
|
6399
6616
|
tag;
|
|
6400
6617
|
rafId;
|
|
@@ -6414,7 +6631,7 @@ var menu = (options = {}) => [
|
|
|
6414
6631
|
}
|
|
6415
6632
|
container.appendChild(this.tag);
|
|
6416
6633
|
const handler = () => this.scheduleUpdate();
|
|
6417
|
-
this.cleanup =
|
|
6634
|
+
this.cleanup = addEventListener2(container, "scroll", handler);
|
|
6418
6635
|
this.scheduleUpdate();
|
|
6419
6636
|
}
|
|
6420
6637
|
destroy() {
|
|
@@ -6456,7 +6673,7 @@ var menu = (options = {}) => [
|
|
|
6456
6673
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
|
6457
6674
|
}
|
|
6458
6675
|
}),
|
|
6459
|
-
|
|
6676
|
+
EditorView25.theme({
|
|
6460
6677
|
".cm-popover-trigger": {
|
|
6461
6678
|
position: "fixed",
|
|
6462
6679
|
padding: "0",
|
|
@@ -6492,12 +6709,12 @@ var outliner = (_options = {}) => [
|
|
|
6492
6709
|
listPaddingLeft: 8
|
|
6493
6710
|
}),
|
|
6494
6711
|
// Researve space for menu.
|
|
6495
|
-
|
|
6496
|
-
class: "
|
|
6712
|
+
EditorView26.contentAttributes.of({
|
|
6713
|
+
class: "w-full !mr-[3rem]"
|
|
6497
6714
|
})
|
|
6498
6715
|
];
|
|
6499
6716
|
var decorations = () => [
|
|
6500
|
-
|
|
6717
|
+
ViewPlugin18.fromClass(class {
|
|
6501
6718
|
decorations = Decoration12.none;
|
|
6502
6719
|
constructor(view) {
|
|
6503
6720
|
this.updateDecorations(view.state, view);
|
|
@@ -6522,7 +6739,7 @@ var decorations = () => [
|
|
|
6522
6739
|
const lineTo = doc.lineAt(item.contentRange.to);
|
|
6523
6740
|
const isSelected = selection.includes(item.index) || item === current;
|
|
6524
6741
|
decorations2.push(Decoration12.line({
|
|
6525
|
-
class:
|
|
6742
|
+
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
6743
|
}).range(line.from, line.from));
|
|
6527
6744
|
}
|
|
6528
6745
|
}
|
|
@@ -6532,7 +6749,7 @@ var decorations = () => [
|
|
|
6532
6749
|
decorations: (v) => v.decorations
|
|
6533
6750
|
}),
|
|
6534
6751
|
// Theme.
|
|
6535
|
-
|
|
6752
|
+
EditorView26.theme(Object.assign({
|
|
6536
6753
|
".cm-list-item": {
|
|
6537
6754
|
borderLeftWidth: "1px",
|
|
6538
6755
|
borderRightWidth: "1px",
|
|
@@ -6557,38 +6774,67 @@ var decorations = () => [
|
|
|
6557
6774
|
marginBottom: "2px"
|
|
6558
6775
|
},
|
|
6559
6776
|
".cm-list-item-focused": {
|
|
6560
|
-
borderColor: "var(--
|
|
6777
|
+
borderColor: "var(--color-neutral-focus-indicator)"
|
|
6561
6778
|
},
|
|
6562
6779
|
"&:focus-within .cm-list-item-selected": {
|
|
6563
|
-
borderColor: "var(--
|
|
6780
|
+
borderColor: "var(--color-separator)"
|
|
6564
6781
|
}
|
|
6565
6782
|
}))
|
|
6566
6783
|
];
|
|
6567
6784
|
|
|
6568
6785
|
// src/extensions/preview/preview.ts
|
|
6569
6786
|
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
|
|
6787
|
+
import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect9, StateField as StateField11 } from "@codemirror/state";
|
|
6788
|
+
import { Decoration as Decoration13, EditorView as EditorView27, ViewPlugin as ViewPlugin19, WidgetType as WidgetType8 } from "@codemirror/view";
|
|
6789
|
+
import { DXN, Entity } from "@dxos/echo";
|
|
6790
|
+
var labelResolvedEffect = StateEffect9.define();
|
|
6572
6791
|
var preview = (options = {}) => {
|
|
6792
|
+
const viewRef = {
|
|
6793
|
+
current: void 0
|
|
6794
|
+
};
|
|
6573
6795
|
return [
|
|
6574
6796
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
|
6575
6797
|
// "Block decorations may not be specified via plugins".
|
|
6576
6798
|
StateField11.define({
|
|
6577
|
-
create: (state) => buildDecorations3(state, options),
|
|
6799
|
+
create: (state) => buildDecorations3(state, options, viewRef),
|
|
6578
6800
|
update: (decorations2, tr) => {
|
|
6579
|
-
if (tr.docChanged) {
|
|
6580
|
-
return buildDecorations3(tr.state, options);
|
|
6801
|
+
if (tr.docChanged || tr.effects.some((effect) => effect.is(labelResolvedEffect))) {
|
|
6802
|
+
return buildDecorations3(tr.state, options, viewRef);
|
|
6581
6803
|
}
|
|
6582
6804
|
return decorations2.map(tr.changes);
|
|
6583
6805
|
},
|
|
6584
6806
|
provide: (field) => [
|
|
6585
|
-
|
|
6586
|
-
|
|
6807
|
+
EditorView27.decorations.from(field),
|
|
6808
|
+
EditorView27.atomicRanges.of((view) => view.state.field(field))
|
|
6587
6809
|
]
|
|
6810
|
+
}),
|
|
6811
|
+
ViewPlugin19.define((view) => {
|
|
6812
|
+
viewRef.current = view;
|
|
6813
|
+
return {
|
|
6814
|
+
destroy() {
|
|
6815
|
+
viewRef.current = void 0;
|
|
6816
|
+
}
|
|
6817
|
+
};
|
|
6588
6818
|
})
|
|
6589
6819
|
];
|
|
6590
6820
|
};
|
|
6591
|
-
var
|
|
6821
|
+
var resolveLabel = (db, dxnStr, viewRef) => {
|
|
6822
|
+
const dxn = DXN.tryParse(dxnStr);
|
|
6823
|
+
if (!dxn) {
|
|
6824
|
+
return;
|
|
6825
|
+
}
|
|
6826
|
+
const ref = db.makeRef(dxn);
|
|
6827
|
+
const target = ref.target;
|
|
6828
|
+
if (target) {
|
|
6829
|
+
return Entity.getLabel(target);
|
|
6830
|
+
}
|
|
6831
|
+
void ref.tryLoad().then(() => {
|
|
6832
|
+
viewRef.current?.dispatch({
|
|
6833
|
+
effects: labelResolvedEffect.of(void 0)
|
|
6834
|
+
});
|
|
6835
|
+
});
|
|
6836
|
+
};
|
|
6837
|
+
var buildDecorations3 = (state, options, viewRef) => {
|
|
6592
6838
|
const builder = new RangeSetBuilder6();
|
|
6593
6839
|
syntaxTree10(state).iterate({
|
|
6594
6840
|
enter: (node) => {
|
|
@@ -6600,8 +6846,13 @@ var buildDecorations3 = (state, options) => {
|
|
|
6600
6846
|
case "Link": {
|
|
6601
6847
|
const link = getLinkRef(state, node.node);
|
|
6602
6848
|
if (link) {
|
|
6849
|
+
const resolved = options.db ? resolveLabel(options.db, link.dxn, viewRef) : void 0;
|
|
6850
|
+
const displayLink = resolved ? {
|
|
6851
|
+
...link,
|
|
6852
|
+
label: resolved
|
|
6853
|
+
} : link;
|
|
6603
6854
|
builder.add(node.from, node.to, Decoration13.replace({
|
|
6604
|
-
widget: new PreviewInlineWidget(options,
|
|
6855
|
+
widget: new PreviewInlineWidget(options, displayLink),
|
|
6605
6856
|
side: 1
|
|
6606
6857
|
}));
|
|
6607
6858
|
}
|
|
@@ -6632,13 +6883,13 @@ var getLinkRef = (state, node) => {
|
|
|
6632
6883
|
const mark = node.getChildren("LinkMark");
|
|
6633
6884
|
const urlNode = node.getChild("URL");
|
|
6634
6885
|
if (mark && urlNode) {
|
|
6635
|
-
const
|
|
6636
|
-
if (
|
|
6886
|
+
const dxn = state.sliceDoc(urlNode.from, urlNode.to);
|
|
6887
|
+
if (dxn.startsWith("dxn:")) {
|
|
6637
6888
|
const label = state.sliceDoc(mark[0].to, mark[1].from);
|
|
6638
6889
|
return {
|
|
6639
6890
|
block: state.sliceDoc(mark[0].from, mark[0].from + 1) === "!",
|
|
6640
6891
|
label,
|
|
6641
|
-
|
|
6892
|
+
dxn
|
|
6642
6893
|
};
|
|
6643
6894
|
}
|
|
6644
6895
|
}
|
|
@@ -6653,13 +6904,13 @@ var PreviewInlineWidget = class extends WidgetType8 {
|
|
|
6653
6904
|
// return false;
|
|
6654
6905
|
// }
|
|
6655
6906
|
eq(other) {
|
|
6656
|
-
return this._link.
|
|
6907
|
+
return this._link.dxn === other._link.dxn && this._link.label === other._link.label;
|
|
6657
6908
|
}
|
|
6658
6909
|
toDOM(_view) {
|
|
6659
6910
|
const root = document.createElement("dx-anchor");
|
|
6660
6911
|
root.classList.add("dx-tag--anchor");
|
|
6661
6912
|
root.textContent = this._link.label;
|
|
6662
|
-
root.setAttribute("
|
|
6913
|
+
root.setAttribute("dxn", this._link.dxn);
|
|
6663
6914
|
return root;
|
|
6664
6915
|
}
|
|
6665
6916
|
};
|
|
@@ -6673,11 +6924,11 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6673
6924
|
// return true;
|
|
6674
6925
|
// }
|
|
6675
6926
|
eq(other) {
|
|
6676
|
-
return this._link.
|
|
6927
|
+
return this._link.dxn === other._link.dxn;
|
|
6677
6928
|
}
|
|
6678
6929
|
toDOM(_view) {
|
|
6679
6930
|
const root = document.createElement("div");
|
|
6680
|
-
root.classList.add("cm-preview-block", "density-fine");
|
|
6931
|
+
root.classList.add("cm-preview-block", "dx-density-fine");
|
|
6681
6932
|
this._options.addBlockContainer?.({
|
|
6682
6933
|
link: this._link,
|
|
6683
6934
|
el: root
|
|
@@ -6693,7 +6944,7 @@ var PreviewBlockWidget = class extends WidgetType8 {
|
|
|
6693
6944
|
};
|
|
6694
6945
|
|
|
6695
6946
|
// src/extensions/replacer.ts
|
|
6696
|
-
import { EditorView as
|
|
6947
|
+
import { EditorView as EditorView28 } from "@codemirror/view";
|
|
6697
6948
|
var defaultReplacements = [
|
|
6698
6949
|
{
|
|
6699
6950
|
input: "--",
|
|
@@ -6756,7 +7007,7 @@ var replacer = ({ replacements = defaultReplacements } = {}) => {
|
|
|
6756
7007
|
const sortedReplacements = [
|
|
6757
7008
|
...replacements
|
|
6758
7009
|
].sort((a, b) => b.input.length - a.input.length);
|
|
6759
|
-
return
|
|
7010
|
+
return EditorView28.inputHandler.of((view, from, to, insert) => {
|
|
6760
7011
|
if (insert.length !== 1) {
|
|
6761
7012
|
return false;
|
|
6762
7013
|
}
|
|
@@ -6840,6 +7091,7 @@ var submit = ({ fireIfEmpty = false, onSubmit } = {}) => {
|
|
|
6840
7091
|
// src/extensions/tags/extended-markdown.ts
|
|
6841
7092
|
import { xmlLanguage } from "@codemirror/lang-xml";
|
|
6842
7093
|
import { parseMixed } from "@lezer/common";
|
|
7094
|
+
var escapeRegExpSource = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6843
7095
|
var extendedMarkdown = ({ registry } = {}) => {
|
|
6844
7096
|
return [
|
|
6845
7097
|
createMarkdownExtensions({
|
|
@@ -6851,30 +7103,82 @@ var extendedMarkdown = ({ registry } = {}) => {
|
|
|
6851
7103
|
{
|
|
6852
7104
|
name: "SetextHeading",
|
|
6853
7105
|
parse: () => false
|
|
6854
|
-
}
|
|
7106
|
+
},
|
|
7107
|
+
// Custom XML block parser that keeps registered tags as a single HTMLBlock
|
|
7108
|
+
// even when their content contains blank lines.
|
|
7109
|
+
...xmlBlockParsers(registry)
|
|
6855
7110
|
]
|
|
6856
7111
|
}
|
|
6857
7112
|
]
|
|
6858
7113
|
})
|
|
6859
7114
|
];
|
|
6860
7115
|
};
|
|
6861
|
-
var
|
|
7116
|
+
var xmlBlockParsers = (registry) => {
|
|
6862
7117
|
const customTags = Object.keys(registry ?? {});
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
7118
|
+
if (customTags.length === 0) {
|
|
7119
|
+
return [];
|
|
7120
|
+
}
|
|
7121
|
+
const tagPattern = customTags.map(escapeRegExpSource).join("|");
|
|
7122
|
+
const selfClosePattern = new RegExp(`^\\s*<(${tagPattern})(\\s[^>]*)?\\/>\\s*$`);
|
|
7123
|
+
const openPattern = new RegExp(`^\\s*<(${tagPattern})(\\s[^>]*)?\\/?>`);
|
|
7124
|
+
return [
|
|
7125
|
+
{
|
|
7126
|
+
name: "XMLBlock",
|
|
7127
|
+
before: "HTMLBlock",
|
|
7128
|
+
parse: (cx, line) => {
|
|
7129
|
+
const match = openPattern.exec(line.text);
|
|
7130
|
+
if (!match) {
|
|
7131
|
+
return false;
|
|
7132
|
+
}
|
|
7133
|
+
if (selfClosePattern.test(line.text)) {
|
|
7134
|
+
const end2 = cx.lineStart + line.text.length;
|
|
7135
|
+
cx.addElement(cx.elt("HTMLBlock", cx.lineStart, end2));
|
|
7136
|
+
cx.nextLine();
|
|
7137
|
+
return true;
|
|
7138
|
+
}
|
|
7139
|
+
if (match[0].trimEnd().endsWith("/>")) {
|
|
7140
|
+
return false;
|
|
7141
|
+
}
|
|
7142
|
+
const tagName = match[1];
|
|
7143
|
+
const closeTag = `</${tagName}>`;
|
|
7144
|
+
const start = cx.lineStart;
|
|
7145
|
+
if (line.text.includes(closeTag)) {
|
|
7146
|
+
cx.addElement(cx.elt("HTMLBlock", start, start + line.text.length));
|
|
7147
|
+
cx.nextLine();
|
|
7148
|
+
return true;
|
|
7149
|
+
}
|
|
7150
|
+
let end = cx.lineStart + line.text.length;
|
|
7151
|
+
while (cx.nextLine()) {
|
|
7152
|
+
end = cx.lineStart + line.text.length;
|
|
7153
|
+
if (line.text.includes(closeTag)) {
|
|
7154
|
+
cx.addElement(cx.elt("HTMLBlock", start, end));
|
|
7155
|
+
cx.nextLine();
|
|
7156
|
+
return true;
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
cx.addElement(cx.elt("HTMLBlock", start, end));
|
|
7160
|
+
return true;
|
|
7161
|
+
}
|
|
7162
|
+
}
|
|
7163
|
+
];
|
|
7164
|
+
};
|
|
7165
|
+
var mixedParser = (registry) => {
|
|
7166
|
+
const customTags = Object.keys(registry ?? {});
|
|
7167
|
+
const tagPattern = new RegExp(`<(${customTags.join("|")})`);
|
|
7168
|
+
return parseMixed((node, input) => {
|
|
7169
|
+
switch (node.name) {
|
|
7170
|
+
// Ignore XML inside of fenced and inline code.
|
|
7171
|
+
case "FencedCode":
|
|
7172
|
+
case "InlineCode": {
|
|
7173
|
+
return null;
|
|
7174
|
+
}
|
|
7175
|
+
// Parse multi-line HTML blocks.
|
|
7176
|
+
// case 'XMLBlock':
|
|
7177
|
+
case "HTMLBlock": {
|
|
7178
|
+
return {
|
|
7179
|
+
parser: xmlLanguage.parser
|
|
7180
|
+
};
|
|
7181
|
+
}
|
|
6878
7182
|
// Parse paragraphs that contain custom XML tags.
|
|
6879
7183
|
// TODO(burdon): Entire paragraph should be parsed as XML.
|
|
6880
7184
|
case "Paragraph": {
|
|
@@ -6891,212 +7195,560 @@ var mixedParser = (registry) => {
|
|
|
6891
7195
|
});
|
|
6892
7196
|
};
|
|
6893
7197
|
|
|
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
|
-
|
|
7198
|
+
// src/extensions/tags/fader.ts
|
|
7199
|
+
import { StateEffect as StateEffect10, StateField as StateField12 } from "@codemirror/state";
|
|
7200
|
+
import { Decoration as Decoration14, EditorView as EditorView29, ViewPlugin as ViewPlugin20 } from "@codemirror/view";
|
|
7201
|
+
var DEFAULT_REMOVAL_DELAY = 5e3;
|
|
7202
|
+
var DEFAULT_COALESCE_WINDOW = 100;
|
|
7203
|
+
var CLEANUP_INTERVAL = 1e3;
|
|
7204
|
+
var fader = (options = {}) => {
|
|
7205
|
+
const removalDelay = DEFAULT_REMOVAL_DELAY;
|
|
7206
|
+
const coalesceWindow = options.coalesce ?? DEFAULT_COALESCE_WINDOW;
|
|
7207
|
+
let lastCount = -1;
|
|
7208
|
+
const log12 = (expiries) => {
|
|
7209
|
+
if (expiries.length !== lastCount) {
|
|
7210
|
+
lastCount = expiries.length;
|
|
7211
|
+
}
|
|
7212
|
+
};
|
|
7213
|
+
const dequeue = StateEffect10.define();
|
|
7214
|
+
const fadeField = StateField12.define({
|
|
7215
|
+
create: () => ({
|
|
7216
|
+
decorations: Decoration14.none,
|
|
7217
|
+
expiries: [],
|
|
7218
|
+
batchStart: 0
|
|
7219
|
+
}),
|
|
7220
|
+
update: ({ decorations: decorations2, expiries, batchStart }, tr) => {
|
|
6911
7221
|
for (const effect of tr.effects) {
|
|
6912
|
-
if (effect.is(
|
|
6913
|
-
|
|
7222
|
+
if (effect.is(dequeue)) {
|
|
7223
|
+
const now2 = effect.value;
|
|
7224
|
+
let removeCount = 0;
|
|
7225
|
+
while (removeCount < expiries.length && expiries[removeCount] <= now2) {
|
|
7226
|
+
removeCount++;
|
|
7227
|
+
}
|
|
7228
|
+
if (removeCount > 0) {
|
|
7229
|
+
expiries = expiries.slice(removeCount);
|
|
7230
|
+
let skipped = 0;
|
|
7231
|
+
decorations2 = decorations2.update({
|
|
7232
|
+
filter: () => {
|
|
7233
|
+
if (skipped < removeCount) {
|
|
7234
|
+
skipped++;
|
|
7235
|
+
return false;
|
|
7236
|
+
}
|
|
7237
|
+
return true;
|
|
7238
|
+
}
|
|
7239
|
+
});
|
|
7240
|
+
}
|
|
6914
7241
|
}
|
|
6915
7242
|
}
|
|
6916
|
-
if (tr.docChanged) {
|
|
6917
|
-
|
|
7243
|
+
if (!tr.docChanged) {
|
|
7244
|
+
log12(expiries);
|
|
7245
|
+
return {
|
|
7246
|
+
decorations: decorations2,
|
|
7247
|
+
expiries,
|
|
7248
|
+
batchStart
|
|
7249
|
+
};
|
|
6918
7250
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
7251
|
+
let isReset = tr.state.doc.length === 0;
|
|
7252
|
+
if (!isReset && tr.startState.doc.length > 0) {
|
|
7253
|
+
tr.changes.iterChanges((fromA, toA) => {
|
|
7254
|
+
if (fromA === 0 && toA === tr.startState.doc.length) {
|
|
7255
|
+
isReset = true;
|
|
7256
|
+
}
|
|
7257
|
+
});
|
|
7258
|
+
}
|
|
7259
|
+
if (isReset) {
|
|
7260
|
+
log12([]);
|
|
7261
|
+
return {
|
|
7262
|
+
decorations: Decoration14.none,
|
|
7263
|
+
expiries: [],
|
|
7264
|
+
batchStart: 0
|
|
7265
|
+
};
|
|
7266
|
+
}
|
|
7267
|
+
const now = Date.now();
|
|
7268
|
+
const add = [];
|
|
7269
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
|
|
7270
|
+
if (toA === tr.startState.doc.length && inserted.length > 0) {
|
|
7271
|
+
add.push({
|
|
7272
|
+
from: fromB,
|
|
7273
|
+
to: toB
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
});
|
|
7277
|
+
if (add.length > 0) {
|
|
7278
|
+
const canCoalesce = expiries.length > 0 && batchStart > 0 && now - batchStart < coalesceWindow;
|
|
7279
|
+
if (canCoalesce) {
|
|
7280
|
+
let lastFrom = -1;
|
|
7281
|
+
let lastTo = -1;
|
|
7282
|
+
decorations2.between(0, tr.state.doc.length, (from, to) => {
|
|
7283
|
+
lastFrom = from;
|
|
7284
|
+
lastTo = to;
|
|
7285
|
+
});
|
|
7286
|
+
if (lastFrom >= 0) {
|
|
7287
|
+
decorations2 = decorations2.update({
|
|
7288
|
+
filter: (from, to) => !(from === lastFrom && to === lastTo)
|
|
7289
|
+
});
|
|
7290
|
+
const mergedFrom = Math.min(lastFrom, add[0].from);
|
|
7291
|
+
const mergedTo = add[add.length - 1].to;
|
|
7292
|
+
decorations2 = decorations2.update({
|
|
7293
|
+
add: [
|
|
7294
|
+
Decoration14.mark({
|
|
7295
|
+
class: "cm-fader"
|
|
7296
|
+
}).range(mergedFrom, mergedTo)
|
|
7297
|
+
]
|
|
7298
|
+
});
|
|
7299
|
+
expiries = [
|
|
7300
|
+
...expiries.slice(0, -1),
|
|
7301
|
+
now + removalDelay
|
|
7302
|
+
];
|
|
7303
|
+
}
|
|
7304
|
+
} else {
|
|
7305
|
+
batchStart = now;
|
|
7306
|
+
expiries = [
|
|
7307
|
+
...expiries,
|
|
7308
|
+
now + removalDelay
|
|
7309
|
+
];
|
|
7310
|
+
decorations2 = decorations2.update({
|
|
7311
|
+
add: add.map(({ from, to }) => Decoration14.mark({
|
|
7312
|
+
class: "cm-fader"
|
|
7313
|
+
}).range(from, to))
|
|
7314
|
+
});
|
|
7315
|
+
}
|
|
7316
|
+
}
|
|
7317
|
+
log12(expiries);
|
|
7318
|
+
return {
|
|
7319
|
+
decorations: decorations2,
|
|
7320
|
+
expiries,
|
|
7321
|
+
batchStart
|
|
7322
|
+
};
|
|
7323
|
+
},
|
|
7324
|
+
provide: (f) => EditorView29.decorations.from(f, (value) => value.decorations)
|
|
6921
7325
|
});
|
|
6922
|
-
const
|
|
7326
|
+
const cleanup = ViewPlugin20.fromClass(class {
|
|
6923
7327
|
view;
|
|
6924
|
-
timer;
|
|
7328
|
+
#timer;
|
|
6925
7329
|
constructor(view) {
|
|
6926
7330
|
this.view = view;
|
|
7331
|
+
this.#schedule();
|
|
6927
7332
|
}
|
|
6928
|
-
update(
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
7333
|
+
update() {
|
|
7334
|
+
this.#schedule();
|
|
7335
|
+
}
|
|
7336
|
+
#schedule() {
|
|
7337
|
+
const { expiries } = this.view.state.field(fadeField);
|
|
7338
|
+
if (expiries.length === 0) {
|
|
7339
|
+
clearTimeout(this.#timer);
|
|
7340
|
+
this.#timer = void 0;
|
|
7341
|
+
return;
|
|
7342
|
+
}
|
|
7343
|
+
if (this.#timer !== void 0) {
|
|
7344
|
+
return;
|
|
6936
7345
|
}
|
|
7346
|
+
const delay = Math.max(CLEANUP_INTERVAL, expiries[0] - Date.now());
|
|
7347
|
+
this.#timer = setTimeout(() => {
|
|
7348
|
+
this.#timer = void 0;
|
|
7349
|
+
this.view.dispatch({
|
|
7350
|
+
effects: dequeue.of(Date.now())
|
|
7351
|
+
});
|
|
7352
|
+
}, delay);
|
|
6937
7353
|
}
|
|
6938
7354
|
destroy() {
|
|
6939
|
-
clearTimeout(this
|
|
7355
|
+
clearTimeout(this.#timer);
|
|
6940
7356
|
}
|
|
6941
7357
|
});
|
|
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
7358
|
return [
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
7359
|
+
fadeField,
|
|
7360
|
+
cleanup,
|
|
7361
|
+
EditorView29.theme({
|
|
7362
|
+
".cm-fader": {
|
|
7363
|
+
animation: "fader 1s ease-out forwards"
|
|
7364
|
+
},
|
|
7365
|
+
"@keyframes fader": {
|
|
7366
|
+
"0%": {
|
|
7367
|
+
textShadow: "0 0 16px rgba(100, 200, 255, 1), 0 0 32px rgba(100, 200, 255, 0.6)"
|
|
7368
|
+
},
|
|
7369
|
+
"100%": {}
|
|
7370
|
+
}
|
|
7371
|
+
})
|
|
6963
7372
|
];
|
|
6964
7373
|
};
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
const
|
|
6977
|
-
const
|
|
6978
|
-
const
|
|
6979
|
-
const
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
7374
|
+
|
|
7375
|
+
// src/extensions/tags/wire.ts
|
|
7376
|
+
import { Annotation as Annotation3, ChangeSet as ChangeSet2, EditorState as EditorState3, StateEffect as StateEffect11, StateField as StateField13 } from "@codemirror/state";
|
|
7377
|
+
import { Decoration as Decoration15, EditorView as EditorView30, ViewPlugin as ViewPlugin21, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
7378
|
+
import { Domino as Domino3 } from "@dxos/ui";
|
|
7379
|
+
var wireBypass = Annotation3.define();
|
|
7380
|
+
var DEFAULT_RATE = 200;
|
|
7381
|
+
var CURSOR_LINGER = 3e3;
|
|
7382
|
+
var wire = (options = {}) => {
|
|
7383
|
+
const rate = options.rate ?? DEFAULT_RATE;
|
|
7384
|
+
const interval = 1e3 / rate;
|
|
7385
|
+
const streamingTags = options.streamingTags ?? /* @__PURE__ */ new Set();
|
|
7386
|
+
const suppressAppend = StateEffect11.define();
|
|
7387
|
+
const insertChunk = StateEffect11.define();
|
|
7388
|
+
const bufferField = StateField13.define({
|
|
7389
|
+
create: () => ({
|
|
7390
|
+
text: "",
|
|
7391
|
+
insertAt: 0
|
|
7392
|
+
}),
|
|
7393
|
+
update: (value, tr) => {
|
|
7394
|
+
let { text, insertAt } = value;
|
|
6984
7395
|
for (const effect of tr.effects) {
|
|
6985
|
-
if (effect.is(
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
7396
|
+
if (effect.is(suppressAppend)) {
|
|
7397
|
+
text += effect.value.text;
|
|
7398
|
+
if (text.length === effect.value.text.length) {
|
|
7399
|
+
insertAt = effect.value.from;
|
|
7400
|
+
}
|
|
7401
|
+
}
|
|
7402
|
+
if (effect.is(insertChunk)) {
|
|
7403
|
+
text = text.slice(effect.value.text.length);
|
|
7404
|
+
insertAt = effect.value.from + effect.value.text.length;
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
if (tr.docChanged) {
|
|
7408
|
+
let isReset = tr.state.doc.length === 0;
|
|
7409
|
+
if (!isReset && tr.startState.doc.length > 0) {
|
|
7410
|
+
tr.changes.iterChanges((fromA, toA) => {
|
|
7411
|
+
if (fromA === 0 && toA === tr.startState.doc.length) {
|
|
7412
|
+
isReset = true;
|
|
7413
|
+
}
|
|
6989
7414
|
});
|
|
6990
7415
|
}
|
|
7416
|
+
if (isReset) {
|
|
7417
|
+
return {
|
|
7418
|
+
text: "",
|
|
7419
|
+
insertAt: 0
|
|
7420
|
+
};
|
|
7421
|
+
}
|
|
7422
|
+
if (!tr.effects.some((effect) => effect.is(insertChunk))) {
|
|
7423
|
+
insertAt = tr.changes.mapPos(Math.min(insertAt, tr.startState.doc.length));
|
|
7424
|
+
}
|
|
6991
7425
|
}
|
|
6992
|
-
|
|
6993
|
-
|
|
7426
|
+
return {
|
|
7427
|
+
text,
|
|
7428
|
+
insertAt
|
|
7429
|
+
};
|
|
7430
|
+
}
|
|
7431
|
+
});
|
|
7432
|
+
const filter = EditorState3.transactionFilter.of((tr) => {
|
|
7433
|
+
if (!tr.docChanged) {
|
|
7434
|
+
return tr;
|
|
7435
|
+
}
|
|
7436
|
+
if (tr.annotation(wireBypass) || tr.effects.some((effect) => effect.is(insertChunk))) {
|
|
7437
|
+
return tr;
|
|
7438
|
+
}
|
|
7439
|
+
let appendedText = "";
|
|
7440
|
+
let appendFrom = -1;
|
|
7441
|
+
let isAppendOnly = true;
|
|
7442
|
+
tr.changes.iterChanges((fromA, toA, _fromB, _toB, inserted) => {
|
|
7443
|
+
if (toA === tr.startState.doc.length && fromA === toA && inserted.length > 0) {
|
|
7444
|
+
appendedText += inserted.sliceString(0);
|
|
7445
|
+
if (appendFrom === -1) {
|
|
7446
|
+
appendFrom = fromA;
|
|
7447
|
+
}
|
|
7448
|
+
} else {
|
|
7449
|
+
isAppendOnly = false;
|
|
6994
7450
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7451
|
+
});
|
|
7452
|
+
if (!isAppendOnly || appendedText.length === 0) {
|
|
7453
|
+
return tr;
|
|
7454
|
+
}
|
|
7455
|
+
return {
|
|
7456
|
+
changes: ChangeSet2.empty(tr.startState.doc.length),
|
|
7457
|
+
effects: suppressAppend.of({
|
|
7458
|
+
from: appendFrom,
|
|
7459
|
+
text: appendedText
|
|
7460
|
+
})
|
|
7461
|
+
};
|
|
7462
|
+
});
|
|
7463
|
+
const drainPlugin = ViewPlugin21.fromClass(class {
|
|
7464
|
+
view;
|
|
7465
|
+
#timer;
|
|
7466
|
+
#activeStreamTag = null;
|
|
7467
|
+
constructor(view) {
|
|
7468
|
+
this.view = view;
|
|
7469
|
+
this.#start();
|
|
7470
|
+
}
|
|
7471
|
+
update(update2) {
|
|
7472
|
+
const buffer = update2.state.field(bufferField);
|
|
7473
|
+
if (buffer.text.length === 0) {
|
|
7474
|
+
this.#activeStreamTag = null;
|
|
7002
7475
|
}
|
|
7003
|
-
if (
|
|
7004
|
-
|
|
7476
|
+
if (buffer.text.length > 0 && this.#timer === void 0) {
|
|
7477
|
+
this.#start();
|
|
7005
7478
|
}
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7479
|
+
}
|
|
7480
|
+
#start() {
|
|
7481
|
+
this.#timer = setInterval(() => {
|
|
7482
|
+
const { text, insertAt } = this.view.state.field(bufferField);
|
|
7483
|
+
if (text.length === 0) {
|
|
7484
|
+
clearInterval(this.#timer);
|
|
7485
|
+
this.#timer = void 0;
|
|
7009
7486
|
return;
|
|
7010
7487
|
}
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
}).range(fromB, toB));
|
|
7488
|
+
const result = flushable(text, streamingTags, this.#activeStreamTag);
|
|
7489
|
+
if (result.count === 0) {
|
|
7490
|
+
return;
|
|
7015
7491
|
}
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7492
|
+
if (result.enterTag) {
|
|
7493
|
+
this.#activeStreamTag = result.enterTag;
|
|
7494
|
+
}
|
|
7495
|
+
if (result.exitTag) {
|
|
7496
|
+
this.#activeStreamTag = null;
|
|
7497
|
+
}
|
|
7498
|
+
const chunk = text.slice(0, result.count);
|
|
7499
|
+
this.view.dispatch({
|
|
7500
|
+
changes: {
|
|
7501
|
+
from: insertAt,
|
|
7502
|
+
insert: chunk
|
|
7503
|
+
},
|
|
7504
|
+
effects: insertChunk.of({
|
|
7505
|
+
from: insertAt,
|
|
7506
|
+
text: chunk
|
|
7507
|
+
})
|
|
7508
|
+
});
|
|
7509
|
+
}, interval);
|
|
7510
|
+
}
|
|
7511
|
+
destroy() {
|
|
7512
|
+
clearInterval(this.#timer);
|
|
7513
|
+
}
|
|
7514
|
+
});
|
|
7515
|
+
return [
|
|
7516
|
+
bufferField,
|
|
7517
|
+
filter,
|
|
7518
|
+
drainPlugin,
|
|
7519
|
+
options.cursor && wireCursor(bufferField)
|
|
7520
|
+
].filter(Boolean);
|
|
7521
|
+
};
|
|
7522
|
+
var wireCursor = (bufferField) => {
|
|
7523
|
+
const hideCursor = StateEffect11.define();
|
|
7524
|
+
const visibilityField = StateField13.define({
|
|
7525
|
+
create: () => ({
|
|
7526
|
+
visible: false,
|
|
7527
|
+
insertAt: 0,
|
|
7528
|
+
lastNonWsAt: 0
|
|
7529
|
+
}),
|
|
7530
|
+
update: (value, tr) => {
|
|
7531
|
+
const { text, insertAt } = tr.state.field(bufferField);
|
|
7532
|
+
if (text.length > 0) {
|
|
7533
|
+
let lastNonWsAt = tr.changes.mapPos(Math.min(value.lastNonWsAt, tr.startState.doc.length));
|
|
7534
|
+
if (tr.docChanged) {
|
|
7535
|
+
tr.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => {
|
|
7536
|
+
const chunk = inserted.sliceString(0);
|
|
7537
|
+
if (chunk.trim().length > 0) {
|
|
7538
|
+
lastNonWsAt = _fromB + chunk.length;
|
|
7539
|
+
}
|
|
7540
|
+
});
|
|
7541
|
+
}
|
|
7542
|
+
return {
|
|
7543
|
+
visible: true,
|
|
7544
|
+
insertAt,
|
|
7545
|
+
lastNonWsAt
|
|
7546
|
+
};
|
|
7547
|
+
}
|
|
7548
|
+
for (const effect of tr.effects) {
|
|
7549
|
+
if (effect.is(hideCursor)) {
|
|
7550
|
+
return {
|
|
7551
|
+
...value,
|
|
7552
|
+
visible: false
|
|
7553
|
+
};
|
|
7554
|
+
}
|
|
7555
|
+
}
|
|
7556
|
+
return value;
|
|
7557
|
+
}
|
|
7558
|
+
});
|
|
7559
|
+
const decorationField = StateField13.define({
|
|
7560
|
+
create: () => Decoration15.none,
|
|
7561
|
+
update: (_decorations, tr) => {
|
|
7562
|
+
const { visible, insertAt, lastNonWsAt } = tr.state.field(visibilityField);
|
|
7563
|
+
if (!visible) {
|
|
7564
|
+
return Decoration15.none;
|
|
7565
|
+
}
|
|
7566
|
+
const { text } = tr.state.field(bufferField);
|
|
7567
|
+
const cursorAt = text.length > 0 ? insertAt : lastNonWsAt;
|
|
7568
|
+
const pos = Math.min(cursorAt, tr.state.doc.length);
|
|
7569
|
+
return Decoration15.set([
|
|
7570
|
+
Decoration15.widget({
|
|
7571
|
+
widget: new CursorWidget(),
|
|
7572
|
+
side: 1
|
|
7573
|
+
}).range(pos)
|
|
7574
|
+
]);
|
|
7020
7575
|
},
|
|
7021
|
-
provide: (
|
|
7576
|
+
provide: (field) => EditorView30.decorations.from(field)
|
|
7022
7577
|
});
|
|
7023
|
-
const timerPlugin =
|
|
7578
|
+
const timerPlugin = ViewPlugin21.fromClass(class {
|
|
7024
7579
|
view;
|
|
7025
|
-
|
|
7026
|
-
_timers = /* @__PURE__ */ new Map();
|
|
7580
|
+
#timer;
|
|
7027
7581
|
constructor(view) {
|
|
7028
7582
|
this.view = view;
|
|
7029
7583
|
}
|
|
7030
7584
|
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(() => {
|
|
7585
|
+
const { text } = update2.state.field(bufferField);
|
|
7586
|
+
const { visible } = update2.state.field(visibilityField);
|
|
7587
|
+
if (text.length > 0) {
|
|
7588
|
+
clearTimeout(this.#timer);
|
|
7589
|
+
this.#timer = void 0;
|
|
7590
|
+
} else if (visible && this.#timer === void 0) {
|
|
7591
|
+
this.#timer = setTimeout(() => {
|
|
7044
7592
|
this.view.dispatch({
|
|
7045
|
-
effects:
|
|
7046
|
-
from: fromB,
|
|
7047
|
-
to: toB
|
|
7048
|
-
})
|
|
7593
|
+
effects: hideCursor.of(null)
|
|
7049
7594
|
});
|
|
7050
|
-
this
|
|
7051
|
-
},
|
|
7052
|
-
|
|
7053
|
-
});
|
|
7595
|
+
this.#timer = void 0;
|
|
7596
|
+
}, CURSOR_LINGER);
|
|
7597
|
+
}
|
|
7054
7598
|
}
|
|
7055
7599
|
destroy() {
|
|
7056
|
-
|
|
7057
|
-
clearTimeout(id);
|
|
7058
|
-
}
|
|
7059
|
-
this._timers.clear();
|
|
7600
|
+
clearTimeout(this.#timer);
|
|
7060
7601
|
}
|
|
7061
7602
|
});
|
|
7062
7603
|
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
|
-
})
|
|
7604
|
+
visibilityField,
|
|
7605
|
+
decorationField,
|
|
7606
|
+
timerPlugin
|
|
7084
7607
|
];
|
|
7085
7608
|
};
|
|
7609
|
+
var CursorWidget = class extends WidgetType9 {
|
|
7610
|
+
toDOM() {
|
|
7611
|
+
const inner = Domino3.of("span").text("\u2217").style({
|
|
7612
|
+
animation: "blink 1s infinite",
|
|
7613
|
+
animationDelay: "250ms"
|
|
7614
|
+
});
|
|
7615
|
+
return Domino3.of("span").style({
|
|
7616
|
+
opacity: "0.8"
|
|
7617
|
+
}).append(inner).root;
|
|
7618
|
+
}
|
|
7619
|
+
};
|
|
7620
|
+
var OPENING_TAG_NAME = /^<([a-zA-Z][\w-]*)/;
|
|
7621
|
+
var escapeRegExpSource2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7622
|
+
var flushable = (buffer, streamingTags, activeStreamTag) => {
|
|
7623
|
+
if (buffer.length === 0) {
|
|
7624
|
+
return {
|
|
7625
|
+
count: 0
|
|
7626
|
+
};
|
|
7627
|
+
}
|
|
7628
|
+
if (activeStreamTag) {
|
|
7629
|
+
const closeTag = `</${activeStreamTag}>`;
|
|
7630
|
+
if (buffer.startsWith(closeTag)) {
|
|
7631
|
+
return {
|
|
7632
|
+
count: closeTag.length,
|
|
7633
|
+
exitTag: true
|
|
7634
|
+
};
|
|
7635
|
+
}
|
|
7636
|
+
if (buffer[0] === "<") {
|
|
7637
|
+
return {
|
|
7638
|
+
count: xmlElementLength(buffer)
|
|
7639
|
+
};
|
|
7640
|
+
}
|
|
7641
|
+
return {
|
|
7642
|
+
count: 1
|
|
7643
|
+
};
|
|
7644
|
+
}
|
|
7645
|
+
const ch = buffer[0];
|
|
7646
|
+
if (ch === "<") {
|
|
7647
|
+
const nameMatch = buffer.match(OPENING_TAG_NAME);
|
|
7648
|
+
if (nameMatch && streamingTags.has(nameMatch[1])) {
|
|
7649
|
+
const close = buffer.indexOf(">");
|
|
7650
|
+
if (close === -1) {
|
|
7651
|
+
return {
|
|
7652
|
+
count: 0
|
|
7653
|
+
};
|
|
7654
|
+
}
|
|
7655
|
+
if (buffer[close - 1] === "/") {
|
|
7656
|
+
return {
|
|
7657
|
+
count: close + 1
|
|
7658
|
+
};
|
|
7659
|
+
}
|
|
7660
|
+
return {
|
|
7661
|
+
count: close + 1,
|
|
7662
|
+
enterTag: nameMatch[1]
|
|
7663
|
+
};
|
|
7664
|
+
}
|
|
7665
|
+
return {
|
|
7666
|
+
count: xmlElementLength(buffer)
|
|
7667
|
+
};
|
|
7668
|
+
}
|
|
7669
|
+
if (ch === "!" && buffer.length > 1 && buffer[1] === "[") {
|
|
7670
|
+
return {
|
|
7671
|
+
count: linkLength(buffer, 1)
|
|
7672
|
+
};
|
|
7673
|
+
}
|
|
7674
|
+
if (ch === "[") {
|
|
7675
|
+
return {
|
|
7676
|
+
count: linkLength(buffer, 0)
|
|
7677
|
+
};
|
|
7678
|
+
}
|
|
7679
|
+
return {
|
|
7680
|
+
count: 1
|
|
7681
|
+
};
|
|
7682
|
+
};
|
|
7683
|
+
var xmlElementLength = (buffer) => {
|
|
7684
|
+
const close = buffer.indexOf(">");
|
|
7685
|
+
if (close === -1) {
|
|
7686
|
+
return 0;
|
|
7687
|
+
}
|
|
7688
|
+
if (buffer[close - 1] === "/") {
|
|
7689
|
+
return close + 1;
|
|
7690
|
+
}
|
|
7691
|
+
if (buffer[1] === "/") {
|
|
7692
|
+
return close + 1;
|
|
7693
|
+
}
|
|
7694
|
+
const nameMatch = buffer.match(OPENING_TAG_NAME);
|
|
7695
|
+
if (!nameMatch) {
|
|
7696
|
+
return 1;
|
|
7697
|
+
}
|
|
7698
|
+
const tagName = nameMatch[1];
|
|
7699
|
+
let depth = 0;
|
|
7700
|
+
const tagPattern = new RegExp(`<(/?)${escapeRegExpSource2(tagName)}(\\s[^>]*)?>`, "g");
|
|
7701
|
+
let match;
|
|
7702
|
+
while ((match = tagPattern.exec(buffer)) !== null) {
|
|
7703
|
+
const isSelfClosing = match[0].endsWith("/>");
|
|
7704
|
+
const isClosing = match[1] === "/";
|
|
7705
|
+
if (isSelfClosing) {
|
|
7706
|
+
if (depth === 0) {
|
|
7707
|
+
return match.index + match[0].length;
|
|
7708
|
+
}
|
|
7709
|
+
} else if (isClosing) {
|
|
7710
|
+
depth--;
|
|
7711
|
+
if (depth === 0) {
|
|
7712
|
+
return match.index + match[0].length;
|
|
7713
|
+
}
|
|
7714
|
+
} else {
|
|
7715
|
+
depth++;
|
|
7716
|
+
}
|
|
7717
|
+
}
|
|
7718
|
+
return 0;
|
|
7719
|
+
};
|
|
7720
|
+
var linkLength = (buffer, offset) => {
|
|
7721
|
+
const bracketClose = buffer.indexOf("]", offset + 1);
|
|
7722
|
+
if (bracketClose === -1) {
|
|
7723
|
+
return 0;
|
|
7724
|
+
}
|
|
7725
|
+
if (bracketClose + 1 >= buffer.length) {
|
|
7726
|
+
return 0;
|
|
7727
|
+
}
|
|
7728
|
+
if (buffer[bracketClose + 1] !== "(") {
|
|
7729
|
+
return 1;
|
|
7730
|
+
}
|
|
7731
|
+
const parenClose = buffer.indexOf(")", bracketClose + 2);
|
|
7732
|
+
if (parenClose === -1) {
|
|
7733
|
+
return 0;
|
|
7734
|
+
}
|
|
7735
|
+
return parenClose + 1;
|
|
7736
|
+
};
|
|
7086
7737
|
|
|
7087
7738
|
// src/extensions/tags/xml-tags.ts
|
|
7088
7739
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7089
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7090
|
-
import { Decoration as
|
|
7740
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect12, StateField as StateField14 } from "@codemirror/state";
|
|
7741
|
+
import { Decoration as Decoration16, EditorView as EditorView31, ViewPlugin as ViewPlugin22, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7091
7742
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7092
|
-
import { log as
|
|
7743
|
+
import { log as log11 } from "@dxos/log";
|
|
7744
|
+
import { Domino as Domino4 } from "@dxos/ui";
|
|
7093
7745
|
|
|
7094
7746
|
// src/extensions/tags/xml-util.ts
|
|
7095
7747
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
7096
|
-
var
|
|
7748
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-util.ts";
|
|
7097
7749
|
var nodeToJson = (state, node) => {
|
|
7098
7750
|
invariant6(node.type.name === "Element", "Node is not an Element", {
|
|
7099
|
-
F:
|
|
7751
|
+
F: __dxlog_file16,
|
|
7100
7752
|
L: 18,
|
|
7101
7753
|
S: void 0,
|
|
7102
7754
|
A: [
|
|
@@ -7160,17 +7812,19 @@ var nodeToJson = (state, node) => {
|
|
|
7160
7812
|
};
|
|
7161
7813
|
|
|
7162
7814
|
// src/extensions/tags/xml-tags.ts
|
|
7163
|
-
var
|
|
7164
|
-
var navigatePreviousEffect =
|
|
7165
|
-
var navigateNextEffect =
|
|
7815
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7816
|
+
var navigatePreviousEffect = StateEffect12.define();
|
|
7817
|
+
var navigateNextEffect = StateEffect12.define();
|
|
7166
7818
|
var getXmlTextChild = (children) => {
|
|
7167
7819
|
const child = children?.[0];
|
|
7168
7820
|
return typeof child === "string" ? child : null;
|
|
7169
7821
|
};
|
|
7170
|
-
var
|
|
7171
|
-
var
|
|
7172
|
-
var
|
|
7173
|
-
var
|
|
7822
|
+
var xmlWidgetId = (explicit, fallback) => typeof explicit === "string" && explicit.length > 0 ? explicit : fallback;
|
|
7823
|
+
var escapeRegExpSource3 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7824
|
+
var xmlTagContextEffect = StateEffect12.define();
|
|
7825
|
+
var xmlTagResetEffect = StateEffect12.define();
|
|
7826
|
+
var xmlTagUpdateEffect = StateEffect12.define();
|
|
7827
|
+
var widgetContextStateField = StateField14.define({
|
|
7174
7828
|
create: () => void 0,
|
|
7175
7829
|
update: (value, tr) => {
|
|
7176
7830
|
for (const effect of tr.effects) {
|
|
@@ -7181,7 +7835,7 @@ var widgetContextStateField = StateField13.define({
|
|
|
7181
7835
|
return value;
|
|
7182
7836
|
}
|
|
7183
7837
|
});
|
|
7184
|
-
var widgetStateMapStateField =
|
|
7838
|
+
var widgetStateMapStateField = StateField14.define({
|
|
7185
7839
|
create: () => ({}),
|
|
7186
7840
|
update: (map, tr) => {
|
|
7187
7841
|
for (const effect of tr.effects) {
|
|
@@ -7190,12 +7844,12 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7190
7844
|
}
|
|
7191
7845
|
if (effect.is(xmlTagUpdateEffect)) {
|
|
7192
7846
|
const { id, value } = effect.value;
|
|
7193
|
-
|
|
7847
|
+
log11("widget updated", {
|
|
7194
7848
|
id,
|
|
7195
7849
|
value
|
|
7196
7850
|
}, {
|
|
7197
|
-
F:
|
|
7198
|
-
L:
|
|
7851
|
+
F: __dxlog_file17,
|
|
7852
|
+
L: 184,
|
|
7199
7853
|
S: void 0,
|
|
7200
7854
|
C: (f, a) => f(...a)
|
|
7201
7855
|
});
|
|
@@ -7209,28 +7863,37 @@ var widgetStateMapStateField = StateField13.define({
|
|
|
7209
7863
|
return map;
|
|
7210
7864
|
}
|
|
7211
7865
|
});
|
|
7212
|
-
var
|
|
7866
|
+
var XML_WIDGET_DATA_ATTR = "data-xml-widget";
|
|
7867
|
+
var xmlTags = ({ registry, setWidgets, bookmarks: bookmarks2, paragraphToWidgetGapRem } = {}) => {
|
|
7213
7868
|
const notifier = createWidgetMap(setWidgets);
|
|
7214
7869
|
const widgetDecorationsField = createWidgetDecorationsField(registry, notifier);
|
|
7870
|
+
const paragraphGapTheme = paragraphToWidgetGapRem != null && paragraphToWidgetGapRem > 0 ? EditorView31.baseTheme({
|
|
7871
|
+
[`& .cm-content > .cm-line:not(:has([${XML_WIDGET_DATA_ATTR}])) + .cm-line:has([${XML_WIDGET_DATA_ATTR}])`]: {
|
|
7872
|
+
marginTop: `${paragraphToWidgetGapRem}rem`
|
|
7873
|
+
}
|
|
7874
|
+
}) : null;
|
|
7215
7875
|
return [
|
|
7216
7876
|
widgetContextStateField,
|
|
7217
7877
|
widgetStateMapStateField,
|
|
7218
7878
|
widgetDecorationsField,
|
|
7219
7879
|
createWidgetUpdatePlugin(widgetDecorationsField, notifier),
|
|
7220
7880
|
createNavigationEffectPlugin(widgetDecorationsField, bookmarks2),
|
|
7221
|
-
bookmarks2?.length ? Prec7.highest(keyHandlers) : []
|
|
7881
|
+
bookmarks2?.length ? Prec7.highest(keyHandlers) : [],
|
|
7882
|
+
...paragraphGapTheme ? [
|
|
7883
|
+
paragraphGapTheme
|
|
7884
|
+
] : []
|
|
7222
7885
|
];
|
|
7223
7886
|
};
|
|
7224
7887
|
var createWidgetMap = (setWidgets) => {
|
|
7225
7888
|
const widgets = /* @__PURE__ */ new Map();
|
|
7226
7889
|
const notifier = {
|
|
7227
7890
|
mounted: (state) => {
|
|
7228
|
-
|
|
7891
|
+
log11("widget mounted", {
|
|
7229
7892
|
id: state.id,
|
|
7230
7893
|
tag: state.props._tag
|
|
7231
7894
|
}, {
|
|
7232
|
-
F:
|
|
7233
|
-
L:
|
|
7895
|
+
F: __dxlog_file17,
|
|
7896
|
+
L: 261,
|
|
7234
7897
|
S: void 0,
|
|
7235
7898
|
C: (f, a) => f(...a)
|
|
7236
7899
|
});
|
|
@@ -7241,12 +7904,12 @@ var createWidgetMap = (setWidgets) => {
|
|
|
7241
7904
|
},
|
|
7242
7905
|
unmounted: (id) => {
|
|
7243
7906
|
const state = widgets.get(id);
|
|
7244
|
-
|
|
7907
|
+
log11("widget unmounted", {
|
|
7245
7908
|
id,
|
|
7246
7909
|
tag: state?.props._tag
|
|
7247
7910
|
}, {
|
|
7248
|
-
F:
|
|
7249
|
-
L:
|
|
7911
|
+
F: __dxlog_file17,
|
|
7912
|
+
L: 267,
|
|
7250
7913
|
S: void 0,
|
|
7251
7914
|
C: (f, a) => f(...a)
|
|
7252
7915
|
});
|
|
@@ -7279,7 +7942,7 @@ var keyHandlers = keymap13.of([
|
|
|
7279
7942
|
}
|
|
7280
7943
|
]);
|
|
7281
7944
|
var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
7282
|
-
return
|
|
7945
|
+
return EditorView31.updateListener.of((update2) => {
|
|
7283
7946
|
update2.transactions.forEach((transaction) => {
|
|
7284
7947
|
for (const effect of transaction.effects) {
|
|
7285
7948
|
if (effect.is(navigatePreviousEffect)) {
|
|
@@ -7307,11 +7970,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7307
7970
|
anchor: line.from,
|
|
7308
7971
|
head: line.from
|
|
7309
7972
|
},
|
|
7310
|
-
effects:
|
|
7311
|
-
line: line.number,
|
|
7312
|
-
|
|
7313
|
-
offset: -16
|
|
7314
|
-
}
|
|
7973
|
+
effects: scrollerLineEffect.of({
|
|
7974
|
+
line: line.number - 1,
|
|
7975
|
+
offset: -16
|
|
7315
7976
|
})
|
|
7316
7977
|
});
|
|
7317
7978
|
continue;
|
|
@@ -7342,11 +8003,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7342
8003
|
anchor: line.to,
|
|
7343
8004
|
head: line.to
|
|
7344
8005
|
},
|
|
7345
|
-
effects:
|
|
7346
|
-
line: line.number,
|
|
7347
|
-
|
|
7348
|
-
offset: -16
|
|
7349
|
-
}
|
|
8006
|
+
effects: scrollerLineEffect.of({
|
|
8007
|
+
line: line.number - 1,
|
|
8008
|
+
offset: -16
|
|
7350
8009
|
})
|
|
7351
8010
|
});
|
|
7352
8011
|
} else {
|
|
@@ -7356,11 +8015,9 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7356
8015
|
anchor: line.to,
|
|
7357
8016
|
head: line.to
|
|
7358
8017
|
},
|
|
7359
|
-
effects:
|
|
7360
|
-
line: line.number,
|
|
7361
|
-
|
|
7362
|
-
position: "end"
|
|
7363
|
-
}
|
|
8018
|
+
effects: scrollerLineEffect.of({
|
|
8019
|
+
line: line.number - 1,
|
|
8020
|
+
position: "end"
|
|
7364
8021
|
})
|
|
7365
8022
|
});
|
|
7366
8023
|
}
|
|
@@ -7370,7 +8027,7 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7370
8027
|
});
|
|
7371
8028
|
});
|
|
7372
8029
|
};
|
|
7373
|
-
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) =>
|
|
8030
|
+
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin22.fromClass(class {
|
|
7374
8031
|
update(update2) {
|
|
7375
8032
|
const widgetStateMap = update2.state.field(widgetStateMapStateField);
|
|
7376
8033
|
const { decorations: decorations2 } = update2.state.field(widgetDecorationsField);
|
|
@@ -7397,19 +8054,25 @@ var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin1
|
|
|
7397
8054
|
}
|
|
7398
8055
|
}
|
|
7399
8056
|
});
|
|
7400
|
-
var createWidgetDecorationsField = (registry = {}, notifier) =>
|
|
8057
|
+
var createWidgetDecorationsField = (registry = {}, notifier) => StateField14.define({
|
|
7401
8058
|
create: (state) => {
|
|
7402
8059
|
return buildDecorations4(state, {
|
|
7403
8060
|
from: 0,
|
|
7404
8061
|
to: state.doc.length
|
|
7405
8062
|
}, registry, notifier);
|
|
7406
8063
|
},
|
|
7407
|
-
update: ({ from, decorations: decorations2 }, tr) => {
|
|
8064
|
+
update: ({ from, streamingFrom, decorations: decorations2 }, tr) => {
|
|
7408
8065
|
for (const effect of tr.effects) {
|
|
7409
8066
|
if (effect.is(xmlTagResetEffect)) {
|
|
8067
|
+
if (tr.docChanged) {
|
|
8068
|
+
return buildDecorations4(tr.state, {
|
|
8069
|
+
from: 0,
|
|
8070
|
+
to: tr.state.doc.length
|
|
8071
|
+
}, registry, notifier);
|
|
8072
|
+
}
|
|
7410
8073
|
return {
|
|
7411
8074
|
from: 0,
|
|
7412
|
-
decorations:
|
|
8075
|
+
decorations: Decoration16.none
|
|
7413
8076
|
};
|
|
7414
8077
|
}
|
|
7415
8078
|
}
|
|
@@ -7417,12 +8080,12 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7417
8080
|
const { state } = tr;
|
|
7418
8081
|
const reset = tr.changes.touchesRange(0, from);
|
|
7419
8082
|
if (reset) {
|
|
7420
|
-
|
|
8083
|
+
log11("document reset", {
|
|
7421
8084
|
from,
|
|
7422
8085
|
to: state.doc.length
|
|
7423
8086
|
}, {
|
|
7424
|
-
F:
|
|
7425
|
-
L:
|
|
8087
|
+
F: __dxlog_file17,
|
|
8088
|
+
L: 429,
|
|
7426
8089
|
S: void 0,
|
|
7427
8090
|
C: (f, a) => f(...a)
|
|
7428
8091
|
});
|
|
@@ -7431,13 +8094,17 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7431
8094
|
to: state.doc.length
|
|
7432
8095
|
}, registry, notifier);
|
|
7433
8096
|
} else {
|
|
8097
|
+
const rebuildFrom = streamingFrom ?? from;
|
|
7434
8098
|
const result = buildDecorations4(state, {
|
|
7435
|
-
from,
|
|
8099
|
+
from: rebuildFrom,
|
|
7436
8100
|
to: state.doc.length
|
|
7437
8101
|
}, registry, notifier);
|
|
7438
8102
|
return {
|
|
7439
8103
|
from: result.from,
|
|
8104
|
+
streamingFrom: result.streamingFrom,
|
|
7440
8105
|
decorations: decorations2.update({
|
|
8106
|
+
// Remove old streaming decorations — they are rebuilt each tick.
|
|
8107
|
+
filter: (_f, _t, deco) => !deco.spec.streaming,
|
|
7441
8108
|
add: decorationSetToArray(result.decorations)
|
|
7442
8109
|
})
|
|
7443
8110
|
};
|
|
@@ -7445,12 +8112,13 @@ var createWidgetDecorationsField = (registry = {}, notifier) => StateField13.def
|
|
|
7445
8112
|
}
|
|
7446
8113
|
return {
|
|
7447
8114
|
from,
|
|
8115
|
+
streamingFrom,
|
|
7448
8116
|
decorations: decorations2
|
|
7449
8117
|
};
|
|
7450
8118
|
},
|
|
7451
8119
|
provide: (field) => [
|
|
7452
|
-
|
|
7453
|
-
|
|
8120
|
+
EditorView31.decorations.from(field, (v) => v.decorations),
|
|
8121
|
+
EditorView31.atomicRanges.of((view) => view.state.field(field).decorations || Decoration16.none)
|
|
7454
8122
|
]
|
|
7455
8123
|
});
|
|
7456
8124
|
var buildDecorations4 = (state, range, registry, notifier) => {
|
|
@@ -7461,10 +8129,11 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7461
8129
|
if (!tree || tree.type.name === "Program" && tree.length === 0) {
|
|
7462
8130
|
return {
|
|
7463
8131
|
from: range.from,
|
|
7464
|
-
decorations:
|
|
8132
|
+
decorations: Decoration16.none
|
|
7465
8133
|
};
|
|
7466
8134
|
}
|
|
7467
8135
|
let last = range.from;
|
|
8136
|
+
let streamingFrom;
|
|
7468
8137
|
tree.iterate({
|
|
7469
8138
|
from: range.from,
|
|
7470
8139
|
to: range.to,
|
|
@@ -7477,21 +8146,26 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7477
8146
|
if (args) {
|
|
7478
8147
|
const def = registry[args._tag];
|
|
7479
8148
|
if (def) {
|
|
8149
|
+
if (def.streaming && !node.node.getChild("CloseTag")) {
|
|
8150
|
+
return false;
|
|
8151
|
+
}
|
|
7480
8152
|
const { block, factory, Component } = def;
|
|
7481
|
-
const widgetState = args.id ? widgetStateMap[args.id] : void 0;
|
|
7482
8153
|
const nodeRange = {
|
|
7483
8154
|
from: node.node.from,
|
|
7484
8155
|
to: node.node.to
|
|
7485
8156
|
};
|
|
8157
|
+
const widgetId = xmlWidgetId(args.id, def.streaming ? `cm-xml-${nodeRange.from}` : `cm-xml-${nodeRange.from}-${nodeRange.to}`);
|
|
8158
|
+
const widgetState = widgetStateMap[widgetId];
|
|
7486
8159
|
const props = {
|
|
7487
|
-
|
|
8160
|
+
id: widgetId,
|
|
7488
8161
|
range: nodeRange,
|
|
8162
|
+
context,
|
|
7489
8163
|
...args,
|
|
7490
8164
|
...widgetState
|
|
7491
8165
|
};
|
|
7492
|
-
const widget = factory ? factory(props) : Component ?
|
|
8166
|
+
const widget = factory ? factory(props) ?? void 0 : Component ? new PlaceholderWidget2(widgetId, Component, props, notifier) : void 0;
|
|
7493
8167
|
if (widget) {
|
|
7494
|
-
builder.add(nodeRange.from, nodeRange.to,
|
|
8168
|
+
builder.add(nodeRange.from, nodeRange.to, Decoration16.replace({
|
|
7495
8169
|
widget,
|
|
7496
8170
|
block,
|
|
7497
8171
|
atomic: true,
|
|
@@ -7503,9 +8177,9 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7503
8177
|
}
|
|
7504
8178
|
}
|
|
7505
8179
|
} catch (err) {
|
|
7506
|
-
|
|
7507
|
-
F:
|
|
7508
|
-
L:
|
|
8180
|
+
log11.catch(err, void 0, {
|
|
8181
|
+
F: __dxlog_file17,
|
|
8182
|
+
L: 538,
|
|
7509
8183
|
S: void 0,
|
|
7510
8184
|
C: (f, a) => f(...a)
|
|
7511
8185
|
});
|
|
@@ -7515,8 +8189,65 @@ var buildDecorations4 = (state, range, registry, notifier) => {
|
|
|
7515
8189
|
}
|
|
7516
8190
|
}
|
|
7517
8191
|
});
|
|
8192
|
+
const streamingTagNames = Object.entries(registry).filter(([, def]) => def.streaming).map(([name]) => name).sort((a, b) => b.length - a.length);
|
|
8193
|
+
if (streamingTagNames.length > 0) {
|
|
8194
|
+
const tailText = state.sliceDoc(range.from, range.to);
|
|
8195
|
+
const streamingPattern = streamingTagNames.map(escapeRegExpSource3).join("|");
|
|
8196
|
+
const tagPattern = new RegExp(`<(${streamingPattern})(\\s[^>]*)?>`, "g");
|
|
8197
|
+
let match;
|
|
8198
|
+
while ((match = tagPattern.exec(tailText)) !== null) {
|
|
8199
|
+
const tagName = match[1];
|
|
8200
|
+
const closeTag = `</${tagName}>`;
|
|
8201
|
+
const afterOpen = match.index + match[0].length;
|
|
8202
|
+
if (tailText.indexOf(closeTag, afterOpen) === -1) {
|
|
8203
|
+
const absoluteFrom = range.from + match.index;
|
|
8204
|
+
const contentFrom = range.from + afterOpen;
|
|
8205
|
+
const innerText = state.sliceDoc(contentFrom, range.to).trim();
|
|
8206
|
+
const def = registry[tagName];
|
|
8207
|
+
const props = {
|
|
8208
|
+
_tag: tagName,
|
|
8209
|
+
context,
|
|
8210
|
+
range: {
|
|
8211
|
+
from: absoluteFrom,
|
|
8212
|
+
to: range.to
|
|
8213
|
+
},
|
|
8214
|
+
children: innerText ? [
|
|
8215
|
+
innerText
|
|
8216
|
+
] : void 0
|
|
8217
|
+
};
|
|
8218
|
+
const attrPattern = /(\w+)="([^"]*)"/g;
|
|
8219
|
+
let attrMatch;
|
|
8220
|
+
while ((attrMatch = attrPattern.exec(match[0])) !== null) {
|
|
8221
|
+
props[attrMatch[1]] = attrMatch[2];
|
|
8222
|
+
}
|
|
8223
|
+
const widgetId = xmlWidgetId(props.id, `cm-xml-${absoluteFrom}`);
|
|
8224
|
+
const widgetState = widgetStateMap[widgetId];
|
|
8225
|
+
const mergedProps = {
|
|
8226
|
+
...props,
|
|
8227
|
+
id: widgetId,
|
|
8228
|
+
...widgetState
|
|
8229
|
+
};
|
|
8230
|
+
const widget = def.factory ? def.factory(mergedProps) ?? void 0 : def.Component ? new PlaceholderWidget2(widgetId, def.Component, mergedProps, notifier, true) : void 0;
|
|
8231
|
+
if (widget) {
|
|
8232
|
+
builder.add(absoluteFrom, range.to, Decoration16.replace({
|
|
8233
|
+
widget,
|
|
8234
|
+
block: def.block,
|
|
8235
|
+
atomic: true,
|
|
8236
|
+
inclusive: true,
|
|
8237
|
+
tag: tagName,
|
|
8238
|
+
streaming: true,
|
|
8239
|
+
contentFrom
|
|
8240
|
+
}));
|
|
8241
|
+
streamingFrom = absoluteFrom;
|
|
8242
|
+
last = absoluteFrom;
|
|
8243
|
+
}
|
|
8244
|
+
break;
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
7518
8248
|
return {
|
|
7519
8249
|
from: last,
|
|
8250
|
+
streamingFrom,
|
|
7520
8251
|
decorations: builder.finish()
|
|
7521
8252
|
};
|
|
7522
8253
|
};
|
|
@@ -7525,12 +8256,14 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7525
8256
|
Component;
|
|
7526
8257
|
props;
|
|
7527
8258
|
notifier;
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
8259
|
+
streaming;
|
|
8260
|
+
#root = null;
|
|
8261
|
+
#view;
|
|
8262
|
+
constructor(id, Component, props, notifier, streaming) {
|
|
8263
|
+
super(), this.id = id, this.Component = Component, this.props = props, this.notifier = notifier, this.streaming = streaming;
|
|
7531
8264
|
invariant7(id, void 0, {
|
|
7532
|
-
F:
|
|
7533
|
-
L:
|
|
8265
|
+
F: __dxlog_file17,
|
|
8266
|
+
L: 641,
|
|
7534
8267
|
S: this,
|
|
7535
8268
|
A: [
|
|
7536
8269
|
"id",
|
|
@@ -7539,27 +8272,50 @@ var PlaceholderWidget2 = class extends WidgetType10 {
|
|
|
7539
8272
|
});
|
|
7540
8273
|
}
|
|
7541
8274
|
get root() {
|
|
7542
|
-
return this
|
|
8275
|
+
return this.#root;
|
|
7543
8276
|
}
|
|
7544
8277
|
eq(other) {
|
|
8278
|
+
if (this.streaming) {
|
|
8279
|
+
return false;
|
|
8280
|
+
}
|
|
7545
8281
|
return this.id === other.id;
|
|
7546
8282
|
}
|
|
7547
8283
|
ignoreEvent() {
|
|
7548
8284
|
return true;
|
|
7549
8285
|
}
|
|
7550
|
-
toDOM(
|
|
7551
|
-
this
|
|
8286
|
+
toDOM(view) {
|
|
8287
|
+
this.#view = view;
|
|
8288
|
+
this.#root = Domino4.of("div").classNames("min-h-[24px]").attributes({
|
|
8289
|
+
[XML_WIDGET_DATA_ATTR]: ""
|
|
8290
|
+
}).root;
|
|
8291
|
+
const props = Object.assign({}, this.props, {
|
|
8292
|
+
view
|
|
8293
|
+
});
|
|
7552
8294
|
this.notifier.mounted({
|
|
7553
8295
|
id: this.id,
|
|
7554
|
-
root: this
|
|
7555
|
-
props
|
|
8296
|
+
root: this.#root,
|
|
8297
|
+
props,
|
|
7556
8298
|
Component: this.Component
|
|
7557
8299
|
});
|
|
7558
|
-
return this
|
|
8300
|
+
return this.#root;
|
|
8301
|
+
}
|
|
8302
|
+
updateDOM(dom) {
|
|
8303
|
+
this.#root = dom;
|
|
8304
|
+
const props = Object.assign({}, this.props, {
|
|
8305
|
+
view: this.#view
|
|
8306
|
+
});
|
|
8307
|
+
this.notifier.mounted({
|
|
8308
|
+
id: this.id,
|
|
8309
|
+
root: this.#root,
|
|
8310
|
+
props,
|
|
8311
|
+
Component: this.Component
|
|
8312
|
+
});
|
|
8313
|
+
return true;
|
|
7559
8314
|
}
|
|
7560
8315
|
destroy(_dom) {
|
|
7561
8316
|
this.notifier.unmounted(this.id);
|
|
7562
|
-
this
|
|
8317
|
+
this.#root = null;
|
|
8318
|
+
this.#view = void 0;
|
|
7563
8319
|
}
|
|
7564
8320
|
};
|
|
7565
8321
|
|
|
@@ -7623,8 +8379,8 @@ export {
|
|
|
7623
8379
|
Cursor,
|
|
7624
8380
|
EditorInputMode,
|
|
7625
8381
|
EditorInputModes,
|
|
7626
|
-
|
|
7627
|
-
|
|
8382
|
+
EditorState4 as EditorState,
|
|
8383
|
+
EditorView32 as EditorView,
|
|
7628
8384
|
EditorViewMode,
|
|
7629
8385
|
EditorViewModes,
|
|
7630
8386
|
Inline,
|
|
@@ -7635,6 +8391,7 @@ export {
|
|
|
7635
8391
|
SpaceAwarenessProvider,
|
|
7636
8392
|
TextKind,
|
|
7637
8393
|
Tree,
|
|
8394
|
+
XML_WIDGET_DATA_ATTR,
|
|
7638
8395
|
addBlockquote,
|
|
7639
8396
|
addBookmark,
|
|
7640
8397
|
addCodeblock,
|
|
@@ -7643,6 +8400,7 @@ export {
|
|
|
7643
8400
|
addStyle,
|
|
7644
8401
|
annotations,
|
|
7645
8402
|
autoScroll,
|
|
8403
|
+
autoScrollEffect,
|
|
7646
8404
|
autocomplete,
|
|
7647
8405
|
automerge,
|
|
7648
8406
|
awareness,
|
|
@@ -7656,9 +8414,11 @@ export {
|
|
|
7656
8414
|
commentClickedEffect,
|
|
7657
8415
|
comments,
|
|
7658
8416
|
commentsState,
|
|
8417
|
+
compactSlots,
|
|
7659
8418
|
convertTreeToJson,
|
|
7660
8419
|
createBasicExtensions,
|
|
7661
8420
|
createComment,
|
|
8421
|
+
createCrawler,
|
|
7662
8422
|
createDataExtensions,
|
|
7663
8423
|
createEditorStateStore,
|
|
7664
8424
|
createEditorStateTransaction,
|
|
@@ -7678,12 +8438,12 @@ export {
|
|
|
7678
8438
|
defaultThemeSlots,
|
|
7679
8439
|
deleteItem,
|
|
7680
8440
|
documentId,
|
|
8441
|
+
documentSlots,
|
|
7681
8442
|
dropFile,
|
|
8443
|
+
editorClassNames,
|
|
7682
8444
|
editorInputMode,
|
|
7683
|
-
editorSlots,
|
|
7684
|
-
editorWidth,
|
|
7685
|
-
editorWithToolbarLayout,
|
|
7686
8445
|
extendedMarkdown,
|
|
8446
|
+
fader,
|
|
7687
8447
|
filterChars,
|
|
7688
8448
|
flattenRect,
|
|
7689
8449
|
focus,
|
|
@@ -7738,10 +8498,12 @@ export {
|
|
|
7738
8498
|
removeList,
|
|
7739
8499
|
removeStyle,
|
|
7740
8500
|
replacer,
|
|
8501
|
+
scrollPastEnd,
|
|
7741
8502
|
scrollThreadIntoView,
|
|
7742
|
-
scrollToBottomEffect,
|
|
7743
8503
|
scrollToLine,
|
|
7744
|
-
|
|
8504
|
+
scroller,
|
|
8505
|
+
scrollerCrawlEffect,
|
|
8506
|
+
scrollerLineEffect,
|
|
7745
8507
|
selectionState,
|
|
7746
8508
|
setBlockquote,
|
|
7747
8509
|
setComments,
|
|
@@ -7749,10 +8511,7 @@ export {
|
|
|
7749
8511
|
setSelection,
|
|
7750
8512
|
setStyle,
|
|
7751
8513
|
singleValueFacet,
|
|
7752
|
-
smoothScroll,
|
|
7753
|
-
stackItemContentEditorClassNames,
|
|
7754
8514
|
staticCompletion,
|
|
7755
|
-
streamer,
|
|
7756
8515
|
submit,
|
|
7757
8516
|
tabbable,
|
|
7758
8517
|
table,
|
|
@@ -7771,7 +8530,10 @@ export {
|
|
|
7771
8530
|
treeFacet,
|
|
7772
8531
|
typeahead,
|
|
7773
8532
|
typewriter,
|
|
8533
|
+
wire,
|
|
8534
|
+
wireBypass,
|
|
7774
8535
|
wrapWithCatch,
|
|
8536
|
+
xmlElementLength,
|
|
7775
8537
|
xmlTagContextEffect,
|
|
7776
8538
|
xmlTagResetEffect,
|
|
7777
8539
|
xmlTagUpdateEffect,
|