I recorded a video of the issue here:
https://jumpshare.com/v/X8UopJZlA0DZaSSMezF9
Am I doing something wrong?
+1 same issue. @jpuri and your demo doesn't work either.
Try this one @kitze, @ZeroCho : https://www.youtube.com/embed/bNU397ZEx5w
@jpuri should be pretty easy to grab the id via regex and convert it to an embed link manually. You don't want a lot of users to try and paste a youtube link and to think that your lib is broken :)
@jpuri
could you please fix this in your demo?

@kitze: embedding link feature works only with embeddable links and normal youtube link is not embeddable. I can go on to parse and fix youtube link but there can be many non-embeddable links and I can not possible support all of them. A possible solution could be to provide a callback property to developers to parse and provide right link to editor.
@ZeroCho: thanks for pointing docs issue just fixed it.
embed.ly can be very useful here to support data extraction for a number of URLs. But its paid :(
I am looking for nice open-source alternate to embedly to fix this issue.
I am planning to provide a callback for developers to extract data from the URL and give back to editor. If the user does not provides the callback the url will be embedded as such in an iframe.
At least for demo I plan to use embed.ly.
@jpuri , I have solved this problem with a very small trick that took me just 1-2 minutes. I have changed addEmbeddedLink function by processing the users' input transforming the Youtube simple links into embedded ones.
addEmbeddedLink: Function = (embeddedLink, height, width): void => {
if (embeddedLink.indexOf("youtube") >= 0){
embeddedLink = embeddedLink.replace("watch?v=","embed/");
embeddedLink = embeddedLink.replace("/watch/", "/embed/");
embeddedLink = embeddedLink.replace("youtu.be/","youtube.com/embed/");
}
......
At least for me it works :smile:
@jpuri How is this feature going on? Any progress? Need help?
Hey, can somebody explain me how to use embeddedlinkparser? Everything i tried doesn't work.
Editor still does not support this @ibrod1983 , I will try to soon add this.
Thank you for your reply. It's really important for me to be able to automatically convert the youtube link, to an embeddable one. I managed to integrate ibudisteanu's code into the addEmbeddedLink function, in the Embedded class.
It worked, but for some reason i was getting various JS errors, with or without this additional code. I have very little experience in editing third party libraries. What i did was: downloaded the full code from this repository; did npm install; removed the "-master" ending from the directory; did npm run build. Did i perhaps miss something? Can u refer me to some guide, that will assist me in editing the code of this library by myself?
Any help will be greatly appreciated :-)
Hey @ibrod1983 :
The steps you have followed above are ok. After build how are you using library in ur project ?
As file system dependency ? That can cause those JS errors.
Try this tool: https://www.npmjs.com/package/yalc
If you can paste error here it will help me judge better.
To be honest, I'm not sure what you mean by "file system dependency". I'm using it, as if it were installed by "npm install". I took the code from github, and copied it to the node_modules directory of my react project. After running the npm install(from the module directory), and running the build, this is what i get in react:
invariant.js:42 Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component'srendermethod, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).
at invariant (invariant.js:42)
at Object.addComponentAsRefTo (ReactOwner.js:68)
at attachRef (ReactRef.js:23)
at Object.ReactRef.attachRefs (ReactRef.js:42)
at ReactDOMComponent.attachRefs (ReactReconciler.js:23)
at CallbackQueue.notifyAll (CallbackQueue.js:76)
at ReactReconcileTransaction.close (ReactReconcileTransaction.js:80)
at ReactReconcileTransaction.closeAll (Transaction.js:209)
at ReactReconcileTransaction.perform (Transaction.js:156)
at batchedMountComponentIntoNode (ReactMount.js:126)
And also:
react-draft-wysiwyg.js:6 Uncaught TypeError: Cannot read property 'focus' of undefined
at react-draft-wysiwyg.js:6
It seems that the editor is working, despite those errors.
Edit: I've used "yalc publish" on a freshly downloaded copy of the repository, then copied it to the node_modules of my React project- and it works fine(no clue why, of course :-)).
The question now is, how would i be able to test changes to the library, without repeating the whole process again and again? Sorry for all the questions, i'm just very new to this..
Error is that now its getting 2 copied of react. Delete node_modules created inside node_modules/react-draft-wysiwyg that should fix this error.
I see...thank you very much
Let me know if you still face any issue.
@jpuri embed link not working with normal URL plz fix
Any updates @jpuri?
I think the most used videos are youtube and vimeo, another videos could be only src that user pasted.
```
const Embed = ({ block, contentState }) => {
const entity = contentState.getEntity(block.getEntityAt(0));
const { src, height, width } = entity.getData();
return ();
};
Not work for me....
Not work for me....
i think you have to change "addEmbeddedLink" to embedCallback
so it should be something like this :
<Editor
toolbar={{
embedded:{
embedCallback: embedVideoCallBack
}
}}
/>
function :
const embedVideoCallBack = (link) =>{
if (link.indexOf("youtube") >= 0){
link = link.replace("watch?v=","embed/");
link = link.replace("/watch/", "/embed/");
link = link.replace("youtu.be/","youtube.com/embed/");
}
return link
}
I need to allow only YouTube URL but embedded only accept URL in return, is there anyway where I can override or something to solve my problem.
_embedded: embedCallBack: This callback is called after user add a url to be embedded, it can be used to do any required modifications to the url. The callback is passed a url and should return url only._
This url helped me to fix my bug : https://github.com/jpuri/react-draft-wysiwyg/blob/master/stories/Embeddable/index.js
Thanks @jpuri
Most helpful comment
@jpuri , I have solved this problem with a very small trick that took me just 1-2 minutes. I have changed addEmbeddedLink function by processing the users' input transforming the Youtube simple links into embedded ones.
At least for me it works :smile: