@pie-element/ebsr 7.0.22 → 7.0.24-next.2

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 (144) hide show
  1. package/CHANGELOG.md +0 -16
  2. package/configure/CHANGELOG.md +0 -16
  3. package/configure/lib/main.js +6 -4
  4. package/configure/lib/main.js.map +1 -1
  5. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
  6. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +1793 -0
  7. package/{LICENSE.md → configure/node_modules/@pie-element/multiple-choice/LICENSE.md} +0 -0
  8. package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
  9. package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
  10. package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
  11. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
  12. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +1334 -0
  13. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +104 -0
  14. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
  15. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +198 -0
  16. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +599 -0
  18. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
  20. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
  22. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
  23. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +768 -0
  24. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +18 -0
  25. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
  26. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +305 -0
  27. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
  28. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +36 -0
  29. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
  30. package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
  31. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +353 -0
  32. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +277 -0
  33. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
  34. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +52 -0
  35. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
  36. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
  37. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +338 -0
  38. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +274 -0
  39. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +298 -0
  40. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
  41. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +157 -0
  42. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
  43. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
  44. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
  45. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +151 -0
  46. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
  47. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +97 -0
  48. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
  49. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +254 -0
  50. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
  52. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +35 -0
  54. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +843 -0
  56. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/controller.js +17304 -17374
  57. package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +77 -0
  58. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/element.js +42 -171
  59. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/index.html +1 -1
  60. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/manifest.json +4 -4
  61. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print-demo.js +46 -46
  62. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.html +1 -1
  63. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.js +70 -259
  64. package/configure/node_modules/@pie-element/multiple-choice/package.json +34 -0
  65. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +672 -0
  66. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +427 -0
  67. package/configure/node_modules/@pie-lib/math-rendering/LICENSE.md +5 -0
  68. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +30 -0
  69. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
  70. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +316 -0
  71. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
  72. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
  73. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
  74. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +123 -0
  75. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
  76. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +103 -0
  77. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
  78. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +275 -0
  79. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
  80. package/configure/node_modules/@pie-lib/math-rendering/package.json +19 -0
  81. package/configure/node_modules/@pie-lib/math-rendering/playground/demo.html +872 -0
  82. package/configure/node_modules/@pie-lib/math-rendering/playground/demo.js +108 -0
  83. package/configure/node_modules/@pie-lib/math-rendering/playground/main.html +156 -0
  84. package/configure/node_modules/@pie-lib/math-rendering/playground/main.js +16 -0
  85. package/configure/node_modules/@pie-lib/math-rendering/playground/webpack.config.js +29 -0
  86. package/configure/node_modules/@pie-lib/math-rendering/src/index.js +4 -0
  87. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +215 -0
  88. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
  89. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
  90. package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
  91. package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +234 -0
  92. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +937 -0
  93. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +602 -0
  94. package/configure/node_modules/@pie-lib/render-ui/LICENSE.md +5 -0
  95. package/configure/node_modules/@pie-lib/render-ui/README.md +33 -0
  96. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +146 -0
  97. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
  98. package/configure/node_modules/@pie-lib/render-ui/lib/color.js +134 -0
  99. package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
  100. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +160 -0
  101. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
  102. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +24 -0
  103. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
  104. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +102 -0
  105. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
  106. package/configure/node_modules/@pie-lib/render-ui/lib/index.js +104 -0
  107. package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
  108. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
  109. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
  110. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +133 -0
  111. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
  112. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +162 -0
  113. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
  114. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
  115. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
  116. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
  117. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
  118. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +160 -0
  119. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
  120. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +206 -0
  121. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
  122. package/configure/node_modules/@pie-lib/render-ui/package.json +30 -0
  123. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +68 -0
  124. package/configure/node_modules/@pie-lib/render-ui/src/color.js +48 -0
  125. package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +100 -0
  126. package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +14 -0
  127. package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +40 -0
  128. package/configure/node_modules/@pie-lib/render-ui/src/index.js +27 -0
  129. package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
  130. package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +77 -0
  131. package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +90 -0
  132. package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +19 -0
  133. package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
  134. package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
  135. package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +118 -0
  136. package/configure/package.json +3 -3
  137. package/configure/src/__tests__/index.test.js +4 -2
  138. package/configure/src/main.jsx +8 -3
  139. package/controller/lib/index.js +79 -3
  140. package/controller/lib/index.js.map +1 -1
  141. package/controller/src/index.js +55 -0
  142. package/package.json +3 -3
  143. package/module/configure.js +0 -472
  144. package/module/demo.js +0 -77
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getStackData = exports.Row = exports.Line = exports.CHTMLmstack = void 0;
9
+
10
+ var _Wrapper = require("mathjax-full/js/output/chtml/Wrapper");
11
+
12
+ var _lodash = _interopRequireDefault(require("lodash"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
+
18
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
+
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
+
22
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
+
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+
26
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
+
28
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
+
30
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
31
+
32
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
+
34
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
+
36
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
37
+
38
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
39
+
40
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
41
+
42
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
43
+
44
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
45
+
46
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
47
+
48
+ var reduceText = function reduceText(acc, n) {
49
+ if (n.node && n.node.kind === 'text') {
50
+ acc += n.node.text;
51
+ }
52
+
53
+ return acc;
54
+ };
55
+
56
+ var Line = /*#__PURE__*/function () {
57
+ function Line() {
58
+ _classCallCheck(this, Line);
59
+
60
+ this.kind = 'line';
61
+ }
62
+
63
+ _createClass(Line, [{
64
+ key: "columns",
65
+ get: function get() {
66
+ return [];
67
+ }
68
+ }]);
69
+
70
+ return Line;
71
+ }();
72
+
73
+ exports.Line = Line;
74
+
75
+ var Row = /*#__PURE__*/function () {
76
+ function Row(columns, operator) {
77
+ _classCallCheck(this, Row);
78
+
79
+ this.kind = 'row';
80
+ this.operator = operator;
81
+ this.columns = columns;
82
+ }
83
+
84
+ _createClass(Row, [{
85
+ key: "pad",
86
+ value: function pad(count) {
87
+ var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'right';
88
+
89
+ if (count < this.columns.length) {
90
+ throw new Error('no');
91
+ }
92
+
93
+ var diff = count - this.columns.length;
94
+
95
+ var padding = _lodash["default"].times(diff).map(function (n) {
96
+ return '__pad__';
97
+ });
98
+
99
+ return direction === 'right' ? [].concat(_toConsumableArray(padding), _toConsumableArray(this.columns)) : [].concat(_toConsumableArray(this.columns), _toConsumableArray(padding));
100
+ }
101
+ }]);
102
+
103
+ return Row;
104
+ }();
105
+
106
+ exports.Row = Row;
107
+
108
+ var mathNodeToCharArray = function mathNodeToCharArray(mn) {
109
+ var text = mn.childNodes.reduce(reduceText, '');
110
+ return text.split('');
111
+ };
112
+ /**
113
+ * Convert child a column entry
114
+ * @param {*} child
115
+ * @return an array of column content
116
+ */
117
+
118
+
119
+ var toColumnArray = function toColumnArray(child) {
120
+ if (!child || !child.kind) {
121
+ return [];
122
+ }
123
+
124
+ if (child.kind === 'msrow') {
125
+ throw new Error('msrow in msrow?');
126
+ }
127
+
128
+ if (child.kind === 'mo') {
129
+ // We are going to treat this operator as a text array.
130
+ // It's probably going to be a decimal point
131
+ console.warn('mo that is not 1st node in msrow?');
132
+ return mathNodeToCharArray(child); // throw new Error('mo must be first child of msrow');
133
+ }
134
+
135
+ if (child.kind === 'mn') {
136
+ return mathNodeToCharArray(child);
137
+ }
138
+
139
+ if (child.toCHTML) {
140
+ return child;
141
+ }
142
+ };
143
+ /**
144
+ * convert mstack chtml childNodes into a Row
145
+ * @param child chtml child node of mstack
146
+ * @return Row | Line
147
+ */
148
+
149
+
150
+ var rowStack = function rowStack(child) {
151
+ if (!child || !child.kind) {
152
+ return;
153
+ }
154
+
155
+ if (child.kind === 'msrow') {
156
+ if (!child.childNodes || child.childNodes.length === 0) {
157
+ return new Row([]);
158
+ }
159
+
160
+ var f = _lodash["default"].first(child.childNodes);
161
+
162
+ var nodes = f && f.kind === 'mo' ? _lodash["default"].tail(child.childNodes) : child.childNodes;
163
+
164
+ var columns = _lodash["default"].flatten(nodes.map(toColumnArray));
165
+
166
+ return new Row(columns, f.kind === 'mo' ? f : undefined);
167
+ }
168
+
169
+ if (child.kind === 'mn') {
170
+ var _columns = mathNodeToCharArray(child);
171
+
172
+ return new Row(_columns, undefined);
173
+ }
174
+
175
+ if (child.kind === 'mo') {
176
+ console.warn('mo on its own row?');
177
+ return new Row([], child);
178
+ }
179
+
180
+ if (child.kind === 'msline') {
181
+ return new Line();
182
+ }
183
+
184
+ if (child.toCHTML) {
185
+ return new Row([child]);
186
+ }
187
+ };
188
+ /** convert MathJax chtml tree to Row[]
189
+ * @param mstack the root of the mathjax chtml tree
190
+ * @return Row[]
191
+ */
192
+
193
+
194
+ var getStackData = function getStackData(mstack) {
195
+ if (!mstack || !mstack.childNodes) {
196
+ return [];
197
+ }
198
+
199
+ return _lodash["default"].compact(mstack.childNodes.map(rowStack));
200
+ };
201
+
202
+ exports.getStackData = getStackData;
203
+
204
+ var CHTMLmstack = /*#__PURE__*/function (_CHTMLWrapper) {
205
+ _inherits(CHTMLmstack, _CHTMLWrapper);
206
+
207
+ var _super = _createSuper(CHTMLmstack);
208
+
209
+ function CHTMLmstack(factory, node) {
210
+ var _this;
211
+
212
+ var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
213
+
214
+ _classCallCheck(this, CHTMLmstack);
215
+
216
+ _this = _super.call(this, factory, node, parent);
217
+ _this.ce = _this.adaptor.document.createElement.bind(_this.adaptor.document);
218
+ return _this;
219
+ }
220
+
221
+ _createClass(CHTMLmstack, [{
222
+ key: "toCHTML",
223
+ value: function toCHTML(parent) {
224
+ var _this2 = this;
225
+
226
+ var chtml = this.standardCHTMLnode(parent);
227
+ var stackData = getStackData(this); // console.log('stackData', stackData);
228
+
229
+ var maxCols = stackData.reduce(function (acc, r) {
230
+ if (r && r.columns.length > acc) {
231
+ acc = r.columns.length;
232
+ }
233
+
234
+ return acc;
235
+ }, 0);
236
+ var table = this.ce('table');
237
+ chtml.appendChild(table);
238
+ stackData.forEach(function (row) {
239
+ var tr = _this2.ce('tr');
240
+
241
+ table.appendChild(tr);
242
+
243
+ if (row.kind === 'row') {
244
+ var td = _this2.ce('td');
245
+
246
+ tr.appendChild(td);
247
+
248
+ if (row.operator && row.operator.toCHTML) {
249
+ td.setAttribute('class', 'inner');
250
+ row.operator.toCHTML(td);
251
+ } else {
252
+ td.textContent = '';
253
+ } // align right for now:
254
+
255
+
256
+ var cols = row.pad(maxCols, 'right');
257
+ cols.forEach(function (c) {
258
+ var t = _this2.ce('td');
259
+
260
+ tr.appendChild(t);
261
+
262
+ if (c === '__pad__') {
263
+ t.textContent = '';
264
+ } else if (typeof c === 'string') {
265
+ t.textContent = c;
266
+ } else if (c.kind === 'none') {
267
+ t.textContent = '';
268
+ } else if (c.toCHTML) {
269
+ t.setAttribute('class', 'inner');
270
+ c.toCHTML(t);
271
+ }
272
+ });
273
+ } else if (row.kind === 'line') {
274
+ var _td = _this2.ce('td');
275
+
276
+ tr.appendChild(_td);
277
+
278
+ _td.setAttribute('colspan', maxCols + 1);
279
+
280
+ _td.setAttribute('class', 'mjx-line');
281
+
282
+ _td.textContent = '';
283
+ }
284
+ });
285
+ }
286
+ }]);
287
+
288
+ return CHTMLmstack;
289
+ }(_Wrapper.CHTMLWrapper);
290
+
291
+ exports.CHTMLmstack = CHTMLmstack;
292
+ CHTMLmstack.styles = {
293
+ 'mjx-mstack > table': {
294
+ 'line-height': 'initial',
295
+ border: 'solid 0px red',
296
+ 'border-spacing': '0em',
297
+ 'border-collapse': 'separate'
298
+ },
299
+ 'mjx-mstack > table > tr': {
300
+ 'line-height': 'initial'
301
+ },
302
+ 'mjx-mstack > table > tr > td': {
303
+ // padding: '1.2rem',
304
+ border: 'solid 0px blue',
305
+ 'font-family': 'sans-serif',
306
+ 'line-height': 'initial'
307
+ },
308
+ 'mjx-mstack > table > tr > td.inner': {
309
+ 'font-family': 'inherit'
310
+ },
311
+ 'mjx-mstack > table > tr > .mjx-line': {
312
+ padding: 0,
313
+ 'border-top': 'solid 1px black'
314
+ }
315
+ };
316
+ //# sourceMappingURL=chtml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/mstack/chtml.js"],"names":["reduceText","acc","n","node","kind","text","Line","Row","columns","operator","count","direction","length","Error","diff","padding","_","times","map","mathNodeToCharArray","mn","childNodes","reduce","split","toColumnArray","child","console","warn","toCHTML","rowStack","f","first","nodes","tail","flatten","undefined","getStackData","mstack","compact","CHTMLmstack","factory","parent","ce","adaptor","document","createElement","bind","chtml","standardCHTMLnode","stackData","maxCols","r","table","appendChild","forEach","row","tr","td","setAttribute","textContent","cols","pad","c","t","CHTMLWrapper","styles","border"],"mappings":";;;;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,GAAD,EAAMC,CAAN,EAAY;AAC7B,MAAIA,CAAC,CAACC,IAAF,IAAUD,CAAC,CAACC,IAAF,CAAOC,IAAP,KAAgB,MAA9B,EAAsC;AACpCH,IAAAA,GAAG,IAAIC,CAAC,CAACC,IAAF,CAAOE,IAAd;AACD;;AACD,SAAOJ,GAAP;AACD,CALD;;IAOaK,I;AACX,kBAAc;AAAA;;AACZ,SAAKF,IAAL,GAAY,MAAZ;AACD;;;;SAED,eAAc;AACZ,aAAO,EAAP;AACD;;;;;;;;IAGUG,G;AACX,eAAYC,OAAZ,EAAqBC,QAArB,EAA+B;AAAA;;AAC7B,SAAKL,IAAL,GAAY,KAAZ;AACA,SAAKK,QAAL,GAAgBA,QAAhB;AACA,SAAKD,OAAL,GAAeA,OAAf;AACD;;;;WAED,aAAIE,KAAJ,EAAgC;AAAA,UAArBC,SAAqB,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uB;AAC5B2D,cAAAA,CAAC,CAACJ,WAAF,GAAgB,EAAhB;AACD,aAFM,MAEA,IAAIG,CAAC,CAAClC,OAAN,EAAe;AACpBmC,cAAAA,CAAC,CAACL,YAAF,CAAe,OAAf,EAAwB,OAAxB;AACAI,cAAAA,CAAC,CAAClC,OAAF,CAAUmC,CAAV;AACD;AACF,WAbD;AAcD,SA1BD,MA0BO,IAAIR,GAAG,CAACnD,IAAJ,KAAa,MAAjB,EAAyB;AAC9B,cAAMqD,GAAE,GAAG,MAAI,CAACf,EAAL,CAAQ,IAAR,CAAX;;AACAc,UAAAA,EAAE,CAACH,WAAH,CAAeI,GAAf;;AACAA,UAAAA,GAAE,CAACC,YAAH,CAAgB,SAAhB,EAA2BR,OAAO,GAAG,CAArC;;AACAO,UAAAA,GAAE,CAACC,YAAH,CAAgB,OAAhB,EAAyB,UAAzB;;AACAD,UAAAA,GAAE,CAACE,WAAH,GAAiB,EAAjB;AACD;AACF,OArCD;AAsCD;;;;EA7D8BK,qB;;;AA+DjCzB,WAAW,CAAC0B,MAAZ,GAAqB;AACnB,wBAAsB;AACpB,mBAAe,SADK;AAEpBC,IAAAA,MAAM,EAAE,eAFY;AAGpB,sBAAkB,KAHE;AAIpB,uBAAmB;AAJC,GADH;AAOnB,6BAA2B;AACzB,mBAAe;AADU,GAPR;AAUnB,kCAAgC;AAC9B;AACAA,IAAAA,MAAM,EAAE,gBAFsB;AAG9B,mBAAe,YAHe;AAI9B,mBAAe;AAJe,GAVb;AAgBnB,wCAAsC;AACpC,mBAAe;AADqB,GAhBnB;AAmBnB,yCAAuC;AACrCnD,IAAAA,OAAO,EAAE,CAD4B;AAErC,kBAAc;AAFuB;AAnBpB,CAArB","sourcesContent":["import { CHTMLWrapper } from 'mathjax-full/js/output/chtml/Wrapper';\nimport _ from 'lodash';\n\nconst reduceText = (acc, n) => {\n if (n.node && n.node.kind === 'text') {\n acc += n.node.text;\n }\n return acc;\n};\n\nexport class Line {\n constructor() {\n this.kind = 'line';\n }\n\n get columns() {\n return [];\n }\n}\n\nexport class Row {\n constructor(columns, operator) {\n this.kind = 'row';\n this.operator = operator;\n this.columns = columns;\n }\n\n pad(count, direction = 'right') {\n if (count < this.columns.length) {\n throw new Error('no');\n }\n\n const diff = count - this.columns.length;\n\n const padding = _.times(diff).map(n => '__pad__');\n return direction === 'right' ? [...padding, ...this.columns] : [...this.columns, ...padding];\n }\n}\n\nconst mathNodeToCharArray = mn => {\n const text = mn.childNodes.reduce(reduceText, '');\n return text.split('');\n};\n\n/**\n * Convert child a column entry\n * @param {*} child\n * @return an array of column content\n */\nconst toColumnArray = child => {\n if (!child || !child.kind) {\n return [];\n }\n\n if (child.kind === 'msrow') {\n throw new Error('msrow in msrow?');\n }\n\n if (child.kind === 'mo') {\n // We are going to treat this operator as a text array.\n // It's probably going to be a decimal point\n console.warn('mo that is not 1st node in msrow?');\n return mathNodeToCharArray(child);\n // throw new Error('mo must be first child of msrow');\n }\n\n if (child.kind === 'mn') {\n return mathNodeToCharArray(child);\n }\n\n if (child.toCHTML) {\n return child;\n }\n};\n\n/**\n * convert mstack chtml childNodes into a Row\n * @param child chtml child node of mstack\n * @return Row | Line\n */\nconst rowStack = child => {\n if (!child || !child.kind) {\n return;\n }\n\n if (child.kind === 'msrow') {\n if (!child.childNodes || child.childNodes.length === 0) {\n return new Row([]);\n }\n const f = _.first(child.childNodes);\n const nodes = f && f.kind === 'mo' ? _.tail(child.childNodes) : child.childNodes;\n\n const columns = _.flatten(nodes.map(toColumnArray));\n\n return new Row(columns, f.kind === 'mo' ? f : undefined);\n }\n\n if (child.kind === 'mn') {\n const columns = mathNodeToCharArray(child);\n return new Row(columns, undefined);\n }\n\n if (child.kind === 'mo') {\n console.warn('mo on its own row?');\n return new Row([], child);\n }\n\n if (child.kind === 'msline') {\n return new Line();\n }\n\n if (child.toCHTML) {\n return new Row([child]);\n }\n};\n\n/** convert MathJax chtml tree to Row[]\n * @param mstack the root of the mathjax chtml tree\n * @return Row[]\n */\n\nexport const getStackData = mstack => {\n if (!mstack || !mstack.childNodes) {\n return [];\n }\n return _.compact(mstack.childNodes.map(rowStack));\n};\n\nexport class CHTMLmstack extends CHTMLWrapper {\n constructor(factory, node, parent = null) {\n super(factory, node, parent);\n\n this.ce = this.adaptor.document.createElement.bind(this.adaptor.document);\n }\n\n toCHTML(parent) {\n const chtml = this.standardCHTMLnode(parent);\n\n const stackData = getStackData(this);\n\n // console.log('stackData', stackData);\n const maxCols = stackData.reduce((acc, r) => {\n if (r && r.columns.length > acc) {\n acc = r.columns.length;\n }\n return acc;\n }, 0);\n\n const table = this.ce('table');\n chtml.appendChild(table);\n\n stackData.forEach(row => {\n const tr = this.ce('tr');\n table.appendChild(tr);\n\n if (row.kind === 'row') {\n const td = this.ce('td');\n tr.appendChild(td);\n if (row.operator && row.operator.toCHTML) {\n td.setAttribute('class', 'inner');\n row.operator.toCHTML(td);\n } else {\n td.textContent = '';\n }\n\n // align right for now:\n const cols = row.pad(maxCols, 'right');\n cols.forEach(c => {\n const t = this.ce('td');\n tr.appendChild(t);\n if (c === '__pad__') {\n t.textContent = '';\n } else if (typeof c === 'string') {\n t.textContent = c;\n } else if (c.kind === 'none') {\n t.textContent = '';\n } else if (c.toCHTML) {\n t.setAttribute('class', 'inner');\n c.toCHTML(t);\n }\n });\n } else if (row.kind === 'line') {\n const td = this.ce('td');\n tr.appendChild(td);\n td.setAttribute('colspan', maxCols + 1);\n td.setAttribute('class', 'mjx-line');\n td.textContent = '';\n }\n });\n }\n}\nCHTMLmstack.styles = {\n 'mjx-mstack > table': {\n 'line-height': 'initial',\n border: 'solid 0px red',\n 'border-spacing': '0em',\n 'border-collapse': 'separate'\n },\n 'mjx-mstack > table > tr': {\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td': {\n // padding: '1.2rem',\n border: 'solid 0px blue',\n 'font-family': 'sans-serif',\n 'line-height': 'initial'\n },\n 'mjx-mstack > table > tr > td.inner': {\n 'font-family': 'inherit'\n },\n 'mjx-mstack > table > tr > .mjx-line': {\n padding: 0,\n 'border-top': 'solid 1px black'\n }\n};\n"],"file":"chtml.js"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mmlNodes = exports.chtmlNodes = void 0;
7
+
8
+ var _chtml = require("./chtml");
9
+
10
+ var _mml = require("./mml");
11
+
12
+ var chtmlNodes = {
13
+ mstack: _chtml.CHTMLmstack
14
+ };
15
+ exports.chtmlNodes = chtmlNodes;
16
+ var mmlNodes = {
17
+ mstack: _mml.MmlMstack,
18
+ msline: _mml.MmlMsline,
19
+ msrow: _mml.MmlMsrow,
20
+ none: _mml.MmlNone
21
+ };
22
+ exports.mmlNodes = mmlNodes;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/mstack/index.js"],"names":["chtmlNodes","mstack","CHTMLmstack","mmlNodes","MmlMstack","msline","MmlMsline","msrow","MmlMsrow","none","MmlNone"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,IAAMA,UAAU,GAAG;AACxBC,EAAAA,MAAM,EAAEC;AADgB,CAAnB;;AAIA,IAAMC,QAAQ,GAAG;AACtBF,EAAAA,MAAM,EAAEG,cADc;AAEtBC,EAAAA,MAAM,EAAEC,cAFc;AAGtBC,EAAAA,KAAK,EAAEC,aAHe;AAItBC,EAAAA,IAAI,EAAEC;AAJgB,CAAjB","sourcesContent":["import { CHTMLmstack } from './chtml';\nimport { MmlNone, MmlMsline, MmlMstack, MmlMsrow } from './mml';\n\nexport const chtmlNodes = {\n mstack: CHTMLmstack\n};\n\nexport const mmlNodes = {\n mstack: MmlMstack,\n msline: MmlMsline,\n msrow: MmlMsrow,\n none: MmlNone\n};\n"],"file":"index.js"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.MmlNone = exports.MmlMstack = exports.MmlMsrow = exports.MmlMsline = void 0;
9
+
10
+ var _MmlNode = require("mathjax-full/js/core/MmlTree/MmlNode");
11
+
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15
+
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+
18
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
+
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
+
22
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
+
24
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
+
26
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
+
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
+
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
+
32
+ var MmlNone = /*#__PURE__*/function (_AbstractMmlNode) {
33
+ _inherits(MmlNone, _AbstractMmlNode);
34
+
35
+ var _super = _createSuper(MmlNone);
36
+
37
+ function MmlNone() {
38
+ _classCallCheck(this, MmlNone);
39
+
40
+ return _super.apply(this, arguments);
41
+ }
42
+
43
+ _createClass(MmlNone, [{
44
+ key: "kind",
45
+ get: function get() {
46
+ return 'none';
47
+ }
48
+ }]);
49
+
50
+ return MmlNone;
51
+ }(_MmlNode.AbstractMmlNode);
52
+
53
+ exports.MmlNone = MmlNone;
54
+
55
+ var MmlMstack = /*#__PURE__*/function (_AbstractMmlNode2) {
56
+ _inherits(MmlMstack, _AbstractMmlNode2);
57
+
58
+ var _super2 = _createSuper(MmlMstack);
59
+
60
+ function MmlMstack() {
61
+ _classCallCheck(this, MmlMstack);
62
+
63
+ return _super2.apply(this, arguments);
64
+ }
65
+
66
+ _createClass(MmlMstack, [{
67
+ key: "kind",
68
+ get: function get() {
69
+ return 'mstack';
70
+ }
71
+ }]);
72
+
73
+ return MmlMstack;
74
+ }(_MmlNode.AbstractMmlNode);
75
+
76
+ exports.MmlMstack = MmlMstack;
77
+
78
+ var MmlMsrow = /*#__PURE__*/function (_AbstractMmlNode3) {
79
+ _inherits(MmlMsrow, _AbstractMmlNode3);
80
+
81
+ var _super3 = _createSuper(MmlMsrow);
82
+
83
+ function MmlMsrow() {
84
+ _classCallCheck(this, MmlMsrow);
85
+
86
+ return _super3.apply(this, arguments);
87
+ }
88
+
89
+ _createClass(MmlMsrow, [{
90
+ key: "kind",
91
+ get: function get() {
92
+ return 'msrow';
93
+ }
94
+ }]);
95
+
96
+ return MmlMsrow;
97
+ }(_MmlNode.AbstractMmlNode);
98
+
99
+ exports.MmlMsrow = MmlMsrow;
100
+
101
+ var MmlMsline = /*#__PURE__*/function (_AbstractMmlNode4) {
102
+ _inherits(MmlMsline, _AbstractMmlNode4);
103
+
104
+ var _super4 = _createSuper(MmlMsline);
105
+
106
+ function MmlMsline() {
107
+ _classCallCheck(this, MmlMsline);
108
+
109
+ return _super4.apply(this, arguments);
110
+ }
111
+
112
+ _createClass(MmlMsline, [{
113
+ key: "kind",
114
+ get: function get() {
115
+ return 'msline';
116
+ }
117
+ }]);
118
+
119
+ return MmlMsline;
120
+ }(_MmlNode.AbstractMmlNode);
121
+
122
+ exports.MmlMsline = MmlMsline;
123
+ //# sourceMappingURL=mml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/mstack/mml.js"],"names":["MmlNone","AbstractMmlNode","MmlMstack","MmlMsrow","MmlMsline"],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;IAEaA,O;;;;;;;;;;;;;SACX,eAAW;AACT,aAAO,MAAP;AACD;;;;EAH0BC,wB;;;;IAMhBC,S;;;;;;;;;;;;;SACX,eAAW;AACT,aAAO,QAAP;AACD;;;;EAH4BD,wB;;;;IAMlBE,Q;;;;;;;;;;;;;SACX,eAAW;AACT,aAAO,OAAP;AACD;;;;EAH2BF,wB;;;;IAKjBG,S;;;;;;;;;;;;;SACX,eAAW;AACT,aAAO,QAAP;AACD;;;;EAH4BH,wB","sourcesContent":["import { AbstractMmlNode } from 'mathjax-full/js/core/MmlTree/MmlNode';\n\nexport class MmlNone extends AbstractMmlNode {\n get kind() {\n return 'none';\n }\n}\n\nexport class MmlMstack extends AbstractMmlNode {\n get kind() {\n return 'mstack';\n }\n}\n\nexport class MmlMsrow extends AbstractMmlNode {\n get kind() {\n return 'msrow';\n }\n}\nexport class MmlMsline extends AbstractMmlNode {\n get kind() {\n return 'msline';\n }\n}\n"],"file":"mml.js"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapMath = exports.unWrapMath = exports.BracketTypes = void 0;
7
+
8
+ var _PAIRS;
9
+
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+
18
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
19
+
20
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
24
+ var BracketTypes = {};
25
+ exports.BracketTypes = BracketTypes;
26
+ BracketTypes.ROUND_BRACKETS = 'round_brackets';
27
+ BracketTypes.SQUARE_BRACKETS = 'square_brackets';
28
+ BracketTypes.DOLLAR = 'dollar';
29
+ BracketTypes.DOUBLE_DOLLAR = 'double_dollar';
30
+ var PAIRS = (_PAIRS = {}, _defineProperty(_PAIRS, BracketTypes.ROUND_BRACKETS, ['\\(', '\\)']), _defineProperty(_PAIRS, BracketTypes.SQUARE_BRACKETS, ['\\[', '\\]']), _defineProperty(_PAIRS, BracketTypes.DOLLAR, ['$', '$']), _defineProperty(_PAIRS, BracketTypes.DOUBLE_DOLLAR, ['$$', '$$']), _PAIRS);
31
+
32
+ var wrapMath = function wrapMath(content, wrapType) {
33
+ if (wrapType === BracketTypes.SQUARE_BRACKETS) {
34
+ console.warn('\\[...\\] is not supported yet'); // eslint-disable-line
35
+
36
+ wrapType = BracketTypes.ROUND_BRACKETS;
37
+ }
38
+
39
+ if (wrapType === BracketTypes.DOUBLE_DOLLAR) {
40
+ console.warn('$$...$$ is not supported yet'); // eslint-disable-line
41
+
42
+ wrapType = BracketTypes.DOLLAR;
43
+ }
44
+
45
+ var _ref = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS],
46
+ _ref2 = _slicedToArray(_ref, 2),
47
+ start = _ref2[0],
48
+ end = _ref2[1];
49
+
50
+ return "".concat(start).concat(content).concat(end);
51
+ };
52
+
53
+ exports.wrapMath = wrapMath;
54
+
55
+ var unWrapMath = function unWrapMath(content) {
56
+ var displayStyleIndex = content.indexOf('\\displaystyle');
57
+
58
+ if (displayStyleIndex !== -1) {
59
+ console.warn('\\displaystyle is not supported - removing'); // eslint-disable-line
60
+
61
+ content = content.replace('\\displaystyle', '').trim();
62
+ }
63
+
64
+ if (content.startsWith('$$') && content.endsWith('$$')) {
65
+ console.warn('$$ syntax is not yet supported'); // eslint-disable-line
66
+
67
+ return {
68
+ unwrapped: content.substring(2, content.length - 2),
69
+ wrapType: BracketTypes.DOLLAR
70
+ };
71
+ }
72
+
73
+ if (content.startsWith('$') && content.endsWith('$')) {
74
+ return {
75
+ unwrapped: content.substring(1, content.length - 1),
76
+ wrapType: BracketTypes.DOLLAR
77
+ };
78
+ }
79
+
80
+ if (content.startsWith('\\[') && content.endsWith('\\]')) {
81
+ console.warn('\\[..\\] syntax is not yet supported'); // eslint-disable-line
82
+
83
+ return {
84
+ unwrapped: content.substring(2, content.length - 2),
85
+ wrapType: BracketTypes.ROUND_BRACKETS
86
+ };
87
+ }
88
+
89
+ if (content.startsWith('\\(') && content.endsWith('\\)')) {
90
+ return {
91
+ unwrapped: content.substring(2, content.length - 2),
92
+ wrapType: BracketTypes.ROUND_BRACKETS
93
+ };
94
+ }
95
+
96
+ return {
97
+ unwrapped: content,
98
+ wrapType: BracketTypes.ROUND_BRACKETS
99
+ };
100
+ };
101
+
102
+ exports.unWrapMath = unWrapMath;
103
+ //# sourceMappingURL=normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/normalization.js"],"names":["BracketTypes","ROUND_BRACKETS","SQUARE_BRACKETS","DOLLAR","DOUBLE_DOLLAR","PAIRS","wrapMath","content","wrapType","console","warn","start","end","unWrapMath","displayStyleIndex","indexOf","replace","trim","startsWith","endsWith","unwrapped","substring","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,YAAY,GAAG,EAArB;;AAEPA,YAAY,CAACC,cAAb,GAA8B,gBAA9B;AACAD,YAAY,CAACE,eAAb,GAA+B,iBAA/B;AACAF,YAAY,CAACG,MAAb,GAAsB,QAAtB;AACAH,YAAY,CAACI,aAAb,GAA6B,eAA7B;AAEA,IAAMC,KAAK,yCACRL,YAAY,CAACC,cAD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,YAAY,CAACC;AAFlB,GAAP;AAID,CAxCM","sourcesContent":["export const BracketTypes = {};\n\nBracketTypes.ROUND_BRACKETS = 'round_brackets';\nBracketTypes.SQUARE_BRACKETS = 'square_brackets';\nBracketTypes.DOLLAR = 'dollar';\nBracketTypes.DOUBLE_DOLLAR = 'double_dollar';\n\nconst PAIRS = {\n [BracketTypes.ROUND_BRACKETS]: ['\\\\(', '\\\\)'],\n [BracketTypes.SQUARE_BRACKETS]: ['\\\\[', '\\\\]'],\n [BracketTypes.DOLLAR]: ['$', '$'],\n [BracketTypes.DOUBLE_DOLLAR]: ['$$', '$$']\n};\n\nexport const wrapMath = (content, wrapType) => {\n if (wrapType === BracketTypes.SQUARE_BRACKETS) {\n console.warn('\\\\[...\\\\] is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.ROUND_BRACKETS;\n }\n if (wrapType === BracketTypes.DOUBLE_DOLLAR) {\n console.warn('$$...$$ is not supported yet'); // eslint-disable-line\n wrapType = BracketTypes.DOLLAR;\n }\n\n const [start, end] = PAIRS[wrapType] || PAIRS[BracketTypes.ROUND_BRACKETS];\n return `${start}${content}${end}`;\n};\n\nexport const unWrapMath = content => {\n const displayStyleIndex = content.indexOf('\\\\displaystyle');\n if (displayStyleIndex !== -1) {\n console.warn('\\\\displaystyle is not supported - removing'); // eslint-disable-line\n content = content.replace('\\\\displaystyle', '').trim();\n }\n\n if (content.startsWith('$$') && content.endsWith('$$')) {\n console.warn('$$ syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.DOLLAR\n };\n }\n if (content.startsWith('$') && content.endsWith('$')) {\n return {\n unwrapped: content.substring(1, content.length - 1),\n wrapType: BracketTypes.DOLLAR\n };\n }\n\n if (content.startsWith('\\\\[') && content.endsWith('\\\\]')) {\n console.warn('\\\\[..\\\\] syntax is not yet supported'); // eslint-disable-line\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n if (content.startsWith('\\\\(') && content.endsWith('\\\\)')) {\n return {\n unwrapped: content.substring(2, content.length - 2),\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n }\n\n return {\n unwrapped: content,\n wrapType: BracketTypes.ROUND_BRACKETS\n };\n};\n"],"file":"normalization.js"}