<commit_before>/**
 * autoResize - resizes a DOM element to the width and height of another DOM element
 *
 * Copyright 2014, <NAME>
 * Licensed under the MIT license
 * refer to https://github.com/handsontable/handsontable/blob/HEAD/handsontable/src/3rdparty/autoResize/index.js
 */

export function autoResize() {
    var defaults = {
            minHeight: 200,
            maxHeight: 300,
            minWidth: 100,
            maxWidth: 300,
        },
        el,
        body = document.body,
        text = document.createTextNode(""),
        span = document.createElement("SPAN"),
        observe = function (element, event, handler) {
            element.addEventListener(event, handler, false);
        },
        unObserve = function (element, event, handler) {
            element.removeEventListener(event, handler, false);
        },
        resize = function (newChar) {
            var width, scrollHeight;

            if (!newChar) {
                newChar = "";
            } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
                newChar = ".";
            }

            if (text.textContent !== void 0) {
                text.textContent = el.value + newChar;
            } else {
                text.data = el.value + newChar; //IE8
            }
            span.style.fontSize = getComputedStyle(el).fontSize;
            span.style.fontFamily = getComputedStyle(el).fontFamily;
            span.style.whiteSpace = "pre";

            body.appendChild(span);
            width = span.clientWidth + 2;
            body.removeChild(span);<commit_msg>解决输入时，宽度自适应但是文本内容换行的问题。添加 paddingWidth 配置<commit_after>/**
 * autoResize - resizes a DOM element to the width and height of another DOM element
 *
 * Copyright 2014, <NAME>
 * Licensed under the MIT license
 * refer to https://github.com/handsontable/handsontable/blob/HEAD/handsontable/src/3rdparty/autoResize/index.js
 */

export function autoResize() {
    var defaults = {
            minHeight: 200,
            maxHeight: 300,
            minWidth: 100,
            maxWidth: 300,
            // text padding
            paddingWidth: 12,
        },
        el,
        body = document.body,
        text = document.createTextNode(""),
        span = document.createElement("SPAN"),
        observe = function (element, event, handler) {
            element.addEventListener(event, handler, false);
        },
        unObserve = function (element, event, handler) {
            element.removeEventListener(event, handler, false);
        },
        resize = function (newChar) {
            var width, scrollHeight;

            if (!newChar) {
                newChar = "";
            } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
                newChar = ".";
            }

            if (text.textContent !== void 0) {
                text.textContent = el.value + newChar;
            } else {
                text.data = el.value + newChar; //IE8
            }
            span.style.fontSize = getComputedStyle(el).fontSize;
            span.style.fontFamily = getComputedStyle(el).fontFamily;
            span.style.whiteSpace = "pre";

            body.appendChild(span);
            width = span.clientWidth + defaults.paddingWidth;
            body.removeChild(span);
{'fraction_non_alphanumeric': 0.11891727493917274, 'fraction_numerical': 0.013686131386861315, 'mean_word_length': 1.7477025898078529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5265908', 'n_tokens_mistral': 956, 'n_tokens_neox': 905, 'n_words': 203}