提交 6ba480ba authored 作者: 钟是志's avatar 钟是志

将wangEditor 只应用于学工的 文章编辑中去

上级 c7ff500a
import request from '@/utils/request';
import config from '@/config/config';
const uploadUrl = config.uploadUrl.split('?')[0];
export default function uploadFile(params) {
return request(uploadUrl,
{
method: 'POST',
body: params,
});
}
......@@ -15,7 +15,7 @@
* */
import React, {useState, useEffect} from 'react';
import WangEditor from './includes/wangEditor.min';
import uploadFile from './uploadFile';
export default function Index( {
height,
zIndex,
......@@ -28,13 +28,13 @@ export default function Index( {
useEffect(()=>{
const editor = new WangEditor(`#wangEditor${key}`);
if(height){
editor.config.height = height;
editor.config.height = height; // 编辑器高度
}
if(zIndex){
editor.config.zIndex = zIndex;
editor.config.zIndex = zIndex; // 编辑器 z-index
}
if(placeholder){
editor.config.placeholder = placeholder;
editor.config.placeholder = placeholder; // placeholder
}
if(focus){
editor.config.focus = focus;
......@@ -43,15 +43,21 @@ export default function Index( {
onChangeValue(newHtml);
};
editor.config.customUploadImg = function(resultFiles, insertImgFn) {
editor.config.customUploadImg = function(resultFiles, insertImgFn) { // 重写上传图片的方法
console.log(resultFiles);
debugger;
uploadFile({ file: resultFiles[0] }).then((y) => {
if(y && y.url){
insertImgFn(y.url);
}
});
// insertImgFn(imgUrl);
};
editor.config.pasteFilterStyle = false; // 关闭粘贴样式的过滤
editor.config.uploadImgMaxSize = 3 * 1024 * 1024; // 上传的图片不能大于3M
editor.config.onchangeTimeout = 500; // html内容改变时的 timeOut 配置
editor.config.uploadImgMaxLength = 1; // 一次最多上传 1 个图片
editor.config.menus = [ // 配置菜单
'head',
'bold',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论