Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14715 closed Bug (invalid)

change default text color

Reported by: Alexandre Tiertant Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

Steps to reproduce

adding this to config

config.colorButton_foreStyle: {
  element: 'font',
  attributes: { 'color': '#FF0000' }
}

Expected result

i would like to change default text color as said in doc:

https://github.com/ckeditor/ckeditor-docs/tree/master/guides/dev/features/colorbutton#custom-color-style-definition

is there a way to change de default text color via the api?

Actual result

do nothing

Other details (browser, OS, CKEditor version, installed plugins)

Change History (5)

comment:1 Changed 10 years ago by Jakub Ś

Resolution: invalid
Status: newclosed
Version: 4.5.10 (GitHub - master)

You need to set default color it in contents.css

comment:2 Changed 10 years ago by Alexandre Tiertant

this only change the color in the editor, not in the html content produced...

comment:3 Changed 10 years ago by Jakub Ś

Your target page (where content lands) needs to have same styles as used in the editor. After all you are creating content for particular page so styles should match.

comment:4 Changed 10 years ago by Alexandre Tiertant

well i'm not using editor to write web site page content... editor is for html that's true but html isn't used only in web content... i would like to set per user default color this is why i would like to change color by default via api. i googled "ckeditor change default text color" and i was not the only one looking at this but noone found a real solution...

comment:5 Changed 10 years ago by Jakub Ś

You can try below:

			CKEDITOR.addCss('.myItalic {font-style: italic;}');			
			var editor = CKEDITOR.replace( 'editor1', {					
				extraAllowedContent : 'p{color}',
				on: {
					pluginsLoaded: function( evt ) {
						evt.editor.dataProcessor.dataFilter.addRules( {
							elements: {
								p: function( el ) {									
										el.attributes['style'] = 'color:#ccc';
								}
							}
						} );
					}
				}
			});

The #ccc can be dynamic. You can read some color value from request and assign it to some JavaScript property in your name space or existing one.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy