Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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 = '165-f5e0a7f8ba443f23562f831be31b8477fc1a3dcf'
gutenberg-mobile = 'v1.121.0'
indexos-media-for-mobile = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'
jackson-databind = '2.12.7.1'
Expand Down