开发者

"Constrained" HTML textarea/WYSIWYG editor?

I am looking for a web-based JavaScript <textarea> editor with support for standard features like selectable font, text colour, paragraph alignment etc. However, there is one considerable constraint: Formatting should always apply to all the text, not parts of the text. That is, the user is able to colour all of his text red, or all of his text blue, but he shouldn't be allowed to mix and match.

None of the editors I've looked at so far explicitly supported this feature, short of hacking it into th开发者_开发问答e editor. Is any editor out there able to do this out of the box, or with small amounts of configuration?

Thanks a lot for any hints!


This should be doable by taking any WYSIWYG editor, removing all text formatting capabilities and controlling the document's style by manipulating the body element's CSS:

my_wysiwyg_editor.document.body.style.fontSize = "15px";
my_wysiwyg_editor.document.body.style.color = "blue";

Here's how to access the WYSIWYG document in CKEditor (the top rated answer is the correct one IIRC, I can't accept it because it was an expired bounty.)

I'm not promising it will work out for you, though, and there will be quirks - the editors tend to add their own stuff to the HTML (e.g. wrap paragraphs into <p> tags and such) which could make life hard.

If you wouldn't need some of the WYSIWYG capabilities, I'd suggest a normal textarea - you can influence that in font size, colour etc. easily and it's way simpler than a full-blown WYSIWYG solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜