Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX empty block creation on device running AOSP keyboard #857

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class ReactAztecText extends AztecText {
// This is required to keep placeholder text working, and start typing with styled text.
// Ref: https://github.com/wordpress-mobile/gutenberg-mobile/issues/707
private String mTagName = "";
private String mEmptyTagHTML = "";

private static final HashMap<ITextFormat, String> typingFormatsMap = new HashMap<ITextFormat, String>() {
{
Expand All @@ -88,21 +89,20 @@ public ReactAztecText(ThemedReactContext reactContext) {
this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() {
@Override
public boolean onEnterKey() {
if (shouldHandleOnEnter) {
if (shouldHandleOnEnter && !isTextChangedListenerDisabled()) {
return onEnter();
}
return false;
}
@Override
public boolean onBackspaceKey() {
if (shouldHandleOnBackspace) {
if (shouldHandleOnBackspace && !isTextChangedListenerDisabled()) {
String content = toHtml(false);
if (TextUtils.isEmpty(content)) {
return onBackspace();
}
else {
String emptyTag = "<" + getTagName() + "></" + getTagName() + ">";
if (!content.equals(emptyTag)) {
if (!content.equals(mEmptyTagHTML)) {
mkevins marked this conversation as resolved.
Show resolved Hide resolved
return onBackspace();
}
}
Expand Down Expand Up @@ -239,6 +239,7 @@ public void run() {

public void setTagName(@Nullable String tagName) {
mTagName = tagName;
mEmptyTagHTML = "<" + mTagName + "></" + mTagName + ">";
}

public String getTagName() {
Expand Down