react-contenteditable

WebJar for react-contenteditable

Лицензия

Лицензия

Категории

Категории

React Взаимодействие с пользователем Веб-фреймворки
Группа

Группа

org.webjars.bowergithub.lovasoa
Идентификатор

Идентификатор

react-contenteditable
Последняя версия

Последняя версия

2.0.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

react-contenteditable
WebJar for react-contenteditable
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/lovasoa/react-contenteditable

Скачать react-contenteditable

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.lovasoa/react-contenteditable/ -->
<dependency>
    <groupId>org.webjars.bowergithub.lovasoa</groupId>
    <artifactId>react-contenteditable</artifactId>
    <version>2.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.lovasoa/react-contenteditable/
implementation 'org.webjars.bowergithub.lovasoa:react-contenteditable:2.0.5'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.lovasoa/react-contenteditable/
implementation ("org.webjars.bowergithub.lovasoa:react-contenteditable:2.0.5")
'org.webjars.bowergithub.lovasoa:react-contenteditable:jar:2.0.5'
<dependency org="org.webjars.bowergithub.lovasoa" name="react-contenteditable" rev="2.0.5">
  <artifact name="react-contenteditable" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.lovasoa', module='react-contenteditable', version='2.0.5')
)
libraryDependencies += "org.webjars.bowergithub.lovasoa" % "react-contenteditable" % "2.0.5"
[org.webjars.bowergithub.lovasoa/react-contenteditable "2.0.5"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

react-contenteditable

React component for a div with editable contents

Build Status download count bundle size license

Install

npm install react-contenteditable

Usage

import React from 'react'
import ContentEditable from 'react-contenteditable'

class MyComponent extends React.Component {
  constructor() {
    super()
    this.contentEditable = React.createRef();
    this.state = {html: "<b>Hello <i>World</i></b>"};
  };

  handleChange = evt => {
    this.setState({html: evt.target.value});
  };

  render = () => {
    return <ContentEditable
              innerRef={this.contentEditable}
              html={this.state.html} // innerHTML of the editable div
              disabled={false}       // use true to disable editing
              onChange={this.handleChange} // handle innerHTML change
              tagName='article' // Use a custom HTML tag (uses a div by default)
            />
  };
};

Available props

prop description type
innerRef element's ref attribute Object | Function
html required: innerHTML of the editable element String
disabled use true to disable editing Boolean
onChange called whenever innerHTML changes Function
onBlur called whenever the html element is blurred Function
onFocus event fires when an element has received focus Function
onKeyUp called whenever a key is released Function
onKeyDown called whenever a key is pressed Function
className the element's CSS class String
style a collection of CSS properties to apply to the element Object

Known Issues

If you are using hooks, please see this issue. Using this component with useState doesn't work, but you can still use useRef :

const text = useRef('');

const handleChange = evt => {
    text.current = evt.target.value;
};

const handleBlur = () => {
    console.log(text.current);
};

return <ContentEditable html={text.current} onBlur={handleBlur} onChange={handleChange} />

Examples

You can try react-contenteditable right from your browser to see if it fits your project's needs:

Версии библиотеки

Версия
2.0.5