0

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
  • 7,361
  • 8
  • 46
  • 65

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
  • 5,348
  • 1
  • 36
  • 46
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,840
  • 21
  • 23
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

Fred Randall
  • 7,544
  • 21
  • 83
  • 184