<commit_before>import Blot from '../blot';
import InlineBlot from '../parent/inline';
import ShadowNode from '../shadow';
import * as Registry from '../../registry';

class TextBlot extends Blot {
  static blotName = 'text';

  domNode: Text;
  private text: string;

  constructor(value: string | Node) {
    if (typeof value === 'string') {
      super(document.createTextNode(value));
    } else {
      super(value);
    }
    this.text = this.domNode.data;
  }

  deleteAt(index: number, length: number): void {
    this.text = this.text.slice(0, index) + this.text.slice(index + length);
    if (this.text.length > 0) {
      this.domNode.data = this.text;
    } else {
      this.remove();
    }
  }

  format(name: string, value: any): void {
    if (Registry.match(name, Registry.Type.ATTRIBUTE) !== null) {
      let target = <InlineBlot>this.wrap(InlineBlot.blotName, true);
      target.format(name, value);
    } else {
      super.format(name, value);
    }
  }

  formatAt(index: number, length: number, name: string, value: any): void {
    var target = <TextBlot>this.isolate(index, length);
    target.format(name, value);
  }

  getLength(): number {
    return this.text.length;
  }

  getValue(): string {
    return this.text;
  }

  insertAt(index: number, value: string, def?: any): void {
    if (def == null) {
      this.text = this.text.slice(0, index) + value + this.text.slice(index);
      this.domNode.data = this.text;
    } else {
      super.insertAt(index, value, def);
    }
  }

  split(index: number, force: boolean = false): ShadowNode {
    if (!force) {
      if (index === 0) return this;
      if (index === this.getLength()) return this.next;
    }
    var after = Registry.create(this.statics.blotName, this.domNode.splitText(index));
    this.parent.insertBefore(after, this.next);
    this.text = this.domNode.data;
    return after;
  }
}


export default TextBlot;<commit_msg>more specific signature<commit_after>import Blot from '../blot';
import InlineBlot from '../parent/inline';
import * as Registry from '../../registry';

class TextBlot extends Blot {
  static blotName = 'text';

  domNode: Text;
  private text: string;

  constructor(value: string | Node) {
    if (typeof value === 'string') {
      super(document.createTextNode(value));
    } else {
      super(value);
    }
    this.text = this.domNode.data;
  }

  deleteAt(index: number, length: number): void {
    this.text = this.text.slice(0, index) + this.text.slice(index + length);
    if (this.text.length > 0) {
      this.domNode.data = this.text;
    } else {
      this.remove();
    }
  }

  format(name: string, value: any): void {
    if (Registry.match(name, Registry.Type.ATTRIBUTE) !== null) {
      let target = <InlineBlot>this.wrap(InlineBlot.blotName, true);
      target.format(name, value);
    } else {
      super.format(name, value);
    }
  }

  formatAt(index: number, length: number, name: string, value: any): void {
    var target = <TextBlot>this.isolate(index, length);
    target.format(name, value);
  }

  getLength(): number {
    return this.text.length;
  }

  getValue(): string {
    return this.text;
  }

  insertAt(index: number, value: string, def?: any): void {
    if (def == null) {
      this.text = this.text.slice(0, index) + value + this.text.slice(index);
      this.domNode.data = this.text;
    } else {
      super.insertAt(index, value, def);
    }
  }

  split(index: number, force: boolean = false): Blot {
    if (!force) {
      if (index === 0) return this;
      if (index === this.getLength()) return this.next;
    }
    var after = Registry.create(this.statics.blotName, this.domNode.splitText(index));
    this.parent.insertBefore(after, this.next);
    this.text = this.domNode.data;
    return after;
  }
}


export default TextBlot;
{'fraction_non_alphanumeric': 0.15287958115183245, 'fraction_numerical': 0.0020942408376963353, 'mean_word_length': 2.8989795918367345, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2187109', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1255, 'n_words': 299}