-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I get the markdown and html from the editor ? #8
Comments
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:
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 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:
After you add that line in you can open your js console and type:
And you will be able to get the markdown that you are looking for |
i get error like this
|
@creativefull Try the suggestion by @thornycrackers |
@16patsle ok thanks bro |
var editor = $(".editor").ghostDown();
console.log(editor.getMarkdown());
The text was updated successfully, but these errors were encountered: