Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Fix typing Chinese in Edge (#2082) (#2088)
Browse files Browse the repository at this point in the history
Summary:
Fixes #2082.
Pull Request resolved: #2088

Differential Revision: D18698264

Pulled By: mrkev

fbshipit-source-id: f5f5d4e4a0ff66a9fef62976af8726660411a106
  • Loading branch information
robbertbrak authored and facebook-github-bot committed Dec 4, 2019
1 parent 861aab8 commit 8c0727e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/component/handlers/composition/DOMObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ class DOMObserver {
return target.textContent;
}
} else if (type === 'childList') {
// `characterData` events won't happen or are ignored when
// removing the last character of a leaf node, what happens
// instead is a `childList` event with a `removedNodes` array.
// For this case the textContent should be '' and
// `DraftModifier.replaceText` will make sure the content is
// updated properly.
if (removedNodes && removedNodes.length) {
// `characterData` events won't happen or are ignored when
// removing the last character of a leaf node, what happens
// instead is a `childList` event with a `removedNodes` array.
// For this case the textContent should be '' and
// `DraftModifier.replaceText` will make sure the content is
// updated properly.
return '';
} else if (target.textContent !== '') {
// Typing Chinese in an empty block in MS Edge results in a
// `childList` event with non-empty textContent.
// See https://github.com/facebook/draft-js/issues/2082
return target.textContent;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getEditorStateFromHTML(html: string) {
const state =
blocksFromHTML != null
? ContentState.createFromBlockArray(
blocksFromHTML.contentBlocks ?? [],
blocksFromHTML.contentBlocks || [],
blocksFromHTML.entityMap,
)
: ContentState.createEmpty();
Expand Down

0 comments on commit 8c0727e

Please sign in to comment.