Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add to root container #486

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/assets/example/theme-css.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* 召集令:如果你有好看的主题样式,欢迎分享,让更多人能够使用到你的主题。
* 提交区:https://github.com/doocs/md/discussions/426
*/
/* 顶层容器样式 */
container {
}
/* 一级标题样式 */
h1 {
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const defaultTheme: Theme = {
'line-height': `1.75`,
},
block: {
container: {},
// 一级标题
h1: {
'display': `table`,
Expand Down Expand Up @@ -288,6 +289,7 @@ const graceTheme = toMerged(defaultTheme, {
base: {
},
block: {
'container': {},
'h1': {
'padding': `0.5em 1em`,
'border-bottom': `2px solid var(--md-primary-color)`,
Expand Down
2 changes: 1 addition & 1 deletion src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const useStore = defineStore(`store`, () => {
</style>
`

output.value = outputTemp
output.value = renderer.createContainer(outputTemp)
}

// 更新 CSS
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PropertiesHyphen } from 'csstype'
import type { Token } from 'marked'

type GFMBlock = `blockquote_note` | `blockquote_tip` | `blockquote_important` | `blockquote_warning` | `blockquote_caution` | `blockquote_title` | `blockquote_title_note` | `blockquote_title_tip` | `blockquote_title_important` | `blockquote_title_warning` | `blockquote_title_caution` | `blockquote_p` | `blockquote_p_note` | `blockquote_p_tip` | `blockquote_p_important` | `blockquote_p_warning` | `blockquote_p_caution`
export type Block = `h1` | `h2` | `h3` | `h4` | `h5` | `h6` | `p` | `blockquote` | `blockquote_p` | `code_pre` | `code` | `image` | `ol` | `ul` | `footnotes` | `figure` | `hr` | GFMBlock
export type Block = `container` | `h1` | `h2` | `h3` | `h4` | `h5` | `h6` | `p` | `blockquote` | `blockquote_p` | `code_pre` | `code` | `image` | `ol` | `ul` | `footnotes` | `figure` | `hr` | GFMBlock
export type Inline = `listitem` | `codespan` | `link` | `wx_link` | `strong` | `table` | `thead` | `td` | `footnote` | `figcaption` | `em`

interface CustomCSSProperties {
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function customCssWithTemplate(jsonString: Partial<Record<Block | Inline,
}

const blockKeys: Block[] = [
`container`,
`h1`,
`h2`,
`h3`,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,8 @@ export function initRenderer(opts: IOpts) {
buildFootnotes,
setOptions,
reset,
createContainer(content: string) {
return styledContent(`container`, content, `section`)
},
}
}
Loading