Custom RichTextEditor Fontsizes [message #1838114] |
Tue, 16 February 2021 06:08  |
Eclipse User |
|
|
|
Hi,
I am looking for a way to change the font sizes the RichTextEditor provide with its toolbar.
I have tried the setting the sizes with the RichTextEditorConfiguration#setOption(String, Object) methode, but there was no change.
Can anybody give me some hint?
Thanks in advance,
Christian
|
|
|
Re: Custom RichTextEditor Fontsizes [message #1838243 is a reply to message #1838114] |
Fri, 19 February 2021 06:56   |
Eclipse User |
|
|
|
Hi,
I think RichTextEditor (3.15.0) does not support setting the proposed font sizes via RichTextEditorConfiguration. Only the options toolbarGroups, removeButtons, toobarCanCollapse, toolbarStartupExpanded, language, defaultlanguage are supported (as far as I can see in the code).
However, as stated in the ckeditor documentation [1], a custom configuration file is one recommended method of setting CKEditor 4 configuration. So what you can do is to
1. register a custom config file as static resource ([2]) with your application (I have copied the config.js that comes with the org.eclipse.rap.nebula.widgets.richtext bundle and changed the config.fontSize_sizes option).
2. set the ckeditor's customConfig option in your entry point:
@Override
protected void createContents(final Composite parent) {
final JavaScriptExecutor executor = RWT.getClient().getService( JavaScriptExecutor.class ); //alternatively, include code as js file and use ClientFileLoader.requireJs
String code = "CKEDITOR.config.customConfig = 'ckeditor_custom_config.js';"; //assuming you created the file in the directory 'resources/ckeditor/' which is the editor's base directory
executor.execute(code);
RichTextEditor editor = new RichTextEditor(parent);
GridDataFactory.fillDefaults().grab(true, true).applyTo(editor);
}
This also enables you to configure all other aspects of the ckeditor.
Downside of this approach is that future support for specific ckeditor config options (defined in your config file) cannot be guaranteed anymore by using the RAP widget (ckeditor version used by the RichTextEditor might change in upcoming releases). Thus, you should check the included ckeditor's version when you update the org.eclipse.rap.nebula.widgets.richtext bundle in your application.
In general, accessing the internally used libraries directly should always be carefully considered. In this case one might say it is okay since we use the officially recommended way to configure the editor.
Regards,
Sebastian
[1] https://ckeditor.com/docs/ckeditor4/latest/guide/dev_configuration.html
[2] https://www.eclipse.org/rap/developers-guide/devguide.php?topic=resources.html&version=3.15
[Updated on: Fri, 19 February 2021 07:33] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04534 seconds