1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2025-04-19 01:56:44 +02:00

Merge pull request #20 from lxsang/master

allow tab, math and highlight in comments
This commit is contained in:
Xuan Sang LE 2020-09-22 17:14:25 +02:00 committed by GitHub
commit 3f7bc5fa7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View File

@ -53,18 +53,17 @@
<?lua if render then ?> <?lua if render then ?>
$(document).ready(function() { $(document).ready(function() {
renderMathInElement($("#container")[0]);
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
hljs.lineNumbersBlock(block);
});
// comment
var options = { var options = {
target: "quick_talk_comment_thread", target: "quick_talk_comment_thread",
api_uri: "https://chat.iohub.dev/comment", api_uri: "https://chat.iohub.dev/comment",
uri: "<?=url?>", uri: "<?=url?>",
page: $("#desktop")[0] onload: function(){
renderMathInElement($("#desktop")[0]);
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
hljs.lineNumbersBlock(block);
});
}
}; };
new QuickTalk(options); new QuickTalk(options);
}); });

View File

@ -94,6 +94,20 @@ class QuickTalk {
} }
}); });
let ta = document.createElement("textarea"); let ta = document.createElement("textarea");
ta.onkeydown = (e) => {
if (e.keyCode === 9) {
// tab was pressed
// get caret position/selection
var val = ta.value, start = ta.selectionStart, end = ta.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
ta.value =
val.substring(0, start) + " " + val.substring(end);
// put caret at right position again
ta.selectionStart = ta.selectionEnd = start + 4;
// prevent the focus lose
return false;
}
};
let footer = document.createElement("div"); let footer = document.createElement("div");
footer.setAttribute("class", "quick-talk-compose-footer"); footer.setAttribute("class", "quick-talk-compose-footer");
this.status_el = document.createElement("div"); this.status_el = document.createElement("div");
@ -190,6 +204,9 @@ class QuickTalk {
ret.result.forEach((comment) => { ret.result.forEach((comment) => {
this.show_comment(container, comment, true); this.show_comment(container, comment, true);
}); });
if (this.options.onload) {
this.options.onload();
}
} }
else { else {
this.error(ret.error); this.error(ret.error);