@lapismd/mira 0.0.3 → 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.
Files changed (203) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/extensions/index.d.ts +7 -0
  3. package/dist/extensions/index.d.ts.map +1 -1
  4. package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte +20 -9
  5. package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte.d.ts.map +1 -1
  6. package/dist/preview/editable-markdown-preview/editing-session.d.ts +13 -0
  7. package/dist/preview/editable-markdown-preview/editing-session.d.ts.map +1 -0
  8. package/dist/preview/editable-markdown-preview/editing-session.js +50 -0
  9. package/dist/preview/editable-markdown-preview/editor-surface.svelte +13 -4
  10. package/dist/preview/editable-markdown-preview/editor-surface.svelte.d.ts +1 -0
  11. package/dist/preview/editable-markdown-preview/editor-surface.svelte.d.ts.map +1 -1
  12. package/dist/preview/editable-markdown-preview/serialized-writer.d.ts +5 -1
  13. package/dist/preview/editable-markdown-preview/serialized-writer.d.ts.map +1 -1
  14. package/dist/preview/editable-markdown-preview/serialized-writer.js +29 -0
  15. package/dist/preview/editable-markdown-preview.svelte +8 -6
  16. package/dist/preview/editable-markdown-preview.svelte.d.ts.map +1 -1
  17. package/package.json +6 -3
  18. package/dist/core/code-mirror.test.d.ts +0 -2
  19. package/dist/core/code-mirror.test.d.ts.map +0 -1
  20. package/dist/core/code-mirror.test.js +0 -68
  21. package/dist/core/images.test.d.ts +0 -2
  22. package/dist/core/images.test.d.ts.map +0 -1
  23. package/dist/core/images.test.js +0 -109
  24. package/dist/core/index.test.d.ts +0 -2
  25. package/dist/core/index.test.d.ts.map +0 -1
  26. package/dist/core/index.test.js +0 -11
  27. package/dist/core/markdown-actions.test.d.ts +0 -2
  28. package/dist/core/markdown-actions.test.d.ts.map +0 -1
  29. package/dist/core/markdown-actions.test.js +0 -182
  30. package/dist/extensions/doodle-dividers.test.d.ts +0 -2
  31. package/dist/extensions/doodle-dividers.test.d.ts.map +0 -1
  32. package/dist/extensions/doodle-dividers.test.js +0 -296
  33. package/dist/extensions/index.test.d.ts +0 -2
  34. package/dist/extensions/index.test.d.ts.map +0 -1
  35. package/dist/extensions/index.test.js +0 -283
  36. package/dist/index.test.d.ts +0 -2
  37. package/dist/index.test.d.ts.map +0 -1
  38. package/dist/index.test.js +0 -64
  39. package/dist/internal/appearance-context.test.d.ts +0 -2
  40. package/dist/internal/appearance-context.test.d.ts.map +0 -1
  41. package/dist/internal/appearance-context.test.js +0 -31
  42. package/dist/internal/codemirror/base/index.test.d.ts +0 -2
  43. package/dist/internal/codemirror/base/index.test.d.ts.map +0 -1
  44. package/dist/internal/codemirror/base/index.test.js +0 -303
  45. package/dist/internal/codemirror/base/search.test.d.ts +0 -2
  46. package/dist/internal/codemirror/base/search.test.d.ts.map +0 -1
  47. package/dist/internal/codemirror/base/search.test.js +0 -155
  48. package/dist/internal/codemirror/base/selection-toolbar.test.d.ts +0 -2
  49. package/dist/internal/codemirror/base/selection-toolbar.test.d.ts.map +0 -1
  50. package/dist/internal/codemirror/base/selection-toolbar.test.js +0 -149
  51. package/dist/internal/codemirror/markdown/authoring.test.d.ts +0 -2
  52. package/dist/internal/codemirror/markdown/authoring.test.d.ts.map +0 -1
  53. package/dist/internal/codemirror/markdown/authoring.test.js +0 -222
  54. package/dist/internal/codemirror/markdown/index.test.d.ts +0 -2
  55. package/dist/internal/codemirror/markdown/index.test.d.ts.map +0 -1
  56. package/dist/internal/codemirror/markdown/index.test.js +0 -158
  57. package/dist/internal/codemirror/markdown/showcase-fixture.test.d.ts +0 -2
  58. package/dist/internal/codemirror/markdown/showcase-fixture.test.d.ts.map +0 -1
  59. package/dist/internal/codemirror/markdown/showcase-fixture.test.js +0 -50
  60. package/dist/internal/codemirror/rich/block-controls.test.d.ts +0 -2
  61. package/dist/internal/codemirror/rich/block-controls.test.d.ts.map +0 -1
  62. package/dist/internal/codemirror/rich/block-controls.test.js +0 -401
  63. package/dist/internal/codemirror/rich/block-ranges.test.d.ts +0 -2
  64. package/dist/internal/codemirror/rich/block-ranges.test.d.ts.map +0 -1
  65. package/dist/internal/codemirror/rich/block-ranges.test.js +0 -310
  66. package/dist/internal/codemirror/rich/block-toolbar.test.d.ts +0 -2
  67. package/dist/internal/codemirror/rich/block-toolbar.test.d.ts.map +0 -1
  68. package/dist/internal/codemirror/rich/block-toolbar.test.js +0 -178
  69. package/dist/internal/codemirror/rich/decorations/fold-indicators.test.d.ts +0 -2
  70. package/dist/internal/codemirror/rich/decorations/fold-indicators.test.d.ts.map +0 -1
  71. package/dist/internal/codemirror/rich/decorations/fold-indicators.test.js +0 -8
  72. package/dist/internal/codemirror/rich/index.test.d.ts +0 -2
  73. package/dist/internal/codemirror/rich/index.test.d.ts.map +0 -1
  74. package/dist/internal/codemirror/rich/index.test.js +0 -607
  75. package/dist/internal/codemirror/rich/utils/code-block-lines.test.d.ts +0 -2
  76. package/dist/internal/codemirror/rich/utils/code-block-lines.test.d.ts.map +0 -1
  77. package/dist/internal/codemirror/rich/utils/code-block-lines.test.js +0 -82
  78. package/dist/internal/codemirror/rich/utils/fenced-code.test.d.ts +0 -2
  79. package/dist/internal/codemirror/rich/utils/fenced-code.test.d.ts.map +0 -1
  80. package/dist/internal/codemirror/rich/utils/fenced-code.test.js +0 -12
  81. package/dist/internal/codemirror/rich/utils/headings.test.d.ts +0 -2
  82. package/dist/internal/codemirror/rich/utils/headings.test.d.ts.map +0 -1
  83. package/dist/internal/codemirror/rich/utils/headings.test.js +0 -27
  84. package/dist/internal/codemirror/rich/utils/height-estimates.test.d.ts +0 -2
  85. package/dist/internal/codemirror/rich/utils/height-estimates.test.d.ts.map +0 -1
  86. package/dist/internal/codemirror/rich/utils/height-estimates.test.js +0 -10
  87. package/dist/internal/codemirror/rich/utils/images.test.d.ts +0 -2
  88. package/dist/internal/codemirror/rich/utils/images.test.d.ts.map +0 -1
  89. package/dist/internal/codemirror/rich/utils/images.test.js +0 -37
  90. package/dist/internal/codemirror/rich/utils/indent.test.d.ts +0 -2
  91. package/dist/internal/codemirror/rich/utils/indent.test.d.ts.map +0 -1
  92. package/dist/internal/codemirror/rich/utils/indent.test.js +0 -169
  93. package/dist/internal/codemirror/rich/utils/inline-math.test.d.ts +0 -2
  94. package/dist/internal/codemirror/rich/utils/inline-math.test.d.ts.map +0 -1
  95. package/dist/internal/codemirror/rich/utils/inline-math.test.js +0 -15
  96. package/dist/internal/codemirror/rich/utils/links.test.d.ts +0 -2
  97. package/dist/internal/codemirror/rich/utils/links.test.d.ts.map +0 -1
  98. package/dist/internal/codemirror/rich/utils/links.test.js +0 -28
  99. package/dist/internal/codemirror/rich/utils/list-callouts.test.d.ts +0 -2
  100. package/dist/internal/codemirror/rich/utils/list-callouts.test.d.ts.map +0 -1
  101. package/dist/internal/codemirror/rich/utils/list-callouts.test.js +0 -47
  102. package/dist/internal/codemirror/rich/utils/measured-indent.test.d.ts +0 -2
  103. package/dist/internal/codemirror/rich/utils/measured-indent.test.d.ts.map +0 -1
  104. package/dist/internal/codemirror/rich/utils/measured-indent.test.js +0 -102
  105. package/dist/internal/codemirror/rich/utils/ranges.test.d.ts +0 -2
  106. package/dist/internal/codemirror/rich/utils/ranges.test.d.ts.map +0 -1
  107. package/dist/internal/codemirror/rich/utils/ranges.test.js +0 -22
  108. package/dist/internal/codemirror/rich/utils/tasks.test.d.ts +0 -2
  109. package/dist/internal/codemirror/rich/utils/tasks.test.d.ts.map +0 -1
  110. package/dist/internal/codemirror/rich/utils/tasks.test.js +0 -57
  111. package/dist/internal/task-states.test.d.ts +0 -2
  112. package/dist/internal/task-states.test.d.ts.map +0 -1
  113. package/dist/internal/task-states.test.js +0 -36
  114. package/dist/mira-code-editor.test.d.ts +0 -2
  115. package/dist/mira-code-editor.test.d.ts.map +0 -1
  116. package/dist/mira-code-editor.test.js +0 -93
  117. package/dist/mode-position.test.d.ts +0 -2
  118. package/dist/mode-position.test.d.ts.map +0 -1
  119. package/dist/mode-position.test.js +0 -60
  120. package/dist/preview/code-language.test.d.ts +0 -2
  121. package/dist/preview/code-language.test.d.ts.map +0 -1
  122. package/dist/preview/code-language.test.js +0 -12
  123. package/dist/preview/components/icon.test.d.ts +0 -2
  124. package/dist/preview/components/icon.test.d.ts.map +0 -1
  125. package/dist/preview/components/icon.test.js +0 -20
  126. package/dist/preview/editable-markdown-preview/behavior.test.d.ts +0 -2
  127. package/dist/preview/editable-markdown-preview/behavior.test.d.ts.map +0 -1
  128. package/dist/preview/editable-markdown-preview/behavior.test.js +0 -36
  129. package/dist/preview/editable-markdown-preview/serialized-writer.test.d.ts +0 -2
  130. package/dist/preview/editable-markdown-preview/serialized-writer.test.d.ts.map +0 -1
  131. package/dist/preview/editable-markdown-preview/serialized-writer.test.js +0 -59
  132. package/dist/preview/embed-target.test.d.ts +0 -2
  133. package/dist/preview/embed-target.test.d.ts.map +0 -1
  134. package/dist/preview/embed-target.test.js +0 -78
  135. package/dist/preview/frontmatter/frontmatter.test.d.ts +0 -2
  136. package/dist/preview/frontmatter/frontmatter.test.d.ts.map +0 -1
  137. package/dist/preview/frontmatter/frontmatter.test.js +0 -190
  138. package/dist/preview/frontmatter/suggestions.test.d.ts +0 -2
  139. package/dist/preview/frontmatter/suggestions.test.d.ts.map +0 -1
  140. package/dist/preview/frontmatter/suggestions.test.js +0 -45
  141. package/dist/preview/outline.test.d.ts +0 -2
  142. package/dist/preview/outline.test.d.ts.map +0 -1
  143. package/dist/preview/outline.test.js +0 -98
  144. package/dist/preview/portable-surfaces.test.d.ts +0 -2
  145. package/dist/preview/portable-surfaces.test.d.ts.map +0 -1
  146. package/dist/preview/portable-surfaces.test.js +0 -513
  147. package/dist/preview/preview.test.d.ts +0 -2
  148. package/dist/preview/preview.test.d.ts.map +0 -1
  149. package/dist/preview/preview.test.js +0 -154
  150. package/dist/preview/remark/callouts.test.d.ts +0 -2
  151. package/dist/preview/remark/callouts.test.d.ts.map +0 -1
  152. package/dist/preview/remark/callouts.test.js +0 -23
  153. package/dist/preview/remark/custom-checklists.test.d.ts +0 -2
  154. package/dist/preview/remark/custom-checklists.test.d.ts.map +0 -1
  155. package/dist/preview/remark/custom-checklists.test.js +0 -51
  156. package/dist/preview/remark/links.test.d.ts +0 -2
  157. package/dist/preview/remark/links.test.d.ts.map +0 -1
  158. package/dist/preview/remark/links.test.js +0 -62
  159. package/dist/preview/remark/parity.test.d.ts +0 -2
  160. package/dist/preview/remark/parity.test.d.ts.map +0 -1
  161. package/dist/preview/remark/parity.test.js +0 -105
  162. package/dist/preview/styles/frontmatter-properties.test.d.ts +0 -2
  163. package/dist/preview/styles/frontmatter-properties.test.d.ts.map +0 -1
  164. package/dist/preview/styles/frontmatter-properties.test.js +0 -57
  165. package/dist/preview/styles/source-mode.test.d.ts +0 -2
  166. package/dist/preview/styles/source-mode.test.d.ts.map +0 -1
  167. package/dist/preview/styles/source-mode.test.js +0 -28
  168. package/dist/tables/extension.test.d.ts +0 -2
  169. package/dist/tables/extension.test.d.ts.map +0 -1
  170. package/dist/tables/extension.test.js +0 -100
  171. package/dist/tables/grid-editor-column.test.d.ts +0 -2
  172. package/dist/tables/grid-editor-column.test.d.ts.map +0 -1
  173. package/dist/tables/grid-editor-column.test.js +0 -27
  174. package/dist/tables/grid-table.test.d.ts +0 -2
  175. package/dist/tables/grid-table.test.d.ts.map +0 -1
  176. package/dist/tables/grid-table.test.js +0 -140
  177. package/dist/tables/index.test.d.ts +0 -2
  178. package/dist/tables/index.test.d.ts.map +0 -1
  179. package/dist/tables/index.test.js +0 -7
  180. package/dist/tables/inline-editor-extensions.test.d.ts +0 -2
  181. package/dist/tables/inline-editor-extensions.test.d.ts.map +0 -1
  182. package/dist/tables/inline-editor-extensions.test.js +0 -23
  183. package/dist/tables/pipe-table.test.d.ts +0 -2
  184. package/dist/tables/pipe-table.test.d.ts.map +0 -1
  185. package/dist/tables/pipe-table.test.js +0 -13
  186. package/dist/tables/table-node.test.d.ts +0 -2
  187. package/dist/tables/table-node.test.d.ts.map +0 -1
  188. package/dist/tables/table-node.test.js +0 -167
  189. package/dist/tables/widgets/source-button.test.d.ts +0 -2
  190. package/dist/tables/widgets/source-button.test.d.ts.map +0 -1
  191. package/dist/tables/widgets/source-button.test.js +0 -11
  192. package/dist/themes/theme-contract.test.d.ts +0 -2
  193. package/dist/themes/theme-contract.test.d.ts.map +0 -1
  194. package/dist/themes/theme-contract.test.js +0 -88
  195. package/dist/ui/index.test.d.ts +0 -2
  196. package/dist/ui/index.test.d.ts.map +0 -1
  197. package/dist/ui/index.test.js +0 -7
  198. package/dist/ui/styles.test.d.ts +0 -2
  199. package/dist/ui/styles.test.d.ts.map +0 -1
  200. package/dist/ui/styles.test.js +0 -26
  201. package/dist/ui/table-dnd/table-dnd-utils.test.d.ts +0 -2
  202. package/dist/ui/table-dnd/table-dnd-utils.test.d.ts.map +0 -1
  203. package/dist/ui/table-dnd/table-dnd-utils.test.js +0 -46
@@ -1,283 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { EditorState } from "@codemirror/state";
3
- import { EditorView } from "@codemirror/view";
4
- import { createMiraCommandKeymap, createMarkdownTemplate, createSlashSnippet, defaultMiraEditorListCallouts, defineMiraExtension, executeMiraCommand, isMiraCommandEnabled, mountMiraExtensionStyles, parseMiraFileTarget, resolveMiraExtensions, resolveMiraListCallouts, selectionToolbarExtension, } from ".";
5
- describe("resolveMiraExtensions", () => {
6
- it("merges contribution arrays in extension order", () => {
7
- const first = defineMiraExtension({
8
- name: "first",
9
- remarkPlugins: [() => undefined],
10
- components: { a: "span" },
11
- });
12
- const second = defineMiraExtension({
13
- name: "second",
14
- rehypePlugins: [() => undefined],
15
- components: { b: "div" },
16
- });
17
- const resolved = resolveMiraExtensions([first, second], {
18
- mode: "source",
19
- readonly: false,
20
- });
21
- expect(resolved.remarkPlugins).toHaveLength(1);
22
- expect(resolved.rehypePlugins).toHaveLength(1);
23
- expect(resolved.components).toEqual({ a: "span", b: "div" });
24
- });
25
- it("merges slash commands in extension order", () => {
26
- const resolved = resolveMiraExtensions([
27
- defineMiraExtension({
28
- name: "first",
29
- slashCommands: [
30
- {
31
- id: "heading",
32
- label: "Heading",
33
- insert: "# ",
34
- },
35
- ],
36
- }),
37
- defineMiraExtension({
38
- name: "second",
39
- slashCommands: [
40
- {
41
- id: "callout",
42
- label: "Callout",
43
- insert: "> [!note] ",
44
- },
45
- ],
46
- }),
47
- ], {
48
- mode: "source",
49
- readonly: false,
50
- });
51
- expect(resolved.slashCommands.map((command) => command.id)).toEqual([
52
- "heading",
53
- "callout",
54
- ]);
55
- });
56
- it("merges block actions in extension order", () => {
57
- const resolved = resolveMiraExtensions([
58
- defineMiraExtension({
59
- name: "first",
60
- blockActions: [
61
- {
62
- id: "duplicate",
63
- label: "Duplicate",
64
- run: () => undefined,
65
- },
66
- ],
67
- }),
68
- defineMiraExtension({
69
- name: "second",
70
- blockActions: [
71
- {
72
- id: "ask-ai",
73
- label: "Ask AI",
74
- run: () => undefined,
75
- },
76
- ],
77
- }),
78
- ], {
79
- mode: "source",
80
- readonly: false,
81
- });
82
- expect(resolved.blockActions.map((action) => action.id)).toEqual([
83
- "duplicate",
84
- "ask-ai",
85
- ]);
86
- });
87
- it("merges list callouts and postprocessors in extension order", () => {
88
- const firstProcessor = vi.fn();
89
- const secondProcessor = vi.fn();
90
- const resolved = resolveMiraExtensions([
91
- defineMiraExtension({
92
- name: "first",
93
- listCallouts: [{ char: "^", color: "80, 70, 220" }],
94
- postProcessors: [firstProcessor],
95
- }),
96
- defineMiraExtension({
97
- name: "second",
98
- listCallouts: [{ char: "@", color: "20, 160, 140" }],
99
- postProcessors: [secondProcessor],
100
- }),
101
- ], {
102
- mode: "preview",
103
- readonly: true,
104
- });
105
- expect(resolved.listCallouts.map((callout) => callout.char)).toEqual([
106
- "^",
107
- "@",
108
- ]);
109
- expect(resolved.postProcessors).toEqual([firstProcessor, secondProcessor]);
110
- });
111
- });
112
- describe("selectionToolbarExtension", () => {
113
- it("contributes only to editable authoring surfaces", () => {
114
- const extension = selectionToolbarExtension({
115
- actions: ["bold", "inlineCode"],
116
- placement: "above",
117
- });
118
- expect(extension.name).toBe("selection-toolbar");
119
- expect(extension.codeMirror?.({ mode: "source", readonly: false })).not.toBeNull();
120
- expect(extension.codeMirror?.({ mode: "live-preview", readonly: false })).not.toBeNull();
121
- expect(extension.codeMirror?.({ mode: "split", readonly: false })).not.toBeNull();
122
- expect(extension.codeMirror?.({ mode: "preview", readonly: false })).toBeNull();
123
- expect(extension.codeMirror?.({ mode: "source", readonly: true })).toBeNull();
124
- });
125
- });
126
- describe("extension runtime contributions", () => {
127
- const context = {
128
- focus: () => undefined,
129
- getValue: () => "",
130
- insertMarkdown: () => undefined,
131
- setValue: () => undefined,
132
- };
133
- it("executes the last enabled command with a matching id", () => {
134
- const first = vi.fn();
135
- const second = vi.fn();
136
- const commands = [
137
- { id: "save", label: "Save first", run: first },
138
- { id: "save", label: "Save second", run: second },
139
- ];
140
- expect(executeMiraCommand(commands, "save", context)).toBe(true);
141
- expect(first).not.toHaveBeenCalled();
142
- expect(second).toHaveBeenCalledWith(context);
143
- });
144
- it("does not execute disabled or unknown commands", () => {
145
- const run = vi.fn();
146
- const command = {
147
- id: "publish",
148
- label: "Publish",
149
- enabled: false,
150
- run,
151
- };
152
- expect(isMiraCommandEnabled(command, context)).toBe(false);
153
- expect(executeMiraCommand([command], "publish", context)).toBe(false);
154
- expect(executeMiraCommand([command], "missing", context)).toBe(false);
155
- expect(run).not.toHaveBeenCalled();
156
- });
157
- it("executes command shortcuts through a CodeMirror keymap", () => {
158
- const run = vi.fn();
159
- const extension = createMiraCommandKeymap([
160
- {
161
- id: "save",
162
- label: "Save",
163
- keybindings: ["Ctrl-s"],
164
- run,
165
- },
166
- ], () => context);
167
- const view = new EditorView({
168
- state: EditorState.create({
169
- extensions: [extension],
170
- }),
171
- });
172
- view.contentDOM.dispatchEvent(new KeyboardEvent("keydown", {
173
- bubbles: true,
174
- ctrlKey: true,
175
- key: "s",
176
- }));
177
- expect(run).toHaveBeenCalledWith(context);
178
- view.destroy();
179
- });
180
- it("mounts and reference-counts external and inline styles", () => {
181
- const cleanupFirst = mountMiraExtensionStyles([
182
- "/extension.css",
183
- {
184
- id: "extension-inline",
185
- cssText: ".extension { color: rebeccapurple; }",
186
- },
187
- ]);
188
- const cleanupSecond = mountMiraExtensionStyles([
189
- "/extension.css",
190
- {
191
- id: "extension-inline",
192
- cssText: ".extension { color: rebeccapurple; }",
193
- },
194
- ]);
195
- expect(document.head.querySelectorAll("[data-mira-extension-style]")).toHaveLength(2);
196
- cleanupFirst();
197
- expect(document.head.querySelectorAll("[data-mira-extension-style]")).toHaveLength(2);
198
- cleanupSecond();
199
- expect(document.head.querySelectorAll("[data-mira-extension-style]")).toHaveLength(0);
200
- });
201
- });
202
- describe("portable file targets", () => {
203
- it("separates paths from heading and block fragments", () => {
204
- expect(parseMiraFileTarget("notes/plan.md#Next Steps", "daily.md")).toEqual({
205
- href: "notes/plan.md#Next Steps",
206
- path: "notes/plan.md",
207
- sourcePath: "daily.md",
208
- subpath: "Next Steps",
209
- fragment: {
210
- kind: "heading",
211
- value: "Next Steps",
212
- },
213
- });
214
- expect(parseMiraFileTarget("notes/plan.md#^decision-1")).toEqual({
215
- href: "notes/plan.md#^decision-1",
216
- path: "notes/plan.md",
217
- subpath: "^decision-1",
218
- fragment: {
219
- kind: "block",
220
- value: "decision-1",
221
- },
222
- sourcePath: undefined,
223
- });
224
- });
225
- it("keeps plain and empty-fragment targets portable", () => {
226
- expect(parseMiraFileTarget("notes/plan.md")).toEqual({
227
- href: "notes/plan.md",
228
- path: "notes/plan.md",
229
- sourcePath: undefined,
230
- subpath: undefined,
231
- fragment: undefined,
232
- });
233
- expect(parseMiraFileTarget("notes/plan.md#").fragment).toBeUndefined();
234
- });
235
- });
236
- describe("portable list callout catalogs", () => {
237
- it("overrides, disables, and appends markers without mutating defaults", () => {
238
- const callouts = resolveMiraListCallouts([
239
- { char: "@", color: "20, 160, 140", icon: "bookmark" },
240
- { char: "%", enabled: false },
241
- { char: "^", color: "80, 70, 220" },
242
- ]);
243
- expect(callouts.find((callout) => callout.char === "@")).toEqual({
244
- char: "@",
245
- color: "20, 160, 140",
246
- icon: "bookmark",
247
- });
248
- expect(callouts.some((callout) => callout.char === "%")).toBe(false);
249
- expect(callouts.at(-1)).toEqual({
250
- char: "^",
251
- color: "80, 70, 220",
252
- });
253
- expect(defaultMiraEditorListCallouts).toHaveLength(7);
254
- });
255
- });
256
- describe("slash snippet helpers", () => {
257
- it("creates markdown templates from cursor markers", () => {
258
- expect(createMarkdownTemplate("## <|>")).toEqual({
259
- markdown: "## ",
260
- selection: 3,
261
- });
262
- });
263
- it("creates slash commands from markdown snippets", () => {
264
- expect(createSlashSnippet({
265
- id: "callout",
266
- label: "Callout",
267
- description: "Insert a callout",
268
- group: "Basic",
269
- keywords: ["note"],
270
- markdown: "> [!note] <|>\n> ",
271
- })).toEqual({
272
- id: "callout",
273
- label: "Callout",
274
- description: "Insert a callout",
275
- group: "Basic",
276
- keywords: ["note"],
277
- insert: {
278
- markdown: "> [!note] \n> ",
279
- selection: 10,
280
- },
281
- });
282
- });
283
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -1,64 +0,0 @@
1
- import { mount, tick, unmount } from "svelte";
2
- import { describe, expect, it } from "vitest";
3
- import Mira from "./mira.svelte";
4
- describe("Mira", () => {
5
- it("exports the Svelte component", () => {
6
- expect(Mira).toBeTruthy();
7
- });
8
- it("renders opaque theme tokens and an independent color mode", async () => {
9
- const target = document.createElement("div");
10
- document.body.append(target);
11
- const component = mount(Mira, {
12
- target,
13
- props: {
14
- value: "# Appearance",
15
- mode: "preview",
16
- theme: "obsidian company-brand",
17
- colorMode: "dark",
18
- },
19
- });
20
- await tick();
21
- const root = target.querySelector(".mira");
22
- expect(root?.dataset.miraTheme).toBe("obsidian company-brand");
23
- expect(root?.dataset.miraColorMode).toBe("dark");
24
- expect(root?.classList.contains("dark")).toBe(true);
25
- await unmount(component);
26
- target.remove();
27
- });
28
- it("inherits appearance when theme and color mode are omitted", async () => {
29
- const target = document.createElement("div");
30
- document.body.append(target);
31
- const component = mount(Mira, {
32
- target,
33
- props: { value: "# Inherit", mode: "preview", theme: "" },
34
- });
35
- await tick();
36
- const root = target.querySelector(".mira");
37
- expect(root?.hasAttribute("data-mira-theme")).toBe(false);
38
- expect(root?.hasAttribute("data-mira-color-mode")).toBe(false);
39
- await unmount(component);
40
- target.remove();
41
- });
42
- it("uses the shared action engine through its handle and minimal toolbar", async () => {
43
- const target = document.createElement("div");
44
- document.body.append(target);
45
- const component = mount(Mira, {
46
- target,
47
- props: { value: "word", mode: "source" },
48
- });
49
- await tick();
50
- component.setSelection({
51
- anchor: { line: 0, ch: 2 },
52
- head: { line: 0, ch: 2 },
53
- });
54
- target.querySelector('[aria-label="Bold"]')?.click();
55
- expect(component.getMarkdown()).toBe("**word**");
56
- expect(component.applyMarkdownAction("bold")).toBe(true);
57
- expect(component.getMarkdown()).toBe("word");
58
- component.setMode("preview");
59
- expect(component.applyMarkdownAction("italic")).toBe(false);
60
- expect(component.getMarkdown()).toBe("word");
61
- await unmount(component);
62
- target.remove();
63
- });
64
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=appearance-context.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appearance-context.test.d.ts","sourceRoot":"","sources":["../../src/internal/appearance-context.test.ts"],"names":[],"mappings":""}
@@ -1,31 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { miraColorModeAttribute, miraColorModeClassName, normalizeMiraTheme, resolveMiraColorModeAttribute, resolveMiraThemeAttribute, } from "./appearance-context";
3
- describe("Mira appearance attributes", () => {
4
- it("passes arbitrary theme token lists through unchanged", () => {
5
- expect(normalizeMiraTheme("obsidian company-brand")).toBe("obsidian company-brand");
6
- expect(normalizeMiraTheme(" mira custom ")).toBe(" mira custom ");
7
- });
8
- it("omits absent and whitespace-only themes", () => {
9
- expect(normalizeMiraTheme(undefined)).toBeUndefined();
10
- expect(normalizeMiraTheme("")).toBeUndefined();
11
- expect(normalizeMiraTheme(" ")).toBeUndefined();
12
- });
13
- it("keeps color mode independent from palette selection", () => {
14
- expect(miraColorModeAttribute("inherit")).toBeUndefined();
15
- expect(miraColorModeAttribute("system")).toBe("system");
16
- expect(miraColorModeClassName("dark")).toBe("dark theme-dark");
17
- expect(miraColorModeClassName("light")).toBe("light theme-light");
18
- expect(miraColorModeClassName("system")).toBeUndefined();
19
- });
20
- it("resolves an omitted appearance from the nearest themed host", () => {
21
- const host = document.createElement("div");
22
- const trigger = document.createElement("button");
23
- host.dataset.miraTheme = "obsidian company-brand";
24
- host.dataset.miraColorMode = "dark";
25
- host.append(trigger);
26
- expect(resolveMiraThemeAttribute(undefined, trigger)).toBe("obsidian company-brand");
27
- expect(resolveMiraColorModeAttribute("inherit", trigger)).toBe("dark");
28
- expect(resolveMiraThemeAttribute("mira", trigger)).toBe("mira");
29
- expect(resolveMiraColorModeAttribute("light", trigger)).toBe("light");
30
- });
31
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../src/internal/codemirror/base/index.test.ts"],"names":[],"mappings":""}