         super.init(frame: .zero, configuration: SectionEditorWebViewConfiguration())
         loadHTMLFromAssetsFile(codeMirrorIndexFileName, scrolledToFragment: nil)
         config.selectionChangedDelegate = self
+        scrollView.keyboardDismissMode = .interactive
     }
 
     required init?(coder: NSCoder) {

    func highlightRedoButton() {
        //
    }


}

            return
        }

        let newSelector = #selector(getter: SectionEditorWebView.customInputAccessoryView)
        guard let newMethod = class_getInstanceMethod(SectionEditorWebView.self, newSelector) else {
            assertionFailure("Couldn't get instance method for \(newSelector)")
            return
        }

        let originalSelector = #selector(getter: SectionEditorWebView.inputAccessoryView)

        class_addMethod(newClass, originalSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))
        objc_registerClassPair(newClass)
        object_setClass(wkContent, newClass)
    }()

    private func associateViewWithSelf(_ view: UIView, using key: inout Int) {
        objc_setAssociatedObject(self, &key, view, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
    }

    @objc private var customInputAccessoryView: UIView? {
        var trueSelf: UIView? = self
        while (trueSelf != nil) && !(trueSelf is WKWebView) {
            trueSelf = trueSelf?.superview
        }
        guard let webView = trueSelf as? SectionEditorWebView else {
            return nil
        }

        guard let preferredInputAccessoryView = preferredInputAccessoryView(associatedWith: webView) else {
            return nil
        }

        preferredInputAccessoryView.apply(theme: Theme.standard)
        return preferredInputAccessoryView
    }

    private func preferredInputAccessoryView(associatedWith webView: SectionEditorWebView) -> (UIView & Themeable)? {
        guard let inputAccessoryViewType = webView.inputAccessoryViewType else {
            return nil
        }

        let maybeView: Any?

        switch inputAccessoryViewType {
        case .default:
            maybeView = objc_getAssociatedObject(webView, &InputAccessoryViewKey.Default)
        case .highlight:
            maybeView = objc_getAssociatedObject(webView, &InputAccessoryViewKey.Highlight)
        }

        guard let preferredInputAccessoryView = maybeView as? UIView & Themeable else {
            assertionFailure("Couldn't get object associated with \(webView)")
            return nil
        }

        return preferredInputAccessoryView
    }

    private func themeableView(associatedWith object: Any, key: inout String) -> (UIView & Themeable)? {
        guard let view = objc_getAssociatedObject(object, key) as? (UIView & Themeable) else {
            return nil
        }
        return view
    }

    // MARK: -

    func setInputViewHidden(type: TextFormattingInputViewController.InputViewType? = nil, hidden: Bool) {
        if hidden {
            inputAccessoryViewType = previousInputAccessoryViewType
        } else {
            inputAccessoryViewType = nil
        }

        let animator = UIViewPropertyAnimator.init(duration: 0.3, curve: .easeInOut) {
            self.resignFirstResponder()
        }

        animator.addCompletion { (_) in
            self.becomeFirstResponder()
        }

        inputViewType = type

        animator.startAnimation()
    }
}

extension SectionEditorWebView: DefaultEditToolbarViewDelegate {
    func defaultEditToolbarViewDidTapTextFormattingButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        setInputViewHidden(type: .textFormatting, hidden: false)
    }

    func defaultEditToolbarViewDidTapHeaderFormattingButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        setInputViewHidden(type: .textStyle, hidden: false)
    }

    func defaultEditToolbarViewDidTapAddCitationButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        //
    }

    func defaultEditToolbarViewDidTapAddLinkButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        //
    }

    func defaultEditToolbarViewDidTapUnorderedListButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        //
    }

    func defaultEditToolbarViewDidTapOrderedListButton(_ defaultEditToolbarView: DefaultEditToolbarView, button: UIButton) {
        //
    }
}

extension SectionEditorWebView: TextFormattingDelegate {
    func textFormattingProvidingDidTapCloseButton(_ textFormattingProviding: TextFormattingProviding) {
        setInputViewHidden(hidden: true)
    }
}

