NoobDev4iPhone
NoobDev4iPhone

Reputation: 5729

TinyMCE appends links to the current URL

I'm running into this weird issue with TinyMCE where selecting a text and adding a link to it without "http://" will cause the new link to append to the current URL.

Example (assume my website is www.example.com):

enter image description here

Now under my settings "click" will link to "www.example.com/linkexample.com". I need it to link to "http://linkexample.com" instead, without manually adding "http://" in the "Url" field in the popup.

I've been trying different solutions online but nothing seemed to work for me.

Here is the list of solutions I've tried so far, none worked for me:

P.S. I'm running the latest TinyMCE 4.1.7

Upvotes: 2

Views: 2489

Answers (3)

nabuage
nabuage

Reputation: 1

I actually replaced this code:

/^\s*www./i.test(e)

with

!(/^\s*(http://|https://)/i.test(e))

Upvotes: -1

EternalHour
EternalHour

Reputation: 8621

In version 4.x this functionality is built in. But unfortunately it's not mentioned in the documentation, it's only documented in the changelog so I would imagine this is widely unknown.

$('textarea').tinymce({
    ...
    link_assume_external_targets: true
    ...
});

enter image description here

Upvotes: 1

Sekai92
Sekai92

Reputation: 72

I'm done to try this one. it's worked for me (tell me if this thing worked for you)

  1. Go to link plugin on tinymce (tinymce/plugins/link)
  2. Edit this file plugin.min.js (tinymce/plugins/link/plugin.min.js)
  3. Find www using Ctrl+F in your editor like Notepad++ or Sublime Text
  4. You will get this code /^\s*www\./i delete www\.
  5. Now your code become /^\s*i
  6. Now Save it. Done
  7. Refresh your code using TinyMCE.
  8. Now try use linkexample.com, You will get notification to add prefix http://

Done. I hope help you out.

Upvotes: 3

Related Questions