Uploaded image for project: 'CKEditor Integration'
  1. CKEditor Integration
  2. CKEDITOR-46

Expose CKEditor events

    XMLWordPrintable

    Details

    • Type: Idea
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Similar issues:

      Description

      As a Wiki UI developer I would like to be able to hook into CKEditor events so that I can perform customs actions with my skin.

      For instance, if I want to toggle a markdown guide to the user when a user clicks the 'Source' button, I have no way of knowing when the CKEditor instance has rendered so I can attach an onclick event handler to the button.

      It would be nice if CKEditor.EditSheet forwarded events fired from CKEditor to the rest of the platform so I can listen to these events.

      It would be nice if these events were XWiki events so that my script files will not need require( ['ckeditor'] ) in my script as that would require me copying the require.config section from CKEditor.EditSheet into another file, and then I have to maintain this file should CKEditor.EditSheet ever change.

      I could make changes to CKEditor.EditSheet to fire an event but any custom changes that I make to that pages makes upgrading the Extension more difficult.

      For example (cut from CKEditor.EditSheet):

       var editor = ckeditor.replace(this, {
              allowedContent: true,
              // ------- snip ----- //
              on: {
                  instanceReady: function(evnt) {
                    document.fire("xwiki:ckeditor:instance:created", {editor: evnt.editor});
                  }
              }
            });
      

      The above code will allow me to observe this XWiki event which can pass me the editor instance so I can make any custom modifications I desire, like this:

      document.observe("xwiki:ckeditor:instance:created", function(evnt) {
              var editor = evnt.memo.editor;
              editor.container.findOne(".cke_button__source").on("click", function() {
                  $("my-format-guide").toggle();
              });
          });
      

      Notice I can easily make any changes that I want to the ckeditor instance without any race conditions or needing to worry that ckeditor.js is loaded and available for my script.

      A

       document.fire("xwiki:ckeditor:instance:beforeCreate", {options: {}}) 
      

      hook before the instance is created would be nice too so I can load custom configurations. I realize that there is already a task to add configuration of CKEditor through the Admin console, but allowing me to edit the configurations through code means I can source control the changes for disaster recovery. Or if the changes that I need to make are not exposed in the Admin console, I'll have to modify the CKEditor.EditSheet directly which creates a maintenance issue for me.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mflorea Marius Dumitru Florea
              Reporter:
              jmiklos Jim Miklos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response: