@formulaxjs/editor 0.1.1 → 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 CHANGED
@@ -1,45 +1,66 @@
1
1
  # @formulaxjs/editor
2
2
 
3
- Browser editing foundation for FormulaX.
3
+ Modal-oriented FormulaX editor UI helpers.
4
4
 
5
- `@formulaxjs/editor` adapts `@formulaxjs/core` state to the DOM. It provides the interactive editor shell, HTML rendering helpers, modal wiring, and browser-side styles used by richer host integrations.
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
6
 
7
7
  > Status: experimental. Public APIs may change before the first stable release.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- pnpm add @formulaxjs/editor @formulaxjs/core @formulaxjs/renderer @formulaxjs/kity-runtime
12
+ pnpm add @formulaxjs/editor
13
13
  ```
14
14
 
15
15
  ## Highlights
16
16
 
17
- - `FormulaEditor` for mounting an interactive FormulaX editor into a DOM node
18
- - `renderInteractiveHtml` for HTML rendering of FormulaX state
19
- - `mountFormulaXKityEditor` for modal-based Kity editing flows
20
- - `formulaXModalStyles` and `editorStyles` for default browser styling
17
+ - `ensureFormulaXModalStyles`
18
+ - `formulaXModalStyles`
19
+ - `mountFormulaXEditor`
20
+ - `preloadFormulaXEditor` and `scheduleFormulaXEditorPreload`
21
+ - `getLatex()`, `getState()`, and `getRenderHtml()` on the mounted editor handle
21
22
 
22
23
  ## Example
23
24
 
24
25
  ```ts
25
- import { FormulaEditor } from '@formulaxjs/editor';
26
+ import {
27
+ ensureFormulaXModalStyles,
28
+ mountFormulaXEditor,
29
+ } from '@formulaxjs/editor';
26
30
 
27
- const root = document.getElementById('editor');
31
+ ensureFormulaXModalStyles(document);
28
32
 
29
- if (!root) {
30
- throw new Error('Missing #editor');
31
- }
32
-
33
- const editor = new FormulaEditor({
34
- root,
35
- onChange(state) {
36
- console.log(state);
37
- },
33
+ const mounted = mountFormulaXEditor(document.querySelector('#host') as HTMLElement, {
34
+ initialLatex: '\\sqrt{x}',
35
+ autofocus: true,
38
36
  });
39
37
 
40
- console.log(editor.getState());
38
+ const latex = await mounted.getLatex();
39
+ const html = await mounted.getRenderHtml();
41
40
  ```
42
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
+
43
60
  ## Package role
44
61
 
45
- Use this package for browser-native FormulaX editing. If you are integrating FormulaX into TinyMCE, CKEditor 5, or Tiptap, prefer the dedicated adapter packages instead.
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`.