@dxos/ui-editor 0.8.4-main.6fa680abb7 → 0.8.4-main.7996785055
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 +154 -96
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +154 -96
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/defaults.d.ts +2 -9
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts.map +1 -1
- package/dist/types/src/extensions/folding.d.ts.map +1 -1
- 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/styles.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +2 -0
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/scroller.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/streamer.d.ts +1 -1
- package/dist/types/src/styles/theme.d.ts +2 -2
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -27
- package/src/defaults.ts +13 -15
- package/src/extensions/auto-scroll.ts +4 -1
- package/src/extensions/folding.ts +1 -18
- package/src/extensions/markdown/bundle.ts +19 -8
- package/src/extensions/markdown/decorate.ts +11 -8
- package/src/extensions/markdown/highlight.ts +4 -10
- package/src/extensions/markdown/parser.test.ts +0 -1
- package/src/extensions/markdown/styles.ts +21 -3
- package/src/extensions/preview/preview.ts +54 -7
- package/src/extensions/scroller.ts +2 -1
- package/src/extensions/tags/streamer.ts +1 -1
- package/src/styles/theme.ts +28 -23
|
@@ -13,16 +13,22 @@ import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
|
|
|
13
13
|
|
|
14
14
|
// src/defaults.ts
|
|
15
15
|
import { mx } from "@dxos/ui-theme";
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
var documentSlots = {
|
|
17
|
+
content: {
|
|
18
|
+
/**
|
|
19
|
+
* CodeMirror content width.
|
|
20
|
+
* 40rem = 640px. Corresponds to initial plank width (Google docs, Stashpad, etc.)
|
|
21
|
+
* 50rem = 800px. Maximum content width for solo mode.
|
|
22
|
+
* NOTE: Max width - 4rem = 2rem left/right margin (or 2rem gutter plus 1rem left/right margin).
|
|
23
|
+
*/
|
|
24
|
+
className: "mx-auto! w-full pointer-fine:max-w-[min(50rem,100%-4rem)] pointer-coarse:max-w-[min(50rem,100%-2rem)]"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var compactSlots = {
|
|
21
28
|
content: {
|
|
22
|
-
className:
|
|
29
|
+
className: "mx-2! w-full"
|
|
23
30
|
}
|
|
24
31
|
};
|
|
25
|
-
var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
|
|
26
32
|
var stackItemContentEditorClassNames = (role) => mx("dx-attention-surface p-0.5 dx-focus-ring-inset data-[toolbar=disabled]:pt-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-h-24" : "dx-container overflow-hidden");
|
|
27
33
|
|
|
28
34
|
// src/extensions/annotations.ts
|
|
@@ -561,8 +567,7 @@ var scroller = ({ overScroll = 0 } = {}) => {
|
|
|
561
567
|
}
|
|
562
568
|
requestAnimationFrame(() => {
|
|
563
569
|
this.view.scrollDOM.scrollTo({
|
|
564
|
-
top: targetScrollTop
|
|
565
|
-
behavior
|
|
570
|
+
top: targetScrollTop
|
|
566
571
|
});
|
|
567
572
|
});
|
|
568
573
|
}
|
|
@@ -586,7 +591,7 @@ var scroller = ({ overScroll = 0 } = {}) => {
|
|
|
586
591
|
} catch (err) {
|
|
587
592
|
log2.catch(err, void 0, {
|
|
588
593
|
F: __dxlog_file2,
|
|
589
|
-
L:
|
|
594
|
+
L: 146,
|
|
590
595
|
S: void 0,
|
|
591
596
|
C: (f, a) => f(...a)
|
|
592
597
|
});
|
|
@@ -656,6 +661,7 @@ function createCrawler(view, k = 0.3, maxStep = 2, targetDelta = 0.5) {
|
|
|
656
661
|
}
|
|
657
662
|
|
|
658
663
|
// src/extensions/auto-scroll.ts
|
|
664
|
+
import { getSize } from "@dxos/ui-theme";
|
|
659
665
|
var autoScroll = (_ = {}) => {
|
|
660
666
|
let buttonContainer;
|
|
661
667
|
let isPinned = true;
|
|
@@ -710,7 +716,7 @@ var autoScroll = (_ = {}) => {
|
|
|
710
716
|
// Scroll button.
|
|
711
717
|
ViewPlugin6.fromClass(class {
|
|
712
718
|
constructor(view) {
|
|
713
|
-
const icon = Domino.of("dx-icon").attributes({
|
|
719
|
+
const icon = Domino.of("dx-icon").classNames(getSize(4)).attributes({
|
|
714
720
|
icon: "ph--arrow-down--regular"
|
|
715
721
|
});
|
|
716
722
|
const button = Domino.of("button").classNames("dx-button bg-accent-surface").attributes({
|
|
@@ -2482,28 +2488,28 @@ import { EditorView as EditorView13 } from "@codemirror/view";
|
|
|
2482
2488
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2483
2489
|
var headings = {
|
|
2484
2490
|
1: {
|
|
2485
|
-
className: "text-
|
|
2486
|
-
fontSize: "var(--text-
|
|
2491
|
+
className: "text-3xl",
|
|
2492
|
+
fontSize: "var(--text-3xl)",
|
|
2487
2493
|
lineHeight: "var(--text-4xl--line-height)"
|
|
2488
2494
|
},
|
|
2489
2495
|
2: {
|
|
2490
|
-
className: "text-
|
|
2491
|
-
fontSize: "var(--text-
|
|
2496
|
+
className: "text-2xl",
|
|
2497
|
+
fontSize: "var(--text-2xl)",
|
|
2492
2498
|
lineHeight: "var(--text-3xl--line-height)"
|
|
2493
2499
|
},
|
|
2494
2500
|
3: {
|
|
2495
|
-
className: "text-
|
|
2496
|
-
fontSize: "var(--text-
|
|
2501
|
+
className: "text-xl",
|
|
2502
|
+
fontSize: "var(--text-xl)",
|
|
2497
2503
|
lineHeight: "var(--text-2xl--line-height)"
|
|
2498
2504
|
},
|
|
2499
2505
|
4: {
|
|
2500
|
-
className: "text-
|
|
2501
|
-
fontSize: "var(--text-
|
|
2506
|
+
className: "text-lg",
|
|
2507
|
+
fontSize: "var(--text-lg)",
|
|
2502
2508
|
lineHeight: "var(--text-xl--line-height)"
|
|
2503
2509
|
},
|
|
2504
2510
|
5: {
|
|
2505
|
-
className: "text-
|
|
2506
|
-
fontSize: "var(--text-
|
|
2511
|
+
className: "text-base",
|
|
2512
|
+
fontSize: "var(--text-base)",
|
|
2507
2513
|
lineHeight: "var(--text-lg--line-height)"
|
|
2508
2514
|
},
|
|
2509
2515
|
6: {
|
|
@@ -2512,20 +2518,20 @@ var headings = {
|
|
|
2512
2518
|
lineHeight: "var(--text-base--line-height)"
|
|
2513
2519
|
}
|
|
2514
2520
|
};
|
|
2521
|
+
var fontBody = '"Inter Variable", ui-sans-serif, system-ui, sans-serif';
|
|
2522
|
+
var fontMono = '"JetBrains Mono Variable", ui-monospace, "Cascadia Code", "Source Code Pro", monospace';
|
|
2515
2523
|
var markdownTheme = {
|
|
2516
|
-
code: "font-mono
|
|
2517
|
-
codeMark: "font-mono text-cm-code-mark",
|
|
2518
|
-
mark: "
|
|
2524
|
+
code: "font-mono! text-cm-code",
|
|
2525
|
+
codeMark: "font-mono! text-cm-code-mark",
|
|
2526
|
+
mark: "font-mono!",
|
|
2519
2527
|
heading: (level) => ({
|
|
2520
|
-
className: mx3(headings[level].className, "font-light text-cm-heading"),
|
|
2528
|
+
className: mx3(headings[level].className, "font-light text-cm-heading-number"),
|
|
2521
2529
|
color: "var(--color-cm-heading) !important",
|
|
2522
2530
|
lineHeight: headings[level].lineHeight,
|
|
2523
2531
|
fontSize: headings[level].fontSize,
|
|
2524
2532
|
fontWeight: "100 !important"
|
|
2525
2533
|
})
|
|
2526
2534
|
};
|
|
2527
|
-
var fontBody = "Inter Variable, ui-sans-serif, system-ui, sans-serif";
|
|
2528
|
-
var fontMono = "JetBrains Mono Variable, ui-monospace, Cascadia Code, Source Code Pro, monospace";
|
|
2529
2535
|
var baseTheme = EditorView13.baseTheme({
|
|
2530
2536
|
/**
|
|
2531
2537
|
* Outer frame.
|
|
@@ -2557,7 +2563,6 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2557
2563
|
*/
|
|
2558
2564
|
".cm-content": {
|
|
2559
2565
|
padding: "unset",
|
|
2560
|
-
lineHeight: "24px",
|
|
2561
2566
|
color: "unset"
|
|
2562
2567
|
},
|
|
2563
2568
|
/**
|
|
@@ -2581,16 +2586,23 @@ var baseTheme = EditorView13.baseTheme({
|
|
|
2581
2586
|
* Height is set to match the corresponding line (which may have wrapped).
|
|
2582
2587
|
*/
|
|
2583
2588
|
".cm-gutterElement": {
|
|
2584
|
-
lineHeight:
|
|
2589
|
+
lineHeight: 1.5,
|
|
2585
2590
|
fontSize: "12px"
|
|
2586
2591
|
},
|
|
2587
2592
|
/**
|
|
2588
2593
|
* Line.
|
|
2589
2594
|
*/
|
|
2590
2595
|
".cm-line": {
|
|
2591
|
-
lineHeight:
|
|
2596
|
+
lineHeight: 1.5,
|
|
2592
2597
|
paddingInline: 0
|
|
2593
2598
|
},
|
|
2599
|
+
/**
|
|
2600
|
+
* Force all inline children to inherit line-height to prevent monospace font metrics
|
|
2601
|
+
* (JetBrains Mono ascent/descent) from inflating the line box beyond 24px.
|
|
2602
|
+
*/
|
|
2603
|
+
".cm-line *": {
|
|
2604
|
+
lineHeight: "inherit"
|
|
2605
|
+
},
|
|
2594
2606
|
".cm-activeLine": {
|
|
2595
2607
|
background: "var(--color-cm-active-line)"
|
|
2596
2608
|
},
|
|
@@ -2768,10 +2780,9 @@ var editorGutter = EditorView13.theme({
|
|
|
2768
2780
|
}
|
|
2769
2781
|
});
|
|
2770
2782
|
var createFontTheme = ({ monospace } = {}) => EditorView13.theme({
|
|
2771
|
-
//
|
|
2783
|
+
// Main content.
|
|
2772
2784
|
".cm-scroller": {
|
|
2773
|
-
fontFamily: monospace ? fontMono : fontBody
|
|
2774
|
-
fontSize: "16px"
|
|
2785
|
+
fontFamily: monospace ? fontMono : fontBody
|
|
2775
2786
|
},
|
|
2776
2787
|
// Maintain defaults for UI components.
|
|
2777
2788
|
".cm-content, .cm-gutters, .cm-panel": {
|
|
@@ -2988,6 +2999,7 @@ var folding = () => {
|
|
|
2988
2999
|
placeholderDOM: () => Domino2.of("span").root
|
|
2989
3000
|
}),
|
|
2990
3001
|
foldGutter({
|
|
3002
|
+
// NOTE: We can't animate since the element is remounted on state change.
|
|
2991
3003
|
markerDOM: (open) => {
|
|
2992
3004
|
return Domino2.of("div").classNames("flex h-full justify-center items-center").children(Domino2.of("svg", Domino2.SVG).classNames(mx4("w-4 h-4 cursor-pointer", open && "rotate-90")).children(Domino2.of("use", Domino2.SVG).attributes({
|
|
2993
3005
|
href: Domino2.icon("ph--caret-right--regular")
|
|
@@ -4274,8 +4286,7 @@ import { completionKeymap } from "@codemirror/autocomplete";
|
|
|
4274
4286
|
import { defaultKeymap as defaultKeymap2, indentWithTab as indentWithTab2 } from "@codemirror/commands";
|
|
4275
4287
|
import { jsonLanguage } from "@codemirror/lang-json";
|
|
4276
4288
|
import { markdown, markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
|
|
4277
|
-
import {
|
|
4278
|
-
import { LanguageDescription, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4289
|
+
import { foldNodeProp, syntaxHighlighting as syntaxHighlighting2 } from "@codemirror/language";
|
|
4279
4290
|
import { languages } from "@codemirror/language-data";
|
|
4280
4291
|
import { keymap as keymap9 } from "@codemirror/view";
|
|
4281
4292
|
import { isTruthy as isTruthy3 } from "@dxos/util";
|
|
@@ -4285,11 +4296,6 @@ import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
|
4285
4296
|
import { HighlightStyle as HighlightStyle2 } from "@codemirror/language";
|
|
4286
4297
|
import { Tag, styleTags, tags } from "@lezer/highlight";
|
|
4287
4298
|
import { Table } from "@lezer/markdown";
|
|
4288
|
-
var styles4 = {
|
|
4289
|
-
code: "font-mono no-underline! text-cm-code",
|
|
4290
|
-
codeMark: "font-mono text-cm-code-mark",
|
|
4291
|
-
mark: "opacity-50"
|
|
4292
|
-
};
|
|
4293
4299
|
var markdownTags = {
|
|
4294
4300
|
Blockquote: Tag.define(),
|
|
4295
4301
|
CodeMark: Tag.define(),
|
|
@@ -4371,7 +4377,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4371
4377
|
markdownTags.LinkReference,
|
|
4372
4378
|
markdownTags.ListMark
|
|
4373
4379
|
],
|
|
4374
|
-
class:
|
|
4380
|
+
class: markdownTheme.mark
|
|
4375
4381
|
},
|
|
4376
4382
|
// Markdown marks.
|
|
4377
4383
|
{
|
|
@@ -4382,7 +4388,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4382
4388
|
markdownTags.QuoteMark,
|
|
4383
4389
|
markdownTags.EmphasisMark
|
|
4384
4390
|
],
|
|
4385
|
-
class:
|
|
4391
|
+
class: markdownTheme.mark
|
|
4386
4392
|
},
|
|
4387
4393
|
// E.g., code block language (after ```).
|
|
4388
4394
|
{
|
|
@@ -4391,7 +4397,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4391
4397
|
tags.function(tags.variableName),
|
|
4392
4398
|
tags.labelName
|
|
4393
4399
|
],
|
|
4394
|
-
class:
|
|
4400
|
+
class: markdownTheme.codeMark
|
|
4395
4401
|
},
|
|
4396
4402
|
// Fonts.
|
|
4397
4403
|
{
|
|
@@ -4457,7 +4463,7 @@ var markdownHighlightStyle = (_options = {}) => {
|
|
|
4457
4463
|
markdownTags.CodeText,
|
|
4458
4464
|
markdownTags.InlineCode
|
|
4459
4465
|
],
|
|
4460
|
-
class:
|
|
4466
|
+
class: markdownTheme.code
|
|
4461
4467
|
},
|
|
4462
4468
|
{
|
|
4463
4469
|
tag: [
|
|
@@ -4495,7 +4501,11 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4495
4501
|
extensions: [
|
|
4496
4502
|
// GFM provided by default.
|
|
4497
4503
|
markdownTagsExtensions,
|
|
4498
|
-
...options.extensions ?? defaultExtensions()
|
|
4504
|
+
...options.extensions ?? defaultExtensions(),
|
|
4505
|
+
// Disable folding for fenced code blocks by overriding foldNodeProp.
|
|
4506
|
+
// Note: returning null from foldService does not prevent syntaxFolding fallback,
|
|
4507
|
+
// so we must override the node prop directly on the FencedCode node type.
|
|
4508
|
+
noFencedCodeFolding
|
|
4499
4509
|
]
|
|
4500
4510
|
}),
|
|
4501
4511
|
// Custom styles.
|
|
@@ -4510,18 +4520,13 @@ var createMarkdownExtensions = (options = {}) => {
|
|
|
4510
4520
|
].filter(isTruthy3))
|
|
4511
4521
|
];
|
|
4512
4522
|
};
|
|
4513
|
-
var
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
]
|
|
4519
|
-
|
|
4520
|
-
"xml",
|
|
4521
|
-
"xhtml"
|
|
4522
|
-
],
|
|
4523
|
-
load: async () => xml()
|
|
4524
|
-
});
|
|
4523
|
+
var noFencedCodeFolding = {
|
|
4524
|
+
props: [
|
|
4525
|
+
foldNodeProp.add({
|
|
4526
|
+
FencedCode: () => null
|
|
4527
|
+
})
|
|
4528
|
+
]
|
|
4529
|
+
};
|
|
4525
4530
|
var defaultExtensions = () => [
|
|
4526
4531
|
noSetExtHeading,
|
|
4527
4532
|
noHtml
|
|
@@ -4565,7 +4570,6 @@ import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
|
4565
4570
|
import { Prec as Prec4, RangeSetBuilder as RangeSetBuilder5, StateEffect as StateEffect6 } from "@codemirror/state";
|
|
4566
4571
|
import { Decoration as Decoration11, EditorView as EditorView23, ViewPlugin as ViewPlugin14, WidgetType as WidgetType7 } from "@codemirror/view";
|
|
4567
4572
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
4568
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
4569
4573
|
|
|
4570
4574
|
// src/extensions/markdown/changes.ts
|
|
4571
4575
|
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
|
@@ -4840,7 +4844,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4840
4844
|
background: "var(--color-cm-codeblock)",
|
|
4841
4845
|
borderLeft: "2px solid var(--color-cm-separator)",
|
|
4842
4846
|
paddingLeft: "1rem",
|
|
4843
|
-
margin:
|
|
4847
|
+
margin: 0
|
|
4844
4848
|
},
|
|
4845
4849
|
/**
|
|
4846
4850
|
* Code and codeblocks.
|
|
@@ -4848,6 +4852,23 @@ var formattingStyles = EditorView21.theme({
|
|
|
4848
4852
|
"& .cm-code": {
|
|
4849
4853
|
fontFamily: fontMono
|
|
4850
4854
|
},
|
|
4855
|
+
// Inline code spans (triggered by backticks) use `text-cm-code` + `font-mono`.
|
|
4856
|
+
// Different monospace font metrics can slightly overflow the fixed CodeMirror line box,
|
|
4857
|
+
// so constrain them to the target 24px height.
|
|
4858
|
+
"& .text-cm-code": {
|
|
4859
|
+
fontFamily: fontMono,
|
|
4860
|
+
height: "24px",
|
|
4861
|
+
display: "inline-flex",
|
|
4862
|
+
alignItems: "center",
|
|
4863
|
+
overflow: "hidden"
|
|
4864
|
+
},
|
|
4865
|
+
"& .text-cm-code-mark": {
|
|
4866
|
+
fontFamily: fontMono,
|
|
4867
|
+
height: "24px",
|
|
4868
|
+
display: "inline-flex",
|
|
4869
|
+
alignItems: "center",
|
|
4870
|
+
overflow: "hidden"
|
|
4871
|
+
},
|
|
4851
4872
|
"& .cm-codeblock-line": {
|
|
4852
4873
|
background: "var(--color-cm-codeblock)",
|
|
4853
4874
|
paddingInline: "1rem !important"
|
|
@@ -4878,6 +4899,7 @@ var formattingStyles = EditorView21.theme({
|
|
|
4878
4899
|
*/
|
|
4879
4900
|
".cm-table *": {
|
|
4880
4901
|
fontFamily: fontMono,
|
|
4902
|
+
lineHeight: 1.5,
|
|
4881
4903
|
textDecoration: "none !important"
|
|
4882
4904
|
},
|
|
4883
4905
|
".cm-table-head": {
|
|
@@ -4903,12 +4925,12 @@ var formattingStyles = EditorView21.theme({
|
|
|
4903
4925
|
},
|
|
4904
4926
|
".cm-image-with-loader": {
|
|
4905
4927
|
display: "block",
|
|
4906
|
-
opacity:
|
|
4928
|
+
opacity: 0,
|
|
4907
4929
|
transitionDuration: "350ms",
|
|
4908
4930
|
transitionProperty: "opacity"
|
|
4909
4931
|
},
|
|
4910
4932
|
".cm-image-with-loader.cm-loaded-image": {
|
|
4911
|
-
opacity:
|
|
4933
|
+
opacity: 1
|
|
4912
4934
|
},
|
|
4913
4935
|
".cm-image-wrapper": {
|
|
4914
4936
|
"grid-template-columns": "1fr",
|
|
@@ -5123,10 +5145,10 @@ var fencedCodeLine = Decoration11.line({
|
|
|
5123
5145
|
class: "cm-code cm-codeblock-line"
|
|
5124
5146
|
});
|
|
5125
5147
|
var fencedCodeLineFirst = Decoration11.line({
|
|
5126
|
-
class:
|
|
5148
|
+
class: "cm-code cm-codeblock-line cm-codeblock-start"
|
|
5127
5149
|
});
|
|
5128
5150
|
var fencedCodeLineLast = Decoration11.line({
|
|
5129
|
-
class:
|
|
5151
|
+
class: "cm-code cm-codeblock-line cm-codeblock-end"
|
|
5130
5152
|
});
|
|
5131
5153
|
var commentBlockLine = fencedCodeLine;
|
|
5132
5154
|
var commentBlockLineFirst = fencedCodeLineFirst;
|
|
@@ -5160,7 +5182,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5160
5182
|
const getHeaderLevels = (node, level) => {
|
|
5161
5183
|
invariant4(level > 0, void 0, {
|
|
5162
5184
|
F: __dxlog_file12,
|
|
5163
|
-
L:
|
|
5185
|
+
L: 178,
|
|
5164
5186
|
S: void 0,
|
|
5165
5187
|
A: [
|
|
5166
5188
|
"level > 0",
|
|
@@ -5199,7 +5221,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5199
5221
|
const getCurrentListLevel = () => {
|
|
5200
5222
|
invariant4(listLevels.length, void 0, {
|
|
5201
5223
|
F: __dxlog_file12,
|
|
5202
|
-
L:
|
|
5224
|
+
L: 200,
|
|
5203
5225
|
S: void 0,
|
|
5204
5226
|
A: [
|
|
5205
5227
|
"listLevels.length",
|
|
@@ -5243,7 +5265,7 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5243
5265
|
deco: hide
|
|
5244
5266
|
});
|
|
5245
5267
|
} else {
|
|
5246
|
-
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
|
|
5268
|
+
const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + "). ";
|
|
5247
5269
|
if (num.length) {
|
|
5248
5270
|
atomicDecoRanges.push({
|
|
5249
5271
|
from: mark.from,
|
|
@@ -5426,11 +5448,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5426
5448
|
}
|
|
5427
5449
|
decoRanges.push({
|
|
5428
5450
|
from: marks[0].to,
|
|
5429
|
-
to: marks[1].from,
|
|
5451
|
+
to: !editing && options.renderLinkButton ? node.to : marks[1].from,
|
|
5430
5452
|
deco: Decoration11.mark({
|
|
5431
5453
|
tagName: "a",
|
|
5432
5454
|
attributes: {
|
|
5433
|
-
class: "cm-link",
|
|
5455
|
+
class: options.renderLinkButton ? "cm-link cm-link-with-button" : "cm-link",
|
|
5434
5456
|
href: url,
|
|
5435
5457
|
rel: "noreferrer",
|
|
5436
5458
|
target: "_blank"
|
|
@@ -5508,8 +5530,11 @@ var buildDecorations2 = (view, options, focus2) => {
|
|
|
5508
5530
|
deco.add(from, to, d);
|
|
5509
5531
|
}
|
|
5510
5532
|
const atomicDeco = new RangeSetBuilder5();
|
|
5511
|
-
for (const { from, to, deco:
|
|
5512
|
-
|
|
5533
|
+
for (const { from, to, deco: deco2 } of atomicDecoRanges) {
|
|
5534
|
+
if (from < to && state.doc.lineAt(from).number !== state.doc.lineAt(to).number) {
|
|
5535
|
+
continue;
|
|
5536
|
+
}
|
|
5537
|
+
atomicDeco.add(from, to, deco2);
|
|
5513
5538
|
}
|
|
5514
5539
|
return {
|
|
5515
5540
|
deco: deco.finish(),
|
|
@@ -6272,7 +6297,7 @@ var commands = () => keymap11.of([
|
|
|
6272
6297
|
// src/extensions/outliner/outliner.ts
|
|
6273
6298
|
import { Prec as Prec5 } from "@codemirror/state";
|
|
6274
6299
|
import { Decoration as Decoration12, EditorView as EditorView25, ViewPlugin as ViewPlugin17 } from "@codemirror/view";
|
|
6275
|
-
import { mx as
|
|
6300
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
6276
6301
|
|
|
6277
6302
|
// src/extensions/outliner/editor.ts
|
|
6278
6303
|
import { EditorSelection as EditorSelection4, EditorState as EditorState2 } from "@codemirror/state";
|
|
@@ -6595,7 +6620,7 @@ var decorations = () => [
|
|
|
6595
6620
|
const lineTo = doc.lineAt(item.contentRange.to);
|
|
6596
6621
|
const isSelected = selection.includes(item.index) || item === current;
|
|
6597
6622
|
decorations2.push(Decoration12.line({
|
|
6598
|
-
class:
|
|
6623
|
+
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"))
|
|
6599
6624
|
}).range(line.from, line.from));
|
|
6600
6625
|
}
|
|
6601
6626
|
}
|
|
@@ -6640,17 +6665,22 @@ var decorations = () => [
|
|
|
6640
6665
|
|
|
6641
6666
|
// src/extensions/preview/preview.ts
|
|
6642
6667
|
import { syntaxTree as syntaxTree10 } from "@codemirror/language";
|
|
6643
|
-
import { RangeSetBuilder as RangeSetBuilder6, StateField as StateField11 } from "@codemirror/state";
|
|
6644
|
-
import { Decoration as Decoration13, EditorView as EditorView26, WidgetType as WidgetType8 } from "@codemirror/view";
|
|
6668
|
+
import { RangeSetBuilder as RangeSetBuilder6, StateEffect as StateEffect8, StateField as StateField11 } from "@codemirror/state";
|
|
6669
|
+
import { Decoration as Decoration13, EditorView as EditorView26, ViewPlugin as ViewPlugin18, WidgetType as WidgetType8 } from "@codemirror/view";
|
|
6670
|
+
import { DXN, Entity } from "@dxos/echo";
|
|
6671
|
+
var labelResolvedEffect = StateEffect8.define();
|
|
6645
6672
|
var preview = (options = {}) => {
|
|
6673
|
+
const viewRef = {
|
|
6674
|
+
current: void 0
|
|
6675
|
+
};
|
|
6646
6676
|
return [
|
|
6647
6677
|
// NOTE: Atomic block decorations must be created from a state field, now a widget, otherwise it results in the following error:
|
|
6648
6678
|
// "Block decorations may not be specified via plugins".
|
|
6649
6679
|
StateField11.define({
|
|
6650
|
-
create: (state) => buildDecorations3(state, options),
|
|
6680
|
+
create: (state) => buildDecorations3(state, options, viewRef),
|
|
6651
6681
|
update: (decorations2, tr) => {
|
|
6652
|
-
if (tr.docChanged) {
|
|
6653
|
-
return buildDecorations3(tr.state, options);
|
|
6682
|
+
if (tr.docChanged || tr.effects.some((effect) => effect.is(labelResolvedEffect))) {
|
|
6683
|
+
return buildDecorations3(tr.state, options, viewRef);
|
|
6654
6684
|
}
|
|
6655
6685
|
return decorations2.map(tr.changes);
|
|
6656
6686
|
},
|
|
@@ -6658,10 +6688,34 @@ var preview = (options = {}) => {
|
|
|
6658
6688
|
EditorView26.decorations.from(field),
|
|
6659
6689
|
EditorView26.atomicRanges.of((view) => view.state.field(field))
|
|
6660
6690
|
]
|
|
6691
|
+
}),
|
|
6692
|
+
ViewPlugin18.define((view) => {
|
|
6693
|
+
viewRef.current = view;
|
|
6694
|
+
return {
|
|
6695
|
+
destroy() {
|
|
6696
|
+
viewRef.current = void 0;
|
|
6697
|
+
}
|
|
6698
|
+
};
|
|
6661
6699
|
})
|
|
6662
6700
|
];
|
|
6663
6701
|
};
|
|
6664
|
-
var
|
|
6702
|
+
var resolveLabel = (db, dxnStr, viewRef) => {
|
|
6703
|
+
const dxn = DXN.tryParse(dxnStr);
|
|
6704
|
+
if (!dxn) {
|
|
6705
|
+
return;
|
|
6706
|
+
}
|
|
6707
|
+
const ref = db.makeRef(dxn);
|
|
6708
|
+
const target = ref.target;
|
|
6709
|
+
if (target) {
|
|
6710
|
+
return Entity.getLabel(target);
|
|
6711
|
+
}
|
|
6712
|
+
void ref.tryLoad().then(() => {
|
|
6713
|
+
viewRef.current?.dispatch({
|
|
6714
|
+
effects: labelResolvedEffect.of(void 0)
|
|
6715
|
+
});
|
|
6716
|
+
});
|
|
6717
|
+
};
|
|
6718
|
+
var buildDecorations3 = (state, options, viewRef) => {
|
|
6665
6719
|
const builder = new RangeSetBuilder6();
|
|
6666
6720
|
syntaxTree10(state).iterate({
|
|
6667
6721
|
enter: (node) => {
|
|
@@ -6673,8 +6727,13 @@ var buildDecorations3 = (state, options) => {
|
|
|
6673
6727
|
case "Link": {
|
|
6674
6728
|
const link = getLinkRef(state, node.node);
|
|
6675
6729
|
if (link) {
|
|
6730
|
+
const resolved = options.db ? resolveLabel(options.db, link.dxn, viewRef) : void 0;
|
|
6731
|
+
const displayLink = resolved ? {
|
|
6732
|
+
...link,
|
|
6733
|
+
label: resolved
|
|
6734
|
+
} : link;
|
|
6676
6735
|
builder.add(node.from, node.to, Decoration13.replace({
|
|
6677
|
-
widget: new PreviewInlineWidget(options,
|
|
6736
|
+
widget: new PreviewInlineWidget(options, displayLink),
|
|
6678
6737
|
side: 1
|
|
6679
6738
|
}));
|
|
6680
6739
|
}
|
|
@@ -6965,8 +7024,8 @@ var mixedParser = (registry) => {
|
|
|
6965
7024
|
};
|
|
6966
7025
|
|
|
6967
7026
|
// src/extensions/tags/streamer.ts
|
|
6968
|
-
import { StateEffect as
|
|
6969
|
-
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as
|
|
7027
|
+
import { StateEffect as StateEffect9, StateField as StateField12 } from "@codemirror/state";
|
|
7028
|
+
import { Decoration as Decoration14, EditorView as EditorView28, ViewPlugin as ViewPlugin19, WidgetType as WidgetType9 } from "@codemirror/view";
|
|
6970
7029
|
import { Domino as Domino3 } from "@dxos/ui";
|
|
6971
7030
|
import { isTruthy as isTruthy4 } from "@dxos/util";
|
|
6972
7031
|
var BLINK_RATE = 2e3;
|
|
@@ -6977,7 +7036,7 @@ var streamer = (options = {}) => {
|
|
|
6977
7036
|
].filter(isTruthy4);
|
|
6978
7037
|
};
|
|
6979
7038
|
var cursor = () => {
|
|
6980
|
-
const hideCursor =
|
|
7039
|
+
const hideCursor = StateEffect9.define();
|
|
6981
7040
|
const showCursor = StateField12.define({
|
|
6982
7041
|
create: () => true,
|
|
6983
7042
|
update: (value, tr) => {
|
|
@@ -6992,7 +7051,7 @@ var cursor = () => {
|
|
|
6992
7051
|
return value;
|
|
6993
7052
|
}
|
|
6994
7053
|
});
|
|
6995
|
-
const timerPlugin =
|
|
7054
|
+
const timerPlugin = ViewPlugin19.fromClass(class {
|
|
6996
7055
|
view;
|
|
6997
7056
|
timer;
|
|
6998
7057
|
constructor(view) {
|
|
@@ -7049,7 +7108,7 @@ var fadeIn = (options = {}) => {
|
|
|
7049
7108
|
const FADE_IN_DURATION = 1e3;
|
|
7050
7109
|
const DEFAULT_REMOVAL_DELAY = 3e3;
|
|
7051
7110
|
const removalDelay = options.removalDelay ?? DEFAULT_REMOVAL_DELAY;
|
|
7052
|
-
const removeDecoration =
|
|
7111
|
+
const removeDecoration = StateEffect9.define();
|
|
7053
7112
|
const fadeField = StateField12.define({
|
|
7054
7113
|
create: () => Decoration14.none,
|
|
7055
7114
|
update: (decorations2, tr) => {
|
|
@@ -7093,7 +7152,7 @@ var fadeIn = (options = {}) => {
|
|
|
7093
7152
|
},
|
|
7094
7153
|
provide: (f) => EditorView28.decorations.from(f)
|
|
7095
7154
|
});
|
|
7096
|
-
const timerPlugin =
|
|
7155
|
+
const timerPlugin = ViewPlugin19.fromClass(class {
|
|
7097
7156
|
view;
|
|
7098
7157
|
// Map a simple key "from-to" to timer id.
|
|
7099
7158
|
_timers = /* @__PURE__ */ new Map();
|
|
@@ -7159,8 +7218,8 @@ var fadeIn = (options = {}) => {
|
|
|
7159
7218
|
|
|
7160
7219
|
// src/extensions/tags/xml-tags.ts
|
|
7161
7220
|
import { syntaxTree as syntaxTree11 } from "@codemirror/language";
|
|
7162
|
-
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as
|
|
7163
|
-
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as
|
|
7221
|
+
import { Prec as Prec7, RangeSetBuilder as RangeSetBuilder7, StateEffect as StateEffect10, StateField as StateField13 } from "@codemirror/state";
|
|
7222
|
+
import { Decoration as Decoration15, EditorView as EditorView29, ViewPlugin as ViewPlugin20, WidgetType as WidgetType10, keymap as keymap13 } from "@codemirror/view";
|
|
7164
7223
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
7165
7224
|
import { log as log11 } from "@dxos/log";
|
|
7166
7225
|
|
|
@@ -7234,15 +7293,15 @@ var nodeToJson = (state, node) => {
|
|
|
7234
7293
|
|
|
7235
7294
|
// src/extensions/tags/xml-tags.ts
|
|
7236
7295
|
var __dxlog_file17 = "/__w/dxos/dxos/packages/ui/ui-editor/src/extensions/tags/xml-tags.ts";
|
|
7237
|
-
var navigatePreviousEffect =
|
|
7238
|
-
var navigateNextEffect =
|
|
7296
|
+
var navigatePreviousEffect = StateEffect10.define();
|
|
7297
|
+
var navigateNextEffect = StateEffect10.define();
|
|
7239
7298
|
var getXmlTextChild = (children) => {
|
|
7240
7299
|
const child = children?.[0];
|
|
7241
7300
|
return typeof child === "string" ? child : null;
|
|
7242
7301
|
};
|
|
7243
|
-
var xmlTagContextEffect =
|
|
7244
|
-
var xmlTagResetEffect =
|
|
7245
|
-
var xmlTagUpdateEffect =
|
|
7302
|
+
var xmlTagContextEffect = StateEffect10.define();
|
|
7303
|
+
var xmlTagResetEffect = StateEffect10.define();
|
|
7304
|
+
var xmlTagUpdateEffect = StateEffect10.define();
|
|
7246
7305
|
var widgetContextStateField = StateField13.define({
|
|
7247
7306
|
create: () => void 0,
|
|
7248
7307
|
update: (value, tr) => {
|
|
@@ -7437,7 +7496,7 @@ var createNavigationEffectPlugin = (widgetDecorationsField, bookmarks2) => {
|
|
|
7437
7496
|
});
|
|
7438
7497
|
});
|
|
7439
7498
|
};
|
|
7440
|
-
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) =>
|
|
7499
|
+
var createWidgetUpdatePlugin = (widgetDecorationsField, notifier) => ViewPlugin20.fromClass(class {
|
|
7441
7500
|
update(update2) {
|
|
7442
7501
|
const widgetStateMap = update2.state.field(widgetStateMapStateField);
|
|
7443
7502
|
const { decorations: decorations2 } = update2.state.field(widgetDecorationsField);
|
|
@@ -7729,6 +7788,7 @@ export {
|
|
|
7729
7788
|
commentClickedEffect,
|
|
7730
7789
|
comments,
|
|
7731
7790
|
commentsState,
|
|
7791
|
+
compactSlots,
|
|
7732
7792
|
convertTreeToJson,
|
|
7733
7793
|
createBasicExtensions,
|
|
7734
7794
|
createComment,
|
|
@@ -7752,11 +7812,9 @@ export {
|
|
|
7752
7812
|
defaultThemeSlots,
|
|
7753
7813
|
deleteItem,
|
|
7754
7814
|
documentId,
|
|
7815
|
+
documentSlots,
|
|
7755
7816
|
dropFile,
|
|
7756
7817
|
editorInputMode,
|
|
7757
|
-
editorSlots,
|
|
7758
|
-
editorWidth,
|
|
7759
|
-
editorWithToolbarLayout,
|
|
7760
7818
|
extendedMarkdown,
|
|
7761
7819
|
filterChars,
|
|
7762
7820
|
flattenRect,
|