1 Star 0 Fork 34

/outline.js

forked from Yaohaixiao/outline.js 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
_resetHeading.js 822 Bytes
一键复制 编辑 原始数据 按行查看 历史
import removeClass from './utils/dom/removeClass'
import isEmpty from './utils/types/isEmpty'
import trim from './utils/lang/trim'
const _resetHeading = ($heading, hasAnchor = true, isAtStart = true) => {
const CLS_HEADING = 'outline-heading'
const text = $heading.innerHTML
const pattern = /^\d+(\.?\d+)*\s?/gi
let $anchor
$heading.innerHTML = text.replace(pattern, '')
$heading.removeAttribute('id')
$heading.removeAttribute('data-id')
removeClass($heading, CLS_HEADING)
if (!hasAnchor) {
return false
}
$anchor = $heading.querySelector(`.${CLS_HEADING}__anchor`)
if (isAtStart) {
removeClass($heading, `${CLS_HEADING}_start`)
}
if (isEmpty(trim($heading.className))) {
$heading.removeAttribute('class')
}
$heading.removeChild($anchor)
}
export default _resetHeading
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/qdplatform/outline.js.git
[email protected]:qdplatform/outline.js.git
qdplatform
outline.js
outline.js
master

搜索帮助