@atlaskit/editor-common 105.9.1 → 105.10.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,38 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 105.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#156919](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156919)
8
+ [`379f5c27f4939`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/379f5c27f4939) -
9
+ delay table sticky headers until table is in viewport
10
+
11
+ ### Patch Changes
12
+
13
+ - [#160973](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/160973)
14
+ [`9f2837a46dd98`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9f2837a46dd98) -
15
+ Ignore error thrown from getPreloadedExtension fallback to sync method
16
+ - [#159655](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/159655)
17
+ [`24f8c627d50f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/24f8c627d50f2) - ##
18
+ WHAT? Remove experimental graceful edit mode from view mode plugin and associated props.
19
+
20
+ ## WHY?
21
+
22
+ This experiment is being cleaned up and we are no longer proceeding in this direction.
23
+
24
+ ## HOW to adjust?
25
+
26
+ This experiment was only enabled for Confluence and should not have been enabled in other places.
27
+ If for some reason any of the following props/state/methdos were used please remove them:
28
+
29
+ - isConsumption
30
+ - contentMode
31
+ - initialContentMode
32
+ - updateContentMode
33
+
34
+ - Updated dependencies
35
+
3
36
  ## 105.9.1
4
37
 
5
38
  ### Patch Changes
@@ -11,7 +11,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
13
13
  var _primitives = require("@atlaskit/primitives");
14
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
14
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
16
15
  /**
17
16
  * @jsxRuntime classic
@@ -168,17 +167,6 @@ var ExtensionLabel = exports.ExtensionLabel = function ExtensionLabel(_ref) {
168
167
  onMouseLeave: function onMouseLeave() {
169
168
  setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(false);
170
169
  },
171
- onClick: function onClick() {
172
- if ((0, _experiments.editorExperiment)('live_pages_graceful_edit', 'text-click-delayed') || (0, _experiments.editorExperiment)('live_pages_graceful_edit', 'text-click-no-delay')) {
173
- var _pluginInjectionApi$c, _pluginInjectionApi$e;
174
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.execute( // Extensions are not yet using the new plugin architecture, and the use of the pluginInjectionApi
175
- // is not type safe in editor-common.
176
- // @ts-ignore
177
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
178
- type: 'intent-to-edit'
179
- }));
180
- }
181
- },
182
170
  "data-testid": "new-lozenge-container",
183
171
  contentEditable: false
184
172
  }, (0, _react.jsx)(_tooltip.default, {
@@ -57,37 +57,29 @@ var _default = exports.default = function _default(extensionProviders) {
57
57
  // preload() has not been called yet
58
58
  return;
59
59
  }
60
- var error;
61
60
  var _iterator = _createForOfIteratorHelper(providersCache),
62
61
  _step;
63
62
  try {
64
63
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
64
  var provider = _step.value;
66
- // Similar to invokeSingle. We are returning the first result that not throwing an error.
67
- // It's OK to get exception here because we have a lot of providers.
68
- // The current provider may not have the extension type we are looking for.
69
65
  try {
70
66
  var _provider$getPreloade;
71
67
  var result = provider === null || provider === void 0 || (_provider$getPreloade = provider.getPreloadedExtension) === null || _provider$getPreloade === void 0 ? void 0 : _provider$getPreloade.call(provider, type, key);
72
68
  if (result) {
73
69
  return result;
74
70
  }
75
- } catch (e) {
76
- error = e instanceof Error ? e : new Error(String(e));
71
+ } catch (_unused) {
72
+ // Not every provider will implement this method.
73
+ // In that case we would get error from other providers in the loop
74
+ // and undefined from that particular provider.
75
+ // We can safely ignore it and fallback to the async getExtension when nothing was found.
77
76
  }
78
77
  }
79
-
80
- // If we exhausted all providers and none of them returned a result, we throw the last error.
81
- // However as a extra precaution, we only throw in the dev environment.
82
- // In production we will return undefined and getExtensionModuleNodeMaybePreloaded will fallback to regular getExtension call.
83
78
  } catch (err) {
84
79
  _iterator.e(err);
85
80
  } finally {
86
81
  _iterator.f();
87
82
  }
88
- if (error && process.env.NODE_ENV !== 'production') {
89
- throw error;
90
- }
91
83
  },
92
84
  getExtension: function getExtension(type, key) {
93
85
  return invokeSingle('getExtension', [type, key]);
@@ -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 = "105.9.1";
20
+ var packageVersion = "105.10.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // Ignored via go/ees007
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nodeVisibilityManager = void 0;
7
+ // Use this selector to set the intersection observer boundary for editor's inline node views
8
+ // If this does not exist, it will use the IntersectionObserver's default root
9
+ var INTERSECTION_OBSERVER_ROOT_SELECTOR = '[data-editor-scroll-container="true"]';
10
+ var editorObservers = new WeakMap();
11
+ var callbackMap = new WeakMap();
12
+
13
+ /**
14
+ * Creates a node visibility manager
15
+ * @param editorElement
16
+ * @returns
17
+ */
18
+ var nodeVisibilityManager = exports.nodeVisibilityManager = function nodeVisibilityManager(editorElement) {
19
+ // Warning! do not reference editorElement outside of internal functions.
20
+ // editorElement is passed to allow support for multiple editors,
21
+
22
+ var unObserveInternal = function unObserveInternal(nodeElement) {
23
+ var _editorObservers$get;
24
+ (_editorObservers$get = editorObservers.get(editorElement)) === null || _editorObservers$get === void 0 || _editorObservers$get.unobserve(nodeElement);
25
+ callbackMap.delete(nodeElement);
26
+ };
27
+ var observe = function observe(observerConfig) {
28
+ var _editorObservers$get2;
29
+ callbackMap.set(observerConfig.element, observerConfig);
30
+ (_editorObservers$get2 = editorObservers.get(editorElement)) === null || _editorObservers$get2 === void 0 || _editorObservers$get2.observe(observerConfig.element);
31
+
32
+ // return clean up
33
+ return function () {
34
+ // consumer needs to unobserve on destroy if their element
35
+ // was observed but never scrolled into view
36
+ unObserveInternal(observerConfig.element);
37
+ };
38
+ };
39
+ var initialiseNodeObserver = function initialiseNodeObserver() {
40
+ if (editorObservers.has(editorElement)) {
41
+ return;
42
+ }
43
+ var intersectionObserverOptions = {
44
+ root: editorElement.closest(INTERSECTION_OBSERVER_ROOT_SELECTOR),
45
+ rootMargin: '0px 0px 100px 0px',
46
+ threshold: 0
47
+ };
48
+ var editorObserver = new IntersectionObserver(function (entries) {
49
+ return entries.map(function (entry) {
50
+ return {
51
+ entry: entry,
52
+ callback: callbackMap.get(entry.target)
53
+ };
54
+ })
55
+ // Invoke callbacks together to group browser rendering
56
+ // Avoiding requestAnimationFrame to reduce visual flickering
57
+ .forEach(function (_ref) {
58
+ var entry = _ref.entry,
59
+ callback = _ref.callback;
60
+ if (entry.isIntersecting) {
61
+ callback === null || callback === void 0 || callback.onFirstVisible();
62
+ if (entry.target instanceof HTMLElement) {
63
+ // immediately unobserve the element after it is visible
64
+ unObserveInternal(entry.target);
65
+ }
66
+ }
67
+ });
68
+ }, intersectionObserverOptions);
69
+ editorObservers.set(editorElement, editorObserver);
70
+ };
71
+ var disconnect = function disconnect() {
72
+ var _editorObservers$get3;
73
+ (_editorObservers$get3 = editorObservers.get(editorElement)) === null || _editorObservers$get3 === void 0 || _editorObservers$get3.disconnect();
74
+ editorObservers.delete(editorElement);
75
+ };
76
+ return {
77
+ initialiseNodeObserver: initialiseNodeObserver,
78
+ observe: observe,
79
+ disconnect: disconnect
80
+ };
81
+ };
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "105.9.1";
26
+ var packageVersion = "105.10.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -10,7 +10,6 @@ import classnames from 'classnames';
10
10
  import { FormattedMessage, defineMessages } from 'react-intl-next';
11
11
  import CustomizeIcon from '@atlaskit/icon/core/customize';
12
12
  import { Box, xcss } from '@atlaskit/primitives';
13
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
13
  import Tooltip from '@atlaskit/tooltip';
15
14
  const containerStyles = css({
16
15
  textAlign: 'left',
@@ -161,17 +160,6 @@ export const ExtensionLabel = ({
161
160
  onMouseLeave: () => {
162
161
  setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(false);
163
162
  },
164
- onClick: () => {
165
- if (editorExperiment('live_pages_graceful_edit', 'text-click-delayed') || editorExperiment('live_pages_graceful_edit', 'text-click-no-delay')) {
166
- var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$e;
167
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.execute( // Extensions are not yet using the new plugin architecture, and the use of the pluginInjectionApi
168
- // is not type safe in editor-common.
169
- // @ts-ignore
170
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
171
- type: 'intent-to-edit'
172
- }));
173
- }
174
- },
175
163
  "data-testid": "new-lozenge-container",
176
164
  contentEditable: false
177
165
  }, jsx(Tooltip, {
@@ -27,28 +27,20 @@ export default (extensionProviders => {
27
27
  // preload() has not been called yet
28
28
  return;
29
29
  }
30
- let error;
31
30
  for (const provider of providersCache) {
32
- // Similar to invokeSingle. We are returning the first result that not throwing an error.
33
- // It's OK to get exception here because we have a lot of providers.
34
- // The current provider may not have the extension type we are looking for.
35
31
  try {
36
32
  var _provider$getPreloade;
37
33
  const result = provider === null || provider === void 0 ? void 0 : (_provider$getPreloade = provider.getPreloadedExtension) === null || _provider$getPreloade === void 0 ? void 0 : _provider$getPreloade.call(provider, type, key);
38
34
  if (result) {
39
35
  return result;
40
36
  }
41
- } catch (e) {
42
- error = e instanceof Error ? e : new Error(String(e));
37
+ } catch {
38
+ // Not every provider will implement this method.
39
+ // In that case we would get error from other providers in the loop
40
+ // and undefined from that particular provider.
41
+ // We can safely ignore it and fallback to the async getExtension when nothing was found.
43
42
  }
44
43
  }
45
-
46
- // If we exhausted all providers and none of them returned a result, we throw the last error.
47
- // However as a extra precaution, we only throw in the dev environment.
48
- // In production we will return undefined and getExtensionModuleNodeMaybePreloaded will fallback to regular getExtension call.
49
- if (error && process.env.NODE_ENV !== 'production') {
50
- throw error;
51
- }
52
44
  },
53
45
  getExtension(type, key) {
54
46
  return invokeSingle('getExtension', [type, key]);
@@ -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 = "105.9.1";
4
+ const packageVersion = "105.10.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -0,0 +1,72 @@
1
+ // Use this selector to set the intersection observer boundary for editor's inline node views
2
+ // If this does not exist, it will use the IntersectionObserver's default root
3
+ const INTERSECTION_OBSERVER_ROOT_SELECTOR = '[data-editor-scroll-container="true"]';
4
+ const editorObservers = new WeakMap();
5
+ const callbackMap = new WeakMap();
6
+
7
+ /**
8
+ * Creates a node visibility manager
9
+ * @param editorElement
10
+ * @returns
11
+ */
12
+ export const nodeVisibilityManager = editorElement => {
13
+ // Warning! do not reference editorElement outside of internal functions.
14
+ // editorElement is passed to allow support for multiple editors,
15
+
16
+ const unObserveInternal = nodeElement => {
17
+ var _editorObservers$get;
18
+ (_editorObservers$get = editorObservers.get(editorElement)) === null || _editorObservers$get === void 0 ? void 0 : _editorObservers$get.unobserve(nodeElement);
19
+ callbackMap.delete(nodeElement);
20
+ };
21
+ const observe = observerConfig => {
22
+ var _editorObservers$get2;
23
+ callbackMap.set(observerConfig.element, observerConfig);
24
+ (_editorObservers$get2 = editorObservers.get(editorElement)) === null || _editorObservers$get2 === void 0 ? void 0 : _editorObservers$get2.observe(observerConfig.element);
25
+
26
+ // return clean up
27
+ return () => {
28
+ // consumer needs to unobserve on destroy if their element
29
+ // was observed but never scrolled into view
30
+ unObserveInternal(observerConfig.element);
31
+ };
32
+ };
33
+ const initialiseNodeObserver = () => {
34
+ if (editorObservers.has(editorElement)) {
35
+ return;
36
+ }
37
+ const intersectionObserverOptions = {
38
+ root: editorElement.closest(INTERSECTION_OBSERVER_ROOT_SELECTOR),
39
+ rootMargin: '0px 0px 100px 0px',
40
+ threshold: 0
41
+ };
42
+ const editorObserver = new IntersectionObserver(entries => entries.map(entry => ({
43
+ entry,
44
+ callback: callbackMap.get(entry.target)
45
+ }))
46
+ // Invoke callbacks together to group browser rendering
47
+ // Avoiding requestAnimationFrame to reduce visual flickering
48
+ .forEach(({
49
+ entry,
50
+ callback
51
+ }) => {
52
+ if (entry.isIntersecting) {
53
+ callback === null || callback === void 0 ? void 0 : callback.onFirstVisible();
54
+ if (entry.target instanceof HTMLElement) {
55
+ // immediately unobserve the element after it is visible
56
+ unObserveInternal(entry.target);
57
+ }
58
+ }
59
+ }), intersectionObserverOptions);
60
+ editorObservers.set(editorElement, editorObserver);
61
+ };
62
+ const disconnect = () => {
63
+ var _editorObservers$get3;
64
+ (_editorObservers$get3 = editorObservers.get(editorElement)) === null || _editorObservers$get3 === void 0 ? void 0 : _editorObservers$get3.disconnect();
65
+ editorObservers.delete(editorElement);
66
+ };
67
+ return {
68
+ initialiseNodeObserver,
69
+ observe,
70
+ disconnect
71
+ };
72
+ };
@@ -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 = "105.9.1";
16
+ const packageVersion = "105.10.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -10,7 +10,6 @@ import classnames from 'classnames';
10
10
  import { FormattedMessage, defineMessages } from 'react-intl-next';
11
11
  import CustomizeIcon from '@atlaskit/icon/core/customize';
12
12
  import { Box, xcss } from '@atlaskit/primitives';
13
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
13
  import Tooltip from '@atlaskit/tooltip';
15
14
  var containerStyles = css({
16
15
  textAlign: 'left',
@@ -160,17 +159,6 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
160
159
  onMouseLeave: function onMouseLeave() {
161
160
  setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(false);
162
161
  },
163
- onClick: function onClick() {
164
- if (editorExperiment('live_pages_graceful_edit', 'text-click-delayed') || editorExperiment('live_pages_graceful_edit', 'text-click-no-delay')) {
165
- var _pluginInjectionApi$c, _pluginInjectionApi$e;
166
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.execute( // Extensions are not yet using the new plugin architecture, and the use of the pluginInjectionApi
167
- // is not type safe in editor-common.
168
- // @ts-ignore
169
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.commands.updateContentMode({
170
- type: 'intent-to-edit'
171
- }));
172
- }
173
- },
174
162
  "data-testid": "new-lozenge-container",
175
163
  contentEditable: false
176
164
  }, jsx(Tooltip, {
@@ -50,37 +50,29 @@ export default (function (extensionProviders) {
50
50
  // preload() has not been called yet
51
51
  return;
52
52
  }
53
- var error;
54
53
  var _iterator = _createForOfIteratorHelper(providersCache),
55
54
  _step;
56
55
  try {
57
56
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
58
57
  var provider = _step.value;
59
- // Similar to invokeSingle. We are returning the first result that not throwing an error.
60
- // It's OK to get exception here because we have a lot of providers.
61
- // The current provider may not have the extension type we are looking for.
62
58
  try {
63
59
  var _provider$getPreloade;
64
60
  var result = provider === null || provider === void 0 || (_provider$getPreloade = provider.getPreloadedExtension) === null || _provider$getPreloade === void 0 ? void 0 : _provider$getPreloade.call(provider, type, key);
65
61
  if (result) {
66
62
  return result;
67
63
  }
68
- } catch (e) {
69
- error = e instanceof Error ? e : new Error(String(e));
64
+ } catch (_unused) {
65
+ // Not every provider will implement this method.
66
+ // In that case we would get error from other providers in the loop
67
+ // and undefined from that particular provider.
68
+ // We can safely ignore it and fallback to the async getExtension when nothing was found.
70
69
  }
71
70
  }
72
-
73
- // If we exhausted all providers and none of them returned a result, we throw the last error.
74
- // However as a extra precaution, we only throw in the dev environment.
75
- // In production we will return undefined and getExtensionModuleNodeMaybePreloaded will fallback to regular getExtension call.
76
71
  } catch (err) {
77
72
  _iterator.e(err);
78
73
  } finally {
79
74
  _iterator.f();
80
75
  }
81
- if (error && process.env.NODE_ENV !== 'production') {
82
- throw error;
83
- }
84
76
  },
85
77
  getExtension: function getExtension(type, key) {
86
78
  return invokeSingle('getExtension', [type, key]);
@@ -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 = "105.9.1";
10
+ var packageVersion = "105.10.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -0,0 +1,75 @@
1
+ // Use this selector to set the intersection observer boundary for editor's inline node views
2
+ // If this does not exist, it will use the IntersectionObserver's default root
3
+ var INTERSECTION_OBSERVER_ROOT_SELECTOR = '[data-editor-scroll-container="true"]';
4
+ var editorObservers = new WeakMap();
5
+ var callbackMap = new WeakMap();
6
+
7
+ /**
8
+ * Creates a node visibility manager
9
+ * @param editorElement
10
+ * @returns
11
+ */
12
+ export var nodeVisibilityManager = function nodeVisibilityManager(editorElement) {
13
+ // Warning! do not reference editorElement outside of internal functions.
14
+ // editorElement is passed to allow support for multiple editors,
15
+
16
+ var unObserveInternal = function unObserveInternal(nodeElement) {
17
+ var _editorObservers$get;
18
+ (_editorObservers$get = editorObservers.get(editorElement)) === null || _editorObservers$get === void 0 || _editorObservers$get.unobserve(nodeElement);
19
+ callbackMap.delete(nodeElement);
20
+ };
21
+ var observe = function observe(observerConfig) {
22
+ var _editorObservers$get2;
23
+ callbackMap.set(observerConfig.element, observerConfig);
24
+ (_editorObservers$get2 = editorObservers.get(editorElement)) === null || _editorObservers$get2 === void 0 || _editorObservers$get2.observe(observerConfig.element);
25
+
26
+ // return clean up
27
+ return function () {
28
+ // consumer needs to unobserve on destroy if their element
29
+ // was observed but never scrolled into view
30
+ unObserveInternal(observerConfig.element);
31
+ };
32
+ };
33
+ var initialiseNodeObserver = function initialiseNodeObserver() {
34
+ if (editorObservers.has(editorElement)) {
35
+ return;
36
+ }
37
+ var intersectionObserverOptions = {
38
+ root: editorElement.closest(INTERSECTION_OBSERVER_ROOT_SELECTOR),
39
+ rootMargin: '0px 0px 100px 0px',
40
+ threshold: 0
41
+ };
42
+ var editorObserver = new IntersectionObserver(function (entries) {
43
+ return entries.map(function (entry) {
44
+ return {
45
+ entry: entry,
46
+ callback: callbackMap.get(entry.target)
47
+ };
48
+ })
49
+ // Invoke callbacks together to group browser rendering
50
+ // Avoiding requestAnimationFrame to reduce visual flickering
51
+ .forEach(function (_ref) {
52
+ var entry = _ref.entry,
53
+ callback = _ref.callback;
54
+ if (entry.isIntersecting) {
55
+ callback === null || callback === void 0 || callback.onFirstVisible();
56
+ if (entry.target instanceof HTMLElement) {
57
+ // immediately unobserve the element after it is visible
58
+ unObserveInternal(entry.target);
59
+ }
60
+ }
61
+ });
62
+ }, intersectionObserverOptions);
63
+ editorObservers.set(editorElement, editorObserver);
64
+ };
65
+ var disconnect = function disconnect() {
66
+ var _editorObservers$get3;
67
+ (_editorObservers$get3 = editorObservers.get(editorElement)) === null || _editorObservers$get3 === void 0 || _editorObservers$get3.disconnect();
68
+ editorObservers.delete(editorElement);
69
+ };
70
+ return {
71
+ initialiseNodeObserver: initialiseNodeObserver,
72
+ observe: observe,
73
+ disconnect: disconnect
74
+ };
75
+ };
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "105.9.1";
23
+ var packageVersion = "105.10.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -0,0 +1,29 @@
1
+ type NodeObservationConfig = {
2
+ element: HTMLElement;
3
+ onFirstVisible: () => void;
4
+ };
5
+ export type NodeVisibilityManager = {
6
+ /**
7
+ * Establishes IntersectionObserver for the editor to monitor all node viewport visibility
8
+ * @param editorDivElement
9
+ * @returns
10
+ */
11
+ initialiseNodeObserver: () => void;
12
+ /**
13
+ * observes specific node element with callbacks for triggering when the node is visible or hidden
14
+ */
15
+ observe: (observeConfig: NodeObservationConfig) => () => void;
16
+ /**
17
+ * Kills the IntersectionObserver and all callbacks
18
+ * @returns
19
+ */
20
+ disconnect: () => void;
21
+ };
22
+ type NodeVisibilityManagerFn = (editorElement: HTMLElement) => NodeVisibilityManager;
23
+ /**
24
+ * Creates a node visibility manager
25
+ * @param editorElement
26
+ * @returns
27
+ */
28
+ export declare const nodeVisibilityManager: NodeVisibilityManagerFn;
29
+ export {};
@@ -0,0 +1,29 @@
1
+ type NodeObservationConfig = {
2
+ element: HTMLElement;
3
+ onFirstVisible: () => void;
4
+ };
5
+ export type NodeVisibilityManager = {
6
+ /**
7
+ * Establishes IntersectionObserver for the editor to monitor all node viewport visibility
8
+ * @param editorDivElement
9
+ * @returns
10
+ */
11
+ initialiseNodeObserver: () => void;
12
+ /**
13
+ * observes specific node element with callbacks for triggering when the node is visible or hidden
14
+ */
15
+ observe: (observeConfig: NodeObservationConfig) => () => void;
16
+ /**
17
+ * Kills the IntersectionObserver and all callbacks
18
+ * @returns
19
+ */
20
+ disconnect: () => void;
21
+ };
22
+ type NodeVisibilityManagerFn = (editorElement: HTMLElement) => NodeVisibilityManager;
23
+ /**
24
+ * Creates a node visibility manager
25
+ * @param editorElement
26
+ * @returns
27
+ */
28
+ export declare const nodeVisibilityManager: NodeVisibilityManagerFn;
29
+ export {};
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/node-visibility",
3
+ "main": "../dist/cjs/node-visibility/node-visibility-manager.js",
4
+ "module": "../dist/esm/node-visibility/node-visibility-manager.js",
5
+ "module:es2019": "../dist/es2019/node-visibility/node-visibility-manager.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/node-visibility/node-visibility-manager.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <5.4": {
12
+ "*": [
13
+ "../dist/types-ts4.5/node-visibility/node-visibility-manager.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "105.9.1",
3
+ "version": "105.10.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/"
@@ -77,6 +77,7 @@
77
77
  "./media-single": "./src/media-single/index.ts",
78
78
  "./media": "./src/media/index.ts",
79
79
  "./monitoring": "./src/monitoring/index.ts",
80
+ "./node-visibility": "./src/node-visibility/node-visibility-manager.ts",
80
81
  "./paste": "./src/paste/index.ts",
81
82
  "./resizer": "./src/resizer/index.ts",
82
83
  "./editor-analytics": "./src/editor-analytics/index.ts",
@@ -139,7 +140,7 @@
139
140
  "@atlaskit/editor-shared-styles": "^3.4.0",
140
141
  "@atlaskit/editor-tables": "^2.9.0",
141
142
  "@atlaskit/emoji": "^69.2.0",
142
- "@atlaskit/icon": "^26.2.0",
143
+ "@atlaskit/icon": "^26.3.0",
143
144
  "@atlaskit/icon-object": "^7.1.0",
144
145
  "@atlaskit/link": "^3.2.0",
145
146
  "@atlaskit/link-datasource": "^4.11.0",
@@ -168,7 +169,7 @@
168
169
  "@atlaskit/task-decision": "^19.2.0",
169
170
  "@atlaskit/textfield": "^8.0.0",
170
171
  "@atlaskit/theme": "^18.0.0",
171
- "@atlaskit/tmp-editor-statsig": "^4.25.0",
172
+ "@atlaskit/tmp-editor-statsig": "^5.0.0",
172
173
  "@atlaskit/tokens": "^4.9.0",
173
174
  "@atlaskit/tooltip": "^20.0.0",
174
175
  "@atlaskit/width-detector": "^5.0.0",