From dad1a2f3651b869e7d41f5464819d14a280b20ce Mon Sep 17 00:00:00 2001 From: Petrisor Lacatus Date: Tue, 5 Sep 2023 18:28:34 +0300 Subject: [PATCH] feat: Added a new `ResetSelection` service that clears all selected items. Fix #41 --- src/svgViewer.ide.ts | 3 +++ src/svgViewer.runtime.ts | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/svgViewer.ide.ts b/src/svgViewer.ide.ts index 5a1e52f..454d4a3 100644 --- a/src/svgViewer.ide.ts +++ b/src/svgViewer.ide.ts @@ -121,6 +121,9 @@ export class SvgViewerWidget extends TWComposerWidget { description: 'Pans onto the selected element in the svg. PanAndZoom must be enabled for this to work.', }, + ResetSelection: { + description: 'Resets the selection, and leaves no element selected', + }, }; } diff --git a/src/svgViewer.runtime.ts b/src/svgViewer.runtime.ts index b4ddd9c..5ce47a9 100644 --- a/src/svgViewer.runtime.ts +++ b/src/svgViewer.runtime.ts @@ -3,9 +3,6 @@ import { TWWidgetDefinition, property, - canBind, - TWEvent, - event, service, } from 'typescriptwebpacksupport/widgetRuntimeSupport'; import { @@ -69,6 +66,13 @@ export class SvgViewerWidget extends TWRuntimeWidget { this.svgRenderer.panOntoElement(); } } + + @service('ResetSelection') + ResetSelection(): void { + this.svgRenderer.triggerElementSelectionByName([]); + this.updateSelection('Data', []); + } + renderHtml(): string { require('./styles/runtime.css');