Hi, I want to implement text alignment functionality in prosemirror, this my code can you any one help me on this.
export default function Editor() {
-
const mySchema = new Schema({*
-
nodes: addListNodes(schema.spec.nodes, “paragraph block*”, “block”),*
-
// marks: schema.spec.marks,*
-
marks: schema.spec.marks*
-
.addToEnd("strike", {* -
parseDOM: [* -
{ tag: "del" },* -
{ tag: "delete" },* -
{ style: "text-decoration=underline" },* -
],* -
toDOM() {* -
return ["del", 0];* -
},* -
})* -
.addToEnd("center", {* -
parseDOM: [* -
{ tag: "p" },* -
// { tag: "center" },* -
{ style: "text-align=center" },* -
],* -
toDOM() {* -
return ["p", 0];* -
},* -
}),* -
});*
-
useEffect(() => {*
-
console.log(mySchema, “test”);*
-
const data: any = document.querySelector(“#content”);*
-
window.view = new EditorView(document.querySelector(“#editor”), {*
-
state: EditorState.create({* -
doc: DOMParser.fromSchema(mySchema).parse(data),* -
plugins: editorSetup({ schema: mySchema }),* -
}),* -
});*
-
}, []);*
-
return (*
-
*
-
<div id="editor" className="container mx-auto">* -
<div id="content"></div>* -
</div>* - *
-
);* }