                 self?.applyElement(elementType, spanning: range)
             }
         }
+
+        // MARK: - Images
+
+        /// Applies an image to the specified range
+        ///
+        /// - Parameters:
+        ///   - imageURL: the URL for the img src attribute
+        ///   - range: the range to insert the image
+        ///
+        func insertImage(imageURL: URL, replacing range:NSRange) {
+            performAsyncUndoable { [weak self] in
+                self?.insertImageSynchronously(imageURL: imageURL, replacing: range)
+            }
+        }
+
+        private func insertImageSynchronously(imageURL: URL, replacing range: NSRange) {
+            let imageURLString = imageURL.absoluteString
+
+            let elementDescriptor = ElementNodeDescriptor(elementType: .img,
+                                                          attributes: [Libxml2.StringAttribute(name:"src", value: imageURLString)])
+
+            rootNode.replaceCharacters(inRange: range, withElement: elementDescriptor)
+        }
+
         // MARK: - Styles to HTML elements
         
         /// Applies a standard HTML element to the specified range.

            }
        }

        // MARK: - Images

        /// Applies an image to the specified range
        ///
        /// - Parameters:
        ///   - imageURL: the URL for the img src attribute
        ///   - range: the range to insert the image
        ///
        func insertImage(imageURL: URL, replacing range:NSRange) {
            performAsyncUndoable { [weak self] in
                self?.insertImageSynchronously(imageURL: imageURL, replacing: range)
            }
        }

        private func insertImageSynchronously(imageURL: URL, replacing range: NSRange) {
            let imageURLString = imageURL.absoluteString

            let elementDescriptor = ElementNodeDescriptor(elementType: .img,
                                                          attributes: [Libxml2.StringAttribute(name:"src", value: imageURLString)])

            rootNode.replaceCharacters(inRange: range, withElement: elementDescriptor)
        }
        
        private static let headerLevels: [StandardElementType] = [.h1, .h2, .h4, .h5, .h6]
        private func elementTypeForHeaderLevel(_ headerLevel: Int) -> StandardElementType? {
            if headerLevel < 1 && headerLevel > DOMString.headerLevels.count {
                return nil

    /// having to figure out if they'll be queueing additional operations (they won't).
    ///
    class DOMString {

        private static let headerLevels: [StandardElementType] = [.h1, .h2, .h4, .h5, .h6]

        private lazy var editContext: EditContext = {
            return EditContext(undoManager: self.domUndoManager)
        }()
