fix(widget): 阻止评论输入框中的斜杠键事件冒泡

防止在评论和回复编辑器的文本区域中输入斜杠字符“/”时,触发全局快捷键操作。
This commit is contained in:
anghunk
2026-02-02 13:12:28 +08:00
parent e6bbac8366
commit 132f2fbbb0
2 changed files with 26 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ export class ReplyEditor extends Component {
placeholder: '支持 Markdown 格式',
disabled: this.props.submitting,
onInput: (e) => this.handleInput(e),
onKeydown: (e) => this.handleTextareaKeydown(e),
},
}),
@@ -186,6 +187,18 @@ export class ReplyEditor extends Component {
}
}
handleTextareaKeydown(e) {
if (
e.key === '/' &&
!e.ctrlKey &&
!e.metaKey &&
!e.altKey &&
!e.shiftKey
) {
e.stopPropagation();
}
}
togglePreview() {
this.state.showPreview = !this.state.showPreview;
this.render();