3xw/cakephp-tinymce

此软件包最新版本(4.2.2)没有提供许可证信息。

CakePHP 工具插件

安装: 761

依赖项: 3

建议者: 0

安全性: 0

星标: 0

关注者: 3

分支: 0

公开问题: 0

语言:Vue

类型:cakephp-plugin

4.2.2 2022-08-23 07:26 UTC

README

Tinymce 4 for cakephp 4.x

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 软件包的推荐方法是

composer require 3xw/cakephp-tinymce

在您的 src/Application.php 文件中

$this->addPlugin(\Trois\Tinymce\Plugin::class, ['boostrap' => true]);

配置

在 config/boostrap 文件末尾

Configure::write('Trois/Tinymce.config', ['tinymce']);

使用自己的配置,创建文件 config/tinymce.php,例如

<?php
use Cake\Routing\Router;

return [
  'Trois/Tinymce'  => [
    'height' => '500',
    'language' => 'fr_FR',
    'language_url' => 'https://static.3xw.ch/tinymce/lang/fr_FR.js',
    'menubar' => false,
    'plugins' => ['advlist autolink lists link charmap print preview searchreplace visualblocks code fullscreen emoticons insertdatetime table contextmenu paste  code help wordcount'],
    'toolbar'  => 'attachment | insert | undo redo | formatselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | emoticons | code | removeformat ',
    'block_formats' => 'Paragraphe=p;Titre 1=h1;Titre 2=h2;Titre 3=h3',
    'formats' => [
      'bold' => ['inline'  => 'strong'],
      'italic' => ['inline'  => 'em'],
      'underline' => ['inline'  => 'u'],
      'strikethrough' => ['inline'  => 'del'],
      'lead' => ['block'  => 'p', 'classes'  => 'lead'],
    ],
    'valid_elements' => '*[style],p[style],strong,em,i,u,del,a[href|target],ul,ol,li[style],table,th,td[style],tr,img[src|style|class|alt|width|height]',
    'valid_styles' => ['*' => 'text-align,color'],
    'content_css' => []
  ]
];

用法

在您的视图文件中

echo $this->element('Trois/Tinymce.tinymce',[
  'field' => 'content',
  'value' => $post->content,
  'init' => [ // optional
    'some_settings' => 'coucou',
    'toolbar'  => 'code | removeformat ', // override settings and add only code & removeformat
]);