如何解决ckeditor4 editorConfig和editorUrl无法在反应中工作吗?
我已经下载了ckeditorckeditor_4.14.1_full.zip的完整软件包并解压缩到我的资产文件夹中,但是当我将此目录用作CKEditor.editorUrl = '../assets/ckeditor/ckeditor.js';
时,它将无法正常工作;如果我使用CKEditor.editorUrl = '//cdn.ckeditor.com/4.14.1/full/ckeditor.js';
这样的CDN,则它将工作正常并且editorConfig也不起作用...
您想告诉我如何定义吗?
createForm.js
import React,{ Component } from 'react';
import CKEditor from 'ckeditor4-react';
CKEditor.editorUrl = '../assets/ckeditor/ckeditor.js'; // this link is not working...
//CKEditor.editorUrl = '//cdn.ckeditor.com/4.14.1/full/ckeditor.js'; it's working!
CKEditor.editorConfig = function (config) {
config.uiColor = '#2b2c26';
config.contentsCss = '../assets/desk/fonts/Nafees-Nastaleeq/css/font.css';
config.font_names = 'Nafees Nastaleeq;' + config.font_names;
};
class App extends Component {
render() {
return (
<div className="App">
<h2>Using CKEditor 4 in React</h2>
<CKEditor
data="<p>Hello from CKEditor 4!</p>"
/>
</div>
);
}
}
export default App;
解决方法
尝试从您的服务器公开ckeditor.js文件,并使用http网址作为
CKEditor.editorUrl ='http:// localhost:5000 / ckeditor / ckeditor.js';
, CKEditor.editorUrl = '../assets/ckeditor/ckeditor.js';
应该
CKEditor.editorUrl = '/assets/ckeditor/ckeditor.js';
如果它不起作用,您可以使用 process.env 和您的网站网址
import CKEditor from 'ckeditor4-react'
CKEditor.editorUrl = `${process.env.REACT_APP_BASE_URL}/ckeditor/ckeditor.js`
您可以为生产和开发设置REACT_APP_BASE_URL
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。