
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
surround-contents
Advanced tools
import surroundContents from 'surround-contents'
surroundContents(getSelection().getRangeAt(0), () => {
const span = document.createElement('span')
span.style.background = 'red'
return span
})
| 参数名 | 类型 | 描述 |
|---|---|---|
| rangeAt | Range | 必填。需要处理的 Range 对象。默认值:null |
| newDomMethod | Function | 选填。创建新节点的函数。默认值见下方代码块。每次需新建节点,不能复用。 |
默认值示例:
() => document.createElement('span')
npm install surround-contents
# 或
yarn add surround-contents
欢迎提 issue 或 PR!
MIT
详见 CHANGELOG.md
FAQs
原生 Range.surroundContents 的增强版,支持跨节点包裹。
We found that surround-contents demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.