From d1f7a30aa1d02a3274793937203924e9d98a0c1d Mon Sep 17 00:00:00 2001 From: Cori Lynn Arnold Date: Wed, 18 Dec 2019 21:19:10 +0000 Subject: [PATCH] Bug 21665: Advanced editor - double clicking on value brings subfield code as well To test, apply patch: 0/Verify that the advanced editor is enabled by going to "Administration" and searching for "EnableAdvancedCatalogingEditor" 1/Set it to "Enable" if it isn't already. 2/Go to "Cataloging", click on "Advanced editor" 3/Search for a record by entering "specious" in the keyword box and hitting enter 4/Click "import" on a record 5/For any subfield (maybe specifically the text in an 020 field) double click on the text 6/Hit CNTRL-V into your favorite text editor, verify that the subfield code was not pasted with the text from the subfield. --- .../intranet-tmpl/lib/koha/cateditor/marc-editor.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 5e39a43b75..5c190d2907 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js @@ -86,6 +86,22 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], editor.overwriteMode = newState; } + function doubleClickSubfield( cm ) { + 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.contentsStart},{line:curCursor.line,ch:subfield.end}); + var textArea = document.createElement("TEXTAREA"); + textArea.value = subfieldText; + textArea.style.background = 'transparent'; + document.body.appendChild(textArea); + textArea.select(); + document.execCommand("Copy"); + document.body.removeChild(textArea); + } + // Editor helper functions function activateTabPosition( cm, pos, idx ) { // Allow tabbing to as-yet-nonexistent positions @@ -625,6 +641,7 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], this.cm.on( 'changes', editorChanges ); this.cm.on( 'cursorActivity', editorCursorActivity ); this.cm.on( 'overwriteToggle', editorSetOverwriteMode ); + this.cm.on( 'dblclick', doubleClickSubfield ); this.onCursorActivity = options.onCursorActivity; -- 2.11.0