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

Japanese input seems to overlap #2595

Closed
bokuweb opened this issue Feb 13, 2019 · 7 comments
Closed

Japanese input seems to overlap #2595

bokuweb opened this issue Feb 13, 2019 · 7 comments

Comments

@bokuweb
Copy link

bokuweb commented Feb 13, 2019

Do you want to request a feature or report a bug?

Bug report

What's the current behavior?

Japanese input seems to overlap in this example (https://www.slatejs.org/#/markdown-preview). Please see following gif. I guess this behavior is occurred by decorator.

untitled

日本語 is duplicated.

My env

Google chrome 71.0.3578.98
Google 日本語入力 2.24.3250.1

What's the expected behavior?

Japanese input does not overlap with decorator.

@wuxiandiejia
Copy link

wuxiandiejia commented Feb 13, 2019

You can add onCompositionStart and onCompositionEnd props on the Editor component.

If you are composing return others in decorateNode method.

Code like this

  decorateNode = (node, editor, next) => {
    const others = next() || []
    if (node.object != 'block' || this.state.isComposing) return others
   // ...

@bokuweb
Copy link
Author

bokuweb commented Feb 13, 2019

@wuxiandiejia Thanks :) I'll try it !!

@bokuweb
Copy link
Author

bokuweb commented Feb 14, 2019

Hmm, I tried above workaround, but unfortunately it does not solve my problem... Do you have any idea??

@wuxiandiejia
Copy link

Maybe you can get help on the slate's slack channel.

@wuxiandiejia
Copy link

wuxiandiejia commented Feb 16, 2019

I found a solution.
When you are composing give the mark a new key to force the mark to re-render.

    // in decorateNode method
      if (typeof token != 'string') {
        const dec = {
          anchor: {
            key: startText.key,
            offset: startOffset,
          },
          focus: {
            key: endText.key,
            offset: endOffset,
          },
          mark: {
            type: token.type,
          },
        }
        if (this.state.isComposing) {
          const nodeKey = token.type + Date.now()
          dec.mark.data = {
            key: nodeKey
          }
        }
        decorations.push(dec)
      }
// set key prop in renderMark method
case 'bold':
        return <strong {...attributes} key={mark.data.get('key')}>{children}</strong>
// other mark also can set key

@bokuweb
Copy link
Author

bokuweb commented Feb 16, 2019

@wuxiandiejia Thanks :) I'll try it 👍

@ianstormtaylor
Copy link
Owner

Hey, thanks for reporting this. I think this is actually a duplicate of #2368, so I'm going to close this in favor of that one. Feel free to comment over there with any other info!

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

No branches or pull requests

3 participants