17 lines
419 B
Swift
17 lines
419 B
Swift
import SwiftUI
|
|
|
|
struct NoteTextEditor: View {
|
|
@Binding var text: String
|
|
let remoteText: String?
|
|
@State private var selection: TextSelection? = nil
|
|
|
|
var body: some View {
|
|
TextEditor(text: $text, selection: $selection)
|
|
.onChange(of: remoteText) { oldValue, newValue in
|
|
guard let newValue, newValue != text else { return }
|
|
// Apply remote text first
|
|
text = newValue
|
|
}
|
|
}
|
|
}
|