Browse Source

typing a backtick when replying to a github url switches to markdown

pull/96/head
Aaron Parecki 6 years ago
parent
commit
4a0cb5a5b3
No known key found for this signature in database GPG Key ID: 276C2817346D6056
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      views/new-post.php

+ 16
- 3
views/new-post.php View File

@ -316,6 +316,9 @@ function restoreNoteState() {
} }
}); });
$("#note_content").change(); $("#note_content").change();
if($("#note_content").val().match(/`/)) {
switchToMarkdown();
}
activateTokenField(); activateTokenField();
} else { } else {
activateTokenField(); activateTokenField();
@ -453,13 +456,17 @@ $(function(){
} }
// Easter egg: press ctrl+shift+m to switch to markdown // Easter egg: press ctrl+shift+m to switch to markdown
if(e.keyCode == 77 && e.ctrlKey && e.shiftKey) { if(e.keyCode == 77 && e.ctrlKey && e.shiftKey) {
$("#content-type-selection select").val("text/markdown");
$("#content-type-selection").removeClass("hidden");
switchToMarkdown();
} }
}); });
}); });
function switchToMarkdown() {
$("#content-type-selection select").val("text/markdown");
$("#content-type-selection").removeClass("hidden");
}
function refreshPhotoPreviews() { function refreshPhotoPreviews() {
$("#photo-previews").html(""); $("#photo-previews").html("");
for(i=0; i<photos.length; i++) { for(i=0; i<photos.length; i++) {
@ -534,12 +541,18 @@ $(function(){
saveNoteState(); saveNoteState();
}); });
$("#note_content").on('keyup', function(){
$("#note_content").on('keyup', function(e){
var scrollHeight = document.getElementById("note_content").scrollHeight; var scrollHeight = document.getElementById("note_content").scrollHeight;
var currentHeight = parseInt($("#note_content").css("height")); var currentHeight = parseInt($("#note_content").css("height"));
if(Math.abs(scrollHeight - currentHeight) > 20) { if(Math.abs(scrollHeight - currentHeight) > 20) {
$("#note_content").css("height", (scrollHeight+30)+"px"); $("#note_content").css("height", (scrollHeight+30)+"px");
} }
// If you type a backtick in the content, and are replying to a github issue, switch to markdown
if(e.key == '`') {
if($("#note_in_reply_to").val().match(/github\.com/)) {
switchToMarkdown();
}
}
}); });
$("#expand-reply").click(function(){ $("#expand-reply").click(function(){

Loading…
Cancel
Save