tldraw 4.3.0-canary.fda2775019a1 → 4.3.0-next.085293d79c32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +1 -1
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +20 -20
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/test-helpers.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +1 -1
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +1 -1
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +20 -20
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +3 -3
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +1 -1
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +10 -10
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -2
- package/src/lib/shapes/draw/getPath.ts +1 -1
- package/src/lib/shapes/draw/toolStates/Drawing.ts +21 -21
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +10 -10
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +4 -2
- package/src/lib/shapes/shared/interpolate-props.ts +3 -3
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +4 -4
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/test-helpers.ts +4 -2
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -1
- package/src/test/__snapshots__/drawing.test.ts.snap +1 -1
- package/src/test/__snapshots__/resizing.test.ts.snap +1 -1
- package/src/test/drawing.test.ts +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/ui/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '4.3.0-
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '4.3.0-next.085293d79c32'\nexport const publishDates = {\n\tmajor: '2025-09-18T14:39:22.803Z',\n\tminor: '2026-01-21T10:25:57.296Z',\n\tpatch: '2026-01-21T10:25:57.296Z',\n}\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/excalidraw/putExcalidrawContent.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tAssetRecordType,\n\tBox,\n\tEditor,\n\tTLArrowShapeArrowheadStyle,\n\tTLAssetId,\n\tTLContent,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFillStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLOpacityType,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tVecModel,\n\tZERO_INDEX_KEY,\n\tb64Vecs,\n\tcompact,\n\tcreateBindingId,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tgetIndices,\n\tisShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/**\n * Put excalidraw clipboard content onto the current page.\n *\n * @param editor - The editor instance.\n * @param excalidrawClipboardContent - The excalidraw clipboard model.\n * @param point - The point at which to put the excalidraw content.\n * @public\n */\nexport async function putExcalidrawContent(\n\teditor: Editor,\n\texcalidrawClipboardContent: any,\n\tpoint?: VecLike\n) {\n\tconst { elements, files } = excalidrawClipboardContent\n\n\tconst tldrawContent: TLContent = {\n\t\tshapes: [],\n\t\tbindings: [],\n\t\trootShapeIds: [],\n\t\tassets: [],\n\t\tschema: editor.store.schema.serialize(),\n\t}\n\n\tconst groupShapeIdToChildren = new Map<string, TLShapeId[]>()\n\tconst rotatedElements = new Map<TLShapeId, number>()\n\n\tconst currentPageId = editor.getCurrentPageId()\n\n\tconst excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()\n\tconst rootShapeIds: TLShapeId[] = []\n\n\tconst skipIds = new Set<string>()\n\n\telements.forEach((element: any) => {\n\t\texcElementIdsToTldrawShapeIds.set(element.id, createShapeId())\n\n\t\tif (element.boundElements !== null) {\n\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\tskipIds.add(boundElement.id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tlet index = ZERO_INDEX_KEY\n\n\tfor (const element of elements) {\n\t\tif (skipIds.has(element.id)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst id = excElementIdsToTldrawShapeIds.get(element.id)!\n\n\t\tconst base = {\n\t\t\tid,\n\t\t\ttypeName: 'shape',\n\t\t\tparentId: currentPageId,\n\t\t\tindex,\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\trotation: 0,\n\t\t\tisLocked: element.locked,\n\t\t\topacity: getOpacity(element.opacity),\n\t\t\tmeta: {},\n\t\t} as const\n\n\t\tif (element.angle !== 0) {\n\t\t\trotatedElements.set(id, element.angle)\n\t\t}\n\n\t\tif (element.groupIds && element.groupIds.length > 0) {\n\t\t\tif (groupShapeIdToChildren.has(element.groupIds[0])) {\n\t\t\t\tgroupShapeIdToChildren.get(element.groupIds[0])?.push(id)\n\t\t\t} else {\n\t\t\t\tgroupShapeIdToChildren.set(element.groupIds[0], [id])\n\t\t\t}\n\t\t} else {\n\t\t\trootShapeIds.push(id)\n\t\t}\n\n\t\tswitch (element.type) {\n\t\t\tcase 'rectangle':\n\t\t\tcase 'ellipse':\n\t\t\tcase 'diamond': {\n\t\t\t\tlet text = ''\n\t\t\t\tlet align: TLDefaultHorizontalAlignStyle = 'middle'\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t\talign = textAlignToAlignTypes[labelElement.textAlign]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst colorToUse =\n\t\t\t\t\telement.backgroundColor === 'transparent' ? element.strokeColor : element.backgroundColor\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'geo',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('geo').getDefaultProps(),\n\t\t\t\t\t\tgeo: element.type,\n\t\t\t\t\t\turl: element.link ?? '',\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[colorToUse] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tfill: getFill(element),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'freedraw': {\n\t\t\t\tconst points: VecModel[] = element.points.map(([x, y, z = 0.5]: number[]) => ({\n\t\t\t\t\tx,\n\t\t\t\t\ty,\n\t\t\t\t\tz,\n\t\t\t\t}))\n\t\t\t\tconst base64Points = b64Vecs.encodePoints(points)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'draw',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('draw').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\tpoints: base64Points,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'line': {\n\t\t\t\tconst points = element.points.slice()\n\t\t\t\tif (points.length < 2) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tconst indices = getIndices(element.points.length)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('line').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tspline: element.roundness ? 'cubic' : 'line',\n\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\t\t\telement.points.map(([x, y]: number[], i: number) => {\n\t\t\t\t\t\t\t\t\tconst index = indices[i]\n\t\t\t\t\t\t\t\t\treturn [index, { id: index, index, x, y }]\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'arrow': {\n\t\t\t\tlet text = ''\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst start = element.points[0]\n\t\t\t\tconst end = element.points[element.points.length - 1]\n\n\t\t\t\tconst startTargetId = excElementIdsToTldrawShapeIds.get(element.startBinding?.elementId)\n\t\t\t\tconst endTargetId = excElementIdsToTldrawShapeIds.get(element.endBinding?.elementId)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('arrow').getDefaultProps(),\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\tkind: element.elbowed ? 'elbow' : 'arc',\n\t\t\t\t\t\tbend: getBend(element, start, end),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'm',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tstart: { x: start[0], y: start[1] },\n\t\t\t\t\t\tend: { x: end[0], y: end[1] },\n\t\t\t\t\t\tarrowheadEnd: arrowheadsToArrowheadTypes[element.endArrowhead] ?? 'none',\n\t\t\t\t\t\tarrowheadStart: arrowheadsToArrowheadTypes[element.startArrowhead] ?? 'none',\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (startTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: startTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'start',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (endTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: endTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'end',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'text': {\n\t\t\t\tconst { size, scale } = getFontSizeAndScale(element.fontSize)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('text').getDefaultProps(),\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale,\n\t\t\t\t\t\tfont: fontFamilyToFontType[element.fontFamily] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(element.text),\n\t\t\t\t\t\ttextAlign: textAlignToTextAlignTypes[element.textAlign],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'image': {\n\t\t\t\tconst file = files[element.fileId]\n\t\t\t\tif (!file) break\n\n\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\ttldrawContent.assets.push({\n\t\t\t\t\tid: assetId,\n\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tfileSize: file.size,\n\t\t\t\t\t\tname: element.id ?? 'Untitled',\n\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\tmimeType: file.mimeType,\n\t\t\t\t\t\tsrc: file.dataURL,\n\t\t\t\t\t},\n\t\t\t\t\tmeta: {},\n\t\t\t\t})\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('image').getDefaultProps(),\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tassetId,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tindex = getIndexAbove(index)\n\t}\n\n\tconst p = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : undefined)\n\n\teditor.putContentOntoCurrentPage(tldrawContent, {\n\t\tpoint: p,\n\t\tselect: false,\n\t\tpreserveIds: true,\n\t})\n\tfor (const groupedShapeIds of groupShapeIdToChildren.values()) {\n\t\tif (groupedShapeIds.length > 1) {\n\t\t\teditor.groupShapes(groupedShapeIds)\n\t\t\tconst groupShape = editor.getShape(groupedShapeIds[0])\n\t\t\tif (groupShape?.parentId && isShapeId(groupShape.parentId)) {\n\t\t\t\trootShapeIds.push(groupShape.parentId)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [id, angle] of rotatedElements) {\n\t\teditor.select(id)\n\t\teditor.rotateShapesBy([id], angle)\n\t}\n\n\tconst rootShapes = compact(rootShapeIds.map((id) => editor.getShape(id)))\n\tconst bounds = Box.Common(rootShapes.map((s) => editor.getShapePageBounds(s)!))\n\tconst viewPortCenter = editor.getViewportPageBounds().center\n\teditor.updateShapes(\n\t\trootShapes.map((s) => {\n\t\t\tconst delta = {\n\t\t\t\tx: (s.x ?? 0) - (bounds.x + bounds.w / 2),\n\t\t\t\ty: (s.y ?? 0) - (bounds.y + bounds.h / 2),\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: s.id,\n\t\t\t\ttype: s.type,\n\t\t\t\tx: viewPortCenter.x + delta.x,\n\t\t\t\ty: viewPortCenter.y + delta.y,\n\t\t\t}\n\t\t})\n\t)\n\teditor.setSelectedShapes(rootShapeIds)\n}\n\n/* --------------- Translating Helpers --------_------ */\n\nconst getOpacity = (opacity: number): TLOpacityType => {\n\tconst t = opacity / 100\n\tif (t < 0.2) {\n\t\treturn 0.1\n\t} else if (t < 0.4) {\n\t\treturn 0.25\n\t} else if (t < 0.6) {\n\t\treturn 0.5\n\t} else if (t < 0.8) {\n\t\treturn 0.75\n\t}\n\n\treturn 1\n}\n\nconst strokeWidthsToSizes: Record<number, TLDefaultSizeStyle> = {\n\t1: 's',\n\t2: 'm',\n\t3: 'l',\n\t4: 'xl',\n}\n\nconst fontSizesToSizes: Record<number, TLDefaultSizeStyle> = {\n\t16: 's',\n\t20: 'm',\n\t28: 'l',\n\t36: 'xl',\n}\n\nfunction getFontSizeAndScale(fontSize: number): { size: TLDefaultSizeStyle; scale: number } {\n\tconst size = fontSizesToSizes[fontSize]\n\tif (size) {\n\t\treturn { size, scale: 1 }\n\t}\n\tif (fontSize < 16) {\n\t\treturn { size: 's', scale: fontSize / 16 }\n\t}\n\tif (fontSize > 36) {\n\t\treturn { size: 'xl', scale: fontSize / 36 }\n\t}\n\treturn { size: 'm', scale: 1 }\n}\n\nconst fontFamilyToFontType: Record<number, TLDefaultFontStyle> = {\n\t1: 'draw',\n\t2: 'sans',\n\t3: 'mono',\n}\n\nconst oc = {\n\tgray: ['#f8f9fa', '#e9ecef', '#ced4da', '#868e96', '#343a40'],\n\tred: ['#fff5f5', '#ffc9c9', '#ff8787', '#fa5252', '#e03131'],\n\tpink: ['#fff0f6', '#fcc2d7', '#f783ac', '#e64980', '#c2255c'],\n\tgrape: ['#f8f0fc', '#eebefa', '#da77f2', '#be4bdb', '#9c36b5'],\n\tviolet: ['#f3f0ff', '#d0bfff', '#9775fa', '#7950f2', '#6741d9'],\n\tindigo: ['#edf2ff', '#bac8ff', '#748ffc', '#4c6ef5', '#3b5bdb'],\n\tblue: ['#e7f5ff', '#a5d8ff', '#4dabf7', '#228be6', '#1971c2'],\n\tcyan: ['#e3fafc', '#99e9f2', '#3bc9db', '#15aabf', '#0c8599'],\n\tteal: ['#e6fcf5', '#96f2d7', '#38d9a9', '#12b886', '#099268'],\n\tgreen: ['#ebfbee', '#b2f2bb', '#69db7c', '#40c057', '#2f9e44'],\n\tlime: ['#f4fce3', '#d8f5a2', '#a9e34b', '#82c91e', '#66a80f'],\n\tyellow: ['#fff9db', '#ffec99', '#ffd43b', '#fab005', '#f08c00'],\n\torange: ['#fff4e6', '#ffd8a8', '#ffa94d', '#fd7e14', '#e8590c'],\n}\n\nfunction mapExcalidrawColorToTldrawColors(\n\texcalidrawColor: keyof typeof oc,\n\tlight: TLDefaultColorStyle,\n\tdark: TLDefaultColorStyle\n) {\n\tconst colors = [0, 1, 2, 3, 4].map((index) => oc[excalidrawColor][index])\n\treturn Object.fromEntries(colors.map((c, i) => [c, i < 3 ? light : dark]))\n}\n\nconst colorsToColors: Record<string, TLDefaultColorStyle> = {\n\t...mapExcalidrawColorToTldrawColors('gray', 'grey', 'black'),\n\t...mapExcalidrawColorToTldrawColors('red', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('pink', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('grape', 'light-violet', 'violet'),\n\t...mapExcalidrawColorToTldrawColors('blue', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('cyan', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('teal', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('green', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('yellow', 'yellow', 'orange'),\n\t...mapExcalidrawColorToTldrawColors('orange', 'yellow', 'orange'),\n\t'#ffffff': 'white',\n\t'#000000': 'black',\n}\n\nconst strokeStylesToStrokeTypes: Record<string, TLDefaultDashStyle> = {\n\tsolid: 'draw',\n\tdashed: 'dashed',\n\tdotted: 'dotted',\n}\n\nconst fillStylesToFillType: Record<string, TLDefaultFillStyle> = {\n\t'cross-hatch': 'pattern',\n\thachure: 'pattern',\n\tsolid: 'solid',\n}\n\nconst textAlignToAlignTypes: Record<string, TLDefaultHorizontalAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst textAlignToTextAlignTypes: Record<string, TLDefaultTextAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst arrowheadsToArrowheadTypes: Record<string, TLArrowShapeArrowheadStyle> = {\n\tarrow: 'arrow',\n\tdot: 'dot',\n\ttriangle: 'triangle',\n\tbar: 'pipe',\n}\n\nfunction getBend(element: any, startPoint: any, endPoint: any) {\n\tlet bend = 0\n\tif (element.points.length > 2) {\n\t\tconst start = new Vec(startPoint[0], startPoint[1])\n\t\tconst end = new Vec(endPoint[0], endPoint[1])\n\t\tconst handle = new Vec(element.points[1][0], element.points[1][1])\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tbend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t}\n\treturn bend\n}\n\nconst getDash = (element: any): TLDefaultDashStyle => {\n\tlet dash: TLDefaultDashStyle = strokeStylesToStrokeTypes[element.strokeStyle] ?? 'draw'\n\tif (dash === 'draw' && element.roughness === 0) {\n\t\tdash = 'solid'\n\t}\n\treturn dash\n}\n\nconst getFill = (element: any): TLDefaultFillStyle => {\n\tif (element.backgroundColor === 'transparent') {\n\t\treturn 'none'\n\t}\n\treturn fillStylesToFillType[element.fillStyle] ?? 'solid'\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EAcA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUP,eAAsB,qBACrB,QACA,4BACA,OACC;AACD,QAAM,EAAE,UAAU,MAAM,IAAI;AAE5B,QAAM,gBAA2B;AAAA,IAChC,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,cAAc,CAAC;AAAA,IACf,QAAQ,CAAC;AAAA,IACT,QAAQ,OAAO,MAAM,OAAO,UAAU;AAAA,EACvC;AAEA,QAAM,yBAAyB,oBAAI,IAAyB;AAC5D,QAAM,kBAAkB,oBAAI,IAAuB;AAEnD,QAAM,gBAAgB,OAAO,iBAAiB;AAE9C,QAAM,gCAAgC,oBAAI,IAAuB;AACjE,QAAM,eAA4B,CAAC;AAEnC,QAAM,UAAU,oBAAI,IAAY;AAEhC,WAAS,QAAQ,CAAC,YAAiB;AAClC,kCAA8B,IAAI,QAAQ,IAAI,cAAc,CAAC;AAE7D,QAAI,QAAQ,kBAAkB,MAAM;AACnC,iBAAW,gBAAgB,QAAQ,eAAe;AACjD,YAAI,aAAa,SAAS,QAAQ;AACjC,kBAAQ,IAAI,aAAa,EAAE;AAAA,QAC5B;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,QAAQ;AAEZ,aAAW,WAAW,UAAU;AAC/B,QAAI,QAAQ,IAAI,QAAQ,EAAE,GAAG;AAC5B;AAAA,IACD;AAEA,UAAM,KAAK,8BAA8B,IAAI,QAAQ,EAAE;AAEvD,UAAM,OAAO;AAAA,MACZ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,GAAG;AAC9B,UAAM,QAAQ,IAAI,IAAI,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC;AAClD,UAAM,MAAM,IAAI,IAAI,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;AAC5C,UAAM,SAAS,IAAI,IAAI,QAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,CAAC,CAAC;AACjE,UAAM,QAAQ,IAAI,IAAI,KAAK,KAAK;AAChC,UAAM,IAAI,IAAI,IAAI,KAAK;AAEvB,UAAM,MAAM,IAAI,IAAI,KAAK,KAAK;AAC9B,UAAM,IAAI,IAAI,IAAI,KAAK,CAAC;AACxB,UAAM,IAAI,IAAI,IAAI,KAAK,CAAC;AAExB,UAAM,QAAQ,IAAI,0BAA0B,GAAG,GAAG,QAAQ,KAAK;AAC/D,WAAO,IAAI,KAAK,OAAO,GAAG;AAC1B,QAAI,IAAI,UAAU,OAAO,KAAK,GAAG,EAAG,SAAQ;AAAA,EAC7C;AACA,SAAO;AACR;AAEA,MAAM,UAAU,CAAC,YAAqC;AACrD,MAAI,OAA2B,0BAA0B,QAAQ,WAAW,KAAK;AACjF,MAAI,SAAS,UAAU,QAAQ,cAAc,GAAG;AAC/C,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,MAAM,UAAU,CAAC,YAAqC;AACrD,MAAI,QAAQ,oBAAoB,eAAe;AAC9C,WAAO;AAAA,EACR;AACA,SAAO,qBAAqB,QAAQ,SAAS,KAAK;AACnD;",
|
|
4
|
+
"sourcesContent": ["import {\n\tAssetRecordType,\n\tBox,\n\tEditor,\n\tTLArrowShapeArrowheadStyle,\n\tTLAssetId,\n\tTLContent,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFillStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLOpacityType,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tVecModel,\n\tZERO_INDEX_KEY,\n\tb64Vecs,\n\tcompact,\n\tcreateBindingId,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tgetIndices,\n\tisShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/**\n * Put excalidraw clipboard content onto the current page.\n *\n * @param editor - The editor instance.\n * @param excalidrawClipboardContent - The excalidraw clipboard model.\n * @param point - The point at which to put the excalidraw content.\n * @public\n */\nexport async function putExcalidrawContent(\n\teditor: Editor,\n\texcalidrawClipboardContent: any,\n\tpoint?: VecLike\n) {\n\tconst { elements, files } = excalidrawClipboardContent\n\n\tconst tldrawContent: TLContent = {\n\t\tshapes: [],\n\t\tbindings: [],\n\t\trootShapeIds: [],\n\t\tassets: [],\n\t\tschema: editor.store.schema.serialize(),\n\t}\n\n\tconst groupShapeIdToChildren = new Map<string, TLShapeId[]>()\n\tconst rotatedElements = new Map<TLShapeId, number>()\n\n\tconst currentPageId = editor.getCurrentPageId()\n\n\tconst excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()\n\tconst rootShapeIds: TLShapeId[] = []\n\n\tconst skipIds = new Set<string>()\n\n\telements.forEach((element: any) => {\n\t\texcElementIdsToTldrawShapeIds.set(element.id, createShapeId())\n\n\t\tif (element.boundElements !== null) {\n\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\tskipIds.add(boundElement.id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tlet index = ZERO_INDEX_KEY\n\n\tfor (const element of elements) {\n\t\tif (skipIds.has(element.id)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst id = excElementIdsToTldrawShapeIds.get(element.id)!\n\n\t\tconst base = {\n\t\t\tid,\n\t\t\ttypeName: 'shape',\n\t\t\tparentId: currentPageId,\n\t\t\tindex,\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\trotation: 0,\n\t\t\tisLocked: element.locked,\n\t\t\topacity: getOpacity(element.opacity),\n\t\t\tmeta: {},\n\t\t} as const\n\n\t\tif (element.angle !== 0) {\n\t\t\trotatedElements.set(id, element.angle)\n\t\t}\n\n\t\tif (element.groupIds && element.groupIds.length > 0) {\n\t\t\tif (groupShapeIdToChildren.has(element.groupIds[0])) {\n\t\t\t\tgroupShapeIdToChildren.get(element.groupIds[0])?.push(id)\n\t\t\t} else {\n\t\t\t\tgroupShapeIdToChildren.set(element.groupIds[0], [id])\n\t\t\t}\n\t\t} else {\n\t\t\trootShapeIds.push(id)\n\t\t}\n\n\t\tswitch (element.type) {\n\t\t\tcase 'rectangle':\n\t\t\tcase 'ellipse':\n\t\t\tcase 'diamond': {\n\t\t\t\tlet text = ''\n\t\t\t\tlet align: TLDefaultHorizontalAlignStyle = 'middle'\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t\talign = textAlignToAlignTypes[labelElement.textAlign]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst colorToUse =\n\t\t\t\t\telement.backgroundColor === 'transparent' ? element.strokeColor : element.backgroundColor\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'geo',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('geo').getDefaultProps(),\n\t\t\t\t\t\tgeo: element.type,\n\t\t\t\t\t\turl: element.link ?? '',\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[colorToUse] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tfill: getFill(element),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'freedraw': {\n\t\t\t\tconst points: VecModel[] = element.points.map(([x, y, z = 0.5]: number[]) => ({\n\t\t\t\t\tx,\n\t\t\t\t\ty,\n\t\t\t\t\tz,\n\t\t\t\t}))\n\t\t\t\tconst base64Points = b64Vecs.encodePoints(points)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'draw',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('draw').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\tpath: base64Points,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'line': {\n\t\t\t\tconst points = element.points.slice()\n\t\t\t\tif (points.length < 2) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tconst indices = getIndices(element.points.length)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('line').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tspline: element.roundness ? 'cubic' : 'line',\n\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\t\t\telement.points.map(([x, y]: number[], i: number) => {\n\t\t\t\t\t\t\t\t\tconst index = indices[i]\n\t\t\t\t\t\t\t\t\treturn [index, { id: index, index, x, y }]\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'arrow': {\n\t\t\t\tlet text = ''\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst start = element.points[0]\n\t\t\t\tconst end = element.points[element.points.length - 1]\n\n\t\t\t\tconst startTargetId = excElementIdsToTldrawShapeIds.get(element.startBinding?.elementId)\n\t\t\t\tconst endTargetId = excElementIdsToTldrawShapeIds.get(element.endBinding?.elementId)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('arrow').getDefaultProps(),\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\tkind: element.elbowed ? 'elbow' : 'arc',\n\t\t\t\t\t\tbend: getBend(element, start, end),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'm',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tstart: { x: start[0], y: start[1] },\n\t\t\t\t\t\tend: { x: end[0], y: end[1] },\n\t\t\t\t\t\tarrowheadEnd: arrowheadsToArrowheadTypes[element.endArrowhead] ?? 'none',\n\t\t\t\t\t\tarrowheadStart: arrowheadsToArrowheadTypes[element.startArrowhead] ?? 'none',\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (startTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: startTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'start',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (endTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: endTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'end',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'text': {\n\t\t\t\tconst { size, scale } = getFontSizeAndScale(element.fontSize)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('text').getDefaultProps(),\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale,\n\t\t\t\t\t\tfont: fontFamilyToFontType[element.fontFamily] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(element.text),\n\t\t\t\t\t\ttextAlign: textAlignToTextAlignTypes[element.textAlign],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'image': {\n\t\t\t\tconst file = files[element.fileId]\n\t\t\t\tif (!file) break\n\n\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\ttldrawContent.assets.push({\n\t\t\t\t\tid: assetId,\n\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tfileSize: file.size,\n\t\t\t\t\t\tname: element.id ?? 'Untitled',\n\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\tmimeType: file.mimeType,\n\t\t\t\t\t\tsrc: file.dataURL,\n\t\t\t\t\t},\n\t\t\t\t\tmeta: {},\n\t\t\t\t})\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('image').getDefaultProps(),\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tassetId,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tindex = getIndexAbove(index)\n\t}\n\n\tconst p = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : undefined)\n\n\teditor.putContentOntoCurrentPage(tldrawContent, {\n\t\tpoint: p,\n\t\tselect: false,\n\t\tpreserveIds: true,\n\t})\n\tfor (const groupedShapeIds of groupShapeIdToChildren.values()) {\n\t\tif (groupedShapeIds.length > 1) {\n\t\t\teditor.groupShapes(groupedShapeIds)\n\t\t\tconst groupShape = editor.getShape(groupedShapeIds[0])\n\t\t\tif (groupShape?.parentId && isShapeId(groupShape.parentId)) {\n\t\t\t\trootShapeIds.push(groupShape.parentId)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [id, angle] of rotatedElements) {\n\t\teditor.select(id)\n\t\teditor.rotateShapesBy([id], angle)\n\t}\n\n\tconst rootShapes = compact(rootShapeIds.map((id) => editor.getShape(id)))\n\tconst bounds = Box.Common(rootShapes.map((s) => editor.getShapePageBounds(s)!))\n\tconst viewPortCenter = editor.getViewportPageBounds().center\n\teditor.updateShapes(\n\t\trootShapes.map((s) => {\n\t\t\tconst delta = {\n\t\t\t\tx: (s.x ?? 0) - (bounds.x + bounds.w / 2),\n\t\t\t\ty: (s.y ?? 0) - (bounds.y + bounds.h / 2),\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: s.id,\n\t\t\t\ttype: s.type,\n\t\t\t\tx: viewPortCenter.x + delta.x,\n\t\t\t\ty: viewPortCenter.y + delta.y,\n\t\t\t}\n\t\t})\n\t)\n\teditor.setSelectedShapes(rootShapeIds)\n}\n\n/* --------------- Translating Helpers --------_------ */\n\nconst getOpacity = (opacity: number): TLOpacityType => {\n\tconst t = opacity / 100\n\tif (t < 0.2) {\n\t\treturn 0.1\n\t} else if (t < 0.4) {\n\t\treturn 0.25\n\t} else if (t < 0.6) {\n\t\treturn 0.5\n\t} else if (t < 0.8) {\n\t\treturn 0.75\n\t}\n\n\treturn 1\n}\n\nconst strokeWidthsToSizes: Record<number, TLDefaultSizeStyle> = {\n\t1: 's',\n\t2: 'm',\n\t3: 'l',\n\t4: 'xl',\n}\n\nconst fontSizesToSizes: Record<number, TLDefaultSizeStyle> = {\n\t16: 's',\n\t20: 'm',\n\t28: 'l',\n\t36: 'xl',\n}\n\nfunction getFontSizeAndScale(fontSize: number): { size: TLDefaultSizeStyle; scale: number } {\n\tconst size = fontSizesToSizes[fontSize]\n\tif (size) {\n\t\treturn { size, scale: 1 }\n\t}\n\tif (fontSize < 16) {\n\t\treturn { size: 's', scale: fontSize / 16 }\n\t}\n\tif (fontSize > 36) {\n\t\treturn { size: 'xl', scale: fontSize / 36 }\n\t}\n\treturn { size: 'm', scale: 1 }\n}\n\nconst fontFamilyToFontType: Record<number, TLDefaultFontStyle> = {\n\t1: 'draw',\n\t2: 'sans',\n\t3: 'mono',\n}\n\nconst oc = {\n\tgray: ['#f8f9fa', '#e9ecef', '#ced4da', '#868e96', '#343a40'],\n\tred: ['#fff5f5', '#ffc9c9', '#ff8787', '#fa5252', '#e03131'],\n\tpink: ['#fff0f6', '#fcc2d7', '#f783ac', '#e64980', '#c2255c'],\n\tgrape: ['#f8f0fc', '#eebefa', '#da77f2', '#be4bdb', '#9c36b5'],\n\tviolet: ['#f3f0ff', '#d0bfff', '#9775fa', '#7950f2', '#6741d9'],\n\tindigo: ['#edf2ff', '#bac8ff', '#748ffc', '#4c6ef5', '#3b5bdb'],\n\tblue: ['#e7f5ff', '#a5d8ff', '#4dabf7', '#228be6', '#1971c2'],\n\tcyan: ['#e3fafc', '#99e9f2', '#3bc9db', '#15aabf', '#0c8599'],\n\tteal: ['#e6fcf5', '#96f2d7', '#38d9a9', '#12b886', '#099268'],\n\tgreen: ['#ebfbee', '#b2f2bb', '#69db7c', '#40c057', '#2f9e44'],\n\tlime: ['#f4fce3', '#d8f5a2', '#a9e34b', '#82c91e', '#66a80f'],\n\tyellow: ['#fff9db', '#ffec99', '#ffd43b', '#fab005', '#f08c00'],\n\torange: ['#fff4e6', '#ffd8a8', '#ffa94d', '#fd7e14', '#e8590c'],\n}\n\nfunction mapExcalidrawColorToTldrawColors(\n\texcalidrawColor: keyof typeof oc,\n\tlight: TLDefaultColorStyle,\n\tdark: TLDefaultColorStyle\n) {\n\tconst colors = [0, 1, 2, 3, 4].map((index) => oc[excalidrawColor][index])\n\treturn Object.fromEntries(colors.map((c, i) => [c, i < 3 ? light : dark]))\n}\n\nconst colorsToColors: Record<string, TLDefaultColorStyle> = {\n\t...mapExcalidrawColorToTldrawColors('gray', 'grey', 'black'),\n\t...mapExcalidrawColorToTldrawColors('red', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('pink', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('grape', 'light-violet', 'violet'),\n\t...mapExcalidrawColorToTldrawColors('blue', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('cyan', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('teal', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('green', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('yellow', 'yellow', 'orange'),\n\t...mapExcalidrawColorToTldrawColors('orange', 'yellow', 'orange'),\n\t'#ffffff': 'white',\n\t'#000000': 'black',\n}\n\nconst strokeStylesToStrokeTypes: Record<string, TLDefaultDashStyle> = {\n\tsolid: 'draw',\n\tdashed: 'dashed',\n\tdotted: 'dotted',\n}\n\nconst fillStylesToFillType: Record<string, TLDefaultFillStyle> = {\n\t'cross-hatch': 'pattern',\n\thachure: 'pattern',\n\tsolid: 'solid',\n}\n\nconst textAlignToAlignTypes: Record<string, TLDefaultHorizontalAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst textAlignToTextAlignTypes: Record<string, TLDefaultTextAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst arrowheadsToArrowheadTypes: Record<string, TLArrowShapeArrowheadStyle> = {\n\tarrow: 'arrow',\n\tdot: 'dot',\n\ttriangle: 'triangle',\n\tbar: 'pipe',\n}\n\nfunction getBend(element: any, startPoint: any, endPoint: any) {\n\tlet bend = 0\n\tif (element.points.length > 2) {\n\t\tconst start = new Vec(startPoint[0], startPoint[1])\n\t\tconst end = new Vec(endPoint[0], endPoint[1])\n\t\tconst handle = new Vec(element.points[1][0], element.points[1][1])\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tbend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t}\n\treturn bend\n}\n\nconst getDash = (element: any): TLDefaultDashStyle => {\n\tlet dash: TLDefaultDashStyle = strokeStylesToStrokeTypes[element.strokeStyle] ?? 'draw'\n\tif (dash === 'draw' && element.roughness === 0) {\n\t\tdash = 'solid'\n\t}\n\treturn dash\n}\n\nconst getFill = (element: any): TLDefaultFillStyle => {\n\tif (element.backgroundColor === 'transparent') {\n\t\treturn 'none'\n\t}\n\treturn fillStylesToFillType[element.fillStyle] ?? 'solid'\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EAcA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUP,eAAsB,qBACrB,QACA,4BACA,OACC;AACD,QAAM,EAAE,UAAU,MAAM,IAAI;AAE5B,QAAM,gBAA2B;AAAA,IAChC,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,cAAc,CAAC;AAAA,IACf,QAAQ,CAAC;AAAA,IACT,QAAQ,OAAO,MAAM,OAAO,UAAU;AAAA,EACvC;AAEA,QAAM,yBAAyB,oBAAI,IAAyB;AAC5D,QAAM,kBAAkB,oBAAI,IAAuB;AAEnD,QAAM,gBAAgB,OAAO,iBAAiB;AAE9C,QAAM,gCAAgC,oBAAI,IAAuB;AACjE,QAAM,eAA4B,CAAC;AAEnC,QAAM,UAAU,oBAAI,IA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AACA,SAAO;AACR;AAEA,MAAM,UAAU,CAAC,YAAqC;AACrD,MAAI,QAAQ,oBAAoB,eAAe;AAC9C,WAAO;AAAA,EACR;AACA,SAAO,qBAAqB,QAAQ,SAAS,KAAK;AACnD;",
|
|
6
6
|
"names": ["index"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/utils/test-helpers.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TLDrawShapeSegment, VecModel } from '@tldraw/editor'\nimport { b64Vecs, compressLegacySegments } from '@tldraw/editor'\n\n/**\n * Helper function to convert draw shape points from VecModel[] to base64 string.\n * This is useful for tests that create draw shapes with the legacy array format.\n *\n * @example\n * ```ts\n * const segments = [{ type: 'free',
|
|
5
|
-
"mappings": "AACA,SAAS,SAAS,8BAA8B;
|
|
4
|
+
"sourcesContent": ["import type { TLDrawShapeSegment, VecModel } from '@tldraw/editor'\nimport { b64Vecs, compressLegacySegments } from '@tldraw/editor'\n\n/**\n * Helper function to convert draw shape points from VecModel[] to base64 string.\n * Uses delta encoding for improved Float16 precision.\n * This is useful for tests that create draw shapes with the legacy array format.\n *\n * @example\n * ```ts\n * const segments = [{ type: 'free', path: pointsToBase64([{x: 0, y: 0, z: 0.5}]) }]\n * ```\n *\n * @public\n */\nexport function pointsToBase64(points: VecModel[]): string {\n\treturn b64Vecs.encodePoints(points)\n}\n\n/**\n * Helper function to convert base64 string back to VecModel[] points.\n * Decodes delta-encoded points to absolute coordinates.\n * This is useful for tests that need to inspect draw shape points.\n *\n * @example\n * ```ts\n * const points = base64ToPoints(shape.props.segments[0].path)\n * expect(points[0].x).toBe(0)\n * ```\n *\n * @public\n */\nexport function base64ToPoints(base64: string): VecModel[] {\n\treturn b64Vecs.decodePoints(base64)\n}\n\n/**\n * Helper function to create draw shape segments from legacy array format.\n * This allows tests to use the old format while the shape uses the new base64 format.\n *\n * @example\n * ```ts\n * editor.createShapes([{\n * type: 'draw',\n * props: {\n * segments: createDrawSegments([[{x: 0, y: 0}, {x: 10, y: 10}]])\n * }\n * }])\n * ```\n * @public\n */\nexport function createDrawSegments(\n\tpointArrays: VecModel[][],\n\ttype: 'free' | 'straight' = 'free'\n): TLDrawShapeSegment[] {\n\treturn compressLegacySegments(\n\t\tpointArrays.map((points) => ({\n\t\t\ttype,\n\t\t\tpoints,\n\t\t}))\n\t)\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,SAAS,8BAA8B;AAczC,SAAS,eAAe,QAA4B;AAC1D,SAAO,QAAQ,aAAa,MAAM;AACnC;AAeO,SAAS,eAAe,QAA4B;AAC1D,SAAO,QAAQ,aAAa,MAAM;AACnC;AAiBO,SAAS,mBACf,aACA,OAA4B,QACL;AACvB,SAAO;AAAA,IACN,YAAY,IAAI,CAAC,YAAY;AAAA,MAC5B;AAAA,MACA;AAAA,IACD,EAAE;AAAA,EACH;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -311,7 +311,7 @@ function buildFromV1Document(editor, _document) {
|
|
|
311
311
|
dash: getV2Dash(v1Shape.style.dash),
|
|
312
312
|
isPen: false,
|
|
313
313
|
isComplete: v1Shape.isComplete,
|
|
314
|
-
segments: [{ type: "free",
|
|
314
|
+
segments: [{ type: "free", path: base64Points }],
|
|
315
315
|
scale: 1,
|
|
316
316
|
scaleX: 1,
|
|
317
317
|
scaleY: 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/tldr/buildFromV1Document.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tAssetRecordType,\n\tEditor,\n\tPageRecordType,\n\tTLArrowShape,\n\tTLArrowShapeArrowheadStyle,\n\tTLAsset,\n\tTLAssetId,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLGeoShape,\n\tTLPageId,\n\tTLShapeId,\n\tVec,\n\tVecModel,\n\tb64Vecs,\n\tclamp,\n\tcreateShapeId,\n\tfetch,\n\tstructuredClone,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../../shapes/arrow/shared'\n\nconst TLDRAW_V1_VERSION = 15.5\n\n/** @internal */\nexport function buildFromV1Document(editor: Editor, _document: unknown) {\n\tlet document = _document as TLV1Document\n\teditor.run(() => {\n\t\tdocument = migrate(document, TLDRAW_V1_VERSION)\n\t\t// Cancel any interactions / states\n\t\teditor.cancel().cancel().cancel().cancel()\n\n\t\tconst firstPageId = editor.getPages()[0].id\n\n\t\t// Set the current page to the first page\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\t// Delete all pages except first page\n\t\tfor (const page of editor.getPages().slice(1)) {\n\t\t\teditor.deletePage(page.id)\n\t\t}\n\n\t\t// Delete all of the shapes on the current page\n\t\teditor.selectAll()\n\t\teditor.deleteShapes(editor.getSelectedShapeIds())\n\n\t\t// Create assets\n\t\tconst v1AssetIdsToV2AssetIds = new Map<string, TLAssetId>()\n\n\t\tObject.values(document.assets ?? {}).forEach((v1Asset) => {\n\t\t\tswitch (v1Asset.type) {\n\t\t\t\tcase TLV1AssetType.Image: {\n\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\tconst placeholderAsset: TLAsset = {\n\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t}\n\t\t\t\t\teditor.createAssets([placeholderAsset])\n\t\t\t\t\ttryMigrateAsset(editor, placeholderAsset)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase TLV1AssetType.Video:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\t\teditor.createAssets([\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\t\t\tisAnimated: true,\n\t\t\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t})\n\n\t\t// Create pages\n\n\t\tconst v1PageIdsToV2PageIds = new Map<string, TLPageId>()\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page, i) => {\n\t\t\t\tif (i === 0) {\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, editor.getCurrentPageId())\n\t\t\t\t} else {\n\t\t\t\t\tconst pageId = PageRecordType.createId()\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, pageId)\n\t\t\t\t\teditor.createPage({ name: v1Page.name ?? 'Page', id: pageId })\n\t\t\t\t}\n\t\t\t})\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page) => {\n\t\t\t\t// Set the current page id to the current page\n\t\t\t\teditor.setCurrentPage(v1PageIdsToV2PageIds.get(v1Page.id)!)\n\n\t\t\t\tconst v1ShapeIdsToV2ShapeIds = new Map<string, TLShapeId>()\n\t\t\t\tconst v1GroupShapeIdsToV1ChildIds = new Map<string, string[]>()\n\n\t\t\t\tconst v1Shapes = Object.values(v1Page.shapes ?? {})\n\t\t\t\t\t.sort((a, b) => (a.childIndex < b.childIndex ? -1 : 1))\n\t\t\t\t\t.slice(0, editor.options.maxShapesPerPage)\n\n\t\t\t\t// Groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Group) return\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.id, [])\n\t\t\t\t})\n\n\t\t\t\tfunction decideNotToCreateShape(v1Shape: TLV1Shape) {\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.delete(v1Shape.id)\n\t\t\t\t\tconst v1GroupParent = v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)\n\t\t\t\t\tif (v1GroupParent) {\n\t\t\t\t\t\tconst ids = v1GroupShapeIdsToV1ChildIds\n\t\t\t\t\t\t\t.get(v1Shape.parentId)!\n\t\t\t\t\t\t\t.filter((id) => id !== v1Shape.id)\n\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.parentId, ids)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Non-groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\t// Skip groups for now, we'll create groups via the app's API\n\t\t\t\t\tif (v1Shape.type === TLV1ShapeType.Group) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\n\t\t\t\t\tif (v1Shape.parentId !== v1Page.id) {\n\t\t\t\t\t\t// If the parent is a group, then add the shape to the group's children\n\t\t\t\t\t\tif (v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)) {\n\t\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.get(v1Shape.parentId)!.push(v1Shape.id)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('parent does not exist', v1Shape)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// First, try to find the shape's parent among the existing groups\n\t\t\t\t\tconst parentId = v1PageIdsToV2PageIds.get(v1Page.id)!\n\n\t\t\t\t\tconst inCommon = {\n\t\t\t\t\t\tid: shapeId,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tx: coerceNumber(v1Shape.point[0]),\n\t\t\t\t\t\ty: coerceNumber(v1Shape.point[1]),\n\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\tisLocked: !!v1Shape.isLocked,\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch (v1Shape.type) {\n\t\t\t\t\t\tcase TLV1ShapeType.Sticky: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'note',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\talign: getV2Align(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Rectangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'rectangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Triangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'triangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Ellipse: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'ellipse',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.radius[0]) * 2,\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.radius[1]) * 2,\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Draw: {\n\t\t\t\t\t\t\tif (v1Shape.points.length === 0) {\n\t\t\t\t\t\t\t\tdecideNotToCreateShape(v1Shape)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst points = v1Shape.points.map(getV2Point)\n\t\t\t\t\t\t\tconst base64Points = b64Vecs.encodePoints(points)\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'draw',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tisPen: false,\n\t\t\t\t\t\t\t\t\t\tisComplete: v1Shape.isComplete,\n\t\t\t\t\t\t\t\t\t\tsegments: [{ type: 'free', points: base64Points }],\n\t\t\t\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t\t\t\t\tscaleX: 1,\n\t\t\t\t\t\t\t\t\t\tscaleY: 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Arrow: {\n\t\t\t\t\t\t\tconst v1Bend = coerceNumber(v1Shape.bend)\n\t\t\t\t\t\t\tconst v1Start = getV2Point(v1Shape.handles.start.point)\n\t\t\t\t\t\t\tconst v1End = getV2Point(v1Shape.handles.end.point)\n\t\t\t\t\t\t\tconst dist = Vec.Dist(v1Start, v1End)\n\t\t\t\t\t\t\tconst v2Bend = (dist * -v1Bend) / 2\n\n\t\t\t\t\t\t\t// Could also be a line... but we'll use it as an arrow anyway\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tarrowheadStart: getV2Arrowhead(v1Shape.decorations?.start),\n\t\t\t\t\t\t\t\t\t\tarrowheadEnd: getV2Arrowhead(v1Shape.decorations?.end),\n\t\t\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.start.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.start.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.end.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.end.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tbend: v2Bend,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Text: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ' '),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2TextSize(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\ttextAlign: getV2TextAlign(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t\tscale: v1Shape.style.scale ?? 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Image: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Video: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rotation = coerceNumber(v1Shape.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(shapeId)\n\t\t\t\t\t\teditor.rotateShapesBy([shapeId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Create groups\n\t\t\t\tv1GroupShapeIdsToV1ChildIds.forEach((v1ChildIds, v1GroupId) => {\n\t\t\t\t\tconst v2ChildShapeIds = v1ChildIds.map((id) => v1ShapeIdsToV2ShapeIds.get(id)!)\n\t\t\t\t\tconst v2GroupId = v1ShapeIdsToV2ShapeIds.get(v1GroupId)!\n\t\t\t\t\teditor.groupShapes(v2ChildShapeIds, { groupId: v2GroupId })\n\n\t\t\t\t\tconst v1Group = v1Page.shapes[v1GroupId]\n\t\t\t\t\tconst rotation = coerceNumber(v1Group.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(v2GroupId)\n\t\t\t\t\t\teditor.rotateShapesBy([v2GroupId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Bind arrows to shapes\n\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Arrow) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst v2ShapeId = v1ShapeIdsToV2ShapeIds.get(v1Shape.id)!\n\t\t\t\t\tconst util = editor.getShapeUtil<TLArrowShape>('arrow')\n\n\t\t\t\t\t// dumb but necessary\n\t\t\t\t\teditor.inputs.setCtrlKey(false)\n\n\t\t\t\t\tfor (const handleId of ['start', 'end'] as const) {\n\t\t\t\t\t\tconst bindingId = v1Shape.handles[handleId].bindingId\n\t\t\t\t\t\tif (bindingId) {\n\t\t\t\t\t\t\tconst binding = v1Page.bindings[bindingId]\n\t\t\t\t\t\t\tif (!binding) {\n\t\t\t\t\t\t\t\t// arrow has a reference to a binding that no longer exists\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst targetId = v1ShapeIdsToV2ShapeIds.get(binding.toId)!\n\n\t\t\t\t\t\t\tconst targetShape = editor.getShape(targetId)!\n\n\t\t\t\t\t\t\t// (unexpected) We didn't create the target shape\n\t\t\t\t\t\t\tif (!targetShape) continue\n\n\t\t\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\t\t\tconst bounds = editor.getShapePageBounds(targetId)!\n\n\t\t\t\t\t\t\t\tconst v2ShapeFresh = editor.getShape<TLArrowShape>(v2ShapeId)!\n\n\t\t\t\t\t\t\t\tconst nx = clamp((coerceNumber(binding.point[0]) + 0.5) / 2, 0.2, 0.8)\n\t\t\t\t\t\t\t\tconst ny = clamp((coerceNumber(binding.point[1]) + 0.5) / 2, 0.2, 0.8)\n\n\t\t\t\t\t\t\t\tconst point = editor.getPointInShapeSpace(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\tx: bounds.minX + bounds.width * nx,\n\t\t\t\t\t\t\t\t\ty: bounds.minY + bounds.height * ny,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tconst handles = editor.getShapeHandles(v2ShapeFresh)!\n\t\t\t\t\t\t\t\tconst change = util.onHandleDrag!(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\thandle: {\n\t\t\t\t\t\t\t\t\t\t...handles.find((h) => h.id === handleId)!,\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tisPrecise: point.x !== 0.5 || point.y !== 0.5,\n\t\t\t\t\t\t\t\t\tisCreatingShape: true,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\t\t\teditor.updateShape(change)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst freshBinding = getArrowBindings(\n\t\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\t\teditor.getShape<TLArrowShape>(v2ShapeId)!\n\t\t\t\t\t\t\t\t)[handleId]\n\t\t\t\t\t\t\t\tif (freshBinding) {\n\t\t\t\t\t\t\t\t\tconst updatedFreshBinding = structuredClone(freshBinding)\n\t\t\t\t\t\t\t\t\tif (binding.distance === 0) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.isExact = true\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (updatedFreshBinding.toId !== targetId) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.toId = targetId\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.normalizedAnchor = { x: nx, y: ny }\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\teditor.updateBinding(updatedFreshBinding)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\n\t\t// Set the current page to the first page again\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\teditor.clearHistory()\n\t\teditor.selectNone()\n\n\t\tconst bounds = editor.getCurrentPageBounds()\n\t\tif (bounds) {\n\t\t\teditor.zoomToBounds(bounds, { targetZoom: 1 })\n\t\t}\n\t})\n}\n\nfunction coerceNumber(n: unknown): number {\n\tif (typeof n !== 'number') return 0\n\tif (Number.isNaN(n)) return 0\n\tif (!Number.isFinite(n)) return 0\n\treturn n\n}\n\nfunction coerceDimension(d: unknown): number {\n\tconst n = coerceNumber(d)\n\tif (n <= 0) return 1\n\treturn n\n}\n\n/**\n * We want to move assets over to our new S3 bucket & extract any relevant metadata. That process is\n * async though, where the rest of our migration is synchronous.\n *\n * We'll write placeholder assets to the app using the old asset URLs, then kick off a process async\n * to try and download the real assets, extract the metadata, and upload them to our new bucket.\n * It's not a big deal if this fails though.\n */\nasync function tryMigrateAsset(editor: Editor, placeholderAsset: TLAsset) {\n\ttry {\n\t\tif (placeholderAsset.type === 'bookmark' || !placeholderAsset.props.src) return\n\n\t\tconst response = await fetch(placeholderAsset.props.src)\n\t\tif (!response.ok) return\n\n\t\tconst file = new File([await response.blob()], placeholderAsset.props.name, {\n\t\t\ttype: response.headers.get('content-type') ?? placeholderAsset.props.mimeType ?? undefined,\n\t\t})\n\n\t\tconst newAsset = await editor.getAssetForExternalContent({ type: 'file', file })\n\t\tif (!newAsset) throw new Error('Could not get asset for external content')\n\t\tif (newAsset.type === 'bookmark') return\n\n\t\teditor.updateAssets([\n\t\t\t{\n\t\t\t\tid: placeholderAsset.id,\n\t\t\t\ttype: placeholderAsset.type,\n\t\t\t\tprops: {\n\t\t\t\t\t...newAsset.props,\n\t\t\t\t\tname: placeholderAsset.props.name,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t} catch {\n\t\t// not a big deal, we'll just keep the placeholder asset\n\t}\n}\n\nfunction migrate(document: TLV1Document, newVersion: number): TLV1Document {\n\tconst { version = 0 } = document\n\n\tif (!document.assets) {\n\t\tdocument.assets = {}\n\t}\n\n\t// Remove unused assets when loading a document\n\tconst assetIdsInUse = new Set<string>()\n\n\tObject.values(document.pages).forEach((page) =>\n\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\tconst { parentId, children, assetId } = shape\n\n\t\t\tif (assetId) {\n\t\t\t\tassetIdsInUse.add(assetId)\n\t\t\t}\n\n\t\t\t// Fix missing parent bug\n\t\t\tif (parentId !== page.id && !page.shapes[parentId]) {\n\t\t\t\tconsole.warn('Encountered a shape with a missing parent!')\n\t\t\t\tshape.parentId = page.id\n\t\t\t}\n\n\t\t\tif (shape.type === TLV1ShapeType.Group && children) {\n\t\t\t\tchildren.forEach((childId) => {\n\t\t\t\t\tif (!page.shapes[childId]) {\n\t\t\t\t\t\tconsole.warn('Encountered a parent with a missing child!', shape.id, childId)\n\t\t\t\t\t\tchildren?.splice(children.indexOf(childId), 1)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// TODO: Remove the shape if it has no children\n\t\t\t}\n\t\t})\n\t)\n\n\tObject.keys(document.assets).forEach((assetId) => {\n\t\tif (!assetIdsInUse.has(assetId)) {\n\t\t\tdelete document.assets[assetId]\n\t\t}\n\t})\n\n\tif (version !== newVersion) {\n\t\tif (version < 14) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.shapes)\n\t\t\t\t\t.filter((shape) => shape.type === TLV1ShapeType.Text)\n\t\t\t\t\t.forEach((shape) => {\n\t\t\t\t\t\tif ((shape as TLV1TextShape).style.font === undefined) {\n\t\t\t\t\t\t\t;(shape as TLV1TextShape).style.font = TLV1FontStyle.Script\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Lowercase styles, move binding meta to binding\n\t\tif (version <= 13) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.bindings).forEach((binding) => {\n\t\t\t\t\tObject.assign(binding, (binding as any).meta)\n\t\t\t\t})\n\n\t\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\t\tObject.entries(shape.style).forEach(([id, style]) => {\n\t\t\t\t\t\tif (typeof style === 'string') {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tshape.style[id] = style.toLowerCase()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (shape.type === TLV1ShapeType.Arrow) {\n\t\t\t\t\t\tif (shape.decorations) {\n\t\t\t\t\t\t\tObject.entries(shape.decorations).forEach(([id, decoration]) => {\n\t\t\t\t\t\t\t\tif ((decoration as unknown) === 'Arrow') {\n\t\t\t\t\t\t\t\t\tshape.decorations = {\n\t\t\t\t\t\t\t\t\t\t...shape.decorations,\n\t\t\t\t\t\t\t\t\t\t[id]: TLV1Decoration.Arrow,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Add document name and file system handle\n\t\tif (version <= 13.1 && document.name == null) {\n\t\t\tdocument.name = 'New Document'\n\t\t}\n\n\t\tif (version < 15 && document.assets == null) {\n\t\t\tdocument.assets = {}\n\t\t}\n\n\t\tObject.values(document.pages).forEach((page) => {\n\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\tif (version < 15.2) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t(shape.type === TLV1ShapeType.Image || shape.type === TLV1ShapeType.Video) &&\n\t\t\t\t\t\tshape.style.isFilled == null\n\t\t\t\t\t) {\n\t\t\t\t\t\tshape.style.isFilled = true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (version < 15.3) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Rectangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Triangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Ellipse ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Arrow\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ('text' in shape && typeof shape.text === 'string') {\n\t\t\t\t\t\t\tshape.label = shape.text\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.label) {\n\t\t\t\t\t\t\tshape.label = ''\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.labelPoint) {\n\t\t\t\t\t\t\tshape.labelPoint = [0.5, 0.5]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n\t// Cleanup\n\tObject.values(document.pageStates).forEach((pageState) => {\n\t\tpageState.selectedIds = pageState.selectedIds.filter((id) => {\n\t\t\treturn document.pages[pageState.id].shapes[id] !== undefined\n\t\t})\n\t\tpageState.bindingId = undefined\n\t\tpageState.editingId = undefined\n\t\tpageState.hoveredId = undefined\n\t\tpageState.pointedId = undefined\n\t})\n\n\tdocument.version = newVersion\n\n\treturn document\n}\n\n/* -------------------- TLV1 Types -------------------- */\n\n/** @internal */\nexport interface TLV1Handle {\n\tid: string\n\tindex: number\n\tpoint: number[]\n\tcanBind?: boolean\n\tbindingId?: string\n}\n\n/** @internal */\nexport interface TLV1BaseBinding {\n\tid: string\n\ttoId: string\n\tfromId: string\n}\n\n/** @internal */\nexport enum TLV1ShapeType {\n\tSticky = 'sticky',\n\tEllipse = 'ellipse',\n\tRectangle = 'rectangle',\n\tTriangle = 'triangle',\n\tDraw = 'draw',\n\tArrow = 'arrow',\n\tText = 'text',\n\tGroup = 'group',\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport enum TLV1ColorStyle {\n\tWhite = 'white',\n\tLightGray = 'lightGray',\n\tGray = 'gray',\n\tBlack = 'black',\n\tGreen = 'green',\n\tCyan = 'cyan',\n\tBlue = 'blue',\n\tIndigo = 'indigo',\n\tViolet = 'violet',\n\tRed = 'red',\n\tOrange = 'orange',\n\tYellow = 'yellow',\n}\n\n/** @internal */\nexport enum TLV1SizeStyle {\n\tSmall = 'small',\n\tMedium = 'medium',\n\tLarge = 'large',\n}\n\n/** @internal */\nexport enum TLV1DashStyle {\n\tDraw = 'draw',\n\tSolid = 'solid',\n\tDashed = 'dashed',\n\tDotted = 'dotted',\n}\n\n/** @internal */\nexport enum TLV1AlignStyle {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n\tJustify = 'justify',\n}\n\n/** @internal */\nexport enum TLV1FontStyle {\n\tScript = 'script',\n\tSans = 'sans',\n\tSerif = 'serif',\n\tMono = 'mono',\n}\n\n/** @internal */\nexport interface TLV1ShapeStyles {\n\tcolor: TLV1ColorStyle\n\tsize: TLV1SizeStyle\n\tdash: TLV1DashStyle\n\tfont?: TLV1FontStyle\n\ttextAlign?: TLV1AlignStyle\n\tisFilled?: boolean\n\tscale?: number\n}\n\n/** @internal */\nexport interface TLV1BaseShape {\n\tid: string\n\tparentId: string\n\tchildIndex: number\n\tname: string\n\tpoint: number[]\n\tassetId?: string\n\trotation?: number\n\tchildren?: string[]\n\tisGhost?: boolean\n\tisHidden?: boolean\n\tisLocked?: boolean\n\tisGenerated?: boolean\n\tisAspectRatioLocked?: boolean\n\tstyle: TLV1ShapeStyles\n\ttype: TLV1ShapeType\n\tlabel?: string\n\thandles?: Record<string, TLV1Handle>\n}\n\n/** @internal */\nexport interface TLV1DrawShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Draw\n\tpoints: number[][]\n\tisComplete: boolean\n}\n\n/** @internal */\nexport interface TLV1RectangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Rectangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1EllipseShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Ellipse\n\tradius: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1TriangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Triangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport enum TLV1Decoration {\n\tArrow = 'arrow',\n}\n\n// The shape created with the arrow tool\n/** @internal */\nexport interface TLV1ArrowShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Arrow\n\tbend: number\n\thandles: {\n\t\tstart: TLV1Handle\n\t\tbend: TLV1Handle\n\t\tend: TLV1Handle\n\t}\n\tdecorations?: {\n\t\tstart?: TLV1Decoration\n\t\tend?: TLV1Decoration\n\t\tmiddle?: TLV1Decoration\n\t}\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1ArrowBinding extends TLV1BaseBinding {\n\thandleId: keyof TLV1ArrowShape['handles']\n\tdistance: number\n\tpoint: number[]\n}\n\n/** @internal */\nexport type TLV1Binding = TLV1ArrowBinding\n\n/** @internal */\nexport interface TLV1ImageShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Image\n\tsize: number[]\n\tassetId: string\n}\n\n/** @internal */\nexport interface TLV1VideoShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Video\n\tsize: number[]\n\tassetId: string\n\tisPlaying: boolean\n\tcurrentTime: number\n}\n\n// The shape created by the text tool\n/** @internal */\nexport interface TLV1TextShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Text\n\ttext: string\n}\n\n// The shape created by the sticky tool\n/** @internal */\nexport interface TLV1StickyShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Sticky\n\tsize: number[]\n\ttext: string\n}\n\n// The shape created when multiple shapes are grouped\n/** @internal */\nexport interface TLV1GroupShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Group\n\tsize: number[]\n\tchildren: string[]\n}\n\n/** @internal */\nexport type TLV1Shape =\n\t| TLV1RectangleShape\n\t| TLV1EllipseShape\n\t| TLV1TriangleShape\n\t| TLV1DrawShape\n\t| TLV1ArrowShape\n\t| TLV1TextShape\n\t| TLV1GroupShape\n\t| TLV1StickyShape\n\t| TLV1ImageShape\n\t| TLV1VideoShape\n\n/** @internal */\nexport interface TLV1Page {\n\tid: string\n\tname?: string\n\tchildIndex?: number\n\tshapes: Record<string, TLV1Shape>\n\tbindings: Record<string, TLV1Binding>\n}\n\n/** @internal */\nexport interface TLV1Bounds {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\twidth: number\n\theight: number\n\trotation?: number\n}\n\n/** @internal */\nexport interface TLV1PageState {\n\tid: string\n\tselectedIds: string[]\n\tcamera: {\n\t\tpoint: number[]\n\t\tzoom: number\n\t}\n\tbrush?: TLV1Bounds | null\n\tpointedId?: string | null\n\thoveredId?: string | null\n\teditingId?: string | null\n\tbindingId?: string | null\n}\n\n/** @internal */\nexport enum TLV1AssetType {\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport interface TLV1ImageAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Image\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1VideoAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Video\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1BaseAsset {\n\tid: string\n\ttype: string\n}\n\n/** @internal */\nexport type TLV1Asset = TLV1ImageAsset | TLV1VideoAsset\n\n/** @internal */\nexport interface TLV1Document {\n\tid: string\n\tname: string\n\tversion: number\n\tpages: Record<string, TLV1Page>\n\tpageStates: Record<string, TLV1PageState>\n\tassets: Record<string, TLV1Asset>\n}\n\n/* ------------------ Translations ------------------ */\n\nconst v1ColorsToV2Colors: Record<TLV1ColorStyle, TLDefaultColorStyle> = {\n\t[TLV1ColorStyle.White]: 'black',\n\t[TLV1ColorStyle.Black]: 'black',\n\t[TLV1ColorStyle.LightGray]: 'grey',\n\t[TLV1ColorStyle.Gray]: 'grey',\n\t[TLV1ColorStyle.Green]: 'light-green',\n\t[TLV1ColorStyle.Cyan]: 'green',\n\t[TLV1ColorStyle.Blue]: 'light-blue',\n\t[TLV1ColorStyle.Indigo]: 'blue',\n\t[TLV1ColorStyle.Orange]: 'orange',\n\t[TLV1ColorStyle.Yellow]: 'yellow',\n\t[TLV1ColorStyle.Red]: 'red',\n\t[TLV1ColorStyle.Violet]: 'light-violet',\n}\n\nconst v1FontsToV2Fonts: Record<TLV1FontStyle, TLDefaultFontStyle> = {\n\t[TLV1FontStyle.Mono]: 'mono',\n\t[TLV1FontStyle.Sans]: 'sans',\n\t[TLV1FontStyle.Script]: 'draw',\n\t[TLV1FontStyle.Serif]: 'serif',\n}\n\nconst v1AlignsToV2Aligns: Record<TLV1AlignStyle, TLDefaultHorizontalAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextAlignsToV2TextAligns: Record<TLV1AlignStyle, TLDefaultTextAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextSizesToV2TextSizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 's',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1SizesToV2Sizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 'm',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1DashesToV2Dashes: Record<TLV1DashStyle, TLDefaultDashStyle> = {\n\t[TLV1DashStyle.Solid]: 'solid',\n\t[TLV1DashStyle.Dashed]: 'dashed',\n\t[TLV1DashStyle.Dotted]: 'dotted',\n\t[TLV1DashStyle.Draw]: 'draw',\n}\n\nfunction getV2Color(color: TLV1ColorStyle | undefined): TLDefaultColorStyle {\n\treturn color ? (v1ColorsToV2Colors[color] ?? 'black') : 'black'\n}\n\nfunction getV2Font(font: TLV1FontStyle | undefined): TLDefaultFontStyle {\n\treturn font ? (v1FontsToV2Fonts[font] ?? 'draw') : 'draw'\n}\n\nfunction getV2Align(align: TLV1AlignStyle | undefined): TLDefaultHorizontalAlignStyle {\n\treturn align ? (v1AlignsToV2Aligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextAlign(align: TLV1AlignStyle | undefined): TLDefaultTextAlignStyle {\n\treturn align ? (v1TextAlignsToV2TextAligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextSize(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1TextSizesToV2TextSizes[size] ?? 'm') : 'm'\n}\n\nfunction getV2Size(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1SizesToV2Sizes[size] ?? 'l') : 'l'\n}\n\nfunction getV2Dash(dash: TLV1DashStyle | undefined): TLDefaultDashStyle {\n\treturn dash ? (v1DashesToV2Dashes[dash] ?? 'draw') : 'draw'\n}\n\nfunction getV2Point(point: number[]): VecModel {\n\treturn {\n\t\tx: coerceNumber(point[0]),\n\t\ty: coerceNumber(point[1]),\n\t\tz: point[2] == null ? 0.5 : coerceNumber(point[2]),\n\t}\n}\n\nfunction getV2Arrowhead(decoration: TLV1Decoration | undefined): TLArrowShapeArrowheadStyle {\n\treturn decoration === TLV1Decoration.Arrow ? 'arrow' : 'none'\n}\n\nfunction getV2Fill(isFilled: boolean | undefined, color: TLV1ColorStyle) {\n\treturn isFilled\n\t\t? color === TLV1ColorStyle.Black || color === TLV1ColorStyle.White\n\t\t\t? 'semi'\n\t\t\t: 'solid'\n\t\t: 'none'\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EAcA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB;AAGnB,SAAS,oBAAoB,QAAgB,WAAoB;AACvE,MAAI,WAAW;AACf,SAAO,IAAI,MAAM;AAChB,eAAW,QAAQ,UAAU,iBAAiB;AAE9C,WAAO,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AAEzC,UAAM,cAAc,OAAO,SAAS,EAAE,CAAC,EAAE;AAGzC,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AAqD;AACvE,SAAO,OAAQ,iBAAiB,IAAI,KAAK,MAAO;AACjD;AAEA,SAAS,UAAU,MAAqD;AACvE,SAAO,OAAQ,mBAAmB,IAAI,KAAK,SAAU;AACtD;AAEA,SAAS,WAAW,OAA2B;AAC9C,SAAO;AAAA,IACN,GAAG,aAAa,MAAM,CAAC,CAAC;AAAA,IACxB,GAAG,aAAa,MAAM,CAAC,CAAC;AAAA,IACxB,GAAG,MAAM,CAAC,KAAK,OAAO,MAAM,aAAa,MAAM,CAAC,CAAC;AAAA,EAClD;AACD;AAEA,SAAS,eAAe,YAAoE;AAC3F,SAAO,eAAe,sBAAuB,UAAU;AACxD;AAEA,SAAS,UAAU,UAA+B,OAAuB;AACxE,SAAO,WACJ,UAAU,uBAAwB,UAAU,sBAC3C,SACA,UACD;AACJ;",
|
|
4
|
+
"sourcesContent": ["import {\n\tAssetRecordType,\n\tEditor,\n\tPageRecordType,\n\tTLArrowShape,\n\tTLArrowShapeArrowheadStyle,\n\tTLAsset,\n\tTLAssetId,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLGeoShape,\n\tTLPageId,\n\tTLShapeId,\n\tVec,\n\tVecModel,\n\tb64Vecs,\n\tclamp,\n\tcreateShapeId,\n\tfetch,\n\tstructuredClone,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../../shapes/arrow/shared'\n\nconst TLDRAW_V1_VERSION = 15.5\n\n/** @internal */\nexport function buildFromV1Document(editor: Editor, _document: unknown) {\n\tlet document = _document as TLV1Document\n\teditor.run(() => {\n\t\tdocument = migrate(document, TLDRAW_V1_VERSION)\n\t\t// Cancel any interactions / states\n\t\teditor.cancel().cancel().cancel().cancel()\n\n\t\tconst firstPageId = editor.getPages()[0].id\n\n\t\t// Set the current page to the first page\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\t// Delete all pages except first page\n\t\tfor (const page of editor.getPages().slice(1)) {\n\t\t\teditor.deletePage(page.id)\n\t\t}\n\n\t\t// Delete all of the shapes on the current page\n\t\teditor.selectAll()\n\t\teditor.deleteShapes(editor.getSelectedShapeIds())\n\n\t\t// Create assets\n\t\tconst v1AssetIdsToV2AssetIds = new Map<string, TLAssetId>()\n\n\t\tObject.values(document.assets ?? {}).forEach((v1Asset) => {\n\t\t\tswitch (v1Asset.type) {\n\t\t\t\tcase TLV1AssetType.Image: {\n\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\tconst placeholderAsset: TLAsset = {\n\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t}\n\t\t\t\t\teditor.createAssets([placeholderAsset])\n\t\t\t\t\ttryMigrateAsset(editor, placeholderAsset)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase TLV1AssetType.Video:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\t\t\tv1AssetIdsToV2AssetIds.set(v1Asset.id, assetId)\n\t\t\t\t\t\teditor.createAssets([\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: assetId,\n\t\t\t\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Asset.size[0]),\n\t\t\t\t\t\t\t\t\th: coerceDimension(v1Asset.size[1]),\n\t\t\t\t\t\t\t\t\tname: v1Asset.fileName ?? 'Untitled',\n\t\t\t\t\t\t\t\t\tisAnimated: true,\n\t\t\t\t\t\t\t\t\tmimeType: null,\n\t\t\t\t\t\t\t\t\tsrc: v1Asset.src,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t])\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t})\n\n\t\t// Create pages\n\n\t\tconst v1PageIdsToV2PageIds = new Map<string, TLPageId>()\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page, i) => {\n\t\t\t\tif (i === 0) {\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, editor.getCurrentPageId())\n\t\t\t\t} else {\n\t\t\t\t\tconst pageId = PageRecordType.createId()\n\t\t\t\t\tv1PageIdsToV2PageIds.set(v1Page.id, pageId)\n\t\t\t\t\teditor.createPage({ name: v1Page.name ?? 'Page', id: pageId })\n\t\t\t\t}\n\t\t\t})\n\n\t\tObject.values(document.pages ?? {})\n\t\t\t.sort((a, b) => ((a.childIndex ?? 1) < (b.childIndex ?? 1) ? -1 : 1))\n\t\t\t.forEach((v1Page) => {\n\t\t\t\t// Set the current page id to the current page\n\t\t\t\teditor.setCurrentPage(v1PageIdsToV2PageIds.get(v1Page.id)!)\n\n\t\t\t\tconst v1ShapeIdsToV2ShapeIds = new Map<string, TLShapeId>()\n\t\t\t\tconst v1GroupShapeIdsToV1ChildIds = new Map<string, string[]>()\n\n\t\t\t\tconst v1Shapes = Object.values(v1Page.shapes ?? {})\n\t\t\t\t\t.sort((a, b) => (a.childIndex < b.childIndex ? -1 : 1))\n\t\t\t\t\t.slice(0, editor.options.maxShapesPerPage)\n\n\t\t\t\t// Groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Group) return\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.id, [])\n\t\t\t\t})\n\n\t\t\t\tfunction decideNotToCreateShape(v1Shape: TLV1Shape) {\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.delete(v1Shape.id)\n\t\t\t\t\tconst v1GroupParent = v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)\n\t\t\t\t\tif (v1GroupParent) {\n\t\t\t\t\t\tconst ids = v1GroupShapeIdsToV1ChildIds\n\t\t\t\t\t\t\t.get(v1Shape.parentId)!\n\t\t\t\t\t\t\t.filter((id) => id !== v1Shape.id)\n\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.set(v1Shape.parentId, ids)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Non-groups only\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\t// Skip groups for now, we'll create groups via the app's API\n\t\t\t\t\tif (v1Shape.type === TLV1ShapeType.Group) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapeId = createShapeId()\n\t\t\t\t\tv1ShapeIdsToV2ShapeIds.set(v1Shape.id, shapeId)\n\n\t\t\t\t\tif (v1Shape.parentId !== v1Page.id) {\n\t\t\t\t\t\t// If the parent is a group, then add the shape to the group's children\n\t\t\t\t\t\tif (v1GroupShapeIdsToV1ChildIds.has(v1Shape.parentId)) {\n\t\t\t\t\t\t\tv1GroupShapeIdsToV1ChildIds.get(v1Shape.parentId)!.push(v1Shape.id)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('parent does not exist', v1Shape)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// First, try to find the shape's parent among the existing groups\n\t\t\t\t\tconst parentId = v1PageIdsToV2PageIds.get(v1Page.id)!\n\n\t\t\t\t\tconst inCommon = {\n\t\t\t\t\t\tid: shapeId,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tx: coerceNumber(v1Shape.point[0]),\n\t\t\t\t\t\ty: coerceNumber(v1Shape.point[1]),\n\t\t\t\t\t\trotation: 0,\n\t\t\t\t\t\tisLocked: !!v1Shape.isLocked,\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch (v1Shape.type) {\n\t\t\t\t\t\tcase TLV1ShapeType.Sticky: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'note',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\talign: getV2Align(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Rectangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'rectangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Triangle: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'triangle',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Ellipse: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tgeo: 'ellipse',\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.radius[0]) * 2,\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.radius[1]) * 2,\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\talign: 'middle',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tconst pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!\n\n\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tif (pageBoundsBeforeLabel.width === pageBoundsBeforeLabel.height) {\n\t\t\t\t\t\t\t\tconst shape = editor.getShape<TLGeoShape>(inCommon.id)!\n\t\t\t\t\t\t\t\tconst { growY } = shape.props\n\t\t\t\t\t\t\t\tconst w = coerceDimension(shape.props.w)\n\t\t\t\t\t\t\t\tconst h = coerceDimension(shape.props.h)\n\t\t\t\t\t\t\t\tconst newW = w + growY / 2\n\t\t\t\t\t\t\t\tconst newH = h + growY / 2\n\n\t\t\t\t\t\t\t\teditor.updateShapes([\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: inCommon.id,\n\t\t\t\t\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\t\t\t\t\tx: coerceNumber(shape.x) - (newW - w) / 2,\n\t\t\t\t\t\t\t\t\t\ty: coerceNumber(shape.y) - (newH - h) / 2,\n\t\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\t\tw: newW,\n\t\t\t\t\t\t\t\t\t\t\th: newH,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Draw: {\n\t\t\t\t\t\t\tif (v1Shape.points.length === 0) {\n\t\t\t\t\t\t\t\tdecideNotToCreateShape(v1Shape)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst points = v1Shape.points.map(getV2Point)\n\t\t\t\t\t\t\tconst base64Points = b64Vecs.encodePoints(points)\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'draw',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tfill: getV2Fill(v1Shape.style.isFilled, v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tisPen: false,\n\t\t\t\t\t\t\t\t\t\tisComplete: v1Shape.isComplete,\n\t\t\t\t\t\t\t\t\t\tsegments: [{ type: 'free', path: base64Points }],\n\t\t\t\t\t\t\t\t\t\tscale: 1,\n\t\t\t\t\t\t\t\t\t\tscaleX: 1,\n\t\t\t\t\t\t\t\t\t\tscaleY: 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Arrow: {\n\t\t\t\t\t\t\tconst v1Bend = coerceNumber(v1Shape.bend)\n\t\t\t\t\t\t\tconst v1Start = getV2Point(v1Shape.handles.start.point)\n\t\t\t\t\t\t\tconst v1End = getV2Point(v1Shape.handles.end.point)\n\t\t\t\t\t\t\tconst dist = Vec.Dist(v1Start, v1End)\n\t\t\t\t\t\t\tconst v2Bend = (dist * -v1Bend) / 2\n\n\t\t\t\t\t\t\t// Could also be a line... but we'll use it as an arrow anyway\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.label ?? ''),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tlabelColor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2Size(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\tdash: getV2Dash(v1Shape.style.dash),\n\t\t\t\t\t\t\t\t\t\tarrowheadStart: getV2Arrowhead(v1Shape.decorations?.start),\n\t\t\t\t\t\t\t\t\t\tarrowheadEnd: getV2Arrowhead(v1Shape.decorations?.end),\n\t\t\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.start.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.start.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\t\t\tx: coerceNumber(v1Shape.handles.end.point[0]),\n\t\t\t\t\t\t\t\t\t\t\ty: coerceNumber(v1Shape.handles.end.point[1]),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tbend: v2Bend,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Text: {\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\trichText: toRichText(v1Shape.text ?? ' '),\n\t\t\t\t\t\t\t\t\t\tcolor: getV2Color(v1Shape.style.color),\n\t\t\t\t\t\t\t\t\t\tsize: getV2TextSize(v1Shape.style.size),\n\t\t\t\t\t\t\t\t\t\tfont: getV2Font(v1Shape.style.font),\n\t\t\t\t\t\t\t\t\t\ttextAlign: getV2TextAlign(v1Shape.style.textAlign),\n\t\t\t\t\t\t\t\t\t\tscale: v1Shape.style.scale ?? 1,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Image: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase TLV1ShapeType.Video: {\n\t\t\t\t\t\t\tconst assetId = v1AssetIdsToV2AssetIds.get(v1Shape.assetId)\n\n\t\t\t\t\t\t\tif (!assetId) {\n\t\t\t\t\t\t\t\tconsole.warn('Could not find asset id', v1Shape.assetId)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\teditor.createShapes([\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...inCommon,\n\t\t\t\t\t\t\t\t\ttype: 'video',\n\t\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\t\tw: coerceDimension(v1Shape.size[0]),\n\t\t\t\t\t\t\t\t\t\th: coerceDimension(v1Shape.size[1]),\n\t\t\t\t\t\t\t\t\t\tassetId,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rotation = coerceNumber(v1Shape.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(shapeId)\n\t\t\t\t\t\teditor.rotateShapesBy([shapeId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Create groups\n\t\t\t\tv1GroupShapeIdsToV1ChildIds.forEach((v1ChildIds, v1GroupId) => {\n\t\t\t\t\tconst v2ChildShapeIds = v1ChildIds.map((id) => v1ShapeIdsToV2ShapeIds.get(id)!)\n\t\t\t\t\tconst v2GroupId = v1ShapeIdsToV2ShapeIds.get(v1GroupId)!\n\t\t\t\t\teditor.groupShapes(v2ChildShapeIds, { groupId: v2GroupId })\n\n\t\t\t\t\tconst v1Group = v1Page.shapes[v1GroupId]\n\t\t\t\t\tconst rotation = coerceNumber(v1Group.rotation)\n\n\t\t\t\t\tif (rotation !== 0) {\n\t\t\t\t\t\teditor.select(v2GroupId)\n\t\t\t\t\t\teditor.rotateShapesBy([v2GroupId], rotation)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// Bind arrows to shapes\n\n\t\t\t\tv1Shapes.forEach((v1Shape) => {\n\t\t\t\t\tif (v1Shape.type !== TLV1ShapeType.Arrow) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tconst v2ShapeId = v1ShapeIdsToV2ShapeIds.get(v1Shape.id)!\n\t\t\t\t\tconst util = editor.getShapeUtil<TLArrowShape>('arrow')\n\n\t\t\t\t\t// dumb but necessary\n\t\t\t\t\teditor.inputs.setCtrlKey(false)\n\n\t\t\t\t\tfor (const handleId of ['start', 'end'] as const) {\n\t\t\t\t\t\tconst bindingId = v1Shape.handles[handleId].bindingId\n\t\t\t\t\t\tif (bindingId) {\n\t\t\t\t\t\t\tconst binding = v1Page.bindings[bindingId]\n\t\t\t\t\t\t\tif (!binding) {\n\t\t\t\t\t\t\t\t// arrow has a reference to a binding that no longer exists\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst targetId = v1ShapeIdsToV2ShapeIds.get(binding.toId)!\n\n\t\t\t\t\t\t\tconst targetShape = editor.getShape(targetId)!\n\n\t\t\t\t\t\t\t// (unexpected) We didn't create the target shape\n\t\t\t\t\t\t\tif (!targetShape) continue\n\n\t\t\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\t\t\tconst bounds = editor.getShapePageBounds(targetId)!\n\n\t\t\t\t\t\t\t\tconst v2ShapeFresh = editor.getShape<TLArrowShape>(v2ShapeId)!\n\n\t\t\t\t\t\t\t\tconst nx = clamp((coerceNumber(binding.point[0]) + 0.5) / 2, 0.2, 0.8)\n\t\t\t\t\t\t\t\tconst ny = clamp((coerceNumber(binding.point[1]) + 0.5) / 2, 0.2, 0.8)\n\n\t\t\t\t\t\t\t\tconst point = editor.getPointInShapeSpace(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\tx: bounds.minX + bounds.width * nx,\n\t\t\t\t\t\t\t\t\ty: bounds.minY + bounds.height * ny,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tconst handles = editor.getShapeHandles(v2ShapeFresh)!\n\t\t\t\t\t\t\t\tconst change = util.onHandleDrag!(v2ShapeFresh, {\n\t\t\t\t\t\t\t\t\thandle: {\n\t\t\t\t\t\t\t\t\t\t...handles.find((h) => h.id === handleId)!,\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tisPrecise: point.x !== 0.5 || point.y !== 0.5,\n\t\t\t\t\t\t\t\t\tisCreatingShape: true,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\t\t\teditor.updateShape(change)\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst freshBinding = getArrowBindings(\n\t\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\t\teditor.getShape<TLArrowShape>(v2ShapeId)!\n\t\t\t\t\t\t\t\t)[handleId]\n\t\t\t\t\t\t\t\tif (freshBinding) {\n\t\t\t\t\t\t\t\t\tconst updatedFreshBinding = structuredClone(freshBinding)\n\t\t\t\t\t\t\t\t\tif (binding.distance === 0) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.isExact = true\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (updatedFreshBinding.toId !== targetId) {\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.toId = targetId\n\t\t\t\t\t\t\t\t\t\tupdatedFreshBinding.props.normalizedAnchor = { x: nx, y: ny }\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\teditor.updateBinding(updatedFreshBinding)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\n\t\t// Set the current page to the first page again\n\t\teditor.setCurrentPage(firstPageId)\n\n\t\teditor.clearHistory()\n\t\teditor.selectNone()\n\n\t\tconst bounds = editor.getCurrentPageBounds()\n\t\tif (bounds) {\n\t\t\teditor.zoomToBounds(bounds, { targetZoom: 1 })\n\t\t}\n\t})\n}\n\nfunction coerceNumber(n: unknown): number {\n\tif (typeof n !== 'number') return 0\n\tif (Number.isNaN(n)) return 0\n\tif (!Number.isFinite(n)) return 0\n\treturn n\n}\n\nfunction coerceDimension(d: unknown): number {\n\tconst n = coerceNumber(d)\n\tif (n <= 0) return 1\n\treturn n\n}\n\n/**\n * We want to move assets over to our new S3 bucket & extract any relevant metadata. That process is\n * async though, where the rest of our migration is synchronous.\n *\n * We'll write placeholder assets to the app using the old asset URLs, then kick off a process async\n * to try and download the real assets, extract the metadata, and upload them to our new bucket.\n * It's not a big deal if this fails though.\n */\nasync function tryMigrateAsset(editor: Editor, placeholderAsset: TLAsset) {\n\ttry {\n\t\tif (placeholderAsset.type === 'bookmark' || !placeholderAsset.props.src) return\n\n\t\tconst response = await fetch(placeholderAsset.props.src)\n\t\tif (!response.ok) return\n\n\t\tconst file = new File([await response.blob()], placeholderAsset.props.name, {\n\t\t\ttype: response.headers.get('content-type') ?? placeholderAsset.props.mimeType ?? undefined,\n\t\t})\n\n\t\tconst newAsset = await editor.getAssetForExternalContent({ type: 'file', file })\n\t\tif (!newAsset) throw new Error('Could not get asset for external content')\n\t\tif (newAsset.type === 'bookmark') return\n\n\t\teditor.updateAssets([\n\t\t\t{\n\t\t\t\tid: placeholderAsset.id,\n\t\t\t\ttype: placeholderAsset.type,\n\t\t\t\tprops: {\n\t\t\t\t\t...newAsset.props,\n\t\t\t\t\tname: placeholderAsset.props.name,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t} catch {\n\t\t// not a big deal, we'll just keep the placeholder asset\n\t}\n}\n\nfunction migrate(document: TLV1Document, newVersion: number): TLV1Document {\n\tconst { version = 0 } = document\n\n\tif (!document.assets) {\n\t\tdocument.assets = {}\n\t}\n\n\t// Remove unused assets when loading a document\n\tconst assetIdsInUse = new Set<string>()\n\n\tObject.values(document.pages).forEach((page) =>\n\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\tconst { parentId, children, assetId } = shape\n\n\t\t\tif (assetId) {\n\t\t\t\tassetIdsInUse.add(assetId)\n\t\t\t}\n\n\t\t\t// Fix missing parent bug\n\t\t\tif (parentId !== page.id && !page.shapes[parentId]) {\n\t\t\t\tconsole.warn('Encountered a shape with a missing parent!')\n\t\t\t\tshape.parentId = page.id\n\t\t\t}\n\n\t\t\tif (shape.type === TLV1ShapeType.Group && children) {\n\t\t\t\tchildren.forEach((childId) => {\n\t\t\t\t\tif (!page.shapes[childId]) {\n\t\t\t\t\t\tconsole.warn('Encountered a parent with a missing child!', shape.id, childId)\n\t\t\t\t\t\tchildren?.splice(children.indexOf(childId), 1)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// TODO: Remove the shape if it has no children\n\t\t\t}\n\t\t})\n\t)\n\n\tObject.keys(document.assets).forEach((assetId) => {\n\t\tif (!assetIdsInUse.has(assetId)) {\n\t\t\tdelete document.assets[assetId]\n\t\t}\n\t})\n\n\tif (version !== newVersion) {\n\t\tif (version < 14) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.shapes)\n\t\t\t\t\t.filter((shape) => shape.type === TLV1ShapeType.Text)\n\t\t\t\t\t.forEach((shape) => {\n\t\t\t\t\t\tif ((shape as TLV1TextShape).style.font === undefined) {\n\t\t\t\t\t\t\t;(shape as TLV1TextShape).style.font = TLV1FontStyle.Script\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Lowercase styles, move binding meta to binding\n\t\tif (version <= 13) {\n\t\t\tObject.values(document.pages).forEach((page) => {\n\t\t\t\tObject.values(page.bindings).forEach((binding) => {\n\t\t\t\t\tObject.assign(binding, (binding as any).meta)\n\t\t\t\t})\n\n\t\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\t\tObject.entries(shape.style).forEach(([id, style]) => {\n\t\t\t\t\t\tif (typeof style === 'string') {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tshape.style[id] = style.toLowerCase()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\tif (shape.type === TLV1ShapeType.Arrow) {\n\t\t\t\t\t\tif (shape.decorations) {\n\t\t\t\t\t\t\tObject.entries(shape.decorations).forEach(([id, decoration]) => {\n\t\t\t\t\t\t\t\tif ((decoration as unknown) === 'Arrow') {\n\t\t\t\t\t\t\t\t\tshape.decorations = {\n\t\t\t\t\t\t\t\t\t\t...shape.decorations,\n\t\t\t\t\t\t\t\t\t\t[id]: TLV1Decoration.Arrow,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\t// Add document name and file system handle\n\t\tif (version <= 13.1 && document.name == null) {\n\t\t\tdocument.name = 'New Document'\n\t\t}\n\n\t\tif (version < 15 && document.assets == null) {\n\t\t\tdocument.assets = {}\n\t\t}\n\n\t\tObject.values(document.pages).forEach((page) => {\n\t\t\tObject.values(page.shapes).forEach((shape) => {\n\t\t\t\tif (version < 15.2) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t(shape.type === TLV1ShapeType.Image || shape.type === TLV1ShapeType.Video) &&\n\t\t\t\t\t\tshape.style.isFilled == null\n\t\t\t\t\t) {\n\t\t\t\t\t\tshape.style.isFilled = true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (version < 15.3) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Rectangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Triangle ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Ellipse ||\n\t\t\t\t\t\tshape.type === TLV1ShapeType.Arrow\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ('text' in shape && typeof shape.text === 'string') {\n\t\t\t\t\t\t\tshape.label = shape.text\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.label) {\n\t\t\t\t\t\t\tshape.label = ''\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!shape.labelPoint) {\n\t\t\t\t\t\t\tshape.labelPoint = [0.5, 0.5]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n\t// Cleanup\n\tObject.values(document.pageStates).forEach((pageState) => {\n\t\tpageState.selectedIds = pageState.selectedIds.filter((id) => {\n\t\t\treturn document.pages[pageState.id].shapes[id] !== undefined\n\t\t})\n\t\tpageState.bindingId = undefined\n\t\tpageState.editingId = undefined\n\t\tpageState.hoveredId = undefined\n\t\tpageState.pointedId = undefined\n\t})\n\n\tdocument.version = newVersion\n\n\treturn document\n}\n\n/* -------------------- TLV1 Types -------------------- */\n\n/** @internal */\nexport interface TLV1Handle {\n\tid: string\n\tindex: number\n\tpoint: number[]\n\tcanBind?: boolean\n\tbindingId?: string\n}\n\n/** @internal */\nexport interface TLV1BaseBinding {\n\tid: string\n\ttoId: string\n\tfromId: string\n}\n\n/** @internal */\nexport enum TLV1ShapeType {\n\tSticky = 'sticky',\n\tEllipse = 'ellipse',\n\tRectangle = 'rectangle',\n\tTriangle = 'triangle',\n\tDraw = 'draw',\n\tArrow = 'arrow',\n\tText = 'text',\n\tGroup = 'group',\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport enum TLV1ColorStyle {\n\tWhite = 'white',\n\tLightGray = 'lightGray',\n\tGray = 'gray',\n\tBlack = 'black',\n\tGreen = 'green',\n\tCyan = 'cyan',\n\tBlue = 'blue',\n\tIndigo = 'indigo',\n\tViolet = 'violet',\n\tRed = 'red',\n\tOrange = 'orange',\n\tYellow = 'yellow',\n}\n\n/** @internal */\nexport enum TLV1SizeStyle {\n\tSmall = 'small',\n\tMedium = 'medium',\n\tLarge = 'large',\n}\n\n/** @internal */\nexport enum TLV1DashStyle {\n\tDraw = 'draw',\n\tSolid = 'solid',\n\tDashed = 'dashed',\n\tDotted = 'dotted',\n}\n\n/** @internal */\nexport enum TLV1AlignStyle {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n\tJustify = 'justify',\n}\n\n/** @internal */\nexport enum TLV1FontStyle {\n\tScript = 'script',\n\tSans = 'sans',\n\tSerif = 'serif',\n\tMono = 'mono',\n}\n\n/** @internal */\nexport interface TLV1ShapeStyles {\n\tcolor: TLV1ColorStyle\n\tsize: TLV1SizeStyle\n\tdash: TLV1DashStyle\n\tfont?: TLV1FontStyle\n\ttextAlign?: TLV1AlignStyle\n\tisFilled?: boolean\n\tscale?: number\n}\n\n/** @internal */\nexport interface TLV1BaseShape {\n\tid: string\n\tparentId: string\n\tchildIndex: number\n\tname: string\n\tpoint: number[]\n\tassetId?: string\n\trotation?: number\n\tchildren?: string[]\n\tisGhost?: boolean\n\tisHidden?: boolean\n\tisLocked?: boolean\n\tisGenerated?: boolean\n\tisAspectRatioLocked?: boolean\n\tstyle: TLV1ShapeStyles\n\ttype: TLV1ShapeType\n\tlabel?: string\n\thandles?: Record<string, TLV1Handle>\n}\n\n/** @internal */\nexport interface TLV1DrawShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Draw\n\tpoints: number[][]\n\tisComplete: boolean\n}\n\n/** @internal */\nexport interface TLV1RectangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Rectangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1EllipseShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Ellipse\n\tradius: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1TriangleShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Triangle\n\tsize: number[]\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport enum TLV1Decoration {\n\tArrow = 'arrow',\n}\n\n// The shape created with the arrow tool\n/** @internal */\nexport interface TLV1ArrowShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Arrow\n\tbend: number\n\thandles: {\n\t\tstart: TLV1Handle\n\t\tbend: TLV1Handle\n\t\tend: TLV1Handle\n\t}\n\tdecorations?: {\n\t\tstart?: TLV1Decoration\n\t\tend?: TLV1Decoration\n\t\tmiddle?: TLV1Decoration\n\t}\n\tlabel?: string\n\tlabelPoint?: number[]\n}\n\n/** @internal */\nexport interface TLV1ArrowBinding extends TLV1BaseBinding {\n\thandleId: keyof TLV1ArrowShape['handles']\n\tdistance: number\n\tpoint: number[]\n}\n\n/** @internal */\nexport type TLV1Binding = TLV1ArrowBinding\n\n/** @internal */\nexport interface TLV1ImageShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Image\n\tsize: number[]\n\tassetId: string\n}\n\n/** @internal */\nexport interface TLV1VideoShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Video\n\tsize: number[]\n\tassetId: string\n\tisPlaying: boolean\n\tcurrentTime: number\n}\n\n// The shape created by the text tool\n/** @internal */\nexport interface TLV1TextShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Text\n\ttext: string\n}\n\n// The shape created by the sticky tool\n/** @internal */\nexport interface TLV1StickyShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Sticky\n\tsize: number[]\n\ttext: string\n}\n\n// The shape created when multiple shapes are grouped\n/** @internal */\nexport interface TLV1GroupShape extends TLV1BaseShape {\n\ttype: TLV1ShapeType.Group\n\tsize: number[]\n\tchildren: string[]\n}\n\n/** @internal */\nexport type TLV1Shape =\n\t| TLV1RectangleShape\n\t| TLV1EllipseShape\n\t| TLV1TriangleShape\n\t| TLV1DrawShape\n\t| TLV1ArrowShape\n\t| TLV1TextShape\n\t| TLV1GroupShape\n\t| TLV1StickyShape\n\t| TLV1ImageShape\n\t| TLV1VideoShape\n\n/** @internal */\nexport interface TLV1Page {\n\tid: string\n\tname?: string\n\tchildIndex?: number\n\tshapes: Record<string, TLV1Shape>\n\tbindings: Record<string, TLV1Binding>\n}\n\n/** @internal */\nexport interface TLV1Bounds {\n\tminX: number\n\tminY: number\n\tmaxX: number\n\tmaxY: number\n\twidth: number\n\theight: number\n\trotation?: number\n}\n\n/** @internal */\nexport interface TLV1PageState {\n\tid: string\n\tselectedIds: string[]\n\tcamera: {\n\t\tpoint: number[]\n\t\tzoom: number\n\t}\n\tbrush?: TLV1Bounds | null\n\tpointedId?: string | null\n\thoveredId?: string | null\n\teditingId?: string | null\n\tbindingId?: string | null\n}\n\n/** @internal */\nexport enum TLV1AssetType {\n\tImage = 'image',\n\tVideo = 'video',\n}\n\n/** @internal */\nexport interface TLV1ImageAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Image\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1VideoAsset extends TLV1BaseAsset {\n\ttype: TLV1AssetType.Video\n\tfileName: string\n\tsrc: string\n\tsize: number[]\n}\n\n/** @internal */\nexport interface TLV1BaseAsset {\n\tid: string\n\ttype: string\n}\n\n/** @internal */\nexport type TLV1Asset = TLV1ImageAsset | TLV1VideoAsset\n\n/** @internal */\nexport interface TLV1Document {\n\tid: string\n\tname: string\n\tversion: number\n\tpages: Record<string, TLV1Page>\n\tpageStates: Record<string, TLV1PageState>\n\tassets: Record<string, TLV1Asset>\n}\n\n/* ------------------ Translations ------------------ */\n\nconst v1ColorsToV2Colors: Record<TLV1ColorStyle, TLDefaultColorStyle> = {\n\t[TLV1ColorStyle.White]: 'black',\n\t[TLV1ColorStyle.Black]: 'black',\n\t[TLV1ColorStyle.LightGray]: 'grey',\n\t[TLV1ColorStyle.Gray]: 'grey',\n\t[TLV1ColorStyle.Green]: 'light-green',\n\t[TLV1ColorStyle.Cyan]: 'green',\n\t[TLV1ColorStyle.Blue]: 'light-blue',\n\t[TLV1ColorStyle.Indigo]: 'blue',\n\t[TLV1ColorStyle.Orange]: 'orange',\n\t[TLV1ColorStyle.Yellow]: 'yellow',\n\t[TLV1ColorStyle.Red]: 'red',\n\t[TLV1ColorStyle.Violet]: 'light-violet',\n}\n\nconst v1FontsToV2Fonts: Record<TLV1FontStyle, TLDefaultFontStyle> = {\n\t[TLV1FontStyle.Mono]: 'mono',\n\t[TLV1FontStyle.Sans]: 'sans',\n\t[TLV1FontStyle.Script]: 'draw',\n\t[TLV1FontStyle.Serif]: 'serif',\n}\n\nconst v1AlignsToV2Aligns: Record<TLV1AlignStyle, TLDefaultHorizontalAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextAlignsToV2TextAligns: Record<TLV1AlignStyle, TLDefaultTextAlignStyle> = {\n\t[TLV1AlignStyle.Start]: 'start',\n\t[TLV1AlignStyle.Middle]: 'middle',\n\t[TLV1AlignStyle.End]: 'end',\n\t[TLV1AlignStyle.Justify]: 'start',\n}\n\nconst v1TextSizesToV2TextSizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 's',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1SizesToV2Sizes: Record<TLV1SizeStyle, TLDefaultSizeStyle> = {\n\t[TLV1SizeStyle.Small]: 'm',\n\t[TLV1SizeStyle.Medium]: 'l',\n\t[TLV1SizeStyle.Large]: 'xl',\n}\n\nconst v1DashesToV2Dashes: Record<TLV1DashStyle, TLDefaultDashStyle> = {\n\t[TLV1DashStyle.Solid]: 'solid',\n\t[TLV1DashStyle.Dashed]: 'dashed',\n\t[TLV1DashStyle.Dotted]: 'dotted',\n\t[TLV1DashStyle.Draw]: 'draw',\n}\n\nfunction getV2Color(color: TLV1ColorStyle | undefined): TLDefaultColorStyle {\n\treturn color ? (v1ColorsToV2Colors[color] ?? 'black') : 'black'\n}\n\nfunction getV2Font(font: TLV1FontStyle | undefined): TLDefaultFontStyle {\n\treturn font ? (v1FontsToV2Fonts[font] ?? 'draw') : 'draw'\n}\n\nfunction getV2Align(align: TLV1AlignStyle | undefined): TLDefaultHorizontalAlignStyle {\n\treturn align ? (v1AlignsToV2Aligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextAlign(align: TLV1AlignStyle | undefined): TLDefaultTextAlignStyle {\n\treturn align ? (v1TextAlignsToV2TextAligns[align] ?? 'middle') : 'middle'\n}\n\nfunction getV2TextSize(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1TextSizesToV2TextSizes[size] ?? 'm') : 'm'\n}\n\nfunction getV2Size(size: TLV1SizeStyle | undefined): TLDefaultSizeStyle {\n\treturn size ? (v1SizesToV2Sizes[size] ?? 'l') : 'l'\n}\n\nfunction getV2Dash(dash: TLV1DashStyle | undefined): TLDefaultDashStyle {\n\treturn dash ? (v1DashesToV2Dashes[dash] ?? 'draw') : 'draw'\n}\n\nfunction getV2Point(point: number[]): VecModel {\n\treturn {\n\t\tx: coerceNumber(point[0]),\n\t\ty: coerceNumber(point[1]),\n\t\tz: point[2] == null ? 0.5 : coerceNumber(point[2]),\n\t}\n}\n\nfunction getV2Arrowhead(decoration: TLV1Decoration | undefined): TLArrowShapeArrowheadStyle {\n\treturn decoration === TLV1Decoration.Arrow ? 'arrow' : 'none'\n}\n\nfunction getV2Fill(isFilled: boolean | undefined, color: TLV1ColorStyle) {\n\treturn isFilled\n\t\t? color === TLV1ColorStyle.Black || color === TLV1ColorStyle.White\n\t\t\t? 'semi'\n\t\t\t: 'solid'\n\t\t: 'none'\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EAcA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAEjC,MAAM,oBAAoB;AAGnB,SAAS,oBAAoB,QAAgB,WAAoB;AACvE,MAAI,WAAW;AACf,SAAO,IAAI,MAAM;AAChB,eAAW,QAAQ,UAAU,iBAAiB;AAE9C,WAAO,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;AAEzC,UAAM,cAAc,OAAO,SAAS,EAAE,CAAC,EAAE;AAGzC,WAAO,eAAe,WAAW;AAGjC,eAAW,QAAQ,OAAO,SAAS,EAAE,MAAM,CAAC,GAAG;AAC9C,aAAO,WAAW,KAAK,EAAE;AAAA,IAC1B;AAGA,WAAO,UAAU;AACjB,WAAO,aAAa,OAAO,oBAAoB,CAAC;AAGhD,UAAM,yBAAyB,oBAAI,IAAuB;AAE1D,WAAO,OAAO,SAAS,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,YAAY;AACzD,cAAQ,QAAQ,MAAM;AAAA,QACrB,KAAK,qBAAqB;AACzB,gBAAM,UAAqB,gBAAgB,SAAS;AACpD,iCAAuB,IAAI,QAAQ,IAAI,OAAO;AAC9C,gBAAM,mBAA4B;AAAA,YACjC,IAAI;AAAA,YACJ,UAAU;AAAA,YACV,MAAM;AAAA,YACN,OAAO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AACJ;",
|
|
6
6
|
"names": ["bounds", "TLV1ShapeType", "TLV1ColorStyle", "TLV1SizeStyle", "TLV1DashStyle", "TLV1AlignStyle", "TLV1FontStyle", "TLV1Decoration", "TLV1AssetType"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tldraw",
|
|
3
3
|
"description": "A tiny little drawing editor.",
|
|
4
|
-
"version": "4.3.0-
|
|
4
|
+
"version": "4.3.0-next.085293d79c32",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"@tiptap/pm": "^3.12.1",
|
|
63
63
|
"@tiptap/react": "^3.12.1",
|
|
64
64
|
"@tiptap/starter-kit": "^3.12.1",
|
|
65
|
-
"@tldraw/editor": "4.3.0-
|
|
66
|
-
"@tldraw/store": "4.3.0-
|
|
65
|
+
"@tldraw/editor": "4.3.0-next.085293d79c32",
|
|
66
|
+
"@tldraw/store": "4.3.0-next.085293d79c32",
|
|
67
67
|
"classnames": "^2.5.1",
|
|
68
68
|
"hotkeys-js": "^3.13.9",
|
|
69
69
|
"idb": "^7.1.1",
|
|
@@ -28,7 +28,7 @@ describe('DrawShapeUtil dot detection', () => {
|
|
|
28
28
|
|
|
29
29
|
describe('getIsDot behavior via hideResizeHandles', () => {
|
|
30
30
|
it('treats a shape with one segment and zero points as a dot', () => {
|
|
31
|
-
const shape = createDrawShape([{ type: 'free',
|
|
31
|
+
const shape = createDrawShape([{ type: 'free', path: '' }])
|
|
32
32
|
const util = editor.getShapeUtil('draw')
|
|
33
33
|
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
34
34
|
})
|
|
@@ -119,26 +119,26 @@ describe('DrawShapeUtil dot detection', () => {
|
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
describe('base64 encoding boundary conditions', () => {
|
|
122
|
-
it('correctly handles the boundary at exactly
|
|
123
|
-
//
|
|
124
|
-
// 2 points =
|
|
122
|
+
it('correctly handles the boundary at exactly 24 base64 characters (2 points)', () => {
|
|
123
|
+
// First point is 16 base64 chars (Float32), delta points are 8 chars each (Float16)
|
|
124
|
+
// 2 points = 24 characters, which should NOT be a dot
|
|
125
125
|
const twoPointsBase64 = pointsToBase64([
|
|
126
126
|
{ x: 0, y: 0, z: 0.5 },
|
|
127
127
|
{ x: 1, y: 1, z: 0.5 },
|
|
128
128
|
])
|
|
129
|
-
expect(twoPointsBase64.length).toBe(
|
|
129
|
+
expect(twoPointsBase64.length).toBe(24)
|
|
130
130
|
|
|
131
|
-
const shape = createDrawShape([{ type: 'free',
|
|
131
|
+
const shape = createDrawShape([{ type: 'free', path: twoPointsBase64 }])
|
|
132
132
|
const util = editor.getShapeUtil('draw')
|
|
133
133
|
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
134
134
|
})
|
|
135
135
|
|
|
136
|
-
it('correctly handles the boundary at exactly
|
|
137
|
-
// 1 point =
|
|
136
|
+
it('correctly handles the boundary at exactly 16 base64 characters (1 point)', () => {
|
|
137
|
+
// 1 point = 16 characters (Float32 first point), which should be a dot
|
|
138
138
|
const onePointBase64 = pointsToBase64([{ x: 0, y: 0, z: 0.5 }])
|
|
139
|
-
expect(onePointBase64.length).toBe(
|
|
139
|
+
expect(onePointBase64.length).toBe(16)
|
|
140
140
|
|
|
141
|
-
const shape = createDrawShape([{ type: 'free',
|
|
141
|
+
const shape = createDrawShape([{ type: 'free', path: onePointBase64 }])
|
|
142
142
|
const util = editor.getShapeUtil('draw')
|
|
143
143
|
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
144
144
|
})
|
|
@@ -227,9 +227,11 @@ function getDot(point: VecLike, sw: number) {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
function getIsDot(shape: TLDrawShape) {
|
|
230
|
-
//
|
|
230
|
+
// First point is 16 base64 chars (3 Float32s = 12 bytes)
|
|
231
|
+
// Each delta point is 8 base64 chars (3 Float16s = 6 bytes)
|
|
232
|
+
// 1 point = 16 chars, 2 points = 24 chars
|
|
231
233
|
// Check if we have less than 2 points without decoding
|
|
232
|
-
return shape.props.segments.length === 1 && shape.props.segments[0].
|
|
234
|
+
return shape.props.segments.length === 1 && shape.props.segments[0].path.length < 24
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
function DrawShapeSvg({ shape, zoomOverride }: { shape: TLDrawShape; zoomOverride?: number }) {
|
|
@@ -109,7 +109,7 @@ export function getPointsFromDrawSegment(
|
|
|
109
109
|
scaleY: number,
|
|
110
110
|
points: Vec[] = []
|
|
111
111
|
) {
|
|
112
|
-
const _points = b64Vecs.decodePoints(segment.
|
|
112
|
+
const _points = b64Vecs.decodePoints(segment.path)
|
|
113
113
|
|
|
114
114
|
// Apply scale factors (used for lazy resize and flipping)
|
|
115
115
|
if (scaleX !== 1 || scaleY !== 1) {
|