Skip to content

Commit

Permalink
only attach key and pointer events to javascript languages
Browse files Browse the repository at this point in the history
  • Loading branch information
souporserious committed Oct 6, 2023
1 parent 0afc577 commit db0002c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mdxts/components/client/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ export function Editor({
}
}

const isJavaScriptBasedLanguage = [
'javascript',
'jsx',
'typescript',
'tsx',
].some((languageToCompare) => languageToCompare === language)

const sharedStyle = {
gridArea: '1 / 1',
whiteSpace: 'pre-wrap',
Expand Down Expand Up @@ -368,13 +375,15 @@ export function Editor({
</div>
<textarea
ref={textareaRef}
onPointerMove={handlePointerMove}
onPointerMove={
isJavaScriptBasedLanguage ? handlePointerMove : undefined
}
onPointerLeave={() => {
setHoverInfo(null)
setHoverPosition(null)
}}
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
onKeyUp={isJavaScriptBasedLanguage ? handleKeyUp : undefined}
onBlur={() => setIsDropdownOpen(false)}
onChange={
defaultValue
Expand Down

1 comment on commit db0002c

@vercel
Copy link

@vercel vercel bot commented on db0002c Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.