@arc-fusion/pb-editor-wrapper
Advanced tools
Comparing version 0.0.404 to 0.0.405
@@ -24,8 +24,2 @@ "use strict"; | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
var FeatureWrapper = function FeatureWrapper(_ref) { | ||
@@ -38,48 +32,9 @@ var fingerprint = _ref.fingerprint, | ||
(0, _react.useEffect)(function () { | ||
var _nextElement$nextSibl; | ||
if (isChain) return; | ||
var enterNode = _reactDom.default === null || _reactDom.default === void 0 ? void 0 : _reactDom.default.findDOMNode(enterRef.current); | ||
addMouseEventsToSiblings(enterNode); | ||
var nextElement = enterNode === null || enterNode === void 0 ? void 0 : enterNode.nextSibling; // LazyLoad and React.Suspense observers: check for no siblings or a placeholder node with no children | ||
if (nextElement !== null && nextElement !== void 0 && nextElement.matches && nextElement.matches("[data-fusion-component=\"".concat(fingerprint, "\"]")) || nextElement !== null && nextElement !== void 0 && nextElement.hasChildNodes && !nextElement.hasChildNodes() && nextElement !== null && nextElement !== void 0 && (_nextElement$nextSibl = nextElement.nextSibling) !== null && _nextElement$nextSibl !== void 0 && _nextElement$nextSibl.matches && nextElement.nextSibling.matches("[data-fusion-component=\"".concat(fingerprint, "\"]"))) { | ||
observeBoundaries(enterNode); | ||
} | ||
return function () { | ||
removeMouseEventsFromSiblings(enterNode); | ||
}; | ||
}, []); | ||
function observeBoundaries(enterNode) { | ||
var parentNode = enterNode.parentNode; | ||
var config = { | ||
childList: true | ||
}; | ||
var observer = new MutationObserver(callback); | ||
observer.observe(parentNode, config); | ||
function callback(mutationsList) { | ||
var _iterator = _createForOfIteratorHelper(mutationsList), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var _mutation$addedNodes; | ||
var mutation = _step.value; | ||
if ((mutation === null || mutation === void 0 ? void 0 : mutation.type) === 'childList' && mutation !== null && mutation !== void 0 && (_mutation$addedNodes = mutation.addedNodes) !== null && _mutation$addedNodes !== void 0 && _mutation$addedNodes.length) { | ||
addMouseEventsToSiblings(enterNode); | ||
} | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} | ||
} | ||
}); | ||
var previewEvents = { | ||
@@ -116,3 +71,3 @@ generateHover: function generateHover(component) { | ||
var siblingNodes = (0, _getSiblingNodes.getSiblingNodes)(fingerprint, enterNode); | ||
console.log('ADD EVENTS', siblingNodes); | ||
console.log('ADD EVENTS V2', siblingNodes); | ||
siblingNodes === null || siblingNodes === void 0 ? void 0 : siblingNodes.forEach(function (element) { | ||
@@ -126,3 +81,3 @@ element === null || element === void 0 ? void 0 : element.addEventListener('mouseenter', onFeatureHover); | ||
var siblingNodes = (0, _getSiblingNodes.getSiblingNodes)(fingerprint, enterNode); | ||
console.log('REMOVE EVENTS', siblingNodes); | ||
console.log('REMOVE EVENTS V2', siblingNodes); | ||
siblingNodes === null || siblingNodes === void 0 ? void 0 : siblingNodes.forEach(function (element) { | ||
@@ -129,0 +84,0 @@ element === null || element === void 0 ? void 0 : element.removeEventListener('mouseenter', onFeatureHover); |
{ | ||
"name": "@arc-fusion/pb-editor-wrapper", | ||
"description": "PageBuilder Preview Wrapper", | ||
"version": "0.0.404", | ||
"version": "0.0.405", | ||
"module": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "files": [ |
8118
121