/oneteam-rte-kt

Kotlin / Android wrapper for https://github.com/oneteam-dev/oneteam-rte

Primary LanguageHTMLApache License 2.0Apache-2.0

oneteam-rte-kt

CircleCI codecov

oneteam-rte-kt is a Kotlin / Android wrapper for oneteam-rte

How to use

There is a sample project.

Add dependencies

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    compile 'com.github.oneteam-dev.oneteam-rte-kt:core:x.y.z'

    // If you want to use default toolbar, add this line.
    compile 'com.github.oneteam-dev.oneteam-rte-kt:toolbar:x.y.z'

    // If you are using RxKotlin or RxJava, there are adapters for it.
    compile 'com.github.oneteam-dev.oneteam-rte-kt:core_rx:x.y.z'
    compile 'com.github.oneteam-dev.oneteam-rte-kt:toolbar_rx:x.y.z'
}

Include RichTextEditorView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main"
    android:layout_width="match_parent" android:layout_height="match_parent" />
    <io.one_team.oneteam_rte_kt.toolbar.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />
    <io.one_team.oneteam_rte_kt.core.RichTextEditorView
        android:id="@+id/editor"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"/>
</RelativeLayout>

Setup toolbar

if you're using default toolbar

class MainActivity {
    override fun onAttachedToWindow() {
        toolbar.editor = editor
        toolbar.addOnClickImageButtonListener {
            // Prompt which image to use and call RichtextEditorView::insertImage
        }

        toolbar.addOnClickInsertLinkButtonListener {
            // Prompt what link to use and call RichtextEditorView::insertLink
        }
    }
}

or implement toolbar by yourself

please see

Development

To change js directory, run command

npm install && npm run build

And necessary assets will be generated in core/main/assets directory.

Publish

git tag x.x.x
./gradlew release

And you can see artifact in Jitpack.io