annotate src/test/tiny.html @ 25:66fd3784e60e

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