Hi all,
I found a problem in safari browser when using prosemirror-tables
.
It is ok in chrome browser. But I test it in two version’s safari browser (v15.0, v14.1), both have the same problem.
The problem happens on IME composing (input CJK characters) and it’s ok when just input the western characters. Here are details of the problem.
- In empty
th
cell, input the CJK characters and it will auto add a new column after inputing. - In empty
td
cell, input the CJK characters and it will keep both western characters and CJK characters after inputing.
Ps: The tiptap’s table node have the same problem. And the editor of confluence seems also have the similar problem.
After some research, I think it maybe a bug of webkit engine on handling the caret in nesting element.
Then I try to fix the problem. I tried a lot:
- write some hack css(-webkit-user-modify), but it will make new problems
- read the source code of
prosemirro-view
, try to add a hack node or whatelse, but failed - …balabala
Then I find an issue: IME composing is not working when the cursor is in th tag.
It inspires me. I try to add a zero-width-space on the empty cell, then the CJK characters can be input normally.
Based on above things, I write a plugin to auto insert and delete a zero-width-sapce during input CJK characters. It really solve the problem but I am not sure it is the best way.
Tada, let the community speaks.
The demo: https://codesandbox.io/s/prosemirror-table-forked-vln1hp?file=/src/index.js:2617-2636
Enable the
autoInsertZeroSpace
plugin to see the right effect.