slate
slate copied to clipboard
fix: fix wxwork(wechatwork) ime can not work
Description: Fix cannot input Chinese on wxwork(wechat work).
Example: wechat and wxwork useragent: Wechat usearagent: Mozilla/5.0 (Linux; Android 13; 22127RK46C Build/TKQ1.220905.001; wv) AppleWebKit/537.36 (KHTML%2C like Gecko) Version/4.0 Chrome/107.0.5304.141 Mobile Safari/537.36 XWEB/5127 MMWEBSDK/20230604 MMWEBID/7189 MicroMessenger/8.0.38.2400(0x28002639) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 qcloudcdn-xinan
wxwork(wexin work) useraget: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.5304.110 Safari/537.36 Language/zh wxwork/4.1.9 (MicroMessenger/6.2) WindowsWechat MailPlugin_Electron WeMail embeddisk
https://github.com/ianstormtaylor/slate/blob/a25d7a40e5440ee54e4debbf42ed1c12d9e2248a/packages/slate-react/src/components/editable.tsx#L1133-L1141 https://github.com/ianstormtaylor/slate/blob/a25d7a40e5440ee54e4debbf42ed1c12d9e2248a/packages/slate-react/src/utils/environment.ts#L56-L57 /.*Wechat/.test(navigator.userAgent) This regex will also filter the useragent of the wxwork(weixin work), causing the wxwork unable receive the IME CompositionEnd event then cannot input Chinese.
Checks
- [x] The new code matches the existing patterns and styles.
- [x] The tests pass with
yarn test
. - [x] The linter passes with
yarn lint
. (Fix errors withyarn fix
.) - [x] The relevant examples still work. (Run examples with
yarn start
.) - [x] You've added a changeset if changing functionality. (Add one with
yarn changeset add
.)
🦋 Changeset detected
Latest commit: 004e14f0f5a76a52e2ed7937805ecc0e9aa4c32e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Name | Type |
---|---|
slate-react | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@dylans I have added the changeset. Please review it again. Thank you.
Slate Can't input Chinese correctly and it carshed on wechat(windows wechat/mac wechat/wxwork) mac:
https://github.com/ianstormtaylor/slate/assets/3305041/64e51a1c-37c9-45cf-b520-0e1c7dac56aa.mp4
win:
I fixed it and it ok on wechat(windows wechat/mac wechat/wxwork...)
https://github.com/ianstormtaylor/slate/assets/3305041/c410f1c8-8865-403f-ae2d-00637abae0e4.mp4
so i want remove restrictions on wechat.
@dylans Please review it again. Thank you.
@evilbs It looks like #5497 solves this by excluding macos rather than all platforms. Could you verify if the solution in the other PR works for you or if this is the better solution?
@dylans PR #5497 doesn't resolve my issue. it is only resolved mac wechat. my case happend on window wechat browser and window wxwork browser.
https://github.com/ianstormtaylor/slate/assets/3305041/eceeef87-e905-41f1-adbd-443af7af63f1
but i found that browser of all platforms of all wechat products have the same problem. WeChat and WxWork(Enterprise WeChat) are two products, but the wechat keyword exists in their useragent
i remove the restrictions, all wechat products can work fine. i checked all platforms and all wechat products.
@evilbs, ok, but in that case it doesn't make sense to completely remove the utility function to check for the Wechat browser, but rather just not to use it here?
@dylans hi, I have restored the utility function, Just remove the check.
This is failing our tests as I believe we need to update our minimum TS version. Will try to address this soon.
Apologies, this one fell off my radar. @evilbs if you have time to clean it up, I'll review and land it.