i have a paragraph node , it allow its attrs like “indent” / “align” and public marks like “blod” / “font-color”, now , i need define a block node ==> “blockquote” to wrap paragraph node , but the paragraph in blockquote should not allow any attrs or marks . How should i do ??
I have tried use schema define , but toDOM(node)
can’t get its parent
You’ll have to define a different paragraph node type to use inside that quote.
I tried , but this makes it ignore normal paragraph , or is there a problem with what I wrote
paragraph_null: {
content: "inline*",
group: "block",
marks: '',
defining: true,
parseDOM: [
{tag: "blockquote>p"},
],
toDOM(node) {
return ['p' , 0]
}
},
paragraph: {
attrs: {
indent: {default: null},
align: {default: null},
},
content: "inline*",
group: "block",
defining: true,
parseDOM: [
{tag: "p" , getAttrs},
],
toDOM(node) {
const attrs = //...
//...
return ['p' , attrs , 0]
}
},
blockquote: {
content: "paragraph_null*",
group: "block",
marks: "",
defining: true,
draggable: false,
parseDOM: [
{ tag: 'blockquote' },
],
toDOM(node) {
return ['blockquote', 0]
}
},
when run:
chainCommands(setBlockType(schema.nodes.paragraph_null) , wrapIn(schema.nodes.blockquote, {}))(state , dispatch , view)
You probably don’t want group: "block"
on your null paragraphs, because that makes them valid everywhere where blocks are allowed (and if you put it in front of the regular paragraph in the schema definition, it’ll be chosen over that when finding a parent node for inline content).
I see !! I changed some logic and it takes effect after I exchange their positions
Sincere thanks to marijn