|
@@ -12,7 +12,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import tinymce from 'tinymce/tinymce';
|
|
|
+import 'tinymce/tinymce';
|
|
|
import Editor from '@tinymce/tinymce-vue';
|
|
|
|
|
|
import 'tinymce/icons/default/icons';
|
|
@@ -88,6 +88,7 @@ export default {
|
|
|
menubar: false,
|
|
|
branding: false,
|
|
|
statusbar: false,
|
|
|
+ // 字数限制
|
|
|
ax_wordlimit_num: 500,
|
|
|
ax_wordlimit_callback(editor) {
|
|
|
editor.execCommand('undo');
|
|
@@ -114,29 +115,42 @@ export default {
|
|
|
fail('上传失败');
|
|
|
});
|
|
|
},
|
|
|
+ file_picker_types: 'media', // 文件上传类型
|
|
|
+ /**
|
|
|
+ * 文件上传自定义逻辑函数
|
|
|
+ * @param {Function} callback
|
|
|
+ * @param {String} value
|
|
|
+ * @param {object} meta
|
|
|
+ */
|
|
|
+ file_picker_callback(callback, value, meta) {
|
|
|
+ if (meta.filetype === 'media') {
|
|
|
+ let filetype = '.mp3, .mp4';
|
|
|
+ let input = document.createElement('input');
|
|
|
+ input.setAttribute('type', 'file');
|
|
|
+ input.setAttribute('accept', filetype);
|
|
|
+ input.click();
|
|
|
+ input.addEventListener('change', () => {
|
|
|
+ let file = input.files[0];
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append(file.name, file, file.name);
|
|
|
+ fileUpload('Mid', formData)
|
|
|
+ .then(({ file_info_list }) => {
|
|
|
+ if (file_info_list.length > 0) {
|
|
|
+ callback(file_info_list[0].file_url);
|
|
|
+ } else {
|
|
|
+ callback('');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ callback('');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.addWheelEvent();
|
|
|
- },
|
|
|
methods: {
|
|
|
- addText() {
|
|
|
- tinymce.get(this.id).selection?.setContent('<strong>some</strong>');
|
|
|
- },
|
|
|
- addWheelEvent() {
|
|
|
- let richText = this.$refs.richText;
|
|
|
- if (!richText?.$el?.nextElementSibling?.getElementsByTagName('iframe')?.length) {
|
|
|
- return setTimeout(this.addWheelEvent, 100);
|
|
|
- }
|
|
|
- richText.$el.nextElementSibling.getElementsByTagName('iframe')[0].contentDocument.addEventListener(
|
|
|
- 'wheel',
|
|
|
- (e) => {
|
|
|
- if (e.ctrlKey) e.preventDefault();
|
|
|
- },
|
|
|
- { passive: false },
|
|
|
- );
|
|
|
- },
|
|
|
updateValue(data) {
|
|
|
this.$emit('update:value', data);
|
|
|
},
|