When having textareas with CKEditor enabled inside table row with Drupal tableDrag behavior attached to it (like textarea field with several values or Imagefield with Title attribute as a textarea) and trying to swap the rows - the text disappears from the CKEditor (and from the corresponding textarea); it swaps fine if you first switch to the plain text editor.

So I added these lines just to the end of the ckeditor.utils.js file:

if (Drupal.tableDrag) {
  Drupal.tableDrag.prototype.onDrag = function() {
    $(this.rowObject.element).find('textarea.ckeditor-processed').each(
      function() {
        if (typeof(CKEDITOR.instances) != 'undefined' && typeof(CKEDITOR.instances[$(this).attr('id')]) != 'undefined') {
          Drupal.ckeditorOff($(this).attr('id'));
        }
      }
    );
  };
  
  Drupal.tableDrag.prototype.onDrop = function() {
    $(this.rowObject.element).find('textarea.ckeditor-mod:not(.ckeditor-processed)').each(
      function() {
        if ((typeof(Drupal.settings.ckeditor.autostart) != 'undefined') && (typeof(Drupal.settings.ckeditor.autostart[$(this).attr('id')]) != 'undefined')) {
          Drupal.ckeditorOn($(this).attr('id'));
        }
      }
    );
  };
}

It overrides the onDrag and onDrop functions as advised by the tabledrag.js file from Drupal.core:

Created tableDrag instances may be modified with custom behaviors by
overriding the .onDrag, .onDrop, .row.onSwap, and .row.onIndent methods.
See blocks.js for an example of adding additional functionality to tableDrag.

Hopefully, it is just what needs to be done - I'm not that well versed in JavaScript :)

As a reference, for the TinyMCE editor the same issue is addressed by the TinyMCE Drag and Drop Integration module (it doesn't use the above functions, but requires some other dependencies).

Let me know if it is fine and I will create a patch then.

Thanks
AndyB

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duozersk’s picture

Status: Needs review » Active

Moving to active as there is no patch yet ;)

duozersk’s picture

Status: Active » Needs review
FileSize
1.31 KB

And here is that patch against 6.x-1.x-dev (at least I believe so).

duozersk’s picture

Is this of any interest? This issue really should be resolved, one way or another.

Please review, will appreciate any feedback.

AndyB

mkesicki’s picture

Status: Needs review » Fixed

I commited patch to repo. Please test DEV version.

duozersk’s picture

thx!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

corrected link to the TynyMCE module