refactor(extension-youtube): command types (#3842)

This commit is contained in:
Sven Adlung 2023-03-23 09:54:58 +01:00 committed by GitHub
parent 3937c44c43
commit e22b873e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,13 +26,15 @@ export interface YoutubeOptions {
width: number;
}
type SetYoutubeVideoOptions = { src: string, width?: number, height?: number, start?: number }
declare module '@tiptap/core' {
interface Commands<ReturnType> {
youtube: {
/**
* Insert a youtube video
*/
setYoutubeVideo: (options: { src: string, width?: number, height?: number, start?: number }) => ReturnType,
setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType,
}
}
}
@ -103,7 +105,7 @@ export const Youtube = Node.create<YoutubeOptions>({
addCommands() {
return {
setYoutubeVideo: options => ({ commands }) => {
setYoutubeVideo: (options: SetYoutubeVideoOptions) => ({ commands }) => {
if (!isValidYoutubeUrl(options.src)) {
return false
}