|
@@ -2,7 +2,24 @@
|
|
<div :class="{fullscreen:fullscreen}" class="tinymce-container" :style="{width:containerWidth}">
|
|
<div :class="{fullscreen:fullscreen}" class="tinymce-container" :style="{width:containerWidth}">
|
|
<textarea :id="tinymceId" class="tinymce-textarea" />
|
|
<textarea :id="tinymceId" class="tinymce-textarea" />
|
|
<div class="editor-custom-btn-container">
|
|
<div class="editor-custom-btn-container">
|
|
- <editorImage color="#1890ff" class="editor-upload-btn" @successCBK="imageSuccessCBK" />
|
|
|
|
|
|
+
|
|
|
|
+ <el-upload
|
|
|
|
+ ref="upload"
|
|
|
|
+ :limit="1"
|
|
|
|
+ action="/api/artical/uploadFile"
|
|
|
|
+ :auto-upload="true"
|
|
|
|
+ :show-file-list="false"
|
|
|
|
+ :headers="headers"
|
|
|
|
+ class="editor-upload-btn mlr10"
|
|
|
|
+ :before-upload="uploadBefore"
|
|
|
|
+ :on-success="uploadSuccess"
|
|
|
|
+ >
|
|
|
|
+ <el-button size="small" type="primary" >
|
|
|
|
+ 添加附件
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-upload>
|
|
|
|
+
|
|
|
|
+ <editorImage color="#1890ff" class="editor-upload-btn mlr10" @successCBK="imageSuccessCBK" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -13,6 +30,7 @@
|
|
* https://panjiachen.github.io/vue-element-admin-site/feature/component/rich-editor.html#tinymce
|
|
* https://panjiachen.github.io/vue-element-admin-site/feature/component/rich-editor.html#tinymce
|
|
*/
|
|
*/
|
|
import editorImage from './components/EditorImage'
|
|
import editorImage from './components/EditorImage'
|
|
|
|
+import editorFile from './components/EditorFile'
|
|
import plugins from './plugins'
|
|
import plugins from './plugins'
|
|
import toolbar from './toolbar'
|
|
import toolbar from './toolbar'
|
|
import load from './dynamicLoadScript'
|
|
import load from './dynamicLoadScript'
|
|
@@ -24,7 +42,7 @@ const tinymceCDN = 'https://cdn.jsdelivr.net/npm/tinymce-all-in-one@4.9.3/tinymc
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: 'Tinymce',
|
|
name: 'Tinymce',
|
|
- components: { editorImage },
|
|
|
|
|
|
+ components: { editorImage, editorFile },
|
|
props: {
|
|
props: {
|
|
id: {
|
|
id: {
|
|
type: String,
|
|
type: String,
|
|
@@ -116,8 +134,6 @@ export default {
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
init() {
|
|
init() {
|
|
- // this.initTinymce()
|
|
|
|
- // dynamic load tinymce from cdn
|
|
|
|
load(tinymceCDN, (err) => {
|
|
load(tinymceCDN, (err) => {
|
|
if (err) {
|
|
if (err) {
|
|
this.$message.error(err.message)
|
|
this.$message.error(err.message)
|
|
@@ -222,6 +238,22 @@ export default {
|
|
tinymce.destroy()
|
|
tinymce.destroy()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ uploadBefore(file) {
|
|
|
|
+ const maxSize = file.size / 1024 / 1024 < 20;
|
|
|
|
+ if (!maxSize) {
|
|
|
|
+ this.$message.error('每个文件最大20M');
|
|
|
|
+ }
|
|
|
|
+ return maxSize;
|
|
|
|
+ },
|
|
|
|
+ uploadSuccess(res, file) {
|
|
|
|
+ console.log( res, file.name )
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ window.tinymce.get(this.tinymceId).insertContent(
|
|
|
|
+ `<a target="_blank" style="cursor:hand;color:blue" href="http://smoa.ndjsxh.cn:8888/preview/${res.data.filename}">${file.name}</a></br>`)
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error('图片上传失败')
|
|
|
|
+ }
|
|
|
|
+ },
|
|
onPaste(e) {
|
|
onPaste(e) {
|
|
var items=e.clipboardData.items;
|
|
var items=e.clipboardData.items;
|
|
var item = items[0];
|
|
var item = items[0];
|
|
@@ -288,4 +320,6 @@ export default {
|
|
.editor-upload-btn {
|
|
.editor-upload-btn {
|
|
display: inline-block;
|
|
display: inline-block;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.mlr10{ margin-left: 10px; margin-right: 10px;}
|
|
</style>
|
|
</style>
|