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] Bug Fix: standardise selection to move to start after markdown toggle #6220

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

potatowagon
Copy link
Contributor

@potatowagon potatowagon commented May 31, 2024

Description

standardise the cursor behavior after toggling markdown, it is observed that $convertToMarkdownString moves cursor to the start, so make $convertFromMarkdownString follow suit. see #6220 (comment)

also, executing @etrepum 's suggestion to add documentation to highlight that the selection (aka cursor) moves after the markdown operation, since it may not be an expected behavior

Closes #6177

Test plan

Before

see video in

https://github.com/facebook/lexical/pull/6220/files#r1627137045

After

Screen.Recording.2024-06-05.at.3.26.41.PM.mov

Copy link

vercel bot commented May 31, 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 Jun 5, 2024 7:38am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 7:38am

@potatowagon potatowagon marked this pull request as draft May 31, 2024 04:12
@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 May 31, 2024
Copy link

github-actions bot commented May 31, 2024

size-limit report 📦

Path Size
lexical - cjs 28.33 KB (0%)
lexical - esm 28.14 KB (0%)
@lexical/rich-text - cjs 36.77 KB (0%)
@lexical/rich-text - esm 28.1 KB (0%)
@lexical/plain-text - cjs 35.35 KB (0%)
@lexical/plain-text - esm 25.33 KB (0%)
@lexical/react - cjs 38.51 KB (0%)
@lexical/react - esm 29.12 KB (0%)

@potatowagon potatowagon changed the title [lexical-markdown] move selection to start instead of end [lexical-markdown] add documentation to highlight selection is moved to the end after markdown render Jun 5, 2024
@potatowagon potatowagon changed the title [lexical-markdown] add documentation to highlight selection is moved to the end after markdown render [lexical-markdown] standardise selection to move to start after markdown toggle Jun 5, 2024
@@ -189,7 +189,6 @@ export default function ActionsPlugin({
$createCodeNode('markdown').append($createTextNode(markdown)),
);
}
root.selectEnd();
Copy link
Contributor Author

@potatowagon potatowagon Jun 5, 2024

Choose a reason for hiding this comment

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

after removing this, we expose the selection behavior of $convertFromMarkdownString and $convertToMarkdownString.

$convertToMarkdownString moves the selector (aka cursor) to the start after the markdown -> string conversion.

demo:

Screen.Recording.2024-06-05.at.3.34.06.PM.mov

in this PR adjust $convertFromMarkdownString to do the same. Also the attached issue has raised a preference for having the cursor at the start instead of the end

@potatowagon potatowagon changed the title [lexical-markdown] standardise selection to move to start after markdown toggle [lexical-markdown] Bug FIx: standardise selection to move to start after markdown toggle Jun 5, 2024
@potatowagon potatowagon changed the title [lexical-markdown] Bug FIx: standardise selection to move to start after markdown toggle [lexical-markdown] Bug Fix: standardise selection to move to start after markdown toggle Jun 5, 2024
@potatowagon potatowagon added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit 0e168d1 Jun 7, 2024
38 checks passed
@potatowagon potatowagon deleted the md-selection branch July 26, 2024 05:50
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
3 participants