File tree Expand file tree Collapse file tree 3 files changed +30
-23
lines changed
pyscriptjs/src/components Expand file tree Collapse file tree 3 files changed +30
-23
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,7 @@ export class BaseEvalElement extends HTMLElement {
45
45
this . shadow = this . attachShadow ( { mode : 'open' } ) ;
46
46
this . wrapper = document . createElement ( 'slot' ) ;
47
47
this . shadow . appendChild ( this . wrapper ) ;
48
- if ( ! this . id )
49
- this . id = this . constructor . name + "-" + guidGenerator ( )
50
- }
48
+ }
51
49
52
50
addToOutput ( s : string ) {
53
51
this . outputElement . innerHTML += "<div>" + s + "</div>" ;
@@ -58,6 +56,11 @@ export class BaseEvalElement extends HTMLElement {
58
56
59
57
}
60
58
59
+ checkId ( ) {
60
+ if ( ! this . id )
61
+ this . id = this . constructor . name + "-" + guidGenerator ( ) ;
62
+ }
63
+
61
64
getSourceFromElement ( ) : string {
62
65
return "" ;
63
66
}
@@ -165,6 +168,8 @@ export class BaseEvalElement extends HTMLElement {
165
168
} // end eval
166
169
}
167
170
171
+
172
+
168
173
function createWidget ( name : string , code : string , klass : string ) {
169
174
170
175
class CustomWidget extends HTMLElement {
Original file line number Diff line number Diff line change @@ -59,26 +59,27 @@ export class PyRepl extends BaseEvalElement {
59
59
60
60
61
61
connectedCallback ( ) {
62
- this . code = this . innerHTML ;
63
- this . innerHTML = '' ;
64
-
65
- let extensions = [
66
- basicSetup ,
67
- languageConf . of ( python ( ) ) ,
68
- keymap . of ( [
69
- ...defaultKeymap ,
70
- { key : "Ctrl-Enter" , run : createCmdHandler ( this ) } ,
71
- { key : "Shift-Enter" , run : createCmdHandler ( this ) }
72
- ] ) ,
73
-
74
- // Event listener function that is called every time an user types something on this editor
75
- // EditorView.updateListener.of((v:ViewUpdate) => {
76
- // if (v.docChanged) {
77
- // console.log(v.changes);
78
-
79
- // }
80
- // })
81
- ] ;
62
+ this . checkId ( )
63
+ this . code = this . innerHTML ;
64
+ this . innerHTML = '' ;
65
+
66
+ let extensions = [
67
+ basicSetup ,
68
+ languageConf . of ( python ( ) ) ,
69
+ keymap . of ( [
70
+ ...defaultKeymap ,
71
+ { key : "Ctrl-Enter" , run : createCmdHandler ( this ) } ,
72
+ { key : "Shift-Enter" , run : createCmdHandler ( this ) }
73
+ ] ) ,
74
+
75
+ // Event listener function that is called every time an user types something on this editor
76
+ // EditorView.updateListener.of((v:ViewUpdate) => {
77
+ // if (v.docChanged) {
78
+ // console.log(v.changes);
79
+
80
+ // }
81
+ // })
82
+ ] ;
82
83
83
84
if ( ! this . hasAttribute ( 'theme' ) ) {
84
85
this . theme = this . getAttribute ( 'theme' ) ;
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ export class PyScript extends BaseEvalElement {
98
98
}
99
99
100
100
connectedCallback ( ) {
101
+ this . checkId ( )
101
102
this . code = this . innerHTML ;
102
103
this . innerHTML = '' ;
103
104
let startState = EditorState . create ( {
You can’t perform that action at this time.
0 commit comments