mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
generic iframe embed (#1234)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user