0.1.0 • Published 2 years ago

svelte-dropzone-textarea v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

svelte-dropzone-textarea

Drag and drop a file into a <textarea> Svelte component and load the file's content into the textarea.

Example usage:

<script>
  import DropzoneTextarea from "svelte-dropzone-textarea";

  let data = "";

  const handleRead = (text) => {
    data = text;
    console.log(`handleRead(): ${text.length} bytes`);
  };

  const handleUpdate = (text) => {
    console.log(`handleUpdate(): ${text.length} bytes`);
  };
</script>

<h1>DropzoneTextarea</h1>
<DropzoneTextarea {handleRead} {handleUpdate} />
<p>data is {data.length} characters long</p>

Props

NameTypeDescription
handleFilefunctionCallback function that is called when a file is dropped.
handleReadfunctionCallback function that is called when a file is dropped and read.
handleUpdatefunctionCallback function that is called when the textarea is updated, includes dropping or typing.
valueModifyfunctionModify value of dropped file contents before updating textarea.
...rest...Any other props are passed to the underlying textarea.