feat: Allow array of extensions for enableInputRules and enablePasteRules options (#2119)

This commit is contained in:
aguingand
2021-11-18 12:44:34 +01:00
committed by GitHub
parent 7e1ca4c8bd
commit 3158c37324
3 changed files with 22 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
import { AnyExtension, EnableRules } from '@tiptap/core'
export default function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
if (Array.isArray(enabled)) {
return enabled.some(enabledExtension => {
const name = typeof enabledExtension === 'string'
? enabledExtension
: enabledExtension.name
return name === extension.name
})
}
return enabled
}