jlaso/jsoneditor-bundle

Symfony JlasoJsonBundle

安装: 16

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 2

分支: 0

公开问题: 0

语言:JavaScript

类型:symfony-bundle

dev-master / 1.0.2.x-dev 2018-11-14 20:28 UTC

This package is auto-updated.

Last update: 2024-09-15 10:08:22 UTC


README

在SF2项目中集成json编辑器

安装

Composer


在你的kernel init文件中实例化Bundle

// app/AppKernel.php
<?php
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Jlaso\Bundle\JlasoJsonEditorBundle\JlasoJsoneditorBundle(),
        );
    }

然后,运行以下命令

    php app/console assets:install web/

将资源复制到项目的Web目录。

其他


基本配置

默认情况下,执行以下操作

将类"jsoneditor"添加到textarea字段以初始化Htmleditor。

    <textarea class="jsoneditor"></textarea>

如果您想使用编辑器的jQuery版本,请设置以下参数

    jlaso_jsoneditor:
        include_jquery: true
        htmleditor_jquery: true
        ...

选项include_jquery允许从Google CDN加载外部jQuery库。如果您还没有在其他地方包含jQuery库,请将其设置为true

如果您使用FormBuilder,请使用数组添加类,您还可以使用theme选项将使用的主题更改为除了'simple'之外的其他主题(例如,您的配置中定义的其他主题 - 上述示例定义了'medium')。例如:

<?php
    $builder->add('introtext', 'textarea', array(
        'attr' => array(
            'class' => 'jsoneditor',
        )
    ));

将脚本添加到您的模板/layout的页面底部(以加快页面显示)。

    {{ jsoneditor_init() }}
# app/config/config.yml
twig:
    form:
        resources:
            - 'JlasoJsoneditorBundle:Form:fields.html.twig'

本地化

您可以通过在配置的最高级别添加语言选择器来更改tiny_mce的语言,例如:

    // app/config/config.yml
    jlaso_jsoneditor:
        include_jquery: true
        jsoneditor_jquery: true
        textarea_class: "jsoneditor"
        language: %locale%
        theme:
            simple:
                mode: "textareas"
                theme: "advanced"
        ...