Last active
April 9, 2020 02:46
-
-
Save RatoX/e374ad8eed5f3c0e96977ee1d16a5a5e to your computer and use it in GitHub Desktop.
ProseMirror EditorState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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