@atlaskit/editor-plugin-quick-insert 7.1.8 → 7.2.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,22 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 7.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`761ce84c554a0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/761ce84c554a0) -
8
+ Adding removeQuickInsertItem method to the quick-insert editor plugin.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 7.1.9
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 7.1.8
4
21
 
5
22
  ### Patch Changes
@@ -184,6 +184,26 @@ var quickInsertPlugin = exports.quickInsertPlugin = function quickInsertPlugin(_
184
184
  }
185
185
  });
186
186
  };
187
+ },
188
+ removeQuickInsertItem: function removeQuickInsertItem(key) {
189
+ return function (_ref0) {
190
+ var _api$quickInsert$shar3, _api$quickInsert3, _providedItems$filter;
191
+ var tr = _ref0.tr;
192
+ var _ref1 = (_api$quickInsert$shar3 = api === null || api === void 0 || (_api$quickInsert3 = api.quickInsert) === null || _api$quickInsert3 === void 0 ? void 0 : _api$quickInsert3.sharedState.currentState()) !== null && _api$quickInsert$shar3 !== void 0 ? _api$quickInsert$shar3 : {},
193
+ providedItems = _ref1.providedItems,
194
+ lazyDefaultItems = _ref1.lazyDefaultItems;
195
+ var defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
196
+ return tr.setMeta(_pluginKey.pluginKey, {
197
+ providedItems: (_providedItems$filter = providedItems === null || providedItems === void 0 ? void 0 : providedItems.filter(function (item) {
198
+ return item.key !== key;
199
+ })) !== null && _providedItems$filter !== void 0 ? _providedItems$filter : [],
200
+ lazyDefaultItems: function lazyDefaultItems() {
201
+ return defaultItems.filter(function (item) {
202
+ return item.key !== key;
203
+ });
204
+ }
205
+ });
206
+ };
187
207
  }
188
208
  },
189
209
  usePluginHook: function usePluginHook() {
@@ -233,7 +253,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
233
253
  },
234
254
  view: function view(editorView) {
235
255
  var providerHandler = /*#__PURE__*/function () {
236
- var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, providerPromise) {
256
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, providerPromise) {
237
257
  var provider, providedItems;
238
258
  return _regenerator.default.wrap(function _callee$(_context) {
239
259
  while (1) switch (_context.prev = _context.next) {
@@ -269,7 +289,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
269
289
  }, _callee, null, [[1, 11]]);
270
290
  }));
271
291
  return function providerHandler(_x, _x2) {
272
- return _ref0.apply(this, arguments);
292
+ return _ref10.apply(this, arguments);
273
293
  };
274
294
  }();
275
295
  providerFactory.subscribe('quickInsertProvider', providerHandler);
@@ -173,6 +173,20 @@ export const quickInsertPlugin = ({
173
173
  return tr.setMeta(pluginKey, {
174
174
  lazyDefaultItems: () => [...defaultItems, ...memoisedNewItems]
175
175
  });
176
+ },
177
+ removeQuickInsertItem: key => ({
178
+ tr
179
+ }) => {
180
+ var _api$quickInsert$shar3, _api$quickInsert3, _providedItems$filter;
181
+ const {
182
+ providedItems,
183
+ lazyDefaultItems
184
+ } = (_api$quickInsert$shar3 = api === null || api === void 0 ? void 0 : (_api$quickInsert3 = api.quickInsert) === null || _api$quickInsert3 === void 0 ? void 0 : _api$quickInsert3.sharedState.currentState()) !== null && _api$quickInsert$shar3 !== void 0 ? _api$quickInsert$shar3 : {};
185
+ const defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
186
+ return tr.setMeta(pluginKey, {
187
+ providedItems: (_providedItems$filter = providedItems === null || providedItems === void 0 ? void 0 : providedItems.filter(item => item.key !== key)) !== null && _providedItems$filter !== void 0 ? _providedItems$filter : [],
188
+ lazyDefaultItems: () => defaultItems.filter(item => item.key !== key)
189
+ });
176
190
  }
177
191
  },
178
192
  usePluginHook: () => {
@@ -177,6 +177,26 @@ export var quickInsertPlugin = function quickInsertPlugin(_ref) {
177
177
  }
178
178
  });
179
179
  };
180
+ },
181
+ removeQuickInsertItem: function removeQuickInsertItem(key) {
182
+ return function (_ref0) {
183
+ var _api$quickInsert$shar3, _api$quickInsert3, _providedItems$filter;
184
+ var tr = _ref0.tr;
185
+ var _ref1 = (_api$quickInsert$shar3 = api === null || api === void 0 || (_api$quickInsert3 = api.quickInsert) === null || _api$quickInsert3 === void 0 ? void 0 : _api$quickInsert3.sharedState.currentState()) !== null && _api$quickInsert$shar3 !== void 0 ? _api$quickInsert$shar3 : {},
186
+ providedItems = _ref1.providedItems,
187
+ lazyDefaultItems = _ref1.lazyDefaultItems;
188
+ var defaultItems = lazyDefaultItems ? lazyDefaultItems() : [];
189
+ return tr.setMeta(pluginKey, {
190
+ providedItems: (_providedItems$filter = providedItems === null || providedItems === void 0 ? void 0 : providedItems.filter(function (item) {
191
+ return item.key !== key;
192
+ })) !== null && _providedItems$filter !== void 0 ? _providedItems$filter : [],
193
+ lazyDefaultItems: function lazyDefaultItems() {
194
+ return defaultItems.filter(function (item) {
195
+ return item.key !== key;
196
+ });
197
+ }
198
+ });
199
+ };
180
200
  }
181
201
  },
182
202
  usePluginHook: function usePluginHook() {
@@ -226,7 +246,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
226
246
  },
227
247
  view: function view(editorView) {
228
248
  var providerHandler = /*#__PURE__*/function () {
229
- var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, providerPromise) {
249
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, providerPromise) {
230
250
  var provider, providedItems;
231
251
  return _regeneratorRuntime.wrap(function _callee$(_context) {
232
252
  while (1) switch (_context.prev = _context.next) {
@@ -262,7 +282,7 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
262
282
  }, _callee, null, [[1, 11]]);
263
283
  }));
264
284
  return function providerHandler(_x, _x2) {
265
- return _ref0.apply(this, arguments);
285
+ return _ref10.apply(this, arguments);
266
286
  };
267
287
  }();
268
288
  providerFactory.subscribe('quickInsertProvider', providerHandler);
@@ -18,6 +18,7 @@ export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
18
18
  commands: {
19
19
  addQuickInsertItem: (item: QuickInsertHandler) => EditorCommand;
20
20
  openElementBrowserModal: EditorCommand;
21
+ removeQuickInsertItem: (key: string) => EditorCommand;
21
22
  };
22
23
  dependencies: [
23
24
  TypeAheadPlugin,
@@ -18,6 +18,7 @@ export type QuickInsertPlugin = NextEditorPlugin<'quickInsert', {
18
18
  commands: {
19
19
  addQuickInsertItem: (item: QuickInsertHandler) => EditorCommand;
20
20
  openElementBrowserModal: EditorCommand;
21
+ removeQuickInsertItem: (key: string) => EditorCommand;
21
22
  };
22
23
  dependencies: [
23
24
  TypeAheadPlugin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "7.1.8",
3
+ "version": "7.2.0",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/modal-dialog": "^14.10.0",
40
40
  "@atlaskit/platform-feature-flags": "^1.1.0",
41
41
  "@atlaskit/theme": "^21.0.0",
42
- "@atlaskit/tmp-editor-statsig": "^19.0.0",
42
+ "@atlaskit/tmp-editor-statsig": "^20.1.0",
43
43
  "@atlaskit/tokens": "^11.0.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@emotion/react": "^11.7.1"