v2.0.0
struct ContentView: View {
@ObservedObject var vm: CodeMirrorVM = .init()
@State var value: String = ""
var body: some View {
- CodeMirror(vm)
+ CodeMirrorView(vm, value: $value)
.onAppear {
vm.setContent(jsonString)
}
}
}
The new component CodeMirror
import SwiftUI
import CodeMirror
struct ContentView: View {
@State var value: String = ""
var body: some View {
CodeMirror(value: $value)
.onLoadSuccess() {
print("Hello!")
}
.onLoadFailed { error in
print("@@@2 \(#function) \(error)")
}
.onContentChange {
print("@@@3 Content Did Change")
}
}
}