About the official website example ToolTips question

I borrowed this code from the official websitetooltip, but I ran into problems with the use of the project, and then tested the official website code, and the same problem

  1. When I enter English characters, it fires once by default, and state.selection.empty is true

2.When I enter Chinese characters, it is triggered twice in a row, and state.selection.empty is false the first time and true the second time

Then I debugged directly on the official website, when I entered the comma character in Chinese, I found that the cursor selected it by default, resulting in the selection not being empty, and there was no problem with English :smiling_face_with_tear:

Pls how can I solve the problem, thanks! :face_with_head_bandage:

My question is that every time I type a character such as a Chinese comma, the tooltip will appear briefly, how can I improve this problem?

GIF 2024-4-14 11-18-54

 if (state.selection.empty||view.composing) {
      this.toolTip.style.display = 'none';
     return;
}

Use view.composing to solve elegantly!!!

1 Like