ebarrosjr/ckeditor

CakePHP 3.x版本选择的CkEditor插件

安装: 147

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:cakephp-plugin

v1.2.0 2019-09-23 13:44 UTC

This package is auto-updated.

Last update: 2024-09-24 00:25:27 UTC


README

安装

您可以使用composer将此插件安装到您的CakePHP应用程序中。这是一个个人版本:https://github.com/CakeCoded/CkEditor,具有选择版本和分发的可能性。

安装composer包的推荐方式是

composer require ebarrosjr/ckeditor

然后在config/bootstrap.php中添加

Plugin::load('CkEditor');

在src/Controller/AppController.php中,或者您希望使用CKEditor的任何控制器中,添加

public $helpers = ['CkEditor.Ck' => [
	'distribution' => 'full', // Default Option :: Others options => 'basic', 'standard'
	'version' => '4.11.4', //Default option, others via CDN page
	'script' => null // You can now point to a custom ckeditor JS file
]];

最后,在您的模板文件中,只需添加以下内容来调用CKEditor

echo $this->Ck->input('field_name');

这相当于使用

echo $this->Form->input('field_name');

不过CKEditor将代替文本区域加载!

高级选项

您可以根据需要调整CKEditor和表单输入。在这方面具有完全的灵活性。

完整的说明如下

echo $this->Form->input($input, $options, $ckEditorOptions, $ckEditorUrl);
@param string $input

字段名称,可以是field_name或model.field_name

@param array $options

选项包括 $options['label'] 用于自定义标签和任何其他自定义Form Helper选项

@param array $ckEditorOptions

这将传递来自 http://docs.ckeditor.com/#!/guide/dev_configuration 的任何选项到CKEditor

@param string $ckEditorUrl

这提供了一个覆盖CKEditor URL的选项。如果需要,您可以使用本地URL。

示例

使用关联的字段名称

echo $this->Ck->input('category.description');

生成自定义标签

echo $this->Ck->input('field_name', ['label' => 'A unique label']);

http://docs.ckeditor.com/#!/guide/dev_configuration添加到CKEditor的选项

echo $this->Ck->input('field_name', [], ['fullPage' => true, 'allowedContent' => 'true']);

加载CKEditor的本地版本或不同版本

echo $this->Ck->input('field_name', [], [], '/js/ckeditor.js');

展示所有选项的示例

echo $this->Ck->input('field_name', ['label' => 'A unique label'], ['fullPage' => true, 'allowedContent' => 'true'], '/js/ckeditor.js');