123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <template>
- <div>
- <article :id="id" :style="styles" class="article" :class="fullScreen ? 'fullScreen' : ''">
- <!-- <textEditor :id="id" :value="inputValue" /> -->
- <span v-show="fullScreen" class="changeSizeBtn" @click="changeSize">
- <svg-icon
- icon-class="icon-sx"
- class="icon"
- />
- </span>
- <span v-show="!fullScreen" class="changeSizeBtn" @click="changeSize">
- <svg-icon
- icon-class="icon-qp"
- class="icon"
- />
- </span>
- <editor :id="'tinymce_'+id" ref="editor" v-model="inputValue" :init="init" @input="changeText" />
- </article>
- </div>
- </template>
- <script>
- import tinymce from 'tinymce/tinymce'
- import Editor from '@tinymce/tinymce-vue'
- import 'tinymce/themes/silver/theme'
- import 'tinymce/icons/default/icons'
- // import textEditor from './editor'
- export default {
- components: {
- Editor
- // textEditor
- },
- props: {
- id: {
- type: String,
- default: '',
- required: true
- },
- value: {
- type: String,
- default: '',
- required: false
- },
- height: {
- type: Number,
- default: 200,
- required: false
- },
- styles: {
- type: Object,
- default: () => {
- return { }
- },
- required: false
- }
- },
- data() {
- return {
- fullScreen: false,
- inputValue: '',
- edit: false,
- init: {
- auto_focus: true,
- language_url: '/tinymce/langs/zh_CN.js',
- language: 'zh_CN',
- skin_url: '/tinymce/skins/ui/oxide', // 编辑器需要一个skin才能正常工作,所以要设置一个skin_url指向之前复制出来的skin文件
- height: this.height,
- browser_spellcheck: true, // 拼写检查
- branding: false, // 去水印
- elementpath: false, // 禁用编辑器底部的状态栏
- statusbar: false, // 隐藏编辑器底部的状态栏
- paste_data_images: true, // 允许粘贴图像
- menubar: false, // 隐藏最上方menu
- fontsize_formats: '14px 16px 18px 20px 24px 26px 28px 30px 32px 36px', // 字体大小
- file_picker_types: 'image',
- images_upload_credentials: true,
- plugins: 'lists table textcolor wordcount contextmenu', // 引入插件
- toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent table | undo redo | removeformat formatselect',
- table_toolbar: 'tableprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells'
- }
- }
- },
- watch: {
- value: {
- handler(newV, oldV) {
- this.inputValue = newV
- },
- immediate: true
- }
- },
- mounted() {
- tinymce.init({ selector: `#tinymce_${this.id}` })
- },
- methods: {
- changeText(e) { // 富文本内容改变
- this.inputValue = e
- this.$emit('update:value', this.inputValue)
- this.$emit('change', this.inputValue)
- },
- changeSize() {
- this.fullScreen = !this.fullScreen
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .article {
- position: relative;
- .changeSizeBtn {
- position: absolute;
- top: 25px;
- right: 20px;
- z-index: 1000;
- }
- }
- .fullScreen {
- position: absolute;
- top: -15px;
- bottom: 0;
- left: 225px;
- right: 0;
- z-index: 1000;
- height: 100vh!important;
- /deep/.tox-tinymce {
- height: 100vh!important;
- }
- }
- .editor {
- border: 1px solid #666;
- }
- </style>
|