@@ -1470,21 +1470,23 @@ Tagify.prototype = {
1470
1470
return this . prefixedTextToTag ( tagsData [ 0 ] )
1471
1471
}
1472
1472
1473
- var frag = document . createDocumentFragment ( )
1473
+ var frag = document . createDocumentFragment ( ) ;
1474
+ var addedTags = [ ] ;
1474
1475
1475
1476
tagsData . forEach ( tagData => {
1476
1477
const newTagNode = this . prepareNewTagNode ( tagData )
1477
1478
frag . appendChild ( newTagNode . tagElm )
1478
1479
this . insertAfterTag ( newTagNode . tagElm )
1479
1480
this . postProcessNewTagNode ( newTagNode . tagElm , newTagNode . tagData )
1481
+ addedTags . push ( { tagElm : newTagNode . tagElm , tagData : newTagNode . tagData } )
1480
1482
} )
1481
1483
1482
- this . appendMixTags ( frag )
1484
+ this . appendMixTags ( frag , addedTags )
1483
1485
1484
1486
return frag . children
1485
1487
} ,
1486
1488
1487
- appendMixTags ( node ) {
1489
+ appendMixTags ( node , addedTags ) {
1488
1490
var selection = ! ! this . state . selection ;
1489
1491
1490
1492
// if "selection" exists, assumes intention of inecting the new tag at the last
@@ -1502,6 +1504,8 @@ Tagify.prototype = {
1502
1504
1503
1505
this . updateValueByDOMTags ( ) // updates internal "this.value"
1504
1506
this . update ( ) // updates original input/textarea
1507
+
1508
+ this . trigger ( 'add' , { tags : addedTags || node . children } )
1505
1509
}
1506
1510
} ,
1507
1511
@@ -1542,6 +1546,8 @@ Tagify.prototype = {
1542
1546
1543
1547
this . postProcessNewTagNode ( tagElm , newTag . tagData )
1544
1548
1549
+ this . trigger ( 'add' , { tag : newTag , data :tagData } )
1550
+
1545
1551
return tagElm
1546
1552
} ,
1547
1553
0 commit comments