@atlaskit/pragmatic-drag-and-drop 1.2.3 → 1.3.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 +18 -0
- package/dist/cjs/adapter/element-adapter.js +35 -2
- package/dist/cjs/adapter/text-selection-adapter.js +12 -3
- package/dist/cjs/make-adapter/make-drop-target.js +11 -11
- package/dist/cjs/make-adapter/make-monitor.js +3 -3
- package/dist/cjs/public-utils/external/url.js +40 -18
- package/dist/cjs/util/media-types/url-media-type.js +2 -2
- package/dist/es2019/adapter/element-adapter.js +36 -5
- package/dist/es2019/adapter/text-selection-adapter.js +12 -3
- package/dist/es2019/public-utils/external/url.js +37 -17
- package/dist/es2019/util/media-types/url-media-type.js +1 -1
- package/dist/esm/adapter/element-adapter.js +36 -3
- package/dist/esm/adapter/text-selection-adapter.js +12 -3
- package/dist/esm/make-adapter/make-drop-target.js +11 -11
- package/dist/esm/make-adapter/make-monitor.js +3 -3
- package/dist/esm/public-utils/external/url.js +41 -19
- package/dist/esm/util/media-types/url-media-type.js +1 -1
- package/dist/types/util/media-types/url-media-type.d.ts +1 -1
- package/dist/types-ts4.5/util/media-types/url-media-type.d.ts +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/pragmatic-drag-and-drop
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#141279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141279)
|
|
8
|
+
[`a38f3af4bfc79`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a38f3af4bfc79) -
|
|
9
|
+
Minor refactor of internal helper.
|
|
10
|
+
|
|
11
|
+
## 1.3.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#128458](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128458)
|
|
16
|
+
[`71c5224450c8a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/71c5224450c8a) -
|
|
17
|
+
Adding workaround for a [bug in Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1912164).
|
|
18
|
+
The external adpater optional URL utilities `containsURLs` and `getURLs` will now correctly
|
|
19
|
+
recognize URLs dragged from the Firefox address bar or bookmarks in to a Firefox `window`.
|
|
20
|
+
|
|
3
21
|
## 1.2.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -82,6 +82,40 @@ var adapter = (0, _makeAdapter.makeAdapter)({
|
|
|
82
82
|
if (!entry) {
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A text selection drag _can_ have the `draggable` element be
|
|
88
|
+
* the `event.target` if the user is dragging the text selection
|
|
89
|
+
* from the `draggable`.
|
|
90
|
+
*
|
|
91
|
+
* To know if the `draggable` is being dragged, we look at whether any
|
|
92
|
+
* `"text/plain"` data is being dragged. If it is, then a text selection
|
|
93
|
+
* drag is occurring.
|
|
94
|
+
*
|
|
95
|
+
* This behaviour has been validated on:
|
|
96
|
+
*
|
|
97
|
+
* - Chrome@128 on Android@14
|
|
98
|
+
* - Chrome@128 on iOS@17.6.1
|
|
99
|
+
* - Chrome@128 on Windows@11
|
|
100
|
+
* - Chrome@128 on MacOS@14.6.1
|
|
101
|
+
* - Firefox@129 on Windows@11 (not possible for user to select text in a draggable)
|
|
102
|
+
* - Firefox@129 on MacOS@14.6.1 (not possible for user to select text in a draggable)
|
|
103
|
+
*
|
|
104
|
+
* Note: Could usually just use: `event.dataTransfer.types.includes(textMediaType)`
|
|
105
|
+
* but unfortunately ProseMirror is always setting `""` as the dragged text
|
|
106
|
+
*
|
|
107
|
+
* Note: Unfortunately editor is (heavily) leaning on the current functionality today
|
|
108
|
+
* and unwinding it will be a decent amount of effort. So for now, a text selection
|
|
109
|
+
* where the `event.target` is a `draggable` element will still trigger the
|
|
110
|
+
* element adapter.
|
|
111
|
+
*
|
|
112
|
+
* // Future state:
|
|
113
|
+
* if(event.dataTransfer.getData(textMediaType)) {
|
|
114
|
+
* return;
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
118
|
+
|
|
85
119
|
var input = (0, _getInput.getInput)(event);
|
|
86
120
|
var feedback = {
|
|
87
121
|
element: entry.element,
|
|
@@ -153,8 +187,7 @@ var adapter = (0, _makeAdapter.makeAdapter)({
|
|
|
153
187
|
* Android version: 14 (November 5, 2023)
|
|
154
188
|
* Chrome version: 120.0
|
|
155
189
|
*/
|
|
156
|
-
|
|
157
|
-
if ((0, _android.isAndroid)() && !types.includes(_textMediaType.textMediaType) && !types.includes(_urlMediaType.urlMediaType)) {
|
|
190
|
+
if ((0, _android.isAndroid)() && !event.dataTransfer.types.includes(_textMediaType.textMediaType) && !event.dataTransfer.types.includes(_urlMediaType.URLMediaType)) {
|
|
158
191
|
event.dataTransfer.setData(_textMediaType.textMediaType, _android.androidFallbackText);
|
|
159
192
|
}
|
|
160
193
|
|
|
@@ -41,7 +41,7 @@ function findTextNode(event) {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// Unlikely that this particular drag is a text selection drag
|
|
45
45
|
if (event.target.draggable) {
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
@@ -52,7 +52,10 @@ function findTextNode(event) {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Grab the first Text node and use that.
|
|
57
|
+
* Only doing a single level search as that is all we need for this bug.
|
|
58
|
+
*/
|
|
56
59
|
var text = Array.from(event.target.childNodes).find(function (node) {
|
|
57
60
|
return node.nodeType === Node.TEXT_NODE;
|
|
58
61
|
});
|
|
@@ -97,7 +100,14 @@ var adapter = (0, _makeAdapter.makeAdapter)({
|
|
|
97
100
|
if (!api.canStart(event)) {
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
103
|
+
|
|
104
|
+
// no text being dragged
|
|
105
|
+
if (!event.dataTransfer.types.includes(_textMediaType.textMediaType)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
100
108
|
var target = findTextNode(event);
|
|
109
|
+
|
|
110
|
+
// could not find `Text` node that is being dragged from
|
|
101
111
|
if (!target) {
|
|
102
112
|
return;
|
|
103
113
|
}
|
|
@@ -106,7 +116,6 @@ var adapter = (0, _makeAdapter.makeAdapter)({
|
|
|
106
116
|
// that the user started the drag from.
|
|
107
117
|
// The full text being dragged can be looked up from the `dataTransfer`.
|
|
108
118
|
target: target,
|
|
109
|
-
// This is safe to do in "dragstart" as the `dataTransfer` is in read/write mode.
|
|
110
119
|
plain: event.dataTransfer.getData(_textMediaType.textMediaType),
|
|
111
120
|
HTML: event.dataTransfer.getData(_htmlMediaType.HTMLMediaType)
|
|
112
121
|
};
|
|
@@ -11,9 +11,9 @@ var _combine = require("../public-utils/combine");
|
|
|
11
11
|
var _addAttribute = require("../util/add-attribute");
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
function _createForOfIteratorHelper(
|
|
15
|
-
function _unsupportedIterableToArray(
|
|
16
|
-
function _arrayLikeToArray(
|
|
14
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
17
|
function copyReverse(array) {
|
|
18
18
|
return array.slice(0).reverse();
|
|
19
19
|
}
|
|
@@ -137,14 +137,14 @@ function makeDropTarget(_ref) {
|
|
|
137
137
|
var _entry$eventName;
|
|
138
138
|
var record = _step.value;
|
|
139
139
|
var entry = registry.get(record.element);
|
|
140
|
-
var
|
|
140
|
+
var args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
141
141
|
self: record
|
|
142
142
|
});
|
|
143
143
|
entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(entry,
|
|
144
144
|
// I cannot seem to get the types right here.
|
|
145
145
|
// TS doesn't seem to like that one event can need `nativeSetDragImage`
|
|
146
146
|
// @ts-expect-error
|
|
147
|
-
|
|
147
|
+
args);
|
|
148
148
|
}
|
|
149
149
|
} catch (err) {
|
|
150
150
|
_iterator.e(err);
|
|
@@ -172,15 +172,15 @@ function makeDropTarget(_ref) {
|
|
|
172
172
|
visited.add(record.element);
|
|
173
173
|
var entry = registry.get(record.element);
|
|
174
174
|
var isOver = isCurrent.has(record.element);
|
|
175
|
-
var
|
|
175
|
+
var args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
176
176
|
self: record
|
|
177
177
|
});
|
|
178
|
-
entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry,
|
|
178
|
+
entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, args);
|
|
179
179
|
|
|
180
180
|
// if we cannot find the drop target in the current array, then it has been left
|
|
181
181
|
if (!isOver) {
|
|
182
182
|
var _entry$onDragLeave;
|
|
183
|
-
entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry,
|
|
183
|
+
entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, args);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
} catch (err) {
|
|
@@ -199,12 +199,12 @@ function makeDropTarget(_ref) {
|
|
|
199
199
|
continue;
|
|
200
200
|
}
|
|
201
201
|
// at this point we have a new drop target that is being entered into
|
|
202
|
-
var
|
|
202
|
+
var _args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
203
203
|
self: _record
|
|
204
204
|
});
|
|
205
205
|
var _entry = registry.get(_record.element);
|
|
206
|
-
_entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry,
|
|
207
|
-
_entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry,
|
|
206
|
+
_entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args);
|
|
207
|
+
_entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args);
|
|
208
208
|
}
|
|
209
209
|
} catch (err) {
|
|
210
210
|
_iterator3.e(err);
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.makeMonitor = makeMonitor;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
function _createForOfIteratorHelper(
|
|
10
|
-
function _unsupportedIterableToArray(
|
|
11
|
-
function _arrayLikeToArray(
|
|
9
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
function makeMonitor() {
|
|
@@ -6,28 +6,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.containsURLs = containsURLs;
|
|
7
7
|
exports.getURLs = getURLs;
|
|
8
8
|
var _urlMediaType = require("../../util/media-types/url-media-type");
|
|
9
|
+
/**
|
|
10
|
+
* 🦊🐞
|
|
11
|
+
* When dragging a URL from the Firefox address bar or bookmarks
|
|
12
|
+
* they are currently not adding an entry for "text/uri-list".
|
|
13
|
+
* They add "text/x-moz-url" data which contains the same information
|
|
14
|
+
* in a different format.
|
|
15
|
+
*
|
|
16
|
+
* [Bug report](https://bugzilla.mozilla.org/show_bug.cgi?id=1912164)
|
|
17
|
+
*/
|
|
18
|
+
var firefoxURLType = 'text/x-moz-url';
|
|
9
19
|
function containsURLs(_ref) {
|
|
10
20
|
var source = _ref.source;
|
|
11
|
-
return source.types.includes(_urlMediaType.
|
|
21
|
+
return source.types.includes(_urlMediaType.URLMediaType) || source.types.includes(firefoxURLType);
|
|
12
22
|
}
|
|
13
23
|
function getURLs(_ref2) {
|
|
14
24
|
var source = _ref2.source;
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
var standard = source.getStringData(_urlMediaType.URLMediaType);
|
|
26
|
+
if (standard != null) {
|
|
27
|
+
return standard
|
|
28
|
+
// You can have multiple urls split by CR+LF (EOL)
|
|
29
|
+
// - CR: Carriage Return '\r'
|
|
30
|
+
// - LF: Line Feed '\n'
|
|
31
|
+
// - EOL: End of Line '\r\n'
|
|
32
|
+
.split('\r\n')
|
|
33
|
+
// a uri-list can have comment lines starting with '#'
|
|
34
|
+
// so we need to remove those
|
|
35
|
+
.filter(function (piece) {
|
|
36
|
+
return !piece.startsWith('#');
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var fallback = source.getStringData(firefoxURLType);
|
|
40
|
+
if (fallback != null) {
|
|
41
|
+
return fallback
|
|
42
|
+
// Values are split by a single LF: Line Feed (`\n`) character.
|
|
43
|
+
// It's not clear from the "text/x-moz-url" documentation that
|
|
44
|
+
// it's use `\n` and not `\r\n`, but based on testing and some
|
|
45
|
+
// Github code searches it seems like `\n` is correct.
|
|
46
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#dragging_links
|
|
47
|
+
.split('\n')
|
|
48
|
+
// Every second line is the title of the url previous url.
|
|
49
|
+
// We are ignoring the page titles in this helper
|
|
50
|
+
.filter(function (_, index) {
|
|
51
|
+
return index % 2 === 0;
|
|
52
|
+
});
|
|
20
53
|
}
|
|
21
|
-
|
|
22
|
-
// You can have multiple urls split by CR+LF (EOL)
|
|
23
|
-
// - CR: Carriage Return '\r'
|
|
24
|
-
// - LF: Line Feed '\n'
|
|
25
|
-
// - EOL: End of Line '\r\n'
|
|
26
|
-
.split('\r\n')
|
|
27
|
-
// a uri-list can have comment lines starting with '#'
|
|
28
|
-
// so we need to remove those
|
|
29
|
-
.filter(function (piece) {
|
|
30
|
-
return !piece.startsWith('#');
|
|
31
|
-
});
|
|
32
|
-
return urls;
|
|
54
|
+
return [];
|
|
33
55
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.URLMediaType = void 0;
|
|
7
7
|
// Why we put the media types in their own files:
|
|
8
8
|
//
|
|
9
9
|
// - we are not putting them all in one file as not all adapters need all types
|
|
10
10
|
// - we are not putting them in the external helpers as some things just need the
|
|
11
11
|
// types and not the external functions code
|
|
12
|
-
var
|
|
12
|
+
var URLMediaType = exports.URLMediaType = 'text/uri-list';
|
|
@@ -7,7 +7,7 @@ import { addAttribute } from '../util/add-attribute';
|
|
|
7
7
|
import { androidFallbackText, isAndroid } from '../util/android';
|
|
8
8
|
import { getInput } from '../util/get-input';
|
|
9
9
|
import { textMediaType } from '../util/media-types/text-media-type';
|
|
10
|
-
import {
|
|
10
|
+
import { URLMediaType } from '../util/media-types/url-media-type';
|
|
11
11
|
import { elementAdapterNativeDataKey } from './element-adapter-native-data-key';
|
|
12
12
|
const draggableRegistry = new WeakMap();
|
|
13
13
|
function addToRegistry(args) {
|
|
@@ -81,6 +81,40 @@ const adapter = makeAdapter({
|
|
|
81
81
|
if (!entry) {
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A text selection drag _can_ have the `draggable` element be
|
|
87
|
+
* the `event.target` if the user is dragging the text selection
|
|
88
|
+
* from the `draggable`.
|
|
89
|
+
*
|
|
90
|
+
* To know if the `draggable` is being dragged, we look at whether any
|
|
91
|
+
* `"text/plain"` data is being dragged. If it is, then a text selection
|
|
92
|
+
* drag is occurring.
|
|
93
|
+
*
|
|
94
|
+
* This behaviour has been validated on:
|
|
95
|
+
*
|
|
96
|
+
* - Chrome@128 on Android@14
|
|
97
|
+
* - Chrome@128 on iOS@17.6.1
|
|
98
|
+
* - Chrome@128 on Windows@11
|
|
99
|
+
* - Chrome@128 on MacOS@14.6.1
|
|
100
|
+
* - Firefox@129 on Windows@11 (not possible for user to select text in a draggable)
|
|
101
|
+
* - Firefox@129 on MacOS@14.6.1 (not possible for user to select text in a draggable)
|
|
102
|
+
*
|
|
103
|
+
* Note: Could usually just use: `event.dataTransfer.types.includes(textMediaType)`
|
|
104
|
+
* but unfortunately ProseMirror is always setting `""` as the dragged text
|
|
105
|
+
*
|
|
106
|
+
* Note: Unfortunately editor is (heavily) leaning on the current functionality today
|
|
107
|
+
* and unwinding it will be a decent amount of effort. So for now, a text selection
|
|
108
|
+
* where the `event.target` is a `draggable` element will still trigger the
|
|
109
|
+
* element adapter.
|
|
110
|
+
*
|
|
111
|
+
* // Future state:
|
|
112
|
+
* if(event.dataTransfer.getData(textMediaType)) {
|
|
113
|
+
* return;
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
|
|
84
118
|
const input = getInput(event);
|
|
85
119
|
const feedback = {
|
|
86
120
|
element: entry.element,
|
|
@@ -149,10 +183,7 @@ const adapter = makeAdapter({
|
|
|
149
183
|
* Android version: 14 (November 5, 2023)
|
|
150
184
|
* Chrome version: 120.0
|
|
151
185
|
*/
|
|
152
|
-
|
|
153
|
-
types
|
|
154
|
-
} = event.dataTransfer;
|
|
155
|
-
if (isAndroid() && !types.includes(textMediaType) && !types.includes(urlMediaType)) {
|
|
186
|
+
if (isAndroid() && !event.dataTransfer.types.includes(textMediaType) && !event.dataTransfer.types.includes(URLMediaType)) {
|
|
156
187
|
event.dataTransfer.setData(textMediaType, androidFallbackText);
|
|
157
188
|
}
|
|
158
189
|
|
|
@@ -34,7 +34,7 @@ function findTextNode(event) {
|
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// Unlikely that this particular drag is a text selection drag
|
|
38
38
|
if (event.target.draggable) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
@@ -45,7 +45,10 @@ function findTextNode(event) {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Grab the first Text node and use that.
|
|
50
|
+
* Only doing a single level search as that is all we need for this bug.
|
|
51
|
+
*/
|
|
49
52
|
const text = Array.from(event.target.childNodes).find(node => node.nodeType === Node.TEXT_NODE);
|
|
50
53
|
return text !== null && text !== void 0 ? text : null;
|
|
51
54
|
}
|
|
@@ -96,7 +99,14 @@ const adapter = makeAdapter({
|
|
|
96
99
|
if (!api.canStart(event)) {
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
102
|
+
|
|
103
|
+
// no text being dragged
|
|
104
|
+
if (!event.dataTransfer.types.includes(textMediaType)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
99
107
|
const target = findTextNode(event);
|
|
108
|
+
|
|
109
|
+
// could not find `Text` node that is being dragged from
|
|
100
110
|
if (!target) {
|
|
101
111
|
return;
|
|
102
112
|
}
|
|
@@ -105,7 +115,6 @@ const adapter = makeAdapter({
|
|
|
105
115
|
// that the user started the drag from.
|
|
106
116
|
// The full text being dragged can be looked up from the `dataTransfer`.
|
|
107
117
|
target,
|
|
108
|
-
// This is safe to do in "dragstart" as the `dataTransfer` is in read/write mode.
|
|
109
118
|
plain: event.dataTransfer.getData(textMediaType),
|
|
110
119
|
HTML: event.dataTransfer.getData(HTMLMediaType)
|
|
111
120
|
};
|
|
@@ -1,26 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URLMediaType } from '../../util/media-types/url-media-type';
|
|
2
|
+
/**
|
|
3
|
+
* 🦊🐞
|
|
4
|
+
* When dragging a URL from the Firefox address bar or bookmarks
|
|
5
|
+
* they are currently not adding an entry for "text/uri-list".
|
|
6
|
+
* They add "text/x-moz-url" data which contains the same information
|
|
7
|
+
* in a different format.
|
|
8
|
+
*
|
|
9
|
+
* [Bug report](https://bugzilla.mozilla.org/show_bug.cgi?id=1912164)
|
|
10
|
+
*/
|
|
11
|
+
const firefoxURLType = 'text/x-moz-url';
|
|
2
12
|
export function containsURLs({
|
|
3
13
|
source
|
|
4
14
|
}) {
|
|
5
|
-
return source.types.includes(
|
|
15
|
+
return source.types.includes(URLMediaType) || source.types.includes(firefoxURLType);
|
|
6
16
|
}
|
|
7
17
|
export function getURLs({
|
|
8
18
|
source
|
|
9
19
|
}) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
const standard = source.getStringData(URLMediaType);
|
|
21
|
+
if (standard != null) {
|
|
22
|
+
return standard
|
|
23
|
+
// You can have multiple urls split by CR+LF (EOL)
|
|
24
|
+
// - CR: Carriage Return '\r'
|
|
25
|
+
// - LF: Line Feed '\n'
|
|
26
|
+
// - EOL: End of Line '\r\n'
|
|
27
|
+
.split('\r\n')
|
|
28
|
+
// a uri-list can have comment lines starting with '#'
|
|
29
|
+
// so we need to remove those
|
|
30
|
+
.filter(piece => !piece.startsWith('#'));
|
|
15
31
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
const fallback = source.getStringData(firefoxURLType);
|
|
33
|
+
if (fallback != null) {
|
|
34
|
+
return fallback
|
|
35
|
+
// Values are split by a single LF: Line Feed (`\n`) character.
|
|
36
|
+
// It's not clear from the "text/x-moz-url" documentation that
|
|
37
|
+
// it's use `\n` and not `\r\n`, but based on testing and some
|
|
38
|
+
// Github code searches it seems like `\n` is correct.
|
|
39
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#dragging_links
|
|
40
|
+
.split('\n')
|
|
41
|
+
// Every second line is the title of the url previous url.
|
|
42
|
+
// We are ignoring the page titles in this helper
|
|
43
|
+
.filter((_, index) => index % 2 === 0);
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
26
46
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// - we are not putting them all in one file as not all adapters need all types
|
|
4
4
|
// - we are not putting them in the external helpers as some things just need the
|
|
5
5
|
// types and not the external functions code
|
|
6
|
-
export const
|
|
6
|
+
export const URLMediaType = 'text/uri-list';
|
|
@@ -8,7 +8,7 @@ import { addAttribute } from '../util/add-attribute';
|
|
|
8
8
|
import { androidFallbackText, isAndroid } from '../util/android';
|
|
9
9
|
import { getInput } from '../util/get-input';
|
|
10
10
|
import { textMediaType } from '../util/media-types/text-media-type';
|
|
11
|
-
import {
|
|
11
|
+
import { URLMediaType } from '../util/media-types/url-media-type';
|
|
12
12
|
import { elementAdapterNativeDataKey } from './element-adapter-native-data-key';
|
|
13
13
|
var draggableRegistry = new WeakMap();
|
|
14
14
|
function addToRegistry(args) {
|
|
@@ -74,6 +74,40 @@ var adapter = makeAdapter({
|
|
|
74
74
|
if (!entry) {
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A text selection drag _can_ have the `draggable` element be
|
|
80
|
+
* the `event.target` if the user is dragging the text selection
|
|
81
|
+
* from the `draggable`.
|
|
82
|
+
*
|
|
83
|
+
* To know if the `draggable` is being dragged, we look at whether any
|
|
84
|
+
* `"text/plain"` data is being dragged. If it is, then a text selection
|
|
85
|
+
* drag is occurring.
|
|
86
|
+
*
|
|
87
|
+
* This behaviour has been validated on:
|
|
88
|
+
*
|
|
89
|
+
* - Chrome@128 on Android@14
|
|
90
|
+
* - Chrome@128 on iOS@17.6.1
|
|
91
|
+
* - Chrome@128 on Windows@11
|
|
92
|
+
* - Chrome@128 on MacOS@14.6.1
|
|
93
|
+
* - Firefox@129 on Windows@11 (not possible for user to select text in a draggable)
|
|
94
|
+
* - Firefox@129 on MacOS@14.6.1 (not possible for user to select text in a draggable)
|
|
95
|
+
*
|
|
96
|
+
* Note: Could usually just use: `event.dataTransfer.types.includes(textMediaType)`
|
|
97
|
+
* but unfortunately ProseMirror is always setting `""` as the dragged text
|
|
98
|
+
*
|
|
99
|
+
* Note: Unfortunately editor is (heavily) leaning on the current functionality today
|
|
100
|
+
* and unwinding it will be a decent amount of effort. So for now, a text selection
|
|
101
|
+
* where the `event.target` is a `draggable` element will still trigger the
|
|
102
|
+
* element adapter.
|
|
103
|
+
*
|
|
104
|
+
* // Future state:
|
|
105
|
+
* if(event.dataTransfer.getData(textMediaType)) {
|
|
106
|
+
* return;
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
|
|
77
111
|
var input = getInput(event);
|
|
78
112
|
var feedback = {
|
|
79
113
|
element: entry.element,
|
|
@@ -145,8 +179,7 @@ var adapter = makeAdapter({
|
|
|
145
179
|
* Android version: 14 (November 5, 2023)
|
|
146
180
|
* Chrome version: 120.0
|
|
147
181
|
*/
|
|
148
|
-
|
|
149
|
-
if (isAndroid() && !types.includes(textMediaType) && !types.includes(urlMediaType)) {
|
|
182
|
+
if (isAndroid() && !event.dataTransfer.types.includes(textMediaType) && !event.dataTransfer.types.includes(URLMediaType)) {
|
|
150
183
|
event.dataTransfer.setData(textMediaType, androidFallbackText);
|
|
151
184
|
}
|
|
152
185
|
|
|
@@ -34,7 +34,7 @@ function findTextNode(event) {
|
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// Unlikely that this particular drag is a text selection drag
|
|
38
38
|
if (event.target.draggable) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
@@ -45,7 +45,10 @@ function findTextNode(event) {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Grab the first Text node and use that.
|
|
50
|
+
* Only doing a single level search as that is all we need for this bug.
|
|
51
|
+
*/
|
|
49
52
|
var text = Array.from(event.target.childNodes).find(function (node) {
|
|
50
53
|
return node.nodeType === Node.TEXT_NODE;
|
|
51
54
|
});
|
|
@@ -90,7 +93,14 @@ var adapter = makeAdapter({
|
|
|
90
93
|
if (!api.canStart(event)) {
|
|
91
94
|
return;
|
|
92
95
|
}
|
|
96
|
+
|
|
97
|
+
// no text being dragged
|
|
98
|
+
if (!event.dataTransfer.types.includes(textMediaType)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
93
101
|
var target = findTextNode(event);
|
|
102
|
+
|
|
103
|
+
// could not find `Text` node that is being dragged from
|
|
94
104
|
if (!target) {
|
|
95
105
|
return;
|
|
96
106
|
}
|
|
@@ -99,7 +109,6 @@ var adapter = makeAdapter({
|
|
|
99
109
|
// that the user started the drag from.
|
|
100
110
|
// The full text being dragged can be looked up from the `dataTransfer`.
|
|
101
111
|
target: target,
|
|
102
|
-
// This is safe to do in "dragstart" as the `dataTransfer` is in read/write mode.
|
|
103
112
|
plain: event.dataTransfer.getData(textMediaType),
|
|
104
113
|
HTML: event.dataTransfer.getData(HTMLMediaType)
|
|
105
114
|
};
|
|
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _createForOfIteratorHelper(
|
|
6
|
-
function _unsupportedIterableToArray(
|
|
7
|
-
function _arrayLikeToArray(
|
|
5
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
8
|
import { combine } from '../public-utils/combine';
|
|
9
9
|
import { addAttribute } from '../util/add-attribute';
|
|
10
10
|
function copyReverse(array) {
|
|
@@ -130,14 +130,14 @@ export function makeDropTarget(_ref) {
|
|
|
130
130
|
var _entry$eventName;
|
|
131
131
|
var record = _step.value;
|
|
132
132
|
var entry = registry.get(record.element);
|
|
133
|
-
var
|
|
133
|
+
var args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
134
134
|
self: record
|
|
135
135
|
});
|
|
136
136
|
entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(entry,
|
|
137
137
|
// I cannot seem to get the types right here.
|
|
138
138
|
// TS doesn't seem to like that one event can need `nativeSetDragImage`
|
|
139
139
|
// @ts-expect-error
|
|
140
|
-
|
|
140
|
+
args);
|
|
141
141
|
}
|
|
142
142
|
} catch (err) {
|
|
143
143
|
_iterator.e(err);
|
|
@@ -165,15 +165,15 @@ export function makeDropTarget(_ref) {
|
|
|
165
165
|
visited.add(record.element);
|
|
166
166
|
var entry = registry.get(record.element);
|
|
167
167
|
var isOver = isCurrent.has(record.element);
|
|
168
|
-
var
|
|
168
|
+
var args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
169
169
|
self: record
|
|
170
170
|
});
|
|
171
|
-
entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry,
|
|
171
|
+
entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, args);
|
|
172
172
|
|
|
173
173
|
// if we cannot find the drop target in the current array, then it has been left
|
|
174
174
|
if (!isOver) {
|
|
175
175
|
var _entry$onDragLeave;
|
|
176
|
-
entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry,
|
|
176
|
+
entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, args);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
} catch (err) {
|
|
@@ -192,12 +192,12 @@ export function makeDropTarget(_ref) {
|
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
// at this point we have a new drop target that is being entered into
|
|
195
|
-
var
|
|
195
|
+
var _args = _objectSpread(_objectSpread({}, payload), {}, {
|
|
196
196
|
self: _record
|
|
197
197
|
});
|
|
198
198
|
var _entry = registry.get(_record.element);
|
|
199
|
-
_entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry,
|
|
200
|
-
_entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry,
|
|
199
|
+
_entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args);
|
|
200
|
+
_entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args);
|
|
201
201
|
}
|
|
202
202
|
} catch (err) {
|
|
203
203
|
_iterator3.e(err);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function _createForOfIteratorHelper(
|
|
3
|
-
function _unsupportedIterableToArray(
|
|
4
|
-
function _arrayLikeToArray(
|
|
2
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
export function makeMonitor() {
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URLMediaType } from '../../util/media-types/url-media-type';
|
|
2
|
+
/**
|
|
3
|
+
* 🦊🐞
|
|
4
|
+
* When dragging a URL from the Firefox address bar or bookmarks
|
|
5
|
+
* they are currently not adding an entry for "text/uri-list".
|
|
6
|
+
* They add "text/x-moz-url" data which contains the same information
|
|
7
|
+
* in a different format.
|
|
8
|
+
*
|
|
9
|
+
* [Bug report](https://bugzilla.mozilla.org/show_bug.cgi?id=1912164)
|
|
10
|
+
*/
|
|
11
|
+
var firefoxURLType = 'text/x-moz-url';
|
|
2
12
|
export function containsURLs(_ref) {
|
|
3
13
|
var source = _ref.source;
|
|
4
|
-
return source.types.includes(
|
|
14
|
+
return source.types.includes(URLMediaType) || source.types.includes(firefoxURLType);
|
|
5
15
|
}
|
|
6
16
|
export function getURLs(_ref2) {
|
|
7
17
|
var source = _ref2.source;
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
var standard = source.getStringData(URLMediaType);
|
|
19
|
+
if (standard != null) {
|
|
20
|
+
return standard
|
|
21
|
+
// You can have multiple urls split by CR+LF (EOL)
|
|
22
|
+
// - CR: Carriage Return '\r'
|
|
23
|
+
// - LF: Line Feed '\n'
|
|
24
|
+
// - EOL: End of Line '\r\n'
|
|
25
|
+
.split('\r\n')
|
|
26
|
+
// a uri-list can have comment lines starting with '#'
|
|
27
|
+
// so we need to remove those
|
|
28
|
+
.filter(function (piece) {
|
|
29
|
+
return !piece.startsWith('#');
|
|
30
|
+
});
|
|
13
31
|
}
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
var fallback = source.getStringData(firefoxURLType);
|
|
33
|
+
if (fallback != null) {
|
|
34
|
+
return fallback
|
|
35
|
+
// Values are split by a single LF: Line Feed (`\n`) character.
|
|
36
|
+
// It's not clear from the "text/x-moz-url" documentation that
|
|
37
|
+
// it's use `\n` and not `\r\n`, but based on testing and some
|
|
38
|
+
// Github code searches it seems like `\n` is correct.
|
|
39
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#dragging_links
|
|
40
|
+
.split('\n')
|
|
41
|
+
// Every second line is the title of the url previous url.
|
|
42
|
+
// We are ignoring the page titles in this helper
|
|
43
|
+
.filter(function (_, index) {
|
|
44
|
+
return index % 2 === 0;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
26
48
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// - we are not putting them all in one file as not all adapters need all types
|
|
4
4
|
// - we are not putting them in the external helpers as some things just need the
|
|
5
5
|
// types and not the external functions code
|
|
6
|
-
export var
|
|
6
|
+
export var URLMediaType = 'text/uri-list';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const URLMediaType = "text/uri-list";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const URLMediaType = "text/uri-list";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/pragmatic-drag-and-drop",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "The core package for Pragmatic drag and drop - enabling fast drag and drop for any experience on any tech stack",
|
|
5
5
|
"repository": "https://github.com/atlassian/pragmatic-drag-and-drop",
|
|
6
6
|
"author": "Atlassian Pty Ltd",
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
"atlaskit:src": "src/index.ts",
|
|
25
25
|
"atlassian": {
|
|
26
26
|
"team": "Design System Team",
|
|
27
|
-
"inPublicMirror": true,
|
|
28
|
-
"releaseModel": "continuous",
|
|
29
27
|
"website": {
|
|
30
28
|
"name": "Core",
|
|
31
29
|
"category": "Libraries"
|
|
@@ -72,6 +70,7 @@
|
|
|
72
70
|
"@atlaskit/visual-regression": "*",
|
|
73
71
|
"@emotion/react": "^11.7.1",
|
|
74
72
|
"@testing-library/dom": "^10.1.0",
|
|
73
|
+
"@testing-library/react": "^12.1.5",
|
|
75
74
|
"@types/raf-schd": "^4.0.1",
|
|
76
75
|
"globby": "^6.1.0",
|
|
77
76
|
"react": "^16.8.0",
|