This commit is contained in:
Dessalines 2021-07-16 13:16:21 -04:00
commit f977859f08
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) { handleInsertCode(i: MarkdownTextArea, event: any) {
event.preventDefault(); event.preventDefault();
i.simpleSurround("`"); if (i.getSelectedText().split(/\r*\n/).length > 1){
i.simpleSurroundBeforeAfter("```\n", "\n```");
} else {
i.simpleSurround('`');
}
} }
handleInsertStrikethrough(i: MarkdownTextArea, event: any) { handleInsertStrikethrough(i: MarkdownTextArea, event: any) {
@ -552,4 +556,11 @@ export class MarkdownTextArea extends Component<
setTimeout(() => autosize.update(textarea), 10); 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) : '';
}
} }