text toolbar - delete text button added

This commit is contained in:
Artur AGH
2023-10-27 15:45:49 +02:00
parent 74accdcb14
commit 46d0d98886
25 changed files with 657 additions and 114 deletions

View File

@@ -36,7 +36,7 @@ export const appSlice = createSlice({
addText: (state, action: PayloadAction<{ initialValue: string }>) => {
const textId = v1();
console.log(state);
state.texts.push({
text: action.payload.initialValue,
id: textId,
@@ -68,8 +68,22 @@ export const appSlice = createSlice({
...action.payload,
};
},
deleteShape: (state, action: PayloadAction<string>) => {
console.log(state.texts);
return {
...state,
texts: state.texts.filter((shape) => shape.id !== action.payload),
};
},
},
});
export const { addImage, addText, selectItem, deselectItem, updateText } =
appSlice.actions;
export const {
addImage,
addText,
selectItem,
deselectItem,
updateText,
deleteShape,
} = appSlice.actions;