yui3 html属性,YUI Rich Editor + invalidHTML + style
問題
I am trying to insert an inline style tag into the editor content. When I call saveHTML it strips out the style block when I'm in rich editor view. I have tried changing the style property of invalidHTML to false, but it still seems to strip the style block out.
Any pointers to the API or suggestions would be helpful at this stage!
Thanks,
Col.
回答1:
I hope I understand your question properly. You just want to be able to insert something like this in your textarea?
.className { font-weight: bold;}
If so this is how I have it working using what is specified in the YUI API documentation. In particular this part on invalidHTML
Before I initialize the editor I specify all the invalid tags I want stripped out:
var invalidTags = {"abbr":{ "keepContents":true },
"acronym":{ "keepContents":true }, "address":{ "keepContents":true },
"applet":"", "area":"", "base":"", "basefont":"", "bdo":"", "big":"",
"blockquote":{ "keepContents":true }, "body":{ "keepContents":true }}
Mine's a rather long list (basically all html tags) as I exclude everything except p, style, br, ul, ol, li. So in your case you'd leave out the style tag.
Then I set up the editor and then pass in the invalidTags as the invalidHTML for the editor before rendering.
So this is what everything looks like after all is said and done.
var invalidTags = {"abbr":{ "keepContents":true },
"acronym":{ "keepContents":true }, "address":{ "keepContents":true },
"applet":"", "area":"", "base":"", "basefont":"", "bdo":"", "big":"",
"blockquote":{ "keepContents":true }, "body":{ "keepContents":true }}
var editor = new YAHOO.widget.Editor('myeditor', {
height: '300px',
width: '500px',
dompath: true,
filterWord: true
}
editor.invalidHTML = invalidTags;
editor.render();
YAHOO.util.Event.on('Update', 'click', function() {
editor.saveHTML();
}
So that's that for how I get it to preserve the tags I want. eg. style.
Hope that helps you out.
來源:https://stackoverflow.com/questions/1303999/yui-rich-editor-invalidhtml-style
總結
以上是生活随笔為你收集整理的yui3 html属性,YUI Rich Editor + invalidHTML + style的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python转cpp_python转c工
- 下一篇: java list 占用内存不释放_性能