repl now accepts code in innerHTML + bump
This commit is contained in:
parent
9b58cf9890
commit
372e93e8f8
4 changed files with 36 additions and 12 deletions
2
packages/repl/examples/repl.html
Normal file
2
packages/repl/examples/repl.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<script src="https://unpkg.com/@strudel/repl@0.9.3"></script>
|
||||
<strudel-editor code='s("bd")'></strudel-editor>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@strudel/repl",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "Strudel REPL as a Web Component",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
|
|
|||
|
|
@ -59,13 +59,24 @@ class StrudelRepl extends HTMLElement {
|
|||
}
|
||||
}
|
||||
connectedCallback() {
|
||||
// setTimeout makes sure the dom is ready
|
||||
setTimeout(() => {
|
||||
const code = (this.innerHTML + '').replace('<!--', '').replace('-->', '').trim();
|
||||
if (code) {
|
||||
// use comment code in element body if present
|
||||
this.setAttribute('code', code);
|
||||
}
|
||||
});
|
||||
// use a separate container for the editor, to make sure the innerHTML stays as is
|
||||
const container = document.createElement('div');
|
||||
this.parentElement.insertBefore(container, this.nextSibling);
|
||||
const drawContext = getDrawContext();
|
||||
const drawTime = [-2, 2];
|
||||
this.editor = new StrudelMirror({
|
||||
defaultOutput: webaudioOutput,
|
||||
getTime: () => getAudioContext().currentTime,
|
||||
transpiler,
|
||||
root: this,
|
||||
root: container,
|
||||
initialCode: '// LOADING',
|
||||
pattern: silence,
|
||||
settings: this.settings,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue