Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical-markdown] shouldMergeAdjacentLines as an option #6642

Merged
merged 8 commits into from
Sep 20, 2024
Merged

Conversation

potatowagon
Copy link
Contributor

@potatowagon potatowagon commented Sep 18, 2024

Description

normalize markdown was introduced in #6629 . one of the significant behavior change this introduced is merging adjacent non empty lines, according to commonmark spec: https://spec.commonmark.org/0.24/#example-177

it is a welcomed change since that brings lexical's impl closer to commonmark. However to avoid breaking current callsites, im making the normalizedMarkdown an option default to true, so it is easier to rollback incase this new behavior causes a regression somewhere downstream

ultimately, if there is no known usecase to have shouldMergeAdjacentLines = false, will look to deprecate shouldMergeAdjacentLines and have it always be true.

Test plan

shouldMergeAdjacentLines = true

Screen.Recording.2024-09-18.at.6.09.06.PM.mov

shouldMergeAdjacentLines = false

Screen.Recording.2024-09-18.at.6.11.26.PM.mov

added automated tests

Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 3:06am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 3:06am

@facebook-github-bot facebook-github-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 18, 2024
@potatowagon potatowagon marked this pull request as draft September 18, 2024 09:55
Copy link

github-actions bot commented Sep 18, 2024

size-limit report 📦

Path Size
lexical - cjs 29.85 KB (0%)
lexical - esm 29.66 KB (0%)
@lexical/rich-text - cjs 38.3 KB (0%)
@lexical/rich-text - esm 31.55 KB (0%)
@lexical/plain-text - cjs 36.9 KB (0%)
@lexical/plain-text - esm 28.86 KB (0%)
@lexical/react - cjs 40.04 KB (0%)
@lexical/react - esm 32.91 KB (0%)

html: '<p><span style="white-space: pre-wrap;">helloworld</span></p>',
md: 'hello\nworld',
shouldNormalizeMarkdown: true,
skipExport: true,
Copy link
Contributor Author

@potatowagon potatowagon Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipping export because:

string -> md -> string
(string)

hello 
world

to (md)helloworld
to (string)helloworld

does not convert back to
(string)

hello 
world

Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldPreserveNewLines is a specific flag while shouldNormalizeMarkdown is very high-level, I don't think they play well with each other and the code shows how we have to chain conditions to make it work.

I would consider targetting the specific parts of the MarkDown we don't want to normalize as opposed to the normalize function as a whole which is an internal implementation.

@potatowagon potatowagon changed the title [lexical-markdown] shouldNormalizeMarkdown as an option [lexical-markdown] shouldMergeAdjacentLines as an option Sep 19, 2024
@potatowagon
Copy link
Contributor Author

shouldPreserveNewLines is a specific flag while shouldNormalizeMarkdown is very high-level, I don't think they play well with each other and the code shows how we have to chain conditions to make it work.

I would consider targetting the specific parts of the MarkDown we don't want to normalize as opposed to the normalize function as a whole which is an internal implementation.

good point, i updated to shouldMergeAdjacentLines instead and placed its in a specific place in normalise markdown

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants