naver / storybook-addon-preview

Storybook Addon Preview can show user selected knobs in various framework code in Storybook
https://naver.github.io/egjs-infinitegrid/storybook/
MIT License
66 stars 10 forks source link

feat: add globals, format #43 #44 #45

Closed daybrush closed 1 year ago

daybrush commented 1 year ago

43 #44

ryuran commented 1 year ago

Tested storybook-addon-preview@2.3.0-beta.1 I set this formater:

 previewFormatter: (format, code) => {
    if (format) {
      return prettier.format(removeEmptyLines(code), {
        parser: "html",
        plugins: [
          htmlParser,
        ],
      });
    }
    return code;
  },

where removeEmptyLine is :

removeEmptyLines = (template) =>  template.trim().replace(/(\r\n|\n|\r)/gm, '\n').replace(/\n\s*\n/gm, '\n');
daybrush commented 1 year ago

@ryuran

Are there any problems using it?

I think I will release it like this.

ryuran commented 1 year ago

Non problem using it. I tested globals with knobs and with args. It works as expected