generic iframe embed (#1234)

This commit is contained in:
Philip Okugbe
2025-06-09 22:32:23 +01:00
committed by GitHub
parent 0029f84d50
commit 50b3f9ddd9
3 changed files with 32 additions and 3 deletions
@@ -18,7 +18,10 @@ import { useForm, zodResolver } from "@mantine/form";
import { notifications } from "@mantine/notifications";
import { useTranslation } from "react-i18next";
import i18n from "i18next";
import { getEmbedProviderById, getEmbedUrlAndProvider } from '@docmost/editor-ext';
import {
getEmbedProviderById,
getEmbedUrlAndProvider,
} from "@docmost/editor-ext";
const schema = z.object({
url: z
@@ -49,6 +52,10 @@ export default function EmbedView(props: NodeViewProps) {
async function onSubmit(data: { url: string }) {
if (provider) {
const embedProvider = getEmbedProviderById(provider);
if (embedProvider.id === "iframe") {
updateAttributes({ src: data.url });
return;
}
if (embedProvider.regex.test(data.url)) {
updateAttributes({ src: data.url });
} else {