From b3d3ceb1714dc372aef4583fb5f6dd197adb751d Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Wed, 4 Sep 2019 17:24:07 +0300 Subject: [PATCH 1/2] Enable batch editing on font change --- react-native-aztec/ios/RNTAztecView/RCTAztecView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift index d8619eafd0..b2905335b6 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift @@ -508,12 +508,15 @@ class RCTAztecView: Aztec.TextView { let fullRange = NSRange(location: 0, length: textStorage.length) + textStorage.beginEditing() textStorage.enumerateAttributes(in: fullRange, options: []) { (attributes, subrange, stop) in let oldFont = font(from: attributes) let newFont = applyFontConstraints(to: oldFont) + textStorage.removeAttribute(.font, range: subrange) textStorage.addAttribute(.font, value: newFont, range: subrange) } + textStorage.endEditing() refreshTypingAttributesAndPlaceholderFont() } From 8cd160b9da5981062b53d88d99aa3aa23b435fa7 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Wed, 4 Sep 2019 20:53:20 +0300 Subject: [PATCH 2/2] Remove unnecessary `removeAttribute` call --- react-native-aztec/ios/RNTAztecView/RCTAztecView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift index b2905335b6..6fdb79d408 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift @@ -513,7 +513,6 @@ class RCTAztecView: Aztec.TextView { let oldFont = font(from: attributes) let newFont = applyFontConstraints(to: oldFont) - textStorage.removeAttribute(.font, range: subrange) textStorage.addAttribute(.font, value: newFont, range: subrange) } textStorage.endEditing()