Skip to content

Commit cb8b2c2

Browse files
committed
fix(textarea): persist shorthand between undo/redo
1 parent b08c46c commit cb8b2c2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

webview-ui/src/components/chat/lexical/MentionNode.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ function convertMentionElement(domNode: HTMLElement): DOMConversionOutput | null
2626
const textContent = domNode.textContent
2727
const trigger = domNode.getAttribute("data-lexical-mention-trigger")
2828
const value = domNode.getAttribute("data-lexical-mention-value")
29+
const label = domNode.getAttribute("data-lexical-mention-label")
2930

3031
if (textContent !== null && trigger !== null && value !== null) {
3132
return {
32-
node: $createMentionNode(trigger, value, null),
33+
node: $createMentionNode(trigger, value, label, textContent),
3334
}
3435
}
3536

@@ -87,18 +88,24 @@ export class MentionNode extends TextNode {
8788
data?: Record<string, any>,
8889
key?: NodeKey,
8990
) {
90-
super(text ?? `${trigger}${label}`, key)
91+
super(text ?? "", key)
92+
9193
this.__trigger = trigger
9294
this.__value = value
9395
this.__label = label
9496
this.__data = data
97+
98+
// Set the formatted text if not explicitly provided
99+
if (!text) {
100+
this.__text = this.getFormattedDisplayText()
101+
}
95102
}
96103

97104
exportJSON(): SerializedMentionNode {
98105
return {
99106
...super.exportJSON(),
100107
value: this.__value,
101-
label: this.getFormattedDisplayText(),
108+
label: this.__label,
102109
trigger: this.__trigger,
103110
data: this.__data,
104111
type: "mention",

0 commit comments

Comments
 (0)