feat: docker compose maybe
This commit is contained in:
5
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/additional-svelte-typings.d.ts
generated
vendored
Normal file
5
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/additional-svelte-typings.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare namespace svelteHTML {
|
||||
interface HTMLAttributes {
|
||||
'on:copyComplete'?: () => void;
|
||||
}
|
||||
}
|
10
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/clipboard.d.ts
generated
vendored
Normal file
10
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/clipboard.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
type ClipboardArgs = string | {
|
||||
element: string;
|
||||
} | {
|
||||
input: string;
|
||||
};
|
||||
export declare function clipboard(node: HTMLElement, args: ClipboardArgs): {
|
||||
update(newArgs: ClipboardArgs): void;
|
||||
destroy(): void;
|
||||
} | undefined;
|
||||
export {};
|
64
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/clipboard.js
generated
vendored
Normal file
64
node_modules/@skeletonlabs/skeleton/dist/actions/Clipboard/clipboard.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
export function clipboard(node, args) {
|
||||
if (!window.isSecureContext) {
|
||||
console.error('Clipboard action failed: app not running in secure context, see: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard');
|
||||
return;
|
||||
}
|
||||
const fireCopyCompleteEvent = () => {
|
||||
node.dispatchEvent(new CustomEvent('copyComplete'));
|
||||
};
|
||||
const onClick = () => {
|
||||
// Handle `data-clipboard` target based on object key
|
||||
if (typeof args === 'object') {
|
||||
// Element Inner HTML
|
||||
if ('element' in args) {
|
||||
const element = document.querySelector(`[data-clipboard="${args.element}"]`);
|
||||
if (!element)
|
||||
throw new Error(`Missing HTMLElement with an attribute of [data-clipboard="${args.element}"]`);
|
||||
copyToClipboard(element.innerHTML, 'text/html').then(fireCopyCompleteEvent);
|
||||
return;
|
||||
}
|
||||
// Form Input Value
|
||||
if ('input' in args) {
|
||||
const input = document.querySelector(`[data-clipboard="${args.input}"]`);
|
||||
if (!input)
|
||||
throw new Error(`Missing HTMLInputElement with an attribute of [data-clipboard="${args.input}"]`);
|
||||
copyToClipboard(input.value).then(fireCopyCompleteEvent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Handle everything else.
|
||||
copyToClipboard(args).then(fireCopyCompleteEvent);
|
||||
};
|
||||
// Event Listener
|
||||
node.addEventListener('click', onClick);
|
||||
// Lifecycle
|
||||
return {
|
||||
update(newArgs) {
|
||||
args = newArgs;
|
||||
},
|
||||
destroy() {
|
||||
node.removeEventListener('click', onClick);
|
||||
}
|
||||
};
|
||||
}
|
||||
// Shared copy method
|
||||
async function copyToClipboard(data, mimeType = 'text/plain') {
|
||||
if (navigator.clipboard.write) {
|
||||
await navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
[mimeType]: new Blob([data], {
|
||||
type: mimeType
|
||||
}),
|
||||
['text/plain']: new Blob([data], {
|
||||
type: 'text/plain'
|
||||
})
|
||||
})
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// fallback since .writeText has wider browser support
|
||||
await new Promise((resolve) => {
|
||||
resolve(navigator.clipboard.writeText(String(data)));
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user