add basic implementation for attributes
This commit is contained in:
17
packages/core/src/utils/getRenderedAttributes.ts
Normal file
17
packages/core/src/utils/getRenderedAttributes.ts
Normal 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 doesn’t exist
|
||||
return attribute.attribute.renderHTML(node.attrs)
|
||||
})
|
||||
.reduce((accumulator, value) => {
|
||||
// TODO: add support for "class" merge
|
||||
return {
|
||||
...accumulator,
|
||||
...value,
|
||||
}
|
||||
}, {})
|
||||
}
|
||||
Reference in New Issue
Block a user