@atlaskit/editor-common 94.14.1 → 94.15.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-common
2
2
 
3
+ ## 94.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`52d232456ff0c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52d232456ff0c) -
8
+ Updated quick insert find function to conditionally set sort function to account for new logic
9
+ around triggering experiment exposure
10
+
11
+ ## 94.14.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#160699](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160699)
16
+ [`3f6d3eca921ed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f6d3eca921ed) -
17
+ ED-25575: migrate panel plugin node rendering to portals
18
+ - Updated dependencies
19
+
3
20
  ## 94.14.1
4
21
 
5
22
  ### Patch Changes
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "94.14.1";
20
+ var packageVersion = "94.15.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createPortalRendererComponent = createPortalRendererComponent;
9
+ exports.getPortalProviderAPI = void 0;
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _reactDom = require("react-dom");
13
+ var _PortalBucket = require("./PortalBucket");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ function createPortalRendererComponent(portalManager) {
17
+ return function PortalRenderer() {
18
+ var _useState = (0, _react.useState)(portalManager.getBuckets()),
19
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
20
+ buckets = _useState2[0],
21
+ setBuckets = _useState2[1];
22
+ (0, _react.useLayoutEffect)(function () {
23
+ portalManager.registerPortalRenderer(setBuckets);
24
+ return function () {
25
+ portalManager.unregisterPortalRenderer();
26
+ };
27
+ }, []);
28
+ var portalsElements = (0, _react.useMemo)(function () {
29
+ return buckets.map(function (_, i) {
30
+ return /*#__PURE__*/_react.default.createElement(_PortalBucket.PortalBucket, {
31
+ key: i,
32
+ id: i,
33
+ portalManager: portalManager
34
+ });
35
+ });
36
+ }, [buckets]);
37
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, portalsElements);
38
+ };
39
+ }
40
+
41
+ /**
42
+ * Creates a portal provider for managing multiple React portals. The provider
43
+ * facilitates rendering, removing, and destroying portals managed by a given
44
+ * PortalManager.
45
+ *
46
+ * @param {PortalManager} portalManager - An instance of a PortalManager which
47
+ * is responsible for registering, managing, and destroying portals.
48
+ * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
49
+ * portals.
50
+ * - `render(children, container, key)` Renders a new React portal with the given
51
+ * children, mounts it into the specified DOM container, and registers it
52
+ * with the PortalManager using a unique key.
53
+ * - `remove(key)` Removes a previously rendered portal identified by its key
54
+ * and deregisters it from the PortalManager.
55
+ * - `destroy()` Clears all portals managed by this provider and invokes the
56
+ * destroy method on the PortalManager to clean up any resources.
57
+ *
58
+ */
59
+ var getPortalProviderAPI = exports.getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
60
+ var portalsMap = new Map();
61
+ return {
62
+ render: function render(children, container, key) {
63
+ var portal = /*#__PURE__*/(0, _reactDom.createPortal)(children(), container, key);
64
+ portalsMap.set(key, portalManager.registerPortal(key, portal));
65
+ },
66
+ remove: function remove(key) {
67
+ var _portalsMap$get;
68
+ (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 || _portalsMap$get();
69
+ portalsMap.delete(key);
70
+ },
71
+ destroy: function destroy() {
72
+ portalsMap.clear();
73
+ portalManager.destroy();
74
+ }
75
+ };
76
+ };
@@ -1,82 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.createPortalRendererComponent = createPortalRendererComponent;
9
- exports.getPortalProviderAPI = void 0;
10
6
  exports.usePortalProvider = usePortalProvider;
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _reactDom = require("react-dom");
14
- var _PortalBucket = require("./PortalBucket");
7
+ var _react = require("react");
8
+ var _common = require("./common");
15
9
  var _PortalManager = require("./PortalManager");
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- function createPortalRendererComponent(portalManager) {
19
- return function PortalRenderer() {
20
- var _useState = (0, _react.useState)(portalManager.getBuckets()),
21
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
22
- buckets = _useState2[0],
23
- setBuckets = _useState2[1];
24
- (0, _react.useLayoutEffect)(function () {
25
- portalManager.registerPortalRenderer(setBuckets);
26
- return function () {
27
- portalManager.unregisterPortalRenderer();
28
- };
29
- }, []);
30
- var portalsElements = (0, _react.useMemo)(function () {
31
- return buckets.map(function (_, i) {
32
- return /*#__PURE__*/_react.default.createElement(_PortalBucket.PortalBucket, {
33
- key: i,
34
- id: i,
35
- portalManager: portalManager
36
- });
37
- });
38
- }, [buckets]);
39
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, portalsElements);
40
- };
41
- }
42
-
43
- /**
44
- * Creates a portal provider for managing multiple React portals. The provider
45
- * facilitates rendering, removing, and destroying portals managed by a given
46
- * PortalManager.
47
- *
48
- * @param {PortalManager} portalManager - An instance of a PortalManager which
49
- * is responsible for registering, managing, and destroying portals.
50
- * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
51
- * portals.
52
- * - `render(children, container, key)` Renders a new React portal with the given
53
- * children, mounts it into the specified DOM container, and registers it
54
- * with the PortalManager using a unique key.
55
- * - `remove(key)` Removes a previously rendered portal identified by its key
56
- * and deregisters it from the PortalManager.
57
- * - `destroy()` Clears all portals managed by this provider and invokes the
58
- * destroy method on the PortalManager to clean up any resources.
59
- *
60
- */
61
- var getPortalProviderAPI = exports.getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
62
- var portalsMap = new Map();
63
- return {
64
- render: function render(children, container, key) {
65
- var portal = /*#__PURE__*/(0, _reactDom.createPortal)(children(), container, key);
66
- portalsMap.set(key, portalManager.registerPortal(key, portal));
67
- },
68
- remove: function remove(key) {
69
- var _portalsMap$get;
70
- (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 || _portalsMap$get();
71
- portalsMap.delete(key);
72
- },
73
- destroy: function destroy() {
74
- portalsMap.clear();
75
- portalManager.destroy();
76
- }
77
- };
78
- };
79
-
80
10
  /**
81
11
  * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
82
12
  * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
@@ -88,10 +18,10 @@ function usePortalProvider() {
88
18
  return new _PortalManager.PortalManager();
89
19
  }, []);
90
20
  var PortalRenderer = (0, _react.useMemo)(function () {
91
- return createPortalRendererComponent(portalManager);
21
+ return (0, _common.createPortalRendererComponent)(portalManager);
92
22
  }, [portalManager]);
93
23
  var portalProviderAPI = (0, _react.useMemo)(function () {
94
- return getPortalProviderAPI(portalManager);
24
+ return (0, _common.getPortalProviderAPI)(portalManager);
95
25
  }, [portalManager]);
96
26
 
97
27
  // Cleanup on unmount
@@ -66,17 +66,22 @@ var options = {
66
66
  * @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
67
67
  */
68
68
  function find(query, items, prioritySortingFn) {
69
- var fuseOptions = _objectSpread({}, options);
70
- if (prioritySortingFn) {
71
- fuseOptions.sortFn = prioritySortingFn(items);
72
- }
73
- var fuse = new _fuse.default(items, fuseOptions);
74
69
  if (query === '') {
75
70
  // Copy and sort list by priority
76
71
  return items.slice(0).sort(function (a, b) {
77
72
  return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
78
73
  });
79
74
  }
75
+ var fuseOptions = _objectSpread({}, options);
76
+ if (prioritySortingFn) {
77
+ var sortFn = prioritySortingFn(items);
78
+ // prioritySortingFn will trigger the experiment exposure, but sortFn
79
+ // will be undefined for the control group.
80
+ if (sortFn) {
81
+ fuseOptions.sortFn = sortFn;
82
+ }
83
+ }
84
+ var fuse = new _fuse.default(items, fuseOptions);
80
85
  return fuse.search(query).map(function (result) {
81
86
  return result.item;
82
87
  });
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "94.14.1";
27
+ var packageVersion = "94.15.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "94.14.1";
4
+ const packageVersion = "94.15.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,57 @@
1
+ import React, { useLayoutEffect, useMemo, useState } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { PortalBucket } from './PortalBucket';
4
+ export function createPortalRendererComponent(portalManager) {
5
+ return function PortalRenderer() {
6
+ const [buckets, setBuckets] = useState(portalManager.getBuckets());
7
+ useLayoutEffect(() => {
8
+ portalManager.registerPortalRenderer(setBuckets);
9
+ return () => {
10
+ portalManager.unregisterPortalRenderer();
11
+ };
12
+ }, []);
13
+ const portalsElements = useMemo(() => buckets.map((_, i) => /*#__PURE__*/React.createElement(PortalBucket, {
14
+ key: i,
15
+ id: i,
16
+ portalManager: portalManager
17
+ })), [buckets]);
18
+ return /*#__PURE__*/React.createElement(React.Fragment, null, portalsElements);
19
+ };
20
+ }
21
+
22
+ /**
23
+ * Creates a portal provider for managing multiple React portals. The provider
24
+ * facilitates rendering, removing, and destroying portals managed by a given
25
+ * PortalManager.
26
+ *
27
+ * @param {PortalManager} portalManager - An instance of a PortalManager which
28
+ * is responsible for registering, managing, and destroying portals.
29
+ * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
30
+ * portals.
31
+ * - `render(children, container, key)` Renders a new React portal with the given
32
+ * children, mounts it into the specified DOM container, and registers it
33
+ * with the PortalManager using a unique key.
34
+ * - `remove(key)` Removes a previously rendered portal identified by its key
35
+ * and deregisters it from the PortalManager.
36
+ * - `destroy()` Clears all portals managed by this provider and invokes the
37
+ * destroy method on the PortalManager to clean up any resources.
38
+ *
39
+ */
40
+ export const getPortalProviderAPI = portalManager => {
41
+ const portalsMap = new Map();
42
+ return {
43
+ render: (children, container, key) => {
44
+ const portal = /*#__PURE__*/createPortal(children(), container, key);
45
+ portalsMap.set(key, portalManager.registerPortal(key, portal));
46
+ },
47
+ remove: key => {
48
+ var _portalsMap$get;
49
+ (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 ? void 0 : _portalsMap$get();
50
+ portalsMap.delete(key);
51
+ },
52
+ destroy: () => {
53
+ portalsMap.clear();
54
+ portalManager.destroy();
55
+ }
56
+ };
57
+ };
@@ -1,62 +1,6 @@
1
- import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { PortalBucket } from './PortalBucket';
1
+ import { useEffect, useMemo } from 'react';
2
+ import { createPortalRendererComponent, getPortalProviderAPI } from './common';
4
3
  import { PortalManager } from './PortalManager';
5
- export function createPortalRendererComponent(portalManager) {
6
- return function PortalRenderer() {
7
- const [buckets, setBuckets] = useState(portalManager.getBuckets());
8
- useLayoutEffect(() => {
9
- portalManager.registerPortalRenderer(setBuckets);
10
- return () => {
11
- portalManager.unregisterPortalRenderer();
12
- };
13
- }, []);
14
- const portalsElements = useMemo(() => buckets.map((_, i) => /*#__PURE__*/React.createElement(PortalBucket, {
15
- key: i,
16
- id: i,
17
- portalManager: portalManager
18
- })), [buckets]);
19
- return /*#__PURE__*/React.createElement(React.Fragment, null, portalsElements);
20
- };
21
- }
22
-
23
- /**
24
- * Creates a portal provider for managing multiple React portals. The provider
25
- * facilitates rendering, removing, and destroying portals managed by a given
26
- * PortalManager.
27
- *
28
- * @param {PortalManager} portalManager - An instance of a PortalManager which
29
- * is responsible for registering, managing, and destroying portals.
30
- * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
31
- * portals.
32
- * - `render(children, container, key)` Renders a new React portal with the given
33
- * children, mounts it into the specified DOM container, and registers it
34
- * with the PortalManager using a unique key.
35
- * - `remove(key)` Removes a previously rendered portal identified by its key
36
- * and deregisters it from the PortalManager.
37
- * - `destroy()` Clears all portals managed by this provider and invokes the
38
- * destroy method on the PortalManager to clean up any resources.
39
- *
40
- */
41
- export const getPortalProviderAPI = portalManager => {
42
- const portalsMap = new Map();
43
- return {
44
- render: (children, container, key) => {
45
- const portal = /*#__PURE__*/createPortal(children(), container, key);
46
- portalsMap.set(key, portalManager.registerPortal(key, portal));
47
- },
48
- remove: key => {
49
- var _portalsMap$get;
50
- (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 ? void 0 : _portalsMap$get();
51
- portalsMap.delete(key);
52
- },
53
- destroy: () => {
54
- portalsMap.clear();
55
- portalManager.destroy();
56
- }
57
- };
58
- };
59
-
60
4
  /**
61
5
  * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
62
6
  * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
@@ -51,16 +51,21 @@ const options = {
51
51
  * @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
52
52
  */
53
53
  export function find(query, items, prioritySortingFn) {
54
+ if (query === '') {
55
+ // Copy and sort list by priority
56
+ return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
57
+ }
54
58
  const fuseOptions = {
55
59
  ...options
56
60
  };
57
61
  if (prioritySortingFn) {
58
- fuseOptions.sortFn = prioritySortingFn(items);
62
+ const sortFn = prioritySortingFn(items);
63
+ // prioritySortingFn will trigger the experiment exposure, but sortFn
64
+ // will be undefined for the control group.
65
+ if (sortFn) {
66
+ fuseOptions.sortFn = sortFn;
67
+ }
59
68
  }
60
69
  const fuse = new Fuse(items, fuseOptions);
61
- if (query === '') {
62
- // Copy and sort list by priority
63
- return items.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
64
- }
65
70
  return fuse.search(query).map(result => result.item);
66
71
  }
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "94.14.1";
16
+ const packageVersion = "94.15.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  class DropList extends Component {
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "94.14.1";
10
+ var packageVersion = "94.15.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,65 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useLayoutEffect, useMemo, useState } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { PortalBucket } from './PortalBucket';
5
+ export function createPortalRendererComponent(portalManager) {
6
+ return function PortalRenderer() {
7
+ var _useState = useState(portalManager.getBuckets()),
8
+ _useState2 = _slicedToArray(_useState, 2),
9
+ buckets = _useState2[0],
10
+ setBuckets = _useState2[1];
11
+ useLayoutEffect(function () {
12
+ portalManager.registerPortalRenderer(setBuckets);
13
+ return function () {
14
+ portalManager.unregisterPortalRenderer();
15
+ };
16
+ }, []);
17
+ var portalsElements = useMemo(function () {
18
+ return buckets.map(function (_, i) {
19
+ return /*#__PURE__*/React.createElement(PortalBucket, {
20
+ key: i,
21
+ id: i,
22
+ portalManager: portalManager
23
+ });
24
+ });
25
+ }, [buckets]);
26
+ return /*#__PURE__*/React.createElement(React.Fragment, null, portalsElements);
27
+ };
28
+ }
29
+
30
+ /**
31
+ * Creates a portal provider for managing multiple React portals. The provider
32
+ * facilitates rendering, removing, and destroying portals managed by a given
33
+ * PortalManager.
34
+ *
35
+ * @param {PortalManager} portalManager - An instance of a PortalManager which
36
+ * is responsible for registering, managing, and destroying portals.
37
+ * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
38
+ * portals.
39
+ * - `render(children, container, key)` Renders a new React portal with the given
40
+ * children, mounts it into the specified DOM container, and registers it
41
+ * with the PortalManager using a unique key.
42
+ * - `remove(key)` Removes a previously rendered portal identified by its key
43
+ * and deregisters it from the PortalManager.
44
+ * - `destroy()` Clears all portals managed by this provider and invokes the
45
+ * destroy method on the PortalManager to clean up any resources.
46
+ *
47
+ */
48
+ export var getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
49
+ var portalsMap = new Map();
50
+ return {
51
+ render: function render(children, container, key) {
52
+ var portal = /*#__PURE__*/createPortal(children(), container, key);
53
+ portalsMap.set(key, portalManager.registerPortal(key, portal));
54
+ },
55
+ remove: function remove(key) {
56
+ var _portalsMap$get;
57
+ (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 || _portalsMap$get();
58
+ portalsMap.delete(key);
59
+ },
60
+ destroy: function destroy() {
61
+ portalsMap.clear();
62
+ portalManager.destroy();
63
+ }
64
+ };
65
+ };
@@ -1,70 +1,6 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react';
3
- import { createPortal } from 'react-dom';
4
- import { PortalBucket } from './PortalBucket';
1
+ import { useEffect, useMemo } from 'react';
2
+ import { createPortalRendererComponent, getPortalProviderAPI } from './common';
5
3
  import { PortalManager } from './PortalManager';
6
- export function createPortalRendererComponent(portalManager) {
7
- return function PortalRenderer() {
8
- var _useState = useState(portalManager.getBuckets()),
9
- _useState2 = _slicedToArray(_useState, 2),
10
- buckets = _useState2[0],
11
- setBuckets = _useState2[1];
12
- useLayoutEffect(function () {
13
- portalManager.registerPortalRenderer(setBuckets);
14
- return function () {
15
- portalManager.unregisterPortalRenderer();
16
- };
17
- }, []);
18
- var portalsElements = useMemo(function () {
19
- return buckets.map(function (_, i) {
20
- return /*#__PURE__*/React.createElement(PortalBucket, {
21
- key: i,
22
- id: i,
23
- portalManager: portalManager
24
- });
25
- });
26
- }, [buckets]);
27
- return /*#__PURE__*/React.createElement(React.Fragment, null, portalsElements);
28
- };
29
- }
30
-
31
- /**
32
- * Creates a portal provider for managing multiple React portals. The provider
33
- * facilitates rendering, removing, and destroying portals managed by a given
34
- * PortalManager.
35
- *
36
- * @param {PortalManager} portalManager - An instance of a PortalManager which
37
- * is responsible for registering, managing, and destroying portals.
38
- * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
39
- * portals.
40
- * - `render(children, container, key)` Renders a new React portal with the given
41
- * children, mounts it into the specified DOM container, and registers it
42
- * with the PortalManager using a unique key.
43
- * - `remove(key)` Removes a previously rendered portal identified by its key
44
- * and deregisters it from the PortalManager.
45
- * - `destroy()` Clears all portals managed by this provider and invokes the
46
- * destroy method on the PortalManager to clean up any resources.
47
- *
48
- */
49
- export var getPortalProviderAPI = function getPortalProviderAPI(portalManager) {
50
- var portalsMap = new Map();
51
- return {
52
- render: function render(children, container, key) {
53
- var portal = /*#__PURE__*/createPortal(children(), container, key);
54
- portalsMap.set(key, portalManager.registerPortal(key, portal));
55
- },
56
- remove: function remove(key) {
57
- var _portalsMap$get;
58
- (_portalsMap$get = portalsMap.get(key)) === null || _portalsMap$get === void 0 || _portalsMap$get();
59
- portalsMap.delete(key);
60
- },
61
- destroy: function destroy() {
62
- portalsMap.clear();
63
- portalManager.destroy();
64
- }
65
- };
66
- };
67
-
68
4
  /**
69
5
  * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
70
6
  * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
@@ -58,17 +58,22 @@ var options = {
58
58
  * @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
59
59
  */
60
60
  export function find(query, items, prioritySortingFn) {
61
- var fuseOptions = _objectSpread({}, options);
62
- if (prioritySortingFn) {
63
- fuseOptions.sortFn = prioritySortingFn(items);
64
- }
65
- var fuse = new Fuse(items, fuseOptions);
66
61
  if (query === '') {
67
62
  // Copy and sort list by priority
68
63
  return items.slice(0).sort(function (a, b) {
69
64
  return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
70
65
  });
71
66
  }
67
+ var fuseOptions = _objectSpread({}, options);
68
+ if (prioritySortingFn) {
69
+ var sortFn = prioritySortingFn(items);
70
+ // prioritySortingFn will trigger the experiment exposure, but sortFn
71
+ // will be undefined for the control group.
72
+ if (sortFn) {
73
+ fuseOptions.sortFn = sortFn;
74
+ }
75
+ }
76
+ var fuse = new Fuse(items, fuseOptions);
72
77
  return fuse.search(query).map(function (result) {
73
78
  return result.item;
74
79
  });
@@ -21,7 +21,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
21
21
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "94.14.1";
24
+ var packageVersion = "94.15.0";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var DropList = /*#__PURE__*/function (_Component) {
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { type PortalManager } from './PortalManager';
3
+ type RenderFn = (children: () => React.ReactChild | JSX.Element | null, container: HTMLElement, key: string) => void;
4
+ type RemoveFn = (key: string) => void;
5
+ type DestoryFn = () => void;
6
+ export interface PortalProviderAPI {
7
+ render: RenderFn;
8
+ remove: RemoveFn;
9
+ destroy: DestoryFn;
10
+ }
11
+ export type PortalRendererComponent = () => JSX.Element;
12
+ export type UsePortalProviderReturnType = [PortalProviderAPI, PortalRendererComponent];
13
+ export declare function createPortalRendererComponent(portalManager: PortalManager): () => JSX.Element;
14
+ /**
15
+ * Creates a portal provider for managing multiple React portals. The provider
16
+ * facilitates rendering, removing, and destroying portals managed by a given
17
+ * PortalManager.
18
+ *
19
+ * @param {PortalManager} portalManager - An instance of a PortalManager which
20
+ * is responsible for registering, managing, and destroying portals.
21
+ * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
22
+ * portals.
23
+ * - `render(children, container, key)` Renders a new React portal with the given
24
+ * children, mounts it into the specified DOM container, and registers it
25
+ * with the PortalManager using a unique key.
26
+ * - `remove(key)` Removes a previously rendered portal identified by its key
27
+ * and deregisters it from the PortalManager.
28
+ * - `destroy()` Clears all portals managed by this provider and invokes the
29
+ * destroy method on the PortalManager to clean up any resources.
30
+ *
31
+ */
32
+ export declare const getPortalProviderAPI: (portalManager: PortalManager) => PortalProviderAPI;
33
+ export {};
@@ -1,4 +1,4 @@
1
1
  export { PortalManager } from './PortalManager';
2
2
  export { PortalBucket } from './PortalBucket';
3
3
  export { usePortalProvider } from './usePortalProvider';
4
- export type { PortalProviderAPI } from './usePortalProvider';
4
+ export type { PortalProviderAPI } from './common';
@@ -1,35 +1,4 @@
1
- import React from 'react';
2
- import { PortalManager } from './PortalManager';
3
- type RenderFn = (children: () => React.ReactChild | JSX.Element | null, container: HTMLElement, key: string) => void;
4
- type RemoveFn = (key: string) => void;
5
- type DestoryFn = () => void;
6
- export interface PortalProviderAPI {
7
- render: RenderFn;
8
- remove: RemoveFn;
9
- destroy: DestoryFn;
10
- }
11
- type PortalRendererComponent = () => JSX.Element;
12
- type UsePortalProviderReturnType = [PortalProviderAPI, PortalRendererComponent];
13
- export declare function createPortalRendererComponent(portalManager: PortalManager): () => JSX.Element;
14
- /**
15
- * Creates a portal provider for managing multiple React portals. The provider
16
- * facilitates rendering, removing, and destroying portals managed by a given
17
- * PortalManager.
18
- *
19
- * @param {PortalManager} portalManager - An instance of a PortalManager which
20
- * is responsible for registering, managing, and destroying portals.
21
- * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
22
- * portals.
23
- * - `render(children, container, key)` Renders a new React portal with the given
24
- * children, mounts it into the specified DOM container, and registers it
25
- * with the PortalManager using a unique key.
26
- * - `remove(key)` Removes a previously rendered portal identified by its key
27
- * and deregisters it from the PortalManager.
28
- * - `destroy()` Clears all portals managed by this provider and invokes the
29
- * destroy method on the PortalManager to clean up any resources.
30
- *
31
- */
32
- export declare const getPortalProviderAPI: (portalManager: PortalManager) => PortalProviderAPI;
1
+ import { type UsePortalProviderReturnType } from './common';
33
2
  /**
34
3
  * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
35
4
  * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
@@ -37,4 +6,3 @@ export declare const getPortalProviderAPI: (portalManager: PortalManager) => Por
37
6
  * 2. PortalRenderer: A React component responsible for rendering the portal content.
38
7
  */
39
8
  export declare function usePortalProvider(): UsePortalProviderReturnType;
40
- export {};
@@ -11,4 +11,4 @@ export declare const memoProcessQuickInsertItems: (items: Array<QuickInsertHandl
11
11
  * @param {QuickInsertItem[]} items - An array of QuickInsertItems to be searched.
12
12
  * @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
13
13
  */
14
- export declare function find(query: string, items: QuickInsertItem[], prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction): QuickInsertItem[];
14
+ export declare function find(query: string, items: QuickInsertItem[], prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined): QuickInsertItem[];
@@ -14,6 +14,7 @@ export type PMPluginFactoryParams = {
14
14
  providerFactory: ProviderFactory;
15
15
  errorReporter?: ErrorReporter;
16
16
  portalProviderAPI: PortalProviderAPI;
17
+ nodeViewPortalProviderAPI: PortalProviderAPI;
17
18
  dispatchAnalyticsEvent: DispatchAnalyticsEvent;
18
19
  featureFlags: FeatureFlags;
19
20
  getIntl: () => IntlShape;
@@ -4,7 +4,7 @@ import type { QuickInsertItem, QuickInsertProvider } from '../provider-factory';
4
4
  import type { EmptyStateHandler } from './empty-state-handler';
5
5
  export type QuickInsertOptions = boolean | {
6
6
  provider?: Promise<QuickInsertProvider>;
7
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
7
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
8
8
  onInsert?: (item: QuickInsertItem) => void;
9
9
  };
10
10
  export type QuickInsertHandlerFn = ((intl: IntlShape) => Array<QuickInsertItem>) & {
@@ -19,7 +19,7 @@ export type QuickInsertSearchOptions = {
19
19
  category?: string;
20
20
  disableDefaultItems?: boolean;
21
21
  featuredItems?: boolean;
22
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
22
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
23
23
  };
24
24
  export type QuickInsertPluginState = {
25
25
  isElementBrowserModalOpen: boolean;
@@ -36,7 +36,7 @@ export interface QuickInsertPluginOptions {
36
36
  enableElementBrowser?: boolean;
37
37
  elementBrowserHelpUrl?: string;
38
38
  emptyStateHandler?: EmptyStateHandler;
39
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
39
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
40
40
  onInsert?: (item: QuickInsertItem) => void;
41
41
  }
42
42
  export type QuickInsertSharedState = {
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { type PortalManager } from './PortalManager';
3
+ type RenderFn = (children: () => React.ReactChild | JSX.Element | null, container: HTMLElement, key: string) => void;
4
+ type RemoveFn = (key: string) => void;
5
+ type DestoryFn = () => void;
6
+ export interface PortalProviderAPI {
7
+ render: RenderFn;
8
+ remove: RemoveFn;
9
+ destroy: DestoryFn;
10
+ }
11
+ export type PortalRendererComponent = () => JSX.Element;
12
+ export type UsePortalProviderReturnType = [
13
+ PortalProviderAPI,
14
+ PortalRendererComponent
15
+ ];
16
+ export declare function createPortalRendererComponent(portalManager: PortalManager): () => JSX.Element;
17
+ /**
18
+ * Creates a portal provider for managing multiple React portals. The provider
19
+ * facilitates rendering, removing, and destroying portals managed by a given
20
+ * PortalManager.
21
+ *
22
+ * @param {PortalManager} portalManager - An instance of a PortalManager which
23
+ * is responsible for registering, managing, and destroying portals.
24
+ * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
25
+ * portals.
26
+ * - `render(children, container, key)` Renders a new React portal with the given
27
+ * children, mounts it into the specified DOM container, and registers it
28
+ * with the PortalManager using a unique key.
29
+ * - `remove(key)` Removes a previously rendered portal identified by its key
30
+ * and deregisters it from the PortalManager.
31
+ * - `destroy()` Clears all portals managed by this provider and invokes the
32
+ * destroy method on the PortalManager to clean up any resources.
33
+ *
34
+ */
35
+ export declare const getPortalProviderAPI: (portalManager: PortalManager) => PortalProviderAPI;
36
+ export {};
@@ -1,4 +1,4 @@
1
1
  export { PortalManager } from './PortalManager';
2
2
  export { PortalBucket } from './PortalBucket';
3
3
  export { usePortalProvider } from './usePortalProvider';
4
- export type { PortalProviderAPI } from './usePortalProvider';
4
+ export type { PortalProviderAPI } from './common';
@@ -1,38 +1,4 @@
1
- import React from 'react';
2
- import { PortalManager } from './PortalManager';
3
- type RenderFn = (children: () => React.ReactChild | JSX.Element | null, container: HTMLElement, key: string) => void;
4
- type RemoveFn = (key: string) => void;
5
- type DestoryFn = () => void;
6
- export interface PortalProviderAPI {
7
- render: RenderFn;
8
- remove: RemoveFn;
9
- destroy: DestoryFn;
10
- }
11
- type PortalRendererComponent = () => JSX.Element;
12
- type UsePortalProviderReturnType = [
13
- PortalProviderAPI,
14
- PortalRendererComponent
15
- ];
16
- export declare function createPortalRendererComponent(portalManager: PortalManager): () => JSX.Element;
17
- /**
18
- * Creates a portal provider for managing multiple React portals. The provider
19
- * facilitates rendering, removing, and destroying portals managed by a given
20
- * PortalManager.
21
- *
22
- * @param {PortalManager} portalManager - An instance of a PortalManager which
23
- * is responsible for registering, managing, and destroying portals.
24
- * @returns {PortalProviderAPI} An object containing methods to render, remove, and destroy
25
- * portals.
26
- * - `render(children, container, key)` Renders a new React portal with the given
27
- * children, mounts it into the specified DOM container, and registers it
28
- * with the PortalManager using a unique key.
29
- * - `remove(key)` Removes a previously rendered portal identified by its key
30
- * and deregisters it from the PortalManager.
31
- * - `destroy()` Clears all portals managed by this provider and invokes the
32
- * destroy method on the PortalManager to clean up any resources.
33
- *
34
- */
35
- export declare const getPortalProviderAPI: (portalManager: PortalManager) => PortalProviderAPI;
1
+ import { type UsePortalProviderReturnType } from './common';
36
2
  /**
37
3
  * Initializes PortalManager and creates PortalRendererComponent. Offers an API (portalProviderAPI) for managing portals.
38
4
  * @returns {[PortalProviderAPI, PortalRendererComponent]} An array containing two elements:
@@ -40,4 +6,3 @@ export declare const getPortalProviderAPI: (portalManager: PortalManager) => Por
40
6
  * 2. PortalRenderer: A React component responsible for rendering the portal content.
41
7
  */
42
8
  export declare function usePortalProvider(): UsePortalProviderReturnType;
43
- export {};
@@ -11,4 +11,4 @@ export declare const memoProcessQuickInsertItems: (items: Array<QuickInsertHandl
11
11
  * @param {QuickInsertItem[]} items - An array of QuickInsertItems to be searched.
12
12
  * @returns {QuickInsertItem[]} - Returns a sorted array of QuickInsertItems based on the priority. If the query string is empty, it will return the array sorted by priority. If a query string is provided, it will return an array of QuickInsertItems that match the query string, sorted by relevance to the query.
13
13
  */
14
- export declare function find(query: string, items: QuickInsertItem[], prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction): QuickInsertItem[];
14
+ export declare function find(query: string, items: QuickInsertItem[], prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined): QuickInsertItem[];
@@ -14,6 +14,7 @@ export type PMPluginFactoryParams = {
14
14
  providerFactory: ProviderFactory;
15
15
  errorReporter?: ErrorReporter;
16
16
  portalProviderAPI: PortalProviderAPI;
17
+ nodeViewPortalProviderAPI: PortalProviderAPI;
17
18
  dispatchAnalyticsEvent: DispatchAnalyticsEvent;
18
19
  featureFlags: FeatureFlags;
19
20
  getIntl: () => IntlShape;
@@ -4,7 +4,7 @@ import type { QuickInsertItem, QuickInsertProvider } from '../provider-factory';
4
4
  import type { EmptyStateHandler } from './empty-state-handler';
5
5
  export type QuickInsertOptions = boolean | {
6
6
  provider?: Promise<QuickInsertProvider>;
7
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
7
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
8
8
  onInsert?: (item: QuickInsertItem) => void;
9
9
  };
10
10
  export type QuickInsertHandlerFn = ((intl: IntlShape) => Array<QuickInsertItem>) & {
@@ -19,7 +19,7 @@ export type QuickInsertSearchOptions = {
19
19
  category?: string;
20
20
  disableDefaultItems?: boolean;
21
21
  featuredItems?: boolean;
22
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
22
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
23
23
  };
24
24
  export type QuickInsertPluginState = {
25
25
  isElementBrowserModalOpen: boolean;
@@ -36,7 +36,7 @@ export interface QuickInsertPluginOptions {
36
36
  enableElementBrowser?: boolean;
37
37
  elementBrowserHelpUrl?: string;
38
38
  emptyStateHandler?: EmptyStateHandler;
39
- prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction;
39
+ prioritySortingFn?: (items: QuickInsertItem[]) => Fuse.FuseSortFunction | undefined;
40
40
  onInsert?: (item: QuickInsertItem) => void;
41
41
  }
42
42
  export type QuickInsertSharedState = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "94.14.1",
3
+ "version": "94.15.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -110,7 +110,7 @@
110
110
  "dependencies": {
111
111
  "@atlaskit/activity-provider": "^2.4.0",
112
112
  "@atlaskit/adf-schema": "^44.2.0",
113
- "@atlaskit/adf-utils": "^19.10.0",
113
+ "@atlaskit/adf-utils": "^19.11.0",
114
114
  "@atlaskit/analytics-listeners": "^8.11.0",
115
115
  "@atlaskit/analytics-namespaced-context": "^6.12.0",
116
116
  "@atlaskit/analytics-next": "^10.1.0",
@@ -136,14 +136,14 @@
136
136
  "@atlaskit/media-common": "^11.7.0",
137
137
  "@atlaskit/media-file-preview": "^0.9.0",
138
138
  "@atlaskit/media-picker": "^67.0.0",
139
- "@atlaskit/media-ui": "^26.0.0",
139
+ "@atlaskit/media-ui": "^26.1.0",
140
140
  "@atlaskit/media-viewer": "49.2.7",
141
141
  "@atlaskit/mention": "^23.3.0",
142
142
  "@atlaskit/menu": "^2.13.0",
143
143
  "@atlaskit/onboarding": "^12.1.0",
144
144
  "@atlaskit/platform-feature-flags": "^0.3.0",
145
145
  "@atlaskit/popper": "^6.3.0",
146
- "@atlaskit/primitives": "^13.0.0",
146
+ "@atlaskit/primitives": "^13.1.0",
147
147
  "@atlaskit/profilecard": "^20.9.0",
148
148
  "@atlaskit/section-message": "^6.6.0",
149
149
  "@atlaskit/smart-card": "^30.2.0",