chore: fix freezing when pressing Enter after adding an inline link to a Super note [skip e2e]
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import { DOMConversionMap, DOMExportOutput, ElementFormatType, LexicalEditor, NodeKey } from 'lexical'
|
import { DOMConversionMap, DOMExportOutput, DecoratorNode, LexicalEditor, NodeKey } from 'lexical'
|
||||||
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
|
|
||||||
import { $createBubbleNode, convertToBubbleElement } from './BubbleUtils'
|
import { $createBubbleNode, convertToBubbleElement } from './BubbleUtils'
|
||||||
import { BubbleComponent } from './BubbleComponent'
|
import { BubbleComponent } from './BubbleComponent'
|
||||||
import { SerializedBubbleNode } from './SerializedBubbleNode'
|
import { SerializedBubbleNode } from './SerializedBubbleNode'
|
||||||
import { ItemNodeInterface } from '../../ItemNodeInterface'
|
import { ItemNodeInterface } from '../../ItemNodeInterface'
|
||||||
|
|
||||||
export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface {
|
export class BubbleNode extends DecoratorNode<JSX.Element> implements ItemNodeInterface {
|
||||||
__id: string
|
__id: string
|
||||||
|
|
||||||
static getType(): string {
|
static getType(): string {
|
||||||
@@ -13,18 +12,16 @@ export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
static clone(node: BubbleNode): BubbleNode {
|
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 {
|
static importJSON(serializedNode: SerializedBubbleNode): BubbleNode {
|
||||||
const node = $createBubbleNode(serializedNode.itemUuid)
|
const node = $createBubbleNode(serializedNode.itemUuid)
|
||||||
node.setFormat(serializedNode.format)
|
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
exportJSON(): SerializedBubbleNode {
|
override exportJSON(): SerializedBubbleNode {
|
||||||
return {
|
return {
|
||||||
...super.exportJSON(),
|
|
||||||
itemUuid: this.getId(),
|
itemUuid: this.getId(),
|
||||||
version: 1,
|
version: 1,
|
||||||
type: 'snbubble',
|
type: 'snbubble',
|
||||||
@@ -57,8 +54,12 @@ export class BubbleNode extends DecoratorBlockNode implements ItemNodeInterface
|
|||||||
return { element }
|
return { element }
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(id: string, format?: ElementFormatType, key?: NodeKey) {
|
updateDOM(): false {
|
||||||
super(format, key)
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(id: string, key?: NodeKey) {
|
||||||
|
super(key)
|
||||||
this.__id = id
|
this.__id = id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Spread } from 'lexical'
|
import { Spread, SerializedLexicalNode } from 'lexical'
|
||||||
import { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
|
|
||||||
|
|
||||||
export type SerializedBubbleNode = Spread<
|
export type SerializedBubbleNode = Spread<
|
||||||
{
|
{
|
||||||
@@ -7,5 +6,5 @@ export type SerializedBubbleNode = Spread<
|
|||||||
version: 1
|
version: 1
|
||||||
type: 'snbubble'
|
type: 'snbubble'
|
||||||
},
|
},
|
||||||
SerializedDecoratorBlockNode
|
SerializedLexicalNode
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export function handleEditorChange(
|
|||||||
const stringifiedEditorState = JSON.stringify(editorState.toJSON())
|
const stringifiedEditorState = JSON.stringify(editorState.toJSON())
|
||||||
onChange?.(stringifiedEditorState, previewText)
|
onChange?.(stringifiedEditorState, previewText)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
window.alert(
|
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(
|
`An invalid change was made inside the Super editor. Your change was not saved. Please report this error to the team: ${JSON.stringify(
|
||||||
error,
|
error,
|
||||||
|
|||||||
Reference in New Issue
Block a user