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

fix: correct css variable names #72

Merged
merged 1 commit into from
Feb 2, 2025
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ export const shikiLazyPlugin = createHighlightPlugin({ parser: lazyParser })

When using Shiki, two CSS variables are set automatically to the `<pre>` element:

- `--prosekit-highlight`: The text color of the code block
- `--prosekit-highlight-bg`: The background color of the code block
- `--prosemirror-highlight`: The text color of the code block
- `--prosemirror-highlight-bg`: The background color of the code block

You can use these variables to set the background color and text color of the code block.

```css
.ProseMirror pre {
color: var(--prosekit-highlight, inherit);
background-color: var(--prosekit-highlight-bg, inherit);
color: var(--prosemirror-highlight, inherit);
background-color: var(--prosemirror-highlight-bg, inherit);
}
```

Expand Down
4 changes: 2 additions & 2 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@

body .ProseMirror pre code {
--background: #f8f8f8;
color: var(--prosekit-highlight, inherit);
background-color: var(--prosekit-highlight-bg, var(--background, inherit));
color: var(--prosemirror-highlight, inherit);
background-color: var(--prosemirror-highlight-bg, var(--background, inherit));
}

</style>
Expand Down
2 changes: 1 addition & 1 deletion src/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createParser(
const style =
rootStyle ||
(fg && bg
? `--prosekit-highlight:${fg};--prosekit-highlight-bg:${bg}`
? `--prosemirror-highlight:${fg};--prosemirror-highlight-bg:${bg}`
: '')

if (style) {
Expand Down
4 changes: 2 additions & 2 deletions test/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('createHighlightPlugin', () => {
"<div contenteditable="true" translate="no" class="ProseMirror">
<pre
data-language="typescript"
style="--prosekit-highlight: #e1e4e8; --prosekit-highlight-bg: #24292e;"
style="--prosemirror-highlight: #e1e4e8; --prosemirror-highlight-bg: #24292e;"
>
<code>
<span class="shiki" style="color: rgb(225, 228, 232);">
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('createHighlightPlugin', () => {
</pre>
<pre
data-language="python"
style="--prosekit-highlight: #e1e4e8; --prosekit-highlight-bg: #24292e;"
style="--prosemirror-highlight: #e1e4e8; --prosemirror-highlight-bg: #24292e;"
>
<code>
<span class="shiki" style="color: rgb(121, 184, 255);">
Expand Down
Loading