The surroundContents() method of the Range interface surrounds the selected content by a provided node.
surroundContents()
MDN Reference