File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,30 @@ export function notebookViewPostProcessor() {
6868 decoratorNode . appendChild ( contentsEl ) ;
6969
7070 containerNode . appendChild ( decoratorNode ) ;
71- cell . parentElement ?. insertBefore ( containerNode , cell ) ;
72- containerNode . appendChild ( cell ) ;
71+
72+ const prevSibling = cellEl . previousElementSibling ;
73+ if (
74+ prevSibling &&
75+ prevSibling . tagName === "DIV" &&
76+ prevSibling . classList . contains ( "cell-code" )
77+ ) {
78+ // If the previous sibling is a cell-code, that is the code cell
79+ // for this output and we should grab it too
80+ cell . parentElement ?. insertBefore ( containerNode , cell ) ;
81+
82+ // Grab the previous element too
83+ const wrapperDiv = doc . createElement ( "div" ) ;
84+ containerNode . appendChild ( wrapperDiv ) ;
85+
86+ // move the cells
87+ wrapperDiv . appendChild ( prevSibling . cloneNode ( true ) ) ;
88+ prevSibling . remove ( ) ;
89+
90+ wrapperDiv . appendChild ( cell ) ;
91+ } else {
92+ cell . parentElement ?. insertBefore ( containerNode , cell ) ;
93+ containerNode . appendChild ( cell ) ;
94+ }
7395 }
7496 }
7597
You can’t perform that action at this time.
0 commit comments