-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Android support #175
Android support #175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,10 @@ var EditorState = require('EditorState'); | |
* The user has begun using an IME input system. Switching to `composite` mode | ||
* allows handling composition input and disables other edit behavior. | ||
*/ | ||
function editOnCompositionStart(): void { | ||
function editOnCompositionStart(e): void { | ||
this.setRenderGuard(); | ||
this.setMode('composite'); | ||
this._onCompositionStart(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this private method might have problems if the class is munged. Also, if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. compositionstart is only fired while we are in editmode from what I saw. the composition one has never been called while I tested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compositionstart can have a non-empty data event which indicate the part of text that is going to be replaced by composition. (on most major web browser). One alternative solution would be to stop caring about those events and diff the DOM at strategical points, updating the model based on content and not on half broken events. Not sure if it's easily doable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We could check for
I'd prefer not to do DOM diffing. Perhaps we could do something similar to the spellcheck handling in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modifier.removeRange is called with the e.data value of compositionstart later in the current patch. I wonder what is best, the text is not removed while in composition, it just get potentially updated at the end. Replace DOM content within the model was what I had in mind. Will check editOnInput why I have time. I'll be off next week. |
||
this.update( | ||
EditorState.set(this.props.editorState, {inCompositionMode: true}) | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ var findAncestorOffsetKey = require('findAncestorOffsetKey'); | |
var nullthrows = require('nullthrows'); | ||
|
||
var isGecko = UserAgent.isEngine('Gecko'); | ||
|
||
var isAndroid = UserAgent.isPlatform('Android'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be more specific about targeting browser engines? Or does this need to apply across Android? |
||
var DOUBLE_NEWLINE = '\n\n'; | ||
|
||
/** | ||
|
@@ -40,7 +40,7 @@ function editOnInput(): void { | |
var domSelection = global.getSelection(); | ||
|
||
var {anchorNode, isCollapsed} = domSelection; | ||
if (anchorNode.nodeType !== Node.TEXT_NODE) { | ||
if (anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.ELEMENT_NODE) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the scenario here? For Android text replacement, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, it just happens. Will check more carefully next time I debug draft-js There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were you able to get more details on this case? |
||
return; | ||
} | ||
|
||
|
@@ -88,7 +88,7 @@ function editOnInput(): void { | |
|
||
var anchorOffset, focusOffset, startOffset, endOffset; | ||
|
||
if (isGecko) { | ||
if (isAndroid || isGecko) { | ||
// Firefox selection does not change while the context menu is open, so | ||
// we preserve the anchor and focus values of the DOM selection. | ||
anchorOffset = domSelection.anchorOffset; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can this happen? Can this conditional be removed? It feels sketchy.