diff --git a/src/actions/actionCanvas.tsx b/src/actions/actionCanvas.tsx index a09c0018..b7382066 100644 --- a/src/actions/actionCanvas.tsx +++ b/src/actions/actionCanvas.tsx @@ -8,7 +8,7 @@ import { t } from "../i18n"; export const actionChangeViewBackgroundColor: Action = { name: "changeViewBackgroundColor", - perform: (elements, appState, value) => { + perform: (_, appState, value) => { return { appState: { ...appState, viewBackgroundColor: value } }; }, PanelComponent: ({ appState, updateData }) => { @@ -23,10 +23,12 @@ export const actionChangeViewBackgroundColor: Action = { ); }, + commitToHistory: () => true, }; export const actionClearCanvas: Action = { name: "clearCanvas", + commitToHistory: () => true, perform: () => { return { elements: [], diff --git a/src/actions/actionDeleteSelected.tsx b/src/actions/actionDeleteSelected.tsx index e3a80917..a2c67dd3 100644 --- a/src/actions/actionDeleteSelected.tsx +++ b/src/actions/actionDeleteSelected.tsx @@ -12,5 +12,6 @@ export const actionDeleteSelected: Action = { }, contextItemLabel: "labels.delete", contextMenuOrder: 3, + commitToHistory: (_, elements) => elements.some(el => el.isSelected), keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE, }; diff --git a/src/actions/actionFinalize.tsx b/src/actions/actionFinalize.tsx index a9d14fcb..fae31eb2 100644 --- a/src/actions/actionFinalize.tsx +++ b/src/actions/actionFinalize.tsx @@ -1,10 +1,12 @@ import { Action } from "./types"; import { KEYS } from "../keys"; import { clearSelection } from "../scene"; +import { isInvisiblySmallElement } from "../element"; export const actionFinalize: Action = { name: "finalize", perform: (elements, appState) => { + let newElements = clearSelection(elements); if (window.document.activeElement instanceof HTMLElement) { window.document.activeElement.blur(); } @@ -13,10 +15,13 @@ export const actionFinalize: Action = { 0, appState.multiElement.points.length - 1, ); + if (isInvisiblySmallElement(appState.multiElement)) { + newElements = newElements.slice(0, -1); + } appState.multiElement.shape = null; } return { - elements: clearSelection(elements), + elements: newElements, appState: { ...appState, elementType: "selection", diff --git a/src/actions/actionProperties.tsx b/src/actions/actionProperties.tsx index 5b92e90f..4c80906a 100644 --- a/src/actions/actionProperties.tsx +++ b/src/actions/actionProperties.tsx @@ -47,6 +47,7 @@ export const actionChangeStrokeColor: Action = { appState: { ...appState, currentItemStrokeColor: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => ( <> @@ -77,6 +78,7 @@ export const actionChangeBackgroundColor: Action = { appState: { ...appState, currentItemBackgroundColor: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => ( <> @@ -107,6 +109,7 @@ export const actionChangeFillStyle: Action = { appState: { ...appState, currentItemFillStyle: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => (
{t("labels.fill")} @@ -143,6 +146,7 @@ export const actionChangeStrokeWidth: Action = { appState: { ...appState, currentItemStrokeWidth: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => (
{t("labels.strokeWidth")} @@ -177,6 +181,7 @@ export const actionChangeSloppiness: Action = { appState: { ...appState, currentItemRoughness: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => (
{t("labels.sloppiness")} @@ -211,6 +216,7 @@ export const actionChangeOpacity: Action = { appState: { ...appState, currentItemOpacity: value }, }; }, + commitToHistory: () => true, PanelComponent: ({ elements, appState, updateData }) => (