tinymceBundle的默认配置

时间:2015-05-04 15:36:01

标签: symfony tinymce

我似乎无法为stfalcon的tinymce捆绑设置默认配置。我按照here给出的指示无效。

这就是我在config.yml中的内容:

setUpVisualizableInstances

而不是为textarea显示工具栏和插件,我什么都没有。不知何故,配置它我已经完成了与tinymce的初始化混淆。有人知道我的错误在哪里吗?

更新

看看Firefox的调试工具,看起来就像是代码:

MyProject/
   res/
       layout/
           main.xml
       layout-large/
           main.xml
init.standard.js中的

是导致问题的原因。 MyProject/ res/ drawable-xhdpi/ awesomeimage.png drawable-hdpi/ awesomeimage.png drawable-mdpi/ awesomeimage.png drawable-ldpi/ awesomeimage.png 中未定义$.get(url, function(responseText) { var e = $.parseHTML(responseText); e = $(e).remove("#qrform"); ... } 。我不知道是什么原因引起的。初始化tinymce"手动"虽然工作。我没有遇到任何问题,如果不使用twig命令,我只需将它放在html页面上:

stfalcon_tinymce:
    theme:
        advanced:
            plugins:
                - "advlist autolink lists link image charmap print preview anchor"
                - "searchreplace visualblocks code fullscreen"
                - "insertdatetime media table contextmenu paste"
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
            image_advtab: true

3 个答案:

答案 0 :(得分:3)

好吧,在修改了init.standard.js之后,我找到了解决方案。显然,你必须将一个数据主题属性传递给你想要的tintaceize,它与你想要在config.yml中拥有默认配置的主题相对应。否则,init.standard.js与您的settings变量的配置选择不匹配。

就我而言,配置的主题是advanced所以我只是在我的表单构建器中执行了此操作:

$builder
    // ...
    ->add('text', 'textarea', array(
        'attr' => array(
            'class'      => 'tinymce',
            'data-theme' => 'advanced'
            )
        ))
    // ...

这就是诀窍。

答案 1 :(得分:0)

此处列出了您需要做的简要清单:

∙将资源复制到您的网络文件夹php app/console assets:install

∙在页面底部添加此{{ tinymce_init() }}(在javascripts部分)

∙将tinymce选择器添加到表单属性:

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

∙并在conf中配置tinymce选择器:

# app/config/config.yml
    stfalcon_tinymce:
        #...
        selector: ".tinymce"

尝试检查一下你是否已经完成它。

<强>更新

另请查看Web浏览器控制台并解决问题(如果有)。

答案 2 :(得分:0)

这是tinymceBundle的默认配置

# app/config/config.yml
stfalcon_tinymce:
    selector: ".tinymce"
    theme:
        simple:
            height: 250
            plugins:
                - "advlist autolink lists link image charmap print preview hr anchor pagebreak"
                - "searchreplace wordcount visualblocks visualchars code fullscreen"
                - "insertdatetime media nonbreaking save table contextmenu directionality"
                - "emoticons template paste textcolor"
            toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link unlink image media"
            toolbar2: "print preview code | forecolor backcolor emoticons"
            image_advtab: true
            templates:
                - {title: 'Test template 1', content: 'Test 1'}
                - {title: 'Test template 2', content: 'Test 2'}
                - {title: 'Test template 3', content: 'Test 3'}
                - {title: 'Test template 4', content: 'Test 4'}

# AppBundle/Form/FormType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('description', TextareaType::class, [
            'attr' => [
                'class' => 'tinymce'
            ]
        ]);
}
相关问题