Insert triple backticks for 'code' button when multiple lines are selected. (#311)

* Insert triple backquotes for 'code' button when multiple lines are selected

* uses theme's purple var in multiline code md
This commit is contained in:
hammsvietro 2021-06-24 16:05:11 -03:00 committed by GitHub
parent b0eac0e9fa
commit b5e87781ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -475,7 +475,11 @@ export class MarkdownTextArea extends Component<
handleInsertCode(i: MarkdownTextArea, event: any) {
event.preventDefault();
i.simpleSurround("`");
if (i.getSelectedText().split(/\r*\n/).length > 1){
i.simpleSurroundBeforeAfter("```\n", "\n```");
} else {
i.simpleSurround('`');
}
}
handleInsertStrikethrough(i: MarkdownTextArea, event: any) {
@ -552,4 +556,11 @@ export class MarkdownTextArea extends Component<
setTimeout(() => autosize.update(textarea), 10);
}
}
getSelectedText(): string {
let textarea: any = document.getElementById(this.id);
let start: number = textarea.selectionStart;
let end: number = textarea.selectionEnd;
return start !== end ? this.state.content.substring(start, end) : '';
}
}