mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
【修复】修复更换ckeditor4编辑器后接龙添加编辑调用失败的问题。
This commit is contained in:
@@ -243,63 +243,12 @@
|
||||
|
||||
//加载编辑器
|
||||
var Authorization = layui.data(layui.setter.tableName)[layui.setter.request.tokenName];
|
||||
//重点代码 适配器
|
||||
class UploadAdapter {
|
||||
constructor(loader) {
|
||||
this.loader = loader;
|
||||
editor = CKEDITOR.replace('editor', {
|
||||
fileTools_requestHeaders: {
|
||||
'Authorization': Authorization
|
||||
}
|
||||
upload() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const data = new FormData();
|
||||
let file = [];
|
||||
this.loader.file.then(res => {
|
||||
file = res; //文件流
|
||||
data.append('upload', file);
|
||||
$.ajax({
|
||||
url: "/Api/Tools/CkEditorUploadFiles",
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
headers: {
|
||||
'Authorization': Authorization
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
if (data) {
|
||||
console.log(data)
|
||||
resolve({
|
||||
default: data.url //后端返回的参数 【注】返回参数格式是{uploaded:1,default:'http://xxx.com'}
|
||||
});
|
||||
} else {
|
||||
reject(data.msg);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
abort() {
|
||||
}
|
||||
}
|
||||
DecoupledEditor
|
||||
.create(document.querySelector('#editor'),
|
||||
{
|
||||
language: 'zh-cn',
|
||||
})
|
||||
.then(editor => {
|
||||
editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
|
||||
return new UploadAdapter(loader);
|
||||
};
|
||||
const toolbarContainer = document.querySelector('#toolbar-container');
|
||||
toolbarContainer.appendChild(editor.ui.view.toolbar.element);
|
||||
window.editor = editor;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//处理属性 为 lay-active 的所有元素事件
|
||||
util.event('lay-active', {
|
||||
@@ -427,7 +376,7 @@
|
||||
|
||||
form.verify({
|
||||
verifytitle: [/^.{0,250}$/, '活动标题最大只允许输入250位字符'],
|
||||
verifydescription: [/^.{0,250}$/,'活动描述最大只允许输入250位字符'],
|
||||
verifydescription: [/^.{0,250}$/, '活动描述最大只允许输入250位字符'],
|
||||
});
|
||||
//重载form
|
||||
form.render(null, 'LAY-app-CoreCmsSolitaire-createForm');
|
||||
|
||||
@@ -292,65 +292,12 @@
|
||||
|
||||
//加载编辑器
|
||||
var Authorization = layui.data(layui.setter.tableName)[layui.setter.request.tokenName];
|
||||
//重点代码 适配器
|
||||
class UploadAdapter {
|
||||
constructor(loader) {
|
||||
this.loader = loader;
|
||||
editor = CKEDITOR.replace('editor', {
|
||||
fileTools_requestHeaders: {
|
||||
'Authorization': Authorization
|
||||
}
|
||||
upload() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const data = new FormData();
|
||||
let file = [];
|
||||
this.loader.file.then(res => {
|
||||
file = res; //文件流
|
||||
data.append('upload', file);
|
||||
$.ajax({
|
||||
url: "/Api/Tools/CkEditorUploadFiles",
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
headers: {
|
||||
'Authorization': Authorization
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (data) {
|
||||
if (data) {
|
||||
console.log(data)
|
||||
resolve({
|
||||
default: data.url //后端返回的参数 【注】返回参数格式是{uploaded:1,default:'http://xxx.com'}
|
||||
});
|
||||
} else {
|
||||
reject(data.msg);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
abort() {
|
||||
}
|
||||
}
|
||||
DecoupledEditor
|
||||
.create(document.querySelector('#editor'),
|
||||
{
|
||||
language: 'zh-cn',
|
||||
})
|
||||
.then(editor => {
|
||||
editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
|
||||
return new UploadAdapter(loader);
|
||||
};
|
||||
const toolbarContainer = document.querySelector('#toolbar-container');
|
||||
toolbarContainer.appendChild(editor.ui.view.toolbar.element);
|
||||
editor.setData(d.params.data.model.contentBody);
|
||||
window.editor = editor;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
editor.setData(d.params.data.model.contentBody);
|
||||
items = d.params.data.items;
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user