Spoiler fixes

This commit is contained in:
Ilya Laktyushin 2021-12-22 16:52:03 +04:00
parent 8a5d0ded9f
commit d5fbab8e56
2 changed files with 29 additions and 5 deletions

View File

@ -58,8 +58,6 @@ public class InvisibleInkDustNode: ASDisplayNode {
private let emitterSpotNode: ASImageNode
private let emitterMaskFillNode: ASDisplayNode
public var isRevealedUpdated: (Bool) -> Void = { _ in }
public var isRevealed = false
public init(textNode: TextNode?) {
@ -232,7 +230,7 @@ public class InvisibleInkDustNode: ASDisplayNode {
square += Float(rect.width * rect.height)
}
self.emitter?.birthRate = square * 0.4
self.emitter?.birthRate = min(100000, square * 0.33)
}
public func update(size: CGSize, color: UIColor, rects: [CGRect], wordRects: [CGRect]) {

View File

@ -2260,10 +2260,36 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
} else if action == #selector(self.formatAttributesBold(_:)) || action == #selector(self.formatAttributesItalic(_:)) || action == #selector(self.formatAttributesMonospace(_:)) || action == #selector(self.formatAttributesLink(_:)) || action == #selector(self.formatAttributesStrikethrough(_:)) || action == #selector(self.formatAttributesUnderline(_:)) || action == #selector(self.formatAttributesSpoiler(_:)) {
if case .format = self.inputMenu.state {
if action == #selector(self.formatAttributesSpoiler(_:)), let selectedRange = self.textInputNode?.selectedRange {
var intersectsMonospace = false
self.inputTextState.inputText.enumerateAttributes(in: selectedRange, options: [], using: { attributes, _, _ in
if let _ = attributes[ChatTextInputAttributes.monospace] {
intersectsMonospace = true
}
})
if !intersectsMonospace {
return ASEditableTextNodeTargetForAction(target: self)
} else {
return ASEditableTextNodeTargetForAction(target: nil)
}
} else if action == #selector(self.formatAttributesMonospace(_:)), let selectedRange = self.textInputNode?.selectedRange {
var intersectsSpoiler = false
self.inputTextState.inputText.enumerateAttributes(in: selectedRange, options: [], using: { attributes, _, _ in
if let _ = attributes[ChatTextInputAttributes.spoiler] {
intersectsSpoiler = true
}
})
if !intersectsSpoiler {
return ASEditableTextNodeTargetForAction(target: self)
} else {
return ASEditableTextNodeTargetForAction(target: nil)
}
} else {
return ASEditableTextNodeTargetForAction(target: self)
}
} else {
return ASEditableTextNodeTargetForAction(target: nil)
}
}
if case .format = self.inputMenu.state {
return ASEditableTextNodeTargetForAction(target: nil)