Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5654 make iOS can not input by composition #5762

Open
tomdyqin opened this issue Nov 7, 2024 · 0 comments
Open

#5654 make iOS can not input by composition #5762

tomdyqin opened this issue Nov 7, 2024 · 0 comments
Labels

Comments

@tomdyqin
Copy link

tomdyqin commented Nov 7, 2024

Description
A clear and concise description of what the bug is.

Recording
A GIF or video showing the issue happening. (If you don't include this, there's a very good chance your issue will be closed, because it's much too hard to figure out exactly what is going wrong, and it makes maintenance much harder.)

Sandbox
A link to a sandbox where the error can be reproduced. (You can start from the base sandbox here: https://codesandbox.io/s/slate-reproductions-c7gyg or refer to the Slate website too.)

Steps
To reproduce the behavior:

  1. Go to page with placeholder
  2. Change IME to default composition lang. like 'Chinese'
  3. Input some word, like 'zhongwen'
  4. Click to pick word, end composition
  5. See error

Expectation
Input some composition lang. at empty editor

Environment

  • Slate Version: 0.103.0
  • Slate React: 0.105.0
  • Operating System: iOS
  • Browser: Safari
  • TypeScript Version: 5.0.2

Context

// slate/packages/slate-react/src/components/editable.tsx
// it will throw error because when input onCompositionEnd,  dom is empty
 const range = ReactEditor.toSlateRange(editor, targetRange, {
              exactMatch: false,
              suppressThrow: false,
})

my solution

// postinstall.js
const path = require('path');
const { writeFileSync, readFileSync } = require('fs-extra');
const replace = (jsPath) => {
  const npmPath = path.resolve(__dirname, '../', jsPath);
  const original = readFileSync(npmPath, 'utf-8');
  const replaced = original.replace('!(IS_ANDROID || IS_IOS)', '!IS_ANDROID');
  if (original === replaced) {
    console.log(`${jsPath} not replacement was made.`);
  } else {
    writeFileSync(npmPath, replaced);
    console.log(`${jsPath} replacement was successful.`);
  }
};
replace('node_modules/slate-react/dist/index.js');
replace('node_modules/slate-react/dist/index.es.js');

#5654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant