Skip to content

Commit

Permalink
Don't fire input rules inside code blocks
Browse files Browse the repository at this point in the history
FIX: Input rules no longer fire in blocks that have their `code` spec
set to true.

Issue #722
  • Loading branch information
marijnh committed Nov 10, 2017
1 parent 0f54a02 commit b4bf676
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/inputrules.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function inputRules({rules}) {
props: {
handleTextInput(view, from, to, text) {
let state = view.state, $from = state.doc.resolve(from)
if ($from.parent.type.spec.code) return false
let textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset,
null, "\ufffc") + text
for (let i = 0; i < rules.length; i++) {
Expand Down

3 comments on commit b4bf676

@Nantris
Copy link

@Nantris Nantris commented on b4bf676 Feb 21, 2024

Choose a reason for hiding this comment

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

@marijnh it would be great if there was a separate spec property for this rather than piggybacking off of spec.code.

We'd like to enable link-matching inputRules inside of codeblocks, but to do so affects other aspects of the codeblock's behavior (eg upon Enter it splits the block rather than inserting /n.)

Maybe like spec.allowInputRules, and it would default to the inverse of spec.code.

@marijnh
Copy link
Member Author

Choose a reason for hiding this comment

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

Can you not use inCode on your input rule for this?

@Nantris
Copy link

Choose a reason for hiding this comment

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

Oh yes, I apologize - I once knew about, but since forgot that option.

Please sign in to comment.