@lemonriver/core 1.1.0 → 1.2.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.
Files changed (92) hide show
  1. package/dist/{build-Dm7gVRhb.js → build-CSkdswfd.js} +1 -1
  2. package/dist/cli/bin.js +5 -5
  3. package/dist/{config-CubOIzrs.js → config-C5-myPY6.js} +129 -2
  4. package/dist/{dev-DgLeXPqp.js → dev-DHtYH8sw.js} +2 -2
  5. package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
  6. package/dist/{preview-CxXQpPk5.js → preview-C1B6-umF.js} +1 -1
  7. package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
  8. package/dist/vite/index.js +1 -1
  9. package/package.json +5 -2
  10. package/release-notes.json +19 -0
  11. package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
  12. package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
  13. package/src/app/lemonriver/feedback/dialog.tsx +222 -0
  14. package/src/app/lemonriver/feedback/export.ts +21 -2
  15. package/src/app/lemonriver/feedback/first-success.ts +30 -0
  16. package/src/app/lemonriver/feedback/install.ts +18 -0
  17. package/src/app/lemonriver/feedback/model.ts +88 -0
  18. package/src/app/lemonriver/help/help-page.tsx +16 -1
  19. package/src/app/lemonriver/links.ts +16 -0
  20. package/src/app/lemonriver/settings/backup-section.tsx +13 -0
  21. package/src/app/lemonriver/settings/settings-page.tsx +20 -0
  22. package/src/app/lemonriver/share/editor-share.tsx +6 -3
  23. package/src/app/lemonriver/share/share-dialog.tsx +2 -0
  24. package/src/app/lemonriver/text/en.ts +45 -0
  25. package/src/app/lemonriver/text/es.ts +42 -0
  26. package/src/app/lemonriver/text/ja.ts +41 -0
  27. package/src/app/lemonriver/text/types.ts +44 -0
  28. package/src/app/lemonriver/text/zh-cn.ts +45 -0
  29. package/src/app/lemonriver/text/zh-tw.ts +45 -0
  30. package/src/app/lemonriver/theme/pages.ts +4 -0
  31. package/src/app/lemonriver/update/release-notes.ts +22 -0
  32. package/src/app/lemonriver/update/update-prompt.tsx +28 -4
  33. package/src/app/components/note-markdown.test.tsx +0 -42
  34. package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
  35. package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
  36. package/src/app/lemonriver/backup/guide.test.ts +0 -45
  37. package/src/app/lemonriver/backup/model.test.ts +0 -108
  38. package/src/app/lemonriver/backup/places.test.ts +0 -154
  39. package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
  40. package/src/app/lemonriver/board/layout.test.ts +0 -245
  41. package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
  42. package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
  43. package/src/app/lemonriver/board/model/cards.test.ts +0 -332
  44. package/src/app/lemonriver/board/model/changes.test.ts +0 -244
  45. package/src/app/lemonriver/board/model/filter.test.ts +0 -50
  46. package/src/app/lemonriver/board/model/history.test.ts +0 -71
  47. package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
  48. package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
  49. package/src/app/lemonriver/board/model/structure.test.ts +0 -350
  50. package/src/app/lemonriver/board/model/timing.test.ts +0 -113
  51. package/src/app/lemonriver/features.test.ts +0 -49
  52. package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
  53. package/src/app/lemonriver/feedback/upload.test.ts +0 -26
  54. package/src/app/lemonriver/help/model.test.ts +0 -179
  55. package/src/app/lemonriver/home/brief.test.ts +0 -38
  56. package/src/app/lemonriver/home/drafts.test.ts +0 -23
  57. package/src/app/lemonriver/home/sorting.test.ts +0 -24
  58. package/src/app/lemonriver/home/time.test.ts +0 -33
  59. package/src/app/lemonriver/outline/files.test.ts +0 -90
  60. package/src/app/lemonriver/outline/model.test.ts +0 -751
  61. package/src/app/lemonriver/public-links.test.ts +0 -32
  62. package/src/app/lemonriver/routes.test.tsx +0 -54
  63. package/src/app/lemonriver/share/codes.test.ts +0 -49
  64. package/src/app/lemonriver/share/compare.test.ts +0 -199
  65. package/src/app/lemonriver/share/folder.test.ts +0 -42
  66. package/src/app/lemonriver/share/guide.test.ts +0 -78
  67. package/src/app/lemonriver/share/naming.test.ts +0 -70
  68. package/src/app/lemonriver/share/paths.test.ts +0 -116
  69. package/src/app/lemonriver/share/pdf.test.ts +0 -79
  70. package/src/app/lemonriver/templates/knobs.test.ts +0 -62
  71. package/src/app/lemonriver/templates/model.test.ts +0 -175
  72. package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
  73. package/src/app/lemonriver/templates/recommend.test.ts +0 -71
  74. package/src/app/lemonriver/text/text.test.ts +0 -90
  75. package/src/app/lemonriver/theme/pages.test.ts +0 -74
  76. package/src/app/lemonriver/theme/themes.test.ts +0 -18
  77. package/src/app/lemonriver/trash/api.test.ts +0 -19
  78. package/src/app/lemonriver/update/prompt.test.ts +0 -84
  79. package/src/app/lemonriver/update/version.test.ts +0 -14
  80. package/src/app/lib/asset-filter.test.ts +0 -176
  81. package/src/app/lib/inspector/fiber.test.ts +0 -154
  82. package/src/app/lib/inspector/geometry.test.ts +0 -324
  83. package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
  84. package/src/app/lib/note-markdown.test.ts +0 -147
  85. package/src/app/lib/pptx/css.test.ts +0 -205
  86. package/src/app/lib/pptx/ooxml.test.ts +0 -199
  87. package/src/app/lib/pptx/text-lines.test.ts +0 -82
  88. package/src/app/lib/print-ready.test.ts +0 -32
  89. package/src/app/lib/sdk.test.ts +0 -13
  90. package/src/app/lib/transition.test.ts +0 -31
  91. package/src/app/lib/use-document-title.test.ts +0 -14
  92. package/src/app/lib/utils.test.ts +0 -49
@@ -1,324 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- alignRects,
4
- distributeRects,
5
- type Rect,
6
- rectContains,
7
- rectsIntersect,
8
- resizeRect,
9
- snapMove,
10
- solveResizeDimensions,
11
- unionRects,
12
- } from './geometry.ts';
13
-
14
- describe('unionRects', () => {
15
- it('finds group bounds across negative coordinates and nested objects', () => {
16
- expect(
17
- unionRects([
18
- { x: -20, y: 30, width: 100, height: 50 },
19
- { x: 0, y: -10, width: 20, height: 20 },
20
- { x: 5, y: 40, width: 10, height: 10 },
21
- ]),
22
- ).toEqual({ x: -20, y: -10, width: 100, height: 90 });
23
- expect(unionRects([])).toBeNull();
24
- });
25
- });
26
-
27
- describe('snapMove', () => {
28
- it('chooses the nearest target on each axis and spans the final snapped objects', () => {
29
- expect(
30
- snapMove(
31
- { x: 0, y: 0, width: 20, height: 20 },
32
- { x: 78, y: 79 },
33
- [
34
- { x: 104, y: 200, width: 40, height: 40 },
35
- { x: 100, y: 250, width: 40, height: 40 },
36
- { x: 300, y: 100, width: 20, height: 20 },
37
- ],
38
- 6,
39
- ),
40
- ).toEqual({
41
- delta: { x: 80, y: 80 },
42
- guides: [
43
- { axis: 'x', position: 100, start: 80, end: 290 },
44
- { axis: 'y', position: 100, start: 80, end: 320 },
45
- ],
46
- });
47
- });
48
-
49
- it('snaps centers and includes candidates exactly at the threshold', () => {
50
- const result = snapMove(
51
- { x: 0, y: 0, width: 20, height: 20 },
52
- { x: 76, y: 50 },
53
- [{ x: 60, y: 200, width: 60, height: 20 }],
54
- 4,
55
- );
56
- expect(result.delta).toEqual({ x: 80, y: 50 });
57
- expect(result.guides).toEqual([{ axis: 'x', position: 90, start: 50, end: 220 }]);
58
- });
59
-
60
- it('breaks equal-distance ties consistently regardless of target order', () => {
61
- const rect = { x: 0, y: 0, width: 20, height: 20 };
62
- const targets = [
63
- { x: 103, y: 200, width: 20, height: 20 },
64
- { x: 97, y: 200, width: 20, height: 20 },
65
- ];
66
- const result = snapMove(rect, { x: 80, y: 50 }, targets, 3);
67
- expect(result.delta).toEqual({ x: 77, y: 50 });
68
- expect(snapMove(rect, { x: 80, y: 50 }, [...targets].reverse(), 3)).toEqual(result);
69
- });
70
-
71
- it('preserves unsnapped movement when every target is outside the threshold', () => {
72
- expect(
73
- snapMove(
74
- { x: 0, y: 0, width: 20, height: 20 },
75
- { x: 10, y: 10 },
76
- [{ x: 100, y: 100, width: 20, height: 20 }],
77
- 5,
78
- ),
79
- ).toEqual({ delta: { x: 10, y: 10 }, guides: [] });
80
- });
81
- });
82
-
83
- describe('alignRects', () => {
84
- const rects = [
85
- { x: 10, y: 20, width: 20, height: 40 },
86
- { x: 80, y: 100, width: 40, height: 20 },
87
- ];
88
-
89
- it.each([
90
- [
91
- 'left',
92
- [
93
- { x: 0, y: 0 },
94
- { x: -70, y: 0 },
95
- ],
96
- ],
97
- [
98
- 'center',
99
- [
100
- { x: 45, y: 0 },
101
- { x: -35, y: 0 },
102
- ],
103
- ],
104
- [
105
- 'right',
106
- [
107
- { x: 90, y: 0 },
108
- { x: 0, y: 0 },
109
- ],
110
- ],
111
- [
112
- 'top',
113
- [
114
- { x: 0, y: 0 },
115
- { x: 0, y: -80 },
116
- ],
117
- ],
118
- [
119
- 'middle',
120
- [
121
- { x: 0, y: 30 },
122
- { x: 0, y: -40 },
123
- ],
124
- ],
125
- [
126
- 'bottom',
127
- [
128
- { x: 0, y: 60 },
129
- { x: 0, y: 0 },
130
- ],
131
- ],
132
- ] as const)('aligns %s against group bounds', (alignment, expected) => {
133
- expect(alignRects(rects, alignment)).toEqual(expected);
134
- });
135
-
136
- it('aligns a single object against explicit slide bounds', () => {
137
- expect(alignRects([rects[0]], 'center', { x: 0, y: 0, width: 1280, height: 720 })).toEqual([
138
- { x: 620, y: 0 },
139
- ]);
140
- expect(alignRects([], 'left')).toEqual([]);
141
- });
142
- });
143
-
144
- describe('distributeRects', () => {
145
- it('creates equal horizontal gaps for unequal sizes and preserves the input order', () => {
146
- const rects = [
147
- { x: 200, y: 20, width: 40, height: 20 },
148
- { x: 60, y: 30, width: 20, height: 30 },
149
- { x: 0, y: 10, width: 60, height: 40 },
150
- ];
151
- expect(distributeRects(rects, 'x')).toEqual([
152
- { x: 0, y: 0 },
153
- { x: 60, y: 0 },
154
- { x: 0, y: 0 },
155
- ]);
156
- });
157
-
158
- it('distributes vertical spacing while keeping the first and last objects fixed', () => {
159
- expect(
160
- distributeRects(
161
- [
162
- { x: 10, y: 0, width: 10, height: 30 },
163
- { x: 30, y: 40, width: 10, height: 10 },
164
- { x: 50, y: 150, width: 10, height: 20 },
165
- { x: 70, y: 210, width: 10, height: 30 },
166
- ],
167
- 'y',
168
- ),
169
- ).toEqual([
170
- { x: 0, y: 0 },
171
- { x: 0, y: 40 },
172
- { x: 0, y: -10 },
173
- { x: 0, y: 0 },
174
- ]);
175
- });
176
-
177
- it('leaves fewer than three objects in place', () => {
178
- expect(distributeRects([], 'x')).toEqual([]);
179
- expect(distributeRects([{ x: 10, y: 20, width: 30, height: 40 }], 'y')).toEqual([
180
- { x: 0, y: 0 },
181
- ]);
182
- });
183
- });
184
-
185
- describe('resizeRect', () => {
186
- const rect: Rect = { x: 100, y: 200, width: 80, height: 40 };
187
-
188
- it('clamps crossed edges to a minimum size while keeping the opposite corner anchored', () => {
189
- expect(resizeRect(rect, 'nw', { x: 200, y: 200 })).toEqual({
190
- x: 172,
191
- y: 232,
192
- width: 8,
193
- height: 8,
194
- });
195
- expect(resizeRect(rect, 'se', { x: -200, y: -200 })).toEqual({
196
- x: 100,
197
- y: 200,
198
- width: 8,
199
- height: 8,
200
- });
201
- });
202
-
203
- it('locks corner aspect ratio using the dominant relative movement', () => {
204
- expect(resizeRect(rect, 'nw', { x: -20, y: -40 }, true)).toEqual({
205
- x: 20,
206
- y: 160,
207
- width: 160,
208
- height: 80,
209
- });
210
- expect(resizeRect(rect, 'sw', { x: -80, y: 10 }, true)).toEqual({
211
- x: 20,
212
- y: 200,
213
- width: 160,
214
- height: 80,
215
- });
216
- });
217
-
218
- it('keeps both minimum size and aspect ratio when shrinking', () => {
219
- expect(resizeRect(rect, 'ne', { x: -100, y: 100 }, true)).toEqual({
220
- x: 100,
221
- y: 232,
222
- width: 16,
223
- height: 8,
224
- });
225
- });
226
-
227
- it('keeps the opposite edge midpoint fixed for aspect-locked side handles', () => {
228
- expect(resizeRect(rect, 'e', { x: 40, y: 100 }, true)).toEqual({
229
- x: 100,
230
- y: 190,
231
- width: 120,
232
- height: 60,
233
- });
234
- expect(resizeRect(rect, 'n', { x: 100, y: -20 }, true)).toEqual({
235
- x: 80,
236
- y: 180,
237
- width: 120,
238
- height: 60,
239
- });
240
- });
241
-
242
- it('ignores perpendicular movement for an unlocked side handle', () => {
243
- expect(resizeRect(rect, 'w', { x: 20, y: 100 })).toEqual({
244
- x: 120,
245
- y: 200,
246
- width: 60,
247
- height: 40,
248
- });
249
- });
250
- });
251
-
252
- describe('solveResizeDimensions', () => {
253
- const size = { width: 200, height: 100 };
254
- const rotatedBasis = (degrees: number, scale = 1) => {
255
- const angle = (degrees * Math.PI) / 180;
256
- return {
257
- a: Math.cos(angle) * scale,
258
- b: Math.sin(angle) * scale,
259
- c: Math.sin(angle) * scale,
260
- d: Math.cos(angle) * scale,
261
- };
262
- };
263
-
264
- it('resizes independent axes exactly for an unrotated element', () => {
265
- expect(solveResizeDimensions(size, { a: 1, b: 0, c: 0, d: 1 }, { x: 50, y: -20 })).toEqual({
266
- width: 250,
267
- height: 80,
268
- });
269
- });
270
-
271
- it('solves feasible rotated sizes without forcing an aspect lock', () => {
272
- const basis = rotatedBasis(30);
273
- const result = solveResizeDimensions(size, basis, {
274
- x: 40 * basis.a - 20 * basis.c,
275
- y: 40 * basis.b - 20 * basis.d,
276
- });
277
- expect(result.width).toBeCloseTo(240);
278
- expect(result.height).toBeCloseTo(80);
279
- });
280
-
281
- it.each([44, 45, 46])('preserves proportions instead of distorting at %s degrees', (angle) => {
282
- const result = solveResizeDimensions(size, rotatedBasis(angle), { x: 50, y: 0 });
283
- expect(result.width).toBeGreaterThan(200);
284
- expect(result.width).toBeLessThan(250);
285
- expect(result.height).toBeGreaterThan(100);
286
- expect(result.width / result.height).toBeCloseTo(2);
287
- });
288
-
289
- it('uses the same safe result under a scaled parent', () => {
290
- const normal = solveResizeDimensions(size, rotatedBasis(44), { x: 50, y: 0 });
291
- const scaled = solveResizeDimensions(size, rotatedBasis(44, 0.2), { x: 10, y: 0 });
292
- expect(scaled.width).toBeCloseTo(normal.width);
293
- expect(scaled.height).toBeCloseTo(normal.height);
294
- });
295
-
296
- it('preserves proportions when the requested bounds require a negative local size', () => {
297
- const result = solveResizeDimensions(size, rotatedBasis(30), { x: 200, y: 0 });
298
- expect(result.width).toBeLessThan(400);
299
- expect(result.width / result.height).toBeCloseTo(2);
300
- });
301
-
302
- it('keeps both local dimensions above the minimum when fitting a smaller box', () => {
303
- const result = solveResizeDimensions(size, rotatedBasis(45), { x: -1000, y: -1000 });
304
- expect(result).toEqual({ width: 16, height: 8 });
305
- });
306
- });
307
-
308
- describe('rectsIntersect', () => {
309
- it('detects overlap but not edges that only touch', () => {
310
- const marquee: Rect = { x: 90, y: 130, width: 510, height: 270 };
311
- expect(rectsIntersect(marquee, { x: 520, y: 360, width: 240, height: 160 })).toBe(true);
312
- expect(rectsIntersect(marquee, { x: 600, y: 360, width: 240, height: 160 })).toBe(false);
313
- expect(rectsIntersect(marquee, { x: 1120, y: 660, width: 240, height: 160 })).toBe(false);
314
- });
315
- });
316
-
317
- describe('rectContains', () => {
318
- it('requires the inner rect to sit fully inside the outer rect', () => {
319
- const outer: Rect = { x: 0, y: 0, width: 100, height: 100 };
320
- expect(rectContains(outer, { x: 10, y: 10, width: 80, height: 80 })).toBe(true);
321
- expect(rectContains(outer, { x: 0, y: 0, width: 100, height: 100 })).toBe(true);
322
- expect(rectContains(outer, { x: 50, y: 50, width: 60, height: 20 })).toBe(false);
323
- });
324
- });
@@ -1,121 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { applyEditBatch } from '../../../editing/batch-edit';
3
- import { appendTextEdit, type TextEditStep } from './text-edit-timeline';
4
-
5
- const source = 'export const Slide = () => <p>Editable body copy</p>;';
6
- const original = 'Editable body copy';
7
- const location = { line: 1, column: source.indexOf('<p>') };
8
-
9
- function save(steps: TextEditStep[]) {
10
- return applyEditBatch(
11
- source,
12
- steps.map(({ op }) => ({ ...location, ops: [op] })),
13
- );
14
- }
15
-
16
- describe('text edit timeline', () => {
17
- it('coalesces consecutive typing while retaining the source baseline', () => {
18
- let steps = appendTextEdit([], { kind: 'set-text', value: 'First', prevText: original }, 1);
19
- steps = appendTextEdit(steps, { kind: 'set-text', value: 'Final', prevText: 'First' }, 2);
20
- expect(steps).toEqual([
21
- { seq: 2, op: { kind: 'set-text', value: 'Final', prevText: original } },
22
- ]);
23
- expect(save(steps).source).toContain('<p>Final</p>');
24
- });
25
-
26
- it('keeps the intermediate text required by a range format before later typing', () => {
27
- const updated = `${original} updated`;
28
- let steps = appendTextEdit([], { kind: 'set-text', value: updated, prevText: original }, 1);
29
- steps = appendTextEdit(
30
- steps,
31
- {
32
- kind: 'set-text-range-style',
33
- start: 0,
34
- end: 8,
35
- key: 'fontWeight',
36
- value: '700',
37
- prevText: updated,
38
- },
39
- 2,
40
- );
41
- steps = appendTextEdit(
42
- steps,
43
- { kind: 'set-text', value: `${updated} again`, prevText: updated },
44
- 3,
45
- );
46
- const result = save(steps);
47
- expect(result.results).toEqual([{ ok: true }, { ok: true }, { ok: true }]);
48
- expect(result.source).toContain('fontWeight');
49
- expect(result.source).toContain('updated again');
50
- });
51
-
52
- it('keeps typing checkpoints across whole-text style operations', () => {
53
- const first = appendTextEdit([], { kind: 'set-text', value: 'First', prevText: original }, 1);
54
- const final = appendTextEdit(first, { kind: 'set-text', value: 'Final', prevText: 'First' }, 3);
55
- expect(final).toHaveLength(2);
56
- const result = applyEditBatch(source, [
57
- { ...location, ops: [final[0].op] },
58
- {
59
- ...location,
60
- ops: [{ kind: 'set-style', key: 'fontSize', value: '28px', prevText: 'First' }],
61
- },
62
- { ...location, ops: [final[1].op] },
63
- ]);
64
- expect(result.results.every((item) => item.ok)).toBe(true);
65
- expect(result.source).toContain('Final');
66
- expect(result.source).toContain('28px');
67
- });
68
-
69
- it('preserves earlier snapshots when typing is coalesced and then resumed after undo', () => {
70
- const before = appendTextEdit([], { kind: 'set-text', value: 'First', prevText: original }, 1);
71
- const after = appendTextEdit(
72
- before,
73
- { kind: 'set-text', value: 'Second', prevText: 'First' },
74
- 2,
75
- );
76
- expect(before[0].op).toEqual({ kind: 'set-text', value: 'First', prevText: original });
77
- expect(after[0].op).toEqual({ kind: 'set-text', value: 'Second', prevText: original });
78
- const resumed = appendTextEdit(
79
- before,
80
- { kind: 'set-text', value: 'Third', prevText: 'First' },
81
- 3,
82
- );
83
- expect(save(resumed).results.every((item) => item.ok)).toBe(true);
84
- expect(save(resumed).source).toContain('<p>Third</p>');
85
- });
86
-
87
- it('formats current text coordinates after inserting a prefix without dropping prior styles', () => {
88
- let steps = appendTextEdit(
89
- [],
90
- {
91
- kind: 'set-text-range-style',
92
- start: 0,
93
- end: 8,
94
- key: 'fontWeight',
95
- value: '700',
96
- prevText: original,
97
- },
98
- 1,
99
- );
100
- const prefixed = `New ${original}`;
101
- steps = appendTextEdit(steps, { kind: 'set-text', value: prefixed, prevText: original }, 2);
102
- steps = appendTextEdit(
103
- steps,
104
- {
105
- kind: 'set-text-range-style',
106
- start: 13,
107
- end: 17,
108
- key: 'fontStyle',
109
- value: 'italic',
110
- prevText: prefixed,
111
- },
112
- 3,
113
- );
114
- const result = save(steps);
115
- expect(result.results).toEqual([{ ok: true }, { ok: true }, { ok: true }]);
116
- expect(result.source).toContain('New Editable');
117
- expect(result.source).toContain('fontWeight');
118
- expect(result.source).toContain('fontStyle');
119
- expect(result.source).toContain('italic');
120
- });
121
- });
@@ -1,147 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { type NoteInline, parseInline, parseNoteMarkdown } from './note-markdown.ts';
3
-
4
- const text = (t: string): NoteInline => ({ type: 'text', text: t });
5
-
6
- describe('parseInline', () => {
7
- it('returns plain text untouched', () => {
8
- expect(parseInline('just a sentence')).toEqual([text('just a sentence')]);
9
- });
10
-
11
- it('parses bold', () => {
12
- expect(parseInline('a **key** point')).toEqual([
13
- text('a '),
14
- { type: 'strong', children: [text('key')] },
15
- text(' point'),
16
- ]);
17
- });
18
-
19
- it('parses italic with stars and underscores', () => {
20
- expect(parseInline('*a* and _b_')).toEqual([
21
- { type: 'em', children: [text('a')] },
22
- text(' and '),
23
- { type: 'em', children: [text('b')] },
24
- ]);
25
- });
26
-
27
- it('parses inline code literally', () => {
28
- expect(parseInline('run `pnpm **dev**`')).toEqual([
29
- text('run '),
30
- { type: 'code', text: 'pnpm **dev**' },
31
- ]);
32
- });
33
-
34
- it('parses italic nested in bold', () => {
35
- expect(parseInline('**bold _in_ here**')).toEqual([
36
- {
37
- type: 'strong',
38
- children: [text('bold '), { type: 'em', children: [text('in')] }, text(' here')],
39
- },
40
- ]);
41
- });
42
-
43
- it('leaves snake_case and unpaired markers alone', () => {
44
- expect(parseInline('use snake_case_names here')).toEqual([text('use snake_case_names here')]);
45
- expect(parseInline('2 * 3 and a_b')).toEqual([text('2 * 3 and a_b')]);
46
- });
47
-
48
- it('treats backslash-escaped delimiters as literal text', () => {
49
- expect(parseInline('\\*not italic\\*')).toEqual([text('*not italic*')]);
50
- expect(parseInline('\\**emphasis**')).toEqual([
51
- text('*'),
52
- { type: 'em', children: [text('emphasis')] },
53
- text('*'),
54
- ]);
55
- expect(parseInline('a \\` b and \\\\ done')).toEqual([text('a ` b and \\ done')]);
56
- });
57
-
58
- it('keeps the backslash inside code spans', () => {
59
- expect(parseInline('`a\\*b`')).toEqual([{ type: 'code', text: 'a\\*b' }]);
60
- });
61
-
62
- it('does not pair emphasis markers padded with spaces', () => {
63
- expect(parseInline('2 * 3 = 6 and 5 * 4')).toEqual([text('2 * 3 = 6 and 5 * 4')]);
64
- expect(parseInline('a ** b ** c')).toEqual([text('a ** b ** c')]);
65
- expect(parseInline('a _ b _ c')).toEqual([text('a _ b _ c')]);
66
- expect(parseInline('*a* and *no trail *')).toEqual([
67
- { type: 'em', children: [text('a')] },
68
- text(' and *no trail *'),
69
- ]);
70
- });
71
- });
72
-
73
- describe('parseNoteMarkdown', () => {
74
- it('splits paragraphs on blank lines and keeps line breaks inside one', () => {
75
- expect(parseNoteMarkdown('one\ntwo\n\nthree')).toEqual([
76
- { type: 'paragraph', lines: [[text('one')], [text('two')]] },
77
- { type: 'paragraph', lines: [[text('three')]] },
78
- ]);
79
- });
80
-
81
- it('parses headings up to level 3', () => {
82
- expect(parseNoteMarkdown('# Intro\n#### not a heading')).toEqual([
83
- { type: 'heading', level: 1, children: [text('Intro')] },
84
- { type: 'paragraph', lines: [[text('#### not a heading')]] },
85
- ]);
86
- });
87
-
88
- it('groups consecutive bullets into one list', () => {
89
- expect(parseNoteMarkdown('- a\n- **b**\ntail')).toEqual([
90
- {
91
- type: 'list',
92
- ordered: false,
93
- items: [[text('a')], [{ type: 'strong', children: [text('b')] }]],
94
- },
95
- { type: 'paragraph', lines: [[text('tail')]] },
96
- ]);
97
- });
98
-
99
- it('parses ordered lists with dot or paren markers', () => {
100
- expect(parseNoteMarkdown('1. a\n2) b')).toEqual([
101
- { type: 'list', ordered: true, items: [[text('a')], [text('b')]] },
102
- ]);
103
- });
104
-
105
- it('keeps unordered and ordered runs as separate lists', () => {
106
- expect(parseNoteMarkdown('- a\n1. b')).toEqual([
107
- { type: 'list', ordered: false, items: [[text('a')]] },
108
- { type: 'list', ordered: true, items: [[text('b')]] },
109
- ]);
110
- });
111
-
112
- it('does not treat a mid-sentence star line as a bullet without a space', () => {
113
- expect(parseNoteMarkdown('*emphasis line*')).toEqual([
114
- { type: 'paragraph', lines: [[{ type: 'em', children: [text('emphasis line')] }]] },
115
- ]);
116
- });
117
-
118
- it('escapes disable heading and list markers', () => {
119
- expect(parseNoteMarkdown('\\# not a heading')).toEqual([
120
- { type: 'paragraph', lines: [[text('# not a heading')]] },
121
- ]);
122
- expect(parseNoteMarkdown('\\- not a bullet\n1\\. not a list')).toEqual([
123
- { type: 'paragraph', lines: [[text('- not a bullet')], [text('1. not a list')]] },
124
- ]);
125
- });
126
-
127
- it('does not treat a 4-digit year line as an ordered list', () => {
128
- expect(parseNoteMarkdown('1995. the year it began')).toEqual([
129
- { type: 'paragraph', lines: [[text('1995. the year it began')]] },
130
- ]);
131
- });
132
-
133
- it('treats a bare # without content as plain text', () => {
134
- expect(parseNoteMarkdown('# ')).toEqual([{ type: 'paragraph', lines: [[text('#')]] }]);
135
- });
136
-
137
- it('preserves leading whitespace in paragraph lines', () => {
138
- expect(parseNoteMarkdown('plan:\n indented detail')).toEqual([
139
- { type: 'paragraph', lines: [[text('plan:')], [text(' indented detail')]] },
140
- ]);
141
- });
142
-
143
- it('handles empty input', () => {
144
- expect(parseNoteMarkdown('')).toEqual([]);
145
- expect(parseNoteMarkdown('\n\n')).toEqual([]);
146
- });
147
- });