@atlaskit/editor-plugin-selection 1.5.5 → 1.6.0
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 +25 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/pm-plugins/auto-expand-selection-range-on-inline-node-key.js +8 -0
- package/dist/cjs/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +67 -0
- package/dist/cjs/{commands.js → pm-plugins/commands.js} +1 -1
- package/dist/cjs/pm-plugins/events/create-selection-between.js +18 -4
- package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/actions.js +1 -1
- package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/utils.js +7 -0
- package/dist/cjs/pm-plugins/gap-cursor-keymap.js +3 -3
- package/dist/cjs/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/cjs/pm-plugins/keymap.js +1 -1
- package/dist/cjs/pm-plugins/mark-boundary-cursor-main.js +2 -2
- package/dist/cjs/{plugin-factory.js → pm-plugins/plugin-factory.js} +1 -1
- package/dist/cjs/pm-plugins/selection-main.js +3 -3
- package/dist/cjs/{utils.js → pm-plugins/utils.js} +1 -1
- package/dist/cjs/{plugin.js → selectionPlugin.js} +7 -1
- package/dist/cjs/selectionPluginType.js +5 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/pm-plugins/auto-expand-selection-range-on-inline-node-key.js +2 -0
- package/dist/es2019/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +63 -0
- package/dist/es2019/{commands.js → pm-plugins/commands.js} +1 -1
- package/dist/es2019/pm-plugins/events/create-selection-between.js +18 -4
- package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/actions.js +1 -1
- package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/utils.js +7 -0
- package/dist/es2019/pm-plugins/gap-cursor-keymap.js +3 -3
- package/dist/es2019/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/es2019/pm-plugins/keymap.js +1 -1
- package/dist/es2019/pm-plugins/mark-boundary-cursor-main.js +2 -2
- package/dist/es2019/{plugin-factory.js → pm-plugins/plugin-factory.js} +1 -1
- package/dist/es2019/pm-plugins/selection-main.js +3 -3
- package/dist/es2019/{utils.js → pm-plugins/utils.js} +1 -1
- package/dist/es2019/{plugin.js → selectionPlugin.js} +5 -1
- package/dist/es2019/selectionPluginType.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/pm-plugins/auto-expand-selection-range-on-inline-node-key.js +2 -0
- package/dist/esm/pm-plugins/auto-expand-selection-range-on-inline-node-main.js +61 -0
- package/dist/esm/{commands.js → pm-plugins/commands.js} +1 -1
- package/dist/esm/pm-plugins/events/create-selection-between.js +18 -4
- package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/actions.js +1 -1
- package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/utils.js +7 -0
- package/dist/esm/pm-plugins/gap-cursor-keymap.js +3 -3
- package/dist/esm/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/esm/pm-plugins/keymap.js +1 -1
- package/dist/esm/pm-plugins/mark-boundary-cursor-main.js +2 -2
- package/dist/esm/{plugin-factory.js → pm-plugins/plugin-factory.js} +1 -1
- package/dist/esm/pm-plugins/selection-main.js +3 -3
- package/dist/esm/{utils.js → pm-plugins/utils.js} +1 -1
- package/dist/esm/{plugin.js → selectionPlugin.js} +7 -1
- package/dist/esm/selectionPluginType.js +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/{types-ts4.5 → types/pm-plugins}/actions.d.ts +1 -1
- package/dist/types/pm-plugins/auto-expand-selection-range-on-inline-node-key.d.ts +2 -0
- package/dist/types/pm-plugins/auto-expand-selection-range-on-inline-node-main.d.ts +2 -0
- package/dist/types/{commands.d.ts → pm-plugins/commands.d.ts} +1 -1
- package/dist/types/{plugin-factory.d.ts → pm-plugins/plugin-factory.d.ts} +1 -1
- package/dist/types/{reducer.d.ts → pm-plugins/reducer.d.ts} +1 -1
- package/dist/types/selectionPlugin.d.ts +3 -0
- package/dist/types/{plugin.d.ts → selectionPluginType.d.ts} +0 -2
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/{types → types-ts4.5/pm-plugins}/actions.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/auto-expand-selection-range-on-inline-node-key.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/auto-expand-selection-range-on-inline-node-main.d.ts +2 -0
- package/dist/types-ts4.5/{commands.d.ts → pm-plugins/commands.d.ts} +1 -1
- package/dist/types-ts4.5/{plugin-factory.d.ts → pm-plugins/plugin-factory.d.ts} +1 -1
- package/dist/types-ts4.5/{reducer.d.ts → pm-plugins/reducer.d.ts} +1 -1
- package/dist/types-ts4.5/selectionPlugin.d.ts +3 -0
- package/dist/types-ts4.5/{plugin.d.ts → selectionPluginType.d.ts} +0 -2
- package/package.json +13 -3
- package/types/package.json +5 -5
- /package/dist/cjs/{actions.js → pm-plugins/actions.js} +0 -0
- /package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/direction.js +0 -0
- /package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/selection.js +0 -0
- /package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/utils/is-ignored.js +0 -0
- /package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.js +0 -0
- /package/dist/cjs/{gap-cursor → pm-plugins/gap-cursor}/utils/place-gap-cursor.js +0 -0
- /package/dist/cjs/{gap-cursor-selection.js → pm-plugins/gap-cursor-selection.js} +0 -0
- /package/dist/cjs/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.js +0 -0
- /package/dist/cjs/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/ui/mark-boundary-cursor-decoration.js +0 -0
- /package/dist/cjs/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/active-marks-side.js +0 -0
- /package/dist/cjs/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.js +0 -0
- /package/dist/cjs/{reducer.js → pm-plugins/reducer.js} +0 -0
- /package/dist/cjs/{types.js → types/index.js} +0 -0
- /package/dist/es2019/{actions.js → pm-plugins/actions.js} +0 -0
- /package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/direction.js +0 -0
- /package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/selection.js +0 -0
- /package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/utils/is-ignored.js +0 -0
- /package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.js +0 -0
- /package/dist/es2019/{gap-cursor → pm-plugins/gap-cursor}/utils/place-gap-cursor.js +0 -0
- /package/dist/es2019/{gap-cursor-selection.js → pm-plugins/gap-cursor-selection.js} +0 -0
- /package/dist/es2019/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.js +0 -0
- /package/dist/es2019/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/ui/mark-boundary-cursor-decoration.js +0 -0
- /package/dist/es2019/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/active-marks-side.js +0 -0
- /package/dist/es2019/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.js +0 -0
- /package/dist/es2019/{reducer.js → pm-plugins/reducer.js} +0 -0
- /package/dist/es2019/{types.js → types/index.js} +0 -0
- /package/dist/esm/{actions.js → pm-plugins/actions.js} +0 -0
- /package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/direction.js +0 -0
- /package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/selection.js +0 -0
- /package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/utils/is-ignored.js +0 -0
- /package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.js +0 -0
- /package/dist/esm/{gap-cursor → pm-plugins/gap-cursor}/utils/place-gap-cursor.js +0 -0
- /package/dist/esm/{gap-cursor-selection.js → pm-plugins/gap-cursor-selection.js} +0 -0
- /package/dist/esm/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.js +0 -0
- /package/dist/esm/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/ui/mark-boundary-cursor-decoration.js +0 -0
- /package/dist/esm/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/active-marks-side.js +0 -0
- /package/dist/esm/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.js +0 -0
- /package/dist/esm/{reducer.js → pm-plugins/reducer.js} +0 -0
- /package/dist/esm/{types.js → types/index.js} +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/actions.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/direction.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/selection.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/utils/is-ignored.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/utils/place-gap-cursor.d.ts +0 -0
- /package/dist/types/{gap-cursor → pm-plugins/gap-cursor}/utils.d.ts +0 -0
- /package/dist/types/{gap-cursor-selection.d.ts → pm-plugins/gap-cursor-selection.d.ts} +0 -0
- /package/dist/types/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.d.ts +0 -0
- /package/dist/types/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/ui/mark-boundary-cursor-decoration.d.ts +0 -0
- /package/dist/types/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/active-marks-side.d.ts +0 -0
- /package/dist/types/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.d.ts +0 -0
- /package/dist/types/{utils.d.ts → pm-plugins/utils.d.ts} +0 -0
- /package/dist/types/{types.d.ts → types/index.d.ts} +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/actions.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/direction.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/selection.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/utils/is-ignored.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/utils/place-gap-cursor.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/utils.d.ts +0 -0
- /package/dist/types-ts4.5/{gap-cursor-selection.d.ts → pm-plugins/gap-cursor-selection.d.ts} +0 -0
- /package/dist/types-ts4.5/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.d.ts +0 -0
- /package/dist/types-ts4.5/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/ui/mark-boundary-cursor-decoration.d.ts +0 -0
- /package/dist/types-ts4.5/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/active-marks-side.d.ts +0 -0
- /package/dist/types-ts4.5/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.d.ts +0 -0
- /package/dist/types-ts4.5/{utils.d.ts → pm-plugins/utils.d.ts} +0 -0
- /package/dist/types-ts4.5/{types.d.ts → types/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#169428](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169428)
|
|
8
|
+
[`dc52eec1d2269`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dc52eec1d2269) -
|
|
9
|
+
[ux] ED-25865 Auto include inline node as a part of selection when selection ends on an inline
|
|
10
|
+
node
|
|
11
|
+
- [#169428](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169428)
|
|
12
|
+
[`ded743b539788`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ded743b539788) -
|
|
13
|
+
[ux] ED-25865 auto expand selection to include inline node
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 1.5.6
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#171440](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171440)
|
|
24
|
+
[`835f7bbff3122`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/835f7bbff3122) -
|
|
25
|
+
ED-25816: refactors plugins to meet folder standards
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
|
|
3
28
|
## 1.5.5
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "selectionPlugin", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _selectionPlugin.selectionPlugin;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _selectionPlugin = require("./selectionPlugin");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.autoExpandSelectionRangeOnInlineNodePluginKey = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var autoExpandSelectionRangeOnInlineNodePluginKey = exports.autoExpandSelectionRangeOnInlineNodePluginKey = new _state.PluginKey('autoExpandSelectionRangeOnInlineNodePlugin');
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAutoExpandSelectionRangeOnInlineNodePlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
|
+
var _autoExpandSelectionRangeOnInlineNodeKey = require("./auto-expand-selection-range-on-inline-node-key");
|
|
11
|
+
var createAutoExpandSelectionRangeOnInlineNodePlugin = exports.createAutoExpandSelectionRangeOnInlineNodePlugin = function createAutoExpandSelectionRangeOnInlineNodePlugin() {
|
|
12
|
+
var mouseDownElement = null;
|
|
13
|
+
return new _safePlugin.SafePlugin({
|
|
14
|
+
key: _autoExpandSelectionRangeOnInlineNodeKey.autoExpandSelectionRangeOnInlineNodePluginKey,
|
|
15
|
+
props: {
|
|
16
|
+
handleDOMEvents: {
|
|
17
|
+
mousedown: function mousedown(_view, event) {
|
|
18
|
+
mouseDownElement = event.target;
|
|
19
|
+
},
|
|
20
|
+
mouseup: function mouseup(view, event) {
|
|
21
|
+
var mouseUpElement = event.target;
|
|
22
|
+
|
|
23
|
+
// terminate early if mouse down and mouse up elements are the same -> e.g a click event
|
|
24
|
+
if (mouseDownElement === mouseUpElement) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// terminate early if mouse up event is not fired on inline node
|
|
29
|
+
if (!isMouseUpOnSupportedNode(mouseUpElement)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var dispatch = view.dispatch,
|
|
33
|
+
state = view.state;
|
|
34
|
+
var selection = state.selection;
|
|
35
|
+
|
|
36
|
+
// terminate early if current selection is on a node
|
|
37
|
+
if (selection instanceof _state.NodeSelection) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// only expand range when experiment is enabled, also fire exposure events here
|
|
42
|
+
if ((0, _experiments.editorExperiment)('expand_selection_range_to_include_inline_node', true, {
|
|
43
|
+
exposure: true
|
|
44
|
+
})) {
|
|
45
|
+
// find the document position of the mouse up element
|
|
46
|
+
var elementStartPosition = view.posAtDOM(mouseUpElement, 0);
|
|
47
|
+
|
|
48
|
+
// find out the direction of selection
|
|
49
|
+
var isAnchorBeforeElement = selection.$anchor.pos <= elementStartPosition;
|
|
50
|
+
var expandedSelectionHeadPosition = isAnchorBeforeElement ? elementStartPosition + 1 : elementStartPosition;
|
|
51
|
+
|
|
52
|
+
// expand the selection to include the mouse up element
|
|
53
|
+
var tr = state.tr.setSelection(_state.TextSelection.create(state.doc, selection.$anchor.pos, expandedSelectionHeadPosition));
|
|
54
|
+
dispatch(tr);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var isMouseUpOnSupportedNode = function isMouseUpOnSupportedNode(mouseUpElement) {
|
|
62
|
+
var supportedNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
63
|
+
var supportedNodeViewContentClassNamesList = supportedNodes.map(function (nodeType) {
|
|
64
|
+
return ".".concat(nodeType, "View-content-wrap");
|
|
65
|
+
}).join(', ');
|
|
66
|
+
return !!mouseUpElement.closest(supportedNodeViewContentClassNamesList);
|
|
67
|
+
};
|
|
@@ -7,10 +7,10 @@ exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = expor
|
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _types = require("../types");
|
|
10
11
|
var _actions = require("./actions");
|
|
11
12
|
var _gapCursorSelection = require("./gap-cursor-selection");
|
|
12
13
|
var _pluginFactory = require("./plugin-factory");
|
|
13
|
-
var _types = require("./types");
|
|
14
14
|
var _utils2 = require("./utils");
|
|
15
15
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
16
16
|
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.onCreateSelectionBetween = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
9
|
var DOC_START_POS = 0;
|
|
9
10
|
function isNodeContentEmpty(maybeNode) {
|
|
10
11
|
return (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.content.size) === 0 || (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.textContent) === '';
|
|
@@ -51,10 +52,23 @@ function findNextSelectionPosition(_ref) {
|
|
|
51
52
|
|
|
52
53
|
//ED-20209: If the targetHead position is just before some node, Then return $targetHead and not select any node.
|
|
53
54
|
var maybeNode = null;
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_drag_and_drop_lists')) {
|
|
56
|
+
// prosemirror calls 'createSelectionBetween' for native 'drop' events, it passes $anchor
|
|
57
|
+
// and $head which are based on a transformed document, but only provides the original
|
|
58
|
+
// doc. Need to remap the $head pos to last element in doc to avoid RangeErrors.
|
|
59
|
+
if ($targetHead.pos >= doc.nodeSize) {
|
|
60
|
+
maybeNode = doc.resolve(doc.nodeSize - 2).nodeBefore;
|
|
61
|
+
} else if ($targetHead.pos !== DOC_START_POS) {
|
|
62
|
+
var justBeforeHeadPos = $targetHead.pos - 1;
|
|
63
|
+
var $resolvedJustBeforeHeadPos = doc.resolve(justBeforeHeadPos);
|
|
64
|
+
maybeNode = $resolvedJustBeforeHeadPos.nodeAfter;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
if ($targetHead.pos !== DOC_START_POS) {
|
|
68
|
+
var _justBeforeHeadPos = $targetHead.pos - 1;
|
|
69
|
+
var _$resolvedJustBeforeHeadPos = doc.resolve(_justBeforeHeadPos);
|
|
70
|
+
maybeNode = _$resolvedJustBeforeHeadPos.nodeAfter;
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
73
|
if (maybeNode === null) {
|
|
60
74
|
maybeNode = $targetHead.nodeAfter;
|
|
@@ -9,7 +9,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
9
9
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var _gapCursorPluginKey = require("../
|
|
12
|
+
var _gapCursorPluginKey = require("../gap-cursor-plugin-key");
|
|
13
13
|
var _direction = require("./direction");
|
|
14
14
|
var _selection2 = require("./selection");
|
|
15
15
|
var _utils3 = require("./utils");
|
|
@@ -9,6 +9,7 @@ exports.getMediaNearPos = getMediaNearPos;
|
|
|
9
9
|
exports.isTextBlockNearPos = exports.isLeftCursor = exports.isIgnoredClick = void 0;
|
|
10
10
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
11
11
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _selection = require("./selection");
|
|
13
14
|
var isLeftCursor = exports.isLeftCursor = function isLeftCursor(side) {
|
|
14
15
|
return side === _selection.Side.LEFT;
|
|
@@ -133,5 +134,11 @@ var getComputedStyleForLayoutMode = exports.getComputedStyleForLayoutMode = func
|
|
|
133
134
|
return window.getComputedStyle(tableContainer);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
137
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true) && node && node.type.name === 'layoutSection') {
|
|
138
|
+
var layoutSectionContainer = dom.querySelector('.layout-section-container');
|
|
139
|
+
if (layoutSectionContainer) {
|
|
140
|
+
return window.getComputedStyle(layoutSectionContainer);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
136
143
|
return style;
|
|
137
144
|
};
|
|
@@ -7,9 +7,9 @@ exports.default = keymapPlugin;
|
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
8
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
9
9
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
|
-
var _actions = require("
|
|
11
|
-
var _direction = require("
|
|
12
|
-
var _selection = require("
|
|
10
|
+
var _actions = require("./gap-cursor/actions");
|
|
11
|
+
var _direction = require("./gap-cursor/direction");
|
|
12
|
+
var _selection = require("./gap-cursor/selection");
|
|
13
13
|
function keymapPlugin() {
|
|
14
14
|
var map = {};
|
|
15
15
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, function (state, dispatch, view) {
|
|
@@ -10,11 +10,11 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _view2 = require("@atlaskit/editor-prosemirror/view");
|
|
12
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
|
-
var _actions = require("../gap-cursor/actions");
|
|
14
|
-
var _direction = require("../gap-cursor/direction");
|
|
15
|
-
var _utils2 = require("../gap-cursor/utils");
|
|
16
|
-
var _placeGapCursor = require("../gap-cursor/utils/place-gap-cursor");
|
|
17
13
|
var _gapCursorPluginKey = require("./gap-cursor-plugin-key");
|
|
14
|
+
var _actions = require("./gap-cursor/actions");
|
|
15
|
+
var _direction = require("./gap-cursor/direction");
|
|
16
|
+
var _utils2 = require("./gap-cursor/utils");
|
|
17
|
+
var _placeGapCursor = require("./gap-cursor/utils/place-gap-cursor");
|
|
18
18
|
var plugin = new _safePlugin.SafePlugin({
|
|
19
19
|
key: _gapCursorPluginKey.gapCursorPluginKey,
|
|
20
20
|
state: {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
8
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
9
|
-
var _commands = require("
|
|
9
|
+
var _commands = require("./commands");
|
|
10
10
|
function keymapPlugin() {
|
|
11
11
|
var list = {};
|
|
12
12
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, _commands.arrowRight, list);
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createMarkBoundaryCursorPlugin = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
8
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
9
|
-
var _markBoundaryCursorDecoration = require("../mark-boundary-cursor/ui/mark-boundary-cursor-decoration");
|
|
10
|
-
var _activeMarksSide = require("../mark-boundary-cursor/utils/active-marks-side");
|
|
11
9
|
var _markBoundaryCursorPluginKey = require("./mark-boundary-cursor-plugin-key");
|
|
10
|
+
var _markBoundaryCursorDecoration = require("./mark-boundary-cursor/ui/mark-boundary-cursor-decoration");
|
|
11
|
+
var _activeMarksSide = require("./mark-boundary-cursor/utils/active-marks-side");
|
|
12
12
|
var createMarkBoundaryCursorPlugin = exports.createMarkBoundaryCursorPlugin = function createMarkBoundaryCursorPlugin() {
|
|
13
13
|
return new _safePlugin.SafePlugin({
|
|
14
14
|
key: _markBoundaryCursorPluginKey.markBoundaryCursorPluginKey,
|
|
@@ -10,8 +10,8 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
|
+
var _types = require("../types");
|
|
13
14
|
var _reducer = require("./reducer");
|
|
14
|
-
var _types = require("./types");
|
|
15
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; }
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getInitialState = exports.createPlugin = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _actions = require("../actions");
|
|
10
|
-
var _pluginFactory = require("../plugin-factory");
|
|
11
9
|
var _types = require("../types");
|
|
12
|
-
var
|
|
10
|
+
var _actions = require("./actions");
|
|
13
11
|
var _createSelectionBetween = require("./events/create-selection-between");
|
|
14
12
|
var _keydown = require("./events/keydown");
|
|
13
|
+
var _pluginFactory = require("./plugin-factory");
|
|
14
|
+
var _utils = require("./utils");
|
|
15
15
|
var getInitialState = exports.getInitialState = function getInitialState(state) {
|
|
16
16
|
return {
|
|
17
17
|
decorationSet: (0, _utils.getDecorations)(state.tr),
|
|
@@ -17,7 +17,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
17
17
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
18
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
19
19
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
20
|
-
var _types = require("
|
|
20
|
+
var _types = require("../types");
|
|
21
21
|
var getDecorations = exports.getDecorations = function getDecorations(tr) {
|
|
22
22
|
if (tr.selection instanceof _state.NodeSelection) {
|
|
23
23
|
return _view.DecorationSet.create(tr.doc, [_view.Decoration.node(tr.selection.from, tr.selection.to, {
|
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.selectionPlugin = exports.default = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
-
var
|
|
10
|
+
var _autoExpandSelectionRangeOnInlineNodeMain = require("./pm-plugins/auto-expand-selection-range-on-inline-node-main");
|
|
11
|
+
var _commands = require("./pm-plugins/commands");
|
|
11
12
|
var _gapCursorKeymap = _interopRequireDefault(require("./pm-plugins/gap-cursor-keymap"));
|
|
12
13
|
var _gapCursorMain = _interopRequireDefault(require("./pm-plugins/gap-cursor-main"));
|
|
13
14
|
var _gapCursorPluginKey = require("./pm-plugins/gap-cursor-plugin-key");
|
|
@@ -77,6 +78,11 @@ var selectionPlugin = exports.selectionPlugin = function selectionPlugin(_ref2)
|
|
|
77
78
|
plugin: function plugin() {
|
|
78
79
|
return (0, _markBoundaryCursorMain.createMarkBoundaryCursorPlugin)();
|
|
79
80
|
}
|
|
81
|
+
}] : []), (0, _toConsumableArray2.default)((0, _platformFeatureFlags.fg)('editor_auto_expand_selection_on_inline_node') ? [{
|
|
82
|
+
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
83
|
+
plugin: function plugin() {
|
|
84
|
+
return (0, _autoExpandSelectionRangeOnInlineNodeMain.createAutoExpandSelectionRangeOnInlineNodePlugin)();
|
|
85
|
+
}
|
|
80
86
|
}] : []));
|
|
81
87
|
}
|
|
82
88
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { selectionPlugin } from './
|
|
1
|
+
export { selectionPlugin } from './selectionPlugin';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
|
+
import { autoExpandSelectionRangeOnInlineNodePluginKey } from './auto-expand-selection-range-on-inline-node-key';
|
|
5
|
+
export const createAutoExpandSelectionRangeOnInlineNodePlugin = () => {
|
|
6
|
+
let mouseDownElement = null;
|
|
7
|
+
return new SafePlugin({
|
|
8
|
+
key: autoExpandSelectionRangeOnInlineNodePluginKey,
|
|
9
|
+
props: {
|
|
10
|
+
handleDOMEvents: {
|
|
11
|
+
mousedown: (_view, event) => {
|
|
12
|
+
mouseDownElement = event.target;
|
|
13
|
+
},
|
|
14
|
+
mouseup: (view, event) => {
|
|
15
|
+
const mouseUpElement = event.target;
|
|
16
|
+
|
|
17
|
+
// terminate early if mouse down and mouse up elements are the same -> e.g a click event
|
|
18
|
+
if (mouseDownElement === mouseUpElement) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// terminate early if mouse up event is not fired on inline node
|
|
23
|
+
if (!isMouseUpOnSupportedNode(mouseUpElement)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const {
|
|
27
|
+
dispatch,
|
|
28
|
+
state
|
|
29
|
+
} = view;
|
|
30
|
+
const {
|
|
31
|
+
selection
|
|
32
|
+
} = state;
|
|
33
|
+
|
|
34
|
+
// terminate early if current selection is on a node
|
|
35
|
+
if (selection instanceof NodeSelection) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// only expand range when experiment is enabled, also fire exposure events here
|
|
40
|
+
if (editorExperiment('expand_selection_range_to_include_inline_node', true, {
|
|
41
|
+
exposure: true
|
|
42
|
+
})) {
|
|
43
|
+
// find the document position of the mouse up element
|
|
44
|
+
const elementStartPosition = view.posAtDOM(mouseUpElement, 0);
|
|
45
|
+
|
|
46
|
+
// find out the direction of selection
|
|
47
|
+
const isAnchorBeforeElement = selection.$anchor.pos <= elementStartPosition;
|
|
48
|
+
const expandedSelectionHeadPosition = isAnchorBeforeElement ? elementStartPosition + 1 : elementStartPosition;
|
|
49
|
+
|
|
50
|
+
// expand the selection to include the mouse up element
|
|
51
|
+
const tr = state.tr.setSelection(TextSelection.create(state.doc, selection.$anchor.pos, expandedSelectionHeadPosition));
|
|
52
|
+
dispatch(tr);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const isMouseUpOnSupportedNode = mouseUpElement => {
|
|
60
|
+
const supportedNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
61
|
+
const supportedNodeViewContentClassNamesList = supportedNodes.map(nodeType => `.${nodeType}View-content-wrap`).join(', ');
|
|
62
|
+
return !!mouseUpElement.closest(supportedNodeViewContentClassNamesList);
|
|
63
|
+
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { isIgnored as isIgnoredByGapCursor } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { isEmptyParagraph, isNodeEmpty } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { RelativeSelectionPos, SelectionDirection, selectionPluginKey } from '../types';
|
|
5
6
|
import { SelectionActionTypes } from './actions';
|
|
6
7
|
import { GapCursorSelection, Side } from './gap-cursor-selection';
|
|
7
8
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
8
|
-
import { RelativeSelectionPos, SelectionDirection, selectionPluginKey } from './types';
|
|
9
9
|
import { findFirstChildNodeToSelect, findLastChildNodeToSelect, findSelectableContainerAfter, findSelectableContainerBefore, findSelectableContainerParent, isSelectableContainerNode, isSelectionAtEndOfParentNode, isSelectionAtStartOfParentNode } from './utils';
|
|
10
10
|
export const selectNearNode = (selectionRelativeToNode, selection) => ({
|
|
11
11
|
tr
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
const DOC_START_POS = 0;
|
|
3
4
|
function isNodeContentEmpty(maybeNode) {
|
|
4
5
|
return (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.content.size) === 0 || (maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.textContent) === '';
|
|
@@ -48,10 +49,23 @@ function findNextSelectionPosition({
|
|
|
48
49
|
|
|
49
50
|
//ED-20209: If the targetHead position is just before some node, Then return $targetHead and not select any node.
|
|
50
51
|
let maybeNode = null;
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (fg('platform_editor_fix_drag_and_drop_lists')) {
|
|
53
|
+
// prosemirror calls 'createSelectionBetween' for native 'drop' events, it passes $anchor
|
|
54
|
+
// and $head which are based on a transformed document, but only provides the original
|
|
55
|
+
// doc. Need to remap the $head pos to last element in doc to avoid RangeErrors.
|
|
56
|
+
if ($targetHead.pos >= doc.nodeSize) {
|
|
57
|
+
maybeNode = doc.resolve(doc.nodeSize - 2).nodeBefore;
|
|
58
|
+
} else if ($targetHead.pos !== DOC_START_POS) {
|
|
59
|
+
const justBeforeHeadPos = $targetHead.pos - 1;
|
|
60
|
+
const $resolvedJustBeforeHeadPos = doc.resolve(justBeforeHeadPos);
|
|
61
|
+
maybeNode = $resolvedJustBeforeHeadPos.nodeAfter;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
if ($targetHead.pos !== DOC_START_POS) {
|
|
65
|
+
const justBeforeHeadPos = $targetHead.pos - 1;
|
|
66
|
+
const $resolvedJustBeforeHeadPos = doc.resolve(justBeforeHeadPos);
|
|
67
|
+
maybeNode = $resolvedJustBeforeHeadPos.nodeAfter;
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
70
|
if (maybeNode === null) {
|
|
57
71
|
maybeNode = $targetHead.nodeAfter;
|
|
@@ -3,7 +3,7 @@ import { isMediaNode, isNodeBeforeMediaNode, isPositionNearTableRow } from '@atl
|
|
|
3
3
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
4
4
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findDomRefAtPos, findPositionOfNodeBefore, removeNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import { gapCursorPluginKey } from '../
|
|
6
|
+
import { gapCursorPluginKey } from '../gap-cursor-plugin-key';
|
|
7
7
|
import { Direction, isBackward, isForward } from './direction';
|
|
8
8
|
import { GapCursorSelection, Side } from './selection';
|
|
9
9
|
import { isTextBlockNearPos } from './utils';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
|
|
2
2
|
import { TableSharedCssClassName, UnsupportedSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { Side } from './selection';
|
|
4
5
|
export const isLeftCursor = side => side === Side.LEFT;
|
|
5
6
|
export function getMediaNearPos(doc, $pos, schema, dir = -1) {
|
|
@@ -120,5 +121,11 @@ export const getComputedStyleForLayoutMode = (dom, node, style) => {
|
|
|
120
121
|
return window.getComputedStyle(tableContainer);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
124
|
+
if (editorExperiment('advanced_layouts', true) && node && node.type.name === 'layoutSection') {
|
|
125
|
+
const layoutSectionContainer = dom.querySelector('.layout-section-container');
|
|
126
|
+
if (layoutSectionContainer) {
|
|
127
|
+
return window.getComputedStyle(layoutSectionContainer);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
123
130
|
return style;
|
|
124
131
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { backspace, bindKeymapWithCommand, deleteKey, insertNewLine, moveDown, moveLeft, moveRight, moveUp } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { createParagraphNear } from '@atlaskit/editor-prosemirror/commands';
|
|
3
3
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
-
import { arrow, deleteNode } from '
|
|
5
|
-
import { Direction } from '
|
|
6
|
-
import { GapCursorSelection } from '
|
|
4
|
+
import { arrow, deleteNode } from './gap-cursor/actions';
|
|
5
|
+
import { Direction } from './gap-cursor/direction';
|
|
6
|
+
import { GapCursorSelection } from './gap-cursor/selection';
|
|
7
7
|
export default function keymapPlugin() {
|
|
8
8
|
const map = {};
|
|
9
9
|
bindKeymapWithCommand(insertNewLine.common, (state, dispatch, view) => {
|
|
@@ -4,11 +4,11 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
|
-
import { deleteNode } from '../gap-cursor/actions';
|
|
8
|
-
import { Direction } from '../gap-cursor/direction';
|
|
9
|
-
import { getLayoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
|
|
10
|
-
import { toDOM } from '../gap-cursor/utils/place-gap-cursor';
|
|
11
7
|
import { gapCursorPluginKey } from './gap-cursor-plugin-key';
|
|
8
|
+
import { deleteNode } from './gap-cursor/actions';
|
|
9
|
+
import { Direction } from './gap-cursor/direction';
|
|
10
|
+
import { getLayoutModeFromTargetNode, isIgnoredClick } from './gap-cursor/utils';
|
|
11
|
+
import { toDOM } from './gap-cursor/utils/place-gap-cursor';
|
|
12
12
|
const plugin = new SafePlugin({
|
|
13
13
|
key: gapCursorPluginKey,
|
|
14
14
|
state: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bindKeymapWithCommand, moveLeft, moveRight } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import { arrowLeft, arrowRight } from '
|
|
3
|
+
import { arrowLeft, arrowRight } from './commands';
|
|
4
4
|
function keymapPlugin() {
|
|
5
5
|
const list = {};
|
|
6
6
|
bindKeymapWithCommand(moveRight.common, arrowRight, list);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { createMarkBoundaryCursorDecoration } from '../mark-boundary-cursor/ui/mark-boundary-cursor-decoration';
|
|
4
|
-
import { getActiveMarksSide } from '../mark-boundary-cursor/utils/active-marks-side';
|
|
5
3
|
import { markBoundaryCursorPluginKey } from './mark-boundary-cursor-plugin-key';
|
|
4
|
+
import { createMarkBoundaryCursorDecoration } from './mark-boundary-cursor/ui/mark-boundary-cursor-decoration';
|
|
5
|
+
import { getActiveMarksSide } from './mark-boundary-cursor/utils/active-marks-side';
|
|
6
6
|
export const createMarkBoundaryCursorPlugin = () => {
|
|
7
7
|
return new SafePlugin({
|
|
8
8
|
key: markBoundaryCursorPluginKey,
|
|
@@ -2,8 +2,8 @@ import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
+
import { selectionPluginKey } from '../types';
|
|
5
6
|
import { reducer } from './reducer';
|
|
6
|
-
import { selectionPluginKey } from './types';
|
|
7
7
|
import { getDecorations, isSelectableContainerNode } from './utils';
|
|
8
8
|
const handleDocChanged = (tr, pluginState) => {
|
|
9
9
|
// in some collab edge cases mapping decorations could throw an error
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { SelectionActionTypes } from '../actions';
|
|
4
|
-
import { createPluginState, getPluginState } from '../plugin-factory';
|
|
5
3
|
import { selectionPluginKey } from '../types';
|
|
6
|
-
import {
|
|
4
|
+
import { SelectionActionTypes } from './actions';
|
|
7
5
|
import { onCreateSelectionBetween } from './events/create-selection-between';
|
|
8
6
|
import { createOnKeydown } from './events/keydown';
|
|
7
|
+
import { createPluginState, getPluginState } from './plugin-factory';
|
|
8
|
+
import { getDecorations, shouldRecalcDecorations } from './utils';
|
|
9
9
|
export const getInitialState = state => ({
|
|
10
10
|
decorationSet: getDecorations(state.tr),
|
|
11
11
|
selection: state.selection
|
|
@@ -4,7 +4,7 @@ import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit
|
|
|
4
4
|
import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { selectionPluginKey } from '
|
|
7
|
+
import { selectionPluginKey } from '../types';
|
|
8
8
|
export const getDecorations = tr => {
|
|
9
9
|
if (tr.selection instanceof NodeSelection) {
|
|
10
10
|
return DecorationSet.create(tr.doc, [Decoration.node(tr.selection.from, tr.selection.to, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import {
|
|
2
|
+
import { createAutoExpandSelectionRangeOnInlineNodePlugin } from './pm-plugins/auto-expand-selection-range-on-inline-node-main';
|
|
3
|
+
import { selectNearNode } from './pm-plugins/commands';
|
|
3
4
|
import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
|
|
4
5
|
import gapCursorPlugin from './pm-plugins/gap-cursor-main';
|
|
5
6
|
import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
|
|
@@ -60,6 +61,9 @@ export const selectionPlugin = ({
|
|
|
60
61
|
}, ...(fg('platform_editor_mark_boundary_cursor') ? [{
|
|
61
62
|
name: 'markBoundaryCursor',
|
|
62
63
|
plugin: () => createMarkBoundaryCursorPlugin()
|
|
64
|
+
}] : []), ...(fg('editor_auto_expand_selection_on_inline_node') ? [{
|
|
65
|
+
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
66
|
+
plugin: () => createAutoExpandSelectionRangeOnInlineNodePlugin()
|
|
63
67
|
}] : [])];
|
|
64
68
|
}
|
|
65
69
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { selectionPlugin } from './
|
|
1
|
+
export { selectionPlugin } from './selectionPlugin';
|