chore: update lexical and rebuild patches (#2864)

This commit is contained in:
Aman Harwara
2024-04-15 20:11:19 +05:30
committed by GitHub
parent eb90005939
commit 896d346c27
59 changed files with 400 additions and 1189 deletions

View File

@@ -35,7 +35,6 @@ import { SearchPlugin } from './Plugins/SearchPlugin/SearchPlugin'
import AutoLinkPlugin from './Plugins/AutoLinkPlugin/AutoLinkPlugin'
import DatetimePlugin from './Plugins/DateTimePlugin/DateTimePlugin'
import PasswordPlugin from './Plugins/PasswordPlugin/PasswordPlugin'
import { MergeSiblingListsPlugin } from './Plugins/MergeSiblingListsPlugin'
type BlocksEditorProps = {
onChange?: (value: string, preview: string) => void
@@ -117,7 +116,6 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
</div>
{isMobile && <ToolbarPlugin />}
<ListPlugin />
<MergeSiblingListsPlugin />
<MarkdownShortcutPlugin transformers={MarkdownTransformers} />
<TablePlugin hasCellMerge />
<OnChangePlugin onChange={handleChange} ignoreSelectionChange={true} />

View File

@@ -1,23 +0,0 @@
import { ListNode, $isListNode } from '@lexical/list'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { useEffect } from 'react'
function mergeListNodesTransform(node: ListNode) {
const nextSibling = node.getNextSibling()
if ($isListNode(nextSibling) && $isListNode(node) && nextSibling.getListType() === node.getListType()) {
node.append(...nextSibling.getChildren())
nextSibling.remove()
}
}
// https://github.com/facebook/lexical/issues/4618
export function MergeSiblingListsPlugin() {
const [editor] = useLexicalComposerContext()
useEffect(() => {
return editor.registerNodeTransform(ListNode, mergeListNodesTransform)
}, [editor])
return null
}