         detectAttachmentRemoved(in: range)
         textStore.replaceCharacters(in: range, with: str)
 
+        let utf16String = textStoreString.utf16
+        let startIndex = utf16String.index(utf16String.startIndex, offsetBy: range.location)
+        let endIndex = utf16String.index(startIndex, offsetBy: range.length)
+        textStoreString.replaceSubrange(startIndex..<endIndex, with: str)
+
         edited(.editedCharacters, range: range, changeInLength: str.characters.count - range.length)
         
         endEditing()


        detectAttachmentRemoved(in: range)
        textStore.replaceCharacters(in: range, with: preprocessedString)
        edited([.editedAttributes, .editedCharacters], range: range, changeInLength: attrString.length - range.length)

        endEditing()

    // MARK: - Calculated Properties

    override open var string: String {
        return textStoreString
    }

    open var mediaAttachments: [MediaAttachment] {
