Node Webkit -Save As dialog with multiple option on "Save as Type" field

Viewed 88

Using Node Webkit, is it possible to create save as with multiple option of the file format?

Desired result is something like this : Desired result is something like this:

With native NW at most I can only display two options. The first option is the pattern written in the 'accept' attribute, and an auto generated "All files (.)" Option.

What I need is more than two options in the Save As Type field.

Is there a way to achieve this?

1 Answers

What you will have to do is to give different 'description' and 'accept' of each option you want to show. This way the saveAs dialog will show you the options and you can save your file with that source.

You can use showSaveFilePicker.

async function saveFile () {
  const result = await window.showSaveFilePicker({
    types: [
      {
        description: 'Web Page, complete(*.htm;*.html)',
        accept: {
          'file/*':['.html']
        }
      },
      {
        description: 'Web Page, complete(*.htm;*.html)',
        accept: {
          'file/*': ['.html'],
        }
      },
      {
        description: 'Web Page, HTML only(*.htm,*.html)',
        accept: {
          'file/*': ['.html'],
        }
      },
      {
        description: 'Text File (*.text,*.text) HTML only(*.htm,*.html)',
        accept: {
          'file/*': ['.txt'],
        }
      }
    ]
  });
  return result;
}
Related