File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
40
40
if ( payload . id === id )
41
41
info . value = payload . data
42
42
} )
43
+ import . meta. hot ?. on ( 'slidev-update-note' , ( payload ) => {
44
+ if ( payload . id === id && info . value . note . trim ( ) !== payload . note . trim ( ) )
45
+ info . value = { ...info . value , ...payload }
46
+ } )
43
47
}
44
48
45
49
return {
Original file line number Diff line number Diff line change @@ -115,7 +115,11 @@ export function createSlidesLoader(
115
115
if ( type === 'json' && req . method === 'POST' ) {
116
116
const body = await getBodyJson ( req )
117
117
const slide = data . slides [ idx ]
118
- hmrPages . add ( idx )
118
+
119
+ const onlyNoteChanged = Object . keys ( body ) . length === 2
120
+ && 'note' in body && body . raw === null
121
+ if ( ! onlyNoteChanged )
122
+ hmrPages . add ( idx )
119
123
120
124
if ( slide . source ) {
121
125
Object . assign ( slide . source , body )
@@ -173,7 +177,6 @@ export function createSlidesLoader(
173
177
if (
174
178
a ?. content . trim ( ) === b ?. content . trim ( )
175
179
&& a ?. title ?. trim ( ) === b ?. title ?. trim ( )
176
- && a ?. note === b ?. note
177
180
&& equal ( a . frontmatter , b . frontmatter )
178
181
&& Object . entries ( a . snippetsUsed ?? { } ) . every ( ( [ file , oldContent ] ) => {
179
182
try {
@@ -184,8 +187,20 @@ export function createSlidesLoader(
184
187
return false
185
188
}
186
189
} )
187
- )
190
+ ) {
191
+ if ( a ?. note !== b ?. note ) {
192
+ ctx . server . ws . send ( {
193
+ type : 'custom' ,
194
+ event : 'slidev-update-note' ,
195
+ data : {
196
+ id : i ,
197
+ note : b ! . note || '' ,
198
+ noteHTML : md . render ( b ! . note || '' ) ,
199
+ } ,
200
+ } )
201
+ }
188
202
continue
203
+ }
189
204
190
205
ctx . server . ws . send ( {
191
206
type : 'custom' ,
You can’t perform that action at this time.
0 commit comments