mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 11:41:08 +00:00
Allow custom menu items for selection menu (#2101)
remove unused vars use gesture handler change callback name, pass selected text back do not use deprecate setTarget do not call super on methodSignatureForSelector twice add checks for custom menu items and callback make custom params optional add custom menu items outside of initWithFrame require key and label for menuItems fix typo
This commit is contained in:
@@ -1439,6 +1439,30 @@ Example:
|
||||
|
||||
```javascript
|
||||
<WebView forceDarkOn={false} />
|
||||
### `menuItems`
|
||||
|
||||
An array of custom menu item objects that will be appended to the UIMenu that appears when selecting text (will appear after 'Copy' and 'Share...'). Used in tandem with `onCustomMenuSelection`
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
<WebView menuItems={[{ label: 'Tweet', key: 'tweet' }, { label: 'Save for later', key: 'saveForLater' }]} />
|
||||
|
||||
```
|
||||
|
||||
### `onCustomMenuSelection`
|
||||
|
||||
Function called when a custom menu item is selected. It receives a Native event, which includes three custom keys: `label`, `key` and `selectedText`.
|
||||
|
||||
```javascript
|
||||
<WebView
|
||||
menuItems={[{ label: 'Tweet', key: 'tweet', { label: 'Save for later', key: 'saveForLater' }]}
|
||||
onCustomMenuSelection={(webViewEvent) => {
|
||||
const { label } = webViewEvent.nativeEvent; // The name of the menu item, i.e. 'Tweet'
|
||||
const { key } = webViewEvent.nativeEvent; // The key of the menu item, i.e. 'tweet'
|
||||
const { selectedText } = webViewEvent.nativeEvent; // Text highlighted
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
||||
### `basicAuthCredential`
|
||||
|
||||
Reference in New Issue
Block a user