mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 23:16:52 +00:00
Merge branch 'main' into develop
This commit is contained in:
@@ -51,35 +51,36 @@ function renderPrismMac() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// Add line numbers
|
||||||
|
const codeBlocks = container?.getElementsByTagName('pre')
|
||||||
|
if (codeBlocks) {
|
||||||
|
Array.from(codeBlocks).forEach(item => {
|
||||||
|
if (!item.classList.contains('line-numbers')) {
|
||||||
|
item.classList.add('line-numbers')
|
||||||
|
item.style.whiteSpace = 'pre-wrap'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
// Add pre-mac element for Mac Style UI
|
||||||
|
if (codeToolBars) {
|
||||||
|
Array.from(codeToolBars).forEach(item => {
|
||||||
|
const existPreMac = item.getElementsByClassName('pre-mac')
|
||||||
|
if (existPreMac.length < codeToolBars.length) {
|
||||||
|
const preMac = document.createElement('div')
|
||||||
|
preMac.classList.add('pre-mac')
|
||||||
|
preMac.innerHTML = '<span></span><span></span><span></span>'
|
||||||
|
item?.appendChild(preMac, item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 10)
|
||||||
|
|
||||||
// 重新渲染之前检查所有的多余text
|
// 重新渲染之前检查所有的多余text
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Prism.highlightAll()
|
Prism.highlightAll()
|
||||||
// Add line numbers
|
|
||||||
const codeBlocks = container?.getElementsByTagName('pre')
|
|
||||||
if (codeBlocks) {
|
|
||||||
Array.from(codeBlocks).forEach(item => {
|
|
||||||
if (!item.classList.contains('line-numbers')) {
|
|
||||||
item.classList.add('line-numbers')
|
|
||||||
item.style.whiteSpace = 'pre-wrap'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
// Add pre-mac element for Mac Style UI
|
|
||||||
if (codeToolBars) {
|
|
||||||
Array.from(codeToolBars).forEach(item => {
|
|
||||||
const existPreMac = item.getElementsByClassName('pre-mac')
|
|
||||||
if (existPreMac.length < codeToolBars.length) {
|
|
||||||
const preMac = document.createElement('div')
|
|
||||||
preMac.classList.add('pre-mac')
|
|
||||||
preMac.innerHTML = '<span></span><span></span><span></span>'
|
|
||||||
item?.appendChild(preMac, item)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, 10)
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('代码渲染', err)
|
console.log('代码渲染', err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default function ArticleDetail(props) {
|
|||||||
const { locale } = useGlobal()
|
const { locale } = useGlobal()
|
||||||
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
|
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
|
||||||
return (<div id="container" className="max-w-5xl overflow-x-auto flex-grow mx-auto w-screen md:w-full ">
|
return (<div id="container" className="max-w-5xl overflow-x-auto flex-grow mx-auto w-screen md:w-full ">
|
||||||
{post?.type && !post?.type.includes('Page') && post?.page_cover && (
|
{post?.type && !post?.type !== 'Page' && post?.page_cover && (
|
||||||
<div className="w-full relative md:flex-shrink-0 overflow-hidden">
|
<div className="w-full relative md:flex-shrink-0 overflow-hidden">
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img alt={post.title} src={post?.page_cover} className='object-center w-full' />
|
<img alt={post.title} src={post?.page_cover} className='object-center w-full' />
|
||||||
|
|||||||
Reference in New Issue
Block a user