Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b5b66e
style: optimize layout
zeevenn Sep 25, 2025
ed4e4dd
feat: insert theme in css editor
zeevenn Sep 25, 2025
212dbfe
feat: generate theme css txt
zeevenn Sep 25, 2025
f5a532d
fix: default css name
zeevenn Sep 25, 2025
23c874a
fix: tab hidden in small width
zeevenn Sep 25, 2025
9382733
feat: export merged theme css
zeevenn Sep 25, 2025
31150e4
style: button bg
zeevenn Sep 25, 2025
7f2aecd
chore: update workflows (#1077)
yanglbme Oct 18, 2025
724de4f
chore: update workflows (#1078)
yanglbme Oct 18, 2025
7067599
fix: correct theme option check in CssEditor
zeevenn Oct 30, 2025
ccbae2f
fix: fixed export button
zeevenn Oct 30, 2025
97698ae
refactor: pure css theme system
zeevenn Oct 30, 2025
8e4d405
fix: build error
zeevenn Oct 30, 2025
213729a
feat: integrate new theme options for indent and justify
zeevenn Oct 30, 2025
8a66f60
feat: enhance theme CSS classes
zeevenn Oct 31, 2025
205111e
refactor: simplify theme export comments and base CSS naming
zeevenn Oct 31, 2025
ccc4a9c
refactor: use kebab-case classname
zeevenn Oct 31, 2025
71ae6f0
refactor: replace deprecated theme CSS file with a new default custom…
zeevenn Oct 31, 2025
4d6135d
refactor: implement new CSS selector mapping and update alert and KaT…
zeevenn Oct 31, 2025
be52462
fix: copy to wechat loss style
zeevenn Oct 31, 2025
74efaaf
fix: replace displayStore
zeevenn Nov 2, 2025
a5dec44
chore: update workflow
zeevenn Nov 3, 2025
42c6c9c
fix: default custom css name
zeevenn Nov 3, 2025
e7c9741
feat: view builtIn theme and create custom css from template
zeevenn Nov 3, 2025
a165d7d
feat: add cursor-pointer class to button
zeevenn Nov 3, 2025
ecb3429
chore: clean up
zeevenn Nov 3, 2025
6b77293
feat(vscode): use new theme system
zeevenn Nov 3, 2025
a0ff9b9
fix: clean
zeevenn Nov 3, 2025
35d8e79
chore: remove csstype
zeevenn Nov 3, 2025
cb0c79f
refactor: export with new theme system
zeevenn Nov 3, 2025
d694165
fix: force print bg in export pdf
zeevenn Nov 3, 2025
4d212ed
chore: remove log
zeevenn Nov 3, 2025
9ab2f8a
fix: tab active
zeevenn Nov 3, 2025
c4a4bca
feat: add selector
zeevenn Nov 3, 2025
bc35fc4
fix: implement smooth scrolling to active tab and enhance tab management
zeevenn Nov 4, 2025
1ccc9ca
fix: style of em tag
yanglbme Nov 4, 2025
eed4e60
fix: style of a tag
yanglbme Nov 4, 2025
cfc84a5
fix: render figcaption
yanglbme Nov 4, 2025
ddcc7f8
feat: support css variable and calc
zeevenn Nov 5, 2025
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
38 changes: 21 additions & 17 deletions apps/vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ThemeName } from '@md/shared'
import { initRenderer } from '@md/core/renderer'
import { customCssWithTemplate, customizeTheme, modifyHtmlContent } from '@md/core/utils'
import { css2json, themeMap } from '@md/shared'
import { generateCSSVariables, modifyHtmlContent } from '@md/core/utils'
import { baseCSSContent, themeMap } from '@md/shared'
import * as vscode from 'vscode'
import { css } from './css'
import { MarkdownTreeDataProvider } from './treeDataProvider'
Expand All @@ -17,7 +18,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand(`markdown.setFontSize`, (size: string) => {
treeDataProvider.updateFontSize(size)
}),
vscode.commands.registerCommand(`markdown.setTheme`, (theme: keyof typeof themeMap) => {
vscode.commands.registerCommand(`markdown.setTheme`, (theme: ThemeName) => {
treeDataProvider.updateTheme(theme)
}),
vscode.commands.registerCommand(`markdown.setPrimaryColor`, (color: string) => {
Expand Down Expand Up @@ -67,27 +68,30 @@ export function activate(context: vscode.ExtensionContext) {
function updateWebview() {
if (!editor)
return

// 使用新主题系统
const renderer = initRenderer({
theme: customCssWithTemplate(
// TODO
css2json(``),
treeDataProvider.getCurrentPrimaryColor(),
customizeTheme(themeMap[treeDataProvider.getCurrentTheme()], {
fontSize: treeDataProvider.getCurrentFontSizeNumber(),
color: treeDataProvider.getCurrentPrimaryColor(),
}),
),
fonts: treeDataProvider.getCurrentFontFamily(),
size: treeDataProvider.getCurrentFontSize(),
isUseIndent: false,
isUseJustify: false,
countStatus: treeDataProvider.getCurrentCountStatus(),
isMacCodeBlock: treeDataProvider.getCurrentMacCodeBlock(),
legend: `none`,
})

const markdownContent = editor.document.getText()
const html = modifyHtmlContent(markdownContent, renderer)
panel.webview.html = wrapHtmlTag(html, css)

// 生成主题 CSS
const variables = generateCSSVariables({
primaryColor: treeDataProvider.getCurrentPrimaryColor(),
fontFamily: treeDataProvider.getCurrentFontFamily(),
fontSize: treeDataProvider.getCurrentFontSize(),
isUseIndent: false,
isUseJustify: false,
})

const themeCSS = themeMap[treeDataProvider.getCurrentTheme() as ThemeName]
const completeCss = `${variables}\n\n${baseCSSContent}\n\n${themeCSS}\n\n${css}`

panel.webview.html = wrapHtmlTag(html, completeCss)
}

// render first webview
Expand Down
8 changes: 4 additions & 4 deletions apps/vscode/src/treeDataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { themeMap } from '@md/shared/configs'
import type { ThemeName } from '@md/shared/configs'
import * as vscode from 'vscode'
import { colorOptions, fontFamilyOptions, fontSizeOptions, themeOptions } from './styleChoices'

export class MarkdownTreeDataProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
private _onDidChangeTreeData: vscode.EventEmitter<vscode.TreeItem | undefined> = new vscode.EventEmitter<vscode.TreeItem | undefined>()
readonly onDidChangeTreeData: vscode.Event<vscode.TreeItem | undefined> = this._onDidChangeTreeData.event
private currentFontSize: string
private currentTheme: keyof typeof themeMap
private currentTheme: ThemeName
private currentPrimaryColor: string
private currentFontFamily: string
private countStatus: boolean
Expand Down Expand Up @@ -157,7 +157,7 @@ export class MarkdownTreeDataProvider implements vscode.TreeDataProvider<vscode.
this._onDidChangeTreeData.fire(undefined)
}

updateTheme(theme: keyof typeof themeMap) {
updateTheme(theme: ThemeName) {
this.currentTheme = theme
this.context.workspaceState.update(`markdownPreview.theme`, theme)
this._onDidChangeTreeData.fire(undefined)
Expand All @@ -183,7 +183,7 @@ export class MarkdownTreeDataProvider implements vscode.TreeDataProvider<vscode.
return Number(this.currentFontSize.replace(`px`, ``))
}

getCurrentTheme(): keyof typeof themeMap {
getCurrentTheme(): ThemeName {
return this.currentTheme
}

Expand Down
1 change: 0 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"core-js": "^3.46.0",
"cos-js-sdk-v5": "^1.8.7",
"crypto-js": "^4.2.0",
"csstype": "^3.1.3",
"es-toolkit": "^1.41.0",
"front-matter": "^4.0.2",
"highlight.js": "^11.11.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/assets/example/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Markdown 中的段落就是一行接一行的文本。要创建新段落,只
### 3. 字体样式:强调你的文字

- **粗体**:用两个星号或下划线包裹文字,如 `**粗体**` 或 `__粗体__`。
- _斜体_:用一个星号或下划线包裹文字,如 `*斜体*` 或 `_斜体_`。
- _斜体_:用一个星号包裹文字,如 `*斜体*`。
- ~~删除线~~:用两个波浪线包裹文字,如 `~~删除线~~`。
- ==高亮==:用两个等号包裹文字,如 `==高亮==`。
- ++下划线++:用两个加号包裹文字,如 `++下划线++`。
Expand Down
150 changes: 0 additions & 150 deletions apps/web/src/assets/example/theme-css.txt

This file was deleted.

Loading