2013-02-21 55 views
2

我正在开发一个PHP-web应用程序,使用TinymceBundle将文本框设置为WYSIWYG-Editors(我接管了该项目,但没有实现这个功能功能)。Symfony2 TinymceBundle - 更新后不保存CTRL-S

显然,标准的tinyMCE Editor具有内置功能,可捕获CTRL + S Click事件并将其视为表单提交(而不是浏览器尝试保存当前网站)。

但现在我做了供应商库的更新,包括TinymceBundle和CTRL + S保存表单不再工作。

这是小工具的配置app/config.yml我如何找到它:

stfalcon_tinymce: 
    include_jquery: true 
    textarea_class: "tinymce" 
    theme: 
     simple: 
      mode: "textareas" 
      theme: "advanced" 
      width: '728' #firefox on windows made it too wide for some reason 
      theme_advanced_buttons1: "mylistbox,mysplitbutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink" 
      theme_advanced_buttons2: "" 
      theme_advanced_buttons3: "" 
      theme_advanced_toolbar_location: "top" 
      theme_advanced_toolbar_align: "left" 
      theme_advanced_statusbar_location: "bottom" 
      plugins: "fullscreen" 
      theme_advanced_buttons1_add: "fullscreen" 
     advanced: 
      language: de 
      theme: "advanced" 
      plugins: "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template" 
      theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect" 
      theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor" 
      theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,|,ltr,rtl,|,fullscreen" 
      theme_advanced_buttons4: "moveforward,movebackward,|,scite,del,ins,|,visualchars,nonbreaking,pagebreak" 
      theme_advanced_toolbar_location: "top" 
      theme_advanced_toolbar_align: "left" 
      theme_advanced_statusbar_location: "bottom" 
      theme_advanced_resizing: true 

为我所看到的,没有什么特别使CTRL + S保存功能,所以我认为它是启用默认情况下,但现在我需要一些东西来重新启用它(因为客户在更新后缺少它),并且我在tinyMCE documentation找不到配置选项。

保持旧版本不是一个真正的选择。

有谁知道如何启用CTRL + S =形式由专人提交功能TinymceBundle的更新后也同样遇到此行为(如果它是TinyMCE的我不能做我猜一个bug)?

在此先感谢!

编辑:日以下是在应用程序中用来渲染编辑器的代码 - 遗憾的是几乎所有的JS-初始化封装在TinymceBundle,连tinyMCE.init(...)呼叫 - 将整个配置应该在工作条目在app/config.ym

具有文本字段的NoticeType类:

{% extends 'EvenosEnoticeBundle::base.html.twig' %} 
{% block body %} 
<h1>Neue Notiz</h1> 
{{ tinymce_init() }} 
<form action="{{ path('notice_create') }}" method="post" {{ form_enctype(form) }}> 
    [...other fields...] 
    {{ form_label(form.text, 'Text') }} 
    {{ form_widget(form.text, { 'attr': {'cols': '100', 'rows': 20} }) }} 
    [...] 
    <p> 
     <button type="submit" class="btnCreate">Anlegen</button> 
    </p> 
</form> 

[...] 

{% endblock %} 

更新问:是否有人知道我怎么可以配置TinyMCE的

class NoticeType extends AbstractType 
{ 
    public function buildForm(FormBuilder $builder, array $options) 
    { 
     $builder 
     ->add('contact') 
     ->add('user') 
     ->add('direction', 'choice', array(
         'choices' => array('out' => 'Ausgehend', 'in' => 'Eingehend',), 
         'required' => true, 
     )) 
     ->add('text', 'textarea', array(
      'attr' => array('class' => 'tinymce'), 
     )) 
     ->add('customer') 
     ->add('date', 'datetime', array(
       'input' => 'datetime', 
       // 'date_format' => \IntlDateFormatter::FULL, 
       'widget' => 'single_text', 
     )) 
     ; 
    } 

    public function getName() 
    { 
     return 'evenos_enoticebundle_noticetype'; 
    } 
} 
在形式呈现模板

具体使用Stfalcon/TinymceBundleSymfony2。正如我所掌握的,它意味着只能通过symfony .yml文件进行配置,这些文件不会让您添加例如功能像TinyMCE的

+0

我在这里面临同样的问题!!你可以在symfony2找到这个soln! – 2015-03-20 08:42:49

回答

0

setup: function (ed) { ... } 

配置您可以实现类似的东西我劝here了类似的问题。

编辑:这是一个很好的教程symfone/tinymce。在部分“重写Render方法”您将设置配置参数如下

tinyMCE.init({ 
    ... 

    setup : function(ed) { 
     ed.onKeyDown.add(function onkeydown(ed, evt) { 
      // Shortcut: ctrl+h 
      if (evt.keyCode == 72 && !evt.altKey && !evt.shiftKey && evt.ctrlKey && !evt.metaKey) { 
       setTimeout(function(){ 
        var e = { type : 'keydown'}; 
        e.charCode = e.keyCode = e.which = 72; 
        e.shiftKey = e.altKey = e.metaKey = false; 
        e.ctrlKey = true; 
        window.parent && window.parent.receiveShortCutEvent && window.parent.receiveShortCutEvent(e); 
       }, 1); 
      } 
     }); 
    }, 
}); 

现在你插入包含在模板中的JavaScript功能receive_shortcutevents脚本标记。

+0

嗯,我希望能有一个更“标准”的方式来做到这一点 - 但很不幸我需要用黑客来做(至少有这种感觉)。我会再等待其他建议,否则我会接受你的回答。 – Manuel 2013-02-22 08:40:46

+0

不幸的是,似乎没有其他的方式(或者我会自己使用它) – Thariama 2013-02-22 08:48:50

+0

不幸的是我使用tinyMCE作为Symfony2的一个包,我认为我可以定义一些回调函数的唯一地方是config.yml文件张贴在我的问题 - 你有在SymFony2的tinyMCE的一些经验?我目前无法弄清楚如何使用你在我的情况下链接的答案。 – Manuel 2013-02-22 09:58:53