编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

PHP 安装 CKEditor5 和 CKFinder3

wxchong 2024-07-04 10:00:36 开源技术 13 ℃ 0 评论

最近Django想写个博客,发现博客还真的不好写,为啥?没有好用的富文本编辑器,转战又去学PHP,发现PHP中的CKEditor5不错,但是有个弊端,上传不了图片,经过多次反复看文档,发现了一个比较好用安装方法,给大家提供一下:

CKEditor5资源下载:

https://ckeditor.com/ckeditor-5-builds/download

ckfinder3资源下载:

https://ckeditor.com/ckeditor-4/download/#ckfinder

写一个如下的html文件

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>CKEditor 5 - Classic editor</title>
    <script src="https://cdn.ckeditor.com/ckeditor5/10.0.0/classic/ckeditor.js"></script>
</head>
<body>
    <h1>Classic editor</h1>
    <textarea name="content" id="editor">
        <p>This is some sample content.</p>
    </textarea>
<script type="text/javascript">
        ClassicEditor
            .create( document.querySelector( '#editor' ), {
                //工具栏可选择项
                //toolbar: ['headings', 'bold', 'italic', 'blockQuote', 'bulletedList', 'numberedList', 'link', 'ImageUpload', 'undo'],
                language: 'zh-cn',
  						 //ckfinder加载
                ckfinder: {
                    uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
                }
            }
            )            
            .catch( error => {
                console.error( error );
            } );
    </script>

</body>
</html>

把ckfinder解压后,放到网站根目录下(例如:/Var/www/html)

打开ckfinder/config.php

$config['authentication'] = function () {
    return true;
};

把false改成true,保存。


OK!就这么简单搞定了,没必要还要composer之类的安装,那样只是越来越晕。

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表