Giter Site home page Giter Site logo

leejaen / react-lz-editor Goto Github PK

View Code? Open in Web Editor NEW
943.0 25.0 155.0 4.07 MB

A multilingual react rich-text editor component includes media support such as texts, images, videos, audios, links etc. Development based on Draft-Js and Ant-design, good support html, markdown, draft-raw mode. 一款基于 draft-Js 和 ant-design 实现的 react 富文本编辑器组件,支持文本、图片、视频、音频、链接等元素插入,同时支持HTML、markdown、draft Raw格式。

Home Page: https://leejaen.github.io/react-lz-editor/index.html

License: MIT License

JavaScript 97.31% CSS 1.08% HTML 1.51% Java 0.10%
react-editor draft-js ant-design react-lz-editor web-editor text-editor antd-editor

react-lz-editor's Introduction

/**
* 感谢各位对本仓库的star和关注,以及提出的宝贵意见,万分抱歉没有及时跟进issue list,
* 本仓库最近着手使用ts进行重写,但会保持向下兼容,修复之前出现的问题,增加移动端适配等特性
*/

中文 npm license

react-lz-editor

An open source react rich-text editor ( mordern react editor includes media support such as texts, images, videos, audios, links etc. ), development based on Draft-Js and Ant-design, good support html, markdown, draft-raw mode. It's supports multiple languages well and welcome you add your language supports.

Language Contributors

Li Zhen Li Zhen Boris Chernysh SibaService.inc Quốc Khánh This JJ
Li Zhen Li Zhen Boris Chernysh SibaService.inc Quốc Khánh This JJ
English Chinese (S. & T.) Russian Japanese Vietnamese Thai

Live demo

react-lz-editor: https://leejaen.github.io/react-lz-editor/index.html

Disabled media insert feature on demo page, because of there was no online API support for the time being, here is The server side API demo in java you may want.

Install

npm install react-lz-editor --save
OR
yarn add react-lz-editor

Version note: React 15.4.2+ and react-dom 15.4.2+ is required. Antd version at least from 2.8.3 in your project is recommended.

Git

git+ssh://[email protected]/leejaen/react-lz-editor.git

Usage & Examples

clicking to code example

import React from 'react';
import ReactDOM from 'react-dom';
import LzEditor from './editor/index.jsx'
class Test extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      htmlContent: `<h1>Yankees, Peeking at the Red Sox, Will Soon Get an Eyeful</h1>
                <p>Whenever Girardi stole a glance, there was rarely any good news for the Yankees. While Girardi’s charges were clawing their way to a split of their four-game series against the formidable Indians, the Boston Red Sox were plowing past the rebuilding Chicago White Sox, sweeping four games at Fenway Park.</p>`,
      markdownContent: "## HEAD 2 \n markdown examples \n ``` welcome ```",
      responseList: []
    }
    this.receiveHtml=this.receiveHtml.bind(this);
  }
  receiveHtml(content) {
    console.log("recieved HTML content", content);
    this.setState({responseList:[]});
  }
  render() {
    let policy = "";
    const uploadProps = {
      action: "http://v0.api.upyun.com/devopee",
      onChange: this.onChange,
      listType: 'picture',
      fileList: this.state.responseList,
      data: (file) => {

      },
      multiple: true,
      beforeUpload: this.beforeUpload,
      showUploadList: true
    }
    return (
      <div>
        <div>Editor demo 1 (use default html format ):
        </div>
        <LzEditor active={true} importContent={this.state.htmlContent} cbReceiver={this.receiveHtml} uploadProps={uploadProps}
        lang="en"/>
        <br/>
        <div>Editor demo 2 (use markdown format ):
        </div>
        <LzEditor
          active={true}
          importContent={this.state.markdownContent}
          cbReceiver={this.receiveMarkdown}
          image={false}
          video={false}
          audio={false}
          convertFormat="markdown"/>
      </div>
    );
  }
}

ReactDOM.render(
  <Test/>, document.getElementById('test'));

screenshot

API

props type default description
active bool false Is reloading content after changing
importContent string "" Editor content value, default to ""
lang string "" Editor using language, default to your browser language settings
cbReceiver function null Callback function, the changed value will be sent to its parameter.
undoRedo bool true Enabled undo and redo feature, default to true
removeStyle bool true Enabled remove style feature, default to true
pasteNoStyle bool true Enabled paste plan text feature, default to true
blockStyle bool true Enabled block style (H1,ol,pre etc.) feature, default to true
alignment bool true Enabled text alignment feature, default to true
inlineStyle bool true Enabled inline style (bold, italic, underline etc.) feature, default to true
color bool true Enabled color text feature, default to true
image bool true Enabled insert image feature, default to true
video bool true Enabled insert video feature, default to true
audio bool true Enabled insert audio feature, default to true
urls bool true Enabled add hyper link feature, default to true
autoSave bool true Enabled auto save to draft-box feature, default to true
fullScreen bool true Enabled full screen feature, default to true
convertFormat string "html" Set support format (html, markdown, raw), default to "html"
disabled bool false Disabled editor or not
uploadProps object null Customize uploading settings. API: Antd.Upload

react-lz-editor's People

Contributors

afc163 avatar bkdev98 avatar fameoflight avatar kirkcola avatar leejaen avatar m-ueta avatar marshalys avatar modestfake avatar pmg1989 avatar thisjj avatar twisger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-lz-editor's Issues

与 antd 自定义 theme 样式冲突

如果项目中使用 react-lz-editor,再按照 antd 的自定义样式去配置,由于下面的代码:

import 'antd/dist/antd.css';

导致样式被覆盖,建议使用推荐的 babel-plugin-import 方式的样式文件导入。

["import", { "libraryName": "antd", "style": true }]

关于编辑器内容自动更新到保险库中的问题

感谢大神的奉献,我在项目中用到您的组件。
目前出现的问题:
如果我再弹出框中用这个组件,那么当我关掉弹出框后,这个“编辑器内容已更新到保险库中”的提示还会在我主页面当中持续显示。我的主页面已经和这个编辑内容无关了,所以不太合理。

引入editor后就报异常

异常如下:
ERROR in ./~/css-loader?sourceMap!./~/postcss-loader!./~/less-loader?sourceMap!./~/antd/lib/checkbox/style/index.css Module build failed: media definitions require block statements after any features @ /Users/Xixi/Test/node_modules/antd/lib/checkbox/style/index.css (line 133, column 7) near lines: } @media \0screen { .ant-checkbox-checked .ant-checkbox-inner:before, @ ./~/antd/lib/checkbox/style/index.css 4:14-159

环境:
"node": "6.3.1"
"react": "^15.5.4"
"react-dom": "^15.5.4"
"antd": "^2.10.0"

webpack的配置如下:
`
{
test: /.(less|css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap!postcss!less?sourceMap')
}, {
test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
}, {
test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader"
}

`

您好,引入之后,放入项目中,启动后报错,

报下面的错,是因为什么?
@ .//antd/lib/modal/style/css.js 5:0-22
@ ./
/react-lz-editor/editor/index.js
@ ./~/react-lz-editor/index.js
@ ./jsx/pages/home.js
@ ./jsx/router.js
@ ./jsx/app.js
@ multi (webpack)-dev-server/client?http://localhost:8989 webpack/hot/dev-serve
r ./jsx/app.js

ERROR in .//antd/lib/message/style/index.css
Module parse failed: D:\项目\react-demo\node_modules\antd\lib\message\style\inde
x.css Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| .ant-message {
| font-size: 12px;
| position: fixed;
@ ./
/antd/lib/message/style/css.js 5:0-22
@ .//react-lz-editor/editor/index.js
@ ./
/react-lz-editor/index.js
@ ./jsx/pages/home.js
@ ./jsx/router.js
@ ./jsx/app.js
@ multi (webpack)-dev-server/client?http://localhost:8989 webpack/hot/dev-serve
r ./jsx/app.js

react-lz-editor整合到antdesign form中,输入变得很怪异,光标指针总是跳跃

这是整合到antdesign form中的实现代码

class Editor extends React.Component {
    state = {
        content: this.props.value,
    }
    componentWillReceiveProps(nextProps) {
        if ('value' in nextProps) {
            const value = nextProps.value;
            this.setState({ content: value });
        }
    }
    handleChange = (content) => {
        this.props.onChange(content)
    }

    render() {
        const uploadConfig = {
            QINIU_URL: "http://up.qiniu.com", //上传地址,现在暂只支持七牛上传
            QINIU_IMG_TOKEN_URL: "http://www.yourServerAddress.mobi/getUptokenOfQiniu.do", //请求图片的token
            QINIU_PFOP: {
                url: "http://www.yourServerAddress.mobi/doQiniuPicPersist.do" //七牛持久保存请求地址
            },
            QINIU_VIDEO_TOKEN_URL: "http://www.yourServerAddress.mobi/getUptokenOfQiniu.do", //请求媒体资源的token
            QINIU_FILE_TOKEN_URL: "http://www.yourServerAddress.mobi/getUptokenOfQiniu.do?name=patch", //其他资源的token的获取
            QINIU_IMG_DOMAIN_URL: "https://image.yourServerAddress.mobi", //图片文件地址的前缀
            QINIU_DOMAIN_VIDEO_URL: "https://video.yourServerAddress.mobi", //视频文件地址的前缀
            QINIU_DOMAIN_FILE_URL: "https://static.yourServerAddress.com/", //其他文件地址前缀
        }
        return <LzEditor
            active={true}
            importContent={this.state.content}
            cbReceiver={this.handleChange}
            uploadConfig={uploadConfig}
            fullScreen={true}
            convertFormat="html" />
    }
}

运行结果图:

通过上面的代码,我以为编辑器应该能正常的工作,然而,在输入中文或者其他字符的时候,光标会自动跳动到其他区域,有时候会调到底部。导致输入异常,但是,表单的数据是能正确地提交!
我尝试了很多遍结果还是一样,希望大家能帮帮我,谢谢!

报错

版本:0.10.12
报错内容:

Error in ./~/react-lz-editor/editor/utils/index.js
Module not found: [CaseSensitivePathsPlugin] `E:\Projects\jzez-admin\node_modules\react-lz-editor\editor\utils\stateToMD\main.js` does not match the corresponding path on disk `statetoMD`.

 @ ./~/react-lz-editor/editor/utils/index.js 43:13-40

原因不知道。。。我就单纯照着demo写的,在antd中引入了这个编辑器,但是无法通过编译

react-lz-editor能否提供一个图片连接功能

建议在图片上传功能中增加一个连接显示图片的功能

react-lz-editor的界面看起来非常舒服,图片上传的功能目前只支持七牛是吗?能否再增加一个功能,图片和视频加入一个超链接选择框,像下面这样的:
image

如果上面预览图片无效,请点击下面的连接

示例路径

// 就像这样简单的操作方式
const url = 'http://img.mabylove.cn/question/edit-image.gif';
return <img src={url } />

多增加一个选项或则配置项,可以选择多种方式呈现内容,这样或许使用起来同样非常的方便。

垂直滚动条回弹

image

滚动条滚动到底部后就会回弹到这个位置,照着demo写的。
在编辑器一定高度时触发。
大概在1080左右,超过1200后没有回弹。

基于react-create-app+antd安装之后报错

Error in ./~/react-lz-editor/editor/toolBar/colorControls.js Module not found: [CaseSensitivePathsPlugin] C:\Users\buxuku\Documents\work\project\ant-test\node_modules\react-lz-editor\editor\toolBar\ColorButton.jsdoes not match the corresponding path on diskcolorButton.js`.

@ ./~/react-lz-editor/editor/toolBar/colorControls.js 9:19-43

Error in ./~/react-lz-editor/global/supports/methods/public.js
Module not found: 'datas/url.jsx' in C:\Users\buxuku\Documents\work\project\ant-test\node_modules\react-lz-editor\global\supports\methods

@ ./~/react-lz-editor/global/supports/methods/public.js 5:11-35`

图片bug

reproduce

  1. 点击图片,然后点击图片的右边 (是空白区), 按下 enter 键,然后打开 chrome inspection tool,结果整个editor就垮了。

虚心求教一个问题

虽然没用上大佬的编辑器,但是也参考了一下大佬的代码。
小弟现在有一个问题,多方搜查也解决不了。

http://wx3.sinaimg.cn/mw690/715ed77dgy1fgv5vfbrbwg20a70hz7oi.gif
这图是通过decorator把特定字符串转成图片。但是这样图片退格总是删不掉,而且总在最后。

http://wx3.sinaimg.cn/mw690/715ed77dgy1fgv5veqiaeg20a70hzwvk.gif
这图是未替换的字符,但是也是跑了一次decorator的,但是这个却没什么问题。

大佬能不能提供一下思路,小弟不胜感激

npm run test 之后报错

$ npm run test

[email protected] test D:\react-lz-editor-master
echo "Error: no test specified" && exit 1

"Error: no test specified"

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files (x86)\node.exe" "C:\Users\Administrator\App Data\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "test"
npm ERR! node v6.9.2
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: echo "Error: no test specified" && exit 1
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'echo "Error: no test s pecified" && exit 1'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-lz-editor packa ge,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! echo "Error: no test specified" && exit 1
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs react-lz-editor
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls react-lz-editor
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! D:\react-lz-editor-master\npm-debug.log

更新到0.10.19后使用自定义上传,点击报错

根据API文档使用自定义上传,没有配置uploadConfig

<LzEditor
            active
            importContent={this.state.goodsInfo.detail}
            uploadProps={uploadProps}
            cbReceiver={this.receiveHtml}
            convertFormat="html"
/>

点击上传就报错了

    public.js:62 Uncaught TypeError: Cannot read property 'QINIU_IMG_TOKEN_URL' of undefined
    at Object.getQiniuToken (public.js:62)
    at Object.returnToken (public.js:52)
    at new UploadImage (UploadImage.js:76)
    at ReactCompositeComponent.js:295
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:294)
    at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:280)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:188)
    at Object.mountComponent (ReactReconciler.js:46)
    at ReactDOMComponent.mountChildren (ReactMultiChild.js:238)

请问如何把内容转为html

我编辑之后把内容存在数据库中,数据库看是html.但是输出数据的时候是纯文本格式。如何把内容转为html格式?

button样式对 全局 antd 样式是侵入的.

对 antd 的默认样式已经做了修改比如 <Button /> 组件的 border-color 改为了红色.

引入 react-lz-editor 后会对全局的 .ant-btn:hover, .ant-btn:focus 进行覆盖.

只配置uploadProps没有配置uploadConfig会报错

如题,点击图片、媒体那些图标控制台会报如下错误:

Uncaught TypeError: Cannot read property 'QINIU_IMG_TOKEN_URL' of undefined
    at Object.getQiniuToken (public.js?1ab4:62)
    at Object.returnToken (public.js?1ab4:52)
    at new UploadImage (UploadImage.js?1e75:76)
    at p._constructComponentWithoutOwner (react-dom.min.js:13)
    at p._constructComponent (react-dom.min.js:13)
    at p.mountComponent (react-dom.min.js:13)
    at Object.mountComponent (react-dom.min.js:14)
    at h.mountChildren (react-dom.min.js:14)
    at h._createInitialChildren (react-dom.min.js:13)
    at h.mountComponent (react-dom.min.js:13)

npm install react-lz-editor --save 更新版本时报 No compatible version found: js-base64@^0.2.1错误

npm install react-lz-editor --save 更新版本时报下面错误

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "react-lz-editor" "--save"
npm ERR! node v7.2.1
npm ERR! npm v3.10.10
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: js-base64@^0.2.1
npm ERR! notarget Valid install targets:
npm ERR! notarget 2.1.9, 2.1.8, 2.1.7, 2.1.6, 2.1.5, 2.1.2, 2.1.1, 2.1.0, 2.0.7, 2.0.6
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'react-lz-editor'
npm ERR! notarget

Example 中注释“上传地址,现在暂只支持七牛上传”,如果希望做到上传到自有服务器上,服务端需要实现哪些接口,是否有指导文档?多谢支持!

Example 中注释“上传地址,现在暂只支持七牛上传”,如果希望做到上传到自有服务器上,服务端需要实现哪些接口,是否有指导文档?多谢支持!

参考:

QINIU_URL: "http://up.qiniu.com", //上传地址,现在暂只支持七牛上传

const uploadConfig = {
QINIU_URL: "http://up.qiniu.com", //上传地址,现在暂只支持七牛上传
QINIU_IMG_TOKEN_URL: "http://www.yourServerAddress.com/getQiniuUptoken.do", //请求图片的token
QINIU_PFOP: {
url: "http://www.yourServerAddress.com/QiniuPicPersist.do" //七牛持久保存请求地址
},
QINIU_VIDEO_TOKEN_URL: "http://www.yourServerAddress.com/getQiniuUptoken.do", //请求媒体资源的token
QINIU_FILE_TOKEN_URL: "http://www.yourServerAddress.com/getQiniuUptoken.do?name=patch", //其他资源的token的获取
QINIU_IMG_DOMAIN_URL: "https://image.yourServerAddress.mobi", //图片文件地址的前缀
QINIU_DOMAIN_VIDEO_URL: "https://video.yourServerAddress.mobi", //视频文件地址的前缀
QINIU_DOMAIN_FILE_URL: "https://static.yourServerAddress.com/", //其他文件地址前缀
}

引用报错

import LzEditor from 'react-lz-editor';

/Users/devinzhang/work/bzh-web/node_modules/antd/lib/style/index.css:9
html {
     ^
SyntaxError: Unexpected token {
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/devinzhang/work/bzh-web/node_modules/antd/lib/affix/style/css.js:3:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

font configuration

README中好像没有提到字体设置,请问现在还没有这个功能码?

请问图片如何混排呢

图片好像只能居中显示,但是我想图片能居左或者居右但控制不了,怎么解决?

编辑回填图片问题

插入图片时img标签外会包一层figure标签,但在回填时figure内的图片不能正常显示,有没有一个解决办法。

请教七牛上传config参数

项目demo中uploadConfig关于七牛那块的参数配置我有点问题,具体我已经发邮件到你的gmail邮箱,还望有时间能得到你的回复,谢谢

安装了0.10.19版本无法显示图标

装了最新版之后无法显示图标,浏览器控制台输出如下错误:

Access to Font at 'http://static.cms.yylending.com/images/iconfont-61dd1f.woff' from origin 'http://cms-dev.yylending.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://cms-dev.yylending.com' is therefore not allowed access.

难道现在字体也跨域吗?

上传的配置项是否可以交由调用一方控制?

目前上传的配置(七牛)是采用传递url过去,我看了下给的java的后端代码,限制了返回的数据的格式(即必须一个json对象,且下面的第一级有uptoken属性),但是在不同的项目中,格式可能早以约定好,所以建议将url改成函数的形式,比如

目前:

QINIU_IMG_TOKEN_URL: "http://www.yourServerAddress.mobi/getUptokenOfQiniu.do"

改成:

QINIU_IMG_TOKEN_URL: () => myToken

这样editor本身不用再限制格式,也方便不同的项目集成本repo

另外还发现几个问题:

获取token的时候采用的是post而非get,为什么要这么做呢,还有就是还发送了一个tokenId参数,而在java后台的示例代码中没有对这个参数进行处理,所以不明白为什么要发送这样一个参数,而且也没有看到可以配置他的地方,默认值为"yourTokenId",也不清楚即便可以配置,配置的作用是什么。

可能有点罗嗦了哈哈,最后一个问题,就是如果没有上面提到的类似的方式传递token给Editor的话,那么一般的后端对获取七牛的token肯定是要做权限验证的,不然任意一个人哪怕是没有登录的都可以获取token了,如果是通过cookie验证的话,目前的实现貌似没加入默认传递cookie,XHR的话是配置withCredentials属性,fetch的话是配置credentials属性。

但是仍然存在一个问题,如果我想通过Authentication首部进行验证的话,又有点麻烦了,现在只能提供一个url参数给Editor,所以建议两种方案解决这个问题。一是保留现在的配置方式,但是增加添加首部的功能。二是增加上面描述到的这种方式,让调用一方自己随便怎么搞,然后获取到了token传给Editor,大概看了下,在这里加上if (_.isFunction(url)) { return url(); }应该就行了。(#47)

这里在数组内创建组件的时候没有设置key,由于这里没有后台实体id与之对应,而且顺序也不太可能变化,所以就设置为数组的index应该就可以了(#47)

:上传时Editor指定了key,从这里可以看到key是随机的,所以传两个相同的文件,这个key是不同的,导致七牛那边存了两份一样的文件。所以建议这个也还是交给调用方决定(通过在生成token的时候设置saveKey)(#47)

:箭头函数的this是由父级决定的,所以很多组件里的that是没有必要的(todo)

:内容转换为html后图片的src出错。

看了下,在chrome按F12观察element面板,可以看到标签都是正确的(一个figure包了一个img,img的src与上传后的地址一致),但是在代码里接收到的content不对,如下:

这是目前的表现形式:

<p ><br></p>
<p ><img src="http://cdn.xx"/></p>
<p ><br></p>
这是我通过https://github.com/sstur/draft-js-export-html库进行转换后的结果:

<p><br></p>
<figure><img src="http://cdn.xx-xxxxx.com/38745258267550641588.jpg?t=foreditor"/></figure>
<p><br></p>

可以看到后者才是正确的,前者把url中的一部分后面截掉了,不知道是什么原因,看了下源码确实有点多,没有细看,不清楚具体是什么原因(猜测可能是域名中有"-"号在转换的时候没有考虑到?)。目前我是用上面提到的库解决了,希望本身能够修复一下。(#47)

这里customStyleMap属性和editorState属性都重复声明了。(todo)

自定义上传图片报错啊!!!

Animate.js:217 Uncaught Error: must set key for children
at Animate.js:217
at Array.map ()
at Animate.render (Animate.js:212)
at ReactCompositeComponent.js:795
at measureLifeCyclePerf (ReactCompositeComponent.js:75)
at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:794)
at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:821)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:361)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:257)
at Object.mountComponent (ReactReconciler.js:45)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.