zoukankan      html  css  js  c++  java
  • vue+ckEditor5

    1.安装依赖
    "@ckeditor/ckeditor5-build-balloon": "^10.1.0", "@ckeditor/ckeditor5-build-classic": "^10.1.0", "@ckeditor/ckeditor5-build-inline": "^10.1.0", "vue-ckeditor5": "^0.1.5",

     2.html 

     <div id="ckEditor">
         <vue-ckeditor type="balloon"  v-model="content" :editors="editors1" :config='config' ></vue-ckeditor>
     </div>

    3.引入文件

      import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
      import BalloonEditor from '@ckeditor/ckeditor5-build-balloon'
      import InlineEditor from '@ckeditor/ckeditor5-build-inline'
      import VueCkeditor from 'vue-ckeditor5'

    4.js

        data(){
          return {
            content: '',
            editors1: {
              // classic: ClassicEditor,
              balloon: BalloonEditor
            },
            config:{
              language:'en',
              ckfinder: {
                  uploadUrl: $.getCookie('prefixUrl') +'/file/uploads'
              },
              image:{
                 toolbar: [ 'imageTextAlternative', '|', 'imageStyle:alignLeft', 'imageStyle:full', 'imageStyle:alignRight' ],
                 styles: [
                    // This option is equal to a situation where no style is applied.
                    'full',
                    // This represents an image aligned to the left.
                    'alignLeft',
                    // This represents an image aligned to the right.
                    'alignRight'
                ]
              },
              fontSize: {
                  options: [
                      'tiny',
                      'small',
                      'big',
                      'huge'
                  ]
              },
              fontFamily: {
                  options: [
                      'default',
                      'Ubuntu, Arial, sans-serif',
                      'Ubuntu Mono, Courier New, Courier, monospace'
                  ]
              },
              toolbar: [
                  'heading',
                '|',
                'alignment',// <--- ADDED
                'bold',
                'italic',
                'link',
                'fontFamily',
                'fontSize',
                // 'bulletedList',
                // 'numberedList',
                'imageUpload',
                // 'blockQuote',
                'undo',
                'redo'
              ]
            }
          }
        },
        components:{
          'vue-ckeditor': VueCkeditor.component
        }
     

    5.处理数据

          ctbrife(str){
            // str = str.replace(/<c:if[^>]*>([sS]*?)</c:if>/g,'')
            str = str.replace(/</?[^>]*>/g,''); //去除HTML tag
            str = str.replace(/[ | ]*
    /g,'
    '); //去除行尾空白
            //str = str.replace(/
    [s| | ]*
    /g,'
    '); //去除多余空行
            str=str.replace(/ /ig,'');//去掉 
            return str.substring(0,40);
          }
  • 相关阅读:
    mybatis中的配置文件的约束
    win10下PHP开发环境搭建
    装饰器的理解
    在iis上添加woff字体文件读取
    转发:使用sql命令查询视图中所有引用的基础表
    转:C4项目中验证用户登录一个特性就搞定
    转载:NSobject官方介绍
    thinkphp生命周期
    array_intersect_assoc — 带索引检查计算数组的交集
    array_flip — 交换数组中的键和值
  • 原文地址:https://www.cnblogs.com/cx709452428/p/10148567.html
Copyright © 2011-2022 走看看