<commit_before>/*
textAngular
Author : <NAME>
License : 2013 MIT
Version 1.0.2
How to Use:
1.Include textAngular.js in your project, alternatively grab all this code and throw it in your "directives.js" module file.
2.Create a div or something, and add the text-angular directive to it. ALSO add a text-angular-name="<YOUR TEXT EDITOR NAME>"
3.Create a textAngularOpts object and bind it to your local scope in the controller you want controlling textAngular
It should look something like:
$scope.textAngularOpts = {
..options go here..
}
4.IF YOU WANT ALL EDITORS TO HAVE INDIVIDUAL SETTINGS -> go to 6. Else go to 7.
5. Create the textAngularEditors property manually (it will get created regardless). Then add to it, a new property with the name of your editor you chose earlier,
if it was "coolMonkeyMan" it will look like this:
$scope.textAngularOpts = {
..options for ALL editors, unless they have their own property...
textAngularEditors : {
coolMonkeyMan : {
..options for this editor ALONE ...
}
}
}

7. Globally inherited settings for each editor or individual settings? Either way you'll need to supply some options!

**OPTIONS**
html <STRING> the default html to show in the editor on load (also will be the property to watch for HTML changes!!!)
toolbar <ARRAY of OBJECTS> holds the toolbar items to configure, more on that later
disableStyle <BOOLEAN> disable all styles on this editor
theme <OBJECT of OBJECTS> holds the theme objects, more on that later
**Toolbar Settings**
The list of available tools in textAngular is large.

Add tools to the toolbar like:

toolbar : [
{title : "<i class='icon-code'></i>", name : "html"},
{title : "h1", name : "h1"},
{title : "h2", name : "h2"}
..and more
]
**OPTIONS**
title <STRING> Can be an angular express, html, or text. Use this to add icons to each tool i,e "<i class='icon-code'></i>"
name <STRING> the command, the tool name, has to be one of the following:

h1
h2
h3
p
pre
ul
ol
quote
undo
redo
b
justifyLeft
justifyRight
justifyCenter
i
clear
insertImage
insertHtml
createLink


**Theme settings**
Every piece of textAngular has a specific class you can grab and style in CSS.
However, you can also use the theme object to specify styling.
Each property takes a normal, jQuery-like CSS property object.
Heres an example :
theme : {
editor : {
"background" : "white",
"color" : "gray",
"text-align" : "left",
"border" : "3px solid rgba(2,2,2,0.2)",
"border-radius" : "5px",
"font-size" : "1.3em",
"font-family" : "Tahoma"
},
toolbar : {
..some styling...
},
toolbarItems : {
..some more styling...
}
}
}

**OPTIONS**

editor -> the actual editor element
toolbar -> the toolbar wrapper
toolbarItems -> each toolbar item
insertForm -> the form that holds the insert stuff
insertFormBtn -> the button that submits the insert stuff


**HOW TO GET THE HTML**

To actually get the model (watch or bind),
simply follow this model:

textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html

so to bind the expression:

{{textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html}}

or to $watch for changes:

$scope.$watch('textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html', function(oldHTML, newHTML){
console.log("My new html is: "+newHTML);
});

*/
var textAngular = angular.module('textAngular', []);

textAngular.directive('compile', function ($compile) {
    // directive factory creates a link function
    return function (scope, element, attrs) {
        scope.$watch(
            function (scope) {
                return scope.$eval(attrs.compile);
            },
            function (value) {
                element.html(value);
                $compile(element.contents())(scope);
            }
        );
    };
});


textAngular.directive('textAngular', function ($compile, $sce, $window, $timeout) {

    var sanitizationWrapper = function (html) {
        return $sce.trustAsHtml(html);
    };
    
    try {
        angular.isDefined(angular.module('ngSanitize'))
    }
    catch {
        sanitizationWrapper = function (html) {
            return html;
        }
    }

    var methods = {
        theme: function (scope, opts) {
            if (opts.disableStyle) {
                return false;
            }
            scope.theme = !! !opts.theme ? {} : opts.theme;

            var editorDefault = {
                "resize": "both",
                "overflow-y": "auto",
                "min-height": "300px",
                "text-align": "left",
                "padding": "4px"
            };
            var toolbarDefault = { //to prevent people from freaking out
                'margin': '0.2em',
                'text-align': 'right',
                'overflow': 'hidden',
                'border-radius': '3px',
                'display': 'inline-block'
            };

            scope.theme.editor = !! !scope.theme.editor ? {
                "background": "#FFFFFF",<commit_msg>fixed catch issue<commit_after>/*
textAngular
Author : <NAME>
License : 2013 MIT
Version 1.0.2
How to Use:
1.Include textAngular.js in your project, alternatively grab all this code and throw it in your "directives.js" module file.
2.Create a div or something, and add the text-angular directive to it. ALSO add a text-angular-name="<YOUR TEXT EDITOR NAME>"
3.Create a textAngularOpts object and bind it to your local scope in the controller you want controlling textAngular
It should look something like:
$scope.textAngularOpts = {
..options go here..
}
4.IF YOU WANT ALL EDITORS TO HAVE INDIVIDUAL SETTINGS -> go to 6. Else go to 7.
5. Create the textAngularEditors property manually (it will get created regardless). Then add to it, a new property with the name of your editor you chose earlier,
if it was "coolMonkeyMan" it will look like this:
$scope.textAngularOpts = {
..options for ALL editors, unless they have their own property...
textAngularEditors : {
coolMonkeyMan : {
..options for this editor ALONE ...
}
}
}

7. Globally inherited settings for each editor or individual settings? Either way you'll need to supply some options!

**OPTIONS**
html <STRING> the default html to show in the editor on load (also will be the property to watch for HTML changes!!!)
toolbar <ARRAY of OBJECTS> holds the toolbar items to configure, more on that later
disableStyle <BOOLEAN> disable all styles on this editor
theme <OBJECT of OBJECTS> holds the theme objects, more on that later
**Toolbar Settings**
The list of available tools in textAngular is large.

Add tools to the toolbar like:

toolbar : [
{title : "<i class='icon-code'></i>", name : "html"},
{title : "h1", name : "h1"},
{title : "h2", name : "h2"}
..and more
]
**OPTIONS**
title <STRING> Can be an angular express, html, or text. Use this to add icons to each tool i,e "<i class='icon-code'></i>"
name <STRING> the command, the tool name, has to be one of the following:

h1
h2
h3
p
pre
ul
ol
quote
undo
redo
b
justifyLeft
justifyRight
justifyCenter
i
clear
insertImage
insertHtml
createLink


**Theme settings**
Every piece of textAngular has a specific class you can grab and style in CSS.
However, you can also use the theme object to specify styling.
Each property takes a normal, jQuery-like CSS property object.
Heres an example :
theme : {
editor : {
"background" : "white",
"color" : "gray",
"text-align" : "left",
"border" : "3px solid rgba(2,2,2,0.2)",
"border-radius" : "5px",
"font-size" : "1.3em",
"font-family" : "Tahoma"
},
toolbar : {
..some styling...
},
toolbarItems : {
..some more styling...
}
}
}

**OPTIONS**

editor -> the actual editor element
toolbar -> the toolbar wrapper
toolbarItems -> each toolbar item
insertForm -> the form that holds the insert stuff
insertFormBtn -> the button that submits the insert stuff


**HOW TO GET THE HTML**

To actually get the model (watch or bind),
simply follow this model:

textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html

so to bind the expression:

{{textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html}}

or to $watch for changes:

$scope.$watch('textAngularOpts.textAngularEditors.<YOUR EDITORS NAME>.html', function(oldHTML, newHTML){
console.log("My new html is: "+newHTML);
});

*/
var textAngular = angular.module('textAngular', []);

textAngular.directive('compile', function ($compile) {
    // directive factory creates a link function
    return function (scope, element, attrs) {
        scope.$watch(
            function (scope) {
                return scope.$eval(attrs.compile);
            },
            function (value) {
                element.html(value);
                $compile(element.contents())(scope);
            }
        );
    };
});


textAngular.directive('textAngular', function ($compile, $sce, $window, $timeout) {

    var sanitizationWrapper = function (html) {
        return $sce.trustAsHtml(html);
    };
    
    try {
        angular.isDefined(angular.module('ngSanitize'))
    }
    catch(e) {
        sanitizationWrapper = function (html) {
            return html;
        }
    }

    var methods = {
        theme: function (scope, opts) {
            if (opts.disableStyle) {
                return false;
            }
            scope.theme = !! !opts.theme ? {} : opts.theme;

            var editorDefault = {
                "resize": "both",
                "overflow-y": "auto",
                "min-height": "300px",
                "text-align": "left",
                "padding": "4px"
            };
            var toolbarDefault = { //to prevent people from freaking out
                'margin': '0.2em',
                'text-align': 'right',
                'overflow': 'hidden',
                'border-radius': '3px',
                'display': 'inline-block'
            };

            scope.theme.editor = !! !scope.theme.editor ? {
                "background": "#FFFFFF",
{'fraction_non_alphanumeric': 0.11373149566105156, 'fraction_numerical': 0.007759060745278203, 'mean_word_length': 2.8582118944466326, 'pattern_counts': {'":': 12, '<': 33, '<?xml version=': 0, '>': 45, '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': '3046301', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2837, 'n_words': 1081}