Open dutchiexl opened 10 years ago
ghost down utilizes codemirror to have an editor like interface, to get the value/markdown you can do this:
Codemirror = CodeMirror.fromTextArea(document.getElementById("the_editor"), { options });
console.log(Codemirror.getValue());
Was this ever solved? I'm currently only able to get the original value of the editor from:
console.log(Codemirror.getValue());
It doesn't include the changes made through the editor.
So I figured out the issue that I was having and I thought I would make a quick post on how to go about this. @ricomonster had the right idea but the problem isn't that you need to instantiate a new CodeMirror object it's that you don't have access to the one that currently exists. If you put his code into the page the console log statement will just print the original value because the page edits the original CodeMirror object and your new CodeMirror object is left alone. Instead look inside the jquery.ghostdown.js file for the following
this.editor = CodeMirror.fromTextArea(this.element.find('textarea')[
mode: 'markdown',
tabMode: 'indent',
lineWrapping: true
});
This is the object that you want to have access to so you can just make this object global by putting this right after the statement:
window.theEditor = this.editor
After you add that line in you can open your js console and type:
window.theEditor.getValue()
And you will be able to get the markdown that you are looking for
i get error like this
Uncaught TypeError: $(...).ghostDown is not a function(…)
@creativefull Try the suggestion by @thornycrackers
@16patsle ok thanks bro
var editor = $(".editor").ghostDown(); console.log(editor.getMarkdown());