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

Fix copy paste #1193

Merged
merged 2 commits into from
May 24, 2019
Merged

Fix copy paste #1193

merged 2 commits into from
May 24, 2019

Conversation

SergioEstevao
Copy link
Contributor

Fixes #

This PR brings the fix for copy paste to develop.

To test:

  • Run the demo app
  • Copy some content from one of the demo content
  • Paste it in another app, for example Notes or Reminders
  • See that the content is pasted in plain text.

Copy link
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

This looks good – tests pass and the code is simple enough.

Tested:

✅ Pastes into Messages as Plain Text.
✅ Pastes into Notes as semi-rich text – headings, bold, italic, underline etc work. Lists don't have bullets or numbers.
✅ Pastes into WP in exactly the same way it was copied.

Works for me, so merging.

@jkmassel jkmassel merged commit 8717837 into develop May 24, 2019
@jkmassel jkmassel deleted the issue/fix_copy_paste branch May 24, 2019 20:43
@@ -555,7 +555,11 @@ open class TextView: UITextView {
// MARK: - Pasteboard Helpers

internal func storeInPasteboard(encoded data: Data, pasteboard: UIPasteboard = UIPasteboard.general) {
pasteboard.setData(data, forPasteboardType: NSAttributedString.pastesboardUTI)
if pasteboard.numberOfItems > 0 {
pasteboard.items[0][NSAttributedString.pastesboardUTI] = data;
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why we're doing this one. Why not use setItems(_:options:) in both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that, but setItems will reset everything, so unless you first copy what you already have there and add the extra UTI to it.

@SergioEstevao
Copy link
Contributor Author

SergioEstevao commented May 27, 2019 via email

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.

3 participants