<commit_before>/* ========================================================================
 * ZUI: Kindeditor plugin - placeholder
 * http://zui.sexy
 * ========================================================================
 * Copyright (c) 2019-2019 <EMAIL>; Licensed MIT
 * ======================================================================== */

KindEditor.EditorClass.prototype.setPlaceholder = function(placeholder, asHtml) {
    var self = this;
    var options = self.options;
    var edit = self.edit;
    var $doc = $(edit.doc);
    var $placeholder = $doc.find('.kindeditor-ph');
    if (!$placeholder.length) {
        $placeholder = $('<div class="kindeditor-ph" style="width:100%; color:#888; padding: 8px; background:none; position:absolute;z-index:10;top:0;border:0;overflow:auto;resize:none; pointer-events:none; white-space: pre-wrap; font-size: 13px"></div>');
        if (options.placeholderStyle) {
            $placeholder.css(options.placeholderStyle);
        }
        $doc.find('body').after($placeholder);
    }
    if (self.plugin.hasContent()) {
        $placeholder.hide();
    }
    $placeholder[asHtml ? 'html' : 'text'](placeholder);
};

KindEditor.EditorClass.prototype.getPlaceholder = function(asHtml) {
    return $(this.edit.doc).find('.kindeditor-ph')[asHtml ? 'html' : 'text']();
};

KindEditor.plugin('placeholder', function(K) {
    var self = this;

    self.plugin.hasContent = function() {
        return self.html().replace(/\s|\n|\r|\t/g, '').replace(/<br\/>/g, '').replace(/<p><\/p>/g, '') !== '';
    };

    self.afterBlur(function() {
        if (!self.plugin.hasContent()) {
            $(self.edit.doc).find('.kindeditor-ph').show();
        }
    });

    self.afterFocus(function() {
        $(self.edit.doc).find('.kindeditor-ph').hide();
    });

    self.afterCreate(function() {
        var options = self.options;
        if (options.placeholderHtml) {
            self.setPlaceholder(options.placeholderHtml, true);
        } else if (options.placeholder) {
            self.setPlaceholder(options.placeholder);
        }
    });
});<commit_msg> * fix placehoder style in kindeditor to prevent scrollbar in iframe.<commit_after>/* ========================================================================
 * ZUI: Kindeditor plugin - placeholder
 * http://zui.sexy
 * ========================================================================
 * Copyright (c) 2019-2019 cnezsoft.com; Licensed MIT
 * ======================================================================== */

KindEditor.EditorClass.prototype.setPlaceholder = function(placeholder, asHtml) {
    var self = this;
    var options = self.options;
    var $editDiv = $(self.edit.div[0]);
    var $placeholder = $editDiv.find('.kindeditor-ph');
    if (!$placeholder.length) {
        $editDiv.css('position', 'relative');
        $placeholder = $('<div class="kindeditor-ph" style="width:100%; color:#888; padding: 8px; background:none; position:absolute;z-index:10;top:0;border:0;overflow:auto;resize:none; pointer-events:none; white-space: pre-wrap; font-size: 13px"></div>');
        if (options.placeholderStyle) {
            $placeholder.css(options.placeholderStyle);
        }
        $editDiv.append($placeholder);
    }
    if (self.plugin.hasContent()) {
        $placeholder.hide();
    }
    $placeholder[asHtml ? 'html' : 'text'](placeholder);
    self.$placeholder = $placeholder;
};

KindEditor.EditorClass.prototype.getPlaceholder = function(asHtml) {
    return self.$placeholder && self.$placeholder[asHtml ? 'html' : 'text']();
};

KindEditor.plugin('placeholder', function(K) {
    var self = this;

    self.plugin.hasContent = function() {
        return self.html().replace(/\s|\n|\r|\t/g, '').replace(/<br\/>/g, '').replace(/<p><\/p>/g, '') !== '';
    };

    self.afterBlur(function() {
        if (!self.plugin.hasContent()) {
            self.$placeholder && self.$placeholder.show();
        }
    });

    self.afterFocus(function() {
        self.$placeholder && self.$placeholder.hide();
    });

    self.afterCreate(function() {
        var options = self.options;
        if (options.placeholderHtml) {
            self.setPlaceholder(options.placeholderHtml, true);
        } else if (options.placeholder) {
            self.setPlaceholder(options.placeholder);
        }
    });
});
{'fraction_non_alphanumeric': 0.2625402669121031, 'fraction_numerical': 0.009894155545329039, 'mean_word_length': 3.4953464322647365, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '2388102', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1198, 'n_words': 196}