@tiptap/extension-youtube 2.0.0-beta.6 → 2.0.0-rc.2

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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  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*.
9
9
 
10
10
  ## Official Documentation
11
- Documentation can be found on the [tiptap website](https://tiptap.dev).
11
+ Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
12
 
13
13
  ## License
14
14
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs ADDED
@@ -0,0 +1,226 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@tiptap/core');
6
+
7
+ const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/;
8
+ const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/g;
9
+ const isValidYoutubeUrl = (url) => {
10
+ return url.match(YOUTUBE_REGEX);
11
+ };
12
+ const getYoutubeEmbedUrl = (nocookie) => {
13
+ return nocookie ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/';
14
+ };
15
+ const getEmbedUrlFromYoutubeUrl = (options) => {
16
+ const { url, allowFullscreen, autoplay, ccLanguage, ccLoadPolicy, controls, disableKBcontrols, enableIFrameApi, endTime, interfaceLanguage, ivLoadPolicy, loop, modestBranding, nocookie, origin, playlist, progressBarColor, startAt, } = options;
17
+ // if is already an embed url, return it
18
+ if (url.includes('/embed/')) {
19
+ return url;
20
+ }
21
+ // if is a youtu.be url, get the id after the /
22
+ if (url.includes('youtu.be')) {
23
+ const id = url.split('/').pop();
24
+ if (!id) {
25
+ return null;
26
+ }
27
+ return `${getYoutubeEmbedUrl(nocookie)}${id}`;
28
+ }
29
+ const videoIdRegex = /v=([-\w]+)/gm;
30
+ const matches = videoIdRegex.exec(url);
31
+ if (!matches || !matches[1]) {
32
+ return null;
33
+ }
34
+ let outputUrl = `${getYoutubeEmbedUrl(nocookie)}${matches[1]}`;
35
+ const params = [];
36
+ if (allowFullscreen === false) {
37
+ params.push('fs=0');
38
+ }
39
+ if (autoplay) {
40
+ params.push('autoplay=1');
41
+ }
42
+ if (ccLanguage) {
43
+ params.push(`cc_lang_pref=${ccLanguage}`);
44
+ }
45
+ if (ccLoadPolicy) {
46
+ params.push('cc_load_policy=1');
47
+ }
48
+ if (!controls) {
49
+ params.push('controls=0');
50
+ }
51
+ if (disableKBcontrols) {
52
+ params.push('disablekb=1');
53
+ }
54
+ if (enableIFrameApi) {
55
+ params.push('enablejsapi=1');
56
+ }
57
+ if (endTime) {
58
+ params.push(`end=${endTime}`);
59
+ }
60
+ if (interfaceLanguage) {
61
+ params.push(`hl=${interfaceLanguage}`);
62
+ }
63
+ if (ivLoadPolicy) {
64
+ params.push(`iv_load_policy=${ivLoadPolicy}`);
65
+ }
66
+ if (loop) {
67
+ params.push('loop=1');
68
+ }
69
+ if (modestBranding) {
70
+ params.push('modestbranding=1');
71
+ }
72
+ if (origin) {
73
+ params.push(`origin=${origin}`);
74
+ }
75
+ if (playlist) {
76
+ params.push(`playlist=${playlist}`);
77
+ }
78
+ if (startAt) {
79
+ params.push(`start=${startAt}`);
80
+ }
81
+ if (progressBarColor) {
82
+ params.push(`color=${progressBarColor}`);
83
+ }
84
+ if (params.length) {
85
+ outputUrl += `?${params.join('&')}`;
86
+ }
87
+ return outputUrl;
88
+ };
89
+
90
+ const Youtube = core.Node.create({
91
+ name: 'youtube',
92
+ addOptions() {
93
+ return {
94
+ addPasteHandler: true,
95
+ allowFullscreen: true,
96
+ autoplay: false,
97
+ ccLanguage: undefined,
98
+ ccLoadPolicy: undefined,
99
+ controls: true,
100
+ disableKBcontrols: false,
101
+ enableIFrameApi: false,
102
+ endTime: 0,
103
+ height: 480,
104
+ interfaceLanguage: undefined,
105
+ ivLoadPolicy: 0,
106
+ loop: false,
107
+ modestBranding: false,
108
+ HTMLAttributes: {},
109
+ inline: false,
110
+ nocookie: false,
111
+ origin: '',
112
+ playlist: '',
113
+ progressBarColor: undefined,
114
+ width: 640,
115
+ };
116
+ },
117
+ inline() {
118
+ return this.options.inline;
119
+ },
120
+ group() {
121
+ return this.options.inline ? 'inline' : 'block';
122
+ },
123
+ draggable: true,
124
+ addAttributes() {
125
+ return {
126
+ src: {
127
+ default: null,
128
+ },
129
+ start: {
130
+ default: 0,
131
+ },
132
+ width: {
133
+ default: this.options.width,
134
+ },
135
+ height: {
136
+ default: this.options.height,
137
+ },
138
+ };
139
+ },
140
+ parseHTML() {
141
+ return [
142
+ {
143
+ tag: 'div[data-youtube-video] iframe',
144
+ },
145
+ ];
146
+ },
147
+ addCommands() {
148
+ return {
149
+ setYoutubeVideo: (options) => ({ commands }) => {
150
+ if (!isValidYoutubeUrl(options.src)) {
151
+ return false;
152
+ }
153
+ return commands.insertContent({
154
+ type: this.name,
155
+ attrs: options,
156
+ });
157
+ },
158
+ };
159
+ },
160
+ addPasteRules() {
161
+ if (!this.options.addPasteHandler) {
162
+ return [];
163
+ }
164
+ return [
165
+ core.nodePasteRule({
166
+ find: YOUTUBE_REGEX_GLOBAL,
167
+ type: this.type,
168
+ getAttributes: match => {
169
+ return { src: match.input };
170
+ },
171
+ }),
172
+ ];
173
+ },
174
+ renderHTML({ HTMLAttributes }) {
175
+ const embedUrl = getEmbedUrlFromYoutubeUrl({
176
+ url: HTMLAttributes.src,
177
+ allowFullscreen: this.options.allowFullscreen,
178
+ autoplay: this.options.autoplay,
179
+ ccLanguage: this.options.ccLanguage,
180
+ ccLoadPolicy: this.options.ccLoadPolicy,
181
+ controls: this.options.controls,
182
+ disableKBcontrols: this.options.disableKBcontrols,
183
+ enableIFrameApi: this.options.enableIFrameApi,
184
+ endTime: this.options.endTime,
185
+ interfaceLanguage: this.options.interfaceLanguage,
186
+ ivLoadPolicy: this.options.ivLoadPolicy,
187
+ loop: this.options.loop,
188
+ modestBranding: this.options.modestBranding,
189
+ nocookie: this.options.nocookie,
190
+ origin: this.options.origin,
191
+ playlist: this.options.playlist,
192
+ progressBarColor: this.options.progressBarColor,
193
+ startAt: HTMLAttributes.start || 0,
194
+ });
195
+ HTMLAttributes.src = embedUrl;
196
+ return [
197
+ 'div',
198
+ { 'data-youtube-video': '' },
199
+ [
200
+ 'iframe',
201
+ core.mergeAttributes(this.options.HTMLAttributes, {
202
+ width: this.options.width,
203
+ height: this.options.height,
204
+ allowfullscreen: this.options.allowFullscreen,
205
+ autoplay: this.options.autoplay,
206
+ ccLanguage: this.options.ccLanguage,
207
+ ccLoadPolicy: this.options.ccLoadPolicy,
208
+ disableKBcontrols: this.options.disableKBcontrols,
209
+ enableIFrameApi: this.options.enableIFrameApi,
210
+ endTime: this.options.endTime,
211
+ interfaceLanguage: this.options.interfaceLanguage,
212
+ ivLoadPolicy: this.options.ivLoadPolicy,
213
+ loop: this.options.loop,
214
+ modestBranding: this.options.modestBranding,
215
+ origin: this.options.origin,
216
+ playlist: this.options.playlist,
217
+ progressBarColor: this.options.progressBarColor,
218
+ }, HTMLAttributes),
219
+ ],
220
+ ];
221
+ },
222
+ });
223
+
224
+ exports.Youtube = Youtube;
225
+ exports["default"] = Youtube;
226
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils.ts","../src/youtube.ts"],"sourcesContent":["export const YOUTUBE_REGEX = /^(https?:\\/\\/)?(www\\.|music\\.)?(youtube\\.com|youtu\\.be)(?!.*\\/channel\\/)(?!\\/@)(.+)?$/\nexport const YOUTUBE_REGEX_GLOBAL = /^(https?:\\/\\/)?(www\\.|music\\.)?(youtube\\.com|youtu\\.be)(?!.*\\/channel\\/)(?!\\/@)(.+)?$/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}\n\nexport const getYoutubeEmbedUrl = (nocookie?: boolean) => {\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 } = options\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=([-\\w]+)/gm\n const matches = videoIdRegex.exec(url)\n\n if (!matches || !matches[1]) {\n return null\n }\n\n let outputUrl = `${getYoutubeEmbedUrl(nocookie)}${matches[1]}`\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 (params.length) {\n outputUrl += `?${params.join('&')}`\n }\n\n return outputUrl\n}\n","import { mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl, YOUTUBE_REGEX_GLOBAL } from './utils'\n\nexport interface YoutubeOptions {\n addPasteHandler: boolean;\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 height: number;\n interfaceLanguage?: string;\n ivLoadPolicy: number;\n loop: boolean;\n modestBranding: boolean;\n HTMLAttributes: Record<string, any>;\n inline: boolean;\n nocookie: boolean;\n origin: string;\n playlist: string;\n progressBarColor?: string;\n width: number;\n}\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 */\n setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType,\n }\n }\n}\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 }\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: (options: SetYoutubeVideoOptions) => ({ 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 })\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 },\n HTMLAttributes,\n ),\n ],\n ]\n },\n})\n"],"names":["Node","nodePasteRule","mergeAttributes"],"mappings":";;;;;;AAAO,MAAM,aAAa,GAAG,uFAAuF,CAAA;AAC7G,MAAM,oBAAoB,GAAG,wFAAwF,CAAA;AAErH,MAAM,iBAAiB,GAAG,CAAC,GAAW,KAAI;AAC/C,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACjC,CAAC,CAAA;AAuBM,MAAM,kBAAkB,GAAG,CAAC,QAAkB,KAAI;IACvD,OAAO,QAAQ,GAAG,yCAAyC,GAAG,gCAAgC,CAAA;AAChG,CAAC,CAAA;AAEM,MAAM,yBAAyB,GAAG,CAAC,OAA2B,KAAI;AACvE,IAAA,MAAM,EACJ,GAAG,EACH,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,OAAO,GACR,GAAG,OAAO,CAAA;;AAGX,IAAA,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC3B,QAAA,OAAO,GAAG,C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eAAe;AAC7C,oBAAA,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;AAC/B,oBAAA,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;AACnC,oBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;AACvC,oBAAA,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;AACjD,oBAAA,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe;AAC7C,oBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;AAC7B,oBAAA,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;AACjD,oBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;AACvC,oBAAA,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;AACvB,oBAAA,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;AAC3C,oBAAA,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;AAC3B,oBAAA,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;AAC/B,oBAAA,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB;AAChD,iBAAA,EACD,cAAc,CACf;AACF,aAAA;SACF,CAAA;KACF;AACF,CAAA;;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,221 @@
1
+ import { Node, nodePasteRule, mergeAttributes } from '@tiptap/core';
2
+
3
+ const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/;
4
+ const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/g;
5
+ const isValidYoutubeUrl = (url) => {
6
+ return url.match(YOUTUBE_REGEX);
7
+ };
8
+ const getYoutubeEmbedUrl = (nocookie) => {
9
+ return nocookie ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/';
10
+ };
11
+ const getEmbedUrlFromYoutubeUrl = (options) => {
12
+ const { url, allowFullscreen, autoplay, ccLanguage, ccLoadPolicy, controls, disableKBcontrols, enableIFrameApi, endTime, interfaceLanguage, ivLoadPolicy, loop, modestBranding, nocookie, origin, playlist, progressBarColor, startAt, } = options;
13
+ // if is already an embed url, return it
14
+ if (url.includes('/embed/')) {
15
+ return url;
16
+ }
17
+ // if is a youtu.be url, get the id after the /
18
+ if (url.includes('youtu.be')) {
19
+ const id = url.split('/').pop();
20
+ if (!id) {
21
+ return null;
22
+ }
23
+ return `${getYoutubeEmbedUrl(nocookie)}${id}`;
24
+ }
25
+ const videoIdRegex = /v=([-\w]+)/gm;
26
+ const matches = videoIdRegex.exec(url);
27
+ if (!matches || !matches[1]) {
28
+ return null;
29
+ }
30
+ let outputUrl = `${getYoutubeEmbedUrl(nocookie)}${matches[1]}`;
31
+ const params = [];
32
+ if (allowFullscreen === false) {
33
+ params.push('fs=0');
34
+ }
35
+ if (autoplay) {
36
+ params.push('autoplay=1');
37
+ }
38
+ if (ccLanguage) {
39
+ params.push(`cc_lang_pref=${ccLanguage}`);
40
+ }
41
+ if (ccLoadPolicy) {
42
+ params.push('cc_load_policy=1');
43
+ }
44
+ if (!controls) {
45
+ params.push('controls=0');
46
+ }
47
+ if (disableKBcontrols) {
48
+ params.push('disablekb=1');
49
+ }
50
+ if (enableIFrameApi) {
51
+ params.push('enablejsapi=1');
52
+ }
53
+ if (endTime) {
54
+ params.push(`end=${endTime}`);
55
+ }
56
+ if (interfaceLanguage) {
57
+ params.push(`hl=${interfaceLanguage}`);
58
+ }
59
+ if (ivLoadPolicy) {
60
+ params.push(`iv_load_policy=${ivLoadPolicy}`);
61
+ }
62
+ if (loop) {
63
+ params.push('loop=1');
64
+ }
65
+ if (modestBranding) {
66
+ params.push('modestbranding=1');
67
+ }
68
+ if (origin) {
69
+ params.push(`origin=${origin}`);
70
+ }
71
+ if (playlist) {
72
+ params.push(`playlist=${playlist}`);
73
+ }
74
+ if (startAt) {
75
+ params.push(`start=${startAt}`);
76
+ }
77
+ if (progressBarColor) {
78
+ params.push(`color=${progressBarColor}`);
79
+ }
80
+ if (params.length) {
81
+ outputUrl += `?${params.join('&')}`;
82
+ }
83
+ return outputUrl;
84
+ };
85
+
86
+ const Youtube = Node.create({
87
+ name: 'youtube',
88
+ addOptions() {
89
+ return {
90
+ addPasteHandler: true,
91
+ allowFullscreen: true,
92
+ autoplay: false,
93
+ ccLanguage: undefined,
94
+ ccLoadPolicy: undefined,
95
+ controls: true,
96
+ disableKBcontrols: false,
97
+ enableIFrameApi: false,
98
+ endTime: 0,
99
+ height: 480,
100
+ interfaceLanguage: undefined,
101
+ ivLoadPolicy: 0,
102
+ loop: false,
103
+ modestBranding: false,
104
+ HTMLAttributes: {},
105
+ inline: false,
106
+ nocookie: false,
107
+ origin: '',
108
+ playlist: '',
109
+ progressBarColor: undefined,
110
+ width: 640,
111
+ };
112
+ },
113
+ inline() {
114
+ return this.options.inline;
115
+ },
116
+ group() {
117
+ return this.options.inline ? 'inline' : 'block';
118
+ },
119
+ draggable: true,
120
+ addAttributes() {
121
+ return {
122
+ src: {
123
+ default: null,
124
+ },
125
+ start: {
126
+ default: 0,
127
+ },
128
+ width: {
129
+ default: this.options.width,
130
+ },
131
+ height: {
132
+ default: this.options.height,
133
+ },
134
+ };
135
+ },
136
+ parseHTML() {
137
+ return [
138
+ {
139
+ tag: 'div[data-youtube-video] iframe',
140
+ },
141
+ ];
142
+ },
143
+ addCommands() {
144
+ return {
145
+ setYoutubeVideo: (options) => ({ commands }) => {
146
+ if (!isValidYoutubeUrl(options.src)) {
147
+ return false;
148
+ }
149
+ return commands.insertContent({
150
+ type: this.name,
151
+ attrs: options,
152
+ });
153
+ },
154
+ };
155
+ },
156
+ addPasteRules() {
157
+ if (!this.options.addPasteHandler) {
158
+ return [];
159
+ }
160
+ return [
161
+ nodePasteRule({
162
+ find: YOUTUBE_REGEX_GLOBAL,
163
+ type: this.type,
164
+ getAttributes: match => {
165
+ return { src: match.input };
166
+ },
167
+ }),
168
+ ];
169
+ },
170
+ renderHTML({ HTMLAttributes }) {
171
+ const embedUrl = getEmbedUrlFromYoutubeUrl({
172
+ url: HTMLAttributes.src,
173
+ allowFullscreen: this.options.allowFullscreen,
174
+ autoplay: this.options.autoplay,
175
+ ccLanguage: this.options.ccLanguage,
176
+ ccLoadPolicy: this.options.ccLoadPolicy,
177
+ controls: this.options.controls,
178
+ disableKBcontrols: this.options.disableKBcontrols,
179
+ enableIFrameApi: this.options.enableIFrameApi,
180
+ endTime: this.options.endTime,
181
+ interfaceLanguage: this.options.interfaceLanguage,
182
+ ivLoadPolicy: this.options.ivLoadPolicy,
183
+ loop: this.options.loop,
184
+ modestBranding: this.options.modestBranding,
185
+ nocookie: this.options.nocookie,
186
+ origin: this.options.origin,
187
+ playlist: this.options.playlist,
188
+ progressBarColor: this.options.progressBarColor,
189
+ startAt: HTMLAttributes.start || 0,
190
+ });
191
+ HTMLAttributes.src = embedUrl;
192
+ return [
193
+ 'div',
194
+ { 'data-youtube-video': '' },
195
+ [
196
+ 'iframe',
197
+ mergeAttributes(this.options.HTMLAttributes, {
198
+ width: this.options.width,
199
+ height: this.options.height,
200
+ allowfullscreen: this.options.allowFullscreen,
201
+ autoplay: this.options.autoplay,
202
+ ccLanguage: this.options.ccLanguage,
203
+ ccLoadPolicy: this.options.ccLoadPolicy,
204
+ disableKBcontrols: this.options.disableKBcontrols,
205
+ enableIFrameApi: this.options.enableIFrameApi,
206
+ endTime: this.options.endTime,
207
+ interfaceLanguage: this.options.interfaceLanguage,
208
+ ivLoadPolicy: this.options.ivLoadPolicy,
209
+ loop: this.options.loop,
210
+ modestBranding: this.options.modestBranding,
211
+ origin: this.options.origin,
212
+ playlist: this.options.playlist,
213
+ progressBarColor: this.options.progressBarColor,
214
+ }, HTMLAttributes),
215
+ ],
216
+ ];
217
+ },
218
+ });
219
+
220
+ export { Youtube, Youtube as default };
221
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/youtube.ts"],"sourcesContent":["export const YOUTUBE_REGEX = /^(https?:\\/\\/)?(www\\.|music\\.)?(youtube\\.com|youtu\\.be)(?!.*\\/channel\\/)(?!\\/@)(.+)?$/\nexport const YOUTUBE_REGEX_GLOBAL = /^(https?:\\/\\/)?(www\\.|music\\.)?(youtube\\.com|youtu\\.be)(?!.*\\/channel\\/)(?!\\/@)(.+)?$/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}\n\nexport const getYoutubeEmbedUrl = (nocookie?: boolean) => {\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 } = options\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=([-\\w]+)/gm\n const matches = videoIdRegex.exec(url)\n\n if (!matches || !matches[1]) {\n return null\n }\n\n let outputUrl = `${getYoutubeEmbedUrl(nocookie)}${matches[1]}`\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 (params.length) {\n outputUrl += `?${params.join('&')}`\n }\n\n return outputUrl\n}\n","import { mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport { getEmbedUrlFromYoutubeUrl, isValidYoutubeUrl, YOUTUBE_REGEX_GLOBAL } from './utils'\n\nexport interface YoutubeOptions {\n addPasteHandler: boolean;\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 height: number;\n interfaceLanguage?: string;\n ivLoadPolicy: number;\n loop: boolean;\n modestBranding: boolean;\n HTMLAttributes: Record<string, any>;\n inline: boolean;\n nocookie: boolean;\n origin: string;\n playlist: string;\n progressBarColor?: string;\n width: number;\n}\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 */\n setYoutubeVideo: (options: SetYoutubeVideoOptions) => ReturnType,\n }\n }\n}\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 }\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: (options: SetYoutubeVideoOptions) => ({ 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 })\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 },\n HTMLAttributes,\n ),\n ],\n ]\n },\n})\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,GAAG,uFAAuF,CAAA;AAC7G,MAAM,oBAAoB,GAAG,wFAAwF,CAAA;AAErH,MAAM,iBAAiB,GAAG,CAAC,GAAW,KAAI;AAC/C,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACjC,CAAC,CAAA;AAuBM,MAAM,kBAAkB,GAAG,CAAC,QAAkB,KAAI;IACvD,OAAO,QAAQ,GAAG,yCAAyC,GAAG,gCAAgC,CAAA;AAChG,CAAC,CAAA;AAEM,MAAM,yBAAyB,GAAG,CAAC,OAA2B,KAAI;AACvE,IAAA,MAAM,EACJ,GAAG,EACH,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,EACZ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