 extension EditorDemoController : UITextFieldDelegate
 {
 
+}
+
+extension EditorDemoController
+{
+    enum EditionMode {
+        case RichText
+        case HTML
+
+        mutating func toggle() {
+            switch self {
+            case .HTML:
+                self = .RichText
+            case .RichText:
+                self = .HTML
+            }
+        }
+    }
+
+    private func switchToHTML() {
+        htmlTextView.text = richTextView.toHTML()
+        htmlTextView.hidden = false
+
+        richTextView.endEditing(true)
+        richTextView.hidden = true
+    }
+
+    private func switchToRichText() {
+        richTextView.loadHTML(htmlTextView.text)
+        richTextView.hidden = false
+
+        htmlTextView.endEditing(true)
+        htmlTextView.hidden = true
+    }
 }
 
 

            richTextView.topAnchor.constraintEqualToAnchor(view.topAnchor),
            bottomConstraint!
        ])
    }

    func configureNavigationBar() {


    // MARK: - Helpers

    @IBAction func switchEditionMode() {
        mode.toggle()
    }


