Skip to content

Commit 03f4c56

Browse files
committed
edit link labels
1 parent 0add4f7 commit 03f4c56

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

css/style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ body {
1010

1111
svg, svg text {
1212
font-family: Nunito, futura, helvetica, arial, sans-serif;
13-
font-weight:600;
13+
font-weight:600;
1414
}
1515
svg text {
1616
cursor: default;
@@ -261,9 +261,12 @@ header > button:hover {
261261
}
262262

263263
.editing .word-tag,
264+
.editing-text,
264265
.editing text {
265266
fill: #fff !important;
266267
}
268+
269+
.editing-rect,
267270
.editing rect {
268271
fill:#a94442;
269272
}

js/components/link.js

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -451,51 +451,30 @@ class Link {
451451
}
452452

453453
listenForEdit(e) {
454-
console.log('listening', e.detail.text, e.detail.text.text());
455454
this.isEditing = true;
456455

457456
let bbox = e.detail.text.bbox();
458-
this.svg.addClass('editing');
457+
e.detail.text.addClass('editing-text');
458+
this.editingText = e.detail.text;
459459
this.editingRect = this.svg.rect(bbox.width + 8, bbox.height + 4)
460460
.x(bbox.x - 4)
461461
.y(bbox.y - 2)
462462
.rx(2)
463463
.ry(2)
464+
.addClass('editing-rect')
464465
.back();
465-
466-
// listenForEdit() {
467-
// this.isEditing = true;
468-
// let bbox = this.svgText.bbox();
469-
//
470-
// this.svg.addClass('editing');
471-
// this.editingRect = this.svg.rect(bbox.width + 8, bbox.height + 4)
472-
// .x(bbox.x - 4)
473-
// .y(bbox.y - 2)
474-
// .rx(2)
475-
// .ry(2)
476-
// .back();
477-
// }
478-
// stopEditing() {
479-
// this.isEditing = false;
480-
// this.svg.removeClass('editing');
481-
// this.editingRect.remove();
482-
// this.editingRect = null;
483-
// this.val = this.val.trim();
484-
// if (!this.val) {
485-
// this.remove();
486-
// }
487-
// else {
488-
// this.entity.calculateBox();
489-
// }
490-
// }
491-
466+
}
467+
text(str) {
468+
if (this.editingText) {
469+
this.editingText.text(str);
470+
}
492471
}
493472
stopEditing() {
494-
console.log('done');
495473
this.isEditing = false;
496-
this.svg.removeClass('editing');
474+
this.editingText.removeClass('editing-text');
497475
this.editingRect.remove();
498-
this.editingRect = null;
476+
this.editingRect = this.editingText = null;
477+
this.draw();
499478
}
500479

501480
getEndpoints() {

0 commit comments

Comments
 (0)