@scaleflex/widget-url 4.4.0 → 4.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.5.1](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.5.0...v4.5.1) (2025-10-14)
7
+
8
+ **Note:** Version bump only for package @scaleflex/widget-url
9
+
10
+
11
+
12
+
13
+
14
+ # [4.5.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.4.0...v4.5.0) (2025-10-08)
15
+
16
+ **Note:** Version bump only for package @scaleflex/widget-url
17
+
18
+
19
+
20
+
21
+
6
22
  # [4.4.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.4.0) (2025-10-07)
7
23
 
8
24
  **Note:** Version bump only for package @scaleflex/widget-url
@@ -0,0 +1,94 @@
1
+ import toArray from '@scaleflex/widget-utils/lib/toArray';
2
+
3
+ /*
4
+ SITUATION
5
+
6
+ 1. Cross-browser dataTransfer.items
7
+
8
+ paste in chrome [Copy Image]:
9
+ 0: {kind: "file", type: "image/png"}
10
+ 1: {kind: "string", type: "text/html"}
11
+ paste in safari [Copy Image]:
12
+ 0: {kind: "file", type: "image/png"}
13
+ 1: {kind: "string", type: "text/html"}
14
+ 2: {kind: "string", type: "text/plain"}
15
+ 3: {kind: "string", type: "text/uri-list"}
16
+ paste in firefox [Copy Image]:
17
+ 0: {kind: "file", type: "image/png"}
18
+ 1: {kind: "string", type: "text/html"}
19
+
20
+ paste in chrome [Copy Image Address]:
21
+ 0: {kind: "string", type: "text/plain"}
22
+ paste in safari [Copy Image Address]:
23
+ 0: {kind: "string", type: "text/plain"}
24
+ 1: {kind: "string", type: "text/uri-list"}
25
+ paste in firefox [Copy Image Address]:
26
+ 0: {kind: "string", type: "text/plain"}
27
+
28
+ drop in chrome [from browser]:
29
+ 0: {kind: "string", type: "text/uri-list"}
30
+ 1: {kind: "string", type: "text/html"}
31
+ drop in safari [from browser]:
32
+ 0: {kind: "string", type: "text/uri-list"}
33
+ 1: {kind: "string", type: "text/html"}
34
+ 2: {kind: "file", type: "image/png"}
35
+ drop in firefox [from browser]:
36
+ 0: {kind: "string", type: "text/uri-list"}
37
+ 1: {kind: "string", type: "text/x-moz-url"}
38
+ 2: {kind: "string", type: "text/plain"}
39
+
40
+ 2. We can determine if it's a 'copypaste' or a 'drop', but we can't discern between [Copy Image] and [Copy Image Address].
41
+
42
+ CONCLUSION
43
+
44
+ 1. 'paste' ([Copy Image] or [Copy Image Address], we can't discern between these two)
45
+ Don't do anything if there is 'file' item. .handlePaste in the ExplorerPlugin will deal with all 'file' items.
46
+ If there are no 'file' items - handle 'text/plain' items.
47
+
48
+ 2. 'drop'
49
+ Take 'text/uri-list' items. Safari has an additional item of .kind === 'file', and you may worry about the item being duplicated (first by ExplorerPlugin, and then by UrlPlugin, now), but don't. Directory handling code won't pay attention to this particular item of kind 'file'.
50
+ */
51
+
52
+ /**
53
+ * Finds all links dropped/pasted from one browser window to another.
54
+ *
55
+ * @param {object} dataTransfer - DataTransfer instance, e.g. e.clipboardData, or e.dataTransfer
56
+ * @param {string} isDropOrPaste - either 'drop' or 'paste'
57
+ * @param {Function} callback - (urlString) => {}
58
+ */
59
+ export default function forEachDroppedOrPastedUrl(dataTransfer, isDropOrPaste, callback) {
60
+ var items = toArray(dataTransfer.items);
61
+ var urlItems;
62
+ switch (isDropOrPaste) {
63
+ case 'paste':
64
+ {
65
+ var atLeastOneFileIsDragged = items.some(function (item) {
66
+ return item.kind === 'file';
67
+ });
68
+ if (atLeastOneFileIsDragged) {
69
+ return;
70
+ } else {
71
+ urlItems = items.filter(function (item) {
72
+ return item.kind === 'string' && item.type === 'text/plain';
73
+ });
74
+ }
75
+ break;
76
+ }
77
+ case 'drop':
78
+ {
79
+ urlItems = items.filter(function (item) {
80
+ return item.kind === 'string' && item.type === 'text/uri-list';
81
+ });
82
+ break;
83
+ }
84
+ default:
85
+ {
86
+ throw new Error("isDropOrPaste must be either 'drop' or 'paste', but it's ".concat(isDropOrPaste));
87
+ }
88
+ }
89
+ urlItems.forEach(function (item) {
90
+ item.getAsString(function (urlString) {
91
+ return callback(urlString);
92
+ });
93
+ });
94
+ }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@scaleflex/widget-url",
3
3
  "description": "The Url plugin lets users import files from the Internet. Paste any URL and it’ll be added!",
4
- "version": "4.4.0",
4
+ "version": "4.5.1",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "style": "dist/style.min.css",
8
8
  "types": "types/index.d.ts",
9
9
  "dependencies": {
10
- "@scaleflex/widget-common": "^4.4.0",
11
- "@scaleflex/widget-companion-client": "^4.4.0",
12
- "@scaleflex/widget-icons": "^4.4.0",
13
- "@scaleflex/widget-utils": "^4.4.0"
10
+ "@scaleflex/widget-common": "^4.5.1",
11
+ "@scaleflex/widget-companion-client": "^4.5.1",
12
+ "@scaleflex/widget-icons": "^4.5.1",
13
+ "@scaleflex/widget-utils": "^4.5.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "react": "^19.0.0",
@@ -30,5 +30,5 @@
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
- "gitHead": "04b8ec545c4f10be89f5a44eed954acf8433360c"
33
+ "gitHead": "b211f9961ad30d3eaa01138f34e190ad5d38fb91"
34
34
  }