Remove clipboard-copy dependency from CodeSnippet, CopyButton (#726)

* chore(deps): remove clipboard-copy

* feat: add copy prop, use navigator.clipboard API

* docs: add clipboard-copy back to docsite for more browser support

* docs(component-api): use outbound link

* docs: add override/prevent copy examples
This commit is contained in:
Eric Liu 2021-07-05 12:12:28 -07:00 committed by GitHub
commit 921c3e121a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 163 additions and 68 deletions

View file

@ -15,6 +15,12 @@ export interface CodeSnippetProps {
*/
code?: string;
/**
* Override the default copy behavior of using the navigator.clipboard.writeText API to copy text
* @default async (code) => { try { await navigator.clipboard.writeText(code); } catch (e) { console.log(e); } }
*/
copy?: (code: string) => void;
/**
* Set to `true` to expand a multi-line code snippet (type="multi")
* @default false

View file

@ -13,6 +13,12 @@ export interface CopyButtonProps extends CopyProps {
* Specify the text to copy
*/
text?: string;
/**
* Override the default copy behavior of using the navigator.clipboard.writeText API to copy text
* @default async (text) => { try { await navigator.clipboard.writeText(text); } catch (e) { console.log(e); } }
*/
copy?: (text: string) => void;
}
export default class CopyButton extends SvelteComponentTyped<