@slidev/docs 51.6.2
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 +21 -0
- package/README.md +39 -0
- package/builtin/cli.md +96 -0
- package/builtin/components.md +359 -0
- package/builtin/layouts.md +217 -0
- package/custom/config-code-runners.md +78 -0
- package/custom/config-context-menu.md +40 -0
- package/custom/config-fonts.md +105 -0
- package/custom/config-highlighter.md +74 -0
- package/custom/config-katex.md +18 -0
- package/custom/config-mermaid.md +47 -0
- package/custom/config-monaco.md +99 -0
- package/custom/config-parser.md +232 -0
- package/custom/config-routes.md +28 -0
- package/custom/config-shortcuts.md +36 -0
- package/custom/config-transformers.md +43 -0
- package/custom/config-unocss.md +46 -0
- package/custom/config-vite.md +83 -0
- package/custom/config-vue.md +25 -0
- package/custom/directory-structure.md +134 -0
- package/custom/index.md +192 -0
- package/features/block-frontmatter.md +39 -0
- package/features/build-with-pdf.md +42 -0
- package/features/bundle-remote-assets.md +29 -0
- package/features/canvas-size.md +32 -0
- package/features/click-marker.md +31 -0
- package/features/code-block-line-numbers.md +32 -0
- package/features/code-block-max-height.md +32 -0
- package/features/direction-variant.md +31 -0
- package/features/draggable.md +82 -0
- package/features/drawing.md +74 -0
- package/features/eject-theme.md +27 -0
- package/features/frontmatter-merging.md +49 -0
- package/features/global-layers.md +99 -0
- package/features/icons.md +58 -0
- package/features/import-snippet.md +48 -0
- package/features/importing-slides.md +69 -0
- package/features/index.md +93 -0
- package/features/latex.md +80 -0
- package/features/line-highlighting.md +57 -0
- package/features/mdc.md +31 -0
- package/features/mermaid.md +37 -0
- package/features/monaco-editor.md +36 -0
- package/features/monaco-run.md +44 -0
- package/features/monaco-write.md +22 -0
- package/features/plantuml.md +26 -0
- package/features/prettier-plugin.md +55 -0
- package/features/recording.md +28 -0
- package/features/remote-access.md +69 -0
- package/features/rough-marker.md +46 -0
- package/features/shiki-magic-move.md +53 -0
- package/features/side-editor.md +17 -0
- package/features/slide-hook.md +33 -0
- package/features/slide-scope-style.md +44 -0
- package/features/slot-sugar.md +83 -0
- package/features/transform-component.md +29 -0
- package/features/twoslash.md +37 -0
- package/features/vscode-extension.md +80 -0
- package/features/zoom-slide.md +33 -0
- package/guide/animations.md +456 -0
- package/guide/component.md +36 -0
- package/guide/exporting.md +240 -0
- package/guide/faq.md +134 -0
- package/guide/global-context.md +169 -0
- package/guide/hosting.md +220 -0
- package/guide/index.md +161 -0
- package/guide/layout.md +32 -0
- package/guide/syntax.md +179 -0
- package/guide/theme-addon.md +62 -0
- package/guide/ui.md +86 -0
- package/guide/why.md +112 -0
- package/guide/write-addon.md +48 -0
- package/guide/write-layout.md +45 -0
- package/guide/write-theme.md +109 -0
- package/index.md +6 -0
- package/package.json +47 -0
- package/resources/addon-gallery.md +32 -0
- package/resources/covers.md +16 -0
- package/resources/learning.md +22 -0
- package/resources/showcases.md +10 -0
- package/resources/theme-gallery.md +32 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Layouts
|
|
2
|
+
|
|
3
|
+
This page lists all the built-in layouts provided by Slidev. These layouts can be used via the `layout` option in the frontmatters of your slides.
|
|
4
|
+
|
|
5
|
+
Note that <LinkInline link="guide/theme-addon" /> may provide additional layouts or override the existing ones. To add your own layouts, see <LinkInline link="guide/write-layout" />.
|
|
6
|
+
|
|
7
|
+
## `center`
|
|
8
|
+
|
|
9
|
+
Displays the content in the middle of the screen.
|
|
10
|
+
|
|
11
|
+
## `cover`
|
|
12
|
+
|
|
13
|
+
Used to display the cover page for the presentation, may contain the presentation title, contextualization, etc.
|
|
14
|
+
|
|
15
|
+
## `default`
|
|
16
|
+
|
|
17
|
+
The most basic layout, to display any kind of content.
|
|
18
|
+
|
|
19
|
+
## `end`
|
|
20
|
+
|
|
21
|
+
The final page for the presentation.
|
|
22
|
+
|
|
23
|
+
## `fact`
|
|
24
|
+
|
|
25
|
+
To show some fact or data with a lot of prominence on the screen.
|
|
26
|
+
|
|
27
|
+
## `full`
|
|
28
|
+
|
|
29
|
+
Use all the space of the screen to display the content.
|
|
30
|
+
|
|
31
|
+
## `image-left`
|
|
32
|
+
|
|
33
|
+
Shows an image on the left side of the screen, the content will be placed on the right side.
|
|
34
|
+
|
|
35
|
+
### Usage
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
---
|
|
39
|
+
layout: image-left
|
|
40
|
+
|
|
41
|
+
# the image source
|
|
42
|
+
image: /path/to/the/image
|
|
43
|
+
|
|
44
|
+
# a custom class name to the content
|
|
45
|
+
class: my-cool-content-on-the-right
|
|
46
|
+
---
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## `image-right`
|
|
50
|
+
|
|
51
|
+
Shows an image on the right side of the screen, the content will be placed on the left side.
|
|
52
|
+
|
|
53
|
+
### Usage
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
---
|
|
57
|
+
layout: image-right
|
|
58
|
+
|
|
59
|
+
# the image source
|
|
60
|
+
image: /path/to/the/image
|
|
61
|
+
|
|
62
|
+
# a custom class name to the content
|
|
63
|
+
class: my-cool-content-on-the-left
|
|
64
|
+
---
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## `image`
|
|
68
|
+
|
|
69
|
+
Shows an image as the main content of the page.
|
|
70
|
+
|
|
71
|
+
### Usage
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
---
|
|
75
|
+
layout: image
|
|
76
|
+
|
|
77
|
+
# the image source
|
|
78
|
+
image: /path/to/the/image
|
|
79
|
+
---
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
You can change the default background size (`cover`) by adding the `backgroundSize` attribute:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
---
|
|
86
|
+
layout: image
|
|
87
|
+
image: /path/to/the/image
|
|
88
|
+
backgroundSize: contain
|
|
89
|
+
---
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
---
|
|
94
|
+
layout: image-left
|
|
95
|
+
image: /path/to/the/image
|
|
96
|
+
backgroundSize: 20em 70%
|
|
97
|
+
---
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## `iframe-left`
|
|
101
|
+
|
|
102
|
+
Shows a web page on the left side of the screen, the content will be placed on the right side.
|
|
103
|
+
|
|
104
|
+
### Usage
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
---
|
|
108
|
+
layout: iframe-left
|
|
109
|
+
|
|
110
|
+
# the web page source
|
|
111
|
+
url: https://github.com/slidevjs/slidev
|
|
112
|
+
|
|
113
|
+
# a custom class name to the content
|
|
114
|
+
class: my-cool-content-on-the-right
|
|
115
|
+
---
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## `iframe-right`
|
|
119
|
+
|
|
120
|
+
Shows a web page on the right side of the screen, the content will be placed on the left side.
|
|
121
|
+
|
|
122
|
+
### Usage
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
---
|
|
126
|
+
layout: iframe-right
|
|
127
|
+
|
|
128
|
+
# the web page source
|
|
129
|
+
url: https://github.com/slidevjs/slidev
|
|
130
|
+
|
|
131
|
+
# a custom class name to the content
|
|
132
|
+
class: my-cool-content-on-the-left
|
|
133
|
+
---
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## `iframe`
|
|
137
|
+
|
|
138
|
+
Shows a web page as the main content of the page.
|
|
139
|
+
|
|
140
|
+
### Usage
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
---
|
|
144
|
+
layout: iframe
|
|
145
|
+
|
|
146
|
+
# the web page source
|
|
147
|
+
url: https://github.com/slidevjs/slidev
|
|
148
|
+
---
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## `intro`
|
|
152
|
+
|
|
153
|
+
To introduce the presentation, usually with the presentation title, a short description, the author, etc.
|
|
154
|
+
|
|
155
|
+
## `none`
|
|
156
|
+
|
|
157
|
+
A layout without any existing styling.
|
|
158
|
+
|
|
159
|
+
## `quote`
|
|
160
|
+
|
|
161
|
+
To display a quotation with prominence.
|
|
162
|
+
|
|
163
|
+
## `section`
|
|
164
|
+
|
|
165
|
+
Used to mark the beginning of a new presentation section.
|
|
166
|
+
|
|
167
|
+
## `statement`
|
|
168
|
+
|
|
169
|
+
Make an affirmation/statement as the main page content.
|
|
170
|
+
|
|
171
|
+
## `two-cols`
|
|
172
|
+
|
|
173
|
+
Separates the page content in two columns.
|
|
174
|
+
|
|
175
|
+
### Usage
|
|
176
|
+
|
|
177
|
+
```md
|
|
178
|
+
---
|
|
179
|
+
layout: two-cols
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
# Left
|
|
183
|
+
|
|
184
|
+
This shows on the left
|
|
185
|
+
|
|
186
|
+
::right::
|
|
187
|
+
|
|
188
|
+
# Right
|
|
189
|
+
|
|
190
|
+
This shows on the right
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## `two-cols-header`
|
|
194
|
+
|
|
195
|
+
Separates the upper and lower lines of the page content, and the second line separates the left and right columns.
|
|
196
|
+
|
|
197
|
+
### Usage
|
|
198
|
+
|
|
199
|
+
```md
|
|
200
|
+
---
|
|
201
|
+
layout: two-cols-header
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
This spans both
|
|
205
|
+
|
|
206
|
+
::left::
|
|
207
|
+
|
|
208
|
+
# Left
|
|
209
|
+
|
|
210
|
+
This shows on the left
|
|
211
|
+
|
|
212
|
+
::right::
|
|
213
|
+
|
|
214
|
+
# Right
|
|
215
|
+
|
|
216
|
+
This shows on the right
|
|
217
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Configure Code Runners
|
|
2
|
+
|
|
3
|
+
<Environment type="client" />
|
|
4
|
+
|
|
5
|
+
Define code runners for custom languages in your Monaco Editor.
|
|
6
|
+
|
|
7
|
+
By default, JavaScript, TypeScript runners are supported built-in. They run in the browser **without** a sandbox environment. If you want more advanced integrations, you can provide your own code runner that sends the code to a remote server, runs in a Web Worker, or anything, up to you.
|
|
8
|
+
|
|
9
|
+
Create `./setup/code-runners.ts` with the following content:
|
|
10
|
+
|
|
11
|
+
<!-- eslint-disable import/first -->
|
|
12
|
+
|
|
13
|
+
```ts twoslash
|
|
14
|
+
declare const executePythonCodeRemotely: (code: string) => Promise<string>
|
|
15
|
+
declare const sanitizeHtml: (html: string) => string
|
|
16
|
+
// ---cut---
|
|
17
|
+
import { defineCodeRunnersSetup } from '@slidev/types'
|
|
18
|
+
|
|
19
|
+
export default defineCodeRunnersSetup(() => {
|
|
20
|
+
return {
|
|
21
|
+
async python(code, ctx) {
|
|
22
|
+
// Somehow execute the code and return the result
|
|
23
|
+
const result = await executePythonCodeRemotely(code)
|
|
24
|
+
return {
|
|
25
|
+
text: result
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
html(code, ctx) {
|
|
29
|
+
return {
|
|
30
|
+
html: sanitizeHtml(code)
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// or other languages, key is the language id
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Runner Context
|
|
39
|
+
|
|
40
|
+
The second argument `ctx` is the runner context, which contains the following properties:
|
|
41
|
+
|
|
42
|
+
```ts twoslash
|
|
43
|
+
import type { CodeRunnerOutputs } from '@slidev/types'
|
|
44
|
+
import type { CodeToHastOptions } from 'shiki'
|
|
45
|
+
// ---cut---
|
|
46
|
+
export interface CodeRunnerContext {
|
|
47
|
+
/**
|
|
48
|
+
* Options passed to runner via the `runnerOptions` prop.
|
|
49
|
+
*/
|
|
50
|
+
options: Record<string, unknown>
|
|
51
|
+
/**
|
|
52
|
+
* Highlight code with shiki.
|
|
53
|
+
*/
|
|
54
|
+
highlight: (code: string, lang: string, options?: Partial<CodeToHastOptions>) => string
|
|
55
|
+
/**
|
|
56
|
+
* Use (other) code runner to run code.
|
|
57
|
+
*/
|
|
58
|
+
run: (code: string, lang: string) => Promise<CodeRunnerOutputs>
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Runner Output
|
|
63
|
+
|
|
64
|
+
The runner can either return a text or HTML output, or an element to be mounted. Refer to https://github.com/slidevjs/slidev/blob/main/packages/types/src/code-runner.ts for more details.
|
|
65
|
+
|
|
66
|
+
## Additional Runner Dependencies
|
|
67
|
+
|
|
68
|
+
By default, Slidev will scan the Markdown source and automatically import the necessary dependencies for the code runners. If you want to manually import dependencies, you can use the `monacoRunAdditionalDeps` option in the slide frontmatter:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
monacoRunAdditionalDeps:
|
|
72
|
+
- ./path/to/dependency
|
|
73
|
+
- lodash-es
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
::: tip
|
|
77
|
+
The paths are resolved relative to the `snippets` directory. And the names of the deps should be exactly the same as the imported ones in the code.
|
|
78
|
+
:::
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Configure Context Menu
|
|
2
|
+
|
|
3
|
+
<Environment type="client" />
|
|
4
|
+
|
|
5
|
+
Customize the context menu items in Slidev.
|
|
6
|
+
|
|
7
|
+
Create `./setup/context-menu.ts` with the following content:
|
|
8
|
+
|
|
9
|
+
<!-- eslint-disable import/first -->
|
|
10
|
+
|
|
11
|
+
```ts twoslash
|
|
12
|
+
// ---cut---
|
|
13
|
+
import { useNav } from '@slidev/client'
|
|
14
|
+
import { defineContextMenuSetup } from '@slidev/types'
|
|
15
|
+
import { computed } from 'vue'
|
|
16
|
+
// ---cut-start---
|
|
17
|
+
// @ts-expect-error missing types
|
|
18
|
+
// ---cut-end---
|
|
19
|
+
import Icon3DCursor from '~icons/carbon/3d-cursor'
|
|
20
|
+
|
|
21
|
+
export default defineContextMenuSetup((items) => {
|
|
22
|
+
const { isPresenter } = useNav()
|
|
23
|
+
return computed(() => [
|
|
24
|
+
...items.value,
|
|
25
|
+
{
|
|
26
|
+
small: false,
|
|
27
|
+
icon: Icon3DCursor, // if `small` is `true`, only the icon is shown
|
|
28
|
+
label: 'Custom Menu Item', // or a Vue component
|
|
29
|
+
action() {
|
|
30
|
+
alert('Custom Menu Item Clicked!')
|
|
31
|
+
},
|
|
32
|
+
disabled: isPresenter.value,
|
|
33
|
+
},
|
|
34
|
+
])
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This will append a new menu item to the context menu.
|
|
39
|
+
|
|
40
|
+
To disable context menu globally, set `contextMenu` to `false` in the frontmatter. `contextMenu` can also be set to `dev` or `build` to only enable the context menu in development or build mode.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Configure Fonts
|
|
2
|
+
|
|
3
|
+
While you can use HTML and CSS to customize the fonts and style for your slides as you want, Slidev also provides a convenient way to use them effortlessly.
|
|
4
|
+
|
|
5
|
+
In your frontmatter, configure as the following:
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
---
|
|
9
|
+
fonts:
|
|
10
|
+
# basically the text
|
|
11
|
+
sans: Robot
|
|
12
|
+
# use with `font-serif` css class from UnoCSS
|
|
13
|
+
serif: Robot Slab
|
|
14
|
+
# for code blocks, inline code, etc.
|
|
15
|
+
mono: Fira Code
|
|
16
|
+
---
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
And that's all.
|
|
20
|
+
|
|
21
|
+
Fonts will be **imported automatically from a provider via CDN, by default it is [Google Fonts](https://fonts.google.com/)**. That means you can use any fonts available on Google Fonts directly.
|
|
22
|
+
|
|
23
|
+
## Local Fonts
|
|
24
|
+
|
|
25
|
+
By default, Slidev assumes all the fonts specified via `fonts` configurations come from Google Fonts. If you want to use local fonts, specify the `fonts.local` to opt-out the auto-importing.
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
---
|
|
29
|
+
fonts:
|
|
30
|
+
# like font-family in css, you can use `,` to separate multiple fonts for fallback
|
|
31
|
+
sans: 'Helvetica Neue,Robot'
|
|
32
|
+
# mark 'Helvetica Neue' as local font
|
|
33
|
+
local: Helvetica Neue
|
|
34
|
+
---
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Weights & Italic
|
|
38
|
+
|
|
39
|
+
By default, Slidev imports three weights `200`,`400`,`600` for each font. You can configure them by:
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
---
|
|
43
|
+
fonts:
|
|
44
|
+
sans: Robot
|
|
45
|
+
# default
|
|
46
|
+
weights: '200,400,600'
|
|
47
|
+
# import italic fonts, default `false`
|
|
48
|
+
italic: false
|
|
49
|
+
---
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This configuration applies to all web fonts. For more fine-grained controls of each font's weights, you will need to manually import them with [HTML](/custom/directory-structure.html#index-html) and CSS.
|
|
53
|
+
|
|
54
|
+
## Fallback Fonts
|
|
55
|
+
|
|
56
|
+
For most of the scenarios, you only need to specify the "special font" and Slidev will append the fallback fonts for you, for example:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
---
|
|
60
|
+
fonts:
|
|
61
|
+
sans: Robot
|
|
62
|
+
serif: Robot Slab
|
|
63
|
+
mono: Fira Code
|
|
64
|
+
---
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
will result in
|
|
68
|
+
|
|
69
|
+
<!-- eslint-skip -->
|
|
70
|
+
|
|
71
|
+
```css
|
|
72
|
+
.font-sans {
|
|
73
|
+
font-family: "Robot",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
|
|
74
|
+
}
|
|
75
|
+
.font-serif {
|
|
76
|
+
font-family: "Robot Slab",ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;
|
|
77
|
+
}
|
|
78
|
+
.font-mono {
|
|
79
|
+
font-family: "Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If you want to disable the fallback fonts, configure as the following:
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
---
|
|
87
|
+
fonts:
|
|
88
|
+
mono: 'Fira Code, monospace'
|
|
89
|
+
fallbacks: false
|
|
90
|
+
---
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Providers
|
|
94
|
+
|
|
95
|
+
- Options: `google` | `coollabs` | `none`
|
|
96
|
+
- Default: `google`
|
|
97
|
+
|
|
98
|
+
Currently, only [Google Fonts](https://fonts.google.com/) and [coolLabs](https://fonts.coollabs.io/) supported, we are planning to add more providers in the future. Specify to `none` will disable the auto-importing feature entirely and treat all the fonts locally.
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
---
|
|
102
|
+
fonts:
|
|
103
|
+
provider: none
|
|
104
|
+
---
|
|
105
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Configure Highlighter
|
|
2
|
+
|
|
3
|
+
Slidev uses [Shiki](https://github.com/shikijs/shiki) as the code highlighter. It's a TextMate Grammar powered syntax highlighter as accurate as VS Code. It generates colored tokens so no additinal CSS is required. Shiki also comes with [a bunch of built-in themes](https://shiki.style/themes). In Slidev, we also provided the [TwoSlash](#twoslash-integration) support.
|
|
4
|
+
|
|
5
|
+
## Configure Shiki
|
|
6
|
+
|
|
7
|
+
<Environment type="both" />
|
|
8
|
+
|
|
9
|
+
Create `./setup/shiki.ts` file with the following content:
|
|
10
|
+
|
|
11
|
+
```ts twoslash
|
|
12
|
+
/* ./setup/shiki.ts */
|
|
13
|
+
import { defineShikiSetup } from '@slidev/types'
|
|
14
|
+
|
|
15
|
+
export default defineShikiSetup(() => {
|
|
16
|
+
return {
|
|
17
|
+
themes: {
|
|
18
|
+
dark: 'min-dark',
|
|
19
|
+
light: 'min-light',
|
|
20
|
+
},
|
|
21
|
+
transformers: [
|
|
22
|
+
// ...
|
|
23
|
+
],
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you want to add custom theme or language (TextMate grammar/themes in JSON), you can import them in the setup file:
|
|
29
|
+
|
|
30
|
+
<!-- eslint-disable import/first-->
|
|
31
|
+
|
|
32
|
+
```ts twoslash
|
|
33
|
+
/* ./setup/shiki.ts */
|
|
34
|
+
import { defineShikiSetup } from '@slidev/types'
|
|
35
|
+
// ---cut-start---
|
|
36
|
+
// @ts-expect-error missing types
|
|
37
|
+
// ---cut-end---
|
|
38
|
+
import customLanguage from './customLanguage.tmLanguage.json'
|
|
39
|
+
// ---cut-start---
|
|
40
|
+
// @ts-expect-error missing types
|
|
41
|
+
// ---cut-end---
|
|
42
|
+
import customTheme from './customTheme.tmTheme.json'
|
|
43
|
+
|
|
44
|
+
export default defineShikiSetup(() => {
|
|
45
|
+
return {
|
|
46
|
+
themes: {
|
|
47
|
+
dark: customTheme,
|
|
48
|
+
light: 'min-light',
|
|
49
|
+
},
|
|
50
|
+
langs: [
|
|
51
|
+
'js',
|
|
52
|
+
'typescript',
|
|
53
|
+
'cpp',
|
|
54
|
+
customLanguage,
|
|
55
|
+
// ...
|
|
56
|
+
],
|
|
57
|
+
transformers: [
|
|
58
|
+
// ...
|
|
59
|
+
],
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Check [Built-in languages](https://shiki.style/languages) and [Built-in themes](https://shiki.style/themes), and refer to [Shiki's docs](https://shiki.style) for more details.
|
|
65
|
+
|
|
66
|
+
:::info
|
|
67
|
+
For now, Shiki Magic Move does not support transformers.
|
|
68
|
+
:::
|
|
69
|
+
|
|
70
|
+
## Configure Prism
|
|
71
|
+
|
|
72
|
+
:::warning
|
|
73
|
+
Prism support has been removed since v0.50. Please use Shiki instead.
|
|
74
|
+
:::
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Configure KaTeX
|
|
2
|
+
|
|
3
|
+
<Environment type="node" />
|
|
4
|
+
|
|
5
|
+
Create `./setup/katex.ts` with the following content:
|
|
6
|
+
|
|
7
|
+
```ts twoslash
|
|
8
|
+
import { defineKatexSetup } from '@slidev/types'
|
|
9
|
+
|
|
10
|
+
export default defineKatexSetup(() => {
|
|
11
|
+
return {
|
|
12
|
+
maxExpand: 2000,
|
|
13
|
+
/* ... */
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The return value should be the custom options for KaTeX. Refer to [KaTeX's documentation](https://katex.org/docs/options.html) or the type definition for the full options list.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Configure Mermaid
|
|
2
|
+
|
|
3
|
+
<Environment type="client" />
|
|
4
|
+
|
|
5
|
+
Create `./setup/mermaid.ts` with the following content:
|
|
6
|
+
|
|
7
|
+
```ts twoslash
|
|
8
|
+
import { defineMermaidSetup } from '@slidev/types'
|
|
9
|
+
|
|
10
|
+
export default defineMermaidSetup(() => {
|
|
11
|
+
return {
|
|
12
|
+
theme: 'forest',
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The return value should be the custom configs for [Mermaid](https://mermaid.js.org/). Refer to the [Mermaid documentation](https://mermaid.js.org/config/schema-docs/config.html) or the type definition for the full config list.
|
|
18
|
+
|
|
19
|
+
## Custom theme/styles
|
|
20
|
+
|
|
21
|
+
In case you want to create your custom Mermaid themes or styles, you can do this by defining `themeVariables` like in the following example:
|
|
22
|
+
|
|
23
|
+
```ts twoslash
|
|
24
|
+
import { defineMermaidSetup } from '@slidev/types'
|
|
25
|
+
|
|
26
|
+
export default defineMermaidSetup(() => {
|
|
27
|
+
return {
|
|
28
|
+
theme: 'base',
|
|
29
|
+
themeVariables: {
|
|
30
|
+
// General theme variables
|
|
31
|
+
noteBkgColor: '#181d29',
|
|
32
|
+
noteTextColor: '#F3EFF5cc',
|
|
33
|
+
noteBorderColor: '#404551',
|
|
34
|
+
|
|
35
|
+
// Sequence diagram variables
|
|
36
|
+
actorBkg: '#0E131F',
|
|
37
|
+
actorBorder: '#44FFD2',
|
|
38
|
+
actorTextColor: '#F3EFF5',
|
|
39
|
+
actorLineColor: '#F3EFF5',
|
|
40
|
+
signalColor: '#F3EFF5',
|
|
41
|
+
signalTextColor: '#F3EFF5',
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You can find all theme variables on the [Mermaid Theme Configuration](https://mermaid.js.org/config/theming.html) page.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Configure Monaco
|
|
2
|
+
|
|
3
|
+
<Environment type="client" />
|
|
4
|
+
|
|
5
|
+
Create `./setup/monaco.ts` with the following content:
|
|
6
|
+
|
|
7
|
+
```ts twoslash
|
|
8
|
+
import { defineMonacoSetup } from '@slidev/types'
|
|
9
|
+
|
|
10
|
+
export default defineMonacoSetup(async (monaco) => {
|
|
11
|
+
// use `monaco` to configure
|
|
12
|
+
})
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Learn more about [configuring Monaco](https://github.com/Microsoft/monaco-editor).
|
|
16
|
+
|
|
17
|
+
## TypeScript Types
|
|
18
|
+
|
|
19
|
+
When using TypeScript with Monaco, types for dependencies will be installed to the client-side automatically.
|
|
20
|
+
|
|
21
|
+
````md
|
|
22
|
+
```ts {monaco}
|
|
23
|
+
import { ref } from 'vue'
|
|
24
|
+
import { useMouse } from '@vueuse/core'
|
|
25
|
+
|
|
26
|
+
const counter = ref(0)
|
|
27
|
+
```
|
|
28
|
+
````
|
|
29
|
+
|
|
30
|
+
In the example above, make sure `vue` and `@vueuse/core` are installed locally as dependencies / devDependencies, Slidev will handle the rest to get the types working for the editor automatically. When deployed as SPA, those types will also be bundled for static hosting.
|
|
31
|
+
|
|
32
|
+
### Additional Types
|
|
33
|
+
|
|
34
|
+
Slidev will scan all the Monaco code blocks in your slides and import the types for those used libraries for you. In case it missed some, you can explicitly specify extra packages to import the types for:
|
|
35
|
+
|
|
36
|
+
```md
|
|
37
|
+
---
|
|
38
|
+
monacoTypesAdditionalPackages:
|
|
39
|
+
- lodash-es
|
|
40
|
+
- foo
|
|
41
|
+
---
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Auto Type Acquisition
|
|
45
|
+
|
|
46
|
+
You can optionally switch to load types from CDN by setting the following headmatter:
|
|
47
|
+
|
|
48
|
+
```md
|
|
49
|
+
---
|
|
50
|
+
monacoTypesSource: ata
|
|
51
|
+
---
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This feature is powered by [`@typescript/ata`](https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ata) and runs completely on the client-side.
|
|
55
|
+
|
|
56
|
+
## Configure Themes
|
|
57
|
+
|
|
58
|
+
Since v0.48.0, Monaco will reuse the Shiki theme you configured in [Shiki's setup file](/custom/config-highlighter#configure-shiki), powered by [`@shikijs/monaco`](https://shiki.style/packages/monaco). You don't need to worry about it anymore and it will have a consistent style with the rest of your code blocks.
|
|
59
|
+
|
|
60
|
+
## Configure the Editor
|
|
61
|
+
|
|
62
|
+
> Available since v0.43.0
|
|
63
|
+
|
|
64
|
+
If you would like to customize the Monaco editor you may pass an `editorOptions` object that matches the [Monaco IEditorOptions](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IEditorOptions.html) definition.
|
|
65
|
+
|
|
66
|
+
````md
|
|
67
|
+
```ts {monaco} { editorOptions: { wordWrap:'on'} }
|
|
68
|
+
console.log('HelloWorld')
|
|
69
|
+
```
|
|
70
|
+
````
|
|
71
|
+
|
|
72
|
+
Alternatively if you would like these options to be applied to every Monaco instance, you can return them in the `defineMonacoSetup` function
|
|
73
|
+
|
|
74
|
+
```ts twoslash
|
|
75
|
+
// ./setup/monaco.ts
|
|
76
|
+
import { defineMonacoSetup } from '@slidev/types'
|
|
77
|
+
|
|
78
|
+
export default defineMonacoSetup(() => {
|
|
79
|
+
return {
|
|
80
|
+
editorOptions: {
|
|
81
|
+
wordWrap: 'on'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Disabling
|
|
88
|
+
|
|
89
|
+
Since v0.48.0, the Monaco editor is enabled by default and only be bundled when you use it. If you want to disable it, you can set `monaco` to `false` in the frontmatter of your slide:
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
---
|
|
93
|
+
monaco: false # can also be `dev` or `build` to conditionally enable it
|
|
94
|
+
---
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configure Code Runners
|
|
98
|
+
|
|
99
|
+
To configure how the Monaco Runner runs the code, or to add support for custom languages, please reference [Configure Code Runners](/custom/config-code-runners).
|