add basic implementation for attributes

This commit is contained in:
Philipp Kühn
2020-10-21 23:32:28 +02:00
parent 7fffe97532
commit 6752d52541
6 changed files with 114 additions and 12 deletions

View File

@@ -0,0 +1,17 @@
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 doesnt exist
return attribute.attribute.renderHTML(node.attrs)
})
.reduce((accumulator, value) => {
// TODO: add support for "class" merge
return {
...accumulator,
...value,
}
}, {})
}