Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Custom RichTextEditor Fontsizes
Custom RichTextEditor Fontsizes [message #1838114] Tue, 16 February 2021 11:08 Go to next message
Christian Mising name is currently offline Christian Mising nameFriend
Messages: 9
Registered: July 2009
Location: Germany
Junior Member
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 11:56 Go to previous messageGo to next message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 44
Registered: January 2013
Member
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 12:33]

Report message to a moderator

Re: Custom RichTextEditor Fontsizes [message #1838259 is a reply to message #1838243] Fri, 19 February 2021 17:21 Go to previous message
Christian Mising name is currently offline Christian Mising nameFriend
Messages: 9
Registered: July 2009
Location: Germany
Junior Member
Thank you Sebastian, i will try that. This is much better than copying the complete bundle.

Regards Christian
Previous Topic:swt text copy/cut/paste support
Next Topic:Open new window/popup and show custom html with css
Goto Forum:
  


Current Time: Mon Dec 09 07:30:30 GMT 2024

Powered by FUDForum. Page generated in 0.06035 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top