@sanity/code-input 3.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +140 -64
- package/lib/_chunks/CodeMirrorProxy-3836f097.js +619 -0
- package/lib/_chunks/CodeMirrorProxy-3836f097.js.map +1 -0
- package/lib/_chunks/CodeMirrorProxy-e83d4d37.js +611 -0
- package/lib/_chunks/CodeMirrorProxy-e83d4d37.js.map +1 -0
- package/lib/_chunks/index-17e68aff.js +563 -0
- package/lib/_chunks/index-17e68aff.js.map +1 -0
- package/lib/_chunks/index-9a4cb814.js +549 -0
- package/lib/_chunks/index-9a4cb814.js.map +1 -0
- package/lib/{src/index.d.ts → index.d.ts} +18 -10
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +10 -1
- package/lib/index.js.map +1 -1
- package/package.json +53 -27
- package/src/CodeInput.tsx +72 -272
- package/src/LanguageField.tsx +33 -0
- package/src/LanguageInput.tsx +32 -0
- package/src/PreviewCode.tsx +40 -68
- package/src/__workshop__/index.ts +22 -0
- package/src/__workshop__/lazy.tsx +54 -0
- package/src/__workshop__/preview.tsx +24 -0
- package/src/__workshop__/props.tsx +24 -0
- package/src/codemirror/CodeMirrorProxy.tsx +157 -0
- package/src/codemirror/CodeModeContext.tsx +4 -0
- package/src/codemirror/defaultCodeModes.ts +109 -0
- package/src/codemirror/extensions/highlightLineExtension.ts +164 -0
- package/src/codemirror/extensions/theme.ts +61 -0
- package/src/codemirror/extensions/useCodeMirrorTheme.ts +63 -0
- package/src/codemirror/extensions/useFontSize.ts +24 -0
- package/src/codemirror/useCodeMirror-client.test.tsx +49 -0
- package/src/{ace-editor/AceEditor-server.test.tsx → codemirror/useCodeMirror-server.test.tsx} +3 -4
- package/src/codemirror/useCodeMirror.tsx +12 -0
- package/src/codemirror/useLanguageMode.tsx +52 -0
- package/src/config.ts +1 -13
- package/src/getMedia.tsx +0 -2
- package/src/index.ts +4 -11
- package/src/plugin.tsx +39 -0
- package/src/schema.tsx +3 -7
- package/src/types.ts +19 -3
- package/src/ui/focusRingStyle.ts +27 -0
- package/src/useFieldMember.ts +16 -0
- package/lib/_chunks/editorSupport-895caf32.esm.js +0 -2
- package/lib/_chunks/editorSupport-895caf32.esm.js.map +0 -1
- package/lib/_chunks/editorSupport-bda3d360.js +0 -2
- package/lib/_chunks/editorSupport-bda3d360.js.map +0 -1
- package/src/ace-editor/AceEditor-client.test.tsx +0 -37
- package/src/ace-editor/AceEditorLazy.tsx +0 -19
- package/src/ace-editor/editorSupport.ts +0 -34
- package/src/ace-editor/groq.ts +0 -630
- package/src/createHighlightMarkers.ts +0 -24
package/src/{ace-editor/AceEditor-server.test.tsx → codemirror/useCodeMirror-server.test.tsx}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import {renderToString} from 'react-dom/server'
|
|
3
|
-
import {
|
|
2
|
+
import {useCodeMirror} from './useCodeMirror'
|
|
4
3
|
|
|
5
|
-
describe('
|
|
4
|
+
describe('useCodeMirror - server', () => {
|
|
6
5
|
it('should render null to string (and not throw and Error)', () => {
|
|
7
6
|
const TestComponent = () => {
|
|
8
|
-
const Editor =
|
|
7
|
+
const Editor = useCodeMirror()
|
|
9
8
|
if (!Editor) {
|
|
10
9
|
return null
|
|
11
10
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {lazy, useEffect, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
export const CodeMirrorProxy = lazy(() => import('./CodeMirrorProxy'))
|
|
4
|
+
|
|
5
|
+
export function useCodeMirror() {
|
|
6
|
+
const [mounted, setMounted] = useState(false)
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
requestAnimationFrame(() => setMounted(true))
|
|
9
|
+
}, [])
|
|
10
|
+
|
|
11
|
+
return mounted ? CodeMirrorProxy : null
|
|
12
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {LANGUAGE_ALIASES, SUPPORTED_LANGUAGES} from '../config'
|
|
2
|
+
import {CodeInputLanguage, CodeInputValue, CodeSchemaType} from '../types'
|
|
3
|
+
import {useMemo} from 'react'
|
|
4
|
+
|
|
5
|
+
export const defaultLanguageMode = 'text'
|
|
6
|
+
|
|
7
|
+
export function useLanguageMode(schemaType: CodeSchemaType, value?: CodeInputValue) {
|
|
8
|
+
const languages = useLanguageAlternatives(schemaType)
|
|
9
|
+
const fixedLanguage = schemaType.options?.language
|
|
10
|
+
const language = value?.language ?? fixedLanguage ?? defaultLanguageMode
|
|
11
|
+
|
|
12
|
+
// the language config from the schema
|
|
13
|
+
const configured = languages.find((entry) => entry.value === language)
|
|
14
|
+
const languageMode = configured?.mode ?? resolveAliasedLanguage(language) ?? defaultLanguageMode
|
|
15
|
+
|
|
16
|
+
return {language, languageMode, languages}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function resolveAliasedLanguage(lang?: string) {
|
|
20
|
+
return (lang && LANGUAGE_ALIASES[lang]) ?? lang
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function useLanguageAlternatives(type: CodeSchemaType) {
|
|
24
|
+
return useMemo((): CodeInputLanguage[] => {
|
|
25
|
+
const languageAlternatives = type.options?.languageAlternatives
|
|
26
|
+
if (!languageAlternatives) {
|
|
27
|
+
return SUPPORTED_LANGUAGES
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!Array.isArray(languageAlternatives)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`'options.languageAlternatives' should be an array, got ${typeof languageAlternatives}`
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return languageAlternatives.reduce((acc: CodeInputLanguage[], {title, value: val, mode}) => {
|
|
37
|
+
const alias = LANGUAGE_ALIASES[val]
|
|
38
|
+
if (alias) {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.warn(
|
|
41
|
+
`'options.languageAlternatives' lists a language with value "%s", which is an alias of "%s" - please replace the value to read "%s"`,
|
|
42
|
+
val,
|
|
43
|
+
alias,
|
|
44
|
+
alias
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return acc.concat({title, value: alias, mode: mode})
|
|
48
|
+
}
|
|
49
|
+
return acc.concat({title, value: val, mode})
|
|
50
|
+
}, [])
|
|
51
|
+
}, [type])
|
|
52
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {CodeInputLanguage} from './types'
|
|
2
2
|
|
|
3
|
-
// NOTE: MAKE SURE THESE ALIGN WITH
|
|
3
|
+
// NOTE: MAKE SURE THESE ALIGN WITH CODE MODES IN ./codemirror/defaultCodeModes.ts
|
|
4
4
|
export const SUPPORTED_LANGUAGES: CodeInputLanguage[] = [
|
|
5
5
|
{title: 'Batch file', value: 'batchfile'},
|
|
6
6
|
{title: 'C#', value: 'csharp'},
|
|
@@ -29,18 +29,6 @@ export const SUPPORTED_LANGUAGES: CodeInputLanguage[] = [
|
|
|
29
29
|
|
|
30
30
|
export const LANGUAGE_ALIASES: Record<string, string | undefined> = {js: 'javascript'}
|
|
31
31
|
|
|
32
|
-
export const SUPPORTED_THEMES = ['github', 'monokai', 'terminal', 'tomorrow']
|
|
33
|
-
|
|
34
|
-
export const DEFAULT_THEME = 'tomorrow'
|
|
35
|
-
export const DEFAULT_DARK_THEME = 'monokai'
|
|
36
|
-
|
|
37
|
-
export const ACE_SET_OPTIONS = {
|
|
38
|
-
useSoftTabs: true,
|
|
39
|
-
navigateWithinSoftTabs: true /* note only supported by ace v1.2.7 or higher */,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const ACE_EDITOR_PROPS = {$blockScrolling: true}
|
|
43
|
-
|
|
44
32
|
export const PATH_LANGUAGE = ['language']
|
|
45
33
|
export const PATH_CODE = ['code']
|
|
46
34
|
export const PATH_FILENAME = ['filename']
|
package/src/getMedia.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {definePlugin} from 'sanity'
|
|
2
|
-
|
|
3
1
|
import {codeSchema, codeTypeName, CodeDefinition} from './schema'
|
|
4
2
|
import PreviewCode, {PreviewCodeProps} from './PreviewCode'
|
|
5
|
-
export type
|
|
3
|
+
export {type CodeInputProps, type CodeInput} from './CodeInput'
|
|
6
4
|
|
|
7
|
-
export type {CodeInputLanguage, CodeInputValue} from './types'
|
|
5
|
+
export type {CodeInputLanguage, CodeInputValue, CodeSchemaType, CodeOptions} from './types'
|
|
8
6
|
|
|
9
7
|
export {PreviewCode, type PreviewCodeProps}
|
|
10
8
|
export {codeSchema, codeTypeName}
|
|
11
9
|
export type {CodeDefinition}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
export const codeInput = definePlugin({
|
|
16
|
-
name: '@sanity/code-input',
|
|
17
|
-
schema: {types: [codeSchema]},
|
|
18
|
-
})
|
|
10
|
+
|
|
11
|
+
export {codeInput} from './plugin'
|
package/src/plugin.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {definePlugin} from 'sanity'
|
|
2
|
+
import {codeSchema} from './schema'
|
|
3
|
+
import {CodeMode} from './codemirror/defaultCodeModes'
|
|
4
|
+
import {CodeInputConfigContext} from './codemirror/CodeModeContext'
|
|
5
|
+
|
|
6
|
+
export interface CodeInputConfig {
|
|
7
|
+
codeModes?: CodeMode[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const codeInput = definePlugin<CodeInputConfig | void>((config) => {
|
|
14
|
+
const codeModes = config && config.codeModes
|
|
15
|
+
const basePlugin = {
|
|
16
|
+
name: '@sanity/code-input',
|
|
17
|
+
schema: {types: [codeSchema]},
|
|
18
|
+
}
|
|
19
|
+
if (!codeModes) {
|
|
20
|
+
return basePlugin
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
...basePlugin,
|
|
24
|
+
form: {
|
|
25
|
+
components: {
|
|
26
|
+
input: (props) => {
|
|
27
|
+
if (props.id !== 'root') {
|
|
28
|
+
return props.renderDefault(props)
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<CodeInputConfigContext.Provider value={config}>
|
|
32
|
+
{props.renderDefault(props)}
|
|
33
|
+
</CodeInputConfigContext.Provider>
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
})
|
package/src/schema.tsx
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import {CodeBlockIcon} from '@sanity/icons'
|
|
2
|
-
import {CodeInput
|
|
3
|
-
import PreviewCode
|
|
2
|
+
import {CodeInput} from './CodeInput'
|
|
3
|
+
import PreviewCode from './PreviewCode'
|
|
4
4
|
import {getMedia} from './getMedia'
|
|
5
5
|
import {defineType, ObjectDefinition} from 'sanity'
|
|
6
|
-
|
|
7
|
-
export type {CodeInputProps, CodeSchemaType} from './CodeInput'
|
|
8
|
-
|
|
9
|
-
export type {CodeInputLanguage, CodeInputValue} from './types'
|
|
10
|
-
export type {PreviewCode, PreviewCodeProps, CodeInput}
|
|
6
|
+
import {CodeOptions} from './types'
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* @public
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import {ObjectSchemaType} from 'sanity'
|
|
2
|
+
|
|
4
3
|
export interface CodeInputLanguage {
|
|
5
4
|
title: string
|
|
6
5
|
value: string
|
|
@@ -17,3 +16,20 @@ export interface CodeInputValue {
|
|
|
17
16
|
language?: string
|
|
18
17
|
highlightedLines?: number[]
|
|
19
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface CodeOptions {
|
|
23
|
+
theme?: string
|
|
24
|
+
darkTheme?: string
|
|
25
|
+
languageAlternatives?: CodeInputLanguage[]
|
|
26
|
+
language?: string
|
|
27
|
+
withFilename?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export interface CodeSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
34
|
+
options?: CodeOptions
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
// todo: import from @sanity/ui instead
|
|
3
|
+
export function focusRingBorderStyle(border: {color: string; width: number}): string {
|
|
4
|
+
return `inset 0 0 0 ${border.width}px ${border.color}`
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
// todo: import from @sanity/ui instead
|
|
9
|
+
export function focusRingStyle(opts: {
|
|
10
|
+
base?: {bg: string}
|
|
11
|
+
border?: {color: string; width: number}
|
|
12
|
+
focusRing: {offset: number; width: number}
|
|
13
|
+
}): string {
|
|
14
|
+
const {base, border, focusRing} = opts
|
|
15
|
+
const focusRingOutsetWidth = focusRing.offset + focusRing.width
|
|
16
|
+
const focusRingInsetWidth = 0 - focusRing.offset
|
|
17
|
+
const bgColor = base ? base.bg : 'var(--card-bg-color)'
|
|
18
|
+
|
|
19
|
+
return [
|
|
20
|
+
focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
|
|
21
|
+
border && focusRingBorderStyle(border),
|
|
22
|
+
focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
|
|
23
|
+
focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`,
|
|
24
|
+
]
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.join(',')
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {useMemo} from 'react'
|
|
2
|
+
import {FieldMember, ObjectMember} from 'sanity'
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export function useFieldMember(
|
|
6
|
+
members: ObjectMember[],
|
|
7
|
+
fieldName: string
|
|
8
|
+
): FieldMember | undefined {
|
|
9
|
+
return useMemo(
|
|
10
|
+
() =>
|
|
11
|
+
members.find(
|
|
12
|
+
(member): member is FieldMember => member.kind === 'field' && member.name === fieldName
|
|
13
|
+
),
|
|
14
|
+
[members, fieldName]
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e from"react-ace";export{default}from"react-ace";import"ace-builds/src-noconflict/mode-batchfile";import"ace-builds/src-noconflict/mode-csharp";import"ace-builds/src-noconflict/mode-css";import"ace-builds/src-noconflict/mode-golang";import"ace-builds/src-noconflict/mode-html";import"ace-builds/src-noconflict/mode-java";import"ace-builds/src-noconflict/mode-javascript";import"ace-builds/src-noconflict/mode-json";import"ace-builds/src-noconflict/mode-jsx";import"ace-builds/src-noconflict/mode-markdown";import"ace-builds/src-noconflict/mode-mysql";import"ace-builds/src-noconflict/mode-php";import"ace-builds/src-noconflict/mode-python";import"ace-builds/src-noconflict/mode-ruby";import"ace-builds/src-noconflict/mode-sass";import"ace-builds/src-noconflict/mode-scss";import"ace-builds/src-noconflict/mode-sh";import"ace-builds/src-noconflict/mode-text";import"ace-builds/src-noconflict/mode-tsx";import"ace-builds/src-noconflict/mode-typescript";import"ace-builds/src-noconflict/mode-xml";import"ace-builds/src-noconflict/mode-yaml";import"ace-builds/src-noconflict/theme-github";import"ace-builds/src-noconflict/theme-monokai";import"ace-builds/src-noconflict/theme-terminal";import"ace-builds/src-noconflict/theme-tomorrow";const o={start:[{include:"#query"},{include:"#value"},{include:"#pair"}],"#query":[{include:"#nullary-access-operator"},{include:"#arraylike"},{include:"#pipe"},{include:"#sort-order"},{include:"#filter"}],"#variable":[{token:"variable.other.groq",regex:/\$[_A-Za-z][_0-9A-Za-z]*/}],"#keyword":[{token:"keyword.other.groq",regex:/\b(?:asc|desc|in|match)\b/}],"#comparison":[{token:"keyword.operator.comparison.groq",regex:/==|!=|>=|<=|<!=>|<|>/}],"#operator":[{token:"keyword.operator.arithmetic.groq",regex:/\+|-|\*{1,2}|\/|%/}],"#pipe":[{token:"keyword.operator.pipe.groq",regex:/\|/}],"#logical":[{token:"keyword.operator.logical.groq",regex:/!|&&|\|\|/}],"#reference":[{token:"keyword.operator.reference.groq",regex:/->/}],"#pair":[{include:"#identifier"},{include:"#value"},{include:"#filter"},{token:"keyword.operator.pair.groq",regex:/[=]>/}],"#arraylike":[{token:"punctuation.definition.bracket.begin.groq",regex:/\[/,push:[{token:["text","keyword.operator.descendant.groq"],regex:/(\])((?:\s*\.)?)/,next:"pop"},{include:"#range"},{include:"#filter"},{include:"#array-values"}]}],"#array":[{token:"punctuation.definition.bracket.begin.groq",regex:/\[/,push:[{token:"punctuation.definition.bracket.end.groq",regex:/\]/,next:"pop"},{include:"#array-values"},{defaultToken:"meta.structure.array.groq"}]}],"#range":[{token:["meta.structure.range.groq","constant.numeric.groq","meta.structure.range.groq","keyword.operator.range.groq","meta.structure.range.groq","constant.numeric.groq","meta.structure.range.groq"],regex:/(\s*)(\d+)(\s*)(\.{2,3})(\s*)(\d+)(\s*)/}],"#spread":[{token:"punctuation.definition.spread.begin.groq",regex:/\.\.\./,push:[{include:"#array"},{include:"#function-call"},{include:"#projection"},{token:"punctuation.definition.spread.end.groq",regex:/(?=.)/,next:"pop"},{defaultToken:"meta.structure.spread.groq"}]}],"#array-values":[{include:"#value"},{include:"#spread"},{token:"punctuation.separator.array.groq",regex:/,/},{token:"invalid.illegal.expected-array-separator.groq",regex:/[^\s\]]/}],"#filter":[{include:"#function-call"},{include:"#keyword"},{include:"#constant"},{include:"#identifier"},{include:"#value"},{include:"#comparison"},{include:"#operator"},{include:"#logical"}],"#comments":[{token:["punctuation.definition.comment.groq","comment.line.double-slash.js"],regex:/(\/\/)(.*$)/}],"#nullary-access-operator":[{token:"constant.language.groq",regex:/[*@^]/}],"#constant":[{token:"constant.language.groq",regex:/\b(?:true|false|null)\b/}],"#number":[{token:"constant.numeric.groq",regex:/-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/}],"#named-projection":[{include:"#identifier"},{include:"#objectkey"},{include:"#projection"}],"#projection":[{token:"punctuation.definition.projection.begin.groq",regex:/\{/,push:[{token:"punctuation.definition.projection.end.groq",regex:/\}/,next:"pop"},{include:"#identifier"},{include:"#objectkey"},{include:"#named-projection"},{include:"#comments"},{include:"#spread"},{include:"#pair"},{token:"punctuation.separator.projection.key-value.groq",regex:/:/,push:[{token:"punctuation.separator.projection.pair.groq",regex:/,|(?=\})/,next:"pop"},{include:"#nullary-access-operator"},{include:"#arraylike"},{include:"#value"},{include:"#spread"},{include:"#identifier"},{include:"#operator"},{include:"#comparison"},{include:"#pair"},{token:"invalid.illegal.expected-projection-separator.groq",regex:/[^\s,]/},{defaultToken:"meta.structure.projection.value.groq"}]},{token:"invalid.illegal.expected-projection-separator.groq",regex:/[^\s},]/},{defaultToken:"meta.structure.projection.groq"}]}],"#string":[{include:"#single-string"},{include:"#double-string"}],"#double-string":[{token:"punctuation.definition.string.begin.groq",regex:/"/,push:[{token:"punctuation.definition.string.end.groq",regex:/"/,next:"pop"},{include:"#stringcontent"},{defaultToken:"string.quoted.double.groq"}]}],"#single-string":[{token:"punctuation.definition.string.single.begin.groq",regex:/'/,push:[{token:"punctuation.definition.string.single.end.groq",regex:/'/,next:"pop"},{include:"#stringcontent"},{defaultToken:"string.quoted.single.groq"}]}],"#objectkey":[{include:"#string"}],"#stringcontent":[{token:"constant.character.escape.groq",regex:/\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})/},{token:"invalid.illegal.unrecognized-string-escape.groq",regex:/\\./}],"#sort-pair":[{token:["variable.other.readwrite.groq","text","keyword.other.groq"],regex:/([_A-Za-z][_0-9A-Za-z]*)(?:(\s*)(asc|desc))?/},{token:["constant.language.groq","punctuation.definition.bracket.begin.groq"],regex:/(@)(\[)/,push:[{token:["punctuation.definition.bracket.begin.groq","text","keyword.other.groq"],regex:/(\])(?:(\s*)(asc|desc))?/,next:"pop"},{include:"#string"}]}],"#sort-order":[{token:"support.function.sortorder.begin.groq",regex:/\border\s*\(/,push:[{token:"support.function.sortorder.end.groq",regex:/\)/,next:"pop"},{include:"#sort-pair"},{token:"punctuation.separator.array.groq",regex:/,/},{token:"invalid.illegal.expected-sort-separator.groq",regex:/[^\s\]]/},{defaultToken:"support.function.sortorder.groq"}]}],"#function-call":[{include:"#function-var-arg"},{include:"#function-single-arg"},{include:"#function-round"}],"#function-var-arg":[{token:"support.function.vararg.begin.groq",regex:/\b(?:coalesce|select)\s*\(/,push:[{token:"support.function.vararg.end.groq",regex:/\)/,next:"pop"},{include:"#value"},{include:"#identifier"},{include:"#filter"},{include:"#pair"},{token:"punctuation.separator.array.groq",regex:/,/},{defaultToken:"support.function.vararg.groq"}]}],"#function-single-arg":[{token:"support.function.singlearg.begin.groq",regex:/\b(?:count|defined|length|path|references)\s*\(/,push:[{token:"support.function.singlearg.end.groq",regex:/\)/,next:"pop"},{include:"#query"},{include:"#identifier"},{include:"#value"},{include:"#pair"},{defaultToken:"support.function.singlearg.groq"}]}],"#identifier":[{token:["variable.other.readwrite.groq","text","punctuation.definition.block.js","text","keyword.operator.reference.groq"],regex:/([_A-Za-z][_0-9A-Za-z]*)(\s*)((?:\[\s*\])?)(\s*)(->)/},{token:["variable.other.readwrite.groq","constant.language.groq","text","punctuation.definition.block.js","text","keyword.operator.descendant.groq"],regex:/(?:([_A-Za-z][_0-9A-Za-z]*)|([@^]))(\s*)((?:\[\s*\])?)(\s*)(\.)/},{token:"variable.other.readwrite.groq",regex:/[_A-Za-z][_0-9A-Za-z]*/}],"#value":[{include:"#constant"},{include:"#number"},{include:"#string"},{include:"#array"},{include:"#variable"},{include:"#projection"},{include:"#comments"},{include:"#function-call"}]};ace.define("ace/mode/groq_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],((e,r,n)=>{const t=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,c=function(){this.$rules=o,this.normalizeRules()};t.inherits(c,i),r.GroqHighlightRules=c})),ace.define("ace/mode/groq",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/groq_highlight_rules","ace/mode/folding/cstyle"],((e,o,r)=>{const n=e("../lib/oop"),t=e("./text").Mode,i=e("../tokenizer").Tokenizer,c=e("./groq_highlight_rules").GroqHighlightRules,a=e("./folding/cstyle").FoldMode,l=function(){const e=new c;this.foldingRules=new a,this.$tokenizer=new i(e.getRules()),this.$keywordList=e.$keywordList};n.inherits(l,t),function(){this.lineCommentStart="'"}.call(l.prototype),o.Mode=l}));
|
|
2
|
-
//# sourceMappingURL=editorSupport-895caf32.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorSupport-895caf32.esm.js","sources":["../../src/ace-editor/groq.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nexport {}\n\n// Grammar from https://github.com/sanity-io/vscode-sanity\nconst rules = {\n start: [\n {\n include: '#query',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n ],\n '#query': [\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#pipe',\n },\n {\n include: '#sort-order',\n },\n {\n include: '#filter',\n },\n ],\n '#variable': [\n {\n token: 'variable.other.groq',\n regex: /\\$[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#keyword': [\n {\n token: 'keyword.other.groq',\n regex: /\\b(?:asc|desc|in|match)\\b/,\n },\n ],\n '#comparison': [\n {\n token: 'keyword.operator.comparison.groq',\n // eslint-disable-next-line no-div-regex\n regex: /==|!=|>=|<=|<!=>|<|>/,\n },\n ],\n '#operator': [\n {\n token: 'keyword.operator.arithmetic.groq',\n regex: /\\+|-|\\*{1,2}|\\/|%/,\n },\n ],\n '#pipe': [\n {\n token: 'keyword.operator.pipe.groq',\n regex: /\\|/,\n },\n ],\n '#logical': [\n {\n token: 'keyword.operator.logical.groq',\n regex: /!|&&|\\|\\|/,\n },\n ],\n '#reference': [\n {\n token: 'keyword.operator.reference.groq',\n regex: /->/,\n },\n ],\n '#pair': [\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#filter',\n },\n {\n token: 'keyword.operator.pair.groq',\n regex: /[=]>/,\n },\n ],\n '#arraylike': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: ['text', 'keyword.operator.descendant.groq'],\n regex: /(\\])((?:\\s*\\.)?)/,\n next: 'pop',\n },\n {\n include: '#range',\n },\n {\n include: '#filter',\n },\n {\n include: '#array-values',\n },\n ],\n },\n ],\n '#array': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: 'punctuation.definition.bracket.end.groq',\n regex: /\\]/,\n next: 'pop',\n },\n {\n include: '#array-values',\n },\n {\n defaultToken: 'meta.structure.array.groq',\n },\n ],\n },\n ],\n '#range': [\n {\n token: [\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n 'keyword.operator.range.groq',\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n ],\n regex: /(\\s*)(\\d+)(\\s*)(\\.{2,3})(\\s*)(\\d+)(\\s*)/,\n },\n ],\n '#spread': [\n {\n token: 'punctuation.definition.spread.begin.groq',\n regex: /\\.\\.\\./,\n push: [\n {\n include: '#array',\n },\n {\n include: '#function-call',\n },\n {\n include: '#projection',\n },\n {\n token: 'punctuation.definition.spread.end.groq',\n regex: /(?=.)/,\n next: 'pop',\n },\n {\n defaultToken: 'meta.structure.spread.groq',\n },\n ],\n },\n ],\n '#array-values': [\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-array-separator.groq',\n regex: /[^\\s\\]]/,\n },\n ],\n '#filter': [\n {\n include: '#function-call',\n },\n {\n include: '#keyword',\n },\n {\n include: '#constant',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#comparison',\n },\n {\n include: '#operator',\n },\n {\n include: '#logical',\n },\n ],\n '#comments': [\n {\n token: ['punctuation.definition.comment.groq', 'comment.line.double-slash.js'],\n regex: /(\\/\\/)(.*$)/,\n },\n ],\n '#nullary-access-operator': [\n {\n token: 'constant.language.groq',\n regex: /[*@^]/,\n },\n ],\n '#constant': [\n {\n token: 'constant.language.groq',\n regex: /\\b(?:true|false|null)\\b/,\n },\n ],\n '#number': [\n {\n token: 'constant.numeric.groq',\n regex: /-?(?:0|[1-9]\\d*)(?:(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?/,\n },\n ],\n '#named-projection': [\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#projection',\n },\n ],\n '#projection': [\n {\n token: 'punctuation.definition.projection.begin.groq',\n regex: /\\{/,\n push: [\n {\n token: 'punctuation.definition.projection.end.groq',\n regex: /\\}/,\n next: 'pop',\n },\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#named-projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#spread',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.projection.key-value.groq',\n regex: /:/,\n push: [\n {\n token: 'punctuation.separator.projection.pair.groq',\n regex: /,|(?=\\})/,\n next: 'pop',\n },\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n include: '#identifier',\n },\n {\n include: '#operator',\n },\n {\n include: '#comparison',\n },\n {\n include: '#pair',\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s,]/,\n },\n {\n defaultToken: 'meta.structure.projection.value.groq',\n },\n ],\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s},]/,\n },\n {\n defaultToken: 'meta.structure.projection.groq',\n },\n ],\n },\n ],\n '#string': [\n {\n include: '#single-string',\n },\n {\n include: '#double-string',\n },\n ],\n '#double-string': [\n {\n token: 'punctuation.definition.string.begin.groq',\n regex: /\"/,\n push: [\n {\n token: 'punctuation.definition.string.end.groq',\n regex: /\"/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.double.groq',\n },\n ],\n },\n ],\n '#single-string': [\n {\n token: 'punctuation.definition.string.single.begin.groq',\n regex: /'/,\n push: [\n {\n token: 'punctuation.definition.string.single.end.groq',\n regex: /'/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.single.groq',\n },\n ],\n },\n ],\n '#objectkey': [\n {\n include: '#string',\n },\n ],\n '#stringcontent': [\n {\n token: 'constant.character.escape.groq',\n regex: /\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/,\n },\n {\n token: 'invalid.illegal.unrecognized-string-escape.groq',\n regex: /\\\\./,\n },\n ],\n '#sort-pair': [\n {\n token: ['variable.other.readwrite.groq', 'text', 'keyword.other.groq'],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(?:(\\s*)(asc|desc))?/,\n },\n {\n token: ['constant.language.groq', 'punctuation.definition.bracket.begin.groq'],\n regex: /(@)(\\[)/,\n push: [\n {\n token: ['punctuation.definition.bracket.begin.groq', 'text', 'keyword.other.groq'],\n regex: /(\\])(?:(\\s*)(asc|desc))?/,\n next: 'pop',\n },\n {\n include: '#string',\n },\n ],\n },\n ],\n '#sort-order': [\n {\n token: 'support.function.sortorder.begin.groq',\n regex: /\\border\\s*\\(/,\n push: [\n {\n token: 'support.function.sortorder.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#sort-pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-sort-separator.groq',\n regex: /[^\\s\\]]/,\n },\n {\n defaultToken: 'support.function.sortorder.groq',\n },\n ],\n },\n ],\n '#function-call': [\n {\n include: '#function-var-arg',\n },\n {\n include: '#function-single-arg',\n },\n {\n include: '#function-round',\n },\n ],\n '#function-var-arg': [\n {\n token: 'support.function.vararg.begin.groq',\n regex: /\\b(?:coalesce|select)\\s*\\(/,\n push: [\n {\n token: 'support.function.vararg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#value',\n },\n {\n include: '#identifier',\n },\n {\n include: '#filter',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n defaultToken: 'support.function.vararg.groq',\n },\n ],\n },\n ],\n '#function-single-arg': [\n {\n token: 'support.function.singlearg.begin.groq',\n regex: /\\b(?:count|defined|length|path|references)\\s*\\(/,\n push: [\n {\n token: 'support.function.singlearg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#query',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n {\n defaultToken: 'support.function.singlearg.groq',\n },\n ],\n },\n ],\n '#identifier': [\n {\n token: [\n 'variable.other.readwrite.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.reference.groq',\n ],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(\\s*)((?:\\[\\s*\\])?)(\\s*)(->)/,\n },\n {\n token: [\n 'variable.other.readwrite.groq',\n 'constant.language.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.descendant.groq',\n ],\n regex: /(?:([_A-Za-z][_0-9A-Za-z]*)|([@^]))(\\s*)((?:\\[\\s*\\])?)(\\s*)(\\.)/,\n },\n {\n token: 'variable.other.readwrite.groq',\n regex: /[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#value': [\n {\n include: '#constant',\n },\n {\n include: '#number',\n },\n {\n include: '#string',\n },\n {\n include: '#array',\n },\n {\n include: '#variable',\n },\n {\n include: '#projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#function-call',\n },\n ],\n}\n\ndeclare let ace: any\n\nace.define(\n 'ace/mode/groq_highlight_rules',\n ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules'],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n const oop = acequire('../lib/oop')\n const TextHighlightRules = acequire('./text_highlight_rules').TextHighlightRules\n\n const GroqHighlightRules = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.$rules = rules\n // @ts-ignore\n this.normalizeRules()\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n\n oop.inherits(GroqHighlightRules, TextHighlightRules)\n\n exports.GroqHighlightRules = GroqHighlightRules\n }\n)\n\nace.define(\n 'ace/mode/groq',\n [\n 'require',\n 'exports',\n 'module',\n 'ace/lib/oop',\n 'ace/mode/text',\n 'ace/tokenizer',\n 'ace/mode/groq_highlight_rules',\n 'ace/mode/folding/cstyle',\n ],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n // eslint-disable-next-line strict\n 'use strict'\n const oop = acequire('../lib/oop')\n const TextMode = acequire('./text').Mode\n const Tokenizer = acequire('../tokenizer').Tokenizer\n const GroqHighlightRules = acequire('./groq_highlight_rules').GroqHighlightRules\n const FoldMode = acequire('./folding/cstyle').FoldMode\n\n const Mode = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n const highlighter = new GroqHighlightRules()\n // @ts-ignore\n this.foldingRules = new FoldMode()\n // @ts-ignore\n this.$tokenizer = new Tokenizer(highlighter.getRules())\n // @ts-ignore\n this.$keywordList = highlighter.$keywordList\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n oop.inherits(Mode, TextMode)\n ;(function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.lineCommentStart = \"'\"\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }.call(Mode.prototype))\n\n exports.Mode = Mode\n }\n)\n"],"names":["rules","start","include","token","regex","push","next","defaultToken","ace","define","acequire","exports","_module","oop","TextHighlightRules","GroqHighlightRules","this","$rules","normalizeRules","inherits","TextMode","Mode","Tokenizer","FoldMode","highlighter","foldingRules","$tokenizer","getRules","$keywordList","lineCommentStart","call","prototype"],"mappings":"stCAKA,MAAMA,EAAQ,CACZC,MAAO,CACL,CACEC,QAAS,UAEX,CACEA,QAAS,UAEX,CACEA,QAAS,UAGb,SAAU,CACR,CACEA,QAAS,4BAEX,CACEA,QAAS,cAEX,CACEA,QAAS,SAEX,CACEA,QAAS,eAEX,CACEA,QAAS,YAGb,YAAa,CACX,CACEC,MAAO,sBACPC,MAAO,6BAGX,WAAY,CACV,CACED,MAAO,qBACPC,MAAO,8BAGX,cAAe,CACb,CACED,MAAO,mCAEPC,MAAO,yBAGX,YAAa,CACX,CACED,MAAO,mCACPC,MAAO,sBAGX,QAAS,CACP,CACED,MAAO,6BACPC,MAAO,OAGX,WAAY,CACV,CACED,MAAO,gCACPC,MAAO,cAGX,aAAc,CACZ,CACED,MAAO,kCACPC,MAAO,OAGX,QAAS,CACP,CACEF,QAAS,eAEX,CACEA,QAAS,UAEX,CACEA,QAAS,WAEX,CACEC,MAAO,6BACPC,MAAO,SAGX,aAAc,CACZ,CACED,MAAO,4CACPC,MAAO,KACPC,KAAM,CACJ,CACEF,MAAO,CAAC,OAAQ,oCAChBC,MAAO,mBACPE,KAAM,OAER,CACEJ,QAAS,UAEX,CACEA,QAAS,WAEX,CACEA,QAAS,oBAKjB,SAAU,CACR,CACEC,MAAO,4CACPC,MAAO,KACPC,KAAM,CACJ,CACEF,MAAO,0CACPC,MAAO,KACPE,KAAM,OAER,CACEJ,QAAS,iBAEX,CACEK,aAAc,gCAKtB,SAAU,CACR,CACEJ,MAAO,CACL,4BACA,wBACA,4BACA,8BACA,4BACA,wBACA,6BAEFC,MAAO,4CAGX,UAAW,CACT,CACED,MAAO,2CACPC,MAAO,SACPC,KAAM,CACJ,CACEH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e&&"default"in e?e:{default:e}}require("ace-builds/src-noconflict/mode-batchfile"),require("ace-builds/src-noconflict/mode-csharp"),require("ace-builds/src-noconflict/mode-css"),require("ace-builds/src-noconflict/mode-golang"),require("ace-builds/src-noconflict/mode-html"),require("ace-builds/src-noconflict/mode-java"),require("ace-builds/src-noconflict/mode-javascript"),require("ace-builds/src-noconflict/mode-json"),require("ace-builds/src-noconflict/mode-jsx"),require("ace-builds/src-noconflict/mode-markdown"),require("ace-builds/src-noconflict/mode-mysql"),require("ace-builds/src-noconflict/mode-php"),require("ace-builds/src-noconflict/mode-python"),require("ace-builds/src-noconflict/mode-ruby"),require("ace-builds/src-noconflict/mode-sass"),require("ace-builds/src-noconflict/mode-scss"),require("ace-builds/src-noconflict/mode-sh"),require("ace-builds/src-noconflict/mode-text"),require("ace-builds/src-noconflict/mode-tsx"),require("ace-builds/src-noconflict/mode-typescript"),require("ace-builds/src-noconflict/mode-xml"),require("ace-builds/src-noconflict/mode-yaml"),require("ace-builds/src-noconflict/theme-github"),require("ace-builds/src-noconflict/theme-monokai"),require("ace-builds/src-noconflict/theme-terminal"),require("ace-builds/src-noconflict/theme-tomorrow");var n=r(e);const o={start:[{include:"#query"},{include:"#value"},{include:"#pair"}],"#query":[{include:"#nullary-access-operator"},{include:"#arraylike"},{include:"#pipe"},{include:"#sort-order"},{include:"#filter"}],"#variable":[{token:"variable.other.groq",regex:/\$[_A-Za-z][_0-9A-Za-z]*/}],"#keyword":[{token:"keyword.other.groq",regex:/\b(?:asc|desc|in|match)\b/}],"#comparison":[{token:"keyword.operator.comparison.groq",regex:/==|!=|>=|<=|<!=>|<|>/}],"#operator":[{token:"keyword.operator.arithmetic.groq",regex:/\+|-|\*{1,2}|\/|%/}],"#pipe":[{token:"keyword.operator.pipe.groq",regex:/\|/}],"#logical":[{token:"keyword.operator.logical.groq",regex:/!|&&|\|\|/}],"#reference":[{token:"keyword.operator.reference.groq",regex:/->/}],"#pair":[{include:"#identifier"},{include:"#value"},{include:"#filter"},{token:"keyword.operator.pair.groq",regex:/[=]>/}],"#arraylike":[{token:"punctuation.definition.bracket.begin.groq",regex:/\[/,push:[{token:["text","keyword.operator.descendant.groq"],regex:/(\])((?:\s*\.)?)/,next:"pop"},{include:"#range"},{include:"#filter"},{include:"#array-values"}]}],"#array":[{token:"punctuation.definition.bracket.begin.groq",regex:/\[/,push:[{token:"punctuation.definition.bracket.end.groq",regex:/\]/,next:"pop"},{include:"#array-values"},{defaultToken:"meta.structure.array.groq"}]}],"#range":[{token:["meta.structure.range.groq","constant.numeric.groq","meta.structure.range.groq","keyword.operator.range.groq","meta.structure.range.groq","constant.numeric.groq","meta.structure.range.groq"],regex:/(\s*)(\d+)(\s*)(\.{2,3})(\s*)(\d+)(\s*)/}],"#spread":[{token:"punctuation.definition.spread.begin.groq",regex:/\.\.\./,push:[{include:"#array"},{include:"#function-call"},{include:"#projection"},{token:"punctuation.definition.spread.end.groq",regex:/(?=.)/,next:"pop"},{defaultToken:"meta.structure.spread.groq"}]}],"#array-values":[{include:"#value"},{include:"#spread"},{token:"punctuation.separator.array.groq",regex:/,/},{token:"invalid.illegal.expected-array-separator.groq",regex:/[^\s\]]/}],"#filter":[{include:"#function-call"},{include:"#keyword"},{include:"#constant"},{include:"#identifier"},{include:"#value"},{include:"#comparison"},{include:"#operator"},{include:"#logical"}],"#comments":[{token:["punctuation.definition.comment.groq","comment.line.double-slash.js"],regex:/(\/\/)(.*$)/}],"#nullary-access-operator":[{token:"constant.language.groq",regex:/[*@^]/}],"#constant":[{token:"constant.language.groq",regex:/\b(?:true|false|null)\b/}],"#number":[{token:"constant.numeric.groq",regex:/-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/}],"#named-projection":[{include:"#identifier"},{include:"#objectkey"},{include:"#projection"}],"#projection":[{token:"punctuation.definition.projection.begin.groq",regex:/\{/,push:[{token:"punctuation.definition.projection.end.groq",regex:/\}/,next:"pop"},{include:"#identifier"},{include:"#objectkey"},{include:"#named-projection"},{include:"#comments"},{include:"#spread"},{include:"#pair"},{token:"punctuation.separator.projection.key-value.groq",regex:/:/,push:[{token:"punctuation.separator.projection.pair.groq",regex:/,|(?=\})/,next:"pop"},{include:"#nullary-access-operator"},{include:"#arraylike"},{include:"#value"},{include:"#spread"},{include:"#identifier"},{include:"#operator"},{include:"#comparison"},{include:"#pair"},{token:"invalid.illegal.expected-projection-separator.groq",regex:/[^\s,]/},{defaultToken:"meta.structure.projection.value.groq"}]},{token:"invalid.illegal.expected-projection-separator.groq",regex:/[^\s},]/},{defaultToken:"meta.structure.projection.groq"}]}],"#string":[{include:"#single-string"},{include:"#double-string"}],"#double-string":[{token:"punctuation.definition.string.begin.groq",regex:/"/,push:[{token:"punctuation.definition.string.end.groq",regex:/"/,next:"pop"},{include:"#stringcontent"},{defaultToken:"string.quoted.double.groq"}]}],"#single-string":[{token:"punctuation.definition.string.single.begin.groq",regex:/'/,push:[{token:"punctuation.definition.string.single.end.groq",regex:/'/,next:"pop"},{include:"#stringcontent"},{defaultToken:"string.quoted.single.groq"}]}],"#objectkey":[{include:"#string"}],"#stringcontent":[{token:"constant.character.escape.groq",regex:/\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})/},{token:"invalid.illegal.unrecognized-string-escape.groq",regex:/\\./}],"#sort-pair":[{token:["variable.other.readwrite.groq","text","keyword.other.groq"],regex:/([_A-Za-z][_0-9A-Za-z]*)(?:(\s*)(asc|desc))?/},{token:["constant.language.groq","punctuation.definition.bracket.begin.groq"],regex:/(@)(\[)/,push:[{token:["punctuation.definition.bracket.begin.groq","text","keyword.other.groq"],regex:/(\])(?:(\s*)(asc|desc))?/,next:"pop"},{include:"#string"}]}],"#sort-order":[{token:"support.function.sortorder.begin.groq",regex:/\border\s*\(/,push:[{token:"support.function.sortorder.end.groq",regex:/\)/,next:"pop"},{include:"#sort-pair"},{token:"punctuation.separator.array.groq",regex:/,/},{token:"invalid.illegal.expected-sort-separator.groq",regex:/[^\s\]]/},{defaultToken:"support.function.sortorder.groq"}]}],"#function-call":[{include:"#function-var-arg"},{include:"#function-single-arg"},{include:"#function-round"}],"#function-var-arg":[{token:"support.function.vararg.begin.groq",regex:/\b(?:coalesce|select)\s*\(/,push:[{token:"support.function.vararg.end.groq",regex:/\)/,next:"pop"},{include:"#value"},{include:"#identifier"},{include:"#filter"},{include:"#pair"},{token:"punctuation.separator.array.groq",regex:/,/},{defaultToken:"support.function.vararg.groq"}]}],"#function-single-arg":[{token:"support.function.singlearg.begin.groq",regex:/\b(?:count|defined|length|path|references)\s*\(/,push:[{token:"support.function.singlearg.end.groq",regex:/\)/,next:"pop"},{include:"#query"},{include:"#identifier"},{include:"#value"},{include:"#pair"},{defaultToken:"support.function.singlearg.groq"}]}],"#identifier":[{token:["variable.other.readwrite.groq","text","punctuation.definition.block.js","text","keyword.operator.reference.groq"],regex:/([_A-Za-z][_0-9A-Za-z]*)(\s*)((?:\[\s*\])?)(\s*)(->)/},{token:["variable.other.readwrite.groq","constant.language.groq","text","punctuation.definition.block.js","text","keyword.operator.descendant.groq"],regex:/(?:([_A-Za-z][_0-9A-Za-z]*)|([@^]))(\s*)((?:\[\s*\])?)(\s*)(\.)/},{token:"variable.other.readwrite.groq",regex:/[_A-Za-z][_0-9A-Za-z]*/}],"#value":[{include:"#constant"},{include:"#number"},{include:"#string"},{include:"#array"},{include:"#variable"},{include:"#projection"},{include:"#comments"},{include:"#function-call"}]};ace.define("ace/mode/groq_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],((e,r,n)=>{const t=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,c=function(){this.$rules=o,this.normalizeRules()};t.inherits(c,i),r.GroqHighlightRules=c})),ace.define("ace/mode/groq",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/groq_highlight_rules","ace/mode/folding/cstyle"],((e,r,n)=>{const o=e("../lib/oop"),t=e("./text").Mode,i=e("../tokenizer").Tokenizer,c=e("./groq_highlight_rules").GroqHighlightRules,a=e("./folding/cstyle").FoldMode,u=function(){const e=new c;this.foldingRules=new a,this.$tokenizer=new i(e.getRules()),this.$keywordList=e.$keywordList};o.inherits(u,t),function(){this.lineCommentStart="'"}.call(u.prototype),r.Mode=u})),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return n.default}});
|
|
2
|
-
//# sourceMappingURL=editorSupport-bda3d360.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editorSupport-bda3d360.js","sources":["../../src/ace-editor/groq.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nexport {}\n\n// Grammar from https://github.com/sanity-io/vscode-sanity\nconst rules = {\n start: [\n {\n include: '#query',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n ],\n '#query': [\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#pipe',\n },\n {\n include: '#sort-order',\n },\n {\n include: '#filter',\n },\n ],\n '#variable': [\n {\n token: 'variable.other.groq',\n regex: /\\$[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#keyword': [\n {\n token: 'keyword.other.groq',\n regex: /\\b(?:asc|desc|in|match)\\b/,\n },\n ],\n '#comparison': [\n {\n token: 'keyword.operator.comparison.groq',\n // eslint-disable-next-line no-div-regex\n regex: /==|!=|>=|<=|<!=>|<|>/,\n },\n ],\n '#operator': [\n {\n token: 'keyword.operator.arithmetic.groq',\n regex: /\\+|-|\\*{1,2}|\\/|%/,\n },\n ],\n '#pipe': [\n {\n token: 'keyword.operator.pipe.groq',\n regex: /\\|/,\n },\n ],\n '#logical': [\n {\n token: 'keyword.operator.logical.groq',\n regex: /!|&&|\\|\\|/,\n },\n ],\n '#reference': [\n {\n token: 'keyword.operator.reference.groq',\n regex: /->/,\n },\n ],\n '#pair': [\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#filter',\n },\n {\n token: 'keyword.operator.pair.groq',\n regex: /[=]>/,\n },\n ],\n '#arraylike': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: ['text', 'keyword.operator.descendant.groq'],\n regex: /(\\])((?:\\s*\\.)?)/,\n next: 'pop',\n },\n {\n include: '#range',\n },\n {\n include: '#filter',\n },\n {\n include: '#array-values',\n },\n ],\n },\n ],\n '#array': [\n {\n token: 'punctuation.definition.bracket.begin.groq',\n regex: /\\[/,\n push: [\n {\n token: 'punctuation.definition.bracket.end.groq',\n regex: /\\]/,\n next: 'pop',\n },\n {\n include: '#array-values',\n },\n {\n defaultToken: 'meta.structure.array.groq',\n },\n ],\n },\n ],\n '#range': [\n {\n token: [\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n 'keyword.operator.range.groq',\n 'meta.structure.range.groq',\n 'constant.numeric.groq',\n 'meta.structure.range.groq',\n ],\n regex: /(\\s*)(\\d+)(\\s*)(\\.{2,3})(\\s*)(\\d+)(\\s*)/,\n },\n ],\n '#spread': [\n {\n token: 'punctuation.definition.spread.begin.groq',\n regex: /\\.\\.\\./,\n push: [\n {\n include: '#array',\n },\n {\n include: '#function-call',\n },\n {\n include: '#projection',\n },\n {\n token: 'punctuation.definition.spread.end.groq',\n regex: /(?=.)/,\n next: 'pop',\n },\n {\n defaultToken: 'meta.structure.spread.groq',\n },\n ],\n },\n ],\n '#array-values': [\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-array-separator.groq',\n regex: /[^\\s\\]]/,\n },\n ],\n '#filter': [\n {\n include: '#function-call',\n },\n {\n include: '#keyword',\n },\n {\n include: '#constant',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#comparison',\n },\n {\n include: '#operator',\n },\n {\n include: '#logical',\n },\n ],\n '#comments': [\n {\n token: ['punctuation.definition.comment.groq', 'comment.line.double-slash.js'],\n regex: /(\\/\\/)(.*$)/,\n },\n ],\n '#nullary-access-operator': [\n {\n token: 'constant.language.groq',\n regex: /[*@^]/,\n },\n ],\n '#constant': [\n {\n token: 'constant.language.groq',\n regex: /\\b(?:true|false|null)\\b/,\n },\n ],\n '#number': [\n {\n token: 'constant.numeric.groq',\n regex: /-?(?:0|[1-9]\\d*)(?:(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?/,\n },\n ],\n '#named-projection': [\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#projection',\n },\n ],\n '#projection': [\n {\n token: 'punctuation.definition.projection.begin.groq',\n regex: /\\{/,\n push: [\n {\n token: 'punctuation.definition.projection.end.groq',\n regex: /\\}/,\n next: 'pop',\n },\n {\n include: '#identifier',\n },\n {\n include: '#objectkey',\n },\n {\n include: '#named-projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#spread',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.projection.key-value.groq',\n regex: /:/,\n push: [\n {\n token: 'punctuation.separator.projection.pair.groq',\n regex: /,|(?=\\})/,\n next: 'pop',\n },\n {\n include: '#nullary-access-operator',\n },\n {\n include: '#arraylike',\n },\n {\n include: '#value',\n },\n {\n include: '#spread',\n },\n {\n include: '#identifier',\n },\n {\n include: '#operator',\n },\n {\n include: '#comparison',\n },\n {\n include: '#pair',\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s,]/,\n },\n {\n defaultToken: 'meta.structure.projection.value.groq',\n },\n ],\n },\n {\n token: 'invalid.illegal.expected-projection-separator.groq',\n regex: /[^\\s},]/,\n },\n {\n defaultToken: 'meta.structure.projection.groq',\n },\n ],\n },\n ],\n '#string': [\n {\n include: '#single-string',\n },\n {\n include: '#double-string',\n },\n ],\n '#double-string': [\n {\n token: 'punctuation.definition.string.begin.groq',\n regex: /\"/,\n push: [\n {\n token: 'punctuation.definition.string.end.groq',\n regex: /\"/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.double.groq',\n },\n ],\n },\n ],\n '#single-string': [\n {\n token: 'punctuation.definition.string.single.begin.groq',\n regex: /'/,\n push: [\n {\n token: 'punctuation.definition.string.single.end.groq',\n regex: /'/,\n next: 'pop',\n },\n {\n include: '#stringcontent',\n },\n {\n defaultToken: 'string.quoted.single.groq',\n },\n ],\n },\n ],\n '#objectkey': [\n {\n include: '#string',\n },\n ],\n '#stringcontent': [\n {\n token: 'constant.character.escape.groq',\n regex: /\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/,\n },\n {\n token: 'invalid.illegal.unrecognized-string-escape.groq',\n regex: /\\\\./,\n },\n ],\n '#sort-pair': [\n {\n token: ['variable.other.readwrite.groq', 'text', 'keyword.other.groq'],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(?:(\\s*)(asc|desc))?/,\n },\n {\n token: ['constant.language.groq', 'punctuation.definition.bracket.begin.groq'],\n regex: /(@)(\\[)/,\n push: [\n {\n token: ['punctuation.definition.bracket.begin.groq', 'text', 'keyword.other.groq'],\n regex: /(\\])(?:(\\s*)(asc|desc))?/,\n next: 'pop',\n },\n {\n include: '#string',\n },\n ],\n },\n ],\n '#sort-order': [\n {\n token: 'support.function.sortorder.begin.groq',\n regex: /\\border\\s*\\(/,\n push: [\n {\n token: 'support.function.sortorder.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#sort-pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n token: 'invalid.illegal.expected-sort-separator.groq',\n regex: /[^\\s\\]]/,\n },\n {\n defaultToken: 'support.function.sortorder.groq',\n },\n ],\n },\n ],\n '#function-call': [\n {\n include: '#function-var-arg',\n },\n {\n include: '#function-single-arg',\n },\n {\n include: '#function-round',\n },\n ],\n '#function-var-arg': [\n {\n token: 'support.function.vararg.begin.groq',\n regex: /\\b(?:coalesce|select)\\s*\\(/,\n push: [\n {\n token: 'support.function.vararg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#value',\n },\n {\n include: '#identifier',\n },\n {\n include: '#filter',\n },\n {\n include: '#pair',\n },\n {\n token: 'punctuation.separator.array.groq',\n regex: /,/,\n },\n {\n defaultToken: 'support.function.vararg.groq',\n },\n ],\n },\n ],\n '#function-single-arg': [\n {\n token: 'support.function.singlearg.begin.groq',\n regex: /\\b(?:count|defined|length|path|references)\\s*\\(/,\n push: [\n {\n token: 'support.function.singlearg.end.groq',\n regex: /\\)/,\n next: 'pop',\n },\n {\n include: '#query',\n },\n {\n include: '#identifier',\n },\n {\n include: '#value',\n },\n {\n include: '#pair',\n },\n {\n defaultToken: 'support.function.singlearg.groq',\n },\n ],\n },\n ],\n '#identifier': [\n {\n token: [\n 'variable.other.readwrite.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.reference.groq',\n ],\n regex: /([_A-Za-z][_0-9A-Za-z]*)(\\s*)((?:\\[\\s*\\])?)(\\s*)(->)/,\n },\n {\n token: [\n 'variable.other.readwrite.groq',\n 'constant.language.groq',\n 'text',\n 'punctuation.definition.block.js',\n 'text',\n 'keyword.operator.descendant.groq',\n ],\n regex: /(?:([_A-Za-z][_0-9A-Za-z]*)|([@^]))(\\s*)((?:\\[\\s*\\])?)(\\s*)(\\.)/,\n },\n {\n token: 'variable.other.readwrite.groq',\n regex: /[_A-Za-z][_0-9A-Za-z]*/,\n },\n ],\n '#value': [\n {\n include: '#constant',\n },\n {\n include: '#number',\n },\n {\n include: '#string',\n },\n {\n include: '#array',\n },\n {\n include: '#variable',\n },\n {\n include: '#projection',\n },\n {\n include: '#comments',\n },\n {\n include: '#function-call',\n },\n ],\n}\n\ndeclare let ace: any\n\nace.define(\n 'ace/mode/groq_highlight_rules',\n ['require', 'exports', 'module', 'ace/lib/oop', 'ace/mode/text_highlight_rules'],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n const oop = acequire('../lib/oop')\n const TextHighlightRules = acequire('./text_highlight_rules').TextHighlightRules\n\n const GroqHighlightRules = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.$rules = rules\n // @ts-ignore\n this.normalizeRules()\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n\n oop.inherits(GroqHighlightRules, TextHighlightRules)\n\n exports.GroqHighlightRules = GroqHighlightRules\n }\n)\n\nace.define(\n 'ace/mode/groq',\n [\n 'require',\n 'exports',\n 'module',\n 'ace/lib/oop',\n 'ace/mode/text',\n 'ace/tokenizer',\n 'ace/mode/groq_highlight_rules',\n 'ace/mode/folding/cstyle',\n ],\n (acequire: (id: string) => any, exports: Record<string, unknown>, _module: any) => {\n // eslint-disable-next-line strict\n 'use strict'\n const oop = acequire('../lib/oop')\n const TextMode = acequire('./text').Mode\n const Tokenizer = acequire('../tokenizer').Tokenizer\n const GroqHighlightRules = acequire('./groq_highlight_rules').GroqHighlightRules\n const FoldMode = acequire('./folding/cstyle').FoldMode\n\n const Mode = function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n const highlighter = new GroqHighlightRules()\n // @ts-ignore\n this.foldingRules = new FoldMode()\n // @ts-ignore\n this.$tokenizer = new Tokenizer(highlighter.getRules())\n // @ts-ignore\n this.$keywordList = highlighter.$keywordList\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }\n oop.inherits(Mode, TextMode)\n ;(function () {\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore\n this.lineCommentStart = \"'\"\n /* eslint-enable @typescript-eslint/ban-ts-comment */\n }.call(Mode.prototype))\n\n exports.Mode = Mode\n }\n)\n"],"names":["rules","start","include","token","regex","push","next","defaultToken","ace","define","acequire","exports","_module","oop","TextHighlightRules","GroqHighlightRules","this","$rules","normalizeRules","inherits","TextMode","Mode","Tokenizer","FoldMode","highlighter","foldingRules","$tokenizer","getRules","$keywordList","lineCommentStart","call","prototype"],"mappings":"u2CAKA,MAAMA,EAAQ,CACZC,MAAO,CACL,CACEC,QAAS,UAEX,CACEA,QAAS,UAEX,CACEA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AS,WAEX,CACEA,QAAS,UAEX,CACEA,QAAS,aAEX,CACEA,QAAS,eAEX,CACEA,QAAS,aAEX,CACEA,QAAS,oBAOfM,IAAIC,OACF,gCACA,CAAC,UAAW,UAAW,SAAU,cAAe,kCAChD,CAACC,EAA+BC,EAAkCC,KAC1D,MAAAC,EAAMH,EAAS,cACfI,EAAqBJ,EAAS,0BAA0BI,mBAExDC,EAAqB,WAGzBC,KAAKC,OAASjB,EAEdgB,KAAKE,gBAAe,EAIlBL,EAAAM,SAASJ,EAAoBD,GAEjCH,EAAQI,mBAAqBA,CAAA,IAIjCP,IAAIC,OACF,gBACA,CACE,UACA,UACA,SACA,cACA,gBACA,gBACA,gCACA,4BAEF,CAACC,EAA+BC,EAAkCC,KAG1D,MAAAC,EAAMH,EAAS,cACfU,EAAWV,EAAS,UAAUW,KAC9BC,EAAYZ,EAAS,gBAAgBY,UACrCP,EAAqBL,EAAS,0BAA0BK,mBACxDQ,EAAWb,EAAS,oBAAoBa,SAExCF,EAAO,WAEL,MAAAG,EAAc,IAAIT,EAEnBC,KAAAS,aAAe,IAAIF,EAExBP,KAAKU,WAAa,IAAIJ,EAAUE,EAAYG,YAE5CX,KAAKY,aAAeJ,EAAYI,YAAA,EAG9Bf,EAAAM,SAASE,EAAMD,GAClB,WAGCJ,KAAKa,iBAAmB,GAE1B,EAAEC,KAAKT,EAAKU,WAEZpB,EAAQU,KAAOA,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
|
-
import React, {Suspense} from 'react'
|
|
3
|
-
|
|
4
|
-
import {queryByText, render, waitForElementToBeRemoved} from '@testing-library/react'
|
|
5
|
-
import {useAceEditor} from './AceEditorLazy'
|
|
6
|
-
|
|
7
|
-
describe('AceEditor - client', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
jest
|
|
10
|
-
.spyOn(window, 'requestAnimationFrame')
|
|
11
|
-
.mockImplementation((callback: FrameRequestCallback): number => {
|
|
12
|
-
callback(0)
|
|
13
|
-
return 0
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
;(window.requestAnimationFrame as any).mockRestore()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('should render suspended ace editor', async () => {
|
|
22
|
-
const fallbackString = 'loading'
|
|
23
|
-
|
|
24
|
-
const TestComponent = () => {
|
|
25
|
-
const AceEditor = useAceEditor()
|
|
26
|
-
return <Suspense fallback={fallbackString}>{AceEditor && <AceEditor />}</Suspense>
|
|
27
|
-
}
|
|
28
|
-
const {container} = render(<TestComponent />)
|
|
29
|
-
|
|
30
|
-
expect(container.innerHTML).toEqual(fallbackString)
|
|
31
|
-
|
|
32
|
-
await waitForElementToBeRemoved(() => queryByText(container, fallbackString))
|
|
33
|
-
|
|
34
|
-
// note: ace will console.error log when mounting
|
|
35
|
-
expect(container.querySelector('.ace_editor')).toBeDefined()
|
|
36
|
-
})
|
|
37
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* AceEditor loads window global directly when imported, which crashes in node envs.
|
|
5
|
-
* This works around the issue by only importing ace-dependencies when window is defined.
|
|
6
|
-
*
|
|
7
|
-
* We only set the ace lazy component after mounting, to allow us to render null on the server,
|
|
8
|
-
* and use suspense on the client. This will make hydration work correctly.
|
|
9
|
-
*/
|
|
10
|
-
export const AceEditorLazy = React.lazy(() => import('./editorSupport'))
|
|
11
|
-
|
|
12
|
-
export function useAceEditor() {
|
|
13
|
-
const [mounted, setMounted] = useState(false)
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
requestAnimationFrame(() => setMounted(true))
|
|
16
|
-
}, [])
|
|
17
|
-
|
|
18
|
-
return mounted ? AceEditorLazy : null
|
|
19
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import ReactAce from 'react-ace'
|
|
2
|
-
export default ReactAce
|
|
3
|
-
|
|
4
|
-
// NOTE: MAKE SURE THESE ALIGN WITH SUPPORTED_LANGUAGES in ./config
|
|
5
|
-
import './groq'
|
|
6
|
-
|
|
7
|
-
import 'ace-builds/src-noconflict/mode-batchfile'
|
|
8
|
-
import 'ace-builds/src-noconflict/mode-csharp'
|
|
9
|
-
import 'ace-builds/src-noconflict/mode-css'
|
|
10
|
-
import 'ace-builds/src-noconflict/mode-golang'
|
|
11
|
-
import 'ace-builds/src-noconflict/mode-html'
|
|
12
|
-
import 'ace-builds/src-noconflict/mode-java'
|
|
13
|
-
import 'ace-builds/src-noconflict/mode-javascript'
|
|
14
|
-
import 'ace-builds/src-noconflict/mode-json'
|
|
15
|
-
import 'ace-builds/src-noconflict/mode-jsx'
|
|
16
|
-
import 'ace-builds/src-noconflict/mode-markdown'
|
|
17
|
-
import 'ace-builds/src-noconflict/mode-mysql'
|
|
18
|
-
import 'ace-builds/src-noconflict/mode-php'
|
|
19
|
-
import 'ace-builds/src-noconflict/mode-python'
|
|
20
|
-
import 'ace-builds/src-noconflict/mode-ruby'
|
|
21
|
-
import 'ace-builds/src-noconflict/mode-sass'
|
|
22
|
-
import 'ace-builds/src-noconflict/mode-scss'
|
|
23
|
-
import 'ace-builds/src-noconflict/mode-sh'
|
|
24
|
-
import 'ace-builds/src-noconflict/mode-text'
|
|
25
|
-
import 'ace-builds/src-noconflict/mode-tsx'
|
|
26
|
-
import 'ace-builds/src-noconflict/mode-typescript'
|
|
27
|
-
import 'ace-builds/src-noconflict/mode-xml'
|
|
28
|
-
import 'ace-builds/src-noconflict/mode-yaml'
|
|
29
|
-
|
|
30
|
-
// Themes
|
|
31
|
-
import 'ace-builds/src-noconflict/theme-github'
|
|
32
|
-
import 'ace-builds/src-noconflict/theme-monokai'
|
|
33
|
-
import 'ace-builds/src-noconflict/theme-terminal'
|
|
34
|
-
import 'ace-builds/src-noconflict/theme-tomorrow'
|