mirror of
https://github.com/purocean/yn.git
synced 2026-10-12 23:31:39 +08:00
upd: 移除标题链接中的 h-
This commit is contained in:
@@ -50,14 +50,17 @@ const handleLink = (link: HTMLAnchorElement) => {
|
||||
if (hash) {
|
||||
await sleep(50)
|
||||
const el = document.getElementById(hash) ||
|
||||
document.getElementById(encodeURIComponent(hash))
|
||||
document.getElementById(encodeURIComponent(hash)) ||
|
||||
document.getElementById(hash.replace(/^h-/, '')) ||
|
||||
document.getElementById(encodeURIComponent(hash.replace(/^h-/, '')))
|
||||
|
||||
if (el) {
|
||||
el.scrollIntoView()
|
||||
|
||||
// 如果是标题的话,也顺便将编辑器滚动到可视区域
|
||||
if (hash.startsWith('h-')) {
|
||||
if (['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(el.tagName)) {
|
||||
el.click()
|
||||
}
|
||||
el.scrollIntoView()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Plugin } from '@fe/context/plugin'
|
||||
|
||||
import { injectLineNumbers } from './markdown-source-line'
|
||||
|
||||
const slugify = (s: string) => 'h-' + encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-'))
|
||||
const slugify = (s: string) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-'))
|
||||
|
||||
const defaults = {
|
||||
level: [2, 3],
|
||||
|
||||
Reference in New Issue
Block a user