@react-native-ohos/clipboard 1.13.3-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/Clipboard.d.ts +159 -0
- package/dist/Clipboard.js +232 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/harmony/clipboard/build-profile.json5 +8 -0
- package/harmony/clipboard/hvigorfile.ts +1 -0
- package/harmony/clipboard/index.ets +26 -0
- package/harmony/clipboard/oh-package.json5 +12 -0
- package/harmony/clipboard/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/clipboard/src/main/cpp/ClipboardPackage.h +58 -0
- package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.cpp +177 -0
- package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.h +39 -0
- package/harmony/clipboard/src/main/ets/ClipboardPackage.ets +47 -0
- package/harmony/clipboard/src/main/ets/Logger.ts +64 -0
- package/harmony/clipboard/src/main/ets/RNCClipboardTurboModule.ts +478 -0
- package/harmony/clipboard/src/main/module.json5 +7 -0
- package/harmony/clipboard/src/main/resources/base/element/string.json +8 -0
- package/harmony/clipboard/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/clipboard/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/clipboard/ts.ets +26 -0
- package/harmony/clipboard.har +0 -0
- package/package.json +81 -0
- package/src/Clipboard.ts +211 -0
- package/src/index.ts +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @react-native-ohos/clipboard
|
|
2
|
+
|
|
3
|
+
This project is based on [@react-native-clipboard/clipboard](https://github.com/react-native-clipboard/clipboard)@1.16.3
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-clipboard-clipboard.md)
|
|
8
|
+
|
|
9
|
+
- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-clipboard-clipboard.md)
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
This library is licensed under [The MIT License (MIT)](https://github.com/react-native-clipboard/clipboard/blob/master/LICENSE)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
4
|
+
*/
|
|
5
|
+
export declare const Clipboard: {
|
|
6
|
+
/**
|
|
7
|
+
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
8
|
+
* ```javascript
|
|
9
|
+
* async _getContent() {
|
|
10
|
+
* var content = await Clipboard.getString();
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
getString(): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* (iOS Only)
|
|
17
|
+
* Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
18
|
+
* ```javascript
|
|
19
|
+
* async _getContent() {
|
|
20
|
+
* var content = await Clipboard.getStrings();
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
getStrings(): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get clipboard image as PNG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
27
|
+
* ```javascript
|
|
28
|
+
* async _getContent() {
|
|
29
|
+
* var content = await Clipboard.getImagePNG();
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
getImagePNG(): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Get clipboard image as JPG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
36
|
+
* ```javascript
|
|
37
|
+
* async _getContent() {
|
|
38
|
+
* var content = await Clipboard.getImageJPG();
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
getImageJPG(): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* (iOS Only)
|
|
45
|
+
* Set content of base64 image type. You can use following code to set clipboard content
|
|
46
|
+
* ```javascript
|
|
47
|
+
* _setContent() {
|
|
48
|
+
* Clipboard.setImage(...);
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
* @param the content to be stored in the clipboard.
|
|
52
|
+
*/
|
|
53
|
+
setImage(content: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* (Android Only)
|
|
56
|
+
* Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
57
|
+
* ```javascript
|
|
58
|
+
* async _getContent() {
|
|
59
|
+
* var content = await Clipboard.getImage();
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
getImage(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Set content of string type. You can use following code to set clipboard content
|
|
66
|
+
* ```javascript
|
|
67
|
+
* _setContent() {
|
|
68
|
+
* Clipboard.setString('hello world');
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
* @param the content to be stored in the clipboard.
|
|
72
|
+
*/
|
|
73
|
+
setString(content: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Set content of string array type. You can use following code to set clipboard content
|
|
76
|
+
* ```javascript
|
|
77
|
+
* _setContent() {
|
|
78
|
+
* Clipboard.setStrings(['hello world', 'second string']);
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
* @param the content to be stored in the clipboard.
|
|
82
|
+
*/
|
|
83
|
+
setStrings(content: string[]): void;
|
|
84
|
+
/**
|
|
85
|
+
* Returns whether the clipboard has content or is empty.
|
|
86
|
+
* This method returns a `Promise`, so you can use following code to get clipboard content
|
|
87
|
+
* ```javascript
|
|
88
|
+
* async _hasContent() {
|
|
89
|
+
* var hasContent = await Clipboard.hasString();
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
hasString(): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Returns whether the clipboard has an image or is empty.
|
|
96
|
+
* This method returns a `Promise`, so you can use following code to check clipboard content
|
|
97
|
+
* ```javascript
|
|
98
|
+
* async _hasContent() {
|
|
99
|
+
* var hasContent = await Clipboard.hasImage();
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
hasImage(): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* (iOS Only)
|
|
106
|
+
* Returns whether the clipboard has a URL content. Can check
|
|
107
|
+
* if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
108
|
+
* This method returns a `Promise`, so you can use following code to check for url content in clipboard.
|
|
109
|
+
* ```javascript
|
|
110
|
+
* async _hasURL() {
|
|
111
|
+
* var hasURL = await Clipboard.hasURL();
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
hasURL(): Promise<boolean> | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* (iOS 14+ Only)
|
|
118
|
+
* Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
|
|
119
|
+
* if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
120
|
+
* This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
|
|
121
|
+
* ```javascript
|
|
122
|
+
* async _hasNumber() {
|
|
123
|
+
* var hasNumber = await Clipboard.hasNumber();
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
hasNumber(): Promise<boolean> | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* (iOS 14+ Only)
|
|
130
|
+
* Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
|
|
131
|
+
* if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
132
|
+
* This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
|
|
133
|
+
* ```javascript
|
|
134
|
+
* async _hasWebURL() {
|
|
135
|
+
* var hasWebURL = await Clipboard.hasWebURL();
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
hasWebURL(): Promise<boolean> | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* (iOS and Android Only)
|
|
142
|
+
* Adds a listener to get notifications when the clipboard has changed.
|
|
143
|
+
* If this is the first listener, turns on clipboard notifications on the native side.
|
|
144
|
+
* It returns EmitterSubscription where you can call "remove" to remove listener
|
|
145
|
+
* ```javascript
|
|
146
|
+
* const listener = () => console.log("changed!");
|
|
147
|
+
* Clipboard.addListener(listener);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
addListener(callback: () => void): EmitterSubscription;
|
|
151
|
+
/**
|
|
152
|
+
* (iOS and Android Only)
|
|
153
|
+
* Removes all previously registered listeners and turns off notifications on the native side.
|
|
154
|
+
* ```javascript
|
|
155
|
+
* Clipboard.removeAllListeners();
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
removeAllListeners(): void;
|
|
159
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Clipboard = void 0;
|
|
27
|
+
var react_native_1 = require("react-native");
|
|
28
|
+
var NativeClipboardModule_1 = __importStar(require("@react-native-clipboard/clipboard/src/NativeClipboardModule"));
|
|
29
|
+
/**
|
|
30
|
+
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
31
|
+
*/
|
|
32
|
+
exports.Clipboard = {
|
|
33
|
+
/**
|
|
34
|
+
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
35
|
+
* ```javascript
|
|
36
|
+
* async _getContent() {
|
|
37
|
+
* var content = await Clipboard.getString();
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
getString: function () {
|
|
42
|
+
return NativeClipboardModule_1.default.getString();
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* (iOS Only)
|
|
46
|
+
* Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
47
|
+
* ```javascript
|
|
48
|
+
* async _getContent() {
|
|
49
|
+
* var content = await Clipboard.getStrings();
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
getStrings: function () {
|
|
54
|
+
return NativeClipboardModule_1.default.getStrings();
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Get clipboard image as PNG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
58
|
+
* ```javascript
|
|
59
|
+
* async _getContent() {
|
|
60
|
+
* var content = await Clipboard.getImagePNG();
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
getImagePNG: function () {
|
|
65
|
+
return NativeClipboardModule_1.default.getImagePNG();
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Get clipboard image as JPG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
69
|
+
* ```javascript
|
|
70
|
+
* async _getContent() {
|
|
71
|
+
* var content = await Clipboard.getImageJPG();
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
getImageJPG: function () {
|
|
76
|
+
return NativeClipboardModule_1.default.getImageJPG();
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* (iOS Only)
|
|
80
|
+
* Set content of base64 image type. You can use following code to set clipboard content
|
|
81
|
+
* ```javascript
|
|
82
|
+
* _setContent() {
|
|
83
|
+
* Clipboard.setImage(...);
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
* @param the content to be stored in the clipboard.
|
|
87
|
+
*/
|
|
88
|
+
setImage: function (content) {
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
|
|
91
|
+
NativeClipboardModule_1.default.setImage(content);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* (Android Only)
|
|
97
|
+
* Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
98
|
+
* ```javascript
|
|
99
|
+
* async _getContent() {
|
|
100
|
+
* var content = await Clipboard.getImage();
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
getImage: function () {
|
|
105
|
+
return NativeClipboardModule_1.default.getImage();
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Set content of string type. You can use following code to set clipboard content
|
|
109
|
+
* ```javascript
|
|
110
|
+
* _setContent() {
|
|
111
|
+
* Clipboard.setString('hello world');
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
* @param the content to be stored in the clipboard.
|
|
115
|
+
*/
|
|
116
|
+
setString: function (content) {
|
|
117
|
+
NativeClipboardModule_1.default.setString(content);
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Set content of string array type. You can use following code to set clipboard content
|
|
121
|
+
* ```javascript
|
|
122
|
+
* _setContent() {
|
|
123
|
+
* Clipboard.setStrings(['hello world', 'second string']);
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
* @param the content to be stored in the clipboard.
|
|
127
|
+
*/
|
|
128
|
+
setStrings: function (content) {
|
|
129
|
+
NativeClipboardModule_1.default.setStrings(content);
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Returns whether the clipboard has content or is empty.
|
|
133
|
+
* This method returns a `Promise`, so you can use following code to get clipboard content
|
|
134
|
+
* ```javascript
|
|
135
|
+
* async _hasContent() {
|
|
136
|
+
* var hasContent = await Clipboard.hasString();
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
hasString: function () {
|
|
141
|
+
return NativeClipboardModule_1.default.hasString();
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Returns whether the clipboard has an image or is empty.
|
|
145
|
+
* This method returns a `Promise`, so you can use following code to check clipboard content
|
|
146
|
+
* ```javascript
|
|
147
|
+
* async _hasContent() {
|
|
148
|
+
* var hasContent = await Clipboard.hasImage();
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
hasImage: function () {
|
|
153
|
+
return NativeClipboardModule_1.default.hasImage();
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* (iOS Only)
|
|
157
|
+
* Returns whether the clipboard has a URL content. Can check
|
|
158
|
+
* if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
159
|
+
* This method returns a `Promise`, so you can use following code to check for url content in clipboard.
|
|
160
|
+
* ```javascript
|
|
161
|
+
* async _hasURL() {
|
|
162
|
+
* var hasURL = await Clipboard.hasURL();
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
hasURL: function () {
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
|
|
169
|
+
return NativeClipboardModule_1.default.hasURL();
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
},
|
|
173
|
+
/**
|
|
174
|
+
* (iOS 14+ Only)
|
|
175
|
+
* Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
|
|
176
|
+
* if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
177
|
+
* This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
|
|
178
|
+
* ```javascript
|
|
179
|
+
* async _hasNumber() {
|
|
180
|
+
* var hasNumber = await Clipboard.hasNumber();
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
hasNumber: function () {
|
|
185
|
+
// @ts-ignore
|
|
186
|
+
if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
|
|
187
|
+
return NativeClipboardModule_1.default.hasNumber();
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* (iOS 14+ Only)
|
|
193
|
+
* Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
|
|
194
|
+
* if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
195
|
+
* This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
|
|
196
|
+
* ```javascript
|
|
197
|
+
* async _hasWebURL() {
|
|
198
|
+
* var hasWebURL = await Clipboard.hasWebURL();
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
hasWebURL: function () {
|
|
203
|
+
// @ts-ignore
|
|
204
|
+
if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
|
|
205
|
+
return NativeClipboardModule_1.default.hasWebURL();
|
|
206
|
+
}
|
|
207
|
+
return;
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* (iOS and Android Only)
|
|
211
|
+
* Adds a listener to get notifications when the clipboard has changed.
|
|
212
|
+
* If this is the first listener, turns on clipboard notifications on the native side.
|
|
213
|
+
* It returns EmitterSubscription where you can call "remove" to remove listener
|
|
214
|
+
* ```javascript
|
|
215
|
+
* const listener = () => console.log("changed!");
|
|
216
|
+
* Clipboard.addListener(listener);
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
addListener: function (callback) {
|
|
220
|
+
return (0, NativeClipboardModule_1.addListener)(callback);
|
|
221
|
+
},
|
|
222
|
+
/**
|
|
223
|
+
* (iOS and Android Only)
|
|
224
|
+
* Removes all previously registered listeners and turns off notifications on the native side.
|
|
225
|
+
* ```javascript
|
|
226
|
+
* Clipboard.removeAllListeners();
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
removeAllListeners: function () {
|
|
230
|
+
(0, NativeClipboardModule_1.removeAllListeners)();
|
|
231
|
+
},
|
|
232
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useClipboard = void 0;
|
|
4
|
+
var Clipboard_1 = require("./Clipboard");
|
|
5
|
+
var useClipboard_1 = require("@react-native-clipboard/clipboard/src/useClipboard");
|
|
6
|
+
Object.defineProperty(exports, "useClipboard", { enumerable: true, get: function () { return useClipboard_1.useClipboard; } });
|
|
7
|
+
exports.default = Clipboard_1.Clipboard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { ClipboardPackage } from './src/main/ets/ClipboardPackage.ets'
|
|
25
|
+
export * from './ts.ets'
|
|
26
|
+
export default ClipboardPackage
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "ISC",
|
|
3
|
+
"types": "",
|
|
4
|
+
"devDependencies": {},
|
|
5
|
+
"name": "@react-native-ohos/clipboard",
|
|
6
|
+
"version": "1.13.3-rc.1",
|
|
7
|
+
"description": "",
|
|
8
|
+
"main": "index.ets",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
file(GLOB rnoh_clipboard_SRC CONFIGURE_DEPENDS *.cpp)
|
|
5
|
+
add_library(rnoh_clipboard SHARED ${rnoh_clipboard_SRC})
|
|
6
|
+
target_include_directories(rnoh_clipboard PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
7
|
+
target_link_libraries(rnoh_clipboard PUBLIC rnoh)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#ifndef CLIPBOARD_PACKAGE_H
|
|
26
|
+
#define CLIPBOARD_PACKAGE_H
|
|
27
|
+
|
|
28
|
+
#include "RNOH/Package.h"
|
|
29
|
+
#include "RNCClipboardTurboModule.h"
|
|
30
|
+
|
|
31
|
+
using namespace rnoh;
|
|
32
|
+
using namespace facebook;
|
|
33
|
+
|
|
34
|
+
class ClipboardTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
35
|
+
public:
|
|
36
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
|
|
37
|
+
{
|
|
38
|
+
if (name == "RNCClipboard") {
|
|
39
|
+
return std::make_shared<RNCClipboardTurboModule>(ctx, name);
|
|
40
|
+
}
|
|
41
|
+
return nullptr;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
namespace rnoh {
|
|
46
|
+
|
|
47
|
+
class ClipboardPackage : public Package {
|
|
48
|
+
public:
|
|
49
|
+
ClipboardPackage(Package::Context ctx) : Package(ctx) {}
|
|
50
|
+
|
|
51
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override
|
|
52
|
+
{
|
|
53
|
+
return std::make_unique<ClipboardTurboModuleFactoryDelegate>();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
} // namespace rnoh
|
|
57
|
+
|
|
58
|
+
#endif
|