-
Notifications
You must be signed in to change notification settings - Fork 102
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
fix(ui-markdown-editor): linebreak - #263, #267, #269 #270
base: main
Are you sure you want to change the base?
Conversation
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.
We'll need to do a thorough investigation on all of this to see what is going on, the limitations, and what these changes do.
@irmerk That is great. Will that take very long? Should I write the description of changes and limitations in more detail? |
@@ -91,17 +90,26 @@ export const insertThematicBreak = (editor, type) => { | |||
Transforms.insertNodes(editor, tBreakNode); | |||
}; | |||
|
|||
export const insertLinebreak = (editor, type) => { | |||
export const insertSoftBreak = (editor, type) => { | |||
const text = { object: 'text', text: '' }; | |||
const br = { type, children: [text], data: {} }; |
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.
Why take type
as an argument if this is just for soft break?
Yeah I think so. This is a sensitive change, so as much helpful context would be great. |
@dselman @irmerk I have updated the pull-request body and added more context highlighting the problem. Does this bring more clarity? Ask me any question that comes to your mind or regarding anything that was unclear. |
When I test this using the Netlify preview there's something strange happening with the selection. Try selecting multiple paragraphs forwards, or backwards, and you see that the selection is getting extended outside of the selection target. |
@dselman I don't see that behavior. Can you make a screen recording to show exactly what is strange? |
@d-e-v-esh |
It seems to be specific to Safari - I don't see it on Chrome. |
@K-Kumar-01 Is this happening only on this update or is this on the master branch? You cut out the URL. |
@d-e-v-esh |
@K-Kumar-01 That is actually a really bad bug. I'll see what is causing the problem and update. |
@dselman Can you show which merge started converting blank lines to |
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.
We still haven't found time yet, but this needs investigation by @accordproject/maintainers-ui.
In the meantime @d-e-v-esh you could rebase all your commits to clean them up and put DCO signoffs on them.
77aa58b
to
495045d
Compare
@irmerk Does this look good now? |
Yes looks good. I think wait to rebase again (because there are conflicting files after I merged a couple other PRs) until we review. |
I've finally been able to look more into this. This is really thorough and I think is on the right track. Some residual awkward behavior I'm seeing is when you press ENTER at the end of "My Heading" at the top of the demo, it inserts two new paragraphs, both of which are not headings, and places the cursor at the beginning of the second one. Could this be because we are inserting |
OH yes! Good point. There's so many related Issues/PRs here I'm getting confused. Okay great, even better. This PR looks good so I'm going to merge! |
@d-e-v-esh we're going to put the changes in this PR on the working group call tomorrow to try to make sure it doesn’t lead to further confusion around linebreaks/softbreaks. If you’ll be on during the call, feel free to add to the conversation. If not, I think @dselman and I can present what the changes will do. |
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 looks very clean - however when I try the Netlify preview and I forward-select past a line break something strange happens with the selection (whole blocks get selected). I can't reproduce the same issue with the master: https://ap-web-components.netlify.app/?path=/story/markdown-editor--demo
Sorry, no idea. Can you reproduce the issue when you run locally using this branch? |
@dselman Yes I can. It doesn't go back to when this was not happening. |
Update: This PR should no longer address #267 |
@irmerk I have implemented the new |
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.
Yes, this looks good to me! Will want @dselman on this as well.
Pinging @dselman on this again. |
@d-e-v-esh looks great. Can you please resolve the merge conflicts and then I will merge. |
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.
Looks great. Please resolve the merge conflicts and I will merge.
Would love to get this into the next release (this week). @d-e-v-esh will you have time to resolve the merge conflicts? |
@d-e-v-esh Any Updates on this? If not, I would love to fix it up and send a PR |
@adithyaakrishna Got extremely busy. I'll get to it in a few days. You can find other issues. This PR is complete, just needs the merge conflicts to be resolved. |
…rdproject#260 Signed-off-by: d-e-v-esh <[email protected]>
dc4c014
to
e9e71ec
Compare
…#267 Signed-off-by: Devesh <[email protected]>
@dselman I removed all the merge conflicts and it works totally great. You can check it out. |
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.
lgtm, thanks @d-e-v-esh !
Closes #263 #267
Update
This was my thought process of finding the problem and the solution.
Identifying the problem
As you can see here, we do not have any function for the
softbreak
.The functions that exist there are
insertLinebreak
andinsertHeadingbreak
.So I thought that maybe
softbreak
was not working because there is no function for it. But that is actually not the case.The
softbreak
was not working because of this conditional statement here. This basically means that ifEnter
is being pressed from a non-heading block then we totally skip out hotkey actions. That is also the reason why pressingCtrl
+Enter
did not inset a page break. If you remove that statement thensoftbreak
and page break works like normal.And this should TOTALLY prevent us from getting a
linebreak
in a paragraph. And the only reason pressingEnter
is still functional is because of this and this functions where we are overridinginsertBreak()
. You can put a fewconsole.log()
there and check which functions work and which do not.That is also the reason why inserting a page break (
Ctrl
+Enter
) andsoftbreak
(Shift
+Enter
) works absolutely fine for all the heading blocks because this conditional statement only restricts non-heading blocks from all theEnter
functions.Exchange in types of
break
BuginsertLinebreak
andinsertHeadingbreak
.console.log()
statement after this line like this:By doing this, we get:
Here:
Pressing
Enter
results in a =>headingbreak
Pressing
Shift
+Enter
results in a =>linebreak
This is the case because this is how it is mentioned in the
hotkeys
file as you can see here.Shift
+Enter
is creating asoftbreak
as it should but it is named as alinebreak
andEnter
is always creating a falseheadingbreak
no matter the type of block. It is falseheadingbreak
and does not do anything because of the problem I mentioned above that is pressingEnter
is useless in a non-heading block because of this conditional statement hereWhat is happening till now:
Every time we press Enter, a heading break is going to get inserted.
How it was implemented was:
enter
keyword when being pressed from a non-heading block. This was causing Page break shortcut does not work consistently #263headingblock
then we will go to our custom hotkeyActions and create a heading breakenter
is called from a non - heading block then we will skip our custom hotkeyActions and a default enter linebreak will occurChanges
headingbreak
to linebreakheadingbreak
Related Issues
Author Checklist
--signoff
option of git commit.master
fromfork:branchname