@ -1,22 +1,25 @@
< template >
< template >
< div :class ="{fullscreen:fullscreen}" class = "tinymce-container editor-container" >
< div :class ="{fullscreen:fullscreen}" class = "tinymce-container editor-container" >
< textarea :id ="tinymceId" class = "tinymce-textarea" / >
< textarea :id ="tinymceId" class = "tinymce-textarea" / >
< el -dialog id = "editor-dialog" class = "image-dialog" title = "选择图片" :visible.sync ="dialogVisible" width = "70%" :close-on-click-modal ="false" append -to -body >
< el -dialog id = "editor-dialog" class = "image-dialog" title = "选择图片" :visible.sync ="dialogVisible" width = "70%" :close-on-click-modal ="false" append -to -body >
< upload -image :multiple ="true" :branch-id ="userInfo.branchId" :dept-id ="userInfo.deptid" :visible ="dialogVisible" @cancel ="dialogVisible=false" @confirm ="handleConfirm" > < / upload -image >
< upload -image :multiple ="true" :branch-id ="userInfo.branchId" :dept-id ="userInfo.deptid" :visible ="dialogVisible" @cancel ="dialogVisible=false" @confirm ="handleConfirm" > < / upload -image >
< / e l - d i a l o g >
< / e l - d i a l o g >
< / div >
< / div >
< / template >
< / template >
< script >
< script >
import config from '@/common/config' ; / / 全 局 公 共 库 i m p o r t
import UploadImage from '@/components/Image/UploadImage' ;
import { mapGetters } from 'vuex'
import config from '@/common/config' ; / / 全 局 公 共 库 i m p o r t
import UploadImage from '@/components/Image/UploadImage' ;
import { mapGetters } from 'vuex'
import plugins from './plugins'
import plugins from './plugins'
import toolbar from './toolbar'
import toolbar from './toolbar'
export default {
export default {
name : 'Tinymce' ,
name : 'Tinymce' ,
components : { UploadImage } ,
components : { UploadImage } ,
props : {
props : {
value : {
value : {
type : String ,
type : String ,
default : ''
default : ''
@ -39,10 +42,10 @@ export default {
}
}
} ,
} ,
data ( ) {
data ( ) {
return {
return {
imageList : [ ] ,
imageList : [ ] ,
dialogVisible : false ,
dialogVisible : false ,
editorHtmlData : this . value ,
editorHtmlData : this . value ,
tinymceId : 'vue-tinymce-' + new Date ( ) . getTime ( ) + ( ( Math . random ( ) * 1000 ) . toFixed ( 0 ) + '' ) ,
tinymceId : 'vue-tinymce-' + new Date ( ) . getTime ( ) + ( ( Math . random ( ) * 1000 ) . toFixed ( 0 ) + '' ) ,
fullscreen : false ,
fullscreen : false ,
languageTypeList : {
languageTypeList : {
@ -54,19 +57,19 @@ export default {
computed : {
computed : {
language ( ) {
language ( ) {
return this . languageTypeList [ this . $store . getters . language ]
return this . languageTypeList [ this . $store . getters . language ]
} ,
} ,
... mapGetters ( [
... mapGetters ( [
'userInfo'
'userInfo'
] )
] )
} ,
} ,
watch : {
watch : {
value ( val ) {
value ( val ) {
if ( val == this . editorHtmlData ) {
if ( val == this . editorHtmlData ) {
return ;
return ;
}
}
this . $nextTick ( ( ) => window . tinymce . get ( this . tinymceId ) . setContent ( val || '' ) )
this . $nextTick ( ( ) => window . tinymce . get ( this . tinymceId ) . setContent ( val || '' ) )
} ,
} ,
editorHtmlData ( val ) {
editorHtmlData ( val ) {
this . $emit ( "input" , val )
this . $emit ( "input" , val )
} ,
} ,
language ( ) {
language ( ) {
@ -75,12 +78,12 @@ export default {
}
}
} ,
} ,
mounted ( ) {
mounted ( ) {
this . $nextTick ( ( ) => this . initTinymce ( ) )
this . $nextTick ( ( ) => this . initTinymce ( ) )
} ,
} ,
/ * *
/ * *
activated ( ) {
activated ( ) {
this . initTinymce ( )
this . initTinymce ( )
} ,
} ,
deactivated ( ) {
deactivated ( ) {
this . destroyTinymce ( )
this . destroyTinymce ( )
@ -111,32 +114,33 @@ export default {
imagetools_cors_hosts : [ 'www.qingqinkj.com' , 'codepen.io' ] ,
imagetools_cors_hosts : [ 'www.qingqinkj.com' , 'codepen.io' ] ,
default_link_target : '_blank' ,
default_link_target : '_blank' ,
link_title : false ,
link_title : false ,
convert_urls : false ,
fontsize_formats : "8pt 10pt 12pt 14pt 18pt 20pt 24pt 28pt 30pt 36pt 38pt 40pt 42pt 46pt 48pt" ,
fontsize_formats : "8pt 10pt 12pt 14pt 18pt 20pt 24pt 28pt 30pt 36pt 38pt 40pt 42pt 46pt 48pt" ,
font_formats : "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings" ,
font_formats : "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings" ,
nonbreaking_force_tab : true , / / i n s e r t i n g n o n b r e a k i n g s p a c e & n b s p ; n e e d N o n b r e a k i n g S p a c e P l u g i n
nonbreaking_force_tab : true , / / i n s e r t i n g n o n b r e a k i n g s p a c e & n b s p ; n e e d N o n b r e a k i n g S p a c e P l u g i n
init_instance_callback : editor => {
init_instance_callback : editor => {
if ( _this . value ) {
if ( _this . value ) {
editor . setContent ( _this . value )
editor . setContent ( _this . value )
}
editor . on ( 'NodeChange Change KeyUp SetContent' , ( ) => {
_this . editorHtmlData = editor . getContent ( )
}
editor . on ( 'NodeChange Change KeyUp SetContent' , ( ) => {
_this . editorHtmlData = editor . getContent ( )
} )
} )
} ,
} ,
setup ( editor ) {
setup ( editor ) {
editor . on ( 'FullscreenStateChanged' , ( e ) => {
editor . on ( 'FullscreenStateChanged' , ( e ) => {
_this . fullscreen = e . state
_this . fullscreen = e . state
} )
} )
editor . addButton ( 'imageList' , {
editor . addButton ( 'imageList' , {
text : '图片库' ,
text : '图片库' ,
icon : false ,
icon : false ,
onclick : function ( ) {
onclick : function ( ) {
_this . dialogVisible = true ;
_this . $nextTick ( ( ) => {
_this . dialogVisible = true ;
_this . $nextTick ( ( ) => {
/ / d o c u m e n t . g e t E l e m e n t B y I d ( " e d i t o r - d i a l o g " ) . s t y l e . z I n d e x = " 1 0 0 0 0 0 "
/ / d o c u m e n t . g e t E l e m e n t B y I d ( " e d i t o r - d i a l o g " ) . s t y l e . z I n d e x = " 1 0 0 0 0 0 "
} )
} )
}
}
} )
} )
}
}
@ -173,9 +177,9 @@ export default {
/ / c o n s o l e . l o g ( e r r ) ;
/ / c o n s o l e . l o g ( e r r ) ;
/ / } ) ;
/ / } ) ;
/ / } ,
/ / } ,
} )
} )
this . setContent ( this . value )
this . setContent ( this . value )
} ,
} ,
destroyTinymce ( ) {
destroyTinymce ( ) {
const tinymce = window . tinymce . get ( this . tinymceId )
const tinymce = window . tinymce . get ( this . tinymceId )
@ -186,13 +190,13 @@ export default {
tinymce . destroy ( )
tinymce . destroy ( )
}
}
} ,
} ,
setContent ( value ) {
setContent ( value ) {
window . tinymce . get ( this . tinymceId ) . setContent ( value )
window . tinymce . get ( this . tinymceId ) . setContent ( value )
} ,
} ,
getContent ( ) {
getContent ( ) {
window . tinymce . get ( this . tinymceId ) . getContent ( )
window . tinymce . get ( this . tinymceId ) . getContent ( )
} ,
} ,
insertImage ( ) {
insertImage ( ) {
let imageList = this . imageList ;
let imageList = this . imageList ;
let imageHtml = "" ;
let imageHtml = "" ;
( imageList || [ ] ) . map ( item => {
( imageList || [ ] ) . map ( item => {
@ -203,10 +207,10 @@ export default {
}
}
this . dialogVisible = false ;
this . dialogVisible = false ;
} ,
} ,
handleConfirm ( imgs ) {
handleConfirm ( imgs ) {
this . imageList = imgs / / { u r l : x x x , r e m a r k : x x x x }
this . imageList = imgs / / { u r l : x x x , r e m a r k : x x x x }
this . insertImage ( ) ;
this . insertImage ( ) ;
} ,
} ,
imageSuccessCBK ( arr ) {
imageSuccessCBK ( arr ) {
const _this = this
const _this = this
@ -247,4 +251,4 @@ export default {
z - index : 20000 ! important ;
z - index : 20000 ! important ;
}
}
< / style >
< / style >