Link to text input fields in CKEditor dialogs

I have been playing with this for a couple of weeks without success ...

In the CKEditor dialog box, text input fields are renamed with a unique number - for example. id: 'txtUrl' will become something like id = '27_textinput'.

How to do it?

// I feel it should be something like:

var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');

// or maybe:

var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');

// and then:

myfield.value = 'myvalue';

But that will not work. Please help! Thanks in advance, R

+3
source share
5 answers

This was the final decision:

var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;
+6
source

inside the exchange part of the element I'm now using

dialog = this.getDialog();  
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);  

and as a result it gives "cke_117_select". (This is selectbox)

alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);  

gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.

+3

You have a page containing CKEditor 3, and a dialog box appears. You open another popup from this dialog, which is a JSP page. To set a value for a field in the dialog box of the parent CKEditor window, do the following:

window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');

This applies to CKEditor 3.

+2
source

Take a look at the sample api dialog:

    // Get a reference to the "Link Info" tab.
    var infoTab = dialogDefinition.getContents( 'info' );

    // Set the default value for the URL field.
    var urlField = infoTab.get( 'url' );
    urlField['default'] = 'www.example.com';
0
source

will arrive

var ckValue = CKEDITOR.instances['txtUrl'].getData();

and install

CKEDITOR.instances['txtUrl'].setData(ckValue);
-1
source

Source: https://habr.com/ru/post/1745566/


All Articles