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

22 lines
562 B
TypeScript
Raw Normal View History

2021-04-21 15:43:31 +08:00
import { ExtensionAttribute } from '../types'
2021-01-29 16:33:42 +08:00
export function getSplittedAttributes(
2021-01-29 16:33:42 +08:00
extensionAttributes: ExtensionAttribute[],
typeName: string,
2021-04-21 15:43:31 +08:00
attributes: Record<string, any>,
): Record<string, any> {
2021-01-29 16:33:42 +08:00
return Object.fromEntries(Object
.entries(attributes)
.filter(([name]) => {
const extensionAttribute = extensionAttributes.find(item => {
return item.type === typeName && item.name === name
})
if (!extensionAttribute) {
return false
}
return extensionAttribute.attribute.keepOnSplit
}))
}