1、 在官网(http://ueditor.baidu.com/website/download.html)下载ueditor完整源码
2、查看官网文档(http://fex.baidu.com/ueditor/)
3、 (https://nodejs.org/en/)下载nodejs进行安装,安装后在命令行执行node –v,出现nodejs的版本号说明安装成功
4、 进入ueditor源码根目录,执行npm install,命令执行结束后,会在ueditor目录下出现一个node_modules文件夹
5、 仍然在该目录下,执行 grunt --encode=utf8 --server= jsp 命令进行打包(电脑上需要有Java环境),
打包成功后会在ueditor源码根目录下出现dist文件夹,里面就是打好包的ueditor了
6、 创建一个web工程,导入刚才打包后的jar包
7、 复制jsp源码到工程中
8、 项目结构
下面要开始修改源码了,注意:
//======================================
这里是修改的代码
//======================================
其他的均是源码部分
9、 修改ConfigManager.java文件
找到private ConfigManager ( String rootPath, String contextPath, String uri )方法
private ConfigManager ( String rootPath, String contextPath, String uri ) throws FileNotFoundException, IOException {
rootPath = rootPath.replace( "\\", "/" );
this.rootPath = rootPath;
this.contextPath = contextPath;
/*
if ( contextPath.length() > 0 ) {
this.originalPath = this.rootPath + uri.substring( contextPath.length() );
} else {
this.originalPath = this.rootPath + uri;
}
*/
//=================================================
//让originalPath指向WebRoot/ueditor/ueditor.config.js文件路径
this.originalPath = this.rootPath +"ueditor"+File.separator+"ueditor.config.js";
//=================================================
this.initEnv();
}
找到
public Map<String, Object> getConfig (
int type )方法
conf.put( "savePath", savePath );
conf.put( "rootPath", this.rootPath );
//============