OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 338 forks source link

`this` context is wrong when using MarkdownDeep.js parser #374

Open kspearrin opened 9 years ago

kspearrin commented 9 years ago

I don't think that this is an EpicEditor issue directly, but I am looking for a possible workaround.

I am trying to use EpicEditor with MarkdownDeep.js (I am using MarkdownDeep on the server-side so I need the parsers to match) as the parser like so:

var markdown = new MarkdownDeep.Markdown();
var editorOptions = {
    parser: markdown.Transform
}
var editor = new EpicEditor(editorOptions).load();

When EpicEditor invokes the markdown.Transform function, this inside the markdown.Transform function is the context of the EpicEditor, not MarkdownDeep.Markdown resulting in the following error on line 145 of MarkdownDeep.js:

Uncaught TypeError: this.ProcessBlocks is not a function

See the following JSFiddle for an example: https://jsfiddle.net/1saet37v/

Is there something I can do to fix this easily?

ref: http://www.toptensoftware.com/markdowndeep/api