In my schema I have a node of type line
, and a node of type chunk
which is a group of line
s. Inside the chunk
’s toDOM
I have some code that uses all the child lines’ attrs, but what I’d really love to do is to be able to calculate and set some attrs
on the chunk
itself (in particular when a joinUp
operation joins two chunks, say). Is there a way to do this? For example, in a plugin, can I detect a joinUp
operation (or anything that may be changing the set of line
s in chunk
s) and do some work to set attr
s on each affected chunk
? I’m hoping this will cause a re-render of the parent chunk
node.
This may be similar to:
- How to re-render parent node when child changes?
- Force nodes of specific type to re-render
- Force toDom to be re-executed
but I’m trying to see if there’s a lightweight solution possible.
For what it’s worth, my schema looks something like:
const schema = new Schema({
nodes: {
text: {
group: "inline"
},
line: {
content: 'inline*',
attrs: {
pageNum: {},
y1: {},
y2: {},
},
isolating: true,
toDOM: () => ["div", 0],
},
chunk: {
content: 'line*',
attrs: {
label: { default: null },
},
toDOM(node) {
// (something that uses children's attrs to render a div
},
},