Add NonDeleted<ExcalidrawElement> (#1068)
* add NonDeleted * make test:all script run tests without prompt * rename helper * replace with helper * make element contructors return nonDeleted elements * cache filtered elements where appliacable for better perf * rename manager element getter * remove unnecessary assertion * fix test * make element types in resizeElement into nonDeleted Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import { ExcalidrawElement } from "../element/types";
|
||||
import {
|
||||
ExcalidrawElement,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "../element/types";
|
||||
|
||||
import { getDefaultAppState } from "../appState";
|
||||
|
||||
@ -16,7 +19,6 @@ import { serializeAsJSON } from "./json";
|
||||
import { ExportType } from "../scene/types";
|
||||
import { restore } from "./restore";
|
||||
import { restoreFromLocalStorage } from "./localStorage";
|
||||
import { hasNonDeletedElements } from "../element";
|
||||
|
||||
export { loadFromBlob } from "./blob";
|
||||
export { saveAsJSON, loadFromJSON } from "./json";
|
||||
@ -283,7 +285,7 @@ export async function importFromBackend(
|
||||
|
||||
export async function exportCanvas(
|
||||
type: ExportType,
|
||||
elements: readonly ExcalidrawElement[],
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
canvas: HTMLCanvasElement,
|
||||
{
|
||||
@ -300,7 +302,7 @@ export async function exportCanvas(
|
||||
scale?: number;
|
||||
},
|
||||
) {
|
||||
if (!hasNonDeletedElements(elements)) {
|
||||
if (elements.length === 0) {
|
||||
return window.alert(t("alerts.cannotExportEmptyCanvas"));
|
||||
}
|
||||
if (type === "svg" || type === "clipboard-svg") {
|
||||
|
Reference in New Issue
Block a user