Hacky implementation of variable autocomplete

This commit is contained in:
Gregory Schier
2023-10-23 10:31:21 -07:00
parent 4ad5d7f291
commit 83e2cab1b6
7 changed files with 83 additions and 61 deletions

View File

@@ -37,6 +37,7 @@ import type { EditorProps } from './index';
import { text } from './text/extension';
import { twig } from './twig/extension';
import { url } from './url/extension';
import type { Environment } from '../../../lib/models';
export const myHighlightStyle = HighlightStyle.define([
{
@@ -95,8 +96,9 @@ const syntaxExtensions: Record<string, LanguageSupport> = {
export function getLanguageExtension({
contentType,
useTemplating = false,
environment,
autocomplete,
}: Pick<EditorProps, 'contentType' | 'useTemplating' | 'autocomplete'>) {
}: { environment: Environment | null } & Pick<EditorProps, 'contentType' | 'useTemplating' | 'autocomplete'>) {
if (contentType === 'application/graphql') {
return graphql();
}
@@ -106,7 +108,7 @@ export function getLanguageExtension({
return base ? base : [];
}
return twig(base, autocomplete);
return twig(base, environment, autocomplete);
}
export const baseExtensions = [