|
|
@@ -19,13 +19,14 @@ let textEditor = {
|
|
|
plugins: [
|
|
|
'advlist autolink lists link charmap print preview anchor textcolor colorpicker',
|
|
|
'searchreplace visualblocks code fullscreen',
|
|
|
- 'insertdatetime media table contextmenu paste image code help'
|
|
|
+ 'insertdatetime media table contextmenu paste image code help'
|
|
|
],
|
|
|
- toolbar: 'undo redo | formatselect | bold italic backcolor forecolor | link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | preview | help',
|
|
|
+ toolbar: 'undo redo | formatselect | bold italic backcolor forecolor | link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | preview | help',
|
|
|
automatic_uploads: false,
|
|
|
image_title: false,
|
|
|
image_description: false,
|
|
|
- images_upload_base_path: 'ad',
|
|
|
+ images_upload_base_path: 'article',
|
|
|
+ file_picker_types: 'file image media',
|
|
|
images_upload_handler: (blobInfo, success, failure) => {
|
|
|
const handler = async () => {
|
|
|
let token = await network.getData('file/token');
|
|
|
@@ -43,6 +44,30 @@ let textEditor = {
|
|
|
|
|
|
handler();
|
|
|
},
|
|
|
+ file_picker_callback: (callback, value, meta) => {
|
|
|
+ // 模拟出一个input用于添加本地文件
|
|
|
+ let inputElem = document.createElement('input');
|
|
|
+ inputElem.setAttribute('type', 'file');
|
|
|
+ inputElem.click();
|
|
|
+ inputElem.onchange = () => {
|
|
|
+ const handler = async () => {
|
|
|
+ let token = await network.getData('file/token');
|
|
|
+ let file = inputElem.files[0];
|
|
|
+
|
|
|
+ let params = new FormData()
|
|
|
+ params.append('file', file);
|
|
|
+ params.append('uploadToken', token);
|
|
|
+ await network.postData('article/upload', params).then(response => {
|
|
|
+ let fileUrl = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + '/uploads/' + response;
|
|
|
+ callback(fileUrl, {text: response})
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ handler();
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
export {
|