annotate src/test/tiny.html @ 23:cdcd1b70c15e

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