Skip to content

Commit

Permalink
Merge pull request #51 from wordpress-mobile/issue/improve_propagatio…
Browse files Browse the repository at this point in the history
…n_of_change_events

Improve propagation of change events
  • Loading branch information
SergioEstevao authored Sep 12, 2018
2 parents be08be7 + bf62df7 commit fea6f0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 8 additions & 7 deletions ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,14 @@ class RCTAztecView: Aztec.TextView {

super.insertText(text)
updatePlaceholderVisibility()

if let onChange = onChange {
let text = packForRN(getHTML(), withName: "text")
onChange(text)
}
}

open override func deleteBackward() {
super.deleteBackward()
updatePlaceholderVisibility()

}

func propagateContentChanges() {
if let onChange = onChange {
let text = packForRN(getHTML(), withName: "text")
onChange(text)
Expand Down Expand Up @@ -149,7 +146,6 @@ class RCTAztecView: Aztec.TextView {
case "strikethrough": toggleStrikethrough(range: selectedRange)
default: print("Format not recognized")
}
propagateFormatChanges()
}

func propagateFormatChanges() {
Expand Down Expand Up @@ -181,5 +177,10 @@ extension RCTAztecView: UITextViewDelegate {
propagateFormatChanges()
}

func textViewDidChange(_ textView: UITextView) {
propagateFormatChanges()
propagateContentChanges()
}

}

3 changes: 1 addition & 2 deletions ios/RNTAztecView/RCTAztecViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ - (void)executeBlock:(ActionBlock)block onNode:(NSNumber *)node {
}

RCT_EXPORT_METHOD(applyFormat:(nonnull NSNumber *)node format:(NSString *)format)
{
RCTLogInfo(@"Apply format: %@", format);
{
[self executeBlock:^(RCTAztecView *aztecView) {
[aztecView applyWithFormat:format];
} onNode:node];
Expand Down

0 comments on commit fea6f0a

Please sign in to comment.