Skip to content
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

Share Extension: Improve text import from other apps #11288

Merged
merged 7 commits into from
Mar 18, 2019

Conversation

nheagy
Copy link
Contributor

@nheagy nheagy commented Mar 15, 2019

Fixes #11222
Fixes #11270

This fixes text import from other applications by treating text from shared files differently than from text shared directly (which will still be blockquoted). It also fixes the issue of shared text (both kinds) being treated like HTML, opening the possibility of nefarious HTML making it into the user's site.

text import longer

To test:

  • Share text from bear using the export UI. See GIF. (cc: @trix180)
  • Share text from Ulysses using text UI
  • In both cases, ensure that the text appears in the body of the post without block quote
  • Also trying sharing from other text editors you may have. Some may only share the text directly, not a file, and the blockquote will still appear
  • Also, try sharing HTML source in another editor. Now that HTML should appear with escaped HTML entities.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@nheagy nheagy added this to the 12.1 milestone Mar 15, 2019
@nheagy nheagy self-assigned this Mar 15, 2019
@nheagy nheagy requested review from frosty and bummytime March 15, 2019 18:06
@nheagy nheagy changed the title Issues/11222 improve text import Share Extension: Improve text import from other apps Mar 15, 2019
Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking fantastic! Fixes the empty editor issue for me when sharing text, and looks easily extendible to add other formats in the future.

Just two small code comments from me!

} else {
returnString = "<blockquote><p>\(selectedText)\(readOnText)</p></blockquote>"
guard importedText.isEmpty else {
return "<p>\(importedText.escapeHtmlNamedEntities())</p>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have imported text, isn't it likely that it's going to be more than one paragraph? Do we need to wrap it in tags here?

@@ -195,6 +205,7 @@ private extension TypeBasedExtensionContentExtractor {

func extract(context: NSExtensionContext, completion: @escaping ([ExtractedItem]) -> Void) {
let itemProviders = context.itemProviders(ofType: acceptedType)
print(acceptedType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to log this out, should we use DDLog instead of print?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I meant to remove that entirely 😉

@nheagy
Copy link
Contributor Author

nheagy commented Mar 16, 2019

@frosty ready for re-review!

@nheagy nheagy requested a review from frosty March 16, 2019 06:07
@trix180
Copy link

trix180 commented Mar 18, 2019

This is hands down awesome.
We are working with some of the team to a custom sharing of a TextBundle format with the Wordpress app which will allow also in-place attachments and images.

About the HTML, I may be missing a use case here but I wonder if escaping it the correct approach instead of converting it to an attributed string and using it in the editor. This approach will eventually allow passing images as base64 in the HTML document.

Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@frosty
Copy link
Contributor

frosty commented Mar 18, 2019

@trix180 Thanks for the HTML –> Attributed String idea... we'll investigate!

@frosty frosty merged commit c361322 into develop Mar 18, 2019
@frosty frosty deleted the issues/11222-improve-text-import branch March 18, 2019 12:08
@frosty
Copy link
Contributor

frosty commented Mar 18, 2019

Merging as Nate is AFK this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants