fix(widget): 阻止评论输入框中的斜杠键事件冒泡
防止在评论和回复编辑器的文本区域中输入斜杠字符“/”时,触发全局快捷键操作。
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user