From 3a6ab971e2e07254ad9cbbca742328ede614bc78 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 4 Nov 2024 11:25:45 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E7=84=A6=E7=82=B9=E5=9C=A8=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E5=9B=BE=E4=B8=8A=E6=97=B6=E6=90=9C=E7=B4=A2=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/assets/scss/business/_graph.scss | 3 ++- app/src/layout/dock/Graph.ts | 8 ++------ app/src/protyle/util/hasClosest.ts | 8 ++++---- 3 files changed, 8 insertions(+), 11 deletions(-) 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) {