@surrealdb/ui 1.2.12 → 1.2.13
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/.claude/launch.json +17 -0
- package/.oxfmtrc.json +27 -0
- package/.oxlintrc.json +23 -0
- package/.zed/settings.json +34 -34
- package/AGENTS.md +21 -19
- package/README.md +15 -10
- package/dist/ui.css +1 -1
- package/dist/ui.d.ts +234 -1
- package/dist/ui.js +8217 -7329
- package/dist/ui.js.map +1 -1
- package/doc/code-style.md +264 -0
- package/doc/stacker-plan.md +219 -0
- package/package.json +119 -116
- package/res/_mixins.scss +15 -11
- package/tests/_setup/e2e-helpers.tsx +85 -85
- package/tests/_setup/portable-stories.ts +11 -10
- package/tests/e2e/MarkdownEditor/content-blocks.test.tsx +140 -139
- package/tests/e2e/MarkdownEditor/edits.test.tsx +101 -100
- package/tests/e2e/MarkdownEditor/heading-fold.test.tsx +35 -34
- package/tests/e2e/MarkdownEditor/hybrid-widgets.test.tsx +178 -177
- package/tests/e2e/MarkdownEditor/image-on-image.test.tsx +50 -49
- package/tests/e2e/MarkdownEditor/jsx-block-content.test.tsx +195 -194
- package/tests/e2e/MarkdownEditor/jsx-highlight.test.tsx +47 -46
- package/tests/e2e/MarkdownEditor/jsx-inline-badges.test.tsx +35 -34
- package/tests/e2e/MarkdownEditor/jsx-inline-click.test.tsx +39 -38
- package/tests/e2e/MarkdownEditor/jsx-selection.test.tsx +28 -27
- package/tests/e2e/MarkdownEditor/link-placeholder.test.tsx +49 -48
- package/tests/e2e/MarkdownEditor/media-align.test.tsx +40 -39
- package/tests/e2e/MarkdownEditor/media-edit.test.tsx +49 -48
- package/tests/e2e/MarkdownEditor/media-sizing.test.tsx +108 -107
- package/tests/e2e/MarkdownEditor/modes.test.tsx +79 -78
- package/tests/e2e/MarkdownEditor/onimage-parity.test.tsx +29 -28
- package/tests/e2e/MarkdownEditor/regressions.test.tsx +194 -193
- package/tests/e2e/MarkdownEditor/slash-commands.test.tsx +81 -80
- package/tests/e2e/MarkdownEditor/table-click.test.tsx +36 -35
- package/tests/e2e/MarkdownEditor/table-controls.test.tsx +44 -43
- package/tests/e2e/MarkdownEditor/table-format.test.tsx +28 -27
- package/tests/e2e/MarkdownEditor/undo-redo.test.tsx +22 -21
- package/tests/e2e/MarkdownViewer/parity.test.tsx +144 -143
- package/tests/e2e/MarkdownViewer/render.test.tsx +20 -19
- package/tests/e2e/Stacker/stacker.test.tsx +304 -0
- package/tests/unit/Editor/helpers.test.ts +26 -26
- package/tests/unit/MarkdownConformance/error-isolation.test.tsx +26 -25
- package/tests/unit/MarkdownConformance/indentation.test.tsx +20 -19
- package/tests/unit/MarkdownConformance/inline-code-fuzz.test.tsx +255 -0
- package/tests/unit/MarkdownConformance/jsx-attributes.test.tsx +39 -38
- package/tests/unit/MarkdownConformance/jsx-fuzz.test.tsx +122 -122
- package/tests/unit/MarkdownConformance/links.test.tsx +78 -54
- package/tests/unit/MarkdownConformance/render-helpers.tsx +60 -60
- package/tests/unit/MarkdownEditor/code-info.test.ts +58 -58
- package/tests/unit/MarkdownEditor/decorations.test.ts +423 -421
- package/tests/unit/MarkdownEditor/editor-ready.test.ts +22 -22
- package/tests/unit/MarkdownEditor/html-descriptors.test.ts +70 -70
- package/tests/unit/MarkdownEditor/indented-fence.test.ts +80 -80
- package/tests/unit/MarkdownEditor/jsx-attr-scan.test.ts +87 -87
- package/tests/unit/MarkdownEditor/jsx-block-widget.test.ts +51 -51
- package/tests/unit/MarkdownEditor/jsx-tag-grammar.test.ts +63 -63
- package/tests/unit/MarkdownEditor/list-indent.test.ts +67 -67
- package/tests/unit/MarkdownEditor/slash-commands.test.ts +150 -150
- package/tests/unit/MarkdownEditor/table-format.test.ts +67 -67
- package/tests/unit/MarkdownEditor/table.test.ts +96 -96
- package/tests/unit/MarkdownEditor/triggers.test.ts +167 -167
- package/tests/unit/MarkdownEditor/widget-store.test.ts +90 -90
- package/tests/unit/MarkdownViewer/callout.test.tsx +42 -42
- package/tests/unit/MarkdownViewer/code-highlight.test.tsx +41 -41
- package/tests/unit/MarkdownViewer/code-title.test.tsx +45 -45
- package/tests/unit/MarkdownViewer/features.test.tsx +129 -129
- package/tests/unit/MarkdownViewer/headings.test.tsx +28 -28
- package/tests/unit/MarkdownViewer/indented-jsx-children.test.tsx +53 -53
- package/tests/unit/MarkdownViewer/jsx-block-nesting.test.tsx +137 -137
- package/tests/unit/MarkdownViewer/jsx.test.tsx +188 -188
- package/tests/unit/MarkdownViewer/list-bullets.test.tsx +31 -31
- package/tests/unit/MarkdownViewer/list-code.test.tsx +45 -45
- package/tests/unit/MarkdownViewer/preserve-newlines.test.tsx +109 -109
- package/tests/unit/MarkdownViewer/read-time.test.ts +13 -13
- package/tests/unit/MarkdownViewer/renderers.test.tsx +75 -75
- package/tests/unit/MarkdownViewer/runnable.test.tsx +51 -51
- package/tests/unit/MarkdownViewer/ssr.test.tsx +56 -55
- package/tests/unit/MarkdownViewer/syntax-highlighting.test.tsx +43 -42
- package/tests/unit/MarkdownViewer/tabs-fenced-code.test.tsx +120 -120
- package/tests/unit/MarkdownViewer/tabs.test.tsx +83 -82
- package/tests/unit/Stacker/drag.test.ts +21 -0
- package/tests/unit/Stacker/helpers.test.ts +105 -0
- package/tests/unit/Stacker/reducer.test.ts +107 -0
- package/tools/duplicate-vector-mappings.json +141 -141
- package/tools/glass-export-overrides.json +6 -6
- package/tools/icon-parser.ts +41 -40
- package/tools/integration-gradient-exports.json +55 -55
- package/tools/picto-compare.ts +32 -32
- package/tools/picto-merge-urls.ts +19 -19
- package/tools/picto-sync.ts +543 -543
- package/tools/picto-verify-gradients.ts +50 -50
- package/tools/vector-export-nodes.json +975 -975
|
@@ -3,51 +3,52 @@ import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
|
|
|
3
3
|
import { MANTINE_THEME } from "@src/theme/mantine";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { page } from "vitest/browser";
|
|
6
|
+
|
|
6
7
|
import { getEditorView, mountStory, nextFrame } from "../../_setup/e2e-helpers";
|
|
7
8
|
|
|
8
9
|
const DOC = 'Text with <Since v="1.5.0" /> inline here.\n';
|
|
9
10
|
|
|
10
11
|
describe("MarkdownEditor / inline JSX click reveal", () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
it("reveals the raw source when an inline component badge is clicked", async () => {
|
|
13
|
+
mountStory(
|
|
14
|
+
<MantineProvider
|
|
15
|
+
theme={MANTINE_THEME}
|
|
16
|
+
cssVariablesResolver={v8CssVariablesResolver}
|
|
17
|
+
forceColorScheme="dark"
|
|
18
|
+
>
|
|
19
|
+
<Paper
|
|
20
|
+
p="md"
|
|
21
|
+
withBorder
|
|
22
|
+
>
|
|
23
|
+
<MarkdownEditor
|
|
24
|
+
mode="preview"
|
|
25
|
+
document={DOC}
|
|
26
|
+
autoFocus={false}
|
|
27
|
+
jsxMode="render"
|
|
28
|
+
/>
|
|
29
|
+
</Paper>
|
|
30
|
+
</MantineProvider>,
|
|
31
|
+
);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const view = await getEditorView();
|
|
34
|
+
await nextFrame();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
// Inactive: the badge renders and the raw tag is hidden.
|
|
37
|
+
expect(document.querySelector(".cm-content")?.textContent).not.toContain("<Since");
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// Click the rendered inline badge.
|
|
40
|
+
await page.getByText("1.5.0").click();
|
|
41
|
+
await nextFrame();
|
|
42
|
+
await nextFrame();
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
// The click selects the component's entire source range (not just a caret),
|
|
45
|
+
// revealing the raw markup for editing.
|
|
46
|
+
const sel = view.state.selection.main;
|
|
47
|
+
const from = DOC.indexOf("<Since");
|
|
48
|
+
const to = DOC.indexOf("/>") + 2;
|
|
49
|
+
expect(sel.from).toBe(from);
|
|
50
|
+
expect(sel.to).toBe(to);
|
|
51
|
+
expect(sel.empty).toBe(false);
|
|
52
|
+
expect(document.querySelector(".cm-content")?.textContent).toContain("<Since");
|
|
53
|
+
});
|
|
53
54
|
});
|
|
@@ -3,6 +3,7 @@ import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
|
|
|
3
3
|
import { Since } from "@src/primitives/Since";
|
|
4
4
|
import { MANTINE_THEME } from "@src/theme/mantine";
|
|
5
5
|
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
6
7
|
import { getEditorView, mountStory, nextFrame } from "../../_setup/e2e-helpers";
|
|
7
8
|
|
|
8
9
|
const JSX_DOC = `<Since v="9.9.9" />
|
|
@@ -11,33 +12,33 @@ Paragraph after component.
|
|
|
11
12
|
`;
|
|
12
13
|
|
|
13
14
|
describe("MarkdownEditor / JSX selection reveal", () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
it("shows JSX widget when inactive and raw source when caret is inside the tag", async () => {
|
|
16
|
+
mountStory(
|
|
17
|
+
<MantineProvider
|
|
18
|
+
theme={MANTINE_THEME}
|
|
19
|
+
cssVariablesResolver={v8CssVariablesResolver}
|
|
20
|
+
forceColorScheme="dark"
|
|
21
|
+
>
|
|
22
|
+
<Paper
|
|
23
|
+
p="md"
|
|
24
|
+
withBorder
|
|
25
|
+
>
|
|
26
|
+
<MarkdownEditor
|
|
27
|
+
mode="preview"
|
|
28
|
+
document={JSX_DOC}
|
|
29
|
+
autoFocus={false}
|
|
30
|
+
jsxMode="render"
|
|
31
|
+
components={{ Since }}
|
|
32
|
+
/>
|
|
33
|
+
</Paper>
|
|
34
|
+
</MantineProvider>,
|
|
35
|
+
);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const view = await getEditorView();
|
|
38
|
+
view.contentDOM.blur();
|
|
39
|
+
await nextFrame();
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
expect(document.body.textContent).toContain("9.9.9");
|
|
42
|
+
expect(document.querySelector(".cm-content")?.textContent).not.toContain("<Since");
|
|
43
|
+
});
|
|
43
44
|
});
|
|
@@ -4,64 +4,65 @@ import { setMarkdownEditorFocused } from "@src/lib/markdown/editor/decorations/e
|
|
|
4
4
|
import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
|
|
5
5
|
import { MANTINE_THEME } from "@src/theme/mantine";
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
|
+
|
|
7
8
|
import { getEditorView, mountStory, nextFrame } from "../../_setup/e2e-helpers";
|
|
8
9
|
|
|
9
10
|
function shell(doc: string) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
return (
|
|
12
|
+
<MantineProvider
|
|
13
|
+
theme={MANTINE_THEME}
|
|
14
|
+
cssVariablesResolver={v8CssVariablesResolver}
|
|
15
|
+
forceColorScheme="dark"
|
|
16
|
+
>
|
|
17
|
+
<Paper p="md">
|
|
18
|
+
<MarkdownEditor
|
|
19
|
+
mode="preview"
|
|
20
|
+
document={doc}
|
|
21
|
+
autoFocus={false}
|
|
22
|
+
/>
|
|
23
|
+
</Paper>
|
|
24
|
+
</MantineProvider>
|
|
25
|
+
);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
async function caretAt(doc: string, index: number) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
mountStory(shell(doc));
|
|
30
|
+
const view = await getEditorView();
|
|
31
|
+
view.focus();
|
|
32
|
+
view.dispatch({
|
|
33
|
+
selection: EditorSelection.cursor(index),
|
|
34
|
+
effects: setMarkdownEditorFocused.of(true),
|
|
35
|
+
});
|
|
36
|
+
await nextFrame();
|
|
37
|
+
await nextFrame();
|
|
38
|
+
return view;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
describe("MarkdownEditor / link placeholders", () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
it("shows an 'alt text' placeholder for an empty link label", async () => {
|
|
43
|
+
const doc = "[](https://surrealdb.com)";
|
|
44
|
+
await caretAt(doc, 1); // caret between the empty []
|
|
45
|
+
expect(document.querySelector(".cm-content")?.textContent).toContain("alt text");
|
|
46
|
+
});
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
it("shows a 'link' placeholder for an empty link destination", async () => {
|
|
49
|
+
const doc = "[label]()";
|
|
50
|
+
await caretAt(doc, doc.indexOf("(") + 1); // caret between the empty ()
|
|
51
|
+
const text = document.querySelector(".cm-content")?.textContent ?? "";
|
|
52
|
+
expect(text).toContain("link");
|
|
53
|
+
});
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
it("shows both placeholders for a fully empty link", async () => {
|
|
56
|
+
const doc = "[]()";
|
|
57
|
+
await caretAt(doc, 1);
|
|
58
|
+
const text = document.querySelector(".cm-content")?.textContent ?? "";
|
|
59
|
+
expect(text).toContain("alt text");
|
|
60
|
+
expect(text).toContain("link");
|
|
61
|
+
});
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
it("does not show placeholders once the sections have content", async () => {
|
|
64
|
+
const doc = "[label](https://surrealdb.com)";
|
|
65
|
+
await caretAt(doc, 3);
|
|
66
|
+
expect(document.querySelector(".cm-content")?.textContent).not.toContain("alt text");
|
|
67
|
+
});
|
|
67
68
|
});
|
|
@@ -4,54 +4,55 @@ import { setMarkdownEditorFocused } from "@src/lib/markdown/editor/decorations/e
|
|
|
4
4
|
import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
|
|
5
5
|
import { MANTINE_THEME } from "@src/theme/mantine";
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
|
+
|
|
7
8
|
import { getEditorView, mountStory, nextFrame, sleep } from "../../_setup/e2e-helpers";
|
|
8
9
|
|
|
9
10
|
const DOC =
|
|
10
|
-
|
|
11
|
+
"Regular paragraph line.\n\n\n\nAnother paragraph.\n";
|
|
11
12
|
|
|
12
13
|
/** Left edge of a line's rendered text content (text nodes have no element box). */
|
|
13
14
|
function textLeft(line: HTMLElement): number {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const range = document.createRange();
|
|
16
|
+
range.selectNodeContents(line);
|
|
17
|
+
return range.getBoundingClientRect().left;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
describe("MarkdownEditor / media alignment", () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
it("aligns the image preview's left edge with regular text", async () => {
|
|
22
|
+
mountStory(
|
|
23
|
+
<MantineProvider
|
|
24
|
+
theme={MANTINE_THEME}
|
|
25
|
+
cssVariablesResolver={v8CssVariablesResolver}
|
|
26
|
+
forceColorScheme="dark"
|
|
27
|
+
>
|
|
28
|
+
<Paper p="md">
|
|
29
|
+
<MarkdownEditor
|
|
30
|
+
mode="preview"
|
|
31
|
+
document={DOC}
|
|
32
|
+
autoFocus={false}
|
|
33
|
+
/>
|
|
34
|
+
</Paper>
|
|
35
|
+
</MantineProvider>,
|
|
36
|
+
);
|
|
37
|
+
const view = await getEditorView();
|
|
38
|
+
view.focus();
|
|
39
|
+
view.dispatch({
|
|
40
|
+
selection: EditorSelection.cursor(view.state.doc.length),
|
|
41
|
+
effects: setMarkdownEditorFocused.of(true),
|
|
42
|
+
});
|
|
43
|
+
await sleep(200);
|
|
44
|
+
await nextFrame();
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const para = Array.from(document.querySelectorAll<HTMLElement>(".cm-line")).find((l) =>
|
|
47
|
+
(l.textContent ?? "").includes("Regular"),
|
|
48
|
+
);
|
|
49
|
+
const img = document.querySelector<HTMLElement>('[data-md-widget="ImageWidget"] img');
|
|
50
|
+
expect(para).toBeTruthy();
|
|
51
|
+
expect(img).toBeTruthy();
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const paraLeft = textLeft(para as HTMLElement);
|
|
54
|
+
const imageLeft = (img as HTMLElement).getBoundingClientRect().left;
|
|
55
|
+
// Within a pixel of the text inset (previously 6px to the left).
|
|
56
|
+
expect(Math.abs(imageLeft - paraLeft)).toBeLessThanOrEqual(1.5);
|
|
57
|
+
});
|
|
57
58
|
});
|
|
@@ -4,60 +4,61 @@ import { setMarkdownEditorFocused } from "@src/lib/markdown/editor/decorations/e
|
|
|
4
4
|
import { MarkdownEditor } from "@src/primitives/MarkdownEditor";
|
|
5
5
|
import { MANTINE_THEME } from "@src/theme/mantine";
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
|
+
|
|
7
8
|
import { getEditorView, mountStory, nextFrame, sleep } from "../../_setup/e2e-helpers";
|
|
8
9
|
|
|
9
10
|
const IMAGE_DOC = "\n\nParagraph after.\n";
|
|
10
11
|
|
|
11
12
|
function shell(doc: string) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
return (
|
|
14
|
+
<MantineProvider
|
|
15
|
+
theme={MANTINE_THEME}
|
|
16
|
+
cssVariablesResolver={v8CssVariablesResolver}
|
|
17
|
+
forceColorScheme="dark"
|
|
18
|
+
>
|
|
19
|
+
<Paper
|
|
20
|
+
p="md"
|
|
21
|
+
withBorder
|
|
22
|
+
>
|
|
23
|
+
<MarkdownEditor
|
|
24
|
+
mode="preview"
|
|
25
|
+
document={doc}
|
|
26
|
+
autoFocus={false}
|
|
27
|
+
/>
|
|
28
|
+
</Paper>
|
|
29
|
+
</MantineProvider>
|
|
30
|
+
);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
describe("MarkdownEditor / media edit action", () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
it("shows an image preview with an edit-source action that reveals the source", async () => {
|
|
35
|
+
mountStory(shell(IMAGE_DOC));
|
|
36
|
+
const view = await getEditorView();
|
|
37
|
+
|
|
38
|
+
// Focused, with the caret away from the image, so the image renders as a
|
|
39
|
+
// preview widget rather than raw source.
|
|
40
|
+
view.focus();
|
|
41
|
+
view.dispatch({
|
|
42
|
+
selection: EditorSelection.cursor(view.state.doc.length),
|
|
43
|
+
effects: setMarkdownEditorFocused.of(true),
|
|
44
|
+
});
|
|
45
|
+
await nextFrame();
|
|
46
|
+
await nextFrame();
|
|
47
|
+
|
|
48
|
+
expect(document.querySelector(".cm-content")?.textContent).not.toContain("![A logo]");
|
|
49
|
+
expect(document.querySelector("img")).not.toBeNull();
|
|
50
|
+
|
|
51
|
+
const action = document.querySelector<HTMLButtonElement>(
|
|
52
|
+
'button[aria-label="Edit source"]',
|
|
53
|
+
);
|
|
54
|
+
expect(action).not.toBeNull();
|
|
55
|
+
|
|
56
|
+
action?.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, button: 0 }));
|
|
57
|
+
await sleep(120);
|
|
58
|
+
await nextFrame();
|
|
59
|
+
|
|
60
|
+
// The image markdown source becomes visible and is selected.
|
|
61
|
+
expect(document.querySelector(".cm-content")?.textContent).toContain("![A logo]");
|
|
62
|
+
expect(view.state.selection.main.empty).toBe(false);
|
|
63
|
+
});
|
|
63
64
|
});
|