@atlaskit/editor-plugin-selection 1.5.1 → 1.5.3

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 1.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#159308](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/159308)
8
+ [`14ef6f05d711c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/14ef6f05d711c) -
9
+ [ED-24690] Replace LD FF with Statsig platform-editor-single-player-expand
10
+ - Updated dependencies
11
+
12
+ ## 1.5.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#155735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155735)
17
+ [`14108e8c08732`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/14108e8c08732) -
18
+ Stop firing `document selected` event
19
+ - [#155735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155735)
20
+ [`1beeeda29023a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1beeeda29023a) -
21
+ Upgrades editor packages to react 18
22
+
3
23
  ## 1.5.1
4
24
 
5
25
  ### Patch Changes
@@ -21,7 +21,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
21
  var isCollapsedExpand = function isCollapsedExpand(node, _ref) {
22
22
  var __livePage = _ref.__livePage;
23
23
  var currentExpandedState;
24
- if (__livePage && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.single-player-expand')) {
24
+ if (__livePage && (0, _platformFeatureFlags.fg)('platform-editor-single-player-expand')) {
25
25
  currentExpandedState = node ? !_expand.expandedState.get(node) : undefined;
26
26
  } else if (__livePage) {
27
27
  currentExpandedState = node === null || node === void 0 ? void 0 : node.attrs.__expanded;
@@ -23,32 +23,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
23
23
  return new _safePlugin.SafePlugin({
24
24
  key: _types.selectionPluginKey,
25
25
  state: (0, _pluginFactory.createPluginState)(dispatch, getInitialState),
26
- view: function view() {
27
- return {
28
- update: function update(editorView, oldEditorState) {
29
- var state = editorView.state;
30
- if (!(0, _utils.shouldRecalcDecorations)({
31
- oldEditorState: oldEditorState,
32
- newEditorState: state
33
- })) {
34
- return;
35
- }
36
- var analyticsPayload = (0, _utils.getNodeSelectionAnalyticsPayload)(state.selection) || (0, _utils.getAllSelectionAnalyticsPayload)(state.selection) ||
37
- // We handle all range/cell selections except click and drag here, which is
38
- // handled in mouseup handler below
39
- !editorView.mouseDown && ((0, _utils.getRangeSelectionAnalyticsPayload)(state.selection, state.doc) || (0, _utils.getCellSelectionAnalyticsPayload)(state));
40
-
41
- // We have to use dispatchAnalyticsEvent over any of the analytics plugin helpers
42
- // as there were several issues caused by the fact that adding analytics through
43
- // the plugin adds a new step to the transaction
44
- // This causes prosemirror to run through some different code paths, eg. attempting
45
- // to map selection
46
- if (analyticsPayload) {
47
- dispatchAnalyticsEvent(analyticsPayload);
48
- }
49
- }
50
- };
51
- },
52
26
  appendTransaction: function appendTransaction(_transactions, oldEditorState, newEditorState) {
53
27
  if (!(0, _utils.shouldRecalcDecorations)({
54
28
  oldEditorState: oldEditorState,
@@ -86,20 +60,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
86
60
  handleDOMEvents: {
87
61
  keydown: (0, _keydown.createOnKeydown)({
88
62
  __livePage: options.__livePage
89
- }),
90
- // We only want to fire analytics for a click and drag range/cell selection when
91
- // the user has finished, otherwise we will get an event almost every time they move
92
- // their mouse which is too much
93
- mouseup: function mouseup(editorView, event) {
94
- var mouseEvent = event;
95
- if (!mouseEvent.shiftKey) {
96
- var analyticsPayload = (0, _utils.getRangeSelectionAnalyticsPayload)(editorView.state.selection, editorView.state.doc) || (0, _utils.getCellSelectionAnalyticsPayload)(editorView.state);
97
- if (analyticsPayload) {
98
- dispatchAnalyticsEvent(analyticsPayload);
99
- }
100
- }
101
- return false;
102
- }
63
+ })
103
64
  }
104
65
  }
105
66
  });
package/dist/cjs/utils.js CHANGED
@@ -9,34 +9,7 @@ Object.defineProperty(exports, "createSelectionClickHandler", {
9
9
  return _selection.createSelectionClickHandler;
10
10
  }
11
11
  });
12
- exports.findSelectableContainerParent = exports.findSelectableContainerBefore = exports.findSelectableContainerAfter = exports.findLastChildNodeToSelect = exports.findFirstChildNodeToSelect = void 0;
13
- Object.defineProperty(exports, "getAllSelectionAnalyticsPayload", {
14
- enumerable: true,
15
- get: function get() {
16
- return _selection.getAllSelectionAnalyticsPayload;
17
- }
18
- });
19
- Object.defineProperty(exports, "getCellSelectionAnalyticsPayload", {
20
- enumerable: true,
21
- get: function get() {
22
- return _selection.getCellSelectionAnalyticsPayload;
23
- }
24
- });
25
- exports.getDecorations = void 0;
26
- Object.defineProperty(exports, "getNodeSelectionAnalyticsPayload", {
27
- enumerable: true,
28
- get: function get() {
29
- return _selection.getNodeSelectionAnalyticsPayload;
30
- }
31
- });
32
- exports.getNodesToDecorateFromSelection = void 0;
33
- Object.defineProperty(exports, "getRangeSelectionAnalyticsPayload", {
34
- enumerable: true,
35
- get: function get() {
36
- return _selection.getRangeSelectionAnalyticsPayload;
37
- }
38
- });
39
- exports.isSelectionAtStartOfParentNode = exports.isSelectionAtEndOfParentNode = exports.isSelectableContainerNode = exports.isSelectableChildNode = void 0;
12
+ exports.isSelectionAtStartOfParentNode = exports.isSelectionAtEndOfParentNode = exports.isSelectableContainerNode = exports.isSelectableChildNode = exports.getNodesToDecorateFromSelection = exports.getDecorations = exports.findSelectableContainerParent = exports.findSelectableContainerBefore = exports.findSelectableContainerAfter = exports.findLastChildNodeToSelect = exports.findFirstChildNodeToSelect = void 0;
40
13
  exports.shouldRecalcDecorations = shouldRecalcDecorations;
41
14
  var _selection = require("@atlaskit/editor-common/selection");
42
15
  var _utils = require("@atlaskit/editor-common/utils");
@@ -1,6 +1,6 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
4
 
5
5
  /*
6
6
  * The way expand was built, no browser recognize selection on it.
@@ -17,7 +17,7 @@ const isCollapsedExpand = (node, {
17
17
  __livePage
18
18
  }) => {
19
19
  let currentExpandedState;
20
- if (__livePage && getBooleanFF('platform.editor.single-player-expand')) {
20
+ if (__livePage && fg('platform-editor-single-player-expand')) {
21
21
  currentExpandedState = node ? !expandedState.get(node) : undefined;
22
22
  } else if (__livePage) {
23
23
  currentExpandedState = node === null || node === void 0 ? void 0 : node.attrs.__expanded;
@@ -3,7 +3,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
3
3
  import { SelectionActionTypes } from '../actions';
4
4
  import { createPluginState, getPluginState } from '../plugin-factory';
5
5
  import { selectionPluginKey } from '../types';
6
- import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getDecorations, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, shouldRecalcDecorations } from '../utils';
6
+ import { getDecorations, shouldRecalcDecorations } from '../utils';
7
7
  import { onCreateSelectionBetween } from './events/create-selection-between';
8
8
  import { createOnKeydown } from './events/keydown';
9
9
  export const getInitialState = state => ({
@@ -14,32 +14,6 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
14
14
  return new SafePlugin({
15
15
  key: selectionPluginKey,
16
16
  state: createPluginState(dispatch, getInitialState),
17
- view: () => ({
18
- update: (editorView, oldEditorState) => {
19
- const {
20
- state
21
- } = editorView;
22
- if (!shouldRecalcDecorations({
23
- oldEditorState,
24
- newEditorState: state
25
- })) {
26
- return;
27
- }
28
- const analyticsPayload = getNodeSelectionAnalyticsPayload(state.selection) || getAllSelectionAnalyticsPayload(state.selection) ||
29
- // We handle all range/cell selections except click and drag here, which is
30
- // handled in mouseup handler below
31
- !editorView.mouseDown && (getRangeSelectionAnalyticsPayload(state.selection, state.doc) || getCellSelectionAnalyticsPayload(state));
32
-
33
- // We have to use dispatchAnalyticsEvent over any of the analytics plugin helpers
34
- // as there were several issues caused by the fact that adding analytics through
35
- // the plugin adds a new step to the transaction
36
- // This causes prosemirror to run through some different code paths, eg. attempting
37
- // to map selection
38
- if (analyticsPayload) {
39
- dispatchAnalyticsEvent(analyticsPayload);
40
- }
41
- }
42
- }),
43
17
  appendTransaction(_transactions, oldEditorState, newEditorState) {
44
18
  if (!shouldRecalcDecorations({
45
19
  oldEditorState,
@@ -79,20 +53,7 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
79
53
  handleDOMEvents: {
80
54
  keydown: createOnKeydown({
81
55
  __livePage: options.__livePage
82
- }),
83
- // We only want to fire analytics for a click and drag range/cell selection when
84
- // the user has finished, otherwise we will get an event almost every time they move
85
- // their mouse which is too much
86
- mouseup: (editorView, event) => {
87
- const mouseEvent = event;
88
- if (!mouseEvent.shiftKey) {
89
- const analyticsPayload = getRangeSelectionAnalyticsPayload(editorView.state.selection, editorView.state.doc) || getCellSelectionAnalyticsPayload(editorView.state);
90
- if (analyticsPayload) {
91
- dispatchAnalyticsEvent(analyticsPayload);
92
- }
93
- }
94
- return false;
95
- }
56
+ })
96
57
  }
97
58
  }
98
59
  });
@@ -1,4 +1,4 @@
1
- import { createSelectionClickHandler, getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
1
+ import { createSelectionClickHandler, isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
2
2
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
3
3
  import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
@@ -240,4 +240,4 @@ export const isSelectionAtEndOfParentNode = ($pos, selection) => {
240
240
  const $after = $pos.doc.resolve($pos.after());
241
241
  return $after.parent.content.size === $after.parentOffset;
242
242
  };
243
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler };
243
+ export { createSelectionClickHandler };
@@ -1,6 +1,6 @@
1
1
  import { expandedState } from '@atlaskit/editor-common/expand';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
4
 
5
5
  /*
6
6
  * The way expand was built, no browser recognize selection on it.
@@ -16,7 +16,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
16
16
  var isCollapsedExpand = function isCollapsedExpand(node, _ref) {
17
17
  var __livePage = _ref.__livePage;
18
18
  var currentExpandedState;
19
- if (__livePage && getBooleanFF('platform.editor.single-player-expand')) {
19
+ if (__livePage && fg('platform-editor-single-player-expand')) {
20
20
  currentExpandedState = node ? !expandedState.get(node) : undefined;
21
21
  } else if (__livePage) {
22
22
  currentExpandedState = node === null || node === void 0 ? void 0 : node.attrs.__expanded;
@@ -3,7 +3,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
3
3
  import { SelectionActionTypes } from '../actions';
4
4
  import { createPluginState, getPluginState } from '../plugin-factory';
5
5
  import { selectionPluginKey } from '../types';
6
- import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getDecorations, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, shouldRecalcDecorations } from '../utils';
6
+ import { getDecorations, shouldRecalcDecorations } from '../utils';
7
7
  import { onCreateSelectionBetween } from './events/create-selection-between';
8
8
  import { createOnKeydown } from './events/keydown';
9
9
  export var getInitialState = function getInitialState(state) {
@@ -17,32 +17,6 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
17
17
  return new SafePlugin({
18
18
  key: selectionPluginKey,
19
19
  state: createPluginState(dispatch, getInitialState),
20
- view: function view() {
21
- return {
22
- update: function update(editorView, oldEditorState) {
23
- var state = editorView.state;
24
- if (!shouldRecalcDecorations({
25
- oldEditorState: oldEditorState,
26
- newEditorState: state
27
- })) {
28
- return;
29
- }
30
- var analyticsPayload = getNodeSelectionAnalyticsPayload(state.selection) || getAllSelectionAnalyticsPayload(state.selection) ||
31
- // We handle all range/cell selections except click and drag here, which is
32
- // handled in mouseup handler below
33
- !editorView.mouseDown && (getRangeSelectionAnalyticsPayload(state.selection, state.doc) || getCellSelectionAnalyticsPayload(state));
34
-
35
- // We have to use dispatchAnalyticsEvent over any of the analytics plugin helpers
36
- // as there were several issues caused by the fact that adding analytics through
37
- // the plugin adds a new step to the transaction
38
- // This causes prosemirror to run through some different code paths, eg. attempting
39
- // to map selection
40
- if (analyticsPayload) {
41
- dispatchAnalyticsEvent(analyticsPayload);
42
- }
43
- }
44
- };
45
- },
46
20
  appendTransaction: function appendTransaction(_transactions, oldEditorState, newEditorState) {
47
21
  if (!shouldRecalcDecorations({
48
22
  oldEditorState: oldEditorState,
@@ -80,20 +54,7 @@ export var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent
80
54
  handleDOMEvents: {
81
55
  keydown: createOnKeydown({
82
56
  __livePage: options.__livePage
83
- }),
84
- // We only want to fire analytics for a click and drag range/cell selection when
85
- // the user has finished, otherwise we will get an event almost every time they move
86
- // their mouse which is too much
87
- mouseup: function mouseup(editorView, event) {
88
- var mouseEvent = event;
89
- if (!mouseEvent.shiftKey) {
90
- var analyticsPayload = getRangeSelectionAnalyticsPayload(editorView.state.selection, editorView.state.doc) || getCellSelectionAnalyticsPayload(editorView.state);
91
- if (analyticsPayload) {
92
- dispatchAnalyticsEvent(analyticsPayload);
93
- }
94
- }
95
- return false;
96
- }
57
+ })
97
58
  }
98
59
  }
99
60
  });
package/dist/esm/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createSelectionClickHandler, getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
1
+ import { createSelectionClickHandler, isIgnored as isIgnoredByGapCursor, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
2
2
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
3
3
  import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNode, flatten } from '@atlaskit/editor-prosemirror/utils';
@@ -246,4 +246,4 @@ export var isSelectionAtEndOfParentNode = function isSelectionAtEndOfParentNode(
246
246
  var $after = $pos.doc.resolve($pos.after());
247
247
  return $after.parent.content.size === $after.parentOffset;
248
248
  };
249
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler };
249
+ export { createSelectionClickHandler };
@@ -1,4 +1,4 @@
1
- import { createSelectionClickHandler, getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload } from '@atlaskit/editor-common/selection';
1
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
2
2
  import type { Node as PmNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
@@ -55,4 +55,4 @@ export declare const findFirstChildNodeToSelect: (parent: PmNode) => NodeWithPos
55
55
  export declare const findLastChildNodeToSelect: (parent: PmNode) => NodeWithPos | undefined;
56
56
  export declare const isSelectionAtStartOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
57
57
  export declare const isSelectionAtEndOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
58
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler, };
58
+ export { createSelectionClickHandler };
@@ -1,4 +1,4 @@
1
- import { createSelectionClickHandler, getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload } from '@atlaskit/editor-common/selection';
1
+ import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
2
2
  import type { Node as PmNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
@@ -55,4 +55,4 @@ export declare const findFirstChildNodeToSelect: (parent: PmNode) => NodeWithPos
55
55
  export declare const findLastChildNodeToSelect: (parent: PmNode) => NodeWithPos | undefined;
56
56
  export declare const isSelectionAtStartOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
57
57
  export declare const isSelectionAtEndOfParentNode: ($pos: ResolvedPos, selection: Selection) => boolean;
58
- export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, createSelectionClickHandler, };
58
+ export { createSelectionClickHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Selection plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -17,15 +17,15 @@
17
17
  "atlassian": {
18
18
  "team": "Editor: Lego",
19
19
  "singleton": true,
20
- "runReact18": false
20
+ "runReact18": true
21
21
  },
22
22
  "dependencies": {
23
- "@atlaskit/editor-common": "^94.0.0",
23
+ "@atlaskit/editor-common": "^94.11.0",
24
24
  "@atlaskit/editor-prosemirror": "6.0.0",
25
- "@atlaskit/editor-shared-styles": "^3.0.0",
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/tokens": "^2.0.0",
28
+ "@atlaskit/tokens": "^2.1.0",
29
29
  "@babel/runtime": "^7.0.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "platform-feature-flags": {
80
- "platform.editor.single-player-expand": {
80
+ "platform-editor-single-player-expand": {
81
81
  "type": "boolean"
82
82
  },
83
83
  "platform_editor_mark_boundary_cursor": {