From 9ffd58cf256bf3c0cd5a217b8933826c70b9b841 Mon Sep 17 00:00:00 2001 From: Joe Vallender Date: Mon, 26 Jul 2021 20:13:05 +0700 Subject: [PATCH] feat: Allow a rule to be skipped from the getAttributes callback in markPasteRule (#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. --- packages/core/src/pasteRules/markPasteRule.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/pasteRules/markPasteRule.ts b/packages/core/src/pasteRules/markPasteRule.ts index 7ece60cf..3ed221ce 100644 --- a/packages/core/src/pasteRules/markPasteRule.ts +++ b/packages/core/src/pasteRules/markPasteRule.ts @@ -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) {