1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <template>
- <div ref="editor" style="text-align:left"></div>
- </template>
- <script>
- import E from 'wangeditor';
- const menus = [
- 'head',
- 'bold',
- 'fontSize',
- 'fontName',
- 'italic',
- 'underline',
- 'strikeThrough',
- 'foreColor',
- 'backColor',
- 'link',
- 'list',
- 'justify',
- 'quote',
-
- 'table',
-
-
- 'undo',
- 'redo',
- ];
- export default {
- name: 'wang-editor',
- model: {
- prop: 'value',
- event: 'change',
- },
- props: {
- value: { type: String, required: false, default: '' },
- },
- data() {
- return {
- editorContent: this.value,
- };
- },
- mounted() {
- var editor = new E(this.$refs.editor);
- editor.customConfig.onchange = html => {
- this.editorContent = html;
- this.$emit('change', html);
- };
-
- editor.customConfig.menus = menus;
- editor.customConfig.zIndex = 0;
- editor.customConfig.uploadImgServer = '/files/cms/images/upload';
- editor.customConfig.uploadImgMaxLength = 1;
- editor.customConfig.uploadImgHooks = {
-
-
- customInsert: function(insertImg, result, editor) {
-
-
-
- var url = result.uri;
- insertImg(url);
-
- },
- };
- editor.create();
- editor.txt.html(this.value);
- },
- methods: {
- getContent: function() {
- return this.editorContent;
- },
- },
- };
- </script>
|