Parsing node and changing the value

#1

Hi,

I have a created a formula node in my schema.

formula : { 
    inline:true,
    group: "inline",
    selectable:true,
    attrs:{
        expression:""
    },
    toDOM(node){ 
        return ["formula",{expression: node.attrs.expression}, node.attrs.expression]
    },
    parseDOM:[{
        tag:"formula",
        getAttrs(dom){
            return {
              expression: dom.attributes.expression.value
            }
        }
    }]
}

My formula tag : <formula expression=“a+b”>a+b</formula>

So when i parse this tag is is possible to replace the “a+b” with other value?

I saw getContent option in parserule but im sure how it will work?

#2

Your getAttrs function could process the attributes it returns. Since this node has no content getContent isn’t relevant.

#3

Thank you marijn.

#4

marijn, I have a table schema in my editor.The rows in my table needs to be dynamic based on the data im getting from my backend. Is it possible to do it ? Can you point me any examples or documentation?

#5

You can modify / generate the document. I can’t really spell out what to do in your specific use case because A) you only vaguely described it, and B) that’s not really my job