android富文本编辑word,Aztec 一个可复用的原生Android富文本编辑器组件

175c33d3c7779c27bef4763781a427e2.png Aztec: Native HTML Editor for Android

68747470733a2f2f636972636c6563692e636f6d2f67682f776f726470726573732d6d6f62696c652f417a746563456469746f722d416e64726f69642e7376673f7374796c653d737667

Aztec (which extends EditText) is a rich-text editor component for writing HTML documents in Android.

Supports Android 4.1+ (API 16 - Jelly Bean)

visual_editor.pngcode_editor.png

Getting started

Declare the main components in your layout:

Visual editor

android:id="@+id/visual"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:scrollbars="vertical"

android:imeOptions="flagNoExtractUi"

aztec:historyEnable="false" />

Source editor

android:id="@+id/source"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:inputType="textNoSuggestions|textMultiLine"

android:scrollbars="vertical"

android:imeOptions="flagNoExtractUi"

aztec:codeBackgroundColor="@android:color/transparent"

aztec:codeTextColor="@android:color/white" />

Toolbar

android:id="@+id/formatting_toolbar"

android:layout_width="match_parent"

android:layout_height="@dimen/format_bar_height"

android:layout_alignParentBottom="true" />

Inflate the views:

val visualEditor = findViewById(R.id.visual)

val sourceEditor = findViewById(R.id.source)

val toolbar = findViewById(R.id.formatting_toolbar)

Configure Aztec with a provided image & video loaders:

Aztec.with(visualEditor, sourceEditor, toolbar, context)

.setImageGetter(GlideImageLoader(context))

.setVideoThumbnailGetter(GlideVideoThumbnailLoader(context))

For more options, such as edit history, listeners and plugins please refer to the demo app implementation.

Build and test

Build the library, build the example project and run unit tests:

$ ./gradlew build

Run unit tests only:

$ ./gradlew test

Before running instrumentation tests

Espresso advises disabling system animations on devices used for testing:

On your device, under Settings->Developer options disable the following 3 settings:

Window animation scale

Transition animation scale

Animator duration scale

One additional setup step is also required to handle an Espresso issue with clicks (see the caveats below):

On your device, under Settings -> Accessibility -> Touch & hold delay, set the delay to Long.

Run the instrumentation tests:

$ ./gradlew cAT

Integrating Aztec in your project

You can import Aztec into your project using Jitpack:

repositories {

maven { url "https://jitpack.io" }

}

dependencies {

api ('com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:v1.3.43')

}

Brave developers can either use the project as a source distribution or have fun with the latest snapshot at their own risk:

dependencies {

api ('com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:develop-SNAPSHOT')

}

Code formatting

We use ktlint for Kotlin linting. You can run ktlint using ./gradlew ktlint, and you can also run ./gradlew ktlintFormat for auto-formatting. There is no IDEA plugin (like Checkstyle's) at this time.

Reference

License

Aztec is an Open Source project covered by the GNU General Public License version 2.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值