pos); edit.addAddedElement(newEl1); Element next = paragraph.getElement(index + 1);
offset); edit.added.add(newEl1); Element next = edit.e.getElement(edit.index + 1);
    private void insertFirstContentTag(ElementSpec[] data)    {            ElementSpec first = data[0];      BranchElement paragraph = (BranchElement) elementStack.peek();      int index = paragraph.getElementIndex(pos);      Element current = paragraph.getElement(index);      int newEndOffset = pos + first.length;      boolean onlyContent = data.length == 1;      Edit edit = getEditForParagraphAndIndex(paragraph, index);      switch (first.getDirection())        {        case ElementSpec.JoinPreviousDirection:          if (current.getEndOffset() != newEndOffset && !onlyContent)            {              Element newEl1 = createLeafElement(paragraph,                                                 current.getAttributes(),                                                 current.getStartOffset(),                                                 newEndOffset);              edit.addAddedElement(newEl1);              edit.addRemovedElement(current);              offset = newEndOffset;            }          break;        case ElementSpec.JoinNextDirection:          if (pos != 0)            {              Element newEl1 = createLeafElement(paragraph,                                                 current.getAttributes(),                                                 current.getStartOffset(),                                                 pos);              edit.addAddedElement(newEl1);              Element next = paragraph.getElement(index + 1);              if (onlyContent)                newEl1 = createLeafElement(paragraph, next.getAttributes(),                                           pos, next.getEndOffset());              else            {                  newEl1 = createLeafElement(paragraph, next.getAttributes(),                                           pos, newEndOffset);                  pos = newEndOffset;            }              edit.addAddedElement(newEl1);          edit.addRemovedElement(current);              edit.addRemovedElement(next);            }                      break;        default:          if (current.getStartOffset() != pos)            {              Element newEl = createLeafElement(paragraph,                                                current.getAttributes(),                                                current.getStartOffset(),                                                pos);              edit.addAddedElement(newEl);        }          edit.addRemovedElement(current);          Element newEl1 = createLeafElement(paragraph, first.getAttributes(),                                             pos, newEndOffset);          edit.addAddedElement(newEl1);          if (current.getEndOffset() != endOffset)              recreateLeaves(newEndOffset, paragraph, onlyContent);          else      offset = newEndOffset;           break;        }    }