@atlaskit/pragmatic-drag-and-drop 1.3.0 → 1.4.0

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
@@ -1,5 +1,42 @@
1
1
  # @atlaskit/pragmatic-drag-and-drop
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#145232](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/145232)
8
+ [`04641b5e6ed55`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/04641b5e6ed55) -
9
+ Adding new optional utility for element dragging: `blockDraggingToIFrames` which disables the
10
+ ability for a user to drag into an `<iframe>` element.
11
+
12
+ Scenarios where this can be helpful:
13
+
14
+ - When you are shifting the interface around in reponse to a drag operation and you don't want the
15
+ drag to enter into an `<iframe>` (for example - when resizing)
16
+ - When you don't want the user to be able to drag into a `<iframe>` on the page (there could be
17
+ lots of reasons why!)
18
+
19
+ ```ts
20
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
21
+ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
22
+ import { blockDraggingToIFrames } from '@atlaskit/pragmatic-drag-and-drop/element/block-dragging-to-iframes';
23
+
24
+ const cleanup = combine(
25
+ blockDraggingToIFrames({ element }),
26
+ draggable({
27
+ element,
28
+ }),
29
+ );
30
+ ```
31
+
32
+ ## 1.3.1
33
+
34
+ ### Patch Changes
35
+
36
+ - [#141279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141279)
37
+ [`a38f3af4bfc79`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a38f3af4bfc79) -
38
+ Minor refactor of internal helper.
39
+
3
40
  ## 1.3.0
4
41
 
5
42
  ### Minor 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
- var types = event.dataTransfer.types;
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
- // unlikely that this particular drag is a text selection drag
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
- // Grab the first Text node and use that
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
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "blockDraggingToIFrames", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _blockDraggingToIframes.blockDraggingToIFrames;
10
+ }
11
+ });
12
+ var _blockDraggingToIframes = require("../../public-utils/element/block-dragging-to-iframes");
@@ -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(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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 _args = _objectSpread(_objectSpread({}, payload), {}, {
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
- _args);
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 _args2 = _objectSpread(_objectSpread({}, payload), {}, {
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, _args2);
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, _args2);
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 _args3 = _objectSpread(_objectSpread({}, payload), {}, {
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, _args3);
207
- _entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args3);
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(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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() {
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.blockDraggingToIFrames = blockDraggingToIFrames;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _elementAdapter = require("../../adapter/element-adapter");
10
+ var _combine = require("../combine");
11
+ /**
12
+ * Set a `style` property on a `HTMLElement`
13
+ *
14
+ * @returns a `cleanup` function to restore the `style` property to it's original state
15
+ */
16
+ function setStyle(el, _ref) {
17
+ var property = _ref.property,
18
+ rule = _ref.rule,
19
+ _ref$priority = _ref.priority,
20
+ priority = _ref$priority === void 0 ? '' : _ref$priority;
21
+ var originalValue = el.style.getPropertyValue(property);
22
+ var originalPriority = el.style.getPropertyPriority(property);
23
+ el.style.setProperty(property, rule, priority);
24
+ return function cleanup() {
25
+ el.style.setProperty(property, originalValue, originalPriority);
26
+ };
27
+ }
28
+ var isActive = false;
29
+
30
+ /**
31
+ * Start blocking dragging to iframes. Only to be called once a drag has started.
32
+ */
33
+ function tryStart() {
34
+ // There can technically be multiple registrations on the same element.
35
+ // Adding a guard to ensure that only one registration does the blocking.
36
+ if (isActive) {
37
+ return;
38
+ }
39
+ isActive = true;
40
+
41
+ // At this stage, we are also not watching for new iframe elements being added to the page
42
+ // (we _could_ do that as a future change)
43
+ var iframeCleanups = Array.from(document.querySelectorAll('iframe')).map(function (iframe) {
44
+ return setStyle(iframe, {
45
+ property: 'pointer-events',
46
+ rule: 'none',
47
+ priority: 'important'
48
+ });
49
+ });
50
+
51
+ // Not returning the cleanup function.
52
+ // This code will clean itself up when the interaction ends in `onDrop()`.
53
+ // Once a drag has started we are blocking iframes until the interaction is finished.
54
+ var cleanup = _combine.combine.apply(void 0, (0, _toConsumableArray2.default)(iframeCleanups).concat([
55
+ // We only need this monitor for listening to the drop
56
+ // as our monitor in `blockDraggingToIFrames()` will only
57
+ // call this function when the drag has started
58
+ (0, _elementAdapter.monitorForElements)({
59
+ onDrop: function onDrop() {
60
+ cleanup();
61
+ }
62
+ }), function release() {
63
+ isActive = false;
64
+ }]));
65
+ }
66
+
67
+ /**
68
+ * Block dragging of a draggable element to <iframe> elements.
69
+ *
70
+ * @description
71
+ *
72
+ * - This function sets `pointer-events:none !important` to all `<iframe>` elements for the duration of the drag.
73
+ * - Once an `<iframe>` is disabled, it will only be re-enabled once the current drag interaction is completed (and not when the `CleanupFn` is called)
74
+ * - This function currently does not watch for new `<iframe>` elements being adding during a drag operation.
75
+ */
76
+ function blockDraggingToIFrames(_ref2) {
77
+ var element = _ref2.element;
78
+ return (0, _elementAdapter.monitorForElements)({
79
+ onGenerateDragPreview: function onGenerateDragPreview(_ref3) {
80
+ var source = _ref3.source;
81
+ // only starting if we are dragging the provided element
82
+ if (source.element === element) {
83
+ tryStart();
84
+ }
85
+ }
86
+ });
87
+ }
@@ -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
- const {
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
- // unlikely that this particular drag is a text selection drag
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
- // Grab the first Text node and use that
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
  };
@@ -0,0 +1 @@
1
+ export { blockDraggingToIFrames } from '../../public-utils/element/block-dragging-to-iframes';
@@ -0,0 +1,80 @@
1
+ import { monitorForElements } from '../../adapter/element-adapter';
2
+ import { combine } from '../combine';
3
+
4
+ /**
5
+ * Set a `style` property on a `HTMLElement`
6
+ *
7
+ * @returns a `cleanup` function to restore the `style` property to it's original state
8
+ */
9
+ function setStyle(el, {
10
+ property,
11
+ rule,
12
+ priority = ''
13
+ }) {
14
+ const originalValue = el.style.getPropertyValue(property);
15
+ const originalPriority = el.style.getPropertyPriority(property);
16
+ el.style.setProperty(property, rule, priority);
17
+ return function cleanup() {
18
+ el.style.setProperty(property, originalValue, originalPriority);
19
+ };
20
+ }
21
+ let isActive = false;
22
+
23
+ /**
24
+ * Start blocking dragging to iframes. Only to be called once a drag has started.
25
+ */
26
+ function tryStart() {
27
+ // There can technically be multiple registrations on the same element.
28
+ // Adding a guard to ensure that only one registration does the blocking.
29
+ if (isActive) {
30
+ return;
31
+ }
32
+ isActive = true;
33
+
34
+ // At this stage, we are also not watching for new iframe elements being added to the page
35
+ // (we _could_ do that as a future change)
36
+ const iframeCleanups = Array.from(document.querySelectorAll('iframe')).map(iframe => setStyle(iframe, {
37
+ property: 'pointer-events',
38
+ rule: 'none',
39
+ priority: 'important'
40
+ }));
41
+
42
+ // Not returning the cleanup function.
43
+ // This code will clean itself up when the interaction ends in `onDrop()`.
44
+ // Once a drag has started we are blocking iframes until the interaction is finished.
45
+ const cleanup = combine(...iframeCleanups,
46
+ // We only need this monitor for listening to the drop
47
+ // as our monitor in `blockDraggingToIFrames()` will only
48
+ // call this function when the drag has started
49
+ monitorForElements({
50
+ onDrop() {
51
+ cleanup();
52
+ }
53
+ }), function release() {
54
+ isActive = false;
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Block dragging of a draggable element to <iframe> elements.
60
+ *
61
+ * @description
62
+ *
63
+ * - This function sets `pointer-events:none !important` to all `<iframe>` elements for the duration of the drag.
64
+ * - Once an `<iframe>` is disabled, it will only be re-enabled once the current drag interaction is completed (and not when the `CleanupFn` is called)
65
+ * - This function currently does not watch for new `<iframe>` elements being adding during a drag operation.
66
+ */
67
+ export function blockDraggingToIFrames({
68
+ element
69
+ }) {
70
+ return monitorForElements({
71
+ onGenerateDragPreview({
72
+ source
73
+ }) {
74
+ // only starting if we are dragging the provided element
75
+ if (source.element === element) {
76
+ tryStart();
77
+ }
78
+ }
79
+ });
80
+ }
@@ -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
- var types = event.dataTransfer.types;
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
- // unlikely that this particular drag is a text selection drag
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
- // Grab the first Text node and use that
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
  };
@@ -0,0 +1 @@
1
+ export { blockDraggingToIFrames } from '../../public-utils/element/block-dragging-to-iframes';
@@ -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(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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 _args = _objectSpread(_objectSpread({}, payload), {}, {
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
- _args);
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 _args2 = _objectSpread(_objectSpread({}, payload), {}, {
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, _args2);
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, _args2);
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 _args3 = _objectSpread(_objectSpread({}, payload), {}, {
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, _args3);
200
- _entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args3);
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(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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() {
@@ -0,0 +1,81 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { monitorForElements } from '../../adapter/element-adapter';
3
+ import { combine } from '../combine';
4
+
5
+ /**
6
+ * Set a `style` property on a `HTMLElement`
7
+ *
8
+ * @returns a `cleanup` function to restore the `style` property to it's original state
9
+ */
10
+ function setStyle(el, _ref) {
11
+ var property = _ref.property,
12
+ rule = _ref.rule,
13
+ _ref$priority = _ref.priority,
14
+ priority = _ref$priority === void 0 ? '' : _ref$priority;
15
+ var originalValue = el.style.getPropertyValue(property);
16
+ var originalPriority = el.style.getPropertyPriority(property);
17
+ el.style.setProperty(property, rule, priority);
18
+ return function cleanup() {
19
+ el.style.setProperty(property, originalValue, originalPriority);
20
+ };
21
+ }
22
+ var isActive = false;
23
+
24
+ /**
25
+ * Start blocking dragging to iframes. Only to be called once a drag has started.
26
+ */
27
+ function tryStart() {
28
+ // There can technically be multiple registrations on the same element.
29
+ // Adding a guard to ensure that only one registration does the blocking.
30
+ if (isActive) {
31
+ return;
32
+ }
33
+ isActive = true;
34
+
35
+ // At this stage, we are also not watching for new iframe elements being added to the page
36
+ // (we _could_ do that as a future change)
37
+ var iframeCleanups = Array.from(document.querySelectorAll('iframe')).map(function (iframe) {
38
+ return setStyle(iframe, {
39
+ property: 'pointer-events',
40
+ rule: 'none',
41
+ priority: 'important'
42
+ });
43
+ });
44
+
45
+ // Not returning the cleanup function.
46
+ // This code will clean itself up when the interaction ends in `onDrop()`.
47
+ // Once a drag has started we are blocking iframes until the interaction is finished.
48
+ var cleanup = combine.apply(void 0, _toConsumableArray(iframeCleanups).concat([
49
+ // We only need this monitor for listening to the drop
50
+ // as our monitor in `blockDraggingToIFrames()` will only
51
+ // call this function when the drag has started
52
+ monitorForElements({
53
+ onDrop: function onDrop() {
54
+ cleanup();
55
+ }
56
+ }), function release() {
57
+ isActive = false;
58
+ }]));
59
+ }
60
+
61
+ /**
62
+ * Block dragging of a draggable element to <iframe> elements.
63
+ *
64
+ * @description
65
+ *
66
+ * - This function sets `pointer-events:none !important` to all `<iframe>` elements for the duration of the drag.
67
+ * - Once an `<iframe>` is disabled, it will only be re-enabled once the current drag interaction is completed (and not when the `CleanupFn` is called)
68
+ * - This function currently does not watch for new `<iframe>` elements being adding during a drag operation.
69
+ */
70
+ export function blockDraggingToIFrames(_ref2) {
71
+ var element = _ref2.element;
72
+ return monitorForElements({
73
+ onGenerateDragPreview: function onGenerateDragPreview(_ref3) {
74
+ var source = _ref3.source;
75
+ // only starting if we are dragging the provided element
76
+ if (source.element === element) {
77
+ tryStart();
78
+ }
79
+ }
80
+ });
81
+ }
@@ -0,0 +1 @@
1
+ export { blockDraggingToIFrames } from '../../public-utils/element/block-dragging-to-iframes';
@@ -0,0 +1,13 @@
1
+ import { type CleanupFn } from '../../internal-types';
2
+ /**
3
+ * Block dragging of a draggable element to <iframe> elements.
4
+ *
5
+ * @description
6
+ *
7
+ * - This function sets `pointer-events:none !important` to all `<iframe>` elements for the duration of the drag.
8
+ * - Once an `<iframe>` is disabled, it will only be re-enabled once the current drag interaction is completed (and not when the `CleanupFn` is called)
9
+ * - This function currently does not watch for new `<iframe>` elements being adding during a drag operation.
10
+ */
11
+ export declare function blockDraggingToIFrames({ element }: {
12
+ element: HTMLElement;
13
+ }): CleanupFn;
@@ -0,0 +1 @@
1
+ export { blockDraggingToIFrames } from '../../public-utils/element/block-dragging-to-iframes';
@@ -0,0 +1,13 @@
1
+ import { type CleanupFn } from '../../internal-types';
2
+ /**
3
+ * Block dragging of a draggable element to <iframe> elements.
4
+ *
5
+ * @description
6
+ *
7
+ * - This function sets `pointer-events:none !important` to all `<iframe>` elements for the duration of the drag.
8
+ * - Once an `<iframe>` is disabled, it will only be re-enabled once the current drag interaction is completed (and not when the `CleanupFn` is called)
9
+ * - This function currently does not watch for new `<iframe>` elements being adding during a drag operation.
10
+ */
11
+ export declare function blockDraggingToIFrames({ element }: {
12
+ element: HTMLElement;
13
+ }): CleanupFn;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/pragmatic-drag-and-drop/element/block-dragging-to-iframes",
3
+ "main": "../../dist/cjs/entry-point/element/block-dragging-to-iframes.js",
4
+ "module": "../../dist/esm/entry-point/element/block-dragging-to-iframes.js",
5
+ "module:es2019": "../../dist/es2019/entry-point/element/block-dragging-to-iframes.js",
6
+ "sideEffects": true,
7
+ "types": "../../dist/types/entry-point/element/block-dragging-to-iframes.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.4": {
10
+ "*": [
11
+ "../../dist/types-ts4.5/entry-point/element/block-dragging-to-iframes.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/pragmatic-drag-and-drop",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
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"
@@ -48,6 +46,7 @@
48
46
  "./element/disable-native-drag-preview": "./src/entry-point/element/disable-native-drag-preview.ts",
49
47
  "./element/scroll-just-enough-into-view": "./src/entry-point/element/scroll-just-enough-into-view.ts",
50
48
  "./element/format-urls-for-external": "./src/entry-point/element/format-urls-for-external.ts",
49
+ "./element/block-dragging-to-iframes": "./src/entry-point/element/block-dragging-to-iframes.ts",
51
50
  "./external/adapter": "./src/entry-point/external/adapter.ts",
52
51
  "./external/file": "./src/entry-point/external/file.ts",
53
52
  "./external/html": "./src/entry-point/external/html.ts",
@@ -72,6 +71,7 @@
72
71
  "@atlaskit/visual-regression": "*",
73
72
  "@emotion/react": "^11.7.1",
74
73
  "@testing-library/dom": "^10.1.0",
74
+ "@testing-library/react": "^12.1.5",
75
75
  "@types/raf-schd": "^4.0.1",
76
76
  "globby": "^6.1.0",
77
77
  "react": "^16.8.0",