Git Product home page Git Product logo

knife's Introduction

Knife

Android Arsenal

Knife (extend EditText) is a rich text editor component for writing documents in Android.

Just select text and use one line code to style it!

Support Android 4.0+

Example

example.gif

Here has a demo apk, and it's source code, very easy to understand~

More experiments see mthli/Type.

Api

  • bold(boolean valid) bold the selected text.

  • italic(boolean valid) italic the selected text.

  • underline(boolean valid) <u>underline</u> the selected text.

  • strikethrough(boolean valid) strikethrough the selected text.

  • bullet(boolean valid) bullet the selected text.

  • quote(boolean valid) quote the selected text.

  • link(String link) and link(String link, int start, int end) to link the text.

  • contains(int FORMAT) return true if the selected text contains the FORMAT.

  • clearFormats() clear all formats.

  • redo() when text changed, you can redo it!

  • undo() when text change, you can also undo it!

  • fromHtml() import from HTML file.

  • toHtml() export as HTML file.

If you want to get more control of the editable text, just extend KnifeText to get all protected method.

Custom

  • app:bulletColor

  • app:bulletRadius

  • app:bulletGapWidth

  • app:historyEnable true to enable record history, so you can redo() and undo().

  • app:historySize the record max limit.

  • app:linkColor

  • app:linkUnderline true to enable link underline.

  • app:quoteColor

  • app:quoteStripeWidth the quote line width.

  • app:quoteCapWidth

TODO

  • Insert image.

Gradle

At your top-level build.gradle file:

repositories {
    // ...
    maven { url 'https://jitpack.io' }
}

And then at your project build.gradle file:

dependencies {
    compile 'com.github.mthli:Knife:v1.1'
}

Done!

Reference

Thanks

License

Copyright 2015 Matthew Lee

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

    http://www.apache.org/licenses/LICENSE-2.0

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.

knife's People

Contributors

mthli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knife's Issues

Problem with bullets, strikethrough and quote

When getting the HTML from knife and then setting it again using Html.from and Html.to methods strikethrough does not appear (even though the strike tag is there in HTML).

With bullets no html tags get added to the HTML content therefore whenever i get the text from knife and try to set it again no bullets are shown.

Quote looks different after settings the text again.

Otherwise it is an awesome library

Links are not clickable

I have two activities. First is the editor activity. Second is the viewer activity where I can view previously stored texts (with xml parameter android:editable="false") however clicking on links doesn't make any response. Any help please ?

Underline

Hello!
Keyboard automatically underline last word (for suggestions), but Knife.toHtml() saves this underline.
Any suggestions, how to solve this?

Failed to resolve gradle

Hi
I'm trying to use your library but the gradle failed to resolved compile 'com.github.mthli:Knife:v1.1'

Documentation?

Hello, i don't know how to instantiate the editor...

any example?

Add Knife to F-Droid

F-Droid is an installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform.
AFAIK Knife is released under Apache License 2 so it is candidate to be added on F-Droid database.
You can follow the instructions on how to submit your app here.
If #you want you can edit README.md in order to add the following code with the correct Knife ID on F-Droid database

[![Get it on F-Droid](https://guardianproject.info/wp-content/uploads/2014/07/logo-fdroid.png)](https://f-droid.org/repository/browse/?fdid=AddHereKnifeID)

Toggle for buttons | Feature Request

Instead of selecting the text and then styling them, there should be functionality to toggle bold, italic, underline, etc. For example: One should be able to tap on bold icon which makes it active (if some text is not selected) and then subsequent text written should be typed bold until the bold icon is clicked again.
Generally when writing I know what words I want to write bold before hand and selecting the text after typing and then styling makes the process longer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.