@atlaskit/editor-plugin-block-controls 3.9.1 → 3.9.2
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/pm-plugins/utils/getSelection.js +59 -9
- package/dist/cjs/ui/global-styles.js +2 -1
- package/dist/es2019/pm-plugins/utils/getSelection.js +59 -8
- package/dist/es2019/ui/global-styles.js +2 -1
- package/dist/esm/pm-plugins/utils/getSelection.js +57 -7
- package/dist/esm/ui/global-styles.js +2 -1
- package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/getSelection.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#139175](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139175)
|
|
8
|
+
[`6274734c42470`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6274734c42470) -
|
|
9
|
+
Allow drag handle to display for empty lines when platform_editor_controls is enabled
|
|
10
|
+
|
|
3
11
|
## 3.9.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setCursorPositionAtMovedNode = exports.selectNode = exports.rootTaskListDepth = exports.rootListDepth = exports.isHandleCorrelatedToSelection = exports.getSelection = exports.getInlineNodePos = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _selection2 = 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 _utils2 = require("@atlaskit/editor-tables/utils");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
|
|
13
14
|
var $startPos = tr.doc.resolve(start);
|
|
14
15
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -51,7 +52,7 @@ var isNodeWithMediaOrExtension = function isNodeWithMediaOrExtension(tr, start,
|
|
|
51
52
|
});
|
|
52
53
|
return hasMediaOrExtension;
|
|
53
54
|
};
|
|
54
|
-
var
|
|
55
|
+
var oldGetSelection = function oldGetSelection(tr, start) {
|
|
55
56
|
var node = tr.doc.nodeAt(start);
|
|
56
57
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
57
58
|
var nodeSize = node ? node.nodeSize : 1;
|
|
@@ -81,12 +82,53 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
|
81
82
|
return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
82
83
|
}
|
|
83
84
|
};
|
|
85
|
+
var newGetSelection = function newGetSelection(tr, start) {
|
|
86
|
+
var node = tr.doc.nodeAt(start);
|
|
87
|
+
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
88
|
+
var nodeSize = node ? node.nodeSize : 1;
|
|
89
|
+
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
90
|
+
|
|
91
|
+
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
92
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
|
|
96
|
+
var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
97
|
+
var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
98
|
+
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension && (0, _platformFeatureFlags.fg)('platform_editor_non_macros_copy_and_paste_fix') || ((0, _platformFeatureFlags.fg)('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
|
|
99
|
+
// decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
|
|
100
|
+
['decisionList', 'layoutColumn'].includes(nodeName || '') || nodeName === 'mediaGroup' && typeof (node === null || node === void 0 ? void 0 : node.childCount) === 'number' && (node === null || node === void 0 ? void 0 : node.childCount) > 1) {
|
|
101
|
+
return new _state.NodeSelection(tr.doc.resolve(start));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// if mediaGroup only has a single child, we want to select the child
|
|
105
|
+
if (nodeName === 'mediaGroup') {
|
|
106
|
+
var $mediaStartPos = tr.doc.resolve(start + 1);
|
|
107
|
+
return new _state.NodeSelection($mediaStartPos);
|
|
108
|
+
}
|
|
109
|
+
if (nodeName === 'taskList' && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
110
|
+
return _state.TextSelection.create(tr.doc, start, start + nodeSize);
|
|
111
|
+
}
|
|
112
|
+
var _getInlineNodePos2 = getInlineNodePos(tr, start, nodeSize),
|
|
113
|
+
inlineNodePos = _getInlineNodePos2.inlineNodePos,
|
|
114
|
+
inlineNodeEndPos = _getInlineNodePos2.inlineNodeEndPos;
|
|
115
|
+
return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
116
|
+
};
|
|
117
|
+
var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
118
|
+
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_widget_visibility')) {
|
|
119
|
+
return newGetSelection(tr, start);
|
|
120
|
+
}
|
|
121
|
+
return oldGetSelection(tr, start);
|
|
122
|
+
};
|
|
84
123
|
var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
|
|
85
124
|
// For table, we need to do cell selection instead of node selection
|
|
86
125
|
if (nodeType === 'table') {
|
|
87
126
|
tr = (0, _utils2.selectTableClosestToPos)(tr, tr.doc.resolve(start + 1));
|
|
88
|
-
|
|
89
|
-
|
|
127
|
+
return tr;
|
|
128
|
+
}
|
|
129
|
+
var selection = getSelection(tr, start);
|
|
130
|
+
if (selection) {
|
|
131
|
+
tr.setSelection(selection);
|
|
90
132
|
}
|
|
91
133
|
return tr;
|
|
92
134
|
};
|
|
@@ -98,12 +140,20 @@ var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = functi
|
|
|
98
140
|
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
99
141
|
// blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
|
|
100
142
|
if (isNodeSelection && node.type.name !== 'blockquote' || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
101
|
-
selection = new
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
143
|
+
selection = new _selection2.GapCursorSelection(tr.doc.resolve(start + node.nodeSize), _selection2.Side.RIGHT);
|
|
144
|
+
tr.setSelection(selection);
|
|
145
|
+
return tr;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
|
|
149
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_widget_visibility')) {
|
|
150
|
+
var _selection = new _state.TextSelection(tr.doc.resolve(start));
|
|
151
|
+
tr.setSelection(_selection);
|
|
152
|
+
return tr;
|
|
106
153
|
}
|
|
154
|
+
var _getInlineNodePos3 = getInlineNodePos(tr, start, nodeSize),
|
|
155
|
+
inlineNodeEndPos = _getInlineNodePos3.inlineNodeEndPos;
|
|
156
|
+
selection = new _state.TextSelection(tr.doc.resolve(inlineNodeEndPos));
|
|
107
157
|
tr.setSelection(selection);
|
|
108
158
|
return tr;
|
|
109
159
|
};
|
|
@@ -8,6 +8,7 @@ exports.GlobalStylesWrapper = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _consts = require("./consts");
|
|
13
14
|
/**
|
|
@@ -188,6 +189,6 @@ var blockCardWithoutLayout = (0, _react.css)({
|
|
|
188
189
|
});
|
|
189
190
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
190
191
|
return (0, _react.jsx)(_react.Global, {
|
|
191
|
-
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
192
|
+
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_widget_visibility') ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
192
193
|
});
|
|
193
194
|
};
|
|
@@ -3,6 +3,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
export const getInlineNodePos = (tr, start, nodeSize) => {
|
|
7
8
|
const $startPos = tr.doc.resolve(start);
|
|
8
9
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -45,7 +46,7 @@ const isNodeWithMediaOrExtension = (tr, start, nodeSize) => {
|
|
|
45
46
|
});
|
|
46
47
|
return hasMediaOrExtension;
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
+
const oldGetSelection = (tr, start) => {
|
|
49
50
|
const node = tr.doc.nodeAt(start);
|
|
50
51
|
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
51
52
|
const nodeSize = node ? node.nodeSize : 1;
|
|
@@ -76,12 +77,54 @@ export const getSelection = (tr, start) => {
|
|
|
76
77
|
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
77
78
|
}
|
|
78
79
|
};
|
|
80
|
+
const newGetSelection = (tr, start) => {
|
|
81
|
+
const node = tr.doc.nodeAt(start);
|
|
82
|
+
const isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
83
|
+
const nodeSize = node ? node.nodeSize : 1;
|
|
84
|
+
const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
85
|
+
|
|
86
|
+
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
87
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
|
|
91
|
+
const isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
92
|
+
const isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
93
|
+
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension && fg('platform_editor_non_macros_copy_and_paste_fix') || (fg('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
|
|
94
|
+
// decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
|
|
95
|
+
['decisionList', 'layoutColumn'].includes(nodeName || '') || nodeName === 'mediaGroup' && typeof (node === null || node === void 0 ? void 0 : node.childCount) === 'number' && (node === null || node === void 0 ? void 0 : node.childCount) > 1) {
|
|
96
|
+
return new NodeSelection(tr.doc.resolve(start));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// if mediaGroup only has a single child, we want to select the child
|
|
100
|
+
if (nodeName === 'mediaGroup') {
|
|
101
|
+
const $mediaStartPos = tr.doc.resolve(start + 1);
|
|
102
|
+
return new NodeSelection($mediaStartPos);
|
|
103
|
+
}
|
|
104
|
+
if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
105
|
+
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
106
|
+
}
|
|
107
|
+
const {
|
|
108
|
+
inlineNodePos,
|
|
109
|
+
inlineNodeEndPos
|
|
110
|
+
} = getInlineNodePos(tr, start, nodeSize);
|
|
111
|
+
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
112
|
+
};
|
|
113
|
+
export const getSelection = (tr, start) => {
|
|
114
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility')) {
|
|
115
|
+
return newGetSelection(tr, start);
|
|
116
|
+
}
|
|
117
|
+
return oldGetSelection(tr, start);
|
|
118
|
+
};
|
|
79
119
|
export const selectNode = (tr, start, nodeType) => {
|
|
80
120
|
// For table, we need to do cell selection instead of node selection
|
|
81
121
|
if (nodeType === 'table') {
|
|
82
122
|
tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
|
|
83
|
-
|
|
84
|
-
|
|
123
|
+
return tr;
|
|
124
|
+
}
|
|
125
|
+
const selection = getSelection(tr, start);
|
|
126
|
+
if (selection) {
|
|
127
|
+
tr.setSelection(selection);
|
|
85
128
|
}
|
|
86
129
|
return tr;
|
|
87
130
|
};
|
|
@@ -94,12 +137,20 @@ export const setCursorPositionAtMovedNode = (tr, start) => {
|
|
|
94
137
|
// blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
|
|
95
138
|
if (isNodeSelection && node.type.name !== 'blockquote' || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
96
139
|
selection = new GapCursorSelection(tr.doc.resolve(start + node.nodeSize), Side.RIGHT);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
140
|
+
tr.setSelection(selection);
|
|
141
|
+
return tr;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
|
|
145
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility')) {
|
|
146
|
+
const selection = new TextSelection(tr.doc.resolve(start));
|
|
147
|
+
tr.setSelection(selection);
|
|
148
|
+
return tr;
|
|
102
149
|
}
|
|
150
|
+
const {
|
|
151
|
+
inlineNodeEndPos
|
|
152
|
+
} = getInlineNodePos(tr, start, nodeSize);
|
|
153
|
+
selection = new TextSelection(tr.doc.resolve(inlineNodeEndPos));
|
|
103
154
|
tr.setSelection(selection);
|
|
104
155
|
return tr;
|
|
105
156
|
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
10
11
|
|
|
@@ -218,6 +219,6 @@ const blockCardWithoutLayout = css({
|
|
|
218
219
|
});
|
|
219
220
|
export const GlobalStylesWrapper = () => {
|
|
220
221
|
return jsx(Global, {
|
|
221
|
-
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
222
|
+
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility') ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
222
223
|
});
|
|
223
224
|
};
|
|
@@ -3,6 +3,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
3
3
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
export var getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
|
|
7
8
|
var $startPos = tr.doc.resolve(start);
|
|
8
9
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -45,7 +46,7 @@ var isNodeWithMediaOrExtension = function isNodeWithMediaOrExtension(tr, start,
|
|
|
45
46
|
});
|
|
46
47
|
return hasMediaOrExtension;
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
+
var oldGetSelection = function oldGetSelection(tr, start) {
|
|
49
50
|
var node = tr.doc.nodeAt(start);
|
|
50
51
|
var isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
51
52
|
var nodeSize = node ? node.nodeSize : 1;
|
|
@@ -75,12 +76,53 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
75
76
|
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
76
77
|
}
|
|
77
78
|
};
|
|
79
|
+
var newGetSelection = function newGetSelection(tr, start) {
|
|
80
|
+
var node = tr.doc.nodeAt(start);
|
|
81
|
+
var isNodeSelection = node && NodeSelection.isSelectable(node);
|
|
82
|
+
var nodeSize = node ? node.nodeSize : 1;
|
|
83
|
+
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
84
|
+
|
|
85
|
+
// this is a fix for empty paragraph selection - put first to avoid any extra work
|
|
86
|
+
if (nodeName === 'paragraph' && tr.selection.empty && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
|
|
90
|
+
var isBlockQuoteWithMediaOrExtension = nodeName === 'blockquote' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
91
|
+
var isListWithMediaOrExtension = nodeName === 'bulletList' && isNodeWithMediaOrExtension(tr, start, nodeSize) || nodeName === 'orderedList' && isNodeWithMediaOrExtension(tr, start, nodeSize);
|
|
92
|
+
if (isNodeSelection && nodeName !== 'blockquote' || isListWithMediaOrExtension && fg('platform_editor_non_macros_copy_and_paste_fix') || (fg('platform_editor_non_macros_copy_and_paste_fix') ? isBlockQuoteWithMediaOrExtension : isBlockQuoteWithMedia) ||
|
|
93
|
+
// decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
|
|
94
|
+
['decisionList', 'layoutColumn'].includes(nodeName || '') || nodeName === 'mediaGroup' && typeof (node === null || node === void 0 ? void 0 : node.childCount) === 'number' && (node === null || node === void 0 ? void 0 : node.childCount) > 1) {
|
|
95
|
+
return new NodeSelection(tr.doc.resolve(start));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// if mediaGroup only has a single child, we want to select the child
|
|
99
|
+
if (nodeName === 'mediaGroup') {
|
|
100
|
+
var $mediaStartPos = tr.doc.resolve(start + 1);
|
|
101
|
+
return new NodeSelection($mediaStartPos);
|
|
102
|
+
}
|
|
103
|
+
if (nodeName === 'taskList' && fg('platform_editor_elements_dnd_multi_select_patch_1')) {
|
|
104
|
+
return TextSelection.create(tr.doc, start, start + nodeSize);
|
|
105
|
+
}
|
|
106
|
+
var _getInlineNodePos2 = getInlineNodePos(tr, start, nodeSize),
|
|
107
|
+
inlineNodePos = _getInlineNodePos2.inlineNodePos,
|
|
108
|
+
inlineNodeEndPos = _getInlineNodePos2.inlineNodeEndPos;
|
|
109
|
+
return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
|
|
110
|
+
};
|
|
111
|
+
export var getSelection = function getSelection(tr, start) {
|
|
112
|
+
if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility')) {
|
|
113
|
+
return newGetSelection(tr, start);
|
|
114
|
+
}
|
|
115
|
+
return oldGetSelection(tr, start);
|
|
116
|
+
};
|
|
78
117
|
export var selectNode = function selectNode(tr, start, nodeType) {
|
|
79
118
|
// For table, we need to do cell selection instead of node selection
|
|
80
119
|
if (nodeType === 'table') {
|
|
81
120
|
tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
|
|
82
|
-
|
|
83
|
-
|
|
121
|
+
return tr;
|
|
122
|
+
}
|
|
123
|
+
var selection = getSelection(tr, start);
|
|
124
|
+
if (selection) {
|
|
125
|
+
tr.setSelection(selection);
|
|
84
126
|
}
|
|
85
127
|
return tr;
|
|
86
128
|
};
|
|
@@ -93,11 +135,19 @@ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(
|
|
|
93
135
|
// blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
|
|
94
136
|
if (isNodeSelection && node.type.name !== 'blockquote' || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
95
137
|
selection = new GapCursorSelection(tr.doc.resolve(start + node.nodeSize), Side.RIGHT);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
138
|
+
tr.setSelection(selection);
|
|
139
|
+
return tr;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
|
|
143
|
+
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility')) {
|
|
144
|
+
var _selection = new TextSelection(tr.doc.resolve(start));
|
|
145
|
+
tr.setSelection(_selection);
|
|
146
|
+
return tr;
|
|
100
147
|
}
|
|
148
|
+
var _getInlineNodePos3 = getInlineNodePos(tr, start, nodeSize),
|
|
149
|
+
inlineNodeEndPos = _getInlineNodePos3.inlineNodeEndPos;
|
|
150
|
+
selection = new TextSelection(tr.doc.resolve(inlineNodeEndPos));
|
|
101
151
|
tr.setSelection(selection);
|
|
102
152
|
return tr;
|
|
103
153
|
};
|
|
@@ -6,6 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
8
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
11
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
|
|
11
12
|
|
|
@@ -181,6 +182,6 @@ var blockCardWithoutLayout = css({
|
|
|
181
182
|
});
|
|
182
183
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
183
184
|
return jsx(Global, {
|
|
184
|
-
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
185
|
+
styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility') ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
|
|
185
186
|
});
|
|
186
187
|
};
|
|
@@ -4,7 +4,7 @@ export declare const getInlineNodePos: (tr: Transaction, start: number, nodeSize
|
|
|
4
4
|
inlineNodePos: number;
|
|
5
5
|
inlineNodeEndPos: number;
|
|
6
6
|
};
|
|
7
|
-
export declare const getSelection: (tr: Transaction, start: number) => NodeSelection | TextSelection;
|
|
7
|
+
export declare const getSelection: (tr: Transaction, start: number) => false | NodeSelection | TextSelection;
|
|
8
8
|
export declare const selectNode: (tr: Transaction, start: number, nodeType: string) => Transaction;
|
|
9
9
|
export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number) => Transaction;
|
|
10
10
|
/**
|
|
@@ -4,7 +4,7 @@ export declare const getInlineNodePos: (tr: Transaction, start: number, nodeSize
|
|
|
4
4
|
inlineNodePos: number;
|
|
5
5
|
inlineNodeEndPos: number;
|
|
6
6
|
};
|
|
7
|
-
export declare const getSelection: (tr: Transaction, start: number) => NodeSelection | TextSelection;
|
|
7
|
+
export declare const getSelection: (tr: Transaction, start: number) => false | NodeSelection | TextSelection;
|
|
8
8
|
export declare const selectNode: (tr: Transaction, start: number, nodeType: string) => Transaction;
|
|
9
9
|
export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number) => Transaction;
|
|
10
10
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.1.0",
|
|
54
54
|
"@atlaskit/primitives": "^14.4.0",
|
|
55
55
|
"@atlaskit/theme": "^18.0.0",
|
|
56
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
56
|
+
"@atlaskit/tmp-editor-statsig": "^4.7.0",
|
|
57
57
|
"@atlaskit/tokens": "^4.7.0",
|
|
58
58
|
"@atlaskit/tooltip": "^20.0.0",
|
|
59
59
|
"@babel/runtime": "^7.0.0",
|