Comments

Nick Robillard’s picture

Ah I'd really like a fix for ckeditor too. :(

I'm going to start hacking around with wysiwygcck.js and try adding a Drupal.wysiwyg.editor.triggerSave for ckeditor.

Nick Robillard’s picture

Well I haven't fixed it but I made some progress. I made a method for ckeditor and it's getting called when "Add another item" is clicked. However the "[CKEDITOR.editor] The instance already exists" exception is still thrown so something is still missing. If someone else takes a stab at solving, hopefully this helps.

wysiwygcck.js (after line 14)

Drupal.wysiwyg.editor.triggerSave.ckeditor = Drupal.wysiwyg.editor.triggerSave.ckeditor || function(context, params) {
  var instance = CKEDITOR.instances[params.field];
  instance.updateElement();
}
mikeker’s picture

I had luck by adding:

Drupal.wysiwyg.editor.triggerSave.ckeditor = Drupal.wysiwyg.editor.triggerSave.ckeditor || function(context, params) {
  Drupal.wysiwyg.editor.detach.ckeditor(context, params);
}

to wysiwygcck.js. (Put it just after the fckeditor line to keep things organized).

Patch coming soon...

mikeker’s picture

Status: Active » Needs review
StatusFileSize
new3.2 KB

This patch adds support for CKEditor version 3.0 and greater.

Note, my text editor removes trailing whitespace on save so there are a couple of extra "changes" that are just whitespace changes.

Syg’s picture

#4
It does solve the problem of "add another" item for Ckeditor, but it generates another problem.

When you add for example a file/image upload field just before the wysiwyg one and upload an image all the wysiwygs in the page disappears.

I guess the condition triggering the detach function is not well set.

K.MacKenzie’s picture

For anyone who is having this problem still, there is a simple solution that fixes AHAH issues for CKeditor.

just add (line 15 of wysiwygcck.js)

Drupal.wysiwyg.editor.triggerSave.ckeditor = Drupal.wysiwyg.editor.triggerSave.ckeditor || function(context, params) {
  var instance = CKeditorAPI.GetInstance(params.field);
  instance.UpdateLinkedField();
}

in place of mikeker's code. This will refresh the editor (and force the value to the html field) but also reload it after, whereas mikeker's code removes it completely.