Skip to content

feat: GutenbergKit supports mentions and cross-posts #22109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,10 @@ class EditPostActivity : BaseAppCompatActivity(), EditorFragmentActivity, Editor
if (editorFragment is GutenbergEditorFragment) {
(editorFragment as GutenbergEditorFragment).updateCapabilities(gutenbergPropsBuilder)
}
if (editorFragment is GutenbergKitEditorFragment) {
val enableXPosts = siteModel.isUsingWpComRestApi && (isXPostsCapable == null || isXPostsCapable == true)
(editorFragment as GutenbergKitEditorFragment).setXPostsEnabled(enableXPosts)
}
}

private val gutenbergPropsBuilder: GutenbergPropsBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
private var isEditorStarted = false
private var isEditorDidMount = false
private var rootView: View? = null
private var isXPostsEnabled: Boolean = false

// Access settings through ViewModel
private val settings: GutenbergKitSettings?
Expand Down Expand Up @@ -139,6 +140,31 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
featuredImageChangeListener?.let(gutenbergView::setFeaturedImageChangeListener)
openMediaLibraryListener?.let(gutenbergView::setOpenMediaLibraryListener)
onLogJsExceptionListener?.let(gutenbergView::setLogJsExceptionListener)

// Set up autocomplete listener for user mentions and cross-post suggestions
gutenbergView.setAutocompleterTriggeredListener(object : GutenbergView.AutocompleterTriggeredListener {
override fun onAutocompleterTriggered(type: String) {
when (type) {
"at-symbol" -> mEditorFragmentListener.showUserSuggestions { result ->
result?.let {
// Appended space completes the autocomplete session
gutenbergView.appendTextAtCursor("$it ")
}
}
"plus-symbol" -> {
if (isXPostsEnabled) {
mEditorFragmentListener.showXpostSuggestions { result ->
result?.let {
// Appended space completes the autocomplete session
gutenbergView.appendTextAtCursor("$it ")
}
}
}
}
}
}
})

gutenbergView.setEditorDidBecomeAvailable {
isEditorDidMount = true
mEditorFragmentListener.onEditorFragmentContentReady(ArrayList<Any?>(), false)
Expand Down Expand Up @@ -523,6 +549,10 @@ class GutenbergKitEditorFragment : EditorFragmentAbstract(), EditorMediaUploadLi
gutenbergView?.start(config)
}

fun setXPostsEnabled(enabled: Boolean) {
isXPostsEnabled = enabled
}

private fun buildEditorConfiguration(editorSettings: String): EditorConfiguration {
val kitSettings = settings!!

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ google-play-services-auth = '20.4.1'
google-services = '4.4.3'
gravatar = '2.5.0'
greenrobot-eventbus = '3.3.1'
gutenberg-kit = 'v0.7.0'
gutenberg-kit = 'v0.8.0-alpha.0'
gutenberg-mobile = 'v1.121.0'
indexos-media-for-mobile = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'
jackson-databind = '2.12.7.1'
Expand Down