diff --git a/app/src/assets/scss/business/_graph.scss b/app/src/assets/scss/business/_graph.scss index 874560fb1..bd2724758 100644 --- a/app/src/assets/scss/business/_graph.scss +++ b/app/src/assets/scss/business/_graph.scss @@ -56,7 +56,8 @@ padding: 4px 8px; color: var(--b3-theme-on-surface); max-width: 10vw; - word-break: break-all; + white-space: break-spaces; + @include text-clamp(3); } } } diff --git a/app/src/layout/dock/Graph.ts b/app/src/layout/dock/Graph.ts index bb83fd8e4..5149e4e84 100644 --- a/app/src/layout/dock/Graph.ts +++ b/app/src/layout/dock/Graph.ts @@ -510,10 +510,8 @@ export class Graph extends Model { // 界面没有渲染时不能进行渲染 return; } + this.network?.destroy(); if (!this.graphData || !this.graphData.nodes || this.graphData.nodes.length === 0) { - if (this.network) { - this.network.destroy(); - } return; } // 使用颜色 @@ -567,10 +565,8 @@ export class Graph extends Model { } }); addScript(`${Constants.PROTYLE_CDN}/js/vis/vis-network.min.js?v=9.1.2`, "protyleVisScript").then(() => { + this.network?.destroy(); if (!this.graphData || !this.graphData.nodes || this.graphData.nodes.length === 0) { - if (this.network) { - this.network.destroy(); - } return; } const config = window.siyuan.config.graph[this.type === "global" ? "global" : "local"]; diff --git a/app/src/protyle/util/hasClosest.ts b/app/src/protyle/util/hasClosest.ts index 5c11131cc..a031988a8 100644 --- a/app/src/protyle/util/hasClosest.ts +++ b/app/src/protyle/util/hasClosest.ts @@ -1,5 +1,5 @@ export const hasClosestByTag = (element: Node, nodeName: string) => { - if (!element) { + if (!element || element.nodeType === 9) { return false; } if (element.nodeType === 3) { @@ -63,7 +63,7 @@ export const hasTopClosestByAttribute = (element: Node, attr: string, value: str }; export const hasClosestByAttribute = (element: Node, attr: string, value: string | null, top = false) => { - if (!element) { + if (!element || element.nodeType === 9) { return false; } if (element.nodeType === 3) { @@ -92,7 +92,7 @@ export const hasClosestBlock = (element: Node) => { }; export const hasClosestByMatchTag = (element: Node, nodeName: string) => { - if (!element) { + if (!element || element.nodeType === 9) { return false; } if (element.nodeType === 3) { @@ -111,7 +111,7 @@ export const hasClosestByMatchTag = (element: Node, nodeName: string) => { }; export const hasClosestByClassName = (element: Node, className: string, top = false) => { - if (!element) { + if (!element || element.nodeType === 9) { return false; } if (element.nodeType === 3) {