annotate src/test/tiny.html @ 34:c8d47981c74f

upload using ajax
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 02 Aug 2022 20:46:02 -0600
parents 72a1b77b4548
children 1ce75c5ab0f7
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>
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
9 function videoIframe(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
10 return '<iframe data-video="'+url+'" width="560" height="315" frameborder="0" allowfullscreen src="'+url+'"></iframe>';
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
11 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
12
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
13 // fucking moronic javascript doesn't have \Q \E in regex
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
14 var videoHandlers = {};
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
15 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
16 let ptn1 = /^https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)(?:\?t=([0-9]+))?/;
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
17 let ptn2 = /^https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)(?:&t=([0-9]+)s)?/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
18 videoHandlers.youtube = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
19 let result = url.match(ptn1) || url.match(ptn2);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
20 if( result ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
21 url = 'https://www.youtube.com/embed/' + result[1];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
22 if( result[2] )
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
23 url += '?start=' + result[2];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
24 return videoIframe(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
25 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
26 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
27 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
28 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
29 let ptn = /^https:\/\/rumble\.com\/embed\/[a-z0-9]+\/\?pub=[a-z0-9]+/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
30 videoHandlers.rumble = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
31 if( url.match(ptn) ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
32 return videoIframe(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
33 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
34 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
35 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
36 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
37 let ptn = /^https:\/\/www\.bitchute\.com\/video\/([a-zA-Z0-9]+)\//;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
38 videoHandlers.bitchute = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
39 let result = url.match(ptn);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
40 if( result ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
41 url = 'https://www.bitchute.com/embed/' + result[1];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
42 return videoIframe(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
43 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
44 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
45 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
46 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
47 let ptn = /^https:\/\/vimeo\.com\/([0-9]+)/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
48 videoHandlers.vimeo = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
49 let result = url.match(ptn);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
50 if( result ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
51 url = 'https://player.vimeo.com/video/' + result[1];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
52 return videoIframe(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
53 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
54 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
55 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
56 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
57 let ptn = /^https:\/\/dai\.ly\/([a-z0-9]+)/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
58 videoHandlers.dailymotion = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
59 let result = url.match(ptn);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
60 if( result ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
61 url = 'https://www.dailymotion.com/embed/video/' + result[1];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
62 return videoIframe(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
63 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
64 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
65 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
66 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
67 let ptn = /^https:\/\/www\.tiktok\.com\/[^/]+\/video\/([0-9]+)/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
68 videoHandlers.tiktok = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
69 let result = url.match(ptn);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
70 if( result ) {
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
71 //let html = '<blockquote class="tiktok-embed" data-video="'+result[1]+'" style="max-width: 560px; margin-left: 0;"><section></section></blockquote>';
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
72 //html += '<script async src="https://www.tiktok.com/embed.js"></'+'script>';
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
73 let html = '<img data-video="'+result[1]+'" src="whataever">';
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
74 return html;
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
75 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
76 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
77 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
78 {
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
79 let ptn = /\.[a-zA-Z0-9]+$/;
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
80 videoHandlers.file = function(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
81 if( url.match(ptn) ) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
82 return '<video controls width="560" height><source src="'+url+'"></video>';
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
83 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
84 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
85 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
86
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
87 function videoUrlToHtml(url) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
88 for (let key in videoHandlers) {
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
89 let handle = videoHandlers[key];
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
90 let html = handle(url);
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
91 if(html) return html;
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
92 }
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
93 return '<a data-video="'+url+'" href="'+url+'">'+url+'</a>';
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
94 }
22
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
95
24
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
96
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
97 function tinymceSetup(editor) {
24
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
98
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
99 editor.ui.registry.addButton('insertImage', {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
100 icon: 'image',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
101 tooltip: 'Insert image',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
102 onAction: function(api) {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
103 editor.windowManager.open({
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
104 title: 'Insert Image',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
105 body: {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
106 type: 'panel',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
107 items: [
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
108 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
109 type: 'urlinput',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
110 name: 'src',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
111 filetype: 'image',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
112 label: 'Source URL'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
113 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
114 ]
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
115 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
116 buttons: [
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
117 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
118 type: 'cancel',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
119 text: 'Cancel'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
120 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
121 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
122 type: 'submit',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
123 text: 'Save',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
124 buttonType: 'primary'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
125 }
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
126 ],
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
127 onSubmit: function(dialogApi) {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
128 let src = dialogApi.getData('src').src.value;
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
129 if(!src) return;
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
130 src = tinymce.DOM.encode(src);
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
131 let html = '<img src="' + src + '">';
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
132 dialogApi.close();
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
133 editor.insertContent(html);
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
134 }
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
135 });
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
136 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
137 });
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
138
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
139 editor.ui.registry.addButton('insertVideo', {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
140 icon: 'embed',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
141 tooltip: 'Insert video',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
142 onAction: function(api) {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
143 editor.windowManager.open({
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
144 title: 'Insert Video',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
145 body: {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
146 type: 'panel',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
147 items: [
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
148 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
149 type: 'urlinput',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
150 name: 'src',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
151 filetype: 'image',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
152 label: 'Source URL'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
153 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
154 ]
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
155 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
156 buttons: [
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
157 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
158 type: 'cancel',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
159 text: 'Cancel'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
160 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
161 {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
162 type: 'submit',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
163 text: 'Save',
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
164 buttonType: 'primary'
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
165 }
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
166 ],
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
167 onSubmit: function(dialogApi) {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
168 let src = dialogApi.getData('src').src.value;
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
169 if(!src) return;
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
170 let html = videoUrlToHtml(src);
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
171 //alert(html);
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
172 dialogApi.close();
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
173 editor.insertContent(html);
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
174 }
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
175 });
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
176 },
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
177 });
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
178
24
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
179 editor.ui.registry.addToggleButton('styleCode', {
32
Franklin Schmidt <fschmidt@gmail.com>
parents: 31
diff changeset
180 icon: 'code-sample',
24
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
181 tooltip: 'Code',
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
182 onAction: function(api) {
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
183 editor.execCommand('mceToggleFormat', false, 'code');
24
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
184 },
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
185 onSetup: function(api) {
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
186 api.setActive(editor.formatter.match('code'));
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
187 let changed = editor.formatter.formatChanged('code', api.setActive);
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
188 return function() { changed.unbind(); };
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
189 }
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
190 });
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
191
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
192 editor.ui.registry.addMenuButton('styleText', {
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
193 icon: 'format',
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
194 tooltip: 'Text',
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
195 fetch: function(callback) {
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
196 callback([
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
197 'fontsize',
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
198 'forecolor',
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
199 ])
fccbe5554fcc tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
200 }
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
201 });
26
0837820b97fb tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 24
diff changeset
202
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
203 editor.on( 'init', function(e) {
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
204 editor.focus();
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
205 } );
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
206 }
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
207
22
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
208 tinymce.init({
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
209 selector: 'textarea',
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
210 setup: tinymceSetup,
27
6871eec2cf4c add rumble
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
211 //menubar: false,
26
0837820b97fb tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 24
diff changeset
212 statusbar: false,
32
Franklin Schmidt <fschmidt@gmail.com>
parents: 31
diff changeset
213 plugins: ['link', 'image', 'media', 'lists', 'code', 'autoresize'],
31
6d265f5e18e2 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 30
diff changeset
214 toolbar: 'link insertImage insertVideo | styleCode bold italic underline strikethrough superscript styleText | blockquote numlist bullist',
26
0837820b97fb tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 24
diff changeset
215 autoresize_bottom_margin: 0,
22
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
216 link_target_list: false,
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
217 link_title: false,
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
218 object_resizing: false,
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
219 contextmenu: false,
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
220 text_patterns: false,
26
0837820b97fb tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 24
diff changeset
221 content_style: 'img {max-width: 500px;} p {margin: 0}',
22
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
222 extended_valid_elements: 'b,i',
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223 formats: {
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
224 bold: { inline: 'b' },
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
225 italic: {inline: 'i'},
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
226 underline: {inline: 'u'},
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
227 },
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
228 });
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
229
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
230 function log() {
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
231 console.log(tinymce.activeEditor.getContent());
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
232 }
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
233 </script>
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
234 </head>
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
235 <body>
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 22
diff changeset
236 <p><a href="https://www.tiny.cloud/">TinyMCE</a></p>
22
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
237 <textarea></textarea>
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
238 <p><button onclick="log()">log</button></p>
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
239 </body>
d87a8f9f43d7 tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
240 </html>