-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from wordpress-mobile/try/add-return-html-with…
…-cursor-command Add a new `returnHTMLWithCursor` command & returning event to the editor
- Loading branch information
Showing
4 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...id/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecHtmlWithCursorEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.wordpress.mobile.ReactNativeAztec; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
/** | ||
* Event emitted by AztecText native view when full content with cursor is requested by JS | ||
*/ | ||
class ReactAztecHtmlWithCursorEvent extends Event<ReactAztecHtmlWithCursorEvent> { | ||
|
||
private static final String EVENT_NAME = "topHTMLWithCursorRequested"; | ||
|
||
private String mText; | ||
private int mCursorPosition; | ||
|
||
public ReactAztecHtmlWithCursorEvent(int viewId, String text, int cursorPosition) { | ||
super(viewId); | ||
mText = text; | ||
mCursorPosition = cursorPosition; | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public boolean canCoalesce() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); | ||
} | ||
|
||
private WritableMap serializeEventData() { | ||
WritableMap eventData = Arguments.createMap(); | ||
eventData.putInt("target", getViewTag()); | ||
eventData.putString("text", mText); | ||
eventData.putInt("cursorPosition", mCursorPosition); | ||
return eventData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters