@formulaxjs/editor 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 +42 -10
- package/dist/index.cjs +194 -445
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +1064 -765
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +186 -431
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @formulaxjs/editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modal-oriented FormulaX editor UI helpers.
|
|
4
4
|
|
|
5
|
-
`@formulaxjs/editor` provides the
|
|
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
|
|
|
@@ -14,21 +14,53 @@ pnpm add @formulaxjs/editor
|
|
|
14
14
|
|
|
15
15
|
## Highlights
|
|
16
16
|
|
|
17
|
-
- `
|
|
18
|
-
- `
|
|
19
|
-
- `
|
|
20
|
-
-
|
|
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 {
|
|
26
|
+
import {
|
|
27
|
+
ensureFormulaXModalStyles,
|
|
28
|
+
mountFormulaXEditor,
|
|
29
|
+
} from '@formulaxjs/editor';
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
ensureFormulaXModalStyles(document);
|
|
32
|
+
|
|
33
|
+
const mounted = mountFormulaXEditor(document.querySelector('#host') as HTMLElement, {
|
|
34
|
+
initialLatex: '\\sqrt{x}',
|
|
35
|
+
autofocus: true,
|
|
29
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.
|
|
30
52
|
```
|
|
31
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
|
+
|
|
32
60
|
## Package role
|
|
33
61
|
|
|
34
|
-
Use this package
|
|
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`.
|