@atlaskit/editor-plugin-block-type 19.0.6 → 19.0.8

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,26 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 19.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`85c7571a0f48b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/85c7571a0f48b) -
8
+ Return focus to the editor after selecting a text style (e.g. a heading) from the toolbar Text
9
+ styles dropdown, so typing continues immediately instead of focus staying on the trigger button.
10
+ The Text styles dropdown now renders inline via `shouldRenderToParent`, which stops the popup
11
+ focus-trap from returning focus to the trigger on close. `ToolbarDropdownMenu` gains an opt-in
12
+ `shouldRenderToParent` prop so only the Text styles menu is affected. Gated behind the
13
+ `platform_editor_return_focus_after_text_styles` feature flag.
14
+ - Updated dependencies
15
+
16
+ ## 19.0.7
17
+
18
+ ### Patch Changes
19
+
20
+ - [`70c05b380d08c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/70c05b380d08c) -
21
+ Clean up experiment `platform_editor_blockquote_in_text_formatting_menu` as globally enabled.
22
+ - Updated dependencies
23
+
3
24
  ## 19.0.6
4
25
 
5
26
  ### Patch Changes
@@ -9,7 +9,7 @@ exports.formatTypes = void 0;
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
11
11
  // Functions duplicated from platform/packages/editor/editor-plugin-text-formatting/src/editor-commands/clear-formatting.ts
12
- // TODO: ED-26959 - Refactor to avoid duplication if platform_editor_blockquote_in_text_formatting_menu experiment is productionalised
12
+ // TODO: ED-26959 - Refactor to avoid duplication.
13
13
  var FORMATTING_NODE_TYPES = exports.FORMATTING_NODE_TYPES = ['heading', 'blockquote'];
14
14
  var FORMATTING_MARK_TYPES = exports.FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup', 'backgroundColor'];
15
15
  var formatTypes = exports.formatTypes = {
@@ -106,6 +106,7 @@ var TextStylesMenuButton = exports.TextStylesMenuButton = function TextStylesMen
106
106
  }),
107
107
  label: formatMessage(_messages.toolbarMessages.textStyles, {
108
108
  blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
109
- })
109
+ }),
110
+ shouldRenderToParent: (0, _platformFeatureFlags.fg)('platform_editor_return_focus_after_text_styles')
110
111
  }, children);
111
112
  };
@@ -238,11 +238,9 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
238
238
  blockTypeIcon: currentIcon || defaultIcon
239
239
  });
240
240
  return (0, _react2.jsx)("span", {
241
- css: (0, _experiments.editorExperiment)('platform_editor_blockquote_in_text_formatting_menu', true) ?
241
+ css:
242
242
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
243
- [_styles.wrapperStyle, _styled.floatingToolbarWrapperStyle] :
244
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
245
- _styles.wrapperStyle
243
+ [_styles.wrapperStyle, _styled.floatingToolbarWrapperStyle]
246
244
  }, (0, _react2.jsx)(_uiMenu.DropdownMenuWithKeyboardNavigation, {
247
245
  items: items,
248
246
  onOpenChange: this.onOpenChange,
@@ -16,7 +16,6 @@ var _transforms = require("@atlaskit/editor-common/transforms");
16
16
  var _utils = require("@atlaskit/editor-common/utils");
17
17
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
18
18
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
19
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
19
  var _blockTypes = require("./block-types");
21
20
  var isNodeAWrappingBlockNode = exports.isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
22
21
  if (!node) {
@@ -127,28 +126,25 @@ function areBlockTypesDisabled(state) {
127
126
  }
128
127
  return disallowedWrapperTypes.length > 0;
129
128
  }
130
- if ((0, _experiments.editorExperiment)('platform_editor_blockquote_in_text_formatting_menu', true)) {
131
- var hasQuote = false;
132
- var hasNestedListInQuote = false;
133
- var _state$selection2 = state.selection,
134
- $from = _state$selection2.$from,
135
- $to = _state$selection2.$to;
136
- state.doc.nodesBetween($from.pos, $to.pos, function (node) {
137
- if (node.type === blockquote) {
138
- hasQuote = true;
139
- node.descendants(function (child) {
140
- if (child.type === bulletList || child.type === orderedList) {
141
- hasNestedListInQuote = true;
142
- return false;
143
- }
144
- return true;
145
- });
146
- }
147
- return !hasNestedListInQuote;
148
- });
149
- return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
150
- }
151
- return disallowedWrapperTypes.length > 0;
129
+ var hasQuote = false;
130
+ var hasNestedListInQuote = false;
131
+ var _state$selection2 = state.selection,
132
+ $from = _state$selection2.$from,
133
+ $to = _state$selection2.$to;
134
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
135
+ if (node.type === blockquote) {
136
+ hasQuote = true;
137
+ node.descendants(function (child) {
138
+ if (child.type === bulletList || child.type === orderedList) {
139
+ hasNestedListInQuote = true;
140
+ return false;
141
+ }
142
+ return true;
143
+ });
144
+ }
145
+ return !hasNestedListInQuote;
146
+ });
147
+ return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
152
148
  }
153
149
 
154
150
  /**
@@ -1,7 +1,7 @@
1
1
  import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
2
2
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
3
3
  // Functions duplicated from platform/packages/editor/editor-plugin-text-formatting/src/editor-commands/clear-formatting.ts
4
- // TODO: ED-26959 - Refactor to avoid duplication if platform_editor_blockquote_in_text_formatting_menu experiment is productionalised
4
+ // TODO: ED-26959 - Refactor to avoid duplication.
5
5
  export const FORMATTING_NODE_TYPES = ['heading', 'blockquote'];
6
6
  export const FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup', 'backgroundColor'];
7
7
  export const formatTypes = {
@@ -92,6 +92,7 @@ export const TextStylesMenuButton = ({
92
92
  }),
93
93
  label: formatMessage(toolbarMessages.textStyles, {
94
94
  blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
95
- })
95
+ }),
96
+ shouldRenderToParent: fg('platform_editor_return_focus_after_text_styles')
96
97
  }, children);
97
98
  };
@@ -208,11 +208,9 @@ class ToolbarBlockType extends React.PureComponent {
208
208
  blockTypeIcon: currentIcon || defaultIcon
209
209
  });
210
210
  return jsx("span", {
211
- css: editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true) ?
211
+ css:
212
212
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
213
- [wrapperStyle, floatingToolbarWrapperStyle] :
214
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
215
- wrapperStyle
213
+ [wrapperStyle, floatingToolbarWrapperStyle]
216
214
  }, jsx(DropdownMenu, {
217
215
  items: items,
218
216
  onOpenChange: this.onOpenChange,
@@ -3,7 +3,6 @@ import { createBlockTaskItem } from '@atlaskit/editor-common/transforms';
3
3
  import { createRule, createWrappingJoinRule } from '@atlaskit/editor-common/utils';
4
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { WRAPPER_BLOCK_TYPES, FORMATTING_NODE_TYPES, FORMATTING_MARK_TYPES } from './block-types';
8
7
  export const isNodeAWrappingBlockNode = node => {
9
8
  if (!node) {
@@ -109,29 +108,26 @@ export function areBlockTypesDisabled(state, allowFontSize = false) {
109
108
  }
110
109
  return disallowedWrapperTypes.length > 0;
111
110
  }
112
- if (editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true)) {
113
- let hasQuote = false;
114
- let hasNestedListInQuote = false;
115
- const {
116
- $from,
117
- $to
118
- } = state.selection;
119
- state.doc.nodesBetween($from.pos, $to.pos, node => {
120
- if (node.type === blockquote) {
121
- hasQuote = true;
122
- node.descendants(child => {
123
- if (child.type === bulletList || child.type === orderedList) {
124
- hasNestedListInQuote = true;
125
- return false;
126
- }
127
- return true;
128
- });
129
- }
130
- return !hasNestedListInQuote;
131
- });
132
- return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
133
- }
134
- return disallowedWrapperTypes.length > 0;
111
+ let hasQuote = false;
112
+ let hasNestedListInQuote = false;
113
+ const {
114
+ $from,
115
+ $to
116
+ } = state.selection;
117
+ state.doc.nodesBetween($from.pos, $to.pos, node => {
118
+ if (node.type === blockquote) {
119
+ hasQuote = true;
120
+ node.descendants(child => {
121
+ if (child.type === bulletList || child.type === orderedList) {
122
+ hasNestedListInQuote = true;
123
+ return false;
124
+ }
125
+ return true;
126
+ });
127
+ }
128
+ return !hasNestedListInQuote;
129
+ });
130
+ return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
135
131
  }
136
132
 
137
133
  /**
@@ -1,7 +1,7 @@
1
1
  import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
2
2
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
3
3
  // Functions duplicated from platform/packages/editor/editor-plugin-text-formatting/src/editor-commands/clear-formatting.ts
4
- // TODO: ED-26959 - Refactor to avoid duplication if platform_editor_blockquote_in_text_formatting_menu experiment is productionalised
4
+ // TODO: ED-26959 - Refactor to avoid duplication.
5
5
  export var FORMATTING_NODE_TYPES = ['heading', 'blockquote'];
6
6
  export var FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup', 'backgroundColor'];
7
7
  export var formatTypes = {
@@ -98,6 +98,7 @@ export var TextStylesMenuButton = function TextStylesMenuButton(_ref) {
98
98
  }),
99
99
  label: formatMessage(toolbarMessages.textStyles, {
100
100
  blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
101
- })
101
+ }),
102
+ shouldRenderToParent: fg('platform_editor_return_focus_after_text_styles')
102
103
  }, children);
103
104
  };
@@ -234,11 +234,9 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
234
234
  blockTypeIcon: currentIcon || defaultIcon
235
235
  });
236
236
  return jsx("span", {
237
- css: editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true) ?
237
+ css:
238
238
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
239
- [wrapperStyle, floatingToolbarWrapperStyle] :
240
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
241
- wrapperStyle
239
+ [wrapperStyle, floatingToolbarWrapperStyle]
242
240
  }, jsx(DropdownMenu, {
243
241
  items: items,
244
242
  onOpenChange: this.onOpenChange,
@@ -3,7 +3,6 @@ import { createBlockTaskItem } from '@atlaskit/editor-common/transforms';
3
3
  import { createRule, createWrappingJoinRule } from '@atlaskit/editor-common/utils';
4
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { WRAPPER_BLOCK_TYPES, FORMATTING_NODE_TYPES, FORMATTING_MARK_TYPES } from './block-types';
8
7
  export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
9
8
  if (!node) {
@@ -114,28 +113,25 @@ export function areBlockTypesDisabled(state) {
114
113
  }
115
114
  return disallowedWrapperTypes.length > 0;
116
115
  }
117
- if (editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true)) {
118
- var hasQuote = false;
119
- var hasNestedListInQuote = false;
120
- var _state$selection2 = state.selection,
121
- $from = _state$selection2.$from,
122
- $to = _state$selection2.$to;
123
- state.doc.nodesBetween($from.pos, $to.pos, function (node) {
124
- if (node.type === blockquote) {
125
- hasQuote = true;
126
- node.descendants(function (child) {
127
- if (child.type === bulletList || child.type === orderedList) {
128
- hasNestedListInQuote = true;
129
- return false;
130
- }
131
- return true;
132
- });
133
- }
134
- return !hasNestedListInQuote;
135
- });
136
- return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
137
- }
138
- return disallowedWrapperTypes.length > 0;
116
+ var hasQuote = false;
117
+ var hasNestedListInQuote = false;
118
+ var _state$selection2 = state.selection,
119
+ $from = _state$selection2.$from,
120
+ $to = _state$selection2.$to;
121
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
122
+ if (node.type === blockquote) {
123
+ hasQuote = true;
124
+ node.descendants(function (child) {
125
+ if (child.type === bulletList || child.type === orderedList) {
126
+ hasNestedListInQuote = true;
127
+ return false;
128
+ }
129
+ return true;
130
+ });
131
+ }
132
+ return !hasNestedListInQuote;
133
+ });
134
+ return disallowedWrapperTypes.length > 0 && (!hasQuote || hasNestedListInQuote);
139
135
  }
140
136
 
141
137
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "19.0.6",
3
+ "version": "19.0.8",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  "@atlaskit/editor-prosemirror": "^8.0.0",
35
35
  "@atlaskit/editor-shared-styles": "^4.0.0",
36
36
  "@atlaskit/editor-tables": "^3.0.0",
37
- "@atlaskit/editor-toolbar": "^2.4.0",
37
+ "@atlaskit/editor-toolbar": "^2.5.0",
38
38
  "@atlaskit/editor-toolbar-model": "^1.2.0",
39
39
  "@atlaskit/icon": "^37.4.0",
40
40
  "@atlaskit/icon-lab": "^7.6.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/primitives": "^22.2.0",
44
44
  "@atlaskit/prosemirror-history": "^1.2.0",
45
45
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
46
- "@atlaskit/tmp-editor-statsig": "^151.0.0",
46
+ "@atlaskit/tmp-editor-statsig": "^152.0.0",
47
47
  "@atlaskit/tokens": "^16.7.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@compiled/react": "^1.0.2",
@@ -113,6 +113,9 @@
113
113
  },
114
114
  "platform_editor_adf_with_localid": {
115
115
  "type": "boolean"
116
+ },
117
+ "platform_editor_return_focus_after_text_styles": {
118
+ "type": "boolean"
116
119
  }
117
120
  }
118
121
  }