margox / braft-editor

美观易用的React富文本编辑器,基于draft-js开发
MIT License
4.61k stars 593 forks source link

V1.3.0,超链接 输入任意字符无作用 #47

Closed 775822253 closed 6 years ago

775822253 commented 6 years ago

超链接输入字符无作用,控制台并未报错

775822253 commented 6 years ago

你们也有这个问题吗

margox commented 6 years ago

http://margox.github.io/braft-editor/ 你访问这个DEMO,会有这个问题么? 贴一下你的代码看看?

775822253 commented 6 years ago

{ qiNiuToken && <BraftEditor {...editorProps} viewWrapper=".ant-form-item-control-wrapper" contentFormat='html' onRawChange={handleRawChange} onHTMLChange={handleHTMLChange} initialContent={storeDetail.content}/> }

775822253 commented 6 years ago

demo刚试了一下 是可以

775822253 commented 6 years ago

应该是我这边放在form里引起的

margox commented 6 years ago

额。form里面阻止了你的输入事件么

775822253 commented 6 years ago

ant design的form表单 我也不知道什么原因 <FormItem label="专题正文:" hasFeedback {...formItemLayout} className={styles.contentEditor}> <div style={{width: '100%'}}> { qiNiuToken && <BraftEditor {...editorProps} viewWrapper=".ant-form-item-control-wrapper" contentFormat='html' onRawChange={handleRawChange} onHTMLChange={handleHTMLChange} initialContent={storeDetail.content}/> } <span style={storeDetail.content == null || storeDetail.content == '<p></p>' || storeDetail.content == ''?{display:'inline',color: '#f04134'}:{display:'none',color: '#f04134'}}>专题正文未填写</span> </div> </FormItem> <FormItem label='专题banner:' {...formItemLayout}> 这样写就正常,但是下面套在{getFieldDecorator就不行了 <FormItem label="专题正文:" hasFeedback {...formItemLayout} className={styles.contentEditor}> {getFieldDecorator('content', { initialValue: storeDetail.content, })( <div style={{width: '100%'}}> { qiNiuToken && <BraftEditor {...editorProps} viewWrapper=".ant-form-item-control-wrapper" contentFormat='html' onRawChange={handleRawChange} onHTMLChange={handleHTMLChange} initialContent={storeDetail.content}/> } <span style={storeDetail.content == null || storeDetail.content == '<p></p>' || storeDetail.content == ''?{display:'inline',color: '#f04134'}:{display:'none',color: '#f04134'}}>专题正文未填写</span> </div> )} </FormItem>

margox commented 6 years ago

initialContent={storeDetail.content} 感觉和这一行有关系

775822253 commented 6 years ago

不不 ,我试过了,就是表单Form的{getFieldDecorator造成的

775822253 commented 6 years ago

我改了下代码,现在可以了,但是添加时候的链接会自动加前缀不~ 我加了一个baidu的网站,然后请求接口保存,我看了下发给后台的a标签是正常的href="www.baidu.com", 再请求接口查询的时候 返回的json里也是正常的href,但是我用谷歌调试工具选中这个a标签查看元素时 ,href却是: <a class="braft-link" href="http://localhost:8000/inspiration/inspirationTheme/specialStore/www.baidu.com" target=""><span data-offset-key="d4plb-0-0"><span data-text="true"> </span></span><span data-offset-key="d4plb-0-1" style="font-size: 14px;"><span data-text="true">当90后</span></span></a>

margox commented 6 years ago

没有加上http://或者https://的话,会被识别成相对路径,所以不要忘了加上http://或者https://

775822253 commented 6 years ago

哦哦,我试试

775822253 commented 6 years ago

恩,是没加前缀的原因