Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copy button copying outdated snippet #18888

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/frameworks/vue3-vite/preset.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
console.log('vue3-vite preset!')
console.log('vue3-vite preset!');
module.exports = require('./dist/preset');
7 changes: 3 additions & 4 deletions code/lib/builder-manager/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] },
Expand Down
4 changes: 3 additions & 1 deletion code/lib/builder-vite/src/codegen-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions code/lib/components/src/syntaxhighlighter/syntaxhighlighter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only real change.. everything else is just formatting

);
const renderer = wrapRenderer(rest.renderer, showLineNumbers);

return (
Expand Down