Skip to content

Commit

Permalink
added simple plaintext editor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishokamp committed Feb 8, 2017
1 parent 80c4b63 commit 3680320
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/scripts/plaintextEditor/plaintextEditor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="typeahead-editor">
<!--NOTE: it's important NOT to leave whitespace between the textarea tags-->
<textarea
class="typeahead-editor"
ng-model="targetSegment"
></textarea>
</div>
42 changes: 42 additions & 0 deletions app/scripts/plaintextEditor/plaintextEditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
angular.module('handycat.editors', ['handycatConfig']);
// an input area with one or more typeahead backends enabled

angular.module('handycat.editors')
.directive('plaintextEditor', ['$log',
function($log) {
return {
scope: {
'targetSegment': '=',
'sourceSegment': '=',
'targetLang': '@',
'sourceLang': '@',
'activeComponent': '=',
'isActive': '='
},
templateUrl: 'scripts/plaintextEditor/plaintextEditor.html',
link: function($scope, el, attrs, segmentCtrl) {

var $inputTextarea = el.find('.atwho-input');

// when i become active, focus me
// If the function gets called with the component id -- i.e. 'typeaheadEditor', focus me
$scope.$watch(
function() {
return $scope.isActive;
}, function(isActive) {
if (isActive && $scope.activeComponent === 'plaintextEditor') {
$log.log('focus plaintext editor');
$inputTextarea.focus();
}
}
)

$scope.$on('clear-editor', function (event, args) {
$log.log('clearEditor fired')
$scope.targetSegment = '';
$inputTextarea.focus();
})

}
}
}])

0 comments on commit 3680320

Please sign in to comment.