-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclipboard.js
More file actions
42 lines (41 loc) · 1.09 KB
/
clipboard.js
File metadata and controls
42 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Concrete command to copy text
var Copy = /** @class */ (function () {
function Copy(clipboard) {
this.clipboard = clipboard;
}
Copy.prototype.execute = function (text) {
this.clipboard.copy(text);
};
return Copy;
}());
// Concrete command to paste text
var Paste = /** @class */ (function () {
function Paste(clipboard) {
this.clipboard = clipboard;
}
Paste.prototype.execute = function () {
this.clipboard.paste();
};
return Paste;
}());
var TextClipboard = /** @class */ (function () {
function TextClipboard() {
}
TextClipboard.prototype.copy = function (text) {
console.log("Clipboard: Copying ...");
this.data = text;
};
TextClipboard.prototype.paste = function () {
console.log("Clipboard: Pasting ... \n".concat(this.data));
};
return TextClipboard;
}());
// Client code
var clipboard = new TextClipboard();
var copy = new Copy(clipboard);
var paste = new Paste(clipboard);
console.log('Enter text to copy: Hello World!');
copy.execute('Hello World!');
paste.execute();
/* OUTPUT
*/