comparison src/test/tiny.html @ 24:fccbe5554fcc

tinymce work
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 19 Jul 2022 22:07:02 -0600
parents cdcd1b70c15e
children 0837820b97fb
comparison
equal deleted inserted replaced
23:cdcd1b70c15e 24:fccbe5554fcc
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <meta name="viewport" content="width=device-width, initial-scale=1"> 4 <meta name="viewport" content="width=device-width, initial-scale=1">
5 <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script> 5 <script src="http://tinymce.luan.software/tinymce.min.js" xreferrerpolicy="origin"></script>
6 <style> 6 <style>
7 </style> 7 </style>
8 <script> 8 <script>
9 var youtubePtn1 = new RegExp('https://youtu.be/([a-zA-Z0-9_-]+)(?:\\?t=([0-9]+))?'); 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)?'); 10 var youtubePtn2 = new RegExp('https://www.youtube.com/watch\\?v=([a-zA-Z0-9_-]+)(?:\\?t=([0-9]+)s)?');
27 html = '<a data-video="'+url+'" href="'+url+'">'+url+'</a>'; 27 html = '<a data-video="'+url+'" href="'+url+'">'+url+'</a>';
28 } 28 }
29 resolve({ html: html }); 29 resolve({ html: html });
30 } 30 }
31 31
32
32 function tinymceSetup(editor) { 33 function tinymceSetup(editor) {
33 editor.ui.registry.addButton('styleCode', { 34
34 text: 'code', 35 editor.ui.registry.addToggleButton('styleCode', {
35 onAction: () => alert('Button clicked!') 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 }
36 }); 59 });
37 } 60 }
38 61
39 tinymce.init({ 62 tinymce.init({
40 selector: 'textarea', 63 selector: 'textarea',
41 setup: tinymceSetup, 64 setup: tinymceSetup,
42 plugins: ['link', 'image', 'media', 'lists'], 65 toolbar: 'link image media | styleCode bold italic underline strikethrough superscript styleText | blockquote numlist bullist',
66 plugins: ['link', 'image', 'media', 'lists', 'code'],
43 link_target_list: false, 67 link_target_list: false,
44 link_title: false, 68 link_title: false,
45 image_description: false, 69 image_description: false,
46 image_dimensions: false, 70 image_dimensions: false,
47 object_resizing: false, 71 object_resizing: false,
51 media_poster: false, 75 media_poster: false,
52 media_url_resolver: media_url_resolver, 76 media_url_resolver: media_url_resolver,
53 text_patterns: false, 77 text_patterns: false,
54 content_style: 'img {max-width: 500px;}', 78 content_style: 'img {max-width: 500px;}',
55 //newline_behavior: 'linebreak', 79 //newline_behavior: 'linebreak',
56 toolbar: 'link image media | styleCode bold | numlist bullist',
57 extended_valid_elements: 'b,i', 80 extended_valid_elements: 'b,i',
58 formats: { 81 formats: {
59 bold: { inline: 'b' }, 82 bold: { inline: 'b' },
60 italic: {inline: 'i'}, 83 italic: {inline: 'i'},
61 underline: {inline: 'u'}, 84 underline: {inline: 'u'},