fix: textView break IME input issue. resolve #342

This commit is contained in:
CMK 2022-03-19 02:51:24 +08:00
parent ad524b0172
commit 4614bd8692
2 changed files with 8 additions and 2 deletions

View File

@ -161,7 +161,10 @@ extension ComposeStatusContentTableViewCell: UITextViewDelegate {
logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): text: \(textView.text ?? "<nil>")")
guard textView === statusContentWarningEditorView.textView else { return }
// replace line break with space
textView.text = textView.text.replacingOccurrences(of: "\n", with: " ")
// needs check input state to prevent break the IME
if textView.markedTextRange == nil {
textView.text = textView.text.replacingOccurrences(of: "\n", with: " ")
}
contentWarningContent.send(textView.text)
}

View File

@ -81,7 +81,10 @@ public struct StatusEditorView: UIViewRepresentable {
}
public func textViewDidChange(_ textView: UITextView) {
parent.string = textView.text
// prevent break IME input
if textView.markedTextRange == nil {
parent.string = textView.text
}
}
func updateLayout(width: CGFloat) {