normalArea.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div>
  3. <article :id="id" :style="styles" class="article" :class="fullScreen ? 'fullScreen' : ''">
  4. <!-- <textEditor :id="id" :value="inputValue" /> -->
  5. <span v-show="fullScreen" class="changeSizeBtn" @click="changeSize">
  6. <svg-icon
  7. icon-class="icon-sx"
  8. class="icon"
  9. />
  10. </span>
  11. <span v-show="!fullScreen" class="changeSizeBtn" @click="changeSize">
  12. <svg-icon
  13. icon-class="icon-qp"
  14. class="icon"
  15. />
  16. </span>
  17. <editor :id="'tinymce_'+id" ref="editor" v-model="inputValue" :init="init" @input="changeText" />
  18. </article>
  19. </div>
  20. </template>
  21. <script>
  22. import tinymce from 'tinymce/tinymce'
  23. import Editor from '@tinymce/tinymce-vue'
  24. import 'tinymce/themes/silver/theme'
  25. import 'tinymce/icons/default/icons'
  26. // import textEditor from './editor'
  27. export default {
  28. components: {
  29. Editor
  30. // textEditor
  31. },
  32. props: {
  33. id: {
  34. type: String,
  35. default: '',
  36. required: true
  37. },
  38. value: {
  39. type: String,
  40. default: '',
  41. required: false
  42. },
  43. height: {
  44. type: Number,
  45. default: 200,
  46. required: false
  47. },
  48. styles: {
  49. type: Object,
  50. default: () => {
  51. return { }
  52. },
  53. required: false
  54. }
  55. },
  56. data() {
  57. return {
  58. fullScreen: false,
  59. inputValue: '',
  60. edit: false,
  61. init: {
  62. auto_focus: true,
  63. language_url: '/tinymce/langs/zh_CN.js',
  64. language: 'zh_CN',
  65. skin_url: '/tinymce/skins/ui/oxide', // 编辑器需要一个skin才能正常工作,所以要设置一个skin_url指向之前复制出来的skin文件
  66. height: this.height,
  67. browser_spellcheck: true, // 拼写检查
  68. branding: false, // 去水印
  69. elementpath: false, // 禁用编辑器底部的状态栏
  70. statusbar: false, // 隐藏编辑器底部的状态栏
  71. paste_data_images: true, // 允许粘贴图像
  72. menubar: false, // 隐藏最上方menu
  73. fontsize_formats: '14px 16px 18px 20px 24px 26px 28px 30px 32px 36px', // 字体大小
  74. file_picker_types: 'image',
  75. images_upload_credentials: true,
  76. plugins: 'lists table textcolor wordcount contextmenu', // 引入插件
  77. toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent table | undo redo | removeformat formatselect',
  78. table_toolbar: 'tableprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells'
  79. }
  80. }
  81. },
  82. watch: {
  83. value: {
  84. handler(newV, oldV) {
  85. this.inputValue = newV
  86. },
  87. immediate: true
  88. }
  89. },
  90. mounted() {
  91. tinymce.init({ selector: `#tinymce_${this.id}` })
  92. },
  93. methods: {
  94. changeText(e) { // 富文本内容改变
  95. this.inputValue = e
  96. this.$emit('update:value', this.inputValue)
  97. this.$emit('change', this.inputValue)
  98. },
  99. changeSize() {
  100. this.fullScreen = !this.fullScreen
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. .article {
  107. position: relative;
  108. .changeSizeBtn {
  109. position: absolute;
  110. top: 25px;
  111. right: 20px;
  112. z-index: 1000;
  113. }
  114. }
  115. .fullScreen {
  116. position: absolute;
  117. top: -15px;
  118. bottom: 0;
  119. left: 225px;
  120. right: 0;
  121. z-index: 1000;
  122. height: 100vh!important;
  123. /deep/.tox-tinymce {
  124. height: 100vh!important;
  125. }
  126. }
  127. .editor {
  128. border: 1px solid #666;
  129. }
  130. </style>