S
S
SlimSavernake2017-11-25 17:12:28
Mobile development
SlimSavernake, 2017-11-25 17:12:28

How to create a second dialog in creditor when clicking OK on the first window?

When I click on a button on the button bar, I want to open a dialog box, enter the information I need there, and when I click OK, open a new dialog box. The second window does not open for me. Tell me how to do it right?
plugin.js

CKEDITOR.plugins.add( 'gallery', {
        icons: 'simplebox',
        init: function( editor ) {
            editor.addCommand('gallery', new CKEDITOR.dialogCommand('galleryDialog'));

            editor.ui.addButton('Gallery', {
                label: 'Insert gallery',
                command: 'gallery',
                toolbar: 'insert',
                icon: this.path + 'images/image.png'
            });

            CKEDITOR.dialog.add( 'galleryDialog', this.path + 'dialogs/gallery.js' );
        }
    } );

dialogs/gallery.js
CKEDITOR.dialog.add( 'galleryDialog', function( editor ) {
    return {
        title: 'Edit Simple Box',
        minWidth: 200,
        minHeight: 100,
        contents: [
            {
                id: 'info',
                elements: [
                    {
                        id: 'align',
                        type: 'html',
                        html: '<div id="myDiv">Sample <b>text</b>.</div><div id="otherId">Another div.</div>',
                        commit: function( widget ) {
                            console.log(1);
                        }
                    },

                ]
            }
        ],
        onOk: function(ee) {

// ТУТ Я ПЫТАЮСЬ СОЗДАТЬ ВТОРОЕ ДИАЛОГОВОЕ ОКНО

            CKEDITOR.dialog.add( 'mydialog', function( editor) {
                // CKEDITOR.dialog.definition

                return {
                    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() );
                    }
                };
            } );


// ТУТ Я ПЫТАЮСЬ ЗАПУСТИТЬ СОЗДАННОЕ ДИАЛОГОВОЕ ОКНО
            CKEDITOR.instances.editor1.openDialog( 'mydialog' );
        }
    };
} );

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Gornostaev, 2019-09-08
@KosteaQ1

What phone do you have in your pocket now, start with that.

S
SEOD, 2019-09-08
@SEOVirus

You need to start 100% with an idea of ​​what you are going to do and how you will promote it. If you do something, and 1000 people download you in half a year, I don’t think that you will still have the desire to continue :)

N
Northwood_FX, 2019-09-12
@Hilandar

Get started on both platforms with Flutter:

K
Karen Ananiev, 2017-11-27
@SlimSavernake

First of all, move the addition of the dialog from the dialog file to the init() function in the plugin file - you don't need to add the dialog every time. Next - replace CKEDITOR.instances.editor1.openDialog( 'mydialog' ) with just editor.openDialog( 'mydialog' ) - the editor instance is passed to the dialog initialization function, you don't need to get it this way. And finally - return false from the onOK() function - this will prevent the first dialog from closing and allow the second one to open. Then you will need to close the first dialog with your hands - in the instance of the second dialog there will be a link to it - dialog._.parentDialog.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question