mirror of
https://github.com/pyscript/pyscript.git
synced 2022-05-01 19:47:48 +03:00
move check id out of constructor
This commit is contained in:
@@ -45,9 +45,7 @@ export class BaseEvalElement extends HTMLElement {
|
|||||||
this.shadow = this.attachShadow({ mode: 'open'});
|
this.shadow = this.attachShadow({ mode: 'open'});
|
||||||
this.wrapper = document.createElement('slot');
|
this.wrapper = document.createElement('slot');
|
||||||
this.shadow.appendChild(this.wrapper);
|
this.shadow.appendChild(this.wrapper);
|
||||||
if (!this.id)
|
}
|
||||||
this.id = this.constructor.name+"-"+guidGenerator()
|
|
||||||
}
|
|
||||||
|
|
||||||
addToOutput(s: string) {
|
addToOutput(s: string) {
|
||||||
this.outputElement.innerHTML += "<div>"+s+"</div>";
|
this.outputElement.innerHTML += "<div>"+s+"</div>";
|
||||||
@@ -58,6 +56,11 @@ export class BaseEvalElement extends HTMLElement {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkId(){
|
||||||
|
if (!this.id)
|
||||||
|
this.id = this.constructor.name+"-"+guidGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
getSourceFromElement(): string{
|
getSourceFromElement(): string{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -165,6 +168,8 @@ export class BaseEvalElement extends HTMLElement {
|
|||||||
} // end eval
|
} // end eval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createWidget(name: string, code: string, klass: string){
|
function createWidget(name: string, code: string, klass: string){
|
||||||
|
|
||||||
class CustomWidget extends HTMLElement{
|
class CustomWidget extends HTMLElement{
|
||||||
|
|||||||
@@ -59,26 +59,27 @@ export class PyRepl extends BaseEvalElement {
|
|||||||
|
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
this.code = this.innerHTML;
|
this.checkId()
|
||||||
this.innerHTML = '';
|
this.code = this.innerHTML;
|
||||||
|
this.innerHTML = '';
|
||||||
|
|
||||||
let extensions = [
|
let extensions = [
|
||||||
basicSetup,
|
basicSetup,
|
||||||
languageConf.of(python()),
|
languageConf.of(python()),
|
||||||
keymap.of([
|
keymap.of([
|
||||||
...defaultKeymap,
|
...defaultKeymap,
|
||||||
{ key: "Ctrl-Enter", run: createCmdHandler(this) },
|
{ key: "Ctrl-Enter", run: createCmdHandler(this) },
|
||||||
{ key: "Shift-Enter", run: createCmdHandler(this) }
|
{ key: "Shift-Enter", run: createCmdHandler(this) }
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// Event listener function that is called every time an user types something on this editor
|
// Event listener function that is called every time an user types something on this editor
|
||||||
// EditorView.updateListener.of((v:ViewUpdate) => {
|
// EditorView.updateListener.of((v:ViewUpdate) => {
|
||||||
// if (v.docChanged) {
|
// if (v.docChanged) {
|
||||||
// console.log(v.changes);
|
// console.log(v.changes);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!this.hasAttribute('theme')) {
|
if (!this.hasAttribute('theme')) {
|
||||||
this.theme = this.getAttribute('theme');
|
this.theme = this.getAttribute('theme');
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ export class PyScript extends BaseEvalElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
this.checkId()
|
||||||
this.code = this.innerHTML;
|
this.code = this.innerHTML;
|
||||||
this.innerHTML = '';
|
this.innerHTML = '';
|
||||||
let startState = EditorState.create({
|
let startState = EditorState.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user