Fix: Support Ctrl+Shift keyboard shortcuts for text direction in RTL documents #2385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#2382
Fix: Support Ctrl+Shift keyboard shortcuts for text direction in RTL documents
Overview
This PR adds support for Windows standard keyboard shortcuts (Ctrl+Shift) to properly switch text direction in Slidev's integrated editor when working with RTL documents.
Problem
When editing RTL presentations (e.g., Hebrew with
htmlAttrs: { dir: rtl }), pressing Ctrl+Left Shift or Ctrl+Right Shift would cause the browser to internally switch text direction, but the visual rendering would break because thedirattribute wasn't being synchronized on the textarea element.This made it difficult to edit mixed-direction content (e.g., inserting English code or formulas in an RTL Hebrew presentation).
Solution
Added a new
useTextDirectioncomposable that:KeyboardEvent.locationdirattribute on the textarea elementwatchto ensure the event listener is attached when the element becomes availableChanges
New File
packages/client/composables/useTextDirection.ts- Composable for handling direction switchingModified Files
packages/client/internals/NoteEditable.vue- Applied composable to notes editorpackages/client/internals/ShikiEditor.vue- Applied composable to Shiki code editorTesting
Tested manually in presenter mode with an RTL document:
htmlAttrs: { dir: rtl, lang: he }in slides.mddir="rtl"✓dir="ltr"✓Text direction switches properly with correct visual rendering and caret positioning.
Related Issues
Fixes the issue where Ctrl+Shift shortcuts don't work properly in RTL documents as described in the original bug report.