mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 17:07:49 +08:00
19 lines
564 B
TypeScript
19 lines
564 B
TypeScript
import { Node, Mark } from 'prosemirror-model'
|
||
import { ExtensionAttribute } from '../types'
|
||
|
||
export default function getRenderedAttributes(node: Node | Mark, attributes: ExtensionAttribute[]) {
|
||
return attributes
|
||
.filter(item => item.attribute.rendered)
|
||
.map(item => {
|
||
// TODO: fallback if renderHTML doesn’t exist
|
||
return item.attribute.renderHTML(node.attrs)
|
||
})
|
||
.reduce((accumulator, value) => {
|
||
// TODO: add support for "class" and "style" merge
|
||
return {
|
||
...accumulator,
|
||
...value,
|
||
}
|
||
}, {})
|
||
}
|