@formulaxjs/editor 0.3.0 → 0.3.1

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.
@@ -5072,6 +5072,21 @@ var FormulaX = (() => {
5072
5072
  }
5073
5073
  });
5074
5074
 
5075
+ // ../kity-runtime/src/i18n.ts
5076
+ function normalizeFormulaXLocale(locale) {
5077
+ if (locale === "zh_CN") {
5078
+ return "zh_CN";
5079
+ }
5080
+ return DEFAULT_FORMULAX_LOCALE;
5081
+ }
5082
+ var DEFAULT_FORMULAX_LOCALE;
5083
+ var init_i18n = __esm({
5084
+ "../kity-runtime/src/i18n.ts"() {
5085
+ "use strict";
5086
+ DEFAULT_FORMULAX_LOCALE = "en_US";
5087
+ }
5088
+ });
5089
+
5075
5090
  // ../kity-runtime/src/vendor/kity-formula/binary-expression.ts
5076
5091
  var BinaryExpressionModule, createBinaryExpressionClass;
5077
5092
  var init_binary_expression = __esm({
@@ -5957,14 +5972,11 @@ var FormulaX = (() => {
5957
5972
  count += 1;
5958
5973
  fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
5959
5974
  this.createFontStyle(fontInfo);
5960
- preloadFont(this.doc, fontInfo).then(() => {
5961
- applyFonts(this.doc, fontInfo);
5962
- }).catch(() => void 0).finally(() => {
5963
- count -= 1;
5964
- if (count === 0) {
5965
- complete(this.doc, callback);
5966
- }
5967
- });
5975
+ applyFonts(this.doc, fontInfo);
5976
+ count -= 1;
5977
+ if (count === 0) {
5978
+ complete(this.doc, callback);
5979
+ }
5968
5980
  });
5969
5981
  },
5970
5982
  createFontStyle: function(fontInfo) {
@@ -5975,13 +5987,6 @@ var FormulaX = (() => {
5975
5987
  this.doc.head.appendChild(stylesheet);
5976
5988
  }
5977
5989
  });
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
5990
  function resolveFontSource(fonts, resourceBase, originalSrc) {
5986
5991
  const directMatch = fonts[originalSrc];
5987
5992
  if (directMatch) {
@@ -6139,11 +6144,11 @@ var FormulaX = (() => {
6139
6144
  bg;
6140
6145
  exp;
6141
6146
  config;
6142
- constructor(kity26, exp, config2) {
6147
+ constructor(kity26, exp, config) {
6143
6148
  this.wrap = new kity26.Group();
6144
6149
  this.bg = new kity26.Rect(0, 0, 0, 0).fill("transparent");
6145
6150
  this.exp = exp;
6146
- this.config = config2;
6151
+ this.config = config;
6147
6152
  this.wrap.setAttr("data-type", "kf-exp-wrap");
6148
6153
  this.bg.setAttr("data-type", "kf-exp-wrap-bg");
6149
6154
  this.wrap.addShape(this.bg);
@@ -6172,14 +6177,14 @@ var FormulaX = (() => {
6172
6177
  static create(kity26, GTYPE2, FontManager, FontInstaller, FPaper, Output) {
6173
6178
  const Formula = kity26.createClass("Formula", {
6174
6179
  base: FPaper,
6175
- constructor: function(container, config2) {
6180
+ constructor: function(container, config) {
6176
6181
  if (this.__FORMULAX_PRESERVE_CALL_BASE__) {
6177
6182
  this.callBase(container);
6178
6183
  }
6179
6184
  FPaper.call(this, container);
6180
6185
  this.expressions = [];
6181
6186
  this.fontInstaller = new FontInstaller(this);
6182
- this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS, config2);
6187
+ this.config = kity26.Utils.extend({}, DEFAULT_OPTIONS, config);
6183
6188
  this.initEnvironment();
6184
6189
  this.initInnerFont();
6185
6190
  },
@@ -13644,7 +13649,7 @@ var FormulaX = (() => {
13644
13649
  value: function() {
13645
13650
  const kf7 = window2.kf;
13646
13651
  const CONSTRUCT_MAPPING = {};
13647
- const CURSOR_CHAR3 = "\uF155";
13652
+ const CURSOR_CHAR4 = "\uF155";
13648
13653
  class Assembly {
13649
13654
  formula;
13650
13655
  constructor(formula) {
@@ -13681,7 +13686,7 @@ var FormulaX = (() => {
13681
13686
  if (tree.name.indexOf("text") === -1) {
13682
13687
  for (let i2 = 0, len = operand.length; i2 < len; i2 += 1) {
13683
13688
  currentOperand = operand[i2];
13684
- if (currentOperand === CURSOR_CHAR3) {
13689
+ if (currentOperand === CURSOR_CHAR4) {
13685
13690
  cursorLocation.push(i2);
13686
13691
  if (!Object.prototype.hasOwnProperty.call(selectInfo, "startOffset")) {
13687
13692
  selectInfo.startOffset = i2;
@@ -16853,6 +16858,35 @@ var FormulaX = (() => {
16853
16858
  }
16854
16859
  Object.keys(list).forEach((key) => callback(list[key], key));
16855
16860
  }
16861
+ function translateToolbarText(value, locale) {
16862
+ if (locale === "zh_CN") {
16863
+ return value;
16864
+ }
16865
+ const normalizedValue = value.replace(/<br\s*\/?>/gi, "").trim();
16866
+ const translatedValue = zhCnToEnUsText.get(normalizedValue);
16867
+ if (!translatedValue) {
16868
+ return value;
16869
+ }
16870
+ const lineBreakMatch = value.match(/<br\s*\/?>/i);
16871
+ return lineBreakMatch ? `${translatedValue}${lineBreakMatch[0]}` : translatedValue;
16872
+ }
16873
+ function localizeToolbarConfig(value, locale) {
16874
+ if (Array.isArray(value)) {
16875
+ return value.map((item) => localizeToolbarConfig(item, locale));
16876
+ }
16877
+ if (!value || typeof value !== "object") {
16878
+ return value;
16879
+ }
16880
+ const result = {};
16881
+ for (const [key, currentValue] of Object.entries(value)) {
16882
+ if ((key === "label" || key === "title") && typeof currentValue === "string") {
16883
+ result[key] = translateToolbarText(currentValue, locale);
16884
+ continue;
16885
+ }
16886
+ result[key] = localizeToolbarConfig(currentValue, locale);
16887
+ }
16888
+ return result;
16889
+ }
16856
16890
  function getUnicodeContents(keySet) {
16857
16891
  let result = [];
16858
16892
  each(keySet, function(key) {
@@ -16872,7 +16906,13 @@ var FormulaX = (() => {
16872
16906
  });
16873
16907
  return result;
16874
16908
  }
16875
- var UI_ELE_TYPE, BOX_TYPE2, OTHER_POSITION, config, toolbar_config_default;
16909
+ function createToolbarConfig(locale = DEFAULT_FORMULAX_LOCALE) {
16910
+ return localizeToolbarConfig(
16911
+ baseToolbarConfig,
16912
+ normalizeFormulaXLocale(locale)
16913
+ );
16914
+ }
16915
+ var UI_ELE_TYPE, BOX_TYPE2, OTHER_POSITION, zhCnToEnUsText, baseToolbarConfig, toolbar_config_default;
16876
16916
  var init_toolbar_config = __esm({
16877
16917
  "../kity-runtime/src/legacy/toolbar-config.ts"() {
16878
16918
  "use strict";
@@ -16881,10 +16921,45 @@ var FormulaX = (() => {
16881
16921
  init_other_position();
16882
16922
  init_toolbar_assets();
16883
16923
  init_formula_symbols();
16924
+ init_i18n();
16884
16925
  UI_ELE_TYPE = legacyEleType;
16885
16926
  BOX_TYPE2 = legacyBoxType;
16886
16927
  OTHER_POSITION = legacyOtherPosition;
16887
- config = [{
16928
+ zhCnToEnUsText = /* @__PURE__ */ new Map([
16929
+ ["\u9884\u8BBE", "Presets"],
16930
+ ["\u9884\u8BBE\u516C\u5F0F", "Preset formulas"],
16931
+ ["\u4E8C\u6B21\u516C\u5F0F", "Quadratic formula"],
16932
+ ["\u4E8C\u9879\u5F0F\u5B9A\u7406", "Binomial theorem"],
16933
+ ["\u52FE\u80A1\u5B9A\u7406", "Pythagorean theorem"],
16934
+ ["\u57FA\u7840\u6570\u5B66", "Basic math"],
16935
+ ["\u5E0C\u814A\u5B57\u6BCD", "Greek letters"],
16936
+ ["\u6C42\u53CD\u5173\u7CFB\u8FD0\u7B97\u7B26", "Negated operators"],
16937
+ ["\u5B57\u6BCD\u7C7B\u7B26\u53F7", "Letter-like symbols"],
16938
+ ["\u7BAD\u5934", "Arrows"],
16939
+ ["\u624B\u5199\u4F53", "Script"],
16940
+ ["\u5206\u6570", "Fraction"],
16941
+ ["\u5E38\u7528\u5206\u6570", "Common fractions"],
16942
+ ["\u4E0A\u4E0B\u6807", "Scripts"],
16943
+ ["\u4E0A\u6807\u548C\u4E0B\u6807", "Superscripts and subscripts"],
16944
+ ["\u5E38\u7528\u7684\u4E0A\u6807\u548C\u4E0B\u6807", "Common superscripts and subscripts"],
16945
+ ["\u6839\u5F0F", "Radicals"],
16946
+ ["\u5E38\u7528\u6839\u5F0F", "Common radicals"],
16947
+ ["\u79EF\u5206", "Integrals"],
16948
+ ["\u5927\u578B\u8FD0\u7B97\u7B26", "Large operators"],
16949
+ ["\u6C42\u548C", "Summations"],
16950
+ ["\u62EC\u53F7", "Brackets"],
16951
+ ["\u65B9\u62EC\u53F7", "Brackets"],
16952
+ ["\u51FD\u6570", "Functions"],
16953
+ ["\u4E09\u89D2\u51FD\u6570", "Trigonometric functions"],
16954
+ ["\u5E38\u7528\u51FD\u6570", "Common functions"],
16955
+ ["\u5C0F\u5199", "Lowercase"],
16956
+ ["\u5927\u5199", "Uppercase"],
16957
+ ["\u53D8\u4F53", "Variants"],
16958
+ ["\u82B1\u4F53", "Fraktur"],
16959
+ ["\u53CC\u7EBF", "Double-struck"],
16960
+ ["\u7F57\u9A6C", "Roman"]
16961
+ ]);
16962
+ baseToolbarConfig = [{
16888
16963
  type: UI_ELE_TYPE.DRAPDOWN_BOX,
16889
16964
  options: {
16890
16965
  button: {
@@ -17290,7 +17365,7 @@ var FormulaX = (() => {
17290
17365
  }];
17291
17366
  (function() {
17292
17367
  let tmp = [], otherImageSrc = resolveToolbarAssetPath("other.png"), currentConf = [];
17293
- each(config, function(conf) {
17368
+ each(baseToolbarConfig, function(conf) {
17294
17369
  if (conf.type === UI_ELE_TYPE.DELIMITER) {
17295
17370
  return;
17296
17371
  }
@@ -17362,7 +17437,7 @@ var FormulaX = (() => {
17362
17437
  "aleph",
17363
17438
  "beth",
17364
17439
  "blacksquare"
17365
- ], configList = config[2].options.box.group[0].items;
17440
+ ], configList = baseToolbarConfig[2].options.box.group[0].items;
17366
17441
  configList.push({
17367
17442
  title: "\u57FA\u7840\u6570\u5B66",
17368
17443
  content: getUnicodeContents(list)
@@ -17378,7 +17453,7 @@ var FormulaX = (() => {
17378
17453
  }, {
17379
17454
  title: "\u53D8\u4F53",
17380
17455
  values: ["digamma", "varepsilon", "varkappa", "varphi", "varpi", "varrho", "varsigma", "vartheta"]
17381
- }], greekConfigList = config[2].options.box.group[1].items;
17456
+ }], greekConfigList = baseToolbarConfig[2].options.box.group[1].items;
17382
17457
  greekConfigList.push({
17383
17458
  title: greekList[0].title,
17384
17459
  content: getUnicodeContents(greekList[0].values)
@@ -17427,7 +17502,7 @@ var FormulaX = (() => {
17427
17502
  "nVDash",
17428
17503
  "nexists"
17429
17504
  ]
17430
- }], greekConfigList = config[2].options.box.group[2].items;
17505
+ }], greekConfigList = baseToolbarConfig[2].options.box.group[2].items;
17431
17506
  greekConfigList.push({
17432
17507
  title: greekList[0].title,
17433
17508
  content: getUnicodeContents(greekList[0].values)
@@ -17453,7 +17528,7 @@ var FormulaX = (() => {
17453
17528
  "Game",
17454
17529
  "Im",
17455
17530
  "Re"
17456
- ], configList = config[2].options.box.group[3].items;
17531
+ ], configList = baseToolbarConfig[2].options.box.group[3].items;
17457
17532
  configList.push({
17458
17533
  title: "\u5B57\u6BCD\u7C7B\u7B26\u53F7",
17459
17534
  content: getUnicodeContents(list)
@@ -17521,7 +17596,7 @@ var FormulaX = (() => {
17521
17596
  "twoheadleftarrow",
17522
17597
  "twoheadrightarrow",
17523
17598
  "rightsquigarrow"
17524
- ], configList = config[2].options.box.group[4].items;
17599
+ ], configList = baseToolbarConfig[2].options.box.group[4].items;
17525
17600
  configList.push({
17526
17601
  title: "\u7BAD\u5934",
17527
17602
  content: getUnicodeContents(list)
@@ -17700,7 +17775,7 @@ var FormulaX = (() => {
17700
17775
  "y",
17701
17776
  "z"
17702
17777
  ]
17703
- }], configList = config[2].options.box.group[5].items;
17778
+ }], configList = baseToolbarConfig[2].options.box.group[5].items;
17704
17779
  each(list[0].values, function(item, index) {
17705
17780
  list[0].values[index] = "mathcal{" + item + "}";
17706
17781
  });
@@ -17730,7 +17805,7 @@ var FormulaX = (() => {
17730
17805
  content: getUnicodeContents(list[3].values)
17731
17806
  });
17732
17807
  })();
17733
- toolbar_config_default = config;
17808
+ toolbar_config_default = createToolbarConfig;
17734
17809
  }
17735
17810
  });
17736
17811
 
@@ -17773,6 +17848,7 @@ var FormulaX = (() => {
17773
17848
  init_toolbar();
17774
17849
  init_scrollbar();
17775
17850
  init_toolbar_config();
17851
+ init_i18n();
17776
17852
  $$8 = createLegacyUiUtils();
17777
17853
  VIEW_STATE = legacyUiDef.VIEW_STATE;
17778
17854
  DEFAULT_EDIT_AREA_HEIGHT = 100;
@@ -17803,7 +17879,8 @@ var FormulaX = (() => {
17803
17879
  this.initScrollEvent();
17804
17880
  },
17805
17881
  initComponents() {
17806
- this.components.toolbar = new toolbar_default(this, this.kfEditor, toolbar_config_default);
17882
+ const toolbarConfig = toolbar_config_default(normalizeFormulaXLocale(this.options.locale));
17883
+ this.components.toolbar = new toolbar_default(this, this.kfEditor, toolbarConfig);
17807
17884
  this.components.scrollbar = new scrollbar_default(this, this.kfEditor);
17808
17885
  },
17809
17886
  updateContainerSize(container, toolbar, editArea) {
@@ -19070,6 +19147,21 @@ var FormulaX = (() => {
19070
19147
  });
19071
19148
 
19072
19149
  // ../kity-runtime/src/legacy/syntax.ts
19150
+ function clampOffset(offset, maxOffset) {
19151
+ return Math.max(0, Math.min(offset, maxOffset));
19152
+ }
19153
+ function normalizeCursorRecord(objTree, cursor) {
19154
+ const fallbackGroupId = objTree.mapping.root.strGroup.attr.id;
19155
+ const targetGroupId = cursor.groupId && objTree.mapping[cursor.groupId] ? cursor.groupId : fallbackGroupId;
19156
+ const operandCount = objTree.mapping[targetGroupId].strGroup.operand.length;
19157
+ const startOffset = clampOffset(cursor.startOffset, operandCount);
19158
+ const endOffset = clampOffset(cursor.endOffset, operandCount);
19159
+ return {
19160
+ groupId: targetGroupId,
19161
+ startOffset: Math.min(startOffset, endOffset),
19162
+ endOffset: Math.max(startOffset, endOffset)
19163
+ };
19164
+ }
19073
19165
  var CURSOR_CHAR2, kity19, SyntaxComponent, syntax_default;
19074
19166
  var init_syntax = __esm({
19075
19167
  "../kity-runtime/src/legacy/syntax.ts"() {
@@ -19130,10 +19222,14 @@ var FormulaX = (() => {
19130
19222
  },
19131
19223
  updateObjTree(objTree) {
19132
19224
  const selectInfo = objTree.select;
19225
+ this.objTree = objTree;
19133
19226
  if (selectInfo?.groupId) {
19134
19227
  this.updateCursor(selectInfo.groupId, selectInfo.startOffset, selectInfo.endOffset);
19228
+ return;
19229
+ }
19230
+ if (this.record.cursor.groupId !== null) {
19231
+ this.record.cursor = normalizeCursorRecord(objTree, this.record.cursor);
19135
19232
  }
19136
- this.objTree = objTree;
19137
19233
  },
19138
19234
  hasCursorInfo() {
19139
19235
  return this.record.cursor.groupId !== null;
@@ -19179,7 +19275,8 @@ var FormulaX = (() => {
19179
19275
  return this.objTree;
19180
19276
  },
19181
19277
  getGroupObject(id) {
19182
- return this.objTree.mapping[id].objGroup || null;
19278
+ const groupInfo = this.objTree.mapping[id];
19279
+ return groupInfo ? groupInfo.objGroup : null;
19183
19280
  },
19184
19281
  getCursorRecord() {
19185
19282
  return kity19.Utils.extend({}, this.record.cursor);
@@ -19255,7 +19352,7 @@ var FormulaX = (() => {
19255
19352
  return this.hasRootplaceholder();
19256
19353
  },
19257
19354
  serialization() {
19258
- const cursor = this.record.cursor;
19355
+ const cursor = normalizeCursorRecord(this.objTree, this.record.cursor);
19259
19356
  const objGroup = this.objTree.mapping[cursor.groupId];
19260
19357
  const curStrGroup = objGroup.strGroup;
19261
19358
  let strStartIndex = Math.min(cursor.endOffset, cursor.startOffset);
@@ -19291,11 +19388,12 @@ var FormulaX = (() => {
19291
19388
  endOffset = startOffset;
19292
19389
  startOffset = tmp;
19293
19390
  }
19294
- this.record.cursor = {
19391
+ const nextCursor = {
19295
19392
  groupId,
19296
19393
  startOffset,
19297
19394
  endOffset
19298
19395
  };
19396
+ this.record.cursor = this.objTree ? normalizeCursorRecord(this.objTree, nextCursor) : nextCursor;
19299
19397
  },
19300
19398
  leftMove() {
19301
19399
  this.components.move.leftMove();
@@ -19336,12 +19434,20 @@ var FormulaX = (() => {
19336
19434
  });
19337
19435
 
19338
19436
  // ../kity-runtime/src/legacy/input.ts
19339
- var KEY_CODE, kity20, InputComponent, input_default;
19437
+ function insertCursorMarkers(value, selectionStart, selectionEnd) {
19438
+ const normalizedStart = Math.max(0, Math.min(selectionStart ?? value.length, value.length));
19439
+ const normalizedEnd = Math.max(0, Math.min(selectionEnd ?? normalizedStart, value.length));
19440
+ const rangeStart = Math.min(normalizedStart, normalizedEnd);
19441
+ const rangeEnd = Math.max(normalizedStart, normalizedEnd);
19442
+ return value.slice(0, rangeStart) + CURSOR_CHAR3 + value.slice(rangeStart, rangeEnd) + CURSOR_CHAR3 + value.slice(rangeEnd);
19443
+ }
19444
+ var KEY_CODE, CURSOR_CHAR3, kity20, InputComponent, input_default;
19340
19445
  var init_input = __esm({
19341
19446
  "../kity-runtime/src/legacy/input.ts"() {
19342
19447
  "use strict";
19343
19448
  init_legacy_utils();
19344
19449
  init_legacy_input_filter();
19450
+ init_legacy_sysconf();
19345
19451
  init_runtime_interop();
19346
19452
  KEY_CODE = {
19347
19453
  LEFT: 37,
@@ -19349,6 +19455,7 @@ var FormulaX = (() => {
19349
19455
  DELETE: 8,
19350
19456
  INPUT: 229
19351
19457
  };
19458
+ CURSOR_CHAR3 = legacySysconf.cursorCharacter;
19352
19459
  kity20 = getLegacyKity();
19353
19460
  InputComponent = kity20.createClass("InputComponent", {
19354
19461
  constructor(parentComponent, kfEditor) {
@@ -19521,7 +19628,12 @@ var FormulaX = (() => {
19521
19628
  return `${e.shiftKey ? "s+" : ""}${e.keyCode}`;
19522
19629
  },
19523
19630
  processingInput() {
19524
- this.restruct(this.inputBox.value);
19631
+ const latexWithCursor = insertCursorMarkers(
19632
+ this.inputBox.value,
19633
+ this.inputBox.selectionStart,
19634
+ this.inputBox.selectionEnd
19635
+ );
19636
+ this.restruct(latexWithCursor);
19525
19637
  this.kfEditor.requestService("ui.update.canvas.view");
19526
19638
  },
19527
19639
  restruct(latexStr) {
@@ -23852,6 +23964,7 @@ var FormulaX = (() => {
23852
23964
 
23853
23965
  // ../kity-runtime/src/create-editor.ts
23854
23966
  init_toolbar_assets();
23967
+ init_i18n();
23855
23968
  var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
23856
23969
  var DEFAULT_EDITOR_HEIGHT = "auto";
23857
23970
  var KITY_STYLE_ID = "formulax-kity-editor-styles";
@@ -24002,6 +24115,7 @@ var FormulaX = (() => {
24002
24115
  const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
24003
24116
  const fontsize = options.render?.fontsize ?? 40;
24004
24117
  const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
24118
+ const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
24005
24119
  const assets = resolveEditorAssets(options.assets);
24006
24120
  try {
24007
24121
  const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
@@ -24030,6 +24144,9 @@ var FormulaX = (() => {
24030
24144
  render: {
24031
24145
  fontsize
24032
24146
  },
24147
+ ui: {
24148
+ locale
24149
+ },
24033
24150
  resource: {
24034
24151
  path: "",
24035
24152
  fonts: assets.fonts
@@ -24112,6 +24229,7 @@ var FormulaX = (() => {
24112
24229
 
24113
24230
  // ../kity-runtime/src/index.ts
24114
24231
  init_dom_utils();
24232
+ init_i18n();
24115
24233
  init_legacy_box_type();
24116
24234
  init_legacy_component();
24117
24235
  init_legacy_ele_type();
@@ -24189,6 +24307,11 @@ var FormulaX = (() => {
24189
24307
  }
24190
24308
 
24191
24309
  // ../renderer/src/svg.ts
24310
+ var SIMPLE_INLINE_HEIGHT_EM = 1.25;
24311
+ var BASE_FORMULA_HEIGHT = 40.5;
24312
+ var SIMPLE_FORMULA_HEIGHT_RATIO = 1.05;
24313
+ var MAX_INLINE_HEIGHT_EM = 1.65;
24314
+ var COMPLEX_FORMULA_SCALE = 0.825;
24192
24315
  function readRenderedFormulaSvgBox(svg2) {
24193
24316
  return getInlineSvgContent(svg2)?.box ?? readSvgBox(svg2);
24194
24317
  }
@@ -24363,6 +24486,7 @@ var FormulaX = (() => {
24363
24486
  "width",
24364
24487
  "height",
24365
24488
  "viewBox",
24489
+ "font-size",
24366
24490
  "class",
24367
24491
  "focusable",
24368
24492
  "aria-hidden",
@@ -24374,13 +24498,24 @@ var FormulaX = (() => {
24374
24498
  target.setAttribute(attribute.name, attribute.value);
24375
24499
  });
24376
24500
  }
24501
+ function calculateInlineHeightEm(height2) {
24502
+ const heightRatio = height2 / BASE_FORMULA_HEIGHT;
24503
+ if (!Number.isFinite(heightRatio) || heightRatio <= SIMPLE_FORMULA_HEIGHT_RATIO) {
24504
+ return SIMPLE_INLINE_HEIGHT_EM;
24505
+ }
24506
+ return Math.min(
24507
+ MAX_INLINE_HEIGHT_EM,
24508
+ SIMPLE_INLINE_HEIGHT_EM * Math.pow(heightRatio, COMPLEX_FORMULA_SCALE)
24509
+ );
24510
+ }
24377
24511
  function sizeSvgForInlineDisplay(clone, source, viewport) {
24512
+ clone.removeAttribute("font-size");
24378
24513
  const viewBox = clone.viewBox?.baseVal;
24379
24514
  const rect = source.getBoundingClientRect();
24380
24515
  const width2 = viewport?.width || viewBox?.width || rect.width || Number(clone.getAttribute("width")) || 1;
24381
24516
  const height2 = viewport?.height || viewBox?.height || rect.height || Number(clone.getAttribute("height")) || 1;
24382
24517
  const ratio = Math.max(0.1, width2 / Math.max(1, height2));
24383
- const inlineHeightEm = 0.875;
24518
+ const inlineHeightEm = calculateInlineHeightEm(height2);
24384
24519
  const inlineWidthEm = Math.min(40, Math.max(0.75, ratio * inlineHeightEm));
24385
24520
  clone.setAttribute("width", roundLength(width2));
24386
24521
  clone.setAttribute("height", roundLength(height2));
@@ -24388,8 +24523,9 @@ var FormulaX = (() => {
24388
24523
  "style",
24389
24524
  mergeInlineStyles(
24390
24525
  clone.getAttribute("style"),
24526
+ "font-size:inherit",
24391
24527
  `width:${roundLength(inlineWidthEm)}em`,
24392
- `height:${inlineHeightEm}em`
24528
+ `height:${roundLength(inlineHeightEm)}em`
24393
24529
  )
24394
24530
  );
24395
24531
  }
@@ -24745,6 +24881,8 @@ var FormulaX = (() => {
24745
24881
  }
24746
24882
 
24747
24883
  .fx-formula-kity-host .kf-editor {
24884
+ box-sizing: border-box;
24885
+ width: 100%;
24748
24886
  height: var(--fx-formula-editor-body-height) !important;
24749
24887
  overflow: visible !important;
24750
24888
  }