@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
|
@@ -0,0 +1,61 @@
|
|
|
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 var createAutoExpandSelectionRangeOnInlineNodePlugin = function createAutoExpandSelectionRangeOnInlineNodePlugin() {
|
|
6
|
+
var mouseDownElement = null;
|
|
7
|
+
return new SafePlugin({
|
|
8
|
+
key: autoExpandSelectionRangeOnInlineNodePluginKey,
|
|
9
|
+
props: {
|
|
10
|
+
handleDOMEvents: {
|
|
11
|
+
mousedown: function mousedown(_view, event) {
|
|
12
|
+
mouseDownElement = event.target;
|
|
13
|
+
},
|
|
14
|
+
mouseup: function mouseup(view, event) {
|
|
15
|
+
var 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
|
+
var dispatch = view.dispatch,
|
|
27
|
+
state = view.state;
|
|
28
|
+
var selection = state.selection;
|
|
29
|
+
|
|
30
|
+
// terminate early if current selection is on a node
|
|
31
|
+
if (selection instanceof NodeSelection) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// only expand range when experiment is enabled, also fire exposure events here
|
|
36
|
+
if (editorExperiment('expand_selection_range_to_include_inline_node', true, {
|
|
37
|
+
exposure: true
|
|
38
|
+
})) {
|
|
39
|
+
// find the document position of the mouse up element
|
|
40
|
+
var elementStartPosition = view.posAtDOM(mouseUpElement, 0);
|
|
41
|
+
|
|
42
|
+
// find out the direction of selection
|
|
43
|
+
var isAnchorBeforeElement = selection.$anchor.pos <= elementStartPosition;
|
|
44
|
+
var expandedSelectionHeadPosition = isAnchorBeforeElement ? elementStartPosition + 1 : elementStartPosition;
|
|
45
|
+
|
|
46
|
+
// expand the selection to include the mouse up element
|
|
47
|
+
var tr = state.tr.setSelection(TextSelection.create(state.doc, selection.$anchor.pos, expandedSelectionHeadPosition));
|
|
48
|
+
dispatch(tr);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var isMouseUpOnSupportedNode = function isMouseUpOnSupportedNode(mouseUpElement) {
|
|
56
|
+
var supportedNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
57
|
+
var supportedNodeViewContentClassNamesList = supportedNodes.map(function (nodeType) {
|
|
58
|
+
return ".".concat(nodeType, "View-content-wrap");
|
|
59
|
+
}).join(', ');
|
|
60
|
+
return !!mouseUpElement.closest(supportedNodeViewContentClassNamesList);
|
|
61
|
+
};
|
|
@@ -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 var selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
|
|
11
11
|
return function (_ref) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
var 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) === '';
|
|
@@ -45,10 +46,23 @@ function findNextSelectionPosition(_ref) {
|
|
|
45
46
|
|
|
46
47
|
//ED-20209: If the targetHead position is just before some node, Then return $targetHead and not select any node.
|
|
47
48
|
var maybeNode = null;
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (fg('platform_editor_fix_drag_and_drop_lists')) {
|
|
50
|
+
// prosemirror calls 'createSelectionBetween' for native 'drop' events, it passes $anchor
|
|
51
|
+
// and $head which are based on a transformed document, but only provides the original
|
|
52
|
+
// doc. Need to remap the $head pos to last element in doc to avoid RangeErrors.
|
|
53
|
+
if ($targetHead.pos >= doc.nodeSize) {
|
|
54
|
+
maybeNode = doc.resolve(doc.nodeSize - 2).nodeBefore;
|
|
55
|
+
} else if ($targetHead.pos !== DOC_START_POS) {
|
|
56
|
+
var justBeforeHeadPos = $targetHead.pos - 1;
|
|
57
|
+
var $resolvedJustBeforeHeadPos = doc.resolve(justBeforeHeadPos);
|
|
58
|
+
maybeNode = $resolvedJustBeforeHeadPos.nodeAfter;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
if ($targetHead.pos !== DOC_START_POS) {
|
|
62
|
+
var _justBeforeHeadPos = $targetHead.pos - 1;
|
|
63
|
+
var _$resolvedJustBeforeHeadPos = doc.resolve(_justBeforeHeadPos);
|
|
64
|
+
maybeNode = _$resolvedJustBeforeHeadPos.nodeAfter;
|
|
65
|
+
}
|
|
52
66
|
}
|
|
53
67
|
if (maybeNode === null) {
|
|
54
68
|
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 var isLeftCursor = function isLeftCursor(side) {
|
|
5
6
|
return side === Side.LEFT;
|
|
@@ -124,5 +125,11 @@ export var getComputedStyleForLayoutMode = function getComputedStyleForLayoutMod
|
|
|
124
125
|
return window.getComputedStyle(tableContainer);
|
|
125
126
|
}
|
|
126
127
|
}
|
|
128
|
+
if (editorExperiment('advanced_layouts', true) && node && node.type.name === 'layoutSection') {
|
|
129
|
+
var layoutSectionContainer = dom.querySelector('.layout-section-container');
|
|
130
|
+
if (layoutSectionContainer) {
|
|
131
|
+
return window.getComputedStyle(layoutSectionContainer);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
127
134
|
return style;
|
|
128
135
|
};
|
|
@@ -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
|
var map = {};
|
|
9
9
|
bindKeymapWithCommand(insertNewLine.common, function (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
|
var 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
|
var 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 var createMarkBoundaryCursorPlugin = function createMarkBoundaryCursorPlugin() {
|
|
7
7
|
return new SafePlugin({
|
|
8
8
|
key: markBoundaryCursorPluginKey,
|
|
@@ -5,8 +5,8 @@ import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
8
|
+
import { selectionPluginKey } from '../types';
|
|
8
9
|
import { reducer } from './reducer';
|
|
9
|
-
import { selectionPluginKey } from './types';
|
|
10
10
|
import { getDecorations, isSelectableContainerNode } from './utils';
|
|
11
11
|
var handleDocChanged = function handleDocChanged(tr, pluginState) {
|
|
12
12
|
// 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 var getInitialState = function getInitialState(state) {
|
|
10
10
|
return {
|
|
11
11
|
decorationSet: getDecorations(state.tr),
|
|
@@ -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 var getDecorations = function 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,6 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
-
import {
|
|
3
|
+
import { createAutoExpandSelectionRangeOnInlineNodePlugin } from './pm-plugins/auto-expand-selection-range-on-inline-node-main';
|
|
4
|
+
import { selectNearNode as _selectNearNode } from './pm-plugins/commands';
|
|
4
5
|
import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
|
|
5
6
|
import gapCursorPlugin from './pm-plugins/gap-cursor-main';
|
|
6
7
|
import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
|
|
@@ -70,6 +71,11 @@ export var selectionPlugin = function selectionPlugin(_ref2) {
|
|
|
70
71
|
plugin: function plugin() {
|
|
71
72
|
return createMarkBoundaryCursorPlugin();
|
|
72
73
|
}
|
|
74
|
+
}] : []), _toConsumableArray(fg('editor_auto_expand_selection_on_inline_node') ? [{
|
|
75
|
+
name: 'autoExpandSelectionRangeOnInlineNode',
|
|
76
|
+
plugin: function plugin() {
|
|
77
|
+
return createAutoExpandSelectionRangeOnInlineNodePlugin();
|
|
78
|
+
}
|
|
73
79
|
}] : []));
|
|
74
80
|
}
|
|
75
81
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { selectionPlugin } from './
|
|
2
|
-
export type { SelectionPlugin } from './
|
|
1
|
+
export { selectionPlugin } from './selectionPlugin';
|
|
2
|
+
export type { SelectionPlugin } from './selectionPluginType';
|
|
3
3
|
export type { EditorSelectionAPI, SetSelectionRelativeToNode, SelectionPluginOptions, } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { RelativeSelectionPos } from '
|
|
3
|
+
import type { RelativeSelectionPos } from '../types';
|
|
4
4
|
export declare enum SelectionActionTypes {
|
|
5
5
|
SET_DECORATIONS = "SET_DECORATIONS",
|
|
6
6
|
SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command, EditorCommandWithMetadata } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { RelativeSelectionPos } from '
|
|
4
|
+
import { RelativeSelectionPos } from '../types';
|
|
5
5
|
export declare const selectNearNode: EditorCommandWithMetadata;
|
|
6
6
|
export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: RelativeSelectionPos, selection?: Selection | null) => Command;
|
|
7
7
|
export declare const arrowRight: Command;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '../types';
|
|
2
2
|
export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import type { SelectionPluginState } from '../types';
|
|
1
2
|
import type { SelectionAction } from './actions';
|
|
2
|
-
import type { SelectionPluginState } from './types';
|
|
3
3
|
export declare function reducer(pluginState: SelectionPluginState, action: SelectionAction): SelectionPluginState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { selectionPlugin } from './
|
|
2
|
-
export type { SelectionPlugin } from './
|
|
1
|
+
export { selectionPlugin } from './selectionPlugin';
|
|
2
|
+
export type { SelectionPlugin } from './selectionPluginType';
|
|
3
3
|
export type { EditorSelectionAPI, SetSelectionRelativeToNode, SelectionPluginOptions, } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { RelativeSelectionPos } from '
|
|
3
|
+
import type { RelativeSelectionPos } from '../types';
|
|
4
4
|
export declare enum SelectionActionTypes {
|
|
5
5
|
SET_DECORATIONS = "SET_DECORATIONS",
|
|
6
6
|
SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command, EditorCommandWithMetadata } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { RelativeSelectionPos } from '
|
|
4
|
+
import { RelativeSelectionPos } from '../types';
|
|
5
5
|
export declare const selectNearNode: EditorCommandWithMetadata;
|
|
6
6
|
export declare const setSelectionRelativeToNode: (selectionRelativeToNode?: RelativeSelectionPos, selection?: Selection | null) => Command;
|
|
7
7
|
export declare const arrowRight: Command;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SelectionPluginState } from '
|
|
1
|
+
import type { SelectionPluginState } from '../types';
|
|
2
2
|
export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import type { SelectionPluginState } from '../types';
|
|
1
2
|
import type { SelectionAction } from './actions';
|
|
2
|
-
import type { SelectionPluginState } from './types';
|
|
3
3
|
export declare function reducer(pluginState: SelectionPluginState, action: SelectionAction): SelectionPluginState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Selection plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
"runReact18": true
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/editor-common": "^96.
|
|
23
|
+
"@atlaskit/editor-common": "^96.3.0",
|
|
24
24
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
25
25
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
26
26
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
27
27
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
28
|
+
"@atlaskit/tmp-editor-statsig": "2.25.0",
|
|
28
29
|
"@atlaskit/tokens": "^2.4.0",
|
|
29
30
|
"@babel/runtime": "^7.0.0"
|
|
30
31
|
},
|
|
@@ -36,6 +37,9 @@
|
|
|
36
37
|
},
|
|
37
38
|
"techstack": {
|
|
38
39
|
"@atlassian/frontend": {
|
|
40
|
+
"code-structure": [
|
|
41
|
+
"editor-plugin"
|
|
42
|
+
],
|
|
39
43
|
"import-structure": [
|
|
40
44
|
"atlassian-conventions"
|
|
41
45
|
],
|
|
@@ -69,7 +73,7 @@
|
|
|
69
73
|
},
|
|
70
74
|
"af:exports": {
|
|
71
75
|
".": "./src/index.ts",
|
|
72
|
-
"./types": "./src/types.ts"
|
|
76
|
+
"./types": "./src/types/index.ts"
|
|
73
77
|
},
|
|
74
78
|
"stricter": {
|
|
75
79
|
"no-unused-dependencies": {
|
|
@@ -82,6 +86,12 @@
|
|
|
82
86
|
},
|
|
83
87
|
"platform_editor_mark_boundary_cursor": {
|
|
84
88
|
"type": "boolean"
|
|
89
|
+
},
|
|
90
|
+
"platform_editor_fix_drag_and_drop_lists": {
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
},
|
|
93
|
+
"editor_auto_expand_selection_on_inline_node": {
|
|
94
|
+
"type": "boolean"
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
}
|
package/types/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection/types",
|
|
3
|
-
"main": "../dist/cjs/types.js",
|
|
4
|
-
"module": "../dist/esm/types.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/types.js",
|
|
3
|
+
"main": "../dist/cjs/types/index.js",
|
|
4
|
+
"module": "../dist/esm/types/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/types/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/types.d.ts",
|
|
7
|
+
"types": "../dist/types/types/index.d.ts",
|
|
8
8
|
"typesVersions": {
|
|
9
9
|
">=4.5 <5.4": {
|
|
10
10
|
"*": [
|
|
11
|
-
"../dist/types-ts4.5/types.d.ts"
|
|
11
|
+
"../dist/types-ts4.5/types/index.d.ts"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/cjs/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/esm/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/utils/inline-code-side.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/{mark-boundary-cursor → pm-plugins/mark-boundary-cursor}/marks-side.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types-ts4.5/{gap-cursor → pm-plugins/gap-cursor}/utils/is-valid-target-node.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types-ts4.5/{gap-cursor-selection.d.ts → pm-plugins/gap-cursor-selection.d.ts}
RENAMED
|
File without changes
|