<commit_before>/**
 * Visual editor for HTML editing. Use TinyMCE.
 *
 * @see https://github.com/santakani/santakani.com/wiki/Visual-Editor:-TinyMCE
 */

var Backbone = require('backbone');

module.exports = Backbone.View.extend({

    initialize: function (options) {
        _.extend(this, _.pick(options, 'imageManager'));

        if (!this.$el.attr('id')) {
            this.$el.attr('id', 'content-editor-' + Math.floor(Math.random() * 10000));
        }

        this.selector = '#' + this.$el.attr('id');

        var that = this;

        // Initialize TinyMCE
        tinymce.init({
            selector: this.selector,
            plugins: ['link', 'image', 'paste'],
            menubar: false,
            statusbar: false,
            toolbar: 'undo redo | styleselect | bold italic | link customimage',

            language: app.locale,

            height: 400,
            min_height: 300,
            max_height: 600,

            content_css: ['/css/app.css', '/css/editor.css'],

            convert_urls: false, // Keep relative URLs for images and links

            paste_as_text: true, // Paste as plain text, remove styles and tags.

            setup: function (editor) {
                editor.on('change', function () {
                    editor.save();
                });
                editor.addButton('customimage', {
                    icon: 'image',
                    onclick: function () {
                        that.imageManager.call({
                            multiple: false,
                            done: function (image) {
                                var id = image.get('id');
                                var src = image.fileUrl('medium');
                                var largeUrl = image.fileUrl('large');
                                var size = image.size('medium');
                                var html = '<a href="' + largeUrl + '"><img src="'
                                    + src + '" width="' + size.width + '" height="'
                                    + size.height + '" alt="Image ' + id + '"></a>';
                                editor.insertContent(html);
                            }
                        });
                    }
                });
            }
        });
    }
});<commit_msg>TinyMCE insert image in new paragraph<commit_after>/**
 * Visual editor for HTML editing. Use TinyMCE.
 *
 * @see https://github.com/santakani/santakani.com/wiki/Visual-Editor:-TinyMCE
 */

var Backbone = require('backbone');

module.exports = Backbone.View.extend({

    initialize: function (options) {
        _.extend(this, _.pick(options, 'imageManager'));

        if (!this.$el.attr('id')) {
            this.$el.attr('id', 'content-editor-' + Math.floor(Math.random() * 10000));
        }

        this.selector = '#' + this.$el.attr('id');

        var that = this;

        // Initialize TinyMCE
        tinymce.init({
            selector: this.selector,
            plugins: ['link', 'image', 'paste'],
            menubar: false,
            statusbar: false,
            toolbar: 'undo redo | styleselect | bold italic | link customimage',

            language: app.locale,

            height: 400,
            min_height: 300,
            max_height: 600,

            content_css: ['/css/app.css', '/css/editor.css'],

            convert_urls: false, // Keep relative URLs for images and links

            paste_as_text: true, // Paste as plain text, remove styles and tags.

            setup: function (editor) {
                editor.on('change', function () {
                    editor.save();
                });
                editor.addButton('customimage', {
                    icon: 'image',
                    onclick: function () {
                        that.imageManager.call({
                            multiple: false,
                            done: function (image) {
                                var id = image.get('id');
                                var src = image.fileUrl('medium');
                                var largeUrl = image.fileUrl('large');
                                var size = image.size('medium');
                                var html = '<p><a href="' + largeUrl + '"><img src="'
                                    + src + '" width="' + size.width + '" height="'
                                    + size.height + '" alt="Image ' + id + '"></a></p>';
                                editor.insertContent(html);
                            }
                        });
                    }
                });
            }
        });
    }
});
{'fraction_non_alphanumeric': 0.1332901274573342, 'fraction_numerical': 0.006048822639879024, 'mean_word_length': 1.195353247984827, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3620556', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1126, 'n_words': 261}