mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -87,7 +87,7 @@ public final class TextFieldComponent: Component {
|
||||
case images([UIImage])
|
||||
case video(Data)
|
||||
case gif(Data)
|
||||
case text
|
||||
case text(NSAttributedString)
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ public final class TextFieldComponent: Component {
|
||||
public let characterLimit: Int?
|
||||
public let enableInlineAnimations: Bool
|
||||
public let emptyLineHandling: EmptyLineHandling
|
||||
public let externalHandlingForMultilinePaste: Bool
|
||||
public let formatMenuAvailability: FormatMenuAvailability
|
||||
public let returnKeyType: UIReturnKeyType
|
||||
public let lockedFormatAction: () -> Void
|
||||
@@ -184,6 +185,7 @@ public final class TextFieldComponent: Component {
|
||||
characterLimit: Int? = nil,
|
||||
enableInlineAnimations: Bool = true,
|
||||
emptyLineHandling: EmptyLineHandling = .allowed,
|
||||
externalHandlingForMultilinePaste: Bool = false,
|
||||
formatMenuAvailability: FormatMenuAvailability,
|
||||
returnKeyType: UIReturnKeyType = .default,
|
||||
lockedFormatAction: @escaping () -> Void,
|
||||
@@ -471,6 +473,10 @@ public final class TextFieldComponent: Component {
|
||||
if let attributedString = attributedString {
|
||||
let current = self.inputState
|
||||
let range = NSMakeRange(current.selectionRange.lowerBound, current.selectionRange.count)
|
||||
if component.externalHandlingForMultilinePaste, component.emptyLineHandling == .notAllowed, attributedString.string.contains("\n") {
|
||||
component.paste(.text(attributedString))
|
||||
return false
|
||||
}
|
||||
if !self.chatInputTextNode(shouldChangeTextIn: range, replacementText: attributedString.string) {
|
||||
return false
|
||||
}
|
||||
@@ -487,7 +493,7 @@ public final class TextFieldComponent: Component {
|
||||
if !self.isUpdating {
|
||||
self.state?.updated(transition: ComponentTransition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(view: self, kind: .textChanged)))
|
||||
}
|
||||
component.paste(.text)
|
||||
component.paste(.text(attributedString))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -537,7 +543,7 @@ public final class TextFieldComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
component.paste(.text)
|
||||
component.paste(.text(NSAttributedString()))
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user