mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 14:21:13 +00:00
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:
parent
b0eac0e9fa
commit
b5e87781ea
14 changed files with 25 additions and 14 deletions
2
src/assets/css/themes/cyborg.min.css
vendored
2
src/assets/css/themes/cyborg.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/darkly.min.css
vendored
2
src/assets/css/themes/darkly.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/i386.min.css
vendored
2
src/assets/css/themes/i386.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/journal.min.css
vendored
2
src/assets/css/themes/journal.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/litely.min.css
vendored
2
src/assets/css/themes/litely.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/litera.min.css
vendored
2
src/assets/css/themes/litera.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/materia.min.css
vendored
2
src/assets/css/themes/materia.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/minty.min.css
vendored
2
src/assets/css/themes/minty.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/sketchy.min.css
vendored
2
src/assets/css/themes/sketchy.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/solar.min.css
vendored
2
src/assets/css/themes/solar.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/united.min.css
vendored
2
src/assets/css/themes/united.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/vaporwave-dark.min.css
vendored
2
src/assets/css/themes/vaporwave-dark.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/assets/css/themes/vaporwave.min.css
vendored
2
src/assets/css/themes/vaporwave.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -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) : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue