From 81f6fae070ada42f6eb7e17af09bea13cc4003ca Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Wed, 15 Nov 2023 18:40:20 +0000 Subject: [PATCH] Add `getSvgAsImage` to exports. (#2229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds `getSvgAsImage` to the package's exports. ### Change Type - [x] `minor` — New feature --- packages/tldraw/api-report.md | 7 +++ packages/tldraw/api/api.json | 92 +++++++++++++++++++++++++++++++++++ packages/tldraw/src/index.ts | 1 + 3 files changed, 100 insertions(+) diff --git a/packages/tldraw/api-report.md b/packages/tldraw/api-report.md index 0d3ac971b..592058c4e 100644 --- a/packages/tldraw/api-report.md +++ b/packages/tldraw/api-report.md @@ -685,6 +685,13 @@ export function getResizedImageDataUrl(dataURLForImage: string, width: number, h quality?: number | undefined; }): Promise; +// @public (undocumented) +export function getSvgAsImage(svg: SVGElement, isSafari: boolean, options: { + type: 'jpeg' | 'png' | 'svg' | 'webp'; + quality: number; + scale: number; +}): Promise; + // @public (undocumented) function Group({ children, size, }: { children: any; diff --git a/packages/tldraw/api/api.json b/packages/tldraw/api/api.json index 6cbfabd54..2f52e844f 100644 --- a/packages/tldraw/api/api.json +++ b/packages/tldraw/api/api.json @@ -7618,6 +7618,98 @@ ], "name": "getResizedImageDataUrl" }, + { + "kind": "Function", + "canonicalReference": "@tldraw/tldraw!getSvgAsImage:function(1)", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export declare function getSvgAsImage(svg: " + }, + { + "kind": "Reference", + "text": "SVGElement", + "canonicalReference": "!SVGElement:interface" + }, + { + "kind": "Content", + "text": ", isSafari: " + }, + { + "kind": "Content", + "text": "boolean" + }, + { + "kind": "Content", + "text": ", options: " + }, + { + "kind": "Content", + "text": "{\n type: 'jpeg' | 'png' | 'svg' | 'webp';\n quality: number;\n scale: number;\n}" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "Blob", + "canonicalReference": "!Blob:interface" + }, + { + "kind": "Content", + "text": " | null>" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "packages/tldraw/src/lib/utils/export/export.ts", + "returnTypeTokenRange": { + "startIndex": 7, + "endIndex": 11 + }, + "releaseTag": "Public", + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "svg", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "isSafari", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 4 + }, + "isOptional": false + }, + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 5, + "endIndex": 6 + }, + "isOptional": false + } + ], + "name": "getSvgAsImage" + }, { "kind": "Class", "canonicalReference": "@tldraw/tldraw!HandTool:class", diff --git a/packages/tldraw/src/index.ts b/packages/tldraw/src/index.ts index 405ec6849..775b77b71 100644 --- a/packages/tldraw/src/index.ts +++ b/packages/tldraw/src/index.ts @@ -151,6 +151,7 @@ export { } from './lib/utils/assets/assets' export { getEmbedInfo } from './lib/utils/embeds/embeds' export { copyAs } from './lib/utils/export/copyAs' +export { getSvgAsImage } from './lib/utils/export/export' export { exportAs } from './lib/utils/export/exportAs' export { setDefaultEditorAssetUrls } from './lib/utils/static-assets/assetUrls' export { truncateStringWithEllipsis } from './lib/utils/text/text'