Skip to content

Commit 4ee072e

Browse files
committed
docs: update magic move docs
1 parent ff88e58 commit 4ee072e

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

guide/syntax.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ function add(
123123
```
124124
~~~
125125

126-
You can enable line number to all slides by setting `lineNumbers: true` on the config or enable each code block individually by setting `lines:true`. You can also set the starting line for each code block and highlight the lines accordingly, defaults to 1:
126+
You can enable line number to all slides by setting `lineNumbers: true` on the config or enable each code block individually by setting `lines: true`. You can also set the starting line for each code block and highlight the lines accordingly, defaults to 1:
127127

128128
~~~md
129-
```ts {6,7}{lines:true, startLine:5}
129+
```ts {6,7}{lines:true,startLine:5}
130130
function add(
131131
a: Ref<number> | number,
132132
b: Ref<number> | number
@@ -218,20 +218,40 @@ const count = ref(0)
218218

219219
> Available since v0.48
220220
221-
Shiki Magic Move enables you to have granular transition between code changes like Keynote's Magic Move. You can check [this demo](https://shiki-magic-move.netlify.app/) to see how it works.
221+
[Shiki Magic Move](https://github.com/shikijs/shiki-magic-move) enables you to have granular transition between code changes, similar to Keynote's Magic Move. You can check [the playground](https://shiki-magic-move.netlify.app/) to see how it works.
222222

223223
In Slidev, we bind it to the [clicks system](/guide/animations#click-animations). The syntax is wrap multiple code blocks representing each steps with <code>````md magic-move</code> (mind it's **4** backticks), this will be transformed into one code block, that morphing to each steps as you click.
224224

225225
~~~~md
226226
````md magic-move
227-
```ts
227+
```js
228228
console.log(`Step ${1}`)
229229
```
230-
```ts
230+
```js
231231
console.log(`Step ${1 + 1}`)
232232
```
233233
```ts
234-
console.log(`Step ${3}`)
234+
console.log(`Step ${3}` as string)
235+
```
236+
````
237+
~~~~
238+
239+
It's also possible mix Magic Move with [line highlighting](#line-highlighting), for example:
240+
241+
~~~~md
242+
````md magic-move {at:4} // [!code hl]
243+
```js {*|1|2-5} // [!code hl]
244+
let count = 1
245+
function add() {
246+
count++
247+
}
248+
```
249+
250+
Non-code blocks in between as ignored, you can put some comments.
251+
252+
```js
253+
let count = 1
254+
const add = () => count += 1
235255
```
236256
````
237257
~~~~

0 commit comments

Comments
 (0)