@@ -101,7 +101,7 @@ export class PyRepl extends BaseEvalElement {
101
101
this . btnRun = document . createElement ( 'button' ) ;
102
102
this . btnRun . innerHTML =
103
103
'<svg id="" class="svelte-fa svelte-ps5qeg" style="height:20px;width:20px;vertical-align:-.125em;transform-origin:center;overflow:visible;color:green" viewBox="0 0 384 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(192 256)" transform-origin="96 0"><g transform="translate(0,0) scale(1,1)"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z" fill="currentColor" transform="translate(-192 -256)"></path></g></g></svg>' ;
104
- addClasses ( this . btnRun , [ 'absolute' , 'right-1' , 'bottom-3 ' , 'opacity-0' , 'group-hover:opacity-100' ] ) ;
104
+ addClasses ( this . btnRun , [ 'absolute' , 'right-1' , 'bottom-1 ' , 'opacity-0' , 'group-hover:opacity-100' ] ) ;
105
105
this . editorNode . appendChild ( this . btnRun ) ;
106
106
107
107
this . btnRun . onclick = wrap ( this ) ;
@@ -171,12 +171,16 @@ export class PyRepl extends BaseEvalElement {
171
171
this . outputElement . style . display = 'block' ;
172
172
173
173
if ( this . hasAttribute ( 'auto-generate' ) ) {
174
- const nextExecId = parseInt ( this . getAttribute ( 'exec-id' ) ) + 1 ;
175
- const newPyRepl = document . createElement ( 'py-repl' ) ;
174
+ const allPyRepls = document . querySelectorAll ( `py-repl[root='${ this . getAttribute ( 'root' ) } '][exec-id]` ) ;
175
+ const lastRepl = allPyRepls [ allPyRepls . length - 1 ] ;
176
+ const lastExecId = lastRepl . getAttribute ( 'exec-id' ) ;
177
+ const nextExecId = parseInt ( lastExecId ) + 1 ;
176
178
179
+ const newPyRepl = document . createElement ( 'py-repl' ) ;
177
180
newPyRepl . setAttribute ( 'root' , this . getAttribute ( 'root' ) ) ;
178
181
newPyRepl . id = this . getAttribute ( 'root' ) + '-' + nextExecId . toString ( ) ;
179
- newPyRepl . setAttribute ( 'auto-generate' , null ) ;
182
+ newPyRepl . setAttribute ( 'auto-generate' , '' ) ;
183
+ this . removeAttribute ( 'auto-generate' ) ;
180
184
181
185
if ( this . hasAttribute ( 'output' ) ) {
182
186
newPyRepl . setAttribute ( 'output' , this . getAttribute ( 'output' ) ) ;
0 commit comments