Hello!
I’m new at ProseMirror after clone code, I change the code of demo.js, and add the following code but not working:
const { dispatch } = view;
const { tr, doc } = state;
const { paragraph } = schema.nodes;
const textNode = schema.text('Hello Prosemirror!');
const newParagraph = paragraph.create(undefined, textNode);
dispatch(tr.replaceRangeWith(0, doc.content.size, newParagraph));
Hope your help! Thanks a lot!
marijn
2
Is the schema you’re using the same schema that the editor uses? In demo.js, that’d be demoSchema
.
1 Like
I got it! It worked after change “schema” to “demoSchema”, Thanks!
const { dispatch } = view;
const { tr, doc } = state;
const { paragraph } = demoSchema.nodes;
const textNode = demoSchema.text('Hello Prosemirror!');
const newParagraph = paragraph.create(undefined, textNode);
dispatch(tr.replaceRangeWith(0, doc.content.size, newParagraph));