Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2 TinymceBundle-更新后CTRL-S不保存_Php_Symfony_Tinymce - Fatal编程技术网

Php Symfony2 TinymceBundle-更新后CTRL-S不保存

Php Symfony2 TinymceBundle-更新后CTRL-S不保存,php,symfony,tinymce,Php,Symfony,Tinymce,我正在开发一个PHPWeb应用程序,它使用TinymceBundle将文本框样式设置为WYSIWYG编辑器(我接管了该项目,最初没有实现此功能) 显然,tinyMCE Editor by standard有一个内置功能,可以捕获Ctrl+S单击事件并将其视为表单提交(而不是浏览器试图保存当前站点) 但现在我更新了供应商库,包括TinymceBundle和Ctrl+S,以保存表单不再有效 这是app/config.yml中小部件的配置,我是如何找到它的: stfalcon_tinymce:

我正在开发一个PHPWeb应用程序,它使用TinymceBundle将文本框样式设置为WYSIWYG编辑器(我接管了该项目,最初没有实现此功能)

显然,tinyMCE Editor by standard有一个内置功能,可以捕获Ctrl+S单击事件并将其视为表单提交(而不是浏览器试图保存当前站点)

但现在我更新了供应商库,包括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保存功能,所以我假设它在默认情况下已启用,但现在我需要一些东西来再次启用它(因为客户在更新后丢失了它),而我当时没有找到用于此功能的配置选项

保留旧版本并不是一个真正的选择

有人知道如何手动启用Ctrl+S=form submit功能吗?或者在TinymceBundle更新后也经历过这种行为(如果是tinyMCE的bug,我想我做不了多少)

编辑:以下是应用程序中用于呈现编辑器的代码-不幸的是,几乎所有JS初始化都封装在
TinymceBundle
中,甚至
tinyMCE.init(…)
call-整个配置应该在
app/config.ym
中的条目上工作

具有文本字段的
NoticeType
类:

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';
    }
}
在呈现表单的模板中:

{% 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的配置

您可以实现类似我针对类似问题建议的功能

编辑:这是一个非常好的教程。在“覆盖渲染方法”部分中,插入设置配置参数,如下所示

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\u shortcutevents
的脚本标记。

我希望有一种更“标准”的方法来实现这一点,但显然我需要一种技巧(至少感觉是这样的)。我会再等几天,等待其他建议,否则我会接受你的答案。不幸的是,似乎没有其他办法(或者我自己也会用)不幸的是,我正在使用tinyMCE作为Symfony2的捆绑包。我认为我唯一可以定义一些回调函数的地方是我在问题中发布的config.yml文件——您对tinyMCE在Symfony2中的使用有经验吗?我目前不知道如何使用您在我的情况下链接的答案。我在不久前有过一些使用Symfony的经验,但不能将两者结合使用。你能找到将呈现html(和javascript)的代码片段吗?不幸的是,该教程是针对symfony 1X的,而不是2X,这两个版本截然不同:/正如我所说,我甚至找不到修改
tinyMCE.init()
调用的地方,因为它隐藏在包中的某个地方,我在应用程序中所拥有的只是twig
tinymce\u init()
调用,它的定义也隐藏在下面的某个地方。。。我将更新我的问题,专门询问有关TinymceBundle for Symfony2的问题。我在这里面临同样的问题!!你能在symfony2中找到解决方案吗!!!
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);
            }
        });
    },
});