Skip to content

Commit 41d709d

Browse files
committed
Add syntax highlighting
1 parent f01679e commit 41d709d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/JsonPathQueryField.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import { QueryField } from '@grafana/ui';
3+
import { QueryField, SlatePrism, BracesPlugin } from '@grafana/ui';
44

55
interface Props {
66
query: string;
@@ -12,9 +12,18 @@ interface Props {
1212
* JsonPathQueryField is an editor for JSON Path.
1313
*/
1414
export const JsonPathQueryField: React.FC<Props> = ({ query, onBlur, onChange }) => {
15+
const plugins = [
16+
BracesPlugin(),
17+
SlatePrism({
18+
onlyIn: (node: any) => node.type === 'code_block',
19+
getSyntax: (node: any) => 'js',
20+
}),
21+
];
22+
1523
return (
1624
<div style={{ marginRight: '4px', width: '100%' }}>
1725
<QueryField
26+
additionalPlugins={plugins}
1827
query={query}
1928
onBlur={onBlur}
2029
onChange={onChange}

0 commit comments

Comments
 (0)