jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.41k stars 1.16k forks source link

All the links created in the editor open in the same tab #1144

Open arjungithub1199 opened 3 years ago

arjungithub1199 commented 3 years ago

When there are multiple links created in the editor, all the tabs gets opened in the same tab. The first link always open a new browser window, but the subsequent link will replace the first window and open up there. This behavior is even after setting defaultTargetOption: "_blank".

The issue can be replicated in the demo section by creating 2 links - https://jpuri.github.io/react-draft-wysiwyg/#/demo

Below is the piece of code I used to create the editor

  <Editor
    editorState={state}
    wrapperClassName="demo-wrapper"
    editorClassName="demo-editor"
    onEditorStateChange={onEditorStateChange}
    toolbar={{
      link: { defaultTargetOption: "_blank" }
    }}
    wrapperStyle={classes.wrapperStyle}
    toolbarStyle={classes.toolbarStyle}
    editorStyle={classes.editorStyle}
  />
rssilvaba commented 3 years ago

I have the exact same issue, wondering how I can just force it to _blank or any way to get around this problem.

rssilvaba commented 3 years ago

Ok, in my case I was using DOMPurify and that was causing the issue. Otherwise the option works fine.

kkieffer commented 2 years ago

Add this where you are using DOMPurify: DOMPurify.setConfig({ ADD_ATTR: ['target'] }); //allow "open in new window" html link targets

chandher58 commented 1 year ago

Add this where you are using DOMPurify: DOMPurify.setConfig({ ADD_ATTR: ['target'] }); //allow "open in new window" html link targets

Where do I have to add this line?