@formulaxjs/kity-runtime 0.3.0 → 0.5.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 +33 -30
- package/README.zh-CN.md +44 -0
- package/dist/base.css +47 -0
- package/dist/{chunk-AOMNUFFB.js → chunk-EQCAHDH7.js} +98 -34
- package/dist/chunk-EQCAHDH7.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 +270 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +270 -185
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/{install-TIZBWEFU.js → install-WDCVVIMM.js} +34 -61
- package/dist/install-WDCVVIMM.js.map +1 -0
- package/dist/other.png +0 -0
- package/dist/scrollbar.css +78 -0
- package/dist/{start-LTYA5XON.js → start-N66J24A5.js} +88 -21
- package/dist/start-N66J24A5.js.map +1 -0
- package/dist/ui.css +625 -0
- package/package.json +7 -2
- package/public/assets/styles/ui.css +58 -26
- package/dist/chunk-AOMNUFFB.js.map +0 -1
- package/dist/install-TIZBWEFU.js.map +0 -1
- package/dist/start-LTYA5XON.js.map +0 -1
- /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
package/dist/index.global.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var FormulaX = (() => {
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
7
15
|
var __esm = (fn, res) => function __init() {
|
|
8
16
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
17
|
};
|
|
@@ -19,98 +27,42 @@ var FormulaX = (() => {
|
|
|
19
27
|
}
|
|
20
28
|
return to;
|
|
21
29
|
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
22
38
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
39
|
|
|
24
|
-
// public/assets/images/toolbar/btn.png
|
|
25
|
-
var btn_default;
|
|
26
|
-
var init_btn = __esm({
|
|
27
|
-
"public/assets/images/toolbar/btn.png"() {
|
|
28
|
-
btn_default = "./btn-5DANP6JY.png";
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// public/assets/images/toolbar/other.png
|
|
33
|
-
var other_default;
|
|
34
|
-
var init_other = __esm({
|
|
35
|
-
"public/assets/images/toolbar/other.png"() {
|
|
36
|
-
other_default = "./other-OMWJFGL5.png";
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// public/assets/styles/editor.css?url
|
|
41
|
-
var editor_default;
|
|
42
|
-
var init_editor = __esm({
|
|
43
|
-
"public/assets/styles/editor.css?url"() {
|
|
44
|
-
editor_default = "./editor-JT5KLVXX.css?url";
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// public/resource/KF_AMS_BB.woff
|
|
49
|
-
var KF_AMS_BB_default;
|
|
50
|
-
var init_KF_AMS_BB = __esm({
|
|
51
|
-
"public/resource/KF_AMS_BB.woff"() {
|
|
52
|
-
KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// public/resource/KF_AMS_CAL.woff
|
|
57
|
-
var KF_AMS_CAL_default;
|
|
58
|
-
var init_KF_AMS_CAL = __esm({
|
|
59
|
-
"public/resource/KF_AMS_CAL.woff"() {
|
|
60
|
-
KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// public/resource/KF_AMS_FRAK.woff
|
|
65
|
-
var KF_AMS_FRAK_default;
|
|
66
|
-
var init_KF_AMS_FRAK = __esm({
|
|
67
|
-
"public/resource/KF_AMS_FRAK.woff"() {
|
|
68
|
-
KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// public/resource/KF_AMS_MAIN.woff
|
|
73
|
-
var KF_AMS_MAIN_default;
|
|
74
|
-
var init_KF_AMS_MAIN = __esm({
|
|
75
|
-
"public/resource/KF_AMS_MAIN.woff"() {
|
|
76
|
-
KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// public/resource/KF_AMS_ROMAN.woff
|
|
81
|
-
var KF_AMS_ROMAN_default;
|
|
82
|
-
var init_KF_AMS_ROMAN = __esm({
|
|
83
|
-
"public/resource/KF_AMS_ROMAN.woff"() {
|
|
84
|
-
KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
40
|
// src/asset-manifest.ts
|
|
89
|
-
var kityFontAssets, kityToolbarAssets, kityStyleAssets, kityAssetManifest;
|
|
41
|
+
var import_btn, import_other, import_editor, import_KF_AMS_BB, import_KF_AMS_CAL, import_KF_AMS_FRAK, import_KF_AMS_MAIN, import_KF_AMS_ROMAN, kityFontAssets, kityToolbarAssets, kityStyleAssets, kityAssetManifest;
|
|
90
42
|
var init_asset_manifest = __esm({
|
|
91
43
|
"src/asset-manifest.ts"() {
|
|
92
44
|
"use strict";
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
45
|
+
import_btn = __toESM(__require("./btn.png"), 1);
|
|
46
|
+
import_other = __toESM(__require("./other.png"), 1);
|
|
47
|
+
import_editor = __toESM(__require("./editor.css?url"), 1);
|
|
48
|
+
import_KF_AMS_BB = __toESM(__require("./KF_AMS_BB.woff"), 1);
|
|
49
|
+
import_KF_AMS_CAL = __toESM(__require("./KF_AMS_CAL.woff"), 1);
|
|
50
|
+
import_KF_AMS_FRAK = __toESM(__require("./KF_AMS_FRAK.woff"), 1);
|
|
51
|
+
import_KF_AMS_MAIN = __toESM(__require("./KF_AMS_MAIN.woff"), 1);
|
|
52
|
+
import_KF_AMS_ROMAN = __toESM(__require("./KF_AMS_ROMAN.woff"), 1);
|
|
101
53
|
kityFontAssets = {
|
|
102
|
-
KF_AMS_BB:
|
|
103
|
-
KF_AMS_CAL:
|
|
104
|
-
KF_AMS_FRAK:
|
|
105
|
-
KF_AMS_MAIN:
|
|
106
|
-
KF_AMS_ROMAN:
|
|
54
|
+
KF_AMS_BB: import_KF_AMS_BB.default,
|
|
55
|
+
KF_AMS_CAL: import_KF_AMS_CAL.default,
|
|
56
|
+
KF_AMS_FRAK: import_KF_AMS_FRAK.default,
|
|
57
|
+
KF_AMS_MAIN: import_KF_AMS_MAIN.default,
|
|
58
|
+
KF_AMS_ROMAN: import_KF_AMS_ROMAN.default
|
|
107
59
|
};
|
|
108
60
|
kityToolbarAssets = {
|
|
109
|
-
btn:
|
|
110
|
-
other:
|
|
61
|
+
btn: import_btn.default,
|
|
62
|
+
other: import_other.default
|
|
111
63
|
};
|
|
112
64
|
kityStyleAssets = {
|
|
113
|
-
editor:
|
|
65
|
+
editor: import_editor.default
|
|
114
66
|
};
|
|
115
67
|
kityAssetManifest = {
|
|
116
68
|
fonts: kityFontAssets,
|
|
@@ -5072,6 +5024,87 @@ var FormulaX = (() => {
|
|
|
5072
5024
|
}
|
|
5073
5025
|
});
|
|
5074
5026
|
|
|
5027
|
+
// src/i18n.ts
|
|
5028
|
+
function normalizeFormulaXLocale(locale) {
|
|
5029
|
+
if (locale === "zh_CN") {
|
|
5030
|
+
return "zh_CN";
|
|
5031
|
+
}
|
|
5032
|
+
return DEFAULT_FORMULAX_LOCALE;
|
|
5033
|
+
}
|
|
5034
|
+
function translateFormulaXText(namespace, value, locale) {
|
|
5035
|
+
if (locale === "zh_CN") {
|
|
5036
|
+
return value;
|
|
5037
|
+
}
|
|
5038
|
+
const normalizedValue = value.replace(/<br\s*\/?>/gi, "").trim();
|
|
5039
|
+
const translatedValue = FORMULAX_TRANSLATIONS[locale]?.[namespace]?.[normalizedValue];
|
|
5040
|
+
if (!translatedValue) {
|
|
5041
|
+
return value;
|
|
5042
|
+
}
|
|
5043
|
+
const lineBreakMatch = value.match(/<br\s*\/?>/i);
|
|
5044
|
+
if (/<br\s*\/?>/i.test(translatedValue)) {
|
|
5045
|
+
return translatedValue;
|
|
5046
|
+
}
|
|
5047
|
+
return lineBreakMatch ? `${translatedValue}${lineBreakMatch[0]}` : translatedValue;
|
|
5048
|
+
}
|
|
5049
|
+
function getFormulaXRuntimeMessage(key, locale = DEFAULT_FORMULAX_LOCALE) {
|
|
5050
|
+
const normalizedLocale = normalizeFormulaXLocale(locale);
|
|
5051
|
+
return FORMULAX_RUNTIME_MESSAGES[normalizedLocale][key] ?? FORMULAX_RUNTIME_MESSAGES[DEFAULT_FORMULAX_LOCALE][key];
|
|
5052
|
+
}
|
|
5053
|
+
var FORMULAX_LOCALES, DEFAULT_FORMULAX_LOCALE, FORMULAX_TRANSLATIONS, FORMULAX_RUNTIME_MESSAGES;
|
|
5054
|
+
var init_i18n = __esm({
|
|
5055
|
+
"src/i18n.ts"() {
|
|
5056
|
+
"use strict";
|
|
5057
|
+
FORMULAX_LOCALES = ["en_US", "zh_CN"];
|
|
5058
|
+
DEFAULT_FORMULAX_LOCALE = "en_US";
|
|
5059
|
+
FORMULAX_TRANSLATIONS = {
|
|
5060
|
+
en_US: {
|
|
5061
|
+
toolbar: {
|
|
5062
|
+
\u9884\u8BBE: "Presets",
|
|
5063
|
+
\u9884\u8BBE\u516C\u5F0F: "Presets",
|
|
5064
|
+
\u4E8C\u6B21\u516C\u5F0F: "Quadratic",
|
|
5065
|
+
\u4E8C\u9879\u5F0F\u5B9A\u7406: "Binomial",
|
|
5066
|
+
\u52FE\u80A1\u5B9A\u7406: "Pythagorean",
|
|
5067
|
+
\u57FA\u7840\u6570\u5B66: "Basic math",
|
|
5068
|
+
\u5E0C\u814A\u5B57\u6BCD: "Greek",
|
|
5069
|
+
\u6C42\u53CD\u5173\u7CFB\u8FD0\u7B97\u7B26: "Negated operators",
|
|
5070
|
+
\u5B57\u6BCD\u7C7B\u7B26\u53F7: "Letter symbols",
|
|
5071
|
+
\u7BAD\u5934: "Arrows",
|
|
5072
|
+
\u624B\u5199\u4F53: "Script",
|
|
5073
|
+
\u5206\u6570: "Fraction",
|
|
5074
|
+
\u5E38\u7528\u5206\u6570: "Common fractions",
|
|
5075
|
+
\u4E0A\u4E0B\u6807: "Scripts",
|
|
5076
|
+
\u4E0A\u6807\u548C\u4E0B\u6807: "Super/subscripts",
|
|
5077
|
+
\u5E38\u7528\u7684\u4E0A\u6807\u548C\u4E0B\u6807: "Common super/subscripts",
|
|
5078
|
+
\u6839\u5F0F: "Radicals",
|
|
5079
|
+
\u5E38\u7528\u6839\u5F0F: "Common radicals",
|
|
5080
|
+
\u79EF\u5206: "Integrals",
|
|
5081
|
+
\u5927\u578B\u8FD0\u7B97\u7B26: "Large<br/>ops",
|
|
5082
|
+
\u6C42\u548C: "Summations",
|
|
5083
|
+
\u62EC\u53F7: "Brackets",
|
|
5084
|
+
\u65B9\u62EC\u53F7: "Brackets",
|
|
5085
|
+
\u51FD\u6570: "Functions",
|
|
5086
|
+
\u4E09\u89D2\u51FD\u6570: "Trig functions",
|
|
5087
|
+
\u5E38\u7528\u51FD\u6570: "Common functions",
|
|
5088
|
+
\u5C0F\u5199: "Lowercase",
|
|
5089
|
+
\u5927\u5199: "Uppercase",
|
|
5090
|
+
\u53D8\u4F53: "Variants",
|
|
5091
|
+
\u82B1\u4F53: "Fraktur",
|
|
5092
|
+
\u53CC\u7EBF: "Double-struck",
|
|
5093
|
+
\u7F57\u9A6C: "Roman"
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
};
|
|
5097
|
+
FORMULAX_RUNTIME_MESSAGES = {
|
|
5098
|
+
en_US: {
|
|
5099
|
+
"editor.placeholder.root": "Type formula here"
|
|
5100
|
+
},
|
|
5101
|
+
zh_CN: {
|
|
5102
|
+
"editor.placeholder.root": "\u8BF7\u8F93\u5165\u516C\u5F0F"
|
|
5103
|
+
}
|
|
5104
|
+
};
|
|
5105
|
+
}
|
|
5106
|
+
});
|
|
5107
|
+
|
|
5075
5108
|
// src/vendor/kity-formula/binary-expression.ts
|
|
5076
5109
|
var BinaryExpressionModule, createBinaryExpressionClass;
|
|
5077
5110
|
var init_binary_expression = __esm({
|
|
@@ -5936,15 +5969,13 @@ var FormulaX = (() => {
|
|
|
5936
5969
|
});
|
|
5937
5970
|
|
|
5938
5971
|
// src/vendor/kity-formula/font-installer.ts
|
|
5939
|
-
var
|
|
5972
|
+
var FontInstallerModule, createFontInstallerClass;
|
|
5940
5973
|
var init_font_installer = __esm({
|
|
5941
5974
|
"src/vendor/kity-formula/font-installer.ts"() {
|
|
5942
5975
|
"use strict";
|
|
5943
|
-
MAIN_FONT_FAMILY = "KF AMS MAIN";
|
|
5944
5976
|
FontInstallerModule = class {
|
|
5945
5977
|
static create(kity26, FontManager, fontConfig, checkerTemplate) {
|
|
5946
5978
|
let nodeList = [];
|
|
5947
|
-
let checkerNode = null;
|
|
5948
5979
|
return kity26.createClass("FontInstaller", {
|
|
5949
5980
|
constructor: function(doc, resource) {
|
|
5950
5981
|
const normalized = typeof resource === "string" ? { path: resource } : resource ?? {};
|
|
@@ -5954,26 +5985,22 @@ var FormulaX = (() => {
|
|
|
5954
5985
|
},
|
|
5955
5986
|
mount: function(callback) {
|
|
5956
5987
|
const fontList = FontManager.getFontList();
|
|
5988
|
+
let count = 0;
|
|
5957
5989
|
kity26.Utils.each(fontList, (fontInfo) => {
|
|
5990
|
+
count += 1;
|
|
5958
5991
|
fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
|
|
5959
5992
|
this.createFontStyle(fontInfo);
|
|
5960
|
-
if (fontInfo.meta.fontFamily === MAIN_FONT_FAMILY) {
|
|
5961
|
-
checkerNode = createFontCheckerNode(this.doc);
|
|
5962
|
-
return;
|
|
5963
|
-
}
|
|
5964
5993
|
applyFonts(this.doc, fontInfo);
|
|
5994
|
+
count -= 1;
|
|
5995
|
+
if (count === 0) {
|
|
5996
|
+
complete(this.doc, callback);
|
|
5997
|
+
}
|
|
5965
5998
|
});
|
|
5966
|
-
complete(this.doc, callback);
|
|
5967
5999
|
},
|
|
5968
6000
|
createFontStyle: function(fontInfo) {
|
|
5969
|
-
const styleId = createFontStyleId(fontInfo);
|
|
5970
|
-
if (this.doc.getElementById(styleId)) {
|
|
5971
|
-
return;
|
|
5972
|
-
}
|
|
5973
6001
|
const stylesheet = this.doc.createElement("style");
|
|
5974
6002
|
const tpl = '@font-face{\nfont-family: "${fontFamily}";\nsrc: url("${src}");\n}';
|
|
5975
6003
|
stylesheet.setAttribute("type", "text/css");
|
|
5976
|
-
stylesheet.id = styleId;
|
|
5977
6004
|
stylesheet.innerHTML = tpl.replace("${fontFamily}", fontInfo.meta.fontFamily).replace("${src}", fontInfo.meta.src);
|
|
5978
6005
|
this.doc.head.appendChild(stylesheet);
|
|
5979
6006
|
}
|
|
@@ -5990,29 +6017,34 @@ var FormulaX = (() => {
|
|
|
5990
6017
|
}
|
|
5991
6018
|
return resourceBase + originalSrc;
|
|
5992
6019
|
}
|
|
5993
|
-
function
|
|
5994
|
-
const raw = `${fontInfo.meta.fontFamily}::${fontInfo.meta.src}`;
|
|
5995
|
-
let hash = 0;
|
|
5996
|
-
for (let index = 0; index < raw.length; index += 1) {
|
|
5997
|
-
hash = (hash << 5) - hash + raw.charCodeAt(index) | 0;
|
|
5998
|
-
}
|
|
5999
|
-
return `formulax-kity-font-${Math.abs(hash).toString(36)}`;
|
|
6000
|
-
}
|
|
6001
|
-
function waitForFontsReady(doc) {
|
|
6020
|
+
function waitForFontsReady(doc, fontList) {
|
|
6002
6021
|
const view = doc.defaultView ?? window;
|
|
6003
6022
|
if (view.document.fonts) {
|
|
6004
|
-
|
|
6023
|
+
const fontLoadPromises = fontList.map((fontInfo) => {
|
|
6024
|
+
return view.document.fonts.load(`50px "${fontInfo.meta.fontFamily}"`);
|
|
6025
|
+
});
|
|
6026
|
+
return Promise.all(fontLoadPromises).then(() => view.document.fonts.ready).then(() => {
|
|
6027
|
+
return new Promise((resolve) => {
|
|
6028
|
+
requestAnimationFrame(() => {
|
|
6029
|
+
requestAnimationFrame(() => {
|
|
6030
|
+
resolve();
|
|
6031
|
+
});
|
|
6032
|
+
});
|
|
6033
|
+
});
|
|
6034
|
+
});
|
|
6005
6035
|
}
|
|
6006
6036
|
return Promise.resolve();
|
|
6007
6037
|
}
|
|
6008
6038
|
function complete(doc, callback) {
|
|
6009
6039
|
const view = doc.defaultView ?? window;
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6040
|
+
const fontList = FontManager.getFontList();
|
|
6041
|
+
const fontArray = Object.values(fontList);
|
|
6042
|
+
waitForFontsReady(doc, fontArray).then(() => {
|
|
6043
|
+
view.setTimeout(() => {
|
|
6044
|
+
initFontSystemInfo(doc);
|
|
6045
|
+
removeTmpNode();
|
|
6046
|
+
callback();
|
|
6047
|
+
}, 100);
|
|
6016
6048
|
}).catch(() => {
|
|
6017
6049
|
view.setTimeout(() => {
|
|
6018
6050
|
initFontSystemInfo(doc);
|
|
@@ -6033,37 +6065,12 @@ var FormulaX = (() => {
|
|
|
6033
6065
|
doc.body.appendChild(node);
|
|
6034
6066
|
nodeList.push(node);
|
|
6035
6067
|
}
|
|
6036
|
-
function createFontCheckerNode(doc) {
|
|
6037
|
-
if (checkerNode) {
|
|
6038
|
-
return checkerNode;
|
|
6039
|
-
}
|
|
6040
|
-
const node = doc.createElement("div");
|
|
6041
|
-
node.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
6042
|
-
node.innerHTML = checkerTemplate.join("");
|
|
6043
|
-
doc.body.appendChild(node);
|
|
6044
|
-
checkerNode = node;
|
|
6045
|
-
return node;
|
|
6046
|
-
}
|
|
6047
|
-
function waitForNextFrames(view, frameCount) {
|
|
6048
|
-
if (typeof view.requestAnimationFrame !== "function") {
|
|
6049
|
-
return Promise.resolve();
|
|
6050
|
-
}
|
|
6051
|
-
return new Promise((resolve) => {
|
|
6052
|
-
const step = (remaining) => {
|
|
6053
|
-
if (remaining <= 0) {
|
|
6054
|
-
resolve();
|
|
6055
|
-
return;
|
|
6056
|
-
}
|
|
6057
|
-
view.requestAnimationFrame(() => {
|
|
6058
|
-
step(remaining - 1);
|
|
6059
|
-
});
|
|
6060
|
-
};
|
|
6061
|
-
step(frameCount);
|
|
6062
|
-
});
|
|
6063
|
-
}
|
|
6064
6068
|
function initFontSystemInfo(doc) {
|
|
6065
|
-
const
|
|
6066
|
-
|
|
6069
|
+
const tmpNode = doc.createElement("div");
|
|
6070
|
+
tmpNode.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
6071
|
+
tmpNode.innerHTML = checkerTemplate.join("");
|
|
6072
|
+
doc.body.appendChild(tmpNode);
|
|
6073
|
+
const rectBox = tmpNode.getElementsByTagName("text")[0].getBBox();
|
|
6067
6074
|
fontConfig.spaceHeight = rectBox.height;
|
|
6068
6075
|
fontConfig.topSpace = -rectBox.y - fontConfig.baseline;
|
|
6069
6076
|
fontConfig.bottomSpace = fontConfig.spaceHeight - fontConfig.topSpace - fontConfig.baseHeight;
|
|
@@ -6072,8 +6079,7 @@ var FormulaX = (() => {
|
|
|
6072
6079
|
fontConfig.meanlinePosition = (fontConfig.topSpace + fontConfig.meanline) / fontConfig.spaceHeight;
|
|
6073
6080
|
fontConfig.ascenderPosition = fontConfig.topSpace / fontConfig.spaceHeight;
|
|
6074
6081
|
fontConfig.descenderPosition = (fontConfig.topSpace + fontConfig.baseHeight) / fontConfig.spaceHeight;
|
|
6075
|
-
|
|
6076
|
-
checkerNode = null;
|
|
6082
|
+
doc.body.removeChild(tmpNode);
|
|
6077
6083
|
}
|
|
6078
6084
|
function removeTmpNode() {
|
|
6079
6085
|
kity26.Utils.each(nodeList, (node) => {
|
|
@@ -6156,11 +6162,11 @@ var FormulaX = (() => {
|
|
|
6156
6162
|
bg;
|
|
6157
6163
|
exp;
|
|
6158
6164
|
config;
|
|
6159
|
-
constructor(kity26, exp,
|
|
6165
|
+
constructor(kity26, exp, config) {
|
|
6160
6166
|
this.wrap = new kity26.Group();
|
|
6161
6167
|
this.bg = new kity26.Rect(0, 0, 0, 0).fill("transparent");
|
|
6162
6168
|
this.exp = exp;
|
|
6163
|
-
this.config =
|
|
6169
|
+
this.config = config;
|
|
6164
6170
|
this.wrap.setAttr("data-type", "kf-exp-wrap");
|
|
6165
6171
|
this.bg.setAttr("data-type", "kf-exp-wrap-bg");
|
|
6166
6172
|
this.wrap.addShape(this.bg);
|
|
@@ -6189,14 +6195,14 @@ var FormulaX = (() => {
|
|
|
6189
6195
|
static create(kity26, GTYPE2, FontManager, FontInstaller, FPaper, Output) {
|
|
6190
6196
|
const Formula = kity26.createClass("Formula", {
|
|
6191
6197
|
base: FPaper,
|
|
6192
|
-
constructor: function(container,
|
|
6198
|
+
constructor: function(container, config) {
|
|
6193
6199
|
if (this.__FORMULAX_PRESERVE_CALL_BASE__) {
|
|
6194
6200
|
this.callBase(container);
|
|
6195
6201
|
}
|
|
6196
6202
|
FPaper.call(this, container);
|
|
6197
6203
|
this.expressions = [];
|
|
6198
6204
|
this.fontInstaller = new FontInstaller(this);
|
|
6199
|
-
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS,
|
|
6205
|
+
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS, config);
|
|
6200
6206
|
this.initEnvironment();
|
|
6201
6207
|
this.initInnerFont();
|
|
6202
6208
|
},
|
|
@@ -13661,7 +13667,7 @@ var FormulaX = (() => {
|
|
|
13661
13667
|
value: function() {
|
|
13662
13668
|
const kf7 = window2.kf;
|
|
13663
13669
|
const CONSTRUCT_MAPPING = {};
|
|
13664
|
-
const
|
|
13670
|
+
const CURSOR_CHAR4 = "\uF155";
|
|
13665
13671
|
class Assembly {
|
|
13666
13672
|
formula;
|
|
13667
13673
|
constructor(formula) {
|
|
@@ -13698,7 +13704,7 @@ var FormulaX = (() => {
|
|
|
13698
13704
|
if (tree.name.indexOf("text") === -1) {
|
|
13699
13705
|
for (let i2 = 0, len = operand.length; i2 < len; i2 += 1) {
|
|
13700
13706
|
currentOperand = operand[i2];
|
|
13701
|
-
if (currentOperand ===
|
|
13707
|
+
if (currentOperand === CURSOR_CHAR4) {
|
|
13702
13708
|
cursorLocation.push(i2);
|
|
13703
13709
|
if (!Object.prototype.hasOwnProperty.call(selectInfo, "startOffset")) {
|
|
13704
13710
|
selectInfo.startOffset = i2;
|
|
@@ -14992,8 +14998,8 @@ var FormulaX = (() => {
|
|
|
14992
14998
|
}
|
|
14993
14999
|
return serviceObject;
|
|
14994
15000
|
}
|
|
14995
|
-
var defaultOptions, components, kity2, kf, KFEditor,
|
|
14996
|
-
var
|
|
15001
|
+
var defaultOptions, components, kity2, kf, KFEditor, editor_default;
|
|
15002
|
+
var init_editor = __esm({
|
|
14997
15003
|
"src/legacy/editor.ts"() {
|
|
14998
15004
|
"use strict";
|
|
14999
15005
|
init_legacy_utils();
|
|
@@ -15104,7 +15110,7 @@ var FormulaX = (() => {
|
|
|
15104
15110
|
components[name] = component;
|
|
15105
15111
|
}
|
|
15106
15112
|
});
|
|
15107
|
-
|
|
15113
|
+
editor_default = KFEditor;
|
|
15108
15114
|
}
|
|
15109
15115
|
});
|
|
15110
15116
|
|
|
@@ -15113,13 +15119,13 @@ var FormulaX = (() => {
|
|
|
15113
15119
|
var init_factory = __esm({
|
|
15114
15120
|
"src/legacy/factory.ts"() {
|
|
15115
15121
|
"use strict";
|
|
15116
|
-
|
|
15122
|
+
init_editor();
|
|
15117
15123
|
init_runtime_interop();
|
|
15118
15124
|
EditorWrapper = class {
|
|
15119
15125
|
callbacks = [];
|
|
15120
15126
|
editor;
|
|
15121
15127
|
constructor(container, options) {
|
|
15122
|
-
this.editor = new
|
|
15128
|
+
this.editor = new editor_default(container, options);
|
|
15123
15129
|
this.editor.ready(() => {
|
|
15124
15130
|
this.trigger();
|
|
15125
15131
|
});
|
|
@@ -16687,6 +16693,7 @@ var FormulaX = (() => {
|
|
|
16687
16693
|
to: "\u2192",
|
|
16688
16694
|
downarrow: "\u2193",
|
|
16689
16695
|
leftrightarrow: "\u2194",
|
|
16696
|
+
updownarrow: "\u2195",
|
|
16690
16697
|
therefore: "\u2234",
|
|
16691
16698
|
because: "\u2235",
|
|
16692
16699
|
"+": "+",
|
|
@@ -16803,7 +16810,7 @@ var FormulaX = (() => {
|
|
|
16803
16810
|
Uparrow: "\u21D1",
|
|
16804
16811
|
Downarrow: "\u21D3",
|
|
16805
16812
|
Leftrightarrow: "\u21D4",
|
|
16806
|
-
Updownarrow: "\
|
|
16813
|
+
Updownarrow: "\u21D5",
|
|
16807
16814
|
longleftarrow: "\u27F5",
|
|
16808
16815
|
longrightarrow: "\u27F6",
|
|
16809
16816
|
longleftrightarrow: "\u27F7",
|
|
@@ -16870,6 +16877,26 @@ var FormulaX = (() => {
|
|
|
16870
16877
|
}
|
|
16871
16878
|
Object.keys(list).forEach((key) => callback(list[key], key));
|
|
16872
16879
|
}
|
|
16880
|
+
function translateToolbarText(value, locale) {
|
|
16881
|
+
return translateFormulaXText("toolbar", value, locale);
|
|
16882
|
+
}
|
|
16883
|
+
function localizeToolbarConfig(value, locale) {
|
|
16884
|
+
if (Array.isArray(value)) {
|
|
16885
|
+
return value.map((item) => localizeToolbarConfig(item, locale));
|
|
16886
|
+
}
|
|
16887
|
+
if (!value || typeof value !== "object") {
|
|
16888
|
+
return value;
|
|
16889
|
+
}
|
|
16890
|
+
const result = {};
|
|
16891
|
+
for (const [key, currentValue] of Object.entries(value)) {
|
|
16892
|
+
if ((key === "label" || key === "title") && typeof currentValue === "string") {
|
|
16893
|
+
result[key] = translateToolbarText(currentValue, locale);
|
|
16894
|
+
continue;
|
|
16895
|
+
}
|
|
16896
|
+
result[key] = localizeToolbarConfig(currentValue, locale);
|
|
16897
|
+
}
|
|
16898
|
+
return result;
|
|
16899
|
+
}
|
|
16873
16900
|
function getUnicodeContents(keySet) {
|
|
16874
16901
|
let result = [];
|
|
16875
16902
|
each(keySet, function(key) {
|
|
@@ -16889,7 +16916,13 @@ var FormulaX = (() => {
|
|
|
16889
16916
|
});
|
|
16890
16917
|
return result;
|
|
16891
16918
|
}
|
|
16892
|
-
|
|
16919
|
+
function createToolbarConfig(locale = DEFAULT_FORMULAX_LOCALE) {
|
|
16920
|
+
return localizeToolbarConfig(
|
|
16921
|
+
baseToolbarConfig,
|
|
16922
|
+
normalizeFormulaXLocale(locale)
|
|
16923
|
+
);
|
|
16924
|
+
}
|
|
16925
|
+
var UI_ELE_TYPE, BOX_TYPE2, OTHER_POSITION, baseToolbarConfig, toolbar_config_default;
|
|
16893
16926
|
var init_toolbar_config = __esm({
|
|
16894
16927
|
"src/legacy/toolbar-config.ts"() {
|
|
16895
16928
|
"use strict";
|
|
@@ -16898,10 +16931,11 @@ var FormulaX = (() => {
|
|
|
16898
16931
|
init_other_position();
|
|
16899
16932
|
init_toolbar_assets();
|
|
16900
16933
|
init_formula_symbols();
|
|
16934
|
+
init_i18n();
|
|
16901
16935
|
UI_ELE_TYPE = legacyEleType;
|
|
16902
16936
|
BOX_TYPE2 = legacyBoxType;
|
|
16903
16937
|
OTHER_POSITION = legacyOtherPosition;
|
|
16904
|
-
|
|
16938
|
+
baseToolbarConfig = [{
|
|
16905
16939
|
type: UI_ELE_TYPE.DRAPDOWN_BOX,
|
|
16906
16940
|
options: {
|
|
16907
16941
|
button: {
|
|
@@ -17307,7 +17341,7 @@ var FormulaX = (() => {
|
|
|
17307
17341
|
}];
|
|
17308
17342
|
(function() {
|
|
17309
17343
|
let tmp = [], otherImageSrc = resolveToolbarAssetPath("other.png"), currentConf = [];
|
|
17310
|
-
each(
|
|
17344
|
+
each(baseToolbarConfig, function(conf) {
|
|
17311
17345
|
if (conf.type === UI_ELE_TYPE.DELIMITER) {
|
|
17312
17346
|
return;
|
|
17313
17347
|
}
|
|
@@ -17379,7 +17413,7 @@ var FormulaX = (() => {
|
|
|
17379
17413
|
"aleph",
|
|
17380
17414
|
"beth",
|
|
17381
17415
|
"blacksquare"
|
|
17382
|
-
], configList =
|
|
17416
|
+
], configList = baseToolbarConfig[2].options.box.group[0].items;
|
|
17383
17417
|
configList.push({
|
|
17384
17418
|
title: "\u57FA\u7840\u6570\u5B66",
|
|
17385
17419
|
content: getUnicodeContents(list)
|
|
@@ -17395,7 +17429,7 @@ var FormulaX = (() => {
|
|
|
17395
17429
|
}, {
|
|
17396
17430
|
title: "\u53D8\u4F53",
|
|
17397
17431
|
values: ["digamma", "varepsilon", "varkappa", "varphi", "varpi", "varrho", "varsigma", "vartheta"]
|
|
17398
|
-
}], greekConfigList =
|
|
17432
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[1].items;
|
|
17399
17433
|
greekConfigList.push({
|
|
17400
17434
|
title: greekList[0].title,
|
|
17401
17435
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -17444,7 +17478,7 @@ var FormulaX = (() => {
|
|
|
17444
17478
|
"nVDash",
|
|
17445
17479
|
"nexists"
|
|
17446
17480
|
]
|
|
17447
|
-
}], greekConfigList =
|
|
17481
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[2].items;
|
|
17448
17482
|
greekConfigList.push({
|
|
17449
17483
|
title: greekList[0].title,
|
|
17450
17484
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -17470,7 +17504,7 @@ var FormulaX = (() => {
|
|
|
17470
17504
|
"Game",
|
|
17471
17505
|
"Im",
|
|
17472
17506
|
"Re"
|
|
17473
|
-
], configList =
|
|
17507
|
+
], configList = baseToolbarConfig[2].options.box.group[3].items;
|
|
17474
17508
|
configList.push({
|
|
17475
17509
|
title: "\u5B57\u6BCD\u7C7B\u7B26\u53F7",
|
|
17476
17510
|
content: getUnicodeContents(list)
|
|
@@ -17538,7 +17572,7 @@ var FormulaX = (() => {
|
|
|
17538
17572
|
"twoheadleftarrow",
|
|
17539
17573
|
"twoheadrightarrow",
|
|
17540
17574
|
"rightsquigarrow"
|
|
17541
|
-
], configList =
|
|
17575
|
+
], configList = baseToolbarConfig[2].options.box.group[4].items;
|
|
17542
17576
|
configList.push({
|
|
17543
17577
|
title: "\u7BAD\u5934",
|
|
17544
17578
|
content: getUnicodeContents(list)
|
|
@@ -17717,7 +17751,7 @@ var FormulaX = (() => {
|
|
|
17717
17751
|
"y",
|
|
17718
17752
|
"z"
|
|
17719
17753
|
]
|
|
17720
|
-
}], configList =
|
|
17754
|
+
}], configList = baseToolbarConfig[2].options.box.group[5].items;
|
|
17721
17755
|
each(list[0].values, function(item, index) {
|
|
17722
17756
|
list[0].values[index] = "mathcal{" + item + "}";
|
|
17723
17757
|
});
|
|
@@ -17747,7 +17781,7 @@ var FormulaX = (() => {
|
|
|
17747
17781
|
content: getUnicodeContents(list[3].values)
|
|
17748
17782
|
});
|
|
17749
17783
|
})();
|
|
17750
|
-
toolbar_config_default =
|
|
17784
|
+
toolbar_config_default = createToolbarConfig;
|
|
17751
17785
|
}
|
|
17752
17786
|
});
|
|
17753
17787
|
|
|
@@ -17790,6 +17824,7 @@ var FormulaX = (() => {
|
|
|
17790
17824
|
init_toolbar();
|
|
17791
17825
|
init_scrollbar();
|
|
17792
17826
|
init_toolbar_config();
|
|
17827
|
+
init_i18n();
|
|
17793
17828
|
$$8 = createLegacyUiUtils();
|
|
17794
17829
|
VIEW_STATE = legacyUiDef.VIEW_STATE;
|
|
17795
17830
|
DEFAULT_EDIT_AREA_HEIGHT = 100;
|
|
@@ -17820,7 +17855,8 @@ var FormulaX = (() => {
|
|
|
17820
17855
|
this.initScrollEvent();
|
|
17821
17856
|
},
|
|
17822
17857
|
initComponents() {
|
|
17823
|
-
|
|
17858
|
+
const toolbarConfig = toolbar_config_default(normalizeFormulaXLocale(this.options.locale));
|
|
17859
|
+
this.components.toolbar = new toolbar_default(this, this.kfEditor, toolbarConfig);
|
|
17824
17860
|
this.components.scrollbar = new scrollbar_default(this, this.kfEditor);
|
|
17825
17861
|
},
|
|
17826
17862
|
updateContainerSize(container, toolbar, editArea) {
|
|
@@ -18129,6 +18165,9 @@ var FormulaX = (() => {
|
|
|
18129
18165
|
operand: []
|
|
18130
18166
|
};
|
|
18131
18167
|
}
|
|
18168
|
+
function getRootPlaceholderText() {
|
|
18169
|
+
return legacySysconf.rootPlaceholder.content;
|
|
18170
|
+
}
|
|
18132
18171
|
function processRootGroup(parser, tree) {
|
|
18133
18172
|
if (!parser.isResetId) {
|
|
18134
18173
|
tree.attr["data-type"] = legacyGroupType.VIRTUAL;
|
|
@@ -18176,7 +18215,7 @@ var FormulaX = (() => {
|
|
|
18176
18215
|
if (isRoot) {
|
|
18177
18216
|
processRootGroup(parser, tree);
|
|
18178
18217
|
} else if (parentTree?.attr?.["data-root"] && tree.name === "placeholder" && onlyPlaceholder(parentTree.operand)) {
|
|
18179
|
-
tree.attr.label =
|
|
18218
|
+
tree.attr.label = getRootPlaceholderText();
|
|
18180
18219
|
}
|
|
18181
18220
|
for (let i2 = 0; i2 < tree.operand.length; i2 += 1) {
|
|
18182
18221
|
const currentOperand = tree.operand[i2];
|
|
@@ -18188,7 +18227,7 @@ var FormulaX = (() => {
|
|
|
18188
18227
|
}
|
|
18189
18228
|
return tree;
|
|
18190
18229
|
}
|
|
18191
|
-
var CURSOR_CHAR,
|
|
18230
|
+
var CURSOR_CHAR, COMBINATION_NAME, PID_PREFIX, pidSeed, kity14, kf5, BaseComponent, Parser, parser_default;
|
|
18192
18231
|
var init_parser = __esm({
|
|
18193
18232
|
"src/legacy/parser.ts"() {
|
|
18194
18233
|
"use strict";
|
|
@@ -18199,7 +18238,6 @@ var FormulaX = (() => {
|
|
|
18199
18238
|
init_kf_ext_extension();
|
|
18200
18239
|
init_vgroup_def();
|
|
18201
18240
|
CURSOR_CHAR = legacySysconf.cursorCharacter;
|
|
18202
|
-
ROOT_P_TEXT = legacySysconf.rootPlaceholder.content;
|
|
18203
18241
|
COMBINATION_NAME = "combination";
|
|
18204
18242
|
PID_PREFIX = "_kf_editor_";
|
|
18205
18243
|
pidSeed = 0;
|
|
@@ -19087,6 +19125,21 @@ var FormulaX = (() => {
|
|
|
19087
19125
|
});
|
|
19088
19126
|
|
|
19089
19127
|
// src/legacy/syntax.ts
|
|
19128
|
+
function clampOffset(offset, maxOffset) {
|
|
19129
|
+
return Math.max(0, Math.min(offset, maxOffset));
|
|
19130
|
+
}
|
|
19131
|
+
function normalizeCursorRecord(objTree, cursor) {
|
|
19132
|
+
const fallbackGroupId = objTree.mapping.root.strGroup.attr.id;
|
|
19133
|
+
const targetGroupId = cursor.groupId && objTree.mapping[cursor.groupId] ? cursor.groupId : fallbackGroupId;
|
|
19134
|
+
const operandCount = objTree.mapping[targetGroupId].strGroup.operand.length;
|
|
19135
|
+
const startOffset = clampOffset(cursor.startOffset, operandCount);
|
|
19136
|
+
const endOffset = clampOffset(cursor.endOffset, operandCount);
|
|
19137
|
+
return {
|
|
19138
|
+
groupId: targetGroupId,
|
|
19139
|
+
startOffset: Math.min(startOffset, endOffset),
|
|
19140
|
+
endOffset: Math.max(startOffset, endOffset)
|
|
19141
|
+
};
|
|
19142
|
+
}
|
|
19090
19143
|
var CURSOR_CHAR2, kity19, SyntaxComponent, syntax_default;
|
|
19091
19144
|
var init_syntax = __esm({
|
|
19092
19145
|
"src/legacy/syntax.ts"() {
|
|
@@ -19147,10 +19200,14 @@ var FormulaX = (() => {
|
|
|
19147
19200
|
},
|
|
19148
19201
|
updateObjTree(objTree) {
|
|
19149
19202
|
const selectInfo = objTree.select;
|
|
19203
|
+
this.objTree = objTree;
|
|
19150
19204
|
if (selectInfo?.groupId) {
|
|
19151
19205
|
this.updateCursor(selectInfo.groupId, selectInfo.startOffset, selectInfo.endOffset);
|
|
19206
|
+
return;
|
|
19207
|
+
}
|
|
19208
|
+
if (this.record.cursor.groupId !== null) {
|
|
19209
|
+
this.record.cursor = normalizeCursorRecord(objTree, this.record.cursor);
|
|
19152
19210
|
}
|
|
19153
|
-
this.objTree = objTree;
|
|
19154
19211
|
},
|
|
19155
19212
|
hasCursorInfo() {
|
|
19156
19213
|
return this.record.cursor.groupId !== null;
|
|
@@ -19196,7 +19253,8 @@ var FormulaX = (() => {
|
|
|
19196
19253
|
return this.objTree;
|
|
19197
19254
|
},
|
|
19198
19255
|
getGroupObject(id) {
|
|
19199
|
-
|
|
19256
|
+
const groupInfo = this.objTree.mapping[id];
|
|
19257
|
+
return groupInfo ? groupInfo.objGroup : null;
|
|
19200
19258
|
},
|
|
19201
19259
|
getCursorRecord() {
|
|
19202
19260
|
return kity19.Utils.extend({}, this.record.cursor);
|
|
@@ -19272,7 +19330,7 @@ var FormulaX = (() => {
|
|
|
19272
19330
|
return this.hasRootplaceholder();
|
|
19273
19331
|
},
|
|
19274
19332
|
serialization() {
|
|
19275
|
-
const cursor = this.record.cursor;
|
|
19333
|
+
const cursor = normalizeCursorRecord(this.objTree, this.record.cursor);
|
|
19276
19334
|
const objGroup = this.objTree.mapping[cursor.groupId];
|
|
19277
19335
|
const curStrGroup = objGroup.strGroup;
|
|
19278
19336
|
let strStartIndex = Math.min(cursor.endOffset, cursor.startOffset);
|
|
@@ -19308,11 +19366,12 @@ var FormulaX = (() => {
|
|
|
19308
19366
|
endOffset = startOffset;
|
|
19309
19367
|
startOffset = tmp;
|
|
19310
19368
|
}
|
|
19311
|
-
|
|
19369
|
+
const nextCursor = {
|
|
19312
19370
|
groupId,
|
|
19313
19371
|
startOffset,
|
|
19314
19372
|
endOffset
|
|
19315
19373
|
};
|
|
19374
|
+
this.record.cursor = this.objTree ? normalizeCursorRecord(this.objTree, nextCursor) : nextCursor;
|
|
19316
19375
|
},
|
|
19317
19376
|
leftMove() {
|
|
19318
19377
|
this.components.move.leftMove();
|
|
@@ -19353,12 +19412,20 @@ var FormulaX = (() => {
|
|
|
19353
19412
|
});
|
|
19354
19413
|
|
|
19355
19414
|
// src/legacy/input.ts
|
|
19356
|
-
|
|
19415
|
+
function insertCursorMarkers(value, selectionStart, selectionEnd) {
|
|
19416
|
+
const normalizedStart = Math.max(0, Math.min(selectionStart ?? value.length, value.length));
|
|
19417
|
+
const normalizedEnd = Math.max(0, Math.min(selectionEnd ?? normalizedStart, value.length));
|
|
19418
|
+
const rangeStart = Math.min(normalizedStart, normalizedEnd);
|
|
19419
|
+
const rangeEnd = Math.max(normalizedStart, normalizedEnd);
|
|
19420
|
+
return value.slice(0, rangeStart) + CURSOR_CHAR3 + value.slice(rangeStart, rangeEnd) + CURSOR_CHAR3 + value.slice(rangeEnd);
|
|
19421
|
+
}
|
|
19422
|
+
var KEY_CODE, CURSOR_CHAR3, kity20, InputComponent, input_default;
|
|
19357
19423
|
var init_input = __esm({
|
|
19358
19424
|
"src/legacy/input.ts"() {
|
|
19359
19425
|
"use strict";
|
|
19360
19426
|
init_legacy_utils();
|
|
19361
19427
|
init_legacy_input_filter();
|
|
19428
|
+
init_legacy_sysconf();
|
|
19362
19429
|
init_runtime_interop();
|
|
19363
19430
|
KEY_CODE = {
|
|
19364
19431
|
LEFT: 37,
|
|
@@ -19366,6 +19433,7 @@ var FormulaX = (() => {
|
|
|
19366
19433
|
DELETE: 8,
|
|
19367
19434
|
INPUT: 229
|
|
19368
19435
|
};
|
|
19436
|
+
CURSOR_CHAR3 = legacySysconf.cursorCharacter;
|
|
19369
19437
|
kity20 = getLegacyKity();
|
|
19370
19438
|
InputComponent = kity20.createClass("InputComponent", {
|
|
19371
19439
|
constructor(parentComponent, kfEditor) {
|
|
@@ -19538,7 +19606,12 @@ var FormulaX = (() => {
|
|
|
19538
19606
|
return `${e.shiftKey ? "s+" : ""}${e.keyCode}`;
|
|
19539
19607
|
},
|
|
19540
19608
|
processingInput() {
|
|
19541
|
-
|
|
19609
|
+
const latexWithCursor = insertCursorMarkers(
|
|
19610
|
+
this.inputBox.value,
|
|
19611
|
+
this.inputBox.selectionStart,
|
|
19612
|
+
this.inputBox.selectionEnd
|
|
19613
|
+
);
|
|
19614
|
+
this.restruct(latexWithCursor);
|
|
19542
19615
|
this.kfEditor.requestService("ui.update.canvas.view");
|
|
19543
19616
|
},
|
|
19544
19617
|
restruct(latexStr) {
|
|
@@ -20044,26 +20117,26 @@ var FormulaX = (() => {
|
|
|
20044
20117
|
var start_exports = {};
|
|
20045
20118
|
__export(start_exports, {
|
|
20046
20119
|
Factory: () => factory_default,
|
|
20047
|
-
KFEditor: () =>
|
|
20120
|
+
KFEditor: () => editor_default,
|
|
20048
20121
|
default: () => start_default,
|
|
20049
20122
|
installKityEditorStart: () => installKityEditorStart
|
|
20050
20123
|
});
|
|
20051
20124
|
function installKityEditorStart(target = window) {
|
|
20052
20125
|
const runtimeTarget = target;
|
|
20053
20126
|
if (!installed3) {
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20127
|
+
editor_default.registerComponents("ui", ui_default);
|
|
20128
|
+
editor_default.registerComponents("parser", parser_default);
|
|
20129
|
+
editor_default.registerComponents("render", render_default);
|
|
20130
|
+
editor_default.registerComponents("position", position_default);
|
|
20131
|
+
editor_default.registerComponents("syntax", syntax_default);
|
|
20132
|
+
editor_default.registerComponents("control", controller_default);
|
|
20133
|
+
editor_default.registerComponents("print", printer_default);
|
|
20061
20134
|
installed3 = true;
|
|
20062
20135
|
}
|
|
20063
20136
|
runtimeTarget.kf = runtimeTarget.kf ?? {};
|
|
20064
20137
|
runtimeTarget.kf.EditorFactory = factory_default;
|
|
20065
20138
|
return {
|
|
20066
|
-
KFEditor:
|
|
20139
|
+
KFEditor: editor_default,
|
|
20067
20140
|
Factory: factory_default
|
|
20068
20141
|
};
|
|
20069
20142
|
}
|
|
@@ -20071,7 +20144,7 @@ var FormulaX = (() => {
|
|
|
20071
20144
|
var init_start = __esm({
|
|
20072
20145
|
"src/boot/start.ts"() {
|
|
20073
20146
|
"use strict";
|
|
20074
|
-
|
|
20147
|
+
init_editor();
|
|
20075
20148
|
init_factory();
|
|
20076
20149
|
init_ui();
|
|
20077
20150
|
init_parser();
|
|
@@ -20088,6 +20161,8 @@ var FormulaX = (() => {
|
|
|
20088
20161
|
// src/index.ts
|
|
20089
20162
|
var index_exports = {};
|
|
20090
20163
|
__export(index_exports, {
|
|
20164
|
+
DEFAULT_FORMULAX_LOCALE: () => DEFAULT_FORMULAX_LOCALE,
|
|
20165
|
+
FORMULAX_LOCALES: () => FORMULAX_LOCALES,
|
|
20091
20166
|
FormulaXEditor: () => FormulaXEditor,
|
|
20092
20167
|
addEvent: () => addEvent,
|
|
20093
20168
|
createElement: () => createElement,
|
|
@@ -20097,6 +20172,7 @@ var FormulaX = (() => {
|
|
|
20097
20172
|
delegateEvent: () => delegateEvent,
|
|
20098
20173
|
ensureKityRuntime: () => ensureKityRuntime,
|
|
20099
20174
|
getClassList: () => getClassList,
|
|
20175
|
+
getFormulaXRuntimeMessage: () => getFormulaXRuntimeMessage,
|
|
20100
20176
|
getRectBox: () => getRectBox,
|
|
20101
20177
|
installLegacyKityData: () => installLegacyKityData,
|
|
20102
20178
|
kityAssetManifest: () => kityAssetManifest,
|
|
@@ -20117,9 +20193,11 @@ var FormulaX = (() => {
|
|
|
20117
20193
|
legacyUiDef: () => legacyUiDef,
|
|
20118
20194
|
legacyUiUtils: () => legacyUiUtils,
|
|
20119
20195
|
mountKityEditor: () => mountKityEditor,
|
|
20196
|
+
normalizeFormulaXLocale: () => normalizeFormulaXLocale,
|
|
20120
20197
|
normalizeMouseEvent: () => normalizeMouseEvent,
|
|
20121
20198
|
publish: () => publish,
|
|
20122
|
-
subscribe: () => subscribe
|
|
20199
|
+
subscribe: () => subscribe,
|
|
20200
|
+
translateFormulaXText: () => translateFormulaXText
|
|
20123
20201
|
});
|
|
20124
20202
|
init_asset_manifest();
|
|
20125
20203
|
|
|
@@ -23603,6 +23681,7 @@ var FormulaX = (() => {
|
|
|
23603
23681
|
|
|
23604
23682
|
// src/create-editor.ts
|
|
23605
23683
|
init_toolbar_assets();
|
|
23684
|
+
init_i18n();
|
|
23606
23685
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
23607
23686
|
var DEFAULT_EDITOR_HEIGHT = "auto";
|
|
23608
23687
|
var KITY_STYLE_ID = "formulax-kity-editor-styles";
|
|
@@ -23753,8 +23832,10 @@ var FormulaX = (() => {
|
|
|
23753
23832
|
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
23754
23833
|
const fontsize = options.render?.fontsize ?? 40;
|
|
23755
23834
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
23835
|
+
const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
|
|
23756
23836
|
const assets = resolveEditorAssets(options.assets);
|
|
23757
23837
|
try {
|
|
23838
|
+
legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
|
|
23758
23839
|
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
23759
23840
|
if (stylesheetInserted) {
|
|
23760
23841
|
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
@@ -23781,6 +23862,9 @@ var FormulaX = (() => {
|
|
|
23781
23862
|
render: {
|
|
23782
23863
|
fontsize
|
|
23783
23864
|
},
|
|
23865
|
+
ui: {
|
|
23866
|
+
locale
|
|
23867
|
+
},
|
|
23784
23868
|
resource: {
|
|
23785
23869
|
path: "",
|
|
23786
23870
|
fonts: assets.fonts
|
|
@@ -23863,6 +23947,7 @@ var FormulaX = (() => {
|
|
|
23863
23947
|
|
|
23864
23948
|
// src/index.ts
|
|
23865
23949
|
init_dom_utils();
|
|
23950
|
+
init_i18n();
|
|
23866
23951
|
init_legacy_box_type();
|
|
23867
23952
|
init_legacy_component();
|
|
23868
23953
|
init_legacy_ele_type();
|