- Rich text editor android
- About
- Rich text editor android
- Latest commit
- Git stats
- Files
- README.md
- Rich text editor android
- About
- RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android.
- Related tags
- Can’t remove format
- Can not input «+»
- add feature fontSize
- Please update to new version
- editor to be scrollable
- Disable Input Mode
- Add ability to disable input on editor making it readonly
- How to show keyboard on activity start when focusing to editor
- Append text into cursor position
- remove static members and schedule tasks more efficiently, let other …
Rich text editor android
The Android RTEditor is a rich text editor component for Android that can be used as a drop in for EditText.
The editor offers the following character formatting options:
- Bold
- Italic
- Underline
Strike through- Superscript
- Subscript
- Different fonts
- Text size
- Text color
- Background color
- Undo/Redo
It also supports the following paragraph formatting:
Add this to your Gradle build file:
Add this to your manifest:
If you use Proguard in your app, please add the following lines to your configuration file:
The «Signature» attribute is required to be able to access generic type, which the rich text editor code does:
The toolbar uses a couple of custom attributes that need to be defined or it will crash when being inflated. You need to use a theme based on either RTE_ThemeLight or RTE_ThemeDark or define all rich text editor attributes (rte_toolbar_themes.xml) in your own theme. These two themes inherit from Theme.AppCompat.Light / Theme.AppCompat.
Make sure to call setTheme before setContentView (or set the theme in the manifest):
The 3 main components
is the EditText drop in component. Add it to your layout like you would EditText:
In code you would typically use methods to set and get the text content:
- set text: RTEditText.setRichTextEditing(true, «My content»);
- get text: RTEditText.getText(RTFormat.HTML)
is an interface for the toolbar used to apply text and paragraph formatting and other features listed above. The actual RTToolbar implementation is in a separate module and is a scrollable ribbon but alternative implementations aren’t too hard to realize (popup, action buttons, floating buttons. ). The toolbar implementation is easy to integrate into your layout:
or if you want to have two ribbons for character and paragraph formatting:
Note that inflating the toolbar might take a moment (noticable) on certain devices because the included icons are high-resolution and each one comes in three different states (pressed, checked, normal). There’s no workaround for this except using different icons with lower resolution.
In code you’d typically not interact with the toolbar (see RTManager below for the one exception).
is the glue that holds the rich text editors (RTEditText), the toolbar and your app together. Each rich text editor and each toolbar needs to be registered with the RTManager before they are functional. Multiple editors and multiple toolbars can be registered. The RTManager is instantiated by your app in code usually in the onCreate passing in an RTApi object that gives the rich text editor access to its context (your app). A typical initialization process looks like this (normally in the onCreate method):
To retrieve the edited text in html format you’d do:
The RTManager also needs to be called in onSaveInstanceState and in onDestroy:
The isSaved parameter passed into RTManager.onDestroy(boolean) is important. If it’s true then media files inserted into the text (images at the moment) will remain untouched. If the parameter is false (text content is dismissed), media files will be deleted. Note that the rich text editor copies the original file to a dedicated area according to the MediaFactory configuration, meaning the original will remain untouched.
If you read the previous section («The 3 main components») you might have noticed the RTApi object. The RTApi is a convenience class giving the various rich text editor components access to the application context and to RTProxy and RTMediaFactory methods.
The first parameter is merely a Context object (Application or Activity context). The RTApi will only store the Application context so no issue with leaking the Activity context here.
The RTProxy allows the rich text editor to call Activity related methods like:
- startActivityForResult/runOnUiThread and Toast methods: for picking images to embed in the text
- Fragment related methods: for the link dialog (LinkFragment)
RTProxyImpl is the standard implementation for RTProxy and there’s usually no need to use a custom implementation. RTProxyImpl stores the Activity context in a SoftReference.
The most interesting class is RTMediaFactory. By overriding it, different storage scenarios for embedded images (and potentially videos and audio files in the future) can be implemented (SQLite database, file system, cloud storage, access through ContentProvider etc.).
The rich text editor supports fonts that are part of the Android device it’s running on. It’s reading all ttf fonts in the /system/fonts, /system/font and /data/fonts and shows them in the editor.
A lot of frequently used fonts have a copyright and can therefore not be included in this library but you can use any true type font you want by adding them to the assets folder of the demo app (just make sure you don’t infringe on someone else’s copyright). The fonts can be put anywhere in the assets folder (root or subdirectories). Since reading the directory structure of the assets folder during run-time is pretty slow (see here) a Gradle script generates an index of all ttf files during build time. In order to create that file during build time, please copy the following code to your build.gradle:
Note that loading the fonts can take a moment. That’s why you should pre-load them in your Application class (it’s an asynchronous call):
The project consists of four different modules:
- ColorPicker: a color picker based on this: https://github.com/LarsWerkman/HoloColorPicker. The RTEditor uses an enhanced version that allows to enter ARGB values, includes a ColorPickerPreference that can be used in preference screens and shows a white and gray chessboard pattern behind the color visible when the the alpha channel is changed and the color becomes (partly) transparent.
- RTEditor: the actual rich text editor (excluding the toolbar implementation).
- RTEditor-Toolbar: the toolbar implementation.
- RTEditor-Demo: this module isn’t part of the actual rich text editor component but contains a sample app that shows how to use the component.
The demo app can also be found on Google Play: Demo App
If you have an issues with this library, please open a issue here: https://github.com/1gravity/Android-RTEditor/issues and provide enough information to reproduce it reliably. The following information needs to be provided:
- Which version of the SDK are you using?
- Which Android build are you using? (e.g. MPZ44Q)
- What device are you using?
- What steps will reproduce the problem? (Please provide the minimal reproducible test case.)
- What is the expected output?
- What do you see instead?
- Relevant logcat output.
- Optional: Link to any screenshot(s) that demonstrate the issue (shared privately in Drive.)
- Optional: Link to your APK (either downloadable in Drive or in the Play Store.)
Copyright 2015-2021 Emanuel Moecklin
Licensed under the Apache License, Version 2.0 (the «License»); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an «AS IS» BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
About
The Android RTEditor is a rich text editor component for Android that can be used as a drop in for EditText
Источник
Rich text editor android
RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android .
- Bold
- Italic
- Subscript
- Superscript
- Strikethrough
- Underline
- Justify Left
- Justify Center
- Justify Right
- Blockquote
- Heading 1
- Heading 2
- Heading 3
- Heading 4
- Heading 5
- Heading 6
- Undo
- Redo
- Indent
- Outdent
- Insert Image
- Insert Youtube
- Insert Video
- Insert Audio
- Insert Link
- Checkbox
- Text Color
- Text Background Color
- Text Font Size
- Unordered List (Bullets)
- Ordered List (Numbers)
Источник
Rich text editor android
Aztec: Native HTML Editor for Android
Aztec (which extends EditText) is a rich-text editor component for writing HTML documents in Android.
Supports Android 4.1+ (API 16 — Jelly Bean)
Declare the main components in your layout:
Inflate the views:
Configure Aztec with a provided image & video loaders:
For more options, such as edit history, listeners and plugins please refer to the demo app implementation.
Build the library, build the example project and run unit tests:
Run unit tests only:
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:
Integrating Aztec in your project
You can import Aztec into your project using Jitpack:
Brave developers can either use the project as a source distribution or have fun with the latest snapshot at their own risk:
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.
Aztec is an open source project covered by the Mozilla Public License Version 2.0.
About
A reusable native Android rich text editor component.
Источник
RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android.
Related tags
Overview
RichEditor for Android is a beautiful Rich Text WYSIWYG Editor for Android .
- Bold
- Italic
- Subscript
- Superscript
- Strikethrough
- Underline
- Justify Left
- Justify Center
- Justify Right
- Blockquote
- Heading 1
- Heading 2
- Heading 3
- Heading 4
- Heading 5
- Heading 6
- Undo
- Redo
- Indent
- Outdent
- Insert Image
- Insert Youtube
- Insert Video
- Insert Audio
- Insert Link
- Checkbox
- Text Color
- Text Background Color
- Text Font Size
- Unordered List (Bullets)
- Ordered List (Numbers)
Attribute change of editor
- Font Size
- Background Color
- Width
- Height
- Placeholder
- Load CSS
- State Callback
Milestone
How do I use it?
Default Setting for Editor
Height
Font
Background
Padding
Placeholder
Others
Please refer the samples for usage.
Functions for ContentEditable
Bold
Italic
Insert Image
Text Change Listener
Others
Please refer the samples for usage.
Applications using RichEditor for Android
Please ping me or send a pull request if you would like to be added here.
Icon | Application |
---|---|
Ameba Ownd | |
ScorePal |
- Inspired by ZSSRichTextEditor in nnhubbard.
Issues
Can’t remove format
Add please command for format removing
Can not input «+»
I can’t input «+», and found the below code in rich_editor.js
add feature fontSize
add fontSize values between 1-7
Please update to new version
Is it possible to upload the latest version to jcenter ?
It would be nice , because i would like to use list elements 🙂
editor to be scrollable
is there any way to scroll the editor, just like textview can be scrollable. I want the editor height to be fixed and should be able to scroll the content.
Disable Input Mode
I’m using your RichText Editor and it is beautiful!
Please I have a question: is it possible to disable the input mode? I would like to present the page as read-only and the user has to unlock the page to edit it.
Thanks in advance,
Add ability to disable input on editor making it readonly
I have been trying to implement this editor for a little while and eventually found the need to make the input readonly. I’m aware that I could just switch out the editor for a web view to view the content but then you don’t have consistency between the editor and the web view.
Using setFocusable, setClickable and setLongClickable mean that you can’t select the text to copy it.
So instead I change the contentEditable property of the editor node in the JS.
I also removed the user-select and user-modify from the CSS as you were mixing two different methods by doing so and it would have required adding a class to override the default styles as well. I chose contenteditable as it has better browser support.
Let me know your thoughts.
P.S. It appears that it would fix issue #79 as well
How to show keyboard on activity start when focusing to editor
i requested the focus by mEditor.focusEditor(); and then code to show keyboard which works with edittext. but with editor, it’s not working.
Append text into cursor position
Would it be possible to add text at the cursor position?
For example, adding a button that clicks adds standard text.
remove static members and schedule tasks more efficiently, let other …
remove static members and schedule tasks more efficiently, let other apps inherit from RichEditor, insert link without selecting a text, add bullets and numbers
Источник