Skip to content

Commit

Permalink
feat: Allow a rule to be skipped from the getAttributes callback in m…
Browse files Browse the repository at this point in the history
…arkPasteRule (#1625)

For example: you are matching URLs with a Regex but want to make additional checks on the match array before deciding if you want to apply the mark or not. Returning null or false won't attempt to apply the mark. Currently the return value of getAttributes is applied unconditionally.
  • Loading branch information
joevallender authored Jul 26, 2021
1 parent e367974 commit 9ffd58c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/pasteRules/markPasteRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default function (
const attrs = getAttributes instanceof Function
? getAttributes(match)
: getAttributes

if (!attrs) {
continue;
}

// adding text before markdown to nodes
if (matchStart > 0) {
Expand Down

0 comments on commit 9ffd58c

Please sign in to comment.