1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-09 19:24:58 +02:00

stop preview refresh when cm changes thru setValue() call.

This commit is contained in:
Kushagra Gour 2017-03-11 19:50:18 +05:30
parent 073a08b176
commit a678d6997a
2 changed files with 13 additions and 4 deletions

View File

@ -429,7 +429,7 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete */
externalJsTextarea.value = (currentItem.externalLibs && currentItem.externalLibs.js) || ''; externalJsTextarea.value = (currentItem.externalLibs && currentItem.externalLibs.js) || '';
externalCssTextarea.value = (currentItem.externalLibs && currentItem.externalLibs.css) || ''; externalCssTextarea.value = (currentItem.externalLibs && currentItem.externalLibs.css) || '';
// FIXME // FIXME
// externalJsTextarea.dispatchEvent(new Event('change')); externalJsTextarea.dispatchEvent(new Event('blur'));
utils.log('refresh editor') utils.log('refresh editor')
// Set the modes manually here, so that the preview refresh triggered by the `setValue` // Set the modes manually here, so that the preview refresh triggered by the `setValue`
@ -743,11 +743,13 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete */
var fileWritten = false; var fileWritten = false;
function errorHandler() { utils.log(arguments); } function errorHandler() { utils.log(arguments); }
utils.log('writing file ', name);
window.webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024 * 5, function(fs){ window.webkitRequestFileSystem(window.TEMPORARY, 1024 * 1024 * 5, function(fs){
fs.root.getFile(name, { create: true }, function(fileEntry) { fs.root.getFile(name, { create: true }, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) { fileEntry.createWriter(function(fileWriter) {
function onWriteComplete() { function onWriteComplete() {
if (fileWritten) { if (fileWritten) {
utils.log('file written ', name);
return cb(); return cb();
} }
fileWritten = true; fileWritten = true;
@ -758,7 +760,9 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete */
} }
fileWriter.onwriteend = onWriteComplete; fileWriter.onwriteend = onWriteComplete;
// Empty the file contents // Empty the file contents
fileWriter.truncate(0) fileWriter.truncate(0);
utils.log('truncating file ', name);
}, errorHandler); }, errorHandler);
}, errorHandler); }, errorHandler);
}, errorHandler); }, errorHandler);
@ -792,7 +796,7 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete */
css: scope.cm.css.getValue(), css: scope.cm.css.getValue(),
js: scope.cm.js.getValue() js: scope.cm.js.getValue()
}; };
utils.log('setPreviewContent', isForced) utils.log('🔎 setPreviewContent', isForced)
// If just CSS was changed (and everything shudn't be empty), // If just CSS was changed (and everything shudn't be empty),
// change the styles inside the iframe. // change the styles inside the iframe.
if (!isForced && currentCode.html === codeInPreview.html && currentCode.js === codeInPreview.js) { if (!isForced && currentCode.html === codeInPreview.html && currentCode.js === codeInPreview.js) {
@ -895,7 +899,11 @@ onboardDontShowInTabOptionBtn, TextareaAutoComplete */
clearTimeout(updateTimer); clearTimeout(updateTimer);
updateTimer = setTimeout(function () { updateTimer = setTimeout(function () {
// This is done so that multiple simultaneous setValue don't trigger too many preview refreshes
// and in turn too many file writes on a single file (eg. preview.html).
if (change.origin !== 'setValue') {
scope.setPreviewContent(); scope.setPreviewContent();
}
// If this isn a user triggered change, handle unsaved changes count. // If this isn a user triggered change, handle unsaved changes count.
if (change.origin === '+input' || change.origin === '+delete') { if (change.origin === '+input' || change.origin === '+delete') {
saveBtn.classList.add('is-marked'); saveBtn.classList.add('is-marked');

View File

@ -7,6 +7,7 @@
- `for`, `while` & `dowhile` loops should be instrumented in the generated JavaScript code. - `for`, `while` & `dowhile` loops should be instrumented in the generated JavaScript code.
- Import should confirm the overriding of existing items. - Import should confirm the overriding of existing items.
- Opening a smaller DOM item shouldn't show left over HTML from a previously open bigger DOM item.
## Interface ## Interface