[lexical-playground] Bug Fix: include font sizes in pt as well in parseAllowedFontSize#7719
[lexical-playground] Bug Fix: include font sizes in pt as well in parseAllowedFontSize#7719etrepum merged 11 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
etrepum
left a comment
There was a problem hiding this comment.
Tests and lint are failing
etrepum
left a comment
There was a problem hiding this comment.
Tests are still failing
|
You can test the behavior of the playground with e2e tests. I do not think the default behavior of TextNode should be changed |
Test verifies font-size handling when copying content from Google Docs/Word and pasting into Lexical.
|
oh looks like some other tests related to copy paste are failing now 😢 |
|
Yes it looks like other tests are expecting the font-size in pt to be ignored on paste, so those expectations would have to change. |
fix tests by style updates for HTML tables and text format in CopyAndPaste specs.
On closer inspection, the toolbar's size is not displayed correctly when the font-size is in pt
etrepum
left a comment
There was a problem hiding this comment.
When inspecting the playground for this I noticed that the toolbar displays the raw number associated with the font-size, the number parsing should be used for this functionality as well.
<FontSize
selectionFontSize={toolbarState.fontSize.slice(0, -2)}
editor={activeEditor}
disabled={!isEditable}Here's a playground link for this PR with some content that uses pt font sizes
In e2e tests and font size plugin, update font sizes to pixels for better rendering.
yes |
|
It looks like some tests are failing because the font-size is a floating point and the precision is different depending on the browser |
|
oh okay I got that. I am thinking to keep font-size in style in pt only. Just round off pt value to nearest px value in toolbar |
|
Yes handling it in a different way in the toolbar will likely work, the parsing should be split into two functions so the toolbar code can just get the px value as a number |
|
Yes agree, I made changes for that |
|
The formatting check is failing |
etrepum
left a comment
There was a problem hiding this comment.
This isn't really how I would've split things up, there are three operations here:
- Parse a font-size as
[fontSize, unit]for certain known units (pt, px) - Normalize that
[fontSize, unit]to a numericpxvalue (fontSizePx) - Validate whether that fontSize falls in the range of allowed sizes
The parseFontSizeForToolbar function needs to do steps 1 and 2 and return the value from 2, but by calling parseAllowedFontSize it has to do all of the steps and then basically repeats steps 1 & 2.
The parseAllowedFontSize function needs to do all of the steps and return the input or an empty string if validation fails.
Fixes #13386 Below I write a clarification to copy and paste into the release note, based on our latest upgrade of Lexical [in v3.29.0](https://github.com/payloadcms/payload/releases/tag/v3.29.0). ## Important This release upgrades the lexical dependency from 0.28.0 to 0.34.0. If you installed lexical manually, update it to 0.34.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 describe breaking changes. We recommend reading them if you're using Lexical APIs directly (`@payloadcms/richtext-lexical/lexical/*`). - [v.0.33.0](https://github.com/facebook/lexical/releases/tag/v0.33.0) - [v.0.30.0](https://github.com/facebook/lexical/releases/tag/v0.30.0) - [v.0.29.0](https://github.com/facebook/lexical/releases/tag/v0.29.0) ___ TODO: - [x] facebook/lexical#7719 - [x] facebook/lexical#7362 - [x] facebook/lexical#7707 - [x] facebook/lexical#7388 - [x] facebook/lexical#7357 - [x] facebook/lexical#7352 - [x] facebook/lexical#7472 - [x] facebook/lexical#7556 - [x] facebook/lexical#7417 - [x] facebook/lexical#1036 - [x] facebook/lexical#7509 - [x] facebook/lexical#7693 - [x] facebook/lexical#7408 - [x] facebook/lexical#7450 - [x] facebook/lexical#7415 - [x] facebook/lexical#7368 - [x] facebook/lexical#7372 - [x] facebook/lexical#7572 - [x] facebook/lexical#7558 - [x] facebook/lexical#7613 - [x] facebook/lexical#7405 - [x] facebook/lexical#7420 - [x] facebook/lexical#7662 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211202581885926


Description
Describe the changes in this pull request
Consider font sizes in pt as well along with px in
parseAllowedFontSizeas most of editors like Google docs and MS word export font-sizes in pt when copied contentCloses #7718
Closes #7726
Test plan
tests added for custom font-size in HTMLCopyAndPaste.test.ts
Before
Screen.Recording.2025-07-22.at.5.53.43.PM.mov
After
Screen.Recording.2025-07-22.at.5.54.26.PM.mov