mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
Merge pull request #18888 from storybookjs/pocka/fix/18829-outdated-snippet-copied
Fix copy button copying outdated snippet
This commit is contained in:
commit
ae618647c1
@ -1,2 +1,2 @@
|
||||
console.log('vue3-vite preset!')
|
||||
console.log('vue3-vite preset!');
|
||||
module.exports = require('./dist/preset');
|
||||
|
@ -7,10 +7,9 @@ export interface Stats {
|
||||
toJson: () => any;
|
||||
}
|
||||
|
||||
export type WithRequiredProperty<Type, Key extends keyof Type> = Type &
|
||||
{
|
||||
[Property in Key]-?: Type[Property];
|
||||
};
|
||||
export type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
|
||||
[Property in Key]-?: Type[Property];
|
||||
};
|
||||
|
||||
export type ManagerBuilder = Builder<
|
||||
WithRequiredProperty<BuildOptions, 'outdir'> & { entryPoints: string[] },
|
||||
|
@ -6,7 +6,9 @@ import type { ExtendedOptions } from './types';
|
||||
import { listStories } from './list-stories';
|
||||
|
||||
const absoluteFilesToImport = (files: string[], name: string) =>
|
||||
files.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'/@fs/${normalizePath(el)}'`).join('\n');
|
||||
files
|
||||
.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'/@fs/${normalizePath(el)}'`)
|
||||
.join('\n');
|
||||
|
||||
export async function generateVirtualStoryEntryCode(options: ExtendedOptions) {
|
||||
const storyEntries = await listStories(options);
|
||||
|
@ -218,15 +218,18 @@ export const SyntaxHighlighter: FC<SyntaxHighlighterProps> = ({
|
||||
const highlightableCode = formatter ? formatter(format, children) : children.trim();
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const onClick = useCallback((e: MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
copyToClipboard(highlightableCode)
|
||||
.then(() => {
|
||||
setCopied(true);
|
||||
globalWindow.setTimeout(() => setCopied(false), 1500);
|
||||
})
|
||||
.catch(logger.error);
|
||||
}, []);
|
||||
const onClick = useCallback(
|
||||
(e: MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
copyToClipboard(highlightableCode)
|
||||
.then(() => {
|
||||
setCopied(true);
|
||||
globalWindow.setTimeout(() => setCopied(false), 1500);
|
||||
})
|
||||
.catch(logger.error);
|
||||
},
|
||||
[highlightableCode]
|
||||
);
|
||||
const renderer = wrapRenderer(rest.renderer, showLineNumbers);
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user