Skip to content

Commit

Permalink
Fix Junction points post processor
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Fontorbe <[email protected]>
  • Loading branch information
gfontorbe committed Apr 29, 2024
1 parent 0c679d4 commit 7604624
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/sprotty/src/features/edge-junction/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const edgeJunctionModule = new ContainerModule(bind => {
bind(TYPES.IEdgeRoutePostprocessor).toService(JunctionFinder);
bind(JunctionPostProcessor).toSelf().inSingletonScope();
bind(TYPES.IVNodePostprocessor).toService(JunctionPostProcessor);
bind(TYPES.HiddenVNodePostprocessor).toService(JunctionPostProcessor);
});

export default edgeJunctionModule;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { injectable, inject } from "inversify";
import { IVNodePostprocessor } from "../../base/views/vnode-postprocessor";
import { VNode } from "snabbdom";
import { Action } from "sprotty-protocol";
import { Action, RequestBoundsAction } from "sprotty-protocol";
import { SModelElementImpl } from "../../base/model/smodel";
import { TYPES } from "../../base/types";
import { ViewerOptions } from "../../base/views/viewer-options";
Expand All @@ -34,10 +34,17 @@ export class JunctionPostProcessor implements IVNodePostprocessor {
return vnode;
}
postUpdate(cause?: Action | undefined): void {
const baseDiv = this.viewerOptions.baseDiv;
const svg = document.querySelector(`#${baseDiv} > svg > g`);
let targetDiv: string = this.viewerOptions.baseDiv;
let junctionSelector = `#${targetDiv} > svg > g > g.sprotty-junction`;

if (cause?.kind === RequestBoundsAction.KIND) {
targetDiv = this.viewerOptions.hiddenDiv;
junctionSelector = `#${targetDiv} > svg > g > g > g.sprotty-junction`;
}

const svg = document.querySelector(`#${targetDiv} > svg > g`);
if (svg) {
const junctionGroups = Array.from(document.querySelectorAll('g.sprotty-junction'));
const junctionGroups = Array.from(document.querySelectorAll(junctionSelector));

junctionGroups.forEach(junctionGroup => {
junctionGroup.remove();
Expand Down
1 change: 1 addition & 0 deletions packages/sprotty/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export * from './features/edge-intersection/intersection-finder';
export * from './features/edge-intersection/sweepline';

export * from './features/edge-junction/junction-finder';
export * from './features/edge-junction/junction-postprocessor';

export * from './features/move/model';
export * from './features/move/move';
Expand Down

0 comments on commit 7604624

Please sign in to comment.