8000 move check id out of constructor by fpliger · Pull Request #43 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

move check id out of constructor #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
11 changes: 8 additions & 3 deletions pyscriptjs/src/components/base.ts
8000
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export class BaseEvalElement extends HTMLElement {
this.shadow = this.attachShadow({ mode: 'open'});
this.wrapper = document.createElement('slot');
this.shadow.appendChild(this.wrapper);
if (!this.id)
this.id = this.constructor.name+"-"+guidGenerator()
}
}

addToOutput(s: string) {
this.outputElement.innerHTML += "<div>"+s+"</div>";
Expand All @@ -58,6 +56,11 @@ export class BaseEvalElement extends HTMLElement {

}

checkId(){
if (!this.id)
this.id = this.constructor.name+"-"+guidGenerator();
}

getSourceFromElement(): string{
return "";
}
Expand Down Expand Up @@ -165,6 +168,8 @@ export class BaseEvalElement extends HTMLElement {
} // end eval
}



function createWidget(name: string, code: string, klass: string){

class CustomWidget extends HTMLElement{
Expand Down
41 changes: 21 additions & 20 deletions pyscriptjs/src/components/pyrepl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,27 @@ export class PyRepl extends BaseEvalElement {


connectedCallback() {
this.code = this.innerHTML;
this.innerHTML = '';

let extensions = [
basicSetup,
languageConf.of(python()),
keymap.of([
...defaultKeymap,
{ key: "Ctrl-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
// EditorView.updateListener.of((v:ViewUpdate) => {
// if (v.docChanged) {
// console.log(v.changes);

// }
// })
];
this.checkId()
this.code = this.innerHTML;
this.innerHTML = '';

let extensions = [
basicSetup,
languageConf.of(python()),
keymap.of([
...defaultKeymap,
{ key: "Ctrl-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
// EditorView.updateListener.of((v:ViewUpdate) => {
// if (v.docChanged) {
// console.log(v.changes);

// }
// })
];

if (!this.hasAttribute('theme')) {
this.theme = this.getAttribute('theme');
Expand Down
1 change: 1 addition & 0 deletions pyscriptjs/src/components/pyscript.ts
5099
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class PyScript extends BaseEvalElement {
}

connectedCallback() {
this.checkId()
this.code = this.innerHTML;
this.innerHTML = '';
let startState = EditorState.create({
Expand Down
0