claude-plan-viewer 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -4
- package/index.ts +238 -65
- package/package.json +25 -15
- package/src/api-docs.html +17 -0
- package/src/client/App.tsx +54 -9
- package/src/client/components/DetailOverlay.tsx +66 -9
- package/src/client/components/DetailPanel.tsx +63 -11
- package/src/client/components/Header.tsx +24 -5
- package/src/client/components/HelpModal.tsx +30 -7
- package/src/client/components/Markdown.tsx +37 -7
- package/src/client/components/PlanRow.tsx +15 -4
- package/src/client/components/ProjectFilter.tsx +6 -11
- package/src/client/components/SearchInput.tsx +7 -1
- package/src/client/components/index.ts +0 -1
- package/src/client/hooks/useFilters.ts +7 -7
- package/src/client/hooks/useFocusTrap.ts +70 -0
- package/src/client/hooks/useKeyboard.ts +2 -2
- package/src/client/hooks/usePlans.ts +64 -73
- package/src/client/hooks/useProjects.ts +24 -11
- package/src/client/index.tsx +1 -1
- package/src/client/types.ts +7 -1
- package/src/client/utils/api.ts +13 -4
- package/src/client/utils/formatters.ts +38 -9
- package/src/client/utils/index.ts +0 -12
- package/src/index.html +13 -0
- package/{styles.css → src/styles/styles.css} +154 -72
- package/index.html +0 -14
- package/prism.bundle.js +0 -35
- package/src/client/utils/markdown.ts +0 -123
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { escapeHtml } from "./strings.ts";
|
|
2
|
-
|
|
3
|
-
// Prism.js is loaded from CDN
|
|
4
|
-
declare const Prism: {
|
|
5
|
-
highlight: (code: string, grammar: unknown, language: string) => string;
|
|
6
|
-
languages: Record<string, unknown>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function renderMarkdown(content: string): string {
|
|
10
|
-
// First, extract and process code blocks before escaping
|
|
11
|
-
const codeBlocks: string[] = [];
|
|
12
|
-
let processed = content.replace(
|
|
13
|
-
/```(\w*)\n([\s\S]*?)```/g,
|
|
14
|
-
(_, lang, code) => {
|
|
15
|
-
const language = lang || "plaintext";
|
|
16
|
-
const grammar = Prism.languages[language] || Prism.languages.plaintext;
|
|
17
|
-
let highlighted: string;
|
|
18
|
-
try {
|
|
19
|
-
highlighted = grammar
|
|
20
|
-
? Prism.highlight(code, grammar, language)
|
|
21
|
-
: escapeHtml(code);
|
|
22
|
-
} catch {
|
|
23
|
-
highlighted = escapeHtml(code);
|
|
24
|
-
}
|
|
25
|
-
const block = `<pre class="language-${language}"><code class="language-${language}">${highlighted}</code></pre>`;
|
|
26
|
-
codeBlocks.push(block);
|
|
27
|
-
return `\x00CODE_BLOCK_${codeBlocks.length - 1}\x00`;
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
// Now escape the rest
|
|
32
|
-
let html = escapeHtml(processed);
|
|
33
|
-
|
|
34
|
-
// Restore code blocks
|
|
35
|
-
html = html.replace(/\x00CODE_BLOCK_(\d+)\x00/g, (_, idx) => codeBlocks[parseInt(idx)]);
|
|
36
|
-
|
|
37
|
-
// Inline code
|
|
38
|
-
html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
|
|
39
|
-
|
|
40
|
-
// Headers
|
|
41
|
-
html = html.replace(/^#### (.+)$/gm, "<h4>$1</h4>");
|
|
42
|
-
html = html.replace(/^### (.+)$/gm, "<h3>$1</h3>");
|
|
43
|
-
html = html.replace(/^## (.+)$/gm, "<h2>$1</h2>");
|
|
44
|
-
html = html.replace(/^# (.+)$/gm, "<h1>$1</h1>");
|
|
45
|
-
|
|
46
|
-
// Bold and italic
|
|
47
|
-
html = html.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
|
|
48
|
-
html = html.replace(/\*([^*]+)\*/g, "<em>$1</em>");
|
|
49
|
-
|
|
50
|
-
// Blockquotes
|
|
51
|
-
html = html.replace(/^> (.+)$/gm, "<blockquote><p>$1</p></blockquote>");
|
|
52
|
-
|
|
53
|
-
// Horizontal rules
|
|
54
|
-
html = html.replace(/^---$/gm, "<hr>");
|
|
55
|
-
|
|
56
|
-
// Links
|
|
57
|
-
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
58
|
-
|
|
59
|
-
// Tables
|
|
60
|
-
html = html.replace(
|
|
61
|
-
/\|(.+)\|\n\|[-| ]+\|\n((?:\|.+\|\n?)+)/g,
|
|
62
|
-
(_, header, body) => {
|
|
63
|
-
const headers = header
|
|
64
|
-
.split("|")
|
|
65
|
-
.filter((c: string) => c.trim())
|
|
66
|
-
.map((c: string) => `<th>${c.trim()}</th>`)
|
|
67
|
-
.join("");
|
|
68
|
-
const rows = body
|
|
69
|
-
.trim()
|
|
70
|
-
.split("\n")
|
|
71
|
-
.map((row: string) => {
|
|
72
|
-
const cells = row
|
|
73
|
-
.split("|")
|
|
74
|
-
.filter((c: string) => c.trim())
|
|
75
|
-
.map((c: string) => `<td>${c.trim()}</td>`)
|
|
76
|
-
.join("");
|
|
77
|
-
return `<tr>${cells}</tr>`;
|
|
78
|
-
})
|
|
79
|
-
.join("");
|
|
80
|
-
return `<table><thead><tr>${headers}</tr></thead><tbody>${rows}</tbody></table>`;
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
// Checkbox lists
|
|
85
|
-
html = html.replace(
|
|
86
|
-
/^- \[x\] (.+)$/gm,
|
|
87
|
-
'<li><input type="checkbox" checked disabled> $1</li>'
|
|
88
|
-
);
|
|
89
|
-
html = html.replace(
|
|
90
|
-
/^- \[ \] (.+)$/gm,
|
|
91
|
-
'<li><input type="checkbox" disabled> $1</li>'
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
// Regular lists
|
|
95
|
-
html = html.replace(/^- (.+)$/gm, "<li>$1</li>");
|
|
96
|
-
html = html.replace(/(<li>.*<\/li>\n?)+/g, "<ul>$&</ul>");
|
|
97
|
-
|
|
98
|
-
// Numbered lists
|
|
99
|
-
html = html.replace(/^\d+\. (.+)$/gm, "<li>$1</li>");
|
|
100
|
-
|
|
101
|
-
// Paragraphs - wrap remaining text blocks
|
|
102
|
-
const blocks = html.split(/\n\n+/);
|
|
103
|
-
html = blocks
|
|
104
|
-
.map((block) => {
|
|
105
|
-
const trimmed = block.trim();
|
|
106
|
-
if (!trimmed) return "";
|
|
107
|
-
if (
|
|
108
|
-
trimmed.startsWith("<h") ||
|
|
109
|
-
trimmed.startsWith("<ul") ||
|
|
110
|
-
trimmed.startsWith("<ol") ||
|
|
111
|
-
trimmed.startsWith("<pre") ||
|
|
112
|
-
trimmed.startsWith("<hr") ||
|
|
113
|
-
trimmed.startsWith("<blockquote") ||
|
|
114
|
-
trimmed.startsWith("<table")
|
|
115
|
-
) {
|
|
116
|
-
return trimmed;
|
|
117
|
-
}
|
|
118
|
-
return "<p>" + trimmed.replace(/\n/g, "<br>") + "</p>";
|
|
119
|
-
})
|
|
120
|
-
.join("\n");
|
|
121
|
-
|
|
122
|
-
return html;
|
|
123
|
-
}
|