Text layers added by keyboard shortcut are now also added into state history

This commit is contained in:
Igor Zinken
2021-01-22 11:17:13 +01:00
parent b3c01b298c
commit bc91df05fc

View File

@@ -26,6 +26,7 @@ import {
CREATE_DOCUMENT, ADD_LAYER, EXPORT_DOCUMENT, DROPBOX_FILE_SELECTOR, SAVE_DROPBOX_DOCUMENT
} from "@/definitions/modal-windows";
import { getCanvasInstance, getSpriteForLayer } from "@/factories/sprite-factory";
import { enqueueState } from "@/factories/history-state-factory";
import { translatePoints } from "@/math/point-math";
let state, getters, commit, dispatch, listener,
@@ -334,7 +335,15 @@ function handleKeyDown( event ) {
case 84: // T
if ( getters.activeDocument ) {
if ( getters.activeLayer?.type !== LAYER_TEXT ) {
commit( "addLayer", { type: LAYER_TEXT });
const fn = () => commit( "addLayer", { type: LAYER_TEXT });
fn();
const addedLayerIndex = getters.activeLayerIndex;
enqueueState( `layerAdd_${addedLayerIndex}`, {
undo() {
commit( "removeLayer", addedLayerIndex );
},
redo: fn,
});
}
setActiveTool( ToolTypes.TEXT );
preventDefault( event );