Closed mrfoxtalbot closed 4 years ago
For some reason I am not being allowed to add tags to this issue, I am not sure why.
đź‘‹ @mrfoxtalbot labels may only be added by those with write access. We review new issues often though and if you are not able to add labels then they will mostly likely be added within a few days!
Tested and confirmed using WPAndroid 13.4-rc-1 on Pixel 3 Android 10. (1m29s)
Added to the Prioritized Android list because it involves the editor and sharing which are both very important flows for this app.
labels may only be added by those with write access.
Got it, thank you Sheri!
I'm looking into this.
Troubleshooting notes so far:
The functions that does the filling both for Aztec and Gutenberg is here:
I am not super familiar with how Gutenberg works yet in the app, but my hunch is that the editor is not loaded completely yet when mEditorFragment.setTitle(title)
is being called in the function above, hence why it has no effect on Gutenberg.
Specifically with Gutenberg, there's this EditorFragmentListener. onEditorFragmentContentReady()
function that's being called once the editor finishes loading. Calling setPostContentFromShareAction()
inside that function seems to make things work in my test.
There's also a small need to convert the content part to into a paragraph block, otherwise it's just added as a regular <p>content</p>
code that's then shown as unrecognized block in the editor.
@shiki Curious about what you would recommend for the situation above.
setPostContentFromShareAction()
inside fillContentEditorFields()
as it is now for Aztec, then add another setPostContentFromShareAction()
inside onEditorFragmentContentReady()
for Gutenberg.Nevertheless, that feels a bit odd to me (and probably will make the code more confusing to read). I would love it to be called from a single place, that handles both the Aztec and Gutenberg cases, but I'm not sure how I would structure it.
Adding a drawing I made to understand the logic flow inside EditPostActivity.java
because why not:
@hafizrahman Sorry I missed this.
It looks like you're on the right track. Though I agree that onEditorFragmentContentReady
seems like an odd place for the change.
One thing I noticed is that when editing an existing post within WordPress, the fillContentEditorFields()
is just enough for Gutenberg to preload the existing post's title and content. It looks like calling setContent
and setTitle
only works once with GutenbergEditorFragment
. The second call does not seem to work.
This is the case when sharing since, first, the setContent
is called in:
And then it's called again when setPostContentFromShareAction()
is executed:
Note that this call is still inside fillContentEditorFields()
.
It looks like the fillContentEditorFields()
would require a re-ordering of the sequence so that if there is a shared INTENT
, we should not call the first setContent
on the GutenbergEditorFragment
. I was able to test this hypothesis by changing fillContentEditorFields()
to this:
private void fillContentEditorFields() {
// Needed blog settings needed by the editor
mEditorFragment.setFeaturedImageSupported(mSite.isFeaturedImageSupported());
if (!mHasSetPostContent) {
mHasSetPostContent = true;
setPostContentFromShareAction();
return;
}
With this code, I was able to share from Youtube and the title and content was loaded. The content was showing up as “Unsupported“ though. There's probably a function somewhere we can use to create a compatible paragraph.
I hope this helps. 🙂
Just leaving a comment here that I tried with alpha-195 and was able to share an image to WordPress from Photos app and also from WhatsApp and a new Post is created, the image gets uploaded and inserted into an image block in the Gutenberg editor. Youtube on the contrary, does show the observed behavior (empty Post).
I had the same issue trying to share a link using alpha-203 (14.1). The weird part is that the post title and content is correctly set but it's not shown in the editor.
Expected behavior
When using the sharing feature from other apps into a new post on the WordPress App I would expect the title for the new post to be created automatically, and the shared content (link or image) to be added to the content.
Actual behavior
If you have the block editor enabled, using the "share to WordPress" feature will create a new empty post, it will not add the title or the content.
Interestingly enough, if you are sharing an image the image will be uploaded to the Media Library, but will not be inserted into the post.
Steps to reproduce the behavior
Enable block editor
Share image or link from a different app
The new post is empty!
Tested on [device], Android [version], WPAndroid [version]