@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,140 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { GridTableNode } from "./grid-table";
3
- function parseGridTable(markdown) {
4
- const node = GridTableNode.fromMarkdown(markdown);
5
- expect(node).not.toBeNull();
6
- return node;
7
- }
8
- function reparseGridTable(node) {
9
- return parseGridTable(node.toMarkdown());
10
- }
11
- function gridCellContent(node, rowIndex, colIndex) {
12
- return node.grid[rowIndex]?.[colIndex]?.cell.content ?? "";
13
- }
14
- const sampleGridTable = [
15
- "+----------------------+-------------------------+",
16
- "| Feature | Behavior |",
17
- "+======================+=========================+",
18
- "| Row and column menus | Kebab dropdown actions |",
19
- "+----------------------+-------------------------+",
20
- "| Drag handles | Reorder rows/columns |",
21
- "+----------------------+-------------------------+",
22
- "| Source toggle | Edit raw Markdown |",
23
- "+----------------------+-------------------------+",
24
- ].join("\n");
25
- const adobeOverviewGridTable = [
26
- "+-------------------+------+",
27
- "| Table Headings | Here |",
28
- "+--------+----------+------+",
29
- "| Sub | Headings | Too |",
30
- "+========+=================+",
31
- "| cell | column spanning |",
32
- "| spans +---------:+------+",
33
- "| rows | normal | cell |",
34
- "+---v----+:---------------:+",
35
- "| | cells can be |",
36
- "| | *formatted* |",
37
- "| | **paragraphs** |",
38
- "| | ``` |",
39
- "| multi | and contain |",
40
- "| line | blocks |",
41
- "| cells | ``` |",
42
- "+========+=========:+======+",
43
- "| footer | cells | |",
44
- "+--------+----------+------+",
45
- ].join("\n");
46
- const horizontalAlignmentExamples = [
47
- { align: "justify", markdown: ["+>-----<+", "| A b C |", "+-------+"] },
48
- { align: "center", markdown: ["+:-----:+", "| ABC |", "+-------+"] },
49
- { align: "left", markdown: ["+:------+", "| ABC |", "+------+"] },
50
- { align: "right", markdown: ["+------:+", "| ABC |", "+------+"] },
51
- ];
52
- const verticalAlignmentExamples = [
53
- {
54
- markdown: [
55
- "+---^---+",
56
- "| Larum |",
57
- "| Ipsum |",
58
- "| |",
59
- "| |",
60
- "+-------+",
61
- ],
62
- valign: "top",
63
- },
64
- {
65
- markdown: [
66
- "+---x---+",
67
- "| |",
68
- "| Larum |",
69
- "| Ipsum |",
70
- "| |",
71
- "+-------+",
72
- ],
73
- valign: "middle",
74
- },
75
- {
76
- markdown: [
77
- "+---v---+",
78
- "| |",
79
- "| |",
80
- "| Larum |",
81
- "| Ipsum |",
82
- "+-------+",
83
- ],
84
- valign: "bottom",
85
- },
86
- ];
87
- describe("GridTableNode", () => {
88
- it("uses the Lapis grid table model", () => {
89
- const node = GridTableNode.fromMarkdown([
90
- "+---------+----------+",
91
- "| Feature | Behavior |",
92
- "+=========+==========+",
93
- "| Handles | Actions |",
94
- "+---------+----------+",
95
- ].join("\n"));
96
- expect(node).not.toBeNull();
97
- expect(node?.getRowCount()).toBe(2);
98
- expect(node?.getColCount()).toBe(2);
99
- expect(node?.toMarkdown()).toContain("Feature");
100
- });
101
- it("preserves table shape after inserting rows and columns", () => {
102
- const node = parseGridTable(sampleGridTable);
103
- node.insertRowAt(node.getRowCount());
104
- node.insertColumnAt(node.getColCount());
105
- const reparsed = reparseGridTable(node);
106
- expect(reparsed.getRowCount()).toBe(5);
107
- expect(reparsed.getColCount()).toBe(3);
108
- expect(gridCellContent(reparsed, 0, 0)).toBe("Feature");
109
- expect(gridCellContent(reparsed, 1, 1)).toBe("Kebab dropdown actions");
110
- });
111
- it("preserves table shape after moving rows and columns", () => {
112
- const node = parseGridTable(sampleGridTable);
113
- node.moveRow(2, 1);
114
- node.moveColumn(1, 0);
115
- const reparsed = reparseGridTable(node);
116
- expect(reparsed.getRowCount()).toBe(4);
117
- expect(reparsed.getColCount()).toBe(2);
118
- expect(gridCellContent(reparsed, 0, 0)).toBe("Behavior");
119
- expect(gridCellContent(reparsed, 1, 1)).toBe("Drag handles");
120
- });
121
- it("parses the Adobe grid-table overview example with merged rows and columns", () => {
122
- const node = parseGridTable(adobeOverviewGridTable);
123
- const cells = node
124
- .getMdastNode()
125
- .children.flatMap((section) => section.children.flatMap((row) => row.children));
126
- expect(node.getColCount()).toBe(3);
127
- expect(cells.some((cell) => cell.colSpan > 1)).toBe(true);
128
- expect(cells.some((cell) => cell.rowSpan > 1)).toBe(true);
129
- expect(cells.some((cell) => cell.content.includes("*formatted*"))).toBe(true);
130
- expect(node.toMarkdown()).toContain("column spanning");
131
- });
132
- it.each(horizontalAlignmentExamples)("parses Adobe horizontal $align grid-table alignment", ({ align, markdown }) => {
133
- const node = parseGridTable(markdown.join("\n"));
134
- expect(node.grid[0]?.[0]?.cell.align).toBe(align);
135
- });
136
- it.each(verticalAlignmentExamples)("parses Adobe vertical $valign grid-table alignment", ({ valign, markdown }) => {
137
- const node = parseGridTable(markdown.join("\n"));
138
- expect(node.grid[0]?.[0]?.cell.valign).toBe(valign);
139
- });
140
- });
@@ -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/tables/index.test.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { createTableExtensions } from ".";
3
- describe("codemirror tables public API", () => {
4
- it("creates the default table extensions", () => {
5
- expect(createTableExtensions()).toHaveLength(3);
6
- });
7
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=inline-editor-extensions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline-editor-extensions.test.d.ts","sourceRoot":"","sources":["../../src/tables/inline-editor-extensions.test.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import { syntaxTree } from "@codemirror/language";
2
- import { EditorState } from "@codemirror/state";
3
- import { describe, expect, it } from "vitest";
4
- import { createInlineTableMarkdownExtensions } from "./inline-editor-extensions";
5
- describe("createInlineTableMarkdownExtensions", () => {
6
- it("uses the shared Mira Markdown parser for rich table cell editing", () => {
7
- const state = EditorState.create({
8
- doc: [
9
- "**bold** _italic_ `code` [[Project Plan|Plan]] ![[Diagram]] #mira/table",
10
- "\\(x + 1\\)",
11
- ].join("\n"),
12
- extensions: createInlineTableMarkdownExtensions(),
13
- });
14
- const tree = syntaxTree(state).toString();
15
- expect(tree).toContain("StrongEmphasis");
16
- expect(tree).toContain("Emphasis");
17
- expect(tree).toContain("InlineCode");
18
- expect(tree).toContain("WikiLink");
19
- expect(tree).toContain("EmbedLink");
20
- expect(tree).toContain("Tag");
21
- expect(tree).toContain("InlineMathBracket");
22
- });
23
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=pipe-table.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-table.test.d.ts","sourceRoot":"","sources":["../../src/tables/pipe-table.test.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { formatMarkdownTable, parseMarkdownTable } from "./pipe-table";
3
- describe("pipe table parser", () => {
4
- it("parses and formats GFM tables", () => {
5
- const table = parseMarkdownTable("| Package | Status |\n| :--- | ---: |\n| Mira | ready |");
6
- expect(table).toEqual({
7
- header: ["Package", "Status"],
8
- align: ["left", "right"],
9
- rows: [["Mira", "ready"]],
10
- });
11
- expect(formatMarkdownTable(table)).toContain("| Package | Status |");
12
- });
13
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=table-node.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-node.test.d.ts","sourceRoot":"","sources":["../../src/tables/table-node.test.ts"],"names":[],"mappings":""}
@@ -1,167 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { TableNode } from "./table-node";
3
- function parseTable(markdown) {
4
- const node = TableNode.fromMarkdown(markdown);
5
- expect(node).not.toBeNull();
6
- return node;
7
- }
8
- function reparseTable(node) {
9
- return parseTable(node.toMarkdown());
10
- }
11
- function cellText(node, rowIndex, colIndex) {
12
- const cell = node.getMdastNode().children[rowIndex]?.children[colIndex];
13
- return (cell?.children
14
- .map((child) => ("value" in child ? child.value : ""))
15
- .join("") ?? "");
16
- }
17
- const sampleTable = [
18
- "| Package | Role | Status |",
19
- "| --- | --- | --- |",
20
- "| @lapismd/mira/core | editor controller | ready |",
21
- "| @lapismd/mira/preview | rendered markdown | ready |",
22
- ].join("\n");
23
- describe("TableNode", () => {
24
- it("uses the Lapis table model", () => {
25
- const node = TableNode.fromMarkdown("| A |\n| --- |\n| B |");
26
- expect(node?.getRowCount()).toBe(2);
27
- expect(node?.getColCount()).toBe(1);
28
- });
29
- it("preserves table shape after inserting rows and columns", () => {
30
- const node = parseTable(sampleTable);
31
- node.insertRowAt(node.getRowCount());
32
- node.insertColumnAt(node.getColCount());
33
- expect(node.toMarkdown()).not.toContain("| :- |");
34
- expect(node.toMarkdown()).not.toContain("| - |");
35
- expect(node.toMarkdown()).toContain("| --- |");
36
- const reparsed = reparseTable(node);
37
- expect(reparsed.getRowCount()).toBe(4);
38
- expect(reparsed.getColCount()).toBe(4);
39
- for (const row of reparsed.getMdastNode().children) {
40
- expect(row.children).toHaveLength(4);
41
- }
42
- expect(cellText(reparsed, 0, 0)).toBe("Package");
43
- expect(cellText(reparsed, 1, 1)).toBe("editor controller");
44
- });
45
- it("preserves table shape after moving rows and columns", () => {
46
- const node = parseTable(sampleTable);
47
- node.moveRow(2, 1);
48
- node.moveColumn(2, 0);
49
- const reparsed = reparseTable(node);
50
- expect(reparsed.getRowCount()).toBe(3);
51
- expect(reparsed.getColCount()).toBe(3);
52
- for (const row of reparsed.getMdastNode().children) {
53
- expect(row.children).toHaveLength(3);
54
- }
55
- expect(cellText(reparsed, 0, 0)).toBe("Status");
56
- expect(cellText(reparsed, 1, 1)).toBe("@lapismd/mira/preview");
57
- });
58
- it("exposes MultiMarkdown spans for live-preview display without changing source", () => {
59
- const markdown = [
60
- "| MultiMarkdown | Span | Status |",
61
- "| :--- | :--- | ---: |",
62
- "| Combined cell | | ready |",
63
- "| Persistent row | rendered markdown | ready |",
64
- "| ^ | source-compatible spans | ready |",
65
- ].join("\n");
66
- const node = parseTable(markdown);
67
- const displayRows = node.getDisplayMdastNode().children;
68
- expect(node.hasSpans()).toBe(true);
69
- expect(displayRows[1]?.children).toHaveLength(2);
70
- expect(displayRows[1]?.children[0]?.data?.hProperties?.colSpan).toBe(2);
71
- expect(displayRows[1]?.children[0]?.data?.hProperties).toMatchObject({
72
- sourceRowIndex: 1,
73
- sourceColIndex: 0,
74
- displayColIndex: 0,
75
- });
76
- expect(displayRows[2]?.children).toHaveLength(3);
77
- expect(displayRows[2]?.children[0]?.data?.hProperties?.rowSpan).toBe(2);
78
- expect(displayRows[2]?.children[0]?.data?.hProperties).toMatchObject({
79
- sourceRowIndex: 2,
80
- sourceColIndex: 0,
81
- displayColIndex: 0,
82
- });
83
- expect(displayRows[3]?.children).toHaveLength(2);
84
- expect(displayRows[3]?.children[0]?.data?.hProperties).toMatchObject({
85
- sourceRowIndex: 3,
86
- sourceColIndex: 1,
87
- displayColIndex: 1,
88
- });
89
- expect(displayRows[3]?.children[1]?.data?.hProperties).toMatchObject({
90
- sourceRowIndex: 3,
91
- sourceColIndex: 2,
92
- displayColIndex: 2,
93
- });
94
- expect(cellText(node, 3, 0)).toBe("^");
95
- expect(node.toMarkdown()).toContain("| ^");
96
- const displayCell = displayRows[3].children[0];
97
- const coords = displayCell.data.hProperties;
98
- node.updateCellContents(coords.sourceColIndex, coords.sourceRowIndex, [
99
- { type: "text", value: "edited span cell" },
100
- ]);
101
- expect(cellText(node, 3, 0)).toBe("^");
102
- expect(cellText(node, 3, 1)).toBe("edited span cell");
103
- });
104
- it("keeps trailing empty columns separate from MultiMarkdown colspans", () => {
105
- const node = parseTable(sampleTable);
106
- node.insertColumnAt(node.getColCount());
107
- node.rerender();
108
- const headerRow = node.getDisplayMdastNode().children[0];
109
- const bodyRow = node.getDisplayMdastNode().children[1];
110
- expect(node.hasSpans()).toBe(false);
111
- expect(node.getColCount()).toBe(4);
112
- expect(headerRow?.children).toHaveLength(4);
113
- expect(bodyRow?.children).toHaveLength(4);
114
- expect(headerRow?.children[2]?.data?.hProperties?.colSpan).toBeUndefined();
115
- });
116
- it("keeps MultiMarkdown display spans after clone and rerender", () => {
117
- const node = parseTable([
118
- "| MultiMarkdown | Span | Status |",
119
- "| :--- | :--- | ---: |",
120
- "| Combined cell | | ready |",
121
- "| Persistent row | rendered markdown | ready |",
122
- "| ^ | source-compatible spans | ready |",
123
- ].join("\n"));
124
- const clone = TableNode.clone(node);
125
- clone.rerender();
126
- expect(clone.hasSpans()).toBe(true);
127
- expect(clone.getDisplayMdastNode().children[1]?.children[0]?.data?.hProperties
128
- ?.colSpan).toBe(2);
129
- expect(clone.getDisplayMdastNode().children[2]?.children[0]?.data?.hProperties
130
- ?.rowSpan).toBe(2);
131
- expect(clone.toMarkdown()).toContain("| ^");
132
- });
133
- it("selects display rows and columns across MultiMarkdown spans", () => {
134
- const node = parseTable([
135
- "| MultiMarkdown | Span | Status |",
136
- "| :--- | :--- | ---: |",
137
- "| Combined cell | | ready |",
138
- "| Persistent row | rendered markdown | ready |",
139
- "| ^ | source-compatible spans | ready |",
140
- ].join("\n"));
141
- expect(node.getCellsInDisplayColumn(0)).toEqual([
142
- [0, 0],
143
- [1, 0],
144
- [2, 0],
145
- ]);
146
- expect(node.getCellsInDisplayColumn(1)).toEqual([
147
- [0, 1],
148
- [1, 0],
149
- [2, 1],
150
- [3, 1],
151
- ]);
152
- expect(node.getCellsInDisplayRow(1)).toEqual([
153
- [1, 0],
154
- [1, 2],
155
- ]);
156
- expect(node.getCellsInDisplayRow(3)).toEqual([
157
- [2, 0],
158
- [3, 1],
159
- [3, 2],
160
- ]);
161
- expect(node.getCellsInDisplayRange([1, 1], [3, 1])).toEqual([
162
- [1, 0],
163
- [2, 1],
164
- [3, 1],
165
- ]);
166
- });
167
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=source-button.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-button.test.d.ts","sourceRoot":"","sources":["../../../src/tables/widgets/source-button.test.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { createSourceButton } from "./source-button";
3
- describe("table source button", () => {
4
- it("calls the source callback from the widget affordance", () => {
5
- const onSource = vi.fn();
6
- const button = createSourceButton(onSource);
7
- button.click();
8
- expect(button.className).toContain("mira-table-widget__source-toggle");
9
- expect(onSource).toHaveBeenCalledTimes(1);
10
- });
11
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=theme-contract.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme-contract.test.d.ts","sourceRoot":"","sources":["../../src/themes/theme-contract.test.ts"],"names":[],"mappings":""}
@@ -1,88 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { describe, expect, it } from "vitest";
3
- const read = (relativePath) => readFileSync(new URL(relativePath, import.meta.url), "utf8");
4
- describe("Mira theme CSS contract", () => {
5
- it("keeps the Mira palette sentinels and defines both color modes", () => {
6
- const source = read("./_mira-palette.css");
7
- expect(source).toContain("light-dark(#fbfbfc, #17181c)");
8
- expect(source).toContain("light-dark(#0f766e, #2dd4bf)");
9
- expect(source).toContain("--mira-focus-ring: var(--mira-accent)");
10
- expect(source).toContain("--mira-callout-default: var(--_mira-callout-default-light)");
11
- expect(source).toContain('[data-mira-color-mode="dark"]');
12
- expect(source).not.toMatch(/--mira-callout-(?!background\b)[\w-]+:\s*light-dark\(/u);
13
- expect(source).not.toMatch(/--mira-widget-shadow:\s*light-dark\(/u);
14
- });
15
- it("maps the distinct Lapis Obsidian palette", () => {
16
- const source = read("./_obsidian-palette.css");
17
- expect(source).toContain('data-mira-theme~="obsidian"');
18
- expect(source).toContain("light-dark(#ffffff, #1e1e1e)");
19
- expect(source).toContain("light-dark(#222222, #dadada)");
20
- expect(source).toContain("light-dark(hsl(257 88.88% 70.95%), #7852ee)");
21
- expect(source).toContain("--mira-syntax-string: light-dark(#007a58, #53dfdd)");
22
- expect(source).not.toContain("#008f67");
23
- expect(source).not.toContain("light-dark(#fbfbfc, #17181c)");
24
- expect(source).toContain("--mira-callout-default: var(--_mira-callout-default-light)");
25
- expect(source).toContain('[data-mira-theme~="obsidian"][data-mira-color-mode="dark"]');
26
- expect(source).not.toMatch(/--mira-callout-(?!background\b)[\w-]+:\s*light-dark\(/u);
27
- expect(source).not.toMatch(/--mira-widget-shadow:\s*light-dark\(/u);
28
- });
29
- it("loads the contract, Mira fallback, and Obsidian override in order", () => {
30
- const source = read("../themes.css");
31
- const contract = source.indexOf("./themes/_contract.css");
32
- const mira = source.indexOf("./themes/_mira-palette.css");
33
- const obsidian = source.indexOf("./themes/_obsidian-palette.css");
34
- expect(contract).toBeGreaterThanOrEqual(0);
35
- expect(mira).toBeGreaterThan(contract);
36
- expect(obsidian).toBeGreaterThan(mira);
37
- });
38
- it("lets inherited light and dark classes override the root system mode", () => {
39
- const source = read("./_contract.css");
40
- expect(source).toContain(":is(.dark, .theme-dark)");
41
- expect(source).toContain(":is(.light, .theme-light)");
42
- expect(source).not.toContain(":where(.dark, .theme-dark)");
43
- expect(source).not.toContain(":where(.light, .theme-light)");
44
- });
45
- it("exports aggregate and individual theme entrypoints", () => {
46
- const manifest = JSON.parse(read("../../package.json"));
47
- expect(manifest.exports).toHaveProperty("./themes/mira.css");
48
- expect(manifest.exports).toHaveProperty("./themes/obsidian.css");
49
- expect(manifest.exports).toHaveProperty("./themes.css");
50
- });
51
- it("uses the theme-primary embed accent for blockquote guides", () => {
52
- const tokens = read("../preview/styles/tokens.css");
53
- const embeds = read("../preview/styles/links-embeds-tags.css");
54
- expect(tokens).toContain("--blockquote-border-color: var(--interactive-accent)");
55
- expect(embeds).toContain("border-inline-start: 2px solid var(--interactive-accent)");
56
- });
57
- it("exposes the complete Lapis-compatible per-level heading contract", () => {
58
- const contract = read("./_contract.css");
59
- const tokens = read("../preview/styles/tokens.css");
60
- const headings = read("../preview/styles/headings.css");
61
- const sizes = [
62
- "1.802em",
63
- "1.602em",
64
- "1.424em",
65
- "1.266em",
66
- "1.125em",
67
- "1em",
68
- ];
69
- const lineHeights = ["1.2", "1.2", "1.3", "1.4", "1.5", "1.5"];
70
- const weights = ["700", "600", "600", "600", "600", "600"];
71
- expect(contract).toContain("--mira-heading-color: var(--mira-foreground)");
72
- for (let index = 0; index < 6; index += 1) {
73
- const level = index + 1;
74
- expect(contract).toContain(`--mira-h${level}-color: var(--mira-heading-color)`);
75
- expect(contract).toContain(`--mira-h${level}-font: var(--mira-font-sans)`);
76
- expect(contract).toContain(`--mira-h${level}-size: ${sizes[index]}`);
77
- expect(contract).toContain(`--mira-h${level}-line-height: ${lineHeights[index]}`);
78
- expect(contract).toContain(`--mira-h${level}-style: normal`);
79
- expect(contract).toContain(`--mira-h${level}-variant: normal`);
80
- expect(contract).toContain(`--mira-h${level}-weight: ${weights[index]}`);
81
- expect(tokens).toContain(`--h${level}-color: var(--mira-h${level}-color)`);
82
- expect(tokens).toContain(`--h${level}-weight: var(--mira-h${level}-weight)`);
83
- }
84
- expect(headings).toContain(".cm-heading:not(.cm-meta)");
85
- expect(headings).toContain("color: inherit");
86
- expect(headings).toContain("font-weight: inherit");
87
- });
88
- });
@@ -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/ui/index.test.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { cn } from ".";
3
- describe("cn", () => {
4
- it("merges class values", () => {
5
- expect(cn("a", false, "b")).toBe("a b");
6
- });
7
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=styles.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.test.d.ts","sourceRoot":"","sources":["../../src/ui/styles.test.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { describe, expect, it } from "vitest";
3
- const readSource = (relativePath) => readFileSync(new URL(relativePath, import.meta.url), "utf8");
4
- describe("Mira UI style boundaries", () => {
5
- it("scopes dialog overlay paint to Mira-owned overlays", () => {
6
- const styles = readSource("./styles.css");
7
- const overlay = readSource("./dialog/dialog-overlay.svelte");
8
- expect(styles).toContain('[data-mira-overlay][data-slot="dialog-overlay"]');
9
- expect(styles).not.toMatch(/(?:^|\n)\[data-slot="dialog-(?:overlay|content|title|description|header|footer)"\]/u);
10
- expect(overlay).toContain("data-mira-overlay");
11
- });
12
- it("scopes popover paint to Mira-owned overlays", () => {
13
- const styles = readSource("./styles.css");
14
- const popover = readSource("./popover/popover-content.svelte");
15
- expect(styles).toContain('[data-mira-overlay][data-slot="popover-content"]');
16
- expect(styles).not.toMatch(/(?:^|\n)\[data-slot="popover-content"\]\s*\{/u);
17
- expect(popover).toContain("data-mira-overlay");
18
- });
19
- it("scopes tooltip paint to Mira-owned overlays", () => {
20
- const styles = readSource("./styles.css");
21
- const tooltip = readSource("./tooltip/tooltip-content.svelte");
22
- expect(styles).toContain('[data-mira-overlay][data-slot="tooltip-content"]');
23
- expect(styles).not.toMatch(/(?:^|\n)\[data-slot="tooltip-content"\]/u);
24
- expect(tooltip).toContain("data-mira-overlay");
25
- });
26
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=table-dnd-utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-dnd-utils.test.d.ts","sourceRoot":"","sources":["../../../src/ui/table-dnd/table-dnd-utils.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { dropIndicatorClasses, isColumnDragSource, isRowDragSource, parseTableDragData, resolveTableDragTargetIndex, tableColDragType, tableRowDragType, } from "./table-dnd-utils";
3
- const rowType = tableRowDragType("csv");
4
- const colType = tableColDragType("csv");
5
- describe("dropIndicatorClasses", () => {
6
- it("marks column drop to the right", () => {
7
- expect(dropIndicatorClasses({ type: colType, index: 1 }, 3, 0, 3, rowType, colType)).toBe("is-dragging-right");
8
- });
9
- it("marks row drop above", () => {
10
- expect(dropIndicatorClasses({ type: rowType, index: 3 }, 1, 1, 0, rowType, colType)).toBe("is-dragging-top");
11
- });
12
- it("detects active row and column drag sources", () => {
13
- expect(isRowDragSource({ type: rowType, index: 2 }, 2, rowType)).toBe(true);
14
- expect(isRowDragSource({ type: rowType, index: 2 }, 1, rowType)).toBe(false);
15
- expect(isColumnDragSource({ type: colType, index: 1 }, 1, colType)).toBe(true);
16
- expect(isColumnDragSource({ type: colType, index: 1 }, 0, colType)).toBe(false);
17
- });
18
- });
19
- describe("parseTableDragData", () => {
20
- it("reads drag data from operation payload", () => {
21
- expect(parseTableDragData({
22
- data: { type: rowType, index: 2 },
23
- }, rowType, colType)).toEqual({ type: rowType, index: 2 });
24
- });
25
- it("parses csv-style drop ids", () => {
26
- expect(parseTableDragData({ id: "csv-row-drop:1:grip" }, rowType, colType)).toEqual({ type: rowType, index: 1 });
27
- });
28
- });
29
- describe("resolveTableDragTargetIndex", () => {
30
- it("prefers explicit drop target over dragOverIndex", () => {
31
- expect(resolveTableDragTargetIndex({
32
- operation: {
33
- source: { data: { type: rowType, index: 1 } },
34
- target: { data: { type: rowType, index: 3 } },
35
- },
36
- }, 2, rowType, colType)).toBe(3);
37
- });
38
- it("falls back to dragOverIndex", () => {
39
- expect(resolveTableDragTargetIndex({
40
- operation: {
41
- source: { data: { type: rowType, index: 1 } },
42
- target: null,
43
- },
44
- }, 3, rowType, colType)).toBe(3);
45
- });
46
- });