Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addYouTubeVideo.isEnabled() throws error #768

Closed
ronnyroeller opened this issue Nov 6, 2020 · 1 comment · Fixed by #769
Closed

addYouTubeVideo.isEnabled() throws error #768

ronnyroeller opened this issue Nov 6, 2020 · 1 comment · Fixed by #769
Labels
status: confirmed 🟢 The bug has been tested and confirmed. type: bug 🪲 Something isn't working

Comments

@ronnyroeller
Copy link
Collaborator

Summary

I want to check if the editor should offer to insert a youtube video. For this, I call commands.addYouTubeVideo.isEnabled(). Doing so, throws this errors:

TypeError: Cannot read property 'video' of undefined
    at createYouTubeUrl (https://qmuwc.csb.app/node_modules/@remirror/preset-embed/dist/preset-embed.browser.esm.js:162:25)
    at IframeExtension.eval [as addYouTubeVideo] (https://qmuwc.csb.app/node_modules/@remirror/preset-embed/dist/preset-embed.browser.esm.js:52:14)
    at addYouTubeVideo (https://qmuwc.csb.app/node_modules/@remirror/preset-embed/dist/preset-embed.browser.esm.js:139:42)
    at Function.eval [as isEnabled] (https://qmuwc.csb.app/node_modules/@remirror/core/dist/core.browser.esm.js:1406:14)

Steps to reproduce

  1. Open reproduction case on codesandbox: https://codesandbox.io/s/focused-hawking-qmuwc?file=/src/App.js:385-410
  2. Check console for error

Expected results

isEnabled() returns boolean.

Actual results

Throws error

@ronnyroeller ronnyroeller added the type: bug 🪲 Something isn't working label Nov 6, 2020
@ifiokjr ifiokjr added the status: confirmed 🟢 The bug has been tested and confirmed. label Nov 6, 2020
@ifiokjr
Copy link
Member

ifiokjr commented Nov 6, 2020

Interestingly, this issue raises a much-needed enhancement.

The reason this is failing is that the addYoutubeVideo command expected an object with the video property. There are two ways of dealing with this. Either require the same arguments for the isEnabled function as the actual command, or, make sure the function can handle isEnabled without requiring access to the first parameter.

Either way, I'll need to improve the types that are generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed 🟢 The bug has been tested and confirmed. type: bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants