@react-native-ohos/clipboard 1.16.3-rc.1 → 1.16.3-rc.2
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 +20 -20
- package/README.OpenSource +10 -10
- package/README.md +13 -13
- package/RNCClipboard.podspec +37 -37
- package/harmony/clipboard/LICENSE +20 -20
- package/harmony/clipboard/NOTICE +32 -32
- package/harmony/clipboard/OAT.xml +37 -37
- package/harmony/clipboard/README.OpenSource +10 -10
- package/harmony/clipboard/README.md +307 -307
- package/harmony/clipboard/build-profile.json5 +7 -7
- package/harmony/clipboard/hvigorfile.ts +1 -1
- package/harmony/clipboard/index.ets +24 -24
- package/harmony/clipboard/oh-package.json5 +12 -12
- package/harmony/clipboard/src/main/cpp/CMakeLists.txt +6 -6
- package/harmony/clipboard/src/main/cpp/ClipboardPackage.h +57 -57
- package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.cpp +197 -197
- package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.h +38 -38
- package/harmony/clipboard/src/main/ets/ClipboardPackage.ts +45 -45
- package/harmony/clipboard/src/main/ets/Logger.ts +63 -63
- package/harmony/clipboard/src/main/ets/RNCClipboardTurboModule.ts +480 -481
- package/harmony/clipboard/src/main/module.json5 +6 -6
- package/harmony/clipboard/src/main/resources/base/element/string.json +7 -7
- package/harmony/clipboard/src/main/resources/en_US/element/string.json +7 -7
- package/harmony/clipboard/src/main/resources/zh_CN/element/string.json +7 -7
- package/harmony/clipboard/ts.ts +25 -25
- package/harmony/clipboard.har +0 -0
- package/package.json +90 -90
- package/src/Clipboard.ts +211 -211
- package/src/index.ts +3 -3
package/src/Clipboard.ts
CHANGED
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
import { type EmitterSubscription, Platform } from "react-native";
|
|
2
|
-
import NativeClipboard, {
|
|
3
|
-
addListener,
|
|
4
|
-
removeAllListeners,
|
|
5
|
-
} from '@react-native-clipboard/clipboard/src/NativeClipboardModule';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
9
|
-
*/
|
|
10
|
-
export const Clipboard = {
|
|
11
|
-
/**
|
|
12
|
-
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
13
|
-
* ```javascript
|
|
14
|
-
* async _getContent() {
|
|
15
|
-
* var content = await Clipboard.getString();
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
getString(): Promise<string> {
|
|
20
|
-
return NativeClipboard.getString();
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* (iOS Only)
|
|
24
|
-
* Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
25
|
-
* ```javascript
|
|
26
|
-
* async _getContent() {
|
|
27
|
-
* var content = await Clipboard.getStrings();
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
getStrings(): Promise<string[]> {
|
|
32
|
-
return NativeClipboard.getStrings();
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Get clipboard image as PNG 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.getImagePNG();
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
getImagePNG(): Promise<string> {
|
|
43
|
-
return NativeClipboard.getImagePNG();
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Get clipboard image as JPG in base64, 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.getImageJPG();
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
getImageJPG(): Promise<string> {
|
|
54
|
-
return NativeClipboard.getImageJPG();
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* (iOS Only)
|
|
58
|
-
* Set content of base64 image type. You can use following code to set clipboard content
|
|
59
|
-
* ```javascript
|
|
60
|
-
* _setContent() {
|
|
61
|
-
* Clipboard.setImage(...);
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
* @param the content to be stored in the clipboard.
|
|
65
|
-
*/
|
|
66
|
-
setImage(content: string) {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
69
|
-
NativeClipboard.setImage(content);
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* (iOS and Android Only)
|
|
75
|
-
* Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
76
|
-
* ```javascript
|
|
77
|
-
* async _getContent() {
|
|
78
|
-
* var content = await Clipboard.getImage();
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
getImage(): Promise<string> {
|
|
83
|
-
return NativeClipboard.getImage();
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* Set content of string type. You can use following code to set clipboard content
|
|
87
|
-
* ```javascript
|
|
88
|
-
* _setContent() {
|
|
89
|
-
* Clipboard.setString('hello world');
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
* @param the content to be stored in the clipboard.
|
|
93
|
-
*/
|
|
94
|
-
setString(content: string) {
|
|
95
|
-
NativeClipboard.setString(content);
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* Set content of string array type. You can use following code to set clipboard content
|
|
99
|
-
* ```javascript
|
|
100
|
-
* _setContent() {
|
|
101
|
-
* Clipboard.setStrings(['hello world', 'second string']);
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
* @param the content to be stored in the clipboard.
|
|
105
|
-
*/
|
|
106
|
-
setStrings(content: string[]) {
|
|
107
|
-
NativeClipboard.setStrings(content);
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Returns whether the clipboard has content or is empty.
|
|
111
|
-
* This method returns a `Promise`, so you can use following code to get clipboard content
|
|
112
|
-
* ```javascript
|
|
113
|
-
* async _hasContent() {
|
|
114
|
-
* var hasContent = await Clipboard.hasString();
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
hasString() {
|
|
119
|
-
return NativeClipboard.hasString();
|
|
120
|
-
},
|
|
121
|
-
/**
|
|
122
|
-
* Returns whether the clipboard has an image or is empty.
|
|
123
|
-
* This method returns a `Promise`, so you can use following code to check clipboard content
|
|
124
|
-
* ```javascript
|
|
125
|
-
* async _hasContent() {
|
|
126
|
-
* var hasContent = await Clipboard.hasImage();
|
|
127
|
-
* }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
hasImage() {
|
|
131
|
-
return NativeClipboard.hasImage();
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* (iOS Only)
|
|
135
|
-
* Returns whether the clipboard has a URL content. Can check
|
|
136
|
-
* if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
137
|
-
* This method returns a `Promise`, so you can use following code to check for url content in clipboard.
|
|
138
|
-
* ```javascript
|
|
139
|
-
* async _hasURL() {
|
|
140
|
-
* var hasURL = await Clipboard.hasURL();
|
|
141
|
-
* }
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
hasURL() {
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
147
|
-
return NativeClipboard.hasURL();
|
|
148
|
-
}
|
|
149
|
-
return;
|
|
150
|
-
},
|
|
151
|
-
/**
|
|
152
|
-
* (iOS 14+ Only)
|
|
153
|
-
* Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
|
|
154
|
-
* if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
155
|
-
* This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
|
|
156
|
-
* ```javascript
|
|
157
|
-
* async _hasNumber() {
|
|
158
|
-
* var hasNumber = await Clipboard.hasNumber();
|
|
159
|
-
* }
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
hasNumber() {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
165
|
-
return NativeClipboard.hasNumber();
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
},
|
|
169
|
-
/**
|
|
170
|
-
* (iOS 14+ Only)
|
|
171
|
-
* Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
|
|
172
|
-
* if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
173
|
-
* This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
|
|
174
|
-
* ```javascript
|
|
175
|
-
* async _hasWebURL() {
|
|
176
|
-
* var hasWebURL = await Clipboard.hasWebURL();
|
|
177
|
-
* }
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
hasWebURL() {
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
183
|
-
return NativeClipboard.hasWebURL();
|
|
184
|
-
}
|
|
185
|
-
return;
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* (iOS and Android Only)
|
|
189
|
-
* Adds a listener to get notifications when the clipboard has changed.
|
|
190
|
-
* If this is the first listener, turns on clipboard notifications on the native side.
|
|
191
|
-
* It returns EmitterSubscription where you can call "remove" to remove listener
|
|
192
|
-
* ```javascript
|
|
193
|
-
* const listener = () => console.log("changed!");
|
|
194
|
-
* Clipboard.addListener(listener);
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
addListener(callback: () => void): EmitterSubscription {
|
|
198
|
-
return addListener(callback);
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* (iOS and Android Only)
|
|
203
|
-
* Removes all previously registered listeners and turns off notifications on the native side.
|
|
204
|
-
* ```javascript
|
|
205
|
-
* Clipboard.removeAllListeners();
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
removeAllListeners() {
|
|
209
|
-
removeAllListeners();
|
|
210
|
-
},
|
|
211
|
-
};
|
|
1
|
+
import { type EmitterSubscription, Platform } from "react-native";
|
|
2
|
+
import NativeClipboard, {
|
|
3
|
+
addListener,
|
|
4
|
+
removeAllListeners,
|
|
5
|
+
} from '@react-native-clipboard/clipboard/src/NativeClipboardModule';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
9
|
+
*/
|
|
10
|
+
export const Clipboard = {
|
|
11
|
+
/**
|
|
12
|
+
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
13
|
+
* ```javascript
|
|
14
|
+
* async _getContent() {
|
|
15
|
+
* var content = await Clipboard.getString();
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
getString(): Promise<string> {
|
|
20
|
+
return NativeClipboard.getString();
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* (iOS Only)
|
|
24
|
+
* Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
25
|
+
* ```javascript
|
|
26
|
+
* async _getContent() {
|
|
27
|
+
* var content = await Clipboard.getStrings();
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
getStrings(): Promise<string[]> {
|
|
32
|
+
return NativeClipboard.getStrings();
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Get clipboard image as PNG 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.getImagePNG();
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
getImagePNG(): Promise<string> {
|
|
43
|
+
return NativeClipboard.getImagePNG();
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Get clipboard image as JPG in base64, 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.getImageJPG();
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
getImageJPG(): Promise<string> {
|
|
54
|
+
return NativeClipboard.getImageJPG();
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* (iOS Only)
|
|
58
|
+
* Set content of base64 image type. You can use following code to set clipboard content
|
|
59
|
+
* ```javascript
|
|
60
|
+
* _setContent() {
|
|
61
|
+
* Clipboard.setImage(...);
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
* @param the content to be stored in the clipboard.
|
|
65
|
+
*/
|
|
66
|
+
setImage(content: string) {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
69
|
+
NativeClipboard.setImage(content);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* (iOS and Android Only)
|
|
75
|
+
* Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
|
|
76
|
+
* ```javascript
|
|
77
|
+
* async _getContent() {
|
|
78
|
+
* var content = await Clipboard.getImage();
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getImage(): Promise<string> {
|
|
83
|
+
return NativeClipboard.getImage();
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Set content of string type. You can use following code to set clipboard content
|
|
87
|
+
* ```javascript
|
|
88
|
+
* _setContent() {
|
|
89
|
+
* Clipboard.setString('hello world');
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
* @param the content to be stored in the clipboard.
|
|
93
|
+
*/
|
|
94
|
+
setString(content: string) {
|
|
95
|
+
NativeClipboard.setString(content);
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* Set content of string array type. You can use following code to set clipboard content
|
|
99
|
+
* ```javascript
|
|
100
|
+
* _setContent() {
|
|
101
|
+
* Clipboard.setStrings(['hello world', 'second string']);
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
* @param the content to be stored in the clipboard.
|
|
105
|
+
*/
|
|
106
|
+
setStrings(content: string[]) {
|
|
107
|
+
NativeClipboard.setStrings(content);
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Returns whether the clipboard has content or is empty.
|
|
111
|
+
* This method returns a `Promise`, so you can use following code to get clipboard content
|
|
112
|
+
* ```javascript
|
|
113
|
+
* async _hasContent() {
|
|
114
|
+
* var hasContent = await Clipboard.hasString();
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
hasString() {
|
|
119
|
+
return NativeClipboard.hasString();
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* Returns whether the clipboard has an image or is empty.
|
|
123
|
+
* This method returns a `Promise`, so you can use following code to check clipboard content
|
|
124
|
+
* ```javascript
|
|
125
|
+
* async _hasContent() {
|
|
126
|
+
* var hasContent = await Clipboard.hasImage();
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
hasImage() {
|
|
131
|
+
return NativeClipboard.hasImage();
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* (iOS Only)
|
|
135
|
+
* Returns whether the clipboard has a URL content. Can check
|
|
136
|
+
* if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
137
|
+
* This method returns a `Promise`, so you can use following code to check for url content in clipboard.
|
|
138
|
+
* ```javascript
|
|
139
|
+
* async _hasURL() {
|
|
140
|
+
* var hasURL = await Clipboard.hasURL();
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
hasURL() {
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
147
|
+
return NativeClipboard.hasURL();
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* (iOS 14+ Only)
|
|
153
|
+
* Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
|
|
154
|
+
* if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
155
|
+
* This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
|
|
156
|
+
* ```javascript
|
|
157
|
+
* async _hasNumber() {
|
|
158
|
+
* var hasNumber = await Clipboard.hasNumber();
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
hasNumber() {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
165
|
+
return NativeClipboard.hasNumber();
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* (iOS 14+ Only)
|
|
171
|
+
* Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
|
|
172
|
+
* if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
|
|
173
|
+
* This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
|
|
174
|
+
* ```javascript
|
|
175
|
+
* async _hasWebURL() {
|
|
176
|
+
* var hasWebURL = await Clipboard.hasWebURL();
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
hasWebURL() {
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
|
|
183
|
+
return NativeClipboard.hasWebURL();
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* (iOS and Android Only)
|
|
189
|
+
* Adds a listener to get notifications when the clipboard has changed.
|
|
190
|
+
* If this is the first listener, turns on clipboard notifications on the native side.
|
|
191
|
+
* It returns EmitterSubscription where you can call "remove" to remove listener
|
|
192
|
+
* ```javascript
|
|
193
|
+
* const listener = () => console.log("changed!");
|
|
194
|
+
* Clipboard.addListener(listener);
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
addListener(callback: () => void): EmitterSubscription {
|
|
198
|
+
return addListener(callback);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* (iOS and Android Only)
|
|
203
|
+
* Removes all previously registered listeners and turns off notifications on the native side.
|
|
204
|
+
* ```javascript
|
|
205
|
+
* Clipboard.removeAllListeners();
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
removeAllListeners() {
|
|
209
|
+
removeAllListeners();
|
|
210
|
+
},
|
|
211
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Clipboard } from "./Clipboard";
|
|
2
|
-
export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
|
|
3
|
-
export default Clipboard;
|
|
1
|
+
import { Clipboard } from "./Clipboard";
|
|
2
|
+
export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
|
|
3
|
+
export default Clipboard;
|