@oat-sa/tao-core-ui 1.67.0 → 1.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/ckeditor/ckConfigurator.js +10 -1
  2. package/dist/maths/calculator/basicCalculator.js +4 -4
  3. package/dist/maths/calculator/calculatorComponent.js +22 -25
  4. package/dist/maths/calculator/core/board.js +12329 -720
  5. package/dist/maths/calculator/core/labels.js +7924 -138
  6. package/dist/maths/calculator/core/plugin.js +4 -5
  7. package/dist/maths/calculator/css/calculator.css +18 -5
  8. package/dist/maths/calculator/css/calculator.css.map +1 -1
  9. package/dist/maths/calculator/defaultCalculator.js +10 -6
  10. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +23 -25
  11. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7979 -194
  12. package/dist/maths/calculator/scientificCalculator.js +7 -12
  13. package/package.json +5 -7
  14. package/src/ckeditor/ckConfigurator.js +11 -4
  15. package/src/maths/calculator/basicCalculator.js +1 -4
  16. package/src/maths/calculator/calculatorComponent.js +49 -60
  17. package/src/maths/calculator/core/board.js +372 -493
  18. package/src/maths/calculator/core/labels.js +46 -48
  19. package/src/maths/calculator/core/plugin.js +3 -5
  20. package/src/maths/calculator/core/tpl/terms.tpl +7 -1
  21. package/src/maths/calculator/css/calculator.css +18 -5
  22. package/src/maths/calculator/css/calculator.css.map +1 -1
  23. package/src/maths/calculator/defaultCalculator.js +7 -9
  24. package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +3 -3
  25. package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +17 -20
  26. package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +102 -108
  27. package/src/maths/calculator/scientificCalculator.js +2 -10
  28. package/src/maths/calculator/scss/calculator.scss +14 -1
  29. package/src/maths/calculator/tpl/basicKeyboard.tpl +3 -3
  30. package/src/maths/calculator/tpl/scientificKeyboard.tpl +4 -4
  31. package/dist/maths/calculator/core/areaBroker.js +0 -43
  32. package/dist/maths/calculator/core/expression.js +0 -463
  33. package/dist/maths/calculator/core/terms.js +0 -456
  34. package/dist/maths/calculator/core/tokenizer.js +0 -229
  35. package/dist/maths/calculator/core/tokens.js +0 -167
  36. package/dist/maths/calculator/plugins/core/degrad.js +0 -71
  37. package/dist/maths/calculator/plugins/core/history.js +0 -149
  38. package/dist/maths/calculator/plugins/core/remind.js +0 -76
  39. package/dist/maths/calculator/plugins/core/stepNavigation.js +0 -148
  40. package/dist/maths/calculator/plugins/modifiers/pow10.js +0 -136
  41. package/dist/maths/calculator/plugins/modifiers/sign.js +0 -314
  42. package/dist/maths/calculator/pluginsLoader.js +0 -47
  43. package/src/maths/calculator/core/areaBroker.js +0 -38
  44. package/src/maths/calculator/core/expression.js +0 -430
  45. package/src/maths/calculator/core/terms.js +0 -459
  46. package/src/maths/calculator/core/tokenizer.js +0 -245
  47. package/src/maths/calculator/core/tokens.js +0 -178
  48. package/src/maths/calculator/plugins/core/degrad.js +0 -90
  49. package/src/maths/calculator/plugins/core/history.js +0 -166
  50. package/src/maths/calculator/plugins/core/remind.js +0 -96
  51. package/src/maths/calculator/plugins/core/stepNavigation.js +0 -175
  52. package/src/maths/calculator/plugins/modifiers/pow10.js +0 -143
  53. package/src/maths/calculator/plugins/modifiers/sign.js +0 -339
  54. package/src/maths/calculator/pluginsLoader.js +0 -46
@@ -1,178 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2019 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
20
- */
21
- import registeredTerms from 'ui/maths/calculator/core/terms';
22
-
23
- /**
24
- * List of helpers that apply on tokens
25
- * @type {Object}
26
- */
27
- var tokensHelper = {
28
- /**
29
- * Identifies the type of a given token
30
- * @param {String|Object} token
31
- * @returns {String|null}
32
- */
33
- getType: function getType(token) {
34
- var type, term;
35
- if ('string' !== typeof token) {
36
- type = (token && token.type) || null;
37
- term = registeredTerms[type];
38
- return (term && term.type) || type;
39
- }
40
- return token;
41
- },
42
-
43
- /**
44
- * Checks if the type is related to a digit value
45
- * @param {String|Object} type
46
- * @returns {Boolean}
47
- */
48
- isDigit: function isDigit(type) {
49
- return tokensHelper.getType(type) === 'digit';
50
- },
51
-
52
- /**
53
- * Checks if the type is related to an operator
54
- * @param {String|Object} type
55
- * @returns {Boolean}
56
- */
57
- isOperator: function isOperator(type) {
58
- return tokensHelper.getType(type) === 'operator';
59
- },
60
-
61
- /**
62
- * Checks if the type is related to an operand
63
- * @param {String|Object} type
64
- * @returns {Boolean}
65
- */
66
- isOperand: function isOperand(type) {
67
- type = tokensHelper.getType(type);
68
- return type !== 'operator' && type !== 'aggregator' && type !== 'separator';
69
- },
70
-
71
- /**
72
- * Checks if the type is related to an operand
73
- * @param {String|Object} type
74
- * @returns {Boolean}
75
- */
76
- isValue: function isValue(type) {
77
- type = tokensHelper.getType(type);
78
- return type === 'digit' || type === 'constant' || type === 'variable' || type === 'term' || type === 'error';
79
- },
80
-
81
- /**
82
- * Checks if the type is related to an aggregator
83
- * @param {String|Object} type
84
- * @returns {Boolean}
85
- */
86
- isAggregator: function isAggregator(type) {
87
- return tokensHelper.getType(type) === 'aggregator';
88
- },
89
-
90
- /**
91
- * Checks if the type is related to an error
92
- * @param {String|Object} type
93
- * @returns {Boolean}
94
- */
95
- isError: function isError(type) {
96
- return tokensHelper.getType(type) === 'error';
97
- },
98
-
99
- /**
100
- * Checks if the type is related to a constant
101
- * @param {String|Object} type
102
- * @returns {Boolean}
103
- */
104
- isConstant: function isConstant(type) {
105
- return tokensHelper.getType(type) === 'constant';
106
- },
107
-
108
- /**
109
- * Checks if the type is related to a variable
110
- * @param {String|Object} type
111
- * @returns {Boolean}
112
- */
113
- isVariable: function isVariable(type) {
114
- type = tokensHelper.getType(type);
115
- return type === 'variable' || type === 'term';
116
- },
117
-
118
- /**
119
- * Checks if the type is related to a function
120
- * @param {String|Object} type
121
- * @returns {Boolean}
122
- */
123
- isFunction: function isFunction(type) {
124
- return tokensHelper.getType(type) === 'function';
125
- },
126
-
127
- /**
128
- * Checks if the type is related to an identifier
129
- * @param {String|Object} type
130
- * @returns {Boolean}
131
- */
132
- isIdentifier: function isIdentifier(type) {
133
- type = tokensHelper.getType(type);
134
- return type === 'constant' || type === 'variable' || type === 'term' || type === 'function' || type === 'error';
135
- },
136
-
137
- /**
138
- * Checks if the type is related to a separator
139
- * @param {String|Object} type
140
- * @returns {Boolean}
141
- */
142
- isSeparator: function isSeparator(type) {
143
- type = tokensHelper.getType(type);
144
- return type === 'operator' || type === 'aggregator' || type === 'separator';
145
- },
146
-
147
- /**
148
- * Checks if the type is related to a modifier
149
- * @param {String|Object} type
150
- * @returns {Boolean}
151
- */
152
- isModifier: function isModifier(type) {
153
- type = tokensHelper.getType(type);
154
- return type === 'operator' || type === 'function';
155
- },
156
-
157
- /**
158
- * Ensures an expression is a string. If a token or a descriptor is provided, extract the value.
159
- * @param {String|Number|Object} expression
160
- * @returns {String}
161
- */
162
- stringValue: function stringValue(expression) {
163
- var type = typeof expression;
164
- if (type !== 'string') {
165
- if (expression && 'undefined' !== typeof expression.value) {
166
- expression = expression.value;
167
- } else if (expression && 'undefined' !== typeof expression.result) {
168
- expression = expression.result;
169
- } else if (type === 'object' || type === 'undefined' || expression === null) {
170
- expression = '';
171
- }
172
- expression = String(expression);
173
- }
174
- return expression;
175
- }
176
- };
177
-
178
- export default tokensHelper;
@@ -1,90 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that switch mode between degree and radian in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
- import __ from 'i18n';
23
- import nsHelper from 'util/namespace';
24
- import pluginFactory from 'ui/maths/calculator/core/plugin';
25
-
26
- var pluginName = 'degrad';
27
-
28
- export default pluginFactory({
29
- name: pluginName,
30
-
31
- /**
32
- * Called when the plugin is installing in its host.
33
- */
34
- install: function install() {
35
- var calculator = this.getCalculator();
36
-
37
- calculator
38
- .setCommand('degree', __('Degree'), __('Set the trigonometric function to work in degrees'))
39
- .setCommand('radian', __('Radian'), __('Set the trigonometric function to work in radians'));
40
- },
41
-
42
- /**
43
- * Called when the plugin should be initialized.
44
- */
45
- init: function init() {
46
- var calculator = this.getCalculator();
47
-
48
- function getMathsConfig() {
49
- var config = calculator.getConfig();
50
- if (!config.maths) {
51
- config.maths = {};
52
- }
53
- return config.maths;
54
- }
55
-
56
- function setupMathsEvaluator() {
57
- var config = calculator.getConfig();
58
- var degree = config.maths && config.maths.degree;
59
- calculator
60
- .setState('degree', degree)
61
- .setState('radian', !degree)
62
- .setupMathsEvaluator();
63
- }
64
-
65
- setupMathsEvaluator();
66
-
67
- calculator
68
- .on(nsHelper.namespaceAll('command-degree', pluginName), function() {
69
- getMathsConfig().degree = true;
70
- setupMathsEvaluator();
71
- })
72
- .on(nsHelper.namespaceAll('command-radian', pluginName), function() {
73
- getMathsConfig().degree = false;
74
- setupMathsEvaluator();
75
- });
76
- },
77
-
78
- /**
79
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
80
- */
81
- destroy: function destroy() {
82
- var calculator = this.getCalculator();
83
- calculator
84
- .deleteCommand('degree')
85
- .deleteCommand('radian')
86
- .setState('degree', false)
87
- .setState('radian', false)
88
- .off('.' + pluginName);
89
- }
90
- });
@@ -1,166 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that manages an history of evaluated expressions in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
- import _ from 'lodash';
23
- import __ from 'i18n';
24
- import nsHelper from 'util/namespace';
25
- import pluginFactory from 'ui/maths/calculator/core/plugin';
26
-
27
- var pluginName = 'history';
28
-
29
- /**
30
- * Defines an entry in the history
31
- * @typedef {Object} historyEntry
32
- * @property {String} expression - The expression that has been extracted when the entry was created
33
- * @property {Object} variables - The list of variables that has been extracted when the entry was created
34
- * @property {String} [current] - The current edited expression if the entry is modified
35
- */
36
-
37
- export default pluginFactory({
38
- name: pluginName,
39
-
40
- /**
41
- * Called when the plugin is installing in its host.
42
- */
43
- install: function install() {
44
- var calculator = this.getCalculator();
45
-
46
- calculator
47
- .setCommand('historyClear', __('Clear History'), __('Clear history'))
48
- .setCommand('historyGet', __('Get History'), __('Get the history list'))
49
- .setCommand('historyUp', __('Previous'), __('Remind the previous expression in the history'))
50
- .setCommand('historyDown', __('Next'), __('Remind the next expression in the history'));
51
- },
52
-
53
- /**
54
- * Called when the plugin should be initialized.
55
- */
56
- init: function init() {
57
- var calculator = this.getCalculator();
58
- var history, cursor, current;
59
-
60
- /**
61
- * Creates an entry from the current state
62
- * @returns {historyEntry}
63
- */
64
- function getCurrentState() {
65
- return {
66
- expression: calculator.getExpression(),
67
- variables: calculator.getVariables(),
68
- current: null
69
- };
70
- }
71
-
72
- /**
73
- * Clears the entire history
74
- */
75
- function reset() {
76
- current = getCurrentState();
77
- history = [];
78
- cursor = 0;
79
- }
80
-
81
- /**
82
- * Retrieves a memory entry in the history
83
- * @param {Number} position
84
- * @returns {Object|null}
85
- */
86
- function getMemoryAt(position) {
87
- if (position >= 0 && position < history.length) {
88
- return history[position];
89
- } else if (position === history.length) {
90
- return current;
91
- }
92
- return null;
93
- }
94
-
95
- /**
96
- * Reminds an expression from the history
97
- * @param {Number} position
98
- */
99
- function remind(position) {
100
- var memory = getMemoryAt(position);
101
-
102
- // keep the current expression in the memory, in case the user goes back to it
103
- if (cursor === history.length && position !== cursor) {
104
- current = getCurrentState();
105
- } else {
106
- history[cursor].current = calculator.getExpression();
107
- }
108
-
109
- // restore an expression from the history at the wanted position
110
- if (memory) {
111
- cursor = position;
112
- if (memory.variables) {
113
- calculator.setVariables(memory.variables);
114
- }
115
- calculator.replace(memory.current || memory.expression);
116
- memory.current = null;
117
- }
118
- }
119
-
120
- /**
121
- * Adds a memory entry in the history from the current expression
122
- */
123
- function push() {
124
- var last = getMemoryAt(history.length - 1);
125
- var memory = getMemoryAt(cursor);
126
- if (!last || calculator.getExpression() !== last.expression) {
127
- history.push(getCurrentState());
128
- }
129
- if (memory) {
130
- memory.current = null;
131
- }
132
- cursor = history.length;
133
- }
134
-
135
- reset();
136
- calculator
137
- .on(nsHelper.namespaceAll('evaluate', pluginName), push)
138
- .on(nsHelper.namespaceAll('command-historyClear command-clearAll destroy', pluginName), reset)
139
- .on(nsHelper.namespaceAll('command-historyUp', pluginName), function() {
140
- remind(cursor - 1);
141
- })
142
- .on(nsHelper.namespaceAll('command-historyDown', pluginName), function() {
143
- remind(cursor + 1);
144
- })
145
- .on(nsHelper.namespaceAll('command-historyGet', pluginName), function() {
146
- /**
147
- * @event history
148
- * @param {Array} history - The current history list
149
- */
150
- calculator.trigger('history', _.map(history, 'expression'));
151
- });
152
- },
153
-
154
- /**
155
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
156
- */
157
- destroy: function destroy() {
158
- var calculator = this.getCalculator();
159
- calculator
160
- .deleteCommand('historyClear')
161
- .deleteCommand('historyUp')
162
- .deleteCommand('historyDown')
163
- .deleteCommand('historyGet')
164
- .off('.' + pluginName);
165
- }
166
- });
@@ -1,96 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that manages a simple value reminder in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
-
23
- import __ from 'i18n';
24
- import nsHelper from 'util/namespace';
25
- import pluginFactory from 'ui/maths/calculator/core/plugin';
26
-
27
- var pluginName = 'remind';
28
- var varRemindName = 'mem';
29
- var varLastName = 'last';
30
-
31
- export default pluginFactory({
32
- name: pluginName,
33
-
34
- /**
35
- * Called when the plugin is installing in its host.
36
- */
37
- install: function install() {
38
- var calculator = this.getCalculator();
39
-
40
- calculator
41
- .setCommand('remind', __('Remind'), __('Remind the recorded value'))
42
- .setCommand('remindLast', __('Remind Last'), __('Remind the last value'))
43
- .setCommand('remindStore', __('Store'), __('Store the value a variable'))
44
- .setCommand('remindClear', __('Clear'), __('Clear the stored variables'));
45
- },
46
-
47
- /**
48
- * Called when the plugin should be initialized.
49
- */
50
- init: function init() {
51
- var calculator = this.getCalculator();
52
-
53
- calculator
54
- .on(nsHelper.namespaceAll('evaluate', pluginName), function(result) {
55
- calculator.setVariable(varLastName, result);
56
- })
57
- .on(nsHelper.namespaceAll('command-remind', pluginName), function() {
58
- if (calculator.hasVariable(varRemindName)) {
59
- calculator.useVariable(varRemindName);
60
- }
61
- })
62
- .on(nsHelper.namespaceAll('command-remindLast', pluginName), function() {
63
- if (calculator.hasVariable(varLastName)) {
64
- calculator.useVariable(varLastName);
65
- }
66
- })
67
- .on(nsHelper.namespaceAll('command-remindStore', pluginName), function() {
68
- if (calculator.hasVariable(varLastName)) {
69
- calculator.setVariable(varRemindName, calculator.getVariable(varLastName));
70
- }
71
- })
72
- .on(nsHelper.namespaceAll('command-remindClear command-clearAll destroy', pluginName), function() {
73
- if (calculator.hasVariable(varRemindName)) {
74
- calculator.deleteVariable(varRemindName);
75
- }
76
- })
77
- .on(nsHelper.namespaceAll('destroy', pluginName), function() {
78
- if (calculator.hasVariable(varLastName)) {
79
- calculator.deleteVariable(varLastName);
80
- }
81
- });
82
- },
83
-
84
- /**
85
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
86
- */
87
- destroy: function destroy() {
88
- var calculator = this.getCalculator();
89
- calculator
90
- .deleteCommand('remind')
91
- .deleteCommand('remindLast')
92
- .deleteCommand('remindStore')
93
- .deleteCommand('remindClear')
94
- .off('.' + pluginName);
95
- }
96
- });