@sertxudeveloper/markdown-editor
Version:
A customizable markdown editor for your projects
33 lines (25 loc) • 725 B
text/typescript
import BlockStyle from '../BlockStyle';
import Plugin from '../Plugin';
import icon from './icon.svg';
export default class Italic extends Plugin {
getKey(): string {
return 'italic';
}
getIcon(): string {
return icon;
}
getTitle(): string {
return 'Italic (Ctrl+I)';
}
onKeyDown(event: KeyboardEvent): void {
if (event.ctrlKey && event.key === 'i') {
event.preventDefault();
this.execute();
}
}
execute(value: string = ''): void {
if (!this.editor.textarea) return;
const textarea = this.editor.textarea;
BlockStyle.applyStyle(textarea, { prefix: '*', suffix: '*', trimFirst: true });
}
}