VUE中tinymce設置字體大小、字體選擇(就沒有一篇文章能說的清楚的,那么我就說清楚這個問題)


 

這篇文章我們講 tinymce富文本編輯器如何增加字體大小、字體選擇

 

 tinymce編輯器:

 

第一步:
toolbar 增加自定義字體大小配置fontsizeselect及字體選擇配置項fontselect

第二步:
tinymce.init 初始化增加配置:
2.1 字體大小選擇具體項目:fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
2.2 特別說明:有人會問那么 上面字體選擇已經配置選項fontselect 那么這里要不要也增加字體選擇,可以確定的是這里不需要增加任何配置即可生效



 
        
代碼示例:
 1 export default {
 2    name: 'tinymce',
 3   props: {
 4     id: {
 5       type: String
 6     },
 7     value: {
 8       type: String,
 9       default: ''
10     },
11     toolbar: {
12       type: Array,
13       required: false,
14       default() {
15         // return ['removeformat undo redo | bullist numlist | outdent indent | forecolor | fullscreen code', 'bold italic blockquote | h2 p media link | alignleft aligncenter alignright'] // 修改前
16         return ['removeformat undo redo |  bullist numlist | outdent indent | forecolor | fullscreen code', 'bold italic blockquote | h2 p  media link | alignleft aligncenter alignright | fontsizeselect | fontselect'] // 修改后 第一步
17    } 18     },
19   },
20   mounted() {
21     this.initTinymce()
22   },
23   methods: {
24     initTinymce() {
25     window.tinymce.init({
26       toolbar: this.toolbar,
27       menubar: this.menubar,
28       plugins: 'advlist,autolink,code,paste,textcolor,colorpicker,fullscreen,link,lists,media,wordcount,imagetools',
29       fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt", // 第二步
30       end_container_on_empty_block: true,
31       powerpaste_word_import: 'clean',
32       code_dialog_height: 450,
33       code_dialog_width: 1000,
34       advlist_bullet_styles: 'square',
35       advlist_number_styles: 'default',
36     })
37    }
38   }
39 }

 

設置前:

 


設置完成后效果:

 

 
        
 
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM