tiptap-extension-code-block-shiki 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +60 -3
- package/dist/tiptap-extension-code-block-shiki.d.ts +4 -0
- package/dist/tiptap-extension-code-block-shiki.js +552 -503
- package/package.json +16 -9
package/LICENSE.md
CHANGED
@@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
|
7
7
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
8
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
@@ -21,13 +21,66 @@ new Editor({
|
|
21
21
|
extensions: [
|
22
22
|
StarterKit.configure({ codeBlock: false }),
|
23
23
|
CodeBlockShiki.configure({
|
24
|
-
defaultTheme: 'tokyo-night'
|
24
|
+
defaultTheme: 'tokyo-night',
|
25
25
|
}),
|
26
26
|
],
|
27
27
|
})
|
28
28
|
```
|
29
29
|
|
30
|
-
Go into your TipTap editor, write
|
30
|
+
Go into your TipTap editor, write ` ```ts `, press <kbd>Enter</kbd>, and write some code! It loads the language on the fly.
|
31
|
+
|
32
|
+
### Dark Mode Support
|
33
|
+
|
34
|
+
You can optionally supply themes to use for light and dark modes
|
35
|
+
|
36
|
+
```ts
|
37
|
+
import { Editor } from '@tiptap/core'
|
38
|
+
import StarterKit from '@tiptap/starter-kit'
|
39
|
+
import CodeBlockShiki from 'tiptap-extension-code-block-shiki'
|
40
|
+
|
41
|
+
new Editor({
|
42
|
+
extensions: [
|
43
|
+
StarterKit.configure({ codeBlock: false }),
|
44
|
+
CodeBlockShiki.configure({
|
45
|
+
defaultTheme: 'tokyo-night' // Fallback theme
|
46
|
+
themes: {
|
47
|
+
light: 'github-light',
|
48
|
+
dark: 'github-dark',
|
49
|
+
},
|
50
|
+
}),
|
51
|
+
],
|
52
|
+
})
|
53
|
+
```
|
54
|
+
|
55
|
+
_Note_: In order to enable theme switching, you must add this snippet to your CSS
|
56
|
+
|
57
|
+
```css
|
58
|
+
@media (prefers-color-scheme: dark) {
|
59
|
+
.tiptap .shiki,
|
60
|
+
.tiptap .shiki span {
|
61
|
+
color: var(--shiki-dark) !important;
|
62
|
+
background-color: var(--shiki-dark-bg) !important;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
If you prefer to manually toggle using data-theme attribute:
|
68
|
+
*/
|
69
|
+
[data-theme='dark'] .tiptap .shiki,
|
70
|
+
[data-theme='dark'] .tiptap .shiki span {
|
71
|
+
color: var(--shiki-dark) !important;
|
72
|
+
background-color: var(--shiki-dark-bg) !important;
|
73
|
+
}
|
74
|
+
|
75
|
+
/*
|
76
|
+
If you prefer to manually toggle using Class-based Dark Mode:
|
77
|
+
*/
|
78
|
+
html.dark .tiptap .shiki,
|
79
|
+
html.dark .tiptap .shiki span {
|
80
|
+
color: var(--shiki-dark) !important;
|
81
|
+
background-color: var(--shiki-dark-bg) !important;
|
82
|
+
}
|
83
|
+
```
|
31
84
|
|
32
85
|
## Demo
|
33
86
|
|
@@ -41,6 +94,10 @@ The extension extends [CodeBlock](https://tiptap.dev/docs/editor/api/nodes/code-
|
|
41
94
|
|
42
95
|
Which theme to use by default. See https://shiki.style/themes.
|
43
96
|
|
97
|
+
## `themes`
|
98
|
+
|
99
|
+
Optionally specify themes for light and dark mode. See https://shiki.matsu.io/guide/dual-themes
|
100
|
+
|
44
101
|
### `defaultLanguage`
|
45
102
|
|
46
103
|
Which language to use, when no language was provided. See https://shiki.style/languages.
|
@@ -66,4 +123,4 @@ Most of this library is just a combination of code from two other libraries:
|
|
66
123
|
|
67
124
|
## License
|
68
125
|
|
69
|
-
MIT
|
126
|
+
MIT
|
@@ -10,6 +10,10 @@ export default CodeBlockShiki;
|
|
10
10
|
export declare interface CodeBlockShikiOptions extends CodeBlockOptions {
|
11
11
|
defaultLanguage: BundledLanguage | null | undefined;
|
12
12
|
defaultTheme: BundledTheme;
|
13
|
+
themes: {
|
14
|
+
light: BundledTheme;
|
15
|
+
dark: BundledTheme;
|
16
|
+
} | null | undefined;
|
13
17
|
}
|
14
18
|
|
15
19
|
export { }
|