Remove more Markdown references

This commit is contained in:
2018-09-17 13:47:03 +02:00
parent 02a7014bf4
commit cede3e75db
2 changed files with 26 additions and 39 deletions

View File

@@ -40,11 +40,6 @@ $(document).on('click','body .comment-action-reply',function(e){
parentDiv.after(commentForm); parentDiv.after(commentForm);
// document.getElementById('comment_field').focus(); // document.getElementById('comment_field').focus();
$(commentField).focus(); $(commentField).focus();
// Convert Markdown
var convert = new Markdown.getSanitizingConverter().makeHtml;
var preview = $('.comment-reply-preview-md');
preview.html(convert($(commentField).val()));
$('.comment-reply-field').addClass('filled'); $('.comment-reply-field').addClass('filled');
}); });
@@ -59,10 +54,6 @@ $(document).on('click','body .comment-action-cancel',function(e){
delete commentField.dataset.originalParentId; delete commentField.dataset.originalParentId;
$(commentField).val(''); $(commentField).val('');
// Convert Markdown
var convert = new Markdown.getSanitizingConverter().makeHtml;
var preview = $('.comment-reply-preview-md');
preview.html(convert($(commentField).val()));
$('.comment-reply-field').removeClass('filled'); $('.comment-reply-field').removeClass('filled');
$('.comment-container').removeClass('is-replying'); $('.comment-container').removeClass('is-replying');

View File

@@ -101,41 +101,37 @@ script(type="text/javascript").
var page_title = 'Edit: {{ node.name }} - {{ project.name }} — Blender Cloud'; var page_title = 'Edit: {{ node.name }} - {{ project.name }} — Blender Cloud';
DocumentTitleAPI.set_page_title(page_title); DocumentTitleAPI.set_page_title(page_title);
/* Build the markdown preview when typing in textarea */ var $contentField = $('.form-group.description textarea'),
var convert = new Markdown.getSanitizingConverter(); $contentPreview = $('<div class="node-edit-form-md-preview" />').insertAfter($contentField);
Markdown.Extra.init(convert);
convert = convert.makeHtml;
var $textarea = $('.form-group.description textarea'), function parseDescriptionContent(content) {
$loader = $('<div class="md-preview-loading"><i class="pi-spin spin"></i></div>').insertAfter($textarea),
$preview = $('<div class="node-edit-form-md-preview" />').insertAfter($loader);
$loader.hide(); $.ajax({
url: "{{ url_for('nodes.preview_markdown')}}",
// Delay function to not start converting heavy posts immediately type: 'post',
var delay = (function(){ data: {content: content},
var timer = 0; headers: {"X-CSRFToken": csrf_token},
return function(callback, ms){ headers: {},
clearTimeout (timer); dataType: 'json'
timer = setTimeout(callback, ms); })
}; .done(function (data) {
})(); $contentPreview.html(data.content);
})
$textarea.keyup(function() { .fail(function (err) {
/* If there's an iframe (YouTube embed), delay markdown convert 1.5s */ toastr.error(xhrErrorResponseMessage(err), 'Parsing failed');
if (/iframe/i.test($textarea.val())) { });
$loader.show();
delay(function(){
// Convert markdown
$preview.html(convert($textarea.val()));
$loader.hide();
}, 1500 );
} else {
// Convert markdown
$preview.html(convert($textarea.val()));
} }
}).trigger('keyup');
var options = {
callback: parseDescriptionContent,
wait: 750,
highlight: false,
allowSubmit: false,
captureLength: 2
}
$contentField.typeWatch(options);
$('input, textarea').keypress(function () { $('input, textarea').keypress(function () {
// Unused: save status of the page as 'edited' // Unused: save status of the page as 'edited'