@atlaskit/editor-plugin-toolbar 5.1.1 → 5.1.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-toolbar
2
2
 
3
+ ## 5.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b6830be30e686`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b6830be30e686) -
8
+ Removed experiment-gated calculateToolbarPosition prop and simplified selection toolbar position
9
+ calculation
10
+ - Updated dependencies
11
+
3
12
  ## 5.1.1
4
13
 
5
14
  ### Patch Changes
@@ -42,6 +42,9 @@
42
42
  {
43
43
  "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
44
44
  },
45
+ {
46
+ "path": "../../editor-shared-styles/afm-jira/tsconfig.json"
47
+ },
45
48
  {
46
49
  "path": "../../editor-toolbar/afm-jira/tsconfig.json"
47
50
  },
@@ -42,6 +42,9 @@
42
42
  {
43
43
  "path": "../../editor-prosemirror/afm-products/tsconfig.json"
44
44
  },
45
+ {
46
+ "path": "../../editor-shared-styles/afm-products/tsconfig.json"
47
+ },
45
48
  {
46
49
  "path": "../../editor-toolbar/afm-products/tsconfig.json"
47
50
  },
@@ -10,9 +10,8 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _bindEventListener = require("bind-event-listener");
12
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
- var _utils = require("@atlaskit/editor-common/utils");
14
13
  var _state = require("@atlaskit/editor-prosemirror/state");
15
- var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
16
15
  var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
17
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
18
17
  var _selectionToolbarOpenExperience = require("./pm-plugins/experiences/selection-toolbar-open-experience");
@@ -36,7 +35,7 @@ function getSelectedNode(editorState) {
36
35
  };
37
36
  }
38
37
  var nodes = editorState.schema.nodes;
39
- var selectedNode = (0, _utils2.findSelectedNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.codeBlock])(selection);
38
+ var selectedNode = (0, _utils.findSelectedNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.codeBlock])(selection);
40
39
  if (selectedNode) {
41
40
  return {
42
41
  node: selectedNode.node,
@@ -47,7 +46,7 @@ function getSelectedNode(editorState) {
47
46
  })
48
47
  };
49
48
  }
50
- var parentNode = (0, _utils2.findParentNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.listItem, nodes.taskItem])(selection);
49
+ var parentNode = (0, _utils.findParentNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.listItem, nodes.taskItem])(selection);
51
50
  if (parentNode) {
52
51
  return {
53
52
  node: parentNode.node,
@@ -83,7 +82,6 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
83
82
  breakpointPreset = config.breakpointPreset;
84
83
  var registry = (0, _editorToolbarModel.createComponentRegistry)();
85
84
  registry.register((0, _toolbarComponents.getToolbarComponents)(contextualFormattingEnabled, api, breakpointPreset));
86
- var cachedCalculateToolbarPosition = (0, _expValEquals.expValEquals)('platform_editor_sel_toolbar_fix', 'isEnabled', true) ? (0, _utils.calculateToolbarPositionTrackHead)(_consts.SELECTION_TOOLBAR_LABEL) : undefined;
87
85
  return {
88
86
  name: 'toolbar',
89
87
  actions: {
@@ -212,8 +210,7 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
212
210
  api: api,
213
211
  editorView: editorView,
214
212
  mountPoint: popupsMountPoint,
215
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
216
- calculateToolbarPosition: cachedCalculateToolbarPosition
213
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
217
214
  });
218
215
  } : undefined
219
216
  };
@@ -44,7 +44,7 @@ var usePluginState = function usePluginState(api) {
44
44
  };
45
45
  });
46
46
  };
47
- var useOnPositionCalculated = function useOnPositionCalculated(editorView, cachedCalculateToolbarPosition) {
47
+ var useOnPositionCalculated = function useOnPositionCalculated(editorView) {
48
48
  var onPositionCalculated = (0, _react.useCallback)(function (position) {
49
49
  try {
50
50
  // Show special position on cell selection only when editor controls experiment is enabled
@@ -53,14 +53,14 @@ var useOnPositionCalculated = function useOnPositionCalculated(editorView, cache
53
53
  if (isCellSelection && isEditorControlsEnabled) {
54
54
  return (0, _utils.calculateToolbarPositionOnCellSelection)(_consts.SELECTION_TOOLBAR_LABEL)(editorView, position);
55
55
  }
56
- return cachedCalculateToolbarPosition ? cachedCalculateToolbarPosition(editorView, position) : (0, _utils.calculateToolbarPositionTrackHead)(_consts.SELECTION_TOOLBAR_LABEL)(editorView, position);
56
+ return (0, _utils.calculateToolbarPositionTrackHead)(_consts.SELECTION_TOOLBAR_LABEL)(editorView, position);
57
57
  } catch (error) {
58
58
  (0, _monitoring.logException)(error, {
59
59
  location: 'editor-plugin-toolbar/selectionToolbar'
60
60
  });
61
61
  return position;
62
62
  }
63
- }, [editorView, cachedCalculateToolbarPosition]);
63
+ }, [editorView]);
64
64
  return onPositionCalculated;
65
65
  };
66
66
  var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref) {
@@ -134,8 +134,7 @@ var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundar
134
134
  var api = _ref2.api,
135
135
  editorView = _ref2.editorView,
136
136
  mountPoint = _ref2.mountPoint,
137
- disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned,
138
- calculateToolbarPosition = _ref2.calculateToolbarPosition;
137
+ disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned;
139
138
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
140
139
  component: _analytics.ACTION_SUBJECT.TOOLBAR,
141
140
  componentId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
@@ -145,7 +144,6 @@ var SelectionToolbarWithErrorBoundary = exports.SelectionToolbarWithErrorBoundar
145
144
  api: api,
146
145
  editorView: editorView,
147
146
  mountPoint: mountPoint,
148
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
149
- calculateToolbarPosition: calculateToolbarPosition
147
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
150
148
  }));
151
149
  };
@@ -1,14 +1,13 @@
1
1
  import React from 'react';
2
2
  import { bind } from 'bind-event-listener';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
5
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
5
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
6
  import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
8
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
8
  import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
10
9
  import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
11
- import { DEFAULT_POPUP_SELECTORS, SELECTION_TOOLBAR_LABEL } from './ui/consts';
10
+ import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
12
11
  import { SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
13
12
  import { getToolbarComponents } from './ui/toolbar-components';
14
13
  import { isEventInContainer } from './ui/utils/toolbar';
@@ -69,7 +68,6 @@ export const toolbarPlugin = ({
69
68
  } = config;
70
69
  const registry = createComponentRegistry();
71
70
  registry.register(getToolbarComponents(contextualFormattingEnabled, api, breakpointPreset));
72
- const cachedCalculateToolbarPosition = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true) ? calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL) : undefined;
73
71
  return {
74
72
  name: 'toolbar',
75
73
  actions: {
@@ -201,8 +199,7 @@ export const toolbarPlugin = ({
201
199
  api: api,
202
200
  editorView: editorView,
203
201
  mountPoint: popupsMountPoint,
204
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
205
- calculateToolbarPosition: cachedCalculateToolbarPosition
202
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
206
203
  });
207
204
  } : undefined
208
205
  };
@@ -36,7 +36,7 @@ const usePluginState = api => {
36
36
  };
37
37
  });
38
38
  };
39
- const useOnPositionCalculated = (editorView, cachedCalculateToolbarPosition) => {
39
+ const useOnPositionCalculated = editorView => {
40
40
  const onPositionCalculated = useCallback(position => {
41
41
  try {
42
42
  // Show special position on cell selection only when editor controls experiment is enabled
@@ -45,14 +45,14 @@ const useOnPositionCalculated = (editorView, cachedCalculateToolbarPosition) =>
45
45
  if (isCellSelection && isEditorControlsEnabled) {
46
46
  return calculateToolbarPositionOnCellSelection(SELECTION_TOOLBAR_LABEL)(editorView, position);
47
47
  }
48
- return cachedCalculateToolbarPosition ? cachedCalculateToolbarPosition(editorView, position) : calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL)(editorView, position);
48
+ return calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL)(editorView, position);
49
49
  } catch (error) {
50
50
  logException(error, {
51
51
  location: 'editor-plugin-toolbar/selectionToolbar'
52
52
  });
53
53
  return position;
54
54
  }
55
- }, [editorView, cachedCalculateToolbarPosition]);
55
+ }, [editorView]);
56
56
  return onPositionCalculated;
57
57
  };
58
58
  export const SelectionToolbar = ({
@@ -126,8 +126,7 @@ export const SelectionToolbarWithErrorBoundary = ({
126
126
  api,
127
127
  editorView,
128
128
  mountPoint,
129
- disableSelectionToolbarWhenPinned,
130
- calculateToolbarPosition
129
+ disableSelectionToolbarWhenPinned
131
130
  }) => {
132
131
  var _api$analytics2;
133
132
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
@@ -139,7 +138,6 @@ export const SelectionToolbarWithErrorBoundary = ({
139
138
  api: api,
140
139
  editorView: editorView,
141
140
  mountPoint: mountPoint,
142
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
143
- calculateToolbarPosition: calculateToolbarPosition
141
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
144
142
  }));
145
143
  };
@@ -5,14 +5,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  import React from 'react';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
- import { calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
9
8
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
9
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
11
10
  import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
12
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
12
  import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
14
13
  import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
15
- import { DEFAULT_POPUP_SELECTORS, SELECTION_TOOLBAR_LABEL } from './ui/consts';
14
+ import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
16
15
  import { SelectionToolbarWithErrorBoundary } from './ui/SelectionToolbar';
17
16
  import { getToolbarComponents } from './ui/toolbar-components';
18
17
  import { isEventInContainer } from './ui/utils/toolbar';
@@ -76,7 +75,6 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
76
75
  breakpointPreset = config.breakpointPreset;
77
76
  var registry = createComponentRegistry();
78
77
  registry.register(getToolbarComponents(contextualFormattingEnabled, api, breakpointPreset));
79
- var cachedCalculateToolbarPosition = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true) ? calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL) : undefined;
80
78
  return {
81
79
  name: 'toolbar',
82
80
  actions: {
@@ -205,8 +203,7 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
205
203
  api: api,
206
204
  editorView: editorView,
207
205
  mountPoint: popupsMountPoint,
208
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false,
209
- calculateToolbarPosition: cachedCalculateToolbarPosition
206
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
210
207
  });
211
208
  } : undefined
212
209
  };
@@ -36,7 +36,7 @@ var usePluginState = function usePluginState(api) {
36
36
  };
37
37
  });
38
38
  };
39
- var useOnPositionCalculated = function useOnPositionCalculated(editorView, cachedCalculateToolbarPosition) {
39
+ var useOnPositionCalculated = function useOnPositionCalculated(editorView) {
40
40
  var onPositionCalculated = useCallback(function (position) {
41
41
  try {
42
42
  // Show special position on cell selection only when editor controls experiment is enabled
@@ -45,14 +45,14 @@ var useOnPositionCalculated = function useOnPositionCalculated(editorView, cache
45
45
  if (isCellSelection && isEditorControlsEnabled) {
46
46
  return calculateToolbarPositionOnCellSelection(SELECTION_TOOLBAR_LABEL)(editorView, position);
47
47
  }
48
- return cachedCalculateToolbarPosition ? cachedCalculateToolbarPosition(editorView, position) : calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL)(editorView, position);
48
+ return calculateToolbarPositionTrackHead(SELECTION_TOOLBAR_LABEL)(editorView, position);
49
49
  } catch (error) {
50
50
  logException(error, {
51
51
  location: 'editor-plugin-toolbar/selectionToolbar'
52
52
  });
53
53
  return position;
54
54
  }
55
- }, [editorView, cachedCalculateToolbarPosition]);
55
+ }, [editorView]);
56
56
  return onPositionCalculated;
57
57
  };
58
58
  export var SelectionToolbar = function SelectionToolbar(_ref) {
@@ -126,8 +126,7 @@ export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErro
126
126
  var api = _ref2.api,
127
127
  editorView = _ref2.editorView,
128
128
  mountPoint = _ref2.mountPoint,
129
- disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned,
130
- calculateToolbarPosition = _ref2.calculateToolbarPosition;
129
+ disableSelectionToolbarWhenPinned = _ref2.disableSelectionToolbarWhenPinned;
131
130
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
132
131
  component: ACTION_SUBJECT.TOOLBAR,
133
132
  componentId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR,
@@ -137,7 +136,6 @@ export var SelectionToolbarWithErrorBoundary = function SelectionToolbarWithErro
137
136
  api: api,
138
137
  editorView: editorView,
139
138
  mountPoint: mountPoint,
140
- disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned,
141
- calculateToolbarPosition: calculateToolbarPosition
139
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned
142
140
  }));
143
141
  };
@@ -2,14 +2,12 @@ import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
- import type { CalculateToolbarPosition } from './types';
6
5
  type SelectionToolbarProps = {
7
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
8
- calculateToolbarPosition?: CalculateToolbarPosition;
9
7
  disableSelectionToolbarWhenPinned: boolean;
10
8
  editorView: EditorView;
11
9
  mountPoint: HTMLElement | undefined;
12
10
  };
13
11
  export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
14
- export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, calculateToolbarPosition, }: SelectionToolbarProps) => React.JSX.Element;
12
+ export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
15
13
  export {};
@@ -2,14 +2,12 @@ import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
- import type { CalculateToolbarPosition } from './types';
6
5
  type SelectionToolbarProps = {
7
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
8
- calculateToolbarPosition?: CalculateToolbarPosition;
9
7
  disableSelectionToolbarWhenPinned: boolean;
10
8
  editorView: EditorView;
11
9
  mountPoint: HTMLElement | undefined;
12
10
  };
13
11
  export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element | null;
14
- export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, calculateToolbarPosition, }: SelectionToolbarProps) => React.JSX.Element;
12
+ export declare const SelectionToolbarWithErrorBoundary: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned, }: SelectionToolbarProps) => React.JSX.Element;
15
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "@atlaskit/editor-toolbar": "^0.20.0",
41
41
  "@atlaskit/editor-toolbar-model": "^0.4.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
- "@atlaskit/tmp-editor-statsig": "^40.2.0",
43
+ "@atlaskit/tmp-editor-statsig": "^40.3.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "bind-event-listener": "^3.0.0",
46
46
  "react-intl-next": "npm:react-intl@^5.18.1"