Bugzilla – Attachment 85396 Details for
Bug 17179
Advanced editor: Add keyboard shortcuts to repeat (duplicate) a field, and cut text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17179: Add keyboard shortcuts to repeat (duplicate) a field, and cut text
Bug-17179-Add-keyboard-shortcuts-to-repeat-duplica.patch (text/plain), 5.86 KB, created by
Nick Clemens (kidclamp)
on 2019-02-20 17:36:50 UTC
(
hide
)
Description:
Bug 17179: Add keyboard shortcuts to repeat (duplicate) a field, and cut text
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-02-20 17:36:50 UTC
Size:
5.86 KB
patch
obsolete
>From accb425b54336a4628bf2bb826d4939ca78caa2a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 20 Feb 2019 17:30:36 +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, default shortcuts are provided >but can be edited per bug 21411 > >The default shortcuts for new/changed functions are: > >Changed: >Ctrl-X: Now cuts a line into the clipboard area >Ctrl-Shift-X: Now cuts current subfield into clipboard area > >Added: >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 > >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 >--- > .../bug_17179_add_keyboard_shortcuts.perl | 13 ++++++ > .../lib/koha/cateditor/marc-editor.js | 48 +++++++++++++++++++++- > .../prog/en/modules/cataloguing/editor.tt | 6 +++ > 3 files changed, 65 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_17179_add_keyboard_shortcuts.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_17179_add_keyboard_shortcuts.perl b/installer/data/mysql/atomicupdate/bug_17179_add_keyboard_shortcuts.perl >new file mode 100644 >index 0000000000..e929914706 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_17179_add_keyboard_shortcuts.perl >@@ -0,0 +1,13 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q| >+ INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys, shortcut_desc) VALUES >+ ("copy_line","Ctrl-C","Copy current field"), >+ ("copy_subfield","Ctrl-Shift-C","Copy current subfield"), >+ ("paste_line","Ctrl-P","Paste selectiion from 'clipboard'"), >+ ("insert_line","Ctrl-I","Copy current field on next line") >+ ;| >+ ); >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 17179 - Add additional keyboard_shortcuts)\n"; >+} >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 af20307ca2..a674b738f9 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js >@@ -160,6 +160,9 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], > _editorKeys[delete_field] = function( cm ) { > // Delete line (or cut) > if ( cm.somethingSelected() ) return true; >+ var curLine = cm.getLine( cm.getCursor().line ); >+ >+ $("#clipboard").prepend('<option>'+curLine+'</option>'); > > cm.execCommand('deleteLine'); > } >@@ -193,8 +196,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('<option>'+subfieldText+'</option>'); >+ subfield.delete(); >+ } >+ } >+ >+ _editorKeys[copy_line] = function( cm ) { >+ // Copy line >+ if ( cm.somethingSelected() ) return true; >+ var curLine = cm.getLine( cm.getCursor().line ); >+ $("#clipboard").prepend('<option>'+curLine+'</option>'); >+ } >+ >+ _editorKeys[copy_subfield] = 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('<option>'+subfieldText+'</option>'); >+ } >+ } >+ >+ _editorKeys[paste_line] = 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 ); >+ } >+ >+ _editorKeys[insert_line] = 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 ); > } > > _editorKeys[next_position] = 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 81f468e823..51aa5cf0a5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >@@ -111,6 +111,12 @@ > </fieldset> > </form> > >+<h3>Clipboard</h3> >+<fieldset class="brief"> >+ <select id="clipboard" name="clipboard" size=10> >+ </select> >+</fieldset> >+ > </div> > > </div> >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17179
:
65090
|
67817
|
68675
|
85396
|
86025
|
86041
|
92406
|
93601
|
93602
|
93676
|
93677
|
93857
|
93858
|
93861
|
93897
|
93898
|
93899