bootstrap-markdown icon indicating copy to clipboard operation
bootstrap-markdown copied to clipboard

Feature request: support for server side rendered preview via ajax

Open aruizca opened this issue 10 years ago • 3 comments

Currently there is no callback function available to update the preview content once the ajax request to parse the original content has completed. Thanks!

aruizca avatar Nov 07 '15 11:11 aruizca

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);
          });
        }

aruizca avatar Nov 07 '15 11:11 aruizca

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.

toopay avatar Dec 14 '15 08:12 toopay

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.

lorentzkim avatar Aug 21 '17 05:08 lorentzkim