プロジェクト

全般

プロフィール

Vote #79778

完了

Switch edit/preview tabs with keyboard shortcuts

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
UI_10
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
10
version_id:
152
issue_org_id:
30459
author_id:
259873
assigned_to_id:
332
comments:
24
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

In Redmine 3.4 and earlier, you could update the preview with keybord shortcuts.
RedmineKeyboardNavigation:
|Key|Description|
|r|Updates the preview in editor mode|

I want to switch Edit/Preview tabs with keybord shortcuts.
Github:
!{width: 70%; border: 1px solid #ccc}github_shortcut.gif!


journals

I remember this topic was also discussed in the original feature. The problem was that there can be multiple editors on a single view and the implemented accesskeys are not able to determine which editor is in focus at the moment. We would need a proper hotkey system beforehand to make this happen.
--------------------------------------------------------------------------------
Bernhard Rohloff wrote:
> I remember this topic was also discussed in the original feature. The problem was that there can be multiple editors on a single view and the implemented accesskeys are not able to determine which editor is in focus at the moment. We would need a proper hotkey system beforehand to make this happen.

Yes, is on the to do list to implement something custom using JS.

Mizuki, do you have some working code? or you have in plan to work on this? just to know in order to not double work on this.

--------------------------------------------------------------------------------
Bernhard Rohloff wrote:
> I remember this topic was also discussed in the original feature.
I have not noticed it. Thank you for the information.
Discussion related to this topic: #27758#note-21

Marius BALTEANU wrote:
> Mizuki, do you have some working code? or you have in plan to work on this? just to know in order to not double work on this.
I have no plans to work for the implementation of this feature.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Which should be the keyboard shortcuts here?
--------------------------------------------------------------------------------
Oh yes! It would be really helpful if this is possible again with wiki pages.

> The problem was that there can be multiple editors on a single view and the implemented accesskeys are not able to determine which editor is in focus at the moment.

I don't know anything about implementation, but I would be surprised if determining the right editor is that hard. Shouldn't it be "document.activeElement":https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement?

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
The attached patch adds ⌘/Ctrl + Shift + P keyboard shortcut to toggle between Edit/Preview tabs. This keyboard shortcut is used by both Github and Gitlab.

I don't think that it's worth it to keep also the old shortcut (r).

Any feedback is welcome.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Marius BALTEANU wrote:
> The attached patch adds ⌘/Ctrl + Shift + P keyboard shortcut to toggle between Edit/Preview tabs. This keyboard shortcut is used by both Github and Gitlab.
>
> I don't think that it's worth it to keep also the old shortcut (r).
>
> Any feedback is welcome.

Thank you for sharing the patch!
I checked the operation of the patch you posted and noticed that there were cases where an exception occurred.

Reproduction procedure:
* Open preview tab with mouse click
* Try to switch from the Preview tab to the Edit tab with the shortcut key ⌘/Ctrl + Shift + P
* " Uncaught TypeError: Cannot read property 'find' of undefined" is outputed in the developer tools console.

If lastJstPreviewed is undefined, I think you should use jst.
<pre><code class="diff">
diff --git a/public/javascripts/jstoolbar/jstoolbar.js b/public/javascripts/jstoolbar/jstoolbar.js
index 64a7be754..7a3631a1a 100644
--- a/public/javascripts/jstoolbar/jstoolbar.js
+++ b/public/javascripts/jstoolbar/jstoolbar.js
@@ -519,8 +519,8 @@ $(document).keydown(function(e) {
jst.find('.tab-preview').click();
lastJstPreviewed = jst
} else {
- lastJstPreviewed.find('.tab-edit').click();
- lastJstPreviewed.find('textarea').focus();
+ (lastJstPreviewed || jst).find('.tab-edit').click();
+ (lastJstPreviewed || jst).find('textarea').focus();
lastJstPreviewed = null;
}
}

</code></pre>

----

I agree with changing the shortcut keys(r to ⌘/Ctrl + Shift + P).
--------------------------------------------------------------------------------
Thanks Mizuki for testing the patch and for reporting the issue found.

The patch was made only for testing purposes and to validate the new shortcut. Please find attached a new version of the patch which is ready from my point of view.

Keyboard shortcuts implemented:
* Ctrl + Shift + P
* Command + Shift + P

I've tested this on the following browsers and it works as expected:
* Chrome (osx)
* Safari (osx)
* Firefox (osx)
* Edge (windows)

Let's discuss this for version:"4.2.0".
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Just a small change to lowercase the key.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
I tried running a new patch. Looks good.

Tested environment:
* Chrome Beta (MacOS Big Sur)
* IE11 in Virtualbox Windows8

Structurally, I think it's good because it works only when there is a jstoolbar.
--------------------------------------------------------------------------------
Adding system tests for this feature.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the patch. Thank you for your contribution.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Tried this with Firefox 93.0 Linux, and ctrl-shift-p opens Firefox's private browsing. ctrl-shift-p does work fine in chrome.

Does anyone else have this issue?
--------------------------------------------------------------------------------
Jonathan Cormier wrote:
> Tried this with Firefox 93.0 Linux, and ctrl-shift-p opens Firefox's private browsing. ctrl-shift-p does work fine in chrome.
>
> Does anyone else have this issue?

Yes, I observe the issue as well (Firefox on Linux). Note however that you can also use Shift+Meta+P which with proper keyboard layout configuration "can be the same":https://superuser.com/questions/246345/how-can-i-make-my-super-keys-windows-key-behave-more-like-ctrl-alt-shift-in-li as Shift+Win+P.
--------------------------------------------------------------------------------


related_issues

relates,Closed,27758,Adds preview option to the wiki toolbar
relates,Closed,34444,Remove unused key :preview from Redmine::AccessKeys::ACCESSKEYS
blocks,Closed,34549,Add keyboard shortcuts for wiki toolbar buttons

Admin Redmine さんが3年以上前に更新

  • カテゴリUI_10 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0