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.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();

View file

@ -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}`);
}

View file

@ -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 {

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
*/
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) {