we wish to use the RichTextArea (Or if another component is better suited… tell) to allow
the users to add some formatting into long text areas.
The problem with the component is, that it is too powerfull
In fact we would like to allow the endusers to only use the following features:
Bold
Italic
Bullet list
Numbered list
The reason for restricting it, is that 1. we also need to export these text parts into PDF and XLS files
and 2. we must prevent having some mixed fonts/sizes in the text.
No supported way to disable specific formatting options exists, but you can hide individual buttons using CSS and attribute selectors. The only real problem with that is that attribute selectors are not supported in IE6, so if you need to support it, there’s no workaround I can think of, other than forking your own component/widget.
If you do end up using attribute selectors, be sure to filter any formatting on the server side as well, since the rich text area allows any HTML to be pasted inside it, and some keyboard shortcuts work also (e.g. CTRL+B for bold).
div[title="Toggle Underline"]
{
display: none;
}
You can check all the title values with Firebug and similar.
You can hide the second row selects easily with the following CSS:
…it seems to have about zero documentation, though, so good luck
(afaik you’ll have to check the TinyMCE docs to see what’s supported and use setConfig(() to configure)
So the html cleanup is still to be done.
Do you know how the component behaves with copy/paste from MS Office applications ?
They usually past a lot of garbage in rich text editors…
For your suggestion to hide the bottom row of the toolbar of a RichTextArea, you advised using the following in the css:
.gwt-RichTextToolbar-bottom { display: none;}
It works great. Of course, this applies to all RichTextArea’s in my app.
However, I have two RichTextArea’s in my app, and I would like to hide the bottom row of the toolbar in only one of them. How can I do that? Please advise.
I tried it out, and it works beautifully. Thank you very much.
Could you comment on an earlier post of mine under the same thread regarding the use of attribute selector to hide a botton on the toolbar of RichTextArea.
Note : as Jouni pointed out, this will not work in IE6, as it does not support Attribute Selectors.
The reason that the example that Jouni posted did not work is that there is a more specific CSS selector in the Reindeer theme that overrides the display and size of the buttons.
If you want/need to do anything more than trivial CSS manipulations with Vaadin, I would suggest it’s almost vital! I don’t use Firefox normally, and our application has to target IE, yet I use FireFox+Firebug to debug/investigate/tweak styesheets all the time. You’ll also need to get your head around CSS selectors - and I’m afraid there’s no avoiding that.