Skip to content

Commit

Permalink
Revert "feat: remove selection outline"
Browse files Browse the repository at this point in the history
This reverts commit 651f40c.
  • Loading branch information
smbea committed Nov 3, 2023
1 parent ad8343b commit 27b3169
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions lib/features/outline/Outline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getBBox } from '../../util/Elements';

var LOW_PRIORITY = 500;

import {
Expand Down Expand Up @@ -75,6 +77,19 @@ export default function Outline(eventBus, styles) {
}
});

eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
var element = event.element,
gfx = event.gfx;

var outline = domQuery('.djs-outline', gfx);

if (!outline) {
outline = createOutline(gfx, element);
svgAppend(gfx, outline);
}

self.updateConnectionOutline(outline, element);
});
}


Expand Down Expand Up @@ -106,6 +121,25 @@ Outline.prototype.updateShapeOutline = function(outline, element) {
}
};

/**
* Updates the outline of a connection respecting the bounding box of
* the connection and an outline offset.
* Register an outline provider with the given priority.
*
* @param {SVGElement} outline
* @param {Element} connection
**/
Outline.prototype.updateConnectionOutline = function(outline, connection) {
var bbox = getBBox(connection);

svgAttr(outline, {
x: bbox.x - this.offset,
y: bbox.y - this.offset,
width: bbox.width + this.offset * 2,
height: bbox.height + this.offset * 2
});
};

/**
* Register an outline provider with the given priority.
*
Expand Down
4 changes: 2 additions & 2 deletions test/spec/features/outline/OutlineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('features/outline/Outline', function() {
}));


it('should not add outline to connection', inject(function(selection, canvas, elementRegistry) {
it('should add outline to connection', inject(function(selection, canvas, elementRegistry) {

// given
var connection = canvas.addConnection({ id: 'select1', waypoints: [ { x: 25, y: 25 }, { x: 115, y: 115 } ] });
Expand All @@ -63,7 +63,7 @@ describe('features/outline/Outline', function() {
var gfx = elementRegistry.getGraphics(connection);
var outline = domQuery('.djs-outline', gfx);

expect(outline).to.not.exist;
expect(outline).to.exist;
expect(svgClasses(gfx).has('selected')).to.be.true; // Outline class is set
}));

Expand Down

0 comments on commit 27b3169

Please sign in to comment.