kadikraman / draftjs-md-converter

Converts content from Draft.js blocks to Markdown and vice versa.
https://kadikraman.github.io/draftjs-md-converter/
MIT License
145 stars 37 forks source link

Added video #30

Closed noamalffasy closed 6 years ago

noamalffasy commented 6 years ago

It uses draft-js-video-plugin for the video type and the markdown is based on remark-shortcodes

kadikraman commented 6 years ago

Hi @noamalffasy - thanks for the PR! Looks like your editor has prettier auto-formatting or something of the like turned on, so it's converted all the single quotes to double quotes, which violates the repo's eslint rules (and thus makes the CI fail).

Could you please revert the quotes back to single quotes so I could review the PR? Thanks!

noamalffasy commented 6 years ago

Hey, sorry about that. I fixed it

kadikraman commented 6 years ago

I've just added prettier to the project so we would have consistent formatting in the future, but merging master into this PR broke the build. All the tests still past, the build is failing at the eslint step, so I'm going to merge this now and fix the linting myself.

kadikraman commented 6 years ago

@noamalffasy published as v1.0.0 (there aren't any breaking changes, I just thought it's about time for a major version release so could do semver properly 😊)

noamalffasy commented 6 years ago

Awesome!

omryr commented 5 years ago

how does this work? if i use embbed video it should be able to work in my markdown? or do i need to add anything?

noamalffasy commented 5 years ago

@omryr I used a draftjs editor that supports plugins (draft-js-plugins-editor) and added draft-js-video-plugin to the plugins. Videos that are added using the plugin (videoPlugin.addVideo(editorState, { src: "https://www.youtube.com/embed/dQw4w9WgXcQ"})) will be formatted properly using this converter to markdown.

omryr commented 5 years ago

@noamalffasy so i dont need to add the plugins myself? or do i need to add them? and thanks for the help

noamalffasy commented 5 years ago

You do need to add the plugins (use this guide to understand how). The converter will convert the video from the editorState JSON format to markdown.

omryr commented 5 years ago

aw i see so i must change the main editor as well, ok thanks for the help, btw did you maybe encounter an issue with cors? "Cross-Origin Read Blocking (CORB) blocked cross-origin response" getting this when trying to load the youtube video

noamalffasy commented 5 years ago

I don't remember getting CORB, did you add the https://www.youtube.com/embed/[ID] url or https://www.youtube.com/watch?v=[ID]?

omryr commented 5 years ago

i added the url like this 'https://www.youtube.com/embed/3Wf29RiKp70'

noamalffasy commented 5 years ago

Does the CORB block the video or another resource?

omryr commented 5 years ago

seems like its the video "Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.youtube.com/embed/u7qkJ6xvJDg with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details."

noamalffasy commented 5 years ago

Try to add type="text/html" to the iframe manually and ?origin=[your domain] to the url and check if it still produces this error. I was unable to reproduce the error but I think that can help you.

omryr commented 5 years ago

in your example btw i dont see any usage of markdown right? because im trying to add the video to a markdown editor

noamalffasy commented 5 years ago

The guide I sent isn't related to markdown, it's only for implementing the video plugin in the editor

omryr commented 5 years ago

I see, so this is what i have already built in, inside the library I am using react-draft-wysiwyg, did you ever use it with markdown?

noamalffasy commented 5 years ago

I haven't used react-draft-wysiwyg and it doesn't seem like it supports plugins so you won't be able to use it with the video plugin. I have used the draft-js-plugins-editor and using plugins I made it a WYSIWYG editor. By using draftjs-md-converter I converted it to markdown and stored on the DB (it's weighs less than the editorState of draft.js), in the preview it converts it from markdown to html.