powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / ckeditor: добавление своего диалога в интсансы
2 сообщений из 2, страница 1 из 1
ckeditor: добавление своего диалога в интсансы
    #38049037
Фотография Antonariy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Сделал свой диалог по образу и подобию официального примера:
Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
var editor = CKEDITOR.replace( 'editor1',
	{ toolbar: [['Source', '-', 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Link', '-', 'MyButton']] }
);
editor.on('pluginsLoaded', function (ev) {
	if (!CKEDITOR.dialog.exists('myDialog')) {
		var href = document.location.href.split('/');
		href.pop();
		href.push('api_dialog', 'my_dialog.js');
		href = href.join('/');
		CKEDITOR.dialog.add('myDialog', href);
	}
	editor.addCommand('myDialogCmd', new CKEDITOR.dialogCommand('myDialog'));
	editor.ui.addButton('MyButton',{
		label: 'My Dialog',
		command: 'myDialogCmd'
	});
});

Все работает, пока редактор статичен и один на странице. Если создать второй редактор, событие pluginsLoaded не срабатывает, что в общем логично, но и кнопка в тулбаре не появляется. Попробовал сделать так (тулбар с кнопкой объявлен в config):
Код: javascript
1.
2.
3.
4.
5.
6.
7.
that.ckeditorGet().on('instanceReady', function (ev) {
    that.ckeditorGet().addCommand('myDialogCmd', new CKEDITOR.dialogCommand('myDialog'));
    that.ckeditorGet().ui.addButton('MyButton', {
        label: 'My Dialog',
        command: 'myDialogCmd'
    });
});

Событие срабатывает, кнопка не появляется.
...
Рейтинг: 0 / 0
ckeditor: добавление своего диалога в интсансы
    #38049119
Фотография Antonariy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Нашел другой способ, все работает:
Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
CKEDITOR.plugins.add('myplugin',{
    init: function (editor) {
        editor.addCommand('mydialog', new CKEDITOR.dialogCommand('mydialog'));
        editor.ui.addButton('MyButton', {
            label: 'My Dialog',
            command: 'mydialog'
        });

        CKEDITOR.dialog.add('mydialog', function (api) {
            // CKEDITOR.dialog.definition
            var dialogDefinition =
            {
                title: 'Sample dialog',
                minWidth: 390,
                minHeight: 130,
                contents: [
                    {
                        id: 'tab1',
                        label: 'Label',
                        title: 'Title',
                        expand: true,
                        padding: 0,
                        elements:
                        [
                            {
                                type: 'html',
                                html: '<p>This is some sample HTML content.</p>'
                            },
                            {
                                type: 'textarea',
                                id: 'textareaId',
                                rows: 4,
                                cols: 40
                            }
                        ]
                    }
                ],
                buttons: [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
                onOk: function () {
                    // "this" is now a CKEDITOR.dialog object.
                    // Accessing dialog elements:
                    var textareaObj = this.getContentElement('tab1', 'textareaId');
                    alert("You have entered: " + textareaObj.getValue());
                }
            };

            return dialogDefinition;
        });
    }
});
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / ckeditor: добавление своего диалога в интсансы
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]