When i want to insert a table with ckeditor he set the table width to 200px. I have to change it to 100% for every table. Is there a way to set the config for 100% as standard?
It's impossible to provide config values to set the default values for all the fields in all the dialogs. Instead, you must use the api as explained in the sample to get the field object and then change it's "default" property as I stated.
Sample to set default width to 80% and cell padding to 4.
// Set defaults for tables
CKEDITOR.on('dialogDefinition',function( ev ){// Take the dialog name and its definition from the event// data.var dialogName = ev.data.name;var dialogDefinition = ev.data.definition;// Check if the definition is from the dialog we're// interested on (the "Table" dialog).if( dialogName =='table'){// Get a reference to the "Table Info" tab.var infoTab = dialogDefinition.getContents('info');
txtWidth = infoTab.get('txtWidth');
txtWidth['default']=80;
cmbWidthType = infoTab.get('cmbWidthType');
cmbWidthType['default']='percents';
txtCellPad = infoTab.get('txtCellPad');
txtCellPad['default']=4;}});
Until recently we were using the same basic configuration shown here to set table defaults. When we migrated to CKEditor 3.6.3 , though, the table popup failed to launch. When the table icon is clicked, the editing window goes grey, but the interface fails to launch and the browser window has to be closed to continue.
This statement in the tableDialog.js file: cmbWidthType['default'] = 'percents';
...worked with the previous CKEditor version, but with 3.6.3 it's flagged by Firebug with this error message: cmbWidthType is null
I've replaced the problem statement with this cmbWidthType['default'] = '%'; ...and though the table interface launches successfully, the default table width is NOT 100%, but rather set at 500pixel width (apparently a value pulled from somewhere else.) Firebug also echos the same error message, i.e. "cmbWidthType is null" with default = '%'
What is the correct syntax for setting default table width to 100% for CKEditor 3.6.3?
Create a folder called my_plugin, inside it create a file plugin.js with the contents:
// Remove default value in table dialog for width (which is 500 by default).
CKEDITOR.plugins.add('my_plugin',{});
CKEDITOR.on('dialogDefinition',function( ev ){// Take the dialog name and its definition from the event data.var dialogName = ev.data.name;var dialogDefinition = ev.data.definition;// Check if the definition is from the dialog we're// interested on (the "Table" dialog).if( dialogName =='table'){// Get a reference to the "Table Info" tab.var infoTab = dialogDefinition.getContents('info');
txtWidth = infoTab.get('txtWidth');
txtWidth['default']='';}});
I used it in Drupal so I don't know how to add the plugin in normal ckeditor. But it worked! :)
Re: How to set standard table width to 100%?
No one can help me?
Re: How to set standard table width to 100%?
Look at the DialogApi sample.
Re: How to set standard table width to 100%?
Thx, but i dint found there a sample.
Isnt there a simple config value?
Re: How to set standard table width to 100%?
Re: How to set standard table width to 100%?
Re: How to set standard table width to 100%?
This statement in the tableDialog.js file:
cmbWidthType['default'] = 'percents';
...worked with the previous CKEditor version, but with 3.6.3 it's flagged by Firebug with this error message: cmbWidthType is null
I've replaced the problem statement with this
cmbWidthType['default'] = '%';
...and though the table interface launches successfully, the default table width is NOT 100%, but rather set at 500pixel width (apparently a value pulled from somewhere else.) Firebug also echos the same error message, i.e. "cmbWidthType is null" with default = '%'
What is the correct syntax for setting default table width to 100% for CKEditor 3.6.3?
In CKEditor 4.1.1, I found
In CKEditor 4.1.1, I found the setting in plugins/table/dialogs/table.js, look for:
... or perhaps just:
(Depending on what value it is currently set to).
And change the value to either a percentage within quotes, or number of pixels without quotes:
Or (for pixel width):
Thak you many many, eddier!
One could make this into a plugin:
Create a folder called my_plugin, inside it create a file plugin.js with the contents:
I used it in Drupal so I don't know how to add the plugin in normal ckeditor. But it worked! :)