Bugzilla – Attachment 93676 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), 7.66 KB, created by
Nick Clemens (kidclamp)
on 2019-10-04 08:09:22 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-10-04 08:09:22 UTC
Size:
7.66 KB
patch
obsolete
>From 2672a3ea3b322e832dd6decf838690fd35862453 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 >Shift-Ctrl-X: Now cuts current subfield into clipboard area > >Added: >Ctrl-C: Copies a line into the clipboard area >Shift-Ctrl-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 > >Signed-off-by: Alex Sassmannshausen <alex@komputilo.eu> >--- > .../bug_17179_add_keyboard_shortcuts.perl | 13 ++++++ > .../lib/koha/cateditor/marc-editor.js | 48 +++++++++++++++++++++- > .../prog/en/includes/keyboard_shortcuts.inc | 8 +++- > .../prog/en/modules/cataloguing/editor.tt | 5 +++ > 4 files changed, 70 insertions(+), 4 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..86c536f79a >--- /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) VALUES >+ ("copy_line","Ctrl-C"), >+ ("copy_subfield","Shift-Ctrl-C"), >+ ("paste_line","Ctrl-P"), >+ ("insert_line","Ctrl-I") >+ ; >+ |); >+ 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 4db3b8ae08..d3528eae88 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/includes/keyboard_shortcuts.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/keyboard_shortcuts.inc >index e735300fdf..38b5abb24a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/keyboard_shortcuts.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/keyboard_shortcuts.inc >@@ -5,12 +5,16 @@ > [%- CASE 'insert_delimiter' -%]<span>Insert delimiter (â¡)</span> > [%- CASE 'subfield_help' -%]<span>Get help on current subfield</span> > [%- CASE 'link_authorities' -%]<span>Link field to authorities</span> >- [%- CASE 'delete_field' -%]<span>Delete current field</span> >- [%- CASE 'delete_subfield' -%]<span>Delete current subfield</span> >+ [%- CASE 'delete_field' -%]<span>Delete current field and copy to 'clipboard'</span> >+ [%- CASE 'delete_subfield' -%]<span>Delete current subfield and copy to 'clipboard'</span> > [%- CASE 'new_line' -%]<span>New field on next line</span> > [%- CASE 'line_break' -%]<span>Insert line break</span> > [%- CASE 'next_position' -%]<span>Move to next position</span> > [%- CASE 'prev_position' -%]<span>Move to previous position</span> > [%- CASE 'toggle_keyboard' -%]<span>Toggle Keyboard</span> >+ [%- CASE 'copy_line' -%]<span>Copy current field</span> >+ [%- CASE 'copy_subfield' -%]<span>Copy current subfield</span> >+ [%- CASE 'paste_line' -%]<span>Paste selection from 'clipboard'</span> >+ [%- CASE 'insert_line' -%]<span>Copy current field on next line</span> > [%- END -%] > [%- END -%] >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 c72bc92bdb..f75fee2e9d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >@@ -109,6 +109,11 @@ > <li><a href="#" id="show-advanced-search" title="Show advanced search (Ctrl-Alt-S)">Advanced »</a></li> > </fieldset> > </form> >+ <h3>Clipboard</h3> >+ <fieldset class="brief"> >+ <select id="clipboard" name="clipboard" size=10> >+ </select> >+ </fieldset> > </aside> > </div> <!-- /.col-sm-2.col-sm-pull-10 --> > </div> <!-- /.row --> >-- >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