From 54ea1e9c0d9774d892eb61ea4f2e986042368119 Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 7 Jul 2021 16:41:42 +0800 Subject: [PATCH] feat: allow thread root post content selectable. ticket: #2875DRC --- Mastodon.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- Mastodon/Diffiable/Section/StatusSection.swift | 3 +++ Mastodon/Scene/Share/View/Content/StatusView.swift | 12 ++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 13bc247fb..73ab14602 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -4833,7 +4833,7 @@ repositoryURL = "https://github.com/TwidereProject/MetaTextView.git"; requirement = { kind = exactVersion; - version = 1.2.5; + version = 1.3.0; }; }; DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = { diff --git a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved index e143e8a71..1f3cc3145 100644 --- a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -114,8 +114,8 @@ "repositoryURL": "https://github.com/TwidereProject/MetaTextView.git", "state": { "branch": null, - "revision": "9ba4027ed0a88185ce95bb1773620c2ceaa9f3bb", - "version": "1.2.5" + "revision": "e2049e14ef411c6810d53c1baf553b5161c6678f", + "version": "1.3.0" } }, { diff --git a/Mastodon/Diffiable/Section/StatusSection.swift b/Mastodon/Diffiable/Section/StatusSection.swift index 33765424f..bcb462bed 100644 --- a/Mastodon/Diffiable/Section/StatusSection.swift +++ b/Mastodon/Diffiable/Section/StatusSection.swift @@ -137,6 +137,9 @@ extension StatusSection { switch item { case .root: + // allow select content + cell.statusView.contentMetaText.textView.isSelectable = true + // configure thread meta StatusSection.configureThreadMeta(cell: cell, status: status) ManagedObjectObserver.observe(object: status.reblog ?? status) .receive(on: RunLoop.main) diff --git a/Mastodon/Scene/Share/View/Content/StatusView.swift b/Mastodon/Scene/Share/View/Content/StatusView.swift index a37b431f2..d62fba0df 100644 --- a/Mastodon/Scene/Share/View/Content/StatusView.swift +++ b/Mastodon/Scene/Share/View/Content/StatusView.swift @@ -220,6 +220,7 @@ final class StatusView: UIView { metaText.textView.textContainer.lineFragmentPadding = 0 metaText.textView.textContainerInset = .zero metaText.textView.layer.masksToBounds = false + metaText.textView.textDragInteraction?.isEnabled = false // disable drag for link and attachment let paragraphStyle: NSMutableParagraphStyle = { let style = NSMutableParagraphStyle() @@ -583,6 +584,17 @@ extension StatusView: MetaTextViewDelegate { // MARK: - UITextViewDelegate extension StatusView: UITextViewDelegate { + + func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { + switch textView { + case contentMetaText.textView: + return false + default: + assertionFailure() + return true + } + } + func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { switch textView { case contentMetaText.textView: