@atlaskit/editor-core 187.44.4 → 187.44.6
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/plugins/floating-toolbar/ui/Dropdown.js +5 -3
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -1
- package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +5 -3
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +2 -1
- package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +5 -3
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +2 -1
- package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.44.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`21305ee6254`](https://bitbucket.org/atlassian/atlassian-frontend/commits/21305ee6254) - ED-19874 Align the dropdown with the floating toolbar if there is a single button in the toolbar
|
|
8
|
+
- [`f7f51be4eac`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f7f51be4eac) - [ux] ED-19784: Adjust logic in onCreateSelectionBetween logic to prevent premature selections on multi-line selections inside block nodes.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 187.44.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -28,7 +28,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
28
28
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
29
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
30
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
var dropdownExpandContainer = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: 0px
|
|
31
|
+
var dropdownExpandContainer = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin: 0px ", ";\n"])), "var(--ds-space-negative-050, -4px)");
|
|
32
32
|
var iconGroup = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n"])));
|
|
33
33
|
var CompositeIcon = function CompositeIcon(_ref) {
|
|
34
34
|
var icon = _ref.icon;
|
|
@@ -121,7 +121,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
121
121
|
buttonTestId = _this$props2.buttonTestId,
|
|
122
122
|
dropdownWidth = _this$props2.dropdownWidth,
|
|
123
123
|
editorView = _this$props2.editorView,
|
|
124
|
-
dropdownListId = _this$props2.dropdownListId
|
|
124
|
+
dropdownListId = _this$props2.dropdownListId,
|
|
125
|
+
alignDropdownWithToolbar = _this$props2.alignDropdownWithToolbar;
|
|
125
126
|
var trigger;
|
|
126
127
|
if (icon) {
|
|
127
128
|
var TriggerIcon = hideExpandIcon ? icon : (0, _react2.jsx)(CompositeIcon, {
|
|
@@ -175,7 +176,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
175
176
|
fitHeight: fitHeight + fitTolerance,
|
|
176
177
|
trigger: trigger,
|
|
177
178
|
editorView: editorView,
|
|
178
|
-
dropdownListId: dropdownListId
|
|
179
|
+
dropdownListId: dropdownListId,
|
|
180
|
+
alignDropdownWithParentElement: alignDropdownWithToolbar
|
|
179
181
|
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
180
182
|
hide: this.hide,
|
|
181
183
|
dispatchCommand: dispatchCommand
|
|
@@ -149,7 +149,8 @@ var ToolbarItems = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
149
149
|
buttonTestId: item.testId,
|
|
150
150
|
editorView: editorView,
|
|
151
151
|
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
152
|
-
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList")
|
|
152
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
|
|
153
|
+
alignDropdownWithToolbar: items.length === 1
|
|
153
154
|
});
|
|
154
155
|
case 'select':
|
|
155
156
|
if (item.selectType === 'list') {
|
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.onCreateSelectionBetween = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
function isNodeContentEmpty(maybeNode) {
|
|
9
|
+
return (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.content.size) === 0 || (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.textContent) === '';
|
|
10
|
+
}
|
|
8
11
|
function findEmptySelectableParentNodePosition($pos, isValidPosition) {
|
|
9
12
|
var doc = $pos.doc;
|
|
10
13
|
if ($pos.pos + 1 > doc.content.size) {
|
|
@@ -42,8 +45,7 @@ var checkPositionNode = function checkPositionNode($pos) {
|
|
|
42
45
|
if (maybeNode.isAtom) {
|
|
43
46
|
return true;
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
return isParentEmpty && _state.NodeSelection.isSelectable(maybeNode);
|
|
48
|
+
return isNodeContentEmpty(maybeNode) && _state.NodeSelection.isSelectable(maybeNode);
|
|
47
49
|
};
|
|
48
50
|
function findNextSelectionPosition(_ref) {
|
|
49
51
|
var $targetHead = _ref.$targetHead,
|
|
@@ -60,7 +62,7 @@ function findNextSelectionPosition(_ref) {
|
|
|
60
62
|
return null;
|
|
61
63
|
}
|
|
62
64
|
var onCreateSelectionBetween = function onCreateSelectionBetween(view, $anchor, $head) {
|
|
63
|
-
var _$head$parent;
|
|
65
|
+
var _$head$parent, _$head$parent2;
|
|
64
66
|
if ($anchor.pos === $head.pos) {
|
|
65
67
|
return null;
|
|
66
68
|
}
|
|
@@ -72,6 +74,11 @@ var onCreateSelectionBetween = function onCreateSelectionBetween(view, $anchor,
|
|
|
72
74
|
if ($head.depth === 1 && ((_$head$parent = $head.parent) === null || _$head$parent === void 0 ? void 0 : _$head$parent.type.name) === 'paragraph') {
|
|
73
75
|
return null;
|
|
74
76
|
}
|
|
77
|
+
|
|
78
|
+
// If head is at the beginning of a non-empty textblock, let ProseMirror handle the text selection
|
|
79
|
+
if ((_$head$parent2 = $head.parent) !== null && _$head$parent2 !== void 0 && _$head$parent2.isTextblock && !isNodeContentEmpty($head.parent) && $head.parentOffset === 0) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
75
82
|
var $nextHeadPosition = findNextSelectionPosition({
|
|
76
83
|
$targetHead: $head,
|
|
77
84
|
$anchor: $anchor,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.44.
|
|
9
|
+
var version = "187.44.6";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -8,7 +8,7 @@ import UiDropdown from '../../../ui/Dropdown';
|
|
|
8
8
|
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
9
9
|
import DropdownMenu, { itemSpacing, menuItemDimensions } from './DropdownMenu';
|
|
10
10
|
const dropdownExpandContainer = css`
|
|
11
|
-
margin: 0px -4px;
|
|
11
|
+
margin: 0px ${"var(--ds-space-negative-050, -4px)"};
|
|
12
12
|
`;
|
|
13
13
|
const iconGroup = css`
|
|
14
14
|
display: flex;
|
|
@@ -97,7 +97,8 @@ export default class Dropdown extends Component {
|
|
|
97
97
|
buttonTestId,
|
|
98
98
|
dropdownWidth,
|
|
99
99
|
editorView,
|
|
100
|
-
dropdownListId
|
|
100
|
+
dropdownListId,
|
|
101
|
+
alignDropdownWithToolbar
|
|
101
102
|
} = this.props;
|
|
102
103
|
let trigger;
|
|
103
104
|
if (icon) {
|
|
@@ -152,7 +153,8 @@ export default class Dropdown extends Component {
|
|
|
152
153
|
fitHeight: fitHeight + fitTolerance,
|
|
153
154
|
trigger: trigger,
|
|
154
155
|
editorView: editorView,
|
|
155
|
-
dropdownListId: dropdownListId
|
|
156
|
+
dropdownListId: dropdownListId,
|
|
157
|
+
alignDropdownWithParentElement: alignDropdownWithToolbar
|
|
156
158
|
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
157
159
|
hide: this.hide,
|
|
158
160
|
dispatchCommand
|
|
@@ -116,7 +116,8 @@ const ToolbarItems = /*#__PURE__*/React.memo(({
|
|
|
116
116
|
buttonTestId: item.testId,
|
|
117
117
|
editorView: editorView,
|
|
118
118
|
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
119
|
-
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList
|
|
119
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && `${item.id}-dropdownList`,
|
|
120
|
+
alignDropdownWithToolbar: items.length === 1
|
|
120
121
|
});
|
|
121
122
|
case 'select':
|
|
122
123
|
if (item.selectType === 'list') {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
function isNodeContentEmpty(maybeNode) {
|
|
3
|
+
return (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.content.size) === 0 || (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.textContent) === '';
|
|
4
|
+
}
|
|
2
5
|
function findEmptySelectableParentNodePosition($pos, isValidPosition) {
|
|
3
6
|
const {
|
|
4
7
|
doc
|
|
@@ -38,8 +41,7 @@ const checkPositionNode = $pos => {
|
|
|
38
41
|
if (maybeNode.isAtom) {
|
|
39
42
|
return true;
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
return isParentEmpty && NodeSelection.isSelectable(maybeNode);
|
|
44
|
+
return isNodeContentEmpty(maybeNode) && NodeSelection.isSelectable(maybeNode);
|
|
43
45
|
};
|
|
44
46
|
function findNextSelectionPosition({
|
|
45
47
|
$targetHead,
|
|
@@ -57,7 +59,7 @@ function findNextSelectionPosition({
|
|
|
57
59
|
return null;
|
|
58
60
|
}
|
|
59
61
|
export const onCreateSelectionBetween = (view, $anchor, $head) => {
|
|
60
|
-
var _$head$parent;
|
|
62
|
+
var _$head$parent, _$head$parent2;
|
|
61
63
|
if ($anchor.pos === $head.pos) {
|
|
62
64
|
return null;
|
|
63
65
|
}
|
|
@@ -69,6 +71,11 @@ export const onCreateSelectionBetween = (view, $anchor, $head) => {
|
|
|
69
71
|
if ($head.depth === 1 && ((_$head$parent = $head.parent) === null || _$head$parent === void 0 ? void 0 : _$head$parent.type.name) === 'paragraph') {
|
|
70
72
|
return null;
|
|
71
73
|
}
|
|
74
|
+
|
|
75
|
+
// If head is at the beginning of a non-empty textblock, let ProseMirror handle the text selection
|
|
76
|
+
if ((_$head$parent2 = $head.parent) !== null && _$head$parent2 !== void 0 && _$head$parent2.isTextblock && !isNodeContentEmpty($head.parent) && $head.parentOffset === 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
72
79
|
const $nextHeadPosition = findNextSelectionPosition({
|
|
73
80
|
$targetHead: $head,
|
|
74
81
|
$anchor,
|
|
@@ -19,7 +19,7 @@ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
|
19
19
|
import UiDropdown from '../../../ui/Dropdown';
|
|
20
20
|
import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
|
|
21
21
|
import DropdownMenu, { itemSpacing, menuItemDimensions } from './DropdownMenu';
|
|
22
|
-
var dropdownExpandContainer = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0px
|
|
22
|
+
var dropdownExpandContainer = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0px ", ";\n"])), "var(--ds-space-negative-050, -4px)");
|
|
23
23
|
var iconGroup = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n"])));
|
|
24
24
|
var CompositeIcon = function CompositeIcon(_ref) {
|
|
25
25
|
var icon = _ref.icon;
|
|
@@ -112,7 +112,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
112
112
|
buttonTestId = _this$props2.buttonTestId,
|
|
113
113
|
dropdownWidth = _this$props2.dropdownWidth,
|
|
114
114
|
editorView = _this$props2.editorView,
|
|
115
|
-
dropdownListId = _this$props2.dropdownListId
|
|
115
|
+
dropdownListId = _this$props2.dropdownListId,
|
|
116
|
+
alignDropdownWithToolbar = _this$props2.alignDropdownWithToolbar;
|
|
116
117
|
var trigger;
|
|
117
118
|
if (icon) {
|
|
118
119
|
var TriggerIcon = hideExpandIcon ? icon : jsx(CompositeIcon, {
|
|
@@ -166,7 +167,8 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
166
167
|
fitHeight: fitHeight + fitTolerance,
|
|
167
168
|
trigger: trigger,
|
|
168
169
|
editorView: editorView,
|
|
169
|
-
dropdownListId: dropdownListId
|
|
170
|
+
dropdownListId: dropdownListId,
|
|
171
|
+
alignDropdownWithParentElement: alignDropdownWithToolbar
|
|
170
172
|
}, Array.isArray(options) ? this.renderArrayOptions(options) : options.render({
|
|
171
173
|
hide: this.hide,
|
|
172
174
|
dispatchCommand: dispatchCommand
|
|
@@ -139,7 +139,8 @@ var ToolbarItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
139
139
|
buttonTestId: item.testId,
|
|
140
140
|
editorView: editorView,
|
|
141
141
|
setDisableParentScroll: scrollable ? setDisableScroll : undefined,
|
|
142
|
-
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList")
|
|
142
|
+
dropdownListId: (item === null || item === void 0 ? void 0 : item.id) && "".concat(item.id, "-dropdownList"),
|
|
143
|
+
alignDropdownWithToolbar: items.length === 1
|
|
143
144
|
});
|
|
144
145
|
case 'select':
|
|
145
146
|
if (item.selectType === 'list') {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
function isNodeContentEmpty(maybeNode) {
|
|
3
|
+
return (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.content.size) === 0 || (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.textContent) === '';
|
|
4
|
+
}
|
|
2
5
|
function findEmptySelectableParentNodePosition($pos, isValidPosition) {
|
|
3
6
|
var doc = $pos.doc;
|
|
4
7
|
if ($pos.pos + 1 > doc.content.size) {
|
|
@@ -36,8 +39,7 @@ var checkPositionNode = function checkPositionNode($pos) {
|
|
|
36
39
|
if (maybeNode.isAtom) {
|
|
37
40
|
return true;
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
return isParentEmpty && NodeSelection.isSelectable(maybeNode);
|
|
42
|
+
return isNodeContentEmpty(maybeNode) && NodeSelection.isSelectable(maybeNode);
|
|
41
43
|
};
|
|
42
44
|
function findNextSelectionPosition(_ref) {
|
|
43
45
|
var $targetHead = _ref.$targetHead,
|
|
@@ -54,7 +56,7 @@ function findNextSelectionPosition(_ref) {
|
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
56
58
|
export var onCreateSelectionBetween = function onCreateSelectionBetween(view, $anchor, $head) {
|
|
57
|
-
var _$head$parent;
|
|
59
|
+
var _$head$parent, _$head$parent2;
|
|
58
60
|
if ($anchor.pos === $head.pos) {
|
|
59
61
|
return null;
|
|
60
62
|
}
|
|
@@ -66,6 +68,11 @@ export var onCreateSelectionBetween = function onCreateSelectionBetween(view, $a
|
|
|
66
68
|
if ($head.depth === 1 && ((_$head$parent = $head.parent) === null || _$head$parent === void 0 ? void 0 : _$head$parent.type.name) === 'paragraph') {
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
71
|
+
|
|
72
|
+
// If head is at the beginning of a non-empty textblock, let ProseMirror handle the text selection
|
|
73
|
+
if ((_$head$parent2 = $head.parent) !== null && _$head$parent2 !== void 0 && _$head$parent2.isTextblock && !isNodeContentEmpty($head.parent) && $head.parentOffset === 0) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
69
76
|
var $nextHeadPosition = findNextSelectionPosition({
|
|
70
77
|
$targetHead: $head,
|
|
71
78
|
$anchor: $anchor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "187.44.
|
|
3
|
+
"version": "187.44.6",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/code": "^14.6.0",
|
|
56
56
|
"@atlaskit/date": "^0.10.0",
|
|
57
57
|
"@atlaskit/datetime-picker": "^12.10.0",
|
|
58
|
-
"@atlaskit/editor-common": "^75.
|
|
58
|
+
"@atlaskit/editor-common": "^75.4.0",
|
|
59
59
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
60
60
|
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
61
61
|
"@atlaskit/editor-palette": "1.5.1",
|