@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.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __esm = (fn, res) => function __init() {
|
|
7
9
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -18,98 +20,42 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
20
|
}
|
|
19
21
|
return to;
|
|
20
22
|
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
21
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
32
|
|
|
23
|
-
// public/assets/images/toolbar/btn.png
|
|
24
|
-
var btn_default;
|
|
25
|
-
var init_btn = __esm({
|
|
26
|
-
"public/assets/images/toolbar/btn.png"() {
|
|
27
|
-
btn_default = "./btn-5DANP6JY.png";
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// public/assets/images/toolbar/other.png
|
|
32
|
-
var other_default;
|
|
33
|
-
var init_other = __esm({
|
|
34
|
-
"public/assets/images/toolbar/other.png"() {
|
|
35
|
-
other_default = "./other-OMWJFGL5.png";
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// public/assets/styles/editor.css?url
|
|
40
|
-
var editor_default;
|
|
41
|
-
var init_editor = __esm({
|
|
42
|
-
"public/assets/styles/editor.css?url"() {
|
|
43
|
-
editor_default = "./editor-JT5KLVXX.css?url";
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// public/resource/KF_AMS_BB.woff
|
|
48
|
-
var KF_AMS_BB_default;
|
|
49
|
-
var init_KF_AMS_BB = __esm({
|
|
50
|
-
"public/resource/KF_AMS_BB.woff"() {
|
|
51
|
-
KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// public/resource/KF_AMS_CAL.woff
|
|
56
|
-
var KF_AMS_CAL_default;
|
|
57
|
-
var init_KF_AMS_CAL = __esm({
|
|
58
|
-
"public/resource/KF_AMS_CAL.woff"() {
|
|
59
|
-
KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// public/resource/KF_AMS_FRAK.woff
|
|
64
|
-
var KF_AMS_FRAK_default;
|
|
65
|
-
var init_KF_AMS_FRAK = __esm({
|
|
66
|
-
"public/resource/KF_AMS_FRAK.woff"() {
|
|
67
|
-
KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// public/resource/KF_AMS_MAIN.woff
|
|
72
|
-
var KF_AMS_MAIN_default;
|
|
73
|
-
var init_KF_AMS_MAIN = __esm({
|
|
74
|
-
"public/resource/KF_AMS_MAIN.woff"() {
|
|
75
|
-
KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// public/resource/KF_AMS_ROMAN.woff
|
|
80
|
-
var KF_AMS_ROMAN_default;
|
|
81
|
-
var init_KF_AMS_ROMAN = __esm({
|
|
82
|
-
"public/resource/KF_AMS_ROMAN.woff"() {
|
|
83
|
-
KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
33
|
// src/asset-manifest.ts
|
|
88
|
-
var kityFontAssets, kityToolbarAssets, kityStyleAssets, kityAssetManifest;
|
|
34
|
+
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;
|
|
89
35
|
var init_asset_manifest = __esm({
|
|
90
36
|
"src/asset-manifest.ts"() {
|
|
91
37
|
"use strict";
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
38
|
+
import_btn = __toESM(require("./btn.png"), 1);
|
|
39
|
+
import_other = __toESM(require("./other.png"), 1);
|
|
40
|
+
import_editor = __toESM(require("./editor.css?url"), 1);
|
|
41
|
+
import_KF_AMS_BB = __toESM(require("./KF_AMS_BB.woff"), 1);
|
|
42
|
+
import_KF_AMS_CAL = __toESM(require("./KF_AMS_CAL.woff"), 1);
|
|
43
|
+
import_KF_AMS_FRAK = __toESM(require("./KF_AMS_FRAK.woff"), 1);
|
|
44
|
+
import_KF_AMS_MAIN = __toESM(require("./KF_AMS_MAIN.woff"), 1);
|
|
45
|
+
import_KF_AMS_ROMAN = __toESM(require("./KF_AMS_ROMAN.woff"), 1);
|
|
100
46
|
kityFontAssets = {
|
|
101
|
-
KF_AMS_BB:
|
|
102
|
-
KF_AMS_CAL:
|
|
103
|
-
KF_AMS_FRAK:
|
|
104
|
-
KF_AMS_MAIN:
|
|
105
|
-
KF_AMS_ROMAN:
|
|
47
|
+
KF_AMS_BB: import_KF_AMS_BB.default,
|
|
48
|
+
KF_AMS_CAL: import_KF_AMS_CAL.default,
|
|
49
|
+
KF_AMS_FRAK: import_KF_AMS_FRAK.default,
|
|
50
|
+
KF_AMS_MAIN: import_KF_AMS_MAIN.default,
|
|
51
|
+
KF_AMS_ROMAN: import_KF_AMS_ROMAN.default
|
|
106
52
|
};
|
|
107
53
|
kityToolbarAssets = {
|
|
108
|
-
btn:
|
|
109
|
-
other:
|
|
54
|
+
btn: import_btn.default,
|
|
55
|
+
other: import_other.default
|
|
110
56
|
};
|
|
111
57
|
kityStyleAssets = {
|
|
112
|
-
editor:
|
|
58
|
+
editor: import_editor.default
|
|
113
59
|
};
|
|
114
60
|
kityAssetManifest = {
|
|
115
61
|
fonts: kityFontAssets,
|
|
@@ -1080,6 +1026,87 @@ var init_toolbar_assets = __esm({
|
|
|
1080
1026
|
}
|
|
1081
1027
|
});
|
|
1082
1028
|
|
|
1029
|
+
// src/i18n.ts
|
|
1030
|
+
function normalizeFormulaXLocale(locale) {
|
|
1031
|
+
if (locale === "zh_CN") {
|
|
1032
|
+
return "zh_CN";
|
|
1033
|
+
}
|
|
1034
|
+
return DEFAULT_FORMULAX_LOCALE;
|
|
1035
|
+
}
|
|
1036
|
+
function translateFormulaXText(namespace, value, locale) {
|
|
1037
|
+
if (locale === "zh_CN") {
|
|
1038
|
+
return value;
|
|
1039
|
+
}
|
|
1040
|
+
const normalizedValue = value.replace(/<br\s*\/?>/gi, "").trim();
|
|
1041
|
+
const translatedValue = FORMULAX_TRANSLATIONS[locale]?.[namespace]?.[normalizedValue];
|
|
1042
|
+
if (!translatedValue) {
|
|
1043
|
+
return value;
|
|
1044
|
+
}
|
|
1045
|
+
const lineBreakMatch = value.match(/<br\s*\/?>/i);
|
|
1046
|
+
if (/<br\s*\/?>/i.test(translatedValue)) {
|
|
1047
|
+
return translatedValue;
|
|
1048
|
+
}
|
|
1049
|
+
return lineBreakMatch ? `${translatedValue}${lineBreakMatch[0]}` : translatedValue;
|
|
1050
|
+
}
|
|
1051
|
+
function getFormulaXRuntimeMessage(key, locale = DEFAULT_FORMULAX_LOCALE) {
|
|
1052
|
+
const normalizedLocale = normalizeFormulaXLocale(locale);
|
|
1053
|
+
return FORMULAX_RUNTIME_MESSAGES[normalizedLocale][key] ?? FORMULAX_RUNTIME_MESSAGES[DEFAULT_FORMULAX_LOCALE][key];
|
|
1054
|
+
}
|
|
1055
|
+
var FORMULAX_LOCALES, DEFAULT_FORMULAX_LOCALE, FORMULAX_TRANSLATIONS, FORMULAX_RUNTIME_MESSAGES;
|
|
1056
|
+
var init_i18n = __esm({
|
|
1057
|
+
"src/i18n.ts"() {
|
|
1058
|
+
"use strict";
|
|
1059
|
+
FORMULAX_LOCALES = ["en_US", "zh_CN"];
|
|
1060
|
+
DEFAULT_FORMULAX_LOCALE = "en_US";
|
|
1061
|
+
FORMULAX_TRANSLATIONS = {
|
|
1062
|
+
en_US: {
|
|
1063
|
+
toolbar: {
|
|
1064
|
+
\u9884\u8BBE: "Presets",
|
|
1065
|
+
\u9884\u8BBE\u516C\u5F0F: "Presets",
|
|
1066
|
+
\u4E8C\u6B21\u516C\u5F0F: "Quadratic",
|
|
1067
|
+
\u4E8C\u9879\u5F0F\u5B9A\u7406: "Binomial",
|
|
1068
|
+
\u52FE\u80A1\u5B9A\u7406: "Pythagorean",
|
|
1069
|
+
\u57FA\u7840\u6570\u5B66: "Basic math",
|
|
1070
|
+
\u5E0C\u814A\u5B57\u6BCD: "Greek",
|
|
1071
|
+
\u6C42\u53CD\u5173\u7CFB\u8FD0\u7B97\u7B26: "Negated operators",
|
|
1072
|
+
\u5B57\u6BCD\u7C7B\u7B26\u53F7: "Letter symbols",
|
|
1073
|
+
\u7BAD\u5934: "Arrows",
|
|
1074
|
+
\u624B\u5199\u4F53: "Script",
|
|
1075
|
+
\u5206\u6570: "Fraction",
|
|
1076
|
+
\u5E38\u7528\u5206\u6570: "Common fractions",
|
|
1077
|
+
\u4E0A\u4E0B\u6807: "Scripts",
|
|
1078
|
+
\u4E0A\u6807\u548C\u4E0B\u6807: "Super/subscripts",
|
|
1079
|
+
\u5E38\u7528\u7684\u4E0A\u6807\u548C\u4E0B\u6807: "Common super/subscripts",
|
|
1080
|
+
\u6839\u5F0F: "Radicals",
|
|
1081
|
+
\u5E38\u7528\u6839\u5F0F: "Common radicals",
|
|
1082
|
+
\u79EF\u5206: "Integrals",
|
|
1083
|
+
\u5927\u578B\u8FD0\u7B97\u7B26: "Large<br/>ops",
|
|
1084
|
+
\u6C42\u548C: "Summations",
|
|
1085
|
+
\u62EC\u53F7: "Brackets",
|
|
1086
|
+
\u65B9\u62EC\u53F7: "Brackets",
|
|
1087
|
+
\u51FD\u6570: "Functions",
|
|
1088
|
+
\u4E09\u89D2\u51FD\u6570: "Trig functions",
|
|
1089
|
+
\u5E38\u7528\u51FD\u6570: "Common functions",
|
|
1090
|
+
\u5C0F\u5199: "Lowercase",
|
|
1091
|
+
\u5927\u5199: "Uppercase",
|
|
1092
|
+
\u53D8\u4F53: "Variants",
|
|
1093
|
+
\u82B1\u4F53: "Fraktur",
|
|
1094
|
+
\u53CC\u7EBF: "Double-struck",
|
|
1095
|
+
\u7F57\u9A6C: "Roman"
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
FORMULAX_RUNTIME_MESSAGES = {
|
|
1100
|
+
en_US: {
|
|
1101
|
+
"editor.placeholder.root": "Type formula here"
|
|
1102
|
+
},
|
|
1103
|
+
zh_CN: {
|
|
1104
|
+
"editor.placeholder.root": "\u8BF7\u8F93\u5165\u516C\u5F0F"
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1083
1110
|
// src/vendor/kity-formula/binary-expression.ts
|
|
1084
1111
|
var BinaryExpressionModule, createBinaryExpressionClass;
|
|
1085
1112
|
var init_binary_expression = __esm({
|
|
@@ -1944,15 +1971,13 @@ var init_expression = __esm({
|
|
|
1944
1971
|
});
|
|
1945
1972
|
|
|
1946
1973
|
// src/vendor/kity-formula/font-installer.ts
|
|
1947
|
-
var
|
|
1974
|
+
var FontInstallerModule, createFontInstallerClass;
|
|
1948
1975
|
var init_font_installer = __esm({
|
|
1949
1976
|
"src/vendor/kity-formula/font-installer.ts"() {
|
|
1950
1977
|
"use strict";
|
|
1951
|
-
MAIN_FONT_FAMILY = "KF AMS MAIN";
|
|
1952
1978
|
FontInstallerModule = class {
|
|
1953
1979
|
static create(kity26, FontManager, fontConfig, checkerTemplate) {
|
|
1954
1980
|
let nodeList = [];
|
|
1955
|
-
let checkerNode = null;
|
|
1956
1981
|
return kity26.createClass("FontInstaller", {
|
|
1957
1982
|
constructor: function(doc, resource) {
|
|
1958
1983
|
const normalized = typeof resource === "string" ? { path: resource } : resource ?? {};
|
|
@@ -1962,26 +1987,22 @@ var init_font_installer = __esm({
|
|
|
1962
1987
|
},
|
|
1963
1988
|
mount: function(callback) {
|
|
1964
1989
|
const fontList = FontManager.getFontList();
|
|
1990
|
+
let count = 0;
|
|
1965
1991
|
kity26.Utils.each(fontList, (fontInfo) => {
|
|
1992
|
+
count += 1;
|
|
1966
1993
|
fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
|
|
1967
1994
|
this.createFontStyle(fontInfo);
|
|
1968
|
-
if (fontInfo.meta.fontFamily === MAIN_FONT_FAMILY) {
|
|
1969
|
-
checkerNode = createFontCheckerNode(this.doc);
|
|
1970
|
-
return;
|
|
1971
|
-
}
|
|
1972
1995
|
applyFonts(this.doc, fontInfo);
|
|
1996
|
+
count -= 1;
|
|
1997
|
+
if (count === 0) {
|
|
1998
|
+
complete(this.doc, callback);
|
|
1999
|
+
}
|
|
1973
2000
|
});
|
|
1974
|
-
complete(this.doc, callback);
|
|
1975
2001
|
},
|
|
1976
2002
|
createFontStyle: function(fontInfo) {
|
|
1977
|
-
const styleId = createFontStyleId(fontInfo);
|
|
1978
|
-
if (this.doc.getElementById(styleId)) {
|
|
1979
|
-
return;
|
|
1980
|
-
}
|
|
1981
2003
|
const stylesheet = this.doc.createElement("style");
|
|
1982
2004
|
const tpl = '@font-face{\nfont-family: "${fontFamily}";\nsrc: url("${src}");\n}';
|
|
1983
2005
|
stylesheet.setAttribute("type", "text/css");
|
|
1984
|
-
stylesheet.id = styleId;
|
|
1985
2006
|
stylesheet.innerHTML = tpl.replace("${fontFamily}", fontInfo.meta.fontFamily).replace("${src}", fontInfo.meta.src);
|
|
1986
2007
|
this.doc.head.appendChild(stylesheet);
|
|
1987
2008
|
}
|
|
@@ -1998,29 +2019,34 @@ var init_font_installer = __esm({
|
|
|
1998
2019
|
}
|
|
1999
2020
|
return resourceBase + originalSrc;
|
|
2000
2021
|
}
|
|
2001
|
-
function
|
|
2002
|
-
const raw = `${fontInfo.meta.fontFamily}::${fontInfo.meta.src}`;
|
|
2003
|
-
let hash = 0;
|
|
2004
|
-
for (let index = 0; index < raw.length; index += 1) {
|
|
2005
|
-
hash = (hash << 5) - hash + raw.charCodeAt(index) | 0;
|
|
2006
|
-
}
|
|
2007
|
-
return `formulax-kity-font-${Math.abs(hash).toString(36)}`;
|
|
2008
|
-
}
|
|
2009
|
-
function waitForFontsReady(doc) {
|
|
2022
|
+
function waitForFontsReady(doc, fontList) {
|
|
2010
2023
|
const view = doc.defaultView ?? window;
|
|
2011
2024
|
if (view.document.fonts) {
|
|
2012
|
-
|
|
2025
|
+
const fontLoadPromises = fontList.map((fontInfo) => {
|
|
2026
|
+
return view.document.fonts.load(`50px "${fontInfo.meta.fontFamily}"`);
|
|
2027
|
+
});
|
|
2028
|
+
return Promise.all(fontLoadPromises).then(() => view.document.fonts.ready).then(() => {
|
|
2029
|
+
return new Promise((resolve) => {
|
|
2030
|
+
requestAnimationFrame(() => {
|
|
2031
|
+
requestAnimationFrame(() => {
|
|
2032
|
+
resolve();
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
});
|
|
2036
|
+
});
|
|
2013
2037
|
}
|
|
2014
2038
|
return Promise.resolve();
|
|
2015
2039
|
}
|
|
2016
2040
|
function complete(doc, callback) {
|
|
2017
2041
|
const view = doc.defaultView ?? window;
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2042
|
+
const fontList = FontManager.getFontList();
|
|
2043
|
+
const fontArray = Object.values(fontList);
|
|
2044
|
+
waitForFontsReady(doc, fontArray).then(() => {
|
|
2045
|
+
view.setTimeout(() => {
|
|
2046
|
+
initFontSystemInfo(doc);
|
|
2047
|
+
removeTmpNode();
|
|
2048
|
+
callback();
|
|
2049
|
+
}, 100);
|
|
2024
2050
|
}).catch(() => {
|
|
2025
2051
|
view.setTimeout(() => {
|
|
2026
2052
|
initFontSystemInfo(doc);
|
|
@@ -2041,37 +2067,12 @@ var init_font_installer = __esm({
|
|
|
2041
2067
|
doc.body.appendChild(node);
|
|
2042
2068
|
nodeList.push(node);
|
|
2043
2069
|
}
|
|
2044
|
-
function createFontCheckerNode(doc) {
|
|
2045
|
-
if (checkerNode) {
|
|
2046
|
-
return checkerNode;
|
|
2047
|
-
}
|
|
2048
|
-
const node = doc.createElement("div");
|
|
2049
|
-
node.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
2050
|
-
node.innerHTML = checkerTemplate.join("");
|
|
2051
|
-
doc.body.appendChild(node);
|
|
2052
|
-
checkerNode = node;
|
|
2053
|
-
return node;
|
|
2054
|
-
}
|
|
2055
|
-
function waitForNextFrames(view, frameCount) {
|
|
2056
|
-
if (typeof view.requestAnimationFrame !== "function") {
|
|
2057
|
-
return Promise.resolve();
|
|
2058
|
-
}
|
|
2059
|
-
return new Promise((resolve) => {
|
|
2060
|
-
const step = (remaining) => {
|
|
2061
|
-
if (remaining <= 0) {
|
|
2062
|
-
resolve();
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
view.requestAnimationFrame(() => {
|
|
2066
|
-
step(remaining - 1);
|
|
2067
|
-
});
|
|
2068
|
-
};
|
|
2069
|
-
step(frameCount);
|
|
2070
|
-
});
|
|
2071
|
-
}
|
|
2072
2070
|
function initFontSystemInfo(doc) {
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2071
|
+
const tmpNode = doc.createElement("div");
|
|
2072
|
+
tmpNode.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
2073
|
+
tmpNode.innerHTML = checkerTemplate.join("");
|
|
2074
|
+
doc.body.appendChild(tmpNode);
|
|
2075
|
+
const rectBox = tmpNode.getElementsByTagName("text")[0].getBBox();
|
|
2075
2076
|
fontConfig.spaceHeight = rectBox.height;
|
|
2076
2077
|
fontConfig.topSpace = -rectBox.y - fontConfig.baseline;
|
|
2077
2078
|
fontConfig.bottomSpace = fontConfig.spaceHeight - fontConfig.topSpace - fontConfig.baseHeight;
|
|
@@ -2080,8 +2081,7 @@ var init_font_installer = __esm({
|
|
|
2080
2081
|
fontConfig.meanlinePosition = (fontConfig.topSpace + fontConfig.meanline) / fontConfig.spaceHeight;
|
|
2081
2082
|
fontConfig.ascenderPosition = fontConfig.topSpace / fontConfig.spaceHeight;
|
|
2082
2083
|
fontConfig.descenderPosition = (fontConfig.topSpace + fontConfig.baseHeight) / fontConfig.spaceHeight;
|
|
2083
|
-
|
|
2084
|
-
checkerNode = null;
|
|
2084
|
+
doc.body.removeChild(tmpNode);
|
|
2085
2085
|
}
|
|
2086
2086
|
function removeTmpNode() {
|
|
2087
2087
|
kity26.Utils.each(nodeList, (node) => {
|
|
@@ -2164,11 +2164,11 @@ var init_formula = __esm({
|
|
|
2164
2164
|
bg;
|
|
2165
2165
|
exp;
|
|
2166
2166
|
config;
|
|
2167
|
-
constructor(kity26, exp,
|
|
2167
|
+
constructor(kity26, exp, config) {
|
|
2168
2168
|
this.wrap = new kity26.Group();
|
|
2169
2169
|
this.bg = new kity26.Rect(0, 0, 0, 0).fill("transparent");
|
|
2170
2170
|
this.exp = exp;
|
|
2171
|
-
this.config =
|
|
2171
|
+
this.config = config;
|
|
2172
2172
|
this.wrap.setAttr("data-type", "kf-exp-wrap");
|
|
2173
2173
|
this.bg.setAttr("data-type", "kf-exp-wrap-bg");
|
|
2174
2174
|
this.wrap.addShape(this.bg);
|
|
@@ -2197,14 +2197,14 @@ var init_formula = __esm({
|
|
|
2197
2197
|
static create(kity26, GTYPE2, FontManager, FontInstaller, FPaper, Output) {
|
|
2198
2198
|
const Formula = kity26.createClass("Formula", {
|
|
2199
2199
|
base: FPaper,
|
|
2200
|
-
constructor: function(container,
|
|
2200
|
+
constructor: function(container, config) {
|
|
2201
2201
|
if (this.__FORMULAX_PRESERVE_CALL_BASE__) {
|
|
2202
2202
|
this.callBase(container);
|
|
2203
2203
|
}
|
|
2204
2204
|
FPaper.call(this, container);
|
|
2205
2205
|
this.expressions = [];
|
|
2206
2206
|
this.fontInstaller = new FontInstaller(this);
|
|
2207
|
-
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS,
|
|
2207
|
+
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS, config);
|
|
2208
2208
|
this.initEnvironment();
|
|
2209
2209
|
this.initInnerFont();
|
|
2210
2210
|
},
|
|
@@ -9669,7 +9669,7 @@ function registerAssemblyModule(context) {
|
|
|
9669
9669
|
value: function() {
|
|
9670
9670
|
const kf7 = window2.kf;
|
|
9671
9671
|
const CONSTRUCT_MAPPING = {};
|
|
9672
|
-
const
|
|
9672
|
+
const CURSOR_CHAR4 = "\uF155";
|
|
9673
9673
|
class Assembly {
|
|
9674
9674
|
formula;
|
|
9675
9675
|
constructor(formula) {
|
|
@@ -9706,7 +9706,7 @@ function registerAssemblyModule(context) {
|
|
|
9706
9706
|
if (tree.name.indexOf("text") === -1) {
|
|
9707
9707
|
for (let i2 = 0, len = operand.length; i2 < len; i2 += 1) {
|
|
9708
9708
|
currentOperand = operand[i2];
|
|
9709
|
-
if (currentOperand ===
|
|
9709
|
+
if (currentOperand === CURSOR_CHAR4) {
|
|
9710
9710
|
cursorLocation.push(i2);
|
|
9711
9711
|
if (!Object.prototype.hasOwnProperty.call(selectInfo, "startOffset")) {
|
|
9712
9712
|
selectInfo.startOffset = i2;
|
|
@@ -11000,8 +11000,8 @@ function getService(serviceName) {
|
|
|
11000
11000
|
}
|
|
11001
11001
|
return serviceObject;
|
|
11002
11002
|
}
|
|
11003
|
-
var defaultOptions, components, kity2, kf, KFEditor,
|
|
11004
|
-
var
|
|
11003
|
+
var defaultOptions, components, kity2, kf, KFEditor, editor_default;
|
|
11004
|
+
var init_editor = __esm({
|
|
11005
11005
|
"src/legacy/editor.ts"() {
|
|
11006
11006
|
"use strict";
|
|
11007
11007
|
init_legacy_utils();
|
|
@@ -11112,7 +11112,7 @@ var init_editor2 = __esm({
|
|
|
11112
11112
|
components[name] = component;
|
|
11113
11113
|
}
|
|
11114
11114
|
});
|
|
11115
|
-
|
|
11115
|
+
editor_default = KFEditor;
|
|
11116
11116
|
}
|
|
11117
11117
|
});
|
|
11118
11118
|
|
|
@@ -11121,13 +11121,13 @@ var EditorWrapper, factory, factory_default;
|
|
|
11121
11121
|
var init_factory = __esm({
|
|
11122
11122
|
"src/legacy/factory.ts"() {
|
|
11123
11123
|
"use strict";
|
|
11124
|
-
|
|
11124
|
+
init_editor();
|
|
11125
11125
|
init_runtime_interop();
|
|
11126
11126
|
EditorWrapper = class {
|
|
11127
11127
|
callbacks = [];
|
|
11128
11128
|
editor;
|
|
11129
11129
|
constructor(container, options) {
|
|
11130
|
-
this.editor = new
|
|
11130
|
+
this.editor = new editor_default(container, options);
|
|
11131
11131
|
this.editor.ready(() => {
|
|
11132
11132
|
this.trigger();
|
|
11133
11133
|
});
|
|
@@ -12695,6 +12695,7 @@ var init_formula_symbols = __esm({
|
|
|
12695
12695
|
to: "\u2192",
|
|
12696
12696
|
downarrow: "\u2193",
|
|
12697
12697
|
leftrightarrow: "\u2194",
|
|
12698
|
+
updownarrow: "\u2195",
|
|
12698
12699
|
therefore: "\u2234",
|
|
12699
12700
|
because: "\u2235",
|
|
12700
12701
|
"+": "+",
|
|
@@ -12811,7 +12812,7 @@ var init_formula_symbols = __esm({
|
|
|
12811
12812
|
Uparrow: "\u21D1",
|
|
12812
12813
|
Downarrow: "\u21D3",
|
|
12813
12814
|
Leftrightarrow: "\u21D4",
|
|
12814
|
-
Updownarrow: "\
|
|
12815
|
+
Updownarrow: "\u21D5",
|
|
12815
12816
|
longleftarrow: "\u27F5",
|
|
12816
12817
|
longrightarrow: "\u27F6",
|
|
12817
12818
|
longleftrightarrow: "\u27F7",
|
|
@@ -12878,6 +12879,26 @@ function each(list, callback) {
|
|
|
12878
12879
|
}
|
|
12879
12880
|
Object.keys(list).forEach((key) => callback(list[key], key));
|
|
12880
12881
|
}
|
|
12882
|
+
function translateToolbarText(value, locale) {
|
|
12883
|
+
return translateFormulaXText("toolbar", value, locale);
|
|
12884
|
+
}
|
|
12885
|
+
function localizeToolbarConfig(value, locale) {
|
|
12886
|
+
if (Array.isArray(value)) {
|
|
12887
|
+
return value.map((item) => localizeToolbarConfig(item, locale));
|
|
12888
|
+
}
|
|
12889
|
+
if (!value || typeof value !== "object") {
|
|
12890
|
+
return value;
|
|
12891
|
+
}
|
|
12892
|
+
const result = {};
|
|
12893
|
+
for (const [key, currentValue] of Object.entries(value)) {
|
|
12894
|
+
if ((key === "label" || key === "title") && typeof currentValue === "string") {
|
|
12895
|
+
result[key] = translateToolbarText(currentValue, locale);
|
|
12896
|
+
continue;
|
|
12897
|
+
}
|
|
12898
|
+
result[key] = localizeToolbarConfig(currentValue, locale);
|
|
12899
|
+
}
|
|
12900
|
+
return result;
|
|
12901
|
+
}
|
|
12881
12902
|
function getUnicodeContents(keySet) {
|
|
12882
12903
|
let result = [];
|
|
12883
12904
|
each(keySet, function(key) {
|
|
@@ -12897,7 +12918,13 @@ function getUnicodeContents(keySet) {
|
|
|
12897
12918
|
});
|
|
12898
12919
|
return result;
|
|
12899
12920
|
}
|
|
12900
|
-
|
|
12921
|
+
function createToolbarConfig(locale = DEFAULT_FORMULAX_LOCALE) {
|
|
12922
|
+
return localizeToolbarConfig(
|
|
12923
|
+
baseToolbarConfig,
|
|
12924
|
+
normalizeFormulaXLocale(locale)
|
|
12925
|
+
);
|
|
12926
|
+
}
|
|
12927
|
+
var UI_ELE_TYPE, BOX_TYPE2, OTHER_POSITION, baseToolbarConfig, toolbar_config_default;
|
|
12901
12928
|
var init_toolbar_config = __esm({
|
|
12902
12929
|
"src/legacy/toolbar-config.ts"() {
|
|
12903
12930
|
"use strict";
|
|
@@ -12906,10 +12933,11 @@ var init_toolbar_config = __esm({
|
|
|
12906
12933
|
init_other_position();
|
|
12907
12934
|
init_toolbar_assets();
|
|
12908
12935
|
init_formula_symbols();
|
|
12936
|
+
init_i18n();
|
|
12909
12937
|
UI_ELE_TYPE = legacyEleType;
|
|
12910
12938
|
BOX_TYPE2 = legacyBoxType;
|
|
12911
12939
|
OTHER_POSITION = legacyOtherPosition;
|
|
12912
|
-
|
|
12940
|
+
baseToolbarConfig = [{
|
|
12913
12941
|
type: UI_ELE_TYPE.DRAPDOWN_BOX,
|
|
12914
12942
|
options: {
|
|
12915
12943
|
button: {
|
|
@@ -13315,7 +13343,7 @@ var init_toolbar_config = __esm({
|
|
|
13315
13343
|
}];
|
|
13316
13344
|
(function() {
|
|
13317
13345
|
let tmp = [], otherImageSrc = resolveToolbarAssetPath("other.png"), currentConf = [];
|
|
13318
|
-
each(
|
|
13346
|
+
each(baseToolbarConfig, function(conf) {
|
|
13319
13347
|
if (conf.type === UI_ELE_TYPE.DELIMITER) {
|
|
13320
13348
|
return;
|
|
13321
13349
|
}
|
|
@@ -13387,7 +13415,7 @@ var init_toolbar_config = __esm({
|
|
|
13387
13415
|
"aleph",
|
|
13388
13416
|
"beth",
|
|
13389
13417
|
"blacksquare"
|
|
13390
|
-
], configList =
|
|
13418
|
+
], configList = baseToolbarConfig[2].options.box.group[0].items;
|
|
13391
13419
|
configList.push({
|
|
13392
13420
|
title: "\u57FA\u7840\u6570\u5B66",
|
|
13393
13421
|
content: getUnicodeContents(list)
|
|
@@ -13403,7 +13431,7 @@ var init_toolbar_config = __esm({
|
|
|
13403
13431
|
}, {
|
|
13404
13432
|
title: "\u53D8\u4F53",
|
|
13405
13433
|
values: ["digamma", "varepsilon", "varkappa", "varphi", "varpi", "varrho", "varsigma", "vartheta"]
|
|
13406
|
-
}], greekConfigList =
|
|
13434
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[1].items;
|
|
13407
13435
|
greekConfigList.push({
|
|
13408
13436
|
title: greekList[0].title,
|
|
13409
13437
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -13452,7 +13480,7 @@ var init_toolbar_config = __esm({
|
|
|
13452
13480
|
"nVDash",
|
|
13453
13481
|
"nexists"
|
|
13454
13482
|
]
|
|
13455
|
-
}], greekConfigList =
|
|
13483
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[2].items;
|
|
13456
13484
|
greekConfigList.push({
|
|
13457
13485
|
title: greekList[0].title,
|
|
13458
13486
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -13478,7 +13506,7 @@ var init_toolbar_config = __esm({
|
|
|
13478
13506
|
"Game",
|
|
13479
13507
|
"Im",
|
|
13480
13508
|
"Re"
|
|
13481
|
-
], configList =
|
|
13509
|
+
], configList = baseToolbarConfig[2].options.box.group[3].items;
|
|
13482
13510
|
configList.push({
|
|
13483
13511
|
title: "\u5B57\u6BCD\u7C7B\u7B26\u53F7",
|
|
13484
13512
|
content: getUnicodeContents(list)
|
|
@@ -13546,7 +13574,7 @@ var init_toolbar_config = __esm({
|
|
|
13546
13574
|
"twoheadleftarrow",
|
|
13547
13575
|
"twoheadrightarrow",
|
|
13548
13576
|
"rightsquigarrow"
|
|
13549
|
-
], configList =
|
|
13577
|
+
], configList = baseToolbarConfig[2].options.box.group[4].items;
|
|
13550
13578
|
configList.push({
|
|
13551
13579
|
title: "\u7BAD\u5934",
|
|
13552
13580
|
content: getUnicodeContents(list)
|
|
@@ -13725,7 +13753,7 @@ var init_toolbar_config = __esm({
|
|
|
13725
13753
|
"y",
|
|
13726
13754
|
"z"
|
|
13727
13755
|
]
|
|
13728
|
-
}], configList =
|
|
13756
|
+
}], configList = baseToolbarConfig[2].options.box.group[5].items;
|
|
13729
13757
|
each(list[0].values, function(item, index) {
|
|
13730
13758
|
list[0].values[index] = "mathcal{" + item + "}";
|
|
13731
13759
|
});
|
|
@@ -13755,7 +13783,7 @@ var init_toolbar_config = __esm({
|
|
|
13755
13783
|
content: getUnicodeContents(list[3].values)
|
|
13756
13784
|
});
|
|
13757
13785
|
})();
|
|
13758
|
-
toolbar_config_default =
|
|
13786
|
+
toolbar_config_default = createToolbarConfig;
|
|
13759
13787
|
}
|
|
13760
13788
|
});
|
|
13761
13789
|
|
|
@@ -13798,6 +13826,7 @@ var init_ui = __esm({
|
|
|
13798
13826
|
init_toolbar();
|
|
13799
13827
|
init_scrollbar();
|
|
13800
13828
|
init_toolbar_config();
|
|
13829
|
+
init_i18n();
|
|
13801
13830
|
$$8 = createLegacyUiUtils();
|
|
13802
13831
|
VIEW_STATE = legacyUiDef.VIEW_STATE;
|
|
13803
13832
|
DEFAULT_EDIT_AREA_HEIGHT = 100;
|
|
@@ -13828,7 +13857,8 @@ var init_ui = __esm({
|
|
|
13828
13857
|
this.initScrollEvent();
|
|
13829
13858
|
},
|
|
13830
13859
|
initComponents() {
|
|
13831
|
-
|
|
13860
|
+
const toolbarConfig = toolbar_config_default(normalizeFormulaXLocale(this.options.locale));
|
|
13861
|
+
this.components.toolbar = new toolbar_default(this, this.kfEditor, toolbarConfig);
|
|
13832
13862
|
this.components.scrollbar = new scrollbar_default(this, this.kfEditor);
|
|
13833
13863
|
},
|
|
13834
13864
|
updateContainerSize(container, toolbar, editArea) {
|
|
@@ -14137,6 +14167,9 @@ function createGroup(parser) {
|
|
|
14137
14167
|
operand: []
|
|
14138
14168
|
};
|
|
14139
14169
|
}
|
|
14170
|
+
function getRootPlaceholderText() {
|
|
14171
|
+
return legacySysconf.rootPlaceholder.content;
|
|
14172
|
+
}
|
|
14140
14173
|
function processRootGroup(parser, tree) {
|
|
14141
14174
|
if (!parser.isResetId) {
|
|
14142
14175
|
tree.attr["data-type"] = legacyGroupType.VIRTUAL;
|
|
@@ -14184,7 +14217,7 @@ function supplementTree(parser, tree, parentTree) {
|
|
|
14184
14217
|
if (isRoot) {
|
|
14185
14218
|
processRootGroup(parser, tree);
|
|
14186
14219
|
} else if (parentTree?.attr?.["data-root"] && tree.name === "placeholder" && onlyPlaceholder(parentTree.operand)) {
|
|
14187
|
-
tree.attr.label =
|
|
14220
|
+
tree.attr.label = getRootPlaceholderText();
|
|
14188
14221
|
}
|
|
14189
14222
|
for (let i2 = 0; i2 < tree.operand.length; i2 += 1) {
|
|
14190
14223
|
const currentOperand = tree.operand[i2];
|
|
@@ -14196,7 +14229,7 @@ function supplementTree(parser, tree, parentTree) {
|
|
|
14196
14229
|
}
|
|
14197
14230
|
return tree;
|
|
14198
14231
|
}
|
|
14199
|
-
var CURSOR_CHAR,
|
|
14232
|
+
var CURSOR_CHAR, COMBINATION_NAME, PID_PREFIX, pidSeed, kity14, kf5, BaseComponent, Parser, parser_default;
|
|
14200
14233
|
var init_parser = __esm({
|
|
14201
14234
|
"src/legacy/parser.ts"() {
|
|
14202
14235
|
"use strict";
|
|
@@ -14207,7 +14240,6 @@ var init_parser = __esm({
|
|
|
14207
14240
|
init_kf_ext_extension();
|
|
14208
14241
|
init_vgroup_def();
|
|
14209
14242
|
CURSOR_CHAR = legacySysconf.cursorCharacter;
|
|
14210
|
-
ROOT_P_TEXT = legacySysconf.rootPlaceholder.content;
|
|
14211
14243
|
COMBINATION_NAME = "combination";
|
|
14212
14244
|
PID_PREFIX = "_kf_editor_";
|
|
14213
14245
|
pidSeed = 0;
|
|
@@ -15095,6 +15127,21 @@ var init_syntax_move = __esm({
|
|
|
15095
15127
|
});
|
|
15096
15128
|
|
|
15097
15129
|
// src/legacy/syntax.ts
|
|
15130
|
+
function clampOffset(offset, maxOffset) {
|
|
15131
|
+
return Math.max(0, Math.min(offset, maxOffset));
|
|
15132
|
+
}
|
|
15133
|
+
function normalizeCursorRecord(objTree, cursor) {
|
|
15134
|
+
const fallbackGroupId = objTree.mapping.root.strGroup.attr.id;
|
|
15135
|
+
const targetGroupId = cursor.groupId && objTree.mapping[cursor.groupId] ? cursor.groupId : fallbackGroupId;
|
|
15136
|
+
const operandCount = objTree.mapping[targetGroupId].strGroup.operand.length;
|
|
15137
|
+
const startOffset = clampOffset(cursor.startOffset, operandCount);
|
|
15138
|
+
const endOffset = clampOffset(cursor.endOffset, operandCount);
|
|
15139
|
+
return {
|
|
15140
|
+
groupId: targetGroupId,
|
|
15141
|
+
startOffset: Math.min(startOffset, endOffset),
|
|
15142
|
+
endOffset: Math.max(startOffset, endOffset)
|
|
15143
|
+
};
|
|
15144
|
+
}
|
|
15098
15145
|
var CURSOR_CHAR2, kity19, SyntaxComponent, syntax_default;
|
|
15099
15146
|
var init_syntax = __esm({
|
|
15100
15147
|
"src/legacy/syntax.ts"() {
|
|
@@ -15155,10 +15202,14 @@ var init_syntax = __esm({
|
|
|
15155
15202
|
},
|
|
15156
15203
|
updateObjTree(objTree) {
|
|
15157
15204
|
const selectInfo = objTree.select;
|
|
15205
|
+
this.objTree = objTree;
|
|
15158
15206
|
if (selectInfo?.groupId) {
|
|
15159
15207
|
this.updateCursor(selectInfo.groupId, selectInfo.startOffset, selectInfo.endOffset);
|
|
15208
|
+
return;
|
|
15209
|
+
}
|
|
15210
|
+
if (this.record.cursor.groupId !== null) {
|
|
15211
|
+
this.record.cursor = normalizeCursorRecord(objTree, this.record.cursor);
|
|
15160
15212
|
}
|
|
15161
|
-
this.objTree = objTree;
|
|
15162
15213
|
},
|
|
15163
15214
|
hasCursorInfo() {
|
|
15164
15215
|
return this.record.cursor.groupId !== null;
|
|
@@ -15204,7 +15255,8 @@ var init_syntax = __esm({
|
|
|
15204
15255
|
return this.objTree;
|
|
15205
15256
|
},
|
|
15206
15257
|
getGroupObject(id) {
|
|
15207
|
-
|
|
15258
|
+
const groupInfo = this.objTree.mapping[id];
|
|
15259
|
+
return groupInfo ? groupInfo.objGroup : null;
|
|
15208
15260
|
},
|
|
15209
15261
|
getCursorRecord() {
|
|
15210
15262
|
return kity19.Utils.extend({}, this.record.cursor);
|
|
@@ -15280,7 +15332,7 @@ var init_syntax = __esm({
|
|
|
15280
15332
|
return this.hasRootplaceholder();
|
|
15281
15333
|
},
|
|
15282
15334
|
serialization() {
|
|
15283
|
-
const cursor = this.record.cursor;
|
|
15335
|
+
const cursor = normalizeCursorRecord(this.objTree, this.record.cursor);
|
|
15284
15336
|
const objGroup = this.objTree.mapping[cursor.groupId];
|
|
15285
15337
|
const curStrGroup = objGroup.strGroup;
|
|
15286
15338
|
let strStartIndex = Math.min(cursor.endOffset, cursor.startOffset);
|
|
@@ -15316,11 +15368,12 @@ var init_syntax = __esm({
|
|
|
15316
15368
|
endOffset = startOffset;
|
|
15317
15369
|
startOffset = tmp;
|
|
15318
15370
|
}
|
|
15319
|
-
|
|
15371
|
+
const nextCursor = {
|
|
15320
15372
|
groupId,
|
|
15321
15373
|
startOffset,
|
|
15322
15374
|
endOffset
|
|
15323
15375
|
};
|
|
15376
|
+
this.record.cursor = this.objTree ? normalizeCursorRecord(this.objTree, nextCursor) : nextCursor;
|
|
15324
15377
|
},
|
|
15325
15378
|
leftMove() {
|
|
15326
15379
|
this.components.move.leftMove();
|
|
@@ -15361,12 +15414,20 @@ var init_syntax = __esm({
|
|
|
15361
15414
|
});
|
|
15362
15415
|
|
|
15363
15416
|
// src/legacy/input.ts
|
|
15364
|
-
|
|
15417
|
+
function insertCursorMarkers(value, selectionStart, selectionEnd) {
|
|
15418
|
+
const normalizedStart = Math.max(0, Math.min(selectionStart ?? value.length, value.length));
|
|
15419
|
+
const normalizedEnd = Math.max(0, Math.min(selectionEnd ?? normalizedStart, value.length));
|
|
15420
|
+
const rangeStart = Math.min(normalizedStart, normalizedEnd);
|
|
15421
|
+
const rangeEnd = Math.max(normalizedStart, normalizedEnd);
|
|
15422
|
+
return value.slice(0, rangeStart) + CURSOR_CHAR3 + value.slice(rangeStart, rangeEnd) + CURSOR_CHAR3 + value.slice(rangeEnd);
|
|
15423
|
+
}
|
|
15424
|
+
var KEY_CODE, CURSOR_CHAR3, kity20, InputComponent, input_default;
|
|
15365
15425
|
var init_input = __esm({
|
|
15366
15426
|
"src/legacy/input.ts"() {
|
|
15367
15427
|
"use strict";
|
|
15368
15428
|
init_legacy_utils();
|
|
15369
15429
|
init_legacy_input_filter();
|
|
15430
|
+
init_legacy_sysconf();
|
|
15370
15431
|
init_runtime_interop();
|
|
15371
15432
|
KEY_CODE = {
|
|
15372
15433
|
LEFT: 37,
|
|
@@ -15374,6 +15435,7 @@ var init_input = __esm({
|
|
|
15374
15435
|
DELETE: 8,
|
|
15375
15436
|
INPUT: 229
|
|
15376
15437
|
};
|
|
15438
|
+
CURSOR_CHAR3 = legacySysconf.cursorCharacter;
|
|
15377
15439
|
kity20 = getLegacyKity();
|
|
15378
15440
|
InputComponent = kity20.createClass("InputComponent", {
|
|
15379
15441
|
constructor(parentComponent, kfEditor) {
|
|
@@ -15546,7 +15608,12 @@ var init_input = __esm({
|
|
|
15546
15608
|
return `${e.shiftKey ? "s+" : ""}${e.keyCode}`;
|
|
15547
15609
|
},
|
|
15548
15610
|
processingInput() {
|
|
15549
|
-
|
|
15611
|
+
const latexWithCursor = insertCursorMarkers(
|
|
15612
|
+
this.inputBox.value,
|
|
15613
|
+
this.inputBox.selectionStart,
|
|
15614
|
+
this.inputBox.selectionEnd
|
|
15615
|
+
);
|
|
15616
|
+
this.restruct(latexWithCursor);
|
|
15550
15617
|
this.kfEditor.requestService("ui.update.canvas.view");
|
|
15551
15618
|
},
|
|
15552
15619
|
restruct(latexStr) {
|
|
@@ -16052,26 +16119,26 @@ var init_printer = __esm({
|
|
|
16052
16119
|
var start_exports = {};
|
|
16053
16120
|
__export(start_exports, {
|
|
16054
16121
|
Factory: () => factory_default,
|
|
16055
|
-
KFEditor: () =>
|
|
16122
|
+
KFEditor: () => editor_default,
|
|
16056
16123
|
default: () => start_default,
|
|
16057
16124
|
installKityEditorStart: () => installKityEditorStart
|
|
16058
16125
|
});
|
|
16059
16126
|
function installKityEditorStart(target = window) {
|
|
16060
16127
|
const runtimeTarget = target;
|
|
16061
16128
|
if (!installed3) {
|
|
16062
|
-
|
|
16063
|
-
|
|
16064
|
-
|
|
16065
|
-
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16129
|
+
editor_default.registerComponents("ui", ui_default);
|
|
16130
|
+
editor_default.registerComponents("parser", parser_default);
|
|
16131
|
+
editor_default.registerComponents("render", render_default);
|
|
16132
|
+
editor_default.registerComponents("position", position_default);
|
|
16133
|
+
editor_default.registerComponents("syntax", syntax_default);
|
|
16134
|
+
editor_default.registerComponents("control", controller_default);
|
|
16135
|
+
editor_default.registerComponents("print", printer_default);
|
|
16069
16136
|
installed3 = true;
|
|
16070
16137
|
}
|
|
16071
16138
|
runtimeTarget.kf = runtimeTarget.kf ?? {};
|
|
16072
16139
|
runtimeTarget.kf.EditorFactory = factory_default;
|
|
16073
16140
|
return {
|
|
16074
|
-
KFEditor:
|
|
16141
|
+
KFEditor: editor_default,
|
|
16075
16142
|
Factory: factory_default
|
|
16076
16143
|
};
|
|
16077
16144
|
}
|
|
@@ -16079,7 +16146,7 @@ var installed3, start_default;
|
|
|
16079
16146
|
var init_start = __esm({
|
|
16080
16147
|
"src/boot/start.ts"() {
|
|
16081
16148
|
"use strict";
|
|
16082
|
-
|
|
16149
|
+
init_editor();
|
|
16083
16150
|
init_factory();
|
|
16084
16151
|
init_ui();
|
|
16085
16152
|
init_parser();
|
|
@@ -16096,6 +16163,8 @@ var init_start = __esm({
|
|
|
16096
16163
|
// src/index.ts
|
|
16097
16164
|
var index_exports = {};
|
|
16098
16165
|
__export(index_exports, {
|
|
16166
|
+
DEFAULT_FORMULAX_LOCALE: () => DEFAULT_FORMULAX_LOCALE,
|
|
16167
|
+
FORMULAX_LOCALES: () => FORMULAX_LOCALES,
|
|
16099
16168
|
FormulaXEditor: () => FormulaXEditor,
|
|
16100
16169
|
addEvent: () => addEvent,
|
|
16101
16170
|
createElement: () => createElement,
|
|
@@ -16105,6 +16174,7 @@ __export(index_exports, {
|
|
|
16105
16174
|
delegateEvent: () => delegateEvent,
|
|
16106
16175
|
ensureKityRuntime: () => ensureKityRuntime,
|
|
16107
16176
|
getClassList: () => getClassList,
|
|
16177
|
+
getFormulaXRuntimeMessage: () => getFormulaXRuntimeMessage,
|
|
16108
16178
|
getRectBox: () => getRectBox,
|
|
16109
16179
|
installLegacyKityData: () => installLegacyKityData,
|
|
16110
16180
|
kityAssetManifest: () => kityAssetManifest,
|
|
@@ -16125,9 +16195,11 @@ __export(index_exports, {
|
|
|
16125
16195
|
legacyUiDef: () => legacyUiDef,
|
|
16126
16196
|
legacyUiUtils: () => legacyUiUtils,
|
|
16127
16197
|
mountKityEditor: () => mountKityEditor,
|
|
16198
|
+
normalizeFormulaXLocale: () => normalizeFormulaXLocale,
|
|
16128
16199
|
normalizeMouseEvent: () => normalizeMouseEvent,
|
|
16129
16200
|
publish: () => publish,
|
|
16130
|
-
subscribe: () => subscribe
|
|
16201
|
+
subscribe: () => subscribe,
|
|
16202
|
+
translateFormulaXText: () => translateFormulaXText
|
|
16131
16203
|
});
|
|
16132
16204
|
module.exports = __toCommonJS(index_exports);
|
|
16133
16205
|
init_asset_manifest();
|
|
@@ -19612,6 +19684,7 @@ function clearFormulaXPerfMarks(...marks) {
|
|
|
19612
19684
|
|
|
19613
19685
|
// src/create-editor.ts
|
|
19614
19686
|
init_toolbar_assets();
|
|
19687
|
+
init_i18n();
|
|
19615
19688
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
19616
19689
|
var DEFAULT_EDITOR_HEIGHT = "auto";
|
|
19617
19690
|
var KITY_STYLE_ID = "formulax-kity-editor-styles";
|
|
@@ -19762,8 +19835,10 @@ async function createKityEditor(container, options = {}) {
|
|
|
19762
19835
|
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
19763
19836
|
const fontsize = options.render?.fontsize ?? 40;
|
|
19764
19837
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
19838
|
+
const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
|
|
19765
19839
|
const assets = resolveEditorAssets(options.assets);
|
|
19766
19840
|
try {
|
|
19841
|
+
legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
|
|
19767
19842
|
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
19768
19843
|
if (stylesheetInserted) {
|
|
19769
19844
|
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
@@ -19790,6 +19865,9 @@ async function createKityEditor(container, options = {}) {
|
|
|
19790
19865
|
render: {
|
|
19791
19866
|
fontsize
|
|
19792
19867
|
},
|
|
19868
|
+
ui: {
|
|
19869
|
+
locale
|
|
19870
|
+
},
|
|
19793
19871
|
resource: {
|
|
19794
19872
|
path: "",
|
|
19795
19873
|
fonts: assets.fonts
|
|
@@ -19872,6 +19950,7 @@ if (typeof window !== "undefined") {
|
|
|
19872
19950
|
|
|
19873
19951
|
// src/index.ts
|
|
19874
19952
|
init_dom_utils();
|
|
19953
|
+
init_i18n();
|
|
19875
19954
|
init_legacy_box_type();
|
|
19876
19955
|
init_legacy_component();
|
|
19877
19956
|
init_legacy_ele_type();
|
|
@@ -19898,6 +19977,8 @@ init_legacy_ui_utils();
|
|
|
19898
19977
|
init_legacy_utils();
|
|
19899
19978
|
// Annotate the CommonJS export names for ESM import in node:
|
|
19900
19979
|
0 && (module.exports = {
|
|
19980
|
+
DEFAULT_FORMULAX_LOCALE,
|
|
19981
|
+
FORMULAX_LOCALES,
|
|
19901
19982
|
FormulaXEditor,
|
|
19902
19983
|
addEvent,
|
|
19903
19984
|
createElement,
|
|
@@ -19907,6 +19988,7 @@ init_legacy_utils();
|
|
|
19907
19988
|
delegateEvent,
|
|
19908
19989
|
ensureKityRuntime,
|
|
19909
19990
|
getClassList,
|
|
19991
|
+
getFormulaXRuntimeMessage,
|
|
19910
19992
|
getRectBox,
|
|
19911
19993
|
installLegacyKityData,
|
|
19912
19994
|
kityAssetManifest,
|
|
@@ -19927,9 +20009,11 @@ init_legacy_utils();
|
|
|
19927
20009
|
legacyUiDef,
|
|
19928
20010
|
legacyUiUtils,
|
|
19929
20011
|
mountKityEditor,
|
|
20012
|
+
normalizeFormulaXLocale,
|
|
19930
20013
|
normalizeMouseEvent,
|
|
19931
20014
|
publish,
|
|
19932
|
-
subscribe
|
|
20015
|
+
subscribe,
|
|
20016
|
+
translateFormulaXText
|
|
19933
20017
|
});
|
|
19934
20018
|
/*!
|
|
19935
20019
|
* Reverse parsing handler: brackets
|