feat: added exportPadding to PNG (blob) export in @excalidraw/utils (#5626)

* added exportPadding

* Update README.md

* Update CHANGELOG.md
This commit is contained in:
zsviczian 2022-08-30 09:18:24 +02:00 committed by GitHub
parent da4fa91ffc
commit 836120c14b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -35,7 +35,10 @@ export const exportToCanvas = ({
files,
maxWidthOrHeight,
getDimensions,
}: ExportOpts) => {
exportPadding,
}: ExportOpts & {
exportPadding?: number;
}) => {
const { elements: restoredElements, appState: restoredAppState } = restore(
{ elements, appState },
null,
@ -46,7 +49,7 @@ export const exportToCanvas = ({
getNonDeletedElements(restoredElements),
{ ...restoredAppState, offsetTop: 0, offsetLeft: 0, width: 0, height: 0 },
files || {},
{ exportBackground, viewBackgroundColor },
{ exportBackground, exportPadding, viewBackgroundColor },
(width: number, height: number) => {
const canvas = document.createElement("canvas");
@ -87,6 +90,7 @@ export const exportToBlob = async (
opts: ExportOpts & {
mimeType?: string;
quality?: number;
exportPadding?: number;
},
): Promise<Blob> => {
let { mimeType = MIME_TYPES.png, quality } = opts;