@atlaskit/editor-plugin-block-menu 5.2.23 → 5.2.24

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,14 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ec581339891b4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ec581339891b4) -
8
+ Fix code block transformation to remove block marks (breakout, alignment) when wrapping into
9
+ layout, blockquote, expand, or panel
10
+ - Updated dependencies
11
+
3
12
  ## 5.2.23
4
13
 
5
14
  ### Patch Changes
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removeBlockMarks = void 0;
7
+ var removeMarks = function removeMarks(disallowedMarks) {
8
+ return function (node) {
9
+ var filteredMarks = node.marks.filter(function (mark) {
10
+ return !disallowedMarks.includes(mark.type);
11
+ });
12
+ return node.mark(filteredMarks);
13
+ };
14
+ };
15
+ var removeBlockMarks = exports.removeBlockMarks = function removeBlockMarks(nodes, schema) {
16
+ var disallowedMarks = [schema.marks.breakout, schema.marks.alignment];
17
+ return nodes.map(removeMarks(disallowedMarks));
18
+ };
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.wrapIntoLayoutStep = void 0;
7
- var _model = require("@atlaskit/editor-prosemirror/model");
7
+ var _marks = require("./marks");
8
8
  var wrapIntoLayoutStep = exports.wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
9
9
  var schema = context.schema;
10
10
  var _ref = schema.nodes || {},
11
11
  layoutSection = _ref.layoutSection,
12
12
  layoutColumn = _ref.layoutColumn;
13
- var columnOne = layoutColumn.createAndFill({}, _model.Fragment.fromArray(nodes));
13
+ var columnOne = layoutColumn.createAndFill({}, (0, _marks.removeBlockMarks)(nodes, schema));
14
14
  var columnTwo = layoutColumn.createAndFill();
15
15
  if (!columnOne || !columnTwo) {
16
16
  return nodes;
17
17
  }
18
- var layout = layoutSection.createAndFill({}, _model.Fragment.fromArray([columnOne, columnTwo]));
19
- if (!layout) {
20
- return nodes;
21
- }
22
- return [layout];
18
+ var layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
19
+ return layout ? [layout] : nodes;
23
20
  };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.wrapStep = void 0;
7
+ var _marks = require("./marks");
7
8
  var _utils = require("./utils");
8
9
  /**
9
10
  * Wraps nodes into the target container type.
@@ -26,9 +27,6 @@ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
26
27
  return node;
27
28
  });
28
29
  }
29
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, processedNodes);
30
- if (outputNode) {
31
- return [outputNode];
32
- }
33
- return nodes;
30
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, (0, _marks.removeBlockMarks)(processedNodes, schema));
31
+ return outputNode ? [outputNode] : nodes;
34
32
  };
@@ -0,0 +1,8 @@
1
+ const removeMarks = disallowedMarks => node => {
2
+ const filteredMarks = node.marks.filter(mark => !disallowedMarks.includes(mark.type));
3
+ return node.mark(filteredMarks);
4
+ };
5
+ export const removeBlockMarks = (nodes, schema) => {
6
+ const disallowedMarks = [schema.marks.breakout, schema.marks.alignment];
7
+ return nodes.map(removeMarks(disallowedMarks));
8
+ };
@@ -1,4 +1,4 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
+ import { removeBlockMarks } from './marks';
2
2
  export const wrapIntoLayoutStep = (nodes, context) => {
3
3
  const {
4
4
  schema
@@ -7,14 +7,11 @@ export const wrapIntoLayoutStep = (nodes, context) => {
7
7
  layoutSection,
8
8
  layoutColumn
9
9
  } = schema.nodes || {};
10
- const columnOne = layoutColumn.createAndFill({}, Fragment.fromArray(nodes));
10
+ const columnOne = layoutColumn.createAndFill({}, removeBlockMarks(nodes, schema));
11
11
  const columnTwo = layoutColumn.createAndFill();
12
12
  if (!columnOne || !columnTwo) {
13
13
  return nodes;
14
14
  }
15
- const layout = layoutSection.createAndFill({}, Fragment.fromArray([columnOne, columnTwo]));
16
- if (!layout) {
17
- return nodes;
18
- }
19
- return [layout];
15
+ const layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
16
+ return layout ? [layout] : nodes;
20
17
  };
@@ -1,3 +1,4 @@
1
+ import { removeBlockMarks } from './marks';
1
2
  import { convertExpandToNestedExpand } from './utils';
2
3
 
3
4
  /**
@@ -23,9 +24,6 @@ export const wrapStep = (nodes, context) => {
23
24
  return node;
24
25
  });
25
26
  }
26
- const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, processedNodes);
27
- if (outputNode) {
28
- return [outputNode];
29
- }
30
- return nodes;
27
+ const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeBlockMarks(processedNodes, schema));
28
+ return outputNode ? [outputNode] : nodes;
31
29
  };
@@ -0,0 +1,12 @@
1
+ var removeMarks = function removeMarks(disallowedMarks) {
2
+ return function (node) {
3
+ var filteredMarks = node.marks.filter(function (mark) {
4
+ return !disallowedMarks.includes(mark.type);
5
+ });
6
+ return node.mark(filteredMarks);
7
+ };
8
+ };
9
+ export var removeBlockMarks = function removeBlockMarks(nodes, schema) {
10
+ var disallowedMarks = [schema.marks.breakout, schema.marks.alignment];
11
+ return nodes.map(removeMarks(disallowedMarks));
12
+ };
@@ -1,17 +1,14 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
+ import { removeBlockMarks } from './marks';
2
2
  export var wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
3
3
  var schema = context.schema;
4
4
  var _ref = schema.nodes || {},
5
5
  layoutSection = _ref.layoutSection,
6
6
  layoutColumn = _ref.layoutColumn;
7
- var columnOne = layoutColumn.createAndFill({}, Fragment.fromArray(nodes));
7
+ var columnOne = layoutColumn.createAndFill({}, removeBlockMarks(nodes, schema));
8
8
  var columnTwo = layoutColumn.createAndFill();
9
9
  if (!columnOne || !columnTwo) {
10
10
  return nodes;
11
11
  }
12
- var layout = layoutSection.createAndFill({}, Fragment.fromArray([columnOne, columnTwo]));
13
- if (!layout) {
14
- return nodes;
15
- }
16
- return [layout];
12
+ var layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
13
+ return layout ? [layout] : nodes;
17
14
  };
@@ -1,3 +1,4 @@
1
+ import { removeBlockMarks } from './marks';
1
2
  import { convertExpandToNestedExpand } from './utils';
2
3
 
3
4
  /**
@@ -21,9 +22,6 @@ export var wrapStep = function wrapStep(nodes, context) {
21
22
  return node;
22
23
  });
23
24
  }
24
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, processedNodes);
25
- if (outputNode) {
26
- return [outputNode];
27
- }
28
- return nodes;
25
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeBlockMarks(processedNodes, schema));
26
+ return outputNode ? [outputNode] : nodes;
29
27
  };
@@ -0,0 +1,2 @@
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const removeBlockMarks: (nodes: PMNode[], schema: Schema) => PMNode[];
@@ -0,0 +1,2 @@
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const removeBlockMarks: (nodes: PMNode[], schema: Schema) => PMNode[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.2.23",
3
+ "version": "5.2.24",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",