chore: fix issue with sibling lists not being merged correctly in Super [skip e2e]
This commit is contained in:
@@ -110,6 +110,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ariakit/react": "^0.3.9",
|
"@ariakit/react": "^0.3.9",
|
||||||
"@lexical/headless": "0.13.1",
|
"@lexical/headless": "0.13.1",
|
||||||
|
"@lexical/list": "0.13.1",
|
||||||
"@radix-ui/react-slot": "^1.0.1",
|
"@radix-ui/react-slot": "^1.0.1",
|
||||||
"@react-pdf/renderer": "^3.3.2",
|
"@react-pdf/renderer": "^3.3.2",
|
||||||
"comlink": "^4.4.1",
|
"comlink": "^4.4.1",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { SearchPlugin } from './Plugins/SearchPlugin/SearchPlugin'
|
|||||||
import AutoLinkPlugin from './Plugins/AutoLinkPlugin/AutoLinkPlugin'
|
import AutoLinkPlugin from './Plugins/AutoLinkPlugin/AutoLinkPlugin'
|
||||||
import DatetimePlugin from './Plugins/DateTimePlugin/DateTimePlugin'
|
import DatetimePlugin from './Plugins/DateTimePlugin/DateTimePlugin'
|
||||||
import PasswordPlugin from './Plugins/PasswordPlugin/PasswordPlugin'
|
import PasswordPlugin from './Plugins/PasswordPlugin/PasswordPlugin'
|
||||||
|
import { MergeSiblingListsPlugin } from './Plugins/MergeSiblingListsPlugin'
|
||||||
|
|
||||||
type BlocksEditorProps = {
|
type BlocksEditorProps = {
|
||||||
onChange?: (value: string, preview: string) => void
|
onChange?: (value: string, preview: string) => void
|
||||||
@@ -116,6 +117,7 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
{isMobile && <ToolbarPlugin />}
|
{isMobile && <ToolbarPlugin />}
|
||||||
<ListPlugin />
|
<ListPlugin />
|
||||||
|
<MergeSiblingListsPlugin />
|
||||||
<MarkdownShortcutPlugin transformers={MarkdownTransformers} />
|
<MarkdownShortcutPlugin transformers={MarkdownTransformers} />
|
||||||
<TablePlugin hasCellMerge />
|
<TablePlugin hasCellMerge />
|
||||||
<OnChangePlugin onChange={handleChange} ignoreSelectionChange={true} />
|
<OnChangePlugin onChange={handleChange} ignoreSelectionChange={true} />
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
@@ -7682,6 +7682,7 @@ __metadata:
|
|||||||
"@babel/preset-env": "*"
|
"@babel/preset-env": "*"
|
||||||
"@babel/preset-typescript": ^7.21.5
|
"@babel/preset-typescript": ^7.21.5
|
||||||
"@lexical/headless": 0.13.1
|
"@lexical/headless": 0.13.1
|
||||||
|
"@lexical/list": 0.13.1
|
||||||
"@lexical/react": 0.13.1
|
"@lexical/react": 0.13.1
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": ^0.5.10
|
"@pmmmwh/react-refresh-webpack-plugin": ^0.5.10
|
||||||
"@radix-ui/react-slot": ^1.0.1
|
"@radix-ui/react-slot": ^1.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user