3.4.2 • Published 3 years ago

@benson.liao/react-content-editable v3.4.2

Weekly downloads
89
License
MIT
Repository
github
Last release
3 years ago

react-content-editable npm

A Component for making element's content editable with input like features (e.g. max length)

Installation

npm i @benson.liao/react-content-editable

Demo

demo link Edit blog

Usage

const React = require('react');
const {useState} = require('react');
const ContentEditable = require('@benson.liao/react-content-editable').default;

const App = () => {
  const [text, setText] = useState('')

  const onChange = (value) => {
    setText(value)
  }

  return (
    <ContentEditable 
      tag='p'
      maxLength='20'
      onChange={onChange}
      value={text}
    />
  )
}
# es6
import React, { useState } from 'react'
import ContentEditable from "@benson.liao/react-content-editable";

const App = () => {
  const [text, setText] = useState('')

  const onChange = (value) => {
    setText(value)
  }

  return (
    <ContentEditable 
      tag='p'
      maxLength='20'
      onChange={onChange}
      value={text}
    />
  )
}

Editable Text

<Editable
  tag="p"
  maxLength='20'
  onChange={onChange}
  value={data}
/>

Editable Text Read only

<Editable
  readOnly
  tag="h1"
  maxLength='20'
  onChange={onChange}
/>

Contributing

We would love some contributions! Check out this document to get started.

Todo

Improve onPaste handler

3.4.0

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.3.1

3 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago