# 二.模板页面(富文本)

前言

重点介绍 ceEditor 的富文本编辑器

代码示例:

<template>
  <div id="ck-editer">
    <ckeditor v-bind="$attrs" v-on="$listeners" :editor="editor"></ckeditor>
    <slot></slot>
  </div>
</template>
  
<script>
import "@ckeditor/ckeditor5-build-decoupled-document/build/translations/zh-cn";
import ckeditor from "@ckeditor/ckeditor5-vue2";
import DecoupledEditor from "@ckeditor/ckeditor5-build-decoupled-document";
import Vue from "vue";
Vue.use(ckeditor); //全局注册
export default {
  data() {
    return {
      editor: DecoupledEditor,
    };
  }
};
</script>

<style lang="less" scoped>
::v-deep.document-editor {
  border: 1px solid var(--ck-color-base-border);
  border-radius: var(--ck-border-radius);
  display: flex;
  flex-flow: column nowrap;
}

::v-deep.ck.ck-toolbar {
  z-index: 1;
  box-shadow: 0 0 5px hsla(0, 0%, 0%, 0.2);
  border-bottom: 1px solid var(--ck-color-toolbar-border);
  border: 0;
  border-radius: 0;
}

::v-deep.ck.ck-content {
  min-height: 300px;
  line-height: normal;
}
.btn{
  display: inherit;
  margin: 10px auto;
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

# 1.简单案例

刷新
全屏/自适应