mirror of
https://github.com/codex-team/editor.js
synced 2026-03-16 23:55:49 +01:00
Hash added
This commit is contained in:
parent
27c8d44a1c
commit
7bdd655f54
9 changed files with 26 additions and 13 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
codex.js
2
codex.js
|
|
@ -10,6 +10,7 @@ module.exports = (function (editor) {
|
|||
'use strict';
|
||||
|
||||
editor.version = VERSION;
|
||||
editor.currentHash = null;
|
||||
|
||||
var init = function () {
|
||||
|
||||
|
|
@ -79,6 +80,7 @@ module.exports = (function (editor) {
|
|||
editor.state = {
|
||||
jsonOutput: [],
|
||||
savingDate: null,
|
||||
hash : null,
|
||||
blocks : [],
|
||||
inputs : []
|
||||
};
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@
|
|||
},
|
||||
},
|
||||
data : {
|
||||
hash: 1486828599309,
|
||||
savingDate: 0,
|
||||
items: [
|
||||
{
|
||||
|
|
@ -207,7 +208,7 @@
|
|||
anchor: 'Update',
|
||||
},
|
||||
],
|
||||
count: 2
|
||||
count: 2,
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ module.exports = (function (core) {
|
|||
if (userSettings.data) {
|
||||
|
||||
editor.state.blocks = userSettings.data;
|
||||
editor.currentHash = userSettings.data.hash || +new Date();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ module.exports = (function (saver) {
|
|||
.then(function () {
|
||||
|
||||
editor.state.savingDate = +new Date();
|
||||
editor.state.hash = editor.currentHash;
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
*/
|
||||
var storage = function () {
|
||||
|
||||
var editor = codex.editor,
|
||||
LOCAL_STORAGE_KEY = 'codex.editor.savedData',
|
||||
interval = null,
|
||||
var editor = codex.editor,
|
||||
CURRENT_ARTICLE_HASH = null,
|
||||
LOCAL_STORAGE_KEY = null,
|
||||
interval = null,
|
||||
config_ = {
|
||||
savingInterval: 1000
|
||||
};
|
||||
|
|
@ -34,6 +35,9 @@ var storage = function () {
|
|||
|
||||
}
|
||||
|
||||
CURRENT_ARTICLE_HASH = editor.currentHash;
|
||||
LOCAL_STORAGE_KEY = 'codex.editor.savedData.'+CURRENT_ARTICLE_HASH;
|
||||
|
||||
config_ = config || config_;
|
||||
|
||||
var localData = get();
|
||||
|
|
@ -49,26 +53,30 @@ var storage = function () {
|
|||
|
||||
editor.state.blocks = localData;
|
||||
editor.renderer.rerender();
|
||||
init(config_.saveInterval);
|
||||
init(config_.savingInterval);
|
||||
|
||||
},
|
||||
cancel : function () {
|
||||
|
||||
init(config_.saveInterval);
|
||||
init(config_.savingInterval);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
init(config_.savingInterval);
|
||||
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
|
||||
};
|
||||
|
||||
var init = function (saveInterval) {
|
||||
var init = function (savingInterval) {
|
||||
|
||||
interval = window.setInterval(save, saveInterval);
|
||||
interval = window.setInterval(save, savingInterval);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue