@formulaxjs/editor 0.2.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.
package/README.md CHANGED
@@ -1,34 +1,66 @@
1
- # @formulaxjs/editor
2
-
3
- Public editor entry and integration helpers for FormulaX.
4
-
5
- `@formulaxjs/editor` provides the public FormulaX editor entry backed by the Kity compatibility runtime, along with shared formula markup helpers and modal wiring used by richer host integrations.
6
-
7
- > Status: experimental. Public APIs may change before the first stable release.
8
-
9
- ## Install
10
-
11
- ```bash
12
- pnpm add @formulaxjs/editor
13
- ```
14
-
15
- ## Highlights
16
-
17
- - `FormulaXEditor` as the public runtime-backed editor entry
18
- - `mountFormulaXEditor` for modal-based Kity editing flows
19
- - `formulaXModalStyles` for shared modal styling
20
- - Formula node helpers for host-editor markup integration
21
-
22
- ## Example
23
-
24
- ```ts
25
- import { FormulaXEditor } from '@formulaxjs/editor';
26
-
27
- new FormulaXEditor({
28
- el: '#app',
29
- });
30
- ```
31
-
32
- ## Package role
33
-
34
- Use this package as the main application-facing FormulaX editor entry. If you are integrating FormulaX into TinyMCE, CKEditor 5, or Tiptap, prefer the dedicated adapter packages instead.
1
+ # @formulaxjs/editor
2
+
3
+ Modal-oriented FormulaX editor UI helpers.
4
+
5
+ `@formulaxjs/editor` provides the browser-side modal styling and embedded editing helpers used by host integrations. It is no longer the shared markup layer or the read-only renderer layer.
6
+
7
+ > Status: experimental. Public APIs may change before the first stable release.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @formulaxjs/editor
13
+ ```
14
+
15
+ ## Highlights
16
+
17
+ - `ensureFormulaXModalStyles`
18
+ - `formulaXModalStyles`
19
+ - `mountFormulaXEditor`
20
+ - `preloadFormulaXEditor` and `scheduleFormulaXEditorPreload`
21
+ - `getLatex()`, `getState()`, and `getRenderHtml()` on the mounted editor handle
22
+
23
+ ## Example
24
+
25
+ ```ts
26
+ import {
27
+ ensureFormulaXModalStyles,
28
+ mountFormulaXEditor,
29
+ } from '@formulaxjs/editor';
30
+
31
+ ensureFormulaXModalStyles(document);
32
+
33
+ const mounted = mountFormulaXEditor(document.querySelector('#host') as HTMLElement, {
34
+ initialLatex: '\\sqrt{x}',
35
+ autofocus: true,
36
+ });
37
+
38
+ const latex = await mounted.getLatex();
39
+ const html = await mounted.getRenderHtml();
40
+ ```
41
+
42
+ ## Preloading
43
+
44
+ If you want the FormulaX runtime to start loading before the user opens the modal, use the preload helpers:
45
+
46
+ ```ts
47
+ import { scheduleFormulaXEditorPreload } from '@formulaxjs/editor';
48
+
49
+ const cleanup = scheduleFormulaXEditorPreload('hover', document.querySelector('#open-formula'));
50
+
51
+ // Call cleanup() if the host UI is torn down before preload triggers.
52
+ ```
53
+
54
+ Supported preload modes:
55
+
56
+ - `idle` schedules runtime loading when the browser is idle.
57
+ - `hover` waits for `pointerenter` or `focusin` on the provided target.
58
+ - `false` disables preloading.
59
+
60
+ ## Package role
61
+
62
+ Use this package for modal-based editing flows and embedded FormulaX editor UI.
63
+
64
+ - If you need shared markup or base formula styles, use `@formulaxjs/renderer`.
65
+ - If you need Kity-based read-only rendering, use `@formulaxjs/renderer-kity`.
66
+ - If you need the low-level legacy runtime entry, use `@formulaxjs/kity-runtime`.