-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 331/mention support on @ keypress (#22119)
* Add '@' button for inserting mentions on mobile * Move react-native-azted dependency to external dependencies section * Handle promise rejection. * Fix focus issue. * Add space after mention * Update selection onFocus. * Check for site capabilities for mentions support * Add the mention button inside a toolbar. * Use HOC for site capabilities. * Only include space after mention on iOS On Android we are discarding selections when we think they might get stripped by Aztec, so adding the space to the ends results in the selection values getting discarded. * Use onKeyDown instead of onEnter and onBackspace. * Intercept @ keypress to trigger mention UI. * Intercept @ keypress to trigger mention UI. * Trigger the UI for mentions only when there is a space before the @ * Put mentions behind the DEV flag. * Only trigger @ keypress on DEV builds. * Remove DEV flag * Only make mention keypress available when capabilities and editing menu are on. * Enable space after mention on Android * Remove DEV flag for toolbar mention button. * Bring changes from gb-mobile to the monorepo structure. * Check triggerKeyCodes on Android * Add newline to end of file * Update code to use keycodes. * Update GB main reference. * Update dependencies. Co-authored-by: Matt Chowning <[email protected]>
- Loading branch information
1 parent
40be8a5
commit 6225038
Showing
9 changed files
with
220 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...android/src/main/java/org/wordpress/mobile/ReactNativeAztec/AztecReactTextChangedEvent.kt
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,34 @@ | ||
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 | ||
|
||
/** | ||
* This event includes all data contained in [com.facebook.react.views.textinput.ReactTextChangedEvent], | ||
* plus some extra info Gutenberg needs from Aztec. | ||
*/ | ||
class AztecReactTextChangedEvent( | ||
viewId: Int, | ||
private val mText: String, | ||
private val mEventCount: Int, | ||
private val mMostRecentChar: Char? | ||
) : Event<AztecReactTextChangedEvent>(viewId) { | ||
|
||
override fun getEventName(): String = "topAztecChange" | ||
|
||
override fun dispatch(rctEventEmitter: RCTEventEmitter) { | ||
rctEventEmitter.receiveEvent(viewTag, eventName, serializeEventData()) | ||
} | ||
|
||
private fun serializeEventData(): WritableMap = | ||
Arguments.createMap().apply { | ||
putString("text", mText) | ||
putInt("eventCount", mEventCount) | ||
putInt("target", viewTag) | ||
if (mMostRecentChar != null) { | ||
putInt("keyCode", mMostRecentChar.toInt()) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.