富文本编辑器真是一个老生常谈的话题,对于我们这种小公司,没有办法自己去重新写一个,也没必要去造这种轮子,所以就挑了一个ueditor来放进项目里。
ueditor自带的上传图片功能是和后端耦合在一起的,对于各家公司的项目有前后分离的情况,并不适用,所以就只能把ueditor的源码改掉。
下面就介绍下修改上传图片的步骤。
首先,我们要找到
editorui["simpleupload"]
这个方法,方法里定义了ui变量,也就是toolbar里面上传图片的按钮,是一个editorui.Button实例。
var name = 'simpleupload',
ui = new editorui.Button({
className:'edui-for-' + name,
title:editor.options.labelMap[name] || editor.getLang("labelMap." + name) || '',
onclick: function () {
console.log(123)
var ImageUploadService = angular.element(document.body).injector().get('ImageUploadService')
// 一些操作
var embed = '<img src="***">';
editor.execC