Smart.Editor Auto Load/Save

Editor Content State Handling

Smart.Editor's allows to automatically store the content to local storage. The autoSaveInterval property determines the interval between each save. The property accepts numeric values as miliseconds. The default interval value is set to 1000ms (1 second). The content is saved only while the Editor is focused.

The auto save feature is not enabled by default. The autoSave property enables/disabled the feature.

The auto load feature of the Editor allows the user to continue from where he left off after re-opening the page. The autoLoad property determines whether the Editor will automatically load the last saved state.

In order for both property to work the Editor should have an id set.

Methods

Additional methods are available for manually saving or loading the Editor:

  • saveState - saves the current state of the Editor to local storage.
  • loadState - this method takes one optional argument which represents a previously saved content of the Editor. If not provided, a local storage lookup for a previously saved state of the Editor will be performed.
  • clearState - clears any stored state of the Editor from Local storage. (Depending on the id of the Editor)
const editor = document.querySelector('smart-editor');

editor.saveState();
editor.loadState();
editor.clearState();