toggle icon when state of header changed; set content in silent

This commit is contained in:
houxg
2016-12-05 14:52:04 +08:00
parent 2206c30779
commit ca5c38e71c
7 changed files with 18 additions and 4 deletions

View File

@@ -21,7 +21,8 @@ public abstract class Editor {
ITALIC,
ORDER_LIST,
UNORDER_LIST,
BLOCK_QUOTE;
HEADER,
BLOCK_QUOTE
}
protected EditorListener mListener;

View File

@@ -78,6 +78,9 @@ public class QuillCallbackHandler {
case "blockquote":
formatStatusMap.put(Editor.Style.BLOCK_QUOTE, getBoolean((Boolean) format.getValue()));
break;
case "header":
Double headerLevel = ((Double)format.getValue());
formatStatusMap.put(Editor.Style.HEADER, headerLevel != null && headerLevel > 0);
}
}
return formatStatusMap;

View File

@@ -69,7 +69,7 @@ public class RichTextEditor extends Editor implements OnJsEditorStateChangedList
@Override
public void setContent(String content) {
execJs(String.format(Locale.US, "quill.pasteHTML('%s');", HtmlUtils.escapeHtml(content)));
execJs(String.format(Locale.US, "quill.pasteHTML('%s', 'silent');", HtmlUtils.escapeHtml(content)));
}
@Override

View File

@@ -331,6 +331,11 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
case BLOCK_QUOTE:
mQuoteBtn.setChecked(enabled);
break;
case HEADER:
if (mHeadingBtn != null) {
mHeadingBtn.setChecked(enabled);
}
break;
}
}
}
@@ -357,6 +362,11 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
case UNORDER_LIST:
mUnorderListBtn.setChecked(enabled);
break;
case HEADER:
if (mHeadingBtn != null) {
mHeadingBtn.setChecked(enabled);
}
break;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

View File

@@ -42,8 +42,8 @@
<org.houxg.leamonax.widget.ToggleImageButton
android:id="@+id/btn_heading"
style="@style/FormatButton"
app:checkedDrawable="@drawable/ic_heading_enable"
app:uncheckedDrawable="@drawable/ic_heading_disable" />
app:checkedDrawable="@drawable/ic_header_richtext_enable"
app:uncheckedDrawable="@drawable/ic_header_richtext_disable" />
<org.houxg.leamonax.widget.ToggleImageButton
android:id="@+id/btn_unorder_list"