I defined an `image` node with parse rule:
{
tag: 'img[src]',
getContent(dom, schema){
debugger
let src = dom.src
if(src.startsWith('img/')){
//... do something
}
const img = fimg.create({src})
return Fragment.from(img)
}
},
And getContent is not called on <img src='img/test.png'>.
Is this a leaf node, like the default image node, by any chance?
Well, the nodespec contains nothing except two attrs: src and width.
Right, then it does not support content, so getContent doesn’t mean anything for such a node.
It does make sense.
I tried getAttrs. It returns some modified src according to it’s original value.
But the image in the editor still has the original src.
So If I want to change it, I have to tranverse over the doc to find the image and make modification, right?
getAttrs will be called when parsing a node with a parse rule that defines it. Make sure there’s no other parse rule with higher precedence being used for image elements.
Yes, it was called.
But the values returned does not take effect in the editor. It shows the original-src image.