ime.composition event
通知合成文本的开始、范围变化、提交或取消。它与普通按键事件不同,不能由 input.key 推导。
Event payload
{
handle,
phase: "start" | "update" | "commit" | "cancel",
range?: { start, end },
revision: u64
}
Examples
host.events.on('ime.composition', ({ phase, range }) => {
if (phase === 'update' && range) editor.markComposition(range);
if (phase === 'commit' || phase === 'cancel') editor.clearComposition();
});
Delivery rules
会话失焦时必须以 commit 或 cancel 明确结束活动合成,不能留下悬空范围。