@atlaskit/editor-core 187.44.3 → 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 +16 -0
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +2 -2
- 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/media/nodeviews/mediaSingle.js +3 -1
- package/dist/cjs/plugins/media/pm-plugins/keymap-media-single.js +2 -2
- package/dist/cjs/plugins/media/pm-plugins/main.js +1 -2
- package/dist/cjs/plugins/media/toolbar/index.js +2 -2
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.js +4 -5
- package/dist/cjs/plugins/media/utils/media-common.js +7 -8
- package/dist/cjs/plugins/media/utils/media-files.js +6 -6
- package/dist/cjs/plugins/media/utils/media-single.js +2 -2
- package/dist/cjs/plugins/placeholder-text/index.js +1 -1
- package/dist/cjs/plugins/selection/commands.js +2 -3
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +10 -11
- package/dist/cjs/plugins/selection/gap-cursor/utils.js +3 -3
- package/dist/cjs/plugins/selection/plugin-factory.js +5 -5
- package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/cjs/plugins/selection/pm-plugins/keymap.js +1 -1
- package/dist/cjs/plugins/selection/utils.js +1 -2
- package/dist/cjs/utils/commands.js +2 -22
- package/dist/cjs/utils/document.js +0 -20
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/expand/pm-plugins/keymap.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/media/nodeviews/mediaSingle.js +4 -2
- package/dist/es2019/plugins/media/pm-plugins/keymap-media-single.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +1 -2
- package/dist/es2019/plugins/media/toolbar/index.js +3 -3
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.js +2 -2
- package/dist/es2019/plugins/media/utils/media-common.js +1 -2
- package/dist/es2019/plugins/media/utils/media-files.js +1 -1
- package/dist/es2019/plugins/media/utils/media-single.js +1 -1
- package/dist/es2019/plugins/placeholder-text/index.js +1 -1
- package/dist/es2019/plugins/selection/commands.js +1 -2
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +2 -4
- package/dist/es2019/plugins/selection/gap-cursor/utils.js +2 -2
- package/dist/es2019/plugins/selection/plugin-factory.js +1 -1
- package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/es2019/plugins/selection/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/selection/utils.js +1 -3
- package/dist/es2019/utils/commands.js +1 -19
- package/dist/es2019/utils/document.js +0 -18
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/expand/pm-plugins/keymap.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/media/nodeviews/mediaSingle.js +4 -2
- package/dist/esm/plugins/media/pm-plugins/keymap-media-single.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +1 -2
- package/dist/esm/plugins/media/toolbar/index.js +3 -3
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.js +2 -2
- package/dist/esm/plugins/media/utils/media-common.js +1 -2
- package/dist/esm/plugins/media/utils/media-files.js +1 -1
- package/dist/esm/plugins/media/utils/media-single.js +1 -1
- package/dist/esm/plugins/placeholder-text/index.js +1 -1
- package/dist/esm/plugins/selection/commands.js +1 -2
- package/dist/esm/plugins/selection/gap-cursor/actions.js +2 -4
- package/dist/esm/plugins/selection/gap-cursor/utils.js +2 -2
- package/dist/esm/plugins/selection/plugin-factory.js +1 -1
- package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +10 -3
- package/dist/esm/plugins/selection/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/selection/utils.js +1 -3
- package/dist/esm/utils/commands.js +1 -21
- package/dist/esm/utils/document.js +0 -20
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
- package/dist/types/plugins/media/ui/CaptionPlaceholder/index.d.ts +0 -1
- package/dist/types/plugins/media/utils/media-files.d.ts +1 -2
- package/dist/types/plugins/selection/commands.d.ts +2 -2
- package/dist/types/plugins/selection/gap-cursor/actions.d.ts +1 -1
- package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types/utils/commands.d.ts +2 -12
- package/dist/types/utils/document.d.ts +0 -4
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Dropdown.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/ui/CaptionPlaceholder/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -2
- package/dist/types-ts4.5/plugins/selection/commands.d.ts +2 -2
- package/dist/types-ts4.5/plugins/selection/gap-cursor/actions.d.ts +1 -1
- package/dist/types-ts4.5/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types-ts4.5/utils/commands.d.ts +2 -12
- package/dist/types-ts4.5/utils/document.d.ts +0 -4
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/utils/prosemirror/position.js +0 -42
- package/dist/cjs/utils/table.js +0 -28
- package/dist/es2019/utils/prosemirror/position.js +0 -1
- package/dist/es2019/utils/table.js +0 -22
- package/dist/esm/utils/prosemirror/position.js +0 -1
- package/dist/esm/utils/table.js +0 -22
- package/dist/types/utils/prosemirror/position.d.ts +0 -1
- package/dist/types/utils/table.d.ts +0 -2
- package/dist/types-ts4.5/utils/prosemirror/position.d.ts +0 -1
- package/dist/types-ts4.5/utils/table.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
11
|
+
## 187.44.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`fa39c6ce044`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa39c6ce044) - [ED-19775] Decouple selection plugin from the editor-core code
|
|
16
|
+
- [`6b0dd092ac1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6b0dd092ac1) - ED-19729 media single performance optimization
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 187.44.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -14,7 +14,7 @@ var _classNames = require("../ui/class-names");
|
|
|
14
14
|
var _commands = require("../commands");
|
|
15
15
|
var _pluginFactory = require("../../selection/plugin-factory");
|
|
16
16
|
var _types = require("../../selection/types");
|
|
17
|
-
var
|
|
17
|
+
var _utils3 = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var isExpandNode = function isExpandNode(node) {
|
|
19
19
|
return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
|
|
20
20
|
};
|
|
@@ -88,7 +88,7 @@ function expandKeymap() {
|
|
|
88
88
|
// however when an expand is in a table cell to the left of the
|
|
89
89
|
// current table cell, arrow UP moves the cursor to the left
|
|
90
90
|
// see ED-15425
|
|
91
|
-
if ((0,
|
|
91
|
+
if ((0, _utils3.isPositionNearTableRow)($from, schema, 'before') && !expand) {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
var prevCursorPos = Math.max($from.pos - $from.parentOffset - 1, 0);
|
|
@@ -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') {
|
|
@@ -303,6 +303,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
303
303
|
}, {
|
|
304
304
|
key: "render",
|
|
305
305
|
value: function render() {
|
|
306
|
+
var _pluginInjectionApi$m;
|
|
306
307
|
var _this$props2 = this.props,
|
|
307
308
|
selected = _this$props2.selected,
|
|
308
309
|
getPos = _this$props2.getPos,
|
|
@@ -350,8 +351,9 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
350
351
|
height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
351
352
|
}
|
|
352
353
|
var isSelected = selected();
|
|
354
|
+
var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
|
|
353
355
|
var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
|
|
354
|
-
var contentWidth =
|
|
356
|
+
var contentWidth = currentMaxWidth || lineLength;
|
|
355
357
|
var mediaSingleProps = {
|
|
356
358
|
layout: layout,
|
|
357
359
|
width: width,
|
|
@@ -9,7 +9,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
9
9
|
var _utils = require("../../../utils");
|
|
10
10
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
12
|
-
var
|
|
12
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
13
|
/**
|
|
14
14
|
* Check if is an empty selection at the start of the node
|
|
15
15
|
*/
|
|
@@ -145,7 +145,7 @@ var maybeRemoveMediaSingleNode = function maybeRemoveMediaSingleNode(schema) {
|
|
|
145
145
|
if (dispatch) {
|
|
146
146
|
// Select media single, and remove paragraph if it's empty.
|
|
147
147
|
(0, _commands.selectNodeBackward)(state, function (tr) {
|
|
148
|
-
if (isEmptyNodeInSchema($from.parent) && !(0,
|
|
148
|
+
if (isEmptyNodeInSchema($from.parent) && !(0, _selection.atTheEndOfDoc)(state)) {
|
|
149
149
|
tr.replace($from.pos - 1, $from.pos + $from.parent.nodeSize - 1); // Remove node
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -37,7 +37,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
37
37
|
var _document = require("../../../utils/document");
|
|
38
38
|
var _mediaCommon2 = require("@atlaskit/media-common");
|
|
39
39
|
var _utils3 = require("../../../utils");
|
|
40
|
-
var _CaptionPlaceholder = require("../ui/CaptionPlaceholder");
|
|
41
40
|
var _reactIntlNext = require("react-intl-next");
|
|
42
41
|
var _mediaTaskManager = require("./mediaTaskManager");
|
|
43
42
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
@@ -775,7 +774,7 @@ var createPlugin = function createPlugin(_schema, options, reactContext, getIntl
|
|
|
775
774
|
},
|
|
776
775
|
handleClick: function handleClick(_editorView, _pos, event) {
|
|
777
776
|
var _event$target;
|
|
778
|
-
var clickedInsideCaptionPlaceholder = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest("[data-id=\"".concat(
|
|
777
|
+
var clickedInsideCaptionPlaceholder = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest("[data-id=\"".concat(_mediaSingle2.CAPTION_PLACEHOLDER_ID, "\"]"));
|
|
779
778
|
|
|
780
779
|
// Workaround for Chrome given a regression introduced in prosemirror-view@1.18.6
|
|
781
780
|
// Returning true prevents that updateSelection() is getting called in the commit below:
|
|
@@ -266,7 +266,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
266
266
|
type: 'custom',
|
|
267
267
|
fallback: [],
|
|
268
268
|
render: function render(editorView) {
|
|
269
|
-
var _widthPlugin$sharedSt2;
|
|
269
|
+
var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
|
|
270
270
|
if (!editorView || !selectedMediaSingleNode) {
|
|
271
271
|
return null;
|
|
272
272
|
}
|
|
@@ -284,7 +284,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
284
284
|
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
285
285
|
mediaWidth = _selectedMediaNode$at.width,
|
|
286
286
|
mediaHeight = _selectedMediaNode$at.height;
|
|
287
|
-
var maxWidthForNestedNode =
|
|
287
|
+
var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
|
|
288
288
|
var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
289
289
|
var isVideoFile = (0, _mediaSingle.isVideo)(selectedMediaNode.attrs.__fileMimeType);
|
|
290
290
|
var minWidth = (0, _mediaSingle2.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
@@ -4,25 +4,24 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
11
|
var _reactIntlNext = require("react-intl-next");
|
|
12
12
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
13
|
var _messages = require("./messages");
|
|
14
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
14
15
|
var _templateObject;
|
|
15
16
|
/** @jsx jsx */
|
|
16
|
-
var placeholder = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n width: 100%;\n text-align: center;\n margin-top:
|
|
17
|
-
var CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
|
|
18
|
-
exports.CAPTION_PLACEHOLDER_ID = CAPTION_PLACEHOLDER_ID;
|
|
17
|
+
var placeholder = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n width: 100%;\n text-align: center;\n margin-top: ", " !important;\n display: block;\n"])), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), "var(--ds-space-100, 8px)");
|
|
19
18
|
var _default = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
20
19
|
var onClick = _ref.onClick;
|
|
21
20
|
return (0, _react2.jsx)("span", {
|
|
22
21
|
ref: ref,
|
|
23
22
|
css: placeholder,
|
|
24
23
|
onClick: onClick,
|
|
25
|
-
"data-id": CAPTION_PLACEHOLDER_ID,
|
|
24
|
+
"data-id": _mediaSingle.CAPTION_PLACEHOLDER_ID,
|
|
26
25
|
"data-testid": "caption-placeholder"
|
|
27
26
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.placeholder));
|
|
28
27
|
});
|
|
@@ -12,7 +12,6 @@ var _utils3 = require("../../../utils");
|
|
|
12
12
|
var _slice = require("../../../utils/slice");
|
|
13
13
|
var _dom = require("../../../utils/dom");
|
|
14
14
|
var _isImage = require("./is-image");
|
|
15
|
-
var _position = require("../../../utils/prosemirror/position");
|
|
16
15
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
17
16
|
var _mediaClient = require("@atlaskit/media-client");
|
|
18
17
|
var isMediaBlobUrlFromAttrs = function isMediaBlobUrlFromAttrs(attrs) {
|
|
@@ -36,7 +35,7 @@ var isSelectionMediaSingleNode = function isSelectionMediaSingleNode(state) {
|
|
|
36
35
|
};
|
|
37
36
|
exports.isSelectionMediaSingleNode = isSelectionMediaSingleNode;
|
|
38
37
|
var posOfPrecedingMediaGroup = function posOfPrecedingMediaGroup(state) {
|
|
39
|
-
if (!(0,
|
|
38
|
+
if (!(0, _selection.atTheBeginningOfBlock)(state)) {
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
41
|
return posOfMediaGroupAbove(state, state.selection.$from);
|
|
@@ -61,7 +60,7 @@ var posOfImmediateFollowingMediaGroup = function posOfImmediateFollowingMediaGro
|
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
var posOfFollowingMediaGroup = function posOfFollowingMediaGroup(state) {
|
|
64
|
-
if (!(0,
|
|
63
|
+
if (!(0, _selection.atTheEndOfBlock)(state)) {
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
67
66
|
return posOfMediaGroupBelow(state, state.selection.$to);
|
|
@@ -73,7 +72,7 @@ var posOfMediaGroupAbove = function posOfMediaGroupAbove(state, $pos) {
|
|
|
73
72
|
adjacentPos = $pos.pos;
|
|
74
73
|
adjacentNode = $pos.nodeBefore;
|
|
75
74
|
} else {
|
|
76
|
-
adjacentPos = (0,
|
|
75
|
+
adjacentPos = (0, _selection.startPositionOfParent)($pos) - 1;
|
|
77
76
|
adjacentNode = state.doc.resolve(adjacentPos).nodeBefore;
|
|
78
77
|
}
|
|
79
78
|
if (adjacentNode && adjacentNode.type === state.schema.nodes.mediaGroup) {
|
|
@@ -88,7 +87,7 @@ var posOfMediaGroupAbove = function posOfMediaGroupAbove(state, $pos) {
|
|
|
88
87
|
*/
|
|
89
88
|
var isInsidePotentialEmptyParagraph = function isInsidePotentialEmptyParagraph(state) {
|
|
90
89
|
var $from = state.selection.$from;
|
|
91
|
-
return $from.parent.type === state.schema.nodes.paragraph && (0,
|
|
90
|
+
return $from.parent.type === state.schema.nodes.paragraph && (0, _selection.atTheBeginningOfBlock)(state) && (0, _selection.atTheEndOfBlock)(state);
|
|
92
91
|
};
|
|
93
92
|
exports.isInsidePotentialEmptyParagraph = isInsidePotentialEmptyParagraph;
|
|
94
93
|
var posOfMediaGroupBelow = function posOfMediaGroupBelow(state, $pos) {
|
|
@@ -99,7 +98,7 @@ var posOfMediaGroupBelow = function posOfMediaGroupBelow(state, $pos) {
|
|
|
99
98
|
adjacentPos = $pos.pos;
|
|
100
99
|
adjacentNode = $pos.nodeAfter;
|
|
101
100
|
} else {
|
|
102
|
-
adjacentPos = (0,
|
|
101
|
+
adjacentPos = (0, _selection.endPositionOfParent)($pos);
|
|
103
102
|
adjacentNode = state.doc.nodeAt(adjacentPos);
|
|
104
103
|
}
|
|
105
104
|
if (adjacentNode && adjacentNode.type === state.schema.nodes.mediaGroup) {
|
|
@@ -112,7 +111,7 @@ var posOfParentMediaGroup = function posOfParentMediaGroup(state, $pos) {
|
|
|
112
111
|
var $from = state.selection.$from;
|
|
113
112
|
$pos = $pos || $from;
|
|
114
113
|
if ($pos.parent.type === state.schema.nodes.mediaGroup) {
|
|
115
|
-
return prepend ? (0,
|
|
114
|
+
return prepend ? (0, _selection.startPositionOfParent)($pos) : (0, _selection.endPositionOfParent)($pos) - 1;
|
|
116
115
|
}
|
|
117
116
|
return;
|
|
118
117
|
};
|
|
@@ -139,7 +138,7 @@ var removeMediaNode = function removeMediaNode(view, node, getPos) {
|
|
|
139
138
|
// If deleting a selected media node, we need to tell where the cursor to go next.
|
|
140
139
|
// Prosemirror didn't gave us the behaviour of moving left if the media node is not the last one.
|
|
141
140
|
// So we handle it ourselves.
|
|
142
|
-
if (selection.from === currentMediaNodePos && !isLastMediaNode && !(0,
|
|
141
|
+
if (selection.from === currentMediaNodePos && !isLastMediaNode && !(0, _selection.atTheBeginningOfDoc)(state) && nodeBefore && nodeBefore.type.name === 'media') {
|
|
143
142
|
var _nodeBefore = (0, _utils.findPositionOfNodeBefore)(tr.selection);
|
|
144
143
|
if (_nodeBefore) {
|
|
145
144
|
tr.setSelection(_state.NodeSelection.create(tr.doc, _nodeBefore));
|
|
@@ -9,7 +9,7 @@ var _utils = require("../../../utils");
|
|
|
9
9
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _mediaCommon = require("./media-common");
|
|
11
11
|
var _utils3 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var
|
|
12
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
14
|
var canInsertMediaInline = function canInsertMediaInline(state) {
|
|
15
15
|
var node = state.schema.nodes.mediaInline.create({});
|
|
@@ -69,7 +69,7 @@ function isSelectionMediaGroup(state) {
|
|
|
69
69
|
function shouldAppendParagraph(state, node) {
|
|
70
70
|
var media = state.schema.nodes.media;
|
|
71
71
|
var wasMediaNode = node && node.type === media;
|
|
72
|
-
return ((0, _utils.insideTableCell)(state) || (0, _utils.isInListItem)(state) || (0, _utils2.isInLayoutColumn)(state) || (0,
|
|
72
|
+
return ((0, _utils.insideTableCell)(state) || (0, _utils.isInListItem)(state) || (0, _utils2.isInLayoutColumn)(state) || (0, _selection.atTheEndOfDoc)(state) && (!(0, _mediaCommon.posOfPrecedingMediaGroup)(state) || (0, _mediaCommon.isSelectionNonMediaBlockNode)(state))) && !wasMediaNode;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
@@ -257,10 +257,10 @@ var findMediaInsertPos = function findMediaInsertPos(state) {
|
|
|
257
257
|
if ((0, _mediaCommon.isSelectionNonMediaBlockNode)(state)) {
|
|
258
258
|
return $to.pos;
|
|
259
259
|
}
|
|
260
|
-
if ((0,
|
|
260
|
+
if ((0, _selection.atTheEndOfBlock)(state)) {
|
|
261
261
|
return $to.pos + 1;
|
|
262
262
|
}
|
|
263
|
-
if ((0,
|
|
263
|
+
if ((0, _selection.atTheBeginningOfBlock)(state)) {
|
|
264
264
|
return $from.pos - 1;
|
|
265
265
|
}
|
|
266
266
|
return $to.pos;
|
|
@@ -275,7 +275,7 @@ var findDeleteRange = function findDeleteRange(state) {
|
|
|
275
275
|
if (!(0, _mediaCommon.isInsidePotentialEmptyParagraph)(state) || (0, _mediaCommon.posOfMediaGroupNearby)(state)) {
|
|
276
276
|
return range($from.pos, $to.pos);
|
|
277
277
|
}
|
|
278
|
-
return range((0,
|
|
278
|
+
return range((0, _selection.startPositionOfParent)($from) - 1, (0, _selection.endPositionOfParent)($to));
|
|
279
279
|
};
|
|
280
280
|
var range = function range(start) {
|
|
281
281
|
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start;
|
|
@@ -292,7 +292,7 @@ var setSelectionAfterMediaInsertion = function setSelectionAfterMediaInsertion(v
|
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
294
|
var $mediaPos = doc.resolve(mediaPos);
|
|
295
|
-
var endOfMediaGroup = (0,
|
|
295
|
+
var endOfMediaGroup = (0, _selection.endPositionOfParent)($mediaPos);
|
|
296
296
|
if (endOfMediaGroup + 1 >= doc.nodeSize - 1) {
|
|
297
297
|
// if nothing after the media group, fallback to select the newest uploaded media item
|
|
298
298
|
(0, _utils.setNodeSelection)(view, mediaPos);
|
|
@@ -19,7 +19,7 @@ var _slice = require("../../../utils/slice");
|
|
|
19
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
20
20
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
21
21
|
var _isImage = require("./is-image");
|
|
22
|
-
var
|
|
22
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
23
23
|
var _mediaCommon2 = require("@atlaskit/media-common");
|
|
24
24
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -38,7 +38,7 @@ var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, file
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
function shouldAddParagraph(state) {
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, _selection.atTheBeginningOfBlock)(state) && !(0, _utils2.checkNodeDown)(state.selection, state.doc, _utils3.isEmptyParagraph);
|
|
42
42
|
}
|
|
43
43
|
function insertNodesWithOptionalParagraph(nodes) {
|
|
44
44
|
var analyticsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -12,7 +12,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
12
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
13
|
var _text = _interopRequireDefault(require("@atlaskit/icon/glyph/media-services/text"));
|
|
14
14
|
var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
|
|
15
|
-
var _utils = require("
|
|
15
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
16
|
var _cursor = require("../fake-text-cursor/cursor");
|
|
17
17
|
var _PlaceholderFloatingToolbar = _interopRequireDefault(require("./ui/PlaceholderFloatingToolbar"));
|
|
18
18
|
var _actions = require("./actions");
|
|
@@ -7,7 +7,6 @@ exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = expor
|
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
8
|
var _gapCursorSelection = require("./gap-cursor-selection");
|
|
9
9
|
var _isIgnored = require("../selection/gap-cursor/utils/is-ignored");
|
|
10
|
-
var _document = require("../../utils/document");
|
|
11
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
11
|
var _actions = require("./actions");
|
|
13
12
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -203,7 +202,7 @@ var findAndSetTextSelection = function findAndSetTextSelection(selectionRelative
|
|
|
203
202
|
};
|
|
204
203
|
var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selectionRelativeToNode, node, pos) {
|
|
205
204
|
return function (state, dispatch) {
|
|
206
|
-
if ((0,
|
|
205
|
+
if ((0, _utils.isNodeEmpty)(node)) {
|
|
207
206
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), _types.SelectionDirection.After)(state, dispatch);
|
|
208
207
|
}
|
|
209
208
|
var selectableNode = (0, _utils2.findFirstChildNodeToSelect)(node);
|
|
@@ -226,7 +225,7 @@ var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selec
|
|
|
226
225
|
};
|
|
227
226
|
var setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to) {
|
|
228
227
|
return function (state, dispatch) {
|
|
229
|
-
if ((0,
|
|
228
|
+
if ((0, _utils.isNodeEmpty)(node)) {
|
|
230
229
|
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), _types.SelectionDirection.Before)(state, dispatch);
|
|
231
230
|
}
|
|
232
231
|
var selectableNode = (0, _utils2.findLastChildNodeToSelect)(node);
|
|
@@ -6,26 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.shouldSkipGapCursor = exports.setSelectionTopLevelBlocks = exports.setGapCursorAtPos = exports.setCursorForTopLevelBlocks = exports.hasGapCursorPlugin = exports.deleteNode = exports.arrow = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
10
9
|
var _direction = require("./direction");
|
|
11
10
|
var _selection = require("./selection");
|
|
12
|
-
var
|
|
11
|
+
var _utils2 = require("./utils");
|
|
13
12
|
var _isValidTargetNode = require("./utils/is-valid-target-node");
|
|
14
|
-
var
|
|
13
|
+
var _selection2 = require("@atlaskit/editor-common/selection");
|
|
15
14
|
var _gapCursorPluginKey = require("../pm-plugins/gap-cursor-plugin-key");
|
|
16
|
-
var
|
|
15
|
+
var _utils3 = require("@atlaskit/editor-common/utils");
|
|
17
16
|
var shouldSkipGapCursor = function shouldSkipGapCursor(direction, state, $pos) {
|
|
18
17
|
var _$pos$nodeBefore;
|
|
19
18
|
var doc = state.doc,
|
|
20
19
|
schema = state.schema;
|
|
21
20
|
switch (direction) {
|
|
22
21
|
case _direction.Direction.UP:
|
|
23
|
-
if ((0,
|
|
22
|
+
if ((0, _selection2.atTheBeginningOfDoc)(state)) {
|
|
24
23
|
return false;
|
|
25
24
|
}
|
|
26
|
-
return (0,
|
|
25
|
+
return (0, _utils3.isPositionNearTableRow)($pos, schema, 'before') || (0, _utils2.isTextBlockNearPos)(doc, schema, $pos, -1) || (0, _utils3.isNodeBeforeMediaNode)($pos, state);
|
|
27
26
|
case _direction.Direction.DOWN:
|
|
28
|
-
return (0,
|
|
27
|
+
return (0, _selection2.atTheEndOfDoc)(state) || (0, _utils2.isTextBlockNearPos)(doc, schema, $pos, 1) || (0, _utils3.isPositionNearTableRow)($pos, schema, 'after') || ((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.type.name) === 'text' && !$pos.nodeAfter // end of a paragraph
|
|
29
28
|
;
|
|
30
29
|
|
|
31
30
|
default:
|
|
@@ -38,7 +37,7 @@ exports.shouldSkipGapCursor = shouldSkipGapCursor;
|
|
|
38
37
|
function shouldHandleMediaGapCursor(dir, state) {
|
|
39
38
|
var _selection$$from$node;
|
|
40
39
|
var selection = state.selection;
|
|
41
|
-
var upArrowFromGapCursorIntoMedia = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.UP && selection.$from.nodeBefore && (0,
|
|
40
|
+
var upArrowFromGapCursorIntoMedia = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.UP && selection.$from.nodeBefore && (0, _utils3.isMediaNode)(selection.$from.nodeBefore);
|
|
42
41
|
var downArrowFromGapCursorIntoMediaGroup = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.DOWN && ((_selection$$from$node = selection.$from.nodeAfter) === null || _selection$$from$node === void 0 ? void 0 : _selection$$from$node.type.name) === 'mediaGroup';
|
|
43
42
|
return upArrowFromGapCursorIntoMedia || downArrowFromGapCursorIntoMediaGroup;
|
|
44
43
|
}
|
|
@@ -49,7 +48,7 @@ function handleMediaGapCursor(dir, state) {
|
|
|
49
48
|
var selection = state.selection,
|
|
50
49
|
tr = state.tr;
|
|
51
50
|
var $pos = (0, _direction.isBackward)(dir) ? selection.$from : selection.$to;
|
|
52
|
-
if (dir === _direction.Direction.UP && selection.$from.nodeBefore && (0,
|
|
51
|
+
if (dir === _direction.Direction.UP && selection.$from.nodeBefore && (0, _utils3.isMediaNode)(selection.$from.nodeBefore)) {
|
|
53
52
|
var _tr$doc$nodeAt;
|
|
54
53
|
var nodeBeforePos = (0, _utils.findPositionOfNodeBefore)(tr.selection);
|
|
55
54
|
if (nodeBeforePos && selection.side === 'right' && ((_tr$doc$nodeAt = tr.doc.nodeAt(nodeBeforePos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) === 'mediaSingle') {
|
|
@@ -94,7 +93,7 @@ var arrow = function arrow(dir, endOfTextblock) {
|
|
|
94
93
|
if (selection.node.isInline) {
|
|
95
94
|
return false;
|
|
96
95
|
}
|
|
97
|
-
if (dir === _direction.Direction.UP && !(0,
|
|
96
|
+
if (dir === _direction.Direction.UP && !(0, _selection2.atTheBeginningOfDoc)(state) && !(0, _utils3.isNodeBeforeMediaNode)($pos, state) || dir === _direction.Direction.DOWN) {
|
|
98
97
|
// We dont add gap cursor on node selections going up and down
|
|
99
98
|
// Except we do if we're going up for a block node which is the
|
|
100
99
|
// first node in the document OR the node before is a media node
|
|
@@ -126,7 +125,7 @@ var arrow = function arrow(dir, endOfTextblock) {
|
|
|
126
125
|
if (view) {
|
|
127
126
|
var domAtPos = view.domAtPos.bind(view);
|
|
128
127
|
var target = (0, _utils.findDomRefAtPos)($pos.pos, domAtPos);
|
|
129
|
-
if (target && target.textContent ===
|
|
128
|
+
if (target && target.textContent === _utils3.ZERO_WIDTH_SPACE) {
|
|
130
129
|
return false;
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -9,7 +9,7 @@ exports.getMediaNearPos = getMediaNearPos;
|
|
|
9
9
|
exports.isTextBlockNearPos = exports.isLeftCursor = exports.isIgnoredClick = void 0;
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _selection = require("./selection");
|
|
12
|
-
var
|
|
12
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
13
13
|
var isLeftCursor = function isLeftCursor(side) {
|
|
14
14
|
return side === _selection.Side.LEFT;
|
|
15
15
|
};
|
|
@@ -96,7 +96,7 @@ var isIgnoredClick = function isIgnoredClick(elem) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// check if we're clicking an image caption placeholder
|
|
99
|
-
if (elem.closest("[data-id=\"".concat(
|
|
99
|
+
if (elem.closest("[data-id=\"".concat(_mediaSingle.CAPTION_PLACEHOLDER_ID, "\"]"))) {
|
|
100
100
|
return true;
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -124,7 +124,7 @@ var isIgnoredClick = function isIgnoredClick(elem) {
|
|
|
124
124
|
return false;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
/*
|
|
127
|
+
/*
|
|
128
128
|
Calculates custom style for breakout mode
|
|
129
129
|
Mainly to handle table width to include the numbered column width as well
|
|
130
130
|
*/
|
|
@@ -9,16 +9,16 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
11
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
12
|
-
var
|
|
12
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _reducer = require("./reducer");
|
|
14
14
|
var _types = require("./types");
|
|
15
|
-
var
|
|
15
|
+
var _utils2 = require("./utils");
|
|
16
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
17
|
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; }
|
|
18
18
|
var handleDocChanged = function handleDocChanged(tr, pluginState) {
|
|
19
19
|
// in some collab edge cases mapping decorations could throw an error
|
|
20
20
|
try {
|
|
21
|
-
if (pluginState.decorationSet.find().length === 0 && (!tr.selectionSet || (0,
|
|
21
|
+
if (pluginState.decorationSet.find().length === 0 && (!tr.selectionSet || (0, _utils2.getDecorations)(tr).find().length === 0)) {
|
|
22
22
|
return pluginState;
|
|
23
23
|
}
|
|
24
24
|
var decorationSet = pluginState.decorationSet.map(tr.mapping, tr.doc);
|
|
@@ -33,14 +33,14 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
|
|
|
33
33
|
};
|
|
34
34
|
var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
|
|
35
35
|
// Reset relative selection pos when user clicks to select a node
|
|
36
|
-
if ((tr.selection instanceof _state.NodeSelection && (0,
|
|
36
|
+
if ((tr.selection instanceof _state.NodeSelection && (0, _utils2.isSelectableContainerNode)(tr.selection.node) || tr.selection instanceof _cellSelection.CellSelection) && !tr.getMeta(_types.selectionPluginKey)) {
|
|
37
37
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
38
|
selectionRelativeToNode: undefined
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return pluginState;
|
|
42
42
|
};
|
|
43
|
-
var _pluginFactory = (0,
|
|
43
|
+
var _pluginFactory = (0, _utils.pluginFactory)(_types.selectionPluginKey, _reducer.reducer, {
|
|
44
44
|
onDocChanged: handleDocChanged,
|
|
45
45
|
onSelectionChanged: handleSelectionChanged
|
|
46
46
|
}),
|
|
@@ -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,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
8
|
-
var _keymaps = require("
|
|
8
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
9
|
var _commands = require("../commands");
|
|
10
10
|
function keymapPlugin() {
|
|
11
11
|
var list = {};
|
|
@@ -38,7 +38,6 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
38
38
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
39
39
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
40
40
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
41
|
-
var _commands = require("../../utils/commands");
|
|
42
41
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
43
42
|
var _isIgnored = require("../selection/gap-cursor/utils/is-ignored");
|
|
44
43
|
var _types = require("./types");
|
|
@@ -52,7 +51,7 @@ function createSelectionClickHandler(nodes, isValidTarget, options) {
|
|
|
52
51
|
var _target = event.target;
|
|
53
52
|
if (isValidTarget(_target)) {
|
|
54
53
|
var selectionPos = options.getNodeSelectionPos ? options.getNodeSelectionPos(view.state, nodePos) : nodePos;
|
|
55
|
-
(0,
|
|
54
|
+
(0, _selection.selectNode)(selectionPos)(view.state, view.dispatch);
|
|
56
55
|
return true;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.withScrollIntoView = exports.
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
6
|
+
exports.withScrollIntoView = exports.isNthParentOfType = void 0;
|
|
8
7
|
/**
|
|
9
8
|
* Creates a filter that checks if the node at a given number of parents above the current
|
|
10
9
|
* selection is of the correct node type.
|
|
@@ -31,23 +30,4 @@ var withScrollIntoView = function withScrollIntoView(command) {
|
|
|
31
30
|
}, view);
|
|
32
31
|
};
|
|
33
32
|
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Insert content, delete a range and create a new selection
|
|
37
|
-
* This function automatically handles the mapping of positions for insertion and deletion.
|
|
38
|
-
* The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
|
|
39
|
-
*
|
|
40
|
-
* @param getSelectionResolvedPos get the resolved position to create a new selection
|
|
41
|
-
* @param insertions content to insert at the specified position
|
|
42
|
-
* @param deletions the ranges to delete
|
|
43
|
-
*/
|
|
44
|
-
exports.withScrollIntoView = withScrollIntoView;
|
|
45
|
-
var selectNode = function selectNode(pos) {
|
|
46
|
-
return function (state, dispatch) {
|
|
47
|
-
if (dispatch) {
|
|
48
|
-
dispatch(state.tr.setSelection(new _state.NodeSelection(state.doc.resolve(pos))));
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
exports.selectNode = selectNode;
|
|
33
|
+
exports.withScrollIntoView = withScrollIntoView;
|