From: Aleksander Ɓukasz Date: Mon, 4 Aug 2014 12:32:11 +0000 (+0200) Subject: editor: canvas - new ctrlx handler X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/3cb9f51454470c9579939e465f07153d0b38f648?ds=sidebyside;hp=457a2c13a27a5fd49bdd5b0162111e3a9220a6ca editor: canvas - new ctrlx handler --- diff --git a/src/editor/modules/documentCanvas/canvas/keyboard.js b/src/editor/modules/documentCanvas/canvas/keyboard.js index e2479a5..f06f1f1 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -179,14 +179,6 @@ var selectsWholeTextElement = function(cursor) { return false; }; -handlers.push({key: KEYS.X, - keydown: function(event, canvas) { - if(event.ctrlKey && selectsWholeTextElement(canvas.getCursor())) { - event.preventDefault(); - } - } -}); - handlers.push({keys: [KEYS.BACKSPACE, KEYS.DELETE], keydown: function(event, canvas) { var cursor = canvas.getCursor(), @@ -289,6 +281,19 @@ var handleKeyEvent = function(e, s) { }; // todo: whileRemoveWholetext var keyEventHandlers = [ + { + applies: function(e, s) { + return e.ctrlKey && + e.key === KEYS.X && + s.type === 'textSelection' && + s.startsAtBeginning() && + s.endsAtEnd(); + }, + run: function(e,s) { + void(s); + e.preventDefault(); + } + }, { applies: function(e, s) { return e.key === KEYS.ARROW_UP && s.type === 'caret';