check for rendered attribute
This commit is contained in:
@@ -3,9 +3,10 @@ import { ExtensionAttribute } from '../types'
|
|||||||
|
|
||||||
export default function getRenderedAttributes(node: Node, attributes: ExtensionAttribute[]) {
|
export default function getRenderedAttributes(node: Node, attributes: ExtensionAttribute[]) {
|
||||||
return attributes
|
return attributes
|
||||||
.map(attribute => {
|
.filter(item => item.attribute.rendered)
|
||||||
|
.map(item => {
|
||||||
// TODO: fallback if renderHTML doesn’t exist
|
// TODO: fallback if renderHTML doesn’t exist
|
||||||
return attribute.attribute.renderHTML(node.attrs)
|
return item.attribute.renderHTML(node.attrs)
|
||||||
})
|
})
|
||||||
.reduce((accumulator, value) => {
|
.reduce((accumulator, value) => {
|
||||||
// TODO: add support for "class" merge
|
// TODO: add support for "class" merge
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export default createNode({
|
|||||||
return {
|
return {
|
||||||
id: {
|
id: {
|
||||||
default: '123',
|
default: '123',
|
||||||
|
rendered: true,
|
||||||
renderHTML: attributes => ({ class: `foo-${attributes.id}`, id: 'foo' }),
|
renderHTML: attributes => ({ class: `foo-${attributes.id}`, id: 'foo' }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user