Copy (yank) link texts with y+LinkHints (#5915)

This commit is contained in:
Christian Günter 2022-12-06 15:50:04 +01:00 committed by GitHub
parent 9ad6fa8afb
commit f13d7c235f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 2 deletions

View File

@ -1355,6 +1355,7 @@ function LinkHints(linkHintHotKey){
this.pendingPath = ""; // already typed code prefix this.pendingPath = ""; // already typed code prefix
this.hintsMap = this.deployHintContainers(); this.hintsMap = this.deployHintContainers();
this.activatedDropdown = null; this.activatedDropdown = null;
this.yankModeActive = false;
} }
LinkHints.prototype.getHintStartValue = function(targetsCount){ LinkHints.prototype.getHintStartValue = function(targetsCount){
@ -1441,10 +1442,15 @@ LinkHints.prototype.handleKey = function(event){
return; return;
} }
if (event.key === "y") {
this.yankModeActive = !this.yankModeActive;
}
if (event.key === this.linkHintHotKey && Hotkeys.isHotkeyCallPossible()) { if (event.key === this.linkHintHotKey && Hotkeys.isHotkeyCallPossible()) {
// on user hide hints, close an opened dropdown too // on user hide hints, close an opened dropdown too
if (this.areHintsDisplayed && this.activatedDropdown) this.closeActivatedDropdown(); if (this.areHintsDisplayed && this.activatedDropdown) this.closeActivatedDropdown();
if (this.areHintsDisplayed) this.yankModeActive = false;
this.pendingPath = ""; this.pendingPath = "";
this.displayHints(!this.areHintsDisplayed); this.displayHints(!this.areHintsDisplayed);
@ -1455,10 +1461,15 @@ LinkHints.prototype.handleKey = function(event){
this.pendingPath += event.key; this.pendingPath += event.key;
var hint = this.hintsMap[this.pendingPath]; var hint = this.hintsMap[this.pendingPath];
if (hint) { // we are there, we have a fully specified tooltip. Let's activate it if (hint) { // we are there, we have a fully specified tooltip. Let's activate or yank it
this.displayHints(false); this.displayHints(false);
event.preventDefault(); event.preventDefault();
if (this.yankModeActive) {
submitSapeventForm({ clipboard : hint.parent.firstChild.textContent },"yank_to_clipboard");
this.yankModeActive = false;
} else {
this.hintActivate(hint); this.hintActivate(hint);
}
} else { } else {
// we are not there yet, but let's filter the link so that only // we are not there yet, but let's filter the link so that only
// the partially matched are shown // the partially matched are shown

View File

@ -163,6 +163,10 @@ CLASS zcl_abapgit_gui_hotkey_ctl IMPLEMENTATION.
&& |<span class="key-id">{ ls_user_settings-link_hint_key }</span>| && |<span class="key-id">{ ls_user_settings-link_hint_key }</span>|
&& |<span class="key-descr">Link Hints</span>| && |<span class="key-descr">Link Hints</span>|
&& |</li>| ). && |</li>| ).
ri_html->add( |<li>|
&& |<span class="key-id">y{ ls_user_settings-link_hint_key }</span>|
&& |<span class="key-descr">Copy Link Text</span>|
&& |</li>| ).
ENDIF. ENDIF.
ri_html->add( '</ul>' ). ri_html->add( '</ul>' ).

View File

@ -569,6 +569,12 @@ CLASS zcl_abapgit_gui_router IMPLEMENTATION.
zcl_abapgit_ui_factory=>get_frontend_services( )->clipboard_export( lt_clipboard ). zcl_abapgit_ui_factory=>get_frontend_services( )->clipboard_export( lt_clipboard ).
MESSAGE 'Successfully exported URL to Clipboard.' TYPE 'S'. MESSAGE 'Successfully exported URL to Clipboard.' TYPE 'S'.
rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act. rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act.
WHEN zif_abapgit_definitions=>c_action-yank_to_clipboard.
lv_clip_content = ii_event->form_data( )->get( 'CLIPBOARD' ).
APPEND lv_clip_content TO lt_clipboard.
zcl_abapgit_ui_factory=>get_frontend_services( )->clipboard_export( lt_clipboard ).
MESSAGE 'Successfully exported to Clipboard.' TYPE 'S'.
rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act.
ENDCASE. ENDCASE.
ENDMETHOD. ENDMETHOD.

View File

@ -511,6 +511,7 @@ INTERFACE zif_abapgit_definitions
homepage TYPE string VALUE 'homepage', homepage TYPE string VALUE 'homepage',
sponsor TYPE string VALUE 'sponsor', sponsor TYPE string VALUE 'sponsor',
clipboard TYPE string VALUE 'clipboard', clipboard TYPE string VALUE 'clipboard',
yank_to_clipboard TYPE string VALUE 'yank_to_clipboard',
show_hotkeys TYPE string VALUE 'show_hotkeys', show_hotkeys TYPE string VALUE 'show_hotkeys',
END OF c_action. END OF c_action.
CONSTANTS c_spagpa_param_repo_key TYPE c LENGTH 20 VALUE 'REPO_KEY' ##NO_TEXT. CONSTANTS c_spagpa_param_repo_key TYPE c LENGTH 20 VALUE 'REPO_KEY' ##NO_TEXT.