Hey jesoX,

Really good module, best implementation I've seen so far for D7. Works perfectly with plain text however when CKEditor is involved (note this may happen for other WYSIWYG editors but I haven't tested) the content doesn't appear to be saved.

Is there anything I can do to get this to work with CKEditor?

Cheers,

Alex

Comments

compujohnny’s picture

Status: Active » Postponed

Hi Alex,

This is an issue with the sisyphus library, it appears to have been fixed here https://github.com/simsalabim/sisyphus/pull/13, but the fix is not commited yet to the official Github repo

You can wait until it's officially committed or you can modify the js file yourself with the updates proposed in the pull request

AlxM’s picture

Hi JesoX,

Thanks for the quick response and pointing me in the right direction. I edited the js as per the pull request but didn't have any luck, which is most likely down to my lack of skills. I'll keep having a play around and let you know if I can get it to work.

Cheers,

Alex

Yurii’s picture

Hi,
I was looking for integration to make it working with CKeditor for a while.

I get it working with modifiead sisyphus.js from this git: https://github.com/TommiGustafsson/sisyphus/tree/8e5b052e99defbaaa4cd30c...

Instructions how to get it working with CKeditor follow, its working for me like a charm.

Installation instructions with support of CKeditor

  1. Download the jQuery update module and extract it to your sites/all/modules directory.
  2. Download the Save Form State module and extract it to your sites/all/modules directory.
  3. Download and extract the modifiead sysyphus archive from https://github.com/TommiGustafsson/sisyphus/archive/master.zip and copy the sisyphus.js file to the Save Form State module's directory.
  4. Download and extract the archive from https://github.com/compujohnny/jStorage/archive/master.zip and copy the jstorage.js file to the Save Form State module's directory.
  5. Enable jQuery Update and configure it's settings and choose jQuery version 1.7 or above.
  6. Open file form_save_state.js (file is inside Save Form State module's directory) and replace all the code there with this code:
    jQuery(document).ready(function() {
    
      jQuery('#' + Drupal.settings.form_save_state.form_id).sisyphus({
        timeout: Drupal.settings.form_save_state.time,
    
        onSave: function() {
          if (Drupal.settings.form_save_state.notify == 1)
            jQuery.jnotify('Data are saved to Local Storage', 500);
        },
    
        //Code added for supporting the latest CKEDITOR
    
        //2.1 Set onBeforeSave to update all textareas from CKEDITOR instances
        onBeforeSave: function () {
    
          for (var edid in CKEDITOR.instances) {
            CKEDITOR.instances[edid].updateElement();
          }
        },
    
        //2.2 Set onBeforeTextSave, which is triggered when text is changed in textareas or input[type=text] elements
        onBeforeTextSave: function () {
    
          //Update
          var ed = CKEDITOR.instances[jQuery(this).attr("name")];
          if (ed) {
            ed.updateElement();
          }
        },
    
        onRestore: function() {
          if (Drupal.settings.form_save_state.notify == 1)
            jQuery.jnotify('Data are restored from Local Storage', 500);
    
          //Code added for support the CKEDITOR support
          for (var edid in CKEDITOR.instances) {
            var instance = CKEDITOR.instances[edid];
            var value = instance.element.getValue();
            instance.setData(value);
          }
        },
    
        onRelease: function() {
          if (Drupal.settings.form_save_state.notify == 1)
            jQuery.jnotify('Data are removed from Local Storage', 'warning', 500);
        }
    
      });
    
    });

    Save the file

  7. Enable the Save Form State module
  8. Configure the Save Form State module's settings from admin/config/form_save_state.
  9. Navigate to the forms you choose in the previous step and enjoy the safety of your data.

I,Hope this will helps

BrockBoland’s picture

This can be added more easily once #2008952: External libraries is in, because it will be easier to swap out the Sisyphus library. The changes to form_save_state.js can be included right in the module, with checks to see if CKEDITOR.instances is set.

BrockBoland’s picture

Status: Postponed » Fixed

Added in http://drupalcode.org/project/form_save_state.git/commit/754de6b

Yurii, I re-worked your code a bit to improve commenting and use the Drupal.behaviors style (which wasn't in place before). The CKEditor support is now included right in form_save_state.js, but is only used when CKEditor is present. I also updated the README to note that a fork of Sisyphus is needed for this to work (and will update the module page with updated installation instructions once the d.o server has packaged the updated -dev release).

Status: Fixed » Closed (fixed)

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