@atlaskit/editor-plugin-block-controls 8.1.7 → 8.2.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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 8.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1be0f3cb5f1fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1be0f3cb5f1fe) -
8
+ EDITOR-5008 fix end pos drop target and styles for synced block
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 8.1.8
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 8.1.7
4
21
 
5
22
  ### Patch Changes
@@ -11,6 +11,7 @@ var _uuid = _interopRequireDefault(require("uuid"));
11
11
  var _selection = require("@atlaskit/editor-common/selection");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _view = require("@atlaskit/editor-prosemirror/view");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
17
  var _consts = require("../ui/consts");
@@ -23,6 +24,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
23
24
  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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
24
25
  var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
25
26
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
27
+ var PARENT_WITH_END_DROP_TARGET_NEXT = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension', 'bodiedSyncBlock'];
26
28
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
27
29
  var shouldDescend = function shouldDescend(node) {
28
30
  return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
@@ -44,16 +46,26 @@ var shouldCollapseMargin = function shouldCollapseMargin(prevNode, nextNode) {
44
46
  return true;
45
47
  };
46
48
  var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
49
+ var isSyncBlockOffsetPatchEnabled = (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2');
47
50
  if (!prevNode && nextNode) {
48
- // first node
51
+ // first node - adjust for bodied containers
52
+ var _offset = 0;
53
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
54
+ _offset += 4;
55
+ }
49
56
  return {
50
57
  gap: 0,
51
- offset: 0
58
+ offset: _offset
52
59
  };
53
60
  } else if (prevNode && !nextNode) {
61
+ // last node - adjust for bodied containers
62
+ var _offset2 = 0;
63
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
64
+ _offset2 -= 4;
65
+ }
54
66
  return {
55
67
  gap: 0,
56
- offset: 0
68
+ offset: _offset2
57
69
  };
58
70
  }
59
71
  var top = getNodeMargins(nextNode).top || 4;
@@ -244,7 +256,8 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
244
256
  return false; //not valid pos, so nested not valid either
245
257
  }
246
258
  }
247
- if (parent.lastChild === node && !(0, _utils.isEmptyParagraph)(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
259
+ var parentTypesWithEndDropTarget = (0, _expValEquals.expValEquals)('platform_synced_block', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_2') ? PARENT_WITH_END_DROP_TARGET_NEXT : PARENT_WITH_END_DROP_TARGET;
260
+ if (parent.lastChild === node && !(0, _utils.isEmptyParagraph)(node) && parentTypesWithEndDropTarget.includes(parent.type.name)) {
248
261
  endPos = pos + node.nodeSize;
249
262
  }
250
263
  var previousNode = popNodeStack(depth); // created scoped variable
@@ -4,6 +4,7 @@ import uuid from 'uuid';
4
4
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
5
5
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
6
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
10
  import { nodeMargins } from '../ui/consts';
@@ -14,6 +15,7 @@ import { maxLayoutColumnSupported } from './utils/consts';
14
15
  import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
15
16
  const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
16
17
  const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
18
+ const PARENT_WITH_END_DROP_TARGET_NEXT = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension', 'bodiedSyncBlock'];
17
19
  const DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
18
20
  const shouldDescend = node => {
19
21
  return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
@@ -35,16 +37,26 @@ const shouldCollapseMargin = (prevNode, nextNode) => {
35
37
  return true;
36
38
  };
37
39
  const getGapAndOffset = (prevNode, nextNode, parentNode) => {
40
+ const isSyncBlockOffsetPatchEnabled = expValEquals('platform_synced_block', 'isEnabled', true) && fg('platform_synced_block_patch_2');
38
41
  if (!prevNode && nextNode) {
39
- // first node
42
+ // first node - adjust for bodied containers
43
+ let offset = 0;
44
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
45
+ offset += 4;
46
+ }
40
47
  return {
41
48
  gap: 0,
42
- offset: 0
49
+ offset
43
50
  };
44
51
  } else if (prevNode && !nextNode) {
52
+ // last node - adjust for bodied containers
53
+ let offset = 0;
54
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
55
+ offset -= 4;
56
+ }
45
57
  return {
46
58
  gap: 0,
47
- offset: 0
59
+ offset
48
60
  };
49
61
  }
50
62
  const top = getNodeMargins(nextNode).top || 4;
@@ -233,7 +245,8 @@ export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPort
233
245
  return false; //not valid pos, so nested not valid either
234
246
  }
235
247
  }
236
- if (parent.lastChild === node && !isEmptyParagraph(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
248
+ const parentTypesWithEndDropTarget = expValEquals('platform_synced_block', 'isEnabled', true) && fg('platform_synced_block_patch_2') ? PARENT_WITH_END_DROP_TARGET_NEXT : PARENT_WITH_END_DROP_TARGET;
249
+ if (parent.lastChild === node && !isEmptyParagraph(node) && parentTypesWithEndDropTarget.includes(parent.type.name)) {
237
250
  endPos = pos + node.nodeSize;
238
251
  }
239
252
  const previousNode = popNodeStack(depth); // created scoped variable
@@ -7,6 +7,7 @@ import uuid from 'uuid';
7
7
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
8
8
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
9
9
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
13
  import { nodeMargins } from '../ui/consts';
@@ -17,6 +18,7 @@ import { maxLayoutColumnSupported } from './utils/consts';
17
18
  import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
18
19
  var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
19
20
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
21
+ var PARENT_WITH_END_DROP_TARGET_NEXT = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension', 'bodiedSyncBlock'];
20
22
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
21
23
  var shouldDescend = function shouldDescend(node) {
22
24
  return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
@@ -38,16 +40,26 @@ var shouldCollapseMargin = function shouldCollapseMargin(prevNode, nextNode) {
38
40
  return true;
39
41
  };
40
42
  var getGapAndOffset = function getGapAndOffset(prevNode, nextNode, parentNode) {
43
+ var isSyncBlockOffsetPatchEnabled = expValEquals('platform_synced_block', 'isEnabled', true) && fg('platform_synced_block_patch_2');
41
44
  if (!prevNode && nextNode) {
42
- // first node
45
+ // first node - adjust for bodied containers
46
+ var _offset = 0;
47
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
48
+ _offset += 4;
49
+ }
43
50
  return {
44
51
  gap: 0,
45
- offset: 0
52
+ offset: _offset
46
53
  };
47
54
  } else if (prevNode && !nextNode) {
55
+ // last node - adjust for bodied containers
56
+ var _offset2 = 0;
57
+ if (isSyncBlockOffsetPatchEnabled && parentNode !== null && parentNode !== void 0 && parentNode.type.name && parentNode.type.name === 'bodiedSyncBlock') {
58
+ _offset2 -= 4;
59
+ }
48
60
  return {
49
61
  gap: 0,
50
- offset: 0
62
+ offset: _offset2
51
63
  };
52
64
  }
53
65
  var top = getNodeMargins(nextNode).top || 4;
@@ -238,7 +250,8 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
238
250
  return false; //not valid pos, so nested not valid either
239
251
  }
240
252
  }
241
- if (parent.lastChild === node && !isEmptyParagraph(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
253
+ var parentTypesWithEndDropTarget = expValEquals('platform_synced_block', 'isEnabled', true) && fg('platform_synced_block_patch_2') ? PARENT_WITH_END_DROP_TARGET_NEXT : PARENT_WITH_END_DROP_TARGET;
254
+ if (parent.lastChild === node && !isEmptyParagraph(node) && parentTypesWithEndDropTarget.includes(parent.type.name)) {
242
255
  endPos = pos + node.nodeSize;
243
256
  }
244
257
  var previousNode = popNodeStack(depth); // created scoped variable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "8.1.7",
3
+ "version": "8.2.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-interaction": "^14.0.0",
38
38
  "@atlaskit/editor-plugin-limited-mode": "^4.0.0",
39
39
  "@atlaskit/editor-plugin-metrics": "^8.0.0",
40
- "@atlaskit/editor-plugin-quick-insert": "^7.2.0",
40
+ "@atlaskit/editor-plugin-quick-insert": "^7.3.0",
41
41
  "@atlaskit/editor-plugin-selection": "^7.0.0",
42
42
  "@atlaskit/editor-plugin-toolbar": "^4.1.0",
43
43
  "@atlaskit/editor-plugin-type-ahead": "^7.0.0",
@@ -54,7 +54,7 @@
54
54
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
55
55
  "@atlaskit/primitives": "^18.0.0",
56
56
  "@atlaskit/theme": "^21.0.0",
57
- "@atlaskit/tmp-editor-statsig": "^21.0.0",
57
+ "@atlaskit/tmp-editor-statsig": "^22.1.0",
58
58
  "@atlaskit/tokens": "^11.0.0",
59
59
  "@atlaskit/tooltip": "^20.14.0",
60
60
  "@babel/runtime": "^7.0.0",
@@ -145,6 +145,9 @@
145
145
  },
146
146
  "platform_editor_native_anchor_patch_2": {
147
147
  "type": "boolean"
148
+ },
149
+ "platform_synced_block_patch_2": {
150
+ "type": "boolean"
148
151
  }
149
152
  }
150
153
  }