Files
klz-cables.com/.pnpm-store/v10/files/53/50c43d56fabef724539b7b12d0c0c75a4c45241cf607cd117941c21f84e23c0f4d0d82a5d0f7f80e52ecf1f1a7528f2abb035b7f3d96e0996af184cd7ed516
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

62 lines
1.9 KiB
Plaintext

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
var utils = require('@lexical/utils');
var lexical = require('lexical');
var react = require('react');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
const capturedEvents = new Set(['mouseenter', 'mouseleave']);
function NodeEventPlugin({
nodeType,
eventType,
eventListener
}) {
const [editor] = LexicalComposerContext.useLexicalComposerContext();
const listenerRef = react.useRef(eventListener);
listenerRef.current = eventListener;
react.useEffect(() => {
const isCaptured = capturedEvents.has(eventType);
const onEvent = event => {
editor.update(() => {
const nearestNode = lexical.$getNearestNodeFromDOMNode(event.target);
if (nearestNode !== null) {
const targetNode = isCaptured ? nearestNode instanceof nodeType ? nearestNode : null : utils.$findMatchingParent(nearestNode, node => node instanceof nodeType);
if (targetNode !== null) {
listenerRef.current(event, editor, targetNode.getKey());
return;
}
}
});
};
return editor.registerRootListener((rootElement, prevRootElement) => {
if (rootElement) {
rootElement.addEventListener(eventType, onEvent, isCaptured);
}
if (prevRootElement) {
prevRootElement.removeEventListener(eventType, onEvent, isCaptured);
}
});
// We intentionally don't respect changes to eventType.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [editor, nodeType]);
return null;
}
exports.NodeEventPlugin = NodeEventPlugin;