
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
ifanrx-react-ueditor
Advanced tools

使用 react 框架对 ueditor 进行封装和扩展
# 使用 npm 安装
npm install ifanrx-react-ueditor --save
# 使用 yarn 安装
yarn add ifanrx-react-ueditor
import ReactUeditor from 'ifanrx-react-ueditor'
<ReactUeditor
ueditorPath={`${window.YOUR_PATH}/ueditor`}"
/>
extendControls 已不推荐使用,请直接使用 plugins,指定插件。
插件分为两种,一种是内置的插件,一种是自定义的插件。现支持内置插件如下:
内置插件,直接传入插件的名称即可。自定义插件则是传入一个 Function,类型定义(使用 typescript 只为了说明类型)为:
interface IPlugin {
(ueditor: UEditor): IPluginConfig
}
interface IPluginConfig {
cssRules: String
menuText: String
onIconClick?: () => void
render: (visible: Boolean, closeModal: () => void) => React.ReactElement<any>
title?: String
}
UEditor 为 UEditor 实例。详细内容,请参考官方文档
内置插件
<ReactUeditor
...
plugins={[
'insertCode',
'uploadImage',
'uploadVideo',
'uploadAudio',
'insertLink',
]}
...
/>
自定义插件
const uploadImagePlugin = ueditor => {
return {
menuText: '图片上传',
cssRules: 'background-position: -726px -77px;',
render: (visible, closeModal) => {
const handleSelectImage = (url) => {
ueditor.focus()
ueditor.execCommand('inserthtml', `<img src="${url}" />`)
closeModal()
}
return <Modal visible={visible} onSelectImage={handleSelectImage} />
}
}
}
<ReactUeditor
...
plugins={[uploadImagePlugin]}
...
/>
更多功能请移步到 react-ueditor 的 wiki 页面
|
kailunyao |
larry011 |
如果你希望为这个项目贡献代码,需要了解以下情况:
在根目录下执行 yarn start 会启动开发服务器,此时会在浏览器中展示 ReactUeditor 的真实效果,在 ReactUeditor/ 下的修改都会进行热更新
example.js, index.html, dist/ 都只是为了展示 ReactUeditor 的真实效果,主要代码在 ReactUeditor/ 中
需要修改 ueditor 源码时,直接修改 ueditor 目录下的文件,修改完执行:cd ueditor 和 yarn grunt 命令,此时会重新生成 ueditor 构建成功的文件到 vendor/ueditor
v2.3.2 (2020-11-11)
FAQs
an ueditor component for react
We found that ifanrx-react-ueditor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.