hyperlinktinymceautolink

TinyMCE links aren't including href


Solved!

The initial problem: I'm using TinyMCE for a text editor. Right now, I just have the default plugins applied. It appears that 'autolink' is one of those, as it turned a link into an 'a' tag. The problem I'm having is that it's not giving the 'a' tag an href. I tried applying the 'link' plugin, but it's giving me the same problem. It creates blue, underlined text in the form of an 'a' tag, but omits any kind of href.

How can I get this to work correctly?

I'm running on a Windows computer in Chrome, though I tried it in Microsoft Edge just to see if that did anything and it didn't.

This was my initial configuration, copy-pasted form their website.

<script>tinymce.init({selector: 'textarea'})</script>

This is my most recent configuration. It's formed from a combination of a codepen I found and a few things I've tried.

<script>tinymce.init({ selector: 'textarea', theme: 'modern', plugins: [ 'advlist autolink lists link image charmap print preview hr anchor pagebreak', 'searchreplace wordcount visualblocks visualchars code fullscreen', 'insertdatetime media nonbreaking save table contextmenu directionality', 'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help' ], toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image', toolbar2: 'print preview media | forecolor backcolor emoticons | codesample help', image_advtab: true, templates: [ { title: 'Test template 1', content: 'Test 1' }, { title: 'Test template 2', content: 'Test 2' } ], relative_urls : true, remove_script_host : false });</script>

Solution: I tried a different rich text editor to see if that would help and it was doing the same thing. After a little more digging, I found that express-sanitizer was the culprit.


Solution

  • The problem was that I was sanitizing my hrefs (and probably a bunch of other stuff) out on the server. If you come across this, check your sanitizer.