Merge branch 'main' of https://github.com/tldraw/tldraw
This commit is contained in:
commit
1778a49272
4 changed files with 2640 additions and 535 deletions
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,7 @@ import { Tldraw, TldrawApp, TDFile, TDDocument } from '@tldraw/tldraw'
|
||||||
import { vscode } from './utils/vscode'
|
import { vscode } from './utils/vscode'
|
||||||
import { defaultDocument } from './utils/defaultDocument'
|
import { defaultDocument } from './utils/defaultDocument'
|
||||||
import type { MessageFromExtension, MessageFromWebview } from './types'
|
import type { MessageFromExtension, MessageFromWebview } from './types'
|
||||||
|
import { exportToImage } from 'utils/export'
|
||||||
|
|
||||||
// Will be placed in global scope by extension
|
// Will be placed in global scope by extension
|
||||||
declare let currentFile: TDFile
|
declare let currentFile: TDFile
|
||||||
|
@ -60,6 +61,7 @@ export default function App(): JSX.Element {
|
||||||
document={rInitialDocument.current}
|
document={rInitialDocument.current}
|
||||||
onMount={handleMount}
|
onMount={handleMount}
|
||||||
onPersist={handlePersist}
|
onPersist={handlePersist}
|
||||||
|
onExport={exportToImage}
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
29
apps/vscode/editor/src/utils/export.ts
Normal file
29
apps/vscode/editor/src/utils/export.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
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()
|
||||||
|
}
|
126
yarn.lock
126
yarn.lock
|
@ -1834,10 +1834,10 @@
|
||||||
globby "^11.0.0"
|
globby "^11.0.0"
|
||||||
read-yaml-file "^1.1.0"
|
read-yaml-file "^1.1.0"
|
||||||
|
|
||||||
"@next/env@12.0.10":
|
"@next/env@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.0.10.tgz#561640fd62279218ccd2798ae907bae8d94a7730"
|
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.1.0.tgz#73713399399b34aa5a01771fb73272b55b22c314"
|
||||||
integrity sha512-mQVj0K6wQ5WEk/sL9SZ+mJXJUaG7el8CpZ6io1uFe9GgNTSC7EgUyNGqM6IQovIFc5ukF4O/hqsdh3S/DCgT2g==
|
integrity sha512-nrIgY6t17FQ9xxwH3jj0a6EOiQ/WDHUos35Hghtr+SWN/ntHIQ7UpuvSi0vaLzZVHQWaDupKI+liO5vANcDeTQ==
|
||||||
|
|
||||||
"@next/eslint-plugin-next@12.0.10":
|
"@next/eslint-plugin-next@12.0.10":
|
||||||
version "12.0.10"
|
version "12.0.10"
|
||||||
|
@ -1846,60 +1846,60 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
glob "7.1.7"
|
glob "7.1.7"
|
||||||
|
|
||||||
"@next/swc-android-arm64@12.0.10":
|
"@next/swc-android-arm64@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-12.0.10.tgz#fd9d716433cc9d361021b0052f8b002bcaff948d"
|
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-12.1.0.tgz#865ba3a9afc204ff2bdeea49dd64d58705007a39"
|
||||||
integrity sha512-xYwXGkNhzZZsM5MD7KRwF5ZNiC8OLPtVMUiagpPnwENg8Hb0GSQo/NbYWXM8YrawEwp9LaZ7OXiuRKPh2JyBdA==
|
integrity sha512-/280MLdZe0W03stA69iL+v6I+J1ascrQ6FrXBlXGCsGzrfMaGr7fskMa0T5AhQIVQD4nA/46QQWxG//DYuFBcA==
|
||||||
|
|
||||||
"@next/swc-darwin-arm64@12.0.10":
|
"@next/swc-darwin-arm64@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.0.10.tgz#34b2d0dc62eb89efb9176af111e3820a11fdb3f0"
|
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.1.0.tgz#08e8b411b8accd095009ed12efbc2f1d4d547135"
|
||||||
integrity sha512-f2zngulkpIJKWHckhRi7X8GZ+J/tNgFF7lYIh7Qx15JH0OTBsjkqxORlkzy+VZyHJ5sWTCaI6HYYd3ow6qkEEg==
|
integrity sha512-R8vcXE2/iONJ1Unf5Ptqjk6LRW3bggH+8drNkkzH4FLEQkHtELhvcmJwkXcuipyQCsIakldAXhRbZmm3YN1vXg==
|
||||||
|
|
||||||
"@next/swc-darwin-x64@12.0.10":
|
"@next/swc-darwin-x64@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-12.0.10.tgz#a4306795159293c7d4d58a2c88ce1710ff0a8baa"
|
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-12.1.0.tgz#fcd684497a76e8feaca88db3c394480ff0b007cd"
|
||||||
integrity sha512-Qykcu/gVC5oTvOQoRBhyuS5GYm5SbcgrFTsaLFkGBmEkg9eMQRiaCswk4IafpDXVzITkVFurzSM28q3tLW2qUw==
|
integrity sha512-ieAz0/J0PhmbZBB8+EA/JGdhRHBogF8BWaeqR7hwveb6SYEIJaDNQy0I+ZN8gF8hLj63bEDxJAs/cEhdnTq+ug==
|
||||||
|
|
||||||
"@next/swc-linux-arm-gnueabihf@12.0.10":
|
"@next/swc-linux-arm-gnueabihf@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.0.10.tgz#1ad15af3d5fca2fef57894d61e16f73aee61ec2e"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.1.0.tgz#9ec6380a27938a5799aaa6035c205b3c478468a7"
|
||||||
integrity sha512-EhqrTFsIXAXN9B/fiiW/QKUK/lSLCXRsLalkUp58KDfMqVLLlj1ORbESAcswiNQOChLuHQSldGEEtOBPQZcd9A==
|
integrity sha512-njUd9hpl6o6A5d08dC0cKAgXKCzm5fFtgGe6i0eko8IAdtAPbtHxtpre3VeSxdZvuGFh+hb0REySQP9T1ttkog==
|
||||||
|
|
||||||
"@next/swc-linux-arm64-gnu@12.0.10":
|
"@next/swc-linux-arm64-gnu@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.0.10.tgz#a84a92d0e1a179c4346c9ed8f22e26f708101ad6"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.1.0.tgz#7f4196dff1049cea479607c75b81033ae2dbd093"
|
||||||
integrity sha512-kqGtC72g3+JYXZbY2ca6digXR5U6AQ6Dzv4eAxYluMePLHjI/Xye1mf9dwVsgmeXfrD/IRDp5K/3A6UNvBm4oQ==
|
integrity sha512-OqangJLkRxVxMhDtcb7Qn1xjzFA3s50EIxY7mljbSCLybU+sByPaWAHY4px97ieOlr2y4S0xdPKkQ3BCAwyo6Q==
|
||||||
|
|
||||||
"@next/swc-linux-arm64-musl@12.0.10":
|
"@next/swc-linux-arm64-musl@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.0.10.tgz#973ec96c77f845bd0a6eecbf1892caa1ee4defaf"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.1.0.tgz#b445f767569cdc2dddee785ca495e1a88c025566"
|
||||||
integrity sha512-bG9zTSNwnSgc1Un/7oz1ZVN4UeXsTWrsQhAGWU78lLLCn4Zj9HQoUCRCGLt0OVs2DBZ+WC8CzzFliQ1SKipVbg==
|
integrity sha512-hB8cLSt4GdmOpcwRe2UzI5UWn6HHO/vLkr5OTuNvCJ5xGDwpPXelVkYW/0+C3g5axbDW2Tym4S+MQCkkH9QfWA==
|
||||||
|
|
||||||
"@next/swc-linux-x64-gnu@12.0.10":
|
"@next/swc-linux-x64-gnu@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.0.10.tgz#efcc7f8252ea8225834760eaf09350f1bead73f7"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.1.0.tgz#67610e9be4fbc987de7535f1bcb17e45fe12f90e"
|
||||||
integrity sha512-c79PcfWtyThiYRa1+3KVfDq0zXaI8o1d6dQWNVqDrtLz5HKM/rbjLdvoNuxDwUeZhxI/d9CtyH6GbuKPw5l/5A==
|
integrity sha512-OKO4R/digvrVuweSw/uBM4nSdyzsBV5EwkUeeG4KVpkIZEe64ZwRpnFB65bC6hGwxIBnTv5NMSnJ+0K/WmG78A==
|
||||||
|
|
||||||
"@next/swc-linux-x64-musl@12.0.10":
|
"@next/swc-linux-x64-musl@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.0.10.tgz#c2a73d939dfd310acc1892a0a132762500dd5757"
|
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.1.0.tgz#ea19a23db08a9f2e34ac30401f774cf7d1669d31"
|
||||||
integrity sha512-g/scgn+21/MLfizOCZOZt+MxNj2/8Tdlwjvy+QZcSUPZRUI2Y5o3HwBvI1f/bSci+NGRU+bUAO0NFtRJ9MzH5w==
|
integrity sha512-JohhgAHZvOD3rQY7tlp7NlmvtvYHBYgY0x5ZCecUT6eCCcl9lv6iV3nfu82ErkxNk1H893fqH0FUpznZ/H3pSw==
|
||||||
|
|
||||||
"@next/swc-win32-arm64-msvc@12.0.10":
|
"@next/swc-win32-arm64-msvc@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.0.10.tgz#2316af5f612cde1691abdf2571ff40ec32ea3429"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.1.0.tgz#eadf054fc412085659b98e145435bbba200b5283"
|
||||||
integrity sha512-gl6B/ravwMeY5Nv4Il2/ARYJQ6u+KPRwGMjS1ZrNudIKlNn4YBeXh5A4cIVm+dHaff6/O/lGOa5/SUYDMZpkww==
|
integrity sha512-T/3gIE6QEfKIJ4dmJk75v9hhNiYZhQYAoYm4iVo1TgcsuaKLFa+zMPh4056AHiG6n9tn2UQ1CFE8EoybEsqsSw==
|
||||||
|
|
||||||
"@next/swc-win32-ia32-msvc@12.0.10":
|
"@next/swc-win32-ia32-msvc@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.0.10.tgz#98a4f74d164871cfaccb0df6efddf2b7bcbaa54b"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.1.0.tgz#68faeae10c89f698bf9d28759172b74c9c21bda1"
|
||||||
integrity sha512-7RVpZ3tSThC6j+iZB0CUYmFiA3kXmN+pE7QcfyAxFaflKlaZoWNMKHIEZDuxSJc6YmQ6kyxsjqxVay2F5+/YCg==
|
integrity sha512-iwnKgHJdqhIW19H9PRPM9j55V6RdcOo6rX+5imx832BCWzkDbyomWnlzBfr6ByUYfhohb8QuH4hSGEikpPqI0Q==
|
||||||
|
|
||||||
"@next/swc-win32-x64-msvc@12.0.10":
|
"@next/swc-win32-x64-msvc@12.1.0":
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.0.10.tgz#5c0ba98b695c4be44d8793aff42971a0dac65c2d"
|
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.1.0.tgz#d27e7e76c87a460a4da99c5bfdb1618dcd6cd064"
|
||||||
integrity sha512-oUIWRKd24jFLRWUYO1CZmML5+32BcpVfqhimGaaZIXcOkfQW+iqiAzdqsv688zaGtyKGeB9ZtiK3NDf+Q0v+Vw==
|
integrity sha512-aBvcbMwuanDH4EMrL2TthNJy+4nP59Bimn8egqv6GHMVj0a44cU6Au4PjOhLNqEh9l+IpRGBqMTzec94UdC5xg==
|
||||||
|
|
||||||
"@node-rs/xxhash-android-arm-eabi@1.2.0":
|
"@node-rs/xxhash-android-arm-eabi@1.2.0":
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
|
@ -8105,27 +8105,27 @@ next-transpile-modules@^9.0.0:
|
||||||
escalade "^3.1.1"
|
escalade "^3.1.1"
|
||||||
|
|
||||||
next@^12.0.7:
|
next@^12.0.7:
|
||||||
version "12.0.10"
|
version "12.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/next/-/next-12.0.10.tgz#fcc4584177418bd777ce157f3165b7ba5e7708f7"
|
resolved "https://registry.yarnpkg.com/next/-/next-12.1.0.tgz#c33d753b644be92fc58e06e5a214f143da61dd5d"
|
||||||
integrity sha512-1y3PpGzpb/EZzz1jgne+JfZXKAVJUjYXwxzrADf/LWN+8yi9o79vMLXpW3mevvCHkEF2sBnIdjzNn16TJrINUw==
|
integrity sha512-s885kWvnIlxsUFHq9UGyIyLiuD0G3BUC/xrH0CEnH5lHEWkwQcHOORgbDF0hbrW9vr/7am4ETfX4A7M6DjrE7Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@next/env" "12.0.10"
|
"@next/env" "12.1.0"
|
||||||
caniuse-lite "^1.0.30001283"
|
caniuse-lite "^1.0.30001283"
|
||||||
postcss "8.4.5"
|
postcss "8.4.5"
|
||||||
styled-jsx "5.0.0"
|
styled-jsx "5.0.0"
|
||||||
use-subscription "1.5.1"
|
use-subscription "1.5.1"
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
"@next/swc-android-arm64" "12.0.10"
|
"@next/swc-android-arm64" "12.1.0"
|
||||||
"@next/swc-darwin-arm64" "12.0.10"
|
"@next/swc-darwin-arm64" "12.1.0"
|
||||||
"@next/swc-darwin-x64" "12.0.10"
|
"@next/swc-darwin-x64" "12.1.0"
|
||||||
"@next/swc-linux-arm-gnueabihf" "12.0.10"
|
"@next/swc-linux-arm-gnueabihf" "12.1.0"
|
||||||
"@next/swc-linux-arm64-gnu" "12.0.10"
|
"@next/swc-linux-arm64-gnu" "12.1.0"
|
||||||
"@next/swc-linux-arm64-musl" "12.0.10"
|
"@next/swc-linux-arm64-musl" "12.1.0"
|
||||||
"@next/swc-linux-x64-gnu" "12.0.10"
|
"@next/swc-linux-x64-gnu" "12.1.0"
|
||||||
"@next/swc-linux-x64-musl" "12.0.10"
|
"@next/swc-linux-x64-musl" "12.1.0"
|
||||||
"@next/swc-win32-arm64-msvc" "12.0.10"
|
"@next/swc-win32-arm64-msvc" "12.1.0"
|
||||||
"@next/swc-win32-ia32-msvc" "12.0.10"
|
"@next/swc-win32-ia32-msvc" "12.1.0"
|
||||||
"@next/swc-win32-x64-msvc" "12.0.10"
|
"@next/swc-win32-x64-msvc" "12.1.0"
|
||||||
|
|
||||||
node-addon-api@^1.6.3:
|
node-addon-api@^1.6.3:
|
||||||
version "1.7.2"
|
version "1.7.2"
|
||||||
|
|
Loading…
Reference in a new issue