diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj
index d5585c329..9b79bf298 100644
--- a/Mastodon.xcodeproj/project.pbxproj
+++ b/Mastodon.xcodeproj/project.pbxproj
@@ -4778,7 +4778,7 @@
repositoryURL = "https://github.com/TwidereProject/MetaTextView.git";
requirement = {
kind = exactVersion;
- version = 1.2.2;
+ version = 1.2.3;
};
};
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
index f1135b12e..ebbde8329 100644
--- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -12,7 +12,7 @@
CoreDataStack.xcscheme_^#shared#^_
orderHint
- 20
+ 21
Mastodon - ASDK.xcscheme_^#shared#^_
@@ -37,7 +37,7 @@
NotificationService.xcscheme_^#shared#^_
orderHint
- 21
+ 22
SuppressBuildableAutocreation
diff --git a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
index fcd3317da..8414b940a 100644
--- a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -114,8 +114,8 @@
"repositoryURL": "https://github.com/TwidereProject/MetaTextView.git",
"state": {
"branch": null,
- "revision": "d48cf6a2479ce6fc4f836b6c4d7ba855cdbc71cc",
- "version": "1.2.2"
+ "revision": "5b86b386464be8a6da5383aa714c458c07da6c01",
+ "version": "1.2.3"
}
},
{
diff --git a/Mastodon/Diffiable/Section/ComposeStatusSection.swift b/Mastodon/Diffiable/Section/ComposeStatusSection.swift
index 3419cc113..6a9dd2b3b 100644
--- a/Mastodon/Diffiable/Section/ComposeStatusSection.swift
+++ b/Mastodon/Diffiable/Section/ComposeStatusSection.swift
@@ -58,14 +58,8 @@ extension ComposeStatusSection {
}
-protocol CustomEmojiReplaceableTextInput: AnyObject {
+protocol CustomEmojiReplaceableTextInput: UITextInput & UIResponder {
var inputView: UIView? { get set }
- func reloadInputViews()
-
- // UIKeyInput
- func insertText(_ text: String)
- // UIResponder
- var isFirstResponder: Bool { get }
}
class CustomEmojiReplaceableTextInputReference {
diff --git a/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift b/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift
index 8314dfc3f..760203a39 100644
--- a/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift
+++ b/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift
@@ -46,8 +46,23 @@ extension CustomEmojiPickerInputViewModel {
removeEmptyReferences()
for reference in customEmojiReplaceableTextInputReferences {
- guard reference.value?.isFirstResponder == true else { continue }
- reference.value?.insertText(text)
+ guard let textInput = reference.value else { continue }
+ guard textInput.isFirstResponder == true else { continue }
+
+ let selectedTextRange = textInput.selectedTextRange
+ textInput.insertText(text)
+
+ // due to insert text render as attachment
+ // the cursor reset logic not works
+ // hack with hard code +2 offset
+ assert(text.hasSuffix(": "))
+ if text.hasPrefix(":") && text.hasSuffix(": "),
+ let selectedTextRange = selectedTextRange,
+ let newPosition = textInput.position(from: selectedTextRange.start, offset: 2) {
+ let newSelectedTextRange = textInput.textRange(from: newPosition, to: newPosition)
+ textInput.selectedTextRange = newSelectedTextRange
+ }
+
return reference
}