mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-08 13:42:00 -05:00
fix undo snapshotting with the background guide layer
This commit is contained in:
parent
29a3d74143
commit
29f5cc7216
1 changed files with 13 additions and 2 deletions
|
@ -1,11 +1,20 @@
|
||||||
// undo functionality
|
// undo functionality
|
||||||
// modifed from https://github.com/memononen/stylii
|
// modifed from https://github.com/memononen/stylii
|
||||||
import paper from '@scratch/paper';
|
import paper from '@scratch/paper';
|
||||||
|
import {getBackgroundGuideLayer} from '../helper/layer';
|
||||||
|
|
||||||
const performSnapshot = function (dispatchPerformSnapshot) {
|
const performSnapshot = function (dispatchPerformSnapshot) {
|
||||||
|
const backgroundGuideLayer = getBackgroundGuideLayer();
|
||||||
|
if (backgroundGuideLayer) {
|
||||||
|
backgroundGuideLayer.remove();
|
||||||
|
}
|
||||||
dispatchPerformSnapshot({
|
dispatchPerformSnapshot({
|
||||||
json: paper.project.exportJSON({asString: false})
|
json: paper.project.exportJSON({asString: false})
|
||||||
});
|
});
|
||||||
|
if (backgroundGuideLayer) {
|
||||||
|
paper.project.addLayer(backgroundGuideLayer);
|
||||||
|
backgroundGuideLayer.sendToBack();
|
||||||
|
}
|
||||||
|
|
||||||
// @todo enable/disable buttons
|
// @todo enable/disable buttons
|
||||||
// updateButtonVisibility();
|
// updateButtonVisibility();
|
||||||
|
@ -13,9 +22,11 @@ const performSnapshot = function (dispatchPerformSnapshot) {
|
||||||
|
|
||||||
const _restore = function (entry, setSelectedItems, onUpdateSvg) {
|
const _restore = function (entry, setSelectedItems, onUpdateSvg) {
|
||||||
for (const layer of paper.project.layers) {
|
for (const layer of paper.project.layers) {
|
||||||
layer.removeChildren();
|
if (!layer.data.isBackgroundGuideLayer) {
|
||||||
|
layer.removeChildren();
|
||||||
|
layer.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paper.project.clear();
|
|
||||||
paper.project.importJSON(entry.json);
|
paper.project.importJSON(entry.json);
|
||||||
paper.view.update();
|
paper.view.update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue