<commit_before>import { Shape } from "./shape";
import { chainObjects } from "../../util/object";
import { HdpiCanvas } from "../../canvas/hdpiCanvas";
import { BBox } from "../bbox";

export class Text extends Shape {
    protected static defaultStyles = chainObjects(Shape.defaultStyles, {
        textAlign: 'start' as CanvasTextAlign,
        font: '10px sans-serif' as string,
        textBaseline: 'alphabetic' as CanvasTextBaseline
    });

    private _x: number = 0;
    set x(value: number) {
        if (this._x !== value) {
            this._x = value;
            this.dirty = true;
        }
    }
    get x(): number {
        return this._x;
    }

    private _y: number = 0;
    set y(value: number) {
        if (this._y !== value) {
            this._y = value;
            this.dirty = true;
        }
    }
    get y(): number {
        return this._y;
    }

    private lineBreakRe = /\r?\n/g;
    private lines: string[] = [];

    private splitText() {
        this.lines = this._text.split(this.lineBreakRe);
    }

    private _text: string = '';
    set text(value: string) {
        if (this._text !== value) {
            this._text = value;
            this.splitText();
            this.dirty = true;<commit_msg>Fix Text node.<commit_after>import { Shape } from "./shape";
import { chainObjects } from "../../util/object";
import { HdpiCanvas } from "../../canvas/hdpiCanvas";
import { BBox } from "../bbox";

export class Text extends Shape {
    protected static defaultStyles = chainObjects(Shape.defaultStyles, {
        textAlign: 'start' as CanvasTextAlign,
        font: '10px sans-serif' as string,
        textBaseline: 'alphabetic' as CanvasTextBaseline
    });

    private _x: number = 0;
    set x(value: number) {
        if (this._x !== value) {
            this._x = value;
            this.dirty = true;
        }
    }
    get x(): number {
        return this._x;
    }

    private _y: number = 0;
    set y(value: number) {
        if (this._y !== value) {
            this._y = value;
            this.dirty = true;
        }
    }
    get y(): number {
        return this._y;
    }

    private lineBreakRe = /\r?\n/g;
    private lines: string[] = [];

    private splitText() {
        this.lines = this._text.split(this.lineBreakRe);
    }

    private _text: string = '';
    set text(value: string) {
        const str = value.toString(); // `value` can be an object here
        if (this._text !== str) {
            this._text = str;
            this.splitText();
            this.dirty = true;
{'fraction_non_alphanumeric': 0.13917122752150118, 'fraction_numerical': 0.003127443315089914, 'mean_word_length': 1.8560267857142858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3016946', 'n_tokens_mistral': 789, 'n_tokens_neox': 767, 'n_words': 210}