-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade codemirror 5 to codemirror 6 (#1510)
* feat: upgrade codemirror 5 to codemirror 6 * fix linter * upgrade typescript to fix lint errors and address comments * hide the accept button when readonly * update yarn.lock * update tsconfig
- Loading branch information
Showing
33 changed files
with
1,738 additions
and
1,708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
querybook/webapp/components/CodeMirrorTooltip/LintTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useCallback, useMemo } from 'react'; | ||
|
||
import { Button } from 'ui/Button/Button'; | ||
|
||
interface IProps { | ||
message: string; | ||
suggestion?: string; | ||
readonly?: boolean; | ||
onAcceptSuggestion?: (suggestion: string) => void; | ||
} | ||
|
||
const SUGGESTION_MAX_LENGTH = 40; | ||
|
||
export const LintTooltip: React.FunctionComponent<IProps> = ({ | ||
message, | ||
suggestion, | ||
readonly = false, | ||
onAcceptSuggestion, | ||
}) => { | ||
const truncatedSuggestion = useMemo( | ||
() => | ||
suggestion && suggestion.length > SUGGESTION_MAX_LENGTH | ||
? suggestion.slice(0, SUGGESTION_MAX_LENGTH - 3) + '...' | ||
: suggestion, | ||
[suggestion] | ||
); | ||
|
||
const onClick = useCallback(() => { | ||
onAcceptSuggestion(suggestion); | ||
}, [onAcceptSuggestion, suggestion]); | ||
|
||
return ( | ||
<div className="rich-text-content"> | ||
<div>{message}</div> | ||
{truncatedSuggestion && ( | ||
<div className="mt8"> | ||
<div> | ||
Replace with <code>{truncatedSuggestion}</code> | ||
</div> | ||
{!readonly && onAcceptSuggestion && ( | ||
<div className="mt8 right-align"> | ||
<Button | ||
title="Accept" | ||
onClick={onClick} | ||
theme="fill" | ||
color="confirm" | ||
icon="Check" | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
margin: 0; | ||
overflow: hidden; | ||
display: flex; | ||
|
||
.QueryEditor { | ||
flex: 1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.