From 1ab8be007856eeb18697ffbe36dfbb8b321ab3a7 Mon Sep 17 00:00:00 2001 From: ssshooter Date: Tue, 3 Oct 2023 19:46:45 +0800 Subject: [PATCH] fix: unselectLink before selection --- package.json | 2 +- src/customLink.ts | 5 +++++ src/index.ts | 2 +- src/mouse.ts | 1 + src/plugin/keypress.ts | 1 + src/plugin/selection.ts | 1 + 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2ab0cba5..7c22e1ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mind-elixir", - "version": "3.2.1", + "version": "3.2.2", "type": "module", "description": "Mind elixir is a free open source mind map core.", "keywords": [ diff --git a/src/customLink.ts b/src/customLink.ts index 338598d9..0f489b8d 100644 --- a/src/customLink.ts +++ b/src/customLink.ts @@ -175,6 +175,11 @@ export const selectLink = function (this: MindElixirInstance, link: CustomSvg) { this.showLinkController(obj, fromData, toData) } +export const unselectLink = function (this: MindElixirInstance) { + this.currentLink = null + this.hideLinkController() +} + export const hideLinkController = function (this: MindElixirInstance) { this.linkController.style.display = 'none' this.P2.style.display = 'none' diff --git a/src/index.ts b/src/index.ts index 37e13d55..07236046 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,7 +126,7 @@ MindElixir.DARK_THEME = DARK_THEME * @memberof MindElixir * @static */ -MindElixir.version = '3.2.1' +MindElixir.version = '3.2.2' /** * @function * @memberof MindElixir diff --git a/src/mouse.ts b/src/mouse.ts index 8df8a247..52033eea 100644 --- a/src/mouse.ts +++ b/src/mouse.ts @@ -16,6 +16,7 @@ export default function (mind: MindElixirInstance) { mind.unselectNode() mind.unselectNodes() mind.unselectSummary() + mind.unselectLink() // e.preventDefault() // can cause tags don't work const target = e.target as any if (target.tagName === 'ME-EPD') { diff --git a/src/plugin/keypress.ts b/src/plugin/keypress.ts index bdb6eda8..6b821e92 100644 --- a/src/plugin/keypress.ts +++ b/src/plugin/keypress.ts @@ -136,6 +136,7 @@ export default function (mind: MindElixirInstance) { } if (e.keyCode === 8 || e.keyCode === 46) { // del,backspace + // bug if (mind.currentLink) mind.removeLink() else if (mind.currentSummary) mind.removeSummary(mind.currentSummary.summaryObj.id) else mind.removeNode() diff --git a/src/plugin/selection.ts b/src/plugin/selection.ts index 71ed16e2..b65c760e 100644 --- a/src/plugin/selection.ts +++ b/src/plugin/selection.ts @@ -35,6 +35,7 @@ export default function (mei: MindElixirInstance) { mei.unselectNode() mei.unselectNodes() mei.unselectSummary() + mei.unselectLink() selection.clearSelection(true, true) } })