@atlaskit/react-ufo 3.7.0 → 3.8.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 (27) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/config/index.js +0 -9
  3. package/dist/cjs/vc/vc-observer/observers/index.js +4 -18
  4. package/dist/cjs/vc/vc-observer/revisions/fy25_01.js +1 -1
  5. package/dist/es2019/config/index.js +0 -8
  6. package/dist/es2019/vc/vc-observer/observers/index.js +0 -15
  7. package/dist/es2019/vc/vc-observer/revisions/fy25_01.js +1 -1
  8. package/dist/esm/config/index.js +0 -8
  9. package/dist/esm/vc/vc-observer/observers/index.js +4 -18
  10. package/dist/esm/vc/vc-observer/revisions/fy25_01.js +1 -1
  11. package/dist/types/common/vc/types.d.ts +1 -1
  12. package/dist/types/config/index.d.ts +0 -2
  13. package/dist/types/vc/vc-observer/observers/index.d.ts +0 -1
  14. package/dist/types-ts4.5/common/vc/types.d.ts +1 -1
  15. package/dist/types-ts4.5/config/index.d.ts +0 -2
  16. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +0 -1
  17. package/package.json +1 -1
  18. package/dist/cjs/vc/vc-observer/observers/editor-lnv/index.js +0 -186
  19. package/dist/cjs/vc/vc-observer/observers/editor-lnv/test-utils.js +0 -68
  20. package/dist/es2019/vc/vc-observer/observers/editor-lnv/index.js +0 -140
  21. package/dist/es2019/vc/vc-observer/observers/editor-lnv/test-utils.js +0 -41
  22. package/dist/esm/vc/vc-observer/observers/editor-lnv/index.js +0 -180
  23. package/dist/esm/vc/vc-observer/observers/editor-lnv/test-utils.js +0 -58
  24. package/dist/types/vc/vc-observer/observers/editor-lnv/index.d.ts +0 -24
  25. package/dist/types/vc/vc-observer/observers/editor-lnv/test-utils.d.ts +0 -35
  26. package/dist/types-ts4.5/vc/vc-observer/observers/editor-lnv/index.d.ts +0 -24
  27. package/dist/types-ts4.5/vc/vc-observer/observers/editor-lnv/test-utils.d.ts +0 -35
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#146843](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/146843)
8
+ [`34bd7506b5f71`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/34bd7506b5f71) -
9
+ remove editor LNV handling, since we already have TTVC v3
10
+
3
11
  ## 3.7.0
4
12
 
5
13
  ### Minor Changes
@@ -16,7 +16,6 @@ exports.getRemovePageSegmentsUFOPrefixes = getRemovePageSegmentsUFOPrefixes;
16
16
  exports.getTypingPerformanceTracingMethod = getTypingPerformanceTracingMethod;
17
17
  exports.getUfoNameOverrides = getUfoNameOverrides;
18
18
  exports.setUFOConfig = setUFOConfig;
19
- exports.shouldHandleEditorLnv = shouldHandleEditorLnv;
20
19
  var config;
21
20
 
22
21
  // Defensively typed, since this is directly user-editable
@@ -264,12 +263,4 @@ function getDoNotAbortActivePressInteractionOnTransition() {
264
263
  } catch (e) {
265
264
  return undefined;
266
265
  }
267
- }
268
- function shouldHandleEditorLnv() {
269
- try {
270
- var _config$enableEditorL, _config12;
271
- return (_config$enableEditorL = (_config12 = config) === null || _config12 === void 0 ? void 0 : _config12.enableEditorLnvHandler) !== null && _config$enableEditorL !== void 0 ? _config$enableEditorL : false;
272
- } catch (e) {
273
- return false;
274
- }
275
266
  }
@@ -9,9 +9,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
- var _config = require("../../../config");
13
12
  var _vcUtils = require("../media-wrapper/vc-utils");
14
- var _editorLnv = require("./editor-lnv");
15
13
  var _isNonVisualStyleMutation = _interopRequireDefault(require("./non-visual-styles/is-non-visual-style-mutation"));
16
14
  var _ssrPlaceholders = require("./ssr-placeholders");
17
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -83,7 +81,6 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
83
81
  this.intersectionObserver = this.getIntersectionObserver();
84
82
  this.mutationObserver = this.getMutationObserver();
85
83
  this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers();
86
- this.editorLnvHandler = new _editorLnv.EditorLnvHandler();
87
84
  }
88
85
  return (0, _createClass2.default)(Observers, [{
89
86
  key: "isBrowserSupported",
@@ -120,7 +117,6 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
120
117
  this.callbacks = new Set();
121
118
  this.ssr.reactRootElement = null;
122
119
  this.ssrPlaceholderHandler.clear();
123
- this.editorLnvHandler.clear();
124
120
  }
125
121
  }, {
126
122
  key: "getTotalTime",
@@ -152,7 +148,6 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
152
148
  if (!this.isBrowserSupported()) {
153
149
  return null;
154
150
  }
155
- var shouldHandleEditorLnvLocal = (0, _config.shouldHandleEditorLnv)();
156
151
  return new MutationObserver(function (mutations) {
157
152
  _this2.measureStart();
158
153
  mutations.forEach(function (mutation) {
@@ -198,15 +193,6 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
198
193
  });
199
194
  return;
200
195
  }
201
- if (shouldHandleEditorLnvLocal) {
202
- if (_this2.editorLnvHandler.shouldHandleAddedNode(node)) {
203
- _this2.editorLnvHandler.handleAddedNode(node).then(function (_ref) {
204
- var shouldIgnore = _ref.shouldIgnore;
205
- _this2.observeElement(node, mutation, 'html', shouldIgnore ? 'editor-lazy-node-view' : ignoreReason);
206
- });
207
- return;
208
- }
209
- }
210
196
  _this2.observeElement(node, mutation, 'html', ignoreReason);
211
197
  }
212
198
  if (node instanceof Text && node.parentElement != null) {
@@ -284,10 +270,10 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
284
270
  }
285
271
  return new IntersectionObserver(function (entries) {
286
272
  _this3.measureStart();
287
- entries.forEach(function (_ref2) {
288
- var isIntersecting = _ref2.isIntersecting,
289
- ir = _ref2.intersectionRect,
290
- target = _ref2.target;
273
+ entries.forEach(function (_ref) {
274
+ var isIntersecting = _ref.isIntersecting,
275
+ ir = _ref.intersectionRect,
276
+ target = _ref.target;
291
277
  var data = _this3.observedMutations.get(target);
292
278
  _this3.observedMutations.delete(target);
293
279
  if (isIntersecting && ir.width > 0 && ir.height > 0) {
@@ -14,7 +14,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
14
14
  var _ViewportUpdateClassifier = require("./ViewportUpdateClassifier");
15
15
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
16
16
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
17
- var legacyIgnoreReasons = ['image', 'ssr-hydration', 'editor-lazy-node-view'];
17
+ var legacyIgnoreReasons = ['image', 'ssr-hydration'];
18
18
  var FY25_01Classifier = exports.FY25_01Classifier = /*#__PURE__*/function (_ViewportUpdateClassi) {
19
19
  function FY25_01Classifier() {
20
20
  var _this;
@@ -256,12 +256,4 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
256
256
  } catch (e) {
257
257
  return undefined;
258
258
  }
259
- }
260
- export function shouldHandleEditorLnv() {
261
- try {
262
- var _config$enableEditorL, _config;
263
- return (_config$enableEditorL = (_config = config) === null || _config === void 0 ? void 0 : _config.enableEditorLnvHandler) !== null && _config$enableEditorL !== void 0 ? _config$enableEditorL : false;
264
- } catch (e) {
265
- return false;
266
- }
267
259
  }
@@ -1,8 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- import { shouldHandleEditorLnv } from '../../../config';
4
3
  import { isContainedWithinMediaWrapper } from '../media-wrapper/vc-utils';
5
- import { EditorLnvHandler } from './editor-lnv';
6
4
  import isNonVisualStyleMutation from './non-visual-styles/is-non-visual-style-mutation';
7
5
  import { SSRPlaceholderHandlers } from './ssr-placeholders';
8
6
  const state = {
@@ -71,7 +69,6 @@ export class Observers {
71
69
  this.intersectionObserver = this.getIntersectionObserver();
72
70
  this.mutationObserver = this.getMutationObserver();
73
71
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers();
74
- this.editorLnvHandler = new EditorLnvHandler();
75
72
  }
76
73
  isBrowserSupported() {
77
74
  return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
@@ -102,7 +99,6 @@ export class Observers {
102
99
  this.callbacks = new Set();
103
100
  this.ssr.reactRootElement = null;
104
101
  this.ssrPlaceholderHandler.clear();
105
- this.editorLnvHandler.clear();
106
102
  }
107
103
  getTotalTime() {
108
104
  return this.totalTime;
@@ -121,7 +117,6 @@ export class Observers {
121
117
  if (!this.isBrowserSupported()) {
122
118
  return null;
123
119
  }
124
- const shouldHandleEditorLnvLocal = shouldHandleEditorLnv();
125
120
  return new MutationObserver(mutations => {
126
121
  this.measureStart();
127
122
  mutations.forEach(mutation => {
@@ -167,16 +162,6 @@ export class Observers {
167
162
  });
168
163
  return;
169
164
  }
170
- if (shouldHandleEditorLnvLocal) {
171
- if (this.editorLnvHandler.shouldHandleAddedNode(node)) {
172
- this.editorLnvHandler.handleAddedNode(node).then(({
173
- shouldIgnore
174
- }) => {
175
- this.observeElement(node, mutation, 'html', shouldIgnore ? 'editor-lazy-node-view' : ignoreReason);
176
- });
177
- return;
178
- }
179
- }
180
165
  this.observeElement(node, mutation, 'html', ignoreReason);
181
166
  }
182
167
  if (node instanceof Text && node.parentElement != null) {
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { ViewportUpdateClassifier } from './ViewportUpdateClassifier';
3
- const legacyIgnoreReasons = ['image', 'ssr-hydration', 'editor-lazy-node-view'];
3
+ const legacyIgnoreReasons = ['image', 'ssr-hydration'];
4
4
  export class FY25_01Classifier extends ViewportUpdateClassifier {
5
5
  VCCalculationMethod({
6
6
  VCParts,
@@ -245,12 +245,4 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
245
245
  } catch (e) {
246
246
  return undefined;
247
247
  }
248
- }
249
- export function shouldHandleEditorLnv() {
250
- try {
251
- var _config$enableEditorL, _config12;
252
- return (_config$enableEditorL = (_config12 = config) === null || _config12 === void 0 ? void 0 : _config12.enableEditorLnvHandler) !== null && _config$enableEditorL !== void 0 ? _config$enableEditorL : false;
253
- } catch (e) {
254
- return false;
255
- }
256
248
  }
@@ -4,9 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { shouldHandleEditorLnv } from '../../../config';
8
7
  import { isContainedWithinMediaWrapper } from '../media-wrapper/vc-utils';
9
- import { EditorLnvHandler } from './editor-lnv';
10
8
  import isNonVisualStyleMutation from './non-visual-styles/is-non-visual-style-mutation';
11
9
  import { SSRPlaceholderHandlers } from './ssr-placeholders';
12
10
  var state = {
@@ -76,7 +74,6 @@ export var Observers = /*#__PURE__*/function () {
76
74
  this.intersectionObserver = this.getIntersectionObserver();
77
75
  this.mutationObserver = this.getMutationObserver();
78
76
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers();
79
- this.editorLnvHandler = new EditorLnvHandler();
80
77
  }
81
78
  return _createClass(Observers, [{
82
79
  key: "isBrowserSupported",
@@ -113,7 +110,6 @@ export var Observers = /*#__PURE__*/function () {
113
110
  this.callbacks = new Set();
114
111
  this.ssr.reactRootElement = null;
115
112
  this.ssrPlaceholderHandler.clear();
116
- this.editorLnvHandler.clear();
117
113
  }
118
114
  }, {
119
115
  key: "getTotalTime",
@@ -145,7 +141,6 @@ export var Observers = /*#__PURE__*/function () {
145
141
  if (!this.isBrowserSupported()) {
146
142
  return null;
147
143
  }
148
- var shouldHandleEditorLnvLocal = shouldHandleEditorLnv();
149
144
  return new MutationObserver(function (mutations) {
150
145
  _this2.measureStart();
151
146
  mutations.forEach(function (mutation) {
@@ -191,15 +186,6 @@ export var Observers = /*#__PURE__*/function () {
191
186
  });
192
187
  return;
193
188
  }
194
- if (shouldHandleEditorLnvLocal) {
195
- if (_this2.editorLnvHandler.shouldHandleAddedNode(node)) {
196
- _this2.editorLnvHandler.handleAddedNode(node).then(function (_ref) {
197
- var shouldIgnore = _ref.shouldIgnore;
198
- _this2.observeElement(node, mutation, 'html', shouldIgnore ? 'editor-lazy-node-view' : ignoreReason);
199
- });
200
- return;
201
- }
202
- }
203
189
  _this2.observeElement(node, mutation, 'html', ignoreReason);
204
190
  }
205
191
  if (node instanceof Text && node.parentElement != null) {
@@ -277,10 +263,10 @@ export var Observers = /*#__PURE__*/function () {
277
263
  }
278
264
  return new IntersectionObserver(function (entries) {
279
265
  _this3.measureStart();
280
- entries.forEach(function (_ref2) {
281
- var isIntersecting = _ref2.isIntersecting,
282
- ir = _ref2.intersectionRect,
283
- target = _ref2.target;
266
+ entries.forEach(function (_ref) {
267
+ var isIntersecting = _ref.isIntersecting,
268
+ ir = _ref.intersectionRect,
269
+ target = _ref.target;
284
270
  var data = _this3.observedMutations.get(target);
285
271
  _this3.observedMutations.delete(target);
286
272
  if (isIntersecting && ir.width > 0 && ir.height > 0) {
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
7
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
9
  import { ViewportUpdateClassifier } from './ViewportUpdateClassifier';
10
- var legacyIgnoreReasons = ['image', 'ssr-hydration', 'editor-lazy-node-view'];
10
+ var legacyIgnoreReasons = ['image', 'ssr-hydration'];
11
11
  export var FY25_01Classifier = /*#__PURE__*/function (_ViewportUpdateClassi) {
12
12
  function FY25_01Classifier() {
13
13
  var _this;
@@ -37,7 +37,7 @@ export type VCEntryType = {
37
37
  vc: number;
38
38
  elements: string[];
39
39
  };
40
- export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'editor-lazy-node-view' | 'not-visible' | 'non-visual-style' | '';
40
+ export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'not-visible' | 'non-visual-style' | '';
41
41
  export type ComponentsLogEntry = {
42
42
  type?: string;
43
43
  targetName: string;
@@ -90,7 +90,6 @@ export type Config = {
90
90
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
91
91
  readonly timeWindowForLateMutationsInMilliseconds?: number;
92
92
  readonly manuallyTrackReactProfilerMounts?: boolean;
93
- readonly enableEditorLnvHandler?: boolean;
94
93
  /**
95
94
  * @private
96
95
  * @deprecated setting this will do nothing now
@@ -112,5 +111,4 @@ export declare function getRemoveInteractionsUFOPrefixes(): boolean;
112
111
  export declare function getUfoNameOverrides(): UFONameOverride | undefined;
113
112
  export declare function getDoNotAbortActivePressInteraction(): string[] | undefined;
114
113
  export declare function getDoNotAbortActivePressInteractionOnTransition(): string[] | undefined;
115
- export declare function shouldHandleEditorLnv(): boolean;
116
114
  export {};
@@ -19,7 +19,6 @@ export declare class Observers implements BrowserObservers {
19
19
  private totalTime;
20
20
  private _startMeasureTimestamp;
21
21
  private ssrPlaceholderHandler;
22
- private editorLnvHandler;
23
22
  private ssr;
24
23
  private selectorConfig;
25
24
  constructor(opts: ConstructorOptions);
@@ -37,7 +37,7 @@ export type VCEntryType = {
37
37
  vc: number;
38
38
  elements: string[];
39
39
  };
40
- export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'editor-lazy-node-view' | 'not-visible' | 'non-visual-style' | '';
40
+ export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'not-visible' | 'non-visual-style' | '';
41
41
  export type ComponentsLogEntry = {
42
42
  type?: string;
43
43
  targetName: string;
@@ -90,7 +90,6 @@ export type Config = {
90
90
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
91
91
  readonly timeWindowForLateMutationsInMilliseconds?: number;
92
92
  readonly manuallyTrackReactProfilerMounts?: boolean;
93
- readonly enableEditorLnvHandler?: boolean;
94
93
  /**
95
94
  * @private
96
95
  * @deprecated setting this will do nothing now
@@ -116,5 +115,4 @@ export declare function getRemoveInteractionsUFOPrefixes(): boolean;
116
115
  export declare function getUfoNameOverrides(): UFONameOverride | undefined;
117
116
  export declare function getDoNotAbortActivePressInteraction(): string[] | undefined;
118
117
  export declare function getDoNotAbortActivePressInteractionOnTransition(): string[] | undefined;
119
- export declare function shouldHandleEditorLnv(): boolean;
120
118
  export {};
@@ -19,7 +19,6 @@ export declare class Observers implements BrowserObservers {
19
19
  private totalTime;
20
20
  private _startMeasureTimestamp;
21
21
  private ssrPlaceholderHandler;
22
- private editorLnvHandler;
23
22
  private ssr;
24
23
  private selectorConfig;
25
24
  constructor(opts: ConstructorOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -1,186 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.EditorLnvHandler = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var placeholderDataKey = 'editorLnvPlaceholder'; // data-editor-lnv-placeholder
12
- var replaceDataKey = 'editorLnvPlaceholderReplace'; // data-editor-lnv-placeholder-replace
13
- var EditorLnvHandler = exports.EditorLnvHandler = /*#__PURE__*/function () {
14
- function EditorLnvHandler() {
15
- var _this = this;
16
- (0, _classCallCheck2.default)(this, EditorLnvHandler);
17
- (0, _defineProperty2.default)(this, "placeholders", new Map());
18
- (0, _defineProperty2.default)(this, "getSizeCallbacks", new Map());
19
- (0, _defineProperty2.default)(this, "isAddedPlaceholderMatchingSizeCallbacks", new Map());
20
- (0, _defineProperty2.default)(this, "isAddedReplaceMatchingSizeCallbacks", new Map());
21
- (0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref) {
22
- var _target$dataset, _target$dataset2;
23
- var target = _ref.target,
24
- boundingClientRect = _ref.boundingClientRect;
25
- _this.intersectionObserver.unobserve(target);
26
- if (!(target instanceof HTMLElement)) {
27
- return;
28
- }
29
- var placeholderId = (_target$dataset = target.dataset) === null || _target$dataset === void 0 ? void 0 : _target$dataset[placeholderDataKey];
30
- if (placeholderId && _this.getSizeCallbacks.has(placeholderId)) {
31
- var _resolve = _this.getSizeCallbacks.get(placeholderId);
32
- _this.getSizeCallbacks.delete(placeholderId);
33
- if (!_resolve) {
34
- return;
35
- }
36
- _resolve({
37
- x: boundingClientRect.x,
38
- y: boundingClientRect.y,
39
- width: boundingClientRect.width,
40
- height: boundingClientRect.height
41
- });
42
- return;
43
- }
44
- if (placeholderId && _this.isAddedPlaceholderMatchingSizeCallbacks.has(placeholderId)) {
45
- var _resolve2 = _this.isAddedPlaceholderMatchingSizeCallbacks.get(placeholderId);
46
- _this.isAddedPlaceholderMatchingSizeCallbacks.delete(placeholderId);
47
- if (!_resolve2) {
48
- return;
49
- }
50
- var placeholder = _this.placeholders.get(placeholderId);
51
- if (!placeholder) {
52
- _resolve2(false);
53
- return;
54
- }
55
- _resolve2(_this.areRectsSameSize(placeholder, boundingClientRect));
56
- return;
57
- }
58
- var replaceId = (_target$dataset2 = target.dataset) === null || _target$dataset2 === void 0 ? void 0 : _target$dataset2[replaceDataKey];
59
- if (replaceId && _this.isAddedReplaceMatchingSizeCallbacks.has(replaceId)) {
60
- var _resolve3 = _this.isAddedReplaceMatchingSizeCallbacks.get(replaceId);
61
- _this.isAddedReplaceMatchingSizeCallbacks.delete(replaceId);
62
- if (!_resolve3) {
63
- return;
64
- }
65
- var _placeholder = _this.placeholders.get(replaceId);
66
- if (!_placeholder) {
67
- _resolve3(false);
68
- return;
69
- }
70
- _this.placeholders.delete(replaceId);
71
- _resolve3(_this.areRectsSameSize(_placeholder, boundingClientRect));
72
- return;
73
- }
74
- });
75
- this.intersectionObserver = new IntersectionObserver(function (entries) {
76
- return entries.filter(function (entry) {
77
- return entry.intersectionRatio > 0;
78
- }).forEach(_this.intersectionObserverCallback);
79
- });
80
- }
81
- return (0, _createClass2.default)(EditorLnvHandler, [{
82
- key: "shouldHandleAddedNode",
83
- value: function shouldHandleAddedNode(el) {
84
- var _el$dataset, _el$dataset2;
85
- return ((_el$dataset = el.dataset) === null || _el$dataset === void 0 ? void 0 : _el$dataset[placeholderDataKey]) || ((_el$dataset2 = el.dataset) === null || _el$dataset2 === void 0 ? void 0 : _el$dataset2[replaceDataKey]);
86
- }
87
- }, {
88
- key: "handleAddedNode",
89
- value: function handleAddedNode(el) {
90
- var _el$dataset3, _el$dataset4;
91
- // If it placeholder does not already exist, add it to the map
92
- var placeholderId = (_el$dataset3 = el.dataset) === null || _el$dataset3 === void 0 ? void 0 : _el$dataset3[placeholderDataKey];
93
- if (placeholderId) {
94
- return this.handleAddedPlaceholderNode(el, placeholderId);
95
- }
96
- var replaceId = (_el$dataset4 = el.dataset) === null || _el$dataset4 === void 0 ? void 0 : _el$dataset4[replaceDataKey];
97
- if (replaceId) {
98
- return this.handleAddedReplaceNode(el, replaceId);
99
- }
100
- return Promise.resolve({
101
- shouldIgnore: false
102
- });
103
- }
104
- }, {
105
- key: "clear",
106
- value: function clear() {
107
- this.placeholders.clear();
108
- this.intersectionObserver.disconnect();
109
- }
110
- }, {
111
- key: "handleAddedPlaceholderNode",
112
- value: function handleAddedPlaceholderNode(el, placeholderId) {
113
- if (this.isExistingPlaceholder(placeholderId)) {
114
- return this.isAddedPlaceholderMatchingSize(el, placeholderId).then(function (isMatching) {
115
- return {
116
- shouldIgnore: isMatching
117
- };
118
- });
119
- }
120
- return this.registerPlaceholder(el, placeholderId).then(function () {
121
- return {
122
- shouldIgnore: false
123
- };
124
- });
125
- }
126
- }, {
127
- key: "handleAddedReplaceNode",
128
- value: function handleAddedReplaceNode(el, placeholderId) {
129
- if (this.isExistingPlaceholder(placeholderId)) {
130
- return this.isAddedReplaceMatchingSize(el, placeholderId).then(function (isMatching) {
131
- return {
132
- shouldIgnore: isMatching
133
- };
134
- });
135
- }
136
- return Promise.resolve({
137
- shouldIgnore: false
138
- });
139
- }
140
- }, {
141
- key: "isExistingPlaceholder",
142
- value: function isExistingPlaceholder(placeholderId) {
143
- return this.placeholders.has(placeholderId);
144
- }
145
- }, {
146
- key: "registerPlaceholder",
147
- value: function registerPlaceholder(el, placeholderId) {
148
- var _this2 = this;
149
- return this.getSize(el, placeholderId).then(function (size) {
150
- _this2.placeholders.set(placeholderId, size);
151
- });
152
- }
153
- }, {
154
- key: "getSize",
155
- value: function getSize(el, placeholderId) {
156
- var _this3 = this;
157
- return new Promise(function (resolve) {
158
- _this3.getSizeCallbacks.set(placeholderId, resolve);
159
- _this3.intersectionObserver.observe(el);
160
- });
161
- }
162
- }, {
163
- key: "isAddedPlaceholderMatchingSize",
164
- value: function isAddedPlaceholderMatchingSize(el, placeholderId) {
165
- var _this4 = this;
166
- return new Promise(function (resolve) {
167
- _this4.isAddedPlaceholderMatchingSizeCallbacks.set(placeholderId, resolve);
168
- _this4.intersectionObserver.observe(el);
169
- });
170
- }
171
- }, {
172
- key: "isAddedReplaceMatchingSize",
173
- value: function isAddedReplaceMatchingSize(el, placeholderId) {
174
- var _this5 = this;
175
- return new Promise(function (resolve) {
176
- _this5.isAddedReplaceMatchingSizeCallbacks.set(placeholderId, resolve);
177
- _this5.intersectionObserver.observe(el);
178
- });
179
- }
180
- }, {
181
- key: "areRectsSameSize",
182
- value: function areRectsSameSize(a, b) {
183
- return Math.abs(a.width - b.width) < 1 && Math.abs(a.height - b.height) < 1;
184
- }
185
- }]);
186
- }();
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createMockIntersectionObserver = createMockIntersectionObserver;
8
- exports.createPlaceholderElement = createPlaceholderElement;
9
- exports.createReplaceElement = createReplaceElement;
10
- exports.handleElements = handleElements;
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
- var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
15
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
- function createPlaceholderElement(id) {
18
- var el = document.createElement('div');
19
- el.dataset.editorLnvPlaceholder = id;
20
- return el;
21
- }
22
- function createReplaceElement(id) {
23
- var el = document.createElement('div');
24
- el.dataset.editorLnvPlaceholderReplace = id;
25
- return el;
26
- }
27
- function handleElements(elements, handler, observerCallback, callback) {
28
- var _elements = (0, _toArray2.default)(elements),
29
- first = _elements[0],
30
- rest = _elements.slice(1);
31
- handler.handleAddedNode(first.element).then(function (result) {
32
- if (!rest.length) {
33
- // Recursion terminating condition
34
- callback(result);
35
- } else {
36
- // Recursively handle the rest of the elements
37
- handleElements(rest, handler, observerCallback, callback);
38
- }
39
- });
40
- observerCallback([{
41
- target: first.element,
42
- boundingClientRect: first.rect
43
- }]);
44
- }
45
- function createMockIntersectionObserver(cbRef) {
46
- return /*#__PURE__*/function () {
47
- function _class(fn) {
48
- (0, _classCallCheck2.default)(this, _class);
49
- cbRef.current = function (entries) {
50
- return fn(entries.map(function (entry) {
51
- return _objectSpread(_objectSpread({}, entry), {}, {
52
- intersectionRatio: 1
53
- });
54
- }));
55
- };
56
- }
57
- return (0, _createClass2.default)(_class, [{
58
- key: "observe",
59
- value: function observe() {}
60
- }, {
61
- key: "unobserve",
62
- value: function unobserve() {}
63
- }, {
64
- key: "disconnect",
65
- value: function disconnect() {}
66
- }]);
67
- }();
68
- }
@@ -1,140 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- const placeholderDataKey = 'editorLnvPlaceholder'; // data-editor-lnv-placeholder
3
- const replaceDataKey = 'editorLnvPlaceholderReplace'; // data-editor-lnv-placeholder-replace
4
-
5
- export class EditorLnvHandler {
6
- constructor() {
7
- _defineProperty(this, "placeholders", new Map());
8
- _defineProperty(this, "getSizeCallbacks", new Map());
9
- _defineProperty(this, "isAddedPlaceholderMatchingSizeCallbacks", new Map());
10
- _defineProperty(this, "isAddedReplaceMatchingSizeCallbacks", new Map());
11
- _defineProperty(this, "intersectionObserverCallback", ({
12
- target,
13
- boundingClientRect
14
- }) => {
15
- var _target$dataset, _target$dataset2;
16
- this.intersectionObserver.unobserve(target);
17
- if (!(target instanceof HTMLElement)) {
18
- return;
19
- }
20
- const placeholderId = (_target$dataset = target.dataset) === null || _target$dataset === void 0 ? void 0 : _target$dataset[placeholderDataKey];
21
- if (placeholderId && this.getSizeCallbacks.has(placeholderId)) {
22
- const resolve = this.getSizeCallbacks.get(placeholderId);
23
- this.getSizeCallbacks.delete(placeholderId);
24
- if (!resolve) {
25
- return;
26
- }
27
- resolve({
28
- x: boundingClientRect.x,
29
- y: boundingClientRect.y,
30
- width: boundingClientRect.width,
31
- height: boundingClientRect.height
32
- });
33
- return;
34
- }
35
- if (placeholderId && this.isAddedPlaceholderMatchingSizeCallbacks.has(placeholderId)) {
36
- const resolve = this.isAddedPlaceholderMatchingSizeCallbacks.get(placeholderId);
37
- this.isAddedPlaceholderMatchingSizeCallbacks.delete(placeholderId);
38
- if (!resolve) {
39
- return;
40
- }
41
- const placeholder = this.placeholders.get(placeholderId);
42
- if (!placeholder) {
43
- resolve(false);
44
- return;
45
- }
46
- resolve(this.areRectsSameSize(placeholder, boundingClientRect));
47
- return;
48
- }
49
- const replaceId = (_target$dataset2 = target.dataset) === null || _target$dataset2 === void 0 ? void 0 : _target$dataset2[replaceDataKey];
50
- if (replaceId && this.isAddedReplaceMatchingSizeCallbacks.has(replaceId)) {
51
- const resolve = this.isAddedReplaceMatchingSizeCallbacks.get(replaceId);
52
- this.isAddedReplaceMatchingSizeCallbacks.delete(replaceId);
53
- if (!resolve) {
54
- return;
55
- }
56
- const placeholder = this.placeholders.get(replaceId);
57
- if (!placeholder) {
58
- resolve(false);
59
- return;
60
- }
61
- this.placeholders.delete(replaceId);
62
- resolve(this.areRectsSameSize(placeholder, boundingClientRect));
63
- return;
64
- }
65
- });
66
- this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
67
- }
68
- shouldHandleAddedNode(el) {
69
- var _el$dataset, _el$dataset2;
70
- return ((_el$dataset = el.dataset) === null || _el$dataset === void 0 ? void 0 : _el$dataset[placeholderDataKey]) || ((_el$dataset2 = el.dataset) === null || _el$dataset2 === void 0 ? void 0 : _el$dataset2[replaceDataKey]);
71
- }
72
- handleAddedNode(el) {
73
- var _el$dataset3, _el$dataset4;
74
- // If it placeholder does not already exist, add it to the map
75
- const placeholderId = (_el$dataset3 = el.dataset) === null || _el$dataset3 === void 0 ? void 0 : _el$dataset3[placeholderDataKey];
76
- if (placeholderId) {
77
- return this.handleAddedPlaceholderNode(el, placeholderId);
78
- }
79
- const replaceId = (_el$dataset4 = el.dataset) === null || _el$dataset4 === void 0 ? void 0 : _el$dataset4[replaceDataKey];
80
- if (replaceId) {
81
- return this.handleAddedReplaceNode(el, replaceId);
82
- }
83
- return Promise.resolve({
84
- shouldIgnore: false
85
- });
86
- }
87
- clear() {
88
- this.placeholders.clear();
89
- this.intersectionObserver.disconnect();
90
- }
91
- handleAddedPlaceholderNode(el, placeholderId) {
92
- if (this.isExistingPlaceholder(placeholderId)) {
93
- return this.isAddedPlaceholderMatchingSize(el, placeholderId).then(isMatching => ({
94
- shouldIgnore: isMatching
95
- }));
96
- }
97
- return this.registerPlaceholder(el, placeholderId).then(() => ({
98
- shouldIgnore: false
99
- }));
100
- }
101
- handleAddedReplaceNode(el, placeholderId) {
102
- if (this.isExistingPlaceholder(placeholderId)) {
103
- return this.isAddedReplaceMatchingSize(el, placeholderId).then(isMatching => ({
104
- shouldIgnore: isMatching
105
- }));
106
- }
107
- return Promise.resolve({
108
- shouldIgnore: false
109
- });
110
- }
111
- isExistingPlaceholder(placeholderId) {
112
- return this.placeholders.has(placeholderId);
113
- }
114
- registerPlaceholder(el, placeholderId) {
115
- return this.getSize(el, placeholderId).then(size => {
116
- this.placeholders.set(placeholderId, size);
117
- });
118
- }
119
- getSize(el, placeholderId) {
120
- return new Promise(resolve => {
121
- this.getSizeCallbacks.set(placeholderId, resolve);
122
- this.intersectionObserver.observe(el);
123
- });
124
- }
125
- isAddedPlaceholderMatchingSize(el, placeholderId) {
126
- return new Promise(resolve => {
127
- this.isAddedPlaceholderMatchingSizeCallbacks.set(placeholderId, resolve);
128
- this.intersectionObserver.observe(el);
129
- });
130
- }
131
- isAddedReplaceMatchingSize(el, placeholderId) {
132
- return new Promise(resolve => {
133
- this.isAddedReplaceMatchingSizeCallbacks.set(placeholderId, resolve);
134
- this.intersectionObserver.observe(el);
135
- });
136
- }
137
- areRectsSameSize(a, b) {
138
- return Math.abs(a.width - b.width) < 1 && Math.abs(a.height - b.height) < 1;
139
- }
140
- }
@@ -1,41 +0,0 @@
1
- export function createPlaceholderElement(id) {
2
- const el = document.createElement('div');
3
- el.dataset.editorLnvPlaceholder = id;
4
- return el;
5
- }
6
- export function createReplaceElement(id) {
7
- const el = document.createElement('div');
8
- el.dataset.editorLnvPlaceholderReplace = id;
9
- return el;
10
- }
11
- export function handleElements(elements, handler, observerCallback, callback) {
12
- const [first, ...rest] = elements;
13
- handler.handleAddedNode(first.element).then(result => {
14
- if (!rest.length) {
15
- // Recursion terminating condition
16
- callback(result);
17
- } else {
18
- // Recursively handle the rest of the elements
19
- handleElements(rest, handler, observerCallback, callback);
20
- }
21
- });
22
- observerCallback([{
23
- target: first.element,
24
- boundingClientRect: first.rect
25
- }]);
26
- }
27
- export function createMockIntersectionObserver(cbRef) {
28
- return class {
29
- constructor(fn) {
30
- cbRef.current = entries => fn(entries.map(entry => {
31
- return {
32
- ...entry,
33
- intersectionRatio: 1
34
- };
35
- }));
36
- }
37
- observe() {}
38
- unobserve() {}
39
- disconnect() {}
40
- };
41
- }
@@ -1,180 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- var placeholderDataKey = 'editorLnvPlaceholder'; // data-editor-lnv-placeholder
5
- var replaceDataKey = 'editorLnvPlaceholderReplace'; // data-editor-lnv-placeholder-replace
6
-
7
- export var EditorLnvHandler = /*#__PURE__*/function () {
8
- function EditorLnvHandler() {
9
- var _this = this;
10
- _classCallCheck(this, EditorLnvHandler);
11
- _defineProperty(this, "placeholders", new Map());
12
- _defineProperty(this, "getSizeCallbacks", new Map());
13
- _defineProperty(this, "isAddedPlaceholderMatchingSizeCallbacks", new Map());
14
- _defineProperty(this, "isAddedReplaceMatchingSizeCallbacks", new Map());
15
- _defineProperty(this, "intersectionObserverCallback", function (_ref) {
16
- var _target$dataset, _target$dataset2;
17
- var target = _ref.target,
18
- boundingClientRect = _ref.boundingClientRect;
19
- _this.intersectionObserver.unobserve(target);
20
- if (!(target instanceof HTMLElement)) {
21
- return;
22
- }
23
- var placeholderId = (_target$dataset = target.dataset) === null || _target$dataset === void 0 ? void 0 : _target$dataset[placeholderDataKey];
24
- if (placeholderId && _this.getSizeCallbacks.has(placeholderId)) {
25
- var _resolve = _this.getSizeCallbacks.get(placeholderId);
26
- _this.getSizeCallbacks.delete(placeholderId);
27
- if (!_resolve) {
28
- return;
29
- }
30
- _resolve({
31
- x: boundingClientRect.x,
32
- y: boundingClientRect.y,
33
- width: boundingClientRect.width,
34
- height: boundingClientRect.height
35
- });
36
- return;
37
- }
38
- if (placeholderId && _this.isAddedPlaceholderMatchingSizeCallbacks.has(placeholderId)) {
39
- var _resolve2 = _this.isAddedPlaceholderMatchingSizeCallbacks.get(placeholderId);
40
- _this.isAddedPlaceholderMatchingSizeCallbacks.delete(placeholderId);
41
- if (!_resolve2) {
42
- return;
43
- }
44
- var placeholder = _this.placeholders.get(placeholderId);
45
- if (!placeholder) {
46
- _resolve2(false);
47
- return;
48
- }
49
- _resolve2(_this.areRectsSameSize(placeholder, boundingClientRect));
50
- return;
51
- }
52
- var replaceId = (_target$dataset2 = target.dataset) === null || _target$dataset2 === void 0 ? void 0 : _target$dataset2[replaceDataKey];
53
- if (replaceId && _this.isAddedReplaceMatchingSizeCallbacks.has(replaceId)) {
54
- var _resolve3 = _this.isAddedReplaceMatchingSizeCallbacks.get(replaceId);
55
- _this.isAddedReplaceMatchingSizeCallbacks.delete(replaceId);
56
- if (!_resolve3) {
57
- return;
58
- }
59
- var _placeholder = _this.placeholders.get(replaceId);
60
- if (!_placeholder) {
61
- _resolve3(false);
62
- return;
63
- }
64
- _this.placeholders.delete(replaceId);
65
- _resolve3(_this.areRectsSameSize(_placeholder, boundingClientRect));
66
- return;
67
- }
68
- });
69
- this.intersectionObserver = new IntersectionObserver(function (entries) {
70
- return entries.filter(function (entry) {
71
- return entry.intersectionRatio > 0;
72
- }).forEach(_this.intersectionObserverCallback);
73
- });
74
- }
75
- return _createClass(EditorLnvHandler, [{
76
- key: "shouldHandleAddedNode",
77
- value: function shouldHandleAddedNode(el) {
78
- var _el$dataset, _el$dataset2;
79
- return ((_el$dataset = el.dataset) === null || _el$dataset === void 0 ? void 0 : _el$dataset[placeholderDataKey]) || ((_el$dataset2 = el.dataset) === null || _el$dataset2 === void 0 ? void 0 : _el$dataset2[replaceDataKey]);
80
- }
81
- }, {
82
- key: "handleAddedNode",
83
- value: function handleAddedNode(el) {
84
- var _el$dataset3, _el$dataset4;
85
- // If it placeholder does not already exist, add it to the map
86
- var placeholderId = (_el$dataset3 = el.dataset) === null || _el$dataset3 === void 0 ? void 0 : _el$dataset3[placeholderDataKey];
87
- if (placeholderId) {
88
- return this.handleAddedPlaceholderNode(el, placeholderId);
89
- }
90
- var replaceId = (_el$dataset4 = el.dataset) === null || _el$dataset4 === void 0 ? void 0 : _el$dataset4[replaceDataKey];
91
- if (replaceId) {
92
- return this.handleAddedReplaceNode(el, replaceId);
93
- }
94
- return Promise.resolve({
95
- shouldIgnore: false
96
- });
97
- }
98
- }, {
99
- key: "clear",
100
- value: function clear() {
101
- this.placeholders.clear();
102
- this.intersectionObserver.disconnect();
103
- }
104
- }, {
105
- key: "handleAddedPlaceholderNode",
106
- value: function handleAddedPlaceholderNode(el, placeholderId) {
107
- if (this.isExistingPlaceholder(placeholderId)) {
108
- return this.isAddedPlaceholderMatchingSize(el, placeholderId).then(function (isMatching) {
109
- return {
110
- shouldIgnore: isMatching
111
- };
112
- });
113
- }
114
- return this.registerPlaceholder(el, placeholderId).then(function () {
115
- return {
116
- shouldIgnore: false
117
- };
118
- });
119
- }
120
- }, {
121
- key: "handleAddedReplaceNode",
122
- value: function handleAddedReplaceNode(el, placeholderId) {
123
- if (this.isExistingPlaceholder(placeholderId)) {
124
- return this.isAddedReplaceMatchingSize(el, placeholderId).then(function (isMatching) {
125
- return {
126
- shouldIgnore: isMatching
127
- };
128
- });
129
- }
130
- return Promise.resolve({
131
- shouldIgnore: false
132
- });
133
- }
134
- }, {
135
- key: "isExistingPlaceholder",
136
- value: function isExistingPlaceholder(placeholderId) {
137
- return this.placeholders.has(placeholderId);
138
- }
139
- }, {
140
- key: "registerPlaceholder",
141
- value: function registerPlaceholder(el, placeholderId) {
142
- var _this2 = this;
143
- return this.getSize(el, placeholderId).then(function (size) {
144
- _this2.placeholders.set(placeholderId, size);
145
- });
146
- }
147
- }, {
148
- key: "getSize",
149
- value: function getSize(el, placeholderId) {
150
- var _this3 = this;
151
- return new Promise(function (resolve) {
152
- _this3.getSizeCallbacks.set(placeholderId, resolve);
153
- _this3.intersectionObserver.observe(el);
154
- });
155
- }
156
- }, {
157
- key: "isAddedPlaceholderMatchingSize",
158
- value: function isAddedPlaceholderMatchingSize(el, placeholderId) {
159
- var _this4 = this;
160
- return new Promise(function (resolve) {
161
- _this4.isAddedPlaceholderMatchingSizeCallbacks.set(placeholderId, resolve);
162
- _this4.intersectionObserver.observe(el);
163
- });
164
- }
165
- }, {
166
- key: "isAddedReplaceMatchingSize",
167
- value: function isAddedReplaceMatchingSize(el, placeholderId) {
168
- var _this5 = this;
169
- return new Promise(function (resolve) {
170
- _this5.isAddedReplaceMatchingSizeCallbacks.set(placeholderId, resolve);
171
- _this5.intersectionObserver.observe(el);
172
- });
173
- }
174
- }, {
175
- key: "areRectsSameSize",
176
- value: function areRectsSameSize(a, b) {
177
- return Math.abs(a.width - b.width) < 1 && Math.abs(a.height - b.height) < 1;
178
- }
179
- }]);
180
- }();
@@ -1,58 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _toArray from "@babel/runtime/helpers/toArray";
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- export function createPlaceholderElement(id) {
8
- var el = document.createElement('div');
9
- el.dataset.editorLnvPlaceholder = id;
10
- return el;
11
- }
12
- export function createReplaceElement(id) {
13
- var el = document.createElement('div');
14
- el.dataset.editorLnvPlaceholderReplace = id;
15
- return el;
16
- }
17
- export function handleElements(elements, handler, observerCallback, callback) {
18
- var _elements = _toArray(elements),
19
- first = _elements[0],
20
- rest = _elements.slice(1);
21
- handler.handleAddedNode(first.element).then(function (result) {
22
- if (!rest.length) {
23
- // Recursion terminating condition
24
- callback(result);
25
- } else {
26
- // Recursively handle the rest of the elements
27
- handleElements(rest, handler, observerCallback, callback);
28
- }
29
- });
30
- observerCallback([{
31
- target: first.element,
32
- boundingClientRect: first.rect
33
- }]);
34
- }
35
- export function createMockIntersectionObserver(cbRef) {
36
- return /*#__PURE__*/function () {
37
- function _class(fn) {
38
- _classCallCheck(this, _class);
39
- cbRef.current = function (entries) {
40
- return fn(entries.map(function (entry) {
41
- return _objectSpread(_objectSpread({}, entry), {}, {
42
- intersectionRatio: 1
43
- });
44
- }));
45
- };
46
- }
47
- return _createClass(_class, [{
48
- key: "observe",
49
- value: function observe() {}
50
- }, {
51
- key: "unobserve",
52
- value: function unobserve() {}
53
- }, {
54
- key: "disconnect",
55
- value: function disconnect() {}
56
- }]);
57
- }();
58
- }
@@ -1,24 +0,0 @@
1
- type HandlerResult = {
2
- shouldIgnore: boolean;
3
- };
4
- export declare class EditorLnvHandler {
5
- private placeholders;
6
- private intersectionObserver;
7
- private getSizeCallbacks;
8
- private isAddedPlaceholderMatchingSizeCallbacks;
9
- private isAddedReplaceMatchingSizeCallbacks;
10
- constructor();
11
- shouldHandleAddedNode(el: HTMLElement): string | undefined;
12
- handleAddedNode(el: HTMLElement): Promise<HandlerResult>;
13
- clear(): void;
14
- private handleAddedPlaceholderNode;
15
- private handleAddedReplaceNode;
16
- private isExistingPlaceholder;
17
- private registerPlaceholder;
18
- private getSize;
19
- private isAddedPlaceholderMatchingSize;
20
- private isAddedReplaceMatchingSize;
21
- private areRectsSameSize;
22
- private intersectionObserverCallback;
23
- }
24
- export {};
@@ -1,35 +0,0 @@
1
- import type { EditorLnvHandler } from './index';
2
- type MockIntersectionObserverEntry = {
3
- target: HTMLElement;
4
- boundingClientRect: {
5
- x: number;
6
- y: number;
7
- width: number;
8
- height: number;
9
- };
10
- };
11
- export type MockIntersectionObserverCallback = (entries: MockIntersectionObserverEntry[]) => void;
12
- export type MockIntersectionObserverCallbackRef = {
13
- current: MockIntersectionObserverCallback | null;
14
- };
15
- export declare function createPlaceholderElement(id: string): HTMLDivElement;
16
- export declare function createReplaceElement(id: string): HTMLDivElement;
17
- export declare function handleElements(elements: {
18
- element: HTMLElement;
19
- rect: {
20
- x: number;
21
- y: number;
22
- width: number;
23
- height: number;
24
- };
25
- }[], handler: EditorLnvHandler, observerCallback: MockIntersectionObserverCallback, callback: (result: {
26
- shouldIgnore: boolean;
27
- }) => void): void;
28
- export declare function createMockIntersectionObserver(cbRef: MockIntersectionObserverCallbackRef): {
29
- new (fn: MockIntersectionObserverCallback): {
30
- observe(): void;
31
- unobserve(): void;
32
- disconnect(): void;
33
- };
34
- };
35
- export {};
@@ -1,24 +0,0 @@
1
- type HandlerResult = {
2
- shouldIgnore: boolean;
3
- };
4
- export declare class EditorLnvHandler {
5
- private placeholders;
6
- private intersectionObserver;
7
- private getSizeCallbacks;
8
- private isAddedPlaceholderMatchingSizeCallbacks;
9
- private isAddedReplaceMatchingSizeCallbacks;
10
- constructor();
11
- shouldHandleAddedNode(el: HTMLElement): string | undefined;
12
- handleAddedNode(el: HTMLElement): Promise<HandlerResult>;
13
- clear(): void;
14
- private handleAddedPlaceholderNode;
15
- private handleAddedReplaceNode;
16
- private isExistingPlaceholder;
17
- private registerPlaceholder;
18
- private getSize;
19
- private isAddedPlaceholderMatchingSize;
20
- private isAddedReplaceMatchingSize;
21
- private areRectsSameSize;
22
- private intersectionObserverCallback;
23
- }
24
- export {};
@@ -1,35 +0,0 @@
1
- import type { EditorLnvHandler } from './index';
2
- type MockIntersectionObserverEntry = {
3
- target: HTMLElement;
4
- boundingClientRect: {
5
- x: number;
6
- y: number;
7
- width: number;
8
- height: number;
9
- };
10
- };
11
- export type MockIntersectionObserverCallback = (entries: MockIntersectionObserverEntry[]) => void;
12
- export type MockIntersectionObserverCallbackRef = {
13
- current: MockIntersectionObserverCallback | null;
14
- };
15
- export declare function createPlaceholderElement(id: string): HTMLDivElement;
16
- export declare function createReplaceElement(id: string): HTMLDivElement;
17
- export declare function handleElements(elements: {
18
- element: HTMLElement;
19
- rect: {
20
- x: number;
21
- y: number;
22
- width: number;
23
- height: number;
24
- };
25
- }[], handler: EditorLnvHandler, observerCallback: MockIntersectionObserverCallback, callback: (result: {
26
- shouldIgnore: boolean;
27
- }) => void): void;
28
- export declare function createMockIntersectionObserver(cbRef: MockIntersectionObserverCallbackRef): {
29
- new (fn: MockIntersectionObserverCallback): {
30
- observe(): void;
31
- unobserve(): void;
32
- disconnect(): void;
33
- };
34
- };
35
- export {};