Skip to content

Commit

Permalink
feat(front): add remove method to highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 25, 2024
1 parent b4e9e5a commit 1ff19a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.4.0-alpha.15",
"version": "2.4.0-alpha.16",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down Expand Up @@ -47,7 +47,7 @@
"web-ifc": "0.0.61"
},
"dependencies": {
"@thatopen/components": ">=2.4.0-alpha.3",
"@thatopen/components": ">=2.4.0-alpha.12",
"camera-controls": "2.7.3",
"dexie": "^4.0.4",
"earcut": "^2.2.4",
Expand Down
21 changes: 20 additions & 1 deletion packages/front/src/fragments/Highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,26 @@ export class Highlighter
onClear,
onBeforeHighlight,
};
this.eventManager.add([onClear, onHighlight]);
this.eventManager.add([onClear, onHighlight, onBeforeHighlight]);
}

/**
* Removes the specified selection.
*
* @param name - The name of the new selection.
*/
remove(name: string) {
this.clear(name);
delete this.selection[name];
this.colors.delete(name);
if (this.selection[name] || this.colors.has(name)) {
throw new Error("A selection with that name already exists!");
}
if (this.events[name]) {
const { onHighlight, onClear, onBeforeHighlight } = this.events[name];
this.eventManager.remove([onClear, onHighlight, onBeforeHighlight]);
delete this.events[name];
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@thatopen/components-front@workspace:packages/front"
dependencies:
"@thatopen/components": ">=2.4.0-alpha.3"
"@thatopen/components": ">=2.4.0-alpha.12"
"@thatopen/fragments": ">=2.4.0-alpha.8"
"@thatopen/ui": ~2.3.0
"@thatopen/ui-obc": ~2.3.0
Expand All @@ -709,7 +709,7 @@ __metadata:
languageName: unknown
linkType: soft

"@thatopen/components@>=2.4.0-alpha.3, @thatopen/components@workspace:packages/core":
"@thatopen/components@>=2.4.0-alpha.12, @thatopen/components@workspace:packages/core":
version: 0.0.0-use.local
resolution: "@thatopen/components@workspace:packages/core"
dependencies:
Expand Down

0 comments on commit 1ff19a5

Please sign in to comment.