1 | const dataTypes = [
|
2 | "text/plain",
|
3 | "text/html"
|
4 | ];
|
5 |
|
6 |
|
7 | var warnOrLog = function() {
|
8 | (console.warn || console.log).call(arguments);
|
9 | };
|
10 | var warn = warnOrLog.bind(console, "[clipboard-polyfill]");
|
11 | var showWarnings = true;
|
12 | export function suppressDTWarnings() {
|
13 | showWarnings = false;
|
14 | }
|
15 |
|
16 | export class DT {
|
17 | private m: {[key:string]: string} = {};
|
18 |
|
19 | public setData(type: string, value: string): void {
|
20 | if (showWarnings && dataTypes.indexOf(type) === -1) {
|
21 | warn("Unknown data type: " + type, "Call clipboard.suppressWarnings() "+
|
22 | "to suppress this warning.");
|
23 | }
|
24 |
|
25 | this.m[type] = value;
|
26 | }
|
27 |
|
28 | public getData(type: string): string | undefined {
|
29 | return this.m[type];
|
30 | }
|
31 |
|
32 |
|
33 | public forEach(f: (value: string, key: string) => void): void {
|
34 | for (var k in this.m) {
|
35 | f(this.m[k], k);
|
36 | }
|
37 | }
|
38 | }
|