@formulaxjs/tinymce 0.2.0 → 0.3.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 +73 -72
- package/README.zh-CN.md +56 -55
- 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 +24136 -128
- 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 +3762 -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 +9 -4
- /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
|
count += 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
|
+
count -= 1;
|
|
5994
|
+
if (count === 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();
|
|
@@ -20537,11 +20626,16 @@ var FormulaX = (() => {
|
|
|
20537
20626
|
fontSize: input.fontSize,
|
|
20538
20627
|
displayMode: input.displayMode,
|
|
20539
20628
|
className: input.className,
|
|
20540
|
-
|
|
20629
|
+
assetCacheKey: input.assetCacheKey
|
|
20541
20630
|
});
|
|
20542
20631
|
}
|
|
20543
20632
|
|
|
20544
20633
|
// ../renderer/src/svg.ts
|
|
20634
|
+
var SIMPLE_INLINE_HEIGHT_EM = 1.25;
|
|
20635
|
+
var BASE_FORMULA_HEIGHT = 40.5;
|
|
20636
|
+
var SIMPLE_FORMULA_HEIGHT_RATIO = 1.05;
|
|
20637
|
+
var MAX_INLINE_HEIGHT_EM = 1.65;
|
|
20638
|
+
var COMPLEX_FORMULA_SCALE = 0.825;
|
|
20545
20639
|
function readRenderedFormulaSvgBox(svg2) {
|
|
20546
20640
|
return getInlineSvgContent(svg2)?.box ?? readSvgBox(svg2);
|
|
20547
20641
|
}
|
|
@@ -20716,6 +20810,7 @@ var FormulaX = (() => {
|
|
|
20716
20810
|
"width",
|
|
20717
20811
|
"height",
|
|
20718
20812
|
"viewBox",
|
|
20813
|
+
"font-size",
|
|
20719
20814
|
"class",
|
|
20720
20815
|
"focusable",
|
|
20721
20816
|
"aria-hidden",
|
|
@@ -20727,13 +20822,24 @@ var FormulaX = (() => {
|
|
|
20727
20822
|
target.setAttribute(attribute.name, attribute.value);
|
|
20728
20823
|
});
|
|
20729
20824
|
}
|
|
20825
|
+
function calculateInlineHeightEm(height2) {
|
|
20826
|
+
const heightRatio = height2 / BASE_FORMULA_HEIGHT;
|
|
20827
|
+
if (!Number.isFinite(heightRatio) || heightRatio <= SIMPLE_FORMULA_HEIGHT_RATIO) {
|
|
20828
|
+
return SIMPLE_INLINE_HEIGHT_EM;
|
|
20829
|
+
}
|
|
20830
|
+
return Math.min(
|
|
20831
|
+
MAX_INLINE_HEIGHT_EM,
|
|
20832
|
+
SIMPLE_INLINE_HEIGHT_EM * Math.pow(heightRatio, COMPLEX_FORMULA_SCALE)
|
|
20833
|
+
);
|
|
20834
|
+
}
|
|
20730
20835
|
function sizeSvgForInlineDisplay(clone, source, viewport) {
|
|
20836
|
+
clone.removeAttribute("font-size");
|
|
20731
20837
|
const viewBox = clone.viewBox?.baseVal;
|
|
20732
20838
|
const rect = source.getBoundingClientRect();
|
|
20733
20839
|
const width2 = viewport?.width || viewBox?.width || rect.width || Number(clone.getAttribute("width")) || 1;
|
|
20734
20840
|
const height2 = viewport?.height || viewBox?.height || rect.height || Number(clone.getAttribute("height")) || 1;
|
|
20735
20841
|
const ratio = Math.max(0.1, width2 / Math.max(1, height2));
|
|
20736
|
-
const inlineHeightEm =
|
|
20842
|
+
const inlineHeightEm = calculateInlineHeightEm(height2);
|
|
20737
20843
|
const inlineWidthEm = Math.min(40, Math.max(0.75, ratio * inlineHeightEm));
|
|
20738
20844
|
clone.setAttribute("width", roundLength(width2));
|
|
20739
20845
|
clone.setAttribute("height", roundLength(height2));
|
|
@@ -20741,8 +20847,9 @@ var FormulaX = (() => {
|
|
|
20741
20847
|
"style",
|
|
20742
20848
|
mergeInlineStyles2(
|
|
20743
20849
|
clone.getAttribute("style"),
|
|
20850
|
+
"font-size:inherit",
|
|
20744
20851
|
`width:${roundLength(inlineWidthEm)}em`,
|
|
20745
|
-
`height:${inlineHeightEm}em`
|
|
20852
|
+
`height:${roundLength(inlineHeightEm)}em`
|
|
20746
20853
|
)
|
|
20747
20854
|
);
|
|
20748
20855
|
}
|
|
@@ -24343,6 +24450,7 @@ var FormulaX = (() => {
|
|
|
24343
24450
|
|
|
24344
24451
|
// ../kity-runtime/src/create-editor.ts
|
|
24345
24452
|
init_toolbar_assets();
|
|
24453
|
+
init_i18n();
|
|
24346
24454
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
24347
24455
|
var DEFAULT_EDITOR_HEIGHT = "auto";
|
|
24348
24456
|
var KITY_STYLE_ID = "formulax-kity-editor-styles";
|
|
@@ -24493,8 +24601,10 @@ var FormulaX = (() => {
|
|
|
24493
24601
|
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
24494
24602
|
const fontsize = options.render?.fontsize ?? 40;
|
|
24495
24603
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
24604
|
+
const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
|
|
24496
24605
|
const assets = resolveEditorAssets(options.assets);
|
|
24497
24606
|
try {
|
|
24607
|
+
legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
|
|
24498
24608
|
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
24499
24609
|
if (stylesheetInserted) {
|
|
24500
24610
|
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
@@ -24521,6 +24631,9 @@ var FormulaX = (() => {
|
|
|
24521
24631
|
render: {
|
|
24522
24632
|
fontsize
|
|
24523
24633
|
},
|
|
24634
|
+
ui: {
|
|
24635
|
+
locale
|
|
24636
|
+
},
|
|
24524
24637
|
resource: {
|
|
24525
24638
|
path: "",
|
|
24526
24639
|
fonts: assets.fonts
|
|
@@ -24603,6 +24716,7 @@ var FormulaX = (() => {
|
|
|
24603
24716
|
|
|
24604
24717
|
// ../kity-runtime/src/index.ts
|
|
24605
24718
|
init_dom_utils();
|
|
24719
|
+
init_i18n();
|
|
24606
24720
|
init_legacy_box_type();
|
|
24607
24721
|
init_legacy_component();
|
|
24608
24722
|
init_legacy_ele_type();
|
|
@@ -24704,7 +24818,7 @@ var FormulaX = (() => {
|
|
|
24704
24818
|
}
|
|
24705
24819
|
function renderLatexToSvgMarkup(latex, options = {}) {
|
|
24706
24820
|
const normalizedLatex = latex.trim();
|
|
24707
|
-
const shouldUseCache = options.cache !== false && !(hasCustomAssetOverrides(options.assets) && !options.
|
|
24821
|
+
const shouldUseCache = options.cache !== false && !(hasCustomAssetOverrides(options.assets) && !options.assetCacheKey);
|
|
24708
24822
|
if (!normalizedLatex) {
|
|
24709
24823
|
return Promise.resolve({
|
|
24710
24824
|
engine: "kity",
|
|
@@ -24720,7 +24834,7 @@ var FormulaX = (() => {
|
|
|
24720
24834
|
fontSize: options.fontSize,
|
|
24721
24835
|
displayMode: options.displayMode,
|
|
24722
24836
|
className: options.className,
|
|
24723
|
-
|
|
24837
|
+
assetCacheKey: options.assetCacheKey
|
|
24724
24838
|
});
|
|
24725
24839
|
if (shouldUseCache) {
|
|
24726
24840
|
const cached = renderCache.get(cacheKey);
|
|
@@ -24933,8 +25047,11 @@ var FormulaX = (() => {
|
|
|
24933
25047
|
inset: 0;
|
|
24934
25048
|
z-index: 2147483000;
|
|
24935
25049
|
display: flex;
|
|
24936
|
-
align-items:
|
|
25050
|
+
align-items: flex-start;
|
|
24937
25051
|
justify-content: center;
|
|
25052
|
+
padding: 16px;
|
|
25053
|
+
overflow-x: hidden;
|
|
25054
|
+
overflow-y: auto;
|
|
24938
25055
|
}
|
|
24939
25056
|
|
|
24940
25057
|
.fx-formula-modal-backdrop {
|
|
@@ -24947,9 +25064,10 @@ var FormulaX = (() => {
|
|
|
24947
25064
|
--fx-formula-editor-body-height: 264px;
|
|
24948
25065
|
--fx-formula-workspace-height: 168px;
|
|
24949
25066
|
position: relative;
|
|
24950
|
-
width: min(
|
|
25067
|
+
width: min(920px, calc(100vw - 32px));
|
|
24951
25068
|
height: auto;
|
|
24952
|
-
max-height:
|
|
25069
|
+
max-height: none;
|
|
25070
|
+
margin: 0 auto;
|
|
24953
25071
|
background: #fff;
|
|
24954
25072
|
border-radius: 14px;
|
|
24955
25073
|
box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
|
|
@@ -25026,6 +25144,8 @@ var FormulaX = (() => {
|
|
|
25026
25144
|
}
|
|
25027
25145
|
|
|
25028
25146
|
.fx-formula-kity-host .kf-editor {
|
|
25147
|
+
box-sizing: border-box;
|
|
25148
|
+
width: 100%;
|
|
25029
25149
|
height: var(--fx-formula-editor-body-height) !important;
|
|
25030
25150
|
overflow: visible !important;
|
|
25031
25151
|
}
|
|
@@ -25165,6 +25285,7 @@ var FormulaX = (() => {
|
|
|
25165
25285
|
initialLatex,
|
|
25166
25286
|
height: options.height ?? "100%",
|
|
25167
25287
|
autofocus: options.autofocus ?? true,
|
|
25288
|
+
locale: options.locale,
|
|
25168
25289
|
assets: options.assets,
|
|
25169
25290
|
render: {
|
|
25170
25291
|
fontsize: options.render?.fontsize ?? 40
|
|
@@ -25269,6 +25390,26 @@ var FormulaX = (() => {
|
|
|
25269
25390
|
return null;
|
|
25270
25391
|
}
|
|
25271
25392
|
|
|
25393
|
+
// ../editor/src/i18n.ts
|
|
25394
|
+
var FORMULAX_EDITOR_MESSAGES = {
|
|
25395
|
+
en_US: {
|
|
25396
|
+
"modal.title": "FormulaX Editor",
|
|
25397
|
+
"modal.insert": "Insert",
|
|
25398
|
+
"modal.update": "Update",
|
|
25399
|
+
"modal.cancel": "Cancel"
|
|
25400
|
+
},
|
|
25401
|
+
zh_CN: {
|
|
25402
|
+
"modal.title": "FormulaX \u7F16\u8F91\u5668",
|
|
25403
|
+
"modal.insert": "\u63D2\u5165",
|
|
25404
|
+
"modal.update": "\u66F4\u65B0",
|
|
25405
|
+
"modal.cancel": "\u53D6\u6D88"
|
|
25406
|
+
}
|
|
25407
|
+
};
|
|
25408
|
+
function getFormulaXEditorMessage(key, locale = DEFAULT_FORMULAX_LOCALE) {
|
|
25409
|
+
const normalizedLocale = normalizeFormulaXLocale(locale);
|
|
25410
|
+
return FORMULAX_EDITOR_MESSAGES[normalizedLocale][key] ?? FORMULAX_EDITOR_MESSAGES[DEFAULT_FORMULAX_LOCALE][key];
|
|
25411
|
+
}
|
|
25412
|
+
|
|
25272
25413
|
// src/styles.ts
|
|
25273
25414
|
function ensureTinyMceStyles(doc2 = document) {
|
|
25274
25415
|
ensureFormulaXBaseStyles(doc2);
|
|
@@ -25281,6 +25422,7 @@ var FormulaX = (() => {
|
|
|
25281
25422
|
initialLatex: input.initialLatex,
|
|
25282
25423
|
height: input.options.editor.height ?? "100%",
|
|
25283
25424
|
autofocus: input.options.editor.autofocus ?? true,
|
|
25425
|
+
locale: input.options.editor.locale,
|
|
25284
25426
|
assets: input.options.editor.assets,
|
|
25285
25427
|
render: {
|
|
25286
25428
|
fontsize: input.options.editor.render?.fontsize ?? 40
|
|
@@ -25547,6 +25689,7 @@ var FormulaX = (() => {
|
|
|
25547
25689
|
"polyline[id|class|style|points|fill|stroke|stroke-width|opacity|transform]"
|
|
25548
25690
|
].join(",");
|
|
25549
25691
|
function resolveOptions(options = {}) {
|
|
25692
|
+
const locale = options.editor?.locale ?? DEFAULT_FORMULAX_LOCALE;
|
|
25550
25693
|
return {
|
|
25551
25694
|
pluginName: options.pluginName ?? "formulax",
|
|
25552
25695
|
buttonName: options.buttonName ?? "formulax",
|
|
@@ -25564,10 +25707,10 @@ var FormulaX = (() => {
|
|
|
25564
25707
|
}),
|
|
25565
25708
|
preload: options.preload ?? "idle",
|
|
25566
25709
|
modal: {
|
|
25567
|
-
title: options.modal?.title ?? "
|
|
25568
|
-
insertText: options.modal?.insertText ?? "
|
|
25569
|
-
updateText: options.modal?.updateText ?? "
|
|
25570
|
-
cancelText: options.modal?.cancelText ?? "
|
|
25710
|
+
title: options.modal?.title ?? getFormulaXEditorMessage("modal.title", locale),
|
|
25711
|
+
insertText: options.modal?.insertText ?? getFormulaXEditorMessage("modal.insert", locale),
|
|
25712
|
+
updateText: options.modal?.updateText ?? getFormulaXEditorMessage("modal.update", locale),
|
|
25713
|
+
cancelText: options.modal?.cancelText ?? getFormulaXEditorMessage("modal.cancel", locale),
|
|
25571
25714
|
width: options.modal?.width ?? "1100px",
|
|
25572
25715
|
height: options.modal?.height ?? "auto",
|
|
25573
25716
|
closeOnBackdrop: options.modal?.closeOnBackdrop ?? true
|
|
@@ -25575,6 +25718,7 @@ var FormulaX = (() => {
|
|
|
25575
25718
|
editor: {
|
|
25576
25719
|
height: options.editor?.height ?? "100%",
|
|
25577
25720
|
autofocus: options.editor?.autofocus ?? true,
|
|
25721
|
+
locale,
|
|
25578
25722
|
assets: options.editor?.assets ?? {},
|
|
25579
25723
|
render: {
|
|
25580
25724
|
fontsize: options.editor?.render?.fontsize ?? 40
|