BLock Editor大纲导航栏向下滚动时增加固定效果
This commit is contained in:
parent
405267b026
commit
c4b242e01f
@ -1055,7 +1055,7 @@ function icon(name: string): string {
|
||||
.blockeditor-outline-rail-wrapper {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
top: 48px; /* 工具栏下方 */
|
||||
top: 100px; /* 相对工具栏 100px */
|
||||
bottom: 12px;
|
||||
width: 24px;
|
||||
overflow: visible;
|
||||
@ -1063,6 +1063,15 @@ function icon(name: string): string {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* 工具栏固定时,大纲导航栏同步固定到容器右侧 */
|
||||
.blockeditor-container .n-affix--affixed ~ .blockeditor-outline-rail-wrapper {
|
||||
position: fixed;
|
||||
top: calc(64px + 100px); /* header + 相对工具栏 100px */
|
||||
bottom: 12px;
|
||||
left: calc(var(--be-container-left) + var(--be-container-width) - 30px);
|
||||
right: auto;
|
||||
}
|
||||
|
||||
/* ── ProseMirror ── */
|
||||
.blockeditor-mount .ProseMirror { outline: none; min-height: 120px; padding-left: 48px; padding-right: 36px; }
|
||||
.blockeditor-mount .ProseMirror > * + * { margin-top: 0.5em; }
|
||||
|
||||
@ -159,13 +159,21 @@ function syncActive() {
|
||||
}
|
||||
|
||||
// ── Helpers ────────────────────────────────────────────────────────────────────
|
||||
/** 获取页面导航栏底部位置(即内容区顶部在视口中的 y 坐标) */
|
||||
/** 获取页面导航栏底部位置(即内容区顶部在视口中的 y 坐标)
|
||||
* 工具栏固定时自动计入工具栏高度,确保内容不被遮挡 */
|
||||
function getContentTop(): number {
|
||||
const header = document.querySelector('.n-layout-header')
|
||||
if (header) {
|
||||
return header.getBoundingClientRect().bottom
|
||||
let top = header ? header.getBoundingClientRect().bottom : 64
|
||||
|
||||
// 工具栏固定时,额外补偿工具栏高度
|
||||
const affixedToolbar = document.querySelector(
|
||||
'.blockeditor-container .n-affix--affixed .blockeditor-toolbar'
|
||||
)
|
||||
if (affixedToolbar) {
|
||||
top += affixedToolbar.getBoundingClientRect().height
|
||||
}
|
||||
return 64 // fallback: AppHeader 高度为 64px
|
||||
|
||||
return top
|
||||
}
|
||||
|
||||
/** 向上查找真正可滚动的祖先容器 */
|
||||
@ -262,12 +270,12 @@ function scrollToBlock(block: BlockInfo) {
|
||||
|
||||
const { view } = props.editor
|
||||
|
||||
// ProseMirror transaction: 设置选区到 heading 行内内容
|
||||
view.dispatch(
|
||||
view.state.tr.setSelection(
|
||||
TextSelection.create(view.state.doc, block.pos + 1),
|
||||
),
|
||||
// ProseMirror transaction: 设置选区到 heading 行内内容(阻止自动滚动,由下方手动控制)
|
||||
const tr = view.state.tr.setSelection(
|
||||
TextSelection.create(view.state.doc, block.pos + 1),
|
||||
)
|
||||
tr.scrollIntoView = false
|
||||
view.dispatch(tr)
|
||||
|
||||
// 定位标题到导航栏下方,留少量边距
|
||||
const domNode = view.nodeDOM(block.pos)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user