Skip to content

fix: Use openInEditor() instead of openInEditor#2118

Merged
antfu merged 1 commit into
slidevjs:mainfrom
zhixiangyao:patch-3
Mar 21, 2025
Merged

fix: Use openInEditor() instead of openInEditor#2118
antfu merged 1 commit into
slidevjs:mainfrom
zhixiangyao:patch-3

Conversation

@zhixiangyao

@zhixiangyao zhixiangyao commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

In the demo/starter/slides.md file, the click event for the "Open in Editor" button should use @click="$slidev.nav.openInEditor()" instead of @click="$slidev.nav.openInEditor"!

Because the openInEditor method takes an optional URL string parameter. Using @click="$slidev.nav.openInEditor" would end up passing the $event object as the url parameter.

In the end, clicking the button will seem like nothing happens (only the network will fail with /__open-in-editor?file=xxxrequests).

  async function openInEditor(url?: string) {
    if (!__DEV__)
      return false
    if (url == null) {
      const slide = currentSlideRoute.value?.meta?.slide
      if (!slide)
        return false
      url = `${slide.filepath}:${slide.start}`
    }
    await fetch(`/__open-in-editor?file=${encodeURIComponent(url)}`)
    return true
  }

@netlify

netlify Bot commented Mar 20, 2025

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 6d27e1e
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/67dbcf6a14245b00084a5760
😎 Deploy Preview https://deploy-preview-2118--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pkg-pr-new

pkg-pr-new Bot commented Mar 20, 2025

Copy link
Copy Markdown

Open in Stackblitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2118

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2118

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2118

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2118

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2118

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2118

commit: 6d27e1e

@antfu
antfu merged commit da595c1 into slidevjs:main Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants