@peaske7/readit 0.1.7 → 0.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 (118) hide show
  1. package/README.md +0 -3
  2. package/biome.json +1 -1
  3. package/bun.lock +43 -185
  4. package/docs/perf-baseline.md +75 -0
  5. package/docs/superpowers/plans/2026-03-26-surgical-pruning.md +1176 -0
  6. package/e2e/perf/add-comment.spec.ts +118 -0
  7. package/e2e/perf/fixtures/generate.ts +331 -0
  8. package/e2e/perf/initial-load.spec.ts +49 -0
  9. package/e2e/perf/perf.setup.ts +23 -0
  10. package/e2e/perf/perf.teardown.ts +9 -0
  11. package/e2e/perf/scroll.spec.ts +39 -0
  12. package/e2e/perf/tab-switch.spec.ts +69 -0
  13. package/e2e/perf/text-selection.spec.ts +119 -0
  14. package/e2e/perf/utils/metrics.ts +286 -0
  15. package/e2e/perf/utils/perf-cli.ts +86 -0
  16. package/package.json +9 -18
  17. package/playwright.config.ts +12 -0
  18. package/src/App.tsx +133 -178
  19. package/src/{cli/index.ts → cli.ts} +211 -107
  20. package/src/components/ActionsMenu.tsx +6 -27
  21. package/src/components/DocumentViewer/DocumentViewer.tsx +78 -105
  22. package/src/components/DocumentViewer/MermaidDiagram.tsx +6 -7
  23. package/src/components/Header.tsx +9 -20
  24. package/src/components/InlineEditor.tsx +5 -5
  25. package/src/components/MarginNote.tsx +71 -93
  26. package/src/components/MarginNotes.tsx +7 -34
  27. package/src/components/RawModal.tsx +9 -8
  28. package/src/components/ReanchorConfirm.tsx +2 -2
  29. package/src/components/SettingsModal.tsx +11 -89
  30. package/src/components/TabBar.tsx +4 -4
  31. package/src/components/TableOfContents.tsx +5 -5
  32. package/src/components/comments/CommentInput.tsx +7 -35
  33. package/src/components/comments/CommentListItem.tsx +9 -11
  34. package/src/components/comments/CommentManager.tsx +53 -37
  35. package/src/components/comments/CommentNav.tsx +14 -14
  36. package/src/components/ui/ActionLink.tsx +14 -18
  37. package/src/components/ui/Button.tsx +42 -43
  38. package/src/components/ui/Dialog.tsx +73 -113
  39. package/src/components/ui/DropdownMenu.tsx +113 -69
  40. package/src/components/ui/Text.tsx +30 -37
  41. package/src/contexts/CommentContext.tsx +75 -106
  42. package/src/contexts/LocaleContext.tsx +45 -4
  43. package/src/contexts/PositionsContext.tsx +16 -0
  44. package/src/contexts/SettingsContext.tsx +133 -0
  45. package/src/hooks/useClickOutside.ts +0 -4
  46. package/src/hooks/useCommentNavigation.ts +6 -29
  47. package/src/hooks/useComments.ts +6 -18
  48. package/src/hooks/useDocument.ts +35 -34
  49. package/src/hooks/useHeadings.test.ts +8 -50
  50. package/src/hooks/useHeadings.ts +5 -88
  51. package/src/hooks/useScrollSpy.ts +10 -14
  52. package/src/hooks/useTextSelection.ts +1 -38
  53. package/src/lib/__fixtures__/bench-data.ts +1 -41
  54. package/src/lib/anchor.bench.ts +57 -67
  55. package/src/lib/anchor.test.ts +5 -1
  56. package/src/lib/anchor.ts +13 -93
  57. package/src/lib/comment-storage.test.ts +4 -4
  58. package/src/lib/comment-storage.ts +2 -46
  59. package/src/lib/export.ts +7 -13
  60. package/src/lib/highlight/core.test.ts +1 -1
  61. package/src/lib/highlight/dom.ts +5 -68
  62. package/src/lib/highlight/highlighter.ts +102 -262
  63. package/src/lib/highlight/resolver.ts +112 -0
  64. package/src/lib/highlight/types.ts +0 -35
  65. package/src/lib/highlight/worker.ts +45 -0
  66. package/src/lib/i18n/en.ts +1 -50
  67. package/src/lib/i18n/ja.ts +1 -50
  68. package/src/lib/i18n/types.ts +1 -49
  69. package/src/lib/margin-layout.ts +5 -27
  70. package/src/lib/positions.ts +150 -0
  71. package/src/lib/utils.ts +2 -19
  72. package/src/schema.ts +81 -0
  73. package/src/{server/index.ts → server.ts} +111 -81
  74. package/src/{store/index.ts → store.ts} +14 -46
  75. package/vite.config.ts +8 -0
  76. package/src/components/DocumentViewer/IframeContainer.tsx +0 -251
  77. package/src/components/DocumentViewer/InlineCode.tsx +0 -60
  78. package/src/components/DocumentViewer/index.ts +0 -1
  79. package/src/components/FloatingTOC.tsx +0 -61
  80. package/src/components/ShortcutCapture.tsx +0 -48
  81. package/src/components/ShortcutList.tsx +0 -198
  82. package/src/components/comments/CommentMinimap.tsx +0 -62
  83. package/src/components/ui/ActionBar.tsx +0 -16
  84. package/src/components/ui/SeparatorDot.tsx +0 -9
  85. package/src/contexts/LayoutContext.tsx +0 -88
  86. package/src/hooks/useClipboard.ts +0 -82
  87. package/src/hooks/useEditorScheme.ts +0 -51
  88. package/src/hooks/useFontPreference.ts +0 -59
  89. package/src/hooks/useKeybindings.ts +0 -108
  90. package/src/hooks/useKeyboardShortcuts.ts +0 -63
  91. package/src/hooks/useLayoutMode.ts +0 -44
  92. package/src/hooks/useLocalePreference.ts +0 -42
  93. package/src/hooks/useReanchorMode.ts +0 -33
  94. package/src/hooks/useScrollMetrics.ts +0 -56
  95. package/src/hooks/useThemePreference.ts +0 -66
  96. package/src/lib/comment-storage.bench.ts +0 -63
  97. package/src/lib/context.bench.ts +0 -41
  98. package/src/lib/context.test.ts +0 -224
  99. package/src/lib/context.ts +0 -193
  100. package/src/lib/editor-links.ts +0 -59
  101. package/src/lib/export.bench.ts +0 -35
  102. package/src/lib/highlight/colors.ts +0 -37
  103. package/src/lib/highlight/core.ts +0 -54
  104. package/src/lib/highlight/index.ts +0 -23
  105. package/src/lib/highlight/script-builder.ts +0 -485
  106. package/src/lib/html-processor.test.tsx +0 -170
  107. package/src/lib/html-processor.tsx +0 -95
  108. package/src/lib/i18n/completeness.test.ts +0 -51
  109. package/src/lib/i18n/translations.test.ts +0 -39
  110. package/src/lib/layout-constants.ts +0 -12
  111. package/src/lib/margin-layout.bench.ts +0 -28
  112. package/src/lib/scroll.test.ts +0 -118
  113. package/src/lib/scroll.ts +0 -47
  114. package/src/lib/shortcut-registry.test.ts +0 -173
  115. package/src/lib/shortcut-registry.ts +0 -209
  116. package/src/lib/utils.test.ts +0 -110
  117. package/src/store/index.test.ts +0 -242
  118. package/src/types/index.ts +0 -127
@@ -1,173 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- DEFAULT_SHORTCUTS,
4
- formatBinding,
5
- isReservedBinding,
6
- type KeybindingOverride,
7
- matchesBinding,
8
- resolveShortcuts,
9
- ShortcutActions,
10
- type ShortcutBinding,
11
- } from "./shortcut-registry";
12
-
13
- describe("DEFAULT_SHORTCUTS", () => {
14
- it("defines 7 shortcuts", () => {
15
- expect(DEFAULT_SHORTCUTS).toHaveLength(7);
16
- });
17
-
18
- it("has unique IDs", () => {
19
- const ids = DEFAULT_SHORTCUTS.map((s) => s.id);
20
- expect(new Set(ids).size).toBe(ids.length);
21
- });
22
-
23
- it("all enabled by default", () => {
24
- for (const shortcut of DEFAULT_SHORTCUTS) {
25
- expect(shortcut.enabled).toBe(true);
26
- }
27
- });
28
- });
29
-
30
- describe("matchesBinding", () => {
31
- it("matches exact key + modifiers", () => {
32
- const binding: ShortcutBinding = { key: "c", alt: true };
33
- const event = new KeyboardEvent("keydown", { key: "c", altKey: true });
34
- expect(matchesBinding(event, binding)).toBe(true);
35
- });
36
-
37
- it("rejects wrong key", () => {
38
- const binding: ShortcutBinding = { key: "c", alt: true };
39
- const event = new KeyboardEvent("keydown", { key: "v", altKey: true });
40
- expect(matchesBinding(event, binding)).toBe(false);
41
- });
42
-
43
- it("rejects extra modifiers", () => {
44
- const binding: ShortcutBinding = { key: "c", alt: true };
45
- const event = new KeyboardEvent("keydown", {
46
- key: "c",
47
- altKey: true,
48
- shiftKey: true,
49
- });
50
- expect(matchesBinding(event, binding)).toBe(false);
51
- });
52
-
53
- it("matches binding with shift", () => {
54
- const binding: ShortcutBinding = { key: "c", alt: true, shift: true };
55
- const event = new KeyboardEvent("keydown", {
56
- key: "c",
57
- altKey: true,
58
- shiftKey: true,
59
- });
60
- expect(matchesBinding(event, binding)).toBe(true);
61
- });
62
-
63
- it("matches meta key", () => {
64
- const binding: ShortcutBinding = { key: "c", meta: true };
65
- const event = new KeyboardEvent("keydown", { key: "c", metaKey: true });
66
- expect(matchesBinding(event, binding)).toBe(true);
67
- });
68
-
69
- it("matches shifted letter key (browser reports uppercase)", () => {
70
- const binding: ShortcutBinding = { key: "c", alt: true, shift: true };
71
- const event = new KeyboardEvent("keydown", {
72
- key: "C",
73
- altKey: true,
74
- shiftKey: true,
75
- });
76
- expect(matchesBinding(event, binding)).toBe(true);
77
- });
78
-
79
- it("matches meta+shift letter key (browser reports uppercase)", () => {
80
- const binding: ShortcutBinding = { key: "c", meta: true, shift: true };
81
- const event = new KeyboardEvent("keydown", {
82
- key: "C",
83
- metaKey: true,
84
- shiftKey: true,
85
- });
86
- expect(matchesBinding(event, binding)).toBe(true);
87
- });
88
-
89
- it("matches key-only binding (no modifiers)", () => {
90
- const binding: ShortcutBinding = { key: "Escape" };
91
- const event = new KeyboardEvent("keydown", { key: "Escape" });
92
- expect(matchesBinding(event, binding)).toBe(true);
93
- });
94
- });
95
-
96
- describe("formatBinding", () => {
97
- it("formats Alt+C", () => {
98
- const binding: ShortcutBinding = { key: "c", alt: true };
99
- expect(formatBinding(binding, true)).toBe("Alt+C");
100
- });
101
-
102
- it("formats meta key as ⌘ on Mac", () => {
103
- const binding: ShortcutBinding = { key: "c", meta: true };
104
- expect(formatBinding(binding, true)).toBe("⌘+C");
105
- });
106
-
107
- it("formats meta key as Ctrl on non-Mac", () => {
108
- const binding: ShortcutBinding = { key: "c", meta: true };
109
- expect(formatBinding(binding, false)).toBe("Ctrl+C");
110
- });
111
-
112
- it("formats shift modifier", () => {
113
- const binding: ShortcutBinding = { key: "c", meta: true, shift: true };
114
- expect(formatBinding(binding, true)).toBe("⌘+Shift+C");
115
- });
116
-
117
- it("formats arrow keys with symbols", () => {
118
- const binding: ShortcutBinding = { key: "ArrowUp", alt: true };
119
- expect(formatBinding(binding, true)).toBe("Alt+↑");
120
- });
121
-
122
- it("formats Escape", () => {
123
- const binding: ShortcutBinding = { key: "Escape" };
124
- expect(formatBinding(binding, true)).toBe("Esc");
125
- });
126
- });
127
-
128
- describe("resolveShortcuts", () => {
129
- it("returns defaults when no overrides", () => {
130
- const resolved = resolveShortcuts([]);
131
- expect(resolved).toEqual(DEFAULT_SHORTCUTS);
132
- });
133
-
134
- it("applies enabled override", () => {
135
- const overrides: KeybindingOverride[] = [
136
- { id: ShortcutActions.COPY_ALL, enabled: false },
137
- ];
138
- const resolved = resolveShortcuts(overrides);
139
- const copyAll = resolved.find((s) => s.id === ShortcutActions.COPY_ALL);
140
- expect(copyAll?.enabled).toBe(false);
141
- });
142
-
143
- it("applies binding override", () => {
144
- const overrides: KeybindingOverride[] = [
145
- {
146
- id: ShortcutActions.COPY_ALL,
147
- enabled: true,
148
- binding: { key: "a", meta: true },
149
- },
150
- ];
151
- const resolved = resolveShortcuts(overrides);
152
- const copyAll = resolved.find((s) => s.id === ShortcutActions.COPY_ALL);
153
- expect(copyAll?.binding).toEqual({ key: "a", meta: true });
154
- });
155
-
156
- it("ignores unknown override IDs", () => {
157
- const overrides: KeybindingOverride[] = [
158
- { id: "unknown_action", enabled: false },
159
- ];
160
- const resolved = resolveShortcuts(overrides);
161
- expect(resolved).toEqual(DEFAULT_SHORTCUTS);
162
- });
163
- });
164
-
165
- describe("isReservedBinding", () => {
166
- it("detects ⌘+W as reserved", () => {
167
- expect(isReservedBinding({ key: "w", meta: true })).toBe(true);
168
- });
169
-
170
- it("allows Alt+C", () => {
171
- expect(isReservedBinding({ key: "c", alt: true })).toBe(false);
172
- });
173
- });
@@ -1,209 +0,0 @@
1
- import type { KeybindingOverride, ShortcutBinding } from "../types";
2
-
3
- export type { KeybindingOverride, ShortcutBinding };
4
-
5
- export const ShortcutActions = {
6
- COPY_ALL: "copyAll",
7
- COPY_ALL_RAW: "copyAllRaw",
8
- NAVIGATE_NEXT: "navigateNext",
9
- NAVIGATE_PREVIOUS: "navigatePrevious",
10
- COPY_SELECTION_RAW: "copySelectionRaw",
11
- COPY_SELECTION_LLM: "copySelectionLLM",
12
- CLEAR_SELECTION: "clearSelection",
13
- } as const;
14
-
15
- export type ShortcutAction =
16
- (typeof ShortcutActions)[keyof typeof ShortcutActions];
17
-
18
- export interface ShortcutDefinition {
19
- id: ShortcutAction;
20
- label: string;
21
- description: string;
22
- defaultBinding: ShortcutBinding;
23
- binding: ShortcutBinding; // resolved (default or user override)
24
- enabled: boolean;
25
- }
26
-
27
- export const DEFAULT_SHORTCUTS: ShortcutDefinition[] = [
28
- {
29
- id: ShortcutActions.COPY_ALL,
30
- label: "Copy All (AI)",
31
- description: "Copy all comments in AI prompt format",
32
- defaultBinding: { key: "c", alt: true },
33
- binding: { key: "c", alt: true },
34
- enabled: true,
35
- },
36
- {
37
- id: ShortcutActions.COPY_ALL_RAW,
38
- label: "Copy All (Raw)",
39
- description: "Copy all comments as raw text",
40
- defaultBinding: { key: "c", alt: true, shift: true },
41
- binding: { key: "c", alt: true, shift: true },
42
- enabled: true,
43
- },
44
- {
45
- id: ShortcutActions.NAVIGATE_NEXT,
46
- label: "Next Comment",
47
- description: "Navigate to next comment",
48
- defaultBinding: { key: "ArrowDown", alt: true },
49
- binding: { key: "ArrowDown", alt: true },
50
- enabled: true,
51
- },
52
- {
53
- id: ShortcutActions.NAVIGATE_PREVIOUS,
54
- label: "Previous Comment",
55
- description: "Navigate to previous comment",
56
- defaultBinding: { key: "ArrowUp", alt: true },
57
- binding: { key: "ArrowUp", alt: true },
58
- enabled: true,
59
- },
60
- {
61
- id: ShortcutActions.COPY_SELECTION_RAW,
62
- label: "Copy Selection",
63
- description: "Copy selected text",
64
- defaultBinding: { key: "c", meta: true },
65
- binding: { key: "c", meta: true },
66
- enabled: true,
67
- },
68
- {
69
- id: ShortcutActions.COPY_SELECTION_LLM,
70
- label: "Copy Selection (LLM)",
71
- description: "Copy selected text with context for LLM",
72
- defaultBinding: { key: "c", meta: true, shift: true },
73
- binding: { key: "c", meta: true, shift: true },
74
- enabled: true,
75
- },
76
- {
77
- id: ShortcutActions.CLEAR_SELECTION,
78
- label: "Clear Selection",
79
- description: "Clear text selection",
80
- defaultBinding: { key: "Escape" },
81
- binding: { key: "Escape" },
82
- enabled: true,
83
- },
84
- ];
85
-
86
- /**
87
- * Check if a KeyboardEvent matches a ShortcutBinding.
88
- * All modifier flags must match exactly (no extra modifiers allowed).
89
- */
90
- export function matchesBinding(
91
- event: KeyboardEvent,
92
- binding: ShortcutBinding,
93
- ): boolean {
94
- if (event.key.toLowerCase() !== binding.key.toLowerCase()) return false;
95
- if (event.altKey !== (binding.alt ?? false)) return false;
96
- if (event.metaKey !== (binding.meta ?? false)) return false;
97
- if (event.shiftKey !== (binding.shift ?? false)) return false;
98
- return true;
99
- }
100
-
101
- const KEY_DISPLAY: Record<string, string> = {
102
- ArrowUp: "↑",
103
- ArrowDown: "↓",
104
- ArrowLeft: "←",
105
- ArrowRight: "→",
106
- Escape: "Esc",
107
- " ": "Space",
108
- Enter: "Enter",
109
- };
110
-
111
- /**
112
- * Format a ShortcutBinding for display.
113
- * Shows ⌘ on Mac, Ctrl on other platforms.
114
- */
115
- export function formatBinding(
116
- binding: ShortcutBinding,
117
- isMac: boolean,
118
- ): string {
119
- const parts: string[] = [];
120
-
121
- if (binding.meta) parts.push(isMac ? "⌘" : "Ctrl");
122
- if (binding.alt) parts.push("Alt");
123
- if (binding.shift) parts.push("Shift");
124
-
125
- const keyDisplay = KEY_DISPLAY[binding.key] ?? binding.key.toUpperCase();
126
- parts.push(keyDisplay);
127
-
128
- return parts.join("+");
129
- }
130
-
131
- /**
132
- * Merge user overrides with default shortcuts.
133
- * Unknown override IDs are ignored.
134
- */
135
- export function resolveShortcuts(
136
- overrides: KeybindingOverride[],
137
- ): ShortcutDefinition[] {
138
- if (overrides.length === 0) return DEFAULT_SHORTCUTS;
139
-
140
- const overrideMap = new Map(overrides.map((o) => [o.id, o]));
141
-
142
- return DEFAULT_SHORTCUTS.map((shortcut) => {
143
- const override = overrideMap.get(shortcut.id);
144
- if (!override) return shortcut;
145
-
146
- return {
147
- ...shortcut,
148
- binding: override.binding ?? shortcut.defaultBinding,
149
- enabled: override.enabled,
150
- };
151
- });
152
- }
153
-
154
- /**
155
- * Browser-reserved key combos that cannot be rebound.
156
- */
157
- export const RESERVED_BINDINGS: ShortcutBinding[] = [
158
- { key: "w", meta: true },
159
- { key: "t", meta: true },
160
- { key: "n", meta: true },
161
- { key: "q", meta: true },
162
- { key: "l", meta: true },
163
- { key: "r", meta: true },
164
- { key: "F5" },
165
- { key: "F11" },
166
- { key: "F12" },
167
- ];
168
-
169
- /**
170
- * Check if a binding conflicts with browser-reserved shortcuts.
171
- */
172
- export function isReservedBinding(binding: ShortcutBinding): boolean {
173
- return RESERVED_BINDINGS.some(
174
- (reserved) =>
175
- reserved.key.toLowerCase() === binding.key.toLowerCase() &&
176
- (reserved.meta ?? false) === (binding.meta ?? false) &&
177
- (reserved.alt ?? false) === (binding.alt ?? false) &&
178
- (reserved.shift ?? false) === (binding.shift ?? false),
179
- );
180
- }
181
-
182
- /**
183
- * Convert a KeyboardEvent to a ShortcutBinding (for the capture UI).
184
- */
185
- export function eventToBinding(
186
- event: KeyboardEvent,
187
- ): ShortcutBinding | undefined {
188
- // Ignore standalone modifier keys
189
- if (["Alt", "Shift", "Control", "Meta"].includes(event.key)) return undefined;
190
-
191
- const binding: ShortcutBinding = { key: event.key };
192
- if (event.altKey) binding.alt = true;
193
- if (event.metaKey) binding.meta = true;
194
- if (event.shiftKey) binding.shift = true;
195
-
196
- return binding;
197
- }
198
-
199
- /**
200
- * Check if two bindings are equal.
201
- */
202
- export function bindingsEqual(a: ShortcutBinding, b: ShortcutBinding): boolean {
203
- return (
204
- a.key.toLowerCase() === b.key.toLowerCase() &&
205
- (a.alt ?? false) === (b.alt ?? false) &&
206
- (a.meta ?? false) === (b.meta ?? false) &&
207
- (a.shift ?? false) === (b.shift ?? false)
208
- );
209
- }
@@ -1,110 +0,0 @@
1
- import { createElement } from "react";
2
- import { describe, expect, it } from "vitest";
3
- import { getTextContent, slugify } from "./utils";
4
-
5
- describe("slugify", () => {
6
- it("converts text to lowercase", () => {
7
- expect(slugify("Hello World")).toBe("hello-world");
8
- });
9
-
10
- it("replaces spaces with hyphens", () => {
11
- expect(slugify("hello world")).toBe("hello-world");
12
- });
13
-
14
- it("removes special characters", () => {
15
- expect(slugify("Hello, World!")).toBe("hello-world");
16
- });
17
-
18
- it("handles multiple spaces", () => {
19
- expect(slugify("hello world")).toBe("hello-world");
20
- });
21
-
22
- it("handles leading/trailing whitespace", () => {
23
- expect(slugify(" hello world ")).toBe("hello-world");
24
- });
25
-
26
- it("preserves underscores", () => {
27
- expect(slugify("hello_world")).toBe("hello_world");
28
- });
29
-
30
- it("handles hyphens", () => {
31
- expect(slugify("hello-world")).toBe("hello-world");
32
- });
33
-
34
- it("collapses multiple hyphens", () => {
35
- expect(slugify("hello---world")).toBe("hello-world");
36
- });
37
- });
38
-
39
- describe("getTextContent", () => {
40
- it("returns string children directly", () => {
41
- expect(getTextContent("Hello")).toBe("Hello");
42
- });
43
-
44
- it("converts number children to string", () => {
45
- expect(getTextContent(123)).toBe("123");
46
- });
47
-
48
- it("joins array of strings", () => {
49
- expect(getTextContent(["Hello", " ", "World"])).toBe("Hello World");
50
- });
51
-
52
- it("extracts text from React element", () => {
53
- const element = createElement("strong", null, "Bold");
54
- expect(getTextContent(element)).toBe("Bold");
55
- });
56
-
57
- it("extracts text from nested React elements", () => {
58
- const element = createElement(
59
- "span",
60
- null,
61
- "Hello ",
62
- createElement("strong", null, "World"),
63
- );
64
- expect(getTextContent(element)).toBe("Hello World");
65
- });
66
-
67
- it("handles mixed array of strings and elements", () => {
68
- const children = ["Hello ", createElement("strong", null, "World"), "!"];
69
- expect(getTextContent(children)).toBe("Hello World!");
70
- });
71
-
72
- it("handles deeply nested elements", () => {
73
- const element = createElement(
74
- "div",
75
- null,
76
- createElement("span", null, createElement("strong", null, "Deep")),
77
- );
78
- expect(getTextContent(element)).toBe("Deep");
79
- });
80
-
81
- it("returns empty string for null", () => {
82
- expect(getTextContent(null)).toBe("");
83
- });
84
-
85
- it("returns empty string for undefined", () => {
86
- expect(getTextContent(undefined)).toBe("");
87
- });
88
-
89
- it("returns empty string for boolean", () => {
90
- expect(getTextContent(true)).toBe("");
91
- expect(getTextContent(false)).toBe("");
92
- });
93
-
94
- it("handles markdown-style inline formatting", () => {
95
- // Simulates what react-markdown produces for "## Hello **World**"
96
- const children = ["Hello ", createElement("strong", null, "World")];
97
- expect(getTextContent(children)).toBe("Hello World");
98
- });
99
-
100
- it("handles complex markdown with multiple formatting", () => {
101
- // Simulates "## Hello **World** and _italic_"
102
- const children = [
103
- "Hello ",
104
- createElement("strong", null, "World"),
105
- " and ",
106
- createElement("em", null, "italic"),
107
- ];
108
- expect(getTextContent(children)).toBe("Hello World and italic");
109
- });
110
- });