Skip to content

Instantly share code, notes, and snippets.

@StephanHoyer
Created February 19, 2016 06:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanHoyer/6fdf609fce745d048e32 to your computer and use it in GitHub Desktop.
Save StephanHoyer/6fdf609fce745d048e32 to your computer and use it in GitHub Desktop.
'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