import React, { useState, useCallback } from "react" import * as hooks from "./hooks" import HelpButton from "./helpButton" import LinkButton from "./util/linkButton" import ContentEditable from "./util/contentEditable" export default Pastebin = -> [openDialog, renderDialog] = hooks.useDialog() [highlight, toggleHighlight] = hooks.useToggle false [text, setText] = useState "" # Paste hook and events clearText = (status) -> setText "" if status == 200 [doPaste, pasting, _] = hooks.usePaste openDialog, useCallback clearText, [] onEditTextUpdate = (ev) -> setText ev.target.value # onEditTextUpdate depends on absolutely nothing for reading onEditTextUpdate = useCallback onEditTextUpdate, [] paste = -> # We force a single file name and mime type on web-pasted content doPaste "web_paste.txt", "text/plain", text # Paste depends only on the actual text # and of course the function doPaste paste = useCallback paste, [text, doPaste]
{renderDialog()}
File Upload