@atlaskit/editor-plugin-block-menu 5.2.0 → 5.2.1
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 +8 -0
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +5 -1
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +25 -19
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -1
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +25 -16
- package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -1
- package/dist/esm/editor-commands/transform-node-utils/utils.js +26 -20
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +2 -2
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e1a0f13fc5c83`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e1a0f13fc5c83) -
|
|
8
|
+
Editor-2778: Table transform to expand and layout
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 5.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -31,7 +31,7 @@ var wrapIntoPanelStep = function wrapIntoPanelStep(nodes, context) {
|
|
|
31
31
|
var TRANSFORM_STEPS = {
|
|
32
32
|
atomic: {
|
|
33
33
|
atomic: undefined,
|
|
34
|
-
container: [
|
|
34
|
+
container: [_wrapStep.wrapStep],
|
|
35
35
|
list: undefined,
|
|
36
36
|
text: undefined
|
|
37
37
|
},
|
|
@@ -115,6 +115,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
115
115
|
// Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
|
|
116
116
|
codeBlock: [_convertTaskListToTextStep.convertTaskListToTextStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
|
|
117
117
|
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
118
|
+
},
|
|
119
|
+
table: {
|
|
120
|
+
expand: [_wrapStep.wrapStep],
|
|
121
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
118
122
|
}
|
|
119
123
|
};
|
|
120
124
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -8,6 +8,7 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
10
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
11
|
+
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
11
12
|
var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selection) {
|
|
12
13
|
if (selection instanceof _state.NodeSelection) {
|
|
13
14
|
return {
|
|
@@ -58,29 +59,34 @@ var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = fu
|
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
|
-
* Use common expandToBlockRange function
|
|
62
|
-
*
|
|
62
|
+
* Use common expandToBlockRange function to get the correct range for the selection
|
|
63
|
+
* For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
|
|
63
64
|
* @param selection
|
|
64
65
|
* @param schema
|
|
65
66
|
* @returns
|
|
66
67
|
*/
|
|
67
68
|
var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function expandSelectionToBlockRange(selection, schema) {
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
var nodes = schema.nodes;
|
|
70
|
+
var nodesNeedToExpandRange = [nodes.listItem, nodes.taskItem];
|
|
71
|
+
|
|
72
|
+
// when adding nodes.tableRow, tableHeader, tableCell in nodesNeedToExpandRang,
|
|
73
|
+
// expandToBlockRange does not return expected table start position, sometimes even freeze editor
|
|
74
|
+
// so handle table in the below logic
|
|
75
|
+
if ((0, _utils2.isTableSelected)(selection)) {
|
|
76
|
+
var table = (0, _utils2.findTable)(selection);
|
|
77
|
+
if (table) {
|
|
78
|
+
var $from = selection.$from.doc.resolve(table.pos);
|
|
79
|
+
var $to = selection.$from.doc.resolve(table.pos + table.node.nodeSize - 1);
|
|
80
|
+
return {
|
|
81
|
+
$from: $from,
|
|
82
|
+
$to: $to
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return (0, _selection.expandToBlockRange)(selection.$from, selection.$to, function (node) {
|
|
87
|
+
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
78
88
|
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
$from: $from,
|
|
84
|
-
$to: $to
|
|
85
|
-
};
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
86
92
|
};
|
|
@@ -26,7 +26,7 @@ const wrapIntoPanelStep = (nodes, context) => {
|
|
|
26
26
|
const TRANSFORM_STEPS = {
|
|
27
27
|
atomic: {
|
|
28
28
|
atomic: undefined,
|
|
29
|
-
container: [
|
|
29
|
+
container: [wrapStep],
|
|
30
30
|
list: undefined,
|
|
31
31
|
text: undefined
|
|
32
32
|
},
|
|
@@ -110,6 +110,10 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
110
110
|
// Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
|
|
111
111
|
codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
|
|
112
112
|
layoutSection: [wrapIntoLayoutStep]
|
|
113
|
+
},
|
|
114
|
+
table: {
|
|
115
|
+
expand: [wrapStep],
|
|
116
|
+
layoutSection: [wrapIntoLayoutStep]
|
|
113
117
|
}
|
|
114
118
|
};
|
|
115
119
|
const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { findParentNodeOfType
|
|
3
|
+
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
|
+
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
6
|
export const getSelectedNode = selection => {
|
|
6
7
|
if (selection instanceof NodeSelection) {
|
|
7
8
|
return {
|
|
@@ -53,28 +54,36 @@ export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested) => {
|
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
|
-
* Use common expandToBlockRange function
|
|
57
|
-
*
|
|
57
|
+
* Use common expandToBlockRange function to get the correct range for the selection
|
|
58
|
+
* For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
|
|
58
59
|
* @param selection
|
|
59
60
|
* @param schema
|
|
60
61
|
* @returns
|
|
61
62
|
*/
|
|
62
63
|
export const expandSelectionToBlockRange = (selection, schema) => {
|
|
63
|
-
const isListInSelection = hasParentNode(node => node.type === schema.nodes.bulletList || node.type === schema.nodes.orderedList)(selection);
|
|
64
64
|
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
nodes
|
|
66
|
+
} = schema;
|
|
67
|
+
const nodesNeedToExpandRange = [nodes.listItem, nodes.taskItem];
|
|
68
|
+
|
|
69
|
+
// when adding nodes.tableRow, tableHeader, tableCell in nodesNeedToExpandRang,
|
|
70
|
+
// expandToBlockRange does not return expected table start position, sometimes even freeze editor
|
|
71
|
+
// so handle table in the below logic
|
|
72
|
+
if (isTableSelected(selection)) {
|
|
73
|
+
const table = findTable(selection);
|
|
74
|
+
if (table) {
|
|
75
|
+
const $from = selection.$from.doc.resolve(table.pos);
|
|
76
|
+
const $to = selection.$from.doc.resolve(table.pos + table.node.nodeSize - 1);
|
|
77
|
+
return {
|
|
78
|
+
$from,
|
|
79
|
+
$to
|
|
80
|
+
};
|
|
70
81
|
}
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
}
|
|
83
|
+
return expandToBlockRange(selection.$from, selection.$to, node => {
|
|
84
|
+
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
85
|
+
return false;
|
|
73
86
|
}
|
|
74
|
-
return
|
|
87
|
+
return true;
|
|
75
88
|
});
|
|
76
|
-
return {
|
|
77
|
-
$from,
|
|
78
|
-
$to
|
|
79
|
-
};
|
|
80
89
|
};
|
|
@@ -26,7 +26,7 @@ var wrapIntoPanelStep = function wrapIntoPanelStep(nodes, context) {
|
|
|
26
26
|
var TRANSFORM_STEPS = {
|
|
27
27
|
atomic: {
|
|
28
28
|
atomic: undefined,
|
|
29
|
-
container: [
|
|
29
|
+
container: [wrapStep],
|
|
30
30
|
list: undefined,
|
|
31
31
|
text: undefined
|
|
32
32
|
},
|
|
@@ -110,6 +110,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
110
110
|
// Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
|
|
111
111
|
codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
|
|
112
112
|
layoutSection: [wrapIntoLayoutStep]
|
|
113
|
+
},
|
|
114
|
+
table: {
|
|
115
|
+
expand: [wrapStep],
|
|
116
|
+
layoutSection: [wrapIntoLayoutStep]
|
|
113
117
|
}
|
|
114
118
|
};
|
|
115
119
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { findParentNodeOfType
|
|
3
|
+
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
|
+
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
6
|
export var getSelectedNode = function getSelectedNode(selection) {
|
|
6
7
|
if (selection instanceof NodeSelection) {
|
|
7
8
|
return {
|
|
@@ -52,29 +53,34 @@ export var getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInCont
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
* Use common expandToBlockRange function
|
|
56
|
-
*
|
|
56
|
+
* Use common expandToBlockRange function to get the correct range for the selection
|
|
57
|
+
* For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
|
|
57
58
|
* @param selection
|
|
58
59
|
* @param schema
|
|
59
60
|
* @returns
|
|
60
61
|
*/
|
|
61
62
|
export var expandSelectionToBlockRange = function expandSelectionToBlockRange(selection, schema) {
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
var nodes = schema.nodes;
|
|
64
|
+
var nodesNeedToExpandRange = [nodes.listItem, nodes.taskItem];
|
|
65
|
+
|
|
66
|
+
// when adding nodes.tableRow, tableHeader, tableCell in nodesNeedToExpandRang,
|
|
67
|
+
// expandToBlockRange does not return expected table start position, sometimes even freeze editor
|
|
68
|
+
// so handle table in the below logic
|
|
69
|
+
if (isTableSelected(selection)) {
|
|
70
|
+
var table = findTable(selection);
|
|
71
|
+
if (table) {
|
|
72
|
+
var $from = selection.$from.doc.resolve(table.pos);
|
|
73
|
+
var $to = selection.$from.doc.resolve(table.pos + table.node.nodeSize - 1);
|
|
74
|
+
return {
|
|
75
|
+
$from: $from,
|
|
76
|
+
$to: $to
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return expandToBlockRange(selection.$from, selection.$to, function (node) {
|
|
81
|
+
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
72
82
|
return false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
$from: $from,
|
|
78
|
-
$to: $to
|
|
79
|
-
};
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
});
|
|
80
86
|
};
|
|
@@ -5,8 +5,8 @@ import type { NodeTypeName } from './types';
|
|
|
5
5
|
export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
6
|
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
|
|
7
7
|
/**
|
|
8
|
-
* Use common expandToBlockRange function
|
|
9
|
-
*
|
|
8
|
+
* Use common expandToBlockRange function to get the correct range for the selection
|
|
9
|
+
* For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
|
|
10
10
|
* @param selection
|
|
11
11
|
* @param schema
|
|
12
12
|
* @returns
|
|
@@ -5,8 +5,8 @@ import type { NodeTypeName } from './types';
|
|
|
5
5
|
export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
|
|
6
6
|
export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean) => NodeTypeName | null;
|
|
7
7
|
/**
|
|
8
|
-
* Use common expandToBlockRange function
|
|
9
|
-
*
|
|
8
|
+
* Use common expandToBlockRange function to get the correct range for the selection
|
|
9
|
+
* For example, if selection starts in a listItem, go find the bullet list or ordered list, their $from
|
|
10
10
|
* @param selection
|
|
11
11
|
* @param schema
|
|
12
12
|
* @returns
|