Skip to content

Commit

Permalink
fix: aa
Browse files Browse the repository at this point in the history
  • Loading branch information
sashuk committed Jun 27, 2023
1 parent 4ba80f9 commit 73c23c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/picasso/src/LexicalEditor/LexicalEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ const LexicalEditor = forwardRef<HTMLDivElement, Props>(function LexicalEditor(
ListItemNode,
HeadingNode,
PicassoTextNode,
{
replace: TextNode,
with: (node: TextNode) => {
console.log('@@@ aaa')

return new PicassoTextNode(node.getTextContent(), node.getKey())
},
},
// {
// replace: TextNode,
// with: (node: TextNode) => {
// console.log('@@@ aaa')

// return new PicassoTextNode(node.getTextContent(), node.getKey())
// },
// },
],
editable: !disabled,
}),
Expand Down
3 changes: 1 addition & 2 deletions packages/picasso/src/LexicalEditor/nodes/TestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ export class PicassoTextNode extends TextNode {
}

exportDOM(editor: LexicalEditor): DOMExportOutput {
throw new Error('aaa')
const { element } = super.exportDOM(editor)

console.log('@@@ element', element)
console.log('@@@ element', element, this.getFormat())

return { element }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { HeadingNode } from '@lexical/rich-text'
import { useEffect } from 'react'

import { replaceHeadingNodes } from './utils'
import { TextNode } from 'lexical'
import { PicassoTextNode } from '../LexicalEditor/nodes/TestNode'

const LexicalHeadingsReplacementPlugin = () => {
const [editor] = useLexicalComposerContext()
Expand All @@ -11,6 +13,13 @@ const LexicalHeadingsReplacementPlugin = () => {
return editor.registerNodeTransform(HeadingNode, replaceHeadingNodes)
}, [editor])

useEffect(() => {
return editor.registerNodeTransform(TextNode, (node: TextNode) => {
console.log('@@@ replacing')
node.replace(new PicassoTextNode(node.getTextContent()))
})
}, [editor])

return null
}

Expand Down

0 comments on commit 73c23c5

Please sign in to comment.