+interface UrlPattern {
+ readonly regex: RegExp;
+ readonly w: number;
+ readonly h: number;
+ readonly url: string;
+}
+
+/**
+ * These patterns originate from the tinymce/tinymce project.
+ * https://github.com/tinymce/tinymce/blob/release/6.6/modules/tinymce/src/plugins/media/main/ts/core/UrlPatterns.ts
+ * License: MIT Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
+ * License Link: https://github.com/tinymce/tinymce/blob/584a150679669859a528828e5d2910a083b1d911/LICENSE.TXT
+ */
+const urlPatterns: UrlPattern[] = [
+ {
+ regex: /.*?youtu\.be\/([\w\-_\?&=.]+)/i,
+ w: 560, h: 314,
+ url: 'https://www.youtube.com/embed/$1',
+ },
+ {
+ regex: /.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,
+ w: 560, h: 314,
+ url: 'https://www.youtube.com/embed/$2?$4',
+ },
+ {
+ regex: /.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,
+ w: 560, h: 314,
+ url: 'https://www.youtube.com/embed/$1',
+ },
+];
+