Skip to content

Commit 485d49e

Browse files
committed
feat: allow banner markdown
Signed-off-by: Innei <[email protected]>
1 parent 72d1f52 commit 485d49e

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/components/ui/markdown/parsers/container.tsx

+23-9
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ import type { MarkdownToJSX } from 'markdown-to-jsx'
44

55
import { Banner } from '../../banner/Banner'
66
import { Gallery } from '../../gallery/Gallery'
7+
import { Markdown } from '../Markdown'
78
import { pickImagesFromMarkdown } from '../utils/image'
89

9-
const shouldCatchContainerName = ['gallery', 'banner', 'carousel'].join('|')
10+
const shouldCatchContainerName = [
11+
'gallery',
12+
'banner',
13+
'carousel',
14+
15+
'warn',
16+
'error',
17+
'danger',
18+
'info',
19+
'success',
20+
'warning',
21+
].join('|')
1022
export const ContainerRule: MarkdownToJSX.Rule = {
1123
match: blockRegex(
1224
new RegExp(
@@ -45,9 +57,14 @@ export const ContainerRule: MarkdownToJSX.Rule = {
4557
<Banner
4658
type={name || (transformMap as any)[name] || 'info'}
4759
className="my-4"
48-
message={content}
4960
key={state?.key}
50-
/>
61+
>
62+
<Markdown
63+
value={content}
64+
allowsScript
65+
className="[&>p:first-child]:mt-0"
66+
/>
67+
</Banner>
5168
)
5269
}
5370
case 'banner': {
@@ -56,12 +73,9 @@ export const ContainerRule: MarkdownToJSX.Rule = {
5673
}
5774

5875
return (
59-
<Banner
60-
type={params}
61-
className="my-4"
62-
message={content}
63-
key={state?.key}
64-
/>
76+
<Banner type={params} className="my-4" key={state?.key}>
77+
<Markdown value={content} allowsScript />
78+
</Banner>
6579
)
6680
}
6781
}

src/socket/handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const eventHandler = (
5757
case EventTypes.POST_DELETE: {
5858
const post = data as PostModel
5959
if (getCurrentPostData()?.id === post.id) {
60-
router.push(routeBuilder(Routes.PageDeletd, {}))
60+
router.replace(routeBuilder(Routes.PageDeletd, {}))
6161
toast.error('文章已删除')
6262
}
6363
break
@@ -77,7 +77,7 @@ export const eventHandler = (
7777
case 'NOTE_DELETE': {
7878
const note = data as NoteModel
7979
if (getCurrentNoteData()?.data.id === note.id) {
80-
router.push(routeBuilder(Routes.PageDeletd, {}))
80+
router.replace(routeBuilder(Routes.PageDeletd, {}))
8181
toast.error('手记已删除')
8282
}
8383
break

0 commit comments

Comments
 (0)