Created
September 2, 2016 21:14
-
-
Save emanchado/5dda9db4bb23614cc2b7bc0f8c762bc8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<head> | |
<meta charset="utf-8" /> | |
<title>ProseMirror test</title> | |
</head> | |
<body> | |
<div id="editor"></div> | |
<div id="content" style="display: none"> | |
<p>First paragraph.</p> | |
<img src="node_modules/hoek/images/hoek.png"/> | |
<p>Second paragraph.</p> | |
</div> | |
<button id="btn-mark">Add mark</button> | |
<button id="btn-export">Export</button> | |
<script src="bug_bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
var prosemirror = require("prosemirror"); | |
var schemaBasic = require("prosemirror/dist/schema-basic"), | |
schema = schemaBasic.schema, | |
EmMark = schemaBasic.EmMark; | |
var editor = new prosemirror.ProseMirror({ | |
place: document.getElementById("editor"), | |
schema: schema, | |
doc: schema.parseDOM(document.getElementById("content")) | |
}); | |
var markType = new EmMark(); | |
var limit; | |
limit = 21; | |
// It works if you uncomment the following | |
// limit = 20; | |
document.getElementById("btn-mark").addEventListener("click", function() { | |
editor.tr.addMark(10, limit, markType.create()).applyAndScroll(); | |
}, false); | |
document.getElementById("btn-export").addEventListener("click", function() { | |
console.log(JSON.stringify(editor.doc.toJSON(), null, 2)); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment