mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:08:29 +02:00
Fix close bracket bug
This commit is contained in:
@@ -74,7 +74,7 @@ export const syntaxHighlightStyle = HighlightStyle.define([
|
|||||||
|
|
||||||
const syntaxTheme = EditorView.theme({}, { dark: true });
|
const syntaxTheme = EditorView.theme({}, { dark: true });
|
||||||
|
|
||||||
const closeBracketsExts: Extension = [closeBrackets(), keymap.of([...closeBracketsKeymap])];
|
const closeBracketsExtensions: Extension = [closeBrackets(), keymap.of([...closeBracketsKeymap])];
|
||||||
|
|
||||||
const syntaxExtensions: Record<NonNullable<EditorProps['language']>, LanguageSupport | null> = {
|
const syntaxExtensions: Record<NonNullable<EditorProps['language']>, LanguageSupport | null> = {
|
||||||
graphql: null,
|
graphql: null,
|
||||||
@@ -88,10 +88,10 @@ const syntaxExtensions: Record<NonNullable<EditorProps['language']>, LanguageSup
|
|||||||
markdown: markdown(),
|
markdown: markdown(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeBracketsFor: (keyof typeof syntaxExtensions)[] = ['json', 'javascript'];
|
const closeBracketsFor: (keyof typeof syntaxExtensions)[] = ['json', 'javascript', 'graphql'];
|
||||||
|
|
||||||
export function getLanguageExtension({
|
export function getLanguageExtension({
|
||||||
language,
|
language = 'text',
|
||||||
useTemplating = false,
|
useTemplating = false,
|
||||||
environmentVariables,
|
environmentVariables,
|
||||||
autocomplete,
|
autocomplete,
|
||||||
@@ -106,21 +106,26 @@ export function getLanguageExtension({
|
|||||||
onClickPathParameter: (name: string) => void;
|
onClickPathParameter: (name: string) => void;
|
||||||
completionOptions: TwigCompletionOption[];
|
completionOptions: TwigCompletionOption[];
|
||||||
} & Pick<EditorProps, 'language' | 'useTemplating' | 'autocomplete'>) {
|
} & Pick<EditorProps, 'language' | 'useTemplating' | 'autocomplete'>) {
|
||||||
if (language === 'graphql') {
|
const extraExtensions: Extension[] = [];
|
||||||
return graphql();
|
|
||||||
}
|
|
||||||
|
|
||||||
const base = syntaxExtensions[language ?? 'text'] ?? text();
|
if (language === 'url') {
|
||||||
if (!useTemplating) {
|
extraExtensions.push(pathParametersPlugin(onClickPathParameter));
|
||||||
return base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraExtensions: Extension[] =
|
|
||||||
language === 'url' ? [pathParametersPlugin(onClickPathParameter)] : [];
|
|
||||||
|
|
||||||
// Only close brackets on languages that need it
|
// Only close brackets on languages that need it
|
||||||
if (language && closeBracketsFor.includes(language)) {
|
if (language && closeBracketsFor.includes(language)) {
|
||||||
extraExtensions.push(closeBracketsExts);
|
extraExtensions.push(closeBracketsExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GraphQL is a special exception
|
||||||
|
if (language === 'graphql') {
|
||||||
|
return [graphql(), extraExtensions];
|
||||||
|
}
|
||||||
|
|
||||||
|
const base = syntaxExtensions[language ?? 'text'] ?? text();
|
||||||
|
|
||||||
|
if (!useTemplating) {
|
||||||
|
return [base, extraExtensions];
|
||||||
}
|
}
|
||||||
|
|
||||||
return twig({
|
return twig({
|
||||||
|
|||||||
Reference in New Issue
Block a user