Files
klz-cables.com/.pnpm-store/v10/files/a3/5cda5fb95af80dd4c4c98e4a1c083466212ea0676757ced5122251c7cbba4ee4883632c663ec9f80352845b606bcb5907721a1ee8405ca5526fc5aa7c46d20
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

10 lines
923 B
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.
*
*/
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$getSelection as t,$isNodeSelection as r,$createNodeSelection as o,$setSelection as n,$getNodeByKey as c}from"lexical";import{useState as a,useEffect as i,useCallback as l}from"react";function d(e,t){return e.getEditorState().read((()=>{const e=c(t);return null!==e&&e.isSelected()}))}function u(c){const[u]=e(),[p,s]=a((()=>d(u,c)));i((()=>{let e=!0;const t=u.registerUpdateListener((()=>{e&&s(d(u,c))}));return()=>{e=!1,t()}}),[u,c]);return[p,l((e=>{u.update((()=>{let a=t();r(a)||(a=o(),n(a)),r(a)&&(e?a.add(c):a.delete(c))}))}),[u,c]),l((()=>{u.update((()=>{const e=t();r(e)&&e.clear()}))}),[u])]}export{u as useLexicalNodeSelection};