@tiptap/extension-youtube 3.20.3 → 3.20.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Youtube: () => Youtube,
24
+ default: () => index_default,
25
+ getEmbedUrlFromYoutubeUrl: () => getEmbedUrlFromYoutubeUrl,
26
+ isValidYoutubeUrl: () => isValidYoutubeUrl
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/youtube.ts
31
+ var import_core = require("@tiptap/core");
32
+
33
+ // src/utils.ts
34
+ var YOUTUBE_REGEX = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/;
35
+ var YOUTUBE_REGEX_GLOBAL = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g;
36
+ var isValidYoutubeUrl = (url) => {
37
+ return url.match(YOUTUBE_REGEX);
38
+ };
39
+ var getYoutubeEmbedUrl = (nocookie, isPlaylist) => {
40
+ if (isPlaylist) {
41
+ return "https://www.youtube-nocookie.com/embed/videoseries?list=";
42
+ }
43
+ return nocookie ? "https://www.youtube-nocookie.com/embed/" : "https://www.youtube.com/embed/";
44
+ };
45
+ var getEmbedUrlFromYoutubeUrl = (options) => {
46
+ const {
47
+ url,
48
+ allowFullscreen,
49
+ autoplay,
50
+ ccLanguage,
51
+ ccLoadPolicy,
52
+ controls,
53
+ disableKBcontrols,
54
+ enableIFrameApi,
55
+ endTime,
56
+ interfaceLanguage,
57
+ ivLoadPolicy,
58
+ loop,
59
+ modestBranding,
60
+ nocookie,
61
+ origin,
62
+ playlist,
63
+ progressBarColor,
64
+ startAt,
65
+ rel
66
+ } = options;
67
+ if (!isValidYoutubeUrl(url)) {
68
+ return null;
69
+ }
70
+ if (url.includes("/embed/")) {
71
+ return url;
72
+ }
73
+ if (url.includes("youtu.be")) {
74
+ const id = url.split("/").pop();
75
+ if (!id) {
76
+ return null;
77
+ }
78
+ return `${getYoutubeEmbedUrl(nocookie)}${id}`;
79
+ }
80
+ const videoIdRegex = /(?:(v|list)=|shorts\/)([-\w]+)/gm;
81
+ const matches = videoIdRegex.exec(url);
82
+ if (!matches || !matches[2]) {
83
+ return null;
84
+ }
85
+ let outputUrl = `${getYoutubeEmbedUrl(nocookie, matches[1] === "list")}${matches[2]}`;
86
+ const params = [];
87
+ if (allowFullscreen === false) {
88
+ params.push("fs=0");
89
+ }
90
+ if (autoplay) {
91
+ params.push("autoplay=1");
92
+ }
93
+ if (ccLanguage) {
94
+ params.push(`cc_lang_pref=${ccLanguage}`);
95
+ }
96
+ if (ccLoadPolicy) {
97
+ params.push("cc_load_policy=1");
98
+ }
99
+ if (!controls) {
100
+ params.push("controls=0");
101
+ }
102
+ if (disableKBcontrols) {
103
+ params.push("disablekb=1");
104
+ }
105
+ if (enableIFrameApi) {
106
+ params.push("enablejsapi=1");
107
+ }
108
+ if (endTime) {
109
+ params.push(`end=${endTime}`);
110
+ }
111
+ if (interfaceLanguage) {
112
+ params.push(`hl=${interfaceLanguage}`);
113
+ }
114
+ if (ivLoadPolicy) {
115
+ params.push(`iv_load_policy=${ivLoadPolicy}`);
116
+ }
117
+ if (loop) {
118
+ params.push("loop=1");
119
+ }
120
+ if (modestBranding) {
121
+ params.push("modestbranding=1");
122
+ }
123
+ if (origin) {
124
+ params.push(`origin=${origin}`);
125
+ }
126
+ if (playlist) {
127
+ params.push(`playlist=${playlist}`);
128
+ }
129
+ if (startAt) {
130
+ params.push(`start=${startAt}`);
131
+ }
132
+ if (progressBarColor) {
133
+ params.push(`color=${progressBarColor}`);
134
+ }
135
+ if (rel !== void 0) {
136
+ params.push(`rel=${rel}`);
137
+ }
138
+ if (params.length) {
139
+ outputUrl += `${matches[1] === "list" ? "&" : "?"}${params.join("&")}`;
140
+ }
141
+ return outputUrl;
142
+ };
143
+
144
+ // src/youtube.ts
145
+ var Youtube = import_core.Node.create({
146
+ name: "youtube",
147
+ addOptions() {
148
+ return {
149
+ addPasteHandler: true,
150
+ allowFullscreen: true,
151
+ autoplay: false,
152
+ ccLanguage: void 0,
153
+ ccLoadPolicy: void 0,
154
+ controls: true,
155
+ disableKBcontrols: false,
156
+ enableIFrameApi: false,
157
+ endTime: 0,
158
+ height: 480,
159
+ interfaceLanguage: void 0,
160
+ ivLoadPolicy: 0,
161
+ loop: false,
162
+ modestBranding: false,
163
+ HTMLAttributes: {},
164
+ inline: false,
165
+ nocookie: false,
166
+ origin: "",
167
+ playlist: "",
168
+ progressBarColor: void 0,
169
+ width: 640,
170
+ rel: 1
171
+ };
172
+ },
173
+ inline() {
174
+ return this.options.inline;
175
+ },
176
+ group() {
177
+ return this.options.inline ? "inline" : "block";
178
+ },
179
+ draggable: true,
180
+ addAttributes() {
181
+ return {
182
+ src: {
183
+ default: null
184
+ },
185
+ start: {
186
+ default: 0
187
+ },
188
+ width: {
189
+ default: this.options.width
190
+ },
191
+ height: {
192
+ default: this.options.height
193
+ }
194
+ };
195
+ },
196
+ parseHTML() {
197
+ return [
198
+ {
199
+ tag: "div[data-youtube-video] iframe"
200
+ }
201
+ ];
202
+ },
203
+ addCommands() {
204
+ return {
205
+ setYoutubeVideo: (options) => ({ commands }) => {
206
+ if (!isValidYoutubeUrl(options.src)) {
207
+ return false;
208
+ }
209
+ return commands.insertContent({
210
+ type: this.name,
211
+ attrs: options
212
+ });
213
+ }
214
+ };
215
+ },
216
+ addPasteRules() {
217
+ if (!this.options.addPasteHandler) {
218
+ return [];
219
+ }
220
+ return [
221
+ (0, import_core.nodePasteRule)({
222
+ find: YOUTUBE_REGEX_GLOBAL,
223
+ type: this.type,
224
+ getAttributes: (match) => {
225
+ return { src: match.input };
226
+ }
227
+ })
228
+ ];
229
+ },
230
+ renderHTML({ HTMLAttributes }) {
231
+ const embedUrl = getEmbedUrlFromYoutubeUrl({
232
+ url: HTMLAttributes.src,
233
+ allowFullscreen: this.options.allowFullscreen,
234
+ autoplay: this.options.autoplay,
235
+ ccLanguage: this.options.ccLanguage,
236
+ ccLoadPolicy: this.options.ccLoadPolicy,
237
+ controls: this.options.controls,
238
+ disableKBcontrols: this.options.disableKBcontrols,
239
+ enableIFrameApi: this.options.enableIFrameApi,
240
+ endTime: this.options.endTime,
241
+ interfaceLanguage: this.options.interfaceLanguage,
242
+ ivLoadPolicy: this.options.ivLoadPolicy,
243
+ loop: this.options.loop,
244
+ modestBranding: this.options.modestBranding,
245
+ nocookie: this.options.nocookie,
246
+ origin: this.options.origin,
247
+ playlist: this.options.playlist,
248
+ progressBarColor: this.options.progressBarColor,
249
+ startAt: HTMLAttributes.start || 0,
250
+ rel: this.options.rel
251
+ });
252
+ HTMLAttributes.src = embedUrl;
253
+ return [
254
+ "div",
255
+ { "data-youtube-video": "" },
256
+ [
257
+ "iframe",
258
+ (0, import_core.mergeAttributes)(
259
+ this.options.HTMLAttributes,
260
+ {
261
+ width: this.options.width,
262
+ height: this.options.height,
263
+ allowfullscreen: this.options.allowFullscreen,
264
+ autoplay: this.options.autoplay,
265
+ ccLanguage: this.options.ccLanguage,
266
+ ccLoadPolicy: this.options.ccLoadPolicy,
267
+ disableKBcontrols: this.options.disableKBcontrols,
268
+ enableIFrameApi: this.options.enableIFrameApi,
269
+ endTime: this.options.endTime,
270
+ interfaceLanguage: this.options.interfaceLanguage,
271
+ ivLoadPolicy: this.options.ivLoadPolicy,
272
+ loop: this.options.loop,
273
+ modestBranding: this.options.modestBranding,
274
+ origin: this.options.origin,
275
+ playlist: this.options.playlist,
276
+ progressBarColor: this.options.progressBarColor,
277
+ rel: this.options.rel
278
+ },
279
+ HTMLAttributes
280
+ )
281
+ ]
282
+ ];
283
+ },
284
+ ...(0, import_core.createAtomBlockMarkdownSpec)({
285
+ nodeName: "youtube",
286
+ allowedAttributes: ["src", "width", "height", "start"]
287
+ })
288
+ });
289
+
290
+ // src/index.ts
291
+ var index_default = Youtube;
292
+ // Annotate the CommonJS export names for ESM import in node:
293
+ 0 && (module.exports = {
294
+ Youtube,
295
+ getEmbedUrlFromYoutubeUrl,
296
+ isValidYoutubeUrl
297
+ });
298
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/youtube.ts","../src/utils.ts"],"sourcesContent":["import { Youtube } from './youtube.js'\n\nexport * from './youtube.js'\n\nexport default Youtube\n","import { createAtomBlockMarkdownSpec, mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl, YOUTUBE_REGEX_GLOBAL } from './utils.js'\n\nexport type { GetEmbedUrlOptions } from './utils.js'\nexport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl } from './utils.js'\n\nexport interface YoutubeOptions {\n /**\n * Controls if the paste handler for youtube videos should be added.\n * @default true\n * @example false\n */\n addPasteHandler: boolean\n\n /**\n * Controls if the youtube video should be allowed to go fullscreen.\n * @default true\n * @example false\n */\n allowFullscreen: boolean\n\n /**\n * Controls if the youtube video should autoplay.\n * @default false\n * @example true\n */\n autoplay: boolean\n\n /**\n * The language of the captions shown in the youtube video.\n * @default undefined\n * @example 'en'\n */\n ccLanguage?: string\n\n /**\n * Controls if the captions should be shown in the youtube video.\n * @default undefined\n * @example true\n */\n ccLoadPolicy?: boolean\n\n /**\n * Controls if the controls should be shown in the youtube video.\n * @default true\n * @example false\n */\n controls: boolean\n\n /**\n * Controls if the keyboard controls should be disabled in the youtube video.\n * @default false\n * @example true\n */\n disableKBcontrols: boolean\n\n /**\n * Controls if the iframe api should be enabled in the youtube video.\n * @default false\n * @example true\n */\n enableIFrameApi: boolean\n\n /**\n * The end time of the youtube video.\n * @default 0\n * @example 120\n */\n endTime: number\n\n /**\n * The height of the youtube video.\n * @default 480\n * @example 720\n */\n height: number\n\n /**\n * The language of the youtube video.\n * @default undefined\n * @example 'en'\n */\n interfaceLanguage?: string\n\n /**\n * Controls if the video annotations should be shown in the youtube video.\n * @default 0\n * @example 1\n */\n ivLoadPolicy: number\n\n /**\n * Controls if the youtube video should loop.\n * @default false\n * @example true\n */\n loop: boolean\n\n /**\n * Controls if the youtube video should show a small youtube logo.\n * @default false\n * @example true\n */\n modestBranding: boolean\n\n /**\n * The HTML attributes for a youtube video node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Controls if the youtube node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean\n\n /**\n * Controls if the youtube video should be loaded from youtube-nocookie.com.\n * @default false\n * @example true\n */\n nocookie: boolean\n\n /**\n * The origin of the youtube video.\n * @default ''\n * @example 'https://tiptap.dev'\n */\n origin: string\n\n /**\n * The playlist of the youtube video.\n * @default ''\n * @example 'PLQg6GaokU5CwiVmsZ0dZm6VeIg0V5z1tK'\n */\n playlist: string\n\n /**\n * The color of the youtube video progress bar.\n * @default undefined\n * @example 'red'\n */\n progressBarColor?: string\n\n /**\n * The width of the youtube video.\n * @default 640\n * @example 1280\n */\n width: number\n\n /**\n * Controls if the related youtube videos at the end are from the same channel.\n * @default 1\n * @example 0\n */\n rel: number\n}\n\n/**\n * The options for setting a youtube video.\n */\ntype SetYoutubeVideoOptions = { src: string; width?: number; height?: number; start?: number }\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n youtube: {\n /**\n * Insert a youtube video\n * @param options The youtube video attributes\n * @example editor.commands.setYoutubeVideo({ src: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })\n */\n setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType\n }\n }\n}\n\n/**\n * This extension adds support for youtube videos.\n * @see https://www.tiptap.dev/api/nodes/youtube\n */\nexport const Youtube = Node.create<YoutubeOptions>({\n name: 'youtube',\n\n addOptions() {\n return {\n addPasteHandler: true,\n allowFullscreen: true,\n autoplay: false,\n ccLanguage: undefined,\n ccLoadPolicy: undefined,\n controls: true,\n disableKBcontrols: false,\n enableIFrameApi: false,\n endTime: 0,\n height: 480,\n interfaceLanguage: undefined,\n ivLoadPolicy: 0,\n loop: false,\n modestBranding: false,\n HTMLAttributes: {},\n inline: false,\n nocookie: false,\n origin: '',\n playlist: '',\n progressBarColor: undefined,\n width: 640,\n rel: 1,\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n start: {\n default: 0,\n },\n width: {\n default: this.options.width,\n },\n height: {\n default: this.options.height,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-youtube-video] iframe',\n },\n ]\n },\n\n addCommands() {\n return {\n setYoutubeVideo:\n (options: SetYoutubeVideoOptions) =>\n ({ commands }) => {\n if (!isValidYoutubeUrl(options.src)) {\n return false\n }\n\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addPasteRules() {\n if (!this.options.addPasteHandler) {\n return []\n }\n\n return [\n nodePasteRule({\n find: YOUTUBE_REGEX_GLOBAL,\n type: this.type,\n getAttributes: match => {\n return { src: match.input }\n },\n }),\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const embedUrl = getEmbedUrlFromYoutubeUrl({\n url: HTMLAttributes.src,\n allowFullscreen: this.options.allowFullscreen,\n autoplay: this.options.autoplay,\n ccLanguage: this.options.ccLanguage,\n ccLoadPolicy: this.options.ccLoadPolicy,\n controls: this.options.controls,\n disableKBcontrols: this.options.disableKBcontrols,\n enableIFrameApi: this.options.enableIFrameApi,\n endTime: this.options.endTime,\n interfaceLanguage: this.options.interfaceLanguage,\n ivLoadPolicy: this.options.ivLoadPolicy,\n loop: this.options.loop,\n modestBranding: this.options.modestBranding,\n nocookie: this.options.nocookie,\n origin: this.options.origin,\n playlist: this.options.playlist,\n progressBarColor: this.options.progressBarColor,\n startAt: HTMLAttributes.start || 0,\n rel: this.options.rel,\n })\n\n HTMLAttributes.src = embedUrl\n\n return [\n 'div',\n { 'data-youtube-video': '' },\n [\n 'iframe',\n mergeAttributes(\n this.options.HTMLAttributes,\n {\n width: this.options.width,\n height: this.options.height,\n allowfullscreen: this.options.allowFullscreen,\n autoplay: this.options.autoplay,\n ccLanguage: this.options.ccLanguage,\n ccLoadPolicy: this.options.ccLoadPolicy,\n disableKBcontrols: this.options.disableKBcontrols,\n enableIFrameApi: this.options.enableIFrameApi,\n endTime: this.options.endTime,\n interfaceLanguage: this.options.interfaceLanguage,\n ivLoadPolicy: this.options.ivLoadPolicy,\n loop: this.options.loop,\n modestBranding: this.options.modestBranding,\n origin: this.options.origin,\n playlist: this.options.playlist,\n progressBarColor: this.options.progressBarColor,\n rel: this.options.rel,\n },\n HTMLAttributes,\n ),\n ],\n ]\n },\n\n ...createAtomBlockMarkdownSpec({\n nodeName: 'youtube',\n allowedAttributes: ['src', 'width', 'height', 'start'],\n }),\n})\n","export const YOUTUBE_REGEX =\n /^((?:https?:)?\\/\\/)?((?:www|m|music)\\.)?((?:youtube\\.com|youtu\\.be|youtube-nocookie\\.com))(\\/(?:[\\w-]+\\?v=|embed\\/|v\\/)?)([\\w-]+)(\\S+)?$/\nexport const YOUTUBE_REGEX_GLOBAL =\n /^((?:https?:)?\\/\\/)?((?:www|m|music)\\.)?((?:youtube\\.com|youtu\\.be|youtube-nocookie\\.com))(\\/(?:[\\w-]+\\?v=|embed\\/|v\\/)?)([\\w-]+)(\\S+)?$/g\n\nexport const isValidYoutubeUrl = (url: string) => {\n return url.match(YOUTUBE_REGEX)\n}\n\nexport interface GetEmbedUrlOptions {\n url: string\n allowFullscreen?: boolean\n autoplay?: boolean\n ccLanguage?: string\n ccLoadPolicy?: boolean\n controls?: boolean\n disableKBcontrols?: boolean\n enableIFrameApi?: boolean\n endTime?: number\n interfaceLanguage?: string\n ivLoadPolicy?: number\n loop?: boolean\n modestBranding?: boolean\n nocookie?: boolean\n origin?: string\n playlist?: string\n progressBarColor?: string\n startAt?: number\n rel?: number\n}\n\nexport const getYoutubeEmbedUrl = (nocookie?: boolean, isPlaylist?: boolean) => {\n if (isPlaylist) {\n return 'https://www.youtube-nocookie.com/embed/videoseries?list='\n }\n return nocookie ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/'\n}\n\nexport const getEmbedUrlFromYoutubeUrl = (options: GetEmbedUrlOptions) => {\n const {\n url,\n allowFullscreen,\n autoplay,\n ccLanguage,\n ccLoadPolicy,\n controls,\n disableKBcontrols,\n enableIFrameApi,\n endTime,\n interfaceLanguage,\n ivLoadPolicy,\n loop,\n modestBranding,\n nocookie,\n origin,\n playlist,\n progressBarColor,\n startAt,\n rel,\n } = options\n\n if (!isValidYoutubeUrl(url)) {\n return null\n }\n\n // if is already an embed url, return it\n if (url.includes('/embed/')) {\n return url\n }\n\n // if is a youtu.be url, get the id after the /\n if (url.includes('youtu.be')) {\n const id = url.split('/').pop()\n\n if (!id) {\n return null\n }\n return `${getYoutubeEmbedUrl(nocookie)}${id}`\n }\n\n const videoIdRegex = /(?:(v|list)=|shorts\\/)([-\\w]+)/gm\n const matches = videoIdRegex.exec(url)\n\n if (!matches || !matches[2]) {\n return null\n }\n\n let outputUrl = `${getYoutubeEmbedUrl(nocookie, matches[1] === 'list')}${matches[2]}`\n\n const params = []\n\n if (allowFullscreen === false) {\n params.push('fs=0')\n }\n\n if (autoplay) {\n params.push('autoplay=1')\n }\n\n if (ccLanguage) {\n params.push(`cc_lang_pref=${ccLanguage}`)\n }\n\n if (ccLoadPolicy) {\n params.push('cc_load_policy=1')\n }\n\n if (!controls) {\n params.push('controls=0')\n }\n\n if (disableKBcontrols) {\n params.push('disablekb=1')\n }\n\n if (enableIFrameApi) {\n params.push('enablejsapi=1')\n }\n\n if (endTime) {\n params.push(`end=${endTime}`)\n }\n\n if (interfaceLanguage) {\n params.push(`hl=${interfaceLanguage}`)\n }\n\n if (ivLoadPolicy) {\n params.push(`iv_load_policy=${ivLoadPolicy}`)\n }\n\n if (loop) {\n params.push('loop=1')\n }\n\n if (modestBranding) {\n params.push('modestbranding=1')\n }\n\n if (origin) {\n params.push(`origin=${origin}`)\n }\n\n if (playlist) {\n params.push(`playlist=${playlist}`)\n }\n\n if (startAt) {\n params.push(`start=${startAt}`)\n }\n\n if (progressBarColor) {\n params.push(`color=${progressBarColor}`)\n }\n\n if (rel !== undefined) {\n params.push(`rel=${rel}`)\n }\n\n if (params.length) {\n outputUrl += `${matches[1] === 'list' ? '&' : '?'}${params.join('&')}`\n }\n\n return outputUrl\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAkF;;;ACA3E,IAAM,gBACX;AACK,IAAM,uBACX;AAEK,IAAM,oBAAoB,CAAC,QAAgB;AAChD,SAAO,IAAI,MAAM,aAAa;AAChC;AAwBO,IAAM,qBAAqB,CAAC,UAAoB,eAAyB;AAC9E,MAAI,YAAY;AACd,WAAO;AAAA,EACT;AACA,SAAO,WAAW,4CAA4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K,QAAQ;AAAA,YACvB,kBAAkB,KAAK,QAAQ;AAAA,YAC/B,KAAK,KAAK,QAAQ;AAAA,UACpB;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAG,yCAA4B;AAAA,IAC7B,UAAU;AAAA,IACV,mBAAmB,CAAC,OAAO,SAAS,UAAU,OAAO;AAAA,EACvD,CAAC;AACH,CAAC;;;ADpVD,IAAO,gBAAQ;","names":[]}
@@ -0,0 +1,188 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ declare const isValidYoutubeUrl: (url: string) => RegExpMatchArray | null;
4
+ interface GetEmbedUrlOptions {
5
+ url: string;
6
+ allowFullscreen?: boolean;
7
+ autoplay?: boolean;
8
+ ccLanguage?: string;
9
+ ccLoadPolicy?: boolean;
10
+ controls?: boolean;
11
+ disableKBcontrols?: boolean;
12
+ enableIFrameApi?: boolean;
13
+ endTime?: number;
14
+ interfaceLanguage?: string;
15
+ ivLoadPolicy?: number;
16
+ loop?: boolean;
17
+ modestBranding?: boolean;
18
+ nocookie?: boolean;
19
+ origin?: string;
20
+ playlist?: string;
21
+ progressBarColor?: string;
22
+ startAt?: number;
23
+ rel?: number;
24
+ }
25
+ declare const getEmbedUrlFromYoutubeUrl: (options: GetEmbedUrlOptions) => string | null;
26
+
27
+ interface YoutubeOptions {
28
+ /**
29
+ * Controls if the paste handler for youtube videos should be added.
30
+ * @default true
31
+ * @example false
32
+ */
33
+ addPasteHandler: boolean;
34
+ /**
35
+ * Controls if the youtube video should be allowed to go fullscreen.
36
+ * @default true
37
+ * @example false
38
+ */
39
+ allowFullscreen: boolean;
40
+ /**
41
+ * Controls if the youtube video should autoplay.
42
+ * @default false
43
+ * @example true
44
+ */
45
+ autoplay: boolean;
46
+ /**
47
+ * The language of the captions shown in the youtube video.
48
+ * @default undefined
49
+ * @example 'en'
50
+ */
51
+ ccLanguage?: string;
52
+ /**
53
+ * Controls if the captions should be shown in the youtube video.
54
+ * @default undefined
55
+ * @example true
56
+ */
57
+ ccLoadPolicy?: boolean;
58
+ /**
59
+ * Controls if the controls should be shown in the youtube video.
60
+ * @default true
61
+ * @example false
62
+ */
63
+ controls: boolean;
64
+ /**
65
+ * Controls if the keyboard controls should be disabled in the youtube video.
66
+ * @default false
67
+ * @example true
68
+ */
69
+ disableKBcontrols: boolean;
70
+ /**
71
+ * Controls if the iframe api should be enabled in the youtube video.
72
+ * @default false
73
+ * @example true
74
+ */
75
+ enableIFrameApi: boolean;
76
+ /**
77
+ * The end time of the youtube video.
78
+ * @default 0
79
+ * @example 120
80
+ */
81
+ endTime: number;
82
+ /**
83
+ * The height of the youtube video.
84
+ * @default 480
85
+ * @example 720
86
+ */
87
+ height: number;
88
+ /**
89
+ * The language of the youtube video.
90
+ * @default undefined
91
+ * @example 'en'
92
+ */
93
+ interfaceLanguage?: string;
94
+ /**
95
+ * Controls if the video annotations should be shown in the youtube video.
96
+ * @default 0
97
+ * @example 1
98
+ */
99
+ ivLoadPolicy: number;
100
+ /**
101
+ * Controls if the youtube video should loop.
102
+ * @default false
103
+ * @example true
104
+ */
105
+ loop: boolean;
106
+ /**
107
+ * Controls if the youtube video should show a small youtube logo.
108
+ * @default false
109
+ * @example true
110
+ */
111
+ modestBranding: boolean;
112
+ /**
113
+ * The HTML attributes for a youtube video node.
114
+ * @default {}
115
+ * @example { class: 'foo' }
116
+ */
117
+ HTMLAttributes: Record<string, any>;
118
+ /**
119
+ * Controls if the youtube node should be inline or not.
120
+ * @default false
121
+ * @example true
122
+ */
123
+ inline: boolean;
124
+ /**
125
+ * Controls if the youtube video should be loaded from youtube-nocookie.com.
126
+ * @default false
127
+ * @example true
128
+ */
129
+ nocookie: boolean;
130
+ /**
131
+ * The origin of the youtube video.
132
+ * @default ''
133
+ * @example 'https://tiptap.dev'
134
+ */
135
+ origin: string;
136
+ /**
137
+ * The playlist of the youtube video.
138
+ * @default ''
139
+ * @example 'PLQg6GaokU5CwiVmsZ0dZm6VeIg0V5z1tK'
140
+ */
141
+ playlist: string;
142
+ /**
143
+ * The color of the youtube video progress bar.
144
+ * @default undefined
145
+ * @example 'red'
146
+ */
147
+ progressBarColor?: string;
148
+ /**
149
+ * The width of the youtube video.
150
+ * @default 640
151
+ * @example 1280
152
+ */
153
+ width: number;
154
+ /**
155
+ * Controls if the related youtube videos at the end are from the same channel.
156
+ * @default 1
157
+ * @example 0
158
+ */
159
+ rel: number;
160
+ }
161
+ /**
162
+ * The options for setting a youtube video.
163
+ */
164
+ type SetYoutubeVideoOptions = {
165
+ src: string;
166
+ width?: number;
167
+ height?: number;
168
+ start?: number;
169
+ };
170
+ declare module '@tiptap/core' {
171
+ interface Commands<ReturnType> {
172
+ youtube: {
173
+ /**
174
+ * Insert a youtube video
175
+ * @param options The youtube video attributes
176
+ * @example editor.commands.setYoutubeVideo({ src: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
177
+ */
178
+ setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType;
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * This extension adds support for youtube videos.
184
+ * @see https://www.tiptap.dev/api/nodes/youtube
185
+ */
186
+ declare const Youtube: Node<YoutubeOptions, any>;
187
+
188
+ export { type GetEmbedUrlOptions, Youtube, type YoutubeOptions, Youtube as default, getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl };
@@ -0,0 +1,188 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ declare const isValidYoutubeUrl: (url: string) => RegExpMatchArray | null;
4
+ interface GetEmbedUrlOptions {
5
+ url: string;
6
+ allowFullscreen?: boolean;
7
+ autoplay?: boolean;
8
+ ccLanguage?: string;
9
+ ccLoadPolicy?: boolean;
10
+ controls?: boolean;
11
+ disableKBcontrols?: boolean;
12
+ enableIFrameApi?: boolean;
13
+ endTime?: number;
14
+ interfaceLanguage?: string;
15
+ ivLoadPolicy?: number;
16
+ loop?: boolean;
17
+ modestBranding?: boolean;
18
+ nocookie?: boolean;
19
+ origin?: string;
20
+ playlist?: string;
21
+ progressBarColor?: string;
22
+ startAt?: number;
23
+ rel?: number;
24
+ }
25
+ declare const getEmbedUrlFromYoutubeUrl: (options: GetEmbedUrlOptions) => string | null;
26
+
27
+ interface YoutubeOptions {
28
+ /**
29
+ * Controls if the paste handler for youtube videos should be added.
30
+ * @default true
31
+ * @example false
32
+ */
33
+ addPasteHandler: boolean;
34
+ /**
35
+ * Controls if the youtube video should be allowed to go fullscreen.
36
+ * @default true
37
+ * @example false
38
+ */
39
+ allowFullscreen: boolean;
40
+ /**
41
+ * Controls if the youtube video should autoplay.
42
+ * @default false
43
+ * @example true
44
+ */
45
+ autoplay: boolean;
46
+ /**
47
+ * The language of the captions shown in the youtube video.
48
+ * @default undefined
49
+ * @example 'en'
50
+ */
51
+ ccLanguage?: string;
52
+ /**
53
+ * Controls if the captions should be shown in the youtube video.
54
+ * @default undefined
55
+ * @example true
56
+ */
57
+ ccLoadPolicy?: boolean;
58
+ /**
59
+ * Controls if the controls should be shown in the youtube video.
60
+ * @default true
61
+ * @example false
62
+ */
63
+ controls: boolean;
64
+ /**
65
+ * Controls if the keyboard controls should be disabled in the youtube video.
66
+ * @default false
67
+ * @example true
68
+ */
69
+ disableKBcontrols: boolean;
70
+ /**
71
+ * Controls if the iframe api should be enabled in the youtube video.
72
+ * @default false
73
+ * @example true
74
+ */
75
+ enableIFrameApi: boolean;
76
+ /**
77
+ * The end time of the youtube video.
78
+ * @default 0
79
+ * @example 120
80
+ */
81
+ endTime: number;
82
+ /**
83
+ * The height of the youtube video.
84
+ * @default 480
85
+ * @example 720
86
+ */
87
+ height: number;
88
+ /**
89
+ * The language of the youtube video.
90
+ * @default undefined
91
+ * @example 'en'
92
+ */
93
+ interfaceLanguage?: string;
94
+ /**
95
+ * Controls if the video annotations should be shown in the youtube video.
96
+ * @default 0
97
+ * @example 1
98
+ */
99
+ ivLoadPolicy: number;
100
+ /**
101
+ * Controls if the youtube video should loop.
102
+ * @default false
103
+ * @example true
104
+ */
105
+ loop: boolean;
106
+ /**
107
+ * Controls if the youtube video should show a small youtube logo.
108
+ * @default false
109
+ * @example true
110
+ */
111
+ modestBranding: boolean;
112
+ /**
113
+ * The HTML attributes for a youtube video node.
114
+ * @default {}
115
+ * @example { class: 'foo' }
116
+ */
117
+ HTMLAttributes: Record<string, any>;
118
+ /**
119
+ * Controls if the youtube node should be inline or not.
120
+ * @default false
121
+ * @example true
122
+ */
123
+ inline: boolean;
124
+ /**
125
+ * Controls if the youtube video should be loaded from youtube-nocookie.com.
126
+ * @default false
127
+ * @example true
128
+ */
129
+ nocookie: boolean;
130
+ /**
131
+ * The origin of the youtube video.
132
+ * @default ''
133
+ * @example 'https://tiptap.dev'
134
+ */
135
+ origin: string;
136
+ /**
137
+ * The playlist of the youtube video.
138
+ * @default ''
139
+ * @example 'PLQg6GaokU5CwiVmsZ0dZm6VeIg0V5z1tK'
140
+ */
141
+ playlist: string;
142
+ /**
143
+ * The color of the youtube video progress bar.
144
+ * @default undefined
145
+ * @example 'red'
146
+ */
147
+ progressBarColor?: string;
148
+ /**
149
+ * The width of the youtube video.
150
+ * @default 640
151
+ * @example 1280
152
+ */
153
+ width: number;
154
+ /**
155
+ * Controls if the related youtube videos at the end are from the same channel.
156
+ * @default 1
157
+ * @example 0
158
+ */
159
+ rel: number;
160
+ }
161
+ /**
162
+ * The options for setting a youtube video.
163
+ */
164
+ type SetYoutubeVideoOptions = {
165
+ src: string;
166
+ width?: number;
167
+ height?: number;
168
+ start?: number;
169
+ };
170
+ declare module '@tiptap/core' {
171
+ interface Commands<ReturnType> {
172
+ youtube: {
173
+ /**
174
+ * Insert a youtube video
175
+ * @param options The youtube video attributes
176
+ * @example editor.commands.setYoutubeVideo({ src: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
177
+ */
178
+ setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType;
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * This extension adds support for youtube videos.
184
+ * @see https://www.tiptap.dev/api/nodes/youtube
185
+ */
186
+ declare const Youtube: Node<YoutubeOptions, any>;
187
+
188
+ export { type GetEmbedUrlOptions, Youtube, type YoutubeOptions, Youtube as default, getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl };
package/dist/index.js ADDED
@@ -0,0 +1,269 @@
1
+ // src/youtube.ts
2
+ import { createAtomBlockMarkdownSpec, mergeAttributes, Node, nodePasteRule } from "@tiptap/core";
3
+
4
+ // src/utils.ts
5
+ var YOUTUBE_REGEX = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/;
6
+ var YOUTUBE_REGEX_GLOBAL = /^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g;
7
+ var isValidYoutubeUrl = (url) => {
8
+ return url.match(YOUTUBE_REGEX);
9
+ };
10
+ var getYoutubeEmbedUrl = (nocookie, isPlaylist) => {
11
+ if (isPlaylist) {
12
+ return "https://www.youtube-nocookie.com/embed/videoseries?list=";
13
+ }
14
+ return nocookie ? "https://www.youtube-nocookie.com/embed/" : "https://www.youtube.com/embed/";
15
+ };
16
+ var getEmbedUrlFromYoutubeUrl = (options) => {
17
+ const {
18
+ url,
19
+ allowFullscreen,
20
+ autoplay,
21
+ ccLanguage,
22
+ ccLoadPolicy,
23
+ controls,
24
+ disableKBcontrols,
25
+ enableIFrameApi,
26
+ endTime,
27
+ interfaceLanguage,
28
+ ivLoadPolicy,
29
+ loop,
30
+ modestBranding,
31
+ nocookie,
32
+ origin,
33
+ playlist,
34
+ progressBarColor,
35
+ startAt,
36
+ rel
37
+ } = options;
38
+ if (!isValidYoutubeUrl(url)) {
39
+ return null;
40
+ }
41
+ if (url.includes("/embed/")) {
42
+ return url;
43
+ }
44
+ if (url.includes("youtu.be")) {
45
+ const id = url.split("/").pop();
46
+ if (!id) {
47
+ return null;
48
+ }
49
+ return `${getYoutubeEmbedUrl(nocookie)}${id}`;
50
+ }
51
+ const videoIdRegex = /(?:(v|list)=|shorts\/)([-\w]+)/gm;
52
+ const matches = videoIdRegex.exec(url);
53
+ if (!matches || !matches[2]) {
54
+ return null;
55
+ }
56
+ let outputUrl = `${getYoutubeEmbedUrl(nocookie, matches[1] === "list")}${matches[2]}`;
57
+ const params = [];
58
+ if (allowFullscreen === false) {
59
+ params.push("fs=0");
60
+ }
61
+ if (autoplay) {
62
+ params.push("autoplay=1");
63
+ }
64
+ if (ccLanguage) {
65
+ params.push(`cc_lang_pref=${ccLanguage}`);
66
+ }
67
+ if (ccLoadPolicy) {
68
+ params.push("cc_load_policy=1");
69
+ }
70
+ if (!controls) {
71
+ params.push("controls=0");
72
+ }
73
+ if (disableKBcontrols) {
74
+ params.push("disablekb=1");
75
+ }
76
+ if (enableIFrameApi) {
77
+ params.push("enablejsapi=1");
78
+ }
79
+ if (endTime) {
80
+ params.push(`end=${endTime}`);
81
+ }
82
+ if (interfaceLanguage) {
83
+ params.push(`hl=${interfaceLanguage}`);
84
+ }
85
+ if (ivLoadPolicy) {
86
+ params.push(`iv_load_policy=${ivLoadPolicy}`);
87
+ }
88
+ if (loop) {
89
+ params.push("loop=1");
90
+ }
91
+ if (modestBranding) {
92
+ params.push("modestbranding=1");
93
+ }
94
+ if (origin) {
95
+ params.push(`origin=${origin}`);
96
+ }
97
+ if (playlist) {
98
+ params.push(`playlist=${playlist}`);
99
+ }
100
+ if (startAt) {
101
+ params.push(`start=${startAt}`);
102
+ }
103
+ if (progressBarColor) {
104
+ params.push(`color=${progressBarColor}`);
105
+ }
106
+ if (rel !== void 0) {
107
+ params.push(`rel=${rel}`);
108
+ }
109
+ if (params.length) {
110
+ outputUrl += `${matches[1] === "list" ? "&" : "?"}${params.join("&")}`;
111
+ }
112
+ return outputUrl;
113
+ };
114
+
115
+ // src/youtube.ts
116
+ var Youtube = Node.create({
117
+ name: "youtube",
118
+ addOptions() {
119
+ return {
120
+ addPasteHandler: true,
121
+ allowFullscreen: true,
122
+ autoplay: false,
123
+ ccLanguage: void 0,
124
+ ccLoadPolicy: void 0,
125
+ controls: true,
126
+ disableKBcontrols: false,
127
+ enableIFrameApi: false,
128
+ endTime: 0,
129
+ height: 480,
130
+ interfaceLanguage: void 0,
131
+ ivLoadPolicy: 0,
132
+ loop: false,
133
+ modestBranding: false,
134
+ HTMLAttributes: {},
135
+ inline: false,
136
+ nocookie: false,
137
+ origin: "",
138
+ playlist: "",
139
+ progressBarColor: void 0,
140
+ width: 640,
141
+ rel: 1
142
+ };
143
+ },
144
+ inline() {
145
+ return this.options.inline;
146
+ },
147
+ group() {
148
+ return this.options.inline ? "inline" : "block";
149
+ },
150
+ draggable: true,
151
+ addAttributes() {
152
+ return {
153
+ src: {
154
+ default: null
155
+ },
156
+ start: {
157
+ default: 0
158
+ },
159
+ width: {
160
+ default: this.options.width
161
+ },
162
+ height: {
163
+ default: this.options.height
164
+ }
165
+ };
166
+ },
167
+ parseHTML() {
168
+ return [
169
+ {
170
+ tag: "div[data-youtube-video] iframe"
171
+ }
172
+ ];
173
+ },
174
+ addCommands() {
175
+ return {
176
+ setYoutubeVideo: (options) => ({ commands }) => {
177
+ if (!isValidYoutubeUrl(options.src)) {
178
+ return false;
179
+ }
180
+ return commands.insertContent({
181
+ type: this.name,
182
+ attrs: options
183
+ });
184
+ }
185
+ };
186
+ },
187
+ addPasteRules() {
188
+ if (!this.options.addPasteHandler) {
189
+ return [];
190
+ }
191
+ return [
192
+ nodePasteRule({
193
+ find: YOUTUBE_REGEX_GLOBAL,
194
+ type: this.type,
195
+ getAttributes: (match) => {
196
+ return { src: match.input };
197
+ }
198
+ })
199
+ ];
200
+ },
201
+ renderHTML({ HTMLAttributes }) {
202
+ const embedUrl = getEmbedUrlFromYoutubeUrl({
203
+ url: HTMLAttributes.src,
204
+ allowFullscreen: this.options.allowFullscreen,
205
+ autoplay: this.options.autoplay,
206
+ ccLanguage: this.options.ccLanguage,
207
+ ccLoadPolicy: this.options.ccLoadPolicy,
208
+ controls: this.options.controls,
209
+ disableKBcontrols: this.options.disableKBcontrols,
210
+ enableIFrameApi: this.options.enableIFrameApi,
211
+ endTime: this.options.endTime,
212
+ interfaceLanguage: this.options.interfaceLanguage,
213
+ ivLoadPolicy: this.options.ivLoadPolicy,
214
+ loop: this.options.loop,
215
+ modestBranding: this.options.modestBranding,
216
+ nocookie: this.options.nocookie,
217
+ origin: this.options.origin,
218
+ playlist: this.options.playlist,
219
+ progressBarColor: this.options.progressBarColor,
220
+ startAt: HTMLAttributes.start || 0,
221
+ rel: this.options.rel
222
+ });
223
+ HTMLAttributes.src = embedUrl;
224
+ return [
225
+ "div",
226
+ { "data-youtube-video": "" },
227
+ [
228
+ "iframe",
229
+ mergeAttributes(
230
+ this.options.HTMLAttributes,
231
+ {
232
+ width: this.options.width,
233
+ height: this.options.height,
234
+ allowfullscreen: this.options.allowFullscreen,
235
+ autoplay: this.options.autoplay,
236
+ ccLanguage: this.options.ccLanguage,
237
+ ccLoadPolicy: this.options.ccLoadPolicy,
238
+ disableKBcontrols: this.options.disableKBcontrols,
239
+ enableIFrameApi: this.options.enableIFrameApi,
240
+ endTime: this.options.endTime,
241
+ interfaceLanguage: this.options.interfaceLanguage,
242
+ ivLoadPolicy: this.options.ivLoadPolicy,
243
+ loop: this.options.loop,
244
+ modestBranding: this.options.modestBranding,
245
+ origin: this.options.origin,
246
+ playlist: this.options.playlist,
247
+ progressBarColor: this.options.progressBarColor,
248
+ rel: this.options.rel
249
+ },
250
+ HTMLAttributes
251
+ )
252
+ ]
253
+ ];
254
+ },
255
+ ...createAtomBlockMarkdownSpec({
256
+ nodeName: "youtube",
257
+ allowedAttributes: ["src", "width", "height", "start"]
258
+ })
259
+ });
260
+
261
+ // src/index.ts
262
+ var index_default = Youtube;
263
+ export {
264
+ Youtube,
265
+ index_default as default,
266
+ getEmbedUrlFromYoutubeUrl,
267
+ isValidYoutubeUrl
268
+ };
269
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/youtube.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["import { createAtomBlockMarkdownSpec, mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl, YOUTUBE_REGEX_GLOBAL } from './utils.js'\n\nexport type { GetEmbedUrlOptions } from './utils.js'\nexport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl } from './utils.js'\n\nexport interface YoutubeOptions {\n /**\n * Controls if the paste handler for youtube videos should be added.\n * @default true\n * @example false\n */\n addPasteHandler: boolean\n\n /**\n * Controls if the youtube video should be allowed to go fullscreen.\n * @default true\n * @example false\n */\n allowFullscreen: boolean\n\n /**\n * Controls if the youtube video should autoplay.\n * @default false\n * @example true\n */\n autoplay: boolean\n\n /**\n * The language of the captions shown in the youtube video.\n * @default undefined\n * @example 'en'\n */\n ccLanguage?: string\n\n /**\n * Controls if the captions should be shown in the youtube video.\n * @default undefined\n * @example true\n */\n ccLoadPolicy?: boolean\n\n /**\n * Controls if the controls should be shown in the youtube video.\n * @default true\n * @example false\n */\n controls: boolean\n\n /**\n * Controls if the keyboard controls should be disabled in the youtube video.\n * @default false\n * @example true\n */\n disableKBcontrols: boolean\n\n /**\n * Controls if the iframe api should be enabled in the youtube video.\n * @default false\n * @example true\n */\n enableIFrameApi: boolean\n\n /**\n * The end time of the youtube video.\n * @default 0\n * @example 120\n */\n endTime: number\n\n /**\n * The height of the youtube video.\n * @default 480\n * @example 720\n */\n height: number\n\n /**\n * The language of the youtube video.\n * @default undefined\n * @example 'en'\n */\n interfaceLanguage?: string\n\n /**\n * Controls if the video annotations should be shown in the youtube video.\n * @default 0\n * @example 1\n */\n ivLoadPolicy: number\n\n /**\n * Controls if the youtube video should loop.\n * @default false\n * @example true\n */\n loop: boolean\n\n /**\n * Controls if the youtube video should show a small youtube logo.\n * @default false\n * @example true\n */\n modestBranding: boolean\n\n /**\n * The HTML attributes for a youtube video node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Controls if the youtube node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean\n\n /**\n * Controls if the youtube video should be loaded from youtube-nocookie.com.\n * @default false\n * @example true\n */\n nocookie: boolean\n\n /**\n * The origin of the youtube video.\n * @default ''\n * @example 'https://tiptap.dev'\n */\n origin: string\n\n /**\n * The playlist of the youtube video.\n * @default ''\n * @example 'PLQg6GaokU5CwiVmsZ0dZm6VeIg0V5z1tK'\n */\n playlist: string\n\n /**\n * The color of the youtube video progress bar.\n * @default undefined\n * @example 'red'\n */\n progressBarColor?: string\n\n /**\n * The width of the youtube video.\n * @default 640\n * @example 1280\n */\n width: number\n\n /**\n * Controls if the related youtube videos at the end are from the same channel.\n * @default 1\n * @example 0\n */\n rel: number\n}\n\n/**\n * The options for setting a youtube video.\n */\ntype SetYoutubeVideoOptions = { src: string; width?: number; height?: number; start?: number }\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n youtube: {\n /**\n * Insert a youtube video\n * @param options The youtube video attributes\n * @example editor.commands.setYoutubeVideo({ src: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })\n */\n setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType\n }\n }\n}\n\n/**\n * This extension adds support for youtube videos.\n * @see https://www.tiptap.dev/api/nodes/youtube\n */\nexport const Youtube = Node.create<YoutubeOptions>({\n name: 'youtube',\n\n addOptions() {\n return {\n addPasteHandler: true,\n allowFullscreen: true,\n autoplay: false,\n ccLanguage: undefined,\n ccLoadPolicy: undefined,\n controls: true,\n disableKBcontrols: false,\n enableIFrameApi: false,\n endTime: 0,\n height: 480,\n interfaceLanguage: undefined,\n ivLoadPolicy: 0,\n loop: false,\n modestBranding: false,\n HTMLAttributes: {},\n inline: false,\n nocookie: false,\n origin: '',\n playlist: '',\n progressBarColor: undefined,\n width: 640,\n rel: 1,\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n start: {\n default: 0,\n },\n width: {\n default: this.options.width,\n },\n height: {\n default: this.options.height,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-youtube-video] iframe',\n },\n ]\n },\n\n addCommands() {\n return {\n setYoutubeVideo:\n (options: SetYoutubeVideoOptions) =>\n ({ commands }) => {\n if (!isValidYoutubeUrl(options.src)) {\n return false\n }\n\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addPasteRules() {\n if (!this.options.addPasteHandler) {\n return []\n }\n\n return [\n nodePasteRule({\n find: YOUTUBE_REGEX_GLOBAL,\n type: this.type,\n getAttributes: match => {\n return { src: match.input }\n },\n }),\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const embedUrl = getEmbedUrlFromYoutubeUrl({\n url: HTMLAttributes.src,\n allowFullscreen: this.options.allowFullscreen,\n autoplay: this.options.autoplay,\n ccLanguage: this.options.ccLanguage,\n ccLoadPolicy: this.options.ccLoadPolicy,\n controls: this.options.controls,\n disableKBcontrols: this.options.disableKBcontrols,\n enableIFrameApi: this.options.enableIFrameApi,\n endTime: this.options.endTime,\n interfaceLanguage: this.options.interfaceLanguage,\n ivLoadPolicy: this.options.ivLoadPolicy,\n loop: this.options.loop,\n modestBranding: this.options.modestBranding,\n nocookie: this.options.nocookie,\n origin: this.options.origin,\n playlist: this.options.playlist,\n progressBarColor: this.options.progressBarColor,\n startAt: HTMLAttributes.start || 0,\n rel: this.options.rel,\n })\n\n HTMLAttributes.src = embedUrl\n\n return [\n 'div',\n { 'data-youtube-video': '' },\n [\n 'iframe',\n mergeAttributes(\n this.options.HTMLAttributes,\n {\n width: this.options.width,\n height: this.options.height,\n allowfullscreen: this.options.allowFullscreen,\n autoplay: this.options.autoplay,\n ccLanguage: this.options.ccLanguage,\n ccLoadPolicy: this.options.ccLoadPolicy,\n disableKBcontrols: this.options.disableKBcontrols,\n enableIFrameApi: this.options.enableIFrameApi,\n endTime: this.options.endTime,\n interfaceLanguage: this.options.interfaceLanguage,\n ivLoadPolicy: this.options.ivLoadPolicy,\n loop: this.options.loop,\n modestBranding: this.options.modestBranding,\n origin: this.options.origin,\n playlist: this.options.playlist,\n progressBarColor: this.options.progressBarColor,\n rel: this.options.rel,\n },\n HTMLAttributes,\n ),\n ],\n ]\n },\n\n ...createAtomBlockMarkdownSpec({\n nodeName: 'youtube',\n allowedAttributes: ['src', 'width', 'height', 'start'],\n }),\n})\n","export const YOUTUBE_REGEX =\n /^((?:https?:)?\\/\\/)?((?:www|m|music)\\.)?((?:youtube\\.com|youtu\\.be|youtube-nocookie\\.com))(\\/(?:[\\w-]+\\?v=|embed\\/|v\\/)?)([\\w-]+)(\\S+)?$/\nexport const YOUTUBE_REGEX_GLOBAL =\n /^((?:https?:)?\\/\\/)?((?:www|m|music)\\.)?((?:youtube\\.com|youtu\\.be|youtube-nocookie\\.com))(\\/(?:[\\w-]+\\?v=|embed\\/|v\\/)?)([\\w-]+)(\\S+)?$/g\n\nexport const isValidYoutubeUrl = (url: string) => {\n return url.match(YOUTUBE_REGEX)\n}\n\nexport interface GetEmbedUrlOptions {\n url: string\n allowFullscreen?: boolean\n autoplay?: boolean\n ccLanguage?: string\n ccLoadPolicy?: boolean\n controls?: boolean\n disableKBcontrols?: boolean\n enableIFrameApi?: boolean\n endTime?: number\n interfaceLanguage?: string\n ivLoadPolicy?: number\n loop?: boolean\n modestBranding?: boolean\n nocookie?: boolean\n origin?: string\n playlist?: string\n progressBarColor?: string\n startAt?: number\n rel?: number\n}\n\nexport const getYoutubeEmbedUrl = (nocookie?: boolean, isPlaylist?: boolean) => {\n if (isPlaylist) {\n return 'https://www.youtube-nocookie.com/embed/videoseries?list='\n }\n return nocookie ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/'\n}\n\nexport const getEmbedUrlFromYoutubeUrl = (options: GetEmbedUrlOptions) => {\n const {\n url,\n allowFullscreen,\n autoplay,\n ccLanguage,\n ccLoadPolicy,\n controls,\n disableKBcontrols,\n enableIFrameApi,\n endTime,\n interfaceLanguage,\n ivLoadPolicy,\n loop,\n modestBranding,\n nocookie,\n origin,\n playlist,\n progressBarColor,\n startAt,\n rel,\n } = options\n\n if (!isValidYoutubeUrl(url)) {\n return null\n }\n\n // if is already an embed url, return it\n if (url.includes('/embed/')) {\n return url\n }\n\n // if is a youtu.be url, get the id after the /\n if (url.includes('youtu.be')) {\n const id = url.split('/').pop()\n\n if (!id) {\n return null\n }\n return `${getYoutubeEmbedUrl(nocookie)}${id}`\n }\n\n const videoIdRegex = /(?:(v|list)=|shorts\\/)([-\\w]+)/gm\n const matches = videoIdRegex.exec(url)\n\n if (!matches || !matches[2]) {\n return null\n }\n\n let outputUrl = `${getYoutubeEmbedUrl(nocookie, matches[1] === 'list')}${matches[2]}`\n\n const params = []\n\n if (allowFullscreen === false) {\n params.push('fs=0')\n }\n\n if (autoplay) {\n params.push('autoplay=1')\n }\n\n if (ccLanguage) {\n params.push(`cc_lang_pref=${ccLanguage}`)\n }\n\n if (ccLoadPolicy) {\n params.push('cc_load_policy=1')\n }\n\n if (!controls) {\n params.push('controls=0')\n }\n\n if (disableKBcontrols) {\n params.push('disablekb=1')\n }\n\n if (enableIFrameApi) {\n params.push('enablejsapi=1')\n }\n\n if (endTime) {\n params.push(`end=${endTime}`)\n }\n\n if (interfaceLanguage) {\n params.push(`hl=${interfaceLanguage}`)\n }\n\n if (ivLoadPolicy) {\n params.push(`iv_load_policy=${ivLoadPolicy}`)\n }\n\n if (loop) {\n params.push('loop=1')\n }\n\n if (modestBranding) {\n params.push('modestbranding=1')\n }\n\n if (origin) {\n params.push(`origin=${origin}`)\n }\n\n if (playlist) {\n params.push(`playlist=${playlist}`)\n }\n\n if (startAt) {\n params.push(`start=${startAt}`)\n }\n\n if (progressBarColor) {\n params.push(`color=${progressBarColor}`)\n }\n\n if (rel !== undefined) {\n params.push(`rel=${rel}`)\n }\n\n if (params.length) {\n outputUrl += `${matches[1] === 'list' ? '&' : '?'}${params.join('&')}`\n }\n\n return outputUrl\n}\n","import { Youtube } from './youtube.js'\n\nexport * from './youtube.js'\n\nexport default Youtube\n"],"mappings":";AAAA,SAAS,6BAA6B,iBAAiB,MAAM,qBAAqB;;;ACA3E,IAAM,gBACX;AACK,IAAM,uBACX;AAEK,IAAM,oBAAoB,CAAC,QAAgB;AAChD,SAAO,IAAI,MAAM,aAAa;AAChC;AAwBO,IAAM,qBAAqB,CAAC,UAAoB,eAAyB;AAC9E,MAAI,YAAY;AACd,WAAO;AAAA,EACT;AACA,SAAO,WAAW,4CAA4C;AAChE;AAEO,IAAM,4BAA4B,CAAC,YAAgC;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,CAAC,kBAAkB,GAAG,GAAG;AAC3B,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,GAAG;AAC3B,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,UAAU,GAAG;AAC5B,UAAM,KAAK,IAAI,MAAM,GAAG,EAAE,IAAI;AAE9B,QAAI,CAAC,IAAI;AACP,aAAO;AAAA,IACT;AACA,WAAO,GAAG,mBAAmB,QAAQ,CAAC,GAAG,EAAE;AAAA,EAC7C;AAEA,QAAM,eAAe;AACrB,QAAM,UAAU,aAAa,KAAK,GAAG;AAErC,MAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,GAAG,mBAAmB,UAAU,QAA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KAAK,QAAQ;AAAA,YACpB,QAAQ,KAAK,QAAQ;AAAA,YACrB,iBAAiB,KAAK,QAAQ;AAAA,YAC9B,UAAU,KAAK,QAAQ;AAAA,YACvB,YAAY,KAAK,QAAQ;AAAA,YACzB,cAAc,KAAK,QAAQ;AAAA,YAC3B,mBAAmB,KAAK,QAAQ;AAAA,YAChC,iBAAiB,KAAK,QAAQ;AAAA,YAC9B,SAAS,KAAK,QAAQ;AAAA,YACtB,mBAAmB,KAAK,QAAQ;AAAA,YAChC,cAAc,KAAK,QAAQ;AAAA,YAC3B,MAAM,KAAK,QAAQ;AAAA,YACnB,gBAAgB,KAAK,QAAQ;AAAA,YAC7B,QAAQ,KAAK,QAAQ;AAAA,YACrB,UAAU,KAAK,QAAQ;AAAA,YACvB,kBAAkB,KAAK,QAAQ;AAAA,YAC/B,KAAK,KAAK,QAAQ;AAAA,UACpB;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,GAAG,4BAA4B;AAAA,IAC7B,UAAU;AAAA,IACV,mBAAmB,CAAC,OAAO,SAAS,UAAU,OAAO;AAAA,EACvD,CAAC;AACH,CAAC;;;AEpVD,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-youtube",
3
3
  "description": "a youtube embed extension for tiptap",
4
- "version": "3.20.3",
4
+ "version": "3.20.5",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -31,10 +31,10 @@
31
31
  "dist"
32
32
  ],
33
33
  "devDependencies": {
34
- "@tiptap/core": "^3.20.3"
34
+ "@tiptap/core": "^3.20.5"
35
35
  },
36
36
  "peerDependencies": {
37
- "@tiptap/core": "^3.20.3"
37
+ "@tiptap/core": "^3.20.5"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",