svelte-dropzone-textarea

0.1.0 • Public • Published

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

Name Type Description
handleFile function Callback function that is called when a file is dropped.
handleRead function Callback function that is called when a file is dropped and read.
handleUpdate function Callback function that is called when the textarea is updated, includes dropping or typing.
valueModify function Modify value of dropped file contents before updating textarea.
...rest ... Any other props are passed to the underlying textarea.

Readme

Keywords

none

Package Sidebar

Install

npm i svelte-dropzone-textarea

Weekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

35.2 kB

Total Files

7

Last publish

Collaborators

  • andygock