Various improvements

This commit is contained in:
Ali
2023-10-29 20:30:26 +04:00
parent bbb543f836
commit 34bd339d8c
10 changed files with 108 additions and 17 deletions

View File

@@ -22,9 +22,18 @@ public protocol ChatInputTextNodeDelegate: AnyObject {
func chatInputTextNodeShouldPaste() -> Bool
func chatInputTextNodeShouldRespondToAction(action: Selector) -> Bool
func chatInputTextNodeTargetForAction(action: Selector) -> ChatInputTextNode.TargetForAction?
}
open class ChatInputTextNode: ASDisplayNode, UITextViewDelegate {
public final class TargetForAction {
public let target: Any?
public init(target: Any?) {
self.target = target
}
}
public weak var delegate: ChatInputTextNodeDelegate? {
didSet {
self.textView.customDelegate = self.delegate
@@ -124,6 +133,18 @@ open class ChatInputTextNode: ASDisplayNode, UITextViewDelegate {
return true
}
}
self.textView.targetForAction = { [weak self] action in
guard let self, let action else {
return nil
}
if let delegate = self.delegate {
return delegate.chatInputTextNodeTargetForAction(action: action).flatMap { value in
return ChatInputTextViewImplTargetForAction(target: value.target)
}
} else {
return nil
}
}
}
public func resetInitialPrimaryLanguage() {