Files
klz-cables.com/.pnpm-store/v10/files/91/a5d5a509c15fa8a359005b005fdbde1e98b09a6e499a3fa0d7bc3bbd114004eafe0c1b7d517d05972a9f20267b3e513404e91334485d510dd9cc5fbaf764f1
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

82 lines
2.7 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 LexicalDecoratorBlockNode = require('@lexical/react/LexicalDecoratorBlockNode');
var useLexicalNodeSelection = require('@lexical/react/useLexicalNodeSelection');
var utils = require('@lexical/utils');
var lexical = require('lexical');
var react = require('react');
var jsxRuntime = require('react/jsx-runtime');
/**
* 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.
*
*/
function BlockWithAlignableContents({
children,
format,
nodeKey,
className
}) {
const [editor] = LexicalComposerContext.useLexicalComposerContext();
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
const ref = react.useRef(null);
react.useEffect(() => {
return utils.mergeRegister(editor.registerCommand(lexical.FORMAT_ELEMENT_COMMAND, formatType => {
if (isSelected) {
const selection = lexical.$getSelection();
if (lexical.$isNodeSelection(selection)) {
const node = lexical.$getNodeByKey(nodeKey);
if (LexicalDecoratorBlockNode.$isDecoratorBlockNode(node)) {
node.setFormat(formatType);
}
} else if (lexical.$isRangeSelection(selection)) {
const nodes = selection.getNodes();
for (const node of nodes) {
if (LexicalDecoratorBlockNode.$isDecoratorBlockNode(node)) {
node.setFormat(formatType);
} else {
const element = utils.$getNearestBlockElementAncestorOrThrow(node);
element.setFormat(formatType);
}
}
}
return true;
}
return false;
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.CLICK_COMMAND, event => {
if (event.target === ref.current) {
event.preventDefault();
if (!event.shiftKey) {
clearSelection();
}
setSelected(!isSelected);
return true;
}
return false;
}, lexical.COMMAND_PRIORITY_LOW));
}, [clearSelection, editor, isSelected, nodeKey, setSelected]);
return /*#__PURE__*/jsxRuntime.jsx("div", {
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
ref: ref,
style: {
textAlign: format ? format : undefined
},
children: children
});
}
exports.BlockWithAlignableContents = BlockWithAlignableContents;