@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,190 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import remarkFrontmatter from "remark-frontmatter";
|
|
3
|
-
import { createParser } from "../renderer/utils";
|
|
4
|
-
import { coerceFrontmatterValue, createFrontmatterPropertyManager, createFrontmatterReplacement, FrontmatterController, frontmatterProperties, mergeFrontmatterRecordProperties, parseFrontmatterYaml, removeFrontmatterRecordProperty, resolveFrontmatterWidget, serializeFrontmatterRecord, } from ".";
|
|
5
|
-
import { remarkFrontmatterToHast, remarkPositionsToData } from "../remark";
|
|
6
|
-
describe("frontmatter utilities", () => {
|
|
7
|
-
it("parses, mutates, and serializes portable YAML properties", () => {
|
|
8
|
-
const parsed = parseFrontmatterYaml("title: Demo\npublished: true\ncount: 2\ntags:\n - mira\n");
|
|
9
|
-
expect(parsed.ok).toBe(true);
|
|
10
|
-
if (!parsed.ok) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const yaml = serializeFrontmatterRecord({
|
|
14
|
-
...parsed.value,
|
|
15
|
-
title: "Updated",
|
|
16
|
-
});
|
|
17
|
-
expect(yaml).toContain("title: Updated");
|
|
18
|
-
expect(createFrontmatterReplacement(yaml)).toMatch(/^---\n/);
|
|
19
|
-
});
|
|
20
|
-
it("derives Lapis-style property types and icons", () => {
|
|
21
|
-
const properties = frontmatterProperties({
|
|
22
|
-
aliases: ["Mira"],
|
|
23
|
-
count: 2,
|
|
24
|
-
draft: false,
|
|
25
|
-
nested: { child: true },
|
|
26
|
-
published: "2026-06-27",
|
|
27
|
-
tags: ["mira", "editor"],
|
|
28
|
-
title: "Demo",
|
|
29
|
-
});
|
|
30
|
-
expect(properties.map((property) => [property.key, property.type])).toEqual([
|
|
31
|
-
["aliases", "aliases"],
|
|
32
|
-
["count", "number"],
|
|
33
|
-
["draft", "checkbox"],
|
|
34
|
-
["nested", "object"],
|
|
35
|
-
["published", "date"],
|
|
36
|
-
["tags", "tags"],
|
|
37
|
-
["title", "text"],
|
|
38
|
-
]);
|
|
39
|
-
expect(properties.find((property) => property.key === "tags")?.icon).toBe("lucide-hash");
|
|
40
|
-
expect(properties.find((property) => property.key === "nested")?.children[0]
|
|
41
|
-
?.type).toBe("checkbox");
|
|
42
|
-
});
|
|
43
|
-
it("applies configured frontmatter property types and widgets", () => {
|
|
44
|
-
const properties = frontmatterProperties({
|
|
45
|
-
status: "draft",
|
|
46
|
-
title: "Demo",
|
|
47
|
-
}, {
|
|
48
|
-
types: {
|
|
49
|
-
status: {
|
|
50
|
-
type: "workflow-state",
|
|
51
|
-
label: "Workflow state",
|
|
52
|
-
icon: "lucide-workflow",
|
|
53
|
-
fallbackKind: "text",
|
|
54
|
-
defaultValue: "draft",
|
|
55
|
-
normalize: (value) => String(value).toUpperCase(),
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
widgets: [
|
|
59
|
-
{
|
|
60
|
-
type: "workflow-state",
|
|
61
|
-
label: "Workflow state",
|
|
62
|
-
icon: "lucide-workflow",
|
|
63
|
-
fallbackKind: "text",
|
|
64
|
-
render: () => undefined,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
});
|
|
68
|
-
const status = properties.find((property) => property.key === "status");
|
|
69
|
-
expect(status?.type).toBe("workflow-state");
|
|
70
|
-
expect(status?.icon).toBe("lucide-workflow");
|
|
71
|
-
expect(resolveFrontmatterWidget({ widgets: [] }, "missing")).toBeNull();
|
|
72
|
-
expect(coerceFrontmatterValue("draft", "workflow-state", {
|
|
73
|
-
widgets: [
|
|
74
|
-
{
|
|
75
|
-
type: "workflow-state",
|
|
76
|
-
normalize: (value) => String(value).toUpperCase(),
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
})).toBe("DRAFT");
|
|
80
|
-
});
|
|
81
|
-
it("removes nested object and array properties immutably", () => {
|
|
82
|
-
const source = {
|
|
83
|
-
nested: { keep: true, remove: "value" },
|
|
84
|
-
values: ["first", "second"],
|
|
85
|
-
};
|
|
86
|
-
expect(removeFrontmatterRecordProperty(source, ["nested", "remove"])).toEqual({
|
|
87
|
-
nested: { keep: true },
|
|
88
|
-
values: ["first", "second"],
|
|
89
|
-
});
|
|
90
|
-
expect(removeFrontmatterRecordProperty(source, ["values", 0])).toEqual({
|
|
91
|
-
nested: { keep: true, remove: "value" },
|
|
92
|
-
values: ["second"],
|
|
93
|
-
});
|
|
94
|
-
expect(source.nested.remove).toBe("value");
|
|
95
|
-
});
|
|
96
|
-
it("merges pasted properties into a portable parent record", () => {
|
|
97
|
-
const source = {
|
|
98
|
-
nested: { keep: true },
|
|
99
|
-
title: "Demo",
|
|
100
|
-
};
|
|
101
|
-
expect(mergeFrontmatterRecordProperties(source, ["nested"], {
|
|
102
|
-
owner: "[[Ada]]",
|
|
103
|
-
status: "ready",
|
|
104
|
-
})).toEqual({
|
|
105
|
-
nested: {
|
|
106
|
-
keep: true,
|
|
107
|
-
owner: "[[Ada]]",
|
|
108
|
-
status: "ready",
|
|
109
|
-
},
|
|
110
|
-
title: "Demo",
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
it("renders frontmatter as a component with source offsets", () => {
|
|
114
|
-
const parser = createParser([
|
|
115
|
-
remarkFrontmatter,
|
|
116
|
-
remarkFrontmatterToHast,
|
|
117
|
-
remarkPositionsToData,
|
|
118
|
-
]);
|
|
119
|
-
const ast = parser("---\ntitle: Demo\n---\n\n# Heading");
|
|
120
|
-
const frontmatter = ast.children.find((node) => node.type === "element" && node.tagName === "frontmatter");
|
|
121
|
-
expect(frontmatter?.properties?.value).toBe("title: Demo");
|
|
122
|
-
expect(frontmatter?.properties?.["data-offset"]).toBe(0);
|
|
123
|
-
expect(frontmatter?.properties?.["data-offset-end"]).toBe(19);
|
|
124
|
-
});
|
|
125
|
-
it("creates a property manager that resolves widgets and setType", () => {
|
|
126
|
-
const manager = createFrontmatterPropertyManager({
|
|
127
|
-
types: {
|
|
128
|
-
status: {
|
|
129
|
-
type: "workflow-state",
|
|
130
|
-
label: "Workflow",
|
|
131
|
-
icon: "lucide-workflow",
|
|
132
|
-
fallbackKind: "text",
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
widgets: [
|
|
136
|
-
{
|
|
137
|
-
type: "workflow-state",
|
|
138
|
-
fallbackKind: "text",
|
|
139
|
-
validate: (value) => typeof value === "string",
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
});
|
|
143
|
-
expect(manager.resolveType("status", "status", "draft")).toBe("workflow-state");
|
|
144
|
-
expect(manager.resolveWidget("workflow-state")?.label).toBeUndefined();
|
|
145
|
-
expect(manager.typeOptions().some((option) => option.type === "text")).toBe(true);
|
|
146
|
-
manager.setType("priority", "number");
|
|
147
|
-
expect(manager.resolveType("priority", "priority", "1")).toBe("number");
|
|
148
|
-
});
|
|
149
|
-
it("commits controller record mutations through onRecordChange", async () => {
|
|
150
|
-
const commits = [];
|
|
151
|
-
const controller = new FrontmatterController({
|
|
152
|
-
record: { title: "Demo", count: 1 },
|
|
153
|
-
onRecordChange(commit) {
|
|
154
|
-
commits.push(commit.record);
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
controller.updateProperty(["title"], "Updated");
|
|
158
|
-
expect(controller.getRecord().title).toBe("Updated");
|
|
159
|
-
expect(commits.at(-1)).toEqual({ title: "Updated", count: 1 });
|
|
160
|
-
const added = controller.addProperty("text");
|
|
161
|
-
expect(added).toBeTruthy();
|
|
162
|
-
expect(Object.keys(controller.getRecord())).toContain(added);
|
|
163
|
-
controller.renameProperty([added], "subtitle");
|
|
164
|
-
expect(controller.getRecord()).toHaveProperty("subtitle");
|
|
165
|
-
expect(controller.getRecord()).not.toHaveProperty(added);
|
|
166
|
-
const title = controller.propertyManager
|
|
167
|
-
.properties(controller.getRecord())
|
|
168
|
-
.find((property) => property.key === "title");
|
|
169
|
-
expect(title).toBeTruthy();
|
|
170
|
-
controller.changePropertyKind(title, "checkbox");
|
|
171
|
-
expect(controller.getRecord().title).toBe(true);
|
|
172
|
-
expect(commits.length).toBeGreaterThan(3);
|
|
173
|
-
});
|
|
174
|
-
it("splices YAML into markdown through controller document adapters", () => {
|
|
175
|
-
const markdown = "---\ntitle: Demo\n---\n\nBody\n";
|
|
176
|
-
let nextValue = markdown;
|
|
177
|
-
const controller = new FrontmatterController({
|
|
178
|
-
yaml: "title: Demo",
|
|
179
|
-
getMarkdown: () => markdown,
|
|
180
|
-
dataOffset: 0,
|
|
181
|
-
dataOffsetEnd: 19,
|
|
182
|
-
onFrontmatterChange(_yaml, value) {
|
|
183
|
-
nextValue = value;
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
controller.updateProperty(["title"], "Updated");
|
|
187
|
-
expect(nextValue).toContain("title: Updated");
|
|
188
|
-
expect(nextValue).toContain("Body");
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.test.d.ts","sourceRoot":"","sources":["../../../src/preview/frontmatter/suggestions.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { filterFrontmatterPropertySuggestions, filterFrontmatterValueSuggestions, parseFrontmatterPillWikilink, readFrontmatterPropertySuggestions, readFrontmatterValueSuggestions, } from "./suggestions";
|
|
3
|
-
describe("frontmatter property suggestions", () => {
|
|
4
|
-
it("loads lazy suggestions and derives configured icons", async () => {
|
|
5
|
-
const suggestions = await readFrontmatterPropertySuggestions({
|
|
6
|
-
propertySuggestions: async () => [
|
|
7
|
-
"status",
|
|
8
|
-
{ name: "owner", kind: "aliases" },
|
|
9
|
-
"status",
|
|
10
|
-
],
|
|
11
|
-
});
|
|
12
|
-
expect(suggestions).toEqual([
|
|
13
|
-
{ name: "status", icon: undefined },
|
|
14
|
-
{ name: "owner", kind: "aliases", icon: "lucide-at-sign" },
|
|
15
|
-
]);
|
|
16
|
-
});
|
|
17
|
-
it("filters, ranks prefixes, and excludes existing names", () => {
|
|
18
|
-
expect(filterFrontmatterPropertySuggestions([{ name: "review-status" }, { name: "status" }, { name: "state" }], "sta", ["state"]).map((suggestion) => suggestion.name)).toEqual(["status", "review-status"]);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe("frontmatter value suggestions", () => {
|
|
22
|
-
it("loads keyed values and ranks prefix matches", async () => {
|
|
23
|
-
const suggestions = await readFrontmatterValueSuggestions({
|
|
24
|
-
valueSuggestions: (key, query) => key === "tags" && query.startsWith("p")
|
|
25
|
-
? ["project/alpha", "inbox", "project/beta"]
|
|
26
|
-
: [],
|
|
27
|
-
}, "tags", "pro");
|
|
28
|
-
expect(suggestions).toEqual(["project/alpha", "project/beta"]);
|
|
29
|
-
});
|
|
30
|
-
it("excludes current pills and empty values", () => {
|
|
31
|
-
expect(filterFrontmatterValueSuggestions(["demo", "ideas", "demo", ""], "dem", [
|
|
32
|
-
"demo",
|
|
33
|
-
])).toEqual([]);
|
|
34
|
-
expect(filterFrontmatterValueSuggestions(["ideas", "demo"], "ide", ["demo"])).toEqual(["ideas"]);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("frontmatter wikilink pills", () => {
|
|
38
|
-
it("recognizes only whole-value wikilinks", () => {
|
|
39
|
-
expect(parseFrontmatterPillWikilink("[[Project|Roadmap]]")).toEqual({
|
|
40
|
-
target: "Project",
|
|
41
|
-
text: "Roadmap",
|
|
42
|
-
});
|
|
43
|
-
expect(parseFrontmatterPillWikilink("See [[Project]]")).toBeNull();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outline.test.d.ts","sourceRoot":"","sources":["../../src/preview/outline.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { activeMarkdownOutlineId, findMarkdownOutlineScrollRoot, } from "./outline";
|
|
3
|
-
function setVerticalLayout(element, layout) {
|
|
4
|
-
Object.defineProperties(element, {
|
|
5
|
-
clientHeight: { configurable: true, value: layout.clientHeight },
|
|
6
|
-
scrollHeight: { configurable: true, value: layout.scrollHeight },
|
|
7
|
-
});
|
|
8
|
-
element.getBoundingClientRect = () => ({
|
|
9
|
-
top: layout.top ?? 0,
|
|
10
|
-
bottom: (layout.top ?? 0) + layout.clientHeight,
|
|
11
|
-
height: layout.clientHeight,
|
|
12
|
-
left: 0,
|
|
13
|
-
right: 0,
|
|
14
|
-
width: 0,
|
|
15
|
-
x: 0,
|
|
16
|
-
y: layout.top ?? 0,
|
|
17
|
-
toJSON: () => ({}),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
describe("Markdown outline scroll tracking", () => {
|
|
21
|
-
it("uses Mira's preview when it owns the scroll range", () => {
|
|
22
|
-
const outer = document.createElement("div");
|
|
23
|
-
const preview = document.createElement("div");
|
|
24
|
-
const heading = document.createElement("h1");
|
|
25
|
-
outer.style.overflowY = "auto";
|
|
26
|
-
preview.style.overflowY = "auto";
|
|
27
|
-
outer.append(preview);
|
|
28
|
-
preview.append(heading);
|
|
29
|
-
setVerticalLayout(outer, { clientHeight: 400, scrollHeight: 800 });
|
|
30
|
-
setVerticalLayout(preview, { clientHeight: 300, scrollHeight: 700 });
|
|
31
|
-
expect(findMarkdownOutlineScrollRoot(heading, preview)).toBe(preview);
|
|
32
|
-
});
|
|
33
|
-
it("finds a consumer scroll owner when the preview overflow is visible", () => {
|
|
34
|
-
const viewport = document.createElement("div");
|
|
35
|
-
const preview = document.createElement("div");
|
|
36
|
-
const heading = document.createElement("h1");
|
|
37
|
-
viewport.style.overflowY = "scroll";
|
|
38
|
-
preview.style.overflowY = "visible";
|
|
39
|
-
viewport.append(preview);
|
|
40
|
-
preview.append(heading);
|
|
41
|
-
setVerticalLayout(viewport, { clientHeight: 300, scrollHeight: 900 });
|
|
42
|
-
setVerticalLayout(preview, { clientHeight: 900, scrollHeight: 900 });
|
|
43
|
-
expect(findMarkdownOutlineScrollRoot(heading, preview)).toBe(viewport);
|
|
44
|
-
});
|
|
45
|
-
it("selects the last heading that crosses the active-section threshold", () => {
|
|
46
|
-
const items = [
|
|
47
|
-
{ id: "intro", text: "Intro", level: 1 },
|
|
48
|
-
{ id: "details", text: "Details", level: 2 },
|
|
49
|
-
{ id: "finish", text: "Finish", level: 2 },
|
|
50
|
-
];
|
|
51
|
-
const scrollRoot = document.createElement("div");
|
|
52
|
-
setVerticalLayout(scrollRoot, {
|
|
53
|
-
clientHeight: 300,
|
|
54
|
-
scrollHeight: 900,
|
|
55
|
-
top: 40,
|
|
56
|
-
});
|
|
57
|
-
const tops = new Map([
|
|
58
|
-
["intro", 8],
|
|
59
|
-
["details", 118],
|
|
60
|
-
["finish", 390],
|
|
61
|
-
]);
|
|
62
|
-
const resolveHeading = (item) => {
|
|
63
|
-
const element = document.createElement("h2");
|
|
64
|
-
setVerticalLayout(element, {
|
|
65
|
-
clientHeight: 32,
|
|
66
|
-
scrollHeight: 32,
|
|
67
|
-
top: tops.get(item.id),
|
|
68
|
-
});
|
|
69
|
-
return element;
|
|
70
|
-
};
|
|
71
|
-
expect(activeMarkdownOutlineId(items, resolveHeading, scrollRoot)).toBe("details");
|
|
72
|
-
});
|
|
73
|
-
it("keeps an explicitly focused outline target active while scrolling settles", () => {
|
|
74
|
-
const items = [
|
|
75
|
-
{ id: "intro", text: "Intro", level: 1 },
|
|
76
|
-
{ id: "details", text: "Details", level: 2 },
|
|
77
|
-
];
|
|
78
|
-
const intro = document.createElement("h1");
|
|
79
|
-
const details = document.createElement("h2");
|
|
80
|
-
const scrollRoot = document.createElement("div");
|
|
81
|
-
const headings = new Map([
|
|
82
|
-
["intro", intro],
|
|
83
|
-
["details", details],
|
|
84
|
-
]);
|
|
85
|
-
setVerticalLayout(scrollRoot, {
|
|
86
|
-
clientHeight: 300,
|
|
87
|
-
scrollHeight: 900,
|
|
88
|
-
top: 0,
|
|
89
|
-
});
|
|
90
|
-
setVerticalLayout(intro, { clientHeight: 32, scrollHeight: 32, top: 8 });
|
|
91
|
-
setVerticalLayout(details, {
|
|
92
|
-
clientHeight: 32,
|
|
93
|
-
scrollHeight: 32,
|
|
94
|
-
top: 390,
|
|
95
|
-
});
|
|
96
|
-
expect(activeMarkdownOutlineId(items, (item) => headings.get(item.id) ?? null, scrollRoot, 96, details)).toBe("details");
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portable-surfaces.test.d.ts","sourceRoot":"","sources":["../../src/preview/portable-surfaces.test.ts"],"names":[],"mappings":""}
|