chore(label-editing): deselect element during editing

This commit is contained in:
Nico Rehwaldt 2014-09-15 14:42:43 +02:00
parent 4428be4227
commit 66c7a31d34
2 changed files with 30 additions and 8 deletions

View File

@ -16,7 +16,7 @@ var MIN_BOUNDS = {
};
function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) {
function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, injector) {
directEditing.registerProvider(this);
commandStack.registerHandler('element.updateLabel', UpdateLabelHandler);
@ -40,10 +40,37 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack) {
directEditing.complete();
});
// remove and restore selection during direct editing
(function() {
try {
var selection = injector.get('selection');
var localSelection;
eventBus.on('directEditing.activate', function() {
localSelection = selection.get();
selection.select(null);
});
eventBus.on('directEditing.deactivate', function() {
selection.select(localSelection);
localSelection = null;
});
} catch (e) { }
})();
this._canvas = canvas;
this._commandStack = commandStack;
}
LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack', 'injector' ];
module.exports = LabelEditingProvider;
LabelEditingProvider.prototype.activate = function(element) {
@ -113,8 +140,3 @@ LabelEditingProvider.prototype.update = function(element, newLabel) {
newLabel: newLabel
});
};
LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack' ];
module.exports = LabelEditingProvider;

View File

@ -42,7 +42,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
var label = element.label;
if (label && dragContext.shapes.indexOf(label) === -1) {
if (label && !label.hidden && dragContext.shapes.indexOf(label) === -1) {
dragContext.shapes.push(label);
}
});