Sitelet https://github.com/overleaf/overleaf/pull/1515
Skip to content

Equation editor - #1515

Open
davrot wants to merge 6 commits into
overleaf:mainfrom
davrot:equation_editor
Open

davrot wants to merge 6 commits into
overleaf:mainfrom
davrot:equation_editor

Conversation

@davrot

@davrot davrot commented Aug 28, 2026

Copy link
Copy Markdown

Description

Screenshot_2026-08-28_01-57-07 Screenshot_2026-08-28_01-57-28 Screenshot_2026-08-28_01-57-58 Screenshot_2026-08-28_01-58-19 Screenshot_2026-08-28_01-59-50

Related issues / Pull Requests

Contributor Agreement

This is human guided AI (mainly qwen3.8; a bit of VS code copilot AI code might be left) and hence can not be copyrighted. You can do with the code what what ever you want.

davrot added 6 commits August 27, 2026 18:05
…0765f

Transplants the live equation-editor surface from the old CE+ checkout
(commit 620765f) into the current CE upstream tree, restyled to the
current Overleaf design system:

- modules/latex-editor: toolbar button (sourceEditorToolbarEndButtons),
  equation editor modal (OLModal/OLButton/OLFormSelect), MathLive input
  with textarea fallback, 513-command search data, pure utils with
  unit tests (modules/latex-editor/test/unit)
- math-preview tooltip: gated 'Open in Equation Editor' menu item
  (feature ol-latexEditorAvailable, was unconditional upstream)
- mathlive 0.110.0 bundled locally (npm + CSS + KaTeX fonts copied to
  js/libs/mathlive-0.110.0/fonts; no CDN loads at runtime), version pin
  in PackageVersions with webpack sync check
- i18n keys added to locales/en.json; CM access via
  useCodeMirrorViewContext instead of the old DOM hooks
- dead code from the old commit NOT ported (symbol-palette.tsx,
  templates-sidebar.tsx, 15 category data files) - see
  references/latex-editor-transplant-plan.md
mathlive's package.json is not exposed by its exports map, so
require('mathlive/package.json') throws ERR_PACKAGE_PATH_NOT_EXPORTED
and breaks the webpack config load (caught by pre-build review).
Live feedback round: raw i18n keys, import failure, blocking modal,
stuck virtual keyboard, lost drag/minimize, trailing spaces on export.

- Root cause of raw keys: webpack translations-loader filters locale
  JSON down to keys listed in frontend/extracted-translations.json;
  regenerate with yarn extract-translations (all 27 module keys now
  extracted) and add the 8 v5 strings to locales/en.json
- Restore the old commit's non-blocking floating window (draggable,
  minimize/restore, no backdrop/focus-trap) so the MathLive virtual
  keyboard on document.body stays usable; z-indexes from the old
  stylesheet (.ML__keyboard above .latex-editor-modal-root)
- Import now handles both a non-empty selection and an
  equation-under-cursor (mathAncestorNode/parseMathContainer, same
  extraction the math preview tooltip uses); CM access stays on
  CodeMirrorViewContext
- wrapLatex trims whitespace and leading/trailing MathLive
  text-space tokens (\text{ }); unit tests added
- mathlive-input back on the proven init flow using debugConsole
MathLive CSS, nested font copy

- 'Open in Equation Editor': the toolbar button listens on window
  (useEventListener hook) but the tooltip dispatched a non-bubbling
  document event that never arrived; dispatch now bubbles
- mathlive/static.css (math-field + KaTeX font-faces) was missing from
  the v5 stylesheet rewrite; restore the @import
- CopyPlugin nested the KaTeX fonts into fonts/fonts/ while MFE.fontsDirectory
  pointed at the outer dir (404 -> CDN fallback); copy to
  js/libs/mathlive-<version> so files land at <version>/fonts/
Implements the round-3 acceptance criterion: 'import an equation (or
open it via Open in Equation Editor) and press Export directly
afterwards - the equation with its environment is intact and the same'.

- splitEquation(): pure util that splits an equation as it appears in
  the document into body + wrapper ($...$ -> inline, $$/\[ \] ->
  display, \begin{equation*?} -> equation, \begin{eqnarray*?} ->
  eqnarray); no fence -> new default wrapper 'inline'
- modal default export wrapper is now 'inline'; pre-loaded content and
  imports are split into body (math-field) + detected environment
  (select), so wrapLatex(body, wrapper) reproduces the original
- 'Open in Equation Editor' dispatches the equation's document range;
  the button selects that range once open (visible mark), so Export
  replaces the original equation exactly; clicking elsewhere moves the
  selection and Export then inserts at the new cursor (no stale ranges)
- tooltip canonicalises display math to \[...\] (the display wrapper
  form) before dispatch
- 10 new unit tests incl. round-trip canonical-form checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant