From 40871b1c0fffa513e6538ebe03d8cdf8fbaba751 Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 10 Apr 2018 18:02:30 -0400 Subject: [PATCH] Rename undo formats, and make format change on costume change skip convert --- src/containers/paper-canvas.jsx | 2 +- src/helper/undo.js | 8 ++++---- src/lib/format.js | 10 +++++----- src/reducers/undo.js | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/containers/paper-canvas.jsx b/src/containers/paper-canvas.jsx index 7941fa32..5655eb85 100644 --- a/src/containers/paper-canvas.jsx +++ b/src/containers/paper-canvas.jsx @@ -115,7 +115,7 @@ class PaperCanvas extends React.Component { this.props.clearHoveredItem(); this.props.clearPasteOffset(); if (svg) { - this.props.changeFormat(Formats.VECTOR); + this.props.changeFormat(Formats.VECTOR_SKIP_CONVERT); // Store the zoom/pan and restore it after importing a new SVG const oldZoom = paper.project.view.zoom; const oldCenter = paper.project.view.center.clone(); diff --git a/src/helper/undo.js b/src/helper/undo.js index a069f516..3f9592d2 100644 --- a/src/helper/undo.js +++ b/src/helper/undo.js @@ -43,8 +43,8 @@ const performUndo = function (undoState, dispatchPerformUndo, setSelectedItems, if (undoState.pointer > 0) { const state = undoState.stack[undoState.pointer - 1]; _restore(state, setSelectedItems, onUpdateSvg); - const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR : - isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null; + const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT : + isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null; if (!format) { log.error(`Invalid format: ${state.paintEditorFormat}`); } @@ -57,8 +57,8 @@ const performRedo = function (undoState, dispatchPerformRedo, setSelectedItems, if (undoState.pointer >= 0 && undoState.pointer < undoState.stack.length - 1) { const state = undoState.stack[undoState.pointer + 1]; _restore(state, setSelectedItems, onUpdateSvg); - const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR : - isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null; + const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT : + isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null; if (!format) { log.error(`Invalid format: ${state.paintEditorFormat}`); } diff --git a/src/lib/format.js b/src/lib/format.js index 0ae9a29a..abad144f 100644 --- a/src/lib/format.js +++ b/src/lib/format.js @@ -3,17 +3,17 @@ import keyMirror from 'keymirror'; const Formats = keyMirror({ BITMAP: null, VECTOR: null, - // Undo formats are conversions caused by the undo/redo stack - UNDO_BITMAP: null, - UNDO_VECTOR: null + // Format changes which should not trigger conversions, for instance undo + BITMAP_SKIP_CONVERT: null, + VECTOR_SKIP_CONVERT: null }); const isVector = function (format) { - return format === Formats.VECTOR || format === Formats.UNDO_VECTOR; + return format === Formats.VECTOR || format === Formats.VECTOR_SKIP_CONVERT; }; const isBitmap = function (format) { - return format === Formats.BITMAP || format === Formats.UNDO_BITMAP; + return format === Formats.BITMAP || format === Formats.BITMAP_SKIP_CONVERT; }; export { diff --git a/src/reducers/undo.js b/src/reducers/undo.js index 0ca26988..e372ffa2 100644 --- a/src/reducers/undo.js +++ b/src/reducers/undo.js @@ -64,7 +64,7 @@ const undoSnapshot = function (snapshot) { }; }; /** - * @param {Format} format Either UNDO_VECTOR or UNDO_BITMAP + * @param {Format} format Either VECTOR_SKIP_CONVERT or BITMAP_SKIP_CONVERT * @return {Action} undo action */ const undo = function (format) { @@ -74,7 +74,7 @@ const undo = function (format) { }; }; /** - * @param {Format} format Either UNDO_VECTOR or UNDO_BITMAP + * @param {Format} format Either VECTOR_SKIP_CONVERT or BITMAP_SKIP_CONVERT * @return {Action} undo action */ const redo = function (format) {