-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display view query text (#1780)
- Loading branch information
Showing
10 changed files
with
494 additions
and
42 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,4 @@ | |
} | ||
} | ||
} | ||
|
||
&__popover-content { | ||
overflow: hidden; | ||
|
||
max-width: 600px; | ||
|
||
white-space: pre; | ||
} | ||
} |
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,28 @@ | ||
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'; | ||
|
||
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,168 @@ | ||
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', | ||
margin: 0, | ||
}, | ||
'code[class*="language-"]': { | ||
...lightTheme['code[class*="language-"]'], | ||
background: 'transparent', | ||
color: 'var(--g-color-text-primary)', | ||
whiteSpace: 'pre-wrap' as const, | ||
}, | ||
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', | ||
margin: 0, | ||
}, | ||
'code[class*="language-"]': { | ||
...darkTheme['code[class*="language-"]'], | ||
background: 'transparent', | ||
color: 'var(--g-color-text-primary)', | ||
whiteSpace: 'pre-wrap' as const, | ||
}, | ||
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
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