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 明确结束活动合成,不能留下悬空范围。
范围使用 UTF-16 code unit offset,端点不得切开代理对。
Requirements
- 事件声明:
ime.composition - 来源:活动 ime-session 句柄
- 信任档位:继承
ime.openSession的 green