Code Monkey home page Code Monkey logo

parvenu's Introduction

Parvenu

A basic rich text editor support for Jetpack Compose

What is this?

The bug prevents us from implementing a rich text editor for Jetpack Compose. As Compose's BasicTextField drops spans when it is edited by a user, the library restores them by inspecting selection and text change. You can try the demo app by running the app module.

img

Installation

There is no maven repository you can use at the moment as it is currently in incubating state, so please install it by code.

Usage

ParvenuEditor is a core component you can use to implement a rich text editor. It is a wrapper composable that restores styles for you. For extensibility, ParvenuEditor does not choose a concrete type of a text field. In other words, you may choose what type of text field you want to use.

For example, you can use the most basic type of text field: BasicTextField.

ParvenuEditor(
  value = editorValue,
  onValueChange = {
    editorValue = it
  }
 ) { value, onValueChange ->
  BasicTextField(
    modifier = Modifier
         .fillMaxWidth()
         .padding(16.dp),
    value = value,
    onValueChange = onValueChange
  )
}

The only thing you should do is to pass value and onValueChange to your text field composable.

If you want to use TextField in the compose material library, just replace BasicTextField with TextField from the example snippet above.

To initialize ParvenuEditorValue, use the constructor:

var editorValue by remember { mutableStateOf(ParvenuEditorValue()) }

parvenu's People

Contributors

onebone avatar

Stargazers

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

Watchers

 avatar

Forkers

0x0cqq

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.