Fix default behavior for copy svg / copy json

pull/289/head
Steve Ruiz 2021-11-18 11:39:00 +00:00
rodzic 3228ff6352
commit c965c12532
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -1451,7 +1451,9 @@ export class TldrawApp extends StateManager<TDSnapshot> {
* @returns A string containing the JSON.
*/
copySvg = (ids = this.selectedIds, pageId = this.currentPageId) => {
if (ids.length === 0) return
if (ids.length === 0) ids = Object.keys(this.page.shapes)
console.log(ids)
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
@ -1542,6 +1544,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
* @returns A string containing the JSON.
*/
copyJson = (ids = this.selectedIds, pageId = this.currentPageId) => {
if (ids.length === 0) ids = Object.keys(this.page.shapes)
const shapes = ids.map((id) => this.getShape(id, pageId))
const json = JSON.stringify(shapes, null, 2)
TLDR.copyStringToClipboard(json)