question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linkify plugin - Link is disabled inside editor

See original GitHub issue

I guess Link is disabled (not working when clicked) inside editor by default in Draft.js. But how to make it clickable using linkify plugin? I think we can add something like this in the anchor tag:

 `<a onClick={onClick} href={link}>`

where onClick event will redirect to the url location. I’ve edited the index.js file in Link folder with something like this:

var openWindow = function(){
    window.open(href, target);
  };
  return _react2.default.createElement('a', _extends({}, props, {
    href: href,
    className: combinedClassName,
    target: target,
    onClick: openWindow
  }));

One more thing, Should I use the saved raw content to display in editor as rich text content?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
laszlokiralycommented, May 7, 2017

i make the link clickable in the editor with

const linkifyPlugin = createLinkifyPlugin({
  component: (props) => {
    const { contentState, ...rest } = props;
    return (
    <a {...rest} onClick={() => {
      window.open(rest.href, "_blank");
    }}
    />);
  }
});

and i remove contentState because of #398

6reactions
oliverwcommented, Dec 21, 2016

@nikgraf I have a similar problem as the original poster. You wrote:

The idea is that in edit mode you don’t follow links. In read mode the links work. Twitter, Slack & Facebook have the same behaviour. Does that make sense?

Still I’m curious about your use-case. Why would you want that?

My use-case is that the editor is always in edit mode (think Evernote for example). I would like to enable the user to Ctrl+Click a link to open it. Could you recommend a strategy to implement this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the draft-js-linkify-plugin function in draft-js ... - Snyk
To help you get started, we've selected a few draft-js-linkify-plugin examples, ... import Editor from 'draft-js-plugins-editor'; // eslint-disable-line ...
Read more >
Enable left click in edit mode for linkify plugin for draftjs
I was trying draft-js-linkify-plugin for creating a simple rich text editor. I have a requirement that link should be clickable while I am ......
Read more >
Linkify - DraftJS Plugins - High quality plugins with great UX
It is important to import the Editor which accepts plugins. import Editor from ... In this case, only the linkifyPlugin // is passed...
Read more >
How I disable a “Link” function on the editor? - WordPress.org
wpDiscuz allows you to hide/show certain text formatting buttons of the comment rich editor. Just click on the corresponding buttons to disable or...
Read more >
User and Workspace Settings - Visual Studio Code
Workbench: Color Customizations setting with Edit in settings.json link ... off: The editor will never be optimized for usage with a Screen Reader....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found