Skip to content

Commit 7f494fe

Browse files
authored
Merge pull request #1 from ChrisUser/feat/add-component
Feat/add component
2 parents add5009 + c523f58 commit 7f494fe

File tree

10 files changed

+576
-112
lines changed

10 files changed

+576
-112
lines changed

README.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
1-
# react-basic-contenteditable
2-
React 18 contenteditable component. Super-customizable!
1+
# React Basic Contenteditable
2+
3+
![React Basic Content Editable](readme-header-img.png)
4+
5+
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+
## Usage
22+
23+
<!-- Live **demo** at: [https://chrisuser.github.io/react-basic-contenteditable/](https://chrisuser.github.io/react-basic-contenteditable/) -->
24+
25+
### Example
26+
27+
```javascript
28+
import ContentEditable from "react-basic-contenteditable"
29+
30+
const App = () => {
31+
const [content, setContent] = useState("")
32+
33+
return (
34+
<div>
35+
<div>{content}</div>
36+
<ContentEditable
37+
placeholder="Type here"
38+
containerClassName="container-class"
39+
contentEditableClassName="contenteditable-class"
40+
placeholderClassName="placeholder-class"
41+
onChange={(content) => setContent(content)}
42+
/>
43+
</div>
44+
)
45+
}
46+
47+
export default App
48+
```
49+
50+
### Props
51+
52+
> All props except `onChange` are optional.
53+
54+
| Name | Optional | Type | Description |
55+
| ------------------------ | -------- | ------------------- | --------------------------------------------------------------------- |
56+
| containerClassName | ✔️ | `string` | Custom classes for the wrapper div |
57+
| contentEditableClassName | ✔️ | `string` | Custom classes for the input element |
58+
| placeholderClassName | ✔️ | `string` | Custom classes for the placeholder text |
59+
| placeholder | ✔️ | `string` | Input placeholder text |
60+
| disabled | ✔️ | `boolean` | Flag that disables the input element |
61+
| updatedContent | ✔️ | `string` | Text injected from parent element into the input as the current value |
62+
| onContentExternalUpdate | ✔️ | `(content) => void` | Method that emits the injected content by the `updatedContent` prop |
63+
| onChange || `(content) => void` | Method that emits the current content as a string |
64+
| onKeyUp | ✔️ | `(e) => void` | Method that emits the keyUp keyboard event |
65+
| onKeyDown | ✔️ | `(e) => void` | Method that emits the keyDown keyboard event |
66+
| onFocus | ✔️ | `(e) => void` | Method that emits the focus event |
67+
| onBlur | ✔️ | `(e) => void` | Method that emits the blur event |
68+
69+
## Contribution
70+
71+
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.\
72+
Remeber to follow the [Contributing Guidelines](https://github.com/ChrisUser/.github/blob/main/CONTRIBUTING.md).
73+
74+
## Licence
75+
76+
React Basic Contenteditable is [MIT licensed](https://github.com/ChrisUser/react-basic-contenteditable/blob/master/LICENSE).

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + React + TS</title>
7+
<title>react-basic-contenteditable</title>
88
</head>
99
<body>
1010
<div id="root"></div>

0 commit comments

Comments
 (0)