From 6806d906eaa126b5edc2859eaddbccb1fdf8adf9 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 10 Dec 2019 15:59:18 -0500 Subject: [PATCH] Fixed history error --- desktop/sources/scripts/client.js | 6 +++--- desktop/sources/scripts/lib/source.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/desktop/sources/scripts/client.js b/desktop/sources/scripts/client.js index ce4c070..383951b 100644 --- a/desktop/sources/scripts/client.js +++ b/desktop/sources/scripts/client.js @@ -47,9 +47,9 @@ function Client () { this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('grid', this.whenOpen) }) this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.write('dotgrid', 'grid', this.tool.export(), 'text/plain') }) this.acels.set('File', 'Export Vector', 'CmdOrCtrl+E', () => { this.source.write('dotgrid', 'svg', this.manager.toString(), 'image/svg+xml') }) - this.acels.set('File', 'Export Image', 'CmdOrCtrl+Shift+E', () => { this.manager.toPNG(this.tool.settings.size, (dataUrl) => { this.source.download('dotgrid', 'png', dataUrl, 'image/png') }) }) - this.acels.set('History', 'Undo', 'CmdOrCtrl+Z', () => { this.history.undo() }) - this.acels.set('History', 'Redo', 'CmdOrCtrl+Shift+Z', () => { this.history.redo() }) + this.acels.set('File', 'Export Image', 'CmdOrCtrl+Shift+E', () => { this.manager.toPNG(this.tool.settings.size, (dataUrl) => { this.source.write('dotgrid', 'png', dataUrl, 'image/png') }) }) + this.acels.set('History', 'Undo', 'CmdOrCtrl+Z', () => { this.tool.undo() }) + this.acels.set('History', 'Redo', 'CmdOrCtrl+Shift+Z', () => { this.tool.redo() }) this.acels.set('Stroke', 'Line', 'A', () => { this.tool.cast('line') }) this.acels.set('Stroke', 'Arc', 'S', () => { this.tool.cast('arc_c') }) this.acels.set('Stroke', 'Arc Rev', 'D', () => { this.tool.cast('arc_r') }) diff --git a/desktop/sources/scripts/lib/source.js b/desktop/sources/scripts/lib/source.js index f651b2e..abbdf89 100644 --- a/desktop/sources/scripts/lib/source.js +++ b/desktop/sources/scripts/lib/source.js @@ -18,14 +18,14 @@ function Source (client) { this.cache = {} } - this.open = (ext, callback) => { + this.open = (ext, callback, store = false) => { console.log('Source', 'Open file..') const input = document.createElement('input') input.type = 'file' input.onchange = (e) => { const file = e.target.files[0] if (file.name.indexOf('.' + ext) < 0) { console.warn('Source', `Skipped ${file.name}`); return } - this.read(file, callback) + this.read(file, callback, store) } input.click() } @@ -60,11 +60,12 @@ function Source (client) { // I/O - this.read = (file, callback) => { + this.read = (file, callback, store = false) => { const reader = new FileReader() reader.onload = (event) => { const res = event.target.result if (callback) { callback(file, res) } + if (store) { this.store(file, res) } } reader.readAsText(file, 'UTF-8') }