@lapismd/mira 0.0.4 → 0.0.5
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/CHANGELOG.md +9 -0
- package/dist/extensions/index.d.ts +7 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte +20 -9
- package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editing-session.d.ts +13 -0
- package/dist/preview/editable-markdown-preview/editing-session.d.ts.map +1 -0
- package/dist/preview/editable-markdown-preview/editing-session.js +50 -0
- package/dist/preview/editable-markdown-preview/editor-surface.svelte +13 -4
- package/dist/preview/editable-markdown-preview/editor-surface.svelte.d.ts +1 -0
- package/dist/preview/editable-markdown-preview/editor-surface.svelte.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.d.ts +5 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.js +29 -0
- package/dist/preview/editable-markdown-preview.svelte +8 -6
- package/dist/preview/editable-markdown-preview.svelte.d.ts.map +1 -1
- package/package.json +5 -2
- package/dist/core/code-mirror.test.d.ts +0 -2
- package/dist/core/code-mirror.test.d.ts.map +0 -1
- package/dist/core/code-mirror.test.js +0 -68
- package/dist/core/images.test.d.ts +0 -2
- package/dist/core/images.test.d.ts.map +0 -1
- package/dist/core/images.test.js +0 -109
- package/dist/core/index.test.d.ts +0 -2
- package/dist/core/index.test.d.ts.map +0 -1
- package/dist/core/index.test.js +0 -11
- package/dist/core/markdown-actions.test.d.ts +0 -2
- package/dist/core/markdown-actions.test.d.ts.map +0 -1
- package/dist/core/markdown-actions.test.js +0 -182
- package/dist/extensions/doodle-dividers.test.d.ts +0 -2
- package/dist/extensions/doodle-dividers.test.d.ts.map +0 -1
- package/dist/extensions/doodle-dividers.test.js +0 -296
- package/dist/extensions/index.test.d.ts +0 -2
- package/dist/extensions/index.test.d.ts.map +0 -1
- package/dist/extensions/index.test.js +0 -283
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -64
- package/dist/internal/appearance-context.test.d.ts +0 -2
- package/dist/internal/appearance-context.test.d.ts.map +0 -1
- package/dist/internal/appearance-context.test.js +0 -31
- package/dist/internal/codemirror/base/index.test.d.ts +0 -2
- package/dist/internal/codemirror/base/index.test.d.ts.map +0 -1
- package/dist/internal/codemirror/base/index.test.js +0 -303
- package/dist/internal/codemirror/base/search.test.d.ts +0 -2
- package/dist/internal/codemirror/base/search.test.d.ts.map +0 -1
- package/dist/internal/codemirror/base/search.test.js +0 -155
- package/dist/internal/codemirror/base/selection-toolbar.test.d.ts +0 -2
- package/dist/internal/codemirror/base/selection-toolbar.test.d.ts.map +0 -1
- package/dist/internal/codemirror/base/selection-toolbar.test.js +0 -149
- package/dist/internal/codemirror/markdown/authoring.test.d.ts +0 -2
- package/dist/internal/codemirror/markdown/authoring.test.d.ts.map +0 -1
- package/dist/internal/codemirror/markdown/authoring.test.js +0 -222
- package/dist/internal/codemirror/markdown/index.test.d.ts +0 -2
- package/dist/internal/codemirror/markdown/index.test.d.ts.map +0 -1
- package/dist/internal/codemirror/markdown/index.test.js +0 -158
- package/dist/internal/codemirror/markdown/showcase-fixture.test.d.ts +0 -2
- package/dist/internal/codemirror/markdown/showcase-fixture.test.d.ts.map +0 -1
- package/dist/internal/codemirror/markdown/showcase-fixture.test.js +0 -50
- package/dist/internal/codemirror/rich/block-controls.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/block-controls.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/block-controls.test.js +0 -401
- package/dist/internal/codemirror/rich/block-ranges.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/block-ranges.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/block-ranges.test.js +0 -310
- package/dist/internal/codemirror/rich/block-toolbar.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/block-toolbar.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/block-toolbar.test.js +0 -178
- package/dist/internal/codemirror/rich/decorations/fold-indicators.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/decorations/fold-indicators.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/decorations/fold-indicators.test.js +0 -8
- package/dist/internal/codemirror/rich/index.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/index.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/index.test.js +0 -607
- package/dist/internal/codemirror/rich/utils/code-block-lines.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/code-block-lines.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/code-block-lines.test.js +0 -82
- package/dist/internal/codemirror/rich/utils/fenced-code.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/fenced-code.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/fenced-code.test.js +0 -12
- package/dist/internal/codemirror/rich/utils/headings.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/headings.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/headings.test.js +0 -27
- package/dist/internal/codemirror/rich/utils/height-estimates.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/height-estimates.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/height-estimates.test.js +0 -10
- package/dist/internal/codemirror/rich/utils/images.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/images.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/images.test.js +0 -37
- package/dist/internal/codemirror/rich/utils/indent.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/indent.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/indent.test.js +0 -169
- package/dist/internal/codemirror/rich/utils/inline-math.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/inline-math.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/inline-math.test.js +0 -15
- package/dist/internal/codemirror/rich/utils/links.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/links.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/links.test.js +0 -28
- package/dist/internal/codemirror/rich/utils/list-callouts.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/list-callouts.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/list-callouts.test.js +0 -47
- package/dist/internal/codemirror/rich/utils/measured-indent.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/measured-indent.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/measured-indent.test.js +0 -102
- package/dist/internal/codemirror/rich/utils/ranges.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/ranges.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/ranges.test.js +0 -22
- package/dist/internal/codemirror/rich/utils/tasks.test.d.ts +0 -2
- package/dist/internal/codemirror/rich/utils/tasks.test.d.ts.map +0 -1
- package/dist/internal/codemirror/rich/utils/tasks.test.js +0 -57
- package/dist/internal/task-states.test.d.ts +0 -2
- package/dist/internal/task-states.test.d.ts.map +0 -1
- package/dist/internal/task-states.test.js +0 -36
- package/dist/mira-code-editor.test.d.ts +0 -2
- package/dist/mira-code-editor.test.d.ts.map +0 -1
- package/dist/mira-code-editor.test.js +0 -93
- package/dist/mode-position.test.d.ts +0 -2
- package/dist/mode-position.test.d.ts.map +0 -1
- package/dist/mode-position.test.js +0 -60
- package/dist/preview/code-language.test.d.ts +0 -2
- package/dist/preview/code-language.test.d.ts.map +0 -1
- package/dist/preview/code-language.test.js +0 -12
- package/dist/preview/components/icon.test.d.ts +0 -2
- package/dist/preview/components/icon.test.d.ts.map +0 -1
- package/dist/preview/components/icon.test.js +0 -20
- package/dist/preview/editable-markdown-preview/behavior.test.d.ts +0 -2
- package/dist/preview/editable-markdown-preview/behavior.test.d.ts.map +0 -1
- package/dist/preview/editable-markdown-preview/behavior.test.js +0 -36
- package/dist/preview/editable-markdown-preview/serialized-writer.test.d.ts +0 -2
- package/dist/preview/editable-markdown-preview/serialized-writer.test.d.ts.map +0 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.test.js +0 -59
- package/dist/preview/embed-target.test.d.ts +0 -2
- package/dist/preview/embed-target.test.d.ts.map +0 -1
- package/dist/preview/embed-target.test.js +0 -78
- package/dist/preview/frontmatter/frontmatter.test.d.ts +0 -2
- package/dist/preview/frontmatter/frontmatter.test.d.ts.map +0 -1
- package/dist/preview/frontmatter/frontmatter.test.js +0 -190
- package/dist/preview/frontmatter/suggestions.test.d.ts +0 -2
- package/dist/preview/frontmatter/suggestions.test.d.ts.map +0 -1
- package/dist/preview/frontmatter/suggestions.test.js +0 -45
- package/dist/preview/outline.test.d.ts +0 -2
- package/dist/preview/outline.test.d.ts.map +0 -1
- package/dist/preview/outline.test.js +0 -98
- package/dist/preview/portable-surfaces.test.d.ts +0 -2
- package/dist/preview/portable-surfaces.test.d.ts.map +0 -1
- package/dist/preview/portable-surfaces.test.js +0 -513
- package/dist/preview/preview.test.d.ts +0 -2
- package/dist/preview/preview.test.d.ts.map +0 -1
- package/dist/preview/preview.test.js +0 -154
- package/dist/preview/remark/callouts.test.d.ts +0 -2
- package/dist/preview/remark/callouts.test.d.ts.map +0 -1
- package/dist/preview/remark/callouts.test.js +0 -23
- package/dist/preview/remark/custom-checklists.test.d.ts +0 -2
- package/dist/preview/remark/custom-checklists.test.d.ts.map +0 -1
- package/dist/preview/remark/custom-checklists.test.js +0 -51
- package/dist/preview/remark/links.test.d.ts +0 -2
- package/dist/preview/remark/links.test.d.ts.map +0 -1
- package/dist/preview/remark/links.test.js +0 -62
- package/dist/preview/remark/parity.test.d.ts +0 -2
- package/dist/preview/remark/parity.test.d.ts.map +0 -1
- package/dist/preview/remark/parity.test.js +0 -105
- package/dist/preview/styles/frontmatter-properties.test.d.ts +0 -2
- package/dist/preview/styles/frontmatter-properties.test.d.ts.map +0 -1
- package/dist/preview/styles/frontmatter-properties.test.js +0 -57
- package/dist/preview/styles/source-mode.test.d.ts +0 -2
- package/dist/preview/styles/source-mode.test.d.ts.map +0 -1
- package/dist/preview/styles/source-mode.test.js +0 -28
- package/dist/tables/extension.test.d.ts +0 -2
- package/dist/tables/extension.test.d.ts.map +0 -1
- package/dist/tables/extension.test.js +0 -100
- package/dist/tables/grid-editor-column.test.d.ts +0 -2
- package/dist/tables/grid-editor-column.test.d.ts.map +0 -1
- package/dist/tables/grid-editor-column.test.js +0 -27
- package/dist/tables/grid-table.test.d.ts +0 -2
- package/dist/tables/grid-table.test.d.ts.map +0 -1
- package/dist/tables/grid-table.test.js +0 -140
- package/dist/tables/index.test.d.ts +0 -2
- package/dist/tables/index.test.d.ts.map +0 -1
- package/dist/tables/index.test.js +0 -7
- package/dist/tables/inline-editor-extensions.test.d.ts +0 -2
- package/dist/tables/inline-editor-extensions.test.d.ts.map +0 -1
- package/dist/tables/inline-editor-extensions.test.js +0 -23
- package/dist/tables/pipe-table.test.d.ts +0 -2
- package/dist/tables/pipe-table.test.d.ts.map +0 -1
- package/dist/tables/pipe-table.test.js +0 -13
- package/dist/tables/table-node.test.d.ts +0 -2
- package/dist/tables/table-node.test.d.ts.map +0 -1
- package/dist/tables/table-node.test.js +0 -167
- package/dist/tables/widgets/source-button.test.d.ts +0 -2
- package/dist/tables/widgets/source-button.test.d.ts.map +0 -1
- package/dist/tables/widgets/source-button.test.js +0 -11
- package/dist/themes/theme-contract.test.d.ts +0 -2
- package/dist/themes/theme-contract.test.d.ts.map +0 -1
- package/dist/themes/theme-contract.test.js +0 -88
- package/dist/ui/index.test.d.ts +0 -2
- package/dist/ui/index.test.d.ts.map +0 -1
- package/dist/ui/index.test.js +0 -7
- package/dist/ui/styles.test.d.ts +0 -2
- package/dist/ui/styles.test.d.ts.map +0 -1
- package/dist/ui/styles.test.js +0 -26
- package/dist/ui/table-dnd/table-dnd-utils.test.d.ts +0 -2
- package/dist/ui/table-dnd/table-dnd-utils.test.d.ts.map +0 -1
- package/dist/ui/table-dnd/table-dnd-utils.test.js +0 -46
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ensureSyntaxTree } from "@codemirror/language";
|
|
2
|
-
import { markdown } from "@codemirror/lang-markdown";
|
|
3
|
-
import { EditorState } from "@codemirror/state";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { buildCodeBlockLineDecorations, isFencedCodeLine, } from "./code-block-lines";
|
|
6
|
-
function lineClasses(source) {
|
|
7
|
-
const state = EditorState.create({
|
|
8
|
-
doc: source,
|
|
9
|
-
});
|
|
10
|
-
const classes = [];
|
|
11
|
-
buildCodeBlockLineDecorations(state).between(0, state.doc.length, (_from, _to, decoration) => {
|
|
12
|
-
if (decoration.spec.class) {
|
|
13
|
-
classes.push(decoration.spec.class);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return classes;
|
|
17
|
-
}
|
|
18
|
-
describe("code block line decorations", () => {
|
|
19
|
-
it("marks every explicit text-fence line for source no-wrap geometry", () => {
|
|
20
|
-
const classes = lineClasses(["```text", "A very long text diagram line", "```"].join("\n"));
|
|
21
|
-
expect(classes).toHaveLength(3);
|
|
22
|
-
expect(classes).toEqual([
|
|
23
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code cm-formatting-code-language-text cm-formatting-code-start",
|
|
24
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code cm-formatting-code-language-text",
|
|
25
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code cm-formatting-code-language-text cm-formatting-code-end",
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
it("keeps other fenced languages with code chrome and start/end radius hooks", () => {
|
|
29
|
-
const classes = lineClasses("```mermaid\nflowchart LR\n```");
|
|
30
|
-
expect(classes).toEqual([
|
|
31
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code cm-formatting-code-start",
|
|
32
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code",
|
|
33
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-formatting-code cm-formatting-code-end",
|
|
34
|
-
]);
|
|
35
|
-
});
|
|
36
|
-
it("detects fenced body lines for indent suppression", () => {
|
|
37
|
-
const state = EditorState.create({
|
|
38
|
-
doc: ["~~~mermaid", " Source --> LivePreview", "~~~", " outside"].join("\n"),
|
|
39
|
-
});
|
|
40
|
-
expect(isFencedCodeLine(state, 1)).toBe(true);
|
|
41
|
-
expect(isFencedCodeLine(state, 2)).toBe(true);
|
|
42
|
-
expect(isFencedCodeLine(state, 3)).toBe(true);
|
|
43
|
-
expect(isFencedCodeLine(state, 4)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
it("marks an indented code block as one continuous block", () => {
|
|
46
|
-
const source = [
|
|
47
|
-
"4. Preformatted text in a list item:",
|
|
48
|
-
"",
|
|
49
|
-
" First preformatted line",
|
|
50
|
-
" Second preformatted line",
|
|
51
|
-
].join("\n");
|
|
52
|
-
const state = EditorState.create({
|
|
53
|
-
doc: source,
|
|
54
|
-
extensions: [markdown()],
|
|
55
|
-
});
|
|
56
|
-
const classes = lineClassesWithState(state);
|
|
57
|
-
expect(classes).toEqual([
|
|
58
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-indented-codeblock cm-indented-codeblock-start",
|
|
59
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-indented-codeblock cm-indented-codeblock-end",
|
|
60
|
-
]);
|
|
61
|
-
});
|
|
62
|
-
it("gives a one-line indented code block both edge hooks", () => {
|
|
63
|
-
const state = EditorState.create({
|
|
64
|
-
doc: " one line of preformatted code",
|
|
65
|
-
extensions: [markdown()],
|
|
66
|
-
});
|
|
67
|
-
expect(lineClassesWithState(state)).toEqual([
|
|
68
|
-
"HyperMD-codeblock HyperMD-codeblock-bg cm-indented-codeblock cm-indented-codeblock-start cm-indented-codeblock-end",
|
|
69
|
-
]);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
function lineClassesWithState(state) {
|
|
73
|
-
const classes = [];
|
|
74
|
-
const tree = ensureSyntaxTree(state, state.doc.length, 100);
|
|
75
|
-
expect(tree).not.toBeNull();
|
|
76
|
-
buildCodeBlockLineDecorations(state, tree).between(0, state.doc.length, (_from, _to, decoration) => {
|
|
77
|
-
if (decoration.spec.class) {
|
|
78
|
-
classes.push(decoration.spec.class);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return classes;
|
|
82
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fenced-code.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/fenced-code.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getFencedCodeLanguage, getFencedCodeWidgetRange } from "./fenced-code";
|
|
3
|
-
describe("fenced code helpers", () => {
|
|
4
|
-
it("detects fenced code language and replacement range", () => {
|
|
5
|
-
const markdown = "```mermaid\ngraph TD\n A --> B\n```\n";
|
|
6
|
-
expect(getFencedCodeLanguage(markdown)).toBe("mermaid");
|
|
7
|
-
expect(getFencedCodeWidgetRange(markdown)).toEqual({
|
|
8
|
-
from: 0,
|
|
9
|
-
to: markdown.trimEnd().length,
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"headings.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/headings.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EditorState } from "@codemirror/state";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { getAtxHeadingMarkerRange, selectionTouchesLine } from "./headings";
|
|
4
|
-
describe("heading utilities", () => {
|
|
5
|
-
it("resolves ATX heading marker ranges including trailing marker space", () => {
|
|
6
|
-
expect(getAtxHeadingMarkerRange("### Heading", 5)).toEqual({
|
|
7
|
-
from: 5,
|
|
8
|
-
to: 9,
|
|
9
|
-
});
|
|
10
|
-
expect(getAtxHeadingMarkerRange("# Spaced", 0)).toEqual({
|
|
11
|
-
from: 0,
|
|
12
|
-
to: 3,
|
|
13
|
-
});
|
|
14
|
-
expect(getAtxHeadingMarkerRange("Not a heading", 0)).toBeNull();
|
|
15
|
-
expect(getAtxHeadingMarkerRange("###NoSpace", 0)).toBeNull();
|
|
16
|
-
});
|
|
17
|
-
it("treats the whole heading line as active for syntax reveal", () => {
|
|
18
|
-
const state = EditorState.create({
|
|
19
|
-
doc: "# Heading\nParagraph",
|
|
20
|
-
selection: { anchor: 4 },
|
|
21
|
-
});
|
|
22
|
-
const headingLine = state.doc.line(1);
|
|
23
|
-
const paragraphLine = state.doc.line(2);
|
|
24
|
-
expect(selectionTouchesLine(state, headingLine.from, headingLine.to)).toBe(true);
|
|
25
|
-
expect(selectionTouchesLine(state, paragraphLine.from, paragraphLine.to)).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"height-estimates.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/height-estimates.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { estimateMarkdownBlockHeight } from "./height-estimates";
|
|
3
|
-
describe("height estimates", () => {
|
|
4
|
-
it("uses a Mermaid minimum height estimate", () => {
|
|
5
|
-
expect(estimateMarkdownBlockHeight("```mermaid\ngraph TD\n```")).toBe(200);
|
|
6
|
-
});
|
|
7
|
-
it("keeps live table height estimates close to the row count", () => {
|
|
8
|
-
expect(estimateMarkdownBlockHeight("| A |\n| --- |\n| x |")).toBe(96);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"images.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/images.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { findMarkdownImageRanges, isStandaloneMarkdownImageLine, resolveMarkdownImageWidgetSource, } from "./images";
|
|
3
|
-
describe("markdown image helpers", () => {
|
|
4
|
-
it("finds inline destination images and skips wiki embeds / code", () => {
|
|
5
|
-
expect(findMarkdownImageRanges('See  and ![[Note]]')).toEqual([
|
|
6
|
-
{
|
|
7
|
-
from: 4,
|
|
8
|
-
to: 46,
|
|
9
|
-
source: '',
|
|
10
|
-
},
|
|
11
|
-
]);
|
|
12
|
-
expect(findMarkdownImageRanges("code `` stays")).toEqual([]);
|
|
13
|
-
expect(findMarkdownImageRanges("![[Architecture Diagram]]")).toEqual([]);
|
|
14
|
-
});
|
|
15
|
-
it("resolves reference-style images from document definitions", () => {
|
|
16
|
-
const document = [
|
|
17
|
-
"![Reference base64][base64-red]",
|
|
18
|
-
"",
|
|
19
|
-
"[base64-red]: data:image/png;base64,abc=",
|
|
20
|
-
].join("\n");
|
|
21
|
-
expect(findMarkdownImageRanges(document.split("\n")[0], document)).toEqual([
|
|
22
|
-
{
|
|
23
|
-
from: 0,
|
|
24
|
-
to: 31,
|
|
25
|
-
source: "",
|
|
26
|
-
},
|
|
27
|
-
]);
|
|
28
|
-
expect(resolveMarkdownImageWidgetSource("![missing][nope]", document)).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
it("detects standalone image lines including data URIs", () => {
|
|
31
|
-
expect(isStandaloneMarkdownImageLine("  ")).toBe(true);
|
|
32
|
-
expect(isStandaloneMarkdownImageLine("")).toBe(true);
|
|
33
|
-
expect(isStandaloneMarkdownImageLine("![Reference base64][base64-red]")).toBe(true);
|
|
34
|
-
expect(isStandaloneMarkdownImageLine(" trailing")).toBe(false);
|
|
35
|
-
expect(isStandaloneMarkdownImageLine("![[Note]]")).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indent.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/indent.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { EditorView } from "@codemirror/view";
|
|
3
|
-
import { createMarkdownCodeMirrorExtensions } from "../../markdown";
|
|
4
|
-
import { getIndentLineLayout, getLineIndentInfo, indentGuideDecorations, normalizeIndentText, selectionTouchesIndent, shouldRenderStyledUnorderedMarker, shouldAnchorPlainIndentToListItem, splitIndentSegments, toMarkdownColumns, } from "./indent";
|
|
5
|
-
describe("indent helpers", () => {
|
|
6
|
-
it("derives Lapis-style indentation metadata", () => {
|
|
7
|
-
expect(toMarkdownColumns("\t ")).toBe(6);
|
|
8
|
-
expect(normalizeIndentText("\t ")).toBe(" ");
|
|
9
|
-
expect(splitIndentSegments(" ")).toEqual([
|
|
10
|
-
{ text: " ", guide: true },
|
|
11
|
-
{ text: " ", guide: false },
|
|
12
|
-
]);
|
|
13
|
-
expect(getLineIndentInfo(" - nested")).toEqual({
|
|
14
|
-
columns: 4,
|
|
15
|
-
depth: 2,
|
|
16
|
-
kind: "ul",
|
|
17
|
-
text: " ",
|
|
18
|
-
});
|
|
19
|
-
expect(getLineIndentInfo(" continuation")).toEqual({
|
|
20
|
-
columns: 2,
|
|
21
|
-
depth: 1,
|
|
22
|
-
kind: "plain",
|
|
23
|
-
text: " ",
|
|
24
|
-
});
|
|
25
|
-
expect(selectionTouchesIndent(2, 2, 0, 4)).toBe(true);
|
|
26
|
-
expect(selectionTouchesIndent(5, 5, 0, 4)).toBe(false);
|
|
27
|
-
expect(shouldRenderStyledUnorderedMarker(true, 12, 10)).toBe(true);
|
|
28
|
-
expect(shouldRenderStyledUnorderedMarker(false, 12, 10)).toBe(false);
|
|
29
|
-
expect(shouldRenderStyledUnorderedMarker(true, 10, 10)).toBe(false);
|
|
30
|
-
expect(shouldRenderStyledUnorderedMarker(true, 11, 10)).toBe(false);
|
|
31
|
-
expect(shouldAnchorPlainIndentToListItem(2, 2)).toBe(true);
|
|
32
|
-
expect(shouldAnchorPlainIndentToListItem(8, 3)).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
it("styles inactive dash and asterisk markers only in live preview", async () => {
|
|
35
|
-
const parent = document.createElement("div");
|
|
36
|
-
document.body.append(parent);
|
|
37
|
-
const view = new EditorView({
|
|
38
|
-
doc: ["# List markers", "", "- Dash item", "* Asterisk item"].join("\n"),
|
|
39
|
-
extensions: [
|
|
40
|
-
createMarkdownCodeMirrorExtensions(),
|
|
41
|
-
indentGuideDecorations({ livePreview: true }),
|
|
42
|
-
],
|
|
43
|
-
parent,
|
|
44
|
-
});
|
|
45
|
-
await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));
|
|
46
|
-
const markerFor = (snippet) => [...parent.querySelectorAll(".cm-line")]
|
|
47
|
-
.find((line) => (line.textContent || "").includes(snippet))
|
|
48
|
-
?.querySelector(".cm-formatting-list-ul");
|
|
49
|
-
expect(markerFor("Dash item")?.textContent).toBe("- ");
|
|
50
|
-
expect(markerFor("Dash item")?.classList).toContain("cm-formatting-list-bullet");
|
|
51
|
-
expect(markerFor("Asterisk item")?.textContent).toBe("* ");
|
|
52
|
-
expect(markerFor("Asterisk item")?.classList).toContain("cm-formatting-list-bullet");
|
|
53
|
-
view.dispatch({ selection: { anchor: view.state.doc.line(3).from } });
|
|
54
|
-
expect(markerFor("Dash item")?.classList).not.toContain("cm-formatting-list-bullet");
|
|
55
|
-
expect(markerFor("Asterisk item")?.classList).toContain("cm-formatting-list-bullet");
|
|
56
|
-
view.destroy();
|
|
57
|
-
parent.remove();
|
|
58
|
-
});
|
|
59
|
-
it("derives authored prefixes for top-level, quoted, and plain lines", () => {
|
|
60
|
-
expect(getIndentLineLayout("- wrapped item")).toMatchObject({
|
|
61
|
-
fallbackColumns: 2,
|
|
62
|
-
indentText: "",
|
|
63
|
-
kind: "ul",
|
|
64
|
-
listKind: "ul",
|
|
65
|
-
markerFrom: 0,
|
|
66
|
-
markerTo: 2,
|
|
67
|
-
});
|
|
68
|
-
expect(getIndentLineLayout("> 1. quoted item")).toMatchObject({
|
|
69
|
-
fallbackColumns: 5,
|
|
70
|
-
indentText: "",
|
|
71
|
-
kind: "quote-list",
|
|
72
|
-
listKind: "ol",
|
|
73
|
-
quoteFrom: 0,
|
|
74
|
-
quoteTo: 2,
|
|
75
|
-
});
|
|
76
|
-
expect(getIndentLineLayout("> quoted paragraph")).toMatchObject({
|
|
77
|
-
fallbackColumns: 2,
|
|
78
|
-
indentText: "",
|
|
79
|
-
kind: "quote",
|
|
80
|
-
quoteFrom: 0,
|
|
81
|
-
quoteTo: 2,
|
|
82
|
-
});
|
|
83
|
-
expect(getIndentLineLayout(" > indented quote")).toMatchObject({
|
|
84
|
-
fallbackColumns: 6,
|
|
85
|
-
indentText: " ",
|
|
86
|
-
kind: "quote",
|
|
87
|
-
quoteFrom: 4,
|
|
88
|
-
quoteTo: 6,
|
|
89
|
-
});
|
|
90
|
-
expect(getIndentLineLayout(" continuation")).toMatchObject({
|
|
91
|
-
fallbackColumns: 4,
|
|
92
|
-
indentText: " ",
|
|
93
|
-
kind: "plain",
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
it("does not apply hanging indent inside fenced code blocks", async () => {
|
|
97
|
-
const parent = document.createElement("div");
|
|
98
|
-
document.body.append(parent);
|
|
99
|
-
const view = new EditorView({
|
|
100
|
-
doc: [
|
|
101
|
-
"~~~mermaid",
|
|
102
|
-
" Source --> LivePreview",
|
|
103
|
-
" LivePreview --> Preview",
|
|
104
|
-
"~~~",
|
|
105
|
-
" outside continuation",
|
|
106
|
-
].join("\n"),
|
|
107
|
-
extensions: indentGuideDecorations({ livePreview: false }),
|
|
108
|
-
parent,
|
|
109
|
-
});
|
|
110
|
-
await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));
|
|
111
|
-
const fenceBody = [...parent.querySelectorAll(".cm-line")].filter((line) => (line.textContent || "").includes("Source --> LivePreview"));
|
|
112
|
-
expect(fenceBody.length).toBe(1);
|
|
113
|
-
expect(fenceBody[0]?.classList.contains("indented-wrapped-line")).toBe(false);
|
|
114
|
-
expect(fenceBody[0]?.querySelector(".cm-hmd-list-indent")).toBeNull();
|
|
115
|
-
const outside = [...parent.querySelectorAll(".cm-line")].find((line) => (line.textContent || "").includes("outside continuation"));
|
|
116
|
-
expect(outside?.classList.contains("indented-wrapped-line")).toBe(true);
|
|
117
|
-
view.destroy();
|
|
118
|
-
parent.remove();
|
|
119
|
-
});
|
|
120
|
-
it("anchors list continuations through syntax-tree ownership", async () => {
|
|
121
|
-
const parent = document.createElement("div");
|
|
122
|
-
document.body.append(parent);
|
|
123
|
-
const view = new EditorView({
|
|
124
|
-
doc: [
|
|
125
|
-
"- Bullet item",
|
|
126
|
-
" This single-space continuation",
|
|
127
|
-
" This two-space continuation",
|
|
128
|
-
"",
|
|
129
|
-
"2. Multiple paragraphs:",
|
|
130
|
-
" First ordered continuation",
|
|
131
|
-
"",
|
|
132
|
-
" Second ordered continuation",
|
|
133
|
-
"",
|
|
134
|
-
"4. Preformatted content:",
|
|
135
|
-
"",
|
|
136
|
-
" Eight-space preformatted content",
|
|
137
|
-
].join("\n"),
|
|
138
|
-
extensions: [
|
|
139
|
-
createMarkdownCodeMirrorExtensions(),
|
|
140
|
-
indentGuideDecorations({ livePreview: false }),
|
|
141
|
-
],
|
|
142
|
-
parent,
|
|
143
|
-
});
|
|
144
|
-
await new Promise((resolve) => requestAnimationFrame(() => resolve(null)));
|
|
145
|
-
const lineContaining = (snippet) => [...parent.querySelectorAll(".cm-line")].find((line) => (line.textContent || "").includes(snippet));
|
|
146
|
-
const bullet = lineContaining("Bullet item");
|
|
147
|
-
const ordered = lineContaining("Multiple paragraphs");
|
|
148
|
-
const single = lineContaining("single-space continuation");
|
|
149
|
-
const two = lineContaining("two-space continuation");
|
|
150
|
-
const first = lineContaining("First ordered continuation");
|
|
151
|
-
const second = lineContaining("Second ordered continuation");
|
|
152
|
-
const preformatted = lineContaining("Eight-space preformatted content");
|
|
153
|
-
expect(bullet?.dataset["indentAnchorLineFrom"]).toBeUndefined();
|
|
154
|
-
expect(bullet?.classList.contains("cm-formatting-list-ul")).toBe(false);
|
|
155
|
-
expect(bullet?.querySelector(".cm-formatting-list-ul")).not.toBeNull();
|
|
156
|
-
expect(single?.dataset["indentAnchorLineFrom"]).toBe(`${view.state.doc.line(1).from}`);
|
|
157
|
-
expect(two?.dataset["indentAnchorLineFrom"]).toBe(`${view.state.doc.line(1).from}`);
|
|
158
|
-
expect(two?.getAttribute("style")).toContain("--hmd-indent-widget-prefix-fallback: var(--list-indent)");
|
|
159
|
-
expect(two?.getAttribute("style")).toContain("--hmd-indent-padding-fallback: 2ch");
|
|
160
|
-
expect(first?.dataset["indentAnchorLineFrom"]).toBe(`${view.state.doc.line(5).from}`);
|
|
161
|
-
expect(second?.dataset["indentAnchorLineFrom"]).toBe(`${view.state.doc.line(5).from}`);
|
|
162
|
-
expect(ordered?.classList.contains("cm-formatting-list-ol")).toBe(false);
|
|
163
|
-
expect(preformatted?.dataset["indentAnchorLineFrom"]).toBeUndefined();
|
|
164
|
-
expect(preformatted?.querySelectorAll(".cm-indent-guide")).toHaveLength(2);
|
|
165
|
-
expect(preformatted?.getAttribute("style")).toContain("--hmd-indent-widget-prefix-fallback: calc(var(--list-indent) + var(--list-indent))");
|
|
166
|
-
view.destroy();
|
|
167
|
-
parent.remove();
|
|
168
|
-
});
|
|
169
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inline-math.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/inline-math.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { findInlineMathRanges } from "./inline-math";
|
|
3
|
-
describe("inline math helpers", () => {
|
|
4
|
-
it("finds inline math ranges while avoiding code and block math", () => {
|
|
5
|
-
expect(findInlineMathRanges("Math $E = mc^2$ works")).toEqual([
|
|
6
|
-
{ from: 5, to: 15, source: "$E = mc^2$" },
|
|
7
|
-
]);
|
|
8
|
-
expect(findInlineMathRanges("Cost is $5 and code `$x$`")).toEqual([]);
|
|
9
|
-
expect(findInlineMathRanges("Block $$x = y$$ stays source")).toEqual([]);
|
|
10
|
-
expect(findInlineMathRanges("Escaped \\$x$ stays source")).toEqual([]);
|
|
11
|
-
});
|
|
12
|
-
it("does not treat block math as inline math", () => {
|
|
13
|
-
expect(findInlineMathRanges("$$\nx = y\n$$")).toEqual([]);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/links.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getMarkdownLinkTextRange, isBareExternalAutolinkUrl, isExternalMarkdownDestination, isExternalMarkdownLink, } from "./links";
|
|
3
|
-
describe("link helpers", () => {
|
|
4
|
-
it("classifies external markdown links and bare autolinks", () => {
|
|
5
|
-
expect(isExternalMarkdownDestination("https://example.com")).toBe(true);
|
|
6
|
-
expect(isExternalMarkdownDestination("//example.com")).toBe(true);
|
|
7
|
-
expect(isExternalMarkdownDestination("notes/architecture.md")).toBe(false);
|
|
8
|
-
expect(isExternalMarkdownLink("[external](https://example.com)")).toBe(true);
|
|
9
|
-
expect(isExternalMarkdownLink("[internal](notes/architecture.md)")).toBe(false);
|
|
10
|
-
expect(isBareExternalAutolinkUrl("URL", undefined, "https://example.com")).toBe(true);
|
|
11
|
-
expect(isBareExternalAutolinkUrl("URL", "Link", "https://example.com")).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
it("resolves decorated text ranges for markdown links", () => {
|
|
14
|
-
expect(getMarkdownLinkTextRange("[label](target.md)", 10, 28)).toEqual({
|
|
15
|
-
from: 11,
|
|
16
|
-
to: 16,
|
|
17
|
-
});
|
|
18
|
-
expect(getMarkdownLinkTextRange("<https://example.com>", 20, 41)).toEqual({
|
|
19
|
-
from: 21,
|
|
20
|
-
to: 40,
|
|
21
|
-
});
|
|
22
|
-
expect(getMarkdownLinkTextRange("https://example.com", 30, 49)).toEqual({
|
|
23
|
-
from: 30,
|
|
24
|
-
to: 49,
|
|
25
|
-
});
|
|
26
|
-
expect(getMarkdownLinkTextRange("not a link", 0, 10)).toBeNull();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-callouts.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/list-callouts.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getListCalloutMarkerRange } from "./list-callouts";
|
|
3
|
-
describe("list callout utilities", () => {
|
|
4
|
-
it("resolves Lapis default list callout markers", () => {
|
|
5
|
-
expect(getListCalloutMarkerRange("- & Highlighted item", 0)).toMatchObject({
|
|
6
|
-
markerStart: 2,
|
|
7
|
-
markerEnd: 3,
|
|
8
|
-
removeEnd: 4,
|
|
9
|
-
marker: "&",
|
|
10
|
-
color: "255, 214, 0",
|
|
11
|
-
});
|
|
12
|
-
expect(getListCalloutMarkerRange(" 1. ? Question", 10)).toMatchObject({
|
|
13
|
-
markerStart: 15,
|
|
14
|
-
markerEnd: 16,
|
|
15
|
-
removeEnd: 17,
|
|
16
|
-
marker: "?",
|
|
17
|
-
color: "255, 145, 0",
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
it("supports task list callout markers after the checkbox token", () => {
|
|
21
|
-
expect(getListCalloutMarkerRange("- [ ] ! Warning", 0)).toMatchObject({
|
|
22
|
-
markerStart: 6,
|
|
23
|
-
markerEnd: 7,
|
|
24
|
-
removeEnd: 8,
|
|
25
|
-
marker: "!",
|
|
26
|
-
color: "255, 23, 68",
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
it("uses injected markers and disabled defaults", () => {
|
|
30
|
-
const callouts = [
|
|
31
|
-
{ char: "&", enabled: false },
|
|
32
|
-
{ char: "^^", color: "80, 70, 220", icon: "bookmark" },
|
|
33
|
-
];
|
|
34
|
-
expect(getListCalloutMarkerRange("- ^^ Custom", 4, callouts)).toMatchObject({
|
|
35
|
-
markerStart: 6,
|
|
36
|
-
markerEnd: 8,
|
|
37
|
-
removeEnd: 9,
|
|
38
|
-
marker: "^^",
|
|
39
|
-
color: "80, 70, 220",
|
|
40
|
-
callout: {
|
|
41
|
-
char: "^^",
|
|
42
|
-
icon: "bookmark",
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
expect(getListCalloutMarkerRange("- & Plain", 0, callouts)).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"measured-indent.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/measured-indent.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { measureIndentSegmentWidth, syncMeasuredIndentStyles, } from "./measured-indent";
|
|
3
|
-
function appendLine(root, from) {
|
|
4
|
-
const line = document.createElement("div");
|
|
5
|
-
line.className = "cm-line";
|
|
6
|
-
line.dataset["lineFrom"] = `${from}`;
|
|
7
|
-
root.append(line);
|
|
8
|
-
return line;
|
|
9
|
-
}
|
|
10
|
-
function domRect(width) {
|
|
11
|
-
return {
|
|
12
|
-
bottom: 16,
|
|
13
|
-
height: 16,
|
|
14
|
-
left: 0,
|
|
15
|
-
right: width,
|
|
16
|
-
toJSON: () => ({}),
|
|
17
|
-
top: 0,
|
|
18
|
-
width,
|
|
19
|
-
x: 0,
|
|
20
|
-
y: 0,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function mockTextRangeMeasurements(characterWidth) {
|
|
24
|
-
vi.spyOn(document, "createRange").mockImplementation(() => {
|
|
25
|
-
let node = null;
|
|
26
|
-
let end = 0;
|
|
27
|
-
const range = {
|
|
28
|
-
setStart(nextNode) {
|
|
29
|
-
node = nextNode;
|
|
30
|
-
},
|
|
31
|
-
setEnd(_nextNode, nextEnd) {
|
|
32
|
-
end = nextEnd;
|
|
33
|
-
},
|
|
34
|
-
getClientRects() {
|
|
35
|
-
const width = (node?.data.slice(0, end).length ?? 0) * characterWidth;
|
|
36
|
-
return [domRect(width)];
|
|
37
|
-
},
|
|
38
|
-
getBoundingClientRect() {
|
|
39
|
-
const width = (node?.data.slice(0, end).length ?? 0) * characterWidth;
|
|
40
|
-
return domRect(width);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
return range;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
vi.restoreAllMocks();
|
|
48
|
-
});
|
|
49
|
-
describe("measured indent styles", () => {
|
|
50
|
-
it("measures plain spacer text instead of its minimum guide slot", () => {
|
|
51
|
-
mockTextRangeMeasurements(8);
|
|
52
|
-
const spacer = document.createElement("span");
|
|
53
|
-
spacer.className = "cm-indent cm-indent-spacer";
|
|
54
|
-
spacer.textContent = " ";
|
|
55
|
-
vi.spyOn(spacer, "getBoundingClientRect").mockReturnValue(domRect(32));
|
|
56
|
-
expect(measureIndentSegmentWidth(spacer)).toBe(16);
|
|
57
|
-
});
|
|
58
|
-
it("keeps guide segments measured by their rendered slot", () => {
|
|
59
|
-
mockTextRangeMeasurements(8);
|
|
60
|
-
const guide = document.createElement("span");
|
|
61
|
-
guide.className = "cm-indent cm-indent-guide";
|
|
62
|
-
guide.textContent = " ";
|
|
63
|
-
vi.spyOn(guide, "getBoundingClientRect").mockReturnValue(domRect(32));
|
|
64
|
-
expect(measureIndentSegmentWidth(guide)).toBe(32);
|
|
65
|
-
});
|
|
66
|
-
it("only writes changed measurements", () => {
|
|
67
|
-
const root = document.createElement("div");
|
|
68
|
-
const line = appendLine(root, 10);
|
|
69
|
-
line.style.setProperty("--hmd-indent-padding-measured", "24px");
|
|
70
|
-
line.style.setProperty("--hmd-indent-prefix-measured", "8px");
|
|
71
|
-
const setProperty = vi.spyOn(line.style, "setProperty");
|
|
72
|
-
syncMeasuredIndentStyles(root, new Map([[10, { paddingPx: 24, prefixPx: 8 }]]));
|
|
73
|
-
expect(setProperty).not.toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
it("removes measurements from lines that no longer carry a prefix", () => {
|
|
76
|
-
const root = document.createElement("div");
|
|
77
|
-
const line = appendLine(root, 10);
|
|
78
|
-
line.style.setProperty("--hmd-indent-padding-measured", "24px");
|
|
79
|
-
line.style.setProperty("--hmd-indent-prefix-measured", "8px");
|
|
80
|
-
syncMeasuredIndentStyles(root, new Map());
|
|
81
|
-
expect(line.style.getPropertyValue("--hmd-indent-padding-measured")).toBe("");
|
|
82
|
-
expect(line.style.getPropertyValue("--hmd-indent-prefix-measured")).toBe("");
|
|
83
|
-
});
|
|
84
|
-
it("preserves a participating line omitted by a transitional read", () => {
|
|
85
|
-
const root = document.createElement("div");
|
|
86
|
-
const line = appendLine(root, 10);
|
|
87
|
-
line.dataset["indentPrefix"] = " ";
|
|
88
|
-
line.style.setProperty("--hmd-indent-padding-measured", "24px");
|
|
89
|
-
line.style.setProperty("--hmd-indent-prefix-measured", "8px");
|
|
90
|
-
syncMeasuredIndentStyles(root, new Map());
|
|
91
|
-
expect(line.style.getPropertyValue("--hmd-indent-padding-measured")).toBe("24px");
|
|
92
|
-
expect(line.style.getPropertyValue("--hmd-indent-prefix-measured")).toBe("8px");
|
|
93
|
-
});
|
|
94
|
-
it("keeps the last measured padding when the parent temporarily falls back", () => {
|
|
95
|
-
const root = document.createElement("div");
|
|
96
|
-
const line = appendLine(root, 10);
|
|
97
|
-
line.style.setProperty("--hmd-indent-padding-measured", "24px");
|
|
98
|
-
syncMeasuredIndentStyles(root, new Map([[10, { paddingPx: null, prefixPx: 32 }]]));
|
|
99
|
-
expect(line.style.getPropertyValue("--hmd-indent-padding-measured")).toBe("24px");
|
|
100
|
-
expect(line.style.getPropertyValue("--hmd-indent-prefix-measured")).toBe("32px");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ranges.test.d.ts","sourceRoot":"","sources":["../../../../../src/internal/codemirror/rich/utils/ranges.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EditorState } from "@codemirror/state";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { hasRenderedInitialFrontmatterCursor } from "./ranges";
|
|
4
|
-
describe("range utilities", () => {
|
|
5
|
-
it("detects the hidden live-preview cursor state at rendered frontmatter start", () => {
|
|
6
|
-
const state = EditorState.create({
|
|
7
|
-
doc: "---\ntitle: Demo\n---\n# Heading",
|
|
8
|
-
selection: { anchor: 0 },
|
|
9
|
-
});
|
|
10
|
-
expect(hasRenderedInitialFrontmatterCursor(state)).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
it("does not hide the cursor for normal document starts or frontmatter source edits", () => {
|
|
13
|
-
expect(hasRenderedInitialFrontmatterCursor(EditorState.create({
|
|
14
|
-
doc: "# Heading",
|
|
15
|
-
selection: { anchor: 0 },
|
|
16
|
-
}))).toBe(false);
|
|
17
|
-
expect(hasRenderedInitialFrontmatterCursor(EditorState.create({
|
|
18
|
-
doc: "---\ntitle: Demo\n---\n# Heading",
|
|
19
|
-
selection: { anchor: 5 },
|
|
20
|
-
}))).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
});
|