0

I'm new to CKEditor development. I have written a plugin to insert custom tag element ( pre ) and update its attributes.

I want to open the plugin dialog( dialog name is snippet ) once user clicks the pre tag element, And i want to fill the textarea with clicked element innerHTML in dialog.

I have two questions.

  1. How to invoke the plugin dialog dynamically?

  2. How to access the elements inside the dialog?

Kirubachari
  • 688
  • 11
  • 27

1 Answers1

1

Enjoy the official plugin development tutorial – there you'll find all the answers. You'll not be able to re-use another plugin's dialog easily though. You need another dialog.

But don't worry, you can copy&paste the source code of Source Dialog plugin's dialog, which is very simple, and use it for your plugin. Code Snippet dialog is also pretty straightforward.

Also

  1. You may find Developer Tools plugin useful.
  2. You can observe various events with the API of the editor easily (including click).
Community
  • 1
  • 1
oleq
  • 15,697
  • 1
  • 38
  • 65
  • Thanks for your suggestion. This is not exactly what i'm looking for. I need a method like CKEditor.openDialog('dialogname') to invoke dialog from my code. I knew about code snippet dialog plugin. But, I would like to create my own customised plugin. Even in that plugin documentation, They didn't mention about how to access the element inside dialog from some other method. – Kirubachari Dec 18 '14 at 13:14
  • 1
    Dialogs are opened with pre-defined [`dialogCommands`](http://docs.ckeditor.com/#!/api/CKEDITOR.dialogCommand). You can access current dialog with [`CKEDITOR.dialog.getCurrent()`](http://docs.ckeditor.com/#!/api/CKEDITOR.dialog-static-method-getCurrent) but if you need to do that, something's wrong with your architecture as dialogs should be controlled with [setup](http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_2-section-setup-functions) and [commit](http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_2-section-commit-functions) functions. – oleq Dec 18 '14 at 15:46
  • Thanks for the reference link. – Kirubachari Dec 19 '14 at 05:32