Prevent Ctrl+S from saving useless content. Add support for custom shortcuts in CkEditor
This commit is contained in:
parent
1d31aab990
commit
1c5847dd01
@ -424,6 +424,24 @@ define([
|
|||||||
logoutHandlers.push(h);
|
logoutHandlers.push(h);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var shortcuts = [];
|
||||||
|
funcs.addShortcuts = function (w) {
|
||||||
|
w = w || window;
|
||||||
|
if (shortcuts.indexOf(w) !== -1) { return; }
|
||||||
|
shortcuts.push(w);
|
||||||
|
$(w).keydown(function (e) {
|
||||||
|
// Ctrl || Meta (mac)
|
||||||
|
if (e.ctrlKey || (navigator.platform === "MacIntel" && e.metaKey)) {
|
||||||
|
// Ctrl+E: New pad modal
|
||||||
|
if (e.which === 69) {
|
||||||
|
e.preventDefault();
|
||||||
|
return void funcs.createNewPadModal();
|
||||||
|
}
|
||||||
|
// Ctrl+S: prevent default (save)
|
||||||
|
if (e.which === 83) { return void e.preventDefault(); }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Object.freeze(funcs);
|
Object.freeze(funcs);
|
||||||
return { create: function (cb) {
|
return { create: function (cb) {
|
||||||
@ -500,6 +518,8 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
ctx.metadataMgr.onReady(waitFor());
|
ctx.metadataMgr.onReady(waitFor());
|
||||||
|
|
||||||
|
funcs.addShortcuts();
|
||||||
}).nThen(function () {
|
}).nThen(function () {
|
||||||
try {
|
try {
|
||||||
var feedback = ctx.metadataMgr.getPrivateData().feedbackAllowed;
|
var feedback = ctx.metadataMgr.getPrivateData().feedbackAllowed;
|
||||||
|
|||||||
@ -863,6 +863,7 @@ Messenger, MessengerUI, Messages) {
|
|||||||
});
|
});
|
||||||
$(window).keydown(function (e) {
|
$(window).keydown(function (e) {
|
||||||
if (e.which === 69 && (e.ctrlKey || (navigator.platform === "MacIntel" && e.metaKey))) {
|
if (e.which === 69 && (e.ctrlKey || (navigator.platform === "MacIntel" && e.metaKey))) {
|
||||||
|
e.preventDefault();
|
||||||
Common.createNewPadModal();
|
Common.createNewPadModal();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -428,6 +428,8 @@ define([
|
|||||||
|
|
||||||
var ifrWindow = $html.find('iframe')[0].contentWindow;
|
var ifrWindow = $html.find('iframe')[0].contentWindow;
|
||||||
|
|
||||||
|
framework._.sfCommon.addShortcuts(ifrWindow);
|
||||||
|
|
||||||
var documentBody = ifrWindow.document.body;
|
var documentBody = ifrWindow.document.body;
|
||||||
|
|
||||||
var observer = new MutationObserver(function (muts) {
|
var observer = new MutationObserver(function (muts) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user