Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Allow .fsd file creation #1586

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading