How add CSS to RichTextEditor ? [message #1772912] |
Mon, 18 September 2017 16:10 |
|
Hi,
I try to add a css file or attributes to the CKEditor using the 'org.eclipse.nebula.widgets.richtext' plugin by two ways :
1. executeJavascript("CKEDITOR.config.addContentsCss=CKEDITOR.getUrl(\"resources/contents.css\")": My css file is included in my plugin and i tried some possible urls ('platform:/plugin....', full link 'C:/....') but nothing works
2. executeJavascript("CKEDITOR.addCss='p{margin:0;}')": Nothing works too
What am i doing wrong about this approach ?
Thanks in advance for your reply.
Regards,
Nicolas.
|
|
|
|
Re: How add CSS to RichTextEditor ? [message #1772955 is a reply to message #1772914] |
Tue, 19 September 2017 12:28 |
|
Hi Dirk,
Just to notice, i found a solution for my problem.
The file referenced by the CKEditor config contents css will have the javascript format, so it will have the following format : 'file:///...'
The following code is used to get the file from the bundle:
final URL cssURL = GenericRichTextEditor.class.getResource("resources/contents.css"); //$NON-NLS-1$
final Bundle bundle = FrameworkUtil.getBundle(GenericRichTextEditor.class);
if (bundle != null) {
try {
cssURL = FileLocator.toFileURL(cssURL);
} catch (IOException e) {
e.printStackTrace();
}
}
And i used it for the CKEditor as following :
executeJavascript('CKEDITOR.config.contentsCss=CKEDITOR.getUrl(\"" + cssURL.toString().replace("file:/", "file:///") + "\");");
Thanks for your reply and your idea.
Nicolas F.
|
|
|
Powered by
FUDForum. Page generated in 5.02840 seconds