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.
This commit is contained in:
Joe Vallender
2021-07-26 20:13:05 +07:00
committed by GitHub
parent e367974e30
commit 9ffd58cf25

View File

@@ -29,6 +29,10 @@ export default function (
const attrs = getAttributes instanceof Function const attrs = getAttributes instanceof Function
? getAttributes(match) ? getAttributes(match)
: getAttributes : getAttributes
if (!attrs) {
continue;
}
// adding text before markdown to nodes // adding text before markdown to nodes
if (matchStart > 0) { if (matchStart > 0) {