UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) 791 B
/** * 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{registerList as r,ListNode as e,ListItemNode as o,registerListStrictIndentTransform as t}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as n}from"lexical";import{useEffect as s}from"react";function l({hasStrictIndent:l=!1,shouldPreserveNumbering:m=!1}){const[c]=i();return s(()=>{if(!c.hasNodes([e,o]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[c]),s(()=>n(r(c,{restoreNumbering:m}),l?t(c):()=>{}),[c,l,m]),function(e){s(()=>r(e),[e])}(c),null}export{l as ListPlugin};