@react-native-ohos/react-native-custom-keyboard 1.0.4-rc.1 → 1.0.4-rc.3

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 (41) hide show
  1. package/OAT.xml +51 -0
  2. package/README.md +8 -4
  3. package/harmony/custom_keyboard/BuildProfile.ets +1 -7
  4. package/harmony/custom_keyboard/Index.ets +2 -6
  5. package/harmony/custom_keyboard/hvigorfile.ts +0 -6
  6. package/harmony/custom_keyboard/oh-package-lock.json5 +18 -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 +4 -8
  10. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardPackage.h +3 -9
  11. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.cpp +130 -106
  12. package/harmony/custom_keyboard/src/main/cpp/CustomKeyboardTurboModuleSpec.h +1 -8
  13. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/RNOH/generated/BaseReactNativeOhTplReactNativeCustomKeyboardPackage.h → RNOH/generated/BaseReactNativeCustomKeyboardPackage.h} +65 -75
  14. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/RNOH → RNOH}/generated/turbo_modules/CustomKeyboardNativeModule.cpp +23 -28
  15. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/RNOH → RNOH}/generated/turbo_modules/CustomKeyboardNativeModule.h +16 -21
  16. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/ComponentDescriptors.h +22 -24
  17. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/EventEmitters.cpp +18 -16
  18. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/EventEmitters.h +19 -17
  19. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/Props.cpp +21 -19
  20. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/Props.h +20 -18
  21. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/ShadowNodes.cpp +19 -17
  22. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/ShadowNodes.h +25 -23
  23. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/States.cpp +18 -16
  24. package/harmony/custom_keyboard/src/main/cpp/generated/{custom_keyboard/react/renderer/components/custom_keyboard → react/renderer/components/react_native_custom_keyboard}/States.h +23 -19
  25. package/harmony/custom_keyboard/src/main/ets/{RNCustomKeyboardPackage.ts → RNCustomKeyboardPackage.ets} +2 -2
  26. package/harmony/custom_keyboard/src/main/ets/generated/components/ts.ts +5 -5
  27. package/harmony/custom_keyboard/src/main/ets/generated/index.ets +5 -8
  28. package/harmony/custom_keyboard/src/main/ets/generated/ts.ts +6 -9
  29. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/CustomKeyboardNativeModule.ts +28 -32
  30. package/harmony/custom_keyboard/src/main/ets/generated/turboModules/ts.ts +5 -8
  31. package/harmony/custom_keyboard/ts.ets +2 -0
  32. package/harmony/custom_keyboard.har +0 -0
  33. package/index.d.ts +0 -6
  34. package/index.js +3 -4
  35. package/package.json +14 -16
  36. package/src/specs/v2/NativeCustomKeyboard.ts +0 -6
  37. package/tsconfig.json +13 -0
  38. package/LICENSE +0 -8
  39. package/README.OpenSource +0 -11
  40. package/harmony/custom_keyboard/ts.ts +0 -8
  41. package/img/rntpc_react-native-custom-keyboard.png +0 -0
package/OAT.xml ADDED
@@ -0,0 +1,51 @@
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>
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
- # react-native-custom-keyboard
1
+ # @react-native-ohos/react-native-custom-keyboard
2
2
 
3
- 本项目基于 [react-native-custom-keyboard](https://github.com/reactnativecn/react-native-custom-keyboard)
3
+ 本项目基于 [react-native-custom-keyboard](https://github.com/reactnativecn/react-native-custom-keyboard)@1.0.3
4
4
 
5
5
  ## 文档地址 / Documentation URL
6
6
 
7
- - [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-custom-keyboard.md)
7
+ [中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-custom-keyboard.md)
8
8
 
9
- - [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-custom-keyboard.md)
9
+ ## Codegen
10
+
11
+ 该库已接入 codegen,具体请查阅文档。
12
+
13
+ The library has been integrated with codegen. Please refer to the documentation for details.
10
14
 
11
15
  ## 请悉知 / Acknowledgements
12
16
 
@@ -1,13 +1,7 @@
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
2
  * Use these variables when you tailor your ArkTS code. They must be of the const type.
9
3
  */
10
- export const HAR_VERSION = '1.0.4-rc.1';
4
+ export const HAR_VERSION = '1.0.3-0.0.2';
11
5
  export const BUILD_MODE_NAME = 'debug';
12
6
  export const DEBUG = true;
13
7
  export const TARGET_NAME = 'default';
@@ -1,7 +1,3 @@
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
+ import { RNCustomKeyboardPackage as CustomKeyboardPackage } from './src/main/ets/RNCustomKeyboardPackage';
7
2
  export * from "./ts";
3
+ export default CustomKeyboardPackage;
@@ -1,9 +1,3 @@
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
  import { harTasks } from '@ohos/hvigor-ohos-plugin';
8
2
 
9
3
  export default {
@@ -0,0 +1,18 @@
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-custom-keyboard",
3
- "version": "1.0.4-rc.1",
3
+ "version": "1.0.4-rc.3",
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,9 +1,3 @@
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
  #include "CustomKeyboardPackage.h"
8
2
  #include "CustomKeyboardTurboModuleSpec.h"
9
3
 
@@ -11,7 +5,8 @@ using namespace facebook;
11
5
  namespace rnoh {
12
6
  class CustomKeyboardTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
13
7
  public:
14
- SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
8
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override
9
+ {
15
10
  if (name == "CustomKeyboardNativeModule") {
16
11
  return std::make_shared<NativeCustomKeyboardTurboModuleSpecJSI>(ctx, name);
17
12
  }
@@ -19,7 +14,8 @@ public:
19
14
  };
20
15
  };
21
16
 
22
- std::unique_ptr<TurboModuleFactoryDelegate> CustomKeyboardPackage::createTurboModuleFactoryDelegate() {
17
+ std::unique_ptr<TurboModuleFactoryDelegate> CustomKeyboardPackage::createTurboModuleFactoryDelegate()
18
+ {
23
19
  return std::make_unique<CustomKeyboardTurboModuleFactoryDelegate>();
24
20
  }
25
21
  } // namespace rnoh
@@ -1,17 +1,11 @@
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
  #pragma once
8
- #include "RNOH/Package.h"
2
+ #include "generated/RNOH/generated/BaseReactNativeCustomKeyboardPackage.h"
9
3
 
10
4
  namespace rnoh {
11
- class CustomKeyboardPackage : public Package {
5
+ class CustomKeyboardPackage : public BaseReactNativeCustomKeyboardPackage {
12
6
 
13
7
  public:
14
- CustomKeyboardPackage(Package::Context ctx) : Package(ctx) {}
8
+ explicit CustomKeyboardPackage(Package::Context ctx) : BaseReactNativeCustomKeyboardPackage(ctx) {}
15
9
 
16
10
  std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override;
17
11
  };
@@ -1,9 +1,3 @@
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
  // NOTE: This entire file should be codegen'ed.
8
2
  #include "CustomKeyboardTurboModuleSpec.h"
9
3
 
@@ -12,15 +6,17 @@ using namespace facebook;
12
6
 
13
7
  static constexpr double HEIGHT = 216;
14
8
  static constexpr int AVOIDENCE = 0;
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
- }
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;
22
16
  }
23
- TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag) {
17
+ }
18
+ TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag)
19
+ {
24
20
  auto weakInstance = m_ctx.instance;
25
21
  auto instance = weakInstance.lock();
26
22
  if (!instance) {
@@ -43,7 +39,8 @@ TextInputNode *NativeCustomKeyboardTurboModuleSpecJSI::getEditById(int tag) {
43
39
  return textInputNode;
44
40
  }
45
41
 
46
- static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance> weakInstance) {
42
+ static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance> weakInstance)
43
+ {
47
44
  auto instance = weakInstance.lock();
48
45
  if (!instance) {
49
46
  return nullptr;
@@ -56,7 +53,8 @@ static std::shared_ptr<RNInstanceCAPI> getInstanceCapi(std::weak_ptr<RNInstance>
56
53
  }
57
54
 
58
55
  static void getDevicePhycicalPixels(std::shared_ptr<RNInstanceCAPI> instanceCapi, double &width, double &height,
59
- double &scale) {
56
+ double &scale)
57
+ {
60
58
  auto turboModule = instanceCapi->getTurboModule("DeviceInfo");
61
59
  auto deviceInfoTurboModule = std::dynamic_pointer_cast<DeviceInfoTurboModule>(turboModule);
62
60
  auto displayMetrics = deviceInfoTurboModule->callSync("getConstants", {});
@@ -69,33 +67,37 @@ static void getDevicePhycicalPixels(std::shared_ptr<RNInstanceCAPI> instanceCapi
69
67
  }
70
68
  }
71
69
 
72
- static void setTextInputUserData(TextInputNode *textInput, UserData *userData) {
70
+ static void setTextInputUserData(TextInputNode *textInput, UserData *userData)
71
+ {
73
72
  ArkUI_NodeHandle view = textInput->getArkUINodeHandle();
74
73
  NativeNodeApi::getInstance()->setUserData(view, userData);
75
74
  }
76
75
 
77
- static UserData *getTextInputUserData(TextInputNode *textInput) {
76
+ static UserData *getTextInputUserData(TextInputNode *textInput)
77
+ {
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
- 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;
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;
89
90
  }
90
91
 
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);
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);
96
97
  }
97
98
 
98
- void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t tag, std::string type) {
99
+ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t tag, std::string type)
100
+ {
99
101
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag, type]() {
100
102
  auto edit = getEditById(tag);
101
103
  if (!edit) {
@@ -106,10 +108,14 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
106
108
  return;
107
109
  }
108
110
  static int surfaceID = START_SURFACE_ID;
109
- while(instanceCapi->findComponentInstanceByTag(surfaceID)){surfaceID++;}
111
+ while (instanceCapi->findComponentInstanceByTag(surfaceID)) {
112
+ surfaceID++;
113
+ }
110
114
  instanceCapi->createSurface(surfaceID, "CustomKeyboard");
111
115
  folly::dynamic initialProps = folly::dynamic::object("tag", tag)("type", type);
112
- double width, height, scale;
116
+ double width;
117
+ double height;
118
+ double scale;
113
119
  getDevicePhycicalPixels(instanceCapi, width, height, scale);
114
120
  instanceCapi->startSurface(surfaceID, 0.0f, 0.0f, width / scale, HEIGHT, 0.0f, 0.0f, scale, false,
115
121
  std::move(initialProps));
@@ -120,28 +126,27 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
120
126
  ArkUINode &node = comp->getLocalRootArkUINode();
121
127
  ArkUI_NodeHandle uiNode = node.getArkUINodeHandle();
122
128
  //空值 说明edit没有绑定点击事件
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) {
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) {
127
134
  if (OH_ArkUI_NodeEvent_GetTargetId(event) == CLICK_TARGET_ID) {
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);
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);
143
149
  }
144
-
145
150
  setCustomKeyboard(edit, uiNode, AVOIDENCE);
146
151
  UserData *userData = new UserData({.data = uiNode, .enabled = true});
147
152
  this->m_userDatas.insert(userData);
@@ -149,7 +154,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::install(jsi::Runtime &rt, int32_t t
149
154
  });
150
155
  }
151
156
 
152
- void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t tag) {
157
+ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t tag)
158
+ {
153
159
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
154
160
  auto instanceCapi = getInstanceCapi(this->m_ctx.instance);
155
161
  if (!instanceCapi) {
@@ -159,7 +165,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t
159
165
  edit->setFocusStatus(false);
160
166
  auto error_code =
161
167
  NativeNodeApi::getInstance()->resetAttribute(edit->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD);
162
- if(error_code){
168
+ if (error_code) {
163
169
  DLOG(ERROR)<<"uninstall custom keyboard error"<<std::endl;
164
170
  return;
165
171
  }
@@ -169,7 +175,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::uninstall(jsi::Runtime &rt, int32_t
169
175
  });
170
176
  }
171
177
 
172
- void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_t tag, std::string text) {
178
+ void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_t tag, std::string text)
179
+ {
173
180
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag, text]() {
174
181
  TextInputNode *textInputNode = this->getEditById(tag);
175
182
  int start = 0;
@@ -181,7 +188,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::insertText(jsi::Runtime &rt, int32_
181
188
  textInputNode->setTextSelection(start+text.size(), start+text.size());
182
189
  });
183
190
  }
184
- void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t tag) {
191
+ void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t tag)
192
+ {
185
193
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
186
194
  TextInputNode *textInputNode = this->getEditById(tag);
187
195
  int start = 0;
@@ -199,7 +207,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::backSpace(jsi::Runtime &rt, int32_t
199
207
  }
200
208
  });
201
209
  }
202
- void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t tag) {
210
+ void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t tag)
211
+ {
203
212
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
204
213
  TextInputNode *textInputNode = this->getEditById(tag);
205
214
  int start = 0;
@@ -217,7 +226,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::doDelete(jsi::Runtime &rt, int32_t
217
226
  }
218
227
  });
219
228
  }
220
- void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t tag) {
229
+ void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t tag)
230
+ {
221
231
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
222
232
  TextInputNode *textInputNode = this->getEditById(tag);
223
233
  int start = 0;
@@ -230,7 +240,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::moveLeft(jsi::Runtime &rt, int32_t
230
240
  }
231
241
  });
232
242
  }
233
- void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t tag) {
243
+ void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t tag)
244
+ {
234
245
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
235
246
  TextInputNode *textInputNode = this->getEditById(tag);
236
247
  int start = 0;
@@ -245,7 +256,8 @@ void NativeCustomKeyboardTurboModuleSpecJSI::moveRight(jsi::Runtime &rt, int32_t
245
256
  });
246
257
  }
247
258
 
248
- void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &rt, int32_t tag) {
259
+ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &rt, int32_t tag)
260
+ {
249
261
  this->m_ctx.taskExecutor->runTask(TaskThread::MAIN, [this, tag]() {
250
262
  auto instanceCapi = getInstanceCapi(this->m_ctx.instance);
251
263
  if (!instanceCapi) {
@@ -255,7 +267,7 @@ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &
255
267
  edit->setFocusStatus(false);
256
268
  auto error_code =
257
269
  NativeNodeApi::getInstance()->resetAttribute(edit->getArkUINodeHandle(), NODE_TEXT_INPUT_CUSTOM_KEYBOARD);
258
- if(error_code){
270
+ if (error_code) {
259
271
  DLOG(ERROR)<<"switch system keyboard error"<<std::endl;
260
272
  return;
261
273
  }
@@ -266,101 +278,113 @@ void NativeCustomKeyboardTurboModuleSpecJSI::switchSystemKeyboard(jsi::Runtime &
266
278
  }
267
279
 
268
280
  // 各个方法的宿主函数定义
269
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install(jsi::Runtime &rt,
270
- react::TurboModule &turboModule,
271
- const jsi::Value *args, size_t count) {
281
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_install(jsi::Runtime &rt,
282
+ react::TurboModule &turboModule,
283
+ const jsi::Value *args, size_t count)
284
+ {
272
285
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)
273
286
  ->install(rt, args[0].asNumber(), args[1].asString(rt).utf8(rt));
274
287
  return jsi::Value::undefined();
275
288
  }
276
289
 
277
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall(jsi::Runtime &rt,
278
- react::TurboModule &turboModule,
279
- const jsi::Value *args,
280
- size_t count) {
290
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_uninstall(jsi::Runtime &rt,
291
+ react::TurboModule &turboModule,
292
+ const jsi::Value *args,
293
+ size_t count)
294
+ {
281
295
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->uninstall(rt, args[0].asNumber());
282
296
  return jsi::Value::undefined();
283
297
  }
284
298
 
285
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText(jsi::Runtime &rt,
286
- react::TurboModule &turboModule,
287
- const jsi::Value *args,
288
- size_t count) {
299
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_insertText(jsi::Runtime &rt,
300
+ react::TurboModule &turboModule,
301
+ const jsi::Value *args,
302
+ size_t count)
303
+ {
289
304
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)
290
305
  ->insertText(rt, args[0].asNumber(), args[1].asString(rt).utf8(rt));
291
306
  return jsi::Value::undefined();
292
307
  }
293
308
 
294
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace(jsi::Runtime &rt,
295
- react::TurboModule &turboModule,
296
- const jsi::Value *args,
297
- size_t count) {
309
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_backSpace(jsi::Runtime &rt,
310
+ react::TurboModule &turboModule,
311
+ const jsi::Value *args,
312
+ size_t count)
313
+ {
298
314
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->backSpace(rt, args[0].asNumber());
299
315
  return jsi::Value::undefined();
300
316
  }
301
317
 
302
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete(jsi::Runtime &rt,
303
- react::TurboModule &turboModule,
304
- const jsi::Value *args, size_t count) {
318
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_doDelete(jsi::Runtime &rt,
319
+ react::TurboModule &turboModule,
320
+ const jsi::Value *args, size_t count)
321
+ {
305
322
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->doDelete(rt, args[0].asNumber());
306
323
  return jsi::Value::undefined();
307
324
  }
308
325
 
309
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft(jsi::Runtime &rt,
310
- react::TurboModule &turboModule,
311
- const jsi::Value *args, size_t count) {
326
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveLeft(jsi::Runtime &rt,
327
+ react::TurboModule &turboModule,
328
+ const jsi::Value *args, size_t count)
329
+ {
312
330
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->moveLeft(rt, args[0].asNumber());
313
331
  return jsi::Value::undefined();
314
332
  }
315
333
 
316
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight(jsi::Runtime &rt,
317
- react::TurboModule &turboModule,
318
- const jsi::Value *args,
319
- size_t count) {
334
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_moveRight(jsi::Runtime &rt,
335
+ react::TurboModule &turboModule,
336
+ const jsi::Value *args,
337
+ size_t count)
338
+ {
320
339
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->moveRight(rt, args[0].asNumber());
321
340
  return jsi::Value::undefined();
322
341
  }
323
342
 
324
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard(
325
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
343
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard(
344
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
345
+ {
326
346
  static_cast<NativeCustomKeyboardTurboModuleSpecJSI *>(&turboModule)->switchSystemKeyboard(rt, args[0].asNumber());
327
347
  return jsi::Value::undefined();
328
348
  }
329
349
 
330
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError(
331
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
350
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError(
351
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
352
+ {
332
353
  return jsi::Value(static_cast<ArkTSTurboModule &>(turboModule).call(rt, "displayRNOHError", args, count));
333
354
  }
334
355
 
335
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp(
336
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
356
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp(
357
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
358
+ {
337
359
  throw std::runtime_error("Exception thrown from C++");
338
360
  }
339
361
 
340
- static jsi::Value __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk(
341
- jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
362
+ static jsi::Value hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk(
363
+ jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count)
364
+ {
342
365
  return jsi::Value(static_cast<ArkTSTurboModule &>(turboModule).call(rt, "throwExceptionArk", args, count));
343
366
  }
344
367
 
345
368
  NativeCustomKeyboardTurboModuleSpecJSI::NativeCustomKeyboardTurboModuleSpecJSI(const ArkTSTurboModule::Context ctx,
346
369
  const std::string name)
347
- : ArkTSTurboModule(ctx, name) {
370
+ : ArkTSTurboModule(ctx, name)
371
+ {
348
372
  methodMap_ = {};
349
373
 
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};
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};
357
381
  methodMap_["switchSystemKeyboard"] =
358
- MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard};
382
+ MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_switchSystemKeyboard};
359
383
 
360
384
  methodMap_["displayRNOHError"] =
361
- MethodMetadata{1, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError};
385
+ MethodMetadata{1, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_displayRNOHError};
362
386
  methodMap_["throwExceptionCpp"] =
363
- MethodMetadata{0, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp};
387
+ MethodMetadata{0, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionCpp};
364
388
  methodMap_["throwExceptionArk"] =
365
- MethodMetadata{0, __hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk};
389
+ MethodMetadata{0, hostFunction_NativeCustomKeyboardTurboModuleSpecJSI_throwExceptionArk};
366
390
  }
@@ -1,10 +1,3 @@
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
-
8
1
  // NOTE: This entire file should be codegen'ed.
9
2
  #pragma once
10
3
 
@@ -18,7 +11,7 @@ using namespace facebook;
18
11
 
19
12
  namespace rnoh {
20
13
 
21
- typedef struct{
14
+ typedef struct {
22
15
  ArkUI_NodeHandle data;
23
16
  bool enabled;
24
17
  }UserData;