@atlaskit/editor-plugin-insert-block 1.14.5 → 1.14.6

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,13 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 1.14.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141109](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141109)
8
+ [`466f39066bd56`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/466f39066bd56) -
9
+ Enforce appearance check for all experiment code
10
+
3
11
  ## 1.14.5
4
12
 
5
13
  ### Patch Changes
@@ -60,7 +60,7 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
60
60
  };
61
61
  }
62
62
  var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_ref) {
63
- var _api$primaryToolbar;
63
+ var _api$primaryToolbar, _options$UNSAFE_edito3;
64
64
  var _ref$config = _ref.config,
65
65
  options = _ref$config === void 0 ? {} : _ref$config,
66
66
  api = _ref.api;
@@ -129,7 +129,10 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
129
129
  }
130
130
  },
131
131
  pmPlugins: function pmPlugins() {
132
- if (!(0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
132
+ var _options$UNSAFE_edito;
133
+ if (
134
+ // @ts-ignore
135
+ !['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') || !(0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
133
136
  [];
134
137
  }
135
138
  return [{
@@ -213,11 +216,11 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
213
216
  // If we decide to ship the feature, we will consider a separate plugin if needed.
214
217
  // Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
215
218
  quickInsert: function quickInsert(intl) {
216
- var _options$UNSAFE_edito;
219
+ var _options$UNSAFE_edito2;
217
220
  var locale = intl.locale;
218
221
  var isEligible = locale.startsWith('en') &&
219
222
  // @ts-ignore
220
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '');
223
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
221
224
  if (isEligible && (0, _experiments.editorExperiment)('element-level-templates', true, {
222
225
  exposure: true
223
226
  })) {
@@ -235,7 +238,9 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
235
238
  },
236
239
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
237
240
  };
238
- if ((0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
241
+ if (
242
+ // @ts-ignore
243
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito3 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito3 !== void 0 ? _options$UNSAFE_edito3 : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
239
244
  plugin.pluginsOptions.contextPanel = function (state) {
240
245
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
241
246
  // so instead just rely on plugin key as we don't need to be reactive to changes here
@@ -112,14 +112,14 @@ var InsertMenuRail = exports.InsertMenuRail = function InsertMenuRail(_ref) {
112
112
  (_api$emoji = api.emoji) === null || _api$emoji === void 0 || _api$emoji.actions.openTypeAhead(inputMethod);
113
113
  break;
114
114
  case 'codeblock':
115
- (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 || _api$codeBlock.actions.insertCodeBlock(inputMethod);
115
+ (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 || _api$codeBlock.actions.insertCodeBlock(inputMethod)(state, dispatch);
116
116
  break;
117
117
  case 'blockquote':
118
118
  // @ts-expect-error
119
- (_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod);
119
+ (_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod)(state, dispatch);
120
120
  break;
121
121
  case 'panel':
122
- (_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod);
122
+ (_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod)(state, dispatch);
123
123
  break;
124
124
  case 'action':
125
125
  // @ts-expect-error
@@ -213,11 +213,12 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
213
213
  (_this$unregisterToggl = (_this2 = _this).unregisterToggleDropdownMenuOptions) === null || _this$unregisterToggl === void 0 || _this$unregisterToggl.call(_this2);
214
214
  });
215
215
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function () {
216
+ var _this$props$editorApp;
216
217
  /**
217
218
  * For insert menu in right rail experiment
218
219
  * - Clean up ticket ED-24801
219
220
  */
220
- if ((0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
221
+ if (['full-page', 'full-width'].includes((_this$props$editorApp = _this.props.editorAppearance) !== null && _this$props$editorApp !== void 0 ? _this$props$editorApp : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
221
222
  exposure: true
222
223
  })) {
223
224
  var pluginInjectionApi = _this.props.pluginInjectionApi;
@@ -245,11 +246,12 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
245
246
  });
246
247
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleOpenByKeyboard", function (event) {
247
248
  if (event.key === 'Enter' || event.key === ' ') {
249
+ var _this$props$editorApp2;
248
250
  /**
249
251
  * For insert menu in right rail experiment
250
252
  * - Clean up ticket ED-24801
251
253
  */
252
- if ((0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
254
+ if (['full-page', 'full-width'].includes((_this$props$editorApp2 = _this.props.editorAppearance) !== null && _this$props$editorApp2 !== void 0 ? _this$props$editorApp2 : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
253
255
  exposure: true
254
256
  })) {
255
257
  var _this$props$pluginInj;
@@ -51,7 +51,7 @@ export const insertBlockPlugin = ({
51
51
  config: options = {},
52
52
  api
53
53
  }) => {
54
- var _api$primaryToolbar;
54
+ var _api$primaryToolbar, _options$UNSAFE_edito3;
55
55
  const toggleDropdownMenuOptionsRef = {
56
56
  current: null
57
57
  };
@@ -118,7 +118,10 @@ export const insertBlockPlugin = ({
118
118
  }
119
119
  },
120
120
  pmPlugins: () => {
121
- if (!editorExperiment('insert-menu-in-right-rail', true)) {
121
+ var _options$UNSAFE_edito;
122
+ if (
123
+ // @ts-ignore
124
+ !['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
122
125
  [];
123
126
  }
124
127
  return [{
@@ -204,13 +207,13 @@ export const insertBlockPlugin = ({
204
207
  // If we decide to ship the feature, we will consider a separate plugin if needed.
205
208
  // Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
206
209
  quickInsert: intl => {
207
- var _options$UNSAFE_edito;
210
+ var _options$UNSAFE_edito2;
208
211
  const {
209
212
  locale
210
213
  } = intl;
211
214
  const isEligible = locale.startsWith('en') &&
212
215
  // @ts-ignore
213
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '');
216
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
214
217
  if (isEligible && editorExperiment('element-level-templates', true, {
215
218
  exposure: true
216
219
  })) {
@@ -228,7 +231,9 @@ export const insertBlockPlugin = ({
228
231
  },
229
232
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
230
233
  };
231
- if (editorExperiment('insert-menu-in-right-rail', true)) {
234
+ if (
235
+ // @ts-ignore
236
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito3 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito3 !== void 0 ? _options$UNSAFE_edito3 : '') && editorExperiment('insert-menu-in-right-rail', true)) {
232
237
  plugin.pluginsOptions.contextPanel = state => {
233
238
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
234
239
  // so instead just rely on plugin key as we don't need to be reactive to changes here
@@ -106,14 +106,14 @@ export const InsertMenuRail = ({
106
106
  (_api$emoji = api.emoji) === null || _api$emoji === void 0 ? void 0 : _api$emoji.actions.openTypeAhead(inputMethod);
107
107
  break;
108
108
  case 'codeblock':
109
- (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 ? void 0 : _api$codeBlock.actions.insertCodeBlock(inputMethod);
109
+ (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 ? void 0 : _api$codeBlock.actions.insertCodeBlock(inputMethod)(state, dispatch);
110
110
  break;
111
111
  case 'blockquote':
112
112
  // @ts-expect-error
113
- (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : _api$blockType.actions.insertBlockQuote(inputMethod);
113
+ (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : _api$blockType.actions.insertBlockQuote(inputMethod)(state, dispatch);
114
114
  break;
115
115
  case 'panel':
116
- (_api$panel = api.panel) === null || _api$panel === void 0 ? void 0 : _api$panel.actions.insertPanel(inputMethod);
116
+ (_api$panel = api.panel) === null || _api$panel === void 0 ? void 0 : _api$panel.actions.insertPanel(inputMethod)(state, dispatch);
117
117
  break;
118
118
  case 'action':
119
119
  // @ts-expect-error
@@ -211,11 +211,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
211
211
  (_this$unregisterToggl = this.unregisterToggleDropdownMenuOptions) === null || _this$unregisterToggl === void 0 ? void 0 : _this$unregisterToggl.call(this);
212
212
  });
213
213
  _defineProperty(this, "handleClick", () => {
214
+ var _this$props$editorApp;
214
215
  /**
215
216
  * For insert menu in right rail experiment
216
217
  * - Clean up ticket ED-24801
217
218
  */
218
- if (editorExperiment('insert-menu-in-right-rail', true, {
219
+ if (['full-page', 'full-width'].includes((_this$props$editorApp = this.props.editorAppearance) !== null && _this$props$editorApp !== void 0 ? _this$props$editorApp : '') && editorExperiment('insert-menu-in-right-rail', true, {
219
220
  exposure: true
220
221
  })) {
221
222
  const {
@@ -246,11 +247,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
246
247
  });
247
248
  _defineProperty(this, "handleOpenByKeyboard", event => {
248
249
  if (event.key === 'Enter' || event.key === ' ') {
250
+ var _this$props$editorApp2;
249
251
  /**
250
252
  * For insert menu in right rail experiment
251
253
  * - Clean up ticket ED-24801
252
254
  */
253
- if (editorExperiment('insert-menu-in-right-rail', true, {
255
+ if (['full-page', 'full-width'].includes((_this$props$editorApp2 = this.props.editorAppearance) !== null && _this$props$editorApp2 !== void 0 ? _this$props$editorApp2 : '') && editorExperiment('insert-menu-in-right-rail', true, {
254
256
  exposure: true
255
257
  })) {
256
258
  var _this$props$pluginInj;
@@ -50,7 +50,7 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
50
50
  };
51
51
  }
52
52
  export var insertBlockPlugin = function insertBlockPlugin(_ref) {
53
- var _api$primaryToolbar;
53
+ var _api$primaryToolbar, _options$UNSAFE_edito3;
54
54
  var _ref$config = _ref.config,
55
55
  options = _ref$config === void 0 ? {} : _ref$config,
56
56
  api = _ref.api;
@@ -119,7 +119,10 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
119
119
  }
120
120
  },
121
121
  pmPlugins: function pmPlugins() {
122
- if (!editorExperiment('insert-menu-in-right-rail', true)) {
122
+ var _options$UNSAFE_edito;
123
+ if (
124
+ // @ts-ignore
125
+ !['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
123
126
  [];
124
127
  }
125
128
  return [{
@@ -203,11 +206,11 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
203
206
  // If we decide to ship the feature, we will consider a separate plugin if needed.
204
207
  // Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
205
208
  quickInsert: function quickInsert(intl) {
206
- var _options$UNSAFE_edito;
209
+ var _options$UNSAFE_edito2;
207
210
  var locale = intl.locale;
208
211
  var isEligible = locale.startsWith('en') &&
209
212
  // @ts-ignore
210
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '');
213
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
211
214
  if (isEligible && editorExperiment('element-level-templates', true, {
212
215
  exposure: true
213
216
  })) {
@@ -225,7 +228,9 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
225
228
  },
226
229
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
227
230
  };
228
- if (editorExperiment('insert-menu-in-right-rail', true)) {
231
+ if (
232
+ // @ts-ignore
233
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito3 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito3 !== void 0 ? _options$UNSAFE_edito3 : '') && editorExperiment('insert-menu-in-right-rail', true)) {
229
234
  plugin.pluginsOptions.contextPanel = function (state) {
230
235
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
231
236
  // so instead just rely on plugin key as we don't need to be reactive to changes here
@@ -101,14 +101,14 @@ export var InsertMenuRail = function InsertMenuRail(_ref) {
101
101
  (_api$emoji = api.emoji) === null || _api$emoji === void 0 || _api$emoji.actions.openTypeAhead(inputMethod);
102
102
  break;
103
103
  case 'codeblock':
104
- (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 || _api$codeBlock.actions.insertCodeBlock(inputMethod);
104
+ (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 || _api$codeBlock.actions.insertCodeBlock(inputMethod)(state, dispatch);
105
105
  break;
106
106
  case 'blockquote':
107
107
  // @ts-expect-error
108
- (_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod);
108
+ (_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod)(state, dispatch);
109
109
  break;
110
110
  case 'panel':
111
- (_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod);
111
+ (_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod)(state, dispatch);
112
112
  break;
113
113
  case 'action':
114
114
  // @ts-expect-error
@@ -204,11 +204,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
204
204
  (_this$unregisterToggl = (_this2 = _this).unregisterToggleDropdownMenuOptions) === null || _this$unregisterToggl === void 0 || _this$unregisterToggl.call(_this2);
205
205
  });
206
206
  _defineProperty(_assertThisInitialized(_this), "handleClick", function () {
207
+ var _this$props$editorApp;
207
208
  /**
208
209
  * For insert menu in right rail experiment
209
210
  * - Clean up ticket ED-24801
210
211
  */
211
- if (editorExperiment('insert-menu-in-right-rail', true, {
212
+ if (['full-page', 'full-width'].includes((_this$props$editorApp = _this.props.editorAppearance) !== null && _this$props$editorApp !== void 0 ? _this$props$editorApp : '') && editorExperiment('insert-menu-in-right-rail', true, {
212
213
  exposure: true
213
214
  })) {
214
215
  var pluginInjectionApi = _this.props.pluginInjectionApi;
@@ -236,11 +237,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
236
237
  });
237
238
  _defineProperty(_assertThisInitialized(_this), "handleOpenByKeyboard", function (event) {
238
239
  if (event.key === 'Enter' || event.key === ' ') {
240
+ var _this$props$editorApp2;
239
241
  /**
240
242
  * For insert menu in right rail experiment
241
243
  * - Clean up ticket ED-24801
242
244
  */
243
- if (editorExperiment('insert-menu-in-right-rail', true, {
245
+ if (['full-page', 'full-width'].includes((_this$props$editorApp2 = _this.props.editorAppearance) !== null && _this$props$editorApp2 !== void 0 ? _this$props$editorApp2 : '') && editorExperiment('insert-menu-in-right-rail', true, {
244
246
  exposure: true
245
247
  })) {
246
248
  var _this$props$pluginInj;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",