Skip to content

Commit 368a687

Browse files
committed
test
1 parent ca53924 commit 368a687

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/lexical/src/state/LexicalAdapter.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
$getSelection,
2323
$createParagraphNode,
2424
$createTextNode,
25+
$getNodeByKey,
2526
} from 'lexical';
2627
import {
2728
$createHeadingNode,
@@ -41,6 +42,7 @@ import {
4142
editorStateToBlocks,
4243
parseMarkdownFormatting,
4344
} from '../tools/utils/blocks';
45+
import { INPUT_UUID_TO_OUTPUT_KEY } from '../plugins/JupyterInputOutputPlugin';
4446

4547
/**
4648
* Result of a document operation
@@ -589,14 +591,11 @@ export class LexicalAdapter {
589591
node.getKey() === blockId
590592
) {
591593
code = node.getTextContent();
592-
// Find corresponding output node (sibling)
593-
const parent = node.getParent();
594-
if (parent) {
595-
parent.getChildren().forEach((sibling: any) => {
596-
if (sibling.getType() === 'jupyter-output') {
597-
jupyterOutputNode = sibling;
598-
}
599-
});
594+
// Find corresponding output node using UUID map (prevents output mixing!)
595+
const inputUuid = node.getJupyterInputNodeUuid();
596+
const outputKey = INPUT_UUID_TO_OUTPUT_KEY.get(inputUuid);
597+
if (outputKey) {
598+
jupyterOutputNode = $getNodeByKey(outputKey);
600599
}
601600
return true; // Found it
602601
}

0 commit comments

Comments
 (0)