Automatically selecting a file for importing styles

I am working on a plugin that requires some specially-configured table, cell and paragraph styles to be defined. I’d like to add a button that automatically loads some starter styles into the application.

My plugin dist/ contains a starterStyles.indd file which contains the styles I’d like to load with app.importStyles().

How can I grab this file as a File object and pass it into importStyles()?
I’ve tried fs.readFile() which returns an ArrayBuffer, and fs.getFileForOpening() will prompt the user, which I don’t want.

Any advice is appreciated!

Ugly typecast, but got it!

async function loadStarterStyles() {
  const folder = await fs.getPluginFolder();
  const entry = await folder.getEntry("starterStyles.indd");
    entry as unknown as File,
  console.log("import done!");
1 Like