mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Merge 12f2fd9f5f
into ab89d4c16f
This commit is contained in:
commit
f8e970dec7
1 changed files with 54 additions and 0 deletions
|
@ -52,6 +52,12 @@ const RE_REDDIT =
|
|||
const RE_REDDIT_EMBED =
|
||||
/^<blockquote[\s\S]*?\shref=["'](https?:\/\/(?:www\.)?reddit\.com\/[^"']*)/i;
|
||||
|
||||
const RE_TUTAR_WITH_USER_ID =
|
||||
/^https:\/\/web\.tutar\.app\?api-key=([a-zA-Z0-9_-]+)&user-id=([a-zA-Z0-9_-]+)$/;
|
||||
|
||||
const RE_TUTAR_WITHOUT_USER_ID =
|
||||
/^https:\/\/web\.tutar\.app\?api-key=([a-zA-Z0-9_-]+)$/;
|
||||
|
||||
const ALLOWED_DOMAINS = new Set([
|
||||
"youtube.com",
|
||||
"youtu.be",
|
||||
|
@ -67,6 +73,7 @@ const ALLOWED_DOMAINS = new Set([
|
|||
"val.town",
|
||||
"giphy.com",
|
||||
"reddit.com",
|
||||
"web.tutar.app",
|
||||
]);
|
||||
|
||||
const ALLOW_SAME_ORIGIN = new Set([
|
||||
|
@ -80,6 +87,7 @@ const ALLOW_SAME_ORIGIN = new Set([
|
|||
"*.simplepdf.eu",
|
||||
"stackblitz.com",
|
||||
"reddit.com",
|
||||
"web.tutar.app",
|
||||
]);
|
||||
|
||||
export const createSrcDoc = (body: string) => {
|
||||
|
@ -268,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(`
|
||||
<iframe
|
||||
src="${safeURL}"
|
||||
id="3d-viewer"
|
||||
allow="camera"
|
||||
allowFullScreen ></iframe>
|
||||
`),
|
||||
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(`
|
||||
<iframe
|
||||
src="${safeURL}"
|
||||
id="3d-viewer"
|
||||
allow="camera"
|
||||
allowFullScreen ></iframe>
|
||||
`),
|
||||
intrinsicSize: { w: 550, h: 550 },
|
||||
sandbox: { allowSameOrigin },
|
||||
};
|
||||
embeddedLinkCache.set(link, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
embeddedLinkCache.set(link, {
|
||||
link,
|
||||
intrinsicSize: aspectRatio,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue