@atlaskit/editor-plugin-insert-block 1.14.4 → 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,22 @@
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
+
11
+ ## 1.14.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [`8c1e1dea50327`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8c1e1dea50327) -
16
+ [ED-24967] Add in code English locale targeting for `platform_editor_element_level_templates`
17
+ experiment
18
+ - Updated dependencies
19
+
3
20
  ## 1.14.4
4
21
 
5
22
  ### 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 [{
@@ -212,11 +215,13 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
212
215
  // This is not the most ideal plugin to add this to, but it is suitable for experiment purpose
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
- quickInsert: function quickInsert() {
216
- var _options$UNSAFE_edito;
217
- if (
218
+ quickInsert: function quickInsert(intl) {
219
+ var _options$UNSAFE_edito2;
220
+ var locale = intl.locale;
221
+ var isEligible = locale.startsWith('en') &&
218
222
  // @ts-ignore
219
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') && (0, _experiments.editorExperiment)('element-level-templates', true, {
223
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
224
+ if (isEligible && (0, _experiments.editorExperiment)('element-level-templates', true, {
220
225
  exposure: true
221
226
  })) {
222
227
  return (0, _templateOptions.templateOptions)(api);
@@ -233,7 +238,9 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
233
238
  },
234
239
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
235
240
  };
236
- 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)) {
237
244
  plugin.pluginsOptions.contextPanel = function (state) {
238
245
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
239
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 [{
@@ -203,11 +206,15 @@ export const insertBlockPlugin = ({
203
206
  // This is not the most ideal plugin to add this to, but it is suitable for experiment purpose
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
- quickInsert: () => {
207
- var _options$UNSAFE_edito;
208
- if (
209
+ quickInsert: intl => {
210
+ var _options$UNSAFE_edito2;
211
+ const {
212
+ locale
213
+ } = intl;
214
+ const isEligible = locale.startsWith('en') &&
209
215
  // @ts-ignore
210
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') && editorExperiment('element-level-templates', true, {
216
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
217
+ if (isEligible && editorExperiment('element-level-templates', true, {
211
218
  exposure: true
212
219
  })) {
213
220
  return templateOptions(api);
@@ -224,7 +231,9 @@ export const insertBlockPlugin = ({
224
231
  },
225
232
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
226
233
  };
227
- 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)) {
228
237
  plugin.pluginsOptions.contextPanel = state => {
229
238
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
230
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 [{
@@ -202,11 +205,13 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
202
205
  // This is not the most ideal plugin to add this to, but it is suitable for experiment purpose
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
- quickInsert: function quickInsert() {
206
- var _options$UNSAFE_edito;
207
- if (
208
+ quickInsert: function quickInsert(intl) {
209
+ var _options$UNSAFE_edito2;
210
+ var locale = intl.locale;
211
+ var isEligible = locale.startsWith('en') &&
208
212
  // @ts-ignore
209
- ['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') && editorExperiment('element-level-templates', true, {
213
+ ['full-page', 'full-width'].includes((_options$UNSAFE_edito2 = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito2 !== void 0 ? _options$UNSAFE_edito2 : '');
214
+ if (isEligible && editorExperiment('element-level-templates', true, {
210
215
  exposure: true
211
216
  })) {
212
217
  return templateOptions(api);
@@ -223,7 +228,9 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
223
228
  },
224
229
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
225
230
  };
226
- 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)) {
227
234
  plugin.pluginsOptions.contextPanel = function (state) {
228
235
  // api.getSharedState() will have an outdated reference to editorState on first mount of this component
229
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.4",
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",
@@ -64,7 +64,7 @@
64
64
  "@atlaskit/primitives": "^12.1.0",
65
65
  "@atlaskit/theme": "^13.0.0",
66
66
  "@atlaskit/tmp-editor-statsig": "^2.1.0",
67
- "@atlaskit/tokens": "^1.59.0",
67
+ "@atlaskit/tokens": "^1.60.0",
68
68
  "@atlaskit/tooltip": "18.7.2",
69
69
  "@babel/runtime": "^7.0.0",
70
70
  "@emotion/react": "^11.7.1",