Fix share extension dropping text shared alongside images - #25987
Open
joshheald wants to merge 2 commits into
Open
Fix share extension dropping text shared alongside images#25987joshheald wants to merge 2 commits into
joshheald wants to merge 2 commits into
Conversation
An image shared as a file declares `public.file-url`, which conforms to `public.url`, so `URLExtractor` claimed it. `URLExtractor` sits ahead of `PlainTextExtractor` in the extractor list, so it won the context, could not convert the image, and returned nothing. The text attachment was never read. `URLExtractor` now skips attachments that are images, leaving them to `ImageExtractor` so the text extractors after it still run. Three related improvements to the draft that is built from the share: - Text that arrives without a source URL is no longer wrapped in a blockquote. That suits a passage quoted from a web page, where it pairs with a "Read on" attribution, not somebody's own note or journal entry. - Blank lines in shared text become paragraph breaks rather than being lost. - Images append after the text instead of at the caret, which setHTML leaves at the start of the document.
Collaborator
Generated by 🚫 Danger |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34350 | |
| Version | PR #25987 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 3c83f21 | |
| Installation URL | 5afa12undovlg |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34350 | |
| Version | PR #25987 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 3c83f21 | |
| Installation URL | 1mtgii2spmq98 |
joshheald
marked this pull request as ready for review
September 3, 2026 13:43
crazytonyli
approved these changes
Sep 3, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes CMM-2397
Description
Sharing a note that contains both text and images into WordPress or Jetpack produced a draft or post with only the images. The text was lost.
Reproduced with Apple Notes and Day One.
Cause.
Text extractors are an ordered list, and the first one to claim the content wins.
URLExtractoris beforePlainTextExtractor, and claims anything with apublic.url. It doesn't actually handle the images, which are handled later byImageExtractor, but it does claim all the content. It just doesn't display itImageExtractorran separately, which is why the images still arrived.Fix.
URLExtractornow skips attachments that are images, leaving them toImageExtractorso the other text extractors after it still run.Fixing the text loss exposed three further problems in the draft that gets built, also fixed here:
insertImageAttachmentinserted atrichTextView.selectedRange, andsetHTMLleaves the caret at position 0, so every image went to the start of the document. They now append at the end. This is just a judgement call, to be honest, but made sense to me.combinedContentHTMLwrappedselectedTextin<blockquote>unconditionally. That suits a passage quoted from a web page, where it pairs with a "Read on " attribution — Safari's JS preprocessing setsselectedTextandurltogether, and that case is unchanged. Text arriving without a source URL is more likely the author's own writing, so it now stays as ordinary paragraphs.<br>.Note on interleaving
Images shared with text in this way cannot be placed back between the paragraphs they came from. Day One sends the entry as one flat
public.plain-textblob; the images carry no name and no position.Apps that share a TextBundle keep their images inline via the existing
handleTextBundlepath (added in #11223), which is unaffected by this change.Testing instructions
Requires a WordPress.com account signed in to the app, since the share extension reads its token from the shared keychain.
The reported bug
trunkthe text is missing.Paragraphs and quoting
4. Share a note with several paragraphs separated by blank lines. Expected: the paragraph breaks survive, and the text is not wrapped in a quote block.
5. In Safari, select a passage of text on a page and share it. Expected: unchanged from
trunk— a blockquote with a "Read on " attribution at the end.Regression check on packaged notes
6. From a markdown editor that shares a TextBundle (Bear, iA Writer), share a note with text between two images. Expected: unchanged from
trunk— images stay in their original positions between the paragraphs.Share.extension.text.and.images.mp4
Release notes
Added to
RELEASE-NOTES.txt.