chore: add c/cpp/auto options in code langauges

This commit is contained in:
Mayur Mahajan 2023-08-01 11:46:01 +05:30 committed by GitHub
parent 62be81395d
commit 70963a55f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,7 +123,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
'BASIC', 'BASIC',
'C', 'C',
'C#', 'C#',
'C++', 'CPP',
'Clojure', 'Clojure',
'CSS', 'CSS',
'Dart', 'Dart',
@ -167,7 +167,10 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
.map((e) => e.toLowerCase()) .map((e) => e.toLowerCase())
.toSet() .toSet()
.intersection(allLanguages.keys.toSet()) .intersection(allLanguages.keys.toSet())
.toList(); .toList()
..add('auto')
..add('c')
..sort();
late final editorState = context.read<EditorState>(); late final editorState = context.read<EditorState>();
@ -253,7 +256,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4),
child: FlowyTextButton( child: FlowyTextButton(
'${language?.capitalize() ?? 'auto'} ', '${language?.capitalize() ?? 'Auto'} ',
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 12.0, horizontal: 12.0,
vertical: 4.0, vertical: 4.0,
@ -281,7 +284,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
Future<void> updateLanguage(String language) async { Future<void> updateLanguage(String language) async {
final transaction = editorState.transaction final transaction = editorState.transaction
..updateNode(node, { ..updateNode(node, {
CodeBlockKeys.language: language, CodeBlockKeys.language: language == 'auto' ? null : language,
}) })
..afterSelection = Selection.collapse( ..afterSelection = Selection.collapse(
node.path, node.path,