final String text = "first\nsecond\nthird";
final int textLen = text.length();
//doc.insertString(0, text, null);
content.insertString(0, text);
event = doc.new DefaultDocumentEvent(0, textLen, EventType.INSERT);
ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, 6),
new ElementSpec(null, ElementSpec.EndTagType),
new ElementSpec(null, ElementSpec.StartTagType),
new ElementSpec(null, ElementSpec.ContentType, 7),
new ElementSpec(null, ElementSpec.EndTagType),
new ElementSpec(null, ElementSpec.StartTagType),
new ElementSpec(null, ElementSpec.ContentType, 5), };
specs[0].setDirection(ElementSpec.JoinPreviousDirection);
specs[specs.length - 2].setDirection(ElementSpec.JoinFractureDirection);
specs[specs.length - 1].setDirection(ElementSpec.JoinNextDirection);
buf.insert(0, textLen, specs, event);
List<?> edits = getEdits(event);