@formulaxjs/ckeditor5 0.3.0 → 0.4.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.
- package/README.md +266 -264
- package/README.zh-CN.md +62 -60
- package/dist/base.css +47 -0
- package/dist/canvg-runtime-UR3JNX5Q.js +2759 -0
- package/dist/canvg-runtime-UR3JNX5Q.js.map +1 -0
- package/dist/chunk-4NHESKRD.js +3407 -0
- package/dist/chunk-4NHESKRD.js.map +1 -0
- package/dist/images/scrollbar/custom/bar-bg.png +0 -0
- package/dist/images/scrollbar/custom/bar.png +0 -0
- package/dist/images/scrollbar/custom/bg.png +0 -0
- package/dist/images/scrollbar/custom/bottom.png +0 -0
- package/dist/images/scrollbar/custom/btn.png +0 -0
- package/dist/images/scrollbar/custom/down.png +0 -0
- package/dist/images/scrollbar/custom/top.png +0 -0
- package/dist/images/scrollbar/custom/up.png +0 -0
- package/dist/images/scrollbar/edit/bar-bg.png +0 -0
- package/dist/images/scrollbar/edit/bar-left.png +0 -0
- package/dist/images/scrollbar/edit/bar-right.png +0 -0
- package/dist/images/scrollbar/edit/thumb-bg.png +0 -0
- package/dist/images/scrollbar/edit/thumb-left.png +0 -0
- package/dist/images/scrollbar/edit/thumb-right.png +0 -0
- package/dist/images/toolbar/btn.png +0 -0
- package/dist/index.cjs +24080 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +294 -150
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3768 -21
- package/dist/index.js.map +1 -1
- package/dist/install-XGCSWTLU.js +5464 -0
- package/dist/install-XGCSWTLU.js.map +1 -0
- package/dist/install-XVTKACEN.js +1349 -0
- package/dist/install-XVTKACEN.js.map +1 -0
- package/dist/other.png +0 -0
- package/dist/scrollbar.css +78 -0
- package/dist/start-CRRRBVTN.js +4926 -0
- package/dist/start-CRRRBVTN.js.map +1 -0
- package/dist/ui.css +625 -0
- package/package.json +10 -5
- /package/dist/{KF_AMS_BB-5QF7FUSO.woff → KF_AMS_BB.woff} +0 -0
- /package/dist/{KF_AMS_CAL-NXRNLAZN.woff → KF_AMS_CAL.woff} +0 -0
- /package/dist/{KF_AMS_FRAK-CO33WWN4.woff → KF_AMS_FRAK.woff} +0 -0
- /package/dist/{KF_AMS_MAIN-25QJVAWY.woff → KF_AMS_MAIN.woff} +0 -0
- /package/dist/{KF_AMS_ROMAN-243BR7HH.woff → KF_AMS_ROMAN.woff} +0 -0
- /package/dist/{btn-5DANP6JY.png → btn.png} +0 -0
- /package/dist/{editor-JT5KLVXX.css → editor.css} +0 -0
- /package/dist/{other-OMWJFGL5.png → images/toolbar/other.png} +0 -0
|
@@ -0,0 +1,1349 @@
|
|
|
1
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/assembly.ts
|
|
2
|
+
function registerAssemblyModule(context) {
|
|
3
|
+
const { _p, window: window2 } = context;
|
|
4
|
+
_p[0] = {
|
|
5
|
+
value: function() {
|
|
6
|
+
const kf = window2.kf;
|
|
7
|
+
const CONSTRUCT_MAPPING = {};
|
|
8
|
+
const CURSOR_CHAR = "\uF155";
|
|
9
|
+
class Assembly {
|
|
10
|
+
formula;
|
|
11
|
+
constructor(formula) {
|
|
12
|
+
this.formula = formula;
|
|
13
|
+
}
|
|
14
|
+
generateBy(data) {
|
|
15
|
+
const tree = data.tree;
|
|
16
|
+
const objTree = {};
|
|
17
|
+
const selectInfo = {};
|
|
18
|
+
const mapping = {};
|
|
19
|
+
if (typeof tree === "string") {
|
|
20
|
+
throw new Error("Unhandled string tree node");
|
|
21
|
+
}
|
|
22
|
+
this.formula.appendExpression(generateExpression(tree, deepCopy(tree), objTree, mapping, selectInfo));
|
|
23
|
+
return {
|
|
24
|
+
select: selectInfo,
|
|
25
|
+
parsedTree: tree,
|
|
26
|
+
tree: objTree,
|
|
27
|
+
mapping
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
regenerateBy(data) {
|
|
31
|
+
this.formula.clearExpressions();
|
|
32
|
+
return this.generateBy(data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function generateExpression(originTree, tree, objTree, mapping, selectInfo) {
|
|
36
|
+
let currentOperand = null;
|
|
37
|
+
let exp = null;
|
|
38
|
+
const cursorLocation = [];
|
|
39
|
+
const operand = tree.operand || [];
|
|
40
|
+
let constructor = null;
|
|
41
|
+
objTree.operand = [];
|
|
42
|
+
if (tree.name.indexOf("text") === -1) {
|
|
43
|
+
for (let i = 0, len = operand.length; i < len; i += 1) {
|
|
44
|
+
currentOperand = operand[i];
|
|
45
|
+
if (currentOperand === CURSOR_CHAR) {
|
|
46
|
+
cursorLocation.push(i);
|
|
47
|
+
if (!Object.prototype.hasOwnProperty.call(selectInfo, "startOffset")) {
|
|
48
|
+
selectInfo.startOffset = i;
|
|
49
|
+
}
|
|
50
|
+
selectInfo.endOffset = i;
|
|
51
|
+
if (tree.attr && tree.attr.id) {
|
|
52
|
+
selectInfo.groupId = tree.attr.id;
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!currentOperand) {
|
|
57
|
+
operand[i] = createObject("empty");
|
|
58
|
+
objTree.operand.push(operand[i]);
|
|
59
|
+
} else if (typeof currentOperand === "string") {
|
|
60
|
+
if (tree.name === "brackets" && i < 2) {
|
|
61
|
+
operand[i] = currentOperand;
|
|
62
|
+
} else if (tree.name === "function" && i === 0) {
|
|
63
|
+
operand[i] = currentOperand;
|
|
64
|
+
} else {
|
|
65
|
+
operand[i] = createObject("text", currentOperand);
|
|
66
|
+
}
|
|
67
|
+
objTree.operand.push(operand[i]);
|
|
68
|
+
} else {
|
|
69
|
+
objTree.operand.push({});
|
|
70
|
+
operand[i] = generateExpression(originTree.operand[i], currentOperand, objTree.operand[objTree.operand.length - 1], mapping, selectInfo);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (cursorLocation.length === 2) {
|
|
74
|
+
selectInfo.endOffset -= 1;
|
|
75
|
+
}
|
|
76
|
+
while (cursorLocation.length) {
|
|
77
|
+
const index = cursorLocation[cursorLocation.length - 1];
|
|
78
|
+
operand.splice(index, 1);
|
|
79
|
+
cursorLocation.pop();
|
|
80
|
+
originTree.operand.splice(index, 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
constructor = getConstructor(tree.name);
|
|
84
|
+
if (!constructor) {
|
|
85
|
+
throw new Error(`operator type error: not found ${tree.operator}`);
|
|
86
|
+
}
|
|
87
|
+
exp = Object.create(constructor.prototype);
|
|
88
|
+
constructor.apply(exp, operand);
|
|
89
|
+
objTree.func = exp;
|
|
90
|
+
for (const fn in tree.callFn) {
|
|
91
|
+
if (!Object.prototype.hasOwnProperty.call(tree.callFn, fn) || !exp[fn]) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
exp[fn].apply(exp, tree.callFn[fn]);
|
|
95
|
+
}
|
|
96
|
+
if (tree.attr) {
|
|
97
|
+
if (tree.attr.id) {
|
|
98
|
+
mapping[tree.attr.id] = {
|
|
99
|
+
objGroup: exp,
|
|
100
|
+
strGroup: originTree
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (tree.attr["data-root"]) {
|
|
104
|
+
mapping.root = {
|
|
105
|
+
objGroup: exp,
|
|
106
|
+
strGroup: originTree
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
exp.setAttr(tree.attr);
|
|
110
|
+
}
|
|
111
|
+
return exp;
|
|
112
|
+
}
|
|
113
|
+
function createObject(type, value) {
|
|
114
|
+
switch (type) {
|
|
115
|
+
case "empty":
|
|
116
|
+
return new kf.EmptyExpression();
|
|
117
|
+
case "text":
|
|
118
|
+
return new kf.TextExpression(value);
|
|
119
|
+
default:
|
|
120
|
+
throw new Error(`Unsupported assembly object type: ${type}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function getConstructor(name) {
|
|
124
|
+
return CONSTRUCT_MAPPING[name] || kf[name.replace(/^[a-z]/i, (match) => match.toUpperCase()).replace(/-([a-z])/gi, (_match, char) => char.toUpperCase()) + "Expression"];
|
|
125
|
+
}
|
|
126
|
+
function deepCopy(source) {
|
|
127
|
+
if (!source || typeof source !== "object") {
|
|
128
|
+
return source;
|
|
129
|
+
}
|
|
130
|
+
if (Array.isArray(source)) {
|
|
131
|
+
return source.map((item) => deepCopy(item));
|
|
132
|
+
}
|
|
133
|
+
const target = {};
|
|
134
|
+
for (const key in source) {
|
|
135
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
136
|
+
target[key] = deepCopy(source[key]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return target;
|
|
140
|
+
}
|
|
141
|
+
return Assembly;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/bootstrap.ts
|
|
147
|
+
function bootstrapLegacyParserRuntime(context) {
|
|
148
|
+
const { _p, window: window2 } = context;
|
|
149
|
+
_p[44] = {
|
|
150
|
+
value: function() {
|
|
151
|
+
const Parser = _p.r(43).Parser;
|
|
152
|
+
_p.r(25);
|
|
153
|
+
window2.kf.Parser = Parser;
|
|
154
|
+
window2.kf.Assembly = _p.r(0);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
_p.r(44);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/latex-parser.ts
|
|
161
|
+
function registerLatexParserModules(context) {
|
|
162
|
+
const { _p } = context;
|
|
163
|
+
_p[25] = {
|
|
164
|
+
value: function(_require) {
|
|
165
|
+
let Parser = _p.r(43).Parser, LatexUtils = _p.r(1), PRE_HANDLER = _p.r(8), serialization = _p.r(42), OP_DEFINE = _p.r(7), REVERSE_DEFINE = _p.r(9), SPECIAL_LIST = _p.r(10), Utils = _p.r(4);
|
|
166
|
+
let leftChar = "\uFFF8", rightChar = "\uFFFC", clearCharPattern = new RegExp(leftChar + "|" + rightChar, "g"), leftCharPattern = new RegExp(leftChar, "g"), rightCharPattern = new RegExp(rightChar, "g");
|
|
167
|
+
Parser.register("latex", Parser.implement({
|
|
168
|
+
parse: function(data) {
|
|
169
|
+
let units = this.split(this.format(data));
|
|
170
|
+
units = this.parseToGroup(units);
|
|
171
|
+
units = this.parseToStruct(units);
|
|
172
|
+
return this.generateTree(units);
|
|
173
|
+
},
|
|
174
|
+
serialization: function(tree, options) {
|
|
175
|
+
return serialization(tree, options);
|
|
176
|
+
},
|
|
177
|
+
expand: function(expandObj) {
|
|
178
|
+
let parseObj = expandObj.parse, formatKey = null, preObj = expandObj.pre, reverseObj = expandObj.reverse;
|
|
179
|
+
for (let key in parseObj) {
|
|
180
|
+
if (!parseObj.hasOwnProperty(key)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
formatKey = key.replace(/\\/g, "");
|
|
184
|
+
OP_DEFINE[formatKey] = parseObj[key];
|
|
185
|
+
}
|
|
186
|
+
for (let key in reverseObj) {
|
|
187
|
+
if (!reverseObj.hasOwnProperty(key)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
REVERSE_DEFINE[key.replace(/\\/g, "")] = reverseObj[key];
|
|
191
|
+
}
|
|
192
|
+
if (preObj) {
|
|
193
|
+
for (let key in preObj) {
|
|
194
|
+
if (!preObj.hasOwnProperty(key)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
PRE_HANDLER[key.replace(/\\/g, "")] = preObj[key];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
// Format input data
|
|
202
|
+
format: function(input) {
|
|
203
|
+
input = clearEmpty(input);
|
|
204
|
+
input = input.replace(clearCharPattern, "").replace(/\\{/gi, leftChar).replace(/\\}/gi, rightChar);
|
|
205
|
+
for (let key in PRE_HANDLER) {
|
|
206
|
+
if (PRE_HANDLER.hasOwnProperty(key)) {
|
|
207
|
+
input = PRE_HANDLER[key](input);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return input;
|
|
211
|
+
},
|
|
212
|
+
split: function(data) {
|
|
213
|
+
let units = [], pattern = /(?:\\[^a-z]\s*)|(?:\\[a-z]+\s*)|(?:[{}]\s*)|(?:[^\\{}]\s*)/gi, emptyPattern = /^\s+|\s+$/g, match = null;
|
|
214
|
+
data = data.replace(emptyPattern, "");
|
|
215
|
+
while (match = pattern.exec(data)) {
|
|
216
|
+
match = match[0].replace(emptyPattern, "");
|
|
217
|
+
if (match) {
|
|
218
|
+
units.push(match);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return units;
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* Generate tree from parsed syntax units
|
|
225
|
+
* @param units Units
|
|
226
|
+
* @return Generated tree object
|
|
227
|
+
*/
|
|
228
|
+
generateTree: function(units) {
|
|
229
|
+
let tree = [], currentUnit = null;
|
|
230
|
+
while (currentUnit = units.shift()) {
|
|
231
|
+
if (Utils.isArray(currentUnit)) {
|
|
232
|
+
tree.push(this.generateTree(currentUnit));
|
|
233
|
+
} else {
|
|
234
|
+
tree.push(currentUnit);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
tree = LatexUtils.toRPNExpression(tree);
|
|
238
|
+
return LatexUtils.generateTree(tree);
|
|
239
|
+
},
|
|
240
|
+
parseToGroup: function(units) {
|
|
241
|
+
let group = [], groupStack = [group], groupCount = 0, bracketsCount = 0;
|
|
242
|
+
for (let i = 0, len = units.length; i < len; i++) {
|
|
243
|
+
switch (units[i]) {
|
|
244
|
+
case "{":
|
|
245
|
+
groupCount++;
|
|
246
|
+
groupStack.push(group);
|
|
247
|
+
group.push([]);
|
|
248
|
+
group = group[group.length - 1];
|
|
249
|
+
break;
|
|
250
|
+
case "}":
|
|
251
|
+
groupCount--;
|
|
252
|
+
group = groupStack.pop();
|
|
253
|
+
break;
|
|
254
|
+
// left-right grouping
|
|
255
|
+
case "\\left":
|
|
256
|
+
bracketsCount++;
|
|
257
|
+
groupStack.push(group);
|
|
258
|
+
group.push([[]]);
|
|
259
|
+
group = group[group.length - 1][0];
|
|
260
|
+
group.type = "brackets";
|
|
261
|
+
i++;
|
|
262
|
+
group.leftBrackets = units[i].replace(leftCharPattern, "{").replace(rightCharPattern, "}");
|
|
263
|
+
break;
|
|
264
|
+
case "\\right":
|
|
265
|
+
bracketsCount--;
|
|
266
|
+
i++;
|
|
267
|
+
group.rightBrackets = units[i].replace(leftCharPattern, "{").replace(rightCharPattern, "}");
|
|
268
|
+
group = groupStack.pop();
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
group.push(units[i].replace(leftCharPattern, "\\{").replace(rightCharPattern, "\\}"));
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (groupCount !== 0) {
|
|
276
|
+
throw new Error("Group Error!");
|
|
277
|
+
}
|
|
278
|
+
if (bracketsCount !== 0) {
|
|
279
|
+
throw new Error("Brackets Error!");
|
|
280
|
+
}
|
|
281
|
+
return groupStack[0];
|
|
282
|
+
},
|
|
283
|
+
parseToStruct: function(units) {
|
|
284
|
+
let structs = [];
|
|
285
|
+
for (let i = 0, len = units.length; i < len; i++) {
|
|
286
|
+
if (Utils.isArray(units[i])) {
|
|
287
|
+
if (units[i].type === "brackets") {
|
|
288
|
+
structs.push(Utils.getBracketsDefine(units[i].leftBrackets, units[i].rightBrackets));
|
|
289
|
+
structs.push(this.parseToStruct(units[i]));
|
|
290
|
+
} else {
|
|
291
|
+
structs.push(this.parseToStruct(units[i]));
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
structs.push(parseStruct(units[i]));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return structs;
|
|
298
|
+
}
|
|
299
|
+
}));
|
|
300
|
+
function parseStruct(str) {
|
|
301
|
+
if (isSpecialCharacter(str)) {
|
|
302
|
+
return str.substring(1);
|
|
303
|
+
}
|
|
304
|
+
switch (Utils.getLatexType(str)) {
|
|
305
|
+
case "operator":
|
|
306
|
+
return Utils.getDefine(str);
|
|
307
|
+
case "function":
|
|
308
|
+
return Utils.getFuncDefine(str);
|
|
309
|
+
default:
|
|
310
|
+
return transformSpecialCharacters(str);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function transformSpecialCharacters(char) {
|
|
314
|
+
if (char.indexOf("\\") === 0) {
|
|
315
|
+
return char + "\\";
|
|
316
|
+
}
|
|
317
|
+
return char;
|
|
318
|
+
}
|
|
319
|
+
function isSpecialCharacter(char) {
|
|
320
|
+
if (char.indexOf("\\") === 0) {
|
|
321
|
+
return !!SPECIAL_LIST[char.substring(1)];
|
|
322
|
+
}
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
function clearEmpty(data) {
|
|
326
|
+
return data.replace(/\\\s+/, "").replace(/\s*([^a-z0-9\s])\s*/gi, function(match, symbol) {
|
|
327
|
+
return symbol;
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
_p[26] = {
|
|
333
|
+
value: function() {
|
|
334
|
+
return function(input) {
|
|
335
|
+
return input.replace(/\\(i+)nt(\b|[^a-zA-Z])/g, function(match, sign, suffix) {
|
|
336
|
+
return "\\int " + sign.length + suffix;
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
_p[27] = {
|
|
342
|
+
value: function() {
|
|
343
|
+
return function(input) {
|
|
344
|
+
return input.replace(/``/g, '"');
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
_p[28] = {
|
|
349
|
+
value: function() {
|
|
350
|
+
return function(operands) {
|
|
351
|
+
if (operands[0] === "{" || operands[0] === "}") {
|
|
352
|
+
operands[0] = "\\" + operands[0];
|
|
353
|
+
}
|
|
354
|
+
if (operands[1] === "{" || operands[1] === "}") {
|
|
355
|
+
operands[1] = "\\" + operands[1];
|
|
356
|
+
}
|
|
357
|
+
return ["\\left", operands[0], operands[2], "\\right", operands[1]].join(" ");
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
_p[29] = {
|
|
362
|
+
value: function() {
|
|
363
|
+
return function(operands) {
|
|
364
|
+
if (this.attr["data-root"] || this.attr["data-placeholder"]) {
|
|
365
|
+
return operands.join("");
|
|
366
|
+
}
|
|
367
|
+
return "{" + operands.join("") + "}";
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
_p[30] = {
|
|
372
|
+
value: function() {
|
|
373
|
+
return function(operands) {
|
|
374
|
+
return "\\frac " + operands[0] + " " + operands[1];
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
_p[31] = {
|
|
379
|
+
value: function() {
|
|
380
|
+
return function(operands) {
|
|
381
|
+
let result = ["\\" + operands[0]];
|
|
382
|
+
if (operands[2]) {
|
|
383
|
+
result.push("^" + operands[2]);
|
|
384
|
+
}
|
|
385
|
+
if (operands[3]) {
|
|
386
|
+
result.push("_" + operands[3]);
|
|
387
|
+
}
|
|
388
|
+
if (operands[1]) {
|
|
389
|
+
result.push(" " + operands[1]);
|
|
390
|
+
}
|
|
391
|
+
return result.join("");
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
_p[32] = {
|
|
396
|
+
value: function() {
|
|
397
|
+
return function(operands) {
|
|
398
|
+
let result = ["\\int "];
|
|
399
|
+
if (this.callFn && this.callFn.setType) {
|
|
400
|
+
result = ["\\"];
|
|
401
|
+
for (let i = 0, len = this.callFn.setType; i < len; i++) {
|
|
402
|
+
result.push("i");
|
|
403
|
+
}
|
|
404
|
+
result.push("nt ");
|
|
405
|
+
}
|
|
406
|
+
if (operands[1]) {
|
|
407
|
+
result.push("^" + operands[1]);
|
|
408
|
+
}
|
|
409
|
+
if (operands[2]) {
|
|
410
|
+
result.push("_" + operands[2]);
|
|
411
|
+
}
|
|
412
|
+
if (operands[0]) {
|
|
413
|
+
result.push(" " + operands[0]);
|
|
414
|
+
}
|
|
415
|
+
return result.join("");
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
_p[33] = {
|
|
420
|
+
value: function() {
|
|
421
|
+
return function(operands) {
|
|
422
|
+
return "\\mathbb{" + operands[0] + "}";
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
_p[34] = {
|
|
427
|
+
value: function() {
|
|
428
|
+
return function(operands) {
|
|
429
|
+
return "\\mathcal{" + operands[0] + "}";
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
_p[35] = {
|
|
434
|
+
value: function() {
|
|
435
|
+
return function(operands) {
|
|
436
|
+
return "\\mathfrak{" + operands[0] + "}";
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
_p[36] = {
|
|
441
|
+
value: function() {
|
|
442
|
+
return function(operands) {
|
|
443
|
+
return "\\mathrm{" + operands[0] + "}";
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
_p[37] = {
|
|
448
|
+
value: function() {
|
|
449
|
+
return function(operands) {
|
|
450
|
+
return operands[0] + "^" + operands[1] + "_" + operands[2];
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
_p[38] = {
|
|
455
|
+
value: function() {
|
|
456
|
+
return function(operands) {
|
|
457
|
+
let result = ["\\sqrt"];
|
|
458
|
+
if (operands[1]) {
|
|
459
|
+
result.push("[" + operands[1] + "]");
|
|
460
|
+
}
|
|
461
|
+
result.push(" " + operands[0]);
|
|
462
|
+
return result.join("");
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
_p[39] = {
|
|
467
|
+
value: function() {
|
|
468
|
+
return function(operands) {
|
|
469
|
+
return operands[0] + "_" + operands[1];
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
_p[40] = {
|
|
474
|
+
value: function() {
|
|
475
|
+
return function(operands) {
|
|
476
|
+
let result = ["\\sum "];
|
|
477
|
+
if (operands[1]) {
|
|
478
|
+
result.push("^" + operands[1]);
|
|
479
|
+
}
|
|
480
|
+
if (operands[2]) {
|
|
481
|
+
result.push("_" + operands[2]);
|
|
482
|
+
}
|
|
483
|
+
if (operands[0]) {
|
|
484
|
+
result.push(" " + operands[0]);
|
|
485
|
+
}
|
|
486
|
+
return result.join("");
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
_p[41] = {
|
|
491
|
+
value: function() {
|
|
492
|
+
return function(operands) {
|
|
493
|
+
return operands[0] + "^" + operands[1];
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
_p[42] = {
|
|
498
|
+
value: function(_require) {
|
|
499
|
+
let reverseHandlerTable = _p.r(9), SPECIAL_LIST = _p.r(10), specialCharPattern = /(\\(?:[\w]+)|(?:[^a-z]))\\/gi;
|
|
500
|
+
return function(tree, options) {
|
|
501
|
+
return reverseParse(tree, options);
|
|
502
|
+
};
|
|
503
|
+
function reverseParse(tree, options) {
|
|
504
|
+
let operands = [], reverseHandlerName = null, originalOperands = null;
|
|
505
|
+
if (typeof tree !== "object") {
|
|
506
|
+
if (isSpecialCharacter(tree)) {
|
|
507
|
+
return "\\" + tree + " ";
|
|
508
|
+
}
|
|
509
|
+
return tree.replace(specialCharPattern, function(match, group) {
|
|
510
|
+
return group + " ";
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
if (tree.name === "combination" && tree.operand.length === 1 && tree.operand[0].name === "combination") {
|
|
514
|
+
tree = tree.operand[0];
|
|
515
|
+
}
|
|
516
|
+
originalOperands = tree.operand;
|
|
517
|
+
for (let i = 0, len = originalOperands.length; i < len; i++) {
|
|
518
|
+
if (originalOperands[i]) {
|
|
519
|
+
operands.push(reverseParse(originalOperands[i]));
|
|
520
|
+
} else {
|
|
521
|
+
operands.push(originalOperands[i]);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (tree.attr && tree.attr._reverse) {
|
|
525
|
+
reverseHandlerName = tree.attr._reverse;
|
|
526
|
+
} else {
|
|
527
|
+
reverseHandlerName = tree.name;
|
|
528
|
+
}
|
|
529
|
+
return reverseHandlerTable[reverseHandlerName].call(tree, operands, options);
|
|
530
|
+
}
|
|
531
|
+
function isSpecialCharacter(char) {
|
|
532
|
+
return !!SPECIAL_LIST[char];
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/latex-support.ts
|
|
539
|
+
function registerLatexSupportModules(context) {
|
|
540
|
+
const { _p } = context;
|
|
541
|
+
_p[1] = {
|
|
542
|
+
value: function(_require) {
|
|
543
|
+
return {
|
|
544
|
+
toRPNExpression: _p.r(2),
|
|
545
|
+
generateTree: _p.r(3)
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
_p[2] = {
|
|
550
|
+
value: function(_require) {
|
|
551
|
+
let Utils = _p.r(4);
|
|
552
|
+
function rpn(units) {
|
|
553
|
+
let signStack = [], currentUnit = null;
|
|
554
|
+
units = processFunction(units);
|
|
555
|
+
while (currentUnit = units.shift()) {
|
|
556
|
+
if (currentUnit.name === "combination" && currentUnit.operand.length === 1 && currentUnit.operand[0].name === "brackets") {
|
|
557
|
+
currentUnit = currentUnit.operand[0];
|
|
558
|
+
}
|
|
559
|
+
if (Utils.isArray(currentUnit)) {
|
|
560
|
+
signStack.push(rpn(currentUnit));
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
signStack.push(currentUnit);
|
|
564
|
+
}
|
|
565
|
+
return signStack;
|
|
566
|
+
}
|
|
567
|
+
function processFunction(units) {
|
|
568
|
+
let processed = [], currentUnit = null;
|
|
569
|
+
while ((currentUnit = units.pop()) !== void 0) {
|
|
570
|
+
if (currentUnit && typeof currentUnit === "object" && (currentUnit.sign === false || currentUnit.name === "function")) {
|
|
571
|
+
let tt = currentUnit.handler(currentUnit, [], processed.reverse());
|
|
572
|
+
processed.unshift(tt);
|
|
573
|
+
processed.reverse();
|
|
574
|
+
} else {
|
|
575
|
+
processed.push(currentUnit);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return processed.reverse();
|
|
579
|
+
}
|
|
580
|
+
return rpn;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
_p[3] = {
|
|
584
|
+
value: function(_require) {
|
|
585
|
+
let mergeHandler = _p.r(13), Utils = _p.r(4);
|
|
586
|
+
function generateTree(units) {
|
|
587
|
+
let currentUnit = null, tree = [];
|
|
588
|
+
for (let i = 0, len = units.length; i < len; i++) {
|
|
589
|
+
if (Utils.isArray(units[i])) {
|
|
590
|
+
units[i] = generateTree(units[i]);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
while (currentUnit = units.shift()) {
|
|
594
|
+
if (typeof currentUnit === "object" && currentUnit.handler) {
|
|
595
|
+
tree.push(currentUnit.handler(currentUnit, tree, units));
|
|
596
|
+
} else {
|
|
597
|
+
tree.push(currentUnit);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return mergeHandler(tree);
|
|
601
|
+
}
|
|
602
|
+
return generateTree;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
_p[4] = {
|
|
606
|
+
value: function(_require) {
|
|
607
|
+
let OPERATOR_LIST = _p.r(7), FUNCTION_LIST = _p.r(6), FUNCTION_HANDLER = _p.r(15), Utils = {
|
|
608
|
+
// Detect the kf type based on input latex string
|
|
609
|
+
getLatexType: function(str) {
|
|
610
|
+
str = str.replace(/^\\/, "");
|
|
611
|
+
if (OPERATOR_LIST[str]) {
|
|
612
|
+
return "operator";
|
|
613
|
+
}
|
|
614
|
+
if (FUNCTION_LIST[str]) {
|
|
615
|
+
return "function";
|
|
616
|
+
}
|
|
617
|
+
return "text";
|
|
618
|
+
},
|
|
619
|
+
isArray: function(obj) {
|
|
620
|
+
return obj && Object.prototype.toString.call(obj) === "[object Array]";
|
|
621
|
+
},
|
|
622
|
+
getDefine: function(str) {
|
|
623
|
+
return Utils.extend({}, OPERATOR_LIST[str.replace("\\", "")]);
|
|
624
|
+
},
|
|
625
|
+
getFuncDefine: function(str) {
|
|
626
|
+
return {
|
|
627
|
+
name: "function",
|
|
628
|
+
params: str.replace(/^\\/, ""),
|
|
629
|
+
handler: FUNCTION_HANDLER
|
|
630
|
+
};
|
|
631
|
+
},
|
|
632
|
+
getBracketsDefine: function(leftBrackets, rightBrackets) {
|
|
633
|
+
return Utils.extend({
|
|
634
|
+
params: [leftBrackets, rightBrackets]
|
|
635
|
+
}, OPERATOR_LIST.brackets);
|
|
636
|
+
},
|
|
637
|
+
extend: function(target, sources) {
|
|
638
|
+
for (let key in sources) {
|
|
639
|
+
if (sources.hasOwnProperty(key)) {
|
|
640
|
+
target[key] = sources[key];
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return target;
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
return Utils;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
_p[5] = {
|
|
650
|
+
value: function() {
|
|
651
|
+
let t = true;
|
|
652
|
+
return {
|
|
653
|
+
".": t,
|
|
654
|
+
"{": t,
|
|
655
|
+
"}": t,
|
|
656
|
+
"[": t,
|
|
657
|
+
"]": t,
|
|
658
|
+
"(": t,
|
|
659
|
+
")": t,
|
|
660
|
+
"|": t
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
_p[6] = {
|
|
665
|
+
value: function() {
|
|
666
|
+
return {
|
|
667
|
+
sin: 1,
|
|
668
|
+
cos: 1,
|
|
669
|
+
arccos: 1,
|
|
670
|
+
cosh: 1,
|
|
671
|
+
det: 1,
|
|
672
|
+
inf: 1,
|
|
673
|
+
limsup: 1,
|
|
674
|
+
Pr: 1,
|
|
675
|
+
tan: 1,
|
|
676
|
+
arcsin: 1,
|
|
677
|
+
cot: 1,
|
|
678
|
+
dim: 1,
|
|
679
|
+
ker: 1,
|
|
680
|
+
ln: 1,
|
|
681
|
+
sec: 1,
|
|
682
|
+
tanh: 1,
|
|
683
|
+
arctan: 1,
|
|
684
|
+
coth: 1,
|
|
685
|
+
exp: 1,
|
|
686
|
+
lg: 1,
|
|
687
|
+
log: 1,
|
|
688
|
+
arg: 1,
|
|
689
|
+
csc: 1,
|
|
690
|
+
gcd: 1,
|
|
691
|
+
lim: 1,
|
|
692
|
+
max: 1,
|
|
693
|
+
sinh: 1,
|
|
694
|
+
deg: 1,
|
|
695
|
+
hom: 1,
|
|
696
|
+
liminf: 1,
|
|
697
|
+
min: 1,
|
|
698
|
+
sup: 1
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
_p[7] = {
|
|
703
|
+
value: function(_require) {
|
|
704
|
+
let scriptHandler = _p.r(22), TYPE = _p.r(11);
|
|
705
|
+
return {
|
|
706
|
+
"^": {
|
|
707
|
+
name: "superscript",
|
|
708
|
+
type: TYPE.OP,
|
|
709
|
+
handler: scriptHandler
|
|
710
|
+
},
|
|
711
|
+
_: {
|
|
712
|
+
name: "subscript",
|
|
713
|
+
type: TYPE.OP,
|
|
714
|
+
handler: scriptHandler
|
|
715
|
+
},
|
|
716
|
+
frac: {
|
|
717
|
+
name: "fraction",
|
|
718
|
+
type: TYPE.FN,
|
|
719
|
+
sign: false,
|
|
720
|
+
handler: _p.r(14)
|
|
721
|
+
},
|
|
722
|
+
sqrt: {
|
|
723
|
+
name: "radical",
|
|
724
|
+
type: TYPE.FN,
|
|
725
|
+
sign: false,
|
|
726
|
+
handler: _p.r(23)
|
|
727
|
+
},
|
|
728
|
+
sum: {
|
|
729
|
+
name: "summation",
|
|
730
|
+
type: TYPE.FN,
|
|
731
|
+
traversal: "rtl",
|
|
732
|
+
handler: _p.r(24)
|
|
733
|
+
},
|
|
734
|
+
"int": {
|
|
735
|
+
name: "integration",
|
|
736
|
+
type: TYPE.FN,
|
|
737
|
+
traversal: "rtl",
|
|
738
|
+
handler: _p.r(16)
|
|
739
|
+
},
|
|
740
|
+
brackets: {
|
|
741
|
+
name: "brackets",
|
|
742
|
+
type: TYPE.FN,
|
|
743
|
+
handler: _p.r(12)
|
|
744
|
+
},
|
|
745
|
+
mathcal: {
|
|
746
|
+
name: "mathcal",
|
|
747
|
+
type: TYPE.FN,
|
|
748
|
+
sign: false,
|
|
749
|
+
handler: _p.r(19)
|
|
750
|
+
},
|
|
751
|
+
mathfrak: {
|
|
752
|
+
name: "mathfrak",
|
|
753
|
+
type: TYPE.FN,
|
|
754
|
+
sign: false,
|
|
755
|
+
handler: _p.r(20)
|
|
756
|
+
},
|
|
757
|
+
mathbb: {
|
|
758
|
+
name: "mathbb",
|
|
759
|
+
type: TYPE.FN,
|
|
760
|
+
sign: false,
|
|
761
|
+
handler: _p.r(18)
|
|
762
|
+
},
|
|
763
|
+
mathrm: {
|
|
764
|
+
name: "mathrm",
|
|
765
|
+
type: TYPE.FN,
|
|
766
|
+
sign: false,
|
|
767
|
+
handler: _p.r(21)
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
_p[8] = {
|
|
773
|
+
value: function(_require) {
|
|
774
|
+
return {
|
|
775
|
+
// Integration preprocessor
|
|
776
|
+
"int": _p.r(26),
|
|
777
|
+
// Quote preprocessor
|
|
778
|
+
quot: _p.r(27)
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
_p[9] = {
|
|
783
|
+
value: function(_require) {
|
|
784
|
+
return {
|
|
785
|
+
combination: _p.r(29),
|
|
786
|
+
fraction: _p.r(30),
|
|
787
|
+
"function": _p.r(31),
|
|
788
|
+
integration: _p.r(32),
|
|
789
|
+
subscript: _p.r(39),
|
|
790
|
+
superscript: _p.r(41),
|
|
791
|
+
script: _p.r(37),
|
|
792
|
+
radical: _p.r(38),
|
|
793
|
+
summation: _p.r(40),
|
|
794
|
+
brackets: _p.r(28),
|
|
795
|
+
mathcal: _p.r(34),
|
|
796
|
+
mathfrak: _p.r(35),
|
|
797
|
+
mathbb: _p.r(33),
|
|
798
|
+
mathrm: _p.r(36)
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
_p[10] = {
|
|
803
|
+
value: function() {
|
|
804
|
+
return {
|
|
805
|
+
"#": 1,
|
|
806
|
+
$: 1,
|
|
807
|
+
"%": 1,
|
|
808
|
+
_: 1,
|
|
809
|
+
"&": 1,
|
|
810
|
+
"{": 1,
|
|
811
|
+
"}": 1,
|
|
812
|
+
"^": 1,
|
|
813
|
+
"~": 1
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
_p[11] = {
|
|
818
|
+
value: function() {
|
|
819
|
+
return {
|
|
820
|
+
OP: 1,
|
|
821
|
+
FN: 2
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
_p[12] = {
|
|
826
|
+
value: function(_require) {
|
|
827
|
+
let BRACKETS_TYPE = _p.r(5);
|
|
828
|
+
return function(info, processedStack, unprocessedStack) {
|
|
829
|
+
for (let i = 0, len = info.params.length; i < len; i++) {
|
|
830
|
+
if (!(info.params[i] in BRACKETS_TYPE)) {
|
|
831
|
+
throw new Error("Brackets: invalid params");
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
info.operand = info.params;
|
|
835
|
+
info.params[2] = unprocessedStack.shift();
|
|
836
|
+
delete info.handler;
|
|
837
|
+
delete info.params;
|
|
838
|
+
return info;
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
_p[13] = {
|
|
843
|
+
value: function() {
|
|
844
|
+
return function() {
|
|
845
|
+
return {
|
|
846
|
+
name: "combination",
|
|
847
|
+
operand: arguments[0] || []
|
|
848
|
+
};
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
_p[14] = {
|
|
853
|
+
value: function() {
|
|
854
|
+
return function(info, processedStack, unprocessedStack) {
|
|
855
|
+
let numerator = unprocessedStack.shift(), denominator = unprocessedStack.shift();
|
|
856
|
+
if (numerator === void 0 || denominator === void 0) {
|
|
857
|
+
throw new Error("Frac: Syntax Error");
|
|
858
|
+
}
|
|
859
|
+
info.operand = [numerator, denominator];
|
|
860
|
+
delete info.handler;
|
|
861
|
+
return info;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
_p[15] = {
|
|
866
|
+
value: function(_require) {
|
|
867
|
+
let ScriptExtractor = _p.r(17);
|
|
868
|
+
return function(info, processedStack, unprocessedStack) {
|
|
869
|
+
let params = ScriptExtractor.exec(unprocessedStack);
|
|
870
|
+
info.operand = [info.params, params.expr, params.superscript, params.subscript];
|
|
871
|
+
delete info.params;
|
|
872
|
+
delete info.handler;
|
|
873
|
+
return info;
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
_p[16] = {
|
|
878
|
+
value: function(_require) {
|
|
879
|
+
let ScriptExtractor = _p.r(17), FN_TYPE = _p.r(11).FN;
|
|
880
|
+
return function(info, processedStack, unprocessedStack) {
|
|
881
|
+
let count = unprocessedStack.shift(), params = ScriptExtractor.exec(unprocessedStack);
|
|
882
|
+
if (params.expr && params.expr.type === FN_TYPE && params.expr.handler) {
|
|
883
|
+
params.expr = params.expr.handler(params.expr, processedStack, unprocessedStack);
|
|
884
|
+
}
|
|
885
|
+
info.operand = [params.expr, params.superscript, params.subscript];
|
|
886
|
+
info.callFn = {
|
|
887
|
+
setType: [count | 0]
|
|
888
|
+
};
|
|
889
|
+
delete info.handler;
|
|
890
|
+
return info;
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
_p[17] = {
|
|
895
|
+
value: function() {
|
|
896
|
+
return {
|
|
897
|
+
exec: function(stack) {
|
|
898
|
+
let result = extractScript(stack), expr = stack.shift();
|
|
899
|
+
if (expr && expr.name && expr.name.indexOf("script") !== -1) {
|
|
900
|
+
throw new Error("Script: syntax error!");
|
|
901
|
+
}
|
|
902
|
+
result.expr = expr || null;
|
|
903
|
+
return result;
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
function extractScript(stack) {
|
|
907
|
+
let scriptGroup = extract(stack), nextGroup = null, result = {
|
|
908
|
+
superscript: null,
|
|
909
|
+
subscript: null
|
|
910
|
+
};
|
|
911
|
+
if (scriptGroup) {
|
|
912
|
+
nextGroup = extract(stack);
|
|
913
|
+
} else {
|
|
914
|
+
return result;
|
|
915
|
+
}
|
|
916
|
+
result[scriptGroup.type] = scriptGroup.value || null;
|
|
917
|
+
if (nextGroup) {
|
|
918
|
+
if (nextGroup.type === scriptGroup.type) {
|
|
919
|
+
throw new Error("Script: syntax error!");
|
|
920
|
+
}
|
|
921
|
+
result[nextGroup.type] = nextGroup.value || null;
|
|
922
|
+
}
|
|
923
|
+
return result;
|
|
924
|
+
}
|
|
925
|
+
function extract(stack) {
|
|
926
|
+
let forward = stack.shift();
|
|
927
|
+
if (!forward) {
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
if (forward.name === "subscript" || forward.name === "superscript") {
|
|
931
|
+
return {
|
|
932
|
+
type: forward.name,
|
|
933
|
+
value: stack.shift()
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
stack.unshift(forward);
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
_p[18] = {
|
|
942
|
+
value: function() {
|
|
943
|
+
return function(info, processedStack, unprocessedStack) {
|
|
944
|
+
let chars = unprocessedStack.shift();
|
|
945
|
+
if (typeof chars === "object" && chars.name === "combination") {
|
|
946
|
+
chars = chars.operand.join("");
|
|
947
|
+
}
|
|
948
|
+
info.name = "text";
|
|
949
|
+
info.attr = {
|
|
950
|
+
_reverse: "mathbb"
|
|
951
|
+
};
|
|
952
|
+
info.callFn = {
|
|
953
|
+
setFamily: ["KF AMS BB"]
|
|
954
|
+
};
|
|
955
|
+
info.operand = [chars];
|
|
956
|
+
delete info.handler;
|
|
957
|
+
return info;
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
_p[19] = {
|
|
962
|
+
value: function() {
|
|
963
|
+
return function(info, processedStack, unprocessedStack) {
|
|
964
|
+
let chars = unprocessedStack.shift();
|
|
965
|
+
if (typeof chars === "object" && chars.name === "combination") {
|
|
966
|
+
chars = chars.operand.join("");
|
|
967
|
+
}
|
|
968
|
+
info.name = "text";
|
|
969
|
+
info.attr = {
|
|
970
|
+
_reverse: "mathcal"
|
|
971
|
+
};
|
|
972
|
+
info.callFn = {
|
|
973
|
+
setFamily: ["KF AMS CAL"]
|
|
974
|
+
};
|
|
975
|
+
info.operand = [chars];
|
|
976
|
+
delete info.handler;
|
|
977
|
+
return info;
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
_p[20] = {
|
|
982
|
+
value: function() {
|
|
983
|
+
return function(info, processedStack, unprocessedStack) {
|
|
984
|
+
let chars = unprocessedStack.shift();
|
|
985
|
+
if (typeof chars === "object" && chars.name === "combination") {
|
|
986
|
+
chars = chars.operand.join("");
|
|
987
|
+
}
|
|
988
|
+
info.name = "text";
|
|
989
|
+
info.attr = {
|
|
990
|
+
_reverse: "mathfrak"
|
|
991
|
+
};
|
|
992
|
+
info.callFn = {
|
|
993
|
+
setFamily: ["KF AMS FRAK"]
|
|
994
|
+
};
|
|
995
|
+
info.operand = [chars];
|
|
996
|
+
delete info.handler;
|
|
997
|
+
return info;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
_p[21] = {
|
|
1002
|
+
value: function() {
|
|
1003
|
+
return function(info, processedStack, unprocessedStack) {
|
|
1004
|
+
let chars = unprocessedStack.shift();
|
|
1005
|
+
if (typeof chars === "object" && chars.name === "combination") {
|
|
1006
|
+
chars = chars.operand.join("");
|
|
1007
|
+
}
|
|
1008
|
+
info.name = "text";
|
|
1009
|
+
info.attr = {
|
|
1010
|
+
_reverse: "mathrm"
|
|
1011
|
+
};
|
|
1012
|
+
info.callFn = {
|
|
1013
|
+
setFamily: ["KF AMS ROMAN"]
|
|
1014
|
+
};
|
|
1015
|
+
info.operand = [chars];
|
|
1016
|
+
delete info.handler;
|
|
1017
|
+
return info;
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
_p[22] = {
|
|
1022
|
+
value: function() {
|
|
1023
|
+
return function(info, processedStack, unprocessedStack) {
|
|
1024
|
+
let base = processedStack.pop(), script = unprocessedStack.shift() || null;
|
|
1025
|
+
if (!script) {
|
|
1026
|
+
throw new Error("Missing script");
|
|
1027
|
+
}
|
|
1028
|
+
base = base || "";
|
|
1029
|
+
if (base.name === info.name || base.name === "script") {
|
|
1030
|
+
throw new Error("script error");
|
|
1031
|
+
}
|
|
1032
|
+
if (base.name === "subscript") {
|
|
1033
|
+
base.name = "script";
|
|
1034
|
+
base.operand[2] = base.operand[1];
|
|
1035
|
+
base.operand[1] = script;
|
|
1036
|
+
return base;
|
|
1037
|
+
} else if (base.name === "superscript") {
|
|
1038
|
+
base.name = "script";
|
|
1039
|
+
base.operand[2] = script;
|
|
1040
|
+
return base;
|
|
1041
|
+
}
|
|
1042
|
+
info.operand = [base, script];
|
|
1043
|
+
delete info.handler;
|
|
1044
|
+
return info;
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
_p[23] = {
|
|
1049
|
+
value: function(_require) {
|
|
1050
|
+
let mergeHandler = _p.r(13);
|
|
1051
|
+
return function(info, processedStack, unprocessedStack) {
|
|
1052
|
+
let exponent = unprocessedStack.shift(), tmp = null, radicand = null;
|
|
1053
|
+
if (exponent === "[") {
|
|
1054
|
+
exponent = [];
|
|
1055
|
+
while (tmp = unprocessedStack.shift()) {
|
|
1056
|
+
if (tmp === "]") {
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
exponent.push(tmp);
|
|
1060
|
+
}
|
|
1061
|
+
if (exponent.length === 0) {
|
|
1062
|
+
exponent = null;
|
|
1063
|
+
} else {
|
|
1064
|
+
exponent = mergeHandler(exponent);
|
|
1065
|
+
}
|
|
1066
|
+
radicand = unprocessedStack.shift();
|
|
1067
|
+
} else {
|
|
1068
|
+
radicand = exponent;
|
|
1069
|
+
exponent = null;
|
|
1070
|
+
}
|
|
1071
|
+
info.operand = [radicand, exponent];
|
|
1072
|
+
delete info.handler;
|
|
1073
|
+
return info;
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
_p[24] = {
|
|
1078
|
+
value: function(_require) {
|
|
1079
|
+
let ScriptExtractor = _p.r(17);
|
|
1080
|
+
return function(info, processedStack, unprocessedStack) {
|
|
1081
|
+
let params = ScriptExtractor.exec(unprocessedStack);
|
|
1082
|
+
info.operand = [params.expr, params.superscript, params.subscript];
|
|
1083
|
+
delete info.handler;
|
|
1084
|
+
return info;
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/parser-core.ts
|
|
1091
|
+
function registerParserCoreModule(context) {
|
|
1092
|
+
const { _p } = context;
|
|
1093
|
+
_p[43] = {
|
|
1094
|
+
value: function(_require, _exports, module) {
|
|
1095
|
+
const CONF = {};
|
|
1096
|
+
const IMPL_POLL = {};
|
|
1097
|
+
const extend = (target, ...sources) => {
|
|
1098
|
+
for (const source of sources) {
|
|
1099
|
+
for (const key in source) {
|
|
1100
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1101
|
+
target[key] = source[key];
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return target;
|
|
1106
|
+
};
|
|
1107
|
+
const setData = (container, key, value) => {
|
|
1108
|
+
if (typeof key === "string") {
|
|
1109
|
+
container[key] = value;
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (typeof key === "object") {
|
|
1113
|
+
for (const currentKey in key) {
|
|
1114
|
+
if (Object.prototype.hasOwnProperty.call(key, currentKey)) {
|
|
1115
|
+
container[currentKey] = key[currentKey];
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
throw new Error("invalid option");
|
|
1121
|
+
};
|
|
1122
|
+
class ParserInterface {
|
|
1123
|
+
constructor() {
|
|
1124
|
+
this.conf = {};
|
|
1125
|
+
}
|
|
1126
|
+
set(key, value) {
|
|
1127
|
+
extend(this.conf, key, value);
|
|
1128
|
+
}
|
|
1129
|
+
parse() {
|
|
1130
|
+
throw new Error("Abstract function");
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
class ParserProxy {
|
|
1134
|
+
constructor(ParserImpl) {
|
|
1135
|
+
this.impl = new ParserImpl();
|
|
1136
|
+
this.conf = {};
|
|
1137
|
+
}
|
|
1138
|
+
config(key, value) {
|
|
1139
|
+
setData(this.conf, key, value);
|
|
1140
|
+
return this;
|
|
1141
|
+
}
|
|
1142
|
+
set(key, value) {
|
|
1143
|
+
this.impl.set(key, value);
|
|
1144
|
+
return this;
|
|
1145
|
+
}
|
|
1146
|
+
parse(data) {
|
|
1147
|
+
const result = {
|
|
1148
|
+
config: {},
|
|
1149
|
+
tree: this.impl.parse(data)
|
|
1150
|
+
};
|
|
1151
|
+
extend(result.config, CONF, this.conf);
|
|
1152
|
+
return result;
|
|
1153
|
+
}
|
|
1154
|
+
serialization(tree, options) {
|
|
1155
|
+
return this.impl.serialization(tree, options);
|
|
1156
|
+
}
|
|
1157
|
+
expand(obj) {
|
|
1158
|
+
this.impl.expand(obj);
|
|
1159
|
+
return this;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
const Parser = {
|
|
1163
|
+
use(type) {
|
|
1164
|
+
if (!IMPL_POLL[type]) {
|
|
1165
|
+
throw new Error("unknown parser type");
|
|
1166
|
+
}
|
|
1167
|
+
return this.proxy(IMPL_POLL[type]);
|
|
1168
|
+
},
|
|
1169
|
+
config(key, value) {
|
|
1170
|
+
setData(CONF, key, value);
|
|
1171
|
+
return this;
|
|
1172
|
+
},
|
|
1173
|
+
register(type, parserImpl) {
|
|
1174
|
+
IMPL_POLL[type.toLowerCase()] = parserImpl;
|
|
1175
|
+
return this;
|
|
1176
|
+
},
|
|
1177
|
+
implement(parser) {
|
|
1178
|
+
const parserDefinition = { ...parser };
|
|
1179
|
+
const parserConstructor = parserDefinition.constructor || function() {
|
|
1180
|
+
};
|
|
1181
|
+
delete parserDefinition.constructor;
|
|
1182
|
+
class ParserImplementation extends ParserInterface {
|
|
1183
|
+
constructor() {
|
|
1184
|
+
super();
|
|
1185
|
+
parserConstructor.call(this);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
extend(ParserImplementation.prototype, parserDefinition);
|
|
1189
|
+
return ParserImplementation;
|
|
1190
|
+
},
|
|
1191
|
+
proxy(parserImpl) {
|
|
1192
|
+
return new ParserProxy(parserImpl);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
module.exports = {
|
|
1196
|
+
Parser,
|
|
1197
|
+
ParserInterface
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/runtime.ts
|
|
1204
|
+
function createLegacyParserModuleRegistry() {
|
|
1205
|
+
const modules = [];
|
|
1206
|
+
modules.r = function resolve(index) {
|
|
1207
|
+
if (modules[index].inited) {
|
|
1208
|
+
return modules[index].value;
|
|
1209
|
+
}
|
|
1210
|
+
if (typeof modules[index].value === "function") {
|
|
1211
|
+
const module = {
|
|
1212
|
+
exports: {}
|
|
1213
|
+
};
|
|
1214
|
+
const returnValue = modules[index].value(null, module.exports, module);
|
|
1215
|
+
modules[index].inited = true;
|
|
1216
|
+
modules[index].value = returnValue;
|
|
1217
|
+
if (returnValue !== void 0) {
|
|
1218
|
+
return returnValue;
|
|
1219
|
+
}
|
|
1220
|
+
for (const key in module.exports) {
|
|
1221
|
+
if (Object.prototype.hasOwnProperty.call(module.exports, key)) {
|
|
1222
|
+
modules[index].inited = true;
|
|
1223
|
+
modules[index].value = module.exports;
|
|
1224
|
+
return module.exports;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
} else {
|
|
1228
|
+
modules[index].inited = true;
|
|
1229
|
+
return modules[index].value;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
return modules;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// ../kity-runtime/src/vendor/kity-formula-parser/install.ts
|
|
1236
|
+
var installed = false;
|
|
1237
|
+
function installLegacyParserRuntime(target = window) {
|
|
1238
|
+
if (installed && target.kf?.Parser && target.kf?.Assembly) {
|
|
1239
|
+
return target.kf;
|
|
1240
|
+
}
|
|
1241
|
+
target.kf = target.kf ?? {};
|
|
1242
|
+
const context = {
|
|
1243
|
+
_p: createLegacyParserModuleRegistry(),
|
|
1244
|
+
window: target
|
|
1245
|
+
};
|
|
1246
|
+
registerAssemblyModule(context);
|
|
1247
|
+
registerLatexSupportModules(context);
|
|
1248
|
+
registerLatexParserModules(context);
|
|
1249
|
+
registerParserCoreModule(context);
|
|
1250
|
+
bootstrapLegacyParserRuntime(context);
|
|
1251
|
+
installed = true;
|
|
1252
|
+
return target.kf;
|
|
1253
|
+
}
|
|
1254
|
+
var install_default = installLegacyParserRuntime;
|
|
1255
|
+
export {
|
|
1256
|
+
install_default as default,
|
|
1257
|
+
installLegacyParserRuntime
|
|
1258
|
+
};
|
|
1259
|
+
/*!
|
|
1260
|
+
* Reverse parsing handler: brackets
|
|
1261
|
+
*/
|
|
1262
|
+
/*!
|
|
1263
|
+
* Reverse parsing handler: combination
|
|
1264
|
+
*/
|
|
1265
|
+
/*!
|
|
1266
|
+
* Reverse parsing handler: fraction
|
|
1267
|
+
*/
|
|
1268
|
+
/*!
|
|
1269
|
+
* Reverse parsing handler: func
|
|
1270
|
+
*/
|
|
1271
|
+
/*!
|
|
1272
|
+
* Reverse parsing handler: integration
|
|
1273
|
+
*/
|
|
1274
|
+
/*!
|
|
1275
|
+
* Reverse parsing handler: mathbb
|
|
1276
|
+
*/
|
|
1277
|
+
/*!
|
|
1278
|
+
* Reverse parsing handler: mathcal (mathscr)
|
|
1279
|
+
*/
|
|
1280
|
+
/*!
|
|
1281
|
+
* Reverse parsing handler: mathfrak
|
|
1282
|
+
*/
|
|
1283
|
+
/*!
|
|
1284
|
+
* Reverse parsing handler: mathrm
|
|
1285
|
+
*/
|
|
1286
|
+
/*!
|
|
1287
|
+
* Reverse parsing handler: script
|
|
1288
|
+
*/
|
|
1289
|
+
/*!
|
|
1290
|
+
* Reverse parsing handler: sqrt
|
|
1291
|
+
*/
|
|
1292
|
+
/*!
|
|
1293
|
+
* Reverse parsing handler: subscript
|
|
1294
|
+
*/
|
|
1295
|
+
/*!
|
|
1296
|
+
* Reverse parsing handler: summation
|
|
1297
|
+
*/
|
|
1298
|
+
/*!
|
|
1299
|
+
* Reverse parsing handler: superscript
|
|
1300
|
+
*/
|
|
1301
|
+
/*!
|
|
1302
|
+
* Kity Formula formula representation parser interface
|
|
1303
|
+
*/
|
|
1304
|
+
/*!
|
|
1305
|
+
* Reverse parsing mapping table
|
|
1306
|
+
*/
|
|
1307
|
+
/*!
|
|
1308
|
+
* Special character definition
|
|
1309
|
+
*/
|
|
1310
|
+
/*!
|
|
1311
|
+
* Bracket processor
|
|
1312
|
+
*/
|
|
1313
|
+
/*!
|
|
1314
|
+
* Merge processing (special processing function)
|
|
1315
|
+
*/
|
|
1316
|
+
/*!
|
|
1317
|
+
* Fraction function processor
|
|
1318
|
+
*/
|
|
1319
|
+
/*!
|
|
1320
|
+
* Function expression processor
|
|
1321
|
+
*/
|
|
1322
|
+
/*!
|
|
1323
|
+
* Integration function processor
|
|
1324
|
+
*/
|
|
1325
|
+
/*!
|
|
1326
|
+
* Common superscript/subscript extractor
|
|
1327
|
+
*/
|
|
1328
|
+
/*!
|
|
1329
|
+
* Double-struck processing
|
|
1330
|
+
*/
|
|
1331
|
+
/*!
|
|
1332
|
+
* Script/Cursive style processing
|
|
1333
|
+
*/
|
|
1334
|
+
/*!
|
|
1335
|
+
* Fraktur/Old German style processing
|
|
1336
|
+
*/
|
|
1337
|
+
/*!
|
|
1338
|
+
* Roman style processing
|
|
1339
|
+
*/
|
|
1340
|
+
/*!
|
|
1341
|
+
* Superscript/subscript operator function processing
|
|
1342
|
+
*/
|
|
1343
|
+
/*!
|
|
1344
|
+
* Square root function processor
|
|
1345
|
+
*/
|
|
1346
|
+
/*!
|
|
1347
|
+
* Summation function processor
|
|
1348
|
+
*/
|
|
1349
|
+
//# sourceMappingURL=install-XVTKACEN.js.map
|