Skip to content

Commit

Permalink
feat: Added a new ResetSelection service that clears all selected i…
Browse files Browse the repository at this point in the history
…tems. Fix #41
  • Loading branch information
stefan-lacatus committed Sep 5, 2023
1 parent 8c73edc commit dad1a2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/svgViewer.ide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
}

Expand Down
10 changes: 7 additions & 3 deletions src/svgViewer.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import {
TWWidgetDefinition,
property,
canBind,
TWEvent,
event,
service,
} from 'typescriptwebpacksupport/widgetRuntimeSupport';
import {
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit dad1a2f

Please sign in to comment.