Skip to content

Instantly share code, notes, and snippets.

@RatoX
Last active April 9, 2020 02:46
Show Gist options
  • Save RatoX/e374ad8eed5f3c0e96977ee1d16a5a5e to your computer and use it in GitHub Desktop.
Save RatoX/e374ad8eed5f3c0e96977ee1d16a5a5e to your computer and use it in GitHub Desktop.
ProseMirror EditorState
'use strict';
const {EditorState} = require('prosemirror-state');
const {Schema, Node} = require('prosemirror-model');
const schema = new Schema({
nodes: {
doc: {
content: 'block+',
},
paragraph: {
content: 'inline*',
group: 'block',
marks: 'strong',
},
text: {
group: 'inline',
},
},
marks: {
strong: {},
},
});
const obj = {
type: 'doc',
content: [
{
type: 'paragraph',
marks: [],
content: [
{
type: 'text',
text: 'Hello',
marks: [{type: 'strong'}],
},
{
type: 'text',
text: 'World',
},
],
},
],
};
const state = EditorState.create({
schema,
doc: Node.fromJSON(schema, obj),
});
state.doc.check();
// Start here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment