Hi I am trying to make some changes to our implementation of CKEDITOR 3.6.2
by removing all but 2 options in the link target type dropdown that appears in the link dialog's target tab.
I tried to achieve this using the API http://docs.cksource.com/ckeditor_api/s ... ialog.html but I am getting an error in the minified core ckeditor.js file in the dialog() method on this line X=S.lang.dir; where S is the editor.
The .lang property of the editor instance is undefined when doing CKEDITOR.dialog(editor, 'link'), when debugging the "editor" object in IE9 I don't see a lang object anywhere, so I'm not sure why this is missing? I didn't work on our original implementation but as far as I know we have only added 2 plugins not related to the link dialog and not changed the ckeditor core.
Here is my code:
for (var i in CKEDITOR.instances) { var editor = CKEDITOR.instances[i]; var dialogObj = CKEDITOR.dialog(editor, 'link'); var linkDialogTargetField = dialogObj.getContentElement('target', 'linkTargetType'); // API didn't seem to have a more efficient approach than clearing all and re-adding the one we want linkDialogTargetField.clear(); linkDialogTargetField.add('notSet', '<not set>'); linkDialogTargetField.add('_blank', 'New Window (_blank)'); }
Re: Editor object .lang is undefined when using CKEDITOR.dia
As I stated to you in http://stackoverflow.com/questions/9403 ... -undefined the correct approach is the second one.
If you don't like using splice, the just set the contents of targetField['items'] using a new array with your values, but your first code is trying to use APIs that are mostly internal and although you might be able to make them work it will be far more complex than using the second approach that it's the suggested method of altering dialog contents.
Re: Editor object .lang is undefined when using CKEDITOR.dia
Yes but why is it the suggested method ? I have seen the approach on blog posts but I was trying to follow the CKEDITOR API documentation http://docs.cksource.com/ckeditor_api/s ... ialog.html as I have stated... do you have a link to why the second approach is the correct one? and not what the Javascript API actually suggests? Thanks
Re: Editor object .lang is undefined when using CKEDITOR.dia
targetField['items'] = [['<not set>', 'notSet'], ['New Window (_blank)', '_blank']];
The dialogDefinition event seems to occur on the initial load of a dialog box inside each editor object.
I didnt see why this was such a great approach when the other approach has API docs that others would have an easier time to follow in the future.
Which is also a similar approach to how the configuration of the editor I thought is meant to work, i.e.
CKEDITOR.config.removeDialogTabs = 'link:advanced';
which works fine.
Re: Editor object .lang is undefined when using CKEDITOR.dia
Also, you didn't state when are you trying to execute the first code, but if the editor hasn't finished initializing then that could be a reason to get an error with the .lang object, and that's a general rule for other manipulations of CKEditor, you must perform them at the right time.
config.removeDialogTabs is a little syntactic sugar to help with a common situation, but if you look at the samples and docs about how to remove other fields you'll see that they always use the dialogDefinition event