Rename undo formats, and make format change on costume change skip convert

This commit is contained in:
DD 2018-04-10 18:02:30 -04:00
parent c6a282c97b
commit 40871b1c0f
4 changed files with 12 additions and 12 deletions

View file

@ -115,7 +115,7 @@ class PaperCanvas extends React.Component {
this.props.clearHoveredItem(); this.props.clearHoveredItem();
this.props.clearPasteOffset(); this.props.clearPasteOffset();
if (svg) { 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 // Store the zoom/pan and restore it after importing a new SVG
const oldZoom = paper.project.view.zoom; const oldZoom = paper.project.view.zoom;
const oldCenter = paper.project.view.center.clone(); const oldCenter = paper.project.view.center.clone();

View file

@ -43,8 +43,8 @@ const performUndo = function (undoState, dispatchPerformUndo, setSelectedItems,
if (undoState.pointer > 0) { if (undoState.pointer > 0) {
const state = undoState.stack[undoState.pointer - 1]; const state = undoState.stack[undoState.pointer - 1];
_restore(state, setSelectedItems, onUpdateSvg); _restore(state, setSelectedItems, onUpdateSvg);
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR : const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null; isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
if (!format) { if (!format) {
log.error(`Invalid format: ${state.paintEditorFormat}`); 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) { if (undoState.pointer >= 0 && undoState.pointer < undoState.stack.length - 1) {
const state = undoState.stack[undoState.pointer + 1]; const state = undoState.stack[undoState.pointer + 1];
_restore(state, setSelectedItems, onUpdateSvg); _restore(state, setSelectedItems, onUpdateSvg);
const format = isVector(state.paintEditorFormat) ? Formats.UNDO_VECTOR : const format = isVector(state.paintEditorFormat) ? Formats.VECTOR_SKIP_CONVERT :
isBitmap(state.paintEditorFormat) ? Formats.UNDO_BITMAP : null; isBitmap(state.paintEditorFormat) ? Formats.BITMAP_SKIP_CONVERT : null;
if (!format) { if (!format) {
log.error(`Invalid format: ${state.paintEditorFormat}`); log.error(`Invalid format: ${state.paintEditorFormat}`);
} }

View file

@ -3,17 +3,17 @@ import keyMirror from 'keymirror';
const Formats = keyMirror({ const Formats = keyMirror({
BITMAP: null, BITMAP: null,
VECTOR: null, VECTOR: null,
// Undo formats are conversions caused by the undo/redo stack // Format changes which should not trigger conversions, for instance undo
UNDO_BITMAP: null, BITMAP_SKIP_CONVERT: null,
UNDO_VECTOR: null VECTOR_SKIP_CONVERT: null
}); });
const isVector = function (format) { 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) { const isBitmap = function (format) {
return format === Formats.BITMAP || format === Formats.UNDO_BITMAP; return format === Formats.BITMAP || format === Formats.BITMAP_SKIP_CONVERT;
}; };
export { export {

View file

@ -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 * @return {Action} undo action
*/ */
const undo = function (format) { 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 * @return {Action} undo action
*/ */
const redo = function (format) { const redo = function (format) {