File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
docs/guides/javascript/modules Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : Dropzone
3+ ---
4+ <Since version =" 4.4 " issueNumber =" MDL-80850 " />
5+
6+ The use of the ` core/dropzone ` module provides a simplified developer experience for creating drop zones within Moodle.
7+
8+ The module attempts to ensure that accessibility requirements are met, including applying the correct styles and keyboard navigation.
9+
10+ Drop zones will trigger callbacks for common actions that occur within the drop zone for other code to listen to and react accordingly.
11+
12+ ``` js title="Example of creating a dropzone"
13+ import Dropzone from ' core/dropzone' ;
14+
15+ // Get the element that will be the dropzone.
16+ const dropZoneContainer = document .querySelector (' #dropZoneId' );
17+ // Create a new dropzone accepting only images.
18+ const dropZone = new Dropzone (
19+ dropZoneContainer,
20+ ' image/*' ,
21+ function (files ) {
22+ window .console .log (files);
23+ }
24+ );
25+ // Set the custom message for the dropzone. Otherwise, it will use the default message.
26+ dropZone .setLabel (' Drop images here' );
27+ // Initialising the dropzone.
28+ dropZone .init ();
29+ ```
You can’t perform that action at this time.
0 commit comments