chore: fix freezing when pressing Enter after adding an inline link to a Super note [skip e2e]

This commit is contained in:
Aman Harwara
2024-01-31 23:33:56 +05:30
parent e1905fa121
commit 703a2898ac
3 changed files with 13 additions and 12 deletions

View File

@@ -1,11 +1,10 @@
import { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalEditor, NodeKey } from 'lexical'
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
import { DOMConversionMap, DOMExportOutput, DecoratorNode, LexicalEditor, NodeKey } from 'lexical'
import { $createBubbleNode, convertToBubbleElement } from './BubbleUtils'
import { BubbleComponent } from './BubbleComponent'
import { SerializedBubbleNode } from './SerializedBubbleNode'
import { ItemNodeInterface } from '../../ItemNodeInterface'
export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface {
export class BubbleNode extends DecoratorNode<JSX.Element> implements ItemNodeInterface {
__id: string
static getType(): string {
@@ -13,18 +12,16 @@ export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface
}
static clone(node: BubbleNode): BubbleNode {
return new BubbleNode(node.__id, node.__format, node.__key)
return new BubbleNode(node.__id, node.__key)
}
static importJSON(serializedNode: SerializedBubbleNode): BubbleNode {
const node = $createBubbleNode(serializedNode.itemUuid)
node.setFormat(serializedNode.format)
return node
}
exportJSON(): SerializedBubbleNode {
override exportJSON(): SerializedBubbleNode {
return {
...super.exportJSON(),
itemUuid: this.getId(),
version: 1,
type: 'snbubble',
@@ -57,8 +54,12 @@ export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface
return { element }
}
constructor(id: string, format?: ElementFormatType, key?: NodeKey) {
super(format, key)
updateDOM(): false {
return false
}
constructor(id: string, key?: NodeKey) {
super(key)
this.__id = id
}

View File

@@ -1,5 +1,4 @@
import { Spread } from 'lexical'
import { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
import { Spread, SerializedLexicalNode } from 'lexical'
export type SerializedBubbleNode = Spread<
{
@@ -7,5 +6,5 @@ export type SerializedBubbleNode = Spread<
version: 1
type: 'snbubble'
},
SerializedDecoratorBlockNode
SerializedLexicalNode
>

View File

@@ -30,6 +30,7 @@ export function handleEditorChange(
const stringifiedEditorState = JSON.stringify(editorState.toJSON())
onChange?.(stringifiedEditorState, previewText)
} catch (error) {
console.error(error)
window.alert(
`An invalid change was made inside the Super editor. Your change was not saved. Please report this error to the team: ${JSON.stringify(
error,