easy-file-system 1.5.41 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -5
- package/example.js +19 -15
- package/lib/example/view.js +7 -3
- package/lib/explorer.js +7 -7
- package/lib/mixins/explorer.js +5 -5
- package/lib/mixins/rubbishBin.js +3 -3
- package/package.json +1 -1
- package/src/example/view.js +6 -1
- package/src/explorer.js +9 -6
- package/src/mixins/explorer.js +4 -4
- package/src/mixins/rubbishBin.js +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A file system explorer and a rubbish bin.
|
|
4
4
|
|
|
5
|
-
The file explorer can be populated with file and directory names. It takes handlers for opening files
|
|
5
|
+
The file explorer can be populated with file and directory names. It takes handlers for opening files, moving and removing entries and so on.
|
|
6
6
|
|
|
7
7
|
### JSX support
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ There is now support for JSX in the form of [Juxtapose](https://github.com/djalb
|
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
21
|
-
You can install Easy
|
|
21
|
+
You can install Easy File System with [npm](https://www.npmjs.com/):
|
|
22
22
|
|
|
23
23
|
npm install easy-file-system
|
|
24
24
|
|
|
@@ -104,17 +104,31 @@ If you try to remove a file or directory more than once, nothing happens.
|
|
|
104
104
|
|
|
105
105
|
### Handling opening files
|
|
106
106
|
|
|
107
|
-
To open a file, so to speak, double
|
|
107
|
+
To open a file, so to speak, double-click on the file name. When this happens the requisite handlers will be called with the file's path.
|
|
108
108
|
|
|
109
109
|
```
|
|
110
|
-
function openHandler(filePath) {
|
|
110
|
+
function openHandler(filePath, explorer) {
|
|
111
111
|
console.log(`Open: '${filePath}'.`)
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
Note that double-clicking on a directory name on the other hand toggle's the entry's collapsed state. Also note that no callback is passed.
|
|
116
|
+
|
|
117
|
+
### Handling selecting files and directories
|
|
118
|
+
|
|
119
|
+
Both file and directory entries can be selected by clicking on the entry's icon. A handler can be set that will be called whenever this happens.
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
function selectedHandler(path, selected, expoorer) {
|
|
123
|
+
console.log(`Open: '${path}'.`)
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Again note that no callback is passed.
|
|
128
|
+
|
|
115
129
|
### Handling moving files and directories
|
|
116
130
|
|
|
117
|
-
When file and directory entries are moved, the requisite handlers are invoked with
|
|
131
|
+
When file and directory entries are moved, the requisite handlers are invoked with three arguments, namely an array of path maps, a reference to the explorer and a `done` callback method. You *must* call the `done()` method when you are done. Each element of the array of path maps is a mutable plain old JavaScript object with `sourceEntryPath`, `targetEntryPath`, `entryDirectory` and `collapsed` properties. The `entryDirectory` property is set to `true` if the entry is a directory. In the case of file path entries, the latter property is set to `null`. If you want the entry to be moved, leave the object as-is. If you want the entry to be left in place, change the source path to `null`. If you want the entry to be removed, change the target path to `null`. Simply leaving the array of path maps alone with therefore move the entries as expected.
|
|
118
132
|
|
|
119
133
|
### Handling removing files and directories
|
|
120
134
|
|