tiptap/packages/core/src/helpers/splitExtensions.ts

17 lines
575 B
TypeScript
Raw Normal View History

2020-10-22 03:01:39 +08:00
import { Extensions } from '../types'
import { Extension } from '../Extension'
import { Node } from '../Node'
import { Mark } from '../Mark'
2020-10-22 03:01:39 +08:00
export default function splitExtensions(extensions: Extensions) {
2020-11-20 04:08:25 +08:00
const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]
const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]
const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]
2020-10-22 03:01:39 +08:00
return {
baseExtensions,
nodeExtensions,
2020-10-22 03:13:38 +08:00
markExtensions,
2020-10-22 03:01:39 +08:00
}
}