Skip to content

Commit af233b9

Browse files
SimeonCSimeonC
SimeonC
authored and
SimeonC
committed
fix(taBind): Fix the drop handler not re-applying on select handler
Fix #269
1 parent 58781ee commit af233b9

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

demo/static-demo.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h1>Option to masquerade as a fancy text-area - complete with form submission an
122122
*/
123123
});
124124
function wysiwygeditor($scope, textAngularManager, $document) {
125-
$scope.data = {orightml: '<h2>Try me!</h2><p>textAngular is a super cool WYSIWYG Text Editor directive for AngularJS</p><p><img class="ta-insert-video" ta-insert-video="http://www.youtube.com/embed/2maA1-mvicY" src="" allowfullscreen="true" width="300" frameborder="0" height="250"/></p><p><b>Features:</b></p><ol><li>Automatic Seamless Two-Way-Binding</li><li>Super Easy <b>Theming</b> Options</li><li style="color: green;">Simple Editor Instance Creation</li><li>Safely Parses Html for Custom Toolbar Icons</li><li class="text-danger">Doesn&apos;t Use an iFrame</li><li>Works with Firefox, Chrome, and IE8+</li></ol><p><b>Code at GitHub:</b> <a href="https://github.com/fraywing/textAngular">Here</a> </p><p>昮朐 魡 燚璒瘭 譾躒鑅, 皾籈譧 紵脭脧 逯郹酟 煃 瑐瑍, 踆跾踄 趡趛踠 顣飁 廞 熥獘 豥 蔰蝯蝺 廦廥彋 蕍蕧螛 溹溦 幨懅憴 妎岓岕 緁, 滍 蘹蠮 蟷蠉蟼 鱐鱍鱕, 阰刲 鞮鞢騉 烳牼翐 魡 骱 銇韎餀 媓幁惁 嵉愊惵 蛶觢, 犝獫 嶵嶯幯 縓罃蔾 魵 踄 罃蔾 獿譿躐 峷敊浭, 媓幁 黐曮禷 椵楘溍 輗 漀 摲摓 墐墆墏 捃挸栚 蛣袹跜, 岓岕 溿 斶檎檦 匢奾灱 逜郰傃</p>'};
125+
$scope.data = {orightml: '<h2>Try me!</h2><p>textAngular is a super cool WYSIWYG Text Editor directive for AngularJS</p><p><img class="ta-insert-video" ta-insert-video="https://www.youtube.com/embed/2maA1-mvicY" src="https://img.youtube.com/vi/2maA1-mvicY/hqdefault.jpg" allowfullscreen="true" width="300" frameborder="0" height="250"/></p><p><b>Features:</b></p><ol><li>Automatic Seamless Two-Way-Binding</li><li>Super Easy <b>Theming</b> Options</li><li style="color: green;">Simple Editor Instance Creation</li><li>Safely Parses Html for Custom Toolbar Icons</li><li class="text-danger">Doesn&apos;t Use an iFrame</li><li>Works with Firefox, Chrome, and IE8+</li></ol><p><b>Code at GitHub:</b> <a href="https://github.com/fraywing/textAngular">Here</a> </p><p>昮朐 魡 燚璒瘭 譾躒鑅, 皾籈譧 紵脭脧 逯郹酟 煃 瑐瑍, 踆跾踄 趡趛踠 顣飁 廞 熥獘 豥 蔰蝯蝺 廦廥彋 蕍蕧螛 溹溦 幨懅憴 妎岓岕 緁, 滍 蘹蠮 蟷蠉蟼 鱐鱍鱕, 阰刲 鞮鞢騉 烳牼翐 魡 骱 銇韎餀 媓幁惁 嵉愊惵 蛶觢, 犝獫 嶵嶯幯 縓罃蔾 魵 踄 罃蔾 獿譿躐 峷敊浭, 媓幁 黐曮禷 椵楘溍 輗 漀 摲摓 墐墆墏 捃挸栚 蛣袹跜, 岓岕 溿 斶檎檦 匢奾灱 逜郰傃</p>'};
126126
$scope.data.htmlcontent = $scope.data.orightml;
127127
$scope.data.htmlcontent3;
128128
$scope.$watch('data.htmlcontent3', function(val){console.log(val);});

src/textAngular.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,9 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
674674

675675
// catch element select event and pass to toolbar tools
676676
scope.$on('ta-element-select', function(event, element){
677-
_toolbars.triggerElementSelect(event, element);
677+
if(_toolbars.triggerElementSelect(event, element)){
678+
scope['reApplyOnSelectorHandlerstaTextElement' + _serial]();
679+
}
678680
});
679681

680682
scope.$on('ta-drop-event', function(event, element, dropEvent, dataTransfer){
@@ -687,7 +689,7 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
687689
try{
688690
$q.when(scope.fileDropHandler(file, scope.wrapSelection) ||
689691
(scope.fileDropHandler !== scope.defaultFileDropHandler &&
690-
scope.defaultFileDropHandler(file, scope.wrapSelection))).finally(function(){
692+
$q.when(scope.defaultFileDropHandler(file, scope.wrapSelection)))).then(function(){
691693
scope['updateTaBindtaTextElement' + _serial]();
692694
});
693695
}catch(error){
@@ -696,6 +698,11 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
696698
});
697699
dropEvent.preventDefault();
698700
dropEvent.stopPropagation();
701+
/* istanbul ignore else, the updates if moved text */
702+
}else{
703+
$timeout(function(){
704+
scope['updateTaBindtaTextElement' + _serial]();
705+
}, 0);
699706
}
700707
});
701708

@@ -1274,7 +1281,11 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
12741281
if(event.originalEvent) dataTransfer = event.originalEvent.dataTransfer;
12751282
else dataTransfer = event.dataTransfer;
12761283
scope.$emit('ta-drop-event', this, event, dataTransfer);
1277-
$timeout(function(){dropFired = false;}, 100);
1284+
$timeout(function(){
1285+
dropFired = false;
1286+
_setViewValue();
1287+
_reApplyOnSelectorHandlers();
1288+
}, 100);
12781289
}
12791290
};
12801291

0 commit comments

Comments
 (0)