Skip to content

[lexical-markdown] Fix: bugs in normalizeMarkdown#7812

Merged
etrepum merged 18 commits intofacebook:mainfrom
GermanJablo:fix-normalizeMarkdown
Oct 16, 2025
Merged

[lexical-markdown] Fix: bugs in normalizeMarkdown#7812
etrepum merged 18 commits intofacebook:mainfrom
GermanJablo:fix-normalizeMarkdown

Conversation

@GermanJablo
Copy link
Copy Markdown
Contributor

@GermanJablo GermanJablo commented Sep 10, 2025

Description

Fixes some bugs when using shouldMergeAdjacentLines. Namely:

  1. In Markdown, lines must be trimmed.
  2. When shouldMergeAdjacentLines is true, lines must be separated by a space.
  3. Errors when using shouldMergeAdjacentLines with mdx (see playground).

The tests I modified mostly had a link to the commonmark playground, demonstrating the first two behaviors.

Test plan

I added some additional tests and corrected others that were incorrect.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 16, 2025 10:37am
lexical-playground Ready Ready Preview Comment Oct 16, 2025 10:37am

@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 Sep 10, 2025
@GermanJablo GermanJablo changed the title [lexical-markdown] Fix: errors in shouldMergeAdjacentLines [lexical-markdown] Fix: bugs in normalizeMarkdown Oct 15, 2025
@etrepum etrepum added this pull request to the merge queue Oct 16, 2025
Merged via the queue into facebook:main with commit 3b605c7 Oct 16, 2025
39 checks passed
This was referenced Oct 27, 2025
GermanJablo added a commit to payloadcms/payload that referenced this pull request Mar 2, 2026
## Summary

Upgrades the lexical dependency from 0.35.0 to 0.41.0.

Keeping up with Lexical releases avoids accumulating too large a gap,
which makes future upgrades risky and time-consuming. This upgrade also
brings in the upstream `normalizeMarkdown` fix
([facebook/lexical#7812](facebook/lexical#7812)),
which means we can eventually drop our vendored copy of that function.

If you installed lexical manually, update it to 0.41.0. Installing
lexical manually is not recommended, as it may break between updates,
and our re-exported versions should be used. See the [yellow banner
box](https://payloadcms.com/docs/rich-text/custom-features) for details.

If you still encounter richtext-lexical errors, do the following, in
this order:

- Delete node_modules
- Delete your lockfile (e.g. pnpm-lock.json)
- Reinstall your dependencies (e.g. pnpm install)

## Lexical Breaking Changes

The following Lexical releases contain breaking changes. We recommend
reading them if you're using Lexical APIs directly
(`@payloadcms/richtext-lexical/lexical/*`).

- [v0.41.0](https://github.com/facebook/lexical/releases/tag/v0.41.0) —
`--lexical-indent-base-value` CSS custom property is now only read from
the editor root element, not from indented elements. **Payload already
handles this change internally** — no action required.
- [v0.39.0](https://github.com/facebook/lexical/releases/tag/v0.39.0) —
`ElementNode` JSON serialization: `textFormat` and `textStyle` are now
only serialized when necessary (when the node has no direct TextNode
children). May affect code that reads these properties from serialized
data.
- [v0.38.0](https://github.com/facebook/lexical/releases/tag/v0.38.1) —
Static transforms from superclasses are now always applied. Table
selection handler priorities lowered from CRITICAL to HIGH.
- [v0.36.1](https://github.com/facebook/lexical/releases/tag/v0.36.1) —
`DecoratorNode.decorate()` return type widened to `null | T`.
Collaboration context changes (not used by Payload).

None of these breaking changes require action from Payload users under
normal usage.

## Changes

- Bump all `@lexical/*` and `lexical` from 0.35.0 to 0.41.0
- Update `lexicalTargetVersion` constant
- Move `--lexical-indent-base-value` CSS variable from
`.LexicalEditorTheme__indent` to the `.LexicalEditorTheme` root selector
(v0.41.0 breaking change)
- Update `textFormat` test expectations for inline code paragraphs
(v0.39.0 serialization change)
- Update pnpm-lock.yaml

## Previous Lexical Upgrades

- [#13715](#13715) — 0.34.0 →
0.35.0
- [#13622](#13622) — 0.28.0 →
0.34.0
- [#11764](#11764) — 0.27.2 →
0.28.0
- [#11564](#11564) — 0.21.0 →
0.27.1
tadjh added a commit to digitalgroundgame/pragmatic-papers that referenced this pull request Mar 18, 2026
## Context

### BREAKING CHANGES:
The only listed breaking changes are in payload 3.79.0. Two of them.
>- rename widget ComponentPath to Component for consistency
([#15780](payloadcms/payload#15780))
([f7d0d04](payloadcms/payload@f7d0d04)
- Renames `Widget.ComponentPath` to `Widget.Component` and types it as
PayloadComponent`instead of`string`
- This aligns dashboard widgets with every other component reference in
(collections, globals, fields, admin components) - none of them _path_
in the property name, and all of them are typed as `PayloadComponent`
- Enables new [typescript
plugin](payloadcms/payload#15779) to work for
widget paths (the plugin uses `PayloadComponent` contextual type
detection - `string`-typed properties were invisible to it)
> - **ui:** typo in CodeEditor export statement
([#15795](payloadcms/payload#15795))
([c5b2a91](payloadcms/payload@c5b2a91))

>**Lexical Upgrade 0.35.0 → 0.41.0 (richtext-lexical)** — Upgrades the
Lexical rich text editor dependency from v0.35.0 to v0.41.0. Includes
upstream fixes like `normalizeMarkdown`
([facebook/lexical#7812](facebook/lexical#7812)).
All Lexical breaking changes are handled internally by Payload — no
action required for standard usage. If you installed `lexical` manually,
update it to 0.41.0 (though using the re-exported versions from
`@payloadcms/richtext-lexical/lexical/*` is recommended).
[#15760](payloadcms/payload#15760)

### Anaylsis of codebase vs breaking changes
Project does not currently define any custom dashboard widgets in
payload.config.ts, we are using the default payload dashboard.

codebase already correctly imports Lexical types via
@payloadcms/richtext-lexical/lexical (which is the recommended pattern)

CodeEditor, we are not importing or using the CodeEditor component

# Changes Made
Downgraded `next`: 15.5.9 → 15.4.11
Upgraded `lucide-react`: 0.378.0 → ^0.471.0 (latest)
Upgraded `baseline-browser-mapping` (latest)
Remove `lexical` dependency
### Further analysis after upgrade using gemini
#### 1. Payload CMS Compatibility Gap

Payload CMS 3.x relies on internal Next.js routing behaviors that were
altered in version 15.5. Staying on `15.5.9` introduced:

- **Build Failures**: Next.js 15.5's new strict TypeScript route
validation rejects Payload's auto-generated API route types
(specifically the `RouteHandlerConfig`).
    
- **Admin UI Slowness**: Documented performance regressions in 15.5
cause the Payload Admin panel to experience massive load-time spikes
(reported jumps from 2s to 30s+).

	OLD dev tested by espdesign
	` ✓ Compiled /admin/[[...segments]] in 5.5s (6831 modules)`
	NEW dev tested by espdesign
	` ✓ Compiled /admin/[[...segments]] in 9s (7912 modules
    
- **HMR Instability**: Turbopack HMR in 15.5 frequently fails to find
client modules in the manifest, leading to frequent "Module not found"
errors during development.
    
**Result**: Reverting to **15.4.11** restores the "Stable Zone" for
Payload 3.x, ensuring fast Admin UI performance and successful
production builds.

#### 2. React 19 Peer Conflict

The previous version of `lucide-react` was hard-coded to expect React 18
or older.

- **Fix**: Upgrading to the latest version of `lucide-react` adds
official support for **React 19**, resolving the peer dependency
warning.

Further changes:
```
`[baseline-browser-mapping] The data in this module is over two months old.  To ensure accurate Baseline data, please update: `npm i baseline-
browser-mapping@latest -D
```

### Migrations:
No :)
```
[22:04:26] INFO: Migration DOWN statements generation complete.
✔ No schema changes detected. Would you like to create a blank migration file? … no
```


## Test Plan
Confirm on staging.
Confirm on dev.

---------

Co-authored-by: tadjh <hello@tadjh.com>
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.

2 participants