mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-04 10:58:18 +00:00
perf: 优化移动端输入法换行
This commit is contained in:
parent
257e69268b
commit
6ed0e14fe0
@ -815,6 +815,12 @@ export default {
|
|||||||
|
|
||||||
// Update model if text changes
|
// Update model if text changes
|
||||||
this.quill.on('text-change', _ => {
|
this.quill.on('text-change', _ => {
|
||||||
|
const {index} = this.quill.getSelection(true);
|
||||||
|
if (this.quill.getText(index - 1, 1) === "\r") {
|
||||||
|
this.quill.insertText(index, "\n");
|
||||||
|
this.quill.deleteText(index - 1, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.textTimer) {
|
if (this.textTimer) {
|
||||||
clearTimeout(this.textTimer)
|
clearTimeout(this.textTimer)
|
||||||
} else {
|
} else {
|
||||||
@ -826,17 +832,10 @@ export default {
|
|||||||
if (this.maxlength > 0 && this.quill.getLength() > this.maxlength) {
|
if (this.maxlength > 0 && this.quill.getLength() > this.maxlength) {
|
||||||
this.quill.deleteText(this.maxlength, this.quill.getLength());
|
this.quill.deleteText(this.maxlength, this.quill.getLength());
|
||||||
}
|
}
|
||||||
let html = this.$refs.editor.firstChild.innerHTML
|
const html = this.$refs.editor.firstChild.innerHTML;
|
||||||
this.updateEmojiQuick(html)
|
this.updateEmojiQuick(html)
|
||||||
this._content = html
|
this._content = html
|
||||||
this.$emit('input', this._content)
|
this.$emit('input', this._content)
|
||||||
this.$nextTick(_ => {
|
|
||||||
const range = this.quill.getSelection();
|
|
||||||
if (range) {
|
|
||||||
const endText = this.quill.getText(range.index);
|
|
||||||
/^\n\n$/.test(endText) && this.quill.deleteText(range.index, 1);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -872,21 +871,6 @@ export default {
|
|||||||
|
|
||||||
// Set enterkeyhint
|
// Set enterkeyhint
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
this.quill.root.addEventListener('keydown', e => {
|
|
||||||
if (e.key === '\r\r' && e.keyCode === 229) {
|
|
||||||
const {index} = this.quill.getSelection(true);
|
|
||||||
this.quill.insertText(index, "\r\n");
|
|
||||||
//
|
|
||||||
this.keyTimer && clearTimeout(this.keyTimer)
|
|
||||||
this.keyTimer = setTimeout(_ => {
|
|
||||||
this.$refs.editor.firstChild.childNodes.forEach(child => {
|
|
||||||
if (/^\r+/.test(child.innerHTML)) {
|
|
||||||
child.innerHTML = child.innerHTML.replace(/^\r+/, "") || "<br>"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, 200)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (this.$isEEUiApp && this.cacheKeyboard.send_button_app === 'enter') {
|
if (this.$isEEUiApp && this.cacheKeyboard.send_button_app === 'enter') {
|
||||||
this.quill.root.setAttribute('enterkeyhint', 'send')
|
this.quill.root.setAttribute('enterkeyhint', 'send')
|
||||||
}
|
}
|
||||||
|
|||||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -794,7 +794,7 @@ export default {
|
|||||||
}
|
}
|
||||||
const data = $A.isJson(newData) ? newData : ($A.jsonParse(window.localStorage.getItem("__system:keyboardConf__")) || {})
|
const data = $A.isJson(newData) ? newData : ($A.jsonParse(window.localStorage.getItem("__system:keyboardConf__")) || {})
|
||||||
data.screenshot_key = (data.screenshot_key || "").trim().toLowerCase()
|
data.screenshot_key = (data.screenshot_key || "").trim().toLowerCase()
|
||||||
data.send_button_app = data.send_button_app || 'button' // button, enter 移动端发送按钮,默认 button (页面按钮发送)
|
data.send_button_app = data.send_button_app || 'enter' // button, enter 移动端发送按钮,默认 enter (键盘回车发送)
|
||||||
data.send_button_desktop = data.send_button_desktop || 'enter' // button, enter 桌面端发送按钮,默认 enter (键盘回车发送)
|
data.send_button_desktop = data.send_button_desktop || 'enter' // button, enter 桌面端发送按钮,默认 enter (键盘回车发送)
|
||||||
window.localStorage.setItem("__system:keyboardConf__", $A.jsonStringify(data))
|
window.localStorage.setItem("__system:keyboardConf__", $A.jsonStringify(data))
|
||||||
state.cacheKeyboard = data
|
state.cacheKeyboard = data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user