@atlaskit/editor-plugin-toolbar 5.1.19 → 5.1.21

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,19 @@
1
1
  # @atlaskit/editor-plugin-toolbar
2
2
 
3
+ ## 5.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b9f9976c6adcd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b9f9976c6adcd) -
8
+ Fix selection toolbar appearing mid-drag on first page load by tracking mouse button state to
9
+ prevent the focus event from prematurely setting shouldShowToolbar to true
10
+
11
+ ## 5.1.20
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 5.1.19
4
18
 
5
19
  ### Patch Changes
@@ -13,6 +13,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _utils = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
18
  var _selectionToolbarOpenExperience = require("./pm-plugins/experiences/selection-toolbar-open-experience");
18
19
  var _pluginKey = require("./pm-plugins/plugin-key");
@@ -113,6 +114,11 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
113
114
  return [{
114
115
  name: 'editor-toolbar-selection',
115
116
  plugin: function plugin() {
117
+ // Tracks mouse-down state to prevent the focus event (first page load)
118
+ // from prematurely showing the toolbar mid-drag
119
+ var mouseState = {
120
+ isMouseDown: false
121
+ };
116
122
  return new _safePlugin.SafePlugin({
117
123
  key: _pluginKey.editorToolbarPluginKey,
118
124
  state: {
@@ -145,6 +151,7 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
145
151
  type: 'mouseup',
146
152
  listener: function listener(ev) {
147
153
  var _api$editorViewMode;
154
+ mouseState.isMouseDown = false;
148
155
  var event = ev;
149
156
  var isInToolbar = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.toolbarContainer);
150
157
  var isInPortal = (0, _toolbar.isEventInContainer)(event, _consts.DEFAULT_POPUP_SELECTORS.portal);
@@ -162,6 +169,11 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
162
169
  var unbindEditorViewFocus = (0, _bindEventListener.bind)(_view.dom, {
163
170
  type: 'focus',
164
171
  listener: function listener() {
172
+ // On first page load, focus fires after mousedown — skip to
173
+ // avoid showing the toolbar mid-drag
174
+ if (mouseState.isMouseDown && (0, _platformFeatureFlags.fg)('platform_editor_fix_toolbar_on_first_highlight')) {
175
+ return;
176
+ }
165
177
  _view.dispatch(_view.state.tr.setMeta(_pluginKey.editorToolbarPluginKey, {
166
178
  shouldShowToolbar: true
167
179
  }));
@@ -177,6 +189,7 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
177
189
  props: {
178
190
  handleDOMEvents: {
179
191
  mousedown: function mousedown(view) {
192
+ mouseState.isMouseDown = true;
180
193
  view.dispatch(view.state.tr.setMeta(_pluginKey.editorToolbarPluginKey, {
181
194
  shouldShowToolbar: false
182
195
  }));
@@ -4,6 +4,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
9
10
  import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
@@ -98,6 +99,11 @@ export const toolbarPlugin = ({
98
99
  return [{
99
100
  name: 'editor-toolbar-selection',
100
101
  plugin: () => {
102
+ // Tracks mouse-down state to prevent the focus event (first page load)
103
+ // from prematurely showing the toolbar mid-drag
104
+ const mouseState = {
105
+ isMouseDown: false
106
+ };
101
107
  return new SafePlugin({
102
108
  key: editorToolbarPluginKey,
103
109
  state: {
@@ -135,6 +141,7 @@ export const toolbarPlugin = ({
135
141
  type: 'mouseup',
136
142
  listener: function (ev) {
137
143
  var _api$editorViewMode;
144
+ mouseState.isMouseDown = false;
138
145
  const event = ev;
139
146
  const isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
140
147
  const isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
@@ -152,6 +159,11 @@ export const toolbarPlugin = ({
152
159
  const unbindEditorViewFocus = bind(view.dom, {
153
160
  type: 'focus',
154
161
  listener: () => {
162
+ // On first page load, focus fires after mousedown — skip to
163
+ // avoid showing the toolbar mid-drag
164
+ if (mouseState.isMouseDown && fg('platform_editor_fix_toolbar_on_first_highlight')) {
165
+ return;
166
+ }
155
167
  view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
156
168
  shouldShowToolbar: true
157
169
  }));
@@ -167,6 +179,7 @@ export const toolbarPlugin = ({
167
179
  props: {
168
180
  handleDOMEvents: {
169
181
  mousedown: view => {
182
+ mouseState.isMouseDown = true;
170
183
  view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
171
184
  shouldShowToolbar: false
172
185
  }));
@@ -8,6 +8,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
8
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  import { getSelectionToolbarOpenExperiencePlugin } from './pm-plugins/experiences/selection-toolbar-open-experience';
13
14
  import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
@@ -106,6 +107,11 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
106
107
  return [{
107
108
  name: 'editor-toolbar-selection',
108
109
  plugin: function plugin() {
110
+ // Tracks mouse-down state to prevent the focus event (first page load)
111
+ // from prematurely showing the toolbar mid-drag
112
+ var mouseState = {
113
+ isMouseDown: false
114
+ };
109
115
  return new SafePlugin({
110
116
  key: editorToolbarPluginKey,
111
117
  state: {
@@ -138,6 +144,7 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
138
144
  type: 'mouseup',
139
145
  listener: function listener(ev) {
140
146
  var _api$editorViewMode;
147
+ mouseState.isMouseDown = false;
141
148
  var event = ev;
142
149
  var isInToolbar = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.toolbarContainer);
143
150
  var isInPortal = isEventInContainer(event, DEFAULT_POPUP_SELECTORS.portal);
@@ -155,6 +162,11 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
155
162
  var unbindEditorViewFocus = bind(_view.dom, {
156
163
  type: 'focus',
157
164
  listener: function listener() {
165
+ // On first page load, focus fires after mousedown — skip to
166
+ // avoid showing the toolbar mid-drag
167
+ if (mouseState.isMouseDown && fg('platform_editor_fix_toolbar_on_first_highlight')) {
168
+ return;
169
+ }
158
170
  _view.dispatch(_view.state.tr.setMeta(editorToolbarPluginKey, {
159
171
  shouldShowToolbar: true
160
172
  }));
@@ -170,6 +182,7 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
170
182
  props: {
171
183
  handleDOMEvents: {
172
184
  mousedown: function mousedown(view) {
185
+ mouseState.isMouseDown = true;
173
186
  view.dispatch(view.state.tr.setMeta(editorToolbarPluginKey, {
174
187
  shouldShowToolbar: false
175
188
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "5.1.19",
3
+ "version": "5.1.21",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,16 +40,19 @@
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": "^54.0.0",
43
+ "@atlaskit/tmp-editor-statsig": "^55.1.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"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^112.16.0",
49
+ "@atlaskit/editor-common": "^112.18.0",
50
50
  "react": "^18.2.0"
51
51
  },
52
52
  "platform-feature-flags": {
53
+ "platform_editor_fix_toolbar_on_first_highlight": {
54
+ "type": "boolean"
55
+ },
53
56
  "platform_editor_toolbar_aifc_placement_overridden": {
54
57
  "type": "boolean"
55
58
  },