我一直在尝试让 TinyMCE 在选择 File Menu::New Document 选项时使用自定义 execcommand_callback 处理程序来执行操作,但即使在最基本的级别上也无法让它工作。该项目在 Rails 4 上,我正在使用来自以下位置的 tinyMCE-rails gem:
https://github.com/sophlenz/tinymce-rails
并遵循以下示例:
http://www.tinymce.com/wiki.php/Configuration3x:execcommand_callback
我已将以下内容放入 tinymce.yml
execcommand_callback: "myCustomExecCommandHandler"
生成的html:
<script>
//<![CDATA[
function myCustomExecCommandHandler(editor_id, elm, command, user_interface, value) {
alert('hello');
}
//]]>
</script>
some html ...
<form accept-charset="UTF-8" action="" id="homepage_form" method="post">
<textarea class="tinymce" cols="10" id="editor" name="editor" rows="10"></textarea>
<script>
//<![CDATA[
tinyMCE.init({"selector":"textarea.tinymce","document_base_url":"/",
"theme_advanced_toolbar_location":"top","theme_advanced_toolbar_align":"left",
"theme_advanced_statusbar_location":"bottom",
"theme_advanced_buttons3_add":"tablecontrols,fullscreen,image,link",
"plugins":"table,fullscreen,image,link",
"execcommand_callback":"myCustomExecCommandHandler"});
//]]>
</script>
more form fields ...
</form>
从表面上看,这没有任何作用。甚至不会引发警告或错误。我究竟做错了什么?