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] Fix: normalize markdown in $convertFromMarkdownString to comply with CommonMark spec (2nd try) #6629

Merged
merged 21 commits into from
Sep 13, 2024

Conversation

GermanJablo
Copy link
Contributor

@GermanJablo GermanJablo commented Sep 12, 2024

Description

See #6627

The only commits added since the first PR are:

  • fix single line code - fixed an additional bug that I noticed on the fly, where code blocks that started and ended on the same line left the flag open, causing subsequent lines to not be normalized.
  • fix table - fixed the problem with tables that @potatowagon mentioned

For both cases I added corresponding tests.

Copy link

vercel bot commented Sep 12, 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 13, 2024 7:48am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2024 7:48am

@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 12, 2024
Copy link

github-actions bot commented Sep 12, 2024

size-limit report 📦

Path Size
lexical - cjs 29.77 KB (0%)
lexical - esm 29.6 KB (0%)
@lexical/rich-text - cjs 38.24 KB (0%)
@lexical/rich-text - esm 31.46 KB (0%)
@lexical/plain-text - cjs 36.82 KB (0%)
@lexical/plain-text - esm 28.86 KB (0%)
@lexical/react - cjs 40.01 KB (0%)
@lexical/react - esm 32.93 KB (0%)

@potatowagon potatowagon added the extended-tests Run extended e2e tests on a PR label Sep 12, 2024
Co-authored-by: Bob Ippolito <bob@redivi.com>
@etrepum
Copy link
Collaborator

etrepum commented Sep 13, 2024

I can repro. Haven't looked at the code but there's a very bad performance issue in all browsers in that test case (hangs for >10 seconds on my laptop in chrome after the second click to the markdown button), but probably just bad enough that the firefox test fails.

npm run test-e2e-plain-firefox packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs:472:3
Screen.Recording.2024-09-12.at.17.58.25.mov

etrepum
etrepum previously approved these changes Sep 13, 2024
@potatowagon
Copy link
Contributor

potatowagon commented Sep 13, 2024

Screen.Recording.2024-09-13.at.12.06.25.PM.mov

lgtm for multi line seperation case,

but for single line + shouldPreserveNewLinesInMarkdown=true, it breaks

before

Screen.Recording.2024-09-13.at.12.15.50.PM.mov

after

Screen.Recording.2024-09-13.at.12.14.16.PM.mov

@@ -82,11 +83,12 @@ function $convertFromMarkdownString(
node?: ElementNode,
shouldPreserveNewLines = false,
): void {
const sanitizedMarkdown = normalizeMarkdown(markdown);
Copy link
Contributor

@potatowagon potatowagon Sep 13, 2024

Choose a reason for hiding this comment

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

can we add a condition here, to only normalizeMarkdown if shouldPreserveNewLines = false?

internally we are using the shouldPreserveNewLines = true feature and normalizeMarkdown is causing eg.

hello
hello

to convert to
hellohello

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should add some test coverage for this to prevent such regressions in the future

Copy link
Contributor

Choose a reason for hiding this comment

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

added in d58c159

etrepum and others added 2 commits September 12, 2024 23:04
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.

4 participants