Skip to content

Commit

Permalink
fix issue with removeFiles and fix issue with pasting content
Browse files Browse the repository at this point in the history
  • Loading branch information
rikschennink committed Jul 27, 2020
1 parent b5d8ebb commit 1a10367
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 4.19.0

- Add locale folder, can now import different locales.
- Improve `supports` method, now correctly detects MacOS Safari 8.
- Improve type definitions file.
- Fix issue with `removeFiles({ revert: false })` not working.
- Fix issue where content pasted in a textarea would be interpreted as a file.


## 4.18.0

- Add fallback for `fetch` when loading remote URLs, if no custom fetch supplied, will use default request.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Or get it from a CDN:

## Internationalization

The [locale folder](./locale/) contains different language files, you can use them like this:
The [locale folder](./locale/) contains different language files, PR's are welcom,e you can use locale files like this:

```js
import pt_BR from 'filepond/locale/pt-br.js';
Expand Down
2 changes: 1 addition & 1 deletion dist/filepond.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.18.0
* FilePond 4.19.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down
30 changes: 25 additions & 5 deletions dist/filepond.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.18.0
* FilePond 4.19.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -7834,6 +7834,23 @@ let listening = false;
const listeners$1 = [];

const handlePaste = e => {
// if is pasting in input or textarea and the target is outside of a filepond scope, ignore
const activeEl = document.activeElement;
if (activeEl && /textarea|input/i.test(activeEl.nodeName)) {
// test textarea or input is contained in filepond root
let inScope = false;
let element = activeEl;
while (element !== document.body) {
if (element.classList.contains('filepond--root')) {
inScope = true;
break;
}
element = element.parentNode;
}

if (!inScope) return;
}

requestDataTransferItems(e.clipboardData).then(files => {
// no files received
if (!files.length) {
Expand Down Expand Up @@ -9096,9 +9113,8 @@ const createApp = (initialOptions = {}) => {

const files = getFiles();

if (!queries.length) {
return Promise.all(files.map(removeFile));
}
if (!queries.length)
return Promise.all(files.map(file => removeFile(file, options)));

// when removing by index the indexes shift after each file removal so we need to convert indexes to ids
const mappedQueries = queries
Expand Down Expand Up @@ -9628,6 +9644,8 @@ const hasCreateObjectURL = () =>
'URL' in window && 'createObjectURL' in window.URL;
const hasVisibility = () => 'visibilityState' in document;
const hasTiming = () => 'performance' in window; // iOS 8.x
const hasCSSSupports = () => 'supports' in (window.CSS || {}); // use to detect Safari 9+
const isIE11 = () => /MSIE|Trident/.test(window.navigator.userAgent);

const supported = (() => {
// Runs immidiately and then remembers result for subsequent calls
Expand All @@ -9641,7 +9659,9 @@ const supported = (() => {
hasPromises() &&
hasBlobSlice() &&
hasCreateObjectURL() &&
hasTiming();
hasTiming() &&
// doesn't need CSSSupports but is a good way to detect Safari 9+ (we do want to support IE11 though)
(hasCSSSupports() || isIE11());

return () => isSupported;
})();
Expand Down
4 changes: 2 additions & 2 deletions dist/filepond.esm.min.js

Large diffs are not rendered by default.

38 changes: 33 additions & 5 deletions dist/filepond.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* FilePond 4.18.0
* FilePond 4.19.0
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -10701,6 +10701,23 @@
var listeners$1 = [];

var handlePaste = function handlePaste(e) {
// if is pasting in input or textarea and the target is outside of a filepond scope, ignore
var activeEl = document.activeElement;
if (activeEl && /textarea|input/i.test(activeEl.nodeName)) {
// test textarea or input is contained in filepond root
var inScope = false;
var element = activeEl;
while (element !== document.body) {
if (element.classList.contains('filepond--root')) {
inScope = true;
break;
}
element = element.parentNode;
}

if (!inScope) return;
}

requestDataTransferItems(e.clipboardData).then(function(files) {
// no files received
if (!files.length) {
Expand Down Expand Up @@ -12122,9 +12139,12 @@

var files = getFiles();

if (!queries.length) {
return Promise.all(files.map(removeFile));
}
if (!queries.length)
return Promise.all(
files.map(function(file) {
return removeFile(file, options);
})
);

// when removing by index the indexes shift after each file removal so we need to convert indexes to ids
var mappedQueries = queries
Expand Down Expand Up @@ -12723,6 +12743,12 @@
var hasTiming = function hasTiming() {
return 'performance' in window;
}; // iOS 8.x
var hasCSSSupports = function hasCSSSupports() {
return 'supports' in (window.CSS || {});
}; // use to detect Safari 9+
var isIE11 = function isIE11() {
return /MSIE|Trident/.test(window.navigator.userAgent);
};

var supported = (function() {
// Runs immidiately and then remembers result for subsequent calls
Expand All @@ -12736,7 +12762,9 @@
hasPromises() &&
hasBlobSlice() &&
hasCreateObjectURL() &&
hasTiming();
hasTiming() &&
// doesn't need CSSSupports but is a good way to detect Safari 9+ (we do want to support IE11 though)
(hasCSSSupports() || isIE11());

return function() {
return isSupported;
Expand Down
2 changes: 1 addition & 1 deletion dist/filepond.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/filepond.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filepond",
"version": "4.18.0",
"version": "4.19.0",
"description": "FilePond, Where files go to stretch their bits.",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -66,4 +66,4 @@
"rollup-plugin-terser": "^4.0.4",
"typescript": "^3.9.6"
}
}
}
4 changes: 1 addition & 3 deletions src/js/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,7 @@ export const createApp = (initialOptions = {}) => {

const files = getFiles();

if (!queries.length) {
return Promise.all(files.map(removeFile));
}
if (!queries.length) return Promise.all(files.map(file => removeFile(file, options)));

// when removing by index the indexes shift after each file removal so we need to convert indexes to ids
const mappedQueries = queries.map(query =>
Expand Down
20 changes: 19 additions & 1 deletion src/js/app/utils/createPaster.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { arrayRemove } from '../../utils/arrayRemove';
import { InteractionMethod } from '../enum/InteractionMethod';
import { requestDataTransferItems } from './requestDataTransferItems';

let listening = false;
const listeners = [];

const handlePaste = e => {

// if is pasting in input or textarea and the target is outside of a filepond scope, ignore
const activeEl = document.activeElement;
if (activeEl && /textarea|input/i.test(activeEl.nodeName)) {

// test textarea or input is contained in filepond root
let inScope = false;
let element = activeEl;
while (element !== document.body) {
if (element.classList.contains('filepond--root')) {
inScope = true;
break;
}
element = element.parentNode;
}

if (!inScope) return;
}

requestDataTransferItems(e.clipboardData).then(files => {
// no files received
if (!files.length) {
Expand Down
7 changes: 6 additions & 1 deletion src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const hasBlobSlice = () => 'slice' in Blob.prototype;
const hasCreateObjectURL = () => 'URL' in window && 'createObjectURL' in window.URL;
const hasVisibility = () => 'visibilityState' in document;
const hasTiming = () => 'performance' in window; // iOS 8.x
const hasCSSSupports = () => 'supports' in (window.CSS || {}); // use to detect Safari 9+
const isIE11 = () => /MSIE|Trident/.test(window.navigator.userAgent);

export const supported = (() => {

Expand All @@ -34,7 +36,10 @@ export const supported = (() => {
hasPromises() &&
hasBlobSlice() &&
hasCreateObjectURL() &&
hasTiming();
hasTiming() &&

// doesn't need CSSSupports but is a good way to detect Safari 9+ (we do want to support IE11 though)
(hasCSSSupports() || isIE11());

return () => isSupported;
})();
Expand Down

0 comments on commit 1a10367

Please sign in to comment.