feat: add logo into export

This commit is contained in:
Arnošt Pleskot
2023-08-28 10:21:37 +02:00
parent 9caa05825d
commit 780af522a2
6 changed files with 170 additions and 31 deletions
+30 -1
View File
@@ -16,7 +16,14 @@ import {
FontString,
NonDeletedExcalidrawElement,
} from "./element/types";
import { AppState, DataURL, Dimensions, LastActiveTool, Zoom } from "./types";
import {
AppState,
DataURL,
Dimensions,
ExportPadding,
LastActiveTool,
Zoom,
} from "./types";
import { unstable_batchedUpdates } from "react-dom";
import { SHAPES } from "./shapes";
import { isEraserActive, isHandToolActive } from "./appState";
@@ -1052,3 +1059,25 @@ export const expandToAspectRatio = (
height: newHeight,
};
};
const isExportPadding = (value: any): value is ExportPadding => {
return (
Array.isArray(value) &&
value.length === 4 &&
value.every((item) => typeof item === "number")
);
};
export const convertToExportPadding = (
padding: number | ExportPadding,
): ExportPadding => {
if (typeof padding === "number") {
return [padding, padding, padding, padding];
}
if (isExportPadding(padding)) {
return padding;
}
throw new Error("Invalid padding value");
};