filepond-plugin-file-rename
Advanced tools
Comparing version 1.1.3 to 1.1.4
/*! | ||
* FilePondPluginFileRename 1.1.3 | ||
* FilePondPluginFileRename 1.1.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -4,0 +4,0 @@ * Please visit https://pqina.nl/filepond/ for details. |
/*! | ||
* FilePondPluginFileRename 1.1.3 | ||
* FilePondPluginFileRename 1.1.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -4,0 +4,0 @@ * Please visit https://pqina.nl/filepond/ for details. |
/*! | ||
* FilePondPluginFileRename 1.1.3 | ||
* FilePondPluginFileRename 1.1.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -22,2 +22,3 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
utils = _ref.utils; | ||
// get quick reference to Type utils | ||
@@ -28,6 +29,7 @@ var Type = utils.Type, | ||
getExtensionFromFilename = utils.getExtensionFromFilename, | ||
getFilenameWithoutExtension = utils.getFilenameWithoutExtension; // called for each file that is loaded | ||
getFilenameWithoutExtension = utils.getFilenameWithoutExtension; | ||
// called for each file that is loaded | ||
// right before it is set to the item state | ||
// should return a promise | ||
addFilter('LOAD_FILE', function(file, _ref2) { | ||
@@ -39,8 +41,8 @@ var query = _ref2.query; | ||
var renameFunction = query('GET_FILE_RENAME_FUNCTION'); | ||
if (!isFile(file) || !allowFileRename || !renameFunction) { | ||
resolve(file); | ||
return; | ||
} // can either return a name or a promise | ||
} | ||
// can either return a name or a promise | ||
var newFilename = renameFunction({ | ||
@@ -50,16 +52,20 @@ name: file.name, | ||
extension: '.'.concat(getExtensionFromFilename(file.name)) | ||
}); // renames the file and resolves | ||
}); | ||
// renames the file and resolves | ||
var rename = function rename(name) { | ||
resolve(renameFile(file, name)); | ||
}; // has returned new filename immidiately | ||
}; | ||
// has returned new filename immidiately | ||
if (typeof newFilename === 'string') { | ||
rename(newFilename); | ||
return; | ||
} // is promise | ||
} | ||
// is promise | ||
newFilename.then(rename); | ||
}); | ||
}); | ||
return { | ||
@@ -69,2 +75,3 @@ options: { | ||
allowFileRename: [true, Type.BOOLEAN], | ||
// Rename function to run for this | ||
@@ -74,12 +81,10 @@ fileRenameFunction: [null, Type.FUNCTION] | ||
}; | ||
}; // fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags | ||
}; | ||
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags | ||
var isBrowser = | ||
typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
if (isBrowser) { | ||
document.dispatchEvent( | ||
new CustomEvent('FilePond:pluginloaded', { | ||
detail: plugin | ||
}) | ||
new CustomEvent('FilePond:pluginloaded', { detail: plugin }) | ||
); | ||
@@ -86,0 +91,0 @@ } |
/*! | ||
* FilePondPluginFileRename 1.1.3 | ||
* FilePondPluginFileRename 1.1.4 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -4,0 +4,0 @@ * Please visit https://pqina.nl/filepond/ for details. |
{ | ||
"name": "filepond-plugin-file-rename", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "File Rename Plugin for FilePond", | ||
@@ -15,2 +15,8 @@ "license": "MIT", | ||
"module": "dist/filepond-plugin-file-rename.esm.js", | ||
"browserslist": [ | ||
"last 1 version and not Explorer 10", | ||
"Explorer 11", | ||
"iOS >= 9", | ||
"Android >= 4.4" | ||
], | ||
"files": [ | ||
@@ -17,0 +23,0 @@ "dist" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9258
160