Skip to content

Commit

Permalink
fix: chromium interrupt ime (#5736)
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax authored Oct 8, 2024
1 parent b1a1021 commit 8c7f7ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
28 changes: 16 additions & 12 deletions site/examples/js/mentions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,22 @@ const Mention = ({ attributes, children, element }) => {
data-cy={`mention-${element.character.replace(' ', '-')}`}
style={style}
>
{IS_MAC ? (
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490
<Fragment>
{children}@{element.character}
</Fragment>
) : (
// Others like Android https://github.com/ianstormtaylor/slate/pull/5360
<Fragment>
@{element.character}
{children}
</Fragment>
)}
{/* Prevent Chromium from interrupting IME when moving the cursor */}
{/* 1. span + inline-block 2. div + contenteditable=false */}
<div contentEditable={false}>
{IS_MAC ? (
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490
<Fragment>
{children}@{element.character}
</Fragment>
) : (
// Others like Android https://github.com/ianstormtaylor/slate/pull/5360
<Fragment>
@{element.character}
{children}
</Fragment>
)}
</div>
</span>
)
}
Expand Down
28 changes: 16 additions & 12 deletions site/examples/ts/mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,22 @@ const Mention = ({ attributes, children, element }) => {
data-cy={`mention-${element.character.replace(' ', '-')}`}
style={style}
>
{IS_MAC ? (
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490
<Fragment>
{children}@{element.character}
</Fragment>
) : (
// Others like Android https://github.com/ianstormtaylor/slate/pull/5360
<Fragment>
@{element.character}
{children}
</Fragment>
)}
{/* Prevent Chromium from interrupting IME when moving the cursor */}
{/* 1. span + inline-block 2. div + contenteditable=false */}
<div contentEditable={false}>
{IS_MAC ? (
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490
<Fragment>
{children}@{element.character}
</Fragment>
) : (
// Others like Android https://github.com/ianstormtaylor/slate/pull/5360
<Fragment>
@{element.character}
{children}
</Fragment>
)}
</div>
</span>
)
}
Expand Down

0 comments on commit 8c7f7ea

Please sign in to comment.