@atlaskit/editor-plugin-block-controls 2.1.6 → 2.1.8

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,23 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#147103](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147103)
8
+ [`c550545f3551e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c550545f3551e) -
9
+ ED-24305 Try to fix type error from getPos in drag handle
10
+ - Updated dependencies
11
+
12
+ ## 2.1.7
13
+
14
+ ### Patch Changes
15
+
16
+ - [#147259](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147259)
17
+ [`887b742b313c6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/887b742b313c6) -
18
+ Experiment flag update
19
+ - Updated dependencies
20
+
3
21
  ## 2.1.6
4
22
 
5
23
  ### Patch Changes
@@ -32,9 +32,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
32
32
  if (rootElement) {
33
33
  var _rootElement$parentEl;
34
34
  // We want to exlude handles from showing for empty paragraph and heading nodes
35
- if ((0, _experiments.editorExperiment)('nested-dnd', true, {
36
- exposure: true
37
- }) && isEmptyNestedParagraphOrHeading(rootElement)) {
35
+ if ((0, _experiments.editorExperiment)('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
38
36
  return false;
39
37
  }
40
38
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
@@ -59,9 +57,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
59
57
  }
60
58
  var parentRootElement = rootElement.parentElement;
61
59
  var pos;
62
- if (parentRootElement && (0, _experiments.editorExperiment)('nested-dnd', true, {
63
- exposure: true
64
- })) {
60
+ if (parentRootElement && (0, _experiments.editorExperiment)('nested-dnd', true)) {
65
61
  var _parentRootElement$ch;
66
62
  var childNodes = Array.from(parentRootElement.childNodes);
67
63
  var index = childNodes.indexOf(rootElement);
@@ -76,9 +72,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
76
72
  pos = view.posAtDOM(rootElement, 0);
77
73
  }
78
74
  var rootPos;
79
- if ((0, _experiments.editorExperiment)('nested-dnd', true, {
80
- exposure: true
81
- })) {
75
+ if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
82
76
  rootPos = view.state.doc.resolve(pos).pos;
83
77
  } else {
84
78
  rootPos = view.state.doc.resolve(pos).start(1) - 1;
@@ -295,6 +295,9 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
295
295
  positionStyles = _useState6[0],
296
296
  setPositionStyles = _useState6[1];
297
297
  (0, _react.useEffect)(function () {
298
+ if ((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_type_error_fix')) {
299
+ return;
300
+ }
298
301
  var cleanUpTransitionListener;
299
302
  if (nodeType === 'extension' || nodeType === 'embedCard') {
300
303
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
@@ -317,6 +320,32 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
317
320
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
318
321
  };
319
322
  }, [calculatePosition, view.dom, anchorName, nodeType]);
323
+ (0, _react.useLayoutEffect)(function () {
324
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_type_error_fix')) {
325
+ return;
326
+ }
327
+ var cleanUpTransitionListener;
328
+ if (nodeType === 'extension' || nodeType === 'embedCard') {
329
+ var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
330
+ if (!dom) {
331
+ return;
332
+ }
333
+ cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
334
+ type: 'transitionend',
335
+ listener: function listener() {
336
+ setPositionStyles(calculatePosition());
337
+ }
338
+ });
339
+ }
340
+ var calcPos = requestAnimationFrame(function () {
341
+ setPositionStyles(calculatePosition());
342
+ });
343
+ return function () {
344
+ var _cleanUpTransitionLis2;
345
+ cancelAnimationFrame(calcPos);
346
+ (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
347
+ };
348
+ }, [calculatePosition, view.dom, anchorName, nodeType]);
320
349
  (0, _react.useEffect)(function () {
321
350
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
322
351
  var id = requestAnimationFrame(function () {
@@ -27,9 +27,7 @@ export const handleMouseOver = (view, event, api) => {
27
27
  if (rootElement) {
28
28
  var _rootElement$parentEl;
29
29
  // We want to exlude handles from showing for empty paragraph and heading nodes
30
- if (editorExperiment('nested-dnd', true, {
31
- exposure: true
32
- }) && isEmptyNestedParagraphOrHeading(rootElement)) {
30
+ if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
33
31
  return false;
34
32
  }
35
33
  const parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
@@ -54,9 +52,7 @@ export const handleMouseOver = (view, event, api) => {
54
52
  }
55
53
  const parentRootElement = rootElement.parentElement;
56
54
  let pos;
57
- if (parentRootElement && editorExperiment('nested-dnd', true, {
58
- exposure: true
59
- })) {
55
+ if (parentRootElement && editorExperiment('nested-dnd', true)) {
60
56
  var _parentRootElement$ch;
61
57
  const childNodes = Array.from(parentRootElement.childNodes);
62
58
  const index = childNodes.indexOf(rootElement);
@@ -71,9 +67,7 @@ export const handleMouseOver = (view, event, api) => {
71
67
  pos = view.posAtDOM(rootElement, 0);
72
68
  }
73
69
  let rootPos;
74
- if (editorExperiment('nested-dnd', true, {
75
- exposure: true
76
- })) {
70
+ if (editorExperiment('nested-dnd', true)) {
77
71
  rootPos = view.state.doc.resolve(pos).pos;
78
72
  } else {
79
73
  rootPos = view.state.doc.resolve(pos).start(1) - 1;
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useCallback, useEffect, useRef, useState } from 'react';
5
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
8
  import { bind } from 'bind-event-listener';
@@ -279,6 +279,9 @@ const DragHandleInternal = ({
279
279
  display: 'none'
280
280
  });
281
281
  useEffect(() => {
282
+ if (fg('platform_editor_element_dnd_nested_type_error_fix')) {
283
+ return;
284
+ }
282
285
  let cleanUpTransitionListener;
283
286
  if (nodeType === 'extension' || nodeType === 'embedCard') {
284
287
  const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
@@ -301,6 +304,32 @@ const DragHandleInternal = ({
301
304
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 ? void 0 : _cleanUpTransitionLis();
302
305
  };
303
306
  }, [calculatePosition, view.dom, anchorName, nodeType]);
307
+ useLayoutEffect(() => {
308
+ if (!fg('platform_editor_element_dnd_nested_type_error_fix')) {
309
+ return;
310
+ }
311
+ let cleanUpTransitionListener;
312
+ if (nodeType === 'extension' || nodeType === 'embedCard') {
313
+ const dom = view.dom.querySelector(`[data-drag-handler-anchor-name="${anchorName}"]`);
314
+ if (!dom) {
315
+ return;
316
+ }
317
+ cleanUpTransitionListener = bind(dom, {
318
+ type: 'transitionend',
319
+ listener: () => {
320
+ setPositionStyles(calculatePosition());
321
+ }
322
+ });
323
+ }
324
+ const calcPos = requestAnimationFrame(() => {
325
+ setPositionStyles(calculatePosition());
326
+ });
327
+ return () => {
328
+ var _cleanUpTransitionLis2;
329
+ cancelAnimationFrame(calcPos);
330
+ (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 ? void 0 : _cleanUpTransitionLis2();
331
+ };
332
+ }, [calculatePosition, view.dom, anchorName, nodeType]);
304
333
  useEffect(() => {
305
334
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
306
335
  const id = requestAnimationFrame(() => {
@@ -26,9 +26,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
26
26
  if (rootElement) {
27
27
  var _rootElement$parentEl;
28
28
  // We want to exlude handles from showing for empty paragraph and heading nodes
29
- if (editorExperiment('nested-dnd', true, {
30
- exposure: true
31
- }) && isEmptyNestedParagraphOrHeading(rootElement)) {
29
+ if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
32
30
  return false;
33
31
  }
34
32
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
@@ -53,9 +51,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
53
51
  }
54
52
  var parentRootElement = rootElement.parentElement;
55
53
  var pos;
56
- if (parentRootElement && editorExperiment('nested-dnd', true, {
57
- exposure: true
58
- })) {
54
+ if (parentRootElement && editorExperiment('nested-dnd', true)) {
59
55
  var _parentRootElement$ch;
60
56
  var childNodes = Array.from(parentRootElement.childNodes);
61
57
  var index = childNodes.indexOf(rootElement);
@@ -70,9 +66,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
70
66
  pos = view.posAtDOM(rootElement, 0);
71
67
  }
72
68
  var rootPos;
73
- if (editorExperiment('nested-dnd', true, {
74
- exposure: true
75
- })) {
69
+ if (editorExperiment('nested-dnd', true)) {
76
70
  rootPos = view.state.doc.resolve(pos).pos;
77
71
  } else {
78
72
  rootPos = view.state.doc.resolve(pos).start(1) - 1;
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  * @jsxRuntime classic
4
4
  * @jsx jsx
5
5
  */
6
- import { useCallback, useEffect, useRef, useState } from 'react';
6
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { bind } from 'bind-event-listener';
@@ -286,6 +286,9 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
286
286
  positionStyles = _useState6[0],
287
287
  setPositionStyles = _useState6[1];
288
288
  useEffect(function () {
289
+ if (fg('platform_editor_element_dnd_nested_type_error_fix')) {
290
+ return;
291
+ }
289
292
  var cleanUpTransitionListener;
290
293
  if (nodeType === 'extension' || nodeType === 'embedCard') {
291
294
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
@@ -308,6 +311,32 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
308
311
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
309
312
  };
310
313
  }, [calculatePosition, view.dom, anchorName, nodeType]);
314
+ useLayoutEffect(function () {
315
+ if (!fg('platform_editor_element_dnd_nested_type_error_fix')) {
316
+ return;
317
+ }
318
+ var cleanUpTransitionListener;
319
+ if (nodeType === 'extension' || nodeType === 'embedCard') {
320
+ var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
321
+ if (!dom) {
322
+ return;
323
+ }
324
+ cleanUpTransitionListener = bind(dom, {
325
+ type: 'transitionend',
326
+ listener: function listener() {
327
+ setPositionStyles(calculatePosition());
328
+ }
329
+ });
330
+ }
331
+ var calcPos = requestAnimationFrame(function () {
332
+ setPositionStyles(calculatePosition());
333
+ });
334
+ return function () {
335
+ var _cleanUpTransitionLis2;
336
+ cancelAnimationFrame(calcPos);
337
+ (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
338
+ };
339
+ }, [calculatePosition, view.dom, anchorName, nodeType]);
311
340
  useEffect(function () {
312
341
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
313
342
  var id = requestAnimationFrame(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^40.9.0",
34
- "@atlaskit/editor-common": "^91.1.0",
34
+ "@atlaskit/editor-common": "^92.0.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/editor-prosemirror": "6.0.0",
42
42
  "@atlaskit/editor-shared-styles": "^3.0.0",
43
43
  "@atlaskit/editor-tables": "^2.8.0",
44
- "@atlaskit/icon": "^22.18.0",
44
+ "@atlaskit/icon": "^22.20.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.3.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
@@ -141,6 +141,9 @@
141
141
  },
142
142
  "platform_editor_element_dnd_nested_fix_patch_2": {
143
143
  "type": "boolean"
144
+ },
145
+ "platform_editor_element_dnd_nested_type_error_fix": {
146
+ "type": "boolean"
144
147
  }
145
148
  }
146
149
  }