From 9de70ec264828b174f0a135b19824ce0c5ae1828 Mon Sep 17 00:00:00 2001 From: linkun Date: Wed, 5 Nov 2025 20:49:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=BF=9E=E7=BA=BFvertices=E5=B7=A5=E5=85=B7removeRedundancies?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BAfalse=E6=97=B6=EF=BC=8C=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E8=BF=9E=E7=BA=BF=E6=97=A0=E6=B3=95=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E9=98=9F=E5=88=97=E3=80=81mouseup=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=86=92=E6=B3=A1=E5=88=B0=E8=BF=9E=E7=BA=BF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/x6/src/registry/tool/vertices.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/x6/src/registry/tool/vertices.ts b/packages/x6/src/registry/tool/vertices.ts index b6ffe3a4e03..c3822edad7c 100644 --- a/packages/x6/src/registry/tool/vertices.ts +++ b/packages/x6/src/registry/tool/vertices.ts @@ -183,13 +183,15 @@ export class Vertices extends ToolsView.ToolItem { return } - const verticesRemoved = edgeView.removeRedundantLinearVertices({ - ui: true, - toolId: this.cid, - }) + if (options.removeRedundancies) { + const verticesRemoved = edgeView.removeRedundantLinearVertices({ + ui: true, + toolId: this.cid, + }) - if (verticesRemoved) { - this.render() + if (verticesRemoved) { + this.render() + } } this.blur() From 89f45f40b96f2ee296671a236bba1495100db429 Mon Sep 17 00:00:00 2001 From: linkun Date: Thu, 6 Nov 2025 17:26:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20#4869=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/x6/src/registry/tool/vertices.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/x6/src/registry/tool/vertices.ts b/packages/x6/src/registry/tool/vertices.ts index c3822edad7c..02e365d7f21 100644 --- a/packages/x6/src/registry/tool/vertices.ts +++ b/packages/x6/src/registry/tool/vertices.ts @@ -179,10 +179,6 @@ export class Vertices extends ToolsView.ToolItem { this.updatePath() } - if (!options.removeRedundancies) { - return - } - if (options.removeRedundancies) { const verticesRemoved = edgeView.removeRedundantLinearVertices({ ui: true, From 4c458a2ec15f6e51fe58b71386cee6f11dad2494 Mon Sep 17 00:00:00 2001 From: linkun Date: Fri, 7 Nov 2025 10:51:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20#4869=20examples?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=AD=E8=A1=A5=E5=85=85=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E9=98=9F=E5=88=97&=E8=BF=9E=E7=BA=BFvertices=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=81=94=E5=90=88=E4=BD=BF=E7=94=A8=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/undo/index.tsx | 106 +++++++++++++++++- 1 file changed, 100 insertions(+), 6 deletions(-) diff --git a/examples/x6-example-features/src/pages/undo/index.tsx b/examples/x6-example-features/src/pages/undo/index.tsx index 695c8c785ab..1260f5ba210 100644 --- a/examples/x6-example-features/src/pages/undo/index.tsx +++ b/examples/x6-example-features/src/pages/undo/index.tsx @@ -22,10 +22,46 @@ export default class Example extends React.Component< container: this.container, width: 800, height: 600, - grid: true, - history: true, + grid: { + size: 10, + visible: true, + type: 'doubleMesh', + args: [ + { + color: '#e6e6e6', + thickness: 1 + }, + { + color: '#ddd', + thickness: 1, + factor: 4 + } + ] + }, + history: { + enabled: true, + beforeAddCommand(event, args) { + if (args && 'options' in args && args.options) { + return args.options.ignore !== true + } + } + }, + selecting: { + enabled: true + }, embedding: { enabled: true, + findParent({ node }) { + const bbox = node.getBBox() + return this.getNodes().filter((node) => { + const data = node.getData() + if (data && data.parent) { + const targetBBox = node.getBBox() + return bbox.isIntersectWithRect(targetBBox) + } + return false + }) + } }, }) @@ -42,6 +78,7 @@ export default class Example extends React.Component< y: 120, width: 100, height: 40, + zIndex: 10, attrs: { label: { text: 'Hello', @@ -50,13 +87,14 @@ export default class Example extends React.Component< strokeWidth: 1, }, }, - }) + }, { ignore: true }) const target = graph.addNode({ x: 300, y: 320, width: 100, height: 40, + zIndex: 10, attrs: { label: { text: 'World', @@ -65,13 +103,14 @@ export default class Example extends React.Component< strokeWidth: 1, }, }, - }) + }, { ignore: true }) graph.addNode({ x: 400, y: 100, width: 150, height: 150, + zIndex: 1, attrs: { label: { text: '🌎', @@ -80,9 +119,64 @@ export default class Example extends React.Component< strokeWidth: 1, }, }, + data: { + parent: true + }, + }, { ignore: true }) + + graph.addEdge( + { + source, + target, + arrts: { + line: { + strokeWidth: 1 + } + }, + vertices: [ + { + x: 220, + y: 220 + }, + { + x: 120, + y: 320 + }, + { + x: 300, + y: 400 + } + ] + }, + { ignore: true } + ) + + graph.on('edge:click', ({ cell }) => { + if (!cell.hasTool('vertices')) { + cell.addTools( + { + name: 'vertices', + args: { + stopPropagation: false, + addable: true, + removeable: false, + removeRedundancies: false, + snapRadius: 10, + attrs: { + r: 4 + } + } + } + ) + } }) - graph.addEdge({ source, target, arrts: { line: { strokeWidth: 1 } } }) + graph.on('edge:unselected', ({ cell }) => { + cell.removeTools() + }) + graph.on('edge:mouseup', ({ cell }) => { + console.log('edge:mouseup', cell) + }) } onUndo = () => { @@ -100,7 +194,7 @@ export default class Example extends React.Component< render() { return (
-

Default Settings

+

Edge Vertices & History & Embedding