@atlaskit/editor-core 188.5.0 → 188.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/labs/next/presets/universal.js +1 -6
- package/dist/cjs/plugins/expand/index.js +0 -2
- package/dist/cjs/plugins/expand/nodeviews/index.js +37 -13
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/ui/Addon/click-area-helper.js +9 -11
- package/dist/cjs/ui/ContentStyles/index.js +13 -13
- package/dist/cjs/utils/selection.js +12 -14
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/labs/next/presets/universal.js +1 -6
- package/dist/es2019/plugins/expand/index.js +0 -2
- package/dist/es2019/plugins/expand/nodeviews/index.js +37 -13
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/ui/Addon/click-area-helper.js +4 -6
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/utils/selection.js +2 -17
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/labs/next/presets/universal.js +1 -6
- package/dist/esm/plugins/expand/index.js +0 -2
- package/dist/esm/plugins/expand/nodeviews/index.js +37 -13
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/ui/Addon/click-area-helper.js +4 -6
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/utils/selection.js +2 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +22 -8
- package/dist/types/plugins/expand/index.d.ts +1 -1
- package/dist/types/plugins/expand/nodeviews/index.d.ts +3 -2
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/utils/selection.d.ts +1 -4
- package/package.json +4 -3
- package/dist/cjs/plugins/selection/actions.js +0 -11
- package/dist/cjs/plugins/selection/commands.js +0 -257
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +0 -272
- package/dist/cjs/plugins/selection/gap-cursor/direction.js +0 -23
- package/dist/cjs/plugins/selection/gap-cursor/selection.js +0 -30
- package/dist/cjs/plugins/selection/gap-cursor/styles.js +0 -17
- package/dist/cjs/plugins/selection/gap-cursor/utils/is-ignored.js +0 -12
- package/dist/cjs/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -12
- package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -103
- package/dist/cjs/plugins/selection/gap-cursor/utils.js +0 -137
- package/dist/cjs/plugins/selection/gap-cursor-selection.js +0 -37
- package/dist/cjs/plugins/selection/index.js +0 -65
- package/dist/cjs/plugins/selection/plugin-factory.js +0 -49
- package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +0 -92
- package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +0 -115
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -46
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +0 -160
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -8
- package/dist/cjs/plugins/selection/pm-plugins/keymap.js +0 -16
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +0 -104
- package/dist/cjs/plugins/selection/reducer.js +0 -26
- package/dist/cjs/plugins/selection/types.js +0 -20
- package/dist/cjs/plugins/selection/utils.js +0 -280
- package/dist/cjs/selection-api/api.js +0 -27
- package/dist/es2019/plugins/selection/actions.js +0 -5
- package/dist/es2019/plugins/selection/commands.js +0 -250
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +0 -270
- package/dist/es2019/plugins/selection/gap-cursor/direction.js +0 -15
- package/dist/es2019/plugins/selection/gap-cursor/selection.js +0 -1
- package/dist/es2019/plugins/selection/gap-cursor/styles.js +0 -145
- package/dist/es2019/plugins/selection/gap-cursor/utils/is-ignored.js +0 -1
- package/dist/es2019/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -1
- package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -94
- package/dist/es2019/plugins/selection/gap-cursor/utils.js +0 -124
- package/dist/es2019/plugins/selection/gap-cursor-selection.js +0 -2
- package/dist/es2019/plugins/selection/index.js +0 -51
- package/dist/es2019/plugins/selection/plugin-factory.js +0 -43
- package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +0 -89
- package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +0 -112
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -40
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +0 -158
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -2
- package/dist/es2019/plugins/selection/pm-plugins/keymap.js +0 -10
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +0 -97
- package/dist/es2019/plugins/selection/reducer.js +0 -18
- package/dist/es2019/plugins/selection/types.js +0 -9
- package/dist/es2019/plugins/selection/utils.js +0 -233
- package/dist/es2019/selection-api/api.js +0 -20
- package/dist/esm/plugins/selection/actions.js +0 -5
- package/dist/esm/plugins/selection/commands.js +0 -251
- package/dist/esm/plugins/selection/gap-cursor/actions.js +0 -266
- package/dist/esm/plugins/selection/gap-cursor/direction.js +0 -15
- package/dist/esm/plugins/selection/gap-cursor/selection.js +0 -1
- package/dist/esm/plugins/selection/gap-cursor/styles.js +0 -10
- package/dist/esm/plugins/selection/gap-cursor/utils/is-ignored.js +0 -1
- package/dist/esm/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -1
- package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -97
- package/dist/esm/plugins/selection/gap-cursor/utils.js +0 -128
- package/dist/esm/plugins/selection/gap-cursor-selection.js +0 -2
- package/dist/esm/plugins/selection/index.js +0 -58
- package/dist/esm/plugins/selection/plugin-factory.js +0 -43
- package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +0 -86
- package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +0 -110
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -40
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +0 -154
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -2
- package/dist/esm/plugins/selection/pm-plugins/keymap.js +0 -10
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +0 -98
- package/dist/esm/plugins/selection/reducer.js +0 -19
- package/dist/esm/plugins/selection/types.js +0 -9
- package/dist/esm/plugins/selection/utils.js +0 -241
- package/dist/esm/selection-api/api.js +0 -21
- package/dist/types/plugins/selection/actions.d.ts +0 -17
- package/dist/types/plugins/selection/commands.d.ts +0 -10
- package/dist/types/plugins/selection/gap-cursor/actions.d.ts +0 -25
- package/dist/types/plugins/selection/gap-cursor/direction.d.ts +0 -10
- package/dist/types/plugins/selection/gap-cursor/selection.d.ts +0 -1
- package/dist/types/plugins/selection/gap-cursor/styles.d.ts +0 -2
- package/dist/types/plugins/selection/gap-cursor/utils/is-ignored.d.ts +0 -1
- package/dist/types/plugins/selection/gap-cursor/utils/is-valid-target-node.d.ts +0 -1
- package/dist/types/plugins/selection/gap-cursor/utils/place-gap-cursor.d.ts +0 -2
- package/dist/types/plugins/selection/gap-cursor/utils.d.ts +0 -8
- package/dist/types/plugins/selection/gap-cursor-selection.d.ts +0 -2
- package/dist/types/plugins/selection/index.d.ts +0 -13
- package/dist/types/plugins/selection/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/events/create-selection-between.d.ts +0 -4
- package/dist/types/plugins/selection/pm-plugins/events/keydown.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/gap-cursor-keymap.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/gap-cursor-main.d.ts +0 -6
- package/dist/types/plugins/selection/pm-plugins/gap-cursor-plugin-key.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/keymap.d.ts +0 -3
- package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +0 -7
- package/dist/types/plugins/selection/reducer.d.ts +0 -3
- package/dist/types/plugins/selection/types.d.ts +0 -12
- package/dist/types/plugins/selection/utils.d.ts +0 -58
- package/dist/types/selection-api/api.d.ts +0 -11
|
@@ -2,7 +2,6 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
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; }
|
|
4
4
|
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) { _defineProperty(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; }
|
|
5
|
-
import { createEditorSelectionAPI } from '../../../selection-api/api';
|
|
6
5
|
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../../../plugins';
|
|
7
6
|
import { datePlugin } from '../../../plugins/date';
|
|
8
7
|
import { captionPlugin } from '@atlaskit/editor-plugin-caption';
|
|
@@ -43,7 +42,6 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
43
42
|
var getEditorFeatureFlags = function getEditorFeatureFlags() {
|
|
44
43
|
return featureFlags;
|
|
45
44
|
};
|
|
46
|
-
var editorSelectionAPI = createEditorSelectionAPI();
|
|
47
45
|
var defaultPreset = createDefaultPreset(_objectSpread(_objectSpread({}, props), {}, {
|
|
48
46
|
createAnalyticsEvent: createAnalyticsEvent
|
|
49
47
|
}));
|
|
@@ -113,7 +111,6 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
113
111
|
allowDropzoneDropLine: isFullPage,
|
|
114
112
|
allowMediaSingleEditable: !isMobile,
|
|
115
113
|
allowRemoteDimensionsFetch: !isMobile,
|
|
116
|
-
editorSelectionAPI: editorSelectionAPI,
|
|
117
114
|
// This is a wild one. I didnt quite understand what the code was doing
|
|
118
115
|
// so a bit of guess for now.
|
|
119
116
|
allowMarkingUploadsAsIncomplete: isMobile,
|
|
@@ -161,7 +158,6 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
161
158
|
allowContextualMenu: !isMobile,
|
|
162
159
|
fullWidthEnabled: appearance === 'full-width',
|
|
163
160
|
wasFullWidthEnabled: prevAppearance && prevAppearance === 'full-width',
|
|
164
|
-
editorSelectionAPI: editorSelectionAPI,
|
|
165
161
|
getEditorFeatureFlags: getEditorFeatureFlags
|
|
166
162
|
}]);
|
|
167
163
|
}
|
|
@@ -202,8 +198,7 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
202
198
|
disableLayout: true
|
|
203
199
|
},
|
|
204
200
|
allowMediaGroup: false,
|
|
205
|
-
isCopyPasteEnabled: true
|
|
206
|
-
editorSelectionAPI: editorSelectionAPI
|
|
201
|
+
isCopyPasteEnabled: true
|
|
207
202
|
}]);
|
|
208
203
|
}
|
|
209
204
|
return builder;
|
|
@@ -9,8 +9,6 @@ import { getToolbarConfig } from './toolbar';
|
|
|
9
9
|
import { createExpandNode } from './commands';
|
|
10
10
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
11
11
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
12
|
-
// TO-DO: replace with editor-plugin-selection
|
|
13
|
-
|
|
14
12
|
var expandPlugin = function expandPlugin(_ref) {
|
|
15
13
|
var _api$featureFlags;
|
|
16
14
|
var _ref$config = _ref.config,
|
|
@@ -61,8 +61,12 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
61
61
|
state = _this$view.state,
|
|
62
62
|
dispatch = _this$view.dispatch;
|
|
63
63
|
if (_this.selectNearNode) {
|
|
64
|
-
var _this
|
|
65
|
-
|
|
64
|
+
var tr = _this.selectNearNode({
|
|
65
|
+
selectionRelativeToNode: RelativeSelectionPos.Start
|
|
66
|
+
})(state);
|
|
67
|
+
if (dispatch) {
|
|
68
|
+
dispatch(tr);
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
var pos = _this.getPos();
|
|
68
72
|
if (typeof pos === 'number') {
|
|
@@ -272,11 +276,18 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
272
276
|
selectionStart = _this$input4.selectionStart,
|
|
273
277
|
selectionEnd = _this$input4.selectionEnd;
|
|
274
278
|
if (selectionStart === selectionEnd && selectionStart === value.length) {
|
|
275
|
-
var _this$api2;
|
|
276
279
|
event.preventDefault();
|
|
277
|
-
var
|
|
280
|
+
var _this$view8 = _this.view,
|
|
281
|
+
state = _this$view8.state,
|
|
282
|
+
dispatch = _this$view8.dispatch;
|
|
278
283
|
_this.view.focus();
|
|
279
|
-
|
|
284
|
+
var tr = _this.selectNearNode({
|
|
285
|
+
selectionRelativeToNode: RelativeSelectionPos.End,
|
|
286
|
+
selection: NodeSelection.create(state.doc, pos)
|
|
287
|
+
})(state);
|
|
288
|
+
if (dispatch) {
|
|
289
|
+
dispatch(tr);
|
|
290
|
+
}
|
|
280
291
|
}
|
|
281
292
|
});
|
|
282
293
|
_defineProperty(this, "handleArrowLeftFromTitle", function (event) {
|
|
@@ -291,19 +302,31 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
291
302
|
selectionStart = _this$input5.selectionStart,
|
|
292
303
|
selectionEnd = _this$input5.selectionEnd;
|
|
293
304
|
if (selectionStart === selectionEnd && selectionStart === 0) {
|
|
294
|
-
var _this$
|
|
305
|
+
var _this$api;
|
|
295
306
|
event.preventDefault();
|
|
296
|
-
var
|
|
307
|
+
var _this$view9 = _this.view,
|
|
308
|
+
state = _this$view9.state,
|
|
309
|
+
dispatch = _this$view9.dispatch;
|
|
297
310
|
_this.view.focus();
|
|
298
|
-
var selectionSharedState = ((_this$
|
|
311
|
+
var selectionSharedState = ((_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.selection) === null || _this$api === void 0 ? void 0 : _this$api.sharedState.currentState()) || {};
|
|
299
312
|
// selectionRelativeToNode is undefined when user clicked to select node, then hit left to get focus in title
|
|
300
313
|
// This is a special case where we want to bypass node selection and jump straight to gap cursor
|
|
301
314
|
if ((selectionSharedState === null || selectionSharedState === void 0 ? void 0 : selectionSharedState.selectionRelativeToNode) === undefined) {
|
|
302
|
-
var _this
|
|
303
|
-
|
|
315
|
+
var tr = _this.selectNearNode({
|
|
316
|
+
selectionRelativeToNode: undefined,
|
|
317
|
+
selection: new GapCursorSelection(state.doc.resolve(pos), Side.LEFT)
|
|
318
|
+
})(state);
|
|
319
|
+
if (dispatch) {
|
|
320
|
+
dispatch(tr);
|
|
321
|
+
}
|
|
304
322
|
} else {
|
|
305
|
-
var _this
|
|
306
|
-
|
|
323
|
+
var _tr = _this.selectNearNode({
|
|
324
|
+
selectionRelativeToNode: RelativeSelectionPos.Start,
|
|
325
|
+
selection: NodeSelection.create(state.doc, pos)
|
|
326
|
+
})(state);
|
|
327
|
+
if (dispatch) {
|
|
328
|
+
dispatch(_tr);
|
|
329
|
+
}
|
|
307
330
|
}
|
|
308
331
|
}
|
|
309
332
|
});
|
|
@@ -445,6 +468,7 @@ export default function (_ref2) {
|
|
|
445
468
|
featureFlags = _ref2.featureFlags,
|
|
446
469
|
api = _ref2.api;
|
|
447
470
|
return function (node, view, getPos) {
|
|
448
|
-
|
|
471
|
+
var _api$selection;
|
|
472
|
+
return new ExpandNodeView(node, view, getPos, getIntl, isMobile, featureFlags, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api);
|
|
449
473
|
};
|
|
450
474
|
}
|
|
@@ -35,7 +35,6 @@ export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
|
35
35
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
36
36
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
37
37
|
export { default as findReplacePlugin } from './find-replace';
|
|
38
|
-
export { default as selectionPlugin } from './selection';
|
|
39
38
|
export { default as mobileSelectionPlugin } from './mobile-selection';
|
|
40
39
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
41
40
|
export { default as avatarGroupPlugin } from './avatar-group';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { closestElement } from '
|
|
2
|
-
import { setSelectionTopLevelBlocks
|
|
3
|
-
import { addParagraphAtEnd } from '
|
|
1
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { setSelectionTopLevelBlocks } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { addParagraphAtEnd } from '@atlaskit/editor-common/commands';
|
|
4
4
|
|
|
5
5
|
// we ignore all of the clicks made inside <div class="ak-editor-content-area" /> (but not clicks on the node itself)
|
|
6
6
|
var insideContentArea = function insideContentArea(ref) {
|
|
@@ -94,9 +94,7 @@ var outsideProsemirrorEditorClickHandler = function outsideProsemirrorEditorClic
|
|
|
94
94
|
if (isBottomAreaClicked) {
|
|
95
95
|
addParagraphAtEnd(tr);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
setSelectionTopLevelBlocks(tr, event, dom, view.posAtCoords.bind(view), isEditorFocused);
|
|
99
|
-
}
|
|
97
|
+
setSelectionTopLevelBlocks(tr, event, dom, view.posAtCoords.bind(view), isEditorFocused);
|
|
100
98
|
if (!tr.docChanged && !tr.selectionSet) {
|
|
101
99
|
return;
|
|
102
100
|
}
|
|
@@ -7,7 +7,6 @@ import { whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, inden
|
|
|
7
7
|
import { akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorDeleteBackgroundWithOpacity, akEditorSelectedNodeClassName, blockNodesVerticalMargin, editorFontSize, getSelectionStyles, SelectionStyle, akEditorLineHeight, akEditorSelectedBorderColor } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { MentionSharedCssClassName } from '@atlaskit/editor-common/mention';
|
|
9
9
|
import { telepointerStyle } from '../../plugins/collab-edit/styles';
|
|
10
|
-
import { gapCursorStyles } from '../../plugins/selection/gap-cursor/styles';
|
|
11
10
|
import { tableStyles } from '@atlaskit/editor-plugin-table/ui/common-styles';
|
|
12
11
|
import { blocktypeStyles } from '@atlaskit/editor-plugin-block-type/styles';
|
|
13
12
|
import { codeBlockStyles } from '../../plugins/code-block/styles';
|
|
@@ -28,6 +27,7 @@ import { linkSharedStyle, codeMarkSharedStyles, ruleSharedStyles } from '@atlask
|
|
|
28
27
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
29
28
|
import { EmojiSharedCssClassName } from '@atlaskit/editor-common/emoji';
|
|
30
29
|
import { N500, N30A, N200 } from '@atlaskit/theme/colors';
|
|
30
|
+
import { gapCursorStyles } from '@atlaskit/editor-common/selection';
|
|
31
31
|
export var linkStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", "\n }\n"])), linkSharedStyle);
|
|
32
32
|
var ruleStyles = function ruleStyles(props) {
|
|
33
33
|
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror {\n ", ";\n\n hr {\n cursor: pointer;\n padding: ", " 0;\n margin: calc(", "em - 4px) 0;\n background-clip: content-box;\n\n &.", " {\n outline: none;\n background-color: ", ";\n }\n }\n }\n"])), ruleSharedStyles(props), "var(--ds-space-050, 4px)", akEditorLineHeight, akEditorSelectedNodeClassName, "var(--ds-border-selected, ".concat(akEditorSelectedBorderColor, ")"));
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
|
-
import { NodeSelection, TextSelection
|
|
2
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
4
|
-
export { setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
5
|
-
export function setAllSelection(view) {
|
|
6
|
-
var state = view.state,
|
|
7
|
-
dispatch = view.dispatch;
|
|
8
|
-
var tr = state.tr.setSelection(new AllSelection(view.state.doc));
|
|
9
|
-
dispatch(tr);
|
|
10
|
-
}
|
|
11
|
-
export function setCellSelection(view, anchor, head) {
|
|
12
|
-
var state = view.state,
|
|
13
|
-
dispatch = view.dispatch;
|
|
14
|
-
dispatch(state.tr.setSelection(CellSelection.create(state.doc, anchor, head)));
|
|
15
|
-
}
|
|
4
|
+
export { setNodeSelection, setTextSelection, setAllSelection, setCellSelection } from '@atlaskit/editor-common/utils';
|
|
16
5
|
|
|
17
6
|
// checks if the given position is within the ProseMirror document
|
|
18
7
|
export var isValidPosition = function isValidPosition(pos, state) {
|
|
@@ -60,13 +60,13 @@ export declare function createDefaultPreset(options: EditorPresetProps & Default
|
|
|
60
60
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
61
61
|
};
|
|
62
62
|
}, CodeBlockOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
63
|
-
pluginConfiguration: import("
|
|
63
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
64
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
64
65
|
commands: {
|
|
65
66
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
66
|
-
selectNearNode: import("@atlaskit/editor-common/types").EditorCommandWithMetadata;
|
|
67
67
|
};
|
|
68
68
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
69
|
-
}, import("
|
|
69
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
|
|
70
70
|
dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
71
71
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
72
72
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
@@ -257,7 +257,14 @@ export declare function createDefaultPreset(options: EditorPresetProps & Default
|
|
|
257
257
|
sharedState: {
|
|
258
258
|
hasFocus: boolean;
|
|
259
259
|
};
|
|
260
|
-
}, undefined
|
|
260
|
+
}, undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
261
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
262
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
263
|
+
commands: {
|
|
264
|
+
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
265
|
+
};
|
|
266
|
+
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
267
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>];
|
|
261
268
|
sharedState: import("@atlaskit/editor-plugin-media/types").MediaPluginState | null;
|
|
262
269
|
actions: {
|
|
263
270
|
insertMediaAsMediaSingle: import("@atlaskit/editor-plugin-media/types").InsertMediaAsMediaSingle;
|
|
@@ -495,13 +502,13 @@ export declare function useDefaultPreset(props: EditorPresetProps & DefaultPrese
|
|
|
495
502
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
496
503
|
};
|
|
497
504
|
}, CodeBlockOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
498
|
-
pluginConfiguration: import("
|
|
505
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
506
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
499
507
|
commands: {
|
|
500
508
|
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
501
|
-
selectNearNode: import("@atlaskit/editor-common/types").EditorCommandWithMetadata;
|
|
502
509
|
};
|
|
503
510
|
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
504
|
-
}, import("
|
|
511
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
|
|
505
512
|
dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
506
513
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
507
514
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
@@ -692,7 +699,14 @@ export declare function useDefaultPreset(props: EditorPresetProps & DefaultPrese
|
|
|
692
699
|
sharedState: {
|
|
693
700
|
hasFocus: boolean;
|
|
694
701
|
};
|
|
695
|
-
}, undefined
|
|
702
|
+
}, undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
|
|
703
|
+
pluginConfiguration: import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined;
|
|
704
|
+
actions: import("@atlaskit/editor-plugin-selection").EditorSelectionAPI;
|
|
705
|
+
commands: {
|
|
706
|
+
displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
|
|
707
|
+
};
|
|
708
|
+
sharedState: import("@atlaskit/editor-common/selection").SelectionSharedState;
|
|
709
|
+
}, import("@atlaskit/editor-plugin-selection/types").SelectionPluginOptions | undefined>];
|
|
696
710
|
sharedState: import("@atlaskit/editor-plugin-media/types").MediaPluginState | null;
|
|
697
711
|
actions: {
|
|
698
712
|
insertMediaAsMediaSingle: import("@atlaskit/editor-plugin-media/types").InsertMediaAsMediaSingle;
|
|
@@ -2,7 +2,7 @@ import type { NextEditorPlugin, EditorProps } from '../../types';
|
|
|
2
2
|
import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
4
|
import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
-
import type { SelectionPlugin } from '
|
|
5
|
+
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
6
|
interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
7
7
|
allowInsertion?: boolean;
|
|
8
8
|
appearance?: EditorProps['appearance'];
|
|
@@ -2,8 +2,9 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { EditorView, NodeView, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { getPosHandlerNode, getPosHandler } from '../../../nodeviews/';
|
|
5
|
-
import type { FeatureFlags, ExtractInjectionAPI
|
|
5
|
+
import type { FeatureFlags, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
6
|
import type expandPlugin from '../index';
|
|
7
|
+
import type { SetSelectionRelativeToNode } from '@atlaskit/editor-common/selection';
|
|
7
8
|
export declare class ExpandNodeView implements NodeView {
|
|
8
9
|
private selectNearNode;
|
|
9
10
|
node: PmNode;
|
|
@@ -20,7 +21,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
20
21
|
isMobile: boolean;
|
|
21
22
|
featureFlags: FeatureFlags;
|
|
22
23
|
api: ExtractInjectionAPI<typeof expandPlugin> | undefined;
|
|
23
|
-
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, featureFlags: FeatureFlags, selectNearNode:
|
|
24
|
+
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, featureFlags: FeatureFlags, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<typeof expandPlugin> | undefined);
|
|
24
25
|
private initHandlers;
|
|
25
26
|
private focusTitle;
|
|
26
27
|
private handleIconKeyDown;
|
|
@@ -35,7 +35,6 @@ export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
|
35
35
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
36
36
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
37
37
|
export { default as findReplacePlugin } from './find-replace';
|
|
38
|
-
export { default as selectionPlugin } from './selection';
|
|
39
38
|
export { default as mobileSelectionPlugin } from './mobile-selection';
|
|
40
39
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
41
40
|
export { default as avatarGroupPlugin } from './avatar-group';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
1
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
export { setNodeSelection, setTextSelection, } from '@atlaskit/editor-common/utils';
|
|
5
|
-
export declare function setAllSelection(view: EditorView): void;
|
|
6
|
-
export declare function setCellSelection(view: EditorView, anchor: number, head?: number): void;
|
|
3
|
+
export { setNodeSelection, setTextSelection, setAllSelection, setCellSelection, } from '@atlaskit/editor-common/utils';
|
|
7
4
|
export declare const isValidPosition: (pos: number, state: EditorState) => boolean;
|
|
8
5
|
export declare const duplicateSelection: (selectionToDuplicate: Selection, doc: Node) => Selection | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "188.5.
|
|
3
|
+
"version": "188.5.2",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/code": "^14.6.0",
|
|
56
56
|
"@atlaskit/date": "^0.10.0",
|
|
57
57
|
"@atlaskit/datetime-picker": "^12.10.0",
|
|
58
|
-
"@atlaskit/editor-common": "^76.
|
|
58
|
+
"@atlaskit/editor-common": "^76.8.0",
|
|
59
59
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
60
60
|
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
61
61
|
"@atlaskit/editor-palette": "1.5.1",
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
"@atlaskit/editor-plugin-placeholder": "^0.1.0",
|
|
88
88
|
"@atlaskit/editor-plugin-quick-insert": "^0.2.0",
|
|
89
89
|
"@atlaskit/editor-plugin-rule": "^0.1.0",
|
|
90
|
-
"@atlaskit/editor-plugin-
|
|
90
|
+
"@atlaskit/editor-plugin-selection": "^0.1.0",
|
|
91
|
+
"@atlaskit/editor-plugin-table": "^5.0.0",
|
|
91
92
|
"@atlaskit/editor-plugin-text-formatting": "^0.4.0",
|
|
92
93
|
"@atlaskit/editor-plugin-type-ahead": "^0.5.0",
|
|
93
94
|
"@atlaskit/editor-plugin-unsupported-content": "^0.2.0",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SelectionActionTypes = void 0;
|
|
7
|
-
var SelectionActionTypes = exports.SelectionActionTypes = /*#__PURE__*/function (SelectionActionTypes) {
|
|
8
|
-
SelectionActionTypes["SET_DECORATIONS"] = "SET_DECORATIONS";
|
|
9
|
-
SelectionActionTypes["SET_RELATIVE_SELECTION"] = "SET_RELATIVE_SELECTION";
|
|
10
|
-
return SelectionActionTypes;
|
|
11
|
-
}({});
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setSelectionRelativeToNode = exports.setSelectionInsideAtNodeEnd = exports.selectNearNode = exports.arrowRight = exports.arrowLeft = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var _gapCursorSelection = require("./gap-cursor-selection");
|
|
9
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
10
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
|
-
var _actions = require("./actions");
|
|
12
|
-
var _pluginFactory = require("./plugin-factory");
|
|
13
|
-
var _utils2 = require("./utils");
|
|
14
|
-
var _types = require("./types");
|
|
15
|
-
var selectNearNode = exports.selectNearNode = function selectNearNode(selectionRelativeToNode, selection) {
|
|
16
|
-
return function (_ref) {
|
|
17
|
-
var tr = _ref.tr;
|
|
18
|
-
tr.setMeta(_types.selectionPluginKey, {
|
|
19
|
-
type: _actions.SelectionActionTypes.SET_RELATIVE_SELECTION,
|
|
20
|
-
selectionRelativeToNode: selectionRelativeToNode
|
|
21
|
-
});
|
|
22
|
-
if (selection) {
|
|
23
|
-
return tr.setSelection(selection);
|
|
24
|
-
}
|
|
25
|
-
return tr;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
var setSelectionRelativeToNode = exports.setSelectionRelativeToNode = function setSelectionRelativeToNode(selectionRelativeToNode, selection) {
|
|
29
|
-
return (0, _pluginFactory.createCommand)({
|
|
30
|
-
type: _actions.SelectionActionTypes.SET_RELATIVE_SELECTION,
|
|
31
|
-
selectionRelativeToNode: selectionRelativeToNode
|
|
32
|
-
}, function (tr) {
|
|
33
|
-
return selectNearNode(selectionRelativeToNode, selection)({
|
|
34
|
-
tr: tr
|
|
35
|
-
}) || tr;
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
var arrowRight = exports.arrowRight = function arrowRight(state, dispatch) {
|
|
39
|
-
var selection = state.selection;
|
|
40
|
-
if (selection instanceof _gapCursorSelection.GapCursorSelection) {
|
|
41
|
-
return arrowRightFromGapCursor(selection)(state, dispatch);
|
|
42
|
-
} else if (selection instanceof _state.NodeSelection) {
|
|
43
|
-
return arrowRightFromNode(selection)(state, dispatch);
|
|
44
|
-
} else if (selection instanceof _state.TextSelection) {
|
|
45
|
-
return arrowRightFromText(selection)(state, dispatch);
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
};
|
|
49
|
-
var arrowLeft = exports.arrowLeft = function arrowLeft(state, dispatch) {
|
|
50
|
-
var selection = state.selection;
|
|
51
|
-
if (selection instanceof _gapCursorSelection.GapCursorSelection) {
|
|
52
|
-
return arrowLeftFromGapCursor(selection)(state, dispatch);
|
|
53
|
-
} else if (selection instanceof _state.NodeSelection) {
|
|
54
|
-
return arrowLeftFromNode(selection)(state, dispatch);
|
|
55
|
-
} else if (selection instanceof _state.TextSelection) {
|
|
56
|
-
return arrowLeftFromText(selection)(state, dispatch);
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
60
|
-
var arrowRightFromGapCursor = function arrowRightFromGapCursor(selection) {
|
|
61
|
-
return function (state, dispatch) {
|
|
62
|
-
var $from = selection.$from,
|
|
63
|
-
$to = selection.$to,
|
|
64
|
-
side = selection.side;
|
|
65
|
-
if (side === _gapCursorSelection.Side.LEFT) {
|
|
66
|
-
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
67
|
-
if (selectableNode) {
|
|
68
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
69
|
-
}
|
|
70
|
-
} else if (side === _gapCursorSelection.Side.RIGHT && (0, _utils2.isSelectionAtEndOfParentNode)($from, selection)) {
|
|
71
|
-
var _selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
72
|
-
if (_selectableNode) {
|
|
73
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode.pos))(state, dispatch);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(selection) {
|
|
80
|
-
return function (state, dispatch) {
|
|
81
|
-
var $from = selection.$from,
|
|
82
|
-
side = selection.side;
|
|
83
|
-
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
84
|
-
selectionRelativeToNode = _getPluginState.selectionRelativeToNode;
|
|
85
|
-
if (side === _gapCursorSelection.Side.RIGHT) {
|
|
86
|
-
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
87
|
-
if (selectableNode) {
|
|
88
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
89
|
-
}
|
|
90
|
-
} else if (side === _gapCursorSelection.Side.LEFT && (0, _utils2.isSelectionAtStartOfParentNode)($from, selection)) {
|
|
91
|
-
if (selectionRelativeToNode === _types.RelativeSelectionPos.Before) {
|
|
92
|
-
var $parent = state.doc.resolve(selection.$from.before(selection.$from.depth));
|
|
93
|
-
if ($parent) {
|
|
94
|
-
var _selectableNode2 = (0, _utils2.findSelectableContainerBefore)($parent, state.doc);
|
|
95
|
-
if (_selectableNode2 && (0, _selection.isIgnored)(_selectableNode2.node)) {
|
|
96
|
-
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
97
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, _selectableNode2.pos))(state, dispatch);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// we don't return this as we want to reset the relative pos, but not block other plugins
|
|
101
|
-
// from responding to arrow left key
|
|
102
|
-
setSelectionRelativeToNode()(state, dispatch);
|
|
103
|
-
} else {
|
|
104
|
-
var _selectableNode3 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
105
|
-
if (_selectableNode3) {
|
|
106
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode3.pos))(state, dispatch);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
var arrowRightFromNode = function arrowRightFromNode(selection) {
|
|
114
|
-
return function (state, dispatch) {
|
|
115
|
-
var node = selection.node,
|
|
116
|
-
from = selection.from,
|
|
117
|
-
$to = selection.$to;
|
|
118
|
-
var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
|
|
119
|
-
selectionRelativeToNode = _getPluginState2.selectionRelativeToNode;
|
|
120
|
-
if (node.isAtom) {
|
|
121
|
-
if ((0, _utils2.isSelectionAtEndOfParentNode)($to, selection)) {
|
|
122
|
-
// selection is for inline node that is the last child of its parent node - set text selection after it
|
|
123
|
-
return findAndSetTextSelection(_types.RelativeSelectionPos.End, state.doc.resolve(from + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
} else if (selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
|
|
127
|
-
// selection is for container node - set selection inside it at the start
|
|
128
|
-
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Inside, node, from)(state, dispatch);
|
|
129
|
-
} else if ((0, _selection.isIgnored)(node) && (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.End)) {
|
|
130
|
-
var selectableNode = (0, _utils2.findSelectableContainerAfter)($to, state.doc);
|
|
131
|
-
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
132
|
-
// selection is for node without gap cursor followed by another node without gap cursor - set node selection for next node
|
|
133
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
var arrowLeftFromNode = function arrowLeftFromNode(selection) {
|
|
140
|
-
return function (state, dispatch) {
|
|
141
|
-
var node = selection.node,
|
|
142
|
-
from = selection.from,
|
|
143
|
-
to = selection.to,
|
|
144
|
-
$from = selection.$from;
|
|
145
|
-
var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
146
|
-
selectionRelativeToNode = _getPluginState3.selectionRelativeToNode;
|
|
147
|
-
if (node.isAtom) {
|
|
148
|
-
if ((0, _utils2.isSelectionAtStartOfParentNode)($from, selection)) {
|
|
149
|
-
// selection is for inline node that is the first child of its parent node - set text selection before it
|
|
150
|
-
return findAndSetTextSelection(_types.RelativeSelectionPos.Start, state.doc.resolve(from), _types.SelectionDirection.Before)(state, dispatch);
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
} else if (selectionRelativeToNode === _types.RelativeSelectionPos.End) {
|
|
154
|
-
// selection is for container node - set selection inside it at the end
|
|
155
|
-
return setSelectionInsideAtNodeEnd(_types.RelativeSelectionPos.Inside, node, from, to)(state, dispatch);
|
|
156
|
-
} else if (!selectionRelativeToNode || selectionRelativeToNode === _types.RelativeSelectionPos.Inside) {
|
|
157
|
-
// selection is for container node - set selection inside it at the start
|
|
158
|
-
// (this is a special case when the user selects by clicking node)
|
|
159
|
-
return setSelectionInsideAtNodeStart(_types.RelativeSelectionPos.Before, node, from)(state, dispatch);
|
|
160
|
-
} else if ((0, _selection.isIgnored)(node) && selectionRelativeToNode === _types.RelativeSelectionPos.Start) {
|
|
161
|
-
// selection is for node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
162
|
-
var selectableNode = (0, _utils2.findSelectableContainerBefore)($from, state.doc);
|
|
163
|
-
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
164
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return false;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
var arrowRightFromText = function arrowRightFromText(selection) {
|
|
171
|
-
return function (state, dispatch) {
|
|
172
|
-
if ((0, _utils2.isSelectionAtEndOfParentNode)(selection.$to, selection)) {
|
|
173
|
-
var selectableNode = (0, _utils2.findSelectableContainerParent)(selection);
|
|
174
|
-
if (selectableNode) {
|
|
175
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return false;
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
182
|
-
return function (state, dispatch) {
|
|
183
|
-
var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
|
|
184
|
-
selectionRelativeToNode = _getPluginState4.selectionRelativeToNode;
|
|
185
|
-
if (selectionRelativeToNode === _types.RelativeSelectionPos.Before) {
|
|
186
|
-
var selectableNode = (0, _utils2.findSelectableContainerBefore)(selection.$from, state.doc);
|
|
187
|
-
if (selectableNode && (0, _selection.isIgnored)(selectableNode.node)) {
|
|
188
|
-
// selection is inside node without gap cursor preceeded by another node without gap cursor - set node selection for previous node
|
|
189
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.End, _state.NodeSelection.create(state.doc, selectableNode.pos))(state, dispatch);
|
|
190
|
-
}
|
|
191
|
-
// we don't return this as we want to reset the relative pos, but not block other plugins
|
|
192
|
-
// from responding to arrow left key
|
|
193
|
-
setSelectionRelativeToNode(undefined)(state, dispatch);
|
|
194
|
-
} else if ((0, _utils2.isSelectionAtStartOfParentNode)(selection.$from, selection)) {
|
|
195
|
-
var _selectableNode4 = (0, _utils2.findSelectableContainerParent)(selection);
|
|
196
|
-
if (_selectableNode4) {
|
|
197
|
-
return setSelectionRelativeToNode(_types.RelativeSelectionPos.Start, _state.NodeSelection.create(state.doc, _selectableNode4.pos))(state, dispatch);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return false;
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
var findAndSetTextSelection = function findAndSetTextSelection(selectionRelativeToNode, $pos, dir) {
|
|
204
|
-
return function (state, dispatch) {
|
|
205
|
-
var sel = _state.Selection.findFrom($pos, dir, true);
|
|
206
|
-
if (sel) {
|
|
207
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, sel)(state, dispatch);
|
|
208
|
-
}
|
|
209
|
-
return false;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
var setSelectionInsideAtNodeStart = function setSelectionInsideAtNodeStart(selectionRelativeToNode, node, pos) {
|
|
213
|
-
return function (state, dispatch) {
|
|
214
|
-
if ((0, _utils.isNodeEmpty)(node)) {
|
|
215
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(pos), _types.SelectionDirection.After)(state, dispatch);
|
|
216
|
-
}
|
|
217
|
-
var selectableNode = (0, _utils2.findFirstChildNodeToSelect)(node);
|
|
218
|
-
if (selectableNode) {
|
|
219
|
-
var childNode = selectableNode.node,
|
|
220
|
-
childPos = selectableNode.pos;
|
|
221
|
-
var selectionPos = pos + childPos + 1;
|
|
222
|
-
if (childNode.isText || childNode.isAtom) {
|
|
223
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.Before)(state, dispatch);
|
|
224
|
-
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
225
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.Before)(state, dispatch);
|
|
226
|
-
} else if (!(0, _selection.isIgnored)(node)) {
|
|
227
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos), _gapCursorSelection.Side.LEFT))(state, dispatch);
|
|
228
|
-
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
229
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return false;
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
var setSelectionInsideAtNodeEnd = exports.setSelectionInsideAtNodeEnd = function setSelectionInsideAtNodeEnd(selectionRelativeToNode, node, from, to) {
|
|
236
|
-
return function (state, dispatch) {
|
|
237
|
-
if ((0, _utils.isNodeEmpty)(node)) {
|
|
238
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(to), _types.SelectionDirection.Before)(state, dispatch);
|
|
239
|
-
}
|
|
240
|
-
var selectableNode = (0, _utils2.findLastChildNodeToSelect)(node);
|
|
241
|
-
if (selectableNode) {
|
|
242
|
-
var childNode = selectableNode.node,
|
|
243
|
-
childPos = selectableNode.pos;
|
|
244
|
-
var selectionPos = from + childPos + childNode.nodeSize;
|
|
245
|
-
if (childNode.isText || childNode.isAtom) {
|
|
246
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos + 1), _types.SelectionDirection.After)(state, dispatch);
|
|
247
|
-
} else if ((0, _utils.isEmptyParagraph)(childNode)) {
|
|
248
|
-
return findAndSetTextSelection(selectionRelativeToNode, state.doc.resolve(selectionPos), _types.SelectionDirection.After)(state, dispatch);
|
|
249
|
-
} else if (!(0, _selection.isIgnored)(node)) {
|
|
250
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, new _gapCursorSelection.GapCursorSelection(state.doc.resolve(selectionPos + 1), _gapCursorSelection.Side.RIGHT))(state, dispatch);
|
|
251
|
-
} else if ((0, _utils2.isSelectableContainerNode)(node)) {
|
|
252
|
-
return setSelectionRelativeToNode(selectionRelativeToNode, _state.NodeSelection.create(state.doc, selectionPos))(state, dispatch);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return false;
|
|
256
|
-
};
|
|
257
|
-
};
|