1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Options helper for Tiny Equation plugin.
|
|
|
18 |
*
|
|
|
19 |
* @module tiny_equation/options
|
|
|
20 |
* @copyright 2022 Huong Nguyen <huongnv13@gmail.com>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
import {getPluginOptionName} from 'editor_tiny/options';
|
|
|
25 |
import {pluginName} from 'tiny_equation/common';
|
|
|
26 |
|
|
|
27 |
const librariesName = getPluginOptionName(pluginName, 'libraries');
|
|
|
28 |
const texFilterName = getPluginOptionName(pluginName, 'texfilter');
|
|
|
29 |
const contextIdName = getPluginOptionName(pluginName, 'contextid');
|
|
|
30 |
const texDocsUrlName = getPluginOptionName(pluginName, 'texdocsurl');
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Register the options for the Tiny Equation plugin.
|
|
|
34 |
*
|
|
|
35 |
* @param {TinyMCE} editor
|
|
|
36 |
*/
|
|
|
37 |
export const register = (editor) => {
|
|
|
38 |
const registerOption = editor.options.register;
|
|
|
39 |
|
|
|
40 |
registerOption(librariesName, {
|
|
|
41 |
processor: 'array',
|
|
|
42 |
"default": [],
|
|
|
43 |
});
|
|
|
44 |
|
|
|
45 |
registerOption(texFilterName, {
|
|
|
46 |
processor: 'boolean',
|
|
|
47 |
"default": false,
|
|
|
48 |
});
|
|
|
49 |
|
|
|
50 |
registerOption(contextIdName, {
|
|
|
51 |
processor: 'number',
|
|
|
52 |
"default": 0,
|
|
|
53 |
});
|
|
|
54 |
|
|
|
55 |
registerOption(texDocsUrlName, {
|
|
|
56 |
processor: 'string',
|
|
|
57 |
"default": '',
|
|
|
58 |
});
|
|
|
59 |
};
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Get the libraries configuration for the Tiny Equation plugin.
|
|
|
63 |
*
|
|
|
64 |
* @param {TinyMCE} editor
|
|
|
65 |
* @returns {object}
|
|
|
66 |
*/
|
|
|
67 |
export const getLibraries = (editor) => editor.options.get(librariesName);
|
|
|
68 |
/**
|
|
|
69 |
* Check if the TEX filter is active or not for the Tiny Equation plugin.
|
|
|
70 |
*
|
|
|
71 |
* @param {TinyMCE} editor
|
|
|
72 |
* @returns {boolean}
|
|
|
73 |
*/
|
|
|
74 |
export const isTexFilterActive = (editor) => editor.options.get(texFilterName);
|
|
|
75 |
/**
|
|
|
76 |
* Get the context id for the Tiny Equation plugin.
|
|
|
77 |
*
|
|
|
78 |
* @param {TinyMCE} editor
|
|
|
79 |
* @returns {number}
|
|
|
80 |
*/
|
|
|
81 |
export const getContextId = (editor) => editor.options.get(contextIdName);
|
|
|
82 |
/**
|
|
|
83 |
* Get the Tex Docs Url for the Tiny Equation plugin.
|
|
|
84 |
*
|
|
|
85 |
* @param {TinyMCE} editor
|
|
|
86 |
* @returns {string}
|
|
|
87 |
*/
|
|
|
88 |
export const getTexDocsUrl = (editor) => editor.options.get(texDocsUrlName);
|