Skip to content

Fix share extension dropping text shared alongside images - #25987

Open
joshheald wants to merge 2 commits into
trunkfrom
fix/cmm-2397-share-extension-drops-text
Open

Fix share extension dropping text shared alongside images#25987
joshheald wants to merge 2 commits into
trunkfrom
fix/cmm-2397-share-extension-drops-text

Conversation

@joshheald

@joshheald joshheald commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

URLExtractor is before PlainTextExtractor, and claims anything with a public.url. It doesn't actually handle the images, which are handled later by ImageExtractor, but it does claim all the content. It just doesn't display it

ImageExtractor ran separately, which is why the images still arrived.

Fix. URLExtractor now skips attachments that are images, leaving them to ImageExtractor so 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:

  • Images were placed above the text. insertImageAttachment inserted at richTextView.selectedRange, and setHTML leaves 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.
  • A shared note became a blockquote. combinedContentHTML wrapped selectedText in <blockquote> unconditionally. That suits a passage quoted from a web page, where it pairs with a "Read on " attribution — Safari's JS preprocessing sets selectedText and url together, 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.
  • Paragraph breaks were lost. Shared text arrives as one flat string. Blank lines now become paragraph breaks and single line breaks become <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-text blob; the images carry no name and no position.

Apps that share a TextBundle keep their images inline via the existing handleTextBundle path (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

  1. In Apple Notes or Day One, write a note with a paragraph of text and one or more images.
  2. Share → WordPress (or Jetpack) → Post as draft.
  3. Open the draft. Expected: the text is in the body and the image(s) is attached below it. On trunk the 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.

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.
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number34350
VersionPR #25987
Bundle IDorg.wordpress.alpha
Commit3c83f21
Installation URL5afa12undovlg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number34350
VersionPR #25987
Bundle IDcom.jetpack.alpha
Commit3c83f21
Installation URL1mtgii2spmq98
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald
joshheald marked this pull request as ready for review September 3, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants