@barocss/math-editor 0.4.0 → 0.5.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.
Files changed (49) hide show
  1. package/API-SESSION.md +10 -0
  2. package/API-WEB-COMPONENT.md +2 -0
  3. package/CHANGELOG.md +61 -0
  4. package/EDITING-SCENARIOS.md +174 -0
  5. package/IMPLEMENTATION.md +95 -0
  6. package/LATEX-GUIDE.md +22 -0
  7. package/LATEX-MODEL.md +12 -0
  8. package/LATEX-SCOPE.md +10 -1
  9. package/README.md +73 -19
  10. package/RELEASING.md +81 -10
  11. package/RENDERING-TESTS.md +79 -0
  12. package/ROADMAP.md +132 -5
  13. package/VALIDATION.md +331 -0
  14. package/dist/context-tools.d.ts +21 -0
  15. package/dist/context-tools.js +37 -0
  16. package/dist/dom/context-keyboard.d.ts +2 -0
  17. package/dist/dom/context-keyboard.js +22 -0
  18. package/dist/dom/menu-position.d.ts +3 -0
  19. package/dist/dom/menu-position.js +45 -1
  20. package/dist/dom.d.ts +2 -0
  21. package/dist/dom.js +187 -38
  22. package/dist/latex.js +11 -0
  23. package/dist/locales/en.js +13 -1
  24. package/dist/locales/en.json +13 -1
  25. package/dist/locales/ko.js +13 -1
  26. package/dist/locales/ko.json +13 -1
  27. package/dist/math-editor.d.ts +3 -1
  28. package/dist/math-editor.js +394 -280
  29. package/dist/math-layout.d.ts +12 -0
  30. package/dist/math-layout.js +59 -0
  31. package/dist/math-spacing.d.ts +13 -0
  32. package/dist/math-spacing.js +87 -0
  33. package/dist/model.d.ts +4 -0
  34. package/dist/model.js +49 -4
  35. package/dist/root-transform.d.ts +19 -0
  36. package/dist/root-transform.js +69 -0
  37. package/dist/suggestions.d.ts +9 -0
  38. package/dist/suggestions.js +53 -0
  39. package/dist/web-component.js +9 -1
  40. package/package.json +11 -3
  41. package/src/fonts/KaTeX_Math-Italic.woff2 +0 -0
  42. package/src/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  43. package/src/fonts/README.md +18 -0
  44. package/src/shapes/README.md +21 -0
  45. package/src/shapes/parenthesis-bottom.svg +1 -0
  46. package/src/shapes/parenthesis-top.svg +1 -0
  47. package/src/shapes/parenthesis.svg +1 -0
  48. package/src/shapes/radical.svg +1 -0
  49. package/src/style.css +695 -44
package/RELEASING.md CHANGED
@@ -1,31 +1,102 @@
1
1
  # Releasing math editor
2
2
 
3
- The source stays in this monorepo. Release only `@barocss/math-editor`; framework subpaths share its version. The initial release is **0.1.0**, public, on the **latest** npm tag.
3
+ See [Editing scenarios](EDITING-SCENARIOS.md) for stable scenario IDs, acceptance criteria, coverage gaps and per-run reporting.
4
+
5
+
6
+ The source stays in this monorepo. The local batch release includes
7
+ `@barocss/math-editor` and the nine public host plugins. All use MIT, public npm
8
+ access and the `latest` tag. Framework adapters are core subpaths and share the
9
+ core version. The private integration workspace and other products are excluded.
10
+
11
+ The published baseline is core **0.4.0** and host plugins **0.1.0**. Later versions
12
+ remain independent; a batch release does not force every package to change.
4
13
 
5
14
  ## Local release
6
15
 
7
16
  ```sh
8
17
  # Repository root. Login is handled by npm, never by storing credentials in the repository.
9
- npm login
10
- pnpm release:math:prepare
11
- # After reviewing changes and browser validation:
18
+ npm login --registry=https://registry.npmjs.org/
19
+ # After reviewing versions, changelogs and browser validation:
12
20
  pnpm release:math
13
21
  ```
14
22
 
15
- Both commands check formatting, types and unit tests, clean/build the package, create a temporary tarball and verify all package entry points. The publish command sends only that verified tarball to the public npm registry. It never runs recursive publishing. `pnpm release` is an alias for this math-only workflow. npm may request account authentication or 2FA during publishing.
23
+ This one command runs release-tool tests, core formatting/type/unit checks,
24
+ integration type/unit checks, builds and package validation. It verifies the core
25
+ entry points and each plugin's packed declarations, runtime imports and required
26
+ files. It then runs **one `pnpm -r publish` command** for the ten allowed names.
27
+ `pnpm release` is an alias for this workflow.
28
+
29
+ Only the inspected package contents enter a generated workspace under
30
+ `output/math-batch-releases/release-*/`. Wrapper manifests use
31
+ `publishConfig.directory` to point at those contents. They give pnpm an explicit
32
+ core-first dependency order without adding dependencies to the published plugin
33
+ manifests. Publish lifecycle scripts are disabled because validation and builds
34
+ already ran. Git checks are disabled only for this generated workspace.
35
+
36
+ pnpm checks npm and skips package versions that already exist. It packs the
37
+ inspected contents again, so the final archive checksum can differ from the
38
+ preparation archive. The batch is not an atomic registry transaction. npm may
39
+ still request authentication for individual packages; one command does not
40
+ guarantee one authentication prompt.
41
+
42
+ For checks without publishing:
43
+
44
+ ```sh
45
+ # Build and inspect all ten packages. No registry publication.
46
+ pnpm release:math:prepare
47
+ # Also exercise recursive publishing with npm's dry-run flag.
48
+ # This can read registry metadata; it does not upload packages.
49
+ pnpm release:math:dry-run
50
+ ```
51
+
52
+ `release.json` records the candidate versions, artifact hashes and command status.
53
+ On success, `pnpm-publish-summary.json` lists newly published packages; versions
54
+ skipped by pnpm are absent. A dry-run summary is not evidence of publication.
55
+ If publishing fails, preserve the report and check each candidate version on npm.
56
+ pnpm 8 may not write its summary after a partial failure. Resolve any uncertain
57
+ results before running the batch again; never use `--force` to retry.
16
58
 
17
59
  Before releasing UI changes, also run `pnpm --filter @barocss/math-demo test:e2e` and the demo build. Verify the intended package name/version and changelog. A version already published to npm must never be reused. The repository's release workflow is manual validation only; it does not publish on main pushes.
18
60
 
19
61
  ## Subsequent versions
20
62
 
21
- 1. Run `pnpm changeset`, select only `@barocss/math-editor`, and write a user-facing change summary.
63
+ 1. Run `pnpm changeset`, select the affected math core and/or public plugins, and write a user-facing change summary.
22
64
  2. Use patch for compatible fixes and minor for features. During 0.x development, clearly identify breaking API changes in a minor release. Reserve 1.0.0 for the agreed stable API.
23
- 3. Run `pnpm version:math`. It runs Changesets in a temporary math-only workspace and copies back only this package manifest/changelog, preventing dependent product version bumps. The consumed changeset summary is retained in CHANGELOG.md.
65
+ 3. Run `pnpm version:math:plan` to preview the core and nine plugin versions. Run `pnpm version:math` to apply that plan. Changesets runs in a temporary math-only workspace and copies back only affected math manifests/changelogs. Unrelated product changesets remain untouched. Review plugin peer-range changes before publishing.
24
66
  4. Review and commit the version/changelog and any dependency/lockfile changes with the implementation. Run release validation, then publish locally.
25
- 5. Record a package-specific Git tag such as `math-editor-v0.1.1` on the release commit, and update the site with the matching package version.
67
+ 5. Record package-specific Git tags on the release commit, and update the site with the matching package version. The batch command does not create commits or tags.
68
+
69
+ Versioning is separate from publishing. Repeating a publish command must not create
70
+ another version. Avoid `pnpm version-packages` and unfiltered `pnpm -r publish`
71
+ for a math-only release because they can include other products.
26
72
 
27
- The first 0.1.0 changelog is seeded explicitly; do not add a version-bump changeset just to publish the initial version. Avoid `pnpm version-packages` for a math-only release because that command processes the entire workspace plan.
73
+ The [host release guide](../math-editor-integrations/docs/RELEASING.md) lists the
74
+ nine plugins and explains changes to shared implementation. For an explicit
75
+ core-only release, use `pnpm version:math:core`,
76
+ `pnpm release:math:core:prepare` and `pnpm release:math:core`.
28
77
 
29
78
  ## Website
30
79
 
31
- `apps/math-demo` remains the site source. The intended static deployment repository is `barocss/math-editor-site`, with GitHub Pages at `math-editor.barocss.com`. Website deployment is separate from npm publication; page-only changes do not require a package version bump. Keep the displayed version and built editor version in sync. Successful npm publication alone does not mean the site or DNS has been configured.
80
+ `apps/math-demo` remains the site source. The static deployment repository is
81
+ `barocss/math-editor-site`, with GitHub Pages at `math-editor.barocss.com`.
82
+ Build the site directly from workspace source:
83
+
84
+ ```sh
85
+ pnpm build:math:site
86
+ ```
87
+
88
+ This builds the main site and the nine-plugin integration sample without a core
89
+ tarball, package `dist` build, npm login, registry lookup or publication check.
90
+ Workspace package exports resolve local source, including the private common
91
+ module. No package version bump is required to rebuild or deploy the site.
92
+ `release.json` records `source: "workspace-source"` and the local package versions
93
+ as metadata; those versions do not claim that the packages are published.
94
+
95
+ For an explicit package-artifact check, the previous command remains available:
96
+
97
+ ```sh
98
+ pnpm release:math:site /path/to/barocss-math-editor.tgz
99
+ ```
100
+
101
+ Both commands print the prepared static site directory and do not deploy it.
102
+ Website deployment and npm publication are independent operations.
@@ -0,0 +1,79 @@
1
+ # Rendering regression checks
2
+
3
+ Compare the editor with KaTeX using the same exported LaTeX, base font size and
4
+ display mode. Keep [editing scenarios](EDITING-SCENARIOS.md) for input behavior;
5
+ this guide defines the visual checks for EDIT-017. KaTeX is the reference image,
6
+ not an editable DOM replacement.
7
+
8
+ ## Three checks for each fixture
9
+
10
+ 1. **Model/output:** the editable tree exports the intended LaTeX and KaTeX accepts it.
11
+ 2. **Geometry:** compare relative positions, font sizes and gaps. Absolute page
12
+ coordinates are not comparable across different containers.
13
+ 3. **Visual review:** save the editor, active-input and KaTeX images together.
14
+ Check curves, stroke thickness, baselines and clipping. Numerical checks alone
15
+ do not establish that the two images look equivalent.
16
+
17
+ The active input, measuring element and passive glyph must use the same font
18
+ metrics. A cursor or hover background must not move a fraction or hide a fence.
19
+ Wait for `document.fonts.ready`. Disable preview fit scaling for comparison and
20
+ set the KaTeX root's computed font size to the editor's base size; matching the
21
+ parent container's font size is not sufficient.
22
+
23
+ ## Initial executable fixtures
24
+
25
+ Run `apps/math-integrations/tests/rendering-regression-check.js` through the
26
+ existing Playwright CLI browser workflow with the local site on port 5184.
27
+ The file is an async `(page) => ...` fixture, not a standalone Node script.
28
+ Omit its final semicolon when passing the function to `run-code`.
29
+
30
+ | Fixture | LaTeX | Renderers / sizes |
31
+ | --- | --- | --- |
32
+ | `indexed-root-power` | `\left(\sqrt[20]{ab}\right)^{\frac{2}{3}}` | Rich React and native DOM; 22px and 36px |
33
+ | `fraction-power` | `x^{\frac{2}{3}}` | Rich React and native DOM; 22px and 36px |
34
+ | `fraction-subscript` | `x_{\frac{2}{3}}` | Rich React and native DOM; 22px and 36px |
35
+
36
+ The 12 combinations currently assert:
37
+
38
+ - Fraction terms use half of the base font size and match KaTeX's computed term
39
+ size within 0.1px. This applies to these implicit-style fixtures, not every
40
+ explicit `\dfrac` or `\tfrac` expression.
41
+ - The exponent is above the base and the subscript is below it.
42
+ - The fraction center's vertical offset from the base glyph center differs from
43
+ KaTeX by less than 0.25em. This is a regression threshold, not pixel equality.
44
+ - The gap from the base box to its fraction script is between 0 and 0.25em.
45
+ - Activating a numerator retains its font size, and typing retains focus.
46
+ - The formula does not produce a KaTeX error.
47
+
48
+ Screenshots are saved as
49
+ `output/playwright/{renderer}-{fixture}-{size}-{editor|katex|active}.png`.
50
+ The returned metrics include editor and reference coordinates. Preserve them
51
+ with the source fingerprint, browser version and screenshot pairs for a run.
52
+ These filenames are overwritten on rerun; archive them if they are used as a
53
+ release baseline. Do not update an accepted baseline simply to hide a failure.
54
+
55
+ ## Why the first correction is bounded
56
+
57
+ Script fractions previously retained body-sized minimum row heights and spacing.
58
+ They now have compact terms and rows. A simple base uses a small script offset;
59
+ a tall structured base uses an offset proportional to the fraction height.
60
+ Empty boundary nodes reserve only a narrow passive cursor position.
61
+
62
+ This fixes the initial cases without changing the JSON model. It is not a
63
+ complete TeX layout engine. Remaining comparison fixtures should cover paired
64
+ scripts, nested fractions in both slots, explicit style overrides, multi-line
65
+ collision, large operators, fences, accents and narrow host containers.
66
+
67
+ As those fixtures grow, consolidate script levels, the math axis, baseline and
68
+ stroke metrics into shared layout rules. Avoid extending a list of formula-
69
+ specific CSS exceptions without a failing fixture and reference measurement.
70
+ Both renderers must use the same rule, and every new notation feature needs
71
+ an editor/KaTeX comparison in passive and active states.
72
+
73
+ ## Release use
74
+
75
+ Run changed fixtures during development. Run the rendering set and applicable
76
+ editing scenarios against release candidate artifacts before publishing. The
77
+ current fixture uses workspace sources and Chromium; it does not certify packed
78
+ packages, all host containers, Firefox/WebKit or OS IME behavior. CI scheduling
79
+ and automatic screenshot-diff approval are not implemented by this guide.
package/ROADMAP.md CHANGED
@@ -4,6 +4,78 @@ This roadmap describes priorities, not release promises. The current package is
4
4
 
5
5
 
6
6
 
7
+ ## Current focus: continuous editing — workspace, 2026-09-10
8
+
9
+ The rendering pass is now the maintenance baseline. Further contour refinement
10
+ is deferred; keep existing checks when notation or layout changes.
11
+
12
+ EDIT-019 now runs through keyboard input, range wrapping, radical conversion,
13
+ matrix input, five-step Undo/Redo, empty-root deletion and restoration, then a
14
+ second typing/history chain without resetting the editor. React standalone block
15
+ plus Quill/Tiptap/ProseMirror/Lexical/TinyMCE/CKEditor/Slate in-place block/inline and
16
+ Editor.js/Gutenberg block pass (17 targets, 499 checkpoints). Host checks verify unchanged draft data,
17
+ Save, reload/Restore, re-edit and Cancel. One-step host Undo/Redo passes where
18
+ configured; the Editor.js demo has no host history integration. Inline also
19
+ checks Enter commit without new paragraphs, right-boundary exit and prose
20
+ continuation at the correct host position.
21
+
22
+ Run `pnpm --filter @barocss/math-editor test:editing`. Timestamped reports include
23
+ checkpoints, browser scope, fixture copy and source fingerprints. The Tiptap sample now separates document Restore from subsequent typing in host history;
24
+ TinyMCE now keeps empty formulas visible with a localized placeholder. Its
25
+ block/inline checks use an inline TinyMCE host; classic iframe mode is separate.
26
+ All nine integration demos now pass this chain. Gutenberg uses the standalone
27
+ provider demo; WordPress admin and other host configurations remain separate.
28
+ Next: range clipboard and populated/grid deletion sequences. Real OS IME
29
+ and clipboard remain deferred; this is not a release-wide certification.
30
+
31
+
32
+ ## Named-function and fraction spacing — workspace, 2026-09-10
33
+
34
+ Named functions and fractions now share horizontal spacing with adjacent text.
35
+ Repeated functions, parentheses after functions, products of functions and
36
+ repeated fractions have paired editor/KaTeX comparisons. Named-function thin
37
+ spacing remains in first and nested exponents. Fixed function glyph padding and
38
+ fraction outer margins no longer accumulate across these expressions.
39
+
40
+ Next: the remaining wrapper atom classes, longer mixed expressions, explicit
41
+ spacing commands, and full painted-bound comparisons. Passing selected anchors
42
+ does not imply whole-expression pixel equality.
43
+
44
+
45
+ ## Contextual operator layout — workspace, 2026-09-10
46
+
47
+ The shared model-to-presentation pass now distinguishes display, text, script and
48
+ scriptscript operator contexts. React and DOM use it for small glyphs, nested
49
+ bound sizes and automatic side limits. Explicit limits remain supported.
50
+
51
+ New comparisons cover numerator/denominator operators, one/two levels of
52
+ superscripts, an operator inside another bound, inline/text fractions and an
53
+ explicit stacked inline integral. Full ink alignment, all multi-operator mixtures
54
+ and narrow-host/cross-browser checks remain separate work.
55
+
56
+ ## Radical and parenthesis outlines — workspace, 2026-09-10
57
+
58
+ Root strokes and short/tall parenthesis contours now use KaTeX-derived SVG masks.
59
+ Tall parentheses retain bounded end caps and extend the straight middle. The
60
+ package includes these assets with their provenance and existing KaTeX MIT notice.
61
+ This removes the old radical polygon without adding a KaTeX runtime dependency.
62
+
63
+ Full KaTeX size-variant selection, vertical brace silhouettes, operators inside
64
+ scripts and cross-browser geometry remain separate work. The renderer continues
65
+ to reserve its existing editing boxes and caret hit areas.
66
+
67
+ ## LaTeX compatibility and nested-root layout — workspace, 2026-09-10
68
+
69
+ - Fixed math-mode literal caret/tilde export while retaining text-run JSON semantics.
70
+ - Protected complex optional root indices during export; all 55 structure kinds
71
+ now have KaTeX render and JSON round-trip regression checks in that slot.
72
+ - Added clearance between nested radical rules and a browser gap measurement.
73
+ - Still open: radical hook outlines, fence ink geometry, operators inside scripts,
74
+ explicit style combinations, broader interaction sequences and other browsers.
75
+
76
+ These are workspace changes. Browser evidence remains in the source-only rendering
77
+ ledger; a metric PASS does not mean complete visual parity or release certification.
78
+
7
79
  ## Editing utilities — workspace, 2026-09-09
8
80
 
9
81
  Included in 0.4.0:
@@ -27,11 +99,11 @@ base-size and compact-spacing controls. See [Styling & themes](STYLING.md).
27
99
 
28
100
  ## Selection-to-caret keyboard behavior — workspace, 2026-09-09
29
101
 
30
- Both renderers now restore the caret when a plain arrow follows a Shift+arrow or
31
- pointer model selection. Left/Up uses the ordered start; Right/Down uses the end.
32
- Typing continues at that position without replacing the former range. Wrapping
33
- suggestions remain selectable with Alt+Up/Down or the pointer. The operation does
34
- not change the formula or create Undo entries.
102
+ A visible wrapping menu owns Up/Down in both renderers. The selected formula
103
+ stays selected while the highlighted suggestion changes; Enter applies it.
104
+ Left/Right returns to the ordered start/end of the selection. Shift+arrows
105
+ continues to adjust the range. Alt+Up/Down remains supported. When the wrapping
106
+ menu is closed, plain arrows restore the caret without changing the formula.
35
107
 
36
108
  ## Matrix rectangles and transpose — workspace, 2026-09-09
37
109
 
@@ -277,3 +349,58 @@ core and all nine plugins now use MIT, with a LICENSE file in each package.
277
349
  Plugin publication remains pending. See the [integration roadmap](../math-editor-integrations/ROADMAP.md),
278
350
  [validation record](../math-editor-integrations/VALIDATION.md), and
279
351
  [release guide](../math-editor-integrations/docs/RELEASING.md).
352
+
353
+ ## Radical conversions — workspace, 2026-09-09
354
+
355
+ Implemented contextual square-root/indexed-root conversion suggestions in React
356
+ and native DOM. The radicand tree and IDs are retained; conversion adds a selected
357
+ index `2`. Square-root conversion accepts only an empty index or `2`. Changes
358
+ participate in normal Undo/Redo and use English/Korean locale messages. Other
359
+ structure conversions are not included in this step.
360
+
361
+ ## Editing scenario register — workspace, 2026-09-09
362
+
363
+ [Editing scenarios](EDITING-SCENARIOS.md) defines EDIT-001 through EDIT-020,
364
+ expected behavior, test mappings, environment scope and a run-record template.
365
+ It distinguishes historical evidence from current verification. The EDIT-019
366
+ sustained chain and source-fingerprinted runner were added on 2026-09-10. Other
367
+ scenario assertions and CI/release enforcement remain separate work.
368
+
369
+ ## Rendering regression baseline — workspace, 2026-09-09
370
+
371
+ [Rendering checks](RENDERING-TESTS.md) now defines executable size and position
372
+ comparisons for fractional exponents/subscripts and a tall indexed-root base.
373
+ React and native DOM share compact script-fraction rules. Empty non-grid slots
374
+ now remove their wrapper with Delete or Backspace and retain other content.
375
+ Next: paired scripts, multi-line collision, explicit style overrides and other
376
+ notation families. Current checks do not implement an automated CI release gate.
377
+
378
+ ## Contextual structure footer — workspace, 2026-09-09
379
+
380
+ Added query-independent radical actions, index editing, disabled explanations,
381
+ F6/Escape access and embedding opt-out. EDIT-021 through EDIT-028 extend the
382
+ scenario register with discovery, target, focus, locale, composition guard and
383
+ lifecycle cases. Future work: context actions for additional structure families,
384
+ explicit Tab-order assertions and broader framework/device coverage.
385
+
386
+ ## Inline-first fence transformations — workspace, 2026-09-09
387
+
388
+ Implemented eight fence presentations through the existing suggestion list,
389
+ Alt+Down discovery/reopening, nearest-wrapper targeting, retained caret/content
390
+ and one-step conversion history. Optional footer controls support F6 and horizontal
391
+ navigation. EDIT-029 through EDIT-032 add keyboard, cancellation, iframe, locale
392
+ and no-toolbar coverage. Additional transformation families and the proposed
393
+ optional radial menu remain future work; the list layout remains the default.
394
+
395
+ ## Horizontal text spacing — workspace, 2026-09-10
396
+
397
+ Replaced fixed inter-token gaps with shared binary/relation/punctuation spacing,
398
+ including unary-sign context and compact script rows. Removed per-token padding
399
+ from mathematical glyph measurement. Empty expression inputs remain available;
400
+ inactive structural caret boundaries are narrower. VIS-066 through VIS-073 add
401
+ addition, equality, unary signs, parentheses, named functions, fractions,
402
+ punctuation and script comparisons at 22 px and 36 px in React and native DOM.
403
+
404
+ Next: longer expressions, complete atom classification across structure wrappers,
405
+ named-function boundaries, explicit spacing commands and browser font differences.
406
+ The source-only rendering ledger records measured limits and remaining work.