Skip to content

[lexical-text] Chore: Add deprecation notice to $findTextIntersectionFromCharacters - #8364

Merged
etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/deprecate-find-text-intersection-07jvx
Apr 17, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/deprecate-find-text-intersection-07jvx

Conversation

@etrepum

@etrepum etrepum commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Description

$findTextIntersectionFromCharacters doesn't work correctly and has no tests, usage, or documentation. Like the situation with @lexical/offset, it would be nice to have something like this, but it should be implemented correctly with an in-repo use case, tests, and documentation.

Test plan

N/A

@vercel

vercel Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 17, 2026 6:48am
lexical-playground Ready Ready Preview, Comment Apr 17, 2026 6:48am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 17, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Apr 17, 2026
@etrepum

etrepum commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator Author

Related #4103 (comment)

@etrepum
etrepum added this pull request to the merge queue Apr 17, 2026
Merged via the queue into meta:main with commit 4437e81 Apr 17, 2026
42 checks passed
@etrepum
etrepum deleted the claude/deprecate-find-text-intersection-07jvx branch April 19, 2026 02:32
@etrepum etrepum mentioned this pull request Apr 27, 2026
zurfyx added a commit that referenced this pull request Oct 31, 2026
…flank, as written, and leave every other export byte for byte as it was

## Description

Review follow-up. The first version decided per text node, from a model of the tags the export would write, which character to write as a reference. The model missed tags the export closes and opens again in one run (`****` between two nodes that share some formats), counted ASCII-only punctuation as CommonMark does not, stopped following one-character texts after 64 nodes, and could write a C1 control as a reference (`€`, which CommonMark reads as `€`). So it changed exports that already read back (`*(beta)***€**` got `€`) and broke one (`***😀****a\_b*`).

Now the export of a block's inline content is built as pieces (tags, the first and last character of each text node, everything else as written), and each run of tags is checked against the characters actually next to it. A run is changed only where it fails CommonMark's flanking rules both as CommonMark classes characters and as parsers that read UTF-16 units do (they disagree on emoji and other characters outside the Basic Multilingual Plane); then the letter or digit on the failing side is written as a reference, and the runs next to that character are checked again, over the whole block. Where this package's import, which counts only ASCII punctuation, would then see a reference next to a character it takes for a letter (`€`), that character is written as a reference too. Only letters, marks, digits, symbols and punctuation are ever written as references (never control characters). Markdown that every reading accepts as written is unchanged.

## Test plan

`EmphasisFlanking.test.ts` now reads every case back with this package's import and with a CommonMark parser (micromark, through @lexical/mdast), and adds the review's byte-identity controls (`*(beta)***€**`, `**a.***€*`, `*—***.**`), the emoji run parsers disagree on (unchanged), and a C1 control (unchanged); the properties run 1,500 random paragraphs through this package's import (ASCII punctuation, all formats) and through micromark (Unicode punctuation; bold, italic, strikethrough, code).

### Before

On 3f30041, with the review's repros and six parsers (commonmark.js, markdown-it, marked, micromark, micromark with GFM):

```
review Regressions: byte-identity controls fail (`*(beta)***€**` and two more), shared-format reference fails commonmark.js
review C1: `**Hello,**€` reads back as `€`
```

On main (c363dd9): review Contexts 9 of 15 and Chain 7 of 7 fail (the issue).

### After

```
$ vitest --run --project unit packages/lexical-markdown/src/__tests__/unit/EmphasisFlanking.test.ts
      Tests  20 passed (20)
$ LEXICAL_MARKDOWN_SEEDS=6000 vitest --run ... EmphasisFlanking.test.ts
      Tests  20 passed (20)

review repros on this head: Contexts 15/15, Chain 7/7 (16 to 256 one-character nodes), C1 5/5, Reference 1/1, Regressions: the three byte-identity controls and commonmark.js pass; micromark, markdown-it and marked read the shared-format case (`***😀****a\_b*`, byte for byte main's export) as main does.

$ pnpm run ci-check
EXIT 0
$ vitest --run --project unit --project scripts-unit
 Test Files  657 passed | 4 skipped (661)
      Tests  28189 passed | 424 expected fail | 135 skipped (28748)
```

A corpus of 6,000 random paragraphs (ASCII and Unicode punctuation, emoji, `*`, `_`, a C1 control; bold, italic, code), compared with main's export: 939 differ, none where main's export read back in all four parsers and this package's import; 0 parser regressions; 847 to 867 cases fixed per parser; this package's import fixed in 531 and broken in 1 (`*—\_***Bc:…`, where main's export failed every parser; this package's import misreads the run after the escaped `\_`; not investigated further).

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 969b4b05 Deployed Apr 17, 2026 by vercel[bot]
Preview – lexical — 969b4b05 Deployed Apr 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants