Skip to content

Commit

Permalink
chore: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Dec 27, 2023
1 parent c98f60a commit 821d5ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/composables/useKeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export default function useKeyboardShortcuts(
if (e.key && e.key === 'Tab') {
getTextSelection()

// Require an active text selection to bind a tab or shift+tab
// This configuration passes the ["no keyboard trap"](https://www.w3.org/TR/WCAG21/#no-keyboard-trap) criterion of the W3C Web Content Accessibility Guidelines
if (selectedText.text) {
e.preventDefault()
if (e.shiftKey) {
Expand Down
2 changes: 2 additions & 0 deletions src/composables/useMarkdownActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default function useMarkdownActions(
// Always focus back on the textarea
await focusTextarea()

// Set the cursor position
textarea.selectionEnd = selectedText.start - wrapperLength

return
Expand Down Expand Up @@ -233,6 +234,7 @@ export default function useMarkdownActions(
return
}

// If some text is selected
if (selectedText.text.length !== 0) {
// Count number of line breaks in selection. Only include a single `\n` or the last of `\n\n`
lineBreakCount = (selectedText.text.match(/\n(?!\n)/g) || []).length
Expand Down

0 comments on commit 821d5ea

Please sign in to comment.