-
- }
-});
-
-var selectsWholeTextElement = function(cursor) {
- if(cursor.isSelecting() && cursor.getSelectionStart().offsetAtBeginning && cursor.getSelectionEnd().offsetAtEnd) {
- return true;
- }
- 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(),
- position = canvas.getCursor().getPosition(),
- element = position.element,
- node = element ? element.wlxmlNode : null,
- direction = 'above',
- caretTo = 'end',
- goto;
-
- if(!element || !node) {
- return;
- }
-
- if(event.which === KEYS.DELETE) {
- direction = 'below';
- caretTo = 'start';
- }
-
- if(cursor.isSelecting()) {
- event.preventDefault();
- var start = cursor.getSelectionStart(),
- end = cursor.getSelectionEnd();
-
- if(direction === 'above') {
- if(start.offsetAtBeginning) {
- goto = canvas.getNearestTextElement('above', start.element);
- caretTo = 'end';
- } else {
- goto = start.element;
- caretTo = start.offset;
+ },
+ {
+ applies: function(e, s) {
+ return e.key === KEYS.ARROW_RIGHT && s.type === 'caret';
+ },
+ run: function(e, s) {
+ /* globals window */
+ var next;
+ if(s.isAtEnd()) {
+ e.preventDefault();
+ next = s.canvas.getNextTextElement(s.element);
+ if(next) {
+ scroll('bottom', next.dom[0]);
+ s.canvas.setCurrentElement(s.canvas.getDocumentElement(next.dom.contents()[0]), {caretTo: 0});