@atlaskit/editor-plugin-block-menu 5.2.27 → 5.2.28

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,13 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.28
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8c62a0141a5fa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c62a0141a5fa) -
8
+ [ux] Fixes contextual transform options for direct children of top level nodes.
9
+ - Updated dependencies
10
+
3
11
  ## 5.2.27
4
12
 
5
13
  ### Patch Changes
@@ -9,13 +9,19 @@ var _model = require("@atlaskit/editor-prosemirror/model");
9
9
  var _transform = require("../editor-commands/transform-node-utils/transform");
10
10
  var _types = require("../editor-commands/transform-node-utils/types");
11
11
  var _utils = require("../editor-commands/transform-node-utils/utils");
12
- var canParentContainNodeType = exports.canParentContainNodeType = function canParentContainNodeType(schema, parentNode, nodeTypeName, nodeTypeAttrs) {
13
- var adjustedNodeTypeName = (0, _utils.getTargetNodeTypeNameInContext)(nodeTypeName, true);
12
+ var canParentContainNodeType = exports.canParentContainNodeType = function canParentContainNodeType(schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) {
13
+ var adjustedNodeTypeName = parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock' ? nodeTypeName : (0, _utils.getTargetNodeTypeNameInContext)(nodeTypeName, true);
14
14
  if (!adjustedNodeTypeName) {
15
15
  return false;
16
16
  }
17
17
  var nodeType = schema.nodes[adjustedNodeTypeName];
18
- return parentNode.type.validContent(_model.Fragment.from(nodeType.createAndFill(nodeTypeAttrs)));
18
+ var content = null;
19
+ var nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
20
+ if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
21
+ var table = schema.nodes[selectedNodeTypeName];
22
+ content = table.createAndFill();
23
+ }
24
+ return parentNode.type.validContent(_model.Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
19
25
  };
20
26
  var isHeadingToHeadingTransformEnabled = function isHeadingToHeadingTransformEnabled(selectedNode, targetNodeTypeAttrs) {
21
27
  var _selectedNode$attrs;
@@ -38,7 +44,7 @@ var isTransformEnabledForNode = function isTransformEnabledForNode(node, targetN
38
44
  if (selectedNodeTypeName === 'heading' && targetNodeTypeName === 'heading') {
39
45
  return isHeadingToHeadingTransformEnabled(node, targetNodeTypeAttrs);
40
46
  }
41
- if (isNested && !canParentContainNodeType(schema, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
47
+ if (isNested && !canParentContainNodeType(schema, selectedNodeTypeName, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
42
48
  return false;
43
49
  }
44
50
  return true;
@@ -3,13 +3,19 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transform-node-utils/transform';
4
4
  import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
5
5
  import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
6
- export const canParentContainNodeType = (schema, parentNode, nodeTypeName, nodeTypeAttrs) => {
7
- const adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true);
6
+ export const canParentContainNodeType = (schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) => {
7
+ const adjustedNodeTypeName = parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock' ? nodeTypeName : getTargetNodeTypeNameInContext(nodeTypeName, true);
8
8
  if (!adjustedNodeTypeName) {
9
9
  return false;
10
10
  }
11
11
  const nodeType = schema.nodes[adjustedNodeTypeName];
12
- return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs)));
12
+ let content = null;
13
+ const nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
14
+ if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
15
+ const table = schema.nodes[selectedNodeTypeName];
16
+ content = table.createAndFill();
17
+ }
18
+ return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
13
19
  };
14
20
  const isHeadingToHeadingTransformEnabled = (selectedNode, targetNodeTypeAttrs) => {
15
21
  var _selectedNode$attrs;
@@ -32,7 +38,7 @@ const isTransformEnabledForNode = (node, targetNodeTypeName, targetNodeTypeAttrs
32
38
  if (selectedNodeTypeName === 'heading' && targetNodeTypeName === 'heading') {
33
39
  return isHeadingToHeadingTransformEnabled(node, targetNodeTypeAttrs);
34
40
  }
35
- if (isNested && !canParentContainNodeType(schema, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
41
+ if (isNested && !canParentContainNodeType(schema, selectedNodeTypeName, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
36
42
  return false;
37
43
  }
38
44
  return true;
@@ -3,13 +3,19 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { isTransformDisabledBasedOnStepsConfig } from '../editor-commands/transform-node-utils/transform';
4
4
  import { toNodeTypeValue } from '../editor-commands/transform-node-utils/types';
5
5
  import { getBlockNodesInRange, getTargetNodeTypeNameInContext } from '../editor-commands/transform-node-utils/utils';
6
- export var canParentContainNodeType = function canParentContainNodeType(schema, parentNode, nodeTypeName, nodeTypeAttrs) {
7
- var adjustedNodeTypeName = getTargetNodeTypeNameInContext(nodeTypeName, true);
6
+ export var canParentContainNodeType = function canParentContainNodeType(schema, selectedNodeTypeName, parentNode, nodeTypeName, nodeTypeAttrs) {
7
+ var adjustedNodeTypeName = parentNode.type.name === 'layoutColumn' || parentNode.type.name === 'bodiedSyncBlock' ? nodeTypeName : getTargetNodeTypeNameInContext(nodeTypeName, true);
8
8
  if (!adjustedNodeTypeName) {
9
9
  return false;
10
10
  }
11
11
  var nodeType = schema.nodes[adjustedNodeTypeName];
12
- return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs)));
12
+ var content = null;
13
+ var nodesThatCantBeNestedInNestedExpand = ['blockCard', 'embedCard', 'table'];
14
+ if (nodesThatCantBeNestedInNestedExpand.includes(selectedNodeTypeName) && (adjustedNodeTypeName === 'expand' || adjustedNodeTypeName === 'nestedExpand')) {
15
+ var table = schema.nodes[selectedNodeTypeName];
16
+ content = table.createAndFill();
17
+ }
18
+ return parentNode.type.validContent(Fragment.from(nodeType.createAndFill(nodeTypeAttrs, content)));
13
19
  };
14
20
  var isHeadingToHeadingTransformEnabled = function isHeadingToHeadingTransformEnabled(selectedNode, targetNodeTypeAttrs) {
15
21
  var _selectedNode$attrs;
@@ -32,7 +38,7 @@ var isTransformEnabledForNode = function isTransformEnabledForNode(node, targetN
32
38
  if (selectedNodeTypeName === 'heading' && targetNodeTypeName === 'heading') {
33
39
  return isHeadingToHeadingTransformEnabled(node, targetNodeTypeAttrs);
34
40
  }
35
- if (isNested && !canParentContainNodeType(schema, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
41
+ if (isNested && !canParentContainNodeType(schema, selectedNodeTypeName, parent, targetNodeTypeName, targetNodeTypeAttrs)) {
36
42
  return false;
37
43
  }
38
44
  return true;
@@ -6,6 +6,6 @@ type TransformDisabledArgs = {
6
6
  targetNodeTypeAttrs?: Record<string, unknown>;
7
7
  targetNodeTypeName: string;
8
8
  };
9
- export declare const canParentContainNodeType: (schema: Schema, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
9
+ export declare const canParentContainNodeType: (schema: Schema, selectedNodeTypeName: NodeTypeName, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
10
10
  export declare const isTransformToTargetDisabled: ({ selection, targetNodeTypeName, targetNodeTypeAttrs, }: TransformDisabledArgs) => boolean;
11
11
  export {};
@@ -6,6 +6,6 @@ type TransformDisabledArgs = {
6
6
  targetNodeTypeAttrs?: Record<string, unknown>;
7
7
  targetNodeTypeName: string;
8
8
  };
9
- export declare const canParentContainNodeType: (schema: Schema, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
9
+ export declare const canParentContainNodeType: (schema: Schema, selectedNodeTypeName: NodeTypeName, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
10
10
  export declare const isTransformToTargetDisabled: ({ selection, targetNodeTypeName, targetNodeTypeAttrs, }: TransformDisabledArgs) => boolean;
11
11
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.2.27",
3
+ "version": "5.2.28",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/css": "^0.19.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
- "@atlaskit/editor-plugin-block-controls": "^7.18.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^7.19.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",