简体   繁体   English

TinyMCE getContent提供编码的URL

[英]TinyMCE getContent giving encoded URLs

I have a page with a TinyMCE textarea for taking some input. 我有一个包含TinyMCE textarea的页面,可以进行一些输入。 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. 请帮助。

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 您可以查看TinyMce配置

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. 更新 :事实证明,根据entity_encoding配置 ,不可能将<>&'和“保留为原始。因此,我看到的方式是使用replace来获取这些原始实体。

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. 如果该URL是<a>标记的href属性,则不会进行HTML编码。

Did you try this plugin? 你尝试过这个插件吗? Seems like a good fit. 似乎很合适。

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

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; 基本上删除替换字符串的某些字符,或者在这种情况下,是您的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(); 然后使用.getContent(); to grab clean URL. 获取干净的URL。

Also check out encodeURIComponent() Function 还要签出encodeURIComponent()函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM