@atlaskit/editor-plugin-block-controls 3.3.19 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#128772](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/128772)
8
+ [`b2f35f81186a9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b2f35f81186a9) -
9
+ Add typeAheadPlugin as an optional dependency, close typeahead when quickinsert is clicked if it's
10
+ open
11
+
3
12
  ## 3.3.19
4
13
 
5
14
  ### Patch Changes
@@ -21,6 +21,7 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
21
21
  var element = document.createElement('span');
22
22
  element.contentEditable = 'false';
23
23
  element.setAttribute('data-blocks-quick-insert-container', 'true');
24
+ element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
24
25
  nodeViewPortalProviderAPI.render(function () {
25
26
  return /*#__PURE__*/(0, _react.createElement)(_quickInsertButton.TypeAheadControl, {
26
27
  api: api,
@@ -161,6 +161,15 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
161
161
  }
162
162
  (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
163
163
  }, [api, getPos, view]);
164
+ var handleMouseDown = (0, _react.useCallback)(function () {
165
+ var _api$typeAhead;
166
+ // close typeahead if it is open, must happen in mouseDown otherwise typeAhead popup will be dismissed and text is left
167
+ if ((_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && _api$typeAhead.actions.isOpen(view.state)) {
168
+ api.typeAhead.actions.close({
169
+ insertCurrentQueryAsRawText: false
170
+ });
171
+ }
172
+ }, [api, view.state]);
164
173
  return (
165
174
  /*#__PURE__*/
166
175
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
@@ -176,7 +185,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
176
185
  type: "button",
177
186
  "aria-label": formatMessage(_messages.blockControlsMessages.insert),
178
187
  xcss: [buttonStyles],
179
- onClick: handleQuickInsert
188
+ onClick: handleQuickInsert,
189
+ onMouseDown: handleMouseDown
180
190
  }, /*#__PURE__*/_react.default.createElement(_add.default, {
181
191
  label: "add",
182
192
  color: "var(--ds-icon-subtle, #626F86)"
@@ -12,6 +12,7 @@ export const quickInsertButtonDecoration = (api, formatMessage, rootPos, anchorN
12
12
  const element = document.createElement('span');
13
13
  element.contentEditable = 'false';
14
14
  element.setAttribute('data-blocks-quick-insert-container', 'true');
15
+ element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
15
16
  nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(TypeAheadControl, {
16
17
  api,
17
18
  getPos,
@@ -149,6 +149,15 @@ export const TypeAheadControl = ({
149
149
  }
150
150
  (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.actions.openTypeAhead('blockControl');
151
151
  }, [api, getPos, view]);
152
+ const handleMouseDown = useCallback(() => {
153
+ var _api$typeAhead;
154
+ // close typeahead if it is open, must happen in mouseDown otherwise typeAhead popup will be dismissed and text is left
155
+ if ((_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && _api$typeAhead.actions.isOpen(view.state)) {
156
+ api.typeAhead.actions.close({
157
+ insertCurrentQueryAsRawText: false
158
+ });
159
+ }
160
+ }, [api, view.state]);
152
161
  return (
153
162
  /*#__PURE__*/
154
163
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
@@ -164,7 +173,8 @@ export const TypeAheadControl = ({
164
173
  type: "button",
165
174
  "aria-label": formatMessage(messages.insert),
166
175
  xcss: [buttonStyles],
167
- onClick: handleQuickInsert
176
+ onClick: handleQuickInsert,
177
+ onMouseDown: handleMouseDown
168
178
  }, /*#__PURE__*/React.createElement(AddIcon, {
169
179
  label: "add",
170
180
  color: "var(--ds-icon-subtle, #626F86)"
@@ -14,6 +14,7 @@ export var quickInsertButtonDecoration = function quickInsertButtonDecoration(ap
14
14
  var element = document.createElement('span');
15
15
  element.contentEditable = 'false';
16
16
  element.setAttribute('data-blocks-quick-insert-container', 'true');
17
+ element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
17
18
  nodeViewPortalProviderAPI.render(function () {
18
19
  return /*#__PURE__*/createElement(TypeAheadControl, {
19
20
  api: api,
@@ -151,6 +151,15 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
151
151
  }
152
152
  (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
153
153
  }, [api, getPos, view]);
154
+ var handleMouseDown = useCallback(function () {
155
+ var _api$typeAhead;
156
+ // close typeahead if it is open, must happen in mouseDown otherwise typeAhead popup will be dismissed and text is left
157
+ if ((_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && _api$typeAhead.actions.isOpen(view.state)) {
158
+ api.typeAhead.actions.close({
159
+ insertCurrentQueryAsRawText: false
160
+ });
161
+ }
162
+ }, [api, view.state]);
154
163
  return (
155
164
  /*#__PURE__*/
156
165
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
@@ -166,7 +175,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
166
175
  type: "button",
167
176
  "aria-label": formatMessage(messages.insert),
168
177
  xcss: [buttonStyles],
169
- onClick: handleQuickInsert
178
+ onClick: handleQuickInsert,
179
+ onMouseDown: handleMouseDown
170
180
  }, /*#__PURE__*/React.createElement(AddIcon, {
171
181
  label: "add",
172
182
  color: "var(--ds-icon-subtle, #626F86)"
@@ -8,6 +8,7 @@ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
9
9
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
10
10
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
11
+ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
11
12
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
12
13
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
13
14
  export type ActiveNode = {
@@ -70,11 +71,8 @@ export type BlockControlsPluginDependencies = [
70
71
  OptionalPlugin<FeatureFlagsPlugin>,
71
72
  OptionalPlugin<AnalyticsPlugin>,
72
73
  OptionalPlugin<AccessibilityUtilsPlugin>,
73
- /**
74
- * For Typeahead - Empty line prompt experiment
75
- * Clean up ticket ED-24824
76
- */
77
74
  OptionalPlugin<QuickInsertPlugin>,
75
+ OptionalPlugin<TypeAheadPlugin>,
78
76
  OptionalPlugin<SelectionPlugin>,
79
77
  OptionalPlugin<MetricsPlugin>
80
78
  ];
@@ -8,6 +8,7 @@ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
9
9
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
10
10
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
11
+ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
11
12
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
12
13
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
13
14
  export type ActiveNode = {
@@ -70,11 +71,8 @@ export type BlockControlsPluginDependencies = [
70
71
  OptionalPlugin<FeatureFlagsPlugin>,
71
72
  OptionalPlugin<AnalyticsPlugin>,
72
73
  OptionalPlugin<AccessibilityUtilsPlugin>,
73
- /**
74
- * For Typeahead - Empty line prompt experiment
75
- * Clean up ticket ED-24824
76
- */
77
74
  OptionalPlugin<QuickInsertPlugin>,
75
+ OptionalPlugin<TypeAheadPlugin>,
78
76
  OptionalPlugin<SelectionPlugin>,
79
77
  OptionalPlugin<MetricsPlugin>
80
78
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.3.19",
3
+ "version": "3.4.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,6 +41,7 @@
41
41
  "@atlaskit/editor-plugin-metrics": "^3.4.0",
42
42
  "@atlaskit/editor-plugin-quick-insert": "^2.1.0",
43
43
  "@atlaskit/editor-plugin-selection": "^2.1.0",
44
+ "@atlaskit/editor-plugin-type-ahead": "^2.1.0",
44
45
  "@atlaskit/editor-plugin-width": "^3.0.0",
45
46
  "@atlaskit/editor-prosemirror": "7.0.0",
46
47
  "@atlaskit/editor-shared-styles": "^3.4.0",
@@ -50,7 +51,7 @@
50
51
  "@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
51
52
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
52
53
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.0.0",
53
- "@atlaskit/primitives": "^14.1.0",
54
+ "@atlaskit/primitives": "^14.2.0",
54
55
  "@atlaskit/theme": "^18.0.0",
55
56
  "@atlaskit/tmp-editor-statsig": "^4.1.0",
56
57
  "@atlaskit/tokens": "^4.5.0",