Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Plugin, string, object, migratable } from '@edtr-io/plugin'
import { createIcon, faFilm } from '@edtr-io/ui'
import * as React from 'react'
import { VideoEditor } from './editor'
import { VideoRenderer } from './renderer'
const stateV0 = string()
const stateV1 = object({ src: string(), alt: string() })
export const videoState = migratable(stateV0).migrate(stateV1, src => {
return { src, alt: '' }
})
export const videoPlugin: Plugin = {
//eslint-disable-next-line react/display-name
Component: props =>
props.editable ? : ,
state: videoState,
title: 'Video',
description: 'Binde Videos von Youtube, Vimeo, Wikimedia und BR ein.',
icon: createIcon(faFilm),
onPaste(clipboardData: DataTransfer) {
const value = clipboardData.getData('text')
const regex = /^(https?:\/\/)?(.*?(youtube\.com\/watch\?(.*&)?v=.+|youtu\.be\/.+|vimeo\.com\/.+|upload\.wikimedia\.org\/.+(\.webm|\.ogg)?|br\.de\/.+))/
if (regex.test(value)) {