@formulaxjs/kity-runtime 0.5.0 → 0.5.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.
package/README.md CHANGED
@@ -14,31 +14,39 @@ Legacy KityFormula runtime adapter for FormulaX.
14
14
  npm install @formulaxjs/kity-runtime
15
15
  ```
16
16
 
17
- ## Highlights
18
-
19
- - `ensureKityRuntime` for lazy runtime bootstrapping
20
- - `createKityEditor` and `mountKityEditor` for mounting a Kity editor into the DOM
21
- - Legacy compatibility exports used by existing KityFormula-oriented integrations
22
-
23
- ## Example
24
-
25
- ```ts
26
- import { mountKityEditor } from '@formulaxjs/kity-runtime';
27
-
28
- const root = document.getElementById('editor');
29
-
30
- if (!root) {
31
- throw new Error('Missing #editor');
32
- }
33
-
34
- const handle = await mountKityEditor(root, {
35
- value: 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}',
36
- locale: 'zh_CN', // optional, defaults to en_US
17
+ ## Highlights
18
+
19
+ - `ensureKityRuntime` for lazy runtime bootstrapping
20
+ - `createKityEditor` and `mountKityEditor` for mounting a Kity editor into the DOM
21
+ - `FormulaXEditor` for a promise-friendly wrapper around the low-level runtime handle
22
+ - Legacy compatibility exports used by existing KityFormula-oriented integrations
23
+
24
+ ## Example
25
+
26
+ ```ts
27
+ import { FormulaXEditor } from '@formulaxjs/kity-runtime';
28
+
29
+ const editor = new FormulaXEditor({
30
+ el: '#editor', // HTMLElement or selector
31
+ initialLatex: 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}',
32
+ height: 320, // optional runtime workspace height
33
+ autofocus: true, // focus after mount
34
+ assets: {
35
+ // optional partial overrides when runtime CSS / fonts / toolbar images live on your CDN
36
+ styles: {
37
+ editor: '/static/formulax/editor.css',
38
+ },
39
+ },
40
+ render: {
41
+ fontsize: 40, // preview / export font size
42
+ },
37
43
  });
38
44
 
39
- console.log(handle.getLatex());
45
+ await editor.execCommand('render', '\\sqrt{x}');
46
+ await editor.focus();
47
+ await editor.destroy();
40
48
  ```
41
49
 
42
50
  ## Package role
43
-
44
- Use this package when you need the low-level legacy Kity editing runtime or compatibility with historical KityFormula behavior. For application-facing editor usage, prefer importing `FormulaXEditor` from `@formulaxjs/editor`. For host-editor integrations, prefer the dedicated adapter packages that already depend on this runtime.
51
+
52
+ Use this package when you need the low-level legacy Kity editing runtime or compatibility with historical KityFormula behavior. For modal-oriented editing flows, prefer `mountFormulaXEditor()` from `@formulaxjs/editor`. For host-editor integrations, prefer the dedicated adapter packages that already depend on this runtime.
package/README.zh-CN.md CHANGED
@@ -18,27 +18,35 @@ npm install @formulaxjs/kity-runtime
18
18
 
19
19
  - `ensureKityRuntime`,用于懒加载 runtime 初始化
20
20
  - `createKityEditor` 与 `mountKityEditor`,用于将 Kity 编辑器挂载到 DOM
21
+ - `FormulaXEditor`,对低层 runtime handle 提供更易用的 Promise 风格包装
21
22
  - 面向既有 KityFormula 集成保留的兼容性导出
22
23
 
23
24
  ## 示例
24
25
 
25
26
  ```ts
26
- import { mountKityEditor } from '@formulaxjs/kity-runtime';
27
-
28
- const root = document.getElementById('editor');
29
-
30
- if (!root) {
31
- throw new Error('Missing #editor');
32
- }
33
-
34
- const handle = await mountKityEditor(root, {
35
- value: 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}',
36
- locale: 'zh_CN', // 可选,默认 en_US
27
+ import { FormulaXEditor } from '@formulaxjs/kity-runtime';
28
+
29
+ const editor = new FormulaXEditor({
30
+ el: '#editor', // HTMLElement 或选择器字符串
31
+ initialLatex: 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}',
32
+ height: 320, // 可选,runtime 工作区高度
33
+ autofocus: true, // 挂载后自动聚焦
34
+ assets: {
35
+ // 可选,当 runtime CSS / 字体 / 工具栏图片放在 CDN 时可局部覆盖
36
+ styles: {
37
+ editor: '/static/formulax/editor.css',
38
+ },
39
+ },
40
+ render: {
41
+ fontsize: 40, // 预览 / 导出字号
42
+ },
37
43
  });
38
44
 
39
- console.log(handle.getLatex());
45
+ await editor.execCommand('render', '\\sqrt{x}');
46
+ await editor.focus();
47
+ await editor.destroy();
40
48
  ```
41
49
 
42
50
  ## 包职责
43
51
 
44
- 当你需要低层旧版 Kity 编辑 runtime,或者需要兼容历史 KityFormula 行为时,请使用这个包。面向应用层的编辑器使用方式,更推荐从 `@formulaxjs/editor` 引入 `FormulaXEditor`;宿主编辑器集成则优先使用已经依赖该 runtime 的专用 adapter 包。
52
+ 当你需要低层旧版 Kity 编辑 runtime,或者需要兼容历史 KityFormula 行为时,请使用这个包。面向弹窗的编辑流程更推荐使用 `@formulaxjs/editor` `mountFormulaXEditor()`;宿主编辑器集成则优先使用已经依赖该 runtime 的专用 adapter 包。