Created
February 19, 2016 06:09
-
-
Save StephanHoyer/6fdf609fce745d048e32 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
'use strict'; | |
var model = require('prosemirror/model'); | |
var ProseMirror = require('prosemirror/edit').ProseMirror; | |
var toDOM = require('prosemirror/convert/to_dom'); | |
var fromDOM = require('prosemirror/convert/from_dom'); | |
var elt = require('prosemirror/dom').elt; | |
function inline(dom, context, added) { | |
var old = context.styles; | |
context.styles = model.style.add(old, added); | |
context.addAll(dom.firstChild, null); | |
context.styles = old; | |
} | |
model.style.underline = {type: 'underline'}; | |
toDOM.renderStyle.underline = function() { | |
return elt('u'); | |
}; | |
fromDOM.tags.u = function(dom, context) { | |
return inline(dom, context, model.style.underline); | |
}; | |
model.style.strike = {type: 'strike'}; | |
toDOM.renderStyle.strike = function() { | |
return elt('strike'); | |
}; | |
fromDOM.tags.strike = function(dom, context) { | |
return inline(dom, context, model.style.strike); | |
}; | |
var editor = new ProseMirror({ | |
place: el, | |
doc: tile.config.text, | |
docFormat: 'html', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment