How do i customize hallo.js to use <strong> instead of <b>?

隐身守侯 提交于 2019-12-23 12:56:05

问题


The question pretty much says it all. Im using hallo.js and it seems to use <b> and <i> for bold and italic. Some of my markup currently requires strong and em in order to have certain CSS rules apply. I also prefer strong and em in general to b and i so Id like to configure this.

There doesnt seem to be any documentation on this directly - can it be done?


回答1:


This can't be done as the markup is not up to hallo.js or any other rich text editor. They just trigger inserting markup, but the inserting is done by the browser. You will get slightly different results from different browsers. A workaround is possible only by changing the markup at the end.

Edit for point to docs on comment question: The problem is that this is behavior of browsers since IE invented design mode without being a standard. The whatwg wrote it in the standard for HTML5. To get more information on the topic itself read
http://www.quirksmode.org/dom/execCommand.html
http://dev.opera.com/articles/view/rich-html-editing-in-the-browser-part-1/
http://www.thismuchiknow.co.uk/?p=64
http://www.whatwg.org/specs/web-apps/2007-10-26/multipage/section-contenteditable.html
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
http://www.w3.org/wiki/Web_Editing_APIs
http://annevankesteren.nl/2005/07/contenteditable
http://www.sitepoint.com/the-tragic-comedy-that-is-rich-text-editing-on-the-web/




回答2:


In case it might help somebody:

I wanted to achieve the same and I've ended up pre-processing the content before saving it. Example of replacing tags for in Python:

content.replace('<b>', '<strong>').replace.('</b>', '</strong>')    

You could use the same technique for any other tags or substrings you might wanna replace.



来源:https://stackoverflow.com/questions/14554002/how-do-i-customize-hallo-js-to-use-strong-instead-of-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!