<commit_before>(function (factory) {
    /* global define */
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node/CommonJS
        module.exports = factory(require('jquery'));
    } else {
        // Browser globals
        factory(window.jQuery);
    }
}(function ($) {
    // Extends plugins for adding Checkbox.
    $.extend($.summernote.plugins, {
        /**
         * @param {Object} context - context object has status of editor.
         */
        'checkbox': function (context) {
            var self = this;
            var ui = $.summernote.ui;

            context.memo('button.checkbox', function () {
                var button = ui.button({
                    contents: '<i class="fa fa-check"/>',
                    tooltip: 'Add Checkbox / ToDo',
                    click: function () {
                        context.invoke('insertNode', self.createCheckbox());
                    }
                });

                return button.render();
            });

            this.createCheckbox = function () {
                var elem = document.createElement('input');
                elem.type = "checkbox";
                elem.className = "tsCheckBox";
                return elem;
            }

            // This events will be attached when editor is initialized.
            this.events = {
                'summernote.init': function (we, e) {                    
                },
                'summernote.keyup': function (we, e) {                    
                }
            };

            this.initialize = function () {
                var layoutInfo = context.layoutInfo;
                var $editor = layoutInfo.editor;

                $editor.click(function (event) {
                    if (event.target.type && event.target.type == 'checkbox') {
                        var checked = $(event.target).is(':checked');
                        $(event.target).attr('checked', checked);
                        context.invoke('insertText', '');
                    }
                });<commit_msg>fixing placement of the cursor after adding a todo checkbox<commit_after>(function (factory) {
    /* global define */
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node/CommonJS
        module.exports = factory(require('jquery'));
    } else {
        // Browser globals
        factory(window.jQuery);
    }
}(function ($) {
    // Extends plugins for adding Checkbox.
    $.extend($.summernote.plugins, {
        /**
         * @param {Object} context - context object has status of editor.
         */
        'checkbox': function (context) {
            var self = this;
            var ui = $.summernote.ui;

            context.memo('button.checkbox', function () {
                var button = ui.button({
                    contents: '<i class="fa fa-check"/>',
                    tooltip: 'Add Checkbox / ToDo',
                    click: function () {
                        context.invoke('insertNode', self.createCheckbox());
                    }
                });

                return button.render();
            });

            this.createCheckbox = function () {
                var checkbox = document.createElement('input');
                checkbox.type = "checkbox";
                checkbox.className = "tsCheckBox";

                var span = document.createElement('span');
                span.appendChild(checkbox);
                span.text = " "
                return span;
            }


            // This events will be attached when editor is initialized.
            this.events = {
                'summernote.init': function (we, e) {                    
                },
                'summernote.keyup': function (we, e) {                    
                }
            };

            this.initialize = function () {
                var layoutInfo = context.layoutInfo;
                var $editor = layoutInfo.editor;

                $editor.click(function (event) {
                    if (event.target.type && event.target.type == 'checkbox') {
                        var checked = $(event.target).is(':checked');
                        $(event.target).attr('checked', checked);
                        context.invoke('insertText', '');
                    }
                });
{'fraction_non_alphanumeric': 0.12427058569267344, 'fraction_numerical': 0.0, 'mean_word_length': 1.2820512820512822, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4108017', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1041, 'n_words': 260}