File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
packages/lexical/src/state Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222 $getSelection ,
2323 $createParagraphNode ,
2424 $createTextNode ,
25+ $getNodeByKey ,
2526} from 'lexical' ;
2627import {
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 }
You can’t perform that action at this time.
0 commit comments