fix type for getAttributes

This commit is contained in:
Philipp Kühn 2021-07-26 15:36:12 +02:00
parent c315935bf9
commit 4636b1a1a5
2 changed files with 9 additions and 3 deletions

View File

@ -35,6 +35,7 @@ module.exports = {
'airbnb-base', 'airbnb-base',
], ],
rules: { rules: {
'no-continue': 'off',
'no-alert': 'off', 'no-alert': 'off',
'no-console': ['warn', { allow: ['warn', 'error'] }], 'no-console': ['warn', { allow: ['warn', 'error'] }],
semi: ['error', 'never'], semi: ['error', 'never'],

View File

@ -4,7 +4,12 @@ import { Slice, Fragment, MarkType } from 'prosemirror-model'
export default function ( export default function (
regexp: RegExp, regexp: RegExp,
type: MarkType, type: MarkType,
getAttributes?: Record<string, any> | ((match: RegExpExecArray) => Record<string, any>), getAttributes?:
| Record<string, any>
| ((match: RegExpExecArray) => Record<string, any>)
| false
| null
,
): Plugin { ): Plugin {
const handler = (fragment: Fragment, parent?: any) => { const handler = (fragment: Fragment, parent?: any) => {
const nodes: any[] = [] const nodes: any[] = []
@ -29,9 +34,9 @@ export default function (
const attrs = getAttributes instanceof Function const attrs = getAttributes instanceof Function
? getAttributes(match) ? getAttributes(match)
: getAttributes : getAttributes
if (!attrs) { if (!attrs) {
continue; continue
} }
// adding text before markdown to nodes // adding text before markdown to nodes