class CoordinatorTextView: NSObject, UITextViewDelegate {
   @Binding var inputCoordinator: String

   init(input: Binding<String>) {
      self._inputCoordinator = input
   }
   func textViewDidChange(_ textView: UITextView) {
      inputCoordinator = textView.text
   }
   func textView(_ textView: UITextView, writingToolsIgnoredRangesInEnclosingRange enclosingRange: NSRange) -> [NSValue] {
      var result: [NSValue] = []
      let nsText = textView.text as NSString
      let text = nsText.substring(with: enclosingRange)

      let regex = /\[([^\]]*)\]/
      let matches = text.matches(of: regex)
      for match in matches {
         let innerRange = NSRange(match.range, in: text)
         result.append(NSValue(range: innerRange))
      }
      return result
   }
}