Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Canvas Selectable #659

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions assets/diagram-js.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
--color-black: hsl(0, 0%, 0%);
--color-black-opacity-10: hsla(0, 0%, 0%, 10%);

--canvas-focus-box-shadow-color: var(--color-blue-205-100-50);
--canvas-fill-color: var(--color-white);

--bendpoint-fill-color: var(--color-blue-205-100-45);
Expand Down Expand Up @@ -88,6 +89,23 @@
--tooltip-error-color: var(--color-red-360-100-45);
}

/**
* SVG styles
*/

.djs-container svg:focus {
box-shadow: inset 0px 0px 0px 1px var(--canvas-focus-box-shadow-color);
outline: none;
}

.djs-container svg.drop-not-ok {
background: var(--shape-drop-not-allowed-fill-color) !important;
}

.djs-container svg.new-parent {
background: var(--shape-drop-allowed-fill-color) !important;
}

/**
* outline styles
*/
Expand Down Expand Up @@ -130,14 +148,6 @@
fill: var(--shape-drop-allowed-fill-color) !important;
}

svg.drop-not-ok {
background: var(--shape-drop-not-allowed-fill-color) !important;
}

svg.new-parent {
background: var(--shape-drop-allowed-fill-color) !important;
}


/* Override move cursor during drop and connect */
.drop-not-ok,
Expand Down
11 changes: 9 additions & 2 deletions lib/core/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from 'min-dash';

import {
assignStyle
assignStyle,
attr as domAttr
} from 'min-dom';

import {
Expand Down Expand Up @@ -166,7 +167,13 @@ Canvas.prototype._init = function(config) {
var container = this._container = createContainer(config);

var svg = this._svg = svgCreate('svg');
svgAttr(svg, { width: '100%', height: '100%' });

svgAttr(svg, {
width: '100%',
height: '100%'
});

domAttr(svg, 'tabindex', 0);

svgAppend(container, svg);

Expand Down
10 changes: 8 additions & 2 deletions test/spec/core/CanvasSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ describe('Canvas', function() {

beforeEach(createDiagram());


it('should create <svg> element', inject(function() {

// then
// when
var svg = container.querySelector('svg');

expect(svg).not.to.be.null;
// then
// svg is created
expect(svg).to.exist;

// and user selectable
expect(svgAttr(svg, 'tabindex')).to.equal('0');
}));

});
Expand Down