1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 03:50:56 +08:00
2021-04-28 20:40:18 +08:00

96 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

layui.use(['jquery'], function () {
var $ = layui.jquery;
var $textarea = $('#vditor-textarea');
var toolbar = [
'emoji',
'headings',
'bold',
'italic',
'strike',
'link',
'|',
'list',
'ordered-list',
'check',
'outdent',
'indent',
'|',
'quote',
'line',
'code',
'inline-code',
'insert-before',
'insert-after',
'|',
'upload',
'table',
'|',
'undo',
'redo',
'|',
'fullscreen',
'edit-mode',
{
name: 'more',
toolbar: [
'both',
'export',
'preview',
'info',
'help',
],
}];
var vditor = new Vditor('vditor', {
mode: 'sv',
minHeight: 450,
outline: false,
toolbar: toolbar,
resize: {
enable: true
},
cache: {
enable: false
},
preview: {
markdown: {
chinesePunct: true,
autoSpace: true
}
},
fullscreen: {
index: 9999
},
counter: {
enable: true,
max: 30000
},
upload: {
url: '/upload/content/img',
max: 10 * 1024 * 1024,
accept: 'image/*',
headers: {
'X-Csrf-Token': $('meta[name="csrf-token"]').attr('content'),
'X-Requested-With': 'XMLHttpRequest'
},
success: function (editor, responseText) {
var json = JSON.parse(responseText);
var img = '![](' + json.data.src + ')';
vditor.insertValue(img);
}
},
value: $textarea.val(),
placeholder: '酷瓜云课堂100%开源在线教育解决方案'
});
/**
* 同步编辑器内容到表单
*/
$('.kg-submit').on('click', function () {
$textarea.val(vditor.getValue());
});
});