Save editing contents of different Jodit instances on different pages in local or remote storage.
It will protect you from:
The saving of contents may be:
The plugin shows you full featured preview when you choose a snapshot to restore.
The interval in seconds to make new snapshot.
The maximum number of snapshots made my the Backup plugin. If limit is exhausted the plugin removed the last backup before creating new.
If set it should parse ISnapshotItem.created
and return a formatted timestamp to display in the left-hand list.
Copyconst jodit = Jodit.make('#editor', { backup: { formatDate(date) { return new Date(date).toDateString(); } } });
Default dialog width.
Interface ISnaphotStorage
for saving your snapshots inside another storage (ex. remote rest API).
Copyinterface ISnapshotItem { created: Date; html: string; } interface ISnapshotStorage { add(item: ISnapshotItem): Promise<boolean>; items(): Promise<ISnapshotItem[]>; clear(): Promise<boolean>; }
Example:
Copyclass RemoteSnaphotSorage { remoteUrl = 'https://someapi.com/save.php'; async add(item) { await fetch(this.remoteUrl, { method: 'POST', body: JSON.stringify(item) }); return true; } async clear() { await fetch(this.remoteUrl + '?all', { method: 'DELETE' }); } items() { return fetch(this.remoteUrl, { method: 'GET' }).then((resp) => resp.json()); } } const jodit = Jodit.make('#editor', { backup: { interval: 20, limit: Infinity, remoteStore: new RemoteSnaphotSorage() } });