From 8633e67127e4613899961bc3ceddec7477468a6f Mon Sep 17 00:00:00 2001 From: Logue Date: Tue, 23 Apr 2024 16:45:28 +0900 Subject: [PATCH] Add indentUnit prop feature. #34 --- src/components/CodeMirror.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/CodeMirror.ts b/src/components/CodeMirror.ts index 62bca41..313e1d7 100644 --- a/src/components/CodeMirror.ts +++ b/src/components/CodeMirror.ts @@ -2,6 +2,7 @@ // CodeMirror import { indentWithTab } from '@codemirror/commands'; +import { indentUnit, type LanguageSupport } from '@codemirror/language'; import { diagnosticCount as linterDagnosticCount, forceLinting, @@ -44,7 +45,6 @@ import { type WritableComputedRef, } from 'vue-demi'; -import type { LanguageSupport } from '@codemirror/language'; import type { StyleSpec } from 'style-mod'; import h, { slot } from '@/helpers/h-demi'; @@ -128,6 +128,13 @@ export default defineComponent({ type: Boolean, default: false, }, + /** + * Tab character + */ + indentUnit: { + type: String, + default: undefined, + }, /** * Allow Multiple Selection. * @@ -394,6 +401,8 @@ export default defineComponent({ props.wrap ? EditorView.lineWrapping : undefined, // Indent with tab props.tab ? keymap.of([indentWithTab]) : undefined, + // Tab character + props.indentUnit ? indentUnit.of(props.indentUnit) : undefined, // Allow Multiple Selections EditorState.allowMultipleSelections.of(props.allowMultipleSelections), // Indent tab size