From 4636b1a1a502ea7ef35e24ce9a752860ca39e745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Mon, 26 Jul 2021 15:36:12 +0200 Subject: [PATCH] fix type for getAttributes --- .eslintrc.js | 1 + packages/core/src/pasteRules/markPasteRule.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 712b445e..e6d6392b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,6 +35,7 @@ module.exports = { 'airbnb-base', ], rules: { + 'no-continue': 'off', 'no-alert': 'off', 'no-console': ['warn', { allow: ['warn', 'error'] }], semi: ['error', 'never'], diff --git a/packages/core/src/pasteRules/markPasteRule.ts b/packages/core/src/pasteRules/markPasteRule.ts index 3ed221ce..6dd7370e 100644 --- a/packages/core/src/pasteRules/markPasteRule.ts +++ b/packages/core/src/pasteRules/markPasteRule.ts @@ -4,7 +4,12 @@ import { Slice, Fragment, MarkType } from 'prosemirror-model' export default function ( regexp: RegExp, type: MarkType, - getAttributes?: Record | ((match: RegExpExecArray) => Record), + getAttributes?: + | Record + | ((match: RegExpExecArray) => Record) + | false + | null + , ): Plugin { const handler = (fragment: Fragment, parent?: any) => { const nodes: any[] = [] @@ -29,9 +34,9 @@ export default function ( const attrs = getAttributes instanceof Function ? getAttributes(match) : getAttributes - + if (!attrs) { - continue; + continue } // adding text before markdown to nodes