fix: render composing text error

pr675
Hufe921 3 years ago
parent 266915af09
commit 310e0e91fb

@ -7,23 +7,27 @@ function compositionstart(host: CanvasEvent) {
function compositionend(host: CanvasEvent, evt: CompositionEvent) {
host.isComposing = false
removeComposingInput(host)
// 处理输入框关闭
const draw = host.getDraw()
const cursor = draw.getCursor()
// 合成结果不存在(输入框关闭)无法触发input事件需手动触发渲染
// 不存在值:删除合成输入
if (!evt.data) {
const agentText = cursor.getAgentDomValue()
if (agentText) {
input(agentText, host)
} else {
const rangeManager = draw.getRange()
const { endIndex: curIndex } = rangeManager.getRange()
draw.render({
curIndex
})
}
removeComposingInput(host)
const rangeManager = draw.getRange()
const { endIndex: curIndex } = rangeManager.getRange()
draw.render({
curIndex,
isSubmitHistory: false
})
} else {
// 存在值无法触发input事件需手动检测并触发渲染
setTimeout(() => {
if (host.compositionInfo) {
input(evt.data, host)
}
})
}
// 移除代理输入框数据
const cursor = draw.getCursor()
cursor.clearAgentDomValue()
}

@ -12,18 +12,19 @@ export function input(data: string, host: CanvasEvent) {
const position = draw.getPosition()
const cursorPosition = position.getCursorPosition()
if (!data || !cursorPosition) return
const isComposing = host.isComposing
// 正在合成文本进行非输入操作
if (isComposing && host.compositionInfo?.value === data) return
const control = draw.getControl()
if (control.isPartRangeInControlOutside()) {
// 忽略选区部分在控件的输入
return
}
const isComposing = host.isComposing
// 移除合成输入
removeComposingInput(host)
if (!isComposing) {
const cursor = draw.getCursor()
cursor.clearAgentDomValue()
} else {
removeComposingInput(host)
}
const activeControl = control.getActiveControl()
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType

Loading…
Cancel
Save