@atlaskit/editor-plugin-block-menu 5.2.12 → 5.2.13
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 +10 -0
- package/dist/cjs/editor-commands/transform-node-utils/transform.js +2 -1
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +1 -53
- package/dist/cjs/editor-commands/transformNode.js +4 -4
- package/dist/cjs/ui/copy-link.js +7 -11
- package/dist/cjs/ui/hooks/useSuggestedItems.js +11 -4
- package/dist/cjs/ui/utils/copyLink.js +4 -4
- package/dist/cjs/ui/utils/suggested-items-rank.js +1 -1
- package/dist/es2019/editor-commands/transform-node-utils/transform.js +2 -1
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +0 -54
- package/dist/es2019/editor-commands/transformNode.js +2 -2
- package/dist/es2019/ui/copy-link.js +7 -11
- package/dist/es2019/ui/hooks/useSuggestedItems.js +10 -5
- package/dist/es2019/ui/utils/copyLink.js +3 -4
- package/dist/es2019/ui/utils/suggested-items-rank.js +0 -5
- package/dist/esm/editor-commands/transform-node-utils/transform.js +2 -1
- package/dist/esm/editor-commands/transform-node-utils/utils.js +0 -52
- package/dist/esm/editor-commands/transformNode.js +2 -2
- package/dist/esm/ui/copy-link.js +7 -11
- package/dist/esm/ui/hooks/useSuggestedItems.js +12 -5
- package/dist/esm/ui/utils/copyLink.js +4 -4
- package/dist/esm/ui/utils/suggested-items-rank.js +1 -1
- package/dist/types/editor-commands/transform-node-utils/utils.d.ts +1 -17
- package/dist/types/ui/utils/copyLink.d.ts +1 -3
- package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +1 -17
- package/dist/types-ts4.5/ui/utils/copyLink.d.ts +1 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.2.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8da61d284b811`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8da61d284b811) -
|
|
8
|
+
EDITOR-3911 Expand selection to block range
|
|
9
|
+
- [`010fbe9d85b12`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/010fbe9d85b12) -
|
|
10
|
+
[ux] Fix bug / make wrap of expand convert to nestedExpand node
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 5.2.12
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -133,7 +133,8 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
133
133
|
decisionList: {
|
|
134
134
|
bulletList: [_decisionListToListStep.decisionListToListStep],
|
|
135
135
|
orderedList: [_decisionListToListStep.decisionListToListStep],
|
|
136
|
-
taskList: [_decisionListToListStep.decisionListToListStep]
|
|
136
|
+
taskList: [_decisionListToListStep.decisionListToListStep],
|
|
137
|
+
layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
140
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.
|
|
7
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
6
|
+
exports.isListType = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
|
|
8
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
9
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
11
|
-
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
12
10
|
var getSelectedNode = exports.getSelectedNode = function getSelectedNode(selection) {
|
|
13
11
|
if (selection instanceof _state.NodeSelection) {
|
|
14
12
|
return {
|
|
@@ -57,56 +55,6 @@ var getTargetNodeTypeNameInContext = exports.getTargetNodeTypeNameInContext = fu
|
|
|
57
55
|
}
|
|
58
56
|
return nodeTypeName;
|
|
59
57
|
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
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
|
|
64
|
-
* @param selection
|
|
65
|
-
* @param schema
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function expandSelectionToBlockRange(selection, schema) {
|
|
69
|
-
var nodes = schema.nodes;
|
|
70
|
-
var nodesNeedToExpandRange = [nodes.bulletList, nodes.orderedList, nodes.taskList, 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
|
-
range: $from.blockRange($to)
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// when selecting a file, selection is on media
|
|
89
|
-
// need to find media group and return its pos
|
|
90
|
-
if (selection instanceof _state.NodeSelection) {
|
|
91
|
-
if (selection.node.type === nodes.media) {
|
|
92
|
-
var mediaGroup = (0, _utils.findParentNodeOfType)(nodes.mediaGroup)(selection);
|
|
93
|
-
if (mediaGroup) {
|
|
94
|
-
var _$from = selection.$from.doc.resolve(mediaGroup.pos);
|
|
95
|
-
var _$to = selection.$from.doc.resolve(mediaGroup.pos + mediaGroup.node.nodeSize);
|
|
96
|
-
return {
|
|
97
|
-
$from: _$from,
|
|
98
|
-
$to: _$to
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return (0, _selection.expandToBlockRange)(selection.$from, selection.$to, function (node) {
|
|
104
|
-
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
58
|
var isListType = exports.isListType = function isListType(node, schema) {
|
|
111
59
|
var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
112
60
|
return lists.some(function (list) {
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformNode = void 0;
|
|
7
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
7
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
10
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
10
11
|
var _transform = require("./transform-node-utils/transform");
|
|
11
|
-
var _utils = require("./
|
|
12
|
-
var _utils2 = require("./transforms/utils");
|
|
12
|
+
var _utils = require("./transforms/utils");
|
|
13
13
|
var transformNode = exports.transformNode = function transformNode(api) {
|
|
14
14
|
return (
|
|
15
15
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -23,13 +23,13 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
23
23
|
}
|
|
24
24
|
var schema = tr.doc.type.schema;
|
|
25
25
|
var nodes = schema.nodes;
|
|
26
|
-
var _expandSelectionToBlo = (0,
|
|
26
|
+
var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(preservedSelection),
|
|
27
27
|
$from = _expandSelectionToBlo.$from,
|
|
28
28
|
$to = _expandSelectionToBlo.$to;
|
|
29
29
|
var isNested = (0, _isNestedNode.isNestedNode)(preservedSelection, '');
|
|
30
30
|
var selectedParent = $from.parent;
|
|
31
31
|
var fragment = _model.Fragment.empty;
|
|
32
|
-
var isList = (0,
|
|
32
|
+
var isList = (0, _utils.isListNode)(selectedParent);
|
|
33
33
|
var slice = tr.doc.slice(isList ? $from.pos - 1 : $from.pos, isList ? $to.pos + 1 : $to.pos);
|
|
34
34
|
slice.content.forEach(function (node) {
|
|
35
35
|
var outputNode = (0, _transform.getOutputNodes)({
|
package/dist/cjs/ui/copy-link.js
CHANGED
|
@@ -31,24 +31,21 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
31
31
|
var _ref2 = config || {},
|
|
32
32
|
getLinkPath = _ref2.getLinkPath,
|
|
33
33
|
blockLinkHashPrefix = _ref2.blockLinkHashPrefix;
|
|
34
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls', 'selection'
|
|
34
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls', 'selection'], function (_ref3) {
|
|
35
35
|
var blockControlsState = _ref3.blockControlsState,
|
|
36
|
-
selectionState = _ref3.selectionState
|
|
37
|
-
coreState = _ref3.coreState;
|
|
36
|
+
selectionState = _ref3.selectionState;
|
|
38
37
|
return {
|
|
39
38
|
menuTriggerBy: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy,
|
|
40
39
|
preservedSelection: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection,
|
|
41
|
-
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
42
|
-
schema: coreState === null || coreState === void 0 ? void 0 : coreState.schema
|
|
40
|
+
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
43
41
|
};
|
|
44
42
|
}),
|
|
45
43
|
preservedSelection = _useSharedPluginState.preservedSelection,
|
|
46
44
|
defaultSelection = _useSharedPluginState.defaultSelection,
|
|
47
|
-
menuTriggerBy = _useSharedPluginState.menuTriggerBy
|
|
48
|
-
schema = _useSharedPluginState.schema;
|
|
45
|
+
menuTriggerBy = _useSharedPluginState.menuTriggerBy;
|
|
49
46
|
var selection = preservedSelection || defaultSelection;
|
|
50
47
|
var handleClick = (0, _react.useCallback)(function () {
|
|
51
|
-
if (!selection
|
|
48
|
+
if (!selection) {
|
|
52
49
|
return;
|
|
53
50
|
}
|
|
54
51
|
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
@@ -74,8 +71,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
74
71
|
(0, _copyLink.copyLink)({
|
|
75
72
|
getLinkPath: getLinkPath,
|
|
76
73
|
blockLinkHashPrefix: blockLinkHashPrefix,
|
|
77
|
-
selection: selection
|
|
78
|
-
schema: schema
|
|
74
|
+
selection: selection
|
|
79
75
|
}).then(function (success) {
|
|
80
76
|
if (success) {
|
|
81
77
|
api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
|
|
@@ -87,7 +83,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
87
83
|
});
|
|
88
84
|
}
|
|
89
85
|
});
|
|
90
|
-
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged,
|
|
86
|
+
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, selection]);
|
|
91
87
|
|
|
92
88
|
// Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested or on empty line
|
|
93
89
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') || !!menuTriggerBy && (0, _isNestedNode.isNestedNode)(selection, menuTriggerBy) || selection !== null && selection !== void 0 && selection.empty) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useSuggestedItems = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
9
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
10
|
var _utils = require("../../editor-commands/transform-node-utils/utils");
|
|
10
11
|
var _suggestedItemsRank = require("../utils/suggested-items-rank");
|
|
11
12
|
var useSuggestedItems = exports.useSuggestedItems = function useSuggestedItems(api) {
|
|
@@ -35,17 +36,23 @@ var useSuggestedItems = exports.useSuggestedItems = function useSuggestedItems(a
|
|
|
35
36
|
if (menuItemsMap.size === 0 || !currentSelection) {
|
|
36
37
|
return [];
|
|
37
38
|
}
|
|
38
|
-
var _expandSelectionToBlo = (0,
|
|
39
|
+
var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(currentSelection),
|
|
39
40
|
range = _expandSelectionToBlo.range;
|
|
40
41
|
if (!range) {
|
|
41
42
|
return [];
|
|
42
43
|
}
|
|
43
44
|
var blockNodes = (0, _utils.getBlockNodesInRange)(range);
|
|
44
|
-
|
|
45
|
-
if (!singleNode) {
|
|
45
|
+
if (blockNodes.length === 0) {
|
|
46
46
|
return [];
|
|
47
47
|
}
|
|
48
|
-
var
|
|
48
|
+
var firstNodeType = blockNodes[0].type.name;
|
|
49
|
+
var allSameType = blockNodes.every(function (node) {
|
|
50
|
+
return node.type.name === firstNodeType;
|
|
51
|
+
});
|
|
52
|
+
if (!allSameType) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
var nodeTypeName = firstNodeType;
|
|
49
56
|
var sortedKeys = (0, _suggestedItemsRank.getSortedSuggestedItems)(nodeTypeName);
|
|
50
57
|
return sortedKeys.map(function (key) {
|
|
51
58
|
return menuItemsMap.get(key);
|
|
@@ -10,15 +10,15 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
11
11
|
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
12
12
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
13
|
-
var
|
|
13
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
14
14
|
var copyLink = exports.copyLink = /*#__PURE__*/function () {
|
|
15
15
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
16
|
-
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection,
|
|
16
|
+
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, blockRange, node, path, url, href;
|
|
17
17
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
|
-
getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? _blockMenu.DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection
|
|
21
|
-
blockRange = (0,
|
|
20
|
+
getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? _blockMenu.DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection;
|
|
21
|
+
blockRange = (0, _selection.expandSelectionToBlockRange)(selection);
|
|
22
22
|
if (blockRange) {
|
|
23
23
|
_context.next = 4;
|
|
24
24
|
break;
|
|
@@ -43,7 +43,7 @@ var BLOCK_MENU_NODE_TYPES = exports.BLOCK_MENU_NODE_TYPES = {
|
|
|
43
43
|
EMBED_CARD: 'embedCard',
|
|
44
44
|
TABLE: 'table'
|
|
45
45
|
};
|
|
46
|
-
var TRANSFORM_SUGGESTED_ITEMS_RANK = exports.TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(
|
|
46
|
+
var TRANSFORM_SUGGESTED_ITEMS_RANK = exports.TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _blockMenu.TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), _blockMenu.TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), _blockMenu.TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)));
|
|
47
47
|
var getSuggestedItemsForNodeType = exports.getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
|
|
48
48
|
return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
|
|
49
49
|
};
|
|
@@ -128,7 +128,8 @@ const TRANSFORM_STEPS_OVERRIDE = {
|
|
|
128
128
|
decisionList: {
|
|
129
129
|
bulletList: [decisionListToListStep],
|
|
130
130
|
orderedList: [decisionListToListStep],
|
|
131
|
-
taskList: [decisionListToListStep]
|
|
131
|
+
taskList: [decisionListToListStep],
|
|
132
|
+
layoutSection: [wrapIntoLayoutStep]
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
135
|
const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
|
-
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
6
4
|
export const getSelectedNode = selection => {
|
|
7
5
|
if (selection instanceof NodeSelection) {
|
|
8
6
|
return {
|
|
@@ -52,58 +50,6 @@ export const getTargetNodeTypeNameInContext = (nodeTypeName, isNested) => {
|
|
|
52
50
|
}
|
|
53
51
|
return nodeTypeName;
|
|
54
52
|
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
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
|
|
59
|
-
* @param selection
|
|
60
|
-
* @param schema
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
export const expandSelectionToBlockRange = (selection, schema) => {
|
|
64
|
-
const {
|
|
65
|
-
nodes
|
|
66
|
-
} = schema;
|
|
67
|
-
const nodesNeedToExpandRange = [nodes.bulletList, nodes.orderedList, nodes.taskList, 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
|
-
range: $from.blockRange($to)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// when selecting a file, selection is on media
|
|
86
|
-
// need to find media group and return its pos
|
|
87
|
-
if (selection instanceof NodeSelection) {
|
|
88
|
-
if (selection.node.type === nodes.media) {
|
|
89
|
-
const mediaGroup = findParentNodeOfType(nodes.mediaGroup)(selection);
|
|
90
|
-
if (mediaGroup) {
|
|
91
|
-
const $from = selection.$from.doc.resolve(mediaGroup.pos);
|
|
92
|
-
const $to = selection.$from.doc.resolve(mediaGroup.pos + mediaGroup.node.nodeSize);
|
|
93
|
-
return {
|
|
94
|
-
$from,
|
|
95
|
-
$to
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return expandToBlockRange(selection.$from, selection.$to, node => {
|
|
101
|
-
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
53
|
export const isListType = (node, schema) => {
|
|
108
54
|
const lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
109
55
|
return lists.some(list => list === node.type);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
4
5
|
import { getOutputNodes } from './transform-node-utils/transform';
|
|
5
|
-
import { expandSelectionToBlockRange } from './transform-node-utils/utils';
|
|
6
6
|
import { isListNode } from './transforms/utils';
|
|
7
7
|
export const transformNode = api =>
|
|
8
8
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -22,7 +22,7 @@ export const transformNode = api =>
|
|
|
22
22
|
const {
|
|
23
23
|
$from,
|
|
24
24
|
$to
|
|
25
|
-
} = expandSelectionToBlockRange(preservedSelection
|
|
25
|
+
} = expandSelectionToBlockRange(preservedSelection);
|
|
26
26
|
const isNested = isNestedNode(preservedSelection, '');
|
|
27
27
|
const selectedParent = $from.parent;
|
|
28
28
|
let fragment = Fragment.empty;
|
|
@@ -29,23 +29,20 @@ const CopyLinkDropdownItemContent = ({
|
|
|
29
29
|
const {
|
|
30
30
|
preservedSelection,
|
|
31
31
|
defaultSelection,
|
|
32
|
-
menuTriggerBy
|
|
33
|
-
|
|
34
|
-
} = useSharedPluginStateWithSelector(api, ['blockControls', 'selection', 'core'], ({
|
|
32
|
+
menuTriggerBy
|
|
33
|
+
} = useSharedPluginStateWithSelector(api, ['blockControls', 'selection'], ({
|
|
35
34
|
blockControlsState,
|
|
36
|
-
selectionState
|
|
37
|
-
coreState
|
|
35
|
+
selectionState
|
|
38
36
|
}) => {
|
|
39
37
|
return {
|
|
40
38
|
menuTriggerBy: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy,
|
|
41
39
|
preservedSelection: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection,
|
|
42
|
-
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
43
|
-
schema: coreState === null || coreState === void 0 ? void 0 : coreState.schema
|
|
40
|
+
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
44
41
|
};
|
|
45
42
|
});
|
|
46
43
|
const selection = preservedSelection || defaultSelection;
|
|
47
44
|
const handleClick = useCallback(() => {
|
|
48
|
-
if (!selection
|
|
45
|
+
if (!selection) {
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
48
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
@@ -72,8 +69,7 @@ const CopyLinkDropdownItemContent = ({
|
|
|
72
69
|
copyLink({
|
|
73
70
|
getLinkPath,
|
|
74
71
|
blockLinkHashPrefix,
|
|
75
|
-
selection
|
|
76
|
-
schema
|
|
72
|
+
selection
|
|
77
73
|
}).then(success => {
|
|
78
74
|
if (success) {
|
|
79
75
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
@@ -86,7 +82,7 @@ const CopyLinkDropdownItemContent = ({
|
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
84
|
});
|
|
89
|
-
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged,
|
|
85
|
+
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, selection]);
|
|
90
86
|
|
|
91
87
|
// Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested or on empty line
|
|
92
88
|
if (!fg('platform_editor_adf_with_localid') || !!menuTriggerBy && isNestedNode(selection, menuTriggerBy) || selection !== null && selection !== void 0 && selection.empty) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import {
|
|
3
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
4
|
+
import { getBlockNodesInRange } from '../../editor-commands/transform-node-utils/utils';
|
|
4
5
|
import { getSortedSuggestedItems } from '../utils/suggested-items-rank';
|
|
5
6
|
export const useSuggestedItems = api => {
|
|
6
7
|
var _api$blockMenu;
|
|
@@ -28,16 +29,20 @@ export const useSuggestedItems = api => {
|
|
|
28
29
|
}
|
|
29
30
|
const {
|
|
30
31
|
range
|
|
31
|
-
} = expandSelectionToBlockRange(currentSelection
|
|
32
|
+
} = expandSelectionToBlockRange(currentSelection);
|
|
32
33
|
if (!range) {
|
|
33
34
|
return [];
|
|
34
35
|
}
|
|
35
36
|
const blockNodes = getBlockNodesInRange(range);
|
|
36
|
-
|
|
37
|
-
if (!singleNode) {
|
|
37
|
+
if (blockNodes.length === 0) {
|
|
38
38
|
return [];
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const firstNodeType = blockNodes[0].type.name;
|
|
41
|
+
const allSameType = blockNodes.every(node => node.type.name === firstNodeType);
|
|
42
|
+
if (!allSameType) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const nodeTypeName = firstNodeType;
|
|
41
46
|
const sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
42
47
|
return sortedKeys.map(key => menuItemsMap.get(key)).filter(item => item !== undefined);
|
|
43
48
|
}, [menuItemsMap, preservedSelection, selection]);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createBlockLinkHashValue, DEFAULT_BLOCK_LINK_HASH_PREFIX } from '@atlaskit/editor-common/block-menu';
|
|
2
2
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
-
import { expandSelectionToBlockRange } from '
|
|
4
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
5
5
|
export const copyLink = async ({
|
|
6
6
|
getLinkPath,
|
|
7
7
|
blockLinkHashPrefix = DEFAULT_BLOCK_LINK_HASH_PREFIX,
|
|
8
|
-
selection
|
|
9
|
-
schema
|
|
8
|
+
selection
|
|
10
9
|
}) => {
|
|
11
|
-
const blockRange = expandSelectionToBlockRange(selection
|
|
10
|
+
const blockRange = expandSelectionToBlockRange(selection);
|
|
12
11
|
if (!blockRange) {
|
|
13
12
|
return false;
|
|
14
13
|
}
|
|
@@ -99,11 +99,6 @@ export const TRANSFORM_SUGGESTED_ITEMS_RANK = {
|
|
|
99
99
|
[TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key]: 100,
|
|
100
100
|
[TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key]: 200,
|
|
101
101
|
[TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key]: 300
|
|
102
|
-
},
|
|
103
|
-
[BLOCK_MENU_NODE_TYPES.BODIED_EXTENSION]: {
|
|
104
|
-
[TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key]: 100,
|
|
105
|
-
[TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key]: 200,
|
|
106
|
-
[TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key]: 300
|
|
107
102
|
}
|
|
108
103
|
};
|
|
109
104
|
export const getSuggestedItemsForNodeType = nodeType => {
|
|
@@ -128,7 +128,8 @@ var TRANSFORM_STEPS_OVERRIDE = {
|
|
|
128
128
|
decisionList: {
|
|
129
129
|
bulletList: [decisionListToListStep],
|
|
130
130
|
orderedList: [decisionListToListStep],
|
|
131
|
-
taskList: [decisionListToListStep]
|
|
131
|
+
taskList: [decisionListToListStep],
|
|
132
|
+
layoutSection: [wrapIntoLayoutStep]
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
135
|
var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
2
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
|
-
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
6
4
|
export var getSelectedNode = function getSelectedNode(selection) {
|
|
7
5
|
if (selection instanceof NodeSelection) {
|
|
8
6
|
return {
|
|
@@ -51,56 +49,6 @@ export var getTargetNodeTypeNameInContext = function getTargetNodeTypeNameInCont
|
|
|
51
49
|
}
|
|
52
50
|
return nodeTypeName;
|
|
53
51
|
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
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
|
|
58
|
-
* @param selection
|
|
59
|
-
* @param schema
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
export var expandSelectionToBlockRange = function expandSelectionToBlockRange(selection, schema) {
|
|
63
|
-
var nodes = schema.nodes;
|
|
64
|
-
var nodesNeedToExpandRange = [nodes.bulletList, nodes.orderedList, nodes.taskList, 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
|
-
range: $from.blockRange($to)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// when selecting a file, selection is on media
|
|
83
|
-
// need to find media group and return its pos
|
|
84
|
-
if (selection instanceof NodeSelection) {
|
|
85
|
-
if (selection.node.type === nodes.media) {
|
|
86
|
-
var mediaGroup = findParentNodeOfType(nodes.mediaGroup)(selection);
|
|
87
|
-
if (mediaGroup) {
|
|
88
|
-
var _$from = selection.$from.doc.resolve(mediaGroup.pos);
|
|
89
|
-
var _$to = selection.$from.doc.resolve(mediaGroup.pos + mediaGroup.node.nodeSize);
|
|
90
|
-
return {
|
|
91
|
-
$from: _$from,
|
|
92
|
-
$to: _$to
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return expandToBlockRange(selection.$from, selection.$to, function (node) {
|
|
98
|
-
if (nodesNeedToExpandRange.includes(node.type)) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return true;
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
52
|
export var isListType = function isListType(node, schema) {
|
|
105
53
|
var lists = [schema.nodes.taskList, schema.nodes.bulletList, schema.nodes.orderedList];
|
|
106
54
|
return lists.some(function (list) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
4
5
|
import { getOutputNodes } from './transform-node-utils/transform';
|
|
5
|
-
import { expandSelectionToBlockRange } from './transform-node-utils/utils';
|
|
6
6
|
import { isListNode } from './transforms/utils';
|
|
7
7
|
export var transformNode = function transformNode(api) {
|
|
8
8
|
return (
|
|
@@ -17,7 +17,7 @@ export var transformNode = function transformNode(api) {
|
|
|
17
17
|
}
|
|
18
18
|
var schema = tr.doc.type.schema;
|
|
19
19
|
var nodes = schema.nodes;
|
|
20
|
-
var _expandSelectionToBlo = expandSelectionToBlockRange(preservedSelection
|
|
20
|
+
var _expandSelectionToBlo = expandSelectionToBlockRange(preservedSelection),
|
|
21
21
|
$from = _expandSelectionToBlo.$from,
|
|
22
22
|
$to = _expandSelectionToBlo.$to;
|
|
23
23
|
var isNested = isNestedNode(preservedSelection, '');
|
package/dist/esm/ui/copy-link.js
CHANGED
|
@@ -22,24 +22,21 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
22
22
|
var _ref2 = config || {},
|
|
23
23
|
getLinkPath = _ref2.getLinkPath,
|
|
24
24
|
blockLinkHashPrefix = _ref2.blockLinkHashPrefix;
|
|
25
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'selection'
|
|
25
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'selection'], function (_ref3) {
|
|
26
26
|
var blockControlsState = _ref3.blockControlsState,
|
|
27
|
-
selectionState = _ref3.selectionState
|
|
28
|
-
coreState = _ref3.coreState;
|
|
27
|
+
selectionState = _ref3.selectionState;
|
|
29
28
|
return {
|
|
30
29
|
menuTriggerBy: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.menuTriggerBy,
|
|
31
30
|
preservedSelection: blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection,
|
|
32
|
-
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
33
|
-
schema: coreState === null || coreState === void 0 ? void 0 : coreState.schema
|
|
31
|
+
defaultSelection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
34
32
|
};
|
|
35
33
|
}),
|
|
36
34
|
preservedSelection = _useSharedPluginState.preservedSelection,
|
|
37
35
|
defaultSelection = _useSharedPluginState.defaultSelection,
|
|
38
|
-
menuTriggerBy = _useSharedPluginState.menuTriggerBy
|
|
39
|
-
schema = _useSharedPluginState.schema;
|
|
36
|
+
menuTriggerBy = _useSharedPluginState.menuTriggerBy;
|
|
40
37
|
var selection = preservedSelection || defaultSelection;
|
|
41
38
|
var handleClick = useCallback(function () {
|
|
42
|
-
if (!selection
|
|
39
|
+
if (!selection) {
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
45
42
|
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
@@ -65,8 +62,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
65
62
|
copyLink({
|
|
66
63
|
getLinkPath: getLinkPath,
|
|
67
64
|
blockLinkHashPrefix: blockLinkHashPrefix,
|
|
68
|
-
selection: selection
|
|
69
|
-
schema: schema
|
|
65
|
+
selection: selection
|
|
70
66
|
}).then(function (success) {
|
|
71
67
|
if (success) {
|
|
72
68
|
api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
|
|
@@ -78,7 +74,7 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
|
|
|
78
74
|
});
|
|
79
75
|
}
|
|
80
76
|
});
|
|
81
|
-
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged,
|
|
77
|
+
}, [api, blockLinkHashPrefix, getLinkPath, onDropdownOpenChanged, selection]);
|
|
82
78
|
|
|
83
79
|
// Hide copy link when `platform_editor_adf_with_localid` feature flag is off or when the node is nested or on empty line
|
|
84
80
|
if (!fg('platform_editor_adf_with_localid') || !!menuTriggerBy && isNestedNode(selection, menuTriggerBy) || selection !== null && selection !== void 0 && selection.empty) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import {
|
|
3
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
4
|
+
import { getBlockNodesInRange } from '../../editor-commands/transform-node-utils/utils';
|
|
4
5
|
import { getSortedSuggestedItems } from '../utils/suggested-items-rank';
|
|
5
6
|
export var useSuggestedItems = function useSuggestedItems(api) {
|
|
6
7
|
var _api$blockMenu;
|
|
@@ -29,17 +30,23 @@ export var useSuggestedItems = function useSuggestedItems(api) {
|
|
|
29
30
|
if (menuItemsMap.size === 0 || !currentSelection) {
|
|
30
31
|
return [];
|
|
31
32
|
}
|
|
32
|
-
var _expandSelectionToBlo = expandSelectionToBlockRange(currentSelection
|
|
33
|
+
var _expandSelectionToBlo = expandSelectionToBlockRange(currentSelection),
|
|
33
34
|
range = _expandSelectionToBlo.range;
|
|
34
35
|
if (!range) {
|
|
35
36
|
return [];
|
|
36
37
|
}
|
|
37
38
|
var blockNodes = getBlockNodesInRange(range);
|
|
38
|
-
|
|
39
|
-
if (!singleNode) {
|
|
39
|
+
if (blockNodes.length === 0) {
|
|
40
40
|
return [];
|
|
41
41
|
}
|
|
42
|
-
var
|
|
42
|
+
var firstNodeType = blockNodes[0].type.name;
|
|
43
|
+
var allSameType = blockNodes.every(function (node) {
|
|
44
|
+
return node.type.name === firstNodeType;
|
|
45
|
+
});
|
|
46
|
+
if (!allSameType) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
var nodeTypeName = firstNodeType;
|
|
43
50
|
var sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
44
51
|
return sortedKeys.map(function (key) {
|
|
45
52
|
return menuItemsMap.get(key);
|
|
@@ -3,15 +3,15 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import { createBlockLinkHashValue, DEFAULT_BLOCK_LINK_HASH_PREFIX } from '@atlaskit/editor-common/block-menu';
|
|
4
4
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
5
5
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
|
-
import { expandSelectionToBlockRange } from '
|
|
6
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
7
7
|
export var copyLink = /*#__PURE__*/function () {
|
|
8
8
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
9
|
-
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection,
|
|
9
|
+
var getLinkPath, _ref$blockLinkHashPre, blockLinkHashPrefix, selection, blockRange, node, path, url, href;
|
|
10
10
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
13
|
-
getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection
|
|
14
|
-
blockRange = expandSelectionToBlockRange(selection
|
|
13
|
+
getLinkPath = _ref.getLinkPath, _ref$blockLinkHashPre = _ref.blockLinkHashPrefix, blockLinkHashPrefix = _ref$blockLinkHashPre === void 0 ? DEFAULT_BLOCK_LINK_HASH_PREFIX : _ref$blockLinkHashPre, selection = _ref.selection;
|
|
14
|
+
blockRange = expandSelectionToBlockRange(selection);
|
|
15
15
|
if (blockRange) {
|
|
16
16
|
_context.next = 4;
|
|
17
17
|
break;
|
|
@@ -37,7 +37,7 @@ export var BLOCK_MENU_NODE_TYPES = {
|
|
|
37
37
|
EMBED_CARD: 'embedCard',
|
|
38
38
|
TABLE: 'table'
|
|
39
39
|
};
|
|
40
|
-
export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(
|
|
40
|
+
export var TRANSFORM_SUGGESTED_ITEMS_RANK = (_TRANSFORM_SUGGESTED_ = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.PARAGRAPH, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_HEADINGS_H1_MENU_ITEM.key, 200), TRANSFORM_HEADINGS_H2_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXPAND, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BLOCKQUOTE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.LAYOUT_SECTION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.PANEL, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.CODE_BLOCK, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.DECISION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.BULLET_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.ORDERED_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.HEADING, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PARAGRAPH_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), _defineProperty(_defineProperty(_defineProperty(_TRANSFORM_SUGGESTED_, BLOCK_MENU_NODE_TYPES.TASK_LIST, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_NUMBERED_LIST_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_BULLETED_LIST_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.MEDIA_SINGLE, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_QUOTE_MENU_ITEM.key, 300)), BLOCK_MENU_NODE_TYPES.EXTENSION, _defineProperty(_defineProperty(_defineProperty({}, TRANSFORM_STRUCTURE_EXPAND_MENU_ITEM.key, 100), TRANSFORM_STRUCTURE_PANEL_MENU_ITEM.key, 200), TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM.key, 300)));
|
|
41
41
|
export var getSuggestedItemsForNodeType = function getSuggestedItemsForNodeType(nodeType) {
|
|
42
42
|
return TRANSFORM_SUGGESTED_ITEMS_RANK[nodeType];
|
|
43
43
|
};
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
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
|
-
/**
|
|
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
|
-
* @param selection
|
|
11
|
-
* @param schema
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
|
|
15
|
-
$from: import("prosemirror-model").ResolvedPos;
|
|
16
|
-
$to: import("prosemirror-model").ResolvedPos;
|
|
17
|
-
range: NodeRange | null;
|
|
18
|
-
} | {
|
|
19
|
-
$from: import("prosemirror-model").ResolvedPos;
|
|
20
|
-
$to: import("prosemirror-model").ResolvedPos;
|
|
21
|
-
range?: undefined;
|
|
22
|
-
};
|
|
23
7
|
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
24
8
|
/**
|
|
25
9
|
* Converts a nestedExpand to a regular expand node.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
1
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
type CopyLinkOptions = {
|
|
4
3
|
blockLinkHashPrefix?: string;
|
|
5
4
|
getLinkPath?: () => string | null;
|
|
6
|
-
schema: Schema;
|
|
7
5
|
selection: Selection;
|
|
8
6
|
};
|
|
9
|
-
export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection,
|
|
7
|
+
export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection, }: CopyLinkOptions) => Promise<boolean>;
|
|
10
8
|
export {};
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
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
|
-
/**
|
|
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
|
-
* @param selection
|
|
11
|
-
* @param schema
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare const expandSelectionToBlockRange: (selection: Selection, schema: Schema) => {
|
|
15
|
-
$from: import("prosemirror-model").ResolvedPos;
|
|
16
|
-
$to: import("prosemirror-model").ResolvedPos;
|
|
17
|
-
range: NodeRange | null;
|
|
18
|
-
} | {
|
|
19
|
-
$from: import("prosemirror-model").ResolvedPos;
|
|
20
|
-
$to: import("prosemirror-model").ResolvedPos;
|
|
21
|
-
range?: undefined;
|
|
22
|
-
};
|
|
23
7
|
export declare const isListType: (node: PMNode, schema: Schema) => boolean;
|
|
24
8
|
/**
|
|
25
9
|
* Converts a nestedExpand to a regular expand node.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
1
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
type CopyLinkOptions = {
|
|
4
3
|
blockLinkHashPrefix?: string;
|
|
5
4
|
getLinkPath?: () => string | null;
|
|
6
|
-
schema: Schema;
|
|
7
5
|
selection: Selection;
|
|
8
6
|
};
|
|
9
|
-
export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection,
|
|
7
|
+
export declare const copyLink: ({ getLinkPath, blockLinkHashPrefix, selection, }: CopyLinkOptions) => Promise<boolean>;
|
|
10
8
|
export {};
|