问题描述
我在页面中使用tinyMCE.我捕获了 + 以使用ajax保存内容,当焦点不在tinyMCE中时,一切正常,但是当焦点在tinyMCE中时,它没有工作.我需要一段代码插入此代码块中(而不是设置或插件中),以使内容保存工作,即使焦点位于tinyMCE内部.
I am using tinyMCE in a page. I capture + to save the content using ajax, when the focus is out of tinyMCE, everything works fine, but when the focus is in the tinyMCE it doesn't work. I need a piece of code to insert in this block of code (and not in the settings or plugins) to make content save working even if the focus is inside tinyMCE.
<script type="text/javascript">
$(document).ready(function() {
dssModify = new Sol.Dss.Modify();
dssModify.config =
{
urlActionContentSave: "<?php echo \Sol\Dss\Dss::me () -> urlActionContentSaveGet () ; ?>",
buttonContentSaveId: "<?php echo \Sol\Dss\Dss::me () -> modifyButtonContentSaveIdGet () ; ?>",
buttonContentSavingTitle: "<?php echo \Sol\Dss\Dss::me () -> modifyButtonContentSavingTitleGet () ; ?>",
buttonContentSaveTitle: "<?php echo \Sol\Dss\Dss::me () -> modifyButtonContentSaveTitleGet () ; ?>",
textareaContentId: "<?php echo \Sol\Dss\Dss::me () -> modifyTextareaContentIdGet () ; ?>",
formId: "<?php echo \Sol\Dss\Dss::me () -> modifyFormIdGet () ; ?>",
idRoutes: "<?php echo $route[ 'id' ] ; ?>"
};
whenClicked = function()
{
$("#"+dssModify.config.textareaContentId).val(tinyMCE.activeEditor.getContent());
dssModify.contentSave();
}
$("#<?php echo Sol\Dss\Dss::me () -> modifyButtonContentSaveIdGet () ; ?>").click( whenClicked );//Click Function
$(window).keypress(function(event) {
if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19))
return true;
whenClicked();
event.preventDefault();
return false;
});
}//Ready function
);
</script>
推荐答案
这是一个棘手的问题.您将必须在主文档中创建一个像这样的函数.
This is a tricky one.You will have to create a function like this in the main document.
function receiveShortCutEvent(eventObject){
//console.log('receiveShortCutEvent', eventObject);
$(document).trigger(eventObject);
$(document).trigger({type: 'keydown', ctrlKey: eventObject.ctrlKey, altKey: eventObject.altKey, which: eventObject.keyCode, originalEvent:eventObject });
return false;
}
在tinymce端,如果输入ctrl + h,则需要调用receiveShortCutEvent.为此,您可以使用设置配置参数.
On the tinymce side you will need to call receiveShortCutEvent if ctrl+h gets typed.You may use the setup configuration paramter for this.
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);
}
});
希望您能明白.
这篇关于禁用tinyMCE ctrl + s快捷方式以启用此快捷方式以保存Ajax内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!