-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[lexical-markdown][lexical-playground] Bug Fix: Keep indent when switching with markdown #7845
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
Open
lytion
wants to merge
18
commits into
facebook:main
Choose a base branch
from
lytion:lytion/indet-lost-when-switching-markdown
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
10027d5
Add Indent Transformer
lytion e9aacd5
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion c02ef17
Remove unused import
lytion e2a6712
Fix prettier error
lytion fe76540
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 4c2a215
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
SimonBct f93caa9
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
SimonBct c93f030
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 8cec7f1
Separate INDENT transformer from default one
SimonBct 4eca17d
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
SimonBct 81deb22
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 6c6b36d
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion b8a5dcd
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 6bec51f
Refactor key comparison
lytion 74fec50
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 18faefc
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion fdc8092
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion 3754f15
Merge branch 'main' into lytion/indet-lost-when-switching-markdown
lytion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like maybe there's a bug elsewhere because tabs are usually supposed to use TabNode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this PR was updated with main but this comment hasn't been addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed the comment.
I think you're right, when clicking on "left indent" button in normal mode, there's no
INDENT_CONTENT_COMMANDwhich I believe should happen and therefore should add a TabNode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make sure we're on the same page.
From what I see:
Markdown use \t for indent and tab key.
CodeHighlight convert \t into TabNode when converting to markdown.
Nodes use __indent and TabNode.
Here the transformer set the correct number of indent and remove all \t found from the start of the line.
If I understand correctly, what you're talking about is to convert all \t into TabNode even if CodeHighlight is disabled.
I can create a TAB transformer that does that, but maybe that's a separate issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking there should never be '\t' or a '\n' in a TextNode, anything that creates a TextNode with those characters in the contents probably has a bug. The solution isn't a transformer, it's to fix the code that's creating those TextNodes. I don't think there is currently a helper to do this other than RangeSelection.insertRawText but one could be added to make this a little easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a quick and dirty refactor but is this the direction you are thinking about ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to say without a thorough audit of that code but probably something like that. It might be the case that it’s better to fix it up afterwards in the markdown case depending on how that code works.