Skip to content

Commit

Permalink
fix: editor hmr
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 7, 2021
1 parent 1086ed2 commit 8239938
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/client/internals/Play.vue
Expand Up @@ -12,6 +12,9 @@ registerShotcuts()
const root = ref<HTMLDivElement>()
function onClick(e: MouseEvent) {
if (showEditor.value)
return
if ((e.target as HTMLElement)?.id === 'slide-container') {
// click right to next, left to previouse
if ((e.screenX / window.innerWidth) > 0.6)
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/core.ts
Expand Up @@ -16,7 +16,7 @@ export function filterDisabled(data: SlidevMarkdown) {
return data
}

function stringifySlide(data: SlideInfo, idx = 1) {
export function stringifySlide(data: SlideInfo, idx = 1) {
if (!data.raw)
prettifySlide(data)

Expand All @@ -25,7 +25,7 @@ function stringifySlide(data: SlideInfo, idx = 1) {
: `---\n${data.raw.startsWith('\n') ? data.raw : `\n${data.raw}`}`
}

function prettifySlide(data: SlideInfo) {
export function prettifySlide(data: SlideInfo) {
data.content = `\n${data.content.trim()}\n`
data.raw = Object.keys(data.frontmatter || {}).length
? `---\n${YAML.dump(data.frontmatter).trim()}\n---\n${data.content}`
Expand Down
5 changes: 1 addition & 4 deletions packages/slidev/node/plugins/loaders.ts
Expand Up @@ -90,10 +90,7 @@ export function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRo
const body = await getBodyJson(req)
Object.assign(data.slides[idx], body)

hmrNextModuleIds.push(`${slidePrefix}${idx}.md`)

if (body.content != null)
hmrNextModuleIds.push(`${slidePrefix}${idx}.md`)
hmrNextModuleIds.push(`${slidePrefix}${idx + 1}.md`)

server.ws.send({
type: 'custom',
Expand Down
2 changes: 2 additions & 0 deletions packages/slidev/node/plugins/preset.ts
Expand Up @@ -30,6 +30,8 @@ const customElements = new Set([
'mspace',
'mtable',
'mtd',
'msup',
'msqrt',
'mtr',
'semantics',
])
Expand Down

0 comments on commit 8239938

Please sign in to comment.