mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 03:22:51 +08:00
替换富文本编辑器为wangeditor
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
};
|
||||
window.onInitElemStyle();
|
||||
|
||||
const { createEditor, createToolbar } = window.wangEditor;
|
||||
|
||||
var lastTableWhere = {};
|
||||
|
||||
@@ -1981,15 +1983,6 @@
|
||||
|
||||
},
|
||||
formSubmitEditor(dataField, form) {
|
||||
// 富文本数据处理
|
||||
var editorList = $(form).closest('.layui-form').find('.editor');
|
||||
if (editorList.length > 0) {
|
||||
$.each(editorList, function (i, v) {
|
||||
var name = $(this).attr("name");
|
||||
dataField[name] = CKEDITOR.instances[name].getData();
|
||||
});
|
||||
}
|
||||
|
||||
return dataField;
|
||||
},
|
||||
|
||||
@@ -2280,17 +2273,63 @@
|
||||
}
|
||||
},
|
||||
editor: function () {
|
||||
CKEDITOR.tools.setCookie('ckCsrfToken', window.CONFIG.CSRF_TOKEN);
|
||||
|
||||
var editorList = document.querySelectorAll(".editor");
|
||||
if (editorList.length > 0) {
|
||||
$.each(editorList, function (i, v) {
|
||||
CKEDITOR.replace(
|
||||
$(this).attr("name"),
|
||||
{
|
||||
height: $(this).height(),
|
||||
filebrowserImageUploadUrl: admin.url('ajax/uploadEditor'),
|
||||
});
|
||||
var editorConfig = {
|
||||
placeholder: '请输入内容',
|
||||
onChange(editor) {
|
||||
const html = editor.getHtml();
|
||||
$(v).val(html);
|
||||
},
|
||||
MENU_CONF: {
|
||||
uploadImage: {
|
||||
server: admin.url('ajax/uploadEditor'),
|
||||
maxFileSize: 10 * 1024 * 1024,
|
||||
fieldName: 'upload',
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var formName = $(this).attr('name');
|
||||
|
||||
var editorId = 'editor-' + formName.replace(/\[/g, '-').replace(/\]/g, '-');
|
||||
var editorContainer = $('<div id="' + editorId + '" style="height:60vh;"></div>');
|
||||
$(this).after(editorContainer);
|
||||
|
||||
var toolbarId = 'toolbar-' + formName.replace(/\[/g, '-').replace(/\]/g, '-');
|
||||
var toolbarContent = $('<div id="' + toolbarId + '"></div>');
|
||||
$(this).after(toolbarContent);
|
||||
|
||||
$(this).hide();
|
||||
|
||||
var originalValue = $(this).val();
|
||||
const editor = createEditor({
|
||||
selector: '#' + editorId,
|
||||
html: originalValue,
|
||||
config: editorConfig,
|
||||
mode: 'default',
|
||||
scroll: true
|
||||
});
|
||||
$(v).data('editor', editor);
|
||||
|
||||
|
||||
const toolbarConfig = {
|
||||
excludeKeys: [
|
||||
'uploadVideo',
|
||||
'fullScreen',
|
||||
'todo',
|
||||
]
|
||||
};
|
||||
|
||||
const toolbar = createToolbar({
|
||||
editor,
|
||||
selector: '#' + toolbarId,
|
||||
config: toolbarConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user