<commit_before>import Delta from 'rich-text/lib/delta';
import Parchment from 'parchment';
import BreakBlot from './break';
import extend from 'extend';


const NEWLINE_LENGTH = 1;


class EmbedBlock extends Parchment.Embed {
  attach() {
    super.attach();
    this.attributes = new Parchment.Attributor.Store(this.domNode);
  }

  delta() {
    let value = {};
    value[this.statics.blotName] = this.value();
    return new Delta().insert(value, this.formats()).insert('\n', this.attributes.values());
  }
}
EmbedBlock.scope = Parchment.Scope.BLOCK_BLOT;
// It is important for cursor behavior EmbedBlocks use tags that are block level elements


class Block extends Parchment.Block {
  constructor(domNode) {
    super(domNode);
    this.optimize();
  }

  delta() {
    return this.descendants(Parchment.Leaf).reduce((delta, leaf) => {
      if (leaf.length() === 0) return delta;
      if (leaf instanceof Parchment.Embed) {
        var value = {};
        value[leaf.statics.blotName] = leaf.value();
      } else {
        var value = leaf.value();
      }
      return delta.insert(value, bubbleFormats(leaf));<commit_msg>fix embedblock's length()<commit_after>import Delta from 'rich-text/lib/delta';
import Parchment from 'parchment';
import BreakBlot from './break';
import extend from 'extend';


const NEWLINE_LENGTH = 1;


class EmbedBlock extends Parchment.Embed {
  attach() {
    super.attach();
    this.attributes = new Parchment.Attributor.Store(this.domNode);
  }

  delta() {
    let value = {};
    value[this.statics.blotName] = this.value();
    return new Delta().insert(value, this.formats()).insert('\n', this.attributes.values());
  }

  length() {
    return super.length() + NEWLINE_LENGTH;
  }
}
EmbedBlock.scope = Parchment.Scope.BLOCK_BLOT;
// It is important for cursor behavior EmbedBlocks use tags that are block level elements


class Block extends Parchment.Block {
  constructor(domNode) {
    super(domNode);
    this.optimize();
  }

  delta() {
    return this.descendants(Parchment.Leaf).reduce((delta, leaf) => {
      if (leaf.length() === 0) return delta;
      if (leaf instanceof Parchment.Embed) {
        var value = {};
        value[leaf.statics.blotName] = leaf.value();
      } else {
        var value = leaf.value();
      }
      return delta.insert(value, bubbleFormats(leaf));
{'fraction_non_alphanumeric': 0.1377245508982036, 'fraction_numerical': 0.001710863986313088, 'mean_word_length': 3.3801498127340825, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2827686', 'n_tokens_mistral': 745, 'n_tokens_neox': 720, 'n_words': 175}