<commit_before>"use strict";

var Core = require("lapis-core/index.js");
var Data = require("lazuli-data/index.js");
var IO = require("lazuli-io/index.js");

/**
* To represent a multi-line text block field
*/
module.exports = Data.Text.clone({
    id: "Textarea",
    css_type: "textarea",
    detokenize_content: false,
    separate_row_in_form: true,
    rows: 5,
    tb_span: 12,
    tb_input_list: "input-lg",
//    update_length         : 80,
    data_length: -1,        // Ignore in Text.validate()
    db_type: "B",
    image_root_path: "olht/",
    video_root_path: "olht/",
    doc_root_path: "olht/",
    video_width: 848,
    video_height: 551,
    flexbox_size: 12,
});


module.exports.override("set", function (new_val) {
    if (typeof new_val !== "string") {
        this.throwError("argument not string: " + this.owner.id + ":" + this.id);
    }
    if (this.css_richtext) {
        new_val = new_val.replace(/<br class="aloha-cleanme">/g, "");
    }
    new_val = new_val.replace(IO.XmlStream.left_bracket_regex, "").replace(IO.XmlStream.right_bracket_regex, "");
    return Data.Text.set.call(this, new_val);
});


module.exports.override("renderUpdateControls", function (div, render_opts, form_type) {
    if (this.css_richtext && render_opts.enable_aloha !== false) {
        div.makeElement("div", "css_richtext_target").text(this.val, true);        // true = don't escape markup
    } else {
        div.makeElement("textarea", this.getInputSizeCSSClass(form_type))
            .attr("rows", this.rows.toFixed(0))
            .text(this.val);
    }
});


module.exports.override("renderUneditable", function (elem, render_opts, inside_table) {
    var div_elem = elem.makeElement("div", "form-control-static");
    var style = this.getUneditableCSSStyle();

    if (!this.validated) {
        this.validate();
    }
    if (style) {
        div_elem.attribute("style", style);
    }
    if (this.getText()) {
        div_elem.text(this.getText(), this.css_richtext);        // don't escape markup if richtext<commit_msg>output zero parts expected if rich text<commit_after>"use strict";

var Core = require("lapis-core/index.js");
var Data = require("lazuli-data/index.js");
var IO = require("lazuli-io/index.js");

/**
* To represent a multi-line text block field
*/
module.exports = Data.Text.clone({
    id: "Textarea",
    css_type: "textarea",
    detokenize_content: false,
    separate_row_in_form: true,
    rows: 5,
    tb_span: 12,
    tb_input_list: "input-lg",
//    update_length         : 80,
    data_length: -1,        // Ignore in Text.validate()
    db_type: "B",
    image_root_path: "olht/",
    video_root_path: "olht/",
    doc_root_path: "olht/",
    video_width: 848,
    video_height: 551,
    flexbox_size: 12,
});


module.exports.override("set", function (new_val) {
    if (typeof new_val !== "string") {
        this.throwError("argument not string: " + this.owner.id + ":" + this.id);
    }
    if (this.css_richtext) {
        new_val = new_val.replace(/<br class="aloha-cleanme">/g, "");
    }
    new_val = new_val.replace(IO.XmlStream.left_bracket_regex, "").replace(IO.XmlStream.right_bracket_regex, "");
    return Data.Text.set.call(this, new_val);
});


module.exports.override("appendClientSideProperties", function (obj) {
    Data.Text.appendClientSideProperties.call(this, obj);
    obj.min_parts_expected = this.css_richtext ? 0 : 1;
    obj.max_parts_expected = this.css_richtext ? 0 : 1;
});


module.exports.override("renderUpdateControls", function (div, render_opts, form_type) {
    if (this.css_richtext && render_opts.enable_aloha !== false) {
        div.makeElement("div", "css_richtext_target").text(this.val, true);        // true = don't escape markup
    } else {
        div.makeElement("textarea", this.getInputSizeCSSClass(form_type))
            .attr("rows", this.rows.toFixed(0))
            .text(this.val);
    }
});


module.exports.override("renderUneditable", function (elem, render_opts, inside_table) {
    var div_elem = elem.makeElement("div", "form-control-static");
    var style = this.getUneditableCSSStyle();

    if (!this.validated) {
        this.validate();
    }
    if (style) {
        div_elem.attribute("style", style);
    }
    if (this.getText()) {
        div_elem.text(this.getText(), this.css_richtext);        // don't escape markup if richtext
{'fraction_non_alphanumeric': 0.15654366261746505, 'fraction_numerical': 0.007792803117121247, 'mean_word_length': 3.200192492781521, 'pattern_counts': {'":': 2, '<': 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': '2847224', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1473, 'n_words': 274}