@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
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
|
-
// ../kity-runtime/public/assets/images/toolbar/btn.png
|
|
25
|
-
var btn_default;
|
|
26
|
-
var init_btn = __esm({
|
|
27
|
-
"../kity-runtime/public/assets/images/toolbar/btn.png"() {
|
|
28
|
-
btn_default = "./btn-5DANP6JY.png";
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// ../kity-runtime/public/assets/images/toolbar/other.png
|
|
33
|
-
var other_default;
|
|
34
|
-
var init_other = __esm({
|
|
35
|
-
"../kity-runtime/public/assets/images/toolbar/other.png"() {
|
|
36
|
-
other_default = "./other-OMWJFGL5.png";
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// ../kity-runtime/public/assets/styles/editor.css?url
|
|
41
|
-
var editor_default;
|
|
42
|
-
var init_editor = __esm({
|
|
43
|
-
"../kity-runtime/public/assets/styles/editor.css?url"() {
|
|
44
|
-
editor_default = "./editor-JT5KLVXX.css?url";
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// ../kity-runtime/public/resource/KF_AMS_BB.woff
|
|
49
|
-
var KF_AMS_BB_default;
|
|
50
|
-
var init_KF_AMS_BB = __esm({
|
|
51
|
-
"../kity-runtime/public/resource/KF_AMS_BB.woff"() {
|
|
52
|
-
KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// ../kity-runtime/public/resource/KF_AMS_CAL.woff
|
|
57
|
-
var KF_AMS_CAL_default;
|
|
58
|
-
var init_KF_AMS_CAL = __esm({
|
|
59
|
-
"../kity-runtime/public/resource/KF_AMS_CAL.woff"() {
|
|
60
|
-
KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// ../kity-runtime/public/resource/KF_AMS_FRAK.woff
|
|
65
|
-
var KF_AMS_FRAK_default;
|
|
66
|
-
var init_KF_AMS_FRAK = __esm({
|
|
67
|
-
"../kity-runtime/public/resource/KF_AMS_FRAK.woff"() {
|
|
68
|
-
KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// ../kity-runtime/public/resource/KF_AMS_MAIN.woff
|
|
73
|
-
var KF_AMS_MAIN_default;
|
|
74
|
-
var init_KF_AMS_MAIN = __esm({
|
|
75
|
-
"../kity-runtime/public/resource/KF_AMS_MAIN.woff"() {
|
|
76
|
-
KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// ../kity-runtime/public/resource/KF_AMS_ROMAN.woff
|
|
81
|
-
var KF_AMS_ROMAN_default;
|
|
82
|
-
var init_KF_AMS_ROMAN = __esm({
|
|
83
|
-
"../kity-runtime/public/resource/KF_AMS_ROMAN.woff"() {
|
|
84
|
-
KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
40
|
// ../kity-runtime/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
|
"../kity-runtime/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,86 @@ var FormulaX = (() => {
|
|
|
5072
5024
|
}
|
|
5073
5025
|
});
|
|
5074
5026
|
|
|
5027
|
+
// ../kity-runtime/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 DEFAULT_FORMULAX_LOCALE, FORMULAX_TRANSLATIONS, FORMULAX_RUNTIME_MESSAGES;
|
|
5054
|
+
var init_i18n = __esm({
|
|
5055
|
+
"../kity-runtime/src/i18n.ts"() {
|
|
5056
|
+
"use strict";
|
|
5057
|
+
DEFAULT_FORMULAX_LOCALE = "en_US";
|
|
5058
|
+
FORMULAX_TRANSLATIONS = {
|
|
5059
|
+
en_US: {
|
|
5060
|
+
toolbar: {
|
|
5061
|
+
\u9884\u8BBE: "Presets",
|
|
5062
|
+
\u9884\u8BBE\u516C\u5F0F: "Presets",
|
|
5063
|
+
\u4E8C\u6B21\u516C\u5F0F: "Quadratic",
|
|
5064
|
+
\u4E8C\u9879\u5F0F\u5B9A\u7406: "Binomial",
|
|
5065
|
+
\u52FE\u80A1\u5B9A\u7406: "Pythagorean",
|
|
5066
|
+
\u57FA\u7840\u6570\u5B66: "Basic math",
|
|
5067
|
+
\u5E0C\u814A\u5B57\u6BCD: "Greek",
|
|
5068
|
+
\u6C42\u53CD\u5173\u7CFB\u8FD0\u7B97\u7B26: "Negated operators",
|
|
5069
|
+
\u5B57\u6BCD\u7C7B\u7B26\u53F7: "Letter symbols",
|
|
5070
|
+
\u7BAD\u5934: "Arrows",
|
|
5071
|
+
\u624B\u5199\u4F53: "Script",
|
|
5072
|
+
\u5206\u6570: "Fraction",
|
|
5073
|
+
\u5E38\u7528\u5206\u6570: "Common fractions",
|
|
5074
|
+
\u4E0A\u4E0B\u6807: "Scripts",
|
|
5075
|
+
\u4E0A\u6807\u548C\u4E0B\u6807: "Super/subscripts",
|
|
5076
|
+
\u5E38\u7528\u7684\u4E0A\u6807\u548C\u4E0B\u6807: "Common super/subscripts",
|
|
5077
|
+
\u6839\u5F0F: "Radicals",
|
|
5078
|
+
\u5E38\u7528\u6839\u5F0F: "Common radicals",
|
|
5079
|
+
\u79EF\u5206: "Integrals",
|
|
5080
|
+
\u5927\u578B\u8FD0\u7B97\u7B26: "Large<br/>ops",
|
|
5081
|
+
\u6C42\u548C: "Summations",
|
|
5082
|
+
\u62EC\u53F7: "Brackets",
|
|
5083
|
+
\u65B9\u62EC\u53F7: "Brackets",
|
|
5084
|
+
\u51FD\u6570: "Functions",
|
|
5085
|
+
\u4E09\u89D2\u51FD\u6570: "Trig functions",
|
|
5086
|
+
\u5E38\u7528\u51FD\u6570: "Common functions",
|
|
5087
|
+
\u5C0F\u5199: "Lowercase",
|
|
5088
|
+
\u5927\u5199: "Uppercase",
|
|
5089
|
+
\u53D8\u4F53: "Variants",
|
|
5090
|
+
\u82B1\u4F53: "Fraktur",
|
|
5091
|
+
\u53CC\u7EBF: "Double-struck",
|
|
5092
|
+
\u7F57\u9A6C: "Roman"
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
};
|
|
5096
|
+
FORMULAX_RUNTIME_MESSAGES = {
|
|
5097
|
+
en_US: {
|
|
5098
|
+
"editor.placeholder.root": "Type formula here"
|
|
5099
|
+
},
|
|
5100
|
+
zh_CN: {
|
|
5101
|
+
"editor.placeholder.root": "\u8BF7\u8F93\u5165\u516C\u5F0F"
|
|
5102
|
+
}
|
|
5103
|
+
};
|
|
5104
|
+
}
|
|
5105
|
+
});
|
|
5106
|
+
|
|
5075
5107
|
// ../kity-runtime/src/vendor/kity-formula/binary-expression.ts
|
|
5076
5108
|
var BinaryExpressionModule, createBinaryExpressionClass;
|
|
5077
5109
|
var init_binary_expression = __esm({
|
|
@@ -5957,14 +5989,11 @@ var FormulaX = (() => {
|
|
|
5957
5989
|
count2 += 1;
|
|
5958
5990
|
fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
|
|
5959
5991
|
this.createFontStyle(fontInfo);
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
complete(this.doc, callback);
|
|
5966
|
-
}
|
|
5967
|
-
});
|
|
5992
|
+
applyFonts(this.doc, fontInfo);
|
|
5993
|
+
count2 -= 1;
|
|
5994
|
+
if (count2 === 0) {
|
|
5995
|
+
complete(this.doc, callback);
|
|
5996
|
+
}
|
|
5968
5997
|
});
|
|
5969
5998
|
},
|
|
5970
5999
|
createFontStyle: function(fontInfo) {
|
|
@@ -5975,13 +6004,6 @@ var FormulaX = (() => {
|
|
|
5975
6004
|
this.doc.head.appendChild(stylesheet);
|
|
5976
6005
|
}
|
|
5977
6006
|
});
|
|
5978
|
-
function preloadFont(doc2, fontInfo) {
|
|
5979
|
-
const view = doc2.defaultView ?? window;
|
|
5980
|
-
if (view.fetch) {
|
|
5981
|
-
return view.fetch(fontInfo.meta.src, { method: "GET" }).then(() => void 0);
|
|
5982
|
-
}
|
|
5983
|
-
return Promise.resolve();
|
|
5984
|
-
}
|
|
5985
6007
|
function resolveFontSource(fonts, resourceBase, originalSrc) {
|
|
5986
6008
|
const directMatch = fonts[originalSrc];
|
|
5987
6009
|
if (directMatch) {
|
|
@@ -6139,11 +6161,11 @@ var FormulaX = (() => {
|
|
|
6139
6161
|
bg;
|
|
6140
6162
|
exp;
|
|
6141
6163
|
config;
|
|
6142
|
-
constructor(kity26, exp,
|
|
6164
|
+
constructor(kity26, exp, config) {
|
|
6143
6165
|
this.wrap = new kity26.Group();
|
|
6144
6166
|
this.bg = new kity26.Rect(0, 0, 0, 0).fill("transparent");
|
|
6145
6167
|
this.exp = exp;
|
|
6146
|
-
this.config =
|
|
6168
|
+
this.config = config;
|
|
6147
6169
|
this.wrap.setAttr("data-type", "kf-exp-wrap");
|
|
6148
6170
|
this.bg.setAttr("data-type", "kf-exp-wrap-bg");
|
|
6149
6171
|
this.wrap.addShape(this.bg);
|
|
@@ -6172,14 +6194,14 @@ var FormulaX = (() => {
|
|
|
6172
6194
|
static create(kity26, GTYPE2, FontManager, FontInstaller, FPaper, Output) {
|
|
6173
6195
|
const Formula = kity26.createClass("Formula", {
|
|
6174
6196
|
base: FPaper,
|
|
6175
|
-
constructor: function(container,
|
|
6197
|
+
constructor: function(container, config) {
|
|
6176
6198
|
if (this.__FORMULAX_PRESERVE_CALL_BASE__) {
|
|
6177
6199
|
this.callBase(container);
|
|
6178
6200
|
}
|
|
6179
6201
|
FPaper.call(this, container);
|
|
6180
6202
|
this.expressions = [];
|
|
6181
6203
|
this.fontInstaller = new FontInstaller(this);
|
|
6182
|
-
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS,
|
|
6204
|
+
this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS, config);
|
|
6183
6205
|
this.initEnvironment();
|
|
6184
6206
|
this.initInnerFont();
|
|
6185
6207
|
},
|
|
@@ -13644,7 +13666,7 @@ var FormulaX = (() => {
|
|
|
13644
13666
|
value: function() {
|
|
13645
13667
|
const kf7 = window2.kf;
|
|
13646
13668
|
const CONSTRUCT_MAPPING = {};
|
|
13647
|
-
const
|
|
13669
|
+
const CURSOR_CHAR4 = "\uF155";
|
|
13648
13670
|
class Assembly {
|
|
13649
13671
|
formula;
|
|
13650
13672
|
constructor(formula) {
|
|
@@ -13681,7 +13703,7 @@ var FormulaX = (() => {
|
|
|
13681
13703
|
if (tree.name.indexOf("text") === -1) {
|
|
13682
13704
|
for (let i2 = 0, len = operand.length; i2 < len; i2 += 1) {
|
|
13683
13705
|
currentOperand = operand[i2];
|
|
13684
|
-
if (currentOperand ===
|
|
13706
|
+
if (currentOperand === CURSOR_CHAR4) {
|
|
13685
13707
|
cursorLocation.push(i2);
|
|
13686
13708
|
if (!Object.prototype.hasOwnProperty.call(selectInfo, "startOffset")) {
|
|
13687
13709
|
selectInfo.startOffset = i2;
|
|
@@ -14975,8 +14997,8 @@ var FormulaX = (() => {
|
|
|
14975
14997
|
}
|
|
14976
14998
|
return serviceObject;
|
|
14977
14999
|
}
|
|
14978
|
-
var defaultOptions, components, kity2, kf, KFEditor,
|
|
14979
|
-
var
|
|
15000
|
+
var defaultOptions, components, kity2, kf, KFEditor, editor_default;
|
|
15001
|
+
var init_editor = __esm({
|
|
14980
15002
|
"../kity-runtime/src/legacy/editor.ts"() {
|
|
14981
15003
|
"use strict";
|
|
14982
15004
|
init_legacy_utils();
|
|
@@ -15087,7 +15109,7 @@ var FormulaX = (() => {
|
|
|
15087
15109
|
components[name] = component;
|
|
15088
15110
|
}
|
|
15089
15111
|
});
|
|
15090
|
-
|
|
15112
|
+
editor_default = KFEditor;
|
|
15091
15113
|
}
|
|
15092
15114
|
});
|
|
15093
15115
|
|
|
@@ -15096,13 +15118,13 @@ var FormulaX = (() => {
|
|
|
15096
15118
|
var init_factory = __esm({
|
|
15097
15119
|
"../kity-runtime/src/legacy/factory.ts"() {
|
|
15098
15120
|
"use strict";
|
|
15099
|
-
|
|
15121
|
+
init_editor();
|
|
15100
15122
|
init_runtime_interop();
|
|
15101
15123
|
EditorWrapper = class {
|
|
15102
15124
|
callbacks = [];
|
|
15103
15125
|
editor;
|
|
15104
15126
|
constructor(container, options) {
|
|
15105
|
-
this.editor = new
|
|
15127
|
+
this.editor = new editor_default(container, options);
|
|
15106
15128
|
this.editor.ready(() => {
|
|
15107
15129
|
this.trigger();
|
|
15108
15130
|
});
|
|
@@ -16670,6 +16692,7 @@ var FormulaX = (() => {
|
|
|
16670
16692
|
to: "\u2192",
|
|
16671
16693
|
downarrow: "\u2193",
|
|
16672
16694
|
leftrightarrow: "\u2194",
|
|
16695
|
+
updownarrow: "\u2195",
|
|
16673
16696
|
therefore: "\u2234",
|
|
16674
16697
|
because: "\u2235",
|
|
16675
16698
|
"+": "+",
|
|
@@ -16786,7 +16809,7 @@ var FormulaX = (() => {
|
|
|
16786
16809
|
Uparrow: "\u21D1",
|
|
16787
16810
|
Downarrow: "\u21D3",
|
|
16788
16811
|
Leftrightarrow: "\u21D4",
|
|
16789
|
-
Updownarrow: "\
|
|
16812
|
+
Updownarrow: "\u21D5",
|
|
16790
16813
|
longleftarrow: "\u27F5",
|
|
16791
16814
|
longrightarrow: "\u27F6",
|
|
16792
16815
|
longleftrightarrow: "\u27F7",
|
|
@@ -16853,6 +16876,26 @@ var FormulaX = (() => {
|
|
|
16853
16876
|
}
|
|
16854
16877
|
Object.keys(list).forEach((key) => callback(list[key], key));
|
|
16855
16878
|
}
|
|
16879
|
+
function translateToolbarText(value, locale) {
|
|
16880
|
+
return translateFormulaXText("toolbar", value, locale);
|
|
16881
|
+
}
|
|
16882
|
+
function localizeToolbarConfig(value, locale) {
|
|
16883
|
+
if (Array.isArray(value)) {
|
|
16884
|
+
return value.map((item) => localizeToolbarConfig(item, locale));
|
|
16885
|
+
}
|
|
16886
|
+
if (!value || typeof value !== "object") {
|
|
16887
|
+
return value;
|
|
16888
|
+
}
|
|
16889
|
+
const result = {};
|
|
16890
|
+
for (const [key, currentValue] of Object.entries(value)) {
|
|
16891
|
+
if ((key === "label" || key === "title") && typeof currentValue === "string") {
|
|
16892
|
+
result[key] = translateToolbarText(currentValue, locale);
|
|
16893
|
+
continue;
|
|
16894
|
+
}
|
|
16895
|
+
result[key] = localizeToolbarConfig(currentValue, locale);
|
|
16896
|
+
}
|
|
16897
|
+
return result;
|
|
16898
|
+
}
|
|
16856
16899
|
function getUnicodeContents(keySet) {
|
|
16857
16900
|
let result = [];
|
|
16858
16901
|
each(keySet, function(key) {
|
|
@@ -16872,7 +16915,13 @@ var FormulaX = (() => {
|
|
|
16872
16915
|
});
|
|
16873
16916
|
return result;
|
|
16874
16917
|
}
|
|
16875
|
-
|
|
16918
|
+
function createToolbarConfig(locale = DEFAULT_FORMULAX_LOCALE) {
|
|
16919
|
+
return localizeToolbarConfig(
|
|
16920
|
+
baseToolbarConfig,
|
|
16921
|
+
normalizeFormulaXLocale(locale)
|
|
16922
|
+
);
|
|
16923
|
+
}
|
|
16924
|
+
var UI_ELE_TYPE, BOX_TYPE2, OTHER_POSITION, baseToolbarConfig, toolbar_config_default;
|
|
16876
16925
|
var init_toolbar_config = __esm({
|
|
16877
16926
|
"../kity-runtime/src/legacy/toolbar-config.ts"() {
|
|
16878
16927
|
"use strict";
|
|
@@ -16881,10 +16930,11 @@ var FormulaX = (() => {
|
|
|
16881
16930
|
init_other_position();
|
|
16882
16931
|
init_toolbar_assets();
|
|
16883
16932
|
init_formula_symbols();
|
|
16933
|
+
init_i18n();
|
|
16884
16934
|
UI_ELE_TYPE = legacyEleType;
|
|
16885
16935
|
BOX_TYPE2 = legacyBoxType;
|
|
16886
16936
|
OTHER_POSITION = legacyOtherPosition;
|
|
16887
|
-
|
|
16937
|
+
baseToolbarConfig = [{
|
|
16888
16938
|
type: UI_ELE_TYPE.DRAPDOWN_BOX,
|
|
16889
16939
|
options: {
|
|
16890
16940
|
button: {
|
|
@@ -17290,7 +17340,7 @@ var FormulaX = (() => {
|
|
|
17290
17340
|
}];
|
|
17291
17341
|
(function() {
|
|
17292
17342
|
let tmp = [], otherImageSrc = resolveToolbarAssetPath("other.png"), currentConf = [];
|
|
17293
|
-
each(
|
|
17343
|
+
each(baseToolbarConfig, function(conf) {
|
|
17294
17344
|
if (conf.type === UI_ELE_TYPE.DELIMITER) {
|
|
17295
17345
|
return;
|
|
17296
17346
|
}
|
|
@@ -17362,7 +17412,7 @@ var FormulaX = (() => {
|
|
|
17362
17412
|
"aleph",
|
|
17363
17413
|
"beth",
|
|
17364
17414
|
"blacksquare"
|
|
17365
|
-
], configList =
|
|
17415
|
+
], configList = baseToolbarConfig[2].options.box.group[0].items;
|
|
17366
17416
|
configList.push({
|
|
17367
17417
|
title: "\u57FA\u7840\u6570\u5B66",
|
|
17368
17418
|
content: getUnicodeContents(list)
|
|
@@ -17378,7 +17428,7 @@ var FormulaX = (() => {
|
|
|
17378
17428
|
}, {
|
|
17379
17429
|
title: "\u53D8\u4F53",
|
|
17380
17430
|
values: ["digamma", "varepsilon", "varkappa", "varphi", "varpi", "varrho", "varsigma", "vartheta"]
|
|
17381
|
-
}], greekConfigList =
|
|
17431
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[1].items;
|
|
17382
17432
|
greekConfigList.push({
|
|
17383
17433
|
title: greekList[0].title,
|
|
17384
17434
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -17427,7 +17477,7 @@ var FormulaX = (() => {
|
|
|
17427
17477
|
"nVDash",
|
|
17428
17478
|
"nexists"
|
|
17429
17479
|
]
|
|
17430
|
-
}], greekConfigList =
|
|
17480
|
+
}], greekConfigList = baseToolbarConfig[2].options.box.group[2].items;
|
|
17431
17481
|
greekConfigList.push({
|
|
17432
17482
|
title: greekList[0].title,
|
|
17433
17483
|
content: getUnicodeContents(greekList[0].values)
|
|
@@ -17453,7 +17503,7 @@ var FormulaX = (() => {
|
|
|
17453
17503
|
"Game",
|
|
17454
17504
|
"Im",
|
|
17455
17505
|
"Re"
|
|
17456
|
-
], configList =
|
|
17506
|
+
], configList = baseToolbarConfig[2].options.box.group[3].items;
|
|
17457
17507
|
configList.push({
|
|
17458
17508
|
title: "\u5B57\u6BCD\u7C7B\u7B26\u53F7",
|
|
17459
17509
|
content: getUnicodeContents(list)
|
|
@@ -17521,7 +17571,7 @@ var FormulaX = (() => {
|
|
|
17521
17571
|
"twoheadleftarrow",
|
|
17522
17572
|
"twoheadrightarrow",
|
|
17523
17573
|
"rightsquigarrow"
|
|
17524
|
-
], configList =
|
|
17574
|
+
], configList = baseToolbarConfig[2].options.box.group[4].items;
|
|
17525
17575
|
configList.push({
|
|
17526
17576
|
title: "\u7BAD\u5934",
|
|
17527
17577
|
content: getUnicodeContents(list)
|
|
@@ -17700,7 +17750,7 @@ var FormulaX = (() => {
|
|
|
17700
17750
|
"y",
|
|
17701
17751
|
"z"
|
|
17702
17752
|
]
|
|
17703
|
-
}], configList =
|
|
17753
|
+
}], configList = baseToolbarConfig[2].options.box.group[5].items;
|
|
17704
17754
|
each(list[0].values, function(item, index) {
|
|
17705
17755
|
list[0].values[index] = "mathcal{" + item + "}";
|
|
17706
17756
|
});
|
|
@@ -17730,7 +17780,7 @@ var FormulaX = (() => {
|
|
|
17730
17780
|
content: getUnicodeContents(list[3].values)
|
|
17731
17781
|
});
|
|
17732
17782
|
})();
|
|
17733
|
-
toolbar_config_default =
|
|
17783
|
+
toolbar_config_default = createToolbarConfig;
|
|
17734
17784
|
}
|
|
17735
17785
|
});
|
|
17736
17786
|
|
|
@@ -17773,6 +17823,7 @@ var FormulaX = (() => {
|
|
|
17773
17823
|
init_toolbar();
|
|
17774
17824
|
init_scrollbar();
|
|
17775
17825
|
init_toolbar_config();
|
|
17826
|
+
init_i18n();
|
|
17776
17827
|
$$8 = createLegacyUiUtils();
|
|
17777
17828
|
VIEW_STATE = legacyUiDef.VIEW_STATE;
|
|
17778
17829
|
DEFAULT_EDIT_AREA_HEIGHT = 100;
|
|
@@ -17803,7 +17854,8 @@ var FormulaX = (() => {
|
|
|
17803
17854
|
this.initScrollEvent();
|
|
17804
17855
|
},
|
|
17805
17856
|
initComponents() {
|
|
17806
|
-
|
|
17857
|
+
const toolbarConfig = toolbar_config_default(normalizeFormulaXLocale(this.options.locale));
|
|
17858
|
+
this.components.toolbar = new toolbar_default(this, this.kfEditor, toolbarConfig);
|
|
17807
17859
|
this.components.scrollbar = new scrollbar_default(this, this.kfEditor);
|
|
17808
17860
|
},
|
|
17809
17861
|
updateContainerSize(container, toolbar, editArea) {
|
|
@@ -18112,6 +18164,9 @@ var FormulaX = (() => {
|
|
|
18112
18164
|
operand: []
|
|
18113
18165
|
};
|
|
18114
18166
|
}
|
|
18167
|
+
function getRootPlaceholderText() {
|
|
18168
|
+
return legacySysconf.rootPlaceholder.content;
|
|
18169
|
+
}
|
|
18115
18170
|
function processRootGroup(parser, tree) {
|
|
18116
18171
|
if (!parser.isResetId) {
|
|
18117
18172
|
tree.attr["data-type"] = legacyGroupType.VIRTUAL;
|
|
@@ -18159,7 +18214,7 @@ var FormulaX = (() => {
|
|
|
18159
18214
|
if (isRoot) {
|
|
18160
18215
|
processRootGroup(parser, tree);
|
|
18161
18216
|
} else if (parentTree?.attr?.["data-root"] && tree.name === "placeholder" && onlyPlaceholder(parentTree.operand)) {
|
|
18162
|
-
tree.attr.label =
|
|
18217
|
+
tree.attr.label = getRootPlaceholderText();
|
|
18163
18218
|
}
|
|
18164
18219
|
for (let i2 = 0; i2 < tree.operand.length; i2 += 1) {
|
|
18165
18220
|
const currentOperand = tree.operand[i2];
|
|
@@ -18171,7 +18226,7 @@ var FormulaX = (() => {
|
|
|
18171
18226
|
}
|
|
18172
18227
|
return tree;
|
|
18173
18228
|
}
|
|
18174
|
-
var CURSOR_CHAR,
|
|
18229
|
+
var CURSOR_CHAR, COMBINATION_NAME, PID_PREFIX, pidSeed, kity14, kf5, BaseComponent, Parser, parser_default;
|
|
18175
18230
|
var init_parser = __esm({
|
|
18176
18231
|
"../kity-runtime/src/legacy/parser.ts"() {
|
|
18177
18232
|
"use strict";
|
|
@@ -18182,7 +18237,6 @@ var FormulaX = (() => {
|
|
|
18182
18237
|
init_kf_ext_extension();
|
|
18183
18238
|
init_vgroup_def();
|
|
18184
18239
|
CURSOR_CHAR = legacySysconf.cursorCharacter;
|
|
18185
|
-
ROOT_P_TEXT = legacySysconf.rootPlaceholder.content;
|
|
18186
18240
|
COMBINATION_NAME = "combination";
|
|
18187
18241
|
PID_PREFIX = "_kf_editor_";
|
|
18188
18242
|
pidSeed = 0;
|
|
@@ -19070,6 +19124,21 @@ var FormulaX = (() => {
|
|
|
19070
19124
|
});
|
|
19071
19125
|
|
|
19072
19126
|
// ../kity-runtime/src/legacy/syntax.ts
|
|
19127
|
+
function clampOffset(offset, maxOffset) {
|
|
19128
|
+
return Math.max(0, Math.min(offset, maxOffset));
|
|
19129
|
+
}
|
|
19130
|
+
function normalizeCursorRecord(objTree, cursor) {
|
|
19131
|
+
const fallbackGroupId = objTree.mapping.root.strGroup.attr.id;
|
|
19132
|
+
const targetGroupId = cursor.groupId && objTree.mapping[cursor.groupId] ? cursor.groupId : fallbackGroupId;
|
|
19133
|
+
const operandCount = objTree.mapping[targetGroupId].strGroup.operand.length;
|
|
19134
|
+
const startOffset = clampOffset(cursor.startOffset, operandCount);
|
|
19135
|
+
const endOffset = clampOffset(cursor.endOffset, operandCount);
|
|
19136
|
+
return {
|
|
19137
|
+
groupId: targetGroupId,
|
|
19138
|
+
startOffset: Math.min(startOffset, endOffset),
|
|
19139
|
+
endOffset: Math.max(startOffset, endOffset)
|
|
19140
|
+
};
|
|
19141
|
+
}
|
|
19073
19142
|
var CURSOR_CHAR2, kity19, SyntaxComponent, syntax_default;
|
|
19074
19143
|
var init_syntax = __esm({
|
|
19075
19144
|
"../kity-runtime/src/legacy/syntax.ts"() {
|
|
@@ -19130,10 +19199,14 @@ var FormulaX = (() => {
|
|
|
19130
19199
|
},
|
|
19131
19200
|
updateObjTree(objTree) {
|
|
19132
19201
|
const selectInfo = objTree.select;
|
|
19202
|
+
this.objTree = objTree;
|
|
19133
19203
|
if (selectInfo?.groupId) {
|
|
19134
19204
|
this.updateCursor(selectInfo.groupId, selectInfo.startOffset, selectInfo.endOffset);
|
|
19205
|
+
return;
|
|
19206
|
+
}
|
|
19207
|
+
if (this.record.cursor.groupId !== null) {
|
|
19208
|
+
this.record.cursor = normalizeCursorRecord(objTree, this.record.cursor);
|
|
19135
19209
|
}
|
|
19136
|
-
this.objTree = objTree;
|
|
19137
19210
|
},
|
|
19138
19211
|
hasCursorInfo() {
|
|
19139
19212
|
return this.record.cursor.groupId !== null;
|
|
@@ -19179,7 +19252,8 @@ var FormulaX = (() => {
|
|
|
19179
19252
|
return this.objTree;
|
|
19180
19253
|
},
|
|
19181
19254
|
getGroupObject(id) {
|
|
19182
|
-
|
|
19255
|
+
const groupInfo = this.objTree.mapping[id];
|
|
19256
|
+
return groupInfo ? groupInfo.objGroup : null;
|
|
19183
19257
|
},
|
|
19184
19258
|
getCursorRecord() {
|
|
19185
19259
|
return kity19.Utils.extend({}, this.record.cursor);
|
|
@@ -19255,7 +19329,7 @@ var FormulaX = (() => {
|
|
|
19255
19329
|
return this.hasRootplaceholder();
|
|
19256
19330
|
},
|
|
19257
19331
|
serialization() {
|
|
19258
|
-
const cursor = this.record.cursor;
|
|
19332
|
+
const cursor = normalizeCursorRecord(this.objTree, this.record.cursor);
|
|
19259
19333
|
const objGroup = this.objTree.mapping[cursor.groupId];
|
|
19260
19334
|
const curStrGroup = objGroup.strGroup;
|
|
19261
19335
|
let strStartIndex = Math.min(cursor.endOffset, cursor.startOffset);
|
|
@@ -19291,11 +19365,12 @@ var FormulaX = (() => {
|
|
|
19291
19365
|
endOffset = startOffset;
|
|
19292
19366
|
startOffset = tmp;
|
|
19293
19367
|
}
|
|
19294
|
-
|
|
19368
|
+
const nextCursor = {
|
|
19295
19369
|
groupId,
|
|
19296
19370
|
startOffset,
|
|
19297
19371
|
endOffset
|
|
19298
19372
|
};
|
|
19373
|
+
this.record.cursor = this.objTree ? normalizeCursorRecord(this.objTree, nextCursor) : nextCursor;
|
|
19299
19374
|
},
|
|
19300
19375
|
leftMove() {
|
|
19301
19376
|
this.components.move.leftMove();
|
|
@@ -19336,12 +19411,20 @@ var FormulaX = (() => {
|
|
|
19336
19411
|
});
|
|
19337
19412
|
|
|
19338
19413
|
// ../kity-runtime/src/legacy/input.ts
|
|
19339
|
-
|
|
19414
|
+
function insertCursorMarkers(value, selectionStart, selectionEnd) {
|
|
19415
|
+
const normalizedStart = Math.max(0, Math.min(selectionStart ?? value.length, value.length));
|
|
19416
|
+
const normalizedEnd = Math.max(0, Math.min(selectionEnd ?? normalizedStart, value.length));
|
|
19417
|
+
const rangeStart = Math.min(normalizedStart, normalizedEnd);
|
|
19418
|
+
const rangeEnd = Math.max(normalizedStart, normalizedEnd);
|
|
19419
|
+
return value.slice(0, rangeStart) + CURSOR_CHAR3 + value.slice(rangeStart, rangeEnd) + CURSOR_CHAR3 + value.slice(rangeEnd);
|
|
19420
|
+
}
|
|
19421
|
+
var KEY_CODE, CURSOR_CHAR3, kity20, InputComponent, input_default;
|
|
19340
19422
|
var init_input = __esm({
|
|
19341
19423
|
"../kity-runtime/src/legacy/input.ts"() {
|
|
19342
19424
|
"use strict";
|
|
19343
19425
|
init_legacy_utils();
|
|
19344
19426
|
init_legacy_input_filter();
|
|
19427
|
+
init_legacy_sysconf();
|
|
19345
19428
|
init_runtime_interop();
|
|
19346
19429
|
KEY_CODE = {
|
|
19347
19430
|
LEFT: 37,
|
|
@@ -19349,6 +19432,7 @@ var FormulaX = (() => {
|
|
|
19349
19432
|
DELETE: 8,
|
|
19350
19433
|
INPUT: 229
|
|
19351
19434
|
};
|
|
19435
|
+
CURSOR_CHAR3 = legacySysconf.cursorCharacter;
|
|
19352
19436
|
kity20 = getLegacyKity();
|
|
19353
19437
|
InputComponent = kity20.createClass("InputComponent", {
|
|
19354
19438
|
constructor(parentComponent, kfEditor) {
|
|
@@ -19521,7 +19605,12 @@ var FormulaX = (() => {
|
|
|
19521
19605
|
return `${e.shiftKey ? "s+" : ""}${e.keyCode}`;
|
|
19522
19606
|
},
|
|
19523
19607
|
processingInput() {
|
|
19524
|
-
|
|
19608
|
+
const latexWithCursor = insertCursorMarkers(
|
|
19609
|
+
this.inputBox.value,
|
|
19610
|
+
this.inputBox.selectionStart,
|
|
19611
|
+
this.inputBox.selectionEnd
|
|
19612
|
+
);
|
|
19613
|
+
this.restruct(latexWithCursor);
|
|
19525
19614
|
this.kfEditor.requestService("ui.update.canvas.view");
|
|
19526
19615
|
},
|
|
19527
19616
|
restruct(latexStr) {
|
|
@@ -20027,26 +20116,26 @@ var FormulaX = (() => {
|
|
|
20027
20116
|
var start_exports = {};
|
|
20028
20117
|
__export(start_exports, {
|
|
20029
20118
|
Factory: () => factory_default,
|
|
20030
|
-
KFEditor: () =>
|
|
20119
|
+
KFEditor: () => editor_default,
|
|
20031
20120
|
default: () => start_default,
|
|
20032
20121
|
installKityEditorStart: () => installKityEditorStart
|
|
20033
20122
|
});
|
|
20034
20123
|
function installKityEditorStart(target = window) {
|
|
20035
20124
|
const runtimeTarget = target;
|
|
20036
20125
|
if (!installed3) {
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20126
|
+
editor_default.registerComponents("ui", ui_default);
|
|
20127
|
+
editor_default.registerComponents("parser", parser_default);
|
|
20128
|
+
editor_default.registerComponents("render", render_default);
|
|
20129
|
+
editor_default.registerComponents("position", position_default);
|
|
20130
|
+
editor_default.registerComponents("syntax", syntax_default);
|
|
20131
|
+
editor_default.registerComponents("control", controller_default);
|
|
20132
|
+
editor_default.registerComponents("print", printer_default);
|
|
20044
20133
|
installed3 = true;
|
|
20045
20134
|
}
|
|
20046
20135
|
runtimeTarget.kf = runtimeTarget.kf ?? {};
|
|
20047
20136
|
runtimeTarget.kf.EditorFactory = factory_default;
|
|
20048
20137
|
return {
|
|
20049
|
-
KFEditor:
|
|
20138
|
+
KFEditor: editor_default,
|
|
20050
20139
|
Factory: factory_default
|
|
20051
20140
|
};
|
|
20052
20141
|
}
|
|
@@ -20054,7 +20143,7 @@ var FormulaX = (() => {
|
|
|
20054
20143
|
var init_start = __esm({
|
|
20055
20144
|
"../kity-runtime/src/boot/start.ts"() {
|
|
20056
20145
|
"use strict";
|
|
20057
|
-
|
|
20146
|
+
init_editor();
|
|
20058
20147
|
init_factory();
|
|
20059
20148
|
init_ui();
|
|
20060
20149
|
init_parser();
|
|
@@ -20191,11 +20280,16 @@ var FormulaX = (() => {
|
|
|
20191
20280
|
fontSize: input.fontSize,
|
|
20192
20281
|
displayMode: input.displayMode,
|
|
20193
20282
|
className: input.className,
|
|
20194
|
-
|
|
20283
|
+
assetCacheKey: input.assetCacheKey
|
|
20195
20284
|
});
|
|
20196
20285
|
}
|
|
20197
20286
|
|
|
20198
20287
|
// ../renderer/src/svg.ts
|
|
20288
|
+
var SIMPLE_INLINE_HEIGHT_EM = 1.25;
|
|
20289
|
+
var BASE_FORMULA_HEIGHT = 40.5;
|
|
20290
|
+
var SIMPLE_FORMULA_HEIGHT_RATIO = 1.05;
|
|
20291
|
+
var MAX_INLINE_HEIGHT_EM = 1.65;
|
|
20292
|
+
var COMPLEX_FORMULA_SCALE = 0.825;
|
|
20199
20293
|
function readRenderedFormulaSvgBox(svg2) {
|
|
20200
20294
|
return getInlineSvgContent(svg2)?.box ?? readSvgBox(svg2);
|
|
20201
20295
|
}
|
|
@@ -20370,6 +20464,7 @@ var FormulaX = (() => {
|
|
|
20370
20464
|
"width",
|
|
20371
20465
|
"height",
|
|
20372
20466
|
"viewBox",
|
|
20467
|
+
"font-size",
|
|
20373
20468
|
"class",
|
|
20374
20469
|
"focusable",
|
|
20375
20470
|
"aria-hidden",
|
|
@@ -20381,13 +20476,24 @@ var FormulaX = (() => {
|
|
|
20381
20476
|
target.setAttribute(attribute.name, attribute.value);
|
|
20382
20477
|
});
|
|
20383
20478
|
}
|
|
20479
|
+
function calculateInlineHeightEm(height2) {
|
|
20480
|
+
const heightRatio = height2 / BASE_FORMULA_HEIGHT;
|
|
20481
|
+
if (!Number.isFinite(heightRatio) || heightRatio <= SIMPLE_FORMULA_HEIGHT_RATIO) {
|
|
20482
|
+
return SIMPLE_INLINE_HEIGHT_EM;
|
|
20483
|
+
}
|
|
20484
|
+
return Math.min(
|
|
20485
|
+
MAX_INLINE_HEIGHT_EM,
|
|
20486
|
+
SIMPLE_INLINE_HEIGHT_EM * Math.pow(heightRatio, COMPLEX_FORMULA_SCALE)
|
|
20487
|
+
);
|
|
20488
|
+
}
|
|
20384
20489
|
function sizeSvgForInlineDisplay(clone4, source2, viewport) {
|
|
20490
|
+
clone4.removeAttribute("font-size");
|
|
20385
20491
|
const viewBox = clone4.viewBox?.baseVal;
|
|
20386
20492
|
const rect = source2.getBoundingClientRect();
|
|
20387
20493
|
const width2 = viewport?.width || viewBox?.width || rect.width || Number(clone4.getAttribute("width")) || 1;
|
|
20388
20494
|
const height2 = viewport?.height || viewBox?.height || rect.height || Number(clone4.getAttribute("height")) || 1;
|
|
20389
20495
|
const ratio = Math.max(0.1, width2 / Math.max(1, height2));
|
|
20390
|
-
const inlineHeightEm =
|
|
20496
|
+
const inlineHeightEm = calculateInlineHeightEm(height2);
|
|
20391
20497
|
const inlineWidthEm = Math.min(40, Math.max(0.75, ratio * inlineHeightEm));
|
|
20392
20498
|
clone4.setAttribute("width", roundLength(width2));
|
|
20393
20499
|
clone4.setAttribute("height", roundLength(height2));
|
|
@@ -20395,8 +20501,9 @@ var FormulaX = (() => {
|
|
|
20395
20501
|
"style",
|
|
20396
20502
|
mergeInlineStyles2(
|
|
20397
20503
|
clone4.getAttribute("style"),
|
|
20504
|
+
"font-size:inherit",
|
|
20398
20505
|
`width:${roundLength(inlineWidthEm)}em`,
|
|
20399
|
-
`height:${inlineHeightEm}em`
|
|
20506
|
+
`height:${roundLength(inlineHeightEm)}em`
|
|
20400
20507
|
)
|
|
20401
20508
|
);
|
|
20402
20509
|
}
|
|
@@ -61179,6 +61286,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61179
61286
|
|
|
61180
61287
|
// ../kity-runtime/src/create-editor.ts
|
|
61181
61288
|
init_toolbar_assets();
|
|
61289
|
+
init_i18n();
|
|
61182
61290
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
61183
61291
|
var DEFAULT_EDITOR_HEIGHT = "auto";
|
|
61184
61292
|
var KITY_STYLE_ID = "formulax-kity-editor-styles";
|
|
@@ -61329,8 +61437,10 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61329
61437
|
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
61330
61438
|
const fontsize = options.render?.fontsize ?? 40;
|
|
61331
61439
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
61440
|
+
const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
|
|
61332
61441
|
const assets = resolveEditorAssets(options.assets);
|
|
61333
61442
|
try {
|
|
61443
|
+
legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
|
|
61334
61444
|
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
61335
61445
|
if (stylesheetInserted) {
|
|
61336
61446
|
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
@@ -61357,6 +61467,9 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61357
61467
|
render: {
|
|
61358
61468
|
fontsize
|
|
61359
61469
|
},
|
|
61470
|
+
ui: {
|
|
61471
|
+
locale
|
|
61472
|
+
},
|
|
61360
61473
|
resource: {
|
|
61361
61474
|
path: "",
|
|
61362
61475
|
fonts: assets.fonts
|
|
@@ -61439,6 +61552,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61439
61552
|
|
|
61440
61553
|
// ../kity-runtime/src/index.ts
|
|
61441
61554
|
init_dom_utils();
|
|
61555
|
+
init_i18n();
|
|
61442
61556
|
init_legacy_box_type();
|
|
61443
61557
|
init_legacy_component();
|
|
61444
61558
|
init_legacy_ele_type();
|
|
@@ -61540,7 +61654,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61540
61654
|
}
|
|
61541
61655
|
function renderLatexToSvgMarkup(latex, options = {}) {
|
|
61542
61656
|
const normalizedLatex = latex.trim();
|
|
61543
|
-
const shouldUseCache = options.cache !== false && !(hasCustomAssetOverrides(options.assets) && !options.
|
|
61657
|
+
const shouldUseCache = options.cache !== false && !(hasCustomAssetOverrides(options.assets) && !options.assetCacheKey);
|
|
61544
61658
|
if (!normalizedLatex) {
|
|
61545
61659
|
return Promise.resolve({
|
|
61546
61660
|
engine: "kity",
|
|
@@ -61556,7 +61670,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
61556
61670
|
fontSize: options.fontSize,
|
|
61557
61671
|
displayMode: options.displayMode,
|
|
61558
61672
|
className: options.className,
|
|
61559
|
-
|
|
61673
|
+
assetCacheKey: options.assetCacheKey
|
|
61560
61674
|
});
|
|
61561
61675
|
if (shouldUseCache) {
|
|
61562
61676
|
const cached = renderCache.get(cacheKey);
|
|
@@ -62054,8 +62168,11 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62054
62168
|
inset: 0;
|
|
62055
62169
|
z-index: 2147483000;
|
|
62056
62170
|
display: flex;
|
|
62057
|
-
align-items:
|
|
62171
|
+
align-items: flex-start;
|
|
62058
62172
|
justify-content: center;
|
|
62173
|
+
padding: 16px;
|
|
62174
|
+
overflow-x: hidden;
|
|
62175
|
+
overflow-y: auto;
|
|
62059
62176
|
}
|
|
62060
62177
|
|
|
62061
62178
|
.fx-formula-modal-backdrop {
|
|
@@ -62068,9 +62185,10 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62068
62185
|
--fx-formula-editor-body-height: 264px;
|
|
62069
62186
|
--fx-formula-workspace-height: 168px;
|
|
62070
62187
|
position: relative;
|
|
62071
|
-
width: min(
|
|
62188
|
+
width: min(920px, calc(100vw - 32px));
|
|
62072
62189
|
height: auto;
|
|
62073
|
-
max-height:
|
|
62190
|
+
max-height: none;
|
|
62191
|
+
margin: 0 auto;
|
|
62074
62192
|
background: #fff;
|
|
62075
62193
|
border-radius: 14px;
|
|
62076
62194
|
box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
|
|
@@ -62147,6 +62265,8 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62147
62265
|
}
|
|
62148
62266
|
|
|
62149
62267
|
.fx-formula-kity-host .kf-editor {
|
|
62268
|
+
box-sizing: border-box;
|
|
62269
|
+
width: 100%;
|
|
62150
62270
|
height: var(--fx-formula-editor-body-height) !important;
|
|
62151
62271
|
overflow: visible !important;
|
|
62152
62272
|
}
|
|
@@ -62286,6 +62406,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62286
62406
|
initialLatex,
|
|
62287
62407
|
height: options.height ?? "100%",
|
|
62288
62408
|
autofocus: options.autofocus ?? true,
|
|
62409
|
+
locale: options.locale,
|
|
62289
62410
|
assets: options.assets,
|
|
62290
62411
|
render: {
|
|
62291
62412
|
fontsize: options.render?.fontsize ?? 40
|
|
@@ -62390,6 +62511,26 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62390
62511
|
return null;
|
|
62391
62512
|
}
|
|
62392
62513
|
|
|
62514
|
+
// ../editor/src/i18n.ts
|
|
62515
|
+
var FORMULAX_EDITOR_MESSAGES = {
|
|
62516
|
+
en_US: {
|
|
62517
|
+
"modal.title": "FormulaX Editor",
|
|
62518
|
+
"modal.insert": "Insert",
|
|
62519
|
+
"modal.update": "Update",
|
|
62520
|
+
"modal.cancel": "Cancel"
|
|
62521
|
+
},
|
|
62522
|
+
zh_CN: {
|
|
62523
|
+
"modal.title": "FormulaX \u7F16\u8F91\u5668",
|
|
62524
|
+
"modal.insert": "\u63D2\u5165",
|
|
62525
|
+
"modal.update": "\u66F4\u65B0",
|
|
62526
|
+
"modal.cancel": "\u53D6\u6D88"
|
|
62527
|
+
}
|
|
62528
|
+
};
|
|
62529
|
+
function getFormulaXEditorMessage(key, locale = DEFAULT_FORMULAX_LOCALE) {
|
|
62530
|
+
const normalizedLocale = normalizeFormulaXLocale(locale);
|
|
62531
|
+
return FORMULAX_EDITOR_MESSAGES[normalizedLocale][key] ?? FORMULAX_EDITOR_MESSAGES[DEFAULT_FORMULAX_LOCALE][key];
|
|
62532
|
+
}
|
|
62533
|
+
|
|
62393
62534
|
// src/modal.ts
|
|
62394
62535
|
function openFormulaXModal(input) {
|
|
62395
62536
|
recordFormulaXPerfPoint("fx:modal:open:start");
|
|
@@ -62441,6 +62582,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62441
62582
|
initialLatex: input.initialLatex,
|
|
62442
62583
|
height: input.options.editor.height,
|
|
62443
62584
|
autofocus: input.options.editor.autofocus,
|
|
62585
|
+
locale: input.options.editor.locale,
|
|
62444
62586
|
assets: input.options.editor.assets,
|
|
62445
62587
|
render: {
|
|
62446
62588
|
fontsize: input.options.editor.render.fontsize
|
|
@@ -62518,6 +62660,7 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62518
62660
|
var DEFAULT_BUTTON_NAME = "formulaX";
|
|
62519
62661
|
var DEFAULT_MODEL_NAME = "formulaX";
|
|
62520
62662
|
function resolveOptions(options = {}) {
|
|
62663
|
+
const locale = options.editor?.locale ?? DEFAULT_FORMULAX_LOCALE;
|
|
62521
62664
|
return {
|
|
62522
62665
|
name: options.name ?? DEFAULT_MODEL_NAME,
|
|
62523
62666
|
buttonName: options.buttonName ?? DEFAULT_BUTTON_NAME,
|
|
@@ -62533,15 +62676,16 @@ Original error: ${originalError.name}: ${originalError.message}` : "";
|
|
|
62533
62676
|
}),
|
|
62534
62677
|
preload: options.preload ?? "idle",
|
|
62535
62678
|
modal: {
|
|
62536
|
-
title: options.modal?.title ?? "
|
|
62537
|
-
insertText: options.modal?.insertText ?? "
|
|
62538
|
-
updateText: options.modal?.updateText ?? "
|
|
62539
|
-
cancelText: options.modal?.cancelText ?? "
|
|
62679
|
+
title: options.modal?.title ?? getFormulaXEditorMessage("modal.title", locale),
|
|
62680
|
+
insertText: options.modal?.insertText ?? getFormulaXEditorMessage("modal.insert", locale),
|
|
62681
|
+
updateText: options.modal?.updateText ?? getFormulaXEditorMessage("modal.update", locale),
|
|
62682
|
+
cancelText: options.modal?.cancelText ?? getFormulaXEditorMessage("modal.cancel", locale),
|
|
62540
62683
|
closeOnBackdrop: options.modal?.closeOnBackdrop ?? true
|
|
62541
62684
|
},
|
|
62542
62685
|
editor: {
|
|
62543
62686
|
height: options.editor?.height ?? "100%",
|
|
62544
62687
|
autofocus: options.editor?.autofocus ?? true,
|
|
62688
|
+
locale,
|
|
62545
62689
|
assets: options.editor?.assets ?? {},
|
|
62546
62690
|
render: {
|
|
62547
62691
|
fontsize: options.editor?.render?.fontsize ?? 40
|