diff --git a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts index 4af2edf725f6..7de0a478e7ca 100644 --- a/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts +++ b/src/main/webapp/app/shared/metis/posting-markdown-editor/posting-markdown-editor.component.ts @@ -126,29 +126,27 @@ export class PostingMarkdownEditorComponent implements OnInit, ControlValueAcces const editor = this.markdownEditor.monacoEditor; if (editor) { - if (editor) { - editor.onDidChangeModelContent((event: { changes: string | any[] }) => { - const position = editor.getPosition(); - if (!position) { - return; - } - - const model = editor.getModel(); - if (!model) { - return; - } - - const lineContent = model.getLineContent(position.lineNumber).trimStart(); - const hasPrefix = lineContent.startsWith('- ') || /^\s*1\. /.test(lineContent); - if (hasPrefix && event.changes.length === 1 && (event.changes[0].text.startsWith('- ') || event.changes[0].text.startsWith('1. '))) { - return; - } - - if (hasPrefix) { - this.handleKeyDown(model, position.lineNumber); - } - }); - } + editor.onDidChangeModelContent((event: { changes: string | any[] }) => { + const position = editor.getPosition(); + if (!position) { + return; + } + + const model = editor.getModel(); + if (!model) { + return; + } + + const lineContent = model.getLineContent(position.lineNumber).trimStart(); + const hasPrefix = lineContent.startsWith('- ') || /^\s*1\. /.test(lineContent); + if (hasPrefix && event.changes.length === 1 && (event.changes[0].text.startsWith('- ') || event.changes[0].text.startsWith('1. '))) { + return; + } + + if (hasPrefix) { + this.handleKeyDown(model, position.lineNumber); + } + }); } }