Skip to content

Commit

Permalink
fix: Additional Canva embed format, closes #8140
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Dec 25, 2024
1 parent 86cfd62 commit 3437bd3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions shared/editor/embeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,21 @@ const embeds: EmbedDescriptor[] = [
new EmbedDescriptor({
title: "Canva",
keywords: "design",
regexMatch: [
/^https:\/\/(?:www\.)?canva\.com\/design\/([a-zA-Z0-9_]*)\/(.*)$/,
],
transformMatch: (matches: RegExpMatchArray) =>
`https://www.canva.com/design/${matches[1]}/view?embed`,
regexMatch: [/^https:\/\/(?:www\.)?canva\.com\/design\/([\/a-zA-Z0-9_]*)$/],
transformMatch: (matches: RegExpMatchArray) => {
const input = matches.input ?? matches[0];

try {
const url = new URL(input);
const params = new URLSearchParams(url.search);
params.append("embed", "");
return `${url.origin}${url.pathname}?${params.toString()}`;
} catch (e) {
//
}

return input;
},
icon: <Img src="/images/canva.png" alt="Canva" />,
}),
new EmbedDescriptor({
Expand Down

0 comments on commit 3437bd3

Please sign in to comment.