Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 在输入法输入未完成时触发change事件 #1224

Merged
merged 2 commits into from Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/js/editor/index.js
Expand Up @@ -128,9 +128,22 @@ Editor.prototype = {
this.toolbarElemId = toolbarElemId
this.textElemId = textElemId

// 记录输入法是否已输入结束
let compositionEnd = true

// 输入法开始输入
$textContainerElem.on('compositionstart', () => {
compositionEnd = false
})

// 输入法结束输入
$textContainerElem.on('compositionend', () => {
compositionEnd = true
})

// 绑定 onchange
$textContainerElem.on('click keyup', () => {
this.change && this.change()
compositionEnd && this.change && this.change()
})
$toolbarElem.on('click', function () {
this.change && this.change()
Expand Down
1 change: 1 addition & 0 deletions src/less/menus.less
@@ -1,6 +1,7 @@
.w-e-toolbar {
display: flex;
padding: 0 5px;
flex-wrap: wrap;

/* 单个菜单 */
.w-e-menu {
Expand Down