Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » How add CSS to RichTextEditor ?
How add CSS to RichTextEditor ? [message #1772912] Mon, 18 September 2017 16:10 Go to next message
Nicolas FAUVERGUE is currently offline Nicolas FAUVERGUEFriend
Messages: 13
Registered: February 2014
Junior Member
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 #1772914 is a reply to message #1772912] Mon, 18 September 2017 16:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
I suppose the problem is that the html page which is included in the richtext bundle does not see the CSS file in your bundle. To be honest, I am not sure if setting a CSS file is possible anyhow. We needed to use bundleshape dir to make the CSS and Javascript references work.
Re: How add CSS to RichTextEditor ? [message #1772955 is a reply to message #1772914] Tue, 19 September 2017 12:28 Go to previous message
Nicolas FAUVERGUE is currently offline Nicolas FAUVERGUEFriend
Messages: 13
Registered: February 2014
Junior Member
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.
Previous Topic:How to increase height of GridColumnGroup Header in nebula Grid
Next Topic:Resizable DropDown Box in NatCombo
Goto Forum:
  


Current Time: Fri Nov 16 19:57:42 GMT 2018

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

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

Back to the top