-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmatheditor.php
64 lines (52 loc) · 2.58 KB
/
matheditor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* *************************************************************************
* * MathEditor **
* *************************************************************************
* @package tinymce **
* @subpackage matheditor **
* @name MathEditor **
* @copyright oohoo.biz **
* @link http://oohoo.biz **
* @author Raymond Wainman ([email protected]) **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
define('NO_MOODLE_COOKIES', true); // Session not used here.
require(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php');
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/editor/tinymce/plugins/matheditor/matheditor.php');
$PAGE->requires->jquery();
$PAGE->set_title(get_string('matheditor:desc', 'tinymce_matheditor'));
$PAGE->set_pagelayout('popup');
$editor = get_texteditor('tinymce');
$plugin = $editor->get_plugin('matheditor');
$PAGE->requires->js(new moodle_url($editor->get_tinymce_base_url().'/tiny_mce_popup.js'));
$PAGE->requires->js(new moodle_url($plugin->get_tinymce_file_url('js/mathquill.min.js')));
$PAGE->requires->css(new moodle_url($plugin->get_tinymce_file_url('css/mathquill.css')));
$PAGE->requires->css(new moodle_url($plugin->get_tinymce_file_url('css/matheditor.css')));
$PAGE->requires->css(new moodle_url($plugin->get_tinymce_file_url('css/matheditor_tinymce.css')));
$PAGE->requires->js(new moodle_url($plugin->get_tinymce_file_url('js/matheditor.js')));
echo $OUTPUT->header();
?>
<div id="editor">
</div>
<script type="text/javascript">
(function() {
$(document).ready(function() {
var tinyMceEditor = tinymce.activeEditor;
// Callback function when the user clicks the insert button
var insertHandler = function(latex) {
tinyMceEditor.execCommand('mathEditorInsert', latex);
tinyMCEPopup.close();
};
var editor = new MathEditor('#editor', tinyMceEditor, insertHandler);
var latex = tinyMCEPopup.getWindowArg('latex');
editor.setLatex(latex);
console.log(MathJax);
});
})();
</script>
<?php
echo $OUTPUT->footer();
?>