Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

feat(markdown-editor) : SHIFT+ENTER inserts a linebreak #188

Merged
merged 3 commits into from
Sep 14, 2020

Conversation

dselman
Copy link
Contributor

@dselman dselman commented Sep 11, 2020

Signed-off-by: Dan Selman danscode@selman.org

Closes #153

Also: #182
Also: #49
Also: #41

Changes

  • Adds a keyboard handler for SHIFT+ENTER which inserts a LINEBREAK into the Slate DOM

Flags

  • HTML copy/paste requires a fix in markdown-html

Screenshots or Video

https://www.loom.com/share/a1458a6fece0468088e2fef776e99d8f

Signed-off-by: Dan Selman <danscode@selman.org>
@jolanglinais
Copy link
Member

Screen Shot 2020-09-11 at 8 19 12 AM

@jolanglinais
Copy link
Member

One issue is you are unable to exit a block quote with pressing ENTER twice.

Copy link

@Michael-Grover Michael-Grover left a comment

Choose a reason for hiding this comment

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

lgtm

@DianaLease
Copy link
Member

One issue is you are unable to exit a block quote with pressing ENTER twice.

I can reproduce this too. In the deployed version, we are able to exit block quotes by hitting enter twice. In this one, we aren't. Exiting lists by hitting enter twice still works.

@Michael-Grover Michael-Grover self-requested a review September 11, 2020 13:38
@Michael-Grover
Copy link

Pressing shift+enter right before a Clause Template causes an error

https://www.loom.com/share/fea2e40ff37d4ddfb885e90cc00854df

image

@Michael-Grover
Copy link

Michael-Grover commented Sep 11, 2020

actually I'm getting this error more than just when I press shift+enter before a Clause Template, is anyone else experiencing this?

@dselman
Copy link
Contributor Author

dselman commented Sep 13, 2020

actually I'm getting this error more than just when I press shift+enter before a Clause Template, is anyone else experiencing this?

Can you create a new issue for this please? It sounds like this is not a regression introduced by this PR.

@dselman
Copy link
Contributor Author

dselman commented Sep 13, 2020

The issue breaking out of block quotes seems to be related to:
https://github.com/accordproject/web-components/blob/master/packages/ui-markdown-editor/src/lib/plugins/withLists.js

(It's pretty confusing that the withLists plugin is dealing with block quotes imo and that this is mixed up with hotkeys).

@DianaLease @irmerk I don't remember writing this — do either of you understand how this code works? It appears to be sensitive to the presence of the LINEBREAK node (which also have empty text), because breaking out of block quotes works until you insert a LINEBREAK, then it no longer works.

Signed-off-by: Dan Selman <danscode@selman.org>
@dselman
Copy link
Contributor Author

dselman commented Sep 14, 2020

Pushed a fix to the problem breaking out of block quotes. The issue appears to be that after we insert a linebreak we get text nodes that don't have "object" : "text" set, so I've added some defensive checks for this.

Copy link
Member

@DianaLease DianaLease left a comment

Choose a reason for hiding this comment

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

This fixes the escaping block quote issue! Looks like we need to also fix the issue Michael mentioned. I can reproduce getting this error in the Contract Editor component when hitting shift+enter:

Cannot read property 'src' of undefined

@DianaLease
Copy link
Member

This fixes the escaping block quote issue! Looks like we need to also fix the issue Michael mentioned. I can reproduce getting this error in the Contract Editor component when hitting shift+enter:

Cannot read property 'src' of undefined

I think it is specific to this PR as I can only reproduce it in the netlify for this PR. @Michael-Grover, what did you mean by actually I'm getting this error more than just when I press shift+enter before a Clause Template? Can you only reproduce it by hitting shift + enter in other places or by doing things besides shift + enter? And can you reproduce it in the currently deployed version of web-components?

@Michael-Grover
Copy link

I can reproduce it by pressing shift+enter in other places, not just directly before the Smart Clause. The error appears to only happen in this PR. I tried it in https://ap-web-components.netlify.app/?path=/story/contract-editor--contract-editor and did not encounter the error.

@dselman
Copy link
Contributor Author

dselman commented Sep 14, 2020

Copy/paste support for line breaks requires merging this PR and releasing markdown-html
accordproject/markdown-transform#325

…ntract Editor code more defensive

Signed-off-by: Diana Lease <dianarlease@gmail.com>
@dselman dselman requested a review from DianaLease September 14, 2020 16:44
Copy link
Member

@DianaLease DianaLease left a comment

Choose a reason for hiding this comment

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

LGTM

@dselman dselman merged commit 63da7f4 into master Sep 14, 2020
@dselman dselman deleted the ds-linebreaks branch September 14, 2020 16:48
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
4 participants