mirror of
https://github.com/blossom-editor/blossom
synced 2024-11-17 14:39:21 +08:00
feat: 编辑时永远置底
This commit is contained in:
parent
f1e5dc5577
commit
e72031ea0e
@ -581,15 +581,7 @@ const initEditor = (_doc?: string) => {
|
||||
EditorRef.value
|
||||
)
|
||||
)
|
||||
// 创建元素
|
||||
let editorHeightHolder = document.createElement('div')
|
||||
editorHeightHolder.style.height = '65vh'
|
||||
editorHeightHolder.addEventListener('click', () => {
|
||||
let length = cmw.getDocLength()
|
||||
cmw.editor.focus()
|
||||
cmw.insert(length, length, '', length, length)
|
||||
})
|
||||
EditorRef.value.appendChild(editorHeightHolder)
|
||||
appendEditorHolder()
|
||||
}
|
||||
/**
|
||||
* 将 markdown 原文设置到编辑器中, 并且会重置编辑器状态
|
||||
@ -611,6 +603,19 @@ const setNewState = (md: string): void => {
|
||||
parse()
|
||||
}
|
||||
|
||||
const appendEditorHolder = () => {
|
||||
// 创建元素
|
||||
let editorHeightHolder = document.createElement('div')
|
||||
editorHeightHolder.style.height = '65vh'
|
||||
editorHeightHolder.style.position = 'relative'
|
||||
editorHeightHolder.addEventListener('click', () => {
|
||||
let length = cmw.getDocLength()
|
||||
cmw.editor.focus()
|
||||
cmw.insert(length, length, '', length, length)
|
||||
})
|
||||
EditorRef.value.appendChild(editorHeightHolder)
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region ----------------------------------------< marked/preview >-------------------------------
|
||||
@ -640,7 +645,7 @@ const renderer = {
|
||||
articleImg.value.push({ targetId: '0', targetName: text, targetUrl: href as string, type: 10 })
|
||||
return renderImage(href, _title, text)
|
||||
},
|
||||
link(href: string | null, title: string | null, text: string): string {
|
||||
link(href: string, title: string | null | undefined, text: string): string {
|
||||
let { link, ref } = renderLink(href, title, text, ArticleTreeDocsRef.value.getDocTreeData())
|
||||
articleLink.value.push(ref)
|
||||
return link
|
||||
@ -656,7 +661,6 @@ const tokenizer = {
|
||||
}
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
marked.use({ tokenizer: tokenizer, renderer: renderer })
|
||||
|
||||
/**
|
||||
@ -671,7 +675,22 @@ const parse = () => {
|
||||
articleHtml.value = content
|
||||
renderInterval.value = Date.now() - begin
|
||||
articleParseing = false
|
||||
nextTick(() => parseToc())
|
||||
nextTick(() => {
|
||||
parseToc()
|
||||
|
||||
let previewHeightHolder = document.createElement('div')
|
||||
previewHeightHolder.style.height = '60vh'
|
||||
PreviewRef.value.appendChild(previewHeightHolder)
|
||||
|
||||
const clientHeight = EditorRef.value.clientHeight
|
||||
const scrollTop = EditorRef.value.scrollTop
|
||||
const scrollHeight = EditorRef.value.scrollHeight
|
||||
let a = clientHeight + scrollTop
|
||||
if (a >= scrollHeight - 150) {
|
||||
EditorRef.value.scrollTop = 99999999
|
||||
PreviewRef.value.scrollTop = 99999999
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ export const renderCode = (code: string, language: string | undefined, _isEscape
|
||||
if (tag.startsWith('h')) {
|
||||
height = tags[i].substring(1)
|
||||
if (!height.endsWith('%')) {
|
||||
width += 'px'
|
||||
height += 'px'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,7 +325,7 @@ export const renderCode = (code: string, language: string | undefined, _isEscape
|
||||
}
|
||||
|
||||
return `<iframe width="${width}" height="${height}" style="margin: 10px 0"
|
||||
scrolling="no" border="0" frameborder="no" framespacing="0"
|
||||
scrolling="no" border="0" frameborder="no" framespacing="0" loading="lazy"
|
||||
src="https://player.bilibili.com/player.html?bvid=${bvid}&page=1&autoplay=0" ></iframe>`
|
||||
}
|
||||
const id = 'pre-' + Date.now() + '-' + randomInt(1, 1000000)
|
||||
@ -398,7 +398,7 @@ export const renderImage = (href: string | null, title: string | null, text: str
|
||||
* ref: 双链内容
|
||||
* }
|
||||
*/
|
||||
export const renderLink = (href: string | null, title: string | null, text: string, docTrees: DocTree[]) => {
|
||||
export const renderLink = (href: string, title: string | null | undefined, text: string, docTrees: DocTree[]) => {
|
||||
let link: string
|
||||
let ref: ArticleReference = { targetId: '0', targetName: text, targetUrl: href as string, type: 21 }
|
||||
if (isBlank(title)) {
|
||||
|
Loading…
Reference in New Issue
Block a user