add history.shouldCreateEntry resolver (#1622)

This commit is contained in:
David Luzar 2020-05-23 07:26:59 +02:00 committed by GitHub
parent 22f7945c70
commit d2ae18995c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1349 additions and 3449 deletions

View file

@ -3,7 +3,7 @@ import React from "react";
import { undo, redo } from "../components/icons";
import { ToolButton } from "../components/ToolButton";
import { t } from "../i18n";
import { SceneHistory } from "../history";
import { SceneHistory, HistoryEntry } from "../history";
import { ExcalidrawElement } from "../element/types";
import { AppState } from "../types";
import { KEYS } from "../keys";
@ -13,10 +13,7 @@ import { newElementWith } from "../element/mutateElement";
const writeData = (
prevElements: readonly ExcalidrawElement[],
appState: AppState,
updater: () => {
elements: ExcalidrawElement[];
appState: AppState;
} | null,
updater: () => HistoryEntry | null,
): ActionResult => {
const commitToHistory = false;
if (
@ -52,6 +49,7 @@ const writeData = (
),
appState: { ...appState, ...data.appState },
commitToHistory,
syncHistory: true,
};
}
return { commitToHistory };

View file

@ -6,6 +6,7 @@ export type ActionResult = {
elements?: readonly ExcalidrawElement[] | null;
appState?: AppState | null;
commitToHistory: boolean;
syncHistory?: boolean;
};
type ActionFn = (