tldraw/apps/www/utils/export.ts
Steve Ruiz c54c800675
[improvement] local copy and export for images (#669)
* local images

use assets for local copy

add menu options

* clean up packages

* cleanup unused content, move file handling into app.paste

* Add tldraw-assets.json to other files.

* add path to editor

* Update build.mjs

* add export to server example with link to gist

* Fix onAssetCreate and onAssetDelete APIs

* Update yarn.lock

* fix bugs on paste, adjust api for getting images, fix readonly on cut, copy, paste

* re-enable swc

* paste svg strings as svg images

* cleanup

* fix string case for tldraw json
2022-05-11 14:25:08 +01:00

29 lines
921 B
TypeScript

import { TDExport } from '@tldraw/tldraw'
export const EXPORT_ENDPOINT =
process.env.NODE_ENV === 'development'
? 'http://localhost:3000/api/export'
: 'https://www.tldraw.com/api/export'
// export async function exportToImage(info: TDExport) {
// if (info.serialized) {
// const link = document.createElement('a')
// link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(info.serialized)
// link.download = info.name + '.' + info.type
// link.click()
// return
// }
// const response = await fetch(EXPORT_ENDPOINT, {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify(info),
// })
// const blob = await response.blob()
// const blobUrl = URL.createObjectURL(blob)
// const link = document.createElement('a')
// link.href = blobUrl
// link.download = info.name + '.' + info.type
// link.click()
// }