22
|
1 <!doctype html>
|
|
2 <html>
|
|
3 <head>
|
|
4 <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5 <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
|
|
6 <style>
|
|
7 </style>
|
|
8 <script>
|
|
9 var youtubePtn1 = new RegExp('https://youtu.be/([a-zA-Z0-9_-]+)(?:\\?t=([0-9]+))?');
|
|
10 var youtubePtn2 = new RegExp('https://www.youtube.com/watch\\?v=([a-zA-Z0-9_-]+)(?:\\?t=([0-9]+)s)?');
|
|
11 var bitchutePtn = new RegExp('https://www.bitchute.com/video/([a-zA-Z0-9]+)/');
|
|
12 var url2;
|
|
13
|
|
14 function media_url_resolver(data,resolve,reject) {
|
|
15 let html;
|
|
16 let url = data.url;
|
|
17 url2 = url;
|
|
18 let result;
|
|
19 if( result = url.match(youtubePtn1) || url.match(youtubePtn2) ) {
|
23
|
20 html = '<iframe data-video="'+url+'" width="560" height="315" src="https://www.youtube.com/embed/' + result[1];
|
22
|
21 if( result[2] )
|
|
22 html += '?start=' + result[2]
|
|
23 html += '" frameborder="0" allowfullscreen></iframe>';
|
|
24 } else if( result = url.match(bitchutePtn) ) {
|
23
|
25 html = '<iframe data-video="'+url+'" width="560" height="315" scrolling="no" frameborder="0" style="border: none;" src="https://www.bitchute.com/embed/' + result[1] + '/"></iframe>';
|
22
|
26 } else {
|
23
|
27 html = '<a data-video="'+url+'" href="'+url+'">'+url+'</a>';
|
22
|
28 }
|
|
29 resolve({ html: html });
|
|
30 }
|
|
31
|
23
|
32 function tinymceSetup(editor) {
|
|
33 editor.ui.registry.addButton('styleCode', {
|
|
34 text: 'code',
|
|
35 onAction: () => alert('Button clicked!')
|
|
36 });
|
|
37 }
|
|
38
|
22
|
39 tinymce.init({
|
|
40 selector: 'textarea',
|
23
|
41 setup: tinymceSetup,
|
|
42 plugins: ['link', 'image', 'media', 'lists'],
|
22
|
43 link_target_list: false,
|
|
44 link_title: false,
|
|
45 image_description: false,
|
|
46 image_dimensions: false,
|
|
47 object_resizing: false,
|
|
48 contextmenu: false,
|
|
49 media_alt_source: false,
|
|
50 media_dimensions: false,
|
|
51 media_poster: false,
|
|
52 media_url_resolver: media_url_resolver,
|
|
53 text_patterns: false,
|
|
54 content_style: 'img {max-width: 500px;}',
|
23
|
55 //newline_behavior: 'linebreak',
|
|
56 toolbar: 'link image media | styleCode bold | numlist bullist',
|
22
|
57 extended_valid_elements: 'b,i',
|
|
58 formats: {
|
|
59 bold: { inline: 'b' },
|
|
60 italic: {inline: 'i'},
|
|
61 underline: {inline: 'u'},
|
|
62 },
|
|
63 });
|
|
64
|
|
65 function log() {
|
|
66 console.log(tinymce.activeEditor.getContent());
|
|
67 }
|
|
68 </script>
|
|
69 </head>
|
|
70 <body>
|
23
|
71 <p><a href="https://www.tiny.cloud/">TinyMCE</a></p>
|
22
|
72 <textarea></textarea>
|
|
73 <p><button onclick="log()">log</button></p>
|
|
74 </body>
|
|
75 </html>
|