diff --git a/react-native-aztec/ios/RNTAztecView/BlockFormatHandler.swift b/react-native-aztec/ios/RNTAztecView/BlockFormatHandler.swift deleted file mode 100644 index 4a096e28405703..00000000000000 --- a/react-native-aztec/ios/RNTAztecView/BlockFormatHandler.swift +++ /dev/null @@ -1,15 +0,0 @@ - -/// Classes conforming this protocol are meant to do formatting work over an specific block. -/// It is useful when we need to force an specific typing format that Aztec is not showing by default. -/// -protocol BlockFormatHandler { - - /// Create an instance of a block formatter handler for the given block. - /// If the given block is not compatible, the init will fail. - /// - init?(block: BlockModel) - - /// Set the typing format to an specific one. - /// - func forceTypingFormat(on textView: RCTAztecView) -} diff --git a/react-native-aztec/ios/RNTAztecView/BlockModel.swift b/react-native-aztec/ios/RNTAztecView/BlockModel.swift deleted file mode 100644 index 7a8c410149a8d5..00000000000000 --- a/react-native-aztec/ios/RNTAztecView/BlockModel.swift +++ /dev/null @@ -1,3 +0,0 @@ -struct BlockModel { - let tag: String -} diff --git a/react-native-aztec/ios/RNTAztecView/HeadingBlockFormatHandler.swift b/react-native-aztec/ios/RNTAztecView/HeadingBlockFormatHandler.swift deleted file mode 100644 index 44223934b11b0d..00000000000000 --- a/react-native-aztec/ios/RNTAztecView/HeadingBlockFormatHandler.swift +++ /dev/null @@ -1,40 +0,0 @@ -import Aztec - -struct HeadingBlockFormatHandler: BlockFormatHandler { - private let level: Header.HeaderType - private let paragraphFormatter = HTMLParagraphFormatter(placeholderAttributes: nil) - private let headerFormatter: HeaderFormatter - - init?(block: BlockModel) { - guard let level = HeadingBlockFormatHandler.headerLevel(from: block.tag) else { - return nil - } - self.level = level - headerFormatter = HeaderFormatter(headerLevel: level) - } - - func forceTypingFormat(on textView: RCTAztecView) { - var attributes = textView.typingAttributes - - attributes = paragraphFormatter.remove(from: textView.typingAttributes) - attributes = headerFormatter.apply(to: textView.typingAttributes, andStore: nil) - - textView.typingAttributes = attributes - if let font = attributes[.font] as? UIFont { - textView.placeholderLabel.font = font - } - } - - private static func headerLevel(from levelString: String) -> Header.HeaderType? { - switch levelString { - case "h2": - return .h2 - case "h3": - return .h3 - case "h4": - return .h4 - default: - return nil - } - } -} diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift index ed0ce36bb87c52..f4a091aea2e8d2 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift @@ -14,14 +14,7 @@ class RCTAztecView: Aztec.TextView { @objc var onSelectionChange: RCTBubblingEventBlock? = nil @objc var minWidth: CGFloat = 0 @objc var maxWidth: CGFloat = 0 - @objc var blockType: NSDictionary? = nil { - didSet { - guard let block = blockType, let tag = block["tag"] as? String else { - return - } - blockModel = BlockModel(tag: tag) - } - } + @objc var activeFormats: NSSet? = nil { didSet { let currentTypingAttributes = formattingIdentifiersForTypingAttributes() @@ -46,13 +39,7 @@ class RCTAztecView: Aztec.TextView { get { return super.textAlignment } - } - - var blockModel = BlockModel(tag: "") { - didSet { - forceTypingAttributesIfNeeded() - } - } + } private var previousContentSize: CGSize = .zero @@ -618,12 +605,6 @@ class RCTAztecView: Aztec.TextView { } } - func forceTypingAttributesIfNeeded() { - if let formatHandler = HeadingBlockFormatHandler(block: blockModel) { - formatHandler.forceTypingFormat(on: self) - } - } - // MARK: - Event Propagation func propagateContentChanges() { @@ -672,8 +653,7 @@ extension RCTAztecView: UITextViewDelegate { guard isInsertingDictationResult == false else { return } - - forceTypingAttributesIfNeeded() + propagateContentChanges() updatePlaceholderVisibility() //Necessary to send height information to JS after pasting text. diff --git a/react-native-aztec/ios/RNTAztecView/RCTAztecViewManager.m b/react-native-aztec/ios/RNTAztecView/RCTAztecViewManager.m index c968ec9fcaf18e..1f9d4a6a8da1ea 100644 --- a/react-native-aztec/ios/RNTAztecView/RCTAztecViewManager.m +++ b/react-native-aztec/ios/RNTAztecView/RCTAztecViewManager.m @@ -11,7 +11,6 @@ @interface RCT_EXTERN_MODULE(RCTAztecViewManager, NSObject) RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onPaste, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock) -RCT_EXPORT_VIEW_PROPERTY(blockType, NSDictionary) RCT_EXPORT_VIEW_PROPERTY(activeFormats, NSSet) RCT_EXPORT_VIEW_PROPERTY(onActiveFormatsChange, RCTBubblingEventBlock)