<commit_before>'use strict';

angular.module('svardMailApp')
    .directive('editable', function () {
        return {
            template: '<div contenteditable="true"></div>',
            restrict: 'E',
            replace: true,
            require: '?ngModel',
            link: function postLink($scope, element, attrs, ctrl) {
                if (!ctrl) {
                    return;
                }

                ctrl.$formatters.unshift(function (value) {
                    return value.replace(/\n/g, '<br />');
                });

                element.on('keyup change', function() {
                    $scope.$apply(function() {
                        ctrl.$setViewValue(element.html());
                    });
                });

                ctrl.$render = function () {
                    element.html(ctrl.$viewValue);
                };
            }
        };
    });<commit_msg>Fixed a directive bug<commit_after>'use strict';

angular.module('svardMailApp')
    .directive('editable', function () {
        return {
            template: '<div contenteditable="true"></div>',
            restrict: 'E',
            replace: true,
            require: '?ngModel',
            link: function postLink($scope, element, attrs, ctrl) {
                if (!ctrl) {
                    return;
                }

                ctrl.$formatters.unshift(function (value) {
                    if (value !== undefined) {
                        return value.replace(/\n/g, '<br />');
                    }
                });

                element.on('keyup change', function() {
                    $scope.$apply(function() {
                        ctrl.$setViewValue(element.html());
                    });
                });

                ctrl.$render = function () {
                    element.html(ctrl.$viewValue);
                };
            }
        };
    });
{'fraction_non_alphanumeric': 0.13838120104438642, 'fraction_numerical': 0.0, 'mean_word_length': 1.1194690265486726, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6122751', 'n_tokens_mistral': 477, 'n_tokens_neox': 445, 'n_words': 80}