2013-02-21 54 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