             attributes.push(config.listAttribute) if config.listAttribute
       element = element.parentNode
     attributes.reverse()
+
+  getMarginOfBlockElementAtIndex: (index) ->
+    if element = @blockElements[index]
+      unless tagName(element) in @getBlockTagNames() or element in @processedElements
+        getBlockElementMargin(element)
+
+  getMarginOfDefaultBlockElement: ->
+    element = makeElement(Trix.config.blockAttributes.default.tagName)
+    @container.appendChild(element)
+    getBlockElementMargin(element)
+
+  translateBlockElementMarginsToNewlines: ->
+    defaultMargin = @getMarginOfDefaultBlockElement()
+
+    for block, index in @blocks when margin = @getMarginOfBlockElementAtIndex(index)
+      if margin.top > defaultMargin.top * 2
+        @prependStringToTextAtIndex("\n", index)
+
+      if margin.bottom > defaultMargin.bottom * 2
+        @appendStringToTextAtIndex("\n", index)
+
+  pieceForString = (string, attributes = {}) ->
+    type = "string"
+    {string, attributes, type}
+
+  pieceForAttachment = (attachment, attributes = {}) ->
+    type = "attachment"
+    {attachment, attributes, type}
+
+  blockForAttributes = (attributes = {}) ->
+    text = []
+    {text, attributes}
 
   getAttachmentAttributes = (element) ->
     JSON.parse(element.dataset.trixAttachment)


  findParentBlockElement: (element) ->
    {parentElement} = element
    while parentElement
      if @isBlockElement(parentElement) and parentElement in @blockElements
        return parentElement
      else


    attributes

  getBlockAttributes: (element) ->
    attributes = []
    while element and element isnt @container
      for attribute, config of Trix.config.blockAttributes when config.parse isnt false
        if tagName(element) is config.tagName
          if config.test?(element) or not config.test
