changeset 24:fccbe5554fcc

tinymce work
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 19 Jul 2022 22:07:02 -0600
parents cdcd1b70c15e
children 66fd3784e60e
files src/test/tiny.html
diffstat 1 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
diff -r cdcd1b70c15e -r fccbe5554fcc src/test/tiny.html
--- a/src/test/tiny.html	Mon Jul 18 23:50:48 2022 -0600
+++ b/src/test/tiny.html	Tue Jul 19 22:07:02 2022 -0600
@@ -2,7 +2,7 @@
 <html>
 	<head>
 		<meta name="viewport" content="width=device-width, initial-scale=1">
-		<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
+		<script src="http://tinymce.luan.software/tinymce.min.js" xreferrerpolicy="origin"></script>
 		<style>
 		</style>
 		<script>
@@ -29,17 +29,41 @@
 				resolve({ html: html });
 			}
 
+
 			function tinymceSetup(editor) {
-				editor.ui.registry.addButton('styleCode', {
-					text: 'code',
-					onAction: () => alert('Button clicked!')
+
+				editor.ui.registry.addToggleButton('styleCode', {
+					//text: 'code',
+					icon: 'sourcecode',
+					tooltip: 'Code',
+					onAction: function(api) {
+						editor.execCommand('mceToggleFormat', false, 'code')
+						//api.setActive( !api.isActive() );
+					},
+					onSetup: function(api) {
+						api.setActive(editor.formatter.match('code'));
+						let changed = editor.formatter.formatChanged('code', api.setActive);
+						return function() { changed.unbind(); };
+					}
+				});
+
+				editor.ui.registry.addMenuButton('styleText', {
+					icon: 'format',
+					tooltip: 'Text',
+					fetch: function(callback) {
+						callback([
+							'fontsize',
+							'forecolor',
+						])
+					}
 				});
 			}
 
 			tinymce.init({
 				selector: 'textarea',
 				setup: tinymceSetup,
-				plugins: ['link', 'image', 'media', 'lists'],
+				toolbar: 'link image media | styleCode bold italic underline strikethrough superscript styleText | blockquote numlist bullist',
+				plugins: ['link', 'image', 'media', 'lists', 'code'],
 				link_target_list: false,
 				link_title: false,
 				image_description: false,
@@ -53,7 +77,6 @@
 				text_patterns: false,
 				content_style: 'img {max-width: 500px;}',
 				//newline_behavior: 'linebreak',
-				toolbar: 'link image media | styleCode bold | numlist bullist',
 				extended_valid_elements: 'b,i',
 				formats: {
 					bold: { inline: 'b' },