I committed #1425894: CKEditor support but noted that it only supported CKEditor v3 and not v4. It looks like from #153313: ckeditor input is lost when using the browser's back button that CKEditor 4 might support a different event for changing field values.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Yurii’s picture

Hi,
I was looking for autosave support with CKeditor v4 and i end up with this solution for now.
Maybe it will help, its same solution like for Tinymce editor.

My addition in autosave.js:

     //Code added for support the CKEDITOR
      if (typeof(CKEDITOR) !== 'undefined'){
        setInterval(function() {
          var id;
          for (id in CKEDITOR.instances) {
            var instance = CKEDITOR.instances[id];
            instance.updateElement();
          }
        }, autosaveSettings.period * 1000);
      }

Code have to be past directly after the Tinymce code

IRuslan’s picture

Provided code is works.
But we should either use that snippet either default for 3 version.
It would be great to have common solution.

heyehren’s picture

For anybody else who has problems getting this working, i had to place the above patch before the following line in the autosave.js file

    save: function (e, o) {
      if (!autosaveSettings.hidden) {
shortspoken’s picture

Works like a charme! Thanks a lot!

Cheers, Moritz

ranelpadon’s picture

There's also a related AutoSave CKEDitor plugin that leverages the HTML 5 LocalStorage object.
http://ckeditor.com/addon/autosave

Nux’s picture

For anyone else trying to figure this out - you need to:

  1. Put autosave plugin folder in "sites/all/modules/ckeditor/plugins/".
  2. In administration panel go to Configuration > Content Authoring > CKEditor.
  3. Edit CKE profile (e.g. Full HTML is in ".../admin/config/content/ckeditor/edit/Full").
  4. Open "Editor appearance" section.
  5. Scroll down to Plugins subsection and enable "Plugin file: autosave".
  6. Save and repeat for all CKE profiles in which you want autosave to work.

It took me awhile to understand that editing config.js doesn't really do much.

Axl’s picture

@IRuslan: the common solution would be to simply wrap a
if (CKEDITOR.version.split('.')[0] <= 3 )
around the <3 and 4+ branches.
Edit: ah, I got it now. it works for v3, too :)
Edit2: actually I used instance.editor.updateElement(); - somehow that worked better with slow connections on v3.

aether’s picture

#1 is working for me.

Adrian Richardson’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.11 KB

I've tried Yurii's solution in #1 and it's working for me for both CKEditor v3 and v4.

Patch attached for review.

Dave Reid’s picture

Status: Needs review » Needs work

@Adrian: That is a patch against scald_og, not autosave.

Adrian Richardson’s picture

Status: Needs work » Needs review
FileSize
1 KB

Oops, I grabbed the wrong file! Sorry about that.

This is what I meant to load :-)

czigor’s picture

Patch in #11 works for me on CKEditor 4.2.3 with Wysiwyg module.

fabsor’s picture

Status: Needs review » Reviewed & tested by the community

This solution seems to work fine!

czigor’s picture

Status: Reviewed & tested by the community » Fixed

Commited, thanks!

Status: Fixed » Closed (fixed)

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