开发者

TinyMCE do not auto convert a URL into a link on Paste

开发者 https://www.devze.com 2023-03-21 00:14 出处:网络
When I paste a URL into a TinyMCE editor it converts the text into alink. So http://vime开发者_StackOverflow中文版o.com/18150336 would be come <a href=\"http://vimeo.com/18150336\">http://vimeo

When I paste a URL into a TinyMCE editor it converts the text into a link.

So http://vime开发者_StackOverflow中文版o.com/18150336 would be come <a href="http://vimeo.com/18150336">http://vimeo.com/18150336</a>. I would like to keep the plain text. Is their a way to configure TinyMCE to keep the link as plain text.

I do not want to strip out tags as adding a hyperlinks should be an option on the toolbar. It should just not happen by default.


You can use the paste plugin and the setting paste_preprocessing in order to keep the plain text. You might need to check inside the function specified using paste_preprocessing if you got a link or not.


It's been 5 years, So I'm probably using a newer version of TinyMCE, anyway this solution worked for me, Just add this option:

paste_preprocess: function(plugin, args) {
    args.content += ' ';
}

So when you initialize the tinymce, it should be something like this:

tinymce.init({
  selector: "textarea",  // change this value according to your HTML
  plugins: "paste",
  paste_preprocess: function(plugin, args) {
    args.content += ' ';
  }
});

This is the page of documentation for TinyMCE V4


It is the TinyMCE plugin autolink which is responsible for automatically creating links on paste. (And write).

https://www.tiny.cloud/docs/plugins/opensource/autolink/

0

精彩评论

暂无评论...
验证码 换一张
取 消