tldraw 4.1.1 → 4.2.0-next.d76c345101d5

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.
Files changed (111) hide show
  1. package/dist-cjs/index.d.ts +15 -11
  2. package/dist-cjs/index.js +3 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/defaultEmbedDefinitions.js +2 -25
  5. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  6. package/dist-cjs/lib/defaultExternalContentHandlers.js +8 -31
  7. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  8. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +31 -101
  9. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  10. package/dist-cjs/lib/shapes/bookmark/bookmarks.js +138 -0
  11. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +7 -0
  12. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +25 -3
  13. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  14. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +20 -4
  15. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  16. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +23 -11
  17. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  18. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +18 -5
  19. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  20. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +21 -9
  21. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  22. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +24 -8
  23. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  24. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +21 -9
  25. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  26. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +23 -8
  27. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  28. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +21 -9
  29. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  30. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +26 -11
  31. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  32. package/dist-cjs/lib/ui/components/DebugMenu/DefaultDebugMenuContent.js +2 -2
  33. package/dist-cjs/lib/ui/components/DebugMenu/DefaultDebugMenuContent.js.map +1 -1
  34. package/dist-cjs/lib/ui/components/menu-items.js +2 -2
  35. package/dist-cjs/lib/ui/components/menu-items.js.map +1 -1
  36. package/dist-cjs/lib/ui/context/actions.js +23 -29
  37. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  38. package/dist-cjs/lib/ui/hooks/useEditorEvents.js +1 -1
  39. package/dist-cjs/lib/ui/hooks/useEditorEvents.js.map +1 -1
  40. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +4 -4
  41. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +1 -1
  42. package/dist-cjs/lib/ui/version.js +3 -3
  43. package/dist-cjs/lib/ui/version.js.map +1 -1
  44. package/dist-esm/index.d.mts +15 -11
  45. package/dist-esm/index.mjs +3 -1
  46. package/dist-esm/index.mjs.map +2 -2
  47. package/dist-esm/lib/defaultEmbedDefinitions.mjs +2 -25
  48. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  49. package/dist-esm/lib/defaultExternalContentHandlers.mjs +8 -31
  50. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  51. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +34 -101
  52. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  53. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs +124 -0
  54. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +7 -0
  55. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +26 -3
  56. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  57. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +20 -4
  58. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  59. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +23 -11
  60. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  61. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +18 -5
  62. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  63. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +21 -9
  64. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  65. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +24 -8
  66. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  67. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +21 -9
  68. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  69. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +23 -8
  70. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  71. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +21 -9
  72. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  73. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +26 -11
  74. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  75. package/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenuContent.mjs +2 -2
  76. package/dist-esm/lib/ui/components/DebugMenu/DefaultDebugMenuContent.mjs.map +1 -1
  77. package/dist-esm/lib/ui/components/menu-items.mjs +2 -2
  78. package/dist-esm/lib/ui/components/menu-items.mjs.map +1 -1
  79. package/dist-esm/lib/ui/context/actions.mjs +23 -29
  80. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  81. package/dist-esm/lib/ui/hooks/useEditorEvents.mjs +1 -1
  82. package/dist-esm/lib/ui/hooks/useEditorEvents.mjs.map +1 -1
  83. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +4 -4
  84. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +1 -1
  85. package/dist-esm/lib/ui/version.mjs +3 -3
  86. package/dist-esm/lib/ui/version.mjs.map +1 -1
  87. package/package.json +3 -3
  88. package/src/index.ts +1 -0
  89. package/src/lib/defaultEmbedDefinitions.ts +2 -25
  90. package/src/lib/defaultExternalContentHandlers.ts +10 -35
  91. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +39 -133
  92. package/src/lib/shapes/bookmark/bookmarks.ts +170 -0
  93. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +28 -2
  94. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +23 -6
  95. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +24 -12
  96. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +21 -10
  97. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +23 -11
  98. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +26 -9
  99. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +23 -10
  100. package/src/lib/tools/SelectTool/childStates/Resizing.ts +24 -9
  101. package/src/lib/tools/SelectTool/childStates/Rotating.ts +27 -11
  102. package/src/lib/tools/SelectTool/childStates/Translating.ts +28 -12
  103. package/src/lib/ui/components/DebugMenu/DefaultDebugMenuContent.tsx +2 -2
  104. package/src/lib/ui/components/menu-items.tsx +2 -2
  105. package/src/lib/ui/context/actions.tsx +27 -31
  106. package/src/lib/ui/hooks/useEditorEvents.ts +1 -1
  107. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +4 -4
  108. package/src/lib/ui/version.ts +3 -3
  109. package/src/lib/utils/embeds/embeds.test.ts +16 -34
  110. package/src/test/SelectTool.test.ts +251 -0
  111. package/src/test/bookmark-shapes.test.ts +129 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/defaultEmbedDefinitions.ts"],
4
- "sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}&center=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\treturn `${url}?embed=true`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'excalidraw',\n\t\ttitle: 'Excalidraw',\n\t\thostnames: ['excalidraw.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hash.match(/#room=/)) {\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hash.match(/#room=/)) {\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as a embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAG7B,MAAM,gBAAgB;AAGf,MAAM,4BAA4B;AAAA,EACxC;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAAC,mBAAmB,cAAc,gBAAgB;AAAA,IAC7D,UAAU;AAAA,IACV,WAAW;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,qBAAqB;AAAA,MACpB,wBAAwB;AAAA,IACzB;AAAA,IACA,YAAY,CAAC,QAAQ;AACpB,YAAM,SAAS,aAAa,GAAG;AAC/B,UAAI,UAAU,OAAO,SAAS,MAAM,aAAa,GAAG;AAEnD,eAAO,aAAa,OAAO,SAAS,MAAM;AAC1C,eAAO;AAAA,MACR;AACA;AAAA,IACD;AAAA,IACA,cAAc,CAAC,QAAQ;AACtB,YAAM,SAAS,aAAa,GAAG;AAC/B,UAAI,UAAU,OAAO,SAAS,MAAM,aAAa,GAAG;AAEnD,eAAO,aAAa,OAAO,OAAO;AAClC,eAAO;AAAA,MACR;AACA;AAAA,IACD;AAAA,IACA,cAAc;AAAA,E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+B,SAAS,IAAkC;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
4
+ "sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}&center=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as a embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAG7B,MAAM,gBAAgB;AAGf,MAAM,4BAA4B;AAAA,EACxC;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAAC,mBAAmB,cAAc,gBAAgB;AAAA,IAC7D,UAAU;AAAA,IACV,WAAW;AAAA,IACX,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IAC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C;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
6
6
  "names": []
7
7
  }
@@ -12,6 +12,7 @@ import {
12
12
  maybeSnapToGrid,
13
13
  toRichText
14
14
  } from "@tldraw/editor";
15
+ import { createBookmarkFromUrl } from "./shapes/bookmark/bookmarks.mjs";
15
16
  import { getCroppedImageDataForReplacedImage } from "./shapes/shared/crop.mjs";
16
17
  import { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from "./shapes/shared/default-shape-constants.mjs";
17
18
  import { containBoxSize } from "./utils/assets/assets.mjs";
@@ -338,38 +339,14 @@ async function defaultHandleExternalUrlContent(editor, { point, url }, { toasts,
338
339
  });
339
340
  }
340
341
  const position = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageBounds().center);
341
- const assetId = AssetRecordType.createId(getHashForString(url));
342
- const shape = createEmptyBookmarkShape(editor, url, position);
343
- let asset = editor.getAsset(assetId);
344
- let shouldAlsoCreateAsset = false;
345
- if (!asset) {
346
- shouldAlsoCreateAsset = true;
347
- try {
348
- const bookmarkAsset = await editor.getAssetForExternalContent({ type: "url", url });
349
- if (!bookmarkAsset) throw Error("Could not create an asset");
350
- asset = bookmarkAsset;
351
- } catch {
352
- toasts.addToast({
353
- title: msg("assets.url.failed"),
354
- severity: "error"
355
- });
356
- return;
357
- }
342
+ const result = await createBookmarkFromUrl(editor, { url, center: position });
343
+ if (!result.ok) {
344
+ toasts.addToast({
345
+ title: msg("assets.url.failed"),
346
+ severity: "error"
347
+ });
348
+ return;
358
349
  }
359
- editor.run(() => {
360
- if (shouldAlsoCreateAsset) {
361
- editor.createAssets([asset]);
362
- }
363
- editor.updateShapes([
364
- {
365
- id: shape.id,
366
- type: shape.type,
367
- props: {
368
- assetId: asset.id
369
- }
370
- }
371
- ]);
372
- });
373
350
  }
374
351
  async function defaultHandleExternalTldrawContent(editor, { point, content }) {
375
352
  editor.run(() => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/defaultExternalContentHandlers.ts"],
4
- "sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tTLVideoShape,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes<TLImageShape>([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes<TLVideoShape>([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes<TLTextShape>([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst assetId: TLAssetId = AssetRecordType.createId(getHashForString(url))\n\tconst shape = createEmptyBookmarkShape(editor, url, position)\n\n\t// Use an existing asset if we have one, or else else create a new one\n\tlet asset = editor.getAsset(assetId) as TLAsset\n\tlet shouldAlsoCreateAsset = false\n\tif (!asset) {\n\t\tshouldAlsoCreateAsset = true\n\t\ttry {\n\t\t\tconst bookmarkAsset = await editor.getAssetForExternalContent({ type: 'url', url })\n\t\t\tif (!bookmarkAsset) throw Error('Could not create an asset')\n\t\t\tasset = bookmarkAsset\n\t\t} catch {\n\t\t\ttoasts.addToast({\n\t\t\t\ttitle: msg('assets.url.failed'),\n\t\t\t\tseverity: 'error',\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\tif (shouldAlsoCreateAsset) {\n\t\t\teditor.createAssets([asset])\n\t\t}\n\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: asset.id,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\t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AE,QAAQ,UAAU,YAAY,YAAY,CAAC;AAAA,MACzF,UAAU;AAAA,IACX,CAAC;AACD,WAAO;AAAA,EACR;AAKA,MAAI,CAAC,KAAK,MAAM;AACf,WAAO,SAAS;AAAA,MACf,OAAO,IAAI,4BAA4B;AAAA,MACvC,UAAU;AAAA,IACX,CAAC;AACD,YAAQ,MAAM,cAAc;AAC5B,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAGA,eAAsB,aACrB,MACA,SACA,SACC;AACD,QAAM;AAAA,IACL,yBAAyB;AAAA,IACzB,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,EACrB,IAAI;AAEJ,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,OAAO,iBAAiB,MAAM,KAAK,YAAY,CAAC;AACtD,cAAY,gBAAgB,SAAS,IAAI;AACzC,QAAM,YAAY,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;",
4
+ "sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tTLVideoShape,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { createBookmarkFromUrl } from './shapes/bookmark/bookmarks'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes<TLImageShape>([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes<TLVideoShape>([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes<TLTextShape>([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\t// Use the new function to create the bookmark\n\tconst result = await createBookmarkFromUrl(editor, { url, center: position })\n\n\tif (!result.ok) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\tisVideoType,\n\t\tmaxImageDimension\n\t)\n\treturn assetInfo\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAiBA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,6BAA6B;AAEtC,SAAS,2CAA2C;AACpD,SAAS,eAAe,YAAY,kBAAkB;AAGtD,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,aAAa,6BAA6B;AAM5C,MAAM,8BAA8B;AAKpC,MAAM,yBAAyB,KAAK,OAAO;AAiC3C,SAAS,uCACf,QACA,SACC;AAED,SAAO,6BAA6B,QAAQ,OAAO,kBAAkB;AACpE,WAAO,+BAA+B,QAAQ,eAAe,OAAO;AAAA,EACrE,CAAC;AAGD,SAAO,6BAA6B,OAAO,OAAO,kBAAkB;AACnE,WAAO,8BAA8B,QAAQ,eAAe,OAAO;AAAA,EACpE,CAAC;AAGD,SAAO,+BAA+B,YAAY,OAAO,oBAAoB;AAC5E,WAAO,oCAAoC,QAAQ,eAAe;AAAA,EACnE,CAAC;AAGD,SAAO,+BAAyD,SAAS,CAAC,oBAAoB;AAC7F,WAAO,kCAAkC,QAAQ,eAAe;AAAA,EACjE,CAAC;AAGD,SAAO,+BAA+B,SAAS,OAAO,oBAAoB;AACzE,WAAO,iCAAiC,QAAQ,iBAAiB,OAAO;AAAA,EACzE,CAAC;AAGD,SAAO,+BAA+B,gBAAgB,OAAO,oBAAoB;AAChF,WAAO,wCAAwC,QAAQ,iBAAiB,OAAO;AAAA,EAChF,CAAC;AAGD,SAAO,+BAA+B,QAAQ,OAAO,oB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