1

I have a page with a TinyMCE textarea for taking some input. When a user types in a content like

#WorldCupRio http://www.ball.com/us/experience?story=hello&city=panama

and i do a

jTextarea.tinymce().getContent()

on it, i get a content like

#WorldCupRio http://www.ball.com/us/experience?story=hello&city=panama

the & is encoded to

&

How can i avoid this encoding with & or any other special character? Pls help.

ghostCoder
  • 1
  • 9
  • 49
  • 72

3 Answers3

1

This should actually be set up during the init phase of the editor.

tinyMCE.init({
     entity_encoding: "raw",
     editor_selector: "tinyMCE",
     relative_urls : false,
     convert_urls : false
    // other config ...
}

You can check out TinyMce configuration

UPDATE: it turns out that according to entity_encoding config, it is not possible to leave < > & ' and " as raw. Hence, the way I see it is to use replace to get back these raw entities.

Niket Pathak
  • 6,323
  • 1
  • 39
  • 51
0

Actually the editor does the right thing.

If the URL would have been the href attribute of an <a> tag, it would not be HTML encoded.

Did you try this plugin? Seems like a good fit.

https://www.tinymce.com/docs/plugins/autolink/

Tudor Ilisoi
  • 2,934
  • 23
  • 25
0

Try:

   tinymce.init({
       entity_encoding : "raw"
    });

Or if your still having issues, you could try something like; basically removing or replacing certain characters of a string, or in this case, your URL; which you could first grab and then sanitize with something like below..

cleanURI = crappyURI.replace(&amp;, ''); // find unwanted characters and then remove

then use .getContent(); to grab clean URL.

Also check out encodeURIComponent() Function

Dr Upvote
  • 8,023
  • 24
  • 91
  • 204