@tiptap/extension-youtube
Advanced tools
Comparing version 3.0.0-next.3 to 3.0.0-next.4
@@ -5,4 +5,4 @@ // src/youtube.ts | ||
// src/utils.ts | ||
var YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?!channel\/)(?!@)(.+)?$/; | ||
var YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/g; | ||
var YOUTUBE_REGEX = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/; | ||
var YOUTUBE_REGEX_GLOBAL = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g; | ||
var isValidYoutubeUrl = (url) => { | ||
@@ -249,7 +249,7 @@ return url.match(YOUTUBE_REGEX); | ||
// src/index.ts | ||
var src_default = Youtube; | ||
var index_default = Youtube; | ||
export { | ||
Youtube, | ||
src_default as default | ||
index_default as default | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-youtube", | ||
"description": "a youtube embed extension for tiptap", | ||
"version": "3.0.0-next.3", | ||
"version": "3.0.0-next.4", | ||
"homepage": "https://tiptap.dev", | ||
@@ -18,3 +18,6 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/index.js", | ||
@@ -32,3 +35,3 @@ "require": "./dist/index.cjs" | ||
"devDependencies": { | ||
"@tiptap/core": "^3.0.0-next.3" | ||
"@tiptap/core": "^3.0.0-next.4" | ||
}, | ||
@@ -44,4 +47,5 @@ "peerDependencies": { | ||
"scripts": { | ||
"build": "tsup" | ||
"build": "tsup", | ||
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/" | ||
} | ||
} | ||
} |
# @tiptap/extension-youtube | ||
[![Version](https://img.shields.io/npm/v/@tiptap/extension-youtube.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-youtube) | ||
@@ -8,8 +9,11 @@ [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-youtube.svg)](https://npmcharts.com/compare/tiptap?minimal=true) | ||
## Introduction | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_. | ||
## Official Documentation | ||
Documentation can be found on the [Tiptap website](https://tiptap.dev). | ||
## License | ||
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md). |
@@ -1,3 +0,5 @@ | ||
export const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?!channel\/)(?!@)(.+)?$/ | ||
export const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/g | ||
export const YOUTUBE_REGEX = | ||
/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/ | ||
export const YOUTUBE_REGEX_GLOBAL = | ||
/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g | ||
@@ -9,20 +11,20 @@ export const isValidYoutubeUrl = (url: string) => { | ||
export interface GetEmbedUrlOptions { | ||
url: string; | ||
allowFullscreen?: boolean; | ||
autoplay?: boolean; | ||
ccLanguage?:string; | ||
ccLoadPolicy?:boolean; | ||
controls?: boolean; | ||
disableKBcontrols?: boolean, | ||
enableIFrameApi?: boolean; | ||
endTime?: number; | ||
interfaceLanguage?: string; | ||
ivLoadPolicy?: number; | ||
loop?: boolean; | ||
modestBranding?: boolean; | ||
nocookie?: boolean; | ||
origin?: string; | ||
playlist?: string; | ||
progressBarColor?: string; | ||
startAt?: number; | ||
url: string | ||
allowFullscreen?: boolean | ||
autoplay?: boolean | ||
ccLanguage?: string | ||
ccLoadPolicy?: boolean | ||
controls?: boolean | ||
disableKBcontrols?: boolean | ||
enableIFrameApi?: boolean | ||
endTime?: number | ||
interfaceLanguage?: string | ||
ivLoadPolicy?: number | ||
loop?: boolean | ||
modestBranding?: boolean | ||
nocookie?: boolean | ||
origin?: string | ||
playlist?: string | ||
progressBarColor?: string | ||
startAt?: number | ||
} | ||
@@ -29,0 +31,0 @@ |
@@ -11,3 +11,3 @@ import { mergeAttributes, Node, nodePasteRule } from '@tiptap/core' | ||
*/ | ||
addPasteHandler: boolean; | ||
addPasteHandler: boolean | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
allowFullscreen: boolean; | ||
allowFullscreen: boolean | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
autoplay: boolean; | ||
autoplay: boolean | ||
@@ -35,3 +35,3 @@ /** | ||
*/ | ||
ccLanguage?: string; | ||
ccLanguage?: string | ||
@@ -43,3 +43,3 @@ /** | ||
*/ | ||
ccLoadPolicy?: boolean; | ||
ccLoadPolicy?: boolean | ||
@@ -51,3 +51,3 @@ /** | ||
*/ | ||
controls: boolean; | ||
controls: boolean | ||
@@ -59,3 +59,3 @@ /** | ||
*/ | ||
disableKBcontrols: boolean; | ||
disableKBcontrols: boolean | ||
@@ -67,3 +67,3 @@ /** | ||
*/ | ||
enableIFrameApi: boolean; | ||
enableIFrameApi: boolean | ||
@@ -75,3 +75,3 @@ /** | ||
*/ | ||
endTime: number; | ||
endTime: number | ||
@@ -83,3 +83,3 @@ /** | ||
*/ | ||
height: number; | ||
height: number | ||
@@ -91,3 +91,3 @@ /** | ||
*/ | ||
interfaceLanguage?: string; | ||
interfaceLanguage?: string | ||
@@ -99,3 +99,3 @@ /** | ||
*/ | ||
ivLoadPolicy: number; | ||
ivLoadPolicy: number | ||
@@ -107,3 +107,3 @@ /** | ||
*/ | ||
loop: boolean; | ||
loop: boolean | ||
@@ -115,3 +115,3 @@ /** | ||
*/ | ||
modestBranding: boolean; | ||
modestBranding: boolean | ||
@@ -123,3 +123,3 @@ /** | ||
*/ | ||
HTMLAttributes: Record<string, any>; | ||
HTMLAttributes: Record<string, any> | ||
@@ -131,3 +131,3 @@ /** | ||
*/ | ||
inline: boolean; | ||
inline: boolean | ||
@@ -139,3 +139,3 @@ /** | ||
*/ | ||
nocookie: boolean; | ||
nocookie: boolean | ||
@@ -147,3 +147,3 @@ /** | ||
*/ | ||
origin: string; | ||
origin: string | ||
@@ -155,3 +155,3 @@ /** | ||
*/ | ||
playlist: string; | ||
playlist: string | ||
@@ -163,3 +163,3 @@ /** | ||
*/ | ||
progressBarColor?: string; | ||
progressBarColor?: string | ||
@@ -171,3 +171,3 @@ /** | ||
*/ | ||
width: number; | ||
width: number | ||
} | ||
@@ -178,3 +178,3 @@ | ||
*/ | ||
type SetYoutubeVideoOptions = { src: string, width?: number, height?: number, start?: number } | ||
type SetYoutubeVideoOptions = { src: string; width?: number; height?: number; start?: number } | ||
@@ -189,3 +189,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType, | ||
setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType | ||
} | ||
@@ -265,12 +265,14 @@ } | ||
return { | ||
setYoutubeVideo: (options: SetYoutubeVideoOptions) => ({ commands }) => { | ||
if (!isValidYoutubeUrl(options.src)) { | ||
return false | ||
} | ||
setYoutubeVideo: | ||
(options: SetYoutubeVideoOptions) => | ||
({ commands }) => { | ||
if (!isValidYoutubeUrl(options.src)) { | ||
return false | ||
} | ||
return commands.insertContent({ | ||
type: this.name, | ||
attrs: options, | ||
}) | ||
}, | ||
return commands.insertContent({ | ||
type: this.name, | ||
attrs: options, | ||
}) | ||
}, | ||
} | ||
@@ -277,0 +279,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
66937
12
1097
19