@atlaskit/editor-plugin-block-menu 5.2.23 → 5.2.25
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 +16 -0
- package/dist/cjs/blockMenuPlugin.js +2 -2
- package/dist/cjs/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js} +3 -50
- package/dist/cjs/editor-commands/transform-node-utils/marks.js +18 -0
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +6 -2
- package/dist/cjs/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +4 -7
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +3 -5
- package/dist/es2019/blockMenuPlugin.js +2 -2
- package/dist/es2019/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js} +2 -49
- package/dist/es2019/editor-commands/transform-node-utils/marks.js +8 -0
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +6 -2
- package/dist/es2019/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +4 -7
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +3 -5
- package/dist/esm/blockMenuPlugin.js +2 -2
- package/dist/esm/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js} +2 -49
- package/dist/esm/editor-commands/transform-node-utils/marks.js +12 -0
- package/dist/esm/editor-commands/transform-node-utils/transform.js +6 -2
- package/dist/esm/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +4 -7
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +3 -5
- package/dist/{types-ts4.5/editor-actions/isTrasformToTargetDisabled.d.ts → types/editor-actions/isTransformToTargetDisabled.d.ts} +1 -1
- package/dist/types/editor-commands/transform-node-utils/marks.d.ts +2 -0
- package/dist/{types/editor-actions/isTrasformToTargetDisabled.d.ts → types-ts4.5/editor-actions/isTransformToTargetDisabled.d.ts} +1 -1
- package/dist/types-ts4.5/editor-commands/transform-node-utils/marks.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.2.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9cb0ce7857313`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9cb0ce7857313) -
|
|
8
|
+
[ux] Fix contextual transform options for single node selections.
|
|
9
|
+
|
|
10
|
+
## 5.2.24
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`ec581339891b4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ec581339891b4) -
|
|
15
|
+
Fix code block transformation to remove block marks (breakout, alignment) when wrapping into
|
|
16
|
+
layout, blockquote, expand, or panel
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 5.2.23
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.blockMenuPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _editorActions = require("./editor-actions");
|
|
10
|
-
var
|
|
10
|
+
var _isTransformToTargetDisabled = require("./editor-actions/isTransformToTargetDisabled");
|
|
11
11
|
var _formatNode2 = require("./editor-commands/formatNode");
|
|
12
12
|
var _transformNode2 = require("./editor-commands/transformNode");
|
|
13
13
|
var _main = require("./pm-plugins/main");
|
|
@@ -46,7 +46,7 @@ var blockMenuPlugin = exports.blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
46
46
|
if (!currentSelection) {
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
|
-
return (0,
|
|
49
|
+
return (0, _isTransformToTargetDisabled.isTransformToTargetDisabled)({
|
|
50
50
|
selection: currentSelection,
|
|
51
51
|
targetNodeTypeName: optionNodeTypeName,
|
|
52
52
|
targetNodeTypeAttrs: optionNodeTypeAttrs
|
package/dist/cjs/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isTransformToTargetDisabled = exports.canParentContainNodeType = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
9
|
var _transform = require("../editor-commands/transform-node-utils/transform");
|
|
@@ -43,7 +43,7 @@ var isTransformEnabledForNode = function isTransformEnabledForNode(node, targetN
|
|
|
43
43
|
}
|
|
44
44
|
return true;
|
|
45
45
|
};
|
|
46
|
-
var
|
|
46
|
+
var isTransformToTargetDisabled = exports.isTransformToTargetDisabled = function isTransformToTargetDisabled(_ref) {
|
|
47
47
|
var selection = _ref.selection,
|
|
48
48
|
targetNodeTypeName = _ref.targetNodeTypeName,
|
|
49
49
|
targetNodeTypeAttrs = _ref.targetNodeTypeAttrs;
|
|
@@ -64,51 +64,4 @@ var isTrasformToTargetDisabled = exports.isTrasformToTargetDisabled = function i
|
|
|
64
64
|
return isTransformEnabledForNode(node, supportedTargetNodeTypeName, targetNodeTypeAttrs, isNested, parent, schema);
|
|
65
65
|
});
|
|
66
66
|
return !isEnabledForAnyNode;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// export const isTrasformToTargetDisabled = ({
|
|
70
|
-
// selection,
|
|
71
|
-
// targetNodeTypeName,
|
|
72
|
-
// targetNodeTypeAttrs,
|
|
73
|
-
// }: TransformDisabledArgs) => {
|
|
74
|
-
// const { range } = expandSelectionToBlockRange(selection);
|
|
75
|
-
// if (!range) {
|
|
76
|
-
// return false;
|
|
77
|
-
// }
|
|
78
|
-
|
|
79
|
-
// const selectedNodes = getBlockNodesInRange(range);
|
|
80
|
-
// const parent = range.parent;
|
|
81
|
-
// const isNested = range.depth >= 1;
|
|
82
|
-
|
|
83
|
-
// const { schema } = selection.$from.doc.type;
|
|
84
|
-
|
|
85
|
-
// const isTransformEnabledForAnySelectedNode = selectedNodes.some((node) => {
|
|
86
|
-
// const selectedNodeTypeName = toNodeTypeValue(node.type.name);
|
|
87
|
-
// const supportedTargetNodeTypeName = toNodeTypeValue(targetNodeTypeName);
|
|
88
|
-
// if (!selectedNodeTypeName || !supportedTargetNodeTypeName) {
|
|
89
|
-
// return false;
|
|
90
|
-
// }
|
|
91
|
-
|
|
92
|
-
// if (isTransformDisabledBasedOnStepsConfig(selectedNodeTypeName, supportedTargetNodeTypeName)) {
|
|
93
|
-
// if (selectedNodeTypeName === 'heading' && supportedTargetNodeTypeName === 'heading') {
|
|
94
|
-
// return isHeadingToHeadingTransformDisabled(node, targetNodeTypeAttrs);
|
|
95
|
-
// }
|
|
96
|
-
// return false;
|
|
97
|
-
// }
|
|
98
|
-
|
|
99
|
-
// if (
|
|
100
|
-
// isNested &&
|
|
101
|
-
// !canParentContainNodeType(schema, parent, supportedTargetNodeTypeName, targetNodeTypeAttrs)
|
|
102
|
-
// ) {
|
|
103
|
-
// return false;
|
|
104
|
-
// }
|
|
105
|
-
|
|
106
|
-
// return true;
|
|
107
|
-
// });
|
|
108
|
-
|
|
109
|
-
// if (isTransformEnabledForAnySelectedNode) {
|
|
110
|
-
// return false;
|
|
111
|
-
// }
|
|
112
|
-
|
|
113
|
-
// return true;
|
|
114
|
-
// };
|
|
67
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -157,7 +157,9 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
157
157
|
},
|
|
158
158
|
mediaGroup: {
|
|
159
159
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
160
|
-
codeBlock: null
|
|
160
|
+
codeBlock: null,
|
|
161
|
+
decisionList: null,
|
|
162
|
+
taskList: null
|
|
161
163
|
},
|
|
162
164
|
decisionList: {
|
|
163
165
|
decisionList: null,
|
|
@@ -189,7 +191,9 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
189
191
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
190
192
|
codeBlock: null,
|
|
191
193
|
decisionList: null,
|
|
192
|
-
taskList: null
|
|
194
|
+
taskList: null,
|
|
195
|
+
orderedList: null,
|
|
196
|
+
bulletList: null
|
|
193
197
|
},
|
|
194
198
|
bodiedExtension: {
|
|
195
199
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
|
|
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.wrapIntoLayoutStep = void 0;
|
|
7
|
-
var
|
|
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({},
|
|
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({},
|
|
19
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
|
-
import {
|
|
3
|
+
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
4
|
import { formatNode } from './editor-commands/formatNode';
|
|
5
5
|
import { transformNode } from './editor-commands/transformNode';
|
|
6
6
|
import { blockMenuPluginKey, createPlugin } from './pm-plugins/main';
|
|
@@ -40,7 +40,7 @@ export const blockMenuPlugin = ({
|
|
|
40
40
|
if (!currentSelection) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return isTransformToTargetDisabled({
|
|
44
44
|
selection: currentSelection,
|
|
45
45
|
targetNodeTypeName: optionNodeTypeName,
|
|
46
46
|
targetNodeTypeAttrs: optionNodeTypeAttrs
|
package/dist/es2019/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js}
RENAMED
|
@@ -37,7 +37,7 @@ const isTransformEnabledForNode = (node, targetNodeTypeName, targetNodeTypeAttrs
|
|
|
37
37
|
}
|
|
38
38
|
return true;
|
|
39
39
|
};
|
|
40
|
-
export const
|
|
40
|
+
export const isTransformToTargetDisabled = ({
|
|
41
41
|
selection,
|
|
42
42
|
targetNodeTypeName,
|
|
43
43
|
targetNodeTypeAttrs
|
|
@@ -60,51 +60,4 @@ export const isTrasformToTargetDisabled = ({
|
|
|
60
60
|
}
|
|
61
61
|
const isEnabledForAnyNode = selectedNodes.some(node => isTransformEnabledForNode(node, supportedTargetNodeTypeName, targetNodeTypeAttrs, isNested, parent, schema));
|
|
62
62
|
return !isEnabledForAnyNode;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// export const isTrasformToTargetDisabled = ({
|
|
66
|
-
// selection,
|
|
67
|
-
// targetNodeTypeName,
|
|
68
|
-
// targetNodeTypeAttrs,
|
|
69
|
-
// }: TransformDisabledArgs) => {
|
|
70
|
-
// const { range } = expandSelectionToBlockRange(selection);
|
|
71
|
-
// if (!range) {
|
|
72
|
-
// return false;
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
|
-
// const selectedNodes = getBlockNodesInRange(range);
|
|
76
|
-
// const parent = range.parent;
|
|
77
|
-
// const isNested = range.depth >= 1;
|
|
78
|
-
|
|
79
|
-
// const { schema } = selection.$from.doc.type;
|
|
80
|
-
|
|
81
|
-
// const isTransformEnabledForAnySelectedNode = selectedNodes.some((node) => {
|
|
82
|
-
// const selectedNodeTypeName = toNodeTypeValue(node.type.name);
|
|
83
|
-
// const supportedTargetNodeTypeName = toNodeTypeValue(targetNodeTypeName);
|
|
84
|
-
// if (!selectedNodeTypeName || !supportedTargetNodeTypeName) {
|
|
85
|
-
// return false;
|
|
86
|
-
// }
|
|
87
|
-
|
|
88
|
-
// if (isTransformDisabledBasedOnStepsConfig(selectedNodeTypeName, supportedTargetNodeTypeName)) {
|
|
89
|
-
// if (selectedNodeTypeName === 'heading' && supportedTargetNodeTypeName === 'heading') {
|
|
90
|
-
// return isHeadingToHeadingTransformDisabled(node, targetNodeTypeAttrs);
|
|
91
|
-
// }
|
|
92
|
-
// return false;
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
// if (
|
|
96
|
-
// isNested &&
|
|
97
|
-
// !canParentContainNodeType(schema, parent, supportedTargetNodeTypeName, targetNodeTypeAttrs)
|
|
98
|
-
// ) {
|
|
99
|
-
// return false;
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
|
-
// return true;
|
|
103
|
-
// });
|
|
104
|
-
|
|
105
|
-
// if (isTransformEnabledForAnySelectedNode) {
|
|
106
|
-
// return false;
|
|
107
|
-
// }
|
|
108
|
-
|
|
109
|
-
// return true;
|
|
110
|
-
// };
|
|
63
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -152,7 +152,9 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
152
152
|
},
|
|
153
153
|
mediaGroup: {
|
|
154
154
|
layoutSection: [wrapIntoLayoutStep],
|
|
155
|
-
codeBlock: null
|
|
155
|
+
codeBlock: null,
|
|
156
|
+
decisionList: null,
|
|
157
|
+
taskList: null
|
|
156
158
|
},
|
|
157
159
|
decisionList: {
|
|
158
160
|
decisionList: null,
|
|
@@ -184,7 +186,9 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
184
186
|
layoutSection: [wrapIntoLayoutStep],
|
|
185
187
|
codeBlock: null,
|
|
186
188
|
decisionList: null,
|
|
187
|
-
taskList: null
|
|
189
|
+
taskList: null,
|
|
190
|
+
orderedList: null,
|
|
191
|
+
bulletList: null
|
|
188
192
|
},
|
|
189
193
|
bodiedExtension: {
|
|
190
194
|
layoutSection: [wrapIntoLayoutStep],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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({},
|
|
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({},
|
|
16
|
-
|
|
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
|
-
|
|
28
|
-
return [outputNode];
|
|
29
|
-
}
|
|
30
|
-
return nodes;
|
|
27
|
+
const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeBlockMarks(processedNodes, schema));
|
|
28
|
+
return outputNode ? [outputNode] : nodes;
|
|
31
29
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createBlockMenuRegistry } from './editor-actions';
|
|
3
|
-
import {
|
|
3
|
+
import { isTransformToTargetDisabled } from './editor-actions/isTransformToTargetDisabled';
|
|
4
4
|
import { formatNode as _formatNode } from './editor-commands/formatNode';
|
|
5
5
|
import { transformNode as _transformNode } from './editor-commands/transformNode';
|
|
6
6
|
import { blockMenuPluginKey, createPlugin } from './pm-plugins/main';
|
|
@@ -39,7 +39,7 @@ export var blockMenuPlugin = function blockMenuPlugin(_ref) {
|
|
|
39
39
|
if (!currentSelection) {
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return isTransformToTargetDisabled({
|
|
43
43
|
selection: currentSelection,
|
|
44
44
|
targetNodeTypeName: optionNodeTypeName,
|
|
45
45
|
targetNodeTypeAttrs: optionNodeTypeAttrs
|
package/dist/esm/editor-actions/{isTrasformToTargetDisabled.js → isTransformToTargetDisabled.js}
RENAMED
|
@@ -37,7 +37,7 @@ var isTransformEnabledForNode = function isTransformEnabledForNode(node, targetN
|
|
|
37
37
|
}
|
|
38
38
|
return true;
|
|
39
39
|
};
|
|
40
|
-
export var
|
|
40
|
+
export var isTransformToTargetDisabled = function isTransformToTargetDisabled(_ref) {
|
|
41
41
|
var selection = _ref.selection,
|
|
42
42
|
targetNodeTypeName = _ref.targetNodeTypeName,
|
|
43
43
|
targetNodeTypeAttrs = _ref.targetNodeTypeAttrs;
|
|
@@ -58,51 +58,4 @@ export var isTrasformToTargetDisabled = function isTrasformToTargetDisabled(_ref
|
|
|
58
58
|
return isTransformEnabledForNode(node, supportedTargetNodeTypeName, targetNodeTypeAttrs, isNested, parent, schema);
|
|
59
59
|
});
|
|
60
60
|
return !isEnabledForAnyNode;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// export const isTrasformToTargetDisabled = ({
|
|
64
|
-
// selection,
|
|
65
|
-
// targetNodeTypeName,
|
|
66
|
-
// targetNodeTypeAttrs,
|
|
67
|
-
// }: TransformDisabledArgs) => {
|
|
68
|
-
// const { range } = expandSelectionToBlockRange(selection);
|
|
69
|
-
// if (!range) {
|
|
70
|
-
// return false;
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
|
-
// const selectedNodes = getBlockNodesInRange(range);
|
|
74
|
-
// const parent = range.parent;
|
|
75
|
-
// const isNested = range.depth >= 1;
|
|
76
|
-
|
|
77
|
-
// const { schema } = selection.$from.doc.type;
|
|
78
|
-
|
|
79
|
-
// const isTransformEnabledForAnySelectedNode = selectedNodes.some((node) => {
|
|
80
|
-
// const selectedNodeTypeName = toNodeTypeValue(node.type.name);
|
|
81
|
-
// const supportedTargetNodeTypeName = toNodeTypeValue(targetNodeTypeName);
|
|
82
|
-
// if (!selectedNodeTypeName || !supportedTargetNodeTypeName) {
|
|
83
|
-
// return false;
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
|
-
// if (isTransformDisabledBasedOnStepsConfig(selectedNodeTypeName, supportedTargetNodeTypeName)) {
|
|
87
|
-
// if (selectedNodeTypeName === 'heading' && supportedTargetNodeTypeName === 'heading') {
|
|
88
|
-
// return isHeadingToHeadingTransformDisabled(node, targetNodeTypeAttrs);
|
|
89
|
-
// }
|
|
90
|
-
// return false;
|
|
91
|
-
// }
|
|
92
|
-
|
|
93
|
-
// if (
|
|
94
|
-
// isNested &&
|
|
95
|
-
// !canParentContainNodeType(schema, parent, supportedTargetNodeTypeName, targetNodeTypeAttrs)
|
|
96
|
-
// ) {
|
|
97
|
-
// return false;
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// return true;
|
|
101
|
-
// });
|
|
102
|
-
|
|
103
|
-
// if (isTransformEnabledForAnySelectedNode) {
|
|
104
|
-
// return false;
|
|
105
|
-
// }
|
|
106
|
-
|
|
107
|
-
// return true;
|
|
108
|
-
// };
|
|
61
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -152,7 +152,9 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
152
152
|
},
|
|
153
153
|
mediaGroup: {
|
|
154
154
|
layoutSection: [wrapIntoLayoutStep],
|
|
155
|
-
codeBlock: null
|
|
155
|
+
codeBlock: null,
|
|
156
|
+
decisionList: null,
|
|
157
|
+
taskList: null
|
|
156
158
|
},
|
|
157
159
|
decisionList: {
|
|
158
160
|
decisionList: null,
|
|
@@ -184,7 +186,9 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
184
186
|
layoutSection: [wrapIntoLayoutStep],
|
|
185
187
|
codeBlock: null,
|
|
186
188
|
decisionList: null,
|
|
187
|
-
taskList: null
|
|
189
|
+
taskList: null,
|
|
190
|
+
orderedList: null,
|
|
191
|
+
bulletList: null
|
|
188
192
|
},
|
|
189
193
|
bodiedExtension: {
|
|
190
194
|
layoutSection: [wrapIntoLayoutStep],
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
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({},
|
|
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({},
|
|
13
|
-
|
|
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
|
-
|
|
26
|
-
return [outputNode];
|
|
27
|
-
}
|
|
28
|
-
return nodes;
|
|
25
|
+
var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeBlockMarks(processedNodes, schema));
|
|
26
|
+
return outputNode ? [outputNode] : nodes;
|
|
29
27
|
};
|
|
@@ -7,5 +7,5 @@ type TransformDisabledArgs = {
|
|
|
7
7
|
targetNodeTypeName: string;
|
|
8
8
|
};
|
|
9
9
|
export declare const canParentContainNodeType: (schema: Schema, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const isTransformToTargetDisabled: ({ selection, targetNodeTypeName, targetNodeTypeAttrs, }: TransformDisabledArgs) => boolean;
|
|
11
11
|
export {};
|
|
@@ -7,5 +7,5 @@ type TransformDisabledArgs = {
|
|
|
7
7
|
targetNodeTypeName: string;
|
|
8
8
|
};
|
|
9
9
|
export declare const canParentContainNodeType: (schema: Schema, parentNode: PMNode, nodeTypeName: NodeTypeName, nodeTypeAttrs?: Record<string, unknown>) => boolean;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const isTransformToTargetDisabled: ({ selection, targetNodeTypeName, targetNodeTypeAttrs, }: TransformDisabledArgs) => boolean;
|
|
11
11
|
export {};
|