<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebEditingDelegate/webView(_:shouldInsert:replacing:given:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebEditingDelegate(im)webView:shouldInsertNode:replacingDOMRange:givenAction:"
  },
  "title" : "webView(_:shouldInsert:replacing:given:)"
}
-->

# webView(_:shouldInsert:replacing:given:)

Returns whether the user should be allowed to insert a node in place of a range of content.

```
optional func webView(_ webView: WebView!, shouldInsert node: DOMNode!, replacing range: DOMRange!, given action: WebViewInsertAction) -> Bool
```

## Parameters

`webView`

The web view that the user is editing.

`node`

The content to insert.

`range`

The portion of the content that is replaced with `node`.

`action`

Indicates the type of user action that initiated the insertion.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the user should be allowed to insert `node` in `webView`; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method may perform an alternate action—for example, insert a different node—and return <doc://com.apple.documentation/documentation/Swift/false>.

## See Also

[`webViewDidChange(_:)`](/documentation/WebKit/WebEditingDelegate/webViewDidChange(_:))

Sent by the default notification center when the user changes content in the web view.

[`webView(_:shouldInsertText:replacing:given:)`](/documentation/WebKit/WebEditingDelegate/webView(_:shouldInsertText:replacing:given:))

Returns whether a user should be allowed to insert text in place of a range of content.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)