From 3699a16b8d25ea8485633a6c92632a5ee30ada72 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 18 Jul 2017 19:23:18 +0000 Subject: [PATCH] Bug 17179 - Add keyboard shortcuts to repeat (duplicate) a field, and cut text This patchset introduces an internal clipboard to the advanced editor and provides some new functionality to make use of this: Ctrl-X: Now cuts a line into the clipboard area Ctrl-Shift-X: Now cuts current subfield into clipboard area Ctrl-C: Copies a line into the clipboard area Ctrl-Shift-C: Copies current subfield into clipboard area Ctrl-P: Pastes the selected item from the clipboard at cursor Ctrl-I: Copies the current line and inserts onto a new line below Ctrl-Z: Functions as undo - this was supported but now in the dropdown help To test: Verify all functionality above and confirm it behaves as expected Note: Ctrl-v pastes from the system clipboard - codemirror does not have access and this is why we use our "Clipboard" For browser cut/paste please use mouse right click or context menus Ctrl-P can be accessed as print by focusing outside the editor window Signed-off-by: Katrin Fischer https://bugs.koha-community.org/show_bug.cgi?id=17191 --- .../lib/koha/cateditor/marc-editor.js | 47 +++++++++++++++++++++- .../prog/en/modules/cataloguing/editor.tt | 30 ++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js index 3b8622a1dc..b71e91752e 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js @@ -151,6 +151,8 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], 'Ctrl-X': function( cm ) { // Delete line (or cut) if ( cm.somethingSelected() ) return true; + var curLine = cm.getLine( cm.getCursor().line ); + $("#clipboard").prepend(''); cm.execCommand('deleteLine'); }, @@ -160,8 +162,49 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], var field = cm.marceditor.getCurrentField(); if ( !field ) return; - var subfield = field.getSubfieldAt( cm.getCursor().ch ); - if ( subfield ) subfield.delete(); + var curCursor = cm.getCursor(); + var subfield = field.getSubfieldAt( curCursor.ch ); + var subfieldText = cm.getRange({line:curCursor.line,ch:subfield.start},{line:curCursor.line,ch:subfield.end}); + if ( subfield ) { + $("#clipboard").prepend(''); + subfield.delete(); + } + }, + + 'Ctrl-C': function( cm ) { + // Copy line + if ( cm.somethingSelected() ) return true; + var curLine = cm.getLine( cm.getCursor().line ); + $("#clipboard").prepend(''); + }, + + 'Shift-Ctrl-C': function( cm ) { + // Copy subfield + var field = cm.marceditor.getCurrentField(); + if ( !field ) return; + + var curCursor = cm.getCursor(); + var subfield = field.getSubfieldAt( curCursor.ch ); + var subfieldText = cm.getRange({line:curCursor.line,ch:subfield.start},{line:curCursor.line,ch:subfield.end}); + if ( subfield ) { + $("#clipboard").prepend(''); + } + }, + + 'Ctrl-P': function( cm ) { + // Paste line from "clipboard" + if ( cm.somethingSelected() ) return true; + var cBoard = document.getElementById("clipboard"); + var strUser = cBoard.options[cBoard.selectedIndex].text; + cm.replaceRange( strUser, cm.getCursor(), null ); + }, + + 'Ctrl-I': function( cm ) { + // Copy line and insert below + if ( cm.somethingSelected() ) return true; + var curLine = cm.getLine( cm.getCursor().line ); + cm.execCommand('newlineAndIndent'); + cm.replaceRange( curLine, cm.getCursor(), null ); }, Tab: function( cm ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt index dd3ab74ea4..dc80e27187 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt @@ -92,6 +92,12 @@ +

Clipboard

+
+ +
+ @@ -273,6 +279,22 @@ Save record + Ctrl-C + Copy current field + + + Ctrl-Shift-C + Copy current subfield + + + Ctrl-P + Paste selection from "clipboard" + + + Ctrl-V + Paste from system clipboard + + Ctrl-X Delete current field @@ -281,6 +303,10 @@ Delete current subfield + Ctrl-I + Copy current field on next line + + Enter New field on next line @@ -296,6 +322,10 @@ Shift-Tab Move to previous position + + Ctrl-Z + Undo previous action + -- 2.11.0