Skip to content

Commit

Permalink
Merge pull request #6 from jpraetorius/improvements
Browse files Browse the repository at this point in the history
initial render simpler but more stable
  • Loading branch information
simonharrer authored Jun 27, 2024
2 parents 7bc9a75 + a5c354a commit c18fc14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ editor.addEventListener('editor-content-changed', (e) => {
const document = e.detail.content;
previewPane.document = document;
});
// now that everything is wired up make the editor spit put the content for a first render
document.dispatchEvent(new CustomEvent('request-document'));
9 changes: 5 additions & 4 deletions src/ui/elements/editor-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export class EditorElement extends LitElement {
this.dispatchEvent(new CustomEvent('editor-content-changed', { detail: { content } }));
});

document.addEventListener('request-document', () => {
this.dispatchEvent(new CustomEvent('editor-content-changed', { detail: { content: editor.getValue() }}));
})

// set up to detect editor errors and emit them
monaco.editor.onDidChangeMarkers((resource) => {
const markers = monaco.editor.getModelMarkers({resource});
Expand All @@ -72,6 +68,11 @@ export class EditorElement extends LitElement {
editor.layout();
});
resizeObserver.observe(this.editor);

// do an initial dispatch of content
setTimeout(() => {
this.dispatchEvent(new CustomEvent('editor-content-changed', { detail: { content: editor.getValue() } }));
}, 200);
}
}
customElements.define("dce-editor", EditorElement);

0 comments on commit c18fc14

Please sign in to comment.