dankito / RichTextEditor

Rich text WYSIWYG editor for Android and JavaFX
Apache License 2.0
92 stars 36 forks source link

how to insert image from local #16

Closed kunz398 closed 5 years ago

kunz398 commented 5 years ago

i have this so far

`<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

<net.dankito.richtexteditor.android.RichTextEditor
    android:id="@+id/editor"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="10"
    />

<net.dankito.richtexteditor.android.toolbar.AllCommandsEditorToolbar
    android:id="@+id/editorToolbar"
    android:layout_width="match_parent"
    android:layout_height="36dp"
    android:background="@color/colorPrimary"
    />

`

and my java file is a fragment which is like: ` editor = (RichTextEditor) rootView.findViewById(R.id.editor);

    editorToolbar = (AllCommandsEditorToolbar) rootView.findViewById(R.id.editorToolbar);
    editorToolbar.setEditor(editor);`

how can i insert images from local i tried the editior.setpermission but it doesnt work it says can not resolve method pleasehelp

dankito commented 5 years ago

If you just want to allow that the user can insert images, then by adding AllCommandsEditorToolbar your're done (I personally prefer the GroupedCommandsToolbar).

Just click on this command almost at the end of AllCommandsEditorToolbar

image

and then on the button with the three dots:

image

If you like to insert images programmatically, this can be done this way:

    editor = (RichTextEditor) findViewById(R.id.editor);

    editor.getJavaScriptExecutor().insertImage("<local path>", "<description>", 0);

Does this answer your question?

kunz398 commented 5 years ago

actually fixed it thank you u can close this now