@lapismd/mira 0.0.4 → 0.1.0
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 +39 -0
- package/dist/extensions/index.d.ts +13 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +13 -3
- package/dist/extensions/inline-links.d.ts +8 -0
- package/dist/extensions/inline-links.d.ts.map +1 -0
- package/dist/extensions/inline-links.js +120 -0
- package/dist/extensions/markdown-editing.d.ts +32 -0
- package/dist/extensions/markdown-editing.d.ts.map +1 -0
- package/dist/extensions/markdown-editing.js +1 -0
- package/dist/internal/codemirror/base/index.d.ts.map +1 -1
- package/dist/internal/codemirror/base/index.js +3 -0
- package/dist/internal/codemirror/markdown/index.d.ts.map +1 -1
- package/dist/internal/codemirror/markdown/index.js +2 -1
- package/dist/internal/codemirror/rich/block-controls.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/block-controls.js +2 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.d.ts +15 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.d.ts.map +1 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.js +67 -0
- package/dist/internal/codemirror/rich/index.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/index.js +43 -9
- package/dist/internal/codemirror/rich/utils/images.d.ts +6 -3
- package/dist/internal/codemirror/rich/utils/images.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/utils/images.js +16 -29
- package/dist/internal/codemirror/rich/utils/references.d.ts +15 -0
- package/dist/internal/codemirror/rich/utils/references.d.ts.map +1 -0
- package/dist/internal/codemirror/rich/utils/references.js +86 -0
- package/dist/internal/codemirror/rich/widgets/preview-widgets.d.ts +3 -0
- package/dist/internal/codemirror/rich/widgets/preview-widgets.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/widgets/preview-widgets.js +31 -3
- package/dist/internal/inline-links/icons.d.ts +115 -0
- package/dist/internal/inline-links/icons.d.ts.map +1 -0
- package/dist/internal/inline-links/icons.js +148 -0
- package/dist/internal/inline-links/live-preview.d.ts +5 -0
- package/dist/internal/inline-links/live-preview.d.ts.map +1 -0
- package/dist/internal/inline-links/live-preview.js +135 -0
- package/dist/internal/inline-links/registry.d.ts +44 -0
- package/dist/internal/inline-links/registry.d.ts.map +1 -0
- package/dist/internal/inline-links/registry.js +153 -0
- package/dist/mira.svelte.d.ts +1 -1
- package/dist/preview/asset-url-lease.d.ts +6 -0
- package/dist/preview/asset-url-lease.d.ts.map +1 -0
- package/dist/preview/asset-url-lease.js +28 -0
- package/dist/preview/components/embed.svelte +10 -5
- package/dist/preview/components/embed.svelte.d.ts.map +1 -1
- package/dist/preview/components/image.svelte +7 -2
- package/dist/preview/components/image.svelte.d.ts.map +1 -1
- package/dist/preview/components/inline-link.svelte +94 -0
- package/dist/preview/components/inline-link.svelte.d.ts +16 -0
- package/dist/preview/components/inline-link.svelte.d.ts.map +1 -0
- package/dist/preview/components/link-destination-tooltip.svelte +63 -0
- package/dist/preview/components/link-destination-tooltip.svelte.d.ts +7 -0
- package/dist/preview/components/link-destination-tooltip.svelte.d.ts.map +1 -0
- package/dist/preview/components/link-site-icon.svelte +39 -0
- package/dist/preview/components/link-site-icon.svelte.d.ts +10 -0
- package/dist/preview/components/link-site-icon.svelte.d.ts.map +1 -0
- package/dist/preview/components/link.svelte +19 -9
- package/dist/preview/components/link.svelte.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte +26 -10
- 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 +15 -0
- package/dist/preview/editable-markdown-preview/editing-session.d.ts.map +1 -0
- package/dist/preview/editable-markdown-preview/editing-session.js +103 -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 +10 -8
- package/dist/preview/editable-markdown-preview/serialized-writer.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.js +105 -6
- package/dist/preview/editable-markdown-preview.svelte +8 -6
- package/dist/preview/editable-markdown-preview.svelte.d.ts.map +1 -1
- package/dist/preview/index.d.ts +2 -0
- package/dist/preview/index.d.ts.map +1 -1
- package/dist/preview/index.js +2 -0
- package/dist/preview/markdown-preview.svelte +11 -0
- package/dist/preview/markdown-preview.svelte.d.ts.map +1 -1
- package/dist/preview/renderer/utils.js +0 -2
- package/dist/preview/styles/inline-links.css +38 -0
- package/dist/preview/styles/links-embeds-tags.css +2 -2
- package/dist/preview/styles/mermaid-highlight.css +4 -3
- package/dist/preview/styles/references.css +72 -0
- package/dist/preview/styles.css +2 -0
- package/dist/tables/editor-column.svelte +20 -7
- package/dist/tables/editor-column.svelte.d.ts +2 -0
- package/dist/tables/editor-column.svelte.d.ts.map +1 -1
- package/dist/tables/editor-table.svelte +4 -0
- package/dist/tables/editor-table.svelte.d.ts +2 -0
- package/dist/tables/editor-table.svelte.d.ts.map +1 -1
- package/dist/tables/grid-editor-column.svelte +6 -2
- package/dist/tables/grid-editor-column.svelte.d.ts +2 -0
- package/dist/tables/grid-editor-column.svelte.d.ts.map +1 -1
- package/dist/tables/grid-editor-table.svelte +4 -0
- package/dist/tables/grid-editor-table.svelte.d.ts +2 -0
- package/dist/tables/grid-editor-table.svelte.d.ts.map +1 -1
- package/dist/tables/index.d.ts +1 -0
- package/dist/tables/index.d.ts.map +1 -1
- package/dist/tables/index.js +1 -0
- package/dist/tables/markdown-table-data-cell.svelte +4 -0
- package/dist/tables/markdown-table-data-cell.svelte.d.ts +2 -0
- package/dist/tables/markdown-table-data-cell.svelte.d.ts.map +1 -1
- package/dist/tables/table-reader.svelte +101 -0
- package/dist/tables/table-reader.svelte.d.ts +21 -0
- package/dist/tables/table-reader.svelte.d.ts.map +1 -0
- package/dist/tables/types.d.ts +2 -0
- package/dist/tables/types.d.ts.map +1 -1
- package/dist/tables/widgets/grid-table-widget.d.ts +1 -1
- package/dist/tables/widgets/grid-table-widget.d.ts.map +1 -1
- package/dist/tables/widgets/grid-table-widget.js +5 -2
- package/dist/tables/widgets/lifecycle.d.ts +4 -0
- package/dist/tables/widgets/lifecycle.d.ts.map +1 -0
- package/dist/tables/widgets/lifecycle.js +13 -0
- package/dist/tables/widgets/pipe-table-widget.d.ts +1 -1
- package/dist/tables/widgets/pipe-table-widget.d.ts.map +1 -1
- package/dist/tables/widgets/pipe-table-widget.js +5 -2
- package/dist/ui/context-menu/context-menu-radio-group.svelte.d.ts +1 -1
- package/dist/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +1 -1
- package/dist/ui/toolbar/toolbar-group.svelte.d.ts +1 -1
- package/inline-links-NOTICE.md +31 -0
- package/package.json +6 -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,23 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createParser } from "../renderer/utils";
|
|
3
|
-
import { remarkPositionsToData } from "./hast";
|
|
4
|
-
import { remarkCallouts } from "./callouts";
|
|
5
|
-
describe("callout rendering", () => {
|
|
6
|
-
it("turns Obsidian callout blockquotes into callout elements", () => {
|
|
7
|
-
const parser = createParser([remarkCallouts]);
|
|
8
|
-
const ast = parser("> [!note] Portable package boundary\n> The editor works.");
|
|
9
|
-
const callout = ast.children.find((node) => node.type === "element" && node.tagName === "callout");
|
|
10
|
-
expect(callout?.properties?.["data-callout"]).toBe("note");
|
|
11
|
-
expect(callout?.properties?.["data-icon"]).toBe("pencil");
|
|
12
|
-
expect(callout?.properties?.title).toBe("Portable package boundary");
|
|
13
|
-
expect(JSON.stringify(callout)).not.toContain("[!note]");
|
|
14
|
-
});
|
|
15
|
-
it("preserves collapsible callout state", () => {
|
|
16
|
-
const parser = createParser([remarkCallouts, remarkPositionsToData]);
|
|
17
|
-
const ast = parser("> [!warning]- Heads up\n> Hidden.");
|
|
18
|
-
const callout = ast.children.find((node) => node.type === "element" && node.tagName === "callout");
|
|
19
|
-
expect(callout?.properties?.["data-expandable"]).toBe("true");
|
|
20
|
-
expect(callout?.properties?.["data-expanded"]).toBe("false");
|
|
21
|
-
expect(Number(callout?.properties?.["data-expand-offset"])).toBeGreaterThan(0);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-checklists.test.d.ts","sourceRoot":"","sources":["../../../src/preview/remark/custom-checklists.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createParser } from "../renderer/utils";
|
|
3
|
-
import { findElement } from "../test-utils";
|
|
4
|
-
import { remarkCustomChecklists } from "./custom-checklists";
|
|
5
|
-
describe("custom checklist rendering", () => {
|
|
6
|
-
it("turns custom task markers into GFM task items with data-task", () => {
|
|
7
|
-
const parser = createParser([remarkCustomChecklists]);
|
|
8
|
-
const ast = parser("- [/] Custom task marker");
|
|
9
|
-
const item = findElement(ast, "li");
|
|
10
|
-
expect(item?.tagName).toBe("li");
|
|
11
|
-
expect(item?.properties?.["data-task"]).toBe("/");
|
|
12
|
-
expect(JSON.stringify(item)).not.toContain("[/]");
|
|
13
|
-
});
|
|
14
|
-
it("preserves data-task for standard task items", () => {
|
|
15
|
-
const parser = createParser([remarkCustomChecklists]);
|
|
16
|
-
const ast = parser("- [x] Done");
|
|
17
|
-
const item = findElement(ast, "li");
|
|
18
|
-
expect(item?.properties?.["data-task"]).toBe("x");
|
|
19
|
-
});
|
|
20
|
-
it("supports Lapis custom task marker characters", () => {
|
|
21
|
-
const parser = createParser([remarkCustomChecklists]);
|
|
22
|
-
const markers = [
|
|
23
|
-
">",
|
|
24
|
-
"<",
|
|
25
|
-
"?",
|
|
26
|
-
"/",
|
|
27
|
-
"!",
|
|
28
|
-
'"',
|
|
29
|
-
"-",
|
|
30
|
-
"*",
|
|
31
|
-
"l",
|
|
32
|
-
"i",
|
|
33
|
-
"S",
|
|
34
|
-
"I",
|
|
35
|
-
"f",
|
|
36
|
-
"k",
|
|
37
|
-
"u",
|
|
38
|
-
"d",
|
|
39
|
-
"w",
|
|
40
|
-
"p",
|
|
41
|
-
"c",
|
|
42
|
-
"b",
|
|
43
|
-
];
|
|
44
|
-
const ast = parser(markers.map((marker) => `- [${marker}] ${marker} task`).join("\n"));
|
|
45
|
-
const serialized = JSON.stringify(ast);
|
|
46
|
-
for (const marker of markers) {
|
|
47
|
-
expect(serialized).toContain(`"data-task":${JSON.stringify(marker)}`);
|
|
48
|
-
expect(serialized).not.toContain(`[${marker}]`);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.test.d.ts","sourceRoot":"","sources":["../../../src/preview/remark/links.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createParser } from "../renderer/utils";
|
|
3
|
-
import { findElement } from "../test-utils";
|
|
4
|
-
import { isExternalMarkdownDestination, isImplicitLocalPathDestination, isLocalPathDestination, } from "./utils";
|
|
5
|
-
import { remarkExternalLinks } from "./external-links";
|
|
6
|
-
import { remarkPathLinks } from "./pathlink";
|
|
7
|
-
import { remarkWikiLinks } from "./wikilink";
|
|
8
|
-
describe("link parity plugins", () => {
|
|
9
|
-
it("marks external links with the Lapis external-link class", () => {
|
|
10
|
-
const parser = createParser([remarkExternalLinks]);
|
|
11
|
-
const ast = parser("[Example](https://example.com)");
|
|
12
|
-
const link = findElement(ast, "a");
|
|
13
|
-
expect(link?.properties?.href).toBe("https://example.com");
|
|
14
|
-
expect(link?.properties?.class).toBe("external-link");
|
|
15
|
-
expect(link?.properties?.target).toBe("_blank");
|
|
16
|
-
expect(link?.properties?.rel).toBe("noreferrer");
|
|
17
|
-
});
|
|
18
|
-
it("keeps wiki and embed links on Lapis id/text properties", () => {
|
|
19
|
-
const parser = createParser([remarkWikiLinks]);
|
|
20
|
-
const ast = parser("[[Project Plan|Plan]] and ![[Image Asset|Diagram]]");
|
|
21
|
-
const wikilink = findElement(ast, "wikilink");
|
|
22
|
-
const embed = findElement(ast, "embed");
|
|
23
|
-
expect(wikilink?.properties?.id).toBe("Project Plan");
|
|
24
|
-
expect(wikilink?.properties?.text).toBe("Plan");
|
|
25
|
-
expect(wikilink?.children).toEqual([{ type: "text", value: "Plan" }]);
|
|
26
|
-
expect(embed?.properties?.id).toBe("Image Asset");
|
|
27
|
-
expect(embed?.properties?.text).toBe("Diagram");
|
|
28
|
-
expect(embed?.children).toEqual([]);
|
|
29
|
-
});
|
|
30
|
-
it("preserves compound embed labels and dimensions", () => {
|
|
31
|
-
const parser = createParser([remarkWikiLinks]);
|
|
32
|
-
const ast = parser("![[Image Asset|Diagram|320x180]]");
|
|
33
|
-
const embed = findElement(ast, "embed");
|
|
34
|
-
expect(embed?.properties?.id).toBe("Image Asset");
|
|
35
|
-
expect(embed?.properties?.text).toBe("Diagram|320x180");
|
|
36
|
-
});
|
|
37
|
-
it("parses implicit local path links as pathlink elements", () => {
|
|
38
|
-
const parser = createParser([remarkPathLinks]);
|
|
39
|
-
const ast = parser("[Project Plan]");
|
|
40
|
-
const pathlink = findElement(ast, "pathlink");
|
|
41
|
-
expect(pathlink?.properties?.id).toBe("Project Plan");
|
|
42
|
-
expect(pathlink?.properties?.text).toBe("Project Plan");
|
|
43
|
-
});
|
|
44
|
-
it("does not consume wikilinks or embeds while parsing implicit path links", () => {
|
|
45
|
-
const parser = createParser([remarkWikiLinks, remarkPathLinks]);
|
|
46
|
-
const ast = parser("[[Project Plan|Plan]] ![[Image Asset|Diagram]] [Project Plan]");
|
|
47
|
-
expect(findElement(ast, "wikilink")?.properties?.id).toBe("Project Plan");
|
|
48
|
-
expect(findElement(ast, "embed")?.properties?.id).toBe("Image Asset");
|
|
49
|
-
expect(findElement(ast, "pathlink")?.properties?.id).toBe("Project Plan");
|
|
50
|
-
});
|
|
51
|
-
it("classifies external and local path destinations like Lapis", () => {
|
|
52
|
-
expect(isExternalMarkdownDestination("https://example.com")).toBe(true);
|
|
53
|
-
expect(isExternalMarkdownDestination("//example.com")).toBe(true);
|
|
54
|
-
expect(isExternalMarkdownDestination("mailto:test@example.com")).toBe(true);
|
|
55
|
-
expect(isExternalMarkdownDestination("tel:+15555551212")).toBe(true);
|
|
56
|
-
expect(isExternalMarkdownDestination("Project Plan.md")).toBe(false);
|
|
57
|
-
expect(isLocalPathDestination("Project Plan.md")).toBe(true);
|
|
58
|
-
expect(isLocalPathDestination("Project.md")).toBe(false);
|
|
59
|
-
expect(isImplicitLocalPathDestination("Project.md")).toBe(true);
|
|
60
|
-
expect(isImplicitLocalPathDestination("https://example.com")).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parity.test.d.ts","sourceRoot":"","sources":["../../../src/preview/remark/parity.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import remarkGfm from "remark-gfm";
|
|
3
|
-
import { createParser } from "../renderer/utils";
|
|
4
|
-
import { findElement } from "../test-utils";
|
|
5
|
-
import { rehypeHighlightLines } from "../rehype-highlight-lines";
|
|
6
|
-
import { rehypeTableSpans } from "../rehype-table-spans";
|
|
7
|
-
import { remarkHeadings } from "./headings";
|
|
8
|
-
import { remarkListCallouts } from "./list-callouts";
|
|
9
|
-
import { remarkMultimarkdownTable } from "./multimarkdown-table";
|
|
10
|
-
describe("Lapis preview parity plugins", () => {
|
|
11
|
-
it("adds Lapis heading classes and data-heading text", () => {
|
|
12
|
-
const parser = createParser([remarkHeadings]);
|
|
13
|
-
const ast = parser("## Portable **heading**");
|
|
14
|
-
const heading = findElement(ast, "h2");
|
|
15
|
-
expect(heading?.properties?.class).toBe("cm-header cm-header-2");
|
|
16
|
-
expect(heading?.properties?.["data-heading"]).toBe("Portable heading");
|
|
17
|
-
});
|
|
18
|
-
it("adds highlighted code line wrappers from fence metadata", () => {
|
|
19
|
-
const parser = createParser([], [rehypeHighlightLines]);
|
|
20
|
-
const ast = parser(["```ts {2}", "const a = 1;", "const b = 2;", "```"].join("\n"));
|
|
21
|
-
const code = findElement(ast, "code");
|
|
22
|
-
const lines = findElements(code, "span").filter((element) => String(element.properties?.class ?? "").includes("code-line"));
|
|
23
|
-
expect(lines).toHaveLength(2);
|
|
24
|
-
expect(lines[1]?.properties?.class).toContain("highlighted-code-line");
|
|
25
|
-
});
|
|
26
|
-
it("adds Lapis MultiMarkdown colspan and rowspan properties", () => {
|
|
27
|
-
const parser = createParser([remarkGfm, remarkMultimarkdownTable], [rehypeTableSpans]);
|
|
28
|
-
const ast = parser([
|
|
29
|
-
"| Package | Role | Status |",
|
|
30
|
-
"| --- | --- | --- |",
|
|
31
|
-
"| combined package | | ready |",
|
|
32
|
-
"| @lapismd/mira/core | editor controller | ready |",
|
|
33
|
-
"| ^ | rendered markdown | ready |",
|
|
34
|
-
].join("\n"));
|
|
35
|
-
const bodyRows = directElementChildren(findElement(ast, "tbody"), "tr");
|
|
36
|
-
const cells = findElements(findElement(ast, "tbody"), "td");
|
|
37
|
-
const cellWithColspan = cells.find((cell) => cell.properties?.colspan === 2);
|
|
38
|
-
const cellWithRowspan = cells.find((cell) => cell.properties?.rowspan === 2);
|
|
39
|
-
expect(bodyRows.map((row) => directElementChildren(row, "td").length)).toEqual([2, 3, 2]);
|
|
40
|
-
expect(cellWithColspan).toBeDefined();
|
|
41
|
-
expect(cellWithRowspan).toBeDefined();
|
|
42
|
-
});
|
|
43
|
-
it("does not treat trailing empty MultiMarkdown cells as colspans", () => {
|
|
44
|
-
const parser = createParser([remarkGfm, remarkMultimarkdownTable], [rehypeTableSpans]);
|
|
45
|
-
const ast = parser([
|
|
46
|
-
"| Package | Role | Status | |",
|
|
47
|
-
"| --- | --- | --- | --- |",
|
|
48
|
-
"| @lapismd/mira/core | editor controller | ready | |",
|
|
49
|
-
].join("\n"));
|
|
50
|
-
const headerCells = directElementChildren(findElement(ast, "thead"), "tr").flatMap((row) => directElementChildren(row, "th"));
|
|
51
|
-
const bodyCells = findElements(findElement(ast, "tbody"), "td");
|
|
52
|
-
expect(headerCells).toHaveLength(4);
|
|
53
|
-
expect(bodyCells).toHaveLength(4);
|
|
54
|
-
expect(headerCells[2]?.properties?.colspan).toBeUndefined();
|
|
55
|
-
expect(bodyCells[2]?.properties?.colspan).toBeUndefined();
|
|
56
|
-
});
|
|
57
|
-
it("renders Lapis default list callout markers", () => {
|
|
58
|
-
const parser = createParser([remarkGfm, remarkListCallouts]);
|
|
59
|
-
const ast = parser("- & Highlighted item\n- ? Question item");
|
|
60
|
-
const items = findElements(ast, "li");
|
|
61
|
-
const markers = findElements(ast, "span").filter((element) => String(element.properties?.class ?? "").includes("lc-list-marker"));
|
|
62
|
-
expect(items[0]?.properties?.class).toContain("lc-list-callout");
|
|
63
|
-
expect(items[0]?.properties?.["data-callout"]).toBe("&");
|
|
64
|
-
expect(items[1]?.properties?.["data-callout"]).toBe("?");
|
|
65
|
-
expect(markers.map((marker) => marker.properties?.["data-callout-char"])).toEqual(["&", "?"]);
|
|
66
|
-
expect(markers[0]?.properties?.["data-offset"]).toBe(2);
|
|
67
|
-
expect(markers[0]?.properties?.["data-offset-end"]).toBe(3);
|
|
68
|
-
});
|
|
69
|
-
it("renders an injected list callout catalog and can disable defaults", () => {
|
|
70
|
-
const parser = createParser([
|
|
71
|
-
remarkGfm,
|
|
72
|
-
[
|
|
73
|
-
remarkListCallouts,
|
|
74
|
-
{
|
|
75
|
-
callouts: [
|
|
76
|
-
{ char: "&", enabled: false },
|
|
77
|
-
{ char: "^", color: "80, 70, 220", icon: "bookmark" },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
]);
|
|
82
|
-
const ast = parser("- & Plain item\n- ^ Custom item");
|
|
83
|
-
const items = findElements(ast, "li");
|
|
84
|
-
const marker = findElements(ast, "span").find((element) => element.properties?.["data-list-callout-marker"] === "true");
|
|
85
|
-
expect(String(items[0]?.properties?.class ?? "")).not.toContain("lc-list-callout");
|
|
86
|
-
expect(items[1]?.properties?.["data-callout"]).toBe("^");
|
|
87
|
-
expect(items[1]?.properties?.style).toContain("80, 70, 220");
|
|
88
|
-
expect(marker?.properties?.["data-callout-icon"]).toBe("bookmark");
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
function findElements(node, tagName) {
|
|
92
|
-
const results = [];
|
|
93
|
-
if (node.type === "element" && node.tagName === tagName) {
|
|
94
|
-
results.push(node);
|
|
95
|
-
}
|
|
96
|
-
for (const child of node.children ?? []) {
|
|
97
|
-
if (child.type === "element") {
|
|
98
|
-
results.push(...findElements(child, tagName));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return results;
|
|
102
|
-
}
|
|
103
|
-
function directElementChildren(node, tagName) {
|
|
104
|
-
return (node.children ?? []).filter((child) => child.type === "element" && child.tagName === tagName);
|
|
105
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter-properties.test.d.ts","sourceRoot":"","sources":["../../../src/preview/styles/frontmatter-properties.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { cwd } from "node:process";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
const css = readFileSync(resolve(cwd(), "src/preview/styles/frontmatter-properties.css"), "utf8");
|
|
6
|
-
const component = readFileSync(resolve(cwd(), "src/preview/components/frontmatter.svelte"), "utf8");
|
|
7
|
-
const listValueComponent = readFileSync(resolve(cwd(), "src/preview/components/frontmatter-property-value-input.svelte"), "utf8");
|
|
8
|
-
const textValueComponent = readFileSync(resolve(cwd(), "src/preview/components/frontmatter-property-text-input.svelte"), "utf8");
|
|
9
|
-
describe("frontmatter property styles", () => {
|
|
10
|
-
it("uses the legacy dropdown and nested type-menu structure", () => {
|
|
11
|
-
expect(component).toContain('import * as DropdownMenu from "../../ui/dropdown-menu/index.js";');
|
|
12
|
-
expect(component).toContain('<DropdownMenu.Content\n class="metadata-property-menu"');
|
|
13
|
-
expect(component).toContain("<DropdownMenu.SubTrigger>");
|
|
14
|
-
expect(component).toContain("<span>Property type</span>");
|
|
15
|
-
expect(component).toContain('<DropdownMenu.SubContent\n class="metadata-property-type-menu"');
|
|
16
|
-
expect(component).toContain("<DropdownMenu.CheckboxItem");
|
|
17
|
-
expect(component).toContain('class="metadata-property-type-menu__type-icon size-4"');
|
|
18
|
-
expect(component).not.toContain("metadata-property-type-menu__item");
|
|
19
|
-
expect(component).not.toMatch(/class="metadata-property[^"\n]*\boverflow-hidden\b/u);
|
|
20
|
-
expect(css).toMatch(/\.metadata-property-menu,\s*\.metadata-property-type-menu\s*\{[^}]*--bits-dropdown-menu-content-available-height/su);
|
|
21
|
-
});
|
|
22
|
-
it("ships pill paint and remove-icon geometry without consumer utilities", () => {
|
|
23
|
-
expect(component).toContain("data-property-pill-kind={toBuiltinFrontmatterKind(property.kind)}");
|
|
24
|
-
expect(component).toContain('<Icon name="x" />');
|
|
25
|
-
expect(component).not.toContain("[&_svg]:size-2.5");
|
|
26
|
-
expect(css).toMatch(/\.metadata-property-pill-chip:not\(\.tag\)\s*\{[^}]*--markdown-alias-background[^}]*--secondary/su);
|
|
27
|
-
expect(css).toMatch(/\.metadata-property-pill-remove \.mira-icon,[^{]+\{[^}]*height: 0\.625rem[^}]*width: 0\.625rem/su);
|
|
28
|
-
expect(component).toContain('class="metadata-property-pill-label"');
|
|
29
|
-
expect(css).toMatch(/\.metadata-property-value-list\s*\{[^}]*flex-wrap:\s*wrap[^}]*min-width:\s*0/su);
|
|
30
|
-
expect(css).toMatch(/\.metadata-property-pill-chip\s*\{[^}]*overflow-wrap:\s*anywhere[^}]*white-space:\s*normal/su);
|
|
31
|
-
expect(css).toMatch(/\.metadata-property-pill-chip\s*\{[^}]*flex:\s*0 0 auto/su);
|
|
32
|
-
expect(css).toMatch(/\.metadata-property-pill-label,[^{]+\{[^}]*text-overflow:\s*clip[^}]*white-space:\s*normal[^}]*width:\s*max-content/su);
|
|
33
|
-
expect(css).toMatch(/\.metadata-property-pill-link \.mira-link-preview__trigger\s*\{[^}]*display:\s*inline-block[^}]*white-space:\s*normal[^}]*width:\s*max-content/su);
|
|
34
|
-
expect(css).toMatch(/\.metadata-property-value-list \.metadata-property-pill-chip\.tag\s*\{[^}]*border-radius:\s*var\(--radius-s\)/su);
|
|
35
|
-
});
|
|
36
|
-
it("portals list and text value suggestions through Mira Popover", () => {
|
|
37
|
-
for (const source of [listValueComponent, textValueComponent]) {
|
|
38
|
-
expect(source).toContain('import * as Popover from "../../ui/popover/index.js";');
|
|
39
|
-
expect(source).toContain("<Popover.Root bind:open>");
|
|
40
|
-
expect(source).toContain('class="mira-property-value-suggestions"');
|
|
41
|
-
expect(source).toContain('role="listbox"');
|
|
42
|
-
}
|
|
43
|
-
expect(component).toContain("<FrontmatterPropertyTextInput");
|
|
44
|
-
expect(component).toContain("const fallbackManager = $derived(");
|
|
45
|
-
expect(component).toContain("(controllerProp ? controllerProp.propertyManager : fallbackManager)");
|
|
46
|
-
expect(css).toContain('[data-slot="popover-content"].mira-property-value-suggestions');
|
|
47
|
-
expect(css).not.toContain('.metadata-property:has(.mira-property-value-input[data-open="true"])');
|
|
48
|
-
expect(listValueComponent).toContain('let draft = $state("");');
|
|
49
|
-
expect(listValueComponent).not.toContain("onInput:");
|
|
50
|
-
expect(listValueComponent).toContain('type="text"');
|
|
51
|
-
expect(listValueComponent).toContain("...textControlProps(props)");
|
|
52
|
-
for (const source of [listValueComponent, textValueComponent]) {
|
|
53
|
-
expect(source).toContain("let activeIndex = $state(-1);");
|
|
54
|
-
expect(source).toContain("activeIndex >= 0");
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-mode.test.d.ts","sourceRoot":"","sources":["../../../src/preview/styles/source-mode.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { cwd } from "node:process";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
const sourceModeStyles = () => readFileSync(resolve(cwd(), "src/preview/styles/source-mode.css"), "utf8");
|
|
7
|
-
describe("source mode styles", () => {
|
|
8
|
-
it("reserves full guide slots only for complete indentation guide segments", () => {
|
|
9
|
-
const styles = sourceModeStyles();
|
|
10
|
-
const guideRules = Array.from(styles.matchAll(/([^{}]+)\{([^{}]*)\}/gu))
|
|
11
|
-
.map((match) => ({ selector: match[1], declarations: match[2] }))
|
|
12
|
-
.filter(({ declarations }) => /min-width:\s*var\(--list-indent\)/u.test(declarations));
|
|
13
|
-
expect(guideRules).toHaveLength(1);
|
|
14
|
-
for (const markup of [
|
|
15
|
-
'<div class="markdown-editor-surface"><div class="cm-editor"><span class="cm-indent-guide"></span><span class="cm-indent"></span></div></div>',
|
|
16
|
-
'<div class="cm-editor markdown-editor-surface"><span class="cm-indent-guide"></span><span class="cm-indent"></span></div>',
|
|
17
|
-
]) {
|
|
18
|
-
const host = document.createElement("div");
|
|
19
|
-
host.innerHTML = markup;
|
|
20
|
-
const guide = host.querySelector(".cm-indent-guide");
|
|
21
|
-
const partial = host.querySelector(".cm-indent");
|
|
22
|
-
for (const { selector } of guideRules) {
|
|
23
|
-
expect(guide.matches(selector.trim())).toBe(true);
|
|
24
|
-
expect(partial.matches(selector.trim())).toBe(false);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.test.d.ts","sourceRoot":"","sources":["../../src/tables/extension.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { syntaxTree } from "@codemirror/language";
|
|
2
|
-
import { EditorState } from "@codemirror/state";
|
|
3
|
-
import { EditorView } from "@codemirror/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { createMarkdownCodeMirrorExtensions } from "../internal/codemirror/markdown/index";
|
|
6
|
-
import { gridTableExtension, gridTableTabAction, tableEnterAction, tableExtension, } from "./extension";
|
|
7
|
-
import { bindTableLineScrollSync } from "./table-line-scroll-sync";
|
|
8
|
-
const markdownTable = [
|
|
9
|
-
"| Feature | Behavior |",
|
|
10
|
-
"| --- | --- |",
|
|
11
|
-
"| Handles | Actions |",
|
|
12
|
-
].join("\n");
|
|
13
|
-
const gridTableMarkdown = [
|
|
14
|
-
"+---------+----------+",
|
|
15
|
-
"| Feature | Behavior |",
|
|
16
|
-
"+=========+==========+",
|
|
17
|
-
"| Handles | Actions |",
|
|
18
|
-
"+---------+----------+",
|
|
19
|
-
].join("\n");
|
|
20
|
-
function createGridTableEditor(cursor) {
|
|
21
|
-
const parent = document.createElement("div");
|
|
22
|
-
document.body.append(parent);
|
|
23
|
-
return new EditorView({
|
|
24
|
-
parent,
|
|
25
|
-
state: EditorState.create({
|
|
26
|
-
doc: gridTableMarkdown,
|
|
27
|
-
extensions: [
|
|
28
|
-
createMarkdownCodeMirrorExtensions({ sourceMode: true }),
|
|
29
|
-
gridTableExtension(),
|
|
30
|
-
],
|
|
31
|
-
selection: { anchor: cursor },
|
|
32
|
-
}),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
describe("table extension", () => {
|
|
36
|
-
it("resolves extension facets for configured keymaps", () => {
|
|
37
|
-
expect(tableExtension({ bindEnter: false, bindTab: false })).toHaveLength(2);
|
|
38
|
-
expect(gridTableExtension({ bindEnter: false, bindTab: false })).toHaveLength(2);
|
|
39
|
-
});
|
|
40
|
-
it("formats a grid table and selects the next cell on Tab", () => {
|
|
41
|
-
const view = createGridTableEditor(gridTableMarkdown.indexOf("Feature"));
|
|
42
|
-
expect(gridTableTabAction(1)(view)).toBe(true);
|
|
43
|
-
expect(view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to)).toBe(" Behavior ");
|
|
44
|
-
expect(view.state.doc.toString()).not.toMatch(/^\s+\| Feature/m);
|
|
45
|
-
expect(syntaxTree(view.state).toString()).toContain("GridTable");
|
|
46
|
-
view.destroy();
|
|
47
|
-
});
|
|
48
|
-
it("moves to the same column on the next pipe-table row with Enter", () => {
|
|
49
|
-
const parent = document.createElement("div");
|
|
50
|
-
document.body.append(parent);
|
|
51
|
-
const view = new EditorView({
|
|
52
|
-
parent,
|
|
53
|
-
state: EditorState.create({
|
|
54
|
-
doc: markdownTable,
|
|
55
|
-
extensions: [createMarkdownCodeMirrorExtensions({ sourceMode: true })],
|
|
56
|
-
selection: { anchor: markdownTable.indexOf("Behavior") },
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
expect(tableEnterAction(view)).toBe(true);
|
|
60
|
-
expect(view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to)).toContain("Actions");
|
|
61
|
-
view.destroy();
|
|
62
|
-
});
|
|
63
|
-
it("decorates every grid-table source row as monospaced table syntax", () => {
|
|
64
|
-
const view = createGridTableEditor(gridTableMarkdown.indexOf("Feature"));
|
|
65
|
-
const tableLines = view.dom.querySelectorAll(".cm-line.cm-table.cm-formatting-table.cm-formatting-grid-table");
|
|
66
|
-
expect(tableLines).toHaveLength(5);
|
|
67
|
-
expect(Array.from(tableLines).map((line) => line.getAttribute("tabindex"))).toEqual(["0", "0", "0", "0", "0"]);
|
|
68
|
-
view.destroy();
|
|
69
|
-
});
|
|
70
|
-
it("keeps consecutive source table lines scrolled together", () => {
|
|
71
|
-
const content = document.createElement("div");
|
|
72
|
-
const lines = Array.from({ length: 5 }, (_, index) => {
|
|
73
|
-
const line = document.createElement("div");
|
|
74
|
-
line.className = index === 3 ? "cm-line" : "cm-line cm-table";
|
|
75
|
-
content.append(line);
|
|
76
|
-
return line;
|
|
77
|
-
});
|
|
78
|
-
[80, 100, 120, 60, 70].forEach((width, index) => {
|
|
79
|
-
Object.defineProperty(lines[index], "scrollWidth", { value: width });
|
|
80
|
-
});
|
|
81
|
-
const unbind = bindTableLineScrollSync(content);
|
|
82
|
-
expect(lines.slice(0, 3).map((line) => line.style.paddingInlineEnd)).toEqual(["40px", "20px", "0px"]);
|
|
83
|
-
expect(lines.slice(0, 3).map((line) => line.tabIndex)).toEqual([0, 0, 0]);
|
|
84
|
-
expect(lines
|
|
85
|
-
.slice(0, 3)
|
|
86
|
-
.map((line) => line.getAttribute("data-mira-table-scroll-sync"))).toEqual(["true", "true", "true"]);
|
|
87
|
-
lines[0].scrollLeft = 24;
|
|
88
|
-
lines[0].dispatchEvent(new Event("scroll"));
|
|
89
|
-
expect(lines.slice(0, 3).map((line) => line.scrollLeft)).toEqual([
|
|
90
|
-
24, 24, 24,
|
|
91
|
-
]);
|
|
92
|
-
expect(lines[4].scrollLeft).toBe(0);
|
|
93
|
-
unbind();
|
|
94
|
-
expect(lines.slice(0, 3).map((line) => line.style.paddingInlineEnd)).toEqual(["", "", ""]);
|
|
95
|
-
expect(lines.slice(0, 3).map((line) => line.getAttribute("tabindex"))).toEqual([null, null, null]);
|
|
96
|
-
expect(lines
|
|
97
|
-
.slice(0, 3)
|
|
98
|
-
.map((line) => line.getAttribute("data-mira-table-scroll-sync"))).toEqual([null, null, null]);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grid-editor-column.test.d.ts","sourceRoot":"","sources":["../../src/tables/grid-editor-column.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { mount, tick, unmount } from "svelte";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import GridEditorColumn from "./grid-editor-column.svelte";
|
|
4
|
-
describe("GridEditorColumn", () => {
|
|
5
|
-
it("moves keyboard focus into the inline editor", async () => {
|
|
6
|
-
const target = document.createElement("div");
|
|
7
|
-
document.body.append(target);
|
|
8
|
-
const component = mount(GridEditorColumn, {
|
|
9
|
-
target,
|
|
10
|
-
props: {
|
|
11
|
-
content: "Feature",
|
|
12
|
-
onContentChange: vi.fn(),
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
await tick();
|
|
16
|
-
const trigger = target.querySelector('button[aria-label="Edit table cell"]');
|
|
17
|
-
expect(trigger).not.toBeNull();
|
|
18
|
-
trigger?.focus();
|
|
19
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
20
|
-
await tick();
|
|
21
|
-
const editor = target.querySelector(".cm-editor.mod-inline .cm-content[contenteditable='true']");
|
|
22
|
-
expect(editor).not.toBeNull();
|
|
23
|
-
expect(document.activeElement).toBe(editor);
|
|
24
|
-
await unmount(component);
|
|
25
|
-
target.remove();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grid-table.test.d.ts","sourceRoot":"","sources":["../../src/tables/grid-table.test.ts"],"names":[],"mappings":""}
|