feat: GFM alerts support custom css

This commit is contained in:
dribble-njr 2024-11-22 13:15:08 +08:00
parent 53a8cd5cd4
commit 2c26d59d7c
2 changed files with 10 additions and 7 deletions

View File

@ -51,11 +51,6 @@ export default function markedAlert(options: AlertOptions = {}): MarkedExtension
},
})
console.log({
...options.theme?.block[className],
...options.theme?.block[`${className}-${variantType}`],
}, `style`)
const firstLine = token.tokens?.[0] as Tokens.Paragraph
const firstLineText = firstLine.raw?.replace(typeRegexp, ``).trim()

View File

@ -34,7 +34,7 @@ export function customizeTheme(theme: Theme, options: {
export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline, PropertiesHyphen>>, color: string, theme: Theme) {
const newTheme = customizeTheme(theme, { color })
const mergeProperties = <T extends Block | Inline = Block>(target: Record<T, PropertiesHyphen>, source: Partial<Record<Block | Inline, PropertiesHyphen>>, keys: T[]) => {
const mergeProperties = <T extends Block | Inline | string = Block>(target: Record<T, PropertiesHyphen>, source: Partial<Record<Block | Inline | string, PropertiesHyphen>>, keys: T[]) => {
keys.forEach((key) => {
if (source[key]) {
target[key] = Object.assign(target[key] || {}, source[key])
@ -42,7 +42,7 @@ export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline,
})
}
const blockKeys: Block[] = [
const blockKeys: (Block | string)[] = [
`h1`,
`h2`,
`h3`,
@ -55,6 +55,14 @@ export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline,
`hr`,
`blockquote`,
`blockquote_p`,
`markdown-alert`,
`markdown-alert-title`,
`markdown-alert-content-wrapper`,
`markdown-alert-title-note`,
`markdown-alert-title-tip`,
`markdown-alert-title-important`,
`markdown-alert-title-warning`,
`markdown-alert-title-caution`,
`image`,
`ul`,
`ol`,