CKEditor5 基本使用
1.引入
<script type="text/javascript" src="/plugin/ckeditor5/ckeditor.js"></script>
2.html
<div class="form-group col-lg-12">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark"></span>内容:</label>
<textarea class="form-control-erbi col-lg-5" name="editor" id="editor" /></textarea>
</div>
3.样式
<style>
.ck-editor__main{
width:75%;
padding-right: 0;
float: right;
}
.ck-editor__editable {
min-height: 200px;
}
</style>
4.启动
var myEditor = null;
window.onload = function(){
ClassicEditor
.create(document.querySelector("#editor"), {
ckfinder: {
uploadUrl: '/admin.php/Common/ck_editor?command=QuickUpload&type=Files&responseType=json'
}
})
.then(editor => {
myEditor = editor;
// 设置初始值
myEditor.setData('');
})
.catch(error => {
console.error(error);
});
}
5.图片上传后台,文件名默认为upload
public function ck_editor(){
$config = array(
"savePath" => "./site_upload/ck_editor/" , //存储文件夹
"maxSize" => 1000000 , //允许的文件最大尺寸,单位KB
"allowFiles" => array( ".gif" , ".png" , ".jpg" , ".jpeg" , ".bmp" ) //允许的文件格式
);
$up = new Uploader( "upload" , $config );
$info = $up->getFileInfo();
$info['url'] = substr($info['url'],1);
$host_name = Func::getHostName();
$url = 'http://' . $host_name . $info['url'];
$qiniu = new QiniuImg();
$ext = pathinfo($url, PATHINFO_EXTENSION);
$name = time() . mt_rand() . '.' . $ext;
$s = $qiniu->up($url, $name, config('app.qiniu.bucket'));
if($s){
@unlink('.'.$info['url']);
$info['url'] = config('cdn_host').$name;
}
if ($info) {
$this->json->setAttr('uploaded',true);
$this->json->setAttr('url',[$info['url']]);
$this->json->Send();
} else {
$this->json->setAttr('uploaded',false);
$this->json->setErr(10099,'上传失败');
$this->json->Send();
}
}
6.获取内容
var htmlStr=myEditor.getData();
$('#editor').val(htmlStr);
配置自己的tarbar
var myEditor = null;
window.onload = function(){
ClassicEditor
.create(document.querySelector("#editor"), {
toolbar: ["undo", "redo", "|", "alignment", "bold", "italic", "blockQuote", "imageTextAlternative", "imageUpload", "heading", "link", "numberedList", "bulletedList"],
ckfinder: {
uploadUrl: '/admin.php/Common/ck_editor?command=QuickUpload&type=Files&responseType=json'
}
})
.then(editor => {
myEditor = editor;
// 设置初始值
myEditor.setData('');
})
.catch(error => {
console.error(error);
});
}

CKEditor5 基本使用的更多相关文章
- CKEditor5 + ckfinder3(php)
CKEditor5资源下载,这里我们选择ckeditor5-build-classic下载: https://ckeditor.com/ckeditor-5-builds/download/ ckfi ...
- CKEditor5 + vue2.0 自定义图片上传、highlight、字体等用法
因业务需求,要在 vue2.0 的项目里使用富文本编辑器,经过调研多个编辑器,CKEditor5 支持 vue,遂采用.因 CKEditor5 文档比较少,此处记录下引用和一些基本用法. CKEdit ...
- ckeditor5 安装高亮,颜色插件
ckeditor5 安装高亮插件 1.准备 git clone -b stable https://github.com/ckeditor/ckeditor5-build-classic.git cd ...
- ckeditor5 增加居中alignment
https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/installing-plugins.html 克隆下来 gi ...
- ckeditor5富文本编辑器在vue中的使用
安装依赖: npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic 要创建编辑器实例,必须首先将编辑器 ...
- CKEditor5 使用第二天 获取回传数据,图片上传
1.当系统中存在编辑功能时,需要将数据库中数据回显到页面,因此采用了最一般的方法,通过隐藏的input标签存贮,在通过CkEditor5中的setData方法将数据赋值到富文本框中 <texta ...
- CKEditor5 输入文字时拼音和汉字同时输入问题
在使用 CKEditor5 + vue 时,出现输入文字时,拼音和文字一起输入到编辑器到问题.与之前项目中使用 ckeditor 的区别是,这次项目是在 python 架构下局部引入 ckeditor ...
- Ckeditor5显示css样式
Ckeditor5在编辑模式是通过js加载样式的,但是在显示时没有提供,官方提供了两种方式来实现. https://ckeditor.com/docs/ckeditor5/latest/builds/ ...
- ckeditor5字体颜色,字体背景颜色设置显示
在config.js中添加相关代码: config.allowedContent=true;//关闭标签过滤, config.colorButton_enableAutomatic = true; c ...
随机推荐
- [LeetCode] 172. Factorial Trailing Zeroes_Easy tag: Math
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...
- 一个新人对于DW标签的理解
标签呢分为 一.一般标签 一般标签内又分为 ① 格式控制标签 格式控制标签的书写格式是: <font .....></font> 以font为开头以/font为结尾 font ...
- Yosemite安装libv8和therubyracer
yosemite ruby version升级的时候,会碰到类似 Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before b ...
- 【kafka学习之二】Kafka集群搭建
安装环境 jdk1.7 zookeeper-3.4.5(参考 https://www.cnblogs.com/cac2020/p/9426531.html) VM虚拟机redhat6.5-x64 ...
- Qt学习之路(45): 自定义model之一
前面我们说了Qt提供的几个预定义model.但是,面对变化万千的需求,那几个model是远远不能满足我们的需要的.另外,对于Qt这种框架来说,model的选择首先要能满足绝大多数功能的需要,这就是说, ...
- web前端----Bootstrap框架补充
一.一个小知识点 1.截取长屏的操作 2.设置默认格式 3.md,sm, xs 4.空格和没有空格的选择器 二.响应式介绍 - 响应式布局是什么? 同一个网页在不同的终端上呈现不同的布局等- 响应式怎 ...
- MySQL数据库总结
引擎 查看MySQL默认引擎:show variables like '%storage_engine%'; 查看表引擎:show table status from 数据库名; 修改表引擎alter ...
- xml声明中的standalone属性
晚上,在测试tinyxml的时候,发现其中声明了<?xml version="1.0" standalone="no" ?>,经查,其含义为stan ...
- Win10 Edge浏览器怎么重装 Win10重装Edge浏览器
具体如下: 重新安装Microsoft Edge 1.按Windows键+ R,打开 输入以下代码,可以直接复制黏贴. %LocalAppData%\Packages\Microsoft.Micros ...
- git2
1,开源的代码管理工具 2,分布式管理工具(更安全,可以脱网操作) 3,git的分支管理更加便捷. 4,代码的传输更新速度更快 利用git可以进入多人配合代码开发.有备份.协同 sudo apt-ge ...