mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-01 06:37:51 +08:00
18 lines
504 B
TypeScript
18 lines
504 B
TypeScript
|
import { Node } from 'prosemirror-model'
|
|||
|
import { ExtensionAttribute } from '../types'
|
|||
|
|
|||
|
export default function getRenderedAttributes(node: Node, attributes: ExtensionAttribute[]) {
|
|||
|
return attributes
|
|||
|
.map(attribute => {
|
|||
|
// TODO: fallback if renderHTML doesn’t exist
|
|||
|
return attribute.attribute.renderHTML(node.attrs)
|
|||
|
})
|
|||
|
.reduce((accumulator, value) => {
|
|||
|
// TODO: add support for "class" merge
|
|||
|
return {
|
|||
|
...accumulator,
|
|||
|
...value,
|
|||
|
}
|
|||
|
}, {})
|
|||
|
}
|