An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 面包屑优化
Vanessa571f753d660c
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.tsindex fa7928a04e..bb8b1605bc 100644--- a/app/src/protyle/breadcrumb/index.ts+++ b/app/src/protyle/breadcrumb/index.ts@@ -31,6 +31,7 @@ import {emitOpenMenu} from "../../plugin/EventBus";import {isInAndroid, isIPad, isMac, updateHotkeyTip} from "../util/compatibility";import {resize} from "../util/resize";import {listIndent, listOutdent} from "../wysiwyg/list";+import {improveBreadcrumbAppearance} from "../wysiwyg/renderBacklink";export class Breadcrumb {public element: HTMLElement;@@ -651,30 +652,8 @@ ${padHTML}html += '<svg class="protyle-breadcrumb__arrow"><use xlink:href="#iconRight"></use></svg>';}});- this.element.classList.remove("protyle-breadcrumb__bar--nowrap");this.element.innerHTML = html;- const itemElements = Array.from(this.element.querySelectorAll(".protyle-breadcrumb__text"));- if (itemElements.length === 0) {- return;- }- let jump = false;- while (this.element.scrollHeight > 30 && !jump && itemElements.length > 1) {- itemElements.find((item, index) => {- if (index > 0) {- if (!item.classList.contains("protyle-breadcrumb__text--ellipsis")) {- item.classList.add("protyle-breadcrumb__text--ellipsis");- return true;- }- if (index === itemElements.length - 1 && item.classList.contains("protyle-breadcrumb__text--ellipsis")) {- jump = true;- }- }- });- }- this.element.classList.add("protyle-breadcrumb__bar--nowrap");- if (this.element.lastElementChild) {- this.element.scrollLeft = (this.element.lastElementChild as HTMLElement).offsetLeft - this.element.clientWidth + 14;- }+ improveBreadcrumbAppearance(this.element.parentElement);});/// #endif}diff --git a/app/src/protyle/render/blockRender.ts b/app/src/protyle/render/blockRender.tsindex 6eb9f88a48..41e416b15c 100644--- a/app/src/protyle/render/blockRender.ts+++ b/app/src/protyle/render/blockRender.ts@@ -3,7 +3,7 @@ import {fetchPost, fetchSyncPost} from "../../util/fetch";import {processRender} from "../util/processCode";import {highlightRender} from "./highlightRender";import {Constants} from "../../constants";-import {genBreadcrumb} from "../wysiwyg/renderBacklink";+import {genBreadcrumb, improveBreadcrumbAppearance} from "../wysiwyg/renderBacklink";import {avRender} from "./av/render";export const blockRender = (protyle: IProtyle, element: Element, top?: number) => {@@ -115,6 +115,7 @@ const renderEmbed = (blocks: {item.lastElementChild.insertAdjacentHTML("beforebegin", html +// 辅助上下移动时进行选中`<div style="position: absolute;">${Constants.ZWSP}</div>`);+ improveBreadcrumbAppearance(item.querySelector(".protyle-wysiwyg__embed"));} else {item.lastElementChild.insertAdjacentHTML("beforebegin", `<div class="ft__smaller ft__secondary b3-form__space--small" contenteditable="false">${window.siyuan.languages.refExpired}</div><div style="position: absolute;">${Constants.ZWSP}</div>`);diff --git a/app/src/protyle/wysiwyg/renderBacklink.ts b/app/src/protyle/wysiwyg/renderBacklink.tsindex 829ab3c0d4..4ceea4916d 100644--- a/app/src/protyle/wysiwyg/renderBacklink.ts+++ b/app/src/protyle/wysiwyg/renderBacklink.ts@@ -19,9 +19,7 @@ export const renderBacklink = (protyle: IProtyle, backlinkData: {html += genBreadcrumb(item.blockPaths, false, index) + setBacklinkFold(item.dom, item.expand);});protyle.wysiwyg.element.innerHTML = html;- protyle.wysiwyg.element.querySelectorAll(".protyle-breadcrumb__bar .protyle-breadcrumb__item--active").forEach((item:HTMLElement) => {- item.parentElement.scrollLeft = item.offsetLeft;- });+ improveBreadcrumbAppearance(protyle.wysiwyg.element);processRender(protyle.wysiwyg.element);highlightRender(protyle.wysiwyg.element);avRender(protyle.wysiwyg.element, protyle);@@ -120,5 +118,33 @@ export const genBreadcrumb = (blockPaths: IBreadcrumb[], renderFirst: boolean, phtml += '<svg class="protyle-breadcrumb__arrow"><use xlink:href="#iconRight"></use></svg>';}});- return `<div contenteditable="false" style="margin-bottom: 8px" class="protyle-breadcrumb__bar protyle-breadcrumb__bar--nowrap">${html}</div>`;+ return `<div contenteditable="false" class="protyle-breadcrumb__bar protyle-breadcrumb__bar--nowrap">${html}</div>`;};++export const improveBreadcrumbAppearance = (element: HTMLElement) => {+ element.querySelectorAll(".protyle-breadcrumb__bar").forEach((item: HTMLElement) => {+ item.classList.remove("protyle-breadcrumb__bar--nowrap");+ const itemElements = Array.from(item.querySelectorAll(".protyle-breadcrumb__text"));+ if (itemElements.length === 0) {+ return;+ }+ let jump = false;+ while (item.scrollHeight > 30 && !jump && itemElements.length > 1) {+ itemElements.find((item, index) => {+ if (index > 0) {+ if (!item.classList.contains("protyle-breadcrumb__text--ellipsis")) {+ item.classList.add("protyle-breadcrumb__text--ellipsis");+ return true;+ }+ if (index === itemElements.length - 1 && item.classList.contains("protyle-breadcrumb__text--ellipsis")) {+ jump = true;+ }+ }+ });+ }+ item.classList.add("protyle-breadcrumb__bar--nowrap");+ if (item.lastElementChild) {+ item.scrollLeft = (item.lastElementChild as HTMLElement).offsetLeft - item.clientWidth + 14;+ }+ });+}