Feature #30459
closedSwitch edit/preview tabs with keyboard shortcuts
0%
Description
RedmineKeyboardNavigation:
Key | Description |
r | Updates the preview in editor mode |
I want to switch Edit/Preview tabs with keybord shortcuts.
Github:
Files
Related issues
Updated by Bernhard Rohloff almost 6 years ago
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.
Updated by Marius BĂLTEANU almost 6 years ago
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.
Updated by Mizuki ISHIKAWA almost 6 years ago
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.
Updated by Marius BĂLTEANU over 5 years ago
- Related to Feature #27758: Adds preview option to the wiki toolbar added
Updated by Marius BĂLTEANU about 5 years ago
Which should be the keyboard shortcuts here?
Updated by Robert Schneider about 4 years ago
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?
Updated by Marius BĂLTEANU almost 4 years ago
- Tracker changed from Defect to Feature
Updated by Go MAEDA almost 4 years ago
- Related to Patch #34444: Remove unused key :preview from Redmine::AccessKeys::ACCESSKEYS added
Updated by Marius BĂLTEANU almost 4 years ago
- File switch_edit_preview_tabs_using_keyboard_shortcuts.patch switch_edit_preview_tabs_using_keyboard_shortcuts.patch added
- Assignee deleted (
Marius BĂLTEANU)
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.
Updated by Mizuki ISHIKAWA almost 4 years ago
- File switch_edit_preview_tabs_using_keyboard_shortcuts-v2.patch switch_edit_preview_tabs_using_keyboard_shortcuts-v2.patch added
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.
- 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.
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;
}
}
I agree with changing the shortcut keys(r to ⌘/Ctrl + Shift + P).
Updated by Marius BĂLTEANU almost 4 years ago
- File 0001-Add-keyboard-shortcut-to-toggle-between-Edit-Preview.patch added
- Assignee deleted (
Marius BĂLTEANU) - Target version set to 4.2.0
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
- Chrome (osx)
- Safari (osx)
- Firefox (osx)
- Edge (windows)
Let's discuss this for 4.2.0.
Updated by Marius BĂLTEANU almost 4 years ago
- File deleted (
0001-Add-keyboard-shortcut-to-toggle-between-Edit-Preview.patch)
Updated by Marius BĂLTEANU almost 4 years ago
- File 0001-Add-keyboard-shortcut-to-toggle-between-Edit-Preview.patch added
Just a small change to lowercase the key.
Updated by Marius BĂLTEANU almost 4 years ago
- File deleted (
0001-Add-keyboard-shortcut-to-toggle-between-Edit-Preview.patch)
Updated by Mizuki ISHIKAWA almost 4 years ago
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.
Updated by Marius BĂLTEANU almost 4 years ago
Adding system tests for this feature.
Updated by Marius BĂLTEANU almost 4 years ago
- Blocks Feature #34549: Add keyboard shortcuts for wiki toolbar buttons added
Updated by Go MAEDA almost 4 years ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you for your contribution.
Updated by Go MAEDA almost 4 years ago
- Subject changed from Switch edit/preview tabs with keybord shortcuts to Switch edit/preview tabs with keyboard shortcuts
Updated by Jonathan Cormier about 3 years ago
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?
Updated by Marcin Szewczyk about 3 years ago
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 as Shift+Win+P.