From affe8463be098135ca557061ca30a71973f9b8aa Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 11 Oct 2017 17:17:19 -0400 Subject: [PATCH] fix undo removes cursor preview --- src/containers/blob/blob.js | 5 ++++- src/containers/line-mode.jsx | 1 - src/helper/selection.js | 1 - src/helper/undo.js | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/containers/blob/blob.js b/src/containers/blob/blob.js index 33c2607f..3d93ebec 100644 --- a/src/containers/blob/blob.js +++ b/src/containers/blob/blob.js @@ -4,6 +4,7 @@ import BroadBrushHelper from './broad-brush-helper'; import SegmentBrushHelper from './segment-brush-helper'; import {MIXED, styleCursorPreview} from '../../helper/style-path'; import {clearSelection} from '../../helper/selection'; +import {getGuideLayer} from '../../helper/layer'; /** * Shared code for the brush and eraser mode. Adds functions on the paper tool object @@ -166,7 +167,7 @@ class Blobbiness { this.cursorPreviewLastPoint = point; } - if (this.cursorPreview && + if (this.cursorPreview && this.cursorPreview.parent && this.brushSize === this.options.brushSize && this.fillColor === this.options.fillColor && this.strokeColor === this.options.strokeColor) { @@ -176,6 +177,8 @@ class Blobbiness { center: point, radius: this.options.brushSize / 2 }); + newPreview.parent = getGuideLayer(); + newPreview.data.isHelperItem = true; if (this.cursorPreview) { this.cursorPreview.remove(); } diff --git a/src/containers/line-mode.jsx b/src/containers/line-mode.jsx index bd7a1980..56cf6dc2 100644 --- a/src/containers/line-mode.jsx +++ b/src/containers/line-mode.jsx @@ -4,7 +4,6 @@ import React from 'react'; import {connect} from 'react-redux'; import bindAll from 'lodash.bindall'; import Modes from '../modes/modes'; -import {changeStrokeWidth} from '../reducers/stroke-width'; import {clearSelection, getSelectedLeafItems} from '../helper/selection'; import {MIXED} from '../helper/style-path'; import {changeMode} from '../reducers/modes'; diff --git a/src/helper/selection.js b/src/helper/selection.js index a7bff794..5a9e6a06 100644 --- a/src/helper/selection.js +++ b/src/helper/selection.js @@ -178,7 +178,6 @@ const _deleteItemSelection = function (items, onUpdateSvg) { }; const _removeSelectedSegments = function (items, onUpdateSvg) { - performSnapshot(undoSnapshot); const segmentsToRemove = []; for (let i = 0; i < items.length; i++) { diff --git a/src/helper/undo.js b/src/helper/undo.js index 45c13826..8e0e326e 100644 --- a/src/helper/undo.js +++ b/src/helper/undo.js @@ -12,6 +12,9 @@ const performSnapshot = function (dispatchPerformSnapshot) { }; const _restore = function (entry, onUpdateSvg) { + for (const layer of paper.project.layers) { + layer.removeChildren(); + } paper.project.clear(); paper.project.importJSON(entry.json); paper.view.update();