Fix default behavior for copy svg / copy json

This commit is contained in:
Steve Ruiz 2021-11-18 11:39:00 +00:00
parent 3228ff6352
commit c965c12532

View file

@ -1451,7 +1451,9 @@ export class TldrawApp extends StateManager<TDSnapshot> {
* @returns A string containing the JSON. * @returns A string containing the JSON.
*/ */
copySvg = (ids = this.selectedIds, pageId = this.currentPageId) => { 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') 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. * @returns A string containing the JSON.
*/ */
copyJson = (ids = this.selectedIds, pageId = this.currentPageId) => { 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 shapes = ids.map((id) => this.getShape(id, pageId))
const json = JSON.stringify(shapes, null, 2) const json = JSON.stringify(shapes, null, 2)
TLDR.copyStringToClipboard(json) TLDR.copyStringToClipboard(json)