Note格式化后按钮变为复制并打开备忘录

This commit is contained in:
2026-07-12 22:29:17 +08:00
parent e86c5e183c
commit d2aa860bc3
+16
View File
@@ -17,6 +17,7 @@ class FormatNoteViewController: UIViewController {
private var resetButton: UIBarButtonItem!
private var rightBarButtonMode: RightBarButtonMode = .paste
private var isCloudFormatted = false
private var isNoteFormatted = false
private enum RightBarButtonMode {
case paste
@@ -120,7 +121,9 @@ class FormatNoteViewController: UIViewController {
textView.text = ""
rightBarButtonMode = .paste
isCloudFormatted = false
isNoteFormatted = false
iCloudButton.setTitle("iCloud 格式化", for: .normal)
noteButton.setTitle("Note 格式化", for: .normal)
updateRightBarButtonItem()
}
@@ -158,10 +161,23 @@ class FormatNoteViewController: UIViewController {
showEmptyAlert()
return
}
if isNoteFormatted {
copyAndOpenNotes()
} else {
textView.text = formatForNote(textView.text)
isNoteFormatted = true
noteButton.setTitle("复制并打开备忘录", for: .normal)
rightBarButtonMode = .reset
updateRightBarButtonItem()
}
}
private func copyAndOpenNotes() {
UIPasteboard.general.string = textView.text
guard let url = URL(string: "mobilenotes://") else { return }
guard UIApplication.shared.canOpenURL(url) else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
private func formatForCloud(_ text: String) -> String {
var content = text