diff --git a/en/application-dev/reference/apis/js-apis-inputmethod-subtype.md b/en/application-dev/reference/apis/js-apis-inputmethod-subtype.md
index 14a5ed2b9a6fee26af15baabfeb07470e9a0f658..f0a38ede3b18acb04b2286651afa9fe2d9ae8a25 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethod-subtype.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethod-subtype.md
@@ -18,15 +18,15 @@ import InputMethodSubtype from '@ohos.InputMethodSubtype';
**System capability**: SystemCapability.MiscServices.InputMethodFramework
-| Name| Type| Readable| Writable| Mandatory| Description|
-| -------- | -------- | -------- | -------- | -------- | -------- |
-| label | string | Yes| No| No| Label of the input method subtype.|
-| labelId10+ | string | Yes| No| No| Label ID of the input method subtype.|
-| name | string | Yes| No| Yes| Bundle name of the input method.|
-| id | string | Yes| No| Yes| ID of the input method subtype.|
-| mode | string | Yes| No| No| Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
-| locale | string | Yes| No| Yes| Locale of the input method subtype.|
-| language | string | Yes| No| Yes| Language of the input method subtype.|
-| icon | string | Yes| No| No| Icon of the input method subtype.|
-| iconId | number | Yes| No| No| Icon ID of the input method subtype.|
-| extra | object | Yes| Yes| No| Extra information of the input method subtype. **NOTE** This parameter is optional since API version 10.|
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| label | string | Yes| No| Optional. Label of the input method subtype.|
+| labelId10+ | string | Yes| No| Optional. Label ID of the input method subtype.|
+| name | string | Yes| No| Mandatory. Bundle name of the input method.|
+| id | string | Yes| No| Mandatory. ID of the input method subtype.|
+| mode | string | Yes| No| Optional. Mode of the input method subtype, including **upper** (uppercase) and **lower** (lowercase).|
+| locale | string | Yes| No| Mandatory. Locale of the input method subtype.|
+| language | string | Yes| No| Mandatory. Language of the input method subtype.|
+| icon | string | Yes| No| Optional. Icon of the input method subtype. It can be obtained by using **iconId**. This parameter is reserved.|
+| iconId | number | Yes| No| Optional. Icon ID of the input method subtype.|
+| extra | object | Yes| Yes| Optional. Extra information of the input method subtype. This parameter is reserved and currently has no specific meaning. **NOTE** This parameter is optional since API version 10.|
diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md
index 553c448b9a148406d548ae6bae0fcfe864d95eb9..b7f0b58fda7dc1f3c1b79d840d39756db8ceeb29 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethod.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethod.md
@@ -35,9 +35,9 @@ Describes the input method application attributes.
| id9+ | string | Yes| No| Mandatory. Unique ID of the input method.|
| label9+ | string | Yes| No| Optional. External name of the input method.|
| labelId10+ | string | Yes| No| Optional. External ID of the input method.|
-| icon9+ | string | Yes| No| Optional. Icon of the input method.|
+| icon9+ | string | Yes| No| Optional. Icon of the input method. It can be obtained by using **iconId**. This parameter is reserved.|
| iconId9+ | number | Yes| No| Optional. Icon ID of the input method.|
-| extra9+ | object | Yes| Yes| Extra information about the input method. - API version 10 and later: optional - API version 9: mandatory|
+| extra9+ | object | Yes| Yes| Extra information about the input method. This parameter is reserved and currently has no specific meaning. - API version 10 and later: optional - API version 9: mandatory|
| packageName(deprecated) | string | Yes| No| Name of the input method package. Mandatory. **NOTE** This API is supported since API version 8 and deprecated since API version 9. You are advised to use **name**.|
| methodId(deprecated) | string | Yes| No| Unique ID of the input method. Mandatory. **NOTE** This API is supported since API version 8 and deprecated since API version 9. You are advised to use **id**.|
@@ -154,15 +154,15 @@ Switches to another input method. This API uses a promise to return the result.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-|target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ |target | [InputMethodProperty](#inputmethodproperty8)| Yes| Input method to switch to.|
**Return value**
-| Type | Description |
-| ----------------------------------------- | ---------------------------- |
-| Promise\ | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
+ | Type | Description |
+ | ----------------------------------------- | ---------------------------- |
+ | Promise\ | Promise used to return the result. The value **true** means that the switching is successful, and **false** means the opposite.|
**Error codes**
@@ -606,9 +606,12 @@ Describes the configuration of the editor component. When the editor component r
**System capability**: SystemCapability.MiscServices.InputMethodFramework
-| Name| Type| Readable| Writable| Description|
+| Name| Type| Read-only| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
-| inputAttribute10+ | [InputAttribute](#inputattribute10) | Yes| Yes| Edit box attribute.|
+| inputAttribute10+ | [InputAttribute](#inputattribute10) | No| Yes| Edit box attribute.|
+| cursorInfo10+ | [CursorInfo](#cursorinfo10) | No| No| Cursor information.|
+| selection10+ | [Range](#range10) | No| No| Text selection range.|
+| windowId10+ | number | No| No| ID of the window where the editor component is located.|
## CursorInfo10+
@@ -1684,7 +1687,7 @@ try {
### off('insertText')10+
-off(type: 'insertText'): void
+off(type: 'insertText', callback?: (text: string) => void): void
Disables listening for the text insertion event of the input method.
@@ -1692,13 +1695,18 @@ Disables listening for the text insertion event of the input method.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'insertText'** indicates the text insertion event.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'insertText'** indicates the text insertion event.|
+| callback | (text: string) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onInsertTextCallback = (text: string) => {
+ console.log(`Succeeded in subscribing insertText: ${text}`);
+};
+inputMethodController.off('insertText', onInsertTextCallback);
inputMethodController.off('insertText');
```
@@ -1773,7 +1781,7 @@ try {
```
### off('deleteLeft')10+
-off(type: 'deleteLeft'): void
+off(type: 'deleteLeft', callback?: (length: number) => void): void
Disables listening for the backward delete event.
@@ -1781,19 +1789,24 @@ Disables listening for the backward delete event.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'deleteLeft'** indicates the backward delete event.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'deleteLeft'** indicates the backward delete event.|
+| callback | (length: number) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onDeleteLeftCallback = (length: number) => {
+ console.log(`Succeeded in subscribing deleteLeft, length: ${length}`);
+};
+inputMethodController.off('deleteLeft', onDeleteLeftCallback);
inputMethodController.off('deleteLeft');
```
### off('deleteRight')10+
-off(type: 'deleteRight'): void
+off(type: 'deleteRight', callback?: (length: number) => void): void
Disables listening for the forward delete event.
@@ -1801,19 +1814,24 @@ Disables listening for the forward delete event.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'deleteRight'** indicates the forward delete event.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'deleteRight'** indicates the forward delete event.|
+| callback | (length: number) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onDeleteRightCallback = (length: number) => {
+ console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
+};
+inputMethodController.off('deleteRight', onDeleteRightCallback);
inputMethodController.off('deleteRight');
```
### on('sendKeyboardStatus')10+
-on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => void): void
+on(type: 'sendKeyboardStatus', callback: (keyboardStatus: KeyboardStatus) => void): void
Enables listening for the keyboard status event of the input method. This API uses an asynchronous callback to return the result.
@@ -1824,7 +1842,7 @@ Enables listening for the keyboard status event of the input method. This API us
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---- |
| type | string | Yes | Listening type. The value **'sendKeyboardStatus'** indicates the keyboard status event.|
-| callback | (keyBoardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes | Callback used to return the keyboard status. Your application needs to perform operations based on the keyboard state returned in the callback.|
+| callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | Yes | Callback used to return the keyboard status. Your application needs to perform operations based on the keyboard state returned in the callback.|
**Error codes**
@@ -1838,8 +1856,8 @@ For details about the error codes, see [Input Method Framework Error Codes](../e
```js
try {
- inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => {
- console.log(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
+ inputMethodController.on('sendKeyboardStatus', (keyboardStatus) => {
+ console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
});
} catch(err) {
console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(err)}`);
@@ -1848,7 +1866,7 @@ try {
### off('sendKeyboardStatus')10+
-off(type: 'sendKeyboardStatus'): void
+off(type: 'sendKeyboardStatus', callback?: (keyboardStatus: KeyboardStatus) => void): void
Disables listening for the keyboard status event of the input method.
@@ -1856,13 +1874,18 @@ Disables listening for the keyboard status event of the input method.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'sendKeyboardStatus'** indicates the keyboard status event.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'sendKeyboardStatus'** indicates the keyboard status event.|
+| callback | (keyboardStatus: [KeyboardStatus](#keyboardstatus10)) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onSendKeyboardStatus = (keyboardStatus: KeyboardStatus) => {
+ console.log(`Succeeded in subscribing sendKeyboardStatus, keyboardStatus: ${keyboardStatus}`);
+};
+inputMethodController.off('sendKeyboardStatus', onSendKeyboardStatus);
inputMethodController.off('sendKeyboardStatus');
```
@@ -1903,7 +1926,7 @@ try {
### off('sendFunctionKey')10+
-off(type: 'sendFunctionKey'): void
+off(type: 'sendFunctionKey', callback?: (functionKey: FunctionKey) => void): void
Disables listening for the function key sending event of the input method.
@@ -1911,13 +1934,18 @@ Disables listening for the function key sending event of the input method.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'sendFunctionKey'** indicates the function key sending event.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'sendFunctionKey'** indicates the function key sending event.|
+| callback | (functionKey: [FunctionKey](#functionkey10)) => void | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onSendFunctionKey = (functionKey: FunctionKey) => {
+ console.log(`Succeeded in subscribing sendFunctionKey, functionKey: ${functionKey.enterKeyType}`);
+};
+inputMethodController.off('sendFunctionKey', onSendFunctionKey);
inputMethodController.off('sendFunctionKey');
```
@@ -1958,7 +1986,7 @@ try {
### off('moveCursor')10+
-off(type: 'moveCursor'): void
+off(type: 'moveCursor', callback?: (direction: Direction) => void): void
Disables listening for the cursor movement event of the input method.
@@ -1969,10 +1997,15 @@ Disables listening for the cursor movement event of the input method.
| Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ---- |
| type | string | Yes | Listening type. The value **'moveCursor'** indicates the cursor movement event.|
+| callback | (direction: [Direction10+](#direction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onMoveCursorCallback = (direction: Direction) => {
+ console.log(`Succeeded in subscribing moveCursor, direction: ${direction}`);
+};
+inputMethodController.off('moveCursor', onMoveCursorCallback);
inputMethodController.off('moveCursor');
```
@@ -2013,7 +2046,7 @@ try {
### off('handleExtendAction')10+
-off(type: 'handleExtendAction'): void
+off(type: 'handleExtendAction', callback?: (action: ExtendAction) => void): void
Disables listening for the extended action handling event of the input method.
@@ -2024,10 +2057,15 @@ Disables listening for the extended action handling event of the input method.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Listening type. The value **'handleExtendAction'** indicates the extended action handling event.|
+| callback | (action: [ExtendAction](#extendaction10)) => void | No| Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onHandleExtendActionCallback = (action: ExtendAction) => {
+ console.log(`Succeeded in subscribing handleExtendAction, action: ${action}`);
+};
+inputMethodController.off('handleExtendAction', onHandleExtendActionCallback);
inputMethodController.off('handleExtendAction');
```
@@ -2056,7 +2094,7 @@ inputMethodController.on('selectByRange', (range) => {
### off('selectByRange')10+
-off(type: 'selectByRange'): void
+off(type: 'selectByRange', callback?: Callback<Range>): void
Disables listening for the select-by-range event.
@@ -2064,13 +2102,18 @@ Disables listening for the select-by-range event.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'selectByRange'** indicates the select-by-range event.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'selectByRange'** indicates the select-by-range event.|
+| callback | Callback<[Range](#range10)> | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onSelectByRangeCallback = (range: Range) => {
+ console.log(`Succeeded in subscribing selectByRange, range: ${JSON.stringify(range)}`);
+};
+inputMethodController.off('selectByRange', onSelectByRangeCallback);
inputMethodController.off('selectByRange');
```
@@ -2099,7 +2142,7 @@ inputMethodController.on('selectByMovement', (movement) => {
### off('selectByMovement')10+
-off(type: 'selectByMovement'): void
+off(type: 'selectByMovement', callback?: Callback<Movement>): void
Disables listening for the select-by-cursor-movement event.
@@ -2107,13 +2150,18 @@ Disables listening for the select-by-cursor-movement event.
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Listening type. The value **'selectByMovement'** indicates the select-by-cursor-movement event.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'selectByMovement'** indicates the select-by-cursor-movement event.|
+| callback | Callback<[Movement](#movement10)> | No | Callback used for disable listening, which must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks corresponding to the set event are invoked.|
**Example**
```js
+let onSelectByMovementCallback = (movement: Movement) => {
+ console.log(`Succeeded in subscribing selectByMovement, movement.direction: ${movement.direction}`);
+};
+inputMethodController.off('selectByMovement', onSelectByMovementCallback);
inputMethodController.off('selectByMovement');
```
@@ -2132,6 +2180,14 @@ Enables listening for the event of obtaining the length of text deleted backward
| type | string | Yes | Listening type. The value **'getLeftTextOfCursor'** indicates the event of obtaining the length of text deleted backward.|
| callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted backward. In this callback, obtain the text of the specified length on the left of the cursor in the latest state of the edit box and return the text.|
+**Error codes**
+
+For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
+
+| Error Code ID| Error Message |
+| -------- | -------------------------------------- |
+| 12800009 | input method client is detached. |
+
**Example**
```js
@@ -2150,7 +2206,7 @@ try {
off(type: 'getLeftTextOfCursor', callback?: (length: number) => string): void;
-Disables listening for the event of obtaining the length of text deleted backward. This API uses an asynchronous callback to return the result.
+Disables listening for the event of obtaining the length of text deleted backward.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
@@ -2190,6 +2246,14 @@ Enables listening for the event of obtaining the length of text deleted forward.
| type | string | Yes | Listening type. The value **'getRightTextOfCursor'** indicates the event of obtaining the length of text deleted forward.|
| callback | (length: number) => string | Yes | Callback used to obtain the text of the specified length deleted forward. In this callback, obtain the text of the specified length on the right of the cursor in the latest state of the edit box and return the text.|
+**Error codes**
+
+For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
+
+| Error Code ID| Error Message |
+| -------- | -------------------------------------- |
+| 12800009 | input method client is detached. |
+
**Example**
```js
@@ -2208,7 +2272,7 @@ try {
off(type: 'getRightTextOfCursor', callback?: (length: number) => string): void;
-Disables listening for the event of obtaining the length of text deleted forward. This API uses an asynchronous callback to return the result.
+Disables listening for the event of obtaining the length of text deleted forward.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
@@ -2248,6 +2312,14 @@ Enables listening for the event of obtaining the index of text at the cursor. Th
| type | string | Yes | Listening type. The value **'getTextIndexAtCursor'** indicates the event of obtaining the index of text at the cursor.|
| callback | () => number | Yes | Callback used to obtain the index of text at the cursor. In this callback, obtain the index of text at the cursor in the latest state of the edit box and return the index.|
+**Error codes**
+
+For details about the error codes, see [Input Method Framework Error Codes](../errorcodes/errorcode-inputmethod-framework.md).
+
+| Error Code ID| Error Message |
+| -------- | -------------------------------------- |
+| 12800009 | input method client is detached. |
+
**Example**
```js
@@ -2266,7 +2338,7 @@ try {
off(type: 'getTextIndexAtCursor', callback?: () => number): void;
-Disables listening for the event of obtaining the index of text at the cursor. This API uses an asynchronous callback to return the result.
+Disables listening for the event of obtaining the index of text at the cursor.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
diff --git a/en/application-dev/reference/apis/js-apis-inputmethodengine.md b/en/application-dev/reference/apis/js-apis-inputmethodengine.md
index 36e504d702912c310765d0afc448ebffc9a34517..7b8283d50367e9cd121bd84c714347992e6e1bb7 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethodengine.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethodengine.md
@@ -923,6 +923,50 @@ inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
});
```
+### on('editorAttributeChanged')10+
+
+on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void
+
+Enables listening for the edit box attribute change event. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.MiscServices.InputMethodFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
+| callback | (attr: EditorAttribute) => void | Yes | Callback used to return the edit box attribute change.|
+
+**Example**
+
+```js
+inputMethodEngine.getKeyboardDelegate().on('editorAttributeChanged', (attr) => {
+ console.log(`Succeeded in receiving attribute of editor, inputPattern = ${attr.inputPattern}, enterKeyType = ${attr.enterKeyType}`);
+});
+```
+
+### off('editorAttributeChanged')10+
+
+off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void
+
+Cancels listening for the edit box attribute change event.
+
+**System capability**: SystemCapability.MiscServices.InputMethodFramework
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. The value **'editorAttributeChanged'** indicates the edit box attribute change event.|
+| callback | (attr: EditorAttribute) => void | No | Callback for the edit box attribute change event. It must correspond to the one in the **on** API.|
+
+**Example**
+
+```js
+inputMethodEngine.getKeyboardDelegate().off('editorAttributeChanged');
+```
+
## Panel10+
In the following API examples, you must first use **[createPanel](#createpanel10)** to obtain a **Panel** instance, and then call the APIs using the obtained instance.
diff --git a/en/application-dev/reference/apis/js-apis-webview.md b/en/application-dev/reference/apis/js-apis-webview.md
index ae261c21ebc5779e283e8e4e19d1355de9216cda..adea4c22a9473f43b8092d0314918537ecaa98b6 100644
--- a/en/application-dev/reference/apis/js-apis-webview.md
+++ b/en/application-dev/reference/apis/js-apis-webview.md
@@ -208,7 +208,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100010 | Can not post message using this port. |
-
### onMessageEventExt10+
onMessageEventExt(callback: (result: WebMessageExt) => void): void
@@ -358,7 +357,7 @@ window.addEventListener('message', function(event) {
h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function(event) {
console.log("hwd In html got message");
- // 2. Receive the message sent from the ArkTS side.
+ // 2. Receive the message sent from the eTS side.
var result = event.data;
console.log("In html got message, typeof: ", typeof(result));
console.log("In html got message, result: ", (result));
@@ -401,7 +400,7 @@ window.addEventListener('message', function(event) {
}
})
-// Use h5Port to send a message of the string type to the ArkTS side.
+// Use h5Port to send a message of the string type to the ets side.
function postStringToApp() {
if (h5Port) {
console.log("In html send string message");
@@ -638,7 +637,7 @@ struct WebComponent {
Button('loadUrl')
.onClick(() => {
try {
- // The headers parameter is carried.
+ // The headers parameter is passed.
this.controller.loadUrl('www.example.com', [{headerKey: "headerKey", headerValue: "headerValue"}]);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
@@ -999,7 +998,7 @@ struct WebComponent {
onActive(): void
-Invoked to instruct the **\** component to enter the foreground, active state.
+Invoked to instruct the **\** component to enter the active foreground state.
**System capability**: SystemCapability.Web.Webview.Core
@@ -1348,12 +1347,14 @@ HTML file to be loaded:
- Hello world!
+
+
@@ -3866,7 +3867,7 @@ struct WebComponent {
getCertificate(): Promise>
-Obtains the certificate information of the current website. When the \ component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
+Obtains the certificate information of this website. When the **\** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
**System capability**: SystemCapability.Web.Webview.Core
@@ -3943,7 +3944,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
- //Load an HTTPS website and view the certificate information of the website.
+ // Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
@@ -4023,7 +4024,7 @@ struct Index {
getCertificate(callback: AsyncCallback>): void
-Obtains the certificate information of the current website. When the \ component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the current website.
+Obtains the certificate information of this website. When the **\** component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the website.
**System capability**: SystemCapability.Web.Webview.Core
@@ -4031,7 +4032,7 @@ Obtains the certificate information of the current website. When the \ comp
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- |
-| callback | AsyncCallback> | Yes | Callback used to obtain the X.509 certificate array of the current HTTPS website.|
+| callback | AsyncCallback> | Yes | Callback used to obtain the X.509 certificate array of the current website.|
**Error codes**
@@ -4100,7 +4101,7 @@ struct Index {
}
.type(ButtonType.Capsule)
.onClick(() => {
- //Load an HTTPS website and view the certificate information of the website.
+ // Load an HTTPS website and view the certificate information of the website.
this.webviewCtl.loadUrl('https://www.example.com')
})
.height(50)
@@ -4222,10 +4223,111 @@ struct WebComponent {
}
```
+### prefetchPage10+
+
+prefetchPage(url: string, additionalHeaders?: Array\): void
+
+Prefetches resources in the background for a page that is likely to be accessed in the near future, without executing the page JavaScript code or presenting the page. This can significantly reduce the load time for the prefetched page.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------------| --------------------------------| ---- | ------------- |
+| url | string | Yes | URL to be preloaded.|
+| additionalHeaders | Array\<[WebHeader](#webheader)> | No | Additional HTTP headers of the URL.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID | Error Message |
+| -------- | ------------------------------------------------------------ |
+| 17100001 | Init error. The WebviewController must be associated with a Web component. |
+| 17100002 | Invalid url. |
+
+**Example**
+
+```ts
+// xxx.ets
+import web_webview from '@ohos.web.webview'
+
+@Entry
+@Component
+struct WebComponent {
+ controller: web_webview.WebviewController = new web_webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('prefetchPopularPage')
+ .onClick(() => {
+ try {
+ // Replace 'https://www.example.com' with a real URL for the API to work.
+ this.controller.prefetchPage('https://www.example.com');
+ } catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ })
+ // Replace ''www.example1.com' with a real URL for the API to work.
+ Web({ src: 'www.example1.com', controller: this.controller })
+ }
+ }
+}
+```
+
+### prepareForPageLoad10+
+
+static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void
+
+Preconnects to a URL. This API can be called before the URL is loaded, to resolve the DNS and establish a socket connection, without obtaining the resources.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------------| ------- | ---- | ------------- |
+| url | string | Yes | URL to be preconnected.|
+| preconnectable | boolean | Yes | Whether to perform preconnection, which involves DNS resolution and socket connection establishment. The value **true** means to perform preconnection, and **false** means the opposite.|
+| numSockets | number | Yes | Number of sockets to be preconnected. The value must be greater than 0. A maximum of six socket connections are allowed.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID | Error Message |
+| -------- | ------------------------------------------------------------ |
+| 17100002 | Invalid url. |
+| 171000013| The number of preconnect sockets is invalid. |
+
+**Example**
+
+```ts
+// xxx.ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+import web_webview from '@ohos.web.webview';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log("EntryAbility onCreate")
+ web_webview.WebviewController.initializeWebEngine()
+ // Replace 'https://www.example.com' with a real URL for the API to work.
+ web_webview.WebviewController.prepareForPageLoad("https://www.example.com", true, 2);
+ globalThis.abilityWant = want
+ console.log("EntryAbility onCreate done")
+ }
+}
+```
+
## WebCookieManager
Implements a **WebCookieManager** instance to manage behavior of cookies in **\** components. All **\** components in an application share a **WebCookieManager** instance.
+> **NOTE**
+>
+> You must load the **\** component before calling APIs in **WebCookieManager**.
+
### getCookie
static getCookie(url: string): string
@@ -4347,7 +4449,6 @@ Saves the cookies in the memory to the drive. This API uses an asynchronous call
| -------- | ---------------------- | ---- | :------------------------------------------------- |
| callback | AsyncCallback\ | Yes | Callback used to return whether the cookies are successfully saved.|
-
**Example**
```ts
@@ -4688,6 +4789,10 @@ struct WebComponent {
Implements a **WebStorage** object to manage the Web SQL database and HTML5 Web Storage APIs. All **\** components in an application share a **WebStorage** object.
+> **NOTE**
+>
+> You must load the **\** component before calling the APIs in **WebStorage**.
+
### deleteOrigin
static deleteOrigin(origin : string): void
@@ -5148,6 +5253,10 @@ struct WebComponent {
Implements a **WebDataBase** object.
+> **NOTE**
+>
+> You must load the **\** component before calling the APIs in **WebDataBase**.
+
### getHttpAuthCredentials
static getHttpAuthCredentials(host: string, realm: string): Array\
@@ -5326,6 +5435,10 @@ struct WebComponent {
Implements a **GeolocationPermissions** object.
+> **NOTE**
+>
+> You must load the **\** component before calling the APIs in **GeolocationPermissions**.
+
### Required Permissions
**ohos.permission.LOCATION**, **ohos.permission.APPROXIMATELY_LOCATION**, and **ohos.permission.LOCATION_IN_BACKGROUND**, which are required for accessing the location information. For details about the permissions, see [@ohos.geolocation (Geolocation)](./js-apis-geolocation.md).
@@ -5739,7 +5852,6 @@ Describes the type of the returned result of script execution using [runJavaScir
| ARRAY_BUFFER | 4 |Raw binary data buffer.|
| ARRAY | 5 |Array type.|
-
## WebMessageType10+
Describes the data type supported by the [webMessagePort](#webmessageport) API.
@@ -5796,7 +5908,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
-
### getNumber10+
getNumber(): number
@@ -5841,7 +5952,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
-
### getArrayBuffer10+
getArrayBuffer(): ArrayBuffer
@@ -5885,7 +5995,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the result. |
-
## WebMessageExt10+
Data object received and sent by the [webMessagePort](#webmessageport) interface.
@@ -5904,7 +6013,6 @@ Obtains the type of the data object.
| --------------| --------------------------------------------------------- |
| [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.|
-
### getString10+
getString(): string
@@ -5927,7 +6035,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
-
### getNumber10+
getNumber(): number
@@ -5950,7 +6057,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
-
### getBoolean10+
getBoolean(): boolean
@@ -5973,7 +6079,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
-
### getArrayBuffer10+
getArrayBuffer(): ArrayBuffer
@@ -6039,7 +6144,6 @@ For details about the error codes, see [Webview Error Codes](../errorcodes/error
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
-
### setType10+
setType(type: WebMessageType): void
@@ -6180,7 +6284,6 @@ Sets the error-object-type data for the data object. For the complete sample cod
| -------- | ------------------------------------- |
| 17100014 | The type does not match with the value of the web message. |
-
## WebStorageOrigin
Provides usage information of the Web SQL Database.
diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
index 2d6b3bab8f6c8dfeef3c2b65b3068d1546d4b652..b3c50c96f5760173ce05f46a39423aaef86d1e3b 100644
--- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
+++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
@@ -107,32 +107,31 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
```
2. Modify the **EntryAbility.ts** file.
+ The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
+ ```ts
+ // xxx.ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+ import web_webview from '@ohos.web.webview';
+
+ export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ // Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI.
+ globalThis.filesDir = this.context.filesDir
+ console.log("Sandbox path is " + globalThis.filesDir)
+ }
+ }
+ ```
- The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
- ```ts
- // xxx.ts
- import UIAbility from '@ohos.app.ability.UIAbility';
- import web_webview from '@ohos.web.webview';
-
- export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- // Bind filesDir to the globalThis object to implement data synchronization between the UIAbility component and the UI.
- globalThis.filesDir = this.context.filesDir
- console.log("Sandbox path is " + globalThis.filesDir)
- }
- }
- ```
-
- HTML file to be loaded:
- ```html
-
-
-
-
-
Hello World
-
-
- ```
+ HTML file to be loaded:
+ ```html
+
+
+
+
+
Hello World
+
+
+ ```
## Attributes
@@ -672,12 +671,16 @@ Sets whether to display the vertical scrollbar, including the default system scr