代码拉取完成,页面将自动刷新
同步操作将从 Yaohaixiao/outline.js 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import isString from './utils/types/isString'
import isElement from './utils/types/isElement'
import createElement from './utils/dom/createElement'
import addClass from './utils/dom/addClass'
import later from './utils/lang/later'
import icon from './utils/icons/icon'
const _updateSiblingElements = (siblingElement, isPrev) => {
let tagName
let $sibling = siblingElement
while ($sibling) {
tagName = $sibling.tagName.toLowerCase()
if (tagName !== 'script' && tagName !== 'style') {
addClass($sibling, 'outline-print_sibling')
}
if (isPrev) {
$sibling = $sibling.previousElementSibling
} else {
$sibling = $sibling.nextElementSibling
}
}
}
const print = (origins, title) => {
let text = title
let $origins
let $wrapper
let $article
let $title
let $sibling
let $icon
if (isString(origins)) {
$origins =
document.querySelector(origins) || document.getElementById(origins)
} else {
if (isElement(origins)) {
$origins = origins
}
}
$icon = icon('close', {
iconSet: 'outline',
size: 20
})
addClass($icon, 'outline-print__close')
$title = $origins.querySelector('h1')
if (isElement(title)) {
$title = title
}
if (isElement($title)) {
text = $title.innerText
}
$article = createElement('article', {
id: 'outline-print__article',
className: 'outline-print__article'
})
$article.innerHTML = $origins.innerHTML
$title = createElement(
'h1',
{
className: 'outline-print__title'
},
text
)
$wrapper = createElement(
'section',
{
id: 'outline-print',
className: 'outline-print'
},
[$icon, $title, $article]
)
document.body.appendChild($wrapper)
later(() => {
$sibling = $wrapper.previousElementSibling
_updateSiblingElements($sibling, true)
$sibling = $wrapper.nextElementSibling
_updateSiblingElements($sibling)
}, 350)
}
export default print
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。