wasabeef / richeditor-android

RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android.
Apache License 2.0
6.23k stars 1.2k forks source link

[Feature Request] RTL support #12

Open HassanHeydariNasab opened 9 years ago

HassanHeydariNasab commented 9 years ago

Please add RTL support ! Thanks

wasabeef commented 9 years ago

@HassanHeydariNasab

i want to pull-request..

manee1982 commented 1 year ago

@HassanHeydariNasab Yes indeed. It would be very nice if RTL is supported in this great project.

I've figure out a solution to support RTL by Extending RichEditor class and add 'setDirectionTo' method:

public class CustomRichEditor extends RichEditor {
    public CustomRichEditor(Context context) {
        super(context);
    }

    public CustomRichEditor(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomRichEditor(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setDirectionTo(String dir) {
        String direction = "(function() {" +
                "    var body  = document.getElementsByTagName(\"body\")[0];" +
                "    body.dir = \"" + dir + "\";" +
                "}) ();";
        exec("javascript:" + direction + "");
    }
}

XML code:

<your.package.name.CustomRichEditor
            android:id="@+id/theID"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="50dp"/>

Thanks in advance @wasabeef