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 icon: 'sourcecode',
|
|
37 tooltip: 'Code',
|
|
38 onAction: function(api) {
|
|
39 editor.execCommand('mceToggleFormat', false, 'code')
|
|
40 //api.setActive( !api.isActive() );
|
|
41 },
|
|
42 onSetup: function(api) {
|
|
43 api.setActive(editor.formatter.match('code'));
|
|
44 let changed = editor.formatter.formatChanged('code', api.setActive);
|
|
45 return function() { changed.unbind(); };
|
|
46 }
|
|
47 });
|
|
48
|
|
49 editor.ui.registry.addMenuButton('styleText', {
|
|
50 icon: 'format',
|
|
51 tooltip: 'Text',
|
|
52 fetch: function(callback) {
|
|
53 callback([
|
|
54 'fontsize',
|
|
55 'forecolor',
|
|
56 ])
|
|
57 }
|
23
|
58 });
|
26
|
59
|
|
60 editor.on( 'init', function(e) {editor.focus()} );
|
|
61 //editor.focus();
|
23
|
62 }
|
|
63
|
22
|
64 tinymce.init({
|
|
65 selector: 'textarea',
|
23
|
66 setup: tinymceSetup,
|
26
|
67 menubar: false,
|
|
68 statusbar: false,
|
24
|
69 toolbar: 'link image media | styleCode bold italic underline strikethrough superscript styleText | blockquote numlist bullist',
|
26
|
70 //block_formats: 'Paragraph=div; Header 1=h1; Header 2=h2; Header 3=h3',
|
|
71 plugins: ['link', 'image', 'media', 'lists', 'code', 'autoresize'],
|
|
72 autoresize_bottom_margin: 0,
|
22
|
73 link_target_list: false,
|
|
74 link_title: false,
|
|
75 image_description: false,
|
|
76 image_dimensions: false,
|
|
77 object_resizing: false,
|
|
78 contextmenu: false,
|
|
79 media_alt_source: false,
|
|
80 media_dimensions: false,
|
|
81 media_poster: false,
|
|
82 media_url_resolver: media_url_resolver,
|
|
83 text_patterns: false,
|
26
|
84 content_style: 'img {max-width: 500px;} p {margin: 0}',
|
23
|
85 //newline_behavior: 'linebreak',
|
22
|
86 extended_valid_elements: 'b,i',
|
|
87 formats: {
|
|
88 bold: { inline: 'b' },
|
|
89 italic: {inline: 'i'},
|
|
90 underline: {inline: 'u'},
|
|
91 },
|
|
92 });
|
|
93
|
|
94 function log() {
|
|
95 console.log(tinymce.activeEditor.getContent());
|
|
96 }
|
|
97 </script>
|
|
98 </head>
|
|
99 <body>
|
23
|
100 <p><a href="https://www.tiny.cloud/">TinyMCE</a></p>
|
22
|
101 <textarea></textarea>
|
|
102 <p><button onclick="log()">log</button></p>
|
|
103 </body>
|
|
104 </html>
|