@arc-fusion/pb-editor-wrapper
Advanced tools
Comparing version 0.0.400 to 0.0.403
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -20,6 +20,12 @@ Object.defineProperty(exports, "__esModule", { | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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) { | ||
@@ -32,28 +38,48 @@ 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); // const nextElement = enterNode?.nextSibling | ||
// // LazyLoad and React.Suspense observers: check for no siblings or a placeholder node with no children | ||
// if (nextElement?.matches && nextElement.matches(`[data-fusion-component="${fingerprint}"]`) || | ||
// nextElement?.hasChildNodes && !nextElement.hasChildNodes() && nextElement?.nextSibling?.matches && nextElement.nextSibling.matches(`[data-fusion-component="${fingerprint}"]`)) { | ||
// observeBoundaries(enterNode) | ||
// } | ||
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) { | ||
// const parentNode = enterNode.parentNode | ||
// const config = { childList: true } | ||
// const observer = new MutationObserver(callback) | ||
// observer.observe(parentNode, config) | ||
// function callback(mutationsList) { | ||
// for (const mutation of mutationsList) { | ||
// if (mutation?.type === 'childList' && mutation?.addedNodes?.length) { | ||
// addMouseEventsToSiblings(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 = { | ||
@@ -60,0 +86,0 @@ generateHover: function generateHover(component) { |
{ | ||
"name": "@arc-fusion/pb-editor-wrapper", | ||
"description": "PageBuilder Preview Wrapper", | ||
"version": "0.0.400", | ||
"version": "0.0.403", | ||
"module": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "files": [ |
11390
157