22
|
1 <!doctype html>
|
|
2 <html>
|
|
3 <head>
|
|
4 <meta name="viewport" content="width=device-width, initial-scale=1">
|
24
|
5 <script src="http://tinymce.luan.software/tinymce.min.js" xreferrerpolicy="origin"></script>
|
22
|
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
|
24
|
32
|
23
|
33 function tinymceSetup(editor) {
|
24
|
34
|
|
35 editor.ui.registry.addToggleButton('styleCode', {
|
|
36 //text: 'code',
|
|
37 icon: 'sourcecode',
|
|
38 tooltip: 'Code',
|
|
39 onAction: function(api) {
|
|
40 editor.execCommand('mceToggleFormat', false, 'code')
|
|
41 //api.setActive( !api.isActive() );
|
|
42 },
|
|
43 onSetup: function(api) {
|
|
44 api.setActive(editor.formatter.match('code'));
|
|
45 let changed = editor.formatter.formatChanged('code', api.setActive);
|
|
46 return function() { changed.unbind(); };
|
|
47 }
|
|
48 });
|
|
49
|
|
50 editor.ui.registry.addMenuButton('styleText', {
|
|
51 icon: 'format',
|
|
52 tooltip: 'Text',
|
|
53 fetch: function(callback) {
|
|
54 callback([
|
|
55 'fontsize',
|
|
56 'forecolor',
|
|
57 ])
|
|
58 }
|
23
|
59 });
|
|
60 }
|
|
61
|
22
|
62 tinymce.init({
|
|
63 selector: 'textarea',
|
23
|
64 setup: tinymceSetup,
|
24
|
65 toolbar: 'link image media | styleCode bold italic underline strikethrough superscript styleText | blockquote numlist bullist',
|
|
66 plugins: ['link', 'image', 'media', 'lists', 'code'],
|
22
|
67 link_target_list: false,
|
|
68 link_title: false,
|
|
69 image_description: false,
|
|
70 image_dimensions: false,
|
|
71 object_resizing: false,
|
|
72 contextmenu: false,
|
|
73 media_alt_source: false,
|
|
74 media_dimensions: false,
|
|
75 media_poster: false,
|
|
76 media_url_resolver: media_url_resolver,
|
|
77 text_patterns: false,
|
|
78 content_style: 'img {max-width: 500px;}',
|
23
|
79 //newline_behavior: 'linebreak',
|
22
|
80 extended_valid_elements: 'b,i',
|
|
81 formats: {
|
|
82 bold: { inline: 'b' },
|
|
83 italic: {inline: 'i'},
|
|
84 underline: {inline: 'u'},
|
|
85 },
|
|
86 });
|
|
87
|
|
88 function log() {
|
|
89 console.log(tinymce.activeEditor.getContent());
|
|
90 }
|
|
91 </script>
|
|
92 </head>
|
|
93 <body>
|
23
|
94 <p><a href="https://www.tiny.cloud/">TinyMCE</a></p>
|
22
|
95 <textarea></textarea>
|
|
96 <p><button onclick="log()">log</button></p>
|
|
97 </body>
|
|
98 </html>
|