Adding style Attributes

How can I add style attributes to the selected node? I’m trying to add the text-align style attribute to selected nodes. I don’t want to wrap the selected node in a new node.

If text-align is a semantic attribute or a consequence of a structural attribute, add it to the schema and use toDOM to render it into the HTML style attribute. Something like:

toDOM(node) {
  const textAlign = node.attrs.textAlign // or derive textAlign from `node.attrs`
  return ['p', { style: 'text-align: ' + textAlign }, 0];
}

If it’s only to highlight a Node, and not all the Node of the same type, use Decoration.node().