support redo/undo
@@ -69,4 +69,5 @@ dependencies {
|
||||
compile 'com.android.support:support-v13:24.1.0'
|
||||
compile project(':img-selector')
|
||||
compile 'com.facebook.stetho:stetho:1.4.1'
|
||||
compile 'com.github.houxg:FlexLayout:1.2'
|
||||
}
|
||||
|
@@ -45,6 +45,10 @@ public abstract class Editor {
|
||||
|
||||
public abstract void updateLink(String title, String url);
|
||||
|
||||
public abstract void redo();
|
||||
|
||||
public abstract void undo();
|
||||
|
||||
public abstract void toggleOrderList();
|
||||
|
||||
public abstract void toggleUnorderList();
|
||||
|
@@ -86,6 +86,16 @@ public class MarkdownEditor extends Editor {
|
||||
execJs(String.format(Locale.US, "ZSSEditor.updateLink('%s', '%s');", url, title));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo() {
|
||||
execJs("MD.undoMgr.redo()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
execJs("MD.undoMgr.undo()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleOrderList() {
|
||||
execJs("ZSSEditor.setOrderedList();");
|
||||
|
@@ -2,6 +2,7 @@ package org.houxg.leanotelite.editor;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
@@ -95,6 +96,16 @@ public class RichTextEditor extends Editor implements OnJsEditorStateChangedList
|
||||
execJs(String.format(Locale.US, "ZSSEditor.updateLink('%s', '%s');", url, title));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo() {
|
||||
execJs("ZSSEditor.redo();");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
execJs("ZSSEditor.undo();");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleOrderList() {
|
||||
execJs("ZSSEditor.setOrderedList();");
|
||||
|
@@ -44,7 +44,7 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
private EditorFragmentListener mListener;
|
||||
private Editor mEditor;
|
||||
|
||||
@BindView(R.id.ll_tools)
|
||||
@BindView(R.id.fl_tools)
|
||||
View mToolContainer;
|
||||
|
||||
@BindView(R.id.btn_bold)
|
||||
@@ -201,6 +201,16 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
mEditor.toggleItalic();
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_undo)
|
||||
void undo() {
|
||||
mEditor.undo();
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_redo)
|
||||
void redo() {
|
||||
mEditor.redo();
|
||||
}
|
||||
|
||||
public void setEditingEnabled(boolean enabled) {
|
||||
mIsEditingEnabled = enabled;
|
||||
mEditor.setEditingEnabled(enabled);
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 962 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_insert_link_black_enable.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_redo_black_disable.png
Normal file
After Width: | Height: | Size: 981 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_redo_black_enable.png
Normal file
After Width: | Height: | Size: 997 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_undo_black_disable.png
Normal file
After Width: | Height: | Size: 1008 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_undo_black_enable.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
@@ -4,11 +4,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_tools"
|
||||
<org.houxg.flexlayout.FlexLayout
|
||||
android:id="@+id/fl_tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:justify_content="space_between"
|
||||
android:background="#EEEEEE">
|
||||
|
||||
<ImageView
|
||||
@@ -16,49 +17,49 @@
|
||||
style="@style/FormatButton"
|
||||
android:src="@drawable/ic_insert_photo_black_disable" />
|
||||
|
||||
<include layout="@layout/separator_horizontal" />
|
||||
|
||||
<org.houxg.leanotelite.widget.ToggleImageButton
|
||||
android:id="@+id/btn_link"
|
||||
style="@style/FormatButton"
|
||||
android:src="@drawable/ic_insert_link_black_disable" />
|
||||
|
||||
<include layout="@layout/separator_horizontal" />
|
||||
|
||||
<org.houxg.leanotelite.widget.ToggleImageButton
|
||||
android:id="@+id/btn_order_list"
|
||||
style="@style/FormatButton"
|
||||
app:checkedDrawable="@drawable/ic_format_list_bulleted_black_enable"
|
||||
app:uncheckedDrawable="@drawable/ic_format_list_bulleted_black_disable" />
|
||||
|
||||
<include layout="@layout/separator_horizontal" />
|
||||
|
||||
<org.houxg.leanotelite.widget.ToggleImageButton
|
||||
android:id="@+id/btn_unorder_list"
|
||||
style="@style/FormatButton"
|
||||
app:checkedDrawable="@drawable/ic_format_list_numbered_black_enable"
|
||||
app:uncheckedDrawable="@drawable/ic_format_list_numbered_black_disable" />
|
||||
|
||||
<include layout="@layout/separator_horizontal" />
|
||||
|
||||
<org.houxg.leanotelite.widget.ToggleImageButton
|
||||
android:id="@+id/btn_bold"
|
||||
style="@style/FormatButton"
|
||||
app:checkedDrawable="@drawable/ic_format_bold_black_enable"
|
||||
app:uncheckedDrawable="@drawable/ic_format_bold_black_disable" />
|
||||
|
||||
<include layout="@layout/separator_horizontal" />
|
||||
|
||||
<org.houxg.leanotelite.widget.ToggleImageButton
|
||||
android:id="@+id/btn_italic"
|
||||
style="@style/FormatButton"
|
||||
app:checkedDrawable="@drawable/ic_format_italic_black_enable"
|
||||
app:uncheckedDrawable="@drawable/ic_format_italic_black_disable" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_undo"
|
||||
style="@style/FormatButton"
|
||||
android:src="@drawable/ic_undo_black_disable" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_redo"
|
||||
style="@style/FormatButton"
|
||||
android:src="@drawable/ic_redo_black_disable" />
|
||||
</org.houxg.flexlayout.FlexLayout>
|
||||
|
||||
<org.houxg.leanotelite.widget.LeaWebView
|
||||
android:id="@+id/web_editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/ll_tools" />
|
||||
android:layout_above="@id/fl_tools" />
|
||||
</RelativeLayout>
|
||||
|