diff --git a/app/src/assets/scss/_protyle.scss b/app/src/assets/scss/_protyle.scss index 34201b66e..831da373d 100644 --- a/app/src/assets/scss/_protyle.scss +++ b/app/src/assets/scss/_protyle.scss @@ -4,16 +4,18 @@ @import "search"; .protyle-scroll { + --b3-dynamicscroll-width: 200px; position: absolute; right: 0; - height: 100%; - top: 0; + top: 30px; width: 16px; padding: 0 8px; + bottom: 9px; // 下图标 hover 时,需要留出一定的空间 svg { height: 16px; width: 16px; + display: block; } &__down, @@ -23,7 +25,6 @@ opacity: 0; cursor: pointer; color: var(--b3-border-color); - margin-left: -0.5px; &:hover { color: var(--b3-theme-on-surface); @@ -31,11 +32,11 @@ } &__up { - top: calc(50% - 114px); + top: calc(50% - var(--b3-dynamicscroll-width) / 2 - 20px); } &__down { - bottom: calc(50% - 135px); + bottom: calc(50% - var(--b3-dynamicscroll-width) / 2 - 20px); } &:hover { @@ -47,13 +48,14 @@ &__bar { position: absolute; - right: -89px; - top: 50%; + right: calc(11px - var(--b3-dynamicscroll-width) / 2); + top: calc(50% - 8px); transform: rotate(90deg); z-index: 1; .b3-slider { - width: 200px; + width: var(--b3-dynamicscroll-width); + display: block; } } } diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index 045a8c3f1..fa70bdfd3 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -9,6 +9,9 @@ import {Constants} from "../constants"; import {openNewWindowById} from "../window/openNewWindow"; /// #endif import {disabledProtyle} from "../protyle/util/onGet"; +import {fetchPost} from "../util/fetch"; +import {lockFile} from "../dialog/processSystem"; +import {showMessage} from "../dialog/message"; export class BlockPanel { public element: HTMLElement; @@ -241,37 +244,49 @@ export class BlockPanel { private initProtyle(editorElement: HTMLElement) { const index = parseInt(editorElement.getAttribute("data-index")); - const action = [Constants.CB_GET_ALL]; - if (this.targetElement.classList.contains("protyle-attr--refcount") || - this.targetElement.classList.contains("counter")) { - action.push(Constants.CB_GET_BACKLINK); - } - const editor = new Protyle(editorElement, { - blockId: this.nodeIds[index], - defId: this.defIds[index] || this.defIds[0] || "", - action, - render: { - gutter: true, - breadcrumbDocName: true, - breadcrumbContext: true - }, - typewriterMode: false, - after: (editor) => { - if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { - disabledProtyle(editor.protyle); - } - editorElement.addEventListener("mouseleave", () => { - hideElements(["gutter"], editor.protyle); - }); - // 浮窗完整文档面包屑应不显示 退出聚焦 - if (editor.protyle.breadcrumb && editor.protyle.block.id === editor.protyle.block.rootID) { - const exitFocusElement = editor.protyle.breadcrumb.element.parentElement.querySelector('[data-type="exit-focus"]'); - exitFocusElement.classList.add("fn__none"); - exitFocusElement.nextElementSibling.classList.add("fn__none"); - } + fetchPost("api/block/getBlockInfo", {id: this.nodeIds[index]}, (response) => { + if (response.code === 2) { + // 文件被锁定 + lockFile(response.data); + return false; } - }); - this.editors.push(editor); + if (response.code === 3) { + showMessage(response.msg); + return; + } + const action = []; + if (response.data.rootID !== this.nodeIds[index]) { + action.push(Constants.CB_GET_ALL); + } + if (this.targetElement.classList.contains("protyle-attr--refcount") || + this.targetElement.classList.contains("counter")) { + action.push(Constants.CB_GET_BACKLINK); + } + const editor = new Protyle(editorElement, { + blockId: this.nodeIds[index], + defId: this.defIds[index] || this.defIds[0] || "", + action, + render: { + scroll: true, + gutter: true, + breadcrumbDocName: true, + }, + typewriterMode: false, + after: (editor) => { + if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { + disabledProtyle(editor.protyle); + } + editorElement.addEventListener("mouseleave", () => { + hideElements(["gutter"], editor.protyle); + }); + if (response.data.rootID !== this.nodeIds[index]) { + editor.protyle.breadcrumb.element.parentElement.insertAdjacentHTML("beforeend", ` +
`) + } + } + }); + this.editors.push(editor); + }) } public destroy() { diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts index 3c582b040..d283f6008 100644 --- a/app/src/history/diff.ts +++ b/app/src/history/diff.ts @@ -43,7 +43,6 @@ const renderCompare = (element: HTMLElement) => { gutter: false, breadcrumb: false, breadcrumbDocName: false, - breadcrumbContext: false, }, typewriterMode: false }); @@ -57,7 +56,6 @@ const renderCompare = (element: HTMLElement) => { gutter: false, breadcrumb: false, breadcrumbDocName: false, - breadcrumbContext: false, }, typewriterMode: false }); diff --git a/app/src/history/history.ts b/app/src/history/history.ts index 2658b07a4..197adb944 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -342,7 +342,6 @@ export const openHistory = () => { gutter: false, breadcrumb: false, breadcrumbDocName: false, - breadcrumbContext: false, }, typewriterMode: false, }); diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.ts index 5b65ef4b6..186099cf5 100644 --- a/app/src/protyle/scroll/event.ts +++ b/app/src/protyle/scroll/event.ts @@ -32,11 +32,6 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => { hideElements(["gutter"], protyle); } - const panelContextElement = protyle.breadcrumb?.element.parentElement.querySelector('[data-type="context"]'); - if (panelContextElement && !panelContextElement.classList.contains("ft__primary")) { - // 悬浮窗需展开上下文后才能进行滚动 https://github.com/siyuan-note/siyuan/issues/2311 - return; - } if (protyle.scroll && !protyle.scroll.element.classList.contains("fn__none")) { clearTimeout(getIndexTimeout); getIndexTimeout = window.setTimeout(() => { diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts index 88bd2403d..c6b5c1444 100644 --- a/app/src/protyle/scroll/index.ts +++ b/app/src/protyle/scroll/index.ts @@ -19,13 +19,13 @@ export class Scroll { if (!isMobile()) { this.parentElement.style.right = "10px"; } - this.parentElement.innerHTML = `