@arc-fusion/pb-editor-wrapper
Advanced tools
Comparing version 0.0.405 to 0.0.406
@@ -12,8 +12,4 @@ "use strict"; | ||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _getSiblingNodes = require("./getSiblingNodes"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,60 +24,4 @@ | ||
plugins = _ref.plugins, | ||
isChain = _ref.isChain, | ||
children = _ref.children; | ||
var enterRef = (0, _react.useRef)(); | ||
(0, _react.useEffect)(function () { | ||
if (isChain) return; | ||
var enterNode = _reactDom.default === null || _reactDom.default === void 0 ? void 0 : _reactDom.default.findDOMNode(enterRef.current); | ||
addMouseEventsToSiblings(enterNode); | ||
return function () { | ||
removeMouseEventsFromSiblings(enterNode); | ||
}; | ||
}); | ||
var previewEvents = { | ||
generateHover: function generateHover(component) { | ||
return new CustomEvent('onFeatureHover', { | ||
detail: { | ||
fingerprint: fingerprint, | ||
component: component, | ||
plugins: plugins | ||
} | ||
}); | ||
}, | ||
generateHoverEnd: function generateHoverEnd(component) { | ||
return new CustomEvent('onFeatureHoverEnd', { | ||
detail: { | ||
fingerprint: fingerprint, | ||
component: component, | ||
plugins: plugins | ||
} | ||
}); | ||
} | ||
}; | ||
var onFeatureHover = function onFeatureHover(component) { | ||
window.dispatchEvent(previewEvents.generateHover(component)); | ||
}; | ||
var onFeatureHoverEnd = function onFeatureHoverEnd(component) { | ||
window.dispatchEvent(previewEvents.generateHoverEnd(component)); | ||
}; | ||
function addMouseEventsToSiblings(enterNode) { | ||
var siblingNodes = (0, _getSiblingNodes.getSiblingNodes)(fingerprint, enterNode); | ||
console.log('ADD EVENTS V2', siblingNodes); | ||
siblingNodes === null || siblingNodes === void 0 ? void 0 : siblingNodes.forEach(function (element) { | ||
element === null || element === void 0 ? void 0 : element.addEventListener('mouseenter', onFeatureHover); | ||
element === null || element === void 0 ? void 0 : element.addEventListener('mouseleave', onFeatureHoverEnd); | ||
}); | ||
} | ||
function removeMouseEventsFromSiblings(enterNode) { | ||
var siblingNodes = (0, _getSiblingNodes.getSiblingNodes)(fingerprint, enterNode); | ||
console.log('REMOVE EVENTS V2', siblingNodes); | ||
siblingNodes === null || siblingNodes === void 0 ? void 0 : siblingNodes.forEach(function (element) { | ||
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseenter', onFeatureHover); | ||
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseleave', onFeatureHoverEnd); | ||
}); | ||
} | ||
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("fusion-enter", { | ||
@@ -88,0 +28,0 @@ id: "fusion-enter-".concat(fingerprint), |
{ | ||
"name": "@arc-fusion/pb-editor-wrapper", | ||
"description": "PageBuilder Preview Wrapper", | ||
"version": "0.0.405", | ||
"version": "0.0.406", | ||
"module": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "files": [ |
5771
68