From e98a099127664cc968744264fad199fb282d4da3 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 25 Sep 2021 20:58:08 +0200 Subject: [PATCH] Send outputData to beforeSave callback --- editor/src/editor.js | 8 ++++++-- list-editor/index.js | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/editor/src/editor.js b/editor/src/editor.js index 780b7d5..1e9a5d8 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -36,7 +36,7 @@ function addSaver(editor, saveUrl, page, beforeSave) { save() { return editor.save() .then(outputData => { - beforeSave() + beforeSave(outputData) let data = { 'json': 1, 'p': page, @@ -429,8 +429,12 @@ function Editor(holder, input) { let saveUrl = element.dataset.saveurl; let page = element.dataset.page; + let beforeSave = (curDoc) => { + indicator.setText('saving...') + } + addIndicator( - addSaver(editor, saveUrl, page, () => indicator.setText('saving...')), + addSaver(editor, saveUrl, page, beforeSave), indicator ).save().then(() => indicator.done()) }) diff --git a/list-editor/index.js b/list-editor/index.js index 10dee27..d499e54 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -73,8 +73,10 @@ function editor(root, inputData, options) { function save() { return new Promise(function (resolve, reject) { + if (store.hasChanged()) { - resolve(store.debug().result) + let result = store.debug().result + resolve(result) store.clearChanged() } }); @@ -146,7 +148,7 @@ function editor(root, inputData, options) { location.href = '/edit/' + id; }) } - return true; + return true; }) cursor.set(0) renderUpdate()