 #= require trix/observers/mutation_observer
 #= require trix/operations/file_verification_operation
 
-{handleEvent, findClosestElementFromNode, findElementForContainerAtOffset, defer} = Trix
+{handleEvent, findClosestElementFromNode, findElementForContainerAtOffset, defer, makeElement} = Trix
 
 inputLog = Trix.Logger.get("input")
 

    paste: (event) ->
      paste = event.clipboardData ? event.testClipboardData
      return unless paste?
      return for type in paste.types when type.match(/^com\.apple/)
      event.preventDefault()

      if html = paste.getData("text/html")
        @delegate?.inputControllerWillPasteText({paste, html})
        @responder?.insertHTML(html)
      else if string = paste.getData("text/plain")
        @delegate?.inputControllerWillPasteText({paste, string})
        @responder?.insertString(string)

      if "Files" in paste.types
        if file = paste.items?[0]?.getAsFile?()
          if not file.name and extension = extensionForFile(file)
            file.name = "pasted-file-#{++pastedFileCount}.#{extension}"
          @delegate?.inputControllerWillAttachFiles()
          if @responder?.insertFile(file)
            file.trixInserted = true

      @requestRender()

    compositionstart: (event) ->
      @mutationObserver.stop()


keyEventIsKeyboardCommand = (event) ->
  if /Mac|^iP/.test(navigator.platform) then event.metaKey else event.ctrlKey

pasteEventIsCrippledSafariHTMLPaste = (event) ->
  if types = event.clipboardData?.types
    "com.apple.webarchive" in types and "text/html" not in types
