@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.
- package/README.md +66 -66
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +178 -40
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
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
|
-
|
|
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`.
|
|
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`.
|
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/formula-modal.ts","../src/perf.ts"],"sourcesContent":["export * from './formula-modal';\nexport * from './perf';\n","import { createEmptyState, parseLatex, type FormulaState } from '@formulaxjs/core';\nimport { mountKityEditor, type KityEditorAssets, type KityEditorHandle } from '@formulaxjs/kity-runtime';\nimport { escapeHtml, ensureFormulaXBaseStyles } from '@formulaxjs/renderer';\nimport {\n serializeKityFormulaFromRoot,\n waitForKityFormulaSvgLayout,\n} from '@formulaxjs/renderer-kity';\nimport {\n clearFormulaXPerfMarks,\n markFormulaXPerf,\n measureFormulaXPerf,\n recordFormulaXPerfPoint,\n} from './perf';\n\nconst EMPTY_FORMULA_PLACEHOLDER = '\\\\placeholder ';\nconst STYLE_ID = 'fx-formula-modal-styles';\n\nexport interface FormulaXEditorOptions {\n initialLatex?: string;\n height?: number | string;\n autofocus?: boolean;\n assets?: Partial<KityEditorAssets>;\n render?: {\n fontsize?: number;\n };\n}\n\nexport interface MountedFormulaXEditor {\n root: HTMLElement;\n getLatex: () => Promise<string>;\n getState: () => Promise<FormulaState>;\n getRenderHtml: () => Promise<string>;\n destroy: () => void;\n}\n\nexport const formulaXModalStyles = `\n.fx-formula-modal-open {\n overflow: hidden;\n}\n\n.fx-formula-modal-root {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.fx-formula-modal-backdrop {\n position: absolute;\n inset: 0;\n background: rgba(15, 23, 42, 0.48);\n}\n\n.fx-formula-modal {\n --fx-formula-editor-body-height: 264px;\n --fx-formula-workspace-height: 168px;\n position: relative;\n width: min(860px, calc(100vw - 32px));\n height: auto;\n max-height: calc(100vh - 32px);\n background: #fff;\n border-radius: 14px;\n box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);\n display: flex;\n flex-direction: column;\n overflow: visible;\n isolation: isolate;\n}\n\n.fx-formula-modal__header,\n.fx-formula-modal__footer,\n.fx-formula-modal__title,\n.fx-formula-modal__close,\n.fx-formula-modal__button,\n.fx-formula-editor-loading,\n.fx-formula-editor-error {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n}\n\n.fx-formula-modal__header {\n min-height: 56px;\n padding: 0 20px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n position: relative;\n z-index: 3;\n background: #fff;\n border-radius: 14px 14px 0 0;\n}\n\n.fx-formula-modal__title {\n font-size: 16px;\n font-weight: 650;\n margin: 0;\n color: #111827;\n}\n\n.fx-formula-modal__close {\n border: 0;\n background: transparent;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n color: #6b7280;\n}\n\n.fx-formula-modal__body {\n flex: 0 0 auto;\n height: var(--fx-formula-editor-body-height);\n padding: 0;\n overflow: visible;\n min-height: var(--fx-formula-editor-body-height);\n position: relative;\n z-index: 2;\n}\n\n.fx-formula-editor-host {\n width: 100%;\n height: var(--fx-formula-editor-body-height);\n min-height: var(--fx-formula-editor-body-height);\n overflow: visible;\n position: relative;\n}\n\n.fx-formula-kity-host {\n width: 100%;\n height: var(--fx-formula-editor-body-height);\n min-height: var(--fx-formula-editor-body-height);\n overflow: visible;\n position: relative;\n}\n\n.fx-formula-kity-host .kf-editor {\n height: var(--fx-formula-editor-body-height) !important;\n overflow: visible !important;\n}\n\n.fx-formula-kity-host .kf-editor-toolbar {\n overflow: visible;\n position: relative;\n z-index: 20;\n}\n\n.fx-formula-kity-host .kf-editor-ui-button-mount-point,\n.fx-formula-kity-host .kf-editor-ui-area-mount,\n.fx-formula-kity-host .kf-editor-ui-box,\n.fx-formula-kity-host .kf-editor-ui-list {\n z-index: 1000;\n}\n\n.fx-formula-kity-host .kf-editor-edit-area,\n.fx-formula-kity-host .kf-editor-canvas-container {\n min-height: var(--fx-formula-workspace-height);\n height: var(--fx-formula-workspace-height);\n}\n\n.fx-formula-kity-host .kf-editor-edit-area {\n flex: 0 0 auto;\n overflow: hidden;\n}\n\n.fx-formula-kity-host .kf-editor,\n.fx-formula-kity-host .kf-editor svg text,\n.fx-formula-kity-host .kf-editor-ui-area-item-text,\n.fx-formula-kity-host .kf-editor-ui-box-item-text,\n.fx-formula-kity-host .kf-editor-ui-box-item-val {\n font-family: \"KF AMS MAIN\", \"Cambria Math\", \"Latin Modern Math\", \"Times New Roman\", serif !important;\n}\n\n.fx-formula-kity-host .kf-editor-ui-box-item-content,\n.fx-formula-kity-host .kf-editor-ui-box-item-val {\n min-width: 32px;\n min-height: 32px;\n}\n\n.fx-formula-kity-host .kf-editor-ui-box-item-val svg,\n.fx-formula-kity-host .kf-editor-ui-box-item-val img,\n.fx-formula-kity-host .kf-editor-ui-area-item-img,\n.fx-formula-kity-host .kf-editor-ui-area-item-text {\n display: block;\n}\n\n.fx-formula-editor-loading {\n height: var(--fx-formula-editor-body-height);\n padding: 24px;\n color: #4b5563;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.fx-formula-editor-error {\n padding: 24px;\n color: #dc2626;\n font-size: 14px;\n}\n\n.fx-formula-editor-error pre {\n white-space: pre-wrap;\n word-break: break-all;\n color: #991b1b;\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-top: 8px;\n}\n\n.fx-formula-modal__footer {\n min-height: 64px;\n padding: 12px 20px;\n border-top: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 12px;\n flex-shrink: 0;\n position: relative;\n z-index: 1;\n background: #fff;\n border-radius: 0 0 14px 14px;\n}\n\n.fx-formula-modal__button {\n appearance: none;\n border: 1px solid #d1d5db;\n background: #fff;\n color: #111827;\n border-radius: 8px;\n padding: 8px 14px;\n font-size: 14px;\n cursor: pointer;\n}\n\n.fx-formula-modal__button--primary {\n border-color: #2563eb;\n background: #2563eb;\n color: #fff;\n}\n`;\n\nexport function ensureFormulaXModalStyles(doc: Document = document): void {\n ensureFormulaXBaseStyles(doc);\n\n if (doc.getElementById(STYLE_ID)) return;\n\n const style = doc.createElement('style');\n style.id = STYLE_ID;\n style.textContent = formulaXModalStyles;\n doc.head.appendChild(style);\n}\n\nexport function renderFormulaXEditorLoadingState(root: HTMLElement): void {\n root.classList.add('fx-formula-kity-host');\n root.innerHTML = `\n <div class=\"fx-formula-editor-loading\" role=\"status\" aria-live=\"polite\">\n Loading FormulaX editor...\n </div>\n `;\n}\n\nexport function mountFormulaXEditor(\n root: HTMLElement,\n options: FormulaXEditorOptions = {},\n): MountedFormulaXEditor {\n recordFormulaXPerfPoint('fx:formula-editor:mount:start');\n const mountStart = markFormulaXPerf('fx:formula-editor:mount:start:scope');\n let destroyed = false;\n let latestLatex = options.initialLatex ?? '';\n let handle: KityEditorHandle | null = null;\n const initialLatex = latestLatex.trim() ? latestLatex : EMPTY_FORMULA_PLACEHOLDER;\n\n renderFormulaXEditorLoadingState(root);\n const loadingVisibleMark = markFormulaXPerf('fx:formula-editor:loading-visible');\n measureFormulaXPerf('fx:formula-editor:loading-visible', mountStart, loadingVisibleMark);\n clearFormulaXPerfMarks(loadingVisibleMark);\n\n const readyPromise = mountKityEditor(root, {\n initialLatex,\n height: options.height ?? '100%',\n autofocus: options.autofocus ?? true,\n assets: options.assets,\n render: {\n fontsize: options.render?.fontsize ?? 40,\n },\n })\n .then((nextHandle) => {\n if (destroyed) {\n nextHandle.destroy();\n throw new Error('FormulaX editor mount cancelled');\n }\n\n const readyMark = markFormulaXPerf('fx:kity-editor:ready');\n measureFormulaXPerf('fx:kity-editor:ready', mountStart, readyMark);\n clearFormulaXPerfMarks(readyMark);\n handle = nextHandle;\n return nextHandle;\n })\n .catch((error) => {\n console.error('[FormulaX] Failed to load FormulaX editor:', error);\n\n if (!destroyed) {\n root.innerHTML = `\n <div class=\"fx-formula-editor-error\">\n Failed to load FormulaX editor.\n <pre>${escapeHtml(error instanceof Error ? error.message : String(error))}</pre>\n </div>\n `;\n }\n\n throw error;\n })\n .finally(() => {\n clearFormulaXPerfMarks(mountStart);\n });\n\n const getCurrentLatex = async (): Promise<string> => {\n const readyHandle = handle ?? await readyPromise;\n const latex = await tryReadLatexFromKityHandle(readyHandle);\n\n if (latex !== null) {\n latestLatex = latex;\n }\n\n return latestLatex;\n };\n\n return {\n root,\n\n getLatex: getCurrentLatex,\n\n async getState(): Promise<FormulaState> {\n const latex = await getCurrentLatex();\n\n try {\n return {\n ...createEmptyState(),\n doc: parseLatex(latex),\n };\n } catch {\n return createEmptyState();\n }\n },\n\n async getRenderHtml(): Promise<string> {\n await readyPromise;\n await waitForKityFormulaSvgLayout(root);\n return serializeKityFormulaFromRoot(root);\n },\n\n destroy(): void {\n if (destroyed) return;\n destroyed = true;\n\n void readyPromise\n .then((readyHandle) => readyHandle.destroy())\n .catch(() => undefined);\n\n root.innerHTML = '';\n },\n };\n}\n\nasync function tryReadLatexFromKityHandle(handle: KityEditorHandle): Promise<string | null> {\n try {\n let isEmpty = false;\n\n handle.ready(function ready() {\n const result = this.execCommand('content.is.empty');\n isEmpty = result === true;\n });\n\n if (isEmpty) {\n return '';\n }\n } catch {\n // Fall back to source commands for runtimes without content.is.empty.\n }\n\n const candidates = [\n 'get.source',\n 'getSource',\n 'getLatex',\n 'get.latex',\n 'get.content',\n 'getContent',\n ];\n\n for (const command of candidates) {\n try {\n let value: unknown = null;\n\n handle.ready(function ready() {\n value = this.execCommand(command);\n });\n\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n\n if (value && typeof value === 'object' && 'latex' in value) {\n const latex = (value as { latex?: unknown }).latex;\n if (typeof latex === 'string' && latex.trim()) {\n return latex;\n }\n }\n } catch {\n // Try the next available command name.\n }\n }\n\n return null;\n}\n","import { ensureKityRuntime } from '@formulaxjs/kity-runtime';\n\ntype FormulaXPerfState = {\n reportedMeasureCount: number;\n reportScheduled: boolean;\n};\n\ntype FormulaXPerfHost = typeof globalThis & {\n __FORMULAX_PERF__?: boolean;\n __FORMULAX_PERF_STATE__?: FormulaXPerfState;\n requestIdleCallback?: (callback: () => void) => number;\n cancelIdleCallback?: (handle: number) => void;\n};\n\nexport type FormulaXEditorPreloadMode = 'idle' | 'hover' | false;\n\nfunction getPerfHost(): FormulaXPerfHost {\n return globalThis as FormulaXPerfHost;\n}\n\nfunction getPerfState(): FormulaXPerfState {\n const host = getPerfHost();\n\n host.__FORMULAX_PERF_STATE__ ??= {\n reportedMeasureCount: 0,\n reportScheduled: false,\n };\n\n return host.__FORMULAX_PERF_STATE__;\n}\n\nfunction hasPerfSupport(): boolean {\n return typeof performance !== 'undefined'\n && typeof performance.mark === 'function'\n && typeof performance.measure === 'function'\n && typeof performance.getEntriesByType === 'function';\n}\n\nfunction isPerfDebugEnabled(): boolean {\n return getPerfHost().__FORMULAX_PERF__ === true;\n}\n\nfunction schedulePerfReport(): void {\n if (!hasPerfSupport() || !isPerfDebugEnabled()) {\n return;\n }\n\n const state = getPerfState();\n if (state.reportScheduled) {\n return;\n }\n\n state.reportScheduled = true;\n\n queueMicrotask(() => {\n state.reportScheduled = false;\n\n const entries = performance\n .getEntriesByType('measure')\n .filter((entry): entry is PerformanceMeasure => entry.name.startsWith('fx:'))\n .sort((left, right) => left.startTime - right.startTime);\n\n const nextEntries = entries.slice(state.reportedMeasureCount);\n state.reportedMeasureCount = entries.length;\n\n if (!nextEntries.length) {\n return;\n }\n\n console.table(nextEntries.map((entry) => ({\n name: entry.name,\n duration: Number(entry.duration.toFixed(2)),\n startTime: Number(entry.startTime.toFixed(2)),\n })));\n });\n}\n\nexport function markFormulaXPerf(name: string): string | null {\n if (!hasPerfSupport()) {\n return null;\n }\n\n const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;\n performance.mark(markName);\n return markName;\n}\n\nexport function measureFormulaXPerf(\n name: string,\n startMark: string | null,\n endMark?: string | null,\n): string | null {\n if (!hasPerfSupport() || !startMark) {\n return null;\n }\n\n const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);\n if (!resolvedEndMark) {\n return null;\n }\n\n performance.measure(name, startMark, resolvedEndMark);\n schedulePerfReport();\n return resolvedEndMark;\n}\n\nexport function recordFormulaXPerfPoint(name: string): void {\n const markName = markFormulaXPerf(name);\n if (!markName) {\n return;\n }\n\n measureFormulaXPerf(name, markName, markName);\n clearFormulaXPerfMarks(markName);\n}\n\nexport function clearFormulaXPerfMarks(...marks: Array<string | null | undefined>): void {\n if (!hasPerfSupport()) {\n return;\n }\n\n for (const mark of marks) {\n if (!mark) {\n continue;\n }\n\n performance.clearMarks(mark);\n }\n}\n\nexport async function preloadFormulaXEditor(): Promise<void> {\n await ensureKityRuntime();\n}\n\nexport function scheduleFormulaXEditorPreload(\n mode: FormulaXEditorPreloadMode,\n target?: EventTarget | null,\n): () => void {\n if (mode === false || typeof window === 'undefined') {\n return () => undefined;\n }\n\n let disposed = false;\n let triggered = false;\n const cleanupCallbacks: Array<() => void> = [];\n\n const trigger = (): void => {\n if (disposed || triggered) {\n return;\n }\n\n triggered = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n\n void preloadFormulaXEditor();\n };\n\n if (mode === 'idle') {\n const host = getPerfHost();\n\n if (typeof host.requestIdleCallback === 'function') {\n const handle = host.requestIdleCallback(() => {\n trigger();\n });\n\n cleanupCallbacks.push(() => {\n host.cancelIdleCallback?.(handle);\n });\n } else {\n const handle = window.setTimeout(() => {\n trigger();\n }, 1);\n\n cleanupCallbacks.push(() => {\n window.clearTimeout(handle);\n });\n }\n\n return () => {\n disposed = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n };\n }\n\n if (target && 'addEventListener' in target && 'removeEventListener' in target) {\n const eventTarget = target as EventTarget;\n\n const onActivate = (): void => {\n trigger();\n };\n\n eventTarget.addEventListener('pointerenter', onActivate, { once: true, passive: true });\n eventTarget.addEventListener('focusin', onActivate, { once: true });\n\n cleanupCallbacks.push(() => {\n eventTarget.removeEventListener('pointerenter', onActivate);\n eventTarget.removeEventListener('focusin', onActivate);\n });\n }\n\n return () => {\n disposed = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n };\n}\n\nexport function waitForFormulaXAnimationFrame(): Promise<void> {\n if (typeof window === 'undefined' || typeof window.requestAnimationFrame !== 'function') {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n window.requestAnimationFrame(() => resolve());\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAgE;AAChE,IAAAA,uBAA8E;AAC9E,sBAAqD;AACrD,2BAGO;;;ACNP,0BAAkC;AAgBlC,SAAS,cAAgC;AACvC,SAAO;AACT;AAEA,SAAS,eAAkC;AACzC,QAAM,OAAO,YAAY;AAEzB,OAAK,4BAA4B;AAAA,IAC/B,sBAAsB;AAAA,IACtB,iBAAiB;AAAA,EACnB;AAEA,SAAO,KAAK;AACd;AAEA,SAAS,iBAA0B;AACjC,SAAO,OAAO,gBAAgB,eACzB,OAAO,YAAY,SAAS,cAC5B,OAAO,YAAY,YAAY,cAC/B,OAAO,YAAY,qBAAqB;AAC/C;AAEA,SAAS,qBAA8B;AACrC,SAAO,YAAY,EAAE,sBAAsB;AAC7C;AAEA,SAAS,qBAA2B;AAClC,MAAI,CAAC,eAAe,KAAK,CAAC,mBAAmB,GAAG;AAC9C;AAAA,EACF;AAEA,QAAM,QAAQ,aAAa;AAC3B,MAAI,MAAM,iBAAiB;AACzB;AAAA,EACF;AAEA,QAAM,kBAAkB;AAExB,iBAAe,MAAM;AACnB,UAAM,kBAAkB;AAExB,UAAM,UAAU,YACb,iBAAiB,SAAS,EAC1B,OAAO,CAAC,UAAuC,MAAM,KAAK,WAAW,KAAK,CAAC,EAC3E,KAAK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I,UAAW;AACf,kBAAY;AAEZ,WAAK,aACF,KAAK,CAAC,gBAAgB,YAAY,QAAQ,CAAC,EAC3C,MAAM,MAAM,MAAS;AAExB,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAe,2BAA2B,QAAkD;AAC1F,MAAI;AACF,QAAI,UAAU;AAEd,WAAO,MAAM,SAAS,QAAQ;AAC5B,YAAM,SAAS,KAAK,YAAY,kBAAkB;AAClD,gBAAU,WAAW;AAAA,IACvB,CAAC;AAED,QAAI,SAAS;AACX,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,aAAW,WAAW,YAAY;AAChC,QAAI;AACF,UAAI,QAAiB;AAErB,aAAO,MAAM,SAAS,QAAQ;AAC5B,gBAAQ,KAAK,YAAY,OAAO;AAAA,MAClC,CAAC;AAED,UAAI,OAAO,UAAU,YAAY,MAAM,KAAK,GAAG;AAC7C,eAAO;AAAA,MACT;AAEA,UAAI,SAAS,OAAO,UAAU,YAAY,WAAW,OAAO;AAC1D,cAAM,QAAS,MAA8B;AAC7C,YAAI,OAAO,UAAU,YAAY,MAAM,KAAK,GAAG;AAC7C,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AACT;","names":["import_kity_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/formula-modal.ts","../src/perf.ts"],"sourcesContent":["export * from './formula-modal';\nexport * from './perf';\n","import { createEmptyState, parseLatex, type FormulaState } from '@formulaxjs/core';\nimport { mountKityEditor, type KityEditorAssets, type KityEditorHandle } from '@formulaxjs/kity-runtime';\nimport { escapeHtml, ensureFormulaXBaseStyles } from '@formulaxjs/renderer';\nimport {\n serializeKityFormulaFromRoot,\n waitForKityFormulaSvgLayout,\n} from '@formulaxjs/renderer-kity';\nimport {\n clearFormulaXPerfMarks,\n markFormulaXPerf,\n measureFormulaXPerf,\n recordFormulaXPerfPoint,\n} from './perf';\n\nconst EMPTY_FORMULA_PLACEHOLDER = '\\\\placeholder ';\nconst STYLE_ID = 'fx-formula-modal-styles';\n\nexport interface FormulaXEditorOptions {\n initialLatex?: string;\n height?: number | string;\n autofocus?: boolean;\n assets?: Partial<KityEditorAssets>;\n render?: {\n fontsize?: number;\n };\n}\n\nexport interface MountedFormulaXEditor {\n root: HTMLElement;\n getLatex: () => Promise<string>;\n getState: () => Promise<FormulaState>;\n getRenderHtml: () => Promise<string>;\n destroy: () => void;\n}\n\nexport const formulaXModalStyles = `\n.fx-formula-modal-open {\n overflow: hidden;\n}\n\n.fx-formula-modal-root {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.fx-formula-modal-backdrop {\n position: absolute;\n inset: 0;\n background: rgba(15, 23, 42, 0.48);\n}\n\n.fx-formula-modal {\n --fx-formula-editor-body-height: 264px;\n --fx-formula-workspace-height: 168px;\n position: relative;\n width: min(860px, calc(100vw - 32px));\n height: auto;\n max-height: calc(100vh - 32px);\n background: #fff;\n border-radius: 14px;\n box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);\n display: flex;\n flex-direction: column;\n overflow: visible;\n isolation: isolate;\n}\n\n.fx-formula-modal__header,\n.fx-formula-modal__footer,\n.fx-formula-modal__title,\n.fx-formula-modal__close,\n.fx-formula-modal__button,\n.fx-formula-editor-loading,\n.fx-formula-editor-error {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n}\n\n.fx-formula-modal__header {\n min-height: 56px;\n padding: 0 20px;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n position: relative;\n z-index: 3;\n background: #fff;\n border-radius: 14px 14px 0 0;\n}\n\n.fx-formula-modal__title {\n font-size: 16px;\n font-weight: 650;\n margin: 0;\n color: #111827;\n}\n\n.fx-formula-modal__close {\n border: 0;\n background: transparent;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n color: #6b7280;\n}\n\n.fx-formula-modal__body {\n flex: 0 0 auto;\n height: var(--fx-formula-editor-body-height);\n padding: 0;\n overflow: visible;\n min-height: var(--fx-formula-editor-body-height);\n position: relative;\n z-index: 2;\n}\n\n.fx-formula-editor-host {\n width: 100%;\n height: var(--fx-formula-editor-body-height);\n min-height: var(--fx-formula-editor-body-height);\n overflow: visible;\n position: relative;\n}\n\n.fx-formula-kity-host {\n width: 100%;\n height: var(--fx-formula-editor-body-height);\n min-height: var(--fx-formula-editor-body-height);\n overflow: visible;\n position: relative;\n}\n\n.fx-formula-kity-host .kf-editor {\n box-sizing: border-box;\n width: 100%;\n height: var(--fx-formula-editor-body-height) !important;\n overflow: visible !important;\n}\n\n.fx-formula-kity-host .kf-editor-toolbar {\n overflow: visible;\n position: relative;\n z-index: 20;\n}\n\n.fx-formula-kity-host .kf-editor-ui-button-mount-point,\n.fx-formula-kity-host .kf-editor-ui-area-mount,\n.fx-formula-kity-host .kf-editor-ui-box,\n.fx-formula-kity-host .kf-editor-ui-list {\n z-index: 1000;\n}\n\n.fx-formula-kity-host .kf-editor-edit-area,\n.fx-formula-kity-host .kf-editor-canvas-container {\n min-height: var(--fx-formula-workspace-height);\n height: var(--fx-formula-workspace-height);\n}\n\n.fx-formula-kity-host .kf-editor-edit-area {\n flex: 0 0 auto;\n overflow: hidden;\n}\n\n.fx-formula-kity-host .kf-editor,\n.fx-formula-kity-host .kf-editor svg text,\n.fx-formula-kity-host .kf-editor-ui-area-item-text,\n.fx-formula-kity-host .kf-editor-ui-box-item-text,\n.fx-formula-kity-host .kf-editor-ui-box-item-val {\n font-family: \"KF AMS MAIN\", \"Cambria Math\", \"Latin Modern Math\", \"Times New Roman\", serif !important;\n}\n\n.fx-formula-kity-host .kf-editor-ui-box-item-content,\n.fx-formula-kity-host .kf-editor-ui-box-item-val {\n min-width: 32px;\n min-height: 32px;\n}\n\n.fx-formula-kity-host .kf-editor-ui-box-item-val svg,\n.fx-formula-kity-host .kf-editor-ui-box-item-val img,\n.fx-formula-kity-host .kf-editor-ui-area-item-img,\n.fx-formula-kity-host .kf-editor-ui-area-item-text {\n display: block;\n}\n\n.fx-formula-editor-loading {\n height: var(--fx-formula-editor-body-height);\n padding: 24px;\n color: #4b5563;\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.fx-formula-editor-error {\n padding: 24px;\n color: #dc2626;\n font-size: 14px;\n}\n\n.fx-formula-editor-error pre {\n white-space: pre-wrap;\n word-break: break-all;\n color: #991b1b;\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-top: 8px;\n}\n\n.fx-formula-modal__footer {\n min-height: 64px;\n padding: 12px 20px;\n border-top: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 12px;\n flex-shrink: 0;\n position: relative;\n z-index: 1;\n background: #fff;\n border-radius: 0 0 14px 14px;\n}\n\n.fx-formula-modal__button {\n appearance: none;\n border: 1px solid #d1d5db;\n background: #fff;\n color: #111827;\n border-radius: 8px;\n padding: 8px 14px;\n font-size: 14px;\n cursor: pointer;\n}\n\n.fx-formula-modal__button--primary {\n border-color: #2563eb;\n background: #2563eb;\n color: #fff;\n}\n`;\n\nexport function ensureFormulaXModalStyles(doc: Document = document): void {\n ensureFormulaXBaseStyles(doc);\n\n if (doc.getElementById(STYLE_ID)) return;\n\n const style = doc.createElement('style');\n style.id = STYLE_ID;\n style.textContent = formulaXModalStyles;\n doc.head.appendChild(style);\n}\n\nexport function renderFormulaXEditorLoadingState(root: HTMLElement): void {\n root.classList.add('fx-formula-kity-host');\n root.innerHTML = `\n <div class=\"fx-formula-editor-loading\" role=\"status\" aria-live=\"polite\">\n Loading FormulaX editor...\n </div>\n `;\n}\n\nexport function mountFormulaXEditor(\n root: HTMLElement,\n options: FormulaXEditorOptions = {},\n): MountedFormulaXEditor {\n recordFormulaXPerfPoint('fx:formula-editor:mount:start');\n const mountStart = markFormulaXPerf('fx:formula-editor:mount:start:scope');\n let destroyed = false;\n let latestLatex = options.initialLatex ?? '';\n let handle: KityEditorHandle | null = null;\n const initialLatex = latestLatex.trim() ? latestLatex : EMPTY_FORMULA_PLACEHOLDER;\n\n renderFormulaXEditorLoadingState(root);\n const loadingVisibleMark = markFormulaXPerf('fx:formula-editor:loading-visible');\n measureFormulaXPerf('fx:formula-editor:loading-visible', mountStart, loadingVisibleMark);\n clearFormulaXPerfMarks(loadingVisibleMark);\n\n const readyPromise = mountKityEditor(root, {\n initialLatex,\n height: options.height ?? '100%',\n autofocus: options.autofocus ?? true,\n assets: options.assets,\n render: {\n fontsize: options.render?.fontsize ?? 40,\n },\n })\n .then((nextHandle) => {\n if (destroyed) {\n nextHandle.destroy();\n throw new Error('FormulaX editor mount cancelled');\n }\n\n const readyMark = markFormulaXPerf('fx:kity-editor:ready');\n measureFormulaXPerf('fx:kity-editor:ready', mountStart, readyMark);\n clearFormulaXPerfMarks(readyMark);\n handle = nextHandle;\n return nextHandle;\n })\n .catch((error) => {\n console.error('[FormulaX] Failed to load FormulaX editor:', error);\n\n if (!destroyed) {\n root.innerHTML = `\n <div class=\"fx-formula-editor-error\">\n Failed to load FormulaX editor.\n <pre>${escapeHtml(error instanceof Error ? error.message : String(error))}</pre>\n </div>\n `;\n }\n\n throw error;\n })\n .finally(() => {\n clearFormulaXPerfMarks(mountStart);\n });\n\n const getCurrentLatex = async (): Promise<string> => {\n const readyHandle = handle ?? await readyPromise;\n const latex = await tryReadLatexFromKityHandle(readyHandle);\n\n if (latex !== null) {\n latestLatex = latex;\n }\n\n return latestLatex;\n };\n\n return {\n root,\n\n getLatex: getCurrentLatex,\n\n async getState(): Promise<FormulaState> {\n const latex = await getCurrentLatex();\n\n try {\n return {\n ...createEmptyState(),\n doc: parseLatex(latex),\n };\n } catch {\n return createEmptyState();\n }\n },\n\n async getRenderHtml(): Promise<string> {\n await readyPromise;\n await waitForKityFormulaSvgLayout(root);\n return serializeKityFormulaFromRoot(root);\n },\n\n destroy(): void {\n if (destroyed) return;\n destroyed = true;\n\n void readyPromise\n .then((readyHandle) => readyHandle.destroy())\n .catch(() => undefined);\n\n root.innerHTML = '';\n },\n };\n}\n\nasync function tryReadLatexFromKityHandle(handle: KityEditorHandle): Promise<string | null> {\n try {\n let isEmpty = false;\n\n handle.ready(function ready() {\n const result = this.execCommand('content.is.empty');\n isEmpty = result === true;\n });\n\n if (isEmpty) {\n return '';\n }\n } catch {\n // Fall back to source commands for runtimes without content.is.empty.\n }\n\n const candidates = [\n 'get.source',\n 'getSource',\n 'getLatex',\n 'get.latex',\n 'get.content',\n 'getContent',\n ];\n\n for (const command of candidates) {\n try {\n let value: unknown = null;\n\n handle.ready(function ready() {\n value = this.execCommand(command);\n });\n\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n\n if (value && typeof value === 'object' && 'latex' in value) {\n const latex = (value as { latex?: unknown }).latex;\n if (typeof latex === 'string' && latex.trim()) {\n return latex;\n }\n }\n } catch {\n // Try the next available command name.\n }\n }\n\n return null;\n}\n","import { ensureKityRuntime } from '@formulaxjs/kity-runtime';\n\ntype FormulaXPerfState = {\n reportedMeasureCount: number;\n reportScheduled: boolean;\n};\n\ntype FormulaXPerfHost = typeof globalThis & {\n __FORMULAX_PERF__?: boolean;\n __FORMULAX_PERF_STATE__?: FormulaXPerfState;\n requestIdleCallback?: (callback: () => void) => number;\n cancelIdleCallback?: (handle: number) => void;\n};\n\nexport type FormulaXEditorPreloadMode = 'idle' | 'hover' | false;\n\nfunction getPerfHost(): FormulaXPerfHost {\n return globalThis as FormulaXPerfHost;\n}\n\nfunction getPerfState(): FormulaXPerfState {\n const host = getPerfHost();\n\n host.__FORMULAX_PERF_STATE__ ??= {\n reportedMeasureCount: 0,\n reportScheduled: false,\n };\n\n return host.__FORMULAX_PERF_STATE__;\n}\n\nfunction hasPerfSupport(): boolean {\n return typeof performance !== 'undefined'\n && typeof performance.mark === 'function'\n && typeof performance.measure === 'function'\n && typeof performance.getEntriesByType === 'function';\n}\n\nfunction isPerfDebugEnabled(): boolean {\n return getPerfHost().__FORMULAX_PERF__ === true;\n}\n\nfunction schedulePerfReport(): void {\n if (!hasPerfSupport() || !isPerfDebugEnabled()) {\n return;\n }\n\n const state = getPerfState();\n if (state.reportScheduled) {\n return;\n }\n\n state.reportScheduled = true;\n\n queueMicrotask(() => {\n state.reportScheduled = false;\n\n const entries = performance\n .getEntriesByType('measure')\n .filter((entry): entry is PerformanceMeasure => entry.name.startsWith('fx:'))\n .sort((left, right) => left.startTime - right.startTime);\n\n const nextEntries = entries.slice(state.reportedMeasureCount);\n state.reportedMeasureCount = entries.length;\n\n if (!nextEntries.length) {\n return;\n }\n\n console.table(nextEntries.map((entry) => ({\n name: entry.name,\n duration: Number(entry.duration.toFixed(2)),\n startTime: Number(entry.startTime.toFixed(2)),\n })));\n });\n}\n\nexport function markFormulaXPerf(name: string): string | null {\n if (!hasPerfSupport()) {\n return null;\n }\n\n const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;\n performance.mark(markName);\n return markName;\n}\n\nexport function measureFormulaXPerf(\n name: string,\n startMark: string | null,\n endMark?: string | null,\n): string | null {\n if (!hasPerfSupport() || !startMark) {\n return null;\n }\n\n const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);\n if (!resolvedEndMark) {\n return null;\n }\n\n performance.measure(name, startMark, resolvedEndMark);\n schedulePerfReport();\n return resolvedEndMark;\n}\n\nexport function recordFormulaXPerfPoint(name: string): void {\n const markName = markFormulaXPerf(name);\n if (!markName) {\n return;\n }\n\n measureFormulaXPerf(name, markName, markName);\n clearFormulaXPerfMarks(markName);\n}\n\nexport function clearFormulaXPerfMarks(...marks: Array<string | null | undefined>): void {\n if (!hasPerfSupport()) {\n return;\n }\n\n for (const mark of marks) {\n if (!mark) {\n continue;\n }\n\n performance.clearMarks(mark);\n }\n}\n\nexport async function preloadFormulaXEditor(): Promise<void> {\n await ensureKityRuntime();\n}\n\nexport function scheduleFormulaXEditorPreload(\n mode: FormulaXEditorPreloadMode,\n target?: EventTarget | null,\n): () => void {\n if (mode === false || typeof window === 'undefined') {\n return () => undefined;\n }\n\n let disposed = false;\n let triggered = false;\n const cleanupCallbacks: Array<() => void> = [];\n\n const trigger = (): void => {\n if (disposed || triggered) {\n return;\n }\n\n triggered = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n\n void preloadFormulaXEditor();\n };\n\n if (mode === 'idle') {\n const host = getPerfHost();\n\n if (typeof host.requestIdleCallback === 'function') {\n const handle = host.requestIdleCallback(() => {\n trigger();\n });\n\n cleanupCallbacks.push(() => {\n host.cancelIdleCallback?.(handle);\n });\n } else {\n const handle = window.setTimeout(() => {\n trigger();\n }, 1);\n\n cleanupCallbacks.push(() => {\n window.clearTimeout(handle);\n });\n }\n\n return () => {\n disposed = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n };\n }\n\n if (target && 'addEventListener' in target && 'removeEventListener' in target) {\n const eventTarget = target as EventTarget;\n\n const onActivate = (): void => {\n trigger();\n };\n\n eventTarget.addEventListener('pointerenter', onActivate, { once: true, passive: true });\n eventTarget.addEventListener('focusin', onActivate, { once: true });\n\n cleanupCallbacks.push(() => {\n eventTarget.removeEventListener('pointerenter', onActivate);\n eventTarget.removeEventListener('focusin', onActivate);\n });\n }\n\n return () => {\n disposed = true;\n\n while (cleanupCallbacks.length) {\n cleanupCallbacks.pop()?.();\n }\n };\n}\n\nexport function waitForFormulaXAnimationFrame(): Promise<void> {\n if (typeof window === 'undefined' || typeof window.requestAnimationFrame !== 'function') {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n window.requestAnimationFrame(() => resolve());\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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