helios-ag/fm-tinymce-bundle

TinyMCE 包,为您的 Symfony 项目添加 TinyMCE 编辑器

2.0 2024-01-11 00:40 UTC

This package is auto-updated.

Last update: 2024-09-08 23:27:59 UTC


README

TinyMCE 在 Symfony 中的集成

包的目的是提供 elFinder 和 TinyMCE 编辑器之间的无缝集成。

代码质量保证

TinyMCE 是一个独立平台的基于网页的 JavaScript WYSIWYG HTML 编辑器控制,作为开源软件在 LGPL 下发布。

TinyMCE 允许您将 HTML TEXTAREA 字段或其他 HTML 元素转换为编辑器实例。

目录

安装

步骤 1: 安装

将 FMTinyMCEBundle 添加到您的 composer.json

{
    "require": {
        "helios-ag/fm-tinymce-bundle": "~1"
    }
}

如果您想覆盖 Richfilemanager 默认的资产目录,请添加以下选项。默认情况下,资产复制到 web/assets/tinymcepublic/assets/tinymce,具体取决于 Symfony 版本

{
    "config": {
        "tinymce-dir": "web/assets/"
    }
}

添加 composer 脚本

"FM\\TinyMCEBundle\\Composer\\TinyMCEScriptHandler::copy",

到 composer.json 的 scripts 部分

{
  "scripts": {
      "symfony-scripts": [
          "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
          "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
          "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
          "FM\\TinyMCEBundle\\Composer\\TinyMCEcriptHandler::copy",
          "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
          "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
          "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
      ]
    }
}

现在运行以下命令告诉 composer 下载包:

composer update helios-ag/fm-tinymce-bundle

步骤 2: 启用包

在 kernel 中启用包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FM\TinyMCEBundle\FMTinyMCEBundle(),
    );
}

基本配置

将配置选项添加到您的 config.yml

fm_tinymce:
    instances:
        first_instance:
            language: en_US
            width: 300
            height: 400
        my_advanced_configuration:
             locale: ru_RU

##高级配置

为了简化说明,这里是一个 TinyMCE 和 Elfinder 包之间的集成示例

fm_tinymce:
    instances:            # Required
        elfinder:
            language: ru
            image_advtab:         true
            file_picker_callback: elFinderBrowser
            filebrowser_type:     fm_elfinder
            filebrowser:
                route:                elfinder
                route_parameters:
                    instance: tinymce

以及 ElFinderBrowser 的配置

fm_elfinder:
    instances:
        tinymce:
            language: ru
            editor: tinymce4 #
            include_assets: true
            relative_path: true
            connector:
                roots:       # at least one root must be defined
                    uploads:
                        show_hidden: false
                        driver: LocalFileSystem
                        path: uploads
                        upload_allow: ['all']

完整的配置参考示例

fm_tinymce:
    enable:               true
    inline:               false
    base_path:            assets/tinymce/
    js_path:              assets/tinymce/tinymce.min.js
    instances:
        default:
            language:             en_US
            width:                600
            height:               300
            theme:                modern
            toolbar_item_size:    small
            menubar:              file edit insert view format table tools
            image_advtab:         false
            templates:
                templates:
                    title:                ~
                    content:              ~
            plugins:              ""
            relative_urls:        false
            convert_urls:         false
            toolbars:
                toolbar1:         undo redo | styleselect | bold italic | link image
            filebrowser_type:     fm_elfinder
            file_picker_callback: elFinderBrowser
            filebrowser:
                url:                  http://localhost/elfinder
                route:                elfinder
                route_parameters:
                    instance: default