From d9a4a0c6f6a0c9c86927d80bf5c81b4e9f6fc6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Russ?= Date: Wed, 30 Oct 2024 16:00:22 +0100 Subject: [PATCH] Feat: Allow .fsd file creation --- packages/plugins/src/menu/NewProject.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/plugins/src/menu/NewProject.ts b/packages/plugins/src/menu/NewProject.ts index 3e4dfa902d..042d1dd963 100644 --- a/packages/plugins/src/menu/NewProject.ts +++ b/packages/plugins/src/menu/NewProject.ts @@ -20,13 +20,23 @@ import { } from '@openscd/open-scd/src/schemas.js'; export default class NewProjectPlugin extends LitElement { + private createNewProject( inputs: WizardInputElement[], wizard: Element ): EditorAction[] { - const docName = inputs[0].value?.match(/\.s[sc]d$/i) - ? inputs[0].value - : inputs[0].value + '.scd'; + + let docName = inputs[0].value ?? '' + + const acceptedFileExtension = ['.ssd', '.scd','.fsd']; + const isValidFileFormat = acceptedFileExtension.some((extension) => { + return inputs[0].value?.endsWith(extension); + }) + + if(!isValidFileFormat) { + docName = docName + '.scd'; + } + const version = ( (wizard.shadowRoot!.querySelector('mwc-list')!.selected) .value @@ -39,7 +49,6 @@ export default class NewProjectPlugin extends LitElement { return [{ actions: [], title: '', derived: true }]; } - private newProjectWizard(): Wizard { return [ {