Merge pull request #28305 from 64BitAsura/next

Angular: Allow format configuration of custom source preview
This commit is contained in:
Valentin Palkovic 2024-07-03 12:41:02 +02:00 committed by GitHub
commit 5196fdffc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,14 +32,20 @@ export const sourceDecorator = (
const channel = addons.getChannel();
const { props, template, userDefinedTemplate } = story;
const { component, argTypes } = context;
const { component, argTypes, parameters } = context;
let toEmit: string;
useEffect(() => {
if (toEmit) {
const { id, unmappedArgs } = context;
channel.emit(SNIPPET_RENDERED, { id, args: unmappedArgs, source: toEmit, format: 'angular' });
const format = parameters?.docs?.source?.format ?? true;
channel.emit(SNIPPET_RENDERED, {
id,
args: unmappedArgs,
source: toEmit,
format: format === true ? 'angular' : format,
});
}
});