@atlaskit/editor-common 74.51.6 → 74.52.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/insert/index.js +1 -1
  3. package/dist/cjs/lists/analytics.js +10 -10
  4. package/dist/cjs/monitoring/error.js +1 -1
  5. package/dist/cjs/preset/editor-commands.js +36 -4
  6. package/dist/cjs/preset/index.js +6 -0
  7. package/dist/cjs/quick-insert/assets/images.js +28 -54
  8. package/dist/cjs/quick-insert/assets/mention.js +27 -9
  9. package/dist/cjs/quick-insert/index.js +20 -1
  10. package/dist/cjs/quick-insert/utils.js +79 -0
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/cjs/utils/dedupe.js +37 -0
  13. package/dist/cjs/utils/index.js +7 -0
  14. package/dist/es2019/insert/index.js +1 -1
  15. package/dist/es2019/lists/analytics.js +6 -6
  16. package/dist/es2019/monitoring/error.js +1 -1
  17. package/dist/es2019/preset/editor-commands.js +21 -3
  18. package/dist/es2019/preset/index.js +1 -1
  19. package/dist/es2019/quick-insert/assets/images.js +29 -53
  20. package/dist/es2019/quick-insert/assets/mention.js +28 -8
  21. package/dist/es2019/quick-insert/index.js +2 -1
  22. package/dist/es2019/quick-insert/utils.js +58 -0
  23. package/dist/es2019/ui/DropList/index.js +1 -1
  24. package/dist/es2019/utils/dedupe.js +25 -0
  25. package/dist/es2019/utils/index.js +2 -1
  26. package/dist/esm/insert/index.js +1 -1
  27. package/dist/esm/lists/analytics.js +10 -10
  28. package/dist/esm/monitoring/error.js +1 -1
  29. package/dist/esm/preset/editor-commands.js +33 -4
  30. package/dist/esm/preset/index.js +1 -1
  31. package/dist/esm/quick-insert/assets/images.js +28 -53
  32. package/dist/esm/quick-insert/assets/mention.js +27 -8
  33. package/dist/esm/quick-insert/index.js +2 -1
  34. package/dist/esm/quick-insert/utils.js +69 -0
  35. package/dist/esm/ui/DropList/index.js +1 -1
  36. package/dist/esm/utils/dedupe.js +31 -0
  37. package/dist/esm/utils/index.js +2 -1
  38. package/dist/types/insert/index.d.ts +4 -3
  39. package/dist/types/link/LinkSearch/index.d.ts +4 -4
  40. package/dist/types/link/LinkSearch/withActivityProvider.d.ts +4 -4
  41. package/dist/types/lists/analytics.d.ts +4 -4
  42. package/dist/types/preset/editor-commands.d.ts +8 -0
  43. package/dist/types/preset/index.d.ts +1 -1
  44. package/dist/types/quick-insert/index.d.ts +1 -0
  45. package/dist/types/quick-insert/utils.d.ts +12 -0
  46. package/dist/types/types/editor-command.d.ts +1 -1
  47. package/dist/types/types/index.d.ts +1 -1
  48. package/dist/types/types/quick-insert.d.ts +13 -0
  49. package/dist/types/ui/OverflowShadow/index.d.ts +4 -4
  50. package/dist/types/utils/dedupe.d.ts +1 -0
  51. package/dist/types/utils/index.d.ts +1 -0
  52. package/dist/types-ts4.5/insert/index.d.ts +4 -3
  53. package/dist/types-ts4.5/link/LinkSearch/index.d.ts +4 -4
  54. package/dist/types-ts4.5/link/LinkSearch/withActivityProvider.d.ts +4 -4
  55. package/dist/types-ts4.5/lists/analytics.d.ts +4 -4
  56. package/dist/types-ts4.5/preset/editor-commands.d.ts +8 -0
  57. package/dist/types-ts4.5/preset/index.d.ts +1 -1
  58. package/dist/types-ts4.5/quick-insert/index.d.ts +1 -0
  59. package/dist/types-ts4.5/quick-insert/utils.d.ts +12 -0
  60. package/dist/types-ts4.5/types/editor-command.d.ts +1 -1
  61. package/dist/types-ts4.5/types/index.d.ts +1 -1
  62. package/dist/types-ts4.5/types/quick-insert.d.ts +13 -0
  63. package/dist/types-ts4.5/ui/OverflowShadow/index.d.ts +4 -4
  64. package/dist/types-ts4.5/utils/dedupe.d.ts +1 -0
  65. package/dist/types-ts4.5/utils/index.d.ts +1 -0
  66. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.52.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c70a6612aba`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c70a6612aba) - [ED-19428] Decouple quick-insert plugin from editor-core
8
+
9
+ ## 74.51.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`4795a87a349`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4795a87a349) - Migrating some actions of `editor-plugin-list` to commands. Adding sharedState for `editor-plugin-text-formatting`.
14
+ - [`a34c6ca52c2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a34c6ca52c2) - [ux] [ED-19442] - Modified images and mentions icons and added dark mode
15
+
3
16
  ## 74.51.6
4
17
 
5
18
  ### Patch Changes
@@ -194,7 +194,7 @@ var finaliseInsert = function finaliseInsert(tr, nodeLength) {
194
194
  };
195
195
 
196
196
  /**
197
- * Method extracted from typeahed plugin to be shared with the element browser on handling element insertion.
197
+ * Method extracted from typeahead plugin to be shared with the element browser on handling element insertion.
198
198
  */
199
199
  var insertSelectedItem = function insertSelectedItem(maybeNode) {
200
200
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getCommonListAnalyticsAttributes = exports.countListItemsInSelection = void 0;
7
7
  var _utils = require("../utils");
8
8
  var _selection = require("./selection");
9
- var getCommonListAnalyticsAttributes = function getCommonListAnalyticsAttributes(state) {
10
- var _state$selection = state.selection,
11
- $from = _state$selection.$from,
12
- $to = _state$selection.$to;
9
+ var getCommonListAnalyticsAttributes = function getCommonListAnalyticsAttributes(tr) {
10
+ var _tr$selection = tr.selection,
11
+ $from = _tr$selection.$from,
12
+ $to = _tr$selection.$to;
13
13
  var fromAttrs = (0, _selection.getListItemAttributes)($from);
14
14
  var toAttrs = (0, _selection.getListItemAttributes)($to);
15
15
  return {
@@ -17,19 +17,19 @@ var getCommonListAnalyticsAttributes = function getCommonListAnalyticsAttributes
17
17
  itemIndexAtSelectionEnd: toAttrs.itemIndex,
18
18
  indentLevelAtSelectionStart: fromAttrs.indentLevel,
19
19
  indentLevelAtSelectionEnd: toAttrs.indentLevel,
20
- itemsInSelection: countListItemsInSelection(state)
20
+ itemsInSelection: countListItemsInSelection(tr)
21
21
  };
22
22
  };
23
23
  exports.getCommonListAnalyticsAttributes = getCommonListAnalyticsAttributes;
24
- var countListItemsInSelection = function countListItemsInSelection(state) {
25
- var _state$selection2 = state.selection,
26
- from = _state$selection2.from,
27
- to = _state$selection2.to;
24
+ var countListItemsInSelection = function countListItemsInSelection(tr) {
25
+ var _tr$selection2 = tr.selection,
26
+ from = _tr$selection2.from,
27
+ to = _tr$selection2.to;
28
28
  if (from === to) {
29
29
  return 1;
30
30
  }
31
31
  var count = 0;
32
- var listSlice = state.doc.cut(from, to);
32
+ var listSlice = tr.doc.cut(from, to);
33
33
  listSlice.content.nodesBetween(0, listSlice.content.size, function (node, pos, parent, index) {
34
34
  if (parent && (0, _utils.isListItemNode)(parent) && !(0, _utils.isListNode)(node) && index === 0) {
35
35
  count++;
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.51.6";
19
+ var packageVersion = "74.52.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
7
+ exports.PassiveTransaction = void 0;
6
8
  exports.editorCommandToPMCommand = editorCommandToPMCommand;
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _state = require("@atlaskit/editor-prosemirror/state");
15
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
7
17
  /**
8
18
  * Convert a EditorCommand to a standard Prosemirror Command.
9
19
  * The preferred approach to dispatching a `EditorCommand` is via the
@@ -20,10 +30,32 @@ function editorCommandToPMCommand(command) {
20
30
  var newTr = command === null || command === void 0 ? void 0 : command({
21
31
  tr: tr
22
32
  });
23
- if (newTr) {
24
- dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
33
+ if (!newTr) {
34
+ return false;
35
+ }
36
+ if (newTr instanceof PassiveTransaction) {
25
37
  return true;
26
38
  }
27
- return false;
39
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
40
+ return true;
28
41
  };
29
- }
42
+ }
43
+
44
+ /**
45
+ * PassiveTransaction is used only to indicate that
46
+ * an `EditorCommand` should return `true` but should not dispatch.
47
+ */
48
+ var PassiveTransaction = /*#__PURE__*/function (_Transaction) {
49
+ (0, _inherits2.default)(PassiveTransaction, _Transaction);
50
+ var _super = _createSuper(PassiveTransaction);
51
+ // This is very cheeky but this should never be used outside its intended
52
+ // purpose - it will likely crash the editor so we should get an early warning
53
+ // signal
54
+ function PassiveTransaction() {
55
+ (0, _classCallCheck2.default)(this, PassiveTransaction);
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ return _super.call(this, {});
58
+ }
59
+ return (0, _createClass2.default)(PassiveTransaction);
60
+ }(_state.Transaction);
61
+ exports.PassiveTransaction = PassiveTransaction;
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "EditorPresetBuilder", {
15
15
  return _builder.EditorPresetBuilder;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "PassiveTransaction", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _editorCommands.PassiveTransaction;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "editorCommandToPMCommand", {
19
25
  enumerable: true,
20
26
  get: function get() {
@@ -6,84 +6,58 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = IconImages;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
10
- /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
11
-
9
+ var _useIconThemed2 = require("../use-icon-themed");
12
10
  function IconImages() {
11
+ var _useIconThemed = (0, _useIconThemed2.useIconThemed)(),
12
+ iconThemed = _useIconThemed.iconThemed;
13
13
  return /*#__PURE__*/_react.default.createElement("svg", {
14
14
  focusable: "false",
15
15
  "aria-hidden": true,
16
16
  width: 40,
17
17
  height: 40
18
- }, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("linearGradient", {
19
- x1: "46.315%",
20
- y1: "-31.529%",
21
- x2: "50%",
22
- y2: "100%",
23
- id: "images-a"
24
- }, /*#__PURE__*/_react.default.createElement("stop", {
25
- stopColor: "#FFD500",
26
- offset: "0%"
27
- }), /*#__PURE__*/_react.default.createElement("stop", {
28
- stopColor: "#FFAB00",
29
- offset: "100%"
30
- })), /*#__PURE__*/_react.default.createElement("linearGradient", {
31
- x1: "100.699%",
32
- y1: "50%",
33
- x2: "-14.52%",
34
- y2: "50%",
35
- id: "images-b"
36
- }, /*#__PURE__*/_react.default.createElement("stop", {
37
- stopColor: "#FAFBFC",
38
- offset: "0%"
39
- }), /*#__PURE__*/_react.default.createElement("stop", {
40
- stopColor: "#F4F6F8",
41
- stopOpacity: 0.859,
42
- offset: "12.52%"
43
- }), /*#__PURE__*/_react.default.createElement("stop", {
44
- stopColor: "#E3E6EA",
45
- stopOpacity: 0.402,
46
- offset: "54.65%"
47
- }), /*#__PURE__*/_react.default.createElement("stop", {
48
- stopColor: "#D7DCE1",
49
- stopOpacity: 0.113,
50
- offset: "83.66%"
51
- }), /*#__PURE__*/_react.default.createElement("stop", {
52
- stopColor: "#D3D8DE",
53
- stopOpacity: 0,
54
- offset: "97.03%"
55
- }))), /*#__PURE__*/_react.default.createElement("g", {
18
+ }, /*#__PURE__*/_react.default.createElement("defs", null), /*#__PURE__*/_react.default.createElement("g", {
56
19
  fill: "none",
57
20
  fillRule: "evenodd"
58
21
  }, /*#__PURE__*/_react.default.createElement("path", {
59
- fill: "#FFF",
22
+ fill: iconThemed({
23
+ light: '#FFF',
24
+ dark: '#161A1D'
25
+ }),
60
26
  d: "M0 0h40v40H0z"
61
27
  }), /*#__PURE__*/_react.default.createElement("g", {
62
28
  transform: "translate(4 9)",
63
29
  fillRule: "nonzero"
64
30
  }, /*#__PURE__*/_react.default.createElement("rect", {
65
- fill: "url(#images-a)",
31
+ fill: iconThemed({
32
+ light: '#EBB800',
33
+ dark: '#09326C'
34
+ }),
66
35
  width: 32,
67
36
  height: 24,
68
37
  rx: 1
69
38
  }), /*#__PURE__*/_react.default.createElement("path", {
70
- fill: "#E5E8EC",
39
+ fill: iconThemed({
40
+ light: '#F7F8F9',
41
+ dark: '#161A1D'
42
+ }),
71
43
  d: "M4 4h24v16H4z"
72
44
  }), /*#__PURE__*/_react.default.createElement("path", {
73
- fill: "#0049B0",
45
+ fill: iconThemed({
46
+ light: '#09326C',
47
+ dark: '#09326C'
48
+ }),
74
49
  d: "M6.351 18.062l5.594-6.017 5.594 6.017z"
75
50
  }), /*#__PURE__*/_react.default.createElement("path", {
76
- fill: "#0065FF",
51
+ fill: iconThemed({
52
+ light: '#0065FF',
53
+ dark: '#0055CC'
54
+ }),
77
55
  d: "M9.341 18.062l8.198-8.818 8.198 8.818z"
78
- }), /*#__PURE__*/_react.default.createElement("path", {
79
- d: "M20.484 14.353c-2.618-1.255-5.104-.564-8.519-1.373C9.625 12.426 6.719 11.135 4 8v11.913h20.294c-.321-2.073-1.26-4.337-3.81-5.56z",
80
- fill: "url(#images-b)",
81
- opacity: 0.37,
82
- style: {
83
- mixBlendMode: 'screen'
84
- }
85
56
  }), /*#__PURE__*/_react.default.createElement("ellipse", {
86
- fill: "#FFAB00",
57
+ fill: iconThemed({
58
+ light: '#F88A0D',
59
+ dark: '#B85C00'
60
+ }),
87
61
  cx: 9,
88
62
  cy: 9.028,
89
63
  rx: 2,
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = IconMention;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4138
10
- /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
11
-
9
+ var _useIconThemed2 = require("../use-icon-themed");
12
10
  function IconMention() {
11
+ var _useIconThemed = (0, _useIconThemed2.useIconThemed)(),
12
+ iconThemed = _useIconThemed.iconThemed;
13
13
  return /*#__PURE__*/_react.default.createElement("svg", {
14
14
  focusable: "false",
15
15
  "aria-hidden": true,
@@ -19,34 +19,52 @@ function IconMention() {
19
19
  fill: "none",
20
20
  fillRule: "evenodd"
21
21
  }, /*#__PURE__*/_react.default.createElement("path", {
22
- fill: "#FFF",
22
+ fill: iconThemed({
23
+ light: '#FFF',
24
+ dark: '#161A1D'
25
+ }),
23
26
  d: "M0 0h40v40H0z"
24
27
  }), /*#__PURE__*/_react.default.createElement("g", {
25
28
  transform: "translate(6 12)"
26
29
  }, /*#__PURE__*/_react.default.createElement("circle", {
27
- fill: "#2684FF",
30
+ fill: iconThemed({
31
+ light: '#388BFF',
32
+ dark: '#0055CC'
33
+ }),
28
34
  cx: 8,
29
35
  cy: 8,
30
36
  r: 8
31
37
  }), /*#__PURE__*/_react.default.createElement("path", {
32
38
  d: "M12.875 12.767A6.891 6.891 0 018.02 14.75a6.889 6.889 0 01-4.895-2.026V11.9c0-1.049.873-1.9 1.95-1.9h5.85c1.077 0 1.95.851 1.95 1.9v.867zM8 3a2.874 2.874 0 10-.001 5.748 2.874 2.874 0 000-5.748",
33
- fill: "#B3D4FF"
39
+ fill: iconThemed({
40
+ light: '#85B8FF',
41
+ dark: '#388BFF'
42
+ })
34
43
  }), /*#__PURE__*/_react.default.createElement("rect", {
35
- fill: "#A5ADBA",
44
+ fill: iconThemed({
45
+ light: '#A4ACB9',
46
+ dark: '#A4ACB9'
47
+ }),
36
48
  x: 19,
37
49
  y: 3,
38
50
  width: 12,
39
51
  height: 1,
40
52
  rx: 0.5
41
53
  }), /*#__PURE__*/_react.default.createElement("rect", {
42
- fill: "#A5ADBA",
54
+ fill: iconThemed({
55
+ light: '#A4ACB9',
56
+ dark: '#A4ACB9'
57
+ }),
43
58
  x: 19,
44
59
  y: 7,
45
60
  width: 6,
46
61
  height: 1,
47
62
  rx: 0.5
48
63
  }), /*#__PURE__*/_react.default.createElement("rect", {
49
- fill: "#A5ADBA",
64
+ fill: iconThemed({
65
+ light: '#A4ACB9',
66
+ dark: '#A4ACB9'
67
+ }),
50
68
  x: 19,
51
69
  y: 11,
52
70
  width: 8,
@@ -159,4 +159,23 @@ Object.defineProperty(exports, "IconStatus", {
159
159
  return _assets.IconStatus;
160
160
  }
161
161
  });
162
- var _assets = require("./assets");
162
+ Object.defineProperty(exports, "find", {
163
+ enumerable: true,
164
+ get: function get() {
165
+ return _utils.find;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "getQuickInsertSuggestions", {
169
+ enumerable: true,
170
+ get: function get() {
171
+ return _utils.getQuickInsertSuggestions;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "memoProcessQuickInsertItems", {
175
+ enumerable: true,
176
+ get: function get() {
177
+ return _utils.memoProcessQuickInsertItems;
178
+ }
179
+ });
180
+ var _assets = require("./assets");
181
+ var _utils = require("./utils");
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.find = find;
8
+ exports.memoProcessQuickInsertItems = exports.getQuickInsertSuggestions = void 0;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _fuse = _interopRequireDefault(require("fuse.js"));
11
+ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
12
+ var _utils = require("../utils");
13
+ var processQuickInsertItems = function processQuickInsertItems(items, intl) {
14
+ return items.reduce(function (acc, item) {
15
+ if (typeof item === 'function') {
16
+ var quickInsertItems = item(intl);
17
+ return acc.concat(quickInsertItems);
18
+ }
19
+ return acc.concat(item);
20
+ }, []);
21
+ };
22
+ var memoProcessQuickInsertItems = (0, _memoizeOne.default)(processQuickInsertItems);
23
+ exports.memoProcessQuickInsertItems = memoProcessQuickInsertItems;
24
+ var options = {
25
+ threshold: 0.3,
26
+ keys: [{
27
+ name: 'title',
28
+ weight: 0.57
29
+ }, {
30
+ name: 'priority',
31
+ weight: 0.3
32
+ }, {
33
+ name: 'keywords',
34
+ weight: 0.08
35
+ }, {
36
+ name: 'description',
37
+ weight: 0.04
38
+ }, {
39
+ name: 'keyshortcut',
40
+ weight: 0.01
41
+ }]
42
+ };
43
+ function find(query, items) {
44
+ var fuse = new _fuse.default(items, options);
45
+ if (query === '') {
46
+ // Copy and sort list by priority
47
+ return items.slice(0).sort(function (a, b) {
48
+ return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
49
+ });
50
+ }
51
+ return fuse.search(query).map(function (result) {
52
+ return result.item;
53
+ });
54
+ }
55
+ var getQuickInsertSuggestions = function getQuickInsertSuggestions(_ref) {
56
+ var searchOptions = _ref.searchOptions,
57
+ _ref$lazyDefaultItems = _ref.lazyDefaultItems,
58
+ lazyDefaultItems = _ref$lazyDefaultItems === void 0 ? function () {
59
+ return [];
60
+ } : _ref$lazyDefaultItems,
61
+ providedItems = _ref.providedItems;
62
+ var query = searchOptions.query,
63
+ category = searchOptions.category,
64
+ disableDefaultItems = searchOptions.disableDefaultItems,
65
+ featuredItems = searchOptions.featuredItems;
66
+ var defaultItems = disableDefaultItems ? [] : lazyDefaultItems();
67
+ var items = providedItems ? (0, _utils.dedupe)([].concat((0, _toConsumableArray2.default)(defaultItems), (0, _toConsumableArray2.default)(providedItems)), function (item) {
68
+ return item.title;
69
+ }) : defaultItems;
70
+ if (featuredItems) {
71
+ return items.filter(function (item) {
72
+ return item.featured;
73
+ });
74
+ }
75
+ return find(query || '', category === 'all' || !category ? items : items.filter(function (item) {
76
+ return item.categories && item.categories.includes(category);
77
+ }));
78
+ };
79
+ exports.getQuickInsertSuggestions = getQuickInsertSuggestions;
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.51.6";
27
+ var packageVersion = "74.52.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dedupe = dedupe;
7
+ function dedupe() {
8
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9
+ var iteratee = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (p) {
10
+ return p;
11
+ };
12
+ /**
13
+ .,
14
+ . _,'f----.._
15
+ |\ ,-'"/ | ,'
16
+ |,_ ,--. /
17
+ /,-. ,'`. (_
18
+ f o| o|__ "`-.
19
+ ,-._.,--'_ `. _.,-`
20
+ `"' ___.,'` j,-'
21
+ `-.__.,--'
22
+ Gotta go fast!
23
+ */
24
+
25
+ var seen = new Set();
26
+ list.forEach(function (l) {
27
+ return seen.add(iteratee(l));
28
+ });
29
+ return list.filter(function (l) {
30
+ var it = iteratee(l);
31
+ if (seen.has(it)) {
32
+ seen.delete(it);
33
+ return true;
34
+ }
35
+ return false;
36
+ });
37
+ }
@@ -281,6 +281,12 @@ Object.defineProperty(exports, "createWrappingJoinRule", {
281
281
  return _inputRules.createWrappingJoinRule;
282
282
  }
283
283
  });
284
+ Object.defineProperty(exports, "dedupe", {
285
+ enumerable: true,
286
+ get: function get() {
287
+ return _dedupe.dedupe;
288
+ }
289
+ });
284
290
  Object.defineProperty(exports, "deleteEmptyParagraphAndMoveBlockUp", {
285
291
  enumerable: true,
286
292
  get: function get() {
@@ -1047,6 +1053,7 @@ var _scrollGutter = require("./scroll-gutter");
1047
1053
  var _getPerformanceTiming = require("./performance/get-performance-timing");
1048
1054
  var _countNodes = require("./count-nodes");
1049
1055
  var _inputRules = require("./input-rules");
1056
+ var _dedupe = require("./dedupe");
1050
1057
  // prosemirror-history does not export its plugin key
1051
1058
  var pmHistoryPluginKey = 'history$';
1052
1059
  exports.pmHistoryPluginKey = pmHistoryPluginKey;
@@ -188,7 +188,7 @@ const finaliseInsert = (tr, nodeLength) => {
188
188
  };
189
189
 
190
190
  /**
191
- * Method extracted from typeahed plugin to be shared with the element browser on handling element insertion.
191
+ * Method extracted from typeahead plugin to be shared with the element browser on handling element insertion.
192
192
  */
193
193
  export const insertSelectedItem = (maybeNode, opts = {}) => (state, tr, start) => {
194
194
  if (!maybeNode) {
@@ -1,12 +1,12 @@
1
1
  import { isListItemNode, isListNode } from '../utils';
2
2
  import { getListItemAttributes } from './selection';
3
- export const getCommonListAnalyticsAttributes = state => {
3
+ export const getCommonListAnalyticsAttributes = tr => {
4
4
  const {
5
5
  selection: {
6
6
  $from,
7
7
  $to
8
8
  }
9
- } = state;
9
+ } = tr;
10
10
  const fromAttrs = getListItemAttributes($from);
11
11
  const toAttrs = getListItemAttributes($to);
12
12
  return {
@@ -14,19 +14,19 @@ export const getCommonListAnalyticsAttributes = state => {
14
14
  itemIndexAtSelectionEnd: toAttrs.itemIndex,
15
15
  indentLevelAtSelectionStart: fromAttrs.indentLevel,
16
16
  indentLevelAtSelectionEnd: toAttrs.indentLevel,
17
- itemsInSelection: countListItemsInSelection(state)
17
+ itemsInSelection: countListItemsInSelection(tr)
18
18
  };
19
19
  };
20
- export const countListItemsInSelection = state => {
20
+ export const countListItemsInSelection = tr => {
21
21
  const {
22
22
  from,
23
23
  to
24
- } = state.selection;
24
+ } = tr.selection;
25
25
  if (from === to) {
26
26
  return 1;
27
27
  }
28
28
  let count = 0;
29
- const listSlice = state.doc.cut(from, to);
29
+ const listSlice = tr.doc.cut(from, to);
30
30
  listSlice.content.nodesBetween(0, listSlice.content.size, (node, pos, parent, index) => {
31
31
  if (parent && isListItemNode(parent) && !isListNode(node) && index === 0) {
32
32
  count++;
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.51.6";
3
+ const packageVersion = "74.52.0";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -1,3 +1,4 @@
1
+ import { Transaction } from '@atlaskit/editor-prosemirror/state';
1
2
  /**
2
3
  * Convert a EditorCommand to a standard Prosemirror Command.
3
4
  * The preferred approach to dispatching a `EditorCommand` is via the
@@ -15,10 +16,27 @@ export function editorCommandToPMCommand(command) {
15
16
  const newTr = command === null || command === void 0 ? void 0 : command({
16
17
  tr
17
18
  });
18
- if (newTr) {
19
- dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
19
+ if (!newTr) {
20
+ return false;
21
+ }
22
+ if (newTr instanceof PassiveTransaction) {
20
23
  return true;
21
24
  }
22
- return false;
25
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
26
+ return true;
23
27
  };
28
+ }
29
+
30
+ /**
31
+ * PassiveTransaction is used only to indicate that
32
+ * an `EditorCommand` should return `true` but should not dispatch.
33
+ */
34
+ export class PassiveTransaction extends Transaction {
35
+ // This is very cheeky but this should never be used outside its intended
36
+ // purpose - it will likely crash the editor so we should get an early warning
37
+ // signal
38
+ constructor() {
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ super({});
41
+ }
24
42
  }
@@ -1,3 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
2
  export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
- export { editorCommandToPMCommand } from './editor-commands';
3
+ export { editorCommandToPMCommand, PassiveTransaction } from './editor-commands';