Autosave widget
The Autosave widget enables periodical automatic saving of a document. This widget is not mature enough yet, so by default it is enabled only in wiki mode, but it is possible to manually enable it in an application using its JS API.
Currently WYSIWYG fields aren't supported by the widget, but all the other form controls will be saved.
Usage
As a wiki user
The widget is enabled by default in wiki mode, although the autosave is not active. As a user, just check the Autosave checkbox next to the action buttons, at the bottom of the editing area. You can optionally change the autosave interval by entering the desired number of minutes in the input following the checkbox.
As a developer
To enable the autosave widget in an application, you can include the js/xwiki/editors/autosave.js script in the sheet, along with a custom JSX that initializes the widget.
In the sheet:
$xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true)##
$xwiki.jsfx.use('js/xwiki/editors/autosave.js')##
## If you don't want to show the UI, then don't include the CSS file
$xwiki.ssfx.use('js/xwiki/editors/autosave.css')##
## Use to the correct name of the sheet, or the document where the JSX is located, if not in the sheet
$xwiki.jsx.use('MyApplication.MyApplicationSheet')##
{{/velocity}}
In the JSX object:
new XWiki.editors.AutoSave({
form : 'inline',
enabled: true,
frequency: 1,
showConfigurationUI: false
});
});
Parameters
The constructor accepts a map of parameters as its only argument, with the following property keys known (all are optional):
Parameter | Description | Default value |
---|---|---|
form | the ID (or DOM node) to save | by default the form containing the element with the "xwikieditcontent" ID is used, which is the main form in wiki edit mode |
enabled | the initial state of the autosave | false - the user must click the checkbox to activate autosaving |
frequency | the interval between consecutive saves, in minutes | 5 |
showConfigurationUI | is the UI for configuring the autosave enabled or not | true |
disabledOpacity | the opacity of the configuration UI (the frequency input) when the autosave is disabled, a number between 0 and 1 | 0.2 |