Skip to content

Commit

Permalink
Merge pull request #56 from wordpress-mobile/fix/emit-onChange-on-sty…
Browse files Browse the repository at this point in the history
…ling

Fix missing styling - Send back to JS the HTML content after a styling command
  • Loading branch information
daniloercoli authored Sep 21, 2018
2 parents f728339 + 82cb251 commit fc3e909
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.textinput.ContentSizeWatcher;
import com.facebook.react.views.textinput.ReactTextChangedEvent;
import com.facebook.react.views.textinput.ReactTextInputLocalData;
import com.facebook.react.views.textinput.ScrollWatcher;

Expand Down Expand Up @@ -261,6 +262,16 @@ public void applyFormat(String format) {
// Update the toolbar state
updateToolbarButtons(getSelectionStart(), getSelectionEnd());
}

// emit onChange because the underlying HTML has changed applying the style
ReactContext reactContext = (ReactContext) getContext();
EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(
new ReactTextChangedEvent(
getId(),
toHtml(false),
incrementAndGetEventCounter())
);
}

// Removes all formats in the list but if none found, applies the first one
Expand Down

0 comments on commit fc3e909

Please sign in to comment.