-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: display view query text #1780
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
14ca9f9
feat: display view query text
astandrik 9fbcecf
fix: import keywords
astandrik b5e9b90
fix: rename
astandrik eb089ce
fix: remove important
astandrik b5c1aee
fix: inline styles instead of scss
astandrik f628c9e
fix: remove cell with popopver
astandrik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,11 @@ | ||
.yql-highlighter { | ||
code { | ||
white-space: pre-wrap !important; | ||
} | ||
|
||
pre { | ||
margin: 0 !important; | ||
|
||
background: transparent !important; | ||
} | ||
} |
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,30 @@ | ||
import {useThemeValue} from '@gravity-ui/uikit'; | ||
import {PrismLight as SyntaxHighlighter} from 'react-syntax-highlighter'; | ||
|
||
import {cn} from '../../utils/cn'; | ||
|
||
import {dark, light, yql} from './yql'; | ||
|
||
import './YqlHighlighter.scss'; | ||
|
||
SyntaxHighlighter.registerLanguage('yql', yql); | ||
|
||
const b = cn('yql-highlighter'); | ||
|
||
interface YqlHighlighterProps { | ||
children: string; | ||
className?: string; | ||
} | ||
|
||
export const YqlHighlighter = ({children, className}: YqlHighlighterProps) => { | ||
const themeValue = useThemeValue(); | ||
const isDark = themeValue === 'dark' || themeValue === 'dark-hc'; | ||
|
||
return ( | ||
<div className={b(null, className)}> | ||
<SyntaxHighlighter language="yql" style={isDark ? dark : light}> | ||
{children} | ||
</SyntaxHighlighter> | ||
</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 |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { | ||
builtinFunctions, | ||
keywords, | ||
typeKeywords, | ||
} from 'monaco-yql-languages/build/yql/yql.keywords'; | ||
import { | ||
vscDarkPlus as darkTheme, | ||
materialLight as lightTheme, | ||
} from 'react-syntax-highlighter/dist/esm/styles/prism'; | ||
|
||
export const light = { | ||
...lightTheme, | ||
'pre[class*="language-"]': { | ||
...lightTheme['pre[class*="language-"]'], | ||
background: 'transparent', | ||
}, | ||
'code[class*="language-"]': { | ||
...lightTheme['code[class*="language-"]'], | ||
background: 'transparent', | ||
color: 'var(--g-color-text-primary)', | ||
}, | ||
comment: { | ||
color: '#969896', | ||
}, | ||
string: { | ||
color: '#a31515', | ||
}, | ||
tablepath: { | ||
color: '#338186', | ||
}, | ||
function: { | ||
color: '#7a3e9d', | ||
}, | ||
udf: { | ||
color: '#7a3e9d', | ||
}, | ||
type: { | ||
color: '#4d932d', | ||
}, | ||
boolean: { | ||
color: '#608b4e', | ||
}, | ||
constant: { | ||
color: '#608b4e', | ||
}, | ||
variable: { | ||
color: '#001188', | ||
}, | ||
}; | ||
|
||
export const dark = { | ||
...darkTheme, | ||
'pre[class*="language-"]': { | ||
...darkTheme['pre[class*="language-"]'], | ||
background: 'transparent', | ||
}, | ||
'code[class*="language-"]': { | ||
...darkTheme['code[class*="language-"]'], | ||
background: 'transparent', | ||
color: 'var(--g-color-text-primary)', | ||
}, | ||
comment: { | ||
color: '#969896', | ||
}, | ||
string: { | ||
color: '#ce9178', | ||
}, | ||
tablepath: { | ||
color: '#338186', | ||
}, | ||
function: { | ||
color: '#9e7bb0', | ||
}, | ||
udf: { | ||
color: '#9e7bb0', | ||
}, | ||
type: { | ||
color: '#6A8759', | ||
}, | ||
boolean: { | ||
color: '#608b4e', | ||
}, | ||
constant: { | ||
color: '#608b4e', | ||
}, | ||
variable: { | ||
color: '#74b0df', | ||
}, | ||
}; | ||
|
||
export function yql(Prism: any) { | ||
// Define YQL language | ||
Prism.languages.yql = { | ||
comment: [ | ||
{ | ||
pattern: /--.*$/m, | ||
greedy: true, | ||
}, | ||
{ | ||
pattern: /\/\*[\s\S]*?(?:\*\/|$)/, | ||
greedy: true, | ||
}, | ||
], | ||
tablepath: { | ||
pattern: /(`[\w/]+`\s*\.\s*)?`[^`]+`/, | ||
greedy: true, | ||
}, | ||
string: [ | ||
{ | ||
pattern: /'(?:\\[\s\S]|[^\\'])*'/, | ||
greedy: true, | ||
}, | ||
{ | ||
pattern: /"(?:\\[\s\S]|[^\\"])*"/, | ||
greedy: true, | ||
}, | ||
{ | ||
pattern: /@@(?:[^@]|@(?!@))*@@/, | ||
greedy: true, | ||
}, | ||
], | ||
variable: [ | ||
{ | ||
pattern: /\$[a-zA-Z_]\w*/, | ||
greedy: true, | ||
}, | ||
], | ||
function: { | ||
pattern: new RegExp(`\\b(?:${builtinFunctions.join('|')})\\b`, 'i'), | ||
greedy: true, | ||
}, | ||
keyword: { | ||
pattern: new RegExp(`\\b(?:${keywords.join('|')})\\b`, 'i'), | ||
greedy: true, | ||
}, | ||
udf: { | ||
pattern: /[A-Za-z_]\w*::[A-Za-z_]\w*/, | ||
greedy: true, | ||
}, | ||
type: { | ||
pattern: new RegExp(`\\b(?:${typeKeywords.join('|')})\\b`, 'i'), | ||
greedy: true, | ||
}, | ||
boolean: { | ||
pattern: /\b(?:true|false|null)\b/i, | ||
greedy: true, | ||
}, | ||
number: { | ||
pattern: /[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i, | ||
greedy: true, | ||
}, | ||
operator: { | ||
pattern: /[-+*/%<>!=&|^~]+|\b(?:and|or|not|is|like|ilike|rlike|in|between)\b/i, | ||
greedy: true, | ||
}, | ||
punctuation: { | ||
pattern: /[;[\](){}.,]/, | ||
greedy: true, | ||
}, | ||
}; | ||
} | ||
|
||
yql.displayName = 'yql'; | ||
yql.aliases = ['yql'] as string[]; |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a popover here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed popover
redeployed stand