diagram-js-direct-editing
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -19,3 +19,3 @@ 'use strict'; | ||
container: canvas.getPaper().node.parentNode, | ||
keyHandler: this.handleKey.bind(this) | ||
keyHandler: _.bind(this._handleKey, this) | ||
}); | ||
@@ -77,5 +77,7 @@ } | ||
var text = this._textbox.getValue(); | ||
var text = this.getValue(); | ||
active.provider.update(active.element, text, active.context.text); | ||
if (text !== active.context.text) { | ||
active.provider.update(active.element, text, active.context.text); | ||
} | ||
@@ -86,4 +88,9 @@ this.close(); | ||
DirectEditing.prototype.handleKey = function(e) { | ||
DirectEditing.prototype.getValue = function() { | ||
return this._textbox.getValue(); | ||
}; | ||
DirectEditing.prototype._handleKey = function(e) { | ||
// stop bubble | ||
@@ -90,0 +97,0 @@ e.stopPropagation(); |
@@ -31,3 +31,5 @@ 'use strict'; | ||
.css(css) | ||
.attr('title', 'Press SHIFT+Enter for line feed') | ||
.focus() | ||
.select() | ||
.on('keydown', this.keyHandler); | ||
@@ -38,2 +40,3 @@ }; | ||
this.textarea | ||
.val('') | ||
.remove() | ||
@@ -40,0 +43,0 @@ .off('keydown', this.keyHandler); |
{ | ||
"name": "diagram-js-direct-editing", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Direct editing support for diagram-js", | ||
@@ -25,3 +25,2 @@ "scripts": { | ||
"grunt-contrib-uglify": "~0.4.0", | ||
"grunt-browserify": "~2.1.0", | ||
"grunt-jsdoc": "~0.5.1", | ||
@@ -40,3 +39,3 @@ "grunt-karma": "~0.8.0", | ||
"karma-bro": "~0.2.0", | ||
"diagram-js": "~0.1.0", | ||
"diagram-js": "~0.2.0", | ||
"jquery": "~2.1.1", | ||
@@ -46,3 +45,3 @@ "lodash": "~2.4.0" | ||
"peerDependencies": { | ||
"diagram-js": "~0.1.0", | ||
"diagram-js": "~0.2.0", | ||
"jquery": "~2.1.1", | ||
@@ -49,0 +48,0 @@ "lodash": "~2.4.0" |
@@ -37,3 +37,3 @@ 'use strict'; | ||
describe('usage', function() { | ||
describe('behavior', function() { | ||
@@ -73,2 +73,3 @@ var DirectEditingProvider = require('./DirectEditingProvider'); | ||
expect(activated).toBe(true); | ||
expect(directEditing.getValue()).toBe('FOO'); | ||
@@ -198,4 +199,46 @@ // textbox is correctly positioned | ||
describe('textbox', function() { | ||
it('should init label on open', inject(function(canvas, directEditing) { | ||
// given | ||
var shape = { | ||
id: 's1', | ||
x: 20, y: 10, width: 60, height: 50, | ||
label: 'FOO' | ||
}; | ||
canvas.addShape(shape); | ||
// when | ||
directEditing.activate(shape); | ||
// then | ||
expect(directEditing._textbox.textarea.val()).toBe('FOO'); | ||
})); | ||
it('should clear label after close', inject(function(canvas, directEditing) { | ||
// given | ||
var shape = { | ||
id: 's1', | ||
x: 20, y: 10, width: 60, height: 50, | ||
label: 'FOO' | ||
}; | ||
canvas.addShape(shape); | ||
// when | ||
directEditing.activate(shape); | ||
directEditing.cancel(); | ||
// then | ||
expect(directEditing._textbox.textarea.val()).toBe(''); | ||
})); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16093
22
392