           block.copyWithText(block.text.removeAttributeAtRange(attribute, textRange))
 
   updateAttributesForAttachment: edit "updateAttributesForAttachment", (attributes, attachment) ->
-    locationRange = @getLocationRangeOfAttachment(attachment)
-    text = @getTextAtIndex(locationRange.index)
-    @blockList = @blockList.editObjectAtIndex locationRange.index, (block) ->
+    positionRange = @getPositionRangeOfAttachment(attachment)
+    {index} = @locationFromPosition(positionRange.start)
+    text = @getTextAtIndex(index)
+
+    @blockList = @blockList.editObjectAtIndex index, (block) ->
       block.copyWithText(text.updateAttributesForAttachment(attributes, attachment))
 
   removeAttributeForAttachment: edit "removeAttributeForAttachment", (attribute, attachment) ->


  insertTextAtPositionRange: edit "insertTextAtPositionRange", (text, positionRange) ->
    positionRange = Trix.PositionRange.box(positionRange)
    locationRange = @locationRangeFromPositionRange(positionRange)

    @removeTextAtPositionRange(positionRange)
    @blockList = @blockList.editObjectAtIndex locationRange.index, (block) ->
      block.copyWithText(block.text.insertTextAtPosition(text, locationRange.offset))

  removeTextAtPositionRange: edit "removeTextAtPositionRange", (positionRange) ->
    locationRange = @locationRangeFromPositionRange(positionRange)
    return if locationRange.isCollapsed()

    leftIndex = locationRange.start.index
    leftBlock = @getBlockAtIndex(leftIndex)
    leftText = leftBlock.text.getTextAtRange([0, locationRange.start.offset])

    rightIndex = locationRange.end.index
    rightBlock = @getBlockAtIndex(rightIndex)
    rightText = rightBlock.text.getTextAtRange([locationRange.end.offset, rightBlock.getLength()])

    text = leftText.appendText(rightText)
    block = leftBlock.copyWithText(text)

  insertBlockBreakAtPositionRange: edit "insertBlockBreakAtPositionRange", (positionRange) ->
    positionRange = Trix.PositionRange.box(positionRange)
    position = positionRange.start
    {offset} = @locationFromPosition(position)

    @removeTextAtPositionRange(positionRange)
    blocks = [new Trix.Block] if offset is 0
    @blockList = @blockList.insertSplittableListAtPosition(new Trix.SplittableList(blocks), position)

  applyBlockAttributeAtPositionRange: edit "applyBlockAttributeAtPositionRange", (attributeName, value, positionRange) ->
