@@ -75,6 +75,7 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
75
75
private var isEditorStarted = false
76
76
private var isEditorDidMount = false
77
77
private var rootView: View ? = null
78
+ private var isXPostsEnabled: Boolean = false
78
79
79
80
// Access settings through ViewModel
80
81
private val settings: GutenbergKitSettings ?
@@ -139,6 +140,31 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
139
140
featuredImageChangeListener?.let (gutenbergView::setFeaturedImageChangeListener)
140
141
openMediaLibraryListener?.let (gutenbergView::setOpenMediaLibraryListener)
141
142
onLogJsExceptionListener?.let (gutenbergView::setLogJsExceptionListener)
143
+
144
+ // Set up autocomplete listener for user mentions and cross-post suggestions
145
+ gutenbergView.setAutocompleterTriggeredListener(object : GutenbergView .AutocompleterTriggeredListener {
146
+ override fun onAutocompleterTriggered (type : String ) {
147
+ when (type) {
148
+ " at-symbol" -> mEditorFragmentListener.showUserSuggestions { result ->
149
+ result?.let {
150
+ // Appended space completes the autocomplete session
151
+ gutenbergView.appendTextAtCursor(" $it " )
152
+ }
153
+ }
154
+ " plus-symbol" -> {
155
+ if (isXPostsEnabled) {
156
+ mEditorFragmentListener.showXpostSuggestions { result ->
157
+ result?.let {
158
+ // Appended space completes the autocomplete session
159
+ gutenbergView.appendTextAtCursor(" $it " )
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ })
167
+
142
168
gutenbergView.setEditorDidBecomeAvailable {
143
169
isEditorDidMount = true
144
170
mEditorFragmentListener.onEditorFragmentContentReady(ArrayList <Any ?>(), false )
@@ -523,6 +549,10 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
523
549
gutenbergView?.start(config)
524
550
}
525
551
552
+ fun setXPostsEnabled (enabled : Boolean ) {
553
+ isXPostsEnabled = enabled
554
+ }
555
+
526
556
private fun buildEditorConfiguration (editorSettings : String ): EditorConfiguration {
527
557
val kitSettings = settings!!
528
558
0 commit comments