Better header editor and added completion data

This commit is contained in:
Gregory Schier
2023-03-19 11:09:21 -07:00
parent cb3f053057
commit d9b40dca83
16 changed files with 568 additions and 92 deletions

View File

@@ -34,6 +34,7 @@ import {
import { tags as t } from '@lezer/highlight';
import { graphqlLanguageSupport } from 'cm6-graphql';
import type { GenericCompletionOption } from './genericCompletion';
import type { EditorProps } from './index';
import { text } from './text/extension';
import { twig } from './twig/extension';
import { url } from './url/extension';
@@ -95,19 +96,15 @@ const syntaxExtensions: Record<string, LanguageSupport> = {
export function getLanguageExtension({
contentType,
useTemplating = false,
autocompleteOptions,
}: {
contentType?: string;
useTemplating?: boolean;
autocompleteOptions?: GenericCompletionOption[];
}) {
autocomplete,
}: Pick<EditorProps, 'contentType' | 'useTemplating' | 'autocomplete'>) {
const justContentType = contentType?.split(';')[0] ?? contentType ?? '';
const base = syntaxExtensions[justContentType] ?? text();
if (!useTemplating) {
return base ? base : [];
}
return twig(base, autocompleteOptions);
return twig(base, autocomplete);
}
export const baseExtensions = [