Open aruizca opened 8 years ago
Something like this:
onPreview: function (e) {
var content = e.getContent();
$.post("/misc/preview",{data: content}, function (data) {
e.setPreviewContent(data);
});
}
at the moment this is what I do, but I might be missing some other steps:
onPreview: function (e) {
var content = e.getContent();
$.post("/misc/preview",{data: content}, function (data) {
$('.md-preview').html(data);
});
}
Hey @aruizca
The onPreview
hook expecting string
as return value, so i guess you could use synchronuous call to your server, and return the result at the end of the hook callback.
I've made a PR #306 that attempts to implement setPreview() as @aruizca has wanted.
Async call would be helpful so server-side rendering of markdown is identical to in-editor preview. Not all of us render and have javascript stack for whole applications, so this would be really useful.
Currently there is no callback function available to update the preview content once the ajax request to parse the original content has completed. Thanks!