Handle inputRules on Enter #6

Closed
castroCrea wants to merge 1 commit from castroCrea/patch-1 into master
castroCrea commented 2021-08-04 19:13:24 +02:00 (Migrated from github.com)

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

https://user-images.githubusercontent.com/20707343/128224623-c794fe97-8cc5-404e-a677-c096e30dcff9.mov

It work for Heading and block to

https://user-images.githubusercontent.com/20707343/128225481-37324416-6cb3-4636-902a-81d9fc1c4558.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. 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 https://user-images.githubusercontent.com/20707343/128224623-c794fe97-8cc5-404e-a677-c096e30dcff9.mov It work for Heading and block to https://user-images.githubusercontent.com/20707343/128225481-37324416-6cb3-4636-902a-81d9fc1c4558.mov
marijnh commented 2021-08-06 10:46:51 +02:00 (Migrated from github.com)

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.

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.
marijn closed this pull request 2026-04-01 20:55:19 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-inputrules!6
No description provided.