Skip to content

Commit 91b8a7a

Browse files
committed
docs: update README.md
1 parent 4ebe59b commit 91b8a7a

2 files changed

Lines changed: 80 additions & 3 deletions

File tree

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,82 @@
1-
# react-basic-contenteditable
1+
# React Basic Contenteditable
22

3-
![React Content Editable](readme-header-img.png)
3+
![React Basic Content Editable](readme-header-img.png)
44

55
A React component that allows you to create an editable area in your application. It's perfect for situations where you need to provide a user-friendly, in-place editing functionality.
6+
7+
## Installation
8+
9+
Install via npm
10+
11+
```sh
12+
npm install --save react-basic-contenteditable
13+
```
14+
15+
or yarn
16+
17+
```sh
18+
yarn add react-basic-contenteditable
19+
```
20+
21+
<br>
22+
23+
## Usage
24+
25+
Live **demo** at: [https://chrisuser.github.io/react-basic-contenteditable/](https://chrisuser.github.io/react-basic-contenteditable/)
26+
27+
## Example
28+
29+
```javascript
30+
import ContentEditable from "react-basic-contenteditable"
31+
32+
const App = () => {
33+
const [content, setContent] = useState("")
34+
35+
return (
36+
<div>
37+
<div>{content}</div>
38+
<ContentEditable
39+
placeholder="Type here"
40+
containerClassName="container-class"
41+
contentEditableClassName="contenteditable-class"
42+
placeholderClassName="placeholder-class"
43+
onChange={(content) => setContent(content)}
44+
/>
45+
</div>
46+
)
47+
}
48+
49+
export default App
50+
```
51+
52+
## Props
53+
54+
> All props except `onChange` are optional.
55+
56+
| Name | Optional | Type | Description |
57+
| ------------------------ | -------- | ------------------- | --------------------------------------------------------------------- |
58+
| containerClassName | ✔️ | `string` | Custom classes for the wrapper div |
59+
| contentEditableClassName | ✔️ | `string` | Custom classes for the input element |
60+
| placeholderClassName | ✔️ | `string` | Custom classes for the placeholder text |
61+
| placeholder | ✔️ | `string` | Input placeholder text |
62+
| disabled | ✔️ | `boolean` | Flag that disables the input element |
63+
| updatedContent | ✔️ | `string` | Text injected from parent element into the input as the current value |
64+
| onContentExternalUpdate | ✔️ | `(content) => void` | Method that emits the injected content by the `updatedContent` prop |
65+
| onChange || `(content) => {}` | Method that emits the current content as a string |
66+
| onKeyUp | ✔️ | `(e) => void` | Method that emits the keyUp keyboard event |
67+
| onKeyDown | ✔️ | `(e) => void` | Method that emits the keyDown keyboard event |
68+
| onFocus | ✔️ | `(e) => void` | Method that emits the focus event |
69+
| onBlur | ✔️ | `(e) => void` | Method that emits the blur event |
70+
71+
<br>
72+
73+
## Contribution
74+
75+
If you have a suggestion that would make this component better feel free to fork the project and open a pull request or create an issue for any idea or bug you find.\
76+
Remeber to follow the [Contributing Guidelines](https://github.com/ChrisUser/.github/blob/main/CONTRIBUTING.md).
77+
78+
<br>
79+
80+
## Licence
81+
82+
React Basic Contenteditable is [MIT licensed](https://github.com/ChrisUser/react-basic-contenteditable/blob/master/LICENSE).

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ContentEditable from "../lib/ContentEditable"
22
import "./App.css"
33
import { useEffect, useState } from "react"
44

5-
function App() {
5+
const App = () => {
66
const [emptyContent, setEmptyContent] = useState<string | undefined>(
77
undefined
88
)

0 commit comments

Comments
 (0)