fix: chinese pinyin input - fix #2039 (#2057)

This commit is contained in:
baiy
2022-01-06 23:18:36 +08:00
committed by GitHub
parent ac979239e8
commit 720d54f91d

View File

@@ -17,6 +17,7 @@
@click="$emit('click', $event)" @click="$emit('click', $event)"
@keydown="$emit('keydown', $event)" @keydown="$emit('keydown', $event)"
@paste="handlePaste" @paste="handlePaste"
@compositionend="handleCompositionEnd"
></div> ></div>
</div> </div>
</template> </template>
@@ -72,7 +73,7 @@ export default defineComponent({
highlightEnabled: true, highlightEnabled: true,
highlightStyle: "", highlightStyle: "",
caseSensitive: true, caseSensitive: true,
fireOn: "keydown", fireOn: "input",
fireOnEnabled: true, fireOnEnabled: true,
} }
}, },
@@ -114,11 +115,17 @@ export default defineComponent({
}, },
methods: { methods: {
handleCompositionEnd() {
this.handleChange()
},
handlePaste(ev) { handlePaste(ev) {
this.handleChange() this.handleChange()
this.$emit("paste", { event: ev, previousValue: this.internalValue }) this.$emit("paste", { event: ev, previousValue: this.internalValue })
}, },
handleChange() { handleChange(e = null) {
if (e && "inputType" in e && e.inputType === "insertCompositionText") {
return
}
this.debouncedHandler = debounce(function () { this.debouncedHandler = debounce(function () {
if (this.$refs.editor) { if (this.$refs.editor) {
if (this.internalValue !== this.$refs.editor.textContent) { if (this.internalValue !== this.$refs.editor.textContent) {