         return separatorView
     }()
 
-    fileprivate(set) var mode = EditionMode.richText {
+    fileprivate(set) var editingMode: EditMode = .richText {
         didSet {
-            switch mode {
+            view.endEditing(true)
+            
+            switch editingMode {
             case .html:
                 switchToHTML()
             case .richText:

            ])
    }

    func configureNavigationBar() {
        let title = NSLocalizedString("HTML", comment: "HTML!")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: title,
                                                            style: .plain,
                                                            target: self,
                                                           action: #selector(switchEditionMode))
    }


    // MARK: - Helpers

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



        case .media:
            showImagePicker()
        case .sourcecode:
            toggleEditingMode()
        }
        updateFormatBar()
    }
