iframe.js 599 B

12345678910111213141516171819202122
  1. const init = () => {
  2. loadEditor(function () {
  3. // create the editor
  4. const target = document.getElementById('container');
  5. const editor = monaco.editor.create(target, { language: 'html' });
  6. // load some sample data
  7. (async () => {
  8. const response = await fetch('https://microsoft.github.io/monaco-editor/');
  9. const html = await response.text();
  10. editor.getModel().setValue(html);
  11. })();
  12. });
  13. };
  14. window.addEventListener('DOMContentLoaded', () => {
  15. if (!window.innerWidth || !window.innerHeight) {
  16. window.addEventListener('resize', init, { once: true });
  17. } else {
  18. init();
  19. }
  20. });