Skip to content

feat: typo correction in the Lexical editor (Phase 2)#1321

Open
sh1nj1 wants to merge 2 commits into
mainfrom
feat/typo-correction-phase2
Open

feat: typo correction in the Lexical editor (Phase 2)#1321
sh1nj1 wants to merge 2 commits into
mainfrom
feat/typo-correction-phase2

Conversation

@sh1nj1

@sh1nj1 sh1nj1 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Phase 2 — typo correction in the inline Lexical editor

Builds on Phase 0+1 (#1317, merged). Extends server-side typo correction from the chat composer to the inline creative editor.

What it does

  • New Lexical plugin paints typo suggestions in the editor, gated by the existing 2D profile: device (voice/soft-keyboard) AND location — the 크리에이티브 편집기 / Creative editor toggle (default off).
  • Same UX as the chat composer: 2-state highlight (auto-applied = faint solid underline; candidate = dotted amber), creatable-combobox popup (Enter = keep, type = custom option, select original = undo).
  • No backend changes — the endpoint already accepts location: "editor" and typo_correction_in_editor already exists.

Markdown-canonical safety (headline guarantee)

The highlight is a volatile DOM overlay over the contenteditable, drawn from live DOM Range rects. The editor state is never mutated to hold a mark, so $convertToMarkdownString (canonical storage) never sees a highlight. Only real corrections mutate the editor (undoable via history). Verified by a unit test on a real headless Lexical editor.

Code blocks, inline code, and link text are excluded (protected spans), matching the server's skip ranges.

Files

  • lib/lexical_typo_text.js — pure offset↔node mapping (flat text + segment map), 11 unit tests
  • components/plugins/typo_correction_plugin.jsx — the plugin + overlay controller, unit tests (collection / auto-apply / markdown-safety)
  • lib/typo_popup.js — combobox popup extracted and now shared with Phase 1 (de-duplicated)
  • lib/typo_settings.js — shared #comments-popup dataset reader
  • reuses the pure core (anchorEdits/partitionByThreshold/shouldRun/detectDevice)

Tests

  • 388 JS tests pass (incl. refactored Phase 1 suite + new Phase 2 suites).

Known limitations (documented)

  • A typo span straddling multiple text nodes (e.g. a bolded middle letter) is skipped rather than mis-edited.
  • jsdom has no layout engine, so overlay rect positioning/clicking is verified in a real browser, not jsdom.

Not in scope (Phase 3)

Device-detection refinement, user dictionary, additional languages.

Extends server-side typo correction to the inline creative editor (location
'editor', gated by the existing 'creative editor' toggle, default off).

The highlight is a volatile DOM overlay over the contenteditable, drawn from
live DOM Range rects — the editor state is never mutated to hold a mark, so
markdown-canonical storage never serializes a highlight. Only real corrections
mutate the editor (and are undoable via history). Code blocks, inline code, and
link text are excluded (protected spans).

- lib/lexical_typo_text.js: pure offset<->node mapping (flat text + segment map)
- components/plugins/typo_correction_plugin.jsx: the Lexical plugin + overlay
- lib/typo_popup.js: combobox popup extracted and shared with Phase 1
- lib/typo_settings.js: shared #comments-popup dataset reader
- reuses the pure core (anchorEdits/partitionByThreshold/shouldRun/detectDevice)

No backend changes — the endpoint already accepts location 'editor'.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

…phase2

# Conflicts:
#	engines/collavre/app/javascript/modules/creative_row_editor.js
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