@react-native-ohos/react-native-custom-keyboard 1.0.4-rc.3 → 1.1.0-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.
Files changed (39) hide show
  1. package/LICENSE +8 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +4 -8
  4. package/harmony/custom_keyboard/BuildProfile.ets +7 -1
  5. package/harmony/custom_keyboard/Index.ets +6 -2
  6. package/harmony/custom_keyboard/hvigorfile.ts +6 -0
  7. package/harmony/custom_keyboard/oh-package.json5 +1 -1
  8. package/harmony/custom_keyboard/src/main/cpp/CMakeLists.txt +1 -1
  9. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardPackage.cpp +8 -4
  10. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardPackage.h +9 -3
  11. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.cpp +106 -130
  12. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.h +8 -1
  13. package/harmony/custom_keyboard/src/main/cpp/generated/{RNOH/generated/BaseReactNativeCustomKeyboardPackage.h → custom_keyboard/RNOH/generated/BaseReactNativeOhTplReactNativeCustomKeyboardPackage.h} +18 -8
  14. package/harmony/custom_keyboard/src/main/cpp/generated/{RNOH → custom_keyboard/RNOH}/generated/turbo_modules/CustomKeyboardNativeModule.cpp +6 -1
  15. package/harmony/custom_keyboard/src/main/cpp/generated/{RNOH → custom_keyboard/RNOH}/generated/turbo_modules/CustomKeyboardNativeModule.h +6 -1
  16. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/ComponentDescriptors.h +7 -5
  17. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/EventEmitters.cpp +3 -5
  18. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/EventEmitters.h +2 -4
  19. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/Props.cpp +3 -5
  20. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/Props.h +2 -4
  21. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/ShadowNodes.cpp +3 -5
  22. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/ShadowNodes.h +5 -7
  23. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/States.cpp +3 -5
  24. package/harmony/custom_keyboard/src/main/cpp/generated/{react/renderer/components/react_native_custom_keyboard → custom_keyboard/react/renderer/components/custom_keyboard}/States.h +2 -6
  25. package/harmony/custom_keyboard/src/main/ets/{RNCustomKeyboardPackage.ets → RNCustomKeyboardPackage.ts} +2 -2
  26. package/harmony/custom_keyboard/src/main/ets/generated/index.ets +4 -1
  27. package/harmony/custom_keyboard/src/main/ets/generated/ts.ts +4 -1
  28. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/CustomKeyboardNativeModule.ts +6 -2
  29. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/ts.ts +4 -1
  30. package/harmony/custom_keyboard/ts.ts +8 -0
  31. package/harmony/custom_keyboard.har +0 -0
  32. package/index.d.ts +6 -0
  33. package/index.js +4 -3
  34. package/package.json +16 -14
  35. package/src/specs/v2/NativeCustomKeyboard.ts +6 -0
  36. package/OAT.xml +0 -51
  37. package/harmony/custom_keyboard/oh-package-lock.json5 +0 -18
  38. package/harmony/custom_keyboard/ts.ets +0 -2
  39. package/tsconfig.json +0 -13
package/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright © 2025 <copyright holders>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "react-native-custom-keyboard",
4
+ "License": "MIT License",
5
+ "License File": "LICENSE",
6
+ "Version Number": "1.0.3",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/reactnativecn/react-native-custom-keyboard",
9
+ "Description": ""
10
+ }
11
+ ]
package/README.md CHANGED
@@ -1,16 +1,12 @@
1
- # @react-native-ohos/react-native-custom-keyboard
1
+ # react-native-custom-keyboard
2
2
 
3
- 本项目基于 [react-native-custom-keyboard](https://github.com/reactnativecn/react-native-custom-keyboard)@1.0.3
3
+ 本项目基于 [react-native-custom-keyboard](https://github.com/reactnativecn/react-native-custom-keyboard)
4
4
 
5
5
  ## 文档地址 / Documentation URL
6
6
 
7
- [中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-custom-keyboard.md)
7
+ - [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-custom-keyboard.md)
8
8
 
9
- ## Codegen
10
-
11
- 该库已接入 codegen,具体请查阅文档。
12
-
13
- The library has been integrated with codegen. Please refer to the documentation for details.
9
+ - [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-custom-keyboard.md)
14
10
 
15
11
  ## 请悉知 / Acknowledgements
16
12
 
@@ -1,7 +1,13 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  /**
2
8
  * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
9
  */
4
- export const HAR_VERSION = '1.0.3-0.0.2';
10
+ export const HAR_VERSION = '1.0.4-rc.1';
5
11
  export const BUILD_MODE_NAME = 'debug';
6
12
  export const DEBUG = true;
7
13
  export const TARGET_NAME = 'default';
@@ -1,3 +1,7 @@
1
- import { RNCustomKeyboardPackage as CustomKeyboardPackage } from './src/main/ets/RNCustomKeyboardPackage';
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
2
7
  export * from "./ts";
3
- export default CustomKeyboardPackage;
@@ -1,3 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
8
 
3
9
  export default {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-custom-keyboard",
3
- "version": "1.0.4-rc.3",
3
+ "version": "1.1.0-rc.2",
4
4
  "description": "",
5
5
  "main": "Index.ets",
6
6
  "author": "",
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13)
2
2
  set(CMAKE_VERBOSE_MAKEFILE on)
3
3
 
4
4
  set(rnoh_custom_keyboard_package_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
5
- file(GLOB_RECURSE rnoh_custom_keyboard_package_generated_SRC "${rnoh_custom_keyboard_package_generated_dir}/**/*.cpp")
5
+ file(GLOB_RECURSE rnoh_custom_keyboard_package_generated_SRC "${rnoh_custom_keyboard_package_generated_dir}/*.cpp")
6
6
  file(GLOB rnoh_custom_keyboard_package_SRC CONFIGURE_DEPENDS *.cpp)
7
7
  add_library(rnoh_custom_keyboard_package SHARED ${rnoh_custom_keyboard_package_SRC} ${rnoh_custom_keyboard_package_generated_SRC})
8
8
  target_include_directories(rnoh_custom_keyboard_package PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_custom_keyboard_package_generated_dir})
@@ -1,3 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  #include "CustomKeyboardPackage.h"
2
8
  #include "CustomKeyboardTurboModuleSpec.h"
3
9
 
@@ -5,8 +11,7 @@ using namespace facebook;
5
11
  namespace rnoh {
6
12
  class CustomKeyboardTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
7
13
  public:
8
- SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
9
- {
14
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
10
15
  if (name == "CustomKeyboardNativeModule") {
11
16
  return std::make_shared<NativeCustomKeyboardTurboModuleSpecJSI>(ctx, name);
12
17
  }
@@ -14,8 +19,7 @@ public:
14
19
  };
15
20
  };
16
21
 
17
- std::unique_ptr<TurboModuleFactoryDelegate> CustomKeyboardPackage::createTurboModuleFactoryDelegate()
18
- {
22
+ std::unique_ptr<TurboModuleFactoryDelegate> CustomKeyboardPackage::createTurboModuleFactoryDelegate() {
19
23
  return std::make_unique<CustomKeyboardTurboModuleFactoryDelegate>();
20
24
  }
21
25
  } // namespace rnoh
@@ -1,11 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  #pragma once
2
- #include "generated/RNOH/generated/BaseReactNativeCustomKeyboardPackage.h"
8
+ #include "RNOH/Package.h"
3
9
 
4
10
  namespace rnoh {
5
- class CustomKeyboardPackage : public BaseReactNativeCustomKeyboardPackage {
11
+ class CustomKeyboardPackage : public Package {
6
12
 
7
13
  public:
8
- explicit CustomKeyboardPackage(Package::Context ctx) : BaseReactNativeCustomKeyboardPackage(ctx) {}
14
+ CustomKeyboardPackage(Package::Context ctx) : Package(ctx) {}
9
15
 
10
16
  std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
11
17
  };
@@ -1,3 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  // NOTE: This entire file should be codegen'ed.
2
8
  #include "CustomKeyboardTurboModuleSpec.h"
3
9
 
@@ -6,17 +12,15 @@ using namespace facebook;
6
12
 
7
13
  static constexpr double HEIGHT = 216;
8
14
  static constexpr int AVOIDENCE = 0;
9
- static constexpr int START_SURFACE_ID = 45;
10
- static constexpr int CLICK_TARGET_ID = NODE_ON_CLICK + 101;
11
- NativeCustomKeyboardTurboModuleSpecJSI::~NativeCustomKeyboardTurboModuleSpecJSI()
12
- {
13
- for (const UserData *userData : m_userDatas) {
14
- delete userData;
15
- userData = nullptr;
15
+ static constexpr int START_SURFACE_ID=45;
16
+ static constexpr int CLICK_TARGET_ID=NODE_ON_CLICK+101;
17
+ NativeCustomKeyboardTurboModuleSpecJSI::~NativeCustomKeyboardTurboModuleSpecJSI() {
18
+ for (const UserData *userData : m_userDatas) {
19
+ delete userData;
20
+ userData = nullptr;
21
+ }
16
22
  }
17
- }
18
- TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag)
19
- {
23
+ TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag) {
20
24
  auto weakInstance = m_ctx.instance;
21
25
  auto instance = weakInstance.lock();
22
26
  if (!instance) {
@@ -39,8 +43,7 @@ TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag)
39
43
  return textInputNode;
40
44
  }
41
45
 
42
- static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance> weakInstance)
43
- {
46
+ static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance> weakInstance) {
44
47
  auto instance = weakInstance.lock();
45
48
  if (!instance) {
46
49
  return nullptr;
@@ -53,8 +56,7 @@ static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance>
53
56
  }
54
57
 
55
58
  static void getDevicePhycicalPixels(std::shared_ptr<RNInstanceCAPI> instanceCapi, double &width, double &height,
56
- double &scale)
57
- {
59
+ double &scale) {
58
60
  auto turboModule = instanceCapi->getTurboModule("DeviceInfo");
59
61
  auto deviceInfoTurboModule = std::dynamic_pointer_cast<DeviceInfoTurboModule>(turboModule);
60
62
  auto displayMetrics = deviceInfoTurboModule->callSync("getConstants", {});
@@ -67,37 +69,33 @@ static void getDevicePhycicalPixels(std::shared_ptr<RNInstanceCAPI> instanceCapi
67
69
  }
68
70
  }
69
71
 
70
- static void setTextInputUserData(TextInputNode *textInput, UserData *userData)
71
- {
72
+ static void setTextInputUserData(TextInputNode *textInput, UserData *userData) {
72
73
  ArkUI_NodeHandle view = textInput->getArkUINodeHandle();
73
74
  NativeNodeApi::getInstance()->setUserData(view, userData);
74
75
  }
75
76
 
76
- static UserData *getTextInputUserData(TextInputNode *textInput)
77
- {
77
+ static UserData *getTextInputUserData(TextInputNode *textInput) {
78
78
  ArkUI_NodeHandle view = textInput->getArkUINodeHandle();
79
- auto data = (NativeNodeApi::getInstance()->getUserData(view));
79
+ auto data=(NativeNodeApi::getInstance()->getUserData(view));
80
80
  UserData *userData = reinterpret_cast<UserData*>(data);
81
81
  return userData;
82
82
  }
83
83
 
84
- static void getTextSelection(TextInputNode* textInput, int32_t &start, int32_t &end)
85
- {
86
- const ArkUI_AttributeItem* item =
87
- NativeNodeApi::getInstance()->getAttribute(textInput->getArkUINodeHandle(), NODE_TEXT_INPUT_TEXT_SELECTION);
88
- start = item->value[0].i32;
89
- end = item->value[1].i32;
84
+ static void getTextSelection(TextInputNode* textInput, int32_t &start, int32_t &end) {
85
+ const ArkUI_AttributeItem* item =
86
+ NativeNodeApi::getInstance()->getAttribute(textInput->getArkUINodeHandle(), NODE_TEXT_INPUT_TEXT_SELECTION);
87
+ start = item->value[0].i32;
88
+ end = item->value[1].i32;
90
89
  }
91
90
 
92
- static void setCustomKeyboard(TextInputNode *textInput, ArkUI_Node* CustomKeyboard, int32_t const &avoidence)
93
- {
94
- ArkUI_NumberValue value = {.i32 = avoidence};
95
- ArkUI_AttributeItem item{.object=CustomKeyboard, .value = &value, .size = 1};
96
- NativeNodeApi::getInstance()->setAttribute(textInput->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &item);
91
+ static void setCustomKeyboard(TextInputNode *textInput, ArkUI_Node* CustomKeyboard, int32_t const &avoidence){
92
+ ArkUI_NumberValue value = {.i32 = avoidence};
93
+ ArkUI_AttributeItem item{.object=CustomKeyboard,.value=&value,.size=1};
94
+ NativeNodeApi::getInstance()->setAttribute(
95
+ textInput->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &item);
97
96
  }
98
97
 
99
- void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t tag, std::string type)
100
- {
98
+ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t tag, std::string type) {
101
99
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag, type]() {
102
100
  auto edit = getEditById(tag);
103
101
  if (!edit) {
@@ -108,14 +106,10 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
108
106
  return;
109
107
  }
110
108
  static int surfaceID = START_SURFACE_ID;
111
- while (instanceCapi->findComponentInstanceByTag(surfaceID)) {
112
- surfaceID++;
113
- }
109
+ while(instanceCapi->findComponentInstanceByTag(surfaceID)){surfaceID++;}
114
110
  instanceCapi->createSurface(surfaceID, "CustomKeyboard");
115
111
  folly::dynamic initialProps = folly::dynamic::object("tag", tag)("type", type);
116
- double width;
117
- double height;
118
- double scale;
112
+ double width, height, scale;
119
113
  getDevicePhycicalPixels(instanceCapi, width, height, scale);
120
114
  instanceCapi->startSurface(surfaceID, 0.0f, 0.0f, width / scale, HEIGHT, 0.0f, 0.0f, scale, false,
121
115
  std::move(initialProps));
@@ -126,27 +120,28 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
126
120
  ArkUINode &node = comp->getLocalRootArkUINode();
127
121
  ArkUI_NodeHandle uiNode = node.getArkUINodeHandle();
128
122
  //空值 说明edit没有绑定点击事件
129
- if (!getTextInputUserData(edit)) {
130
- NativeNodeApi::getInstance()->registerNodeEvent(edit->getArkUINodeHandle(),
131
- NODE_ON_CLICK, CLICK_TARGET_ID,
132
- edit->getArkUINodeHandle());
133
- auto callback = [](ArkUI_NodeEvent *event) {
123
+ if(!getTextInputUserData(edit)) {
124
+ NativeNodeApi::getInstance()->registerNodeEvent(
125
+ edit->getArkUINodeHandle(), NODE_ON_CLICK, CLICK_TARGET_ID, edit->getArkUINodeHandle());
126
+ auto callback = [](ArkUI_NodeEvent *event) {
134
127
  if (OH_ArkUI_NodeEvent_GetTargetId(event) == CLICK_TARGET_ID) {
135
- //get textInputNode and userData
136
- ArkUI_NodeHandle textNode = OH_ArkUI_NodeEvent_GetNodeHandle(event);
137
- void* data = (NativeNodeApi::getInstance()->getUserData(textNode));
138
- UserData *userData = reinterpret_cast<UserData*>(data);
139
- if (userData && userData->data && userData->enabled == false) {
140
- userData->enabled = true;
141
- //set customkeyboard
142
- ArkUI_NumberValue value = {.i32 = AVOIDENCE};
143
- ArkUI_AttributeItem item{.object=userData->data, .value=&value, .size=1};
144
- NativeNodeApi::getInstance()->setAttribute(textNode, NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &item);
145
- }
146
- }
147
- };
148
- NativeNodeApi::getInstance()->addNodeEventReceiver(edit->getArkUINodeHandle(), callback);
128
+ //get textInputNode and userData
129
+ ArkUI_NodeHandle textNode=OH_ArkUI_NodeEvent_GetNodeHandle(event);
130
+ void* data=(NativeNodeApi::getInstance()->getUserData(textNode));
131
+ UserData *userData = reinterpret_cast<UserData*>(data);
132
+ if (userData && userData->data && userData->enabled == false) {
133
+ userData->enabled = true;
134
+ //set customkeyboard
135
+ ArkUI_NumberValue value = {.i32 = AVOIDENCE};
136
+ ArkUI_AttributeItem item{.object=userData->data,.value=&value,.size=1};
137
+ NativeNodeApi::getInstance()->setAttribute(
138
+ textNode, NODE_TEXT_INPUT_CUSTOM_KEYBOARD, &item);
139
+ }
140
+ }
141
+ };
142
+ NativeNodeApi::getInstance()->addNodeEventReceiver(edit->getArkUINodeHandle(),callback);
149
143
  }
144
+
150
145
  setCustomKeyboard(edit, uiNode, AVOIDENCE);
151
146
  UserData *userData = new UserData({.data = uiNode, .enabled = true});
152
147
  this->m_userDatas.insert(userData);
@@ -154,8 +149,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
154
149
  });
155
150
  }
156
151
 
157
- void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t tag)
158
- {
152
+ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t tag) {
159
153
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
160
154
  auto instanceCapi = getInstanceCapi(this->m_ctx.instance);
161
155
  if (!instanceCapi) {
@@ -165,7 +159,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t
165
159
  edit->setFocusStatus(false);
166
160
  auto error_code =
167
161
  NativeNodeApi::getInstance()->resetAttribute(edit->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD);
168
- if (error_code) {
162
+ if(error_code){
169
163
  DLOG(ERROR)<<"uninstall custom keyboard error"<<std::endl;
170
164
  return;
171
165
  }
@@ -175,8 +169,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t
175
169
  });
176
170
  }
177
171
 
178
- void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_t tag, std::string text)
179
- {
172
+ void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_t tag, std::string text) {
180
173
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag, text]() {
181
174
  TextInputNode *textInputNode = this->getEditById(tag);
182
175
  int start = 0;
@@ -188,8 +181,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_
188
181
  textInputNode->setTextSelection(start+text.size(), start+text.size());
189
182
  });
190
183
  }
191
- void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t tag)
192
- {
184
+ void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t tag) {
193
185
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
194
186
  TextInputNode *textInputNode = this->getEditById(tag);
195
187
  int start = 0;
@@ -207,8 +199,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t
207
199
  }
208
200
  });
209
201
  }
210
- void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t tag)
211
- {
202
+ void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t tag) {
212
203
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
213
204
  TextInputNode *textInputNode = this->getEditById(tag);
214
205
  int start = 0;
@@ -226,8 +217,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t
226
217
  }
227
218
  });
228
219
  }
229
- void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t tag)
230
- {
220
+ void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t tag) {
231
221
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
232
222
  TextInputNode *textInputNode = this->getEditById(tag);
233
223
  int start = 0;
@@ -240,8 +230,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t
240
230
  }
241
231
  });
242
232
  }
243
- void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t tag)
244
- {
233
+ void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t tag) {
245
234
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
246
235
  TextInputNode *textInputNode = this->getEditById(tag);
247
236
  int start = 0;
@@ -256,8 +245,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t
256
245
  });
257
246
  }
258
247
 
259
- void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &rt, int32_t tag)
260
- {
248
+ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &rt, int32_t tag) {
261
249
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
262
250
  auto instanceCapi = getInstanceCapi(this->m_ctx.instance);
263
251
  if (!instanceCapi) {
@@ -267,7 +255,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &
267
255
  edit->setFocusStatus(false);
268
256
  auto error_code =
269
257
  NativeNodeApi::getInstance()->resetAttribute(edit->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD);
270
- if (error_code) {
258
+ if(error_code){
271
259
  DLOG(ERROR)<<"switch system keyboard error"<<std::endl;
272
260
  return;
273
261
  }
@@ -278,113 +266,101 @@ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &
278
266
  }
279
267
 
280
268
  // 各个方法的宿主函数定义
281
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install(jsi::Runtime &rt,
282
- react::TurboModule &turboModule,
283
- const jsi::Value *args, size_t count)
284
- {
269
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install(jsi::Runtime &rt,
270
+ react::TurboModule &turboModule,
271
+ const jsi::Value *args, size_t count) {
285
272
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)
286
273
  ->install(rt, args[0].asNumber(), args[1].asString(rt).utf8(rt));
287
274
  return jsi::Value::undefined();
288
275
  }
289
276
 
290
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall(jsi::Runtime &rt,
291
- react::TurboModule &turboModule,
292
- const jsi::Value *args,
293
- size_t count)
294
- {
277
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall(jsi::Runtime &rt,
278
+ react::TurboModule &turboModule,
279
+ const jsi::Value *args,
280
+ size_t count) {
295
281
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->uninstall(rt, args[0].asNumber());
296
282
  return jsi::Value::undefined();
297
283
  }
298
284
 
299
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText(jsi::Runtime &rt,
300
- react::TurboModule &turboModule,
301
- const jsi::Value *args,
302
- size_t count)
303
- {
285
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText(jsi::Runtime &rt,
286
+ react::TurboModule &turboModule,
287
+ const jsi::Value *args,
288
+ size_t count) {
304
289
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)
305
290
  ->insertText(rt, args[0].asNumber(), args[1].asString(rt).utf8(rt));
306
291
  return jsi::Value::undefined();
307
292
  }
308
293
 
309
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace(jsi::Runtime &rt,
310
- react::TurboModule &turboModule,
311
- const jsi::Value *args,
312
- size_t count)
313
- {
294
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace(jsi::Runtime &rt,
295
+ react::TurboModule &turboModule,
296
+ const jsi::Value *args,
297
+ size_t count) {
314
298
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->backSpace(rt, args[0].asNumber());
315
299
  return jsi::Value::undefined();
316
300
  }
317
301
 
318
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete(jsi::Runtime &rt,
319
- react::TurboModule &turboModule,
320
- const jsi::Value *args, size_t count)
321
- {
302
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete(jsi::Runtime &rt,
303
+ react::TurboModule &turboModule,
304
+ const jsi::Value *args, size_t count) {
322
305
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->doDelete(rt, args[0].asNumber());
323
306
  return jsi::Value::undefined();
324
307
  }
325
308
 
326
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft(jsi::Runtime &rt,
327
- react::TurboModule &turboModule,
328
- const jsi::Value *args, size_t count)
329
- {
309
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft(jsi::Runtime &rt,
310
+ react::TurboModule &turboModule,
311
+ const jsi::Value *args, size_t count) {
330
312
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->moveLeft(rt, args[0].asNumber());
331
313
  return jsi::Value::undefined();
332
314
  }
333
315
 
334
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight(jsi::Runtime &rt,
335
- react::TurboModule &turboModule,
336
- const jsi::Value *args,
337
- size_t count)
338
- {
316
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight(jsi::Runtime &rt,
317
+ react::TurboModule &turboModule,
318
+ const jsi::Value *args,
319
+ size_t count) {
339
320
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->moveRight(rt, args[0].asNumber());
340
321
  return jsi::Value::undefined();
341
322
  }
342
323
 
343
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard(
344
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
345
- {
324
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard(
325
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
346
326
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->switchSystemKeyboard(rt, args[0].asNumber());
347
327
  return jsi::Value::undefined();
348
328
  }
349
329
 
350
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError(
351
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
352
- {
330
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError(
331
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
353
332
  return jsi::Value(static_cast<ArkTSTurboModule &>(turboModule).call(rt, "displayRNOHError", args, count));
354
333
  }
355
334
 
356
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp(
357
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
358
- {
335
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp(
336
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
359
337
  throw std::runtime_error("Exception thrown from C++");
360
338
  }
361
339
 
362
- static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk(
363
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
364
- {
340
+ static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk(
341
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
365
342
  return jsi::Value(static_cast<ArkTSTurboModule &>(turboModule).call(rt, "throwExceptionArk", args, count));
366
343
  }
367
344
 
368
345
  NativeCustomKeyboardTurboModuleSpecJSI::NativeCustomKeyboardTurboModuleSpecJSI(const ArkTSTurboModule::Context ctx,
369
346
  const std::string name)
370
- : ArkTSTurboModule(ctx, name)
371
- {
347
+ : ArkTSTurboModule(ctx, name) {
372
348
  methodMap_ = {};
373
349
 
374
- methodMap_["install"] = MethodMetadata{2, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install};
375
- methodMap_["uninstall"] = MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall};
376
- methodMap_["insertText"] = MethodMetadata{2, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText};
377
- methodMap_["backSpace"] = MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace};
378
- methodMap_["doDelete"] = MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete};
379
- methodMap_["moveLeft"] = MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft};
380
- methodMap_["moveRight"] = MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight};
350
+ methodMap_["install"] = MethodMetadata{2, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install};
351
+ methodMap_["uninstall"] = MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall};
352
+ methodMap_["insertText"] = MethodMetadata{2, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText};
353
+ methodMap_["backSpace"] = MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace};
354
+ methodMap_["doDelete"] = MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete};
355
+ methodMap_["moveLeft"] = MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft};
356
+ methodMap_["moveRight"] = MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight};
381
357
  methodMap_["switchSystemKeyboard"] =
382
- MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard};
358
+ MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard};
383
359
 
384
360
  methodMap_["displayRNOHError"] =
385
- MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError};
361
+ MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError};
386
362
  methodMap_["throwExceptionCpp"] =
387
- MethodMetadata{0, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp};
363
+ MethodMetadata{0, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp};
388
364
  methodMap_["throwExceptionArk"] =
389
- MethodMetadata{0, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk};
365
+ MethodMetadata{0, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk};
390
366
  }
@@ -1,3 +1,10 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+
1
8
  // NOTE: This entire file should be codegen'ed.
2
9
  #pragma once
3
10
 
@@ -11,7 +18,7 @@ using namespace facebook;
11
18
 
12
19
  namespace rnoh {
13
20
 
14
- typedef struct {
21
+ typedef struct{
15
22
  ArkUI_NodeHandle data;
16
23
  bool enabled;
17
24
  }UserData;
@@ -1,5 +1,8 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
3
6
  */
4
7
 
5
8
  #pragma once
@@ -10,7 +13,7 @@
10
13
 
11
14
  namespace rnoh {
12
15
 
13
- class BaseReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
16
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
14
17
  public:
15
18
  SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
16
19
  if (name == "CustomKeyboardNativeModule") {
@@ -20,29 +23,36 @@ class BaseReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate : public Tu
20
23
  };
21
24
  };
22
25
 
23
- class BaseReactNativeCustomKeyboardPackageEventEmitRequestHandler : public EventEmitRequestHandler {
26
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackageEventEmitRequestHandler : public EventEmitRequestHandler {
24
27
  public:
25
28
  void handleEvent(Context const &ctx) override {
26
29
  auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
30
+ auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
31
+
27
32
  if (eventEmitter == nullptr) {
28
33
  return;
29
34
  }
30
35
 
36
+ std::vector<std::string> supportedComponentNames = {
37
+ };
38
+
31
39
  std::vector<std::string> supportedEventNames = {
32
40
  };
33
- if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
41
+
42
+ if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
43
+ std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
34
44
  eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
35
45
  }
36
46
  }
37
47
  };
38
48
 
39
49
 
40
- class BaseReactNativeCustomKeyboardPackage : public Package {
50
+ class BaseReactNativeOhosReactNativeCustomKeyboardPackage : public Package {
41
51
  public:
42
- BaseReactNativeCustomKeyboardPackage(Package::Context ctx) : Package(ctx){};
52
+ BaseReactNativeOhosReactNativeCustomKeyboardPackage(Package::Context ctx) : Package(ctx){};
43
53
 
44
54
  std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
45
- return std::make_unique<BaseReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate>();
55
+ return std::make_unique<BaseReactNativeOhosReactNativeCustomKeyboardPackageTurboModuleFactoryDelegate>();
46
56
  }
47
57
 
48
58
  std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
@@ -57,7 +67,7 @@ class BaseReactNativeCustomKeyboardPackage : public Package {
57
67
 
58
68
  EventEmitRequestHandlers createEventEmitRequestHandlers() override {
59
69
  return {
60
- std::make_shared<BaseReactNativeCustomKeyboardPackageEventEmitRequestHandler>(),
70
+ std::make_shared<BaseReactNativeOhosReactNativeCustomKeyboardPackageEventEmitRequestHandler>(),
61
71
  };
62
72
  }
63
73
  };
@@ -1,5 +1,10 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
3
8
  */
4
9
 
5
10
  #include "CustomKeyboardNativeModule.h"
@@ -1,5 +1,10 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
3
8
  */
4
9
 
5
10
  #pragma once
@@ -10,13 +10,15 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include <react/renderer/components/react_native_custom_keyboard/ShadowNodes.h>
13
+ #include "ShadowNodes.h"
14
14
  #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
15
16
 
16
- namespace facebook {
17
- namespace react {
17
+ namespace facebook::react {
18
18
 
19
19
 
20
20
 
21
- } // namespace react
22
- } // namespace facebook
21
+ void _react_native_ohos_react_native_custom_keyboard_registerComponentDescriptorsFromCodegen(
22
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
23
+
24
+ } // namespace facebook::react
@@ -8,11 +8,9 @@
8
8
  * @generated by codegen project: GenerateEventEmitterCpp.js
9
9
  */
10
10
 
11
- #include <react/renderer/components/react_native_custom_keyboard/EventEmitters.h>
11
+ #include "EventEmitters.h"
12
12
 
13
13
 
14
- namespace facebook {
15
- namespace react {
14
+ namespace facebook::react {
16
15
 
17
- } // namespace react
18
- } // namespace facebook
16
+ } // namespace facebook::react
@@ -12,8 +12,6 @@
12
12
  #include <react/renderer/components/view/ViewEventEmitter.h>
13
13
 
14
14
 
15
- namespace facebook {
16
- namespace react {
15
+ namespace facebook::react {
17
16
 
18
- } // namespace react
19
- } // namespace facebook
17
+ } // namespace facebook::react
@@ -8,14 +8,12 @@
8
8
  * @generated by codegen project: GeneratePropsCpp.js
9
9
  */
10
10
 
11
- #include <react/renderer/components/react_native_custom_keyboard/Props.h>
11
+ #include "Props.h"
12
12
  #include <react/renderer/core/PropsParserContext.h>
13
13
  #include <react/renderer/core/propsConversions.h>
14
14
 
15
- namespace facebook {
16
- namespace react {
15
+ namespace facebook::react {
17
16
 
18
17
 
19
18
 
20
- } // namespace react
21
- } // namespace facebook
19
+ } // namespace facebook::react
@@ -11,10 +11,8 @@
11
11
 
12
12
 
13
13
 
14
- namespace facebook {
15
- namespace react {
14
+ namespace facebook::react {
16
15
 
17
16
 
18
17
 
19
- } // namespace react
20
- } // namespace facebook
18
+ } // namespace facebook::react
@@ -8,12 +8,10 @@
8
8
  * @generated by codegen project: GenerateShadowNodeCpp.js
9
9
  */
10
10
 
11
- #include <react/renderer/components/react_native_custom_keyboard/ShadowNodes.h>
11
+ #include "ShadowNodes.h"
12
12
 
13
- namespace facebook {
14
- namespace react {
13
+ namespace facebook::react {
15
14
 
16
15
 
17
16
 
18
- } // namespace react
19
- } // namespace facebook
17
+ } // namespace facebook::react
@@ -10,16 +10,14 @@
10
10
 
11
11
  #pragma once
12
12
 
13
- #include <react/renderer/components/react_native_custom_keyboard/EventEmitters.h>
14
- #include <react/renderer/components/react_native_custom_keyboard/Props.h>
15
- #include <react/renderer/components/react_native_custom_keyboard/States.h>
13
+ #include "EventEmitters.h"
14
+ #include "Props.h"
15
+ #include "States.h"
16
16
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
17
  #include <jsi/jsi.h>
18
18
 
19
- namespace facebook {
20
- namespace react {
19
+ namespace facebook::react {
21
20
 
22
21
 
23
22
 
24
- } // namespace react
25
- } // namespace facebook
23
+ } // namespace facebook::react
@@ -7,12 +7,10 @@
7
7
  *
8
8
  * @generated by codegen project: GenerateStateCpp.js
9
9
  */
10
- #include <react/renderer/components/react_native_custom_keyboard/States.h>
10
+ #include "States.h"
11
11
 
12
- namespace facebook {
13
- namespace react {
12
+ namespace facebook::react {
14
13
 
15
14
 
16
15
 
17
- } // namespace react
18
- } // namespace facebook
16
+ } // namespace facebook::react
@@ -10,14 +10,10 @@
10
10
 
11
11
  #ifdef ANDROID
12
12
  #include <folly/dynamic.h>
13
- #include <react/renderer/mapbuffer/MapBuffer.h>
14
- #include <react/renderer/mapbuffer/MapBufferBuilder.h>
15
13
  #endif
16
14
 
17
- namespace facebook {
18
- namespace react {
15
+ namespace facebook::react {
19
16
 
20
17
 
21
18
 
22
- } // namespace react
23
- } // namespace facebook
19
+ } // namespace facebook::react
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { RNOHPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony';
25
+ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
26
26
  import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
27
27
  import { TM } from './generated/ts'
28
28
  import { RNCustomKeyboardTurboModule } from './RNCustomKeyboardTurboModule';
@@ -40,7 +40,7 @@ class RNCustomKeyboardTurboModuleFactory extends TurboModulesFactory {
40
40
  }
41
41
  }
42
42
 
43
- export class RNCustomKeyboardPackage extends RNOHPackage {
43
+ export class RNCustomKeyboardPackage extends RNPackage {
44
44
  createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
45
45
  return new RNCustomKeyboardTurboModuleFactory(ctx);
46
46
  }
@@ -1,5 +1,8 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
3
6
  */
4
7
 
5
8
  export * from "./ts"
@@ -1,5 +1,8 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
3
6
  */
4
7
 
5
8
  export * as RNC from "./components/ts"
@@ -1,8 +1,12 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
6
+ *
7
+ * @generatorVersion: 2
3
8
  */
4
9
 
5
- import { Tag } from "@rnoh/react-native-openharmony/ts"
6
10
 
7
11
  export namespace CustomKeyboardNativeModule {
8
12
  export const NAME = 'CustomKeyboardNativeModule' as const
@@ -1,5 +1,8 @@
1
1
  /**
2
- * This code was generated by "react-native codegen-lib-harmony"
2
+ * This code was generated by "react-native codegen-harmony"
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be
5
+ * lost once the code is regenerated.
3
6
  */
4
7
 
5
8
  export * from "./CustomKeyboardNativeModule"
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export * from './src/main/ets/RNCustomKeyboardPackage';
8
+ export * from "./src/main/ets/RNCustomKeyboardTurboModule";
Binary file
package/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  declare namespace RNCustomKeyboard {
2
8
  function install: (tag: number, type: string) => void;
3
9
  function uninstall: (tag: number) => void;
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  'use strict'
2
3
  import React, { Component } from 'react';
3
4
  import { PropTypes } from 'prop-types';
@@ -47,9 +48,9 @@ export class CustomTextInput extends Component {
47
48
  ...TextInput.propTypes,
48
49
  customKeyboardType: PropTypes.string,
49
50
  };
50
- componentDidMount() {
51
+ handleLayout = () => {
51
52
  install(findNodeHandle(this.input), this.props.customKeyboardType);
52
- }
53
+ };
53
54
  componentDidUpdate(newProps) {
54
55
  if (newProps.customKeyboardType !== this.props.customKeyboardType) {
55
56
  install(findNodeHandle(this.input), newProps.customKeyboardType);
@@ -60,6 +61,6 @@ export class CustomTextInput extends Component {
60
61
  };
61
62
  render() {
62
63
  const { customKeyboardType, ...others } = this.props;
63
- return <TextInput {...others} ref={this.onRef} />;
64
+ return <TextInput {...others} ref={this.onRef} onLayout={this.handleLayout}/>;
64
65
  }
65
66
  }
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-custom-keyboard",
3
- "version": "1.0.4-rc.3",
3
+ "version": "1.1.0-rc.2",
4
4
  "description": "",
5
5
  "nativePackage": true,
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-custom-keyboard --cpp-output-path ./harmony/custom_keyboard/src/main/cpp/generated --ets-output-path ./harmony/custom_keyboard/src/main/ets/generated --turbo-modules-spec-paths ./src --arkts-components-spec-paths ./src"
9
+ "test": "echo \"Error: no test specified\" && exit 1"
11
10
  },
12
11
  "repository": {
13
12
  "type": "git"
@@ -26,17 +25,20 @@
26
25
  "devDependencies": {
27
26
  "typescript": "^4.6.2"
28
27
  },
28
+ "files": [
29
+ "src",
30
+ "img",
31
+ "harmony",
32
+ "harmony/custom_keyboard.har",
33
+ "index.d.ts",
34
+ "index.harmony.js",
35
+ "cpp",
36
+ "!lib/typescript/example",
37
+ "!**/__tests__",
38
+ "!**/__fixtures__",
39
+ "!**/__mocks__"
40
+ ],
29
41
  "harmony": {
30
- "alias": "react-native-custom-keyboard",
31
- "autolinking": {
32
- "etsPackageClassName":"CustomKeyboardPackage",
33
- "cppPackageClassName":"CustomKeyboardPackage",
34
- "cmakeLibraryTargetName": "rnoh_custom_keyboard_package",
35
- "ohPackageName": "@react-native-ohos/react-native-custom-keyboard"
36
- }
37
- },
38
- "publishConfig": {
39
- "registry": "https://registry.npmjs.org/",
40
- "access": "public"
42
+ "alias": "react-native-custom-keyboard"
41
43
  }
42
44
  }
@@ -1,3 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
1
7
  import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2
8
  import { TurboModuleRegistry } from 'react-native';
3
9
 
package/OAT.xml DELETED
@@ -1,51 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <configuration>
3
- <oatconfig>
4
- <licensefile>LICENSE</licensefile>
5
- <policylist>
6
- <policy name="projectPolicy" desc="">
7
- <policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
8
- </policy>
9
- <policy name="projectPolicy" desc="">
10
- <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
11
- <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
12
- <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
13
- <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
14
- <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
15
- </policy>
16
- </policylist>
17
- <filefilterlist>
18
- <filefilter name="defaultFilter" desc="Files not to check">
19
-
20
- </filefilter>
21
- <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
22
- <filteritem type="filename" name=".prettierrc.js" desc="工程配置文件,不添加许可证头"/>
23
- <filteritem type="filename" name="LICENSE" desc="许可证说明文件,不添加版权头"/>
24
- <filteritem type="filename" name="babel.config.js" desc="工程配置文件,不添加许可证头"/>
25
- <filteritem type="filename" name="app.plugin.js" desc="工程配置文件,不添加许可证头"/>
26
- <filteritem type="filename" name="*.ts" desc="工程配置文件,不添加许可证头"/>
27
- <filteritem type="filepath" name="harmony/custom_keyboard/gitignore" desc="工程配置文件,不添加许可证头"/>
28
- <filteritem type="filename" name="*.h" desc="工程配置文件,不添加许可证头"/>
29
- <filteritem type="filename" name="*.cpp" desc="工程配置文件,不添加许可证头"/>
30
- <filteritem type="filename" name="*.ets" desc="工程配置文件,不添加许可证头"/>
31
-
32
- </filefilter>
33
- <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
34
- <filteritem type="filepath" name="harmony/custom_keyboard.har" desc="项目打包文件"/>
35
- </filefilter>
36
-
37
- <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
38
- <filteritem type="filename" name=".prettierrc.js" desc="示例工程配置文件,不添加版权头"/>
39
- <filteritem type="filename" name="LICENSE" desc="许可证说明文件,不添加版权头"/>
40
- <filteritem type="filename" name="babel.config.js" desc="示例工程配置文件,不添加版权头"/>
41
- <filteritem type="filename" name="app.plugin.js" desc="示例工程配置文件,不添加版权头"/>
42
- <filteritem type="filename" name="*.cpp" desc="示例工程配置文件,不添加版权头"/>
43
- <filteritem type="filename" name="*.ets" desc="示例工程配置文件,不添加版权头"/>
44
- <filteritem type="filename" name="*.ts" desc="示例工程配置文件,不添加版权头"/>
45
- <filteritem type="filepath" name="harmony/custom_keyboard/gitignore" desc="示例工程配置文件,不添加版权头"/>
46
- <filteritem type="filename" name="*.h" desc="示例工程配置文件,不添加版权头"/>
47
-
48
- </filefilter>
49
- </filefilterlist>
50
- </oatconfig>
51
- </configuration>
@@ -1,18 +0,0 @@
1
- {
2
- "meta": {
3
- "stableOrder": true
4
- },
5
- "lockfileVersion": 3,
6
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7
- "specifiers": {
8
- "@rnoh/react-native-openharmony@../libs/react_native_openharmony.har": "@rnoh/react-native-openharmony@../libs/react_native_openharmony.har"
9
- },
10
- "packages": {
11
- "@rnoh/react-native-openharmony@../libs/react_native_openharmony.har": {
12
- "name": "@react-native-ohos/react-native-openharmony",
13
- "version": "0.72.28",
14
- "resolved": "../libs/react_native_openharmony.har",
15
- "registryType": "local"
16
- }
17
- }
18
- }
@@ -1,2 +0,0 @@
1
- export * from './src/main/ets/RNCustomKeyboardPackage';
2
- export * from "./src/main/ets/RNCustomKeyboardTurboModule";
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "include": ["src/**/*.ts"],
3
- "compilerOptions": {
4
- "target": "es5",
5
- "module": "commonjs",
6
- "strict": true,
7
- "moduleResolution": "node",
8
- "lib": ["es2015", "es2016", "esnext"],
9
- "jsx": "react-native",
10
- "resolveJsonModule": true
11
- },
12
- "exclude": ["node_modules"]
13
- }