fix: render composing text error
This commit is contained in:
@@ -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 {
|
||||
removeComposingInput(host)
|
||||
const rangeManager = draw.getRange()
|
||||
const { endIndex: curIndex } = rangeManager.getRange()
|
||||
draw.render({
|
||||
curIndex
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user