@atlaskit/editor-plugin-block-controls 11.2.15 → 11.2.16
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 +11 -0
- package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +10 -0
- package/dist/cjs/pm-plugins/utils/getSelection.js +21 -1
- package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +10 -0
- package/dist/es2019/pm-plugins/utils/getSelection.js +21 -1
- package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +10 -0
- package/dist/esm/pm-plugins/utils/getSelection.js +21 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 11.2.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`38fb4916b9085`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38fb4916b9085) -
|
|
8
|
+
Add `@atlaskit/editor-common/node-selection` entry-point with platform-level node selection
|
|
9
|
+
utilities. Under `platform_editor_maui_jira_updates`, `open-remix-modal` and
|
|
10
|
+
`editor-plugin-block-controls` delegate to these utilities, fixing remix selection in environments
|
|
11
|
+
where `blockControls` is not present.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 11.2.15
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.expandAndUpdateSelection = void 0;
|
|
7
|
+
var _nodeSelection = require("@atlaskit/editor-common/node-selection");
|
|
7
8
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
|
+
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
8
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
14
|
var _getSelection = require("./getSelection");
|
|
11
15
|
var _selection2 = require("./selection");
|
|
12
16
|
var isPosWithinRange = function isPosWithinRange(pos, range) {
|
|
@@ -60,6 +64,12 @@ var expandAndUpdateSelection = exports.expandAndUpdateSelection = function expan
|
|
|
60
64
|
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && (0, _selection.isMultiBlockRange)(expandedRange.range)) {
|
|
61
65
|
// Then create a selection from the start of the first node to the end of the last node
|
|
62
66
|
tr.setSelection(_state.TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
|
|
67
|
+
} else if (
|
|
68
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
69
|
+
(0, _platformFeatureFlags.fg)('platform_editor_maui_jira_updates') && ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0, _experiments.editorExperiment)('platform_editor_block_menu', true))) {
|
|
70
|
+
// Under the gate (and when on the simplified newGetSelection path), use
|
|
71
|
+
// the platform-level composer — same path as open-remix-modal, no drift.
|
|
72
|
+
(0, _nodeSelection.selectNodeAtPos)(tr, startPos, nodeType);
|
|
63
73
|
} else if (nodeType === 'table') {
|
|
64
74
|
(0, _utils.selectTableClosestToPos)(tr, tr.doc.resolve(startPos + 1));
|
|
65
75
|
} else {
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setCursorPositionAtMovedNode = exports.selectNode = exports.rootTaskListDepth = exports.rootListDepth = exports.newGetSelection = exports.isNodeWithCodeBlock = exports.isHandleCorrelatedToSelection = exports.getSelection = exports.getInlineNodePos = void 0;
|
|
7
|
+
var _nodeSelection = require("@atlaskit/editor-common/node-selection");
|
|
7
8
|
var _selection2 = require("@atlaskit/editor-common/selection");
|
|
8
9
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
9
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
12
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
15
|
var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
|
|
14
16
|
var $startPos = doc.resolve(start);
|
|
@@ -91,6 +93,16 @@ var oldGetSelection = function oldGetSelection(tr, start) {
|
|
|
91
93
|
* @returns The appropriate selection for the node.
|
|
92
94
|
*/
|
|
93
95
|
var newGetSelection = exports.newGetSelection = function newGetSelection(doc, selectionEmpty, start) {
|
|
96
|
+
// Under the gate, delegate to getNodeSelectionForPos only when
|
|
97
|
+
// platform_editor_block_menu is on — getNodeSelectionForPos matches that
|
|
98
|
+
// simplified path (NodeSelection for all nodes). When block_menu is off,
|
|
99
|
+
// fall through to the oldGetSelection branch which handles expand/taskList/
|
|
100
|
+
// inline nodes correctly with TextSelection.
|
|
101
|
+
if (
|
|
102
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
103
|
+
(0, _platformFeatureFlags.fg)('platform_editor_maui_jira_updates') && (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
104
|
+
return (0, _nodeSelection.getNodeSelectionForPos)(doc, start) || false;
|
|
105
|
+
}
|
|
94
106
|
var node = doc.nodeAt(start);
|
|
95
107
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
96
108
|
var nodeSize = node ? node.nodeSize : 1;
|
|
@@ -136,7 +148,15 @@ var getSelection = exports.getSelection = function getSelection(tr, start, api)
|
|
|
136
148
|
return oldGetSelection(tr, start);
|
|
137
149
|
};
|
|
138
150
|
var selectNode = exports.selectNode = function selectNode(tr, start, nodeType, api) {
|
|
139
|
-
//
|
|
151
|
+
// Only use the platform path when already on the simplified newGetSelection
|
|
152
|
+
// branch — i.e. when platform_editor_block_menu is on or toolbar flags are
|
|
153
|
+
// enabled. This preserves oldGetSelection behaviour (e.g. taskList →
|
|
154
|
+
// TextSelection) in legacy contexts where those flags are off.
|
|
155
|
+
if (
|
|
156
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
157
|
+
(0, _platformFeatureFlags.fg)('platform_editor_maui_jira_updates') && (0, _experiments.editorExperiment)('platform_editor_block_menu', true)) {
|
|
158
|
+
return (0, _nodeSelection.selectNodeAtPos)(tr, start, nodeType);
|
|
159
|
+
}
|
|
140
160
|
if (nodeType === 'table') {
|
|
141
161
|
tr = (0, _utils2.selectTableClosestToPos)(tr, tr.doc.resolve(start + 1));
|
|
142
162
|
return tr;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
|
|
1
2
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
2
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
5
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
8
|
import { selectNode } from './getSelection';
|
|
5
9
|
import { adjustSelectionBoundsForEdgePositions } from './selection';
|
|
6
10
|
const isPosWithinRange = (pos, range) => {
|
|
@@ -56,6 +60,12 @@ export const expandAndUpdateSelection = ({
|
|
|
56
60
|
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiBlockRange(expandedRange.range)) {
|
|
57
61
|
// Then create a selection from the start of the first node to the end of the last node
|
|
58
62
|
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
|
|
63
|
+
} else if (
|
|
64
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
65
|
+
fg('platform_editor_maui_jira_updates') && (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true))) {
|
|
66
|
+
// Under the gate (and when on the simplified newGetSelection path), use
|
|
67
|
+
// the platform-level composer — same path as open-remix-modal, no drift.
|
|
68
|
+
selectNodeAtPos(tr, startPos, nodeType);
|
|
59
69
|
} else if (nodeType === 'table') {
|
|
60
70
|
selectTableClosestToPos(tr, tr.doc.resolve(startPos + 1));
|
|
61
71
|
} else {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { getNodeSelectionForPos, selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
|
|
1
2
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
3
4
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
export const getInlineNodePos = (doc, start, nodeSize) => {
|
|
8
10
|
const $startPos = doc.resolve(start);
|
|
@@ -86,6 +88,16 @@ const oldGetSelection = (tr, start) => {
|
|
|
86
88
|
* @returns The appropriate selection for the node.
|
|
87
89
|
*/
|
|
88
90
|
export const newGetSelection = (doc, selectionEmpty, start) => {
|
|
91
|
+
// Under the gate, delegate to getNodeSelectionForPos only when
|
|
92
|
+
// platform_editor_block_menu is on — getNodeSelectionForPos matches that
|
|
93
|
+
// simplified path (NodeSelection for all nodes). When block_menu is off,
|
|
94
|
+
// fall through to the oldGetSelection branch which handles expand/taskList/
|
|
95
|
+
// inline nodes correctly with TextSelection.
|
|
96
|
+
if (
|
|
97
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
98
|
+
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
99
|
+
return getNodeSelectionForPos(doc, start) || false;
|
|
100
|
+
}
|
|
89
101
|
const node = doc.nodeAt(start);
|
|
90
102
|
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
91
103
|
const nodeSize = node ? node.nodeSize : 1;
|
|
@@ -132,7 +144,15 @@ export const getSelection = (tr, start, api) => {
|
|
|
132
144
|
return oldGetSelection(tr, start);
|
|
133
145
|
};
|
|
134
146
|
export const selectNode = (tr, start, nodeType, api) => {
|
|
135
|
-
//
|
|
147
|
+
// Only use the platform path when already on the simplified newGetSelection
|
|
148
|
+
// branch — i.e. when platform_editor_block_menu is on or toolbar flags are
|
|
149
|
+
// enabled. This preserves oldGetSelection behaviour (e.g. taskList →
|
|
150
|
+
// TextSelection) in legacy contexts where those flags are off.
|
|
151
|
+
if (
|
|
152
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
153
|
+
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
154
|
+
return selectNodeAtPos(tr, start, nodeType);
|
|
155
|
+
}
|
|
136
156
|
if (nodeType === 'table') {
|
|
137
157
|
tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
|
|
138
158
|
return tr;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
|
|
1
2
|
import { expandToBlockRange, isMultiBlockRange } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
2
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
5
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
8
|
import { selectNode } from './getSelection';
|
|
5
9
|
import { adjustSelectionBoundsForEdgePositions } from './selection';
|
|
6
10
|
var isPosWithinRange = function isPosWithinRange(pos, range) {
|
|
@@ -54,6 +58,12 @@ export var expandAndUpdateSelection = function expandAndUpdateSelection(_ref2) {
|
|
|
54
58
|
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiBlockRange(expandedRange.range)) {
|
|
55
59
|
// Then create a selection from the start of the first node to the end of the last node
|
|
56
60
|
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
|
|
61
|
+
} else if (
|
|
62
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
63
|
+
fg('platform_editor_maui_jira_updates') && (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || editorExperiment('platform_editor_block_menu', true))) {
|
|
64
|
+
// Under the gate (and when on the simplified newGetSelection path), use
|
|
65
|
+
// the platform-level composer — same path as open-remix-modal, no drift.
|
|
66
|
+
selectNodeAtPos(tr, startPos, nodeType);
|
|
57
67
|
} else if (nodeType === 'table') {
|
|
58
68
|
selectTableClosestToPos(tr, tr.doc.resolve(startPos + 1));
|
|
59
69
|
} else {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { getNodeSelectionForPos, selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
|
|
1
2
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
2
3
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
3
4
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
export var getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
|
|
8
10
|
var $startPos = doc.resolve(start);
|
|
@@ -85,6 +87,16 @@ var oldGetSelection = function oldGetSelection(tr, start) {
|
|
|
85
87
|
* @returns The appropriate selection for the node.
|
|
86
88
|
*/
|
|
87
89
|
export var newGetSelection = function newGetSelection(doc, selectionEmpty, start) {
|
|
90
|
+
// Under the gate, delegate to getNodeSelectionForPos only when
|
|
91
|
+
// platform_editor_block_menu is on — getNodeSelectionForPos matches that
|
|
92
|
+
// simplified path (NodeSelection for all nodes). When block_menu is off,
|
|
93
|
+
// fall through to the oldGetSelection branch which handles expand/taskList/
|
|
94
|
+
// inline nodes correctly with TextSelection.
|
|
95
|
+
if (
|
|
96
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
97
|
+
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
98
|
+
return getNodeSelectionForPos(doc, start) || false;
|
|
99
|
+
}
|
|
88
100
|
var node = doc.nodeAt(start);
|
|
89
101
|
var isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
90
102
|
var nodeSize = node ? node.nodeSize : 1;
|
|
@@ -130,7 +142,15 @@ export var getSelection = function getSelection(tr, start, api) {
|
|
|
130
142
|
return oldGetSelection(tr, start);
|
|
131
143
|
};
|
|
132
144
|
export var selectNode = function selectNode(tr, start, nodeType, api) {
|
|
133
|
-
//
|
|
145
|
+
// Only use the platform path when already on the simplified newGetSelection
|
|
146
|
+
// branch — i.e. when platform_editor_block_menu is on or toolbar flags are
|
|
147
|
+
// enabled. This preserves oldGetSelection behaviour (e.g. taskList →
|
|
148
|
+
// TextSelection) in legacy contexts where those flags are off.
|
|
149
|
+
if (
|
|
150
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
151
|
+
fg('platform_editor_maui_jira_updates') && editorExperiment('platform_editor_block_menu', true)) {
|
|
152
|
+
return selectNodeAtPos(tr, start, nodeType);
|
|
153
|
+
}
|
|
134
154
|
if (nodeType === 'table') {
|
|
135
155
|
tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
|
|
136
156
|
return tr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.16",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^19.0.0",
|
|
58
58
|
"@atlaskit/theme": "^23.2.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^77.
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^77.2.0",
|
|
60
60
|
"@atlaskit/tokens": "^13.0.0",
|
|
61
61
|
"@atlaskit/tooltip": "^22.0.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"uuid": "^3.1.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@atlaskit/editor-common": "^114.
|
|
70
|
+
"@atlaskit/editor-common": "^114.26.0",
|
|
71
71
|
"react": "^18.2.0",
|
|
72
72
|
"react-dom": "^18.2.0",
|
|
73
73
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -132,6 +132,9 @@
|
|
|
132
132
|
"platform_editor_content_mode_button_mvp": {
|
|
133
133
|
"type": "boolean"
|
|
134
134
|
},
|
|
135
|
+
"platform_editor_maui_jira_updates": {
|
|
136
|
+
"type": "boolean"
|
|
137
|
+
},
|
|
135
138
|
"platform_editor_table_sticky_header_patch_6": {
|
|
136
139
|
"type": "boolean"
|
|
137
140
|
},
|