UNPKG

1.93 kBTypeScriptView Raw
1import { Observable } from 'rxjs';
2import { ClipboardParams, IClipboardResponse } from './interface';
3/**
4 * The following code is heavily copied from https://github.com/zenorocha/clipboard.js
5 */
6export declare class ClipboardService {
7 document: any;
8 private window;
9 private copySubject;
10 copyResponse$: Observable<IClipboardResponse>;
11 private tempTextArea;
12 private config;
13 constructor(document: any, window: any);
14 configure(config: ClipboardParams): void;
15 copy(content: string): void;
16 get isSupported(): boolean;
17 isTargetValid(element: HTMLInputElement | HTMLTextAreaElement): boolean;
18 /**
19 * Attempts to copy from an input `targetElm`
20 */
21 copyFromInputElement(targetElm: HTMLInputElement | HTMLTextAreaElement, isFocus?: boolean): boolean;
22 /**
23 * This is a hack for IE11 to return `true` even if copy fails.
24 */
25 isCopySuccessInIE11(): boolean;
26 /**
27 * Creates a fake textarea element, sets its value from `text` property,
28 * and makes a selection on it.
29 */
30 copyFromContent(content: string, container?: HTMLElement): boolean;
31 /**
32 * Remove temporary textarea if any exists.
33 */
34 destroy(container?: HTMLElement): void;
35 /**
36 * Select the target html input element.
37 */
38 private selectTarget;
39 private copyText;
40 /**
41 * Moves focus away from `target` and back to the trigger, removes current selection.
42 */
43 private clearSelection;
44 /**
45 * Creates a fake textarea for copy command.
46 */
47 private createTempTextArea;
48 /**
49 * Pushes copy operation response to copySubject, to provide global access
50 * to the response.
51 */
52 pushCopyResponse(response: IClipboardResponse): void;
53 /**
54 * @deprecated use pushCopyResponse instead.
55 */
56 pushCopyReponse(response: IClipboardResponse): void;
57}