Commit bdbe563f authored by Rebecca Blundell's avatar Rebecca Blundell Committed by Robert Lyon
Browse files

Bug 1847381: Tinymce - mathslate changes

getting mathslate to work with Tinymce 5
added new svg icon too font list as svg (fa icon)

behatnotneeded

Change-Id: I0f3cc21290896eca2bca68d6d210ed02d059e380
(cherry picked from commit 34fa16b1)
parent c2d2226e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ Version: 1.1

Changes:

 * Adjusting the config.json options for uppercase Greek letters
 * Adding the 'aria-hidden="true"' to presentation icons
 * Removed target=_blank links
 * Allowing mathslate to work under https:
Rewrote to work with Tinymce 5 as this library is not maintained.
Copy across the version used with Mahara 19.10 or later and check
the functionality is still working.
+2 −2
Original line number Diff line number Diff line
@@ -43,8 +43,8 @@ YUI().use('moodle-tinymce_mathslate-editor','moodle-tinymce_mathslate-textool',
MathJax.Hub.Queue(['Typeset',MathJax.Hub]);
var editor = new M.tinymce_mathslate.Editor('#editor',"https:./config.json");
Y.one('#editor').addClass('mathslate-tinymce');
var mathEditor = top.tinymce.activeEditor.windowManager.getParams();
mathEditor.output = function(format) { return editor.output(format); }
// Get the selected content from tinymce active editor
var activeEditorselected = parent.tinymce.activeEditor.selection.getContent({format: 'text'});
});
</script>
</head>
+2 −2
Original line number Diff line number Diff line
@@ -43,8 +43,8 @@ YUI().use('moodle-tinymce_mathslate-editor','moodle-tinymce_mathslate-textool',
MathJax.Hub.Queue(['Typeset',MathJax.Hub]);
var editor = new M.tinymce_mathslate.Editor('#editor',"http:./config.json");
Y.one('#editor').addClass('mathslate-tinymce');
var mathEditor = top.tinymce.activeEditor.windowManager.getParams();
mathEditor.output = function(format) { return editor.output(format); }
// Get the selected content from tinymce active editor
var activeEditorselected = parent.tinymce.activeEditor.selection.getContent({format: 'text'});
});
</script>
</head>
+51 −41
Original line number Diff line number Diff line
@@ -4,66 +4,76 @@
 * Copyright 2013, Daniel Thies
 * Released under LGPL License.
 *
 * Updated for Tinymce 5, Catalyst IT
 * LGPL 2019
 */

tinymce.PluginManager.add('mathslate', function(editor,url) {

        if ((typeof M === 'object') && M.mathslateURL) {
            url = M.mathslateURL;
        }

	function showDialog() {

                var cssId, linkElm, dom=editor.dom,math;

		var win, mathEditor={output: null};

		var slateurl = location.protocol == 'https:' ? '/mathslate-s.html' : '/mathslate.html';

		win = editor.windowManager.open({
		win = editor.windowManager.openUrl({
			title: "Math Editor",
			spacing: 10,
			padding: 10,
			width: 525,
			height: 500,
			url: url + slateurl,
			width: 520,
			height: 550,
			body: {
				type: 'panel',
				items: [{
					type: 'iframe',
					name: 'mathslate',
					content : url + slateurl,
					html: url + slateurl,
					type: 'object',
				}]
			},
			buttons: [
				{text: "Insert Inline", onclick: function() {
                                        editor.execCommand('mceInsertContent', 
                                            false, '\\('+
                                            mathEditor.output('tex')
                                            +'\\)');
					win.close();
                                        }
				{type: 'custom',
				text: "Insert Inline",
				name: "inline",
				primary: true,
				},
				{type: 'custom',
				text: "Insert Display",
				name: "display",
				primary: false
				},
				{text: "Insert Display", onclick: function() {
                                        editor.execCommand('mceInsertContent', 
                                            false, '\\['+
                                            mathEditor.output('tex')
                                            +'\\]');
				{type: 'cancel',
				text: "Cancel",
				name: "cancel",
				primary: false
				}
			],
			onAction: (win, details) => {
				if (details.name === 'inline') {
                    var output = jQuery('.tox-navobj iframe').contents().find('.mathslate-preview').text();
					editor.selection.setContent('\\\(' + output + '\\\)');
					win.close();
				}
				},
				{text: "Cancel", onclick: function() {
				if (details.name === 'display') {
                    var output = jQuery('.tox-navobj iframe').contents().find('.mathslate-preview').text();
					editor.selection.setContent('\\\[' + output + '\\\]');
					win.close();
				}
				if (details.name === 'cancel') {
					win.close();
				}
			]
			},
                mathEditor
                );
		});
	}

	editor.addButton('mathslate', {
                image : url + '/img/mathslate.png',
	editor.ui.registry.addButton('mathslate', {
                path : url + '/img/mathslate.png',
		tooltip: 'Insert Math',
		onclick: showDialog
		onAction: showDialog,
		icon: 'mathslate'
	});

	editor.addMenuItem('mathslate', {
                image : url + '/img/mathslate.png',
	editor.ui.registry.addMenuItem('mathslate', {
		text: 'Insert Math',
		onclick: showDialog,
		onAction: showDialog,
		context: 'insert'
	});
});
+2 −1
Original line number Diff line number Diff line
@@ -12918,7 +12918,8 @@
        'user': '<svg width="24" height="24"><path d="M12 24a12 12 0 1 1 0-24 12 12 0 0 1 0 24zm-8.7-5.3a11 11 0 0 0 17.4 0C19.4 16.3 14.6 15 12 15c-2.6 0-7.4 1.3-8.7 3.7zM12 13c2.2 0 4-2 4-4.5S14.2 4 12 4 8 6 8 8.5 9.8 13 12 13z" fill-rule="nonzero"/></svg>',
        'warning': '<svg width="24" height="24"><path d="M19.8 18.3c.2.5.3.9 0 1.2-.1.3-.5.5-1 .5H5.2c-.5 0-.9-.2-1-.5-.3-.3-.2-.7 0-1.2L11 4.7l.5-.5.5-.2c.2 0 .3 0 .5.2.2 0 .3.3.5.5l6.8 13.6zM12 18c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7a1 1 0 0 0-.3-.7 1 1 0 0 0-.7-.3 1 1 0 0 0-.7.3 1 1 0 0 0-.3.7c0 .3.1.5.3.7.2.2.4.3.7.3zm.7-3l.3-4a1 1 0 0 0-.3-.7 1 1 0 0 0-.7-.3 1 1 0 0 0-.7.3 1 1 0 0 0-.3.7l.3 4h1.4z" fill-rule="evenodd"/></svg>',
        'zoom-in': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-1-9a1 1 0 0 1 2 0v6a1 1 0 0 1-2 0V8zm-2 4a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2H8z" fill-rule="nonzero"/></svg>',
        'zoom-out': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-3-5a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2H8z" fill-rule="nonzero"/></svg>'
        'zoom-out': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12zm-3-5a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2H8z" fill-rule="nonzero"/></svg>',
        'mathslate': '<svg width="25" height="25" viewBox="0 -200 900 900"><path fill-rule="nonzero" d="M571.31 251.31l-22.62-22.62c-6.25-6.25-16.38-6.25-22.63 0L480 274.75l-46.06-46.06c-6.25-6.25-16.38-6.25-22.63 0l-22.62 22.62c-6.25 6.25-6.25 16.38 0 22.63L434.75 320l-46.06 46.06c-6.25 6.25-6.25 16.38 0 22.63l22.62 22.62c6.25 6.25 16.38 6.25 22.63 0L480 365.25l46.06 46.06c6.25 6.25 16.38 6.25 22.63 0l22.62-22.62c6.25-6.25 6.25-16.38 0-22.63L525.25 320l46.06-46.06c6.25-6.25 6.25-16.38 0-22.63zM552 0H307.65c-14.54 0-27.26 9.8-30.95 23.87l-84.79 322.8-58.41-106.1A32.008 32.008 0 0 0 105.47 224H24c-13.25 0-24 10.74-24 24v48c0 13.25 10.75 24 24 24h43.62l88.88 163.73C168.99 503.5 186.3 512 204.94 512c17.27 0 44.44-9 54.28-41.48L357.03 96H552c13.25 0 24-10.75 24-24V24c0-13.26-10.75-24-24-24z"></path></svg>'
      };
    };