diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index aa944bb84..0b7a5806a 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -87,7 +87,6 @@ 62FD27D32893707B00B205C5 /* BookmarkViewController+DataSourceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D22893707B00B205C5 /* BookmarkViewController+DataSourceProvider.swift */; }; 62FD27D52893708A00B205C5 /* BookmarkViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D42893708A00B205C5 /* BookmarkViewModel+Diffable.swift */; }; 87FFDA5D898A5C42ADCB35E7 /* Pods_Mastodon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4ABE34829701A4496C5BB64 /* Pods_Mastodon.framework */; }; - CD91FB31290EDA6F00BB9463 /* MetaTextView+PasteExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD91FB30290EDA6F00BB9463 /* MetaTextView+PasteExtensions.swift */; }; DB0009A626AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; settings = {ATTRIBUTES = (codegen, ); }; }; DB0009A726AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; }; DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0140CE25C42AEE00F9F3CF /* OSLog.swift */; }; @@ -605,7 +604,6 @@ BB482D32A7B9825BF5327C4F /* Pods-Mastodon-MastodonUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon-MastodonUITests.release.xcconfig"; path = "Target Support Files/Pods-Mastodon-MastodonUITests/Pods-Mastodon-MastodonUITests.release.xcconfig"; sourceTree = ""; }; BD7598A87F4497045EDEF252 /* Pods-Mastodon.asdk - release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.asdk - release.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.asdk - release.xcconfig"; sourceTree = ""; }; C3789232A52F43529CA67E95 /* Pods-MastodonIntent.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MastodonIntent.asdk - debug.xcconfig"; path = "Target Support Files/Pods-MastodonIntent/Pods-MastodonIntent.asdk - debug.xcconfig"; sourceTree = ""; }; - CD91FB30290EDA6F00BB9463 /* MetaTextView+PasteExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MetaTextView+PasteExtensions.swift"; sourceTree = ""; }; CD92E0F10BDE4FE7C4B999F2 /* Pods_MastodonTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MastodonTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D7D7CF93E262178800077512 /* Pods-Mastodon-AppShared.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon-AppShared.debug.xcconfig"; path = "Target Support Files/Pods-Mastodon-AppShared/Pods-Mastodon-AppShared.debug.xcconfig"; sourceTree = ""; }; DB0009A826AEE5DC009B9D2D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; name = Base; path = Base.lproj/Intents.intentdefinition; sourceTree = ""; }; @@ -1867,7 +1865,6 @@ DB8190C52601FF0400020C08 /* AttachmentContainerView.swift */, DB9A486B26032AC1008B817C /* AttachmentContainerView+EmptyStateView.swift */, DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */, - CD91FB30290EDA6F00BB9463 /* MetaTextView+PasteExtensions.swift */, ); path = View; sourceTree = ""; @@ -3296,7 +3293,6 @@ 2D84350525FF858100EECE90 /* UIScrollView.swift in Sources */, 6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */, 5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */, - CD91FB31290EDA6F00BB9463 /* MetaTextView+PasteExtensions.swift in Sources */, DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */, 0FB3D2FE25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift in Sources */, 5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */, diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index fb6ee43f9..d2bc0a2cb 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -301,6 +301,36 @@ extension ComposeViewController { } +extension ComposeViewController { + public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { + + // Enable pasting images + if (action == #selector(UIResponderStandardEditActions.paste(_:))) { + return UIPasteboard.general.hasStrings || UIPasteboard.general.hasImages; + } + + return super.canPerformAction(action, withSender: sender); + } + + override func paste(_ sender: Any?) { + logger.debug("Paste event received") + + // Look for images on the clipboard + if UIPasteboard.general.hasImages, let images = UIPasteboard.general.images { + logger.warning("Got image paste event, however attachments are not yet re-implemented."); + let attachmentViewModels = images.map { image in + return AttachmentViewModel( + api: viewModel.context.apiService, + authContext: viewModel.authContext, + input: .image(image), + delegate: composeContentViewModel + ) + } + composeContentViewModel.attachmentViewModels += attachmentViewModels + } + } +} + // MARK: - UIAdaptivePresentationControllerDelegate extension ComposeViewController: UIAdaptivePresentationControllerDelegate { @@ -455,33 +485,3 @@ extension ComposeViewController: UIAdaptivePresentationControllerDelegate { // } // //} - -extension ComposeViewController { - public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { - - // Enable pasting images - if (action == #selector(UIResponderStandardEditActions.paste(_:))) { - return UIPasteboard.general.hasStrings || UIPasteboard.general.hasImages; - } - - return super.canPerformAction(action, withSender: sender); - } - - override func paste(_ sender: Any?) { - logger.debug("Paste event received") - - // Look for images on the clipboard - if (UIPasteboard.general.hasImages) { - if let images = UIPasteboard.general.images { - logger.warning("Got image paste event, however attachments are not yet re-implemented."); -// viewModel.attachmentServices = viewModel.attachmentServices + images.map({ image in -// MastodonAttachmentService( -// context: context, -// image: image, -// initialAuthenticationBox: viewModel.authenticationBox -// ) -// }) - } - } - } -} diff --git a/Mastodon/Scene/Compose/View/MetaTextView+PasteExtensions.swift b/MastodonSDK/Sources/MastodonUI/Vendor/MetaTextView+PasteExtensions.swift similarity index 100% rename from Mastodon/Scene/Compose/View/MetaTextView+PasteExtensions.swift rename to MastodonSDK/Sources/MastodonUI/Vendor/MetaTextView+PasteExtensions.swift diff --git a/Podfile.lock b/Podfile.lock index e8785b512..3b9928a0b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -33,6 +33,6 @@ SPEC CHECKSUMS: SwiftGen: 67860cc7c3cfc2ed25b9b74cfd55495fc89f9108 XLPagerTabStrip: 61c57fd61f611ee5f01ff1495ad6fbee8bf496c5 -PODFILE CHECKSUM: a60ecee06525582c010e270ac7a17024e441a0da +PODFILE CHECKSUM: 8fddf46611e09d2eb1a5d67c464c236884a08e80 COCOAPODS: 1.11.3