codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.78k stars 369 forks source link

EditorView compositionend state #1069

Closed mainhanu closed 1 year ago

mainhanu commented 1 year ago

I use codemirror in a react component, and want to trigger onChange props when code changes

EditorView.updateListener.of((v) => {
  // trigget props.onChange 
})

when use IME, I want to trigger onChange only when composition end, how can I konw this state.

I tried composing,but the value is also true when composition end

marijnh commented 1 year ago

Indeed, view.compositing is still true when the last change the the composition is applied. You could set a timeout when composing changes come in, to flush them when view.composing is false, maybe?

mainhanu commented 1 year ago

Indeed, view.compositing is still true when the last change the the composition is applied. You could set a timeout when composing changes come in, to flush them when view.composing is false, maybe?

when to flush the change?if last change is by IME composition end, the prev change may be lost?

marijnh commented 1 year ago

I don't understand what you mean by that. What does it mean for a change to be lost?

(In any case, I'm closing this, since it's a question, which are better asked on the forum.)