mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
core: add delay on live preview for MarkdownInput to avoid making too much request to the API
This commit is contained in:
parent
19c1361e47
commit
97b06b160b
@ -6,6 +6,7 @@
|
||||
<script src="{{ statics.js }}"> </script>
|
||||
<script type="text/javascript">
|
||||
var css = "{{ statics.css }}";
|
||||
var lastAPICall;
|
||||
|
||||
// Only import the css once
|
||||
if (!document.head.innerHTML.includes(css)){
|
||||
@ -40,7 +41,6 @@
|
||||
}).done(function (msg) {
|
||||
preview.innerHTML = msg;
|
||||
});
|
||||
return preview.innerHTML;
|
||||
}
|
||||
|
||||
// Pretty markdown input
|
||||
@ -48,7 +48,11 @@
|
||||
element: document.getElementById("{{ widget.attrs.id }}"),
|
||||
spellChecker: false,
|
||||
previewRender: function(plainText, preview){ // Async method
|
||||
return customMarkdownParser(plainText, preview);
|
||||
clearTimeout(lastAPICall);
|
||||
lastAPICall = setTimeout(function (plainText, preview){
|
||||
customMarkdownParser(plainText, preview);
|
||||
}, 300, plainText, preview);
|
||||
return preview.innerHTML;
|
||||
},
|
||||
// showIcons: ["code", "table", "clean-block"],
|
||||
toolbar: [
|
||||
|
Loading…
Reference in New Issue
Block a user