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

Handle inputRules on Enter #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

castroCrea
Copy link

@castroCrea castroCrea commented Aug 4, 2021

I'm creating an inputRule for links const inputRegexExact = /(https?:\/\/[\w\d./?=#]+)[\s\n]$/; that will create my link at the end of a line when the user hit enter. I didn't reach it but it will be perfect that the Enter trigger the inputRules and go to the line but only for marks

Enregistrement.de.l.ecran.2021-08-04.a.19.11.19.mov

It work for Heading and block to

Enregistrement.de.l.ecran.2021-08-04.a.19.18.14.mov

I'm creating an inputRule for links `const inputRegexExact = /(https?:\/\/[\w\d./?=#]+)[\s\n]$/;` that will create my link at the end of a line when the user hit enter
@marijnh
Copy link
Member

marijnh commented Aug 6, 2021

I don't like how this blurs the meaning of the matched strings (that "\n" isn't actually in the document), and it seems like this would be really hard to use correctly, since you have to somehow duplicate all the complexities of the enter key's effect inside your input rule handler, alongside the text-changing effect it has.

A better approach might be a regular enter key handler that scans for the text itself, creates the link, and then call through to the default enter handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants