From 381178d23654e23c8c2abce59e97e5ee734f8c0e Mon Sep 17 00:00:00 2001 From: ritk20 Date: Thu, 10 Oct 2024 17:49:49 +0530 Subject: [PATCH] feat: adds web.tutAR embeds --- packages/excalidraw/element/embeddable.ts | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/packages/excalidraw/element/embeddable.ts b/packages/excalidraw/element/embeddable.ts index eada31a5b..3874d30f6 100644 --- a/packages/excalidraw/element/embeddable.ts +++ b/packages/excalidraw/element/embeddable.ts @@ -14,6 +14,7 @@ import type { import { sanitizeHTMLAttribute } from "../data/url"; import type { MarkRequired } from "../utility-types"; import { StoreAction } from "../store"; +import { t } from "../i18n"; type IframeDataWithSandbox = MarkRequired; @@ -51,6 +52,12 @@ const RE_REDDIT = const RE_REDDIT_EMBED = /^ { @@ -267,6 +276,52 @@ export const getEmbedLink = ( return ret; } + const tutarLinkWithUserId = link.match(RE_TUTAR_WITH_USER_ID); + if(tutarLinkWithUserId) { + const [, apiKey, userId] = link.match(RE_TUTAR_WITH_USER_ID)!; + const safeURL = sanitizeHTMLAttribute( + `https://web.tutar.app?api-key=${apiKey}&user-id=${userId}`, + ); + const ret: IframeDataWithSandbox = { + type: "document", + srcdoc: () => + createSrcDoc(` + + `), + intrinsicSize: { w: 550, h: 550 }, + sandbox: { allowSameOrigin }, + }; + embeddedLinkCache.set(link, ret); + return ret; + } + + const tutarLinkWithoutUserId = link.match(RE_TUTAR_WITHOUT_USER_ID); + if(tutarLinkWithoutUserId) { + const [, apiKey] = link.match(RE_TUTAR_WITHOUT_USER_ID)!; + const safeURL = sanitizeHTMLAttribute( + `https://web.tutar.app?api-key=${apiKey}`, + ); + const ret: IframeDataWithSandbox = { + type: "document", + srcdoc: () => + createSrcDoc(` + + `), + intrinsicSize: { w: 550, h: 550 }, + sandbox: { allowSameOrigin }, + }; + embeddedLinkCache.set(link, ret); + return ret; + } + embeddedLinkCache.set(link, { link, intrinsicSize: aspectRatio,