Skip to content

Commit

Permalink
Feat: Allow .fsd file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
trusz authored Oct 30, 2024
1 parent a510664 commit d9a4a0c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/plugins/src/menu/NewProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <SupportedVersion>(
(<ListItemBase>wizard.shadowRoot!.querySelector('mwc-list')!.selected)
.value
Expand All @@ -39,7 +49,6 @@ export default class NewProjectPlugin extends LitElement {

return [{ actions: [], title: '', derived: true }];
}

private newProjectWizard(): Wizard {
return [
{
Expand Down

0 comments on commit d9a4a0c

Please sign in to comment.