mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
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:
parent
6ed4aaa86e
commit
921c3e121a
19 changed files with 163 additions and 68 deletions
|
@ -13,6 +13,18 @@
|
|||
*/
|
||||
export let code = undefined;
|
||||
|
||||
/**
|
||||
* Override the default copy behavior of using the navigator.clipboard.writeText API to copy text
|
||||
* @type {(code: string) => void}
|
||||
*/
|
||||
export let copy = async (code) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
/** Set to `true` to expand a multi-line code snippet (type="multi") */
|
||||
export let expanded = false;
|
||||
|
||||
|
@ -77,7 +89,6 @@
|
|||
export let ref = null;
|
||||
|
||||
import { createEventDispatcher, tick } from "svelte";
|
||||
import copy from "clipboard-copy";
|
||||
import ChevronDown16 from "carbon-icons-svelte/lib/ChevronDown16/ChevronDown16.svelte";
|
||||
import Button from "../Button/Button.svelte";
|
||||
import Copy from "../Copy/Copy.svelte";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue