Skip to content

Commit

Permalink
✨ Support background color of code span decoration (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemmingh committed Sep 2, 2021
1 parent 8df58cd commit f67fa77
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
"main": "./dist/extension",
"contributes": {
"colors": [
{
"id": "markdown.extension.editor.codeSpan.background",
"description": "Background color of code spans in the Markdown editor.",
"defaults": {
"dark": "#00000000",
"light": "#00000000",
"highContrast": "#00000000"
}
},
{
"id": "markdown.extension.editor.codeSpan.border",
"description": "Border color of code spans in the Markdown editor.",
Expand Down
3 changes: 3 additions & 0 deletions src/theming/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import type ConfigKnownKey from "../configuration/KnownKey";
// Keys are sorted in alphabetical order.

const enum Color {
EditorCodeSpanBackground,
EditorCodeSpanBorder,
EditorFormattingMarkForeground,
EditorTrailingSpaceBackground,
}

const colors: Readonly<Record<Color, vscode.ThemeColor>> = {
[Color.EditorCodeSpanBackground]: new vscode.ThemeColor("markdown.extension.editor.codeSpan.background"),
[Color.EditorCodeSpanBorder]: new vscode.ThemeColor("markdown.extension.editor.codeSpan.border"),
[Color.EditorFormattingMarkForeground]: new vscode.ThemeColor("markdown.extension.editor.formattingMark.foreground"),
[Color.EditorTrailingSpaceBackground]: new vscode.ThemeColor("markdown.extension.editor.trailingSpace.background"),
Expand Down Expand Up @@ -57,6 +59,7 @@ export const enum DecorationClass {
*/
export const decorationStyles: Readonly<Record<DecorationClass, Readonly<vscode.DecorationRenderOptions>>> = {
[DecorationClass.CodeSpan]: {
backgroundColor: colors[Color.EditorCodeSpanBackground],
border: "1px solid",
borderColor: colors[Color.EditorCodeSpanBorder],
borderRadius: "3px",
Expand Down

0 comments on commit f67fa77

Please sign in to comment.