Skip to content

Commit e6d40d8

Browse files
Merge pull request #1200 from wordpress-mobile/issue/notify_changes_only_on_user_event
Notify changes on TextView only on user events
2 parents b9e565d + 12d8bd0 commit e6d40d8

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Aztec/Classes/Extensions/UITextView+Delegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ extension UITextView {
66
/// Notifies the delegate of a text change.
77
///
88
final func notifyTextViewDidChange() {
9+
if let textView = self as? TextView, !textView.shouldNotifyOfNonUserChanges {
10+
return
11+
}
912
delegate?.textViewDidChange?(self)
1013
NotificationCenter.default.post(name: UITextView.textDidChangeNotification, object: self)
1114
}

Aztec/Classes/TextKit/TextView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ open class TextView: UITextView {
173173
///
174174
open var pasteboardDelegate: TextViewPasteboardDelegate = AztecTextViewPasteboardDelegate()
175175

176+
177+
/// If this is true the text view will notify is delegate and notification system when changes happen by calls to methods like setHTML
178+
///
179+
open var shouldNotifyOfNonUserChanges = true
180+
176181
// MARK: - Customizable Input VC
177182

178183
private var customInputViewController: UIInputViewController?

0 commit comments

Comments
 (0)