网站首页 > 精选文章 正文
第一步 访问
https://ckeditor.com/ckeditor-5/online-builder/
第二步 选择Classic 根据自身需求选择需要的ckeditor5插件 注意带有**标识的为收费插件,选择好后点击Next step,进入下一步
第三步 选择工具栏默认显示的插件,并可以进行排序设置,选择Next step 进入下一步
第四步 选择语言,简体中文选择第一个Chinese, 点击Next step进入下一步
第五步 点击Start按钮 生成自定义构建压缩包, 然后点击 Download your custom CKEditor 5 build 按钮开始下载
第六步 下载完成后,可以得到一个ckeditor5-34.2.0-xxxx.zip的压缩包,然后直接将压缩包剪切到vue3根目录下并解压,修改解压后目录为ckeditor5-34.2.0,目录结构如下
第七步 在项目目录下,运行命令 yarn add @ckeditor/ckeditor5-vue 安装 @ckeditor/ckeditor5-vue
第八步 在项目目录下, 运行命令 yarn add file:./ckeditor5-34.2.0 安装自定义构建ckeditor(注意:最近发现yarn2.0版本运行该命令会报错,如遇到这种情况
可尝试直接将以下代码放入package.json的dependencies中,再运行yarn install 或 yarn进行安装
"ckeditor5-custom-build": "file:./ckeditor5-34.2.0"
第九步 在main.ts文件中引入ckeditor 如下图
如果不想在全局引入Ckeditor5,只在需要的vue组件中使用的话,可以不做以上main.ts修改,只在需要使用ckeditor5的vue组件中加入以下代码即可
// @ts-ignore
import CKEditor from '@ckeditor/ckeditor5-vue';
const ckeditor = CKEditor.component;
第十步 在需要Ckeditor的vue页面中,使用即可,代码如下
<template>
<div>
<ckeditor :editor="state.editor" v-model="state.editorData" :config="state.editorConfig"></ckeditor>
</div>
</template>
<script lang="ts" setup>
import {nextTick, onMounted, reactive} from "vue";
// @ts-ignore
import {Editor as ClassicEditor} from 'ckeditor5-custom-build/build/ckeditor';
const state = reactive({
editor: ClassicEditor,
editorData: '',
editorConfig: {
// The configuration of the editor.
}
})
</script>
<style scoped>
</style>
运行效果图如下:
另外如果想调整工具栏中插件的顺序、对插件进行分组或者删减不常用的插件,可以在editorConfig中进行自定义配置,下方附一份配置示例
<template>
<div>
<ckeditor :editor="state.editor" v-model="state.editorData" :config="state.editorConfig"></ckeditor>
</div>
</template>
<script lang="ts" setup>
import {nextTick, onMounted, reactive} from "vue";
// @ts-ignore
import {Editor as ClassicEditor} from 'ckeditor5-custom-build/build/ckeditor';
const state = reactive({
editor: ClassicEditor,
editorData: '',
editorConfig: {
// The configuration of the editor.
toolbar: {
items: [
'undo', 'redo',
'|',
'findAndReplace', 'selectAll',
'|',
'heading',
'|',
'removeFormat', 'bold', 'italic', 'strikethrough', 'underline', 'code', 'subscript', 'superscript',
'|',
'specialCharacters', 'horizontalLine', 'pageBreak',
'|',
'-',
'highlight', 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor',
'|',
'link', 'blockQuote', 'insertTable', 'uploadImage', 'codeBlock', 'htmlEmbed',
'|',
'bulletedList', 'numberedList', 'todoList',
'|',
'outdent', 'indent', 'alignment',
'|',
'textPartLanguage',
'|',
'sourceEditing'
],
shouldNotGroupWhenFull: true
},
}
})
</script>
<style scoped>
</style>
配置后效果如下图
- 上一篇: 使用vue3和go搭建网站(附源码)
- 下一篇:已经是最后一篇了
猜你喜欢
- 2025-05-27 使用vue3和go搭建网站(附源码)
- 2025-05-27 「干货」Vue+Element前端导入导出Excel
- 2025-05-27 好的项目,万物皆可打包,我将Vue项目打包成客户端(模拟钉钉)
- 2025-05-27 vue下载excel文件方法
- 2025-05-27 vue组件的注册
- 2025-05-27 我常用的几个 VueUse 最佳组合,推荐给你们
- 2025-05-27 Vue开发环境搭建
- 2025-05-27 基于 Vue 超漂亮Toast提示组件Vue-Toastification
- 05-27vue3安装在线构建ckeditor5教程
- 05-27使用vue3和go搭建网站(附源码)
- 05-27「干货」Vue+Element前端导入导出Excel
- 05-27好的项目,万物皆可打包,我将Vue项目打包成客户端(模拟钉钉)
- 05-27vue下载excel文件方法
- 05-27vue组件的注册
- 05-27我常用的几个 VueUse 最佳组合,推荐给你们
- 05-27Vue开发环境搭建
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)