@storybook/addon-notes: support global decorator

Support the global decorator usage supplied in [the README](https://github.com/storybooks/storybook/blob/9f30442098e5350f5ba4872887cf9d1a03146e74/addons/ondevice-notes/README.md#getting-started)
This commit is contained in:
Andrew MacLeay
2019-01-28 15:24:13 -05:00
parent 6f8151b703
commit 140d0dc3e4
2 changed files with 8 additions and 1 deletions
+4
View File
@@ -17,5 +17,9 @@ export type WithNotesOptions = string | {
markdownOptions?: MarkedOptions;
};
// It would be preferable to infer the argument types, but that requires TS v 3.1
// export function withNotes(...args: StoryDecorator extends (...a: infer A) => any ? A : never): ReturnType<StoryDecorator>;
export function withNotes(story: RenderFunction, context: { kind: string, story: string }): ReturnType<StoryDecorator>;
// Less-preferred but still supported:
export function withNotes(options?: WithNotesOptions): StoryDecorator;
export function withMarkdownNotes(markdown: string, options?: MarkedOptions): StoryDecorator;
@@ -1,8 +1,11 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { addDecorator, storiesOf } from '@storybook/react';
import { withNotes, withMarkdownNotes, } from '@storybook/addon-notes';
// New, preferred global registration:
addDecorator(withNotes);
const SIMPLE_MARKDOWN = `
## Markdown for component